Skip to content

Commit

Permalink
version 0.2.9.6 - better quantization
Browse files Browse the repository at this point in the history
  • Loading branch information
rcanut committed Jan 18, 2023
1 parent 23eadd2 commit a2fbaaa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
51 changes: 47 additions & 4 deletions encoder/image_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
****************************************************************************
* NHW Image Codec *
* file: image_processing.c *
* version: 0.2.9.5 *
* last update: $ 01112023 nhw exp $ *
* version: 0.2.9.6 *
* last update: $ 01182023 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand Down Expand Up @@ -184,7 +184,7 @@ L_OVER4N: a = -a;

void offsetY(image_buffer *im,encode_state *enc, int m1)
{
int i,j,wavelet_order,exw,a,r,scan,t1=0,quant=0;
int i,j,wavelet_order,exw,a,r,scan,t1=0,quant=0,quant2,quant3,quant4=0;
short *nhw_process;

nhw_process=(short*)im->im_process;
Expand Down Expand Up @@ -398,7 +398,50 @@ void offsetY(image_buffer *im,encode_state *enc, int m1)
{
if ((i&511)<(2*IM_DIM-1) && nhw_process[i+1]==7) nhw_process[i+1]=9;
}


if (a>=14 && nhw_process[i+1]>=14 && im->setup->quality_setting<=LOW4)
{
if (i>=(2*IM_SIZE) || (i&511)>=IM_DIM)
{
quant2 = (a&510);
quant3 = (nhw_process[i+1]&510);

if(((quant2)&7)==6 && ((quant3)&7)==6 && ((a&1)==1 || (nhw_process[i+1]&1)==1))
{
if (!quant4)
{
if ((a&504)==(nhw_process[i+1]&504))
{
if (a>=nhw_process[i+1])
{
a+=2;nhw_process[i+1]-=2;
}
else nhw_process[i+1]+=2;
}
else if (a<=nhw_process[i+1])
{
a+=2;nhw_process[i+1]-=2;
}
else nhw_process[i+1]+=2;

quant4=1;
}
else if (quant4==1)
{
quant4=2;
}
else if (quant4==2)
{
quant4=0;
}
/*else if (quant4==3)
{
quant4=0;
}*/
}
}
}

if (a<m1 && a>-m1)
{
nhw_process[i]=128;continue;
Expand Down
6 changes: 3 additions & 3 deletions encoder/nhw_encoder_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
****************************************************************************
* NHW Image Codec *
* file: nhw_encoder_cli.c *
* version: 0.2.9.5 *
* last update: $ 01112023 nhw exp $ *
* version: 0.2.9.6 *
* last update: $ 01182023 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand Down Expand Up @@ -50,7 +50,7 @@
#include "codec.h"

#define PROGRAM "nhw-enc"
#define VERSION "0.2.9.5"
#define VERSION "0.2.9.6"

#define NHW_QUALITY_MIN LOW20
#define NHW_QUALITY_MAX HIGH3
Expand Down

0 comments on commit a2fbaaa

Please sign in to comment.