Skip to content

Commit

Permalink
new -l14 very high compression quality setting & precision improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
rcanut committed Dec 12, 2018
1 parent 0f7f6d8 commit 3f96e62
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
9 changes: 5 additions & 4 deletions decoder/nhw_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ void main(int argc, char **argv)
else if (im.setup->quality_setting==LOW7) Y_inv=1.186945;
else if (im.setup->quality_setting==LOW8) Y_inv=1.186945;
else if (im.setup->quality_setting==LOW9) Y_inv=1.200205;
else if (im.setup->quality_setting==LOW10) Y_inv=1.32396;
else if (im.setup->quality_setting==LOW11) Y_inv=1.440352;
else if (im.setup->quality_setting==LOW12) Y_inv=1.579181;
else if (im.setup->quality_setting==LOW13) Y_inv=1.671837;
else if (im.setup->quality_setting==LOW10) Y_inv=1.292623;
else if (im.setup->quality_setting==LOW11) Y_inv=1.405146;
else if (im.setup->quality_setting==LOW12) Y_inv=1.536961;
else if (im.setup->quality_setting==LOW13) Y_inv=1.624591;
else if (im.setup->quality_setting==LOW14) Y_inv=1.715602;

for (m=0;m<4;m++)
{
Expand Down
9 changes: 5 additions & 4 deletions encoder/colorspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ void downsample_YUV420(image_buffer *im,encode_state *enc,int rate)
else if (im->setup->quality_setting==LOW7) Qtz=27607;
else if (im->setup->quality_setting==LOW8) Qtz=27607;
else if (im->setup->quality_setting==LOW9) Qtz=27302;
else if (im->setup->quality_setting==LOW10) Qtz=24750;
else if (im->setup->quality_setting==LOW11) Qtz=22750;
else if (im->setup->quality_setting==LOW12) Qtz=20750;
else if (im->setup->quality_setting==LOW13) Qtz=19600;
else if (im->setup->quality_setting==LOW10) Qtz=25350;
else if (im->setup->quality_setting==LOW11) Qtz=23320;
else if (im->setup->quality_setting==LOW12) Qtz=21320;
else if (im->setup->quality_setting==LOW13) Qtz=20170;
else if (im->setup->quality_setting==LOW14) Qtz=19100;

for (i=0,j=0;i<12*IM_SIZE;i+=3,j++)
{
Expand Down
13 changes: 7 additions & 6 deletions encoder/image_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,16 @@ void pre_processing(image_buffer *im)
else if (im->setup->quality_setting==LOW7) sharpness=67;
else if (im->setup->quality_setting==LOW8) sharpness=64;
else if (im->setup->quality_setting==LOW9) sharpness=58;
else if (im->setup->quality_setting==LOW10) sharpness=46;
else if (im->setup->quality_setting==LOW11) sharpness=30;
else if (im->setup->quality_setting==LOW12) sharpness=7;
else if (im->setup->quality_setting==LOW10) sharpness=40;
else if (im->setup->quality_setting==LOW11) sharpness=24;
else if (im->setup->quality_setting==LOW12) sharpness=3;
else if (im->setup->quality_setting<LOW12) sharpness=0;

if (im->setup->quality_setting>LOW11) n1=36;
else if (im->setup->quality_setting==LOW11) n1=28;
else if (im->setup->quality_setting==LOW12) n1=14;
else if (im->setup->quality_setting==LOW13) n1=10;
else if (im->setup->quality_setting==LOW11) n1=24;
else if (im->setup->quality_setting==LOW12) n1=10;
else if (im->setup->quality_setting==LOW13) n1=6;
else if (im->setup->quality_setting==LOW14) n1=5;

for (i=(2*IM_DIM);i<((4*IM_SIZE)-(2*IM_DIM));i+=(2*IM_DIM))
{
Expand Down
30 changes: 24 additions & 6 deletions encoder/nhw_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* NHW Image Codec *
* file: nhw_encoder.c *
* version: 0.1.5 *
* last update: $ 12102018 nhw exp $ *
* last update: $ 12122018 nhw exp $ *
* *
****************************************************************************
****************************************************************************
Expand Down Expand Up @@ -92,6 +92,7 @@ void main(int argc, char **argv)
else if (strcmp(arg,"-l11")==0) im.setup->quality_setting=LOW11;
else if (strcmp(arg,"-l12")==0) im.setup->quality_setting=LOW12;
else if (strcmp(arg,"-l13")==0) im.setup->quality_setting=LOW13;
else if (strcmp(arg,"-l14")==0) im.setup->quality_setting=LOW14;
*argv--;*argv--;*argv--;

select=8; //for now...
Expand Down Expand Up @@ -143,7 +144,10 @@ void encode_image(image_buffer *im,encode_state *enc, int ratio)
im->setup->RES_HIGH=0;

wavelet_analysis(im,(2*IM_DIM)>>1,end_transform,1);


if (im->setup->quality_setting>LOW14)
{

for (i=0,count=0;i<(4*IM_SIZE>>1);i+=(2*IM_DIM),count+=IM_DIM)
{
for (scan=i,j=0;j<IM_DIM;j++,scan++)
Expand Down Expand Up @@ -283,9 +287,11 @@ void encode_image(image_buffer *im,encode_state *enc, int ratio)

wavelet_analysis(im,(2*IM_DIM)>>1,end_transform,1);

}

if (im->setup->quality_setting<=LOW9)
{
wvlt_thrx1=10;
if (im->setup->quality_setting>LOW14) wvlt_thrx1=10;else wvlt_thrx1=11;

for (i=IM_SIZE;i<(2*IM_SIZE);i+=(2*IM_DIM))
{
Expand Down Expand Up @@ -340,6 +346,16 @@ void encode_image(image_buffer *im,encode_state *enc, int ratio)
wvlt_thrx6=17;
wvlt_thrx7=17;
}
else if (im->setup->quality_setting==LOW14)
{
wvlt_thrx1=12;
wvlt_thrx2=16;
wvlt_thrx3=10;
wvlt_thrx4=15;
wvlt_thrx5=36;
wvlt_thrx6=17;
wvlt_thrx7=17;
}

for (i=0,scan=0;i<(IM_SIZE);i+=(2*IM_DIM))
{
Expand Down Expand Up @@ -894,17 +910,19 @@ void encode_image(image_buffer *im,encode_state *enc, int ratio)
{
if (nhw_process[scan]>=16) nhw_process[scan]=7;
else if (nhw_process[scan]<=-16) nhw_process[scan]=-7;
else nhw_process[scan]=0;
else nhw_process[scan]=0;
}
else nhw_process[scan]=0;
}
else if (abs(nhw_process[scan])<(wvlt_thrx2-5))
{
if (im->setup->quality_setting>LOW10)
{
if (nhw_process[scan]>=16) nhw_process[scan]=7;
else if (nhw_process[scan]<=-16) nhw_process[scan]=-7;
else nhw_process[scan]=0;
else if (nhw_process[scan]<=-16) nhw_process[scan]=-7;
else nhw_process[scan]=0;
}
else nhw_process[scan]=0;
}
}
}
Expand Down

0 comments on commit 3f96e62

Please sign in to comment.