rcanut / nhwcodec

NHW : A Next-Generation Image Compression Codec
Other
68 stars 9 forks source link

Lots of compiler warnings #14

Open eblanca opened 2 months ago

eblanca commented 2 months ago

Just building the tools under mingw64:

$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Now when compiling the decoder I have:

$ gcc -O3 -Wall -Wextra *.c -o nhw_dec.exe
compress_pixel.c: In function 'retrieve_pixel_UV_comp':
compress_pixel.c:446:43: warning: unused parameter 'im' [-Wunused-parameter]
  446 | void retrieve_pixel_UV_comp(image_buffer *im,decode_state *os,int p1,unsigned int *d1,short *im3)
      |                             ~~~~~~~~~~~~~~^~
compress_pixel.c: In function 'retrieve_pixel_Y_comp':
compress_pixel.c:108:35: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-la
rger-than=]
  108 |         os->book=(unsigned short*)calloc(e,sizeof(short));
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~
In file included from compress_pixel.c:43:
C:/msys64/mingw64/include/stdlib.h:536:17: note: in a call to allocation function 'calloc' declared here
  536 |   void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements);
      |                 ^~~~~~
filters.c: In function 'upfilter53':
filters.c:68:33: warning: unused variable 'r' [-Wunused-variable]
   68 |         short *E=_X,*_E1_=E+M-2,r,m=0,a;
      |                                 ^
filters.c: In function 'upfilter53III':
filters.c:158:33: warning: unused variable 'r' [-Wunused-variable]
  158 |         short *E=_X,*_E2_=E+M-2,r;
      |                                 ^
filters.c: In function 'upfilter53VI':
filters.c:176:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  176 |         if (_RES[0]>0) _RES[0]+=32;_RES[0]>>=6;
      |         ^~
filters.c:176:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  176 |         if (_RES[0]>0) _RES[0]+=32;_RES[0]>>=6;
      |                                    ^~~~
filters.c:177:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  177 |         if (_RES[1]>0) _RES[1]+=32;_RES[1]>>=6;
      |         ^~
filters.c:177:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  177 |         if (_RES[1]>0) _RES[1]+=32;_RES[1]>>=6;
      |                                    ^~~~
filters.c:173:33: warning: unused variable 'r' [-Wunused-variable]
  173 |         short *E=_X,*_E2_=E+M-2,r;
      |                                 ^
nhw_decoder.c: In function 'decode_image':
nhw_decoder.c:297:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  297 |         for (i=1;i<os->nhw_res6_len;i++)
      |                   ^
nhw_decoder.c:318:58: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  318 |                                 if (((os->nhw_res6[i]<<1)<(nhwresH3I[stage-1]&255)) && (os->nhw_res6[i-1]!=127)) count+=IM_DIM;
      |                                                          ^
nhw_decoder.c:62:81: warning: unused variable 'nhwres4I' [-Wunused-variable]
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                                                                                 ^~~~~~~~
nhw_decoder.c:58:15: warning: unused variable 'res256' [-Wunused-variable]
   58 |         char *res256;
      |               ^~~~~~
nhw_decoder.c:56:71: warning: unused variable 'res_decompr' [-Wunused-variable]
   56 |         int nhw,stage,wavelet_order,end_transform,i,j,e=0,count,scan,*res_decompr,exw1,res,nhw_selectII;
      |                                                                       ^~~~~~~~~~~
nhw_decoder.c:56:23: warning: variable 'wavelet_order' set but not used [-Wunused-but-set-variable]
   56 |         int nhw,stage,wavelet_order,end_transform,i,j,e=0,count,scan,*res_decompr,exw1,res,nhw_selectII;
      |                       ^~~~~~~~~~~~~
nhw_decoder.c: In function 'parse_file':
nhw_decoder.c:1482:26: warning: variable 'mem' set but not used [-Wunused-but-set-variable]
 1482 |         int i,j,ch,e,a=0,mem,run,nhw;
      |                          ^~~
nhw_decoder.c: In function 'decode_image':
nhw_decoder.c:761:42: warning: 'nhwres3' may be used uninitialized [-Wmaybe-uninitialized]
  761 |                         im_nhw2[((nhwres3[i]&65280)<<1)+(nhwres3[i]&255)]-=4;
      |                                   ~~~~~~~^~~
nhw_decoder.c:62:63: note: 'nhwres3' was declared here
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                                                               ^~~~~~~
nhw_decoder.c:768:42: warning: 'nhwres4' may be used uninitialized [-Wmaybe-uninitialized]
  768 |                         im_nhw2[((nhwres4[i]&65280)<<1)+(nhwres4[i]&255)]+=4;
      |                                   ~~~~~~~^~~
nhw_decoder.c:62:72: note: 'nhwres4' was declared here
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                                                                        ^~~~~~~
nhw_decoder.c:775:42: warning: 'nhwres5' may be used uninitialized [-Wmaybe-uninitialized]
  775 |                         im_nhw2[((nhwres5[i]&65280)<<1)+(nhwres5[i]&255)]+=2;
      |                                   ~~~~~~~^~~
nhw_decoder.c:62:91: note: 'nhwres5' was declared here
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                                                                                           ^~~~~~~
nhw_decoder.c:783:42: warning: 'nhwres6' may be used uninitialized [-Wmaybe-uninitialized]
  783 |                         im_nhw2[((nhwres6[i]&65280)<<1)+(nhwres6[i]&255)]-=2;
      |                                   ~~~~~~~^~~
nhw_decoder.c:62:100: note: 'nhwres6' was declared here
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                                                                                                    ^~~~~~~
nhw_decoder.c:726:43: warning: 'nhwresH1' may be used uninitialized [-Wmaybe-uninitialized]
  726 |                         im_nhw2[((nhwresH1[i]&65280)<<1)+(nhwresH1[i]&255)]-=3;
      |                                   ~~~~~~~~^~~
nhw_decoder.c:60:25: note: 'nhwresH1' was declared here
   60 |         unsigned short *nhwresH1,*nhwresH2,*nhwresH1I;
      |                         ^~~~~~~~
nhw_decoder.c:751:42: warning: 'nhwres2' may be used uninitialized [-Wmaybe-uninitialized]
  751 |                         im_nhw2[((nhwres2[i]&65280)<<1)+(nhwres2[i]&255)]+=e;
      |                                   ~~~~~~~^~~
nhw_decoder.c:62:34: note: 'nhwres2' was declared here
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                                  ^~~~~~~
nhw_decoder.c:745:42: warning: 'nhwres1' may be used uninitialized [-Wmaybe-uninitialized]
  745 |                         im_nhw2[((nhwres1[i]&65280)<<1)+(nhwres1[i]&255)]-=e;
      |                                   ~~~~~~~^~~
nhw_decoder.c:62:25: note: 'nhwres1' was declared here
   62 |         unsigned short *nhwres1,*nhwres2,*nhwres1I,*nhwres3I,*nhwres3,*nhwres4,*nhwres4I,*nhwres5,*nhwres6;
      |                         ^~~~~~~
nhw_decoder.c:732:43: warning: 'nhwresH2' may be used uninitialized [-Wmaybe-uninitialized]
  732 |                         im_nhw2[((nhwresH2[i]&65280)<<1)+(nhwresH2[i]&255)]+=3;
      |                                   ~~~~~~~~^~~
nhw_decoder.c:60:35: note: 'nhwresH2' was declared here
   60 |         unsigned short *nhwresH1,*nhwresH2,*nhwresH1I;
      |                                   ^~~~~~~~
nhw_decoder_cli.c: In function 'write_image_bmp':
nhw_decoder_cli.c:111:27: warning: unused variable 'len' [-Wunused-variable]
  111 |         int i,Y,U,V,R,G,B,len,m,t;
      |                           ^~~
nhw_decoder_cli.c:108:35: warning: unused parameter 'dec' [-Wunused-parameter]
  108 | int write_image_bmp(decode_state *dec, image_buffer *im, char *file_name)
      |                     ~~~~~~~~~~~~~~^~~
nhw_decoder_cli.c: In function 'setup_bmp_header':
nhw_decoder_cli.c:296:18: warning: unused variable 'tmpi16' [-Wunused-variable]
  296 |         uint16_t tmpi16;
      |                  ^~~~~~
nhw_decoder_cli.c:295:27: warning: unused variable 'img_bpp' [-Wunused-variable]
  295 |         int img_w, img_h, img_bpp;
      |                           ^~~~~~~
nhw_decoder_cli.c:295:20: warning: unused variable 'img_h' [-Wunused-variable]
  295 |         int img_w, img_h, img_bpp;
      |                    ^~~~~
nhw_decoder_cli.c:295:13: warning: unused variable 'img_w' [-Wunused-variable]
  295 |         int img_w, img_h, img_bpp;
      |             ^~~~~
nhw_decoder_cli.c: In function 'write_image_bmp':
nhw_decoder_cli.c:268:73: warning: 'Y_inv' may be used uninitialized [-Wmaybe-uninitialized]
  268 |                                 B = (((int)((Y + 516*U         + B_COMP)*Y_inv +128.5f))>>8);
      |                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
nhw_decoder_cli.c:113:27: note: 'Y_inv' was declared here
  113 |         float Y_q_setting,Y_inv;
      |                           ^~~~~
wavelet_filterbank.c: In function 'wavelet_synthesis2':
wavelet_filterbank.c:304:27: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  304 |                 for (i=0;i<os->nhw_res6_len;i++)
      |                           ^
wavelet_filterbank.c:237:89: warning: unused parameter 'Y' [-Wunused-parameter]
  237 | void wavelet_synthesis2(image_buffer *im,decode_state *os,int norder,int last_stage,int Y)
      |                                                                                     ~~~~^

And, when compiling the encoder:

$ gcc -O3 -Wall -Wextra *.c -o nhw_enc.exe
colorspace.c: In function 'downsample_YUV420':
colorspace.c:55:55: warning: unused parameter 'enc' [-Wunused-parameter]
   55 | void downsample_YUV420(image_buffer *im,encode_state *enc,int rate)
      |                                         ~~~~~~~~~~~~~~^~~
colorspace.c:55:63: warning: unused parameter 'rate' [-Wunused-parameter]
   55 | void downsample_YUV420(image_buffer *im,encode_state *enc,int rate)
      |                                                           ~~~~^~~~
colorspace.c:195:91: warning: 'Qtz' may be used uninitialized [-Wmaybe-uninitialized]
  195 |                         colorsY[j] = ((( 66*colors[i] + 129*colors[i+1] +  25*colors[i+2])*Qtz + 4194304)>>23)+ 16;
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
colorspace.c:57:23: note: 'Qtz' was declared here
   57 |         int i,j,Y,U,V,Qtz;
      |                       ^~~
compress_pixel.c: In function 'wavlts2packet':
compress_pixel.c:358:1: warning: label 'L_TAG' defined but not used [-Wunused-label]
  358 | L_TAG:  e=1;
      | ^~~~~
compress_pixel.c:56:53: warning: unused variable 'huffman_word' [-Wunused-variable]
   56 |         unsigned int weight[354],weight2[354],l1,l2,huffman_word;
      |                                                     ^~~~~~~~~~~~
compress_pixel.c: In function 'Y_highres_compression':
compress_pixel.c:473:23: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  473 |         int i,j,e,Y,a,res,scan,count,mem;
      |                       ^~~
compress_pixel.c: In function 'highres_compression':
compress_pixel.c:880:19: warning: unused variable 'Y' [-Wunused-variable]
  880 |         int i,j,e,Y,a,res,scan,count;
      |                   ^
compress_pixel.c:880:17: warning: variable 'e' set but not used [-Wunused-but-set-variable]
  880 |         int i,j,e,Y,a,res,scan,count;
      |                 ^
In file included from compress_pixel.c:51:
tree.h: At top level:
tree.h:143:13: warning: 'extra_table' defined but not used [-Wunused-variable]
  143 | static char extra_table[109] = {
      |             ^~~~~~~~~~~
tree.h:55:22: warning: 'extra_words2' defined but not used [-Wunused-variable]
   55 | static unsigned char extra_words2[19]={60,62,66,68,70,74,76,78,82,84,86,90,92,94,98,100,102,106,108};
      |                      ^~~~~~~~~~~~
tree.h:54:22: warning: 'extra_words1' defined but not used [-Wunused-variable]
   54 | static unsigned char extra_words1[19]={10,12,14,18,20,22,26,28,30,34,36,38,42,44,46,50,52,54,58};
      |                      ^~~~~~~~~~~~
filters.c: In function 'downfilter53IV':
filters.c:348:23: warning: unused variable 'a' [-Wunused-variable]
  348 |         int r,e=0,m=0,a,w_end;
      |                       ^
filters.c:348:19: warning: variable 'm' set but not used [-Wunused-but-set-variable]
  348 |         int r,e=0,m=0,a,w_end;
      |                   ^
filters.c:348:13: warning: unused variable 'r' [-Wunused-variable]
  348 |         int r,e=0,m=0,a,w_end;
      |             ^
filters.c: In function 'upfilter53':
filters.c:446:33: warning: unused variable 'r' [-Wunused-variable]
  446 |         short *E=_X,*_E1_=E+M-2,r=0,m=0,a;
      |                                 ^
filters.c: In function 'upfilter53III':
filters.c:536:33: warning: unused variable 'r' [-Wunused-variable]
  536 |         short *E=_X,*_E2_=E+M-2,r;
      |                                 ^
filters.c: In function 'upfilter53VI':
filters.c:554:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  554 |         if (_RES[0]>0) _RES[0]+=32;_RES[0]>>=6;
      |         ^~
filters.c:554:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  554 |         if (_RES[0]>0) _RES[0]+=32;_RES[0]>>=6;
      |                                    ^~~~
filters.c:555:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  555 |         if (_RES[1]>0) _RES[1]+=32;_RES[1]>>=6;
      |         ^~
filters.c:555:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  555 |         if (_RES[1]>0) _RES[1]+=32;_RES[1]>>=6;
      |                                    ^~~~
filters.c:551:33: warning: unused variable 'r' [-Wunused-variable]
  551 |         short *E=_X,*_E2_=E+M-2,r;
      |                                 ^
filters.c: In function 'upfilter53VI_II':
filters.c:579:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  579 |         if (_RES[0]>0) _RES[0]+=32;_RES[0]>>=6;
      |         ^~
filters.c:579:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  579 |         if (_RES[0]>0) _RES[0]+=32;_RES[0]>>=6;
      |                                    ^~~~
filters.c:580:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  580 |         if (_RES[1]>0) _RES[1]+=32;_RES[1]>>=6;
      |         ^~
filters.c:580:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  580 |         if (_RES[1]>0) _RES[1]+=32;_RES[1]>>=6;
      |                                    ^~~~
filters.c:576:35: warning: unused variable 'm' [-Wunused-variable]
  576 |         short *E=_X,*_E2_=E+M-2,r,m;
      |                                   ^
filters.c:576:33: warning: unused variable 'r' [-Wunused-variable]
  576 |         short *E=_X,*_E2_=E+M-2,r,m;
      |                                 ^
filters.c: In function 'upfilter53IV':
filters.c:624:22: warning: unused variable '_E2_' [-Wunused-variable]
  624 |         short *E=_X,*_E2_=E+M-2;
      |                      ^~~~
filters.c:622:51: warning: unused parameter '_RES' [-Wunused-parameter]
  622 | __inline void upfilter53IV(short *_X,int M,short *_RES)
      |                                            ~~~~~~~^~~~
image_processing.c: In function 'offsetUV':
image_processing.c:110:17: warning: unused variable 'wavelet_order' [-Wunused-variable]
  110 |         int i,j,wavelet_order,exw,a;
      |                 ^~~~~~~~~~~~~
image_processing.c:110:15: warning: unused variable 'j' [-Wunused-variable]
  110 |         int i,j,wavelet_order,exw,a;
      |               ^
image_processing.c:108:46: warning: unused parameter 'enc' [-Wunused-parameter]
  108 | void offsetUV(image_buffer *im,encode_state *enc,int m2)
      |                                ~~~~~~~~~~~~~~^~~
image_processing.c: In function 'offsetY':
image_processing.c:187:88: warning: variable 'quant5' set but not used [-Wunused-but-set-variable]
  187 |         int i,j,wavelet_order,exw,a,r1=0,r2=0,scan,t1=0,quant=0,quant2,quant3,quant4=0,quant5=0,quant6=0;
      |                                                                                        ^~~~~~
image_processing.c:187:52: warning: unused variable 't1' [-Wunused-variable]
  187 |         int i,j,wavelet_order,exw,a,r1=0,r2=0,scan,t1=0,quant=0,quant2,quant3,quant4=0,quant5=0,quant6=0;
      |                                                    ^~
image_processing.c:187:47: warning: unused variable 'scan' [-Wunused-variable]
  187 |         int i,j,wavelet_order,exw,a,r1=0,r2=0,scan,t1=0,quant=0,quant2,quant3,quant4=0,quant5=0,quant6=0;
      |                                               ^~~~
image_processing.c:187:17: warning: variable 'wavelet_order' set but not used [-Wunused-but-set-variable]
  187 |         int i,j,wavelet_order,exw,a,r1=0,r2=0,scan,t1=0,quant=0,quant2,quant3,quant4=0,quant5=0,quant6=0;
      |                 ^~~~~~~~~~~~~
image_processing.c:185:45: warning: unused parameter 'enc' [-Wunused-parameter]
  185 | void offsetY(image_buffer *im,encode_state *enc, int m1)
      |                               ~~~~~~~~~~~~~~^~~
image_processing.c: In function 'im_recons_wavelet_band':
image_processing.c:525:26: warning: unused variable 'count' [-Wunused-variable]
  525 |         int i,j,a,r,scan,count;
      |                          ^~~~~
image_processing.c: In function 'offsetY_recons256':
image_processing.c:1624:17: warning: variable 'wavelet_order' set but not used [-Wunused-but-set-variable]
 1624 |         int i,j,wavelet_order,a,e,t,quant=0,quant6=0;
      |                 ^~~~~~~~~~~~~
image_processing.c: In function 'offsetUV_recons256':
image_processing.c:2216:33: warning: unused variable 'e' [-Wunused-variable]
 2216 |         int i,j,wavelet_order,a,e=0;
      |                                 ^
image_processing.c:2216:17: warning: variable 'wavelet_order' set but not used [-Wunused-but-set-variable]
 2216 |         int i,j,wavelet_order,a,e=0;
      |                 ^~~~~~~~~~~~~
In file included from image_processing.c:51:
tree.h: At top level:
tree.h:130:22: warning: 'len' defined but not used [-Wunused-variable]
  130 | static unsigned char len[DEPTH]={
      |                      ^~~
tree.h:58:21: warning: 'huffman_tree' defined but not used [-Wunused-variable]
   58 | static unsigned int huffman_tree[DEPTH]={
      |                     ^~~~~~~~~~~~
image_processing.c: In function 'pre_processing':
image_processing.c:782:48: warning: 'n1' may be used uninitialized [-Wmaybe-uninitialized]
  782 |                                 if (abs(res)>4 && abs(res)<n1)
      |                                     ~~~~~~~~~~~^~~~~~~~~~~~~~
image_processing.c:560:77: note: 'n1' was declared here
  560 |     int i,j,scan,res,res2,res3,res4,count,e=0,f=0,a=0,sharpness=0,sharpn2=0,n1,t,t1,t2,t3,t4,t5,t6,t7;
      |                                                                             ^~
nhw_encoder.c: In function 'encode_image':
nhw_encoder.c:1008:41: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
 1008 |                                         if (abs(nhw_process[scan+IM_DIM])<8) nhw_process[scan+IM_DIM]=10204;nhw_process[scan]=10100;
      |                                         ^~
nhw_encoder.c:1008:109: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
 1008 |                                         if (abs(nhw_process[scan+IM_DIM])<8) nhw_process[scan+IM_DIM]=10204;nhw_process[scan]=10100;
      |                                                                                                             ^~~~~~~~~~~
nhw_encoder.c:1020:41: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
 1020 |                                         if (abs(nhw_process[scan+IM_DIM])<8) nhw_process[scan+IM_DIM]=10300;nhw_process[scan]=10100;
      |                                         ^~
nhw_encoder.c:1020:109: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
 1020 |                                         if (abs(nhw_process[scan+IM_DIM])<8) nhw_process[scan+IM_DIM]=10300;nhw_process[scan]=10100;
      |                                                                                                             ^~~~~~~~~~~
nhw_encoder.c:64:19: warning: variable 'wavelet_order' set but not used [-Wunused-but-set-variable]
   64 |         int stage,wavelet_order,end_transform,i,j,e=0,a=0,Y,count,scan,res,res_setting,res_uv,y_wavelet,y_wavelet2;
      |                   ^~~~~~~~~~~~~
nhw_encoder.c:347:156: warning: 'wvlt_thrx2' may be used uninitialized [-Wmaybe-uninitialized]
  347 |                                         abs(nhw_process[scan+3]-nhw_process[scan+1])<wvlt_thrx1 && abs(nhw_process[scan+3]-nhw_process[scan+2])<(wvlt_th
rx2-2))
      |                                                                                                                                                 ~~~~~~~~
~~~^~~
nhw_encoder.c:66:34: note: 'wvlt_thrx2' was declared here
   66 |         unsigned char wvlt_thrx1,wvlt_thrx2,wvlt_thrx3,wvlt_thrx4,wvlt_thrx5,wvlt_thrx6,wvlt_thrx7;
      |                                  ^~~~~~~~~~
nhw_encoder.c:451:92: warning: 'wvlt_thrx3' may be used uninitialized [-Wmaybe-uninitialized]
  451 |                                 if (abs(nhw_process[scan+1]-nhw_process[scan+(4*IM_DIM)+1])<wvlt_thrx3 && abs(nhw_process[scan+(2*IM_DIM)]-nhw_process[s
can+(2*IM_DIM)+2])<wvlt_thrx3)
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
nhw_encoder.c:66:45: note: 'wvlt_thrx3' was declared here
   66 |         unsigned char wvlt_thrx1,wvlt_thrx2,wvlt_thrx3,wvlt_thrx4,wvlt_thrx5,wvlt_thrx6,wvlt_thrx7;
      |                                             ^~~~~~~~~~
nhw_encoder.c:453:121: warning: 'wvlt_thrx4' may be used uninitialized [-Wmaybe-uninitialized]
  453 |                                         if (abs(nhw_process[scan+(2*IM_DIM)+1]-nhw_process[scan+(2*IM_DIM)])<(wvlt_thrx4-1) && abs(nhw_process[scan+1]-n
hw_process[scan+(2*IM_DIM)+1])<wvlt_thrx4)
      |                                                                                                              ~~~~~~~~~~~^~~
nhw_encoder.c:66:56: note: 'wvlt_thrx4' was declared here
   66 |         unsigned char wvlt_thrx1,wvlt_thrx2,wvlt_thrx3,wvlt_thrx4,wvlt_thrx5,wvlt_thrx6,wvlt_thrx7;
      |                                                        ^~~~~~~~~~
nhw_encoder.c:387:98: warning: 'wvlt_thrx5' may be used uninitialized [-Wmaybe-uninitialized]
  387 |                                                         if (abs(nhw_process[((scan+count)<<1)+e])<wvlt_thrx5) nhw_process[((scan+count)<<1)+e]=0;
      |                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
nhw_encoder.c:66:67: note: 'wvlt_thrx5' was declared here
   66 |         unsigned char wvlt_thrx1,wvlt_thrx2,wvlt_thrx3,wvlt_thrx4,wvlt_thrx5,wvlt_thrx6,wvlt_thrx7;
      |                                                                   ^~~~~~~~~~
nhw_encoder.c:376:103: warning: 'wvlt_thrx6' may be used uninitialized [-Wmaybe-uninitialized]
  376 |                                                         if (abs(nhw_process[((scan+count)<<1)+IM_DIM])<wvlt_thrx6) nhw_process[((scan+count)<<1)+IM_DIM]
=0;
      |                                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
nhw_encoder.c:66:78: note: 'wvlt_thrx6' was declared here
   66 |         unsigned char wvlt_thrx1,wvlt_thrx2,wvlt_thrx3,wvlt_thrx4,wvlt_thrx5,wvlt_thrx6,wvlt_thrx7;
      |                                                                              ^~~~~~~~~~
nhw_encoder.c:550:89: warning: 'wvlt_thrx7' may be used uninitialized [-Wmaybe-uninitialized]
  550 |                                         if (abs(nhw_process[scan+2]-nhw_process[scan+1])<wvlt_thrx7 && abs(nhw_process[scan+2]-nhw_process[scan])<wvlt_t
hrx7  && abs(nhw_process[scan+1]-nhw_process[scan])<wvlt_thrx7)
      |                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
nhw_encoder.c:66:89: note: 'wvlt_thrx7' was declared here
   66 |         unsigned char wvlt_thrx1,wvlt_thrx2,wvlt_thrx3,wvlt_thrx4,wvlt_thrx5,wvlt_thrx6,wvlt_thrx7;
      |                                                                                         ^~~~~~~~~~
nhw_encoder.c:65:33: warning: 'ch_comp' may be used uninitialized [-Wmaybe-uninitialized]
   65 |         unsigned char *highres,*ch_comp,*scan_run,*nhw_res1I_word,*nhw_res3I_word,*nhw_res5I_word;
      |                                 ^~~~~~~
wavelet_filterbank.c: In function 'wavelet_synthesis_high_quality_settings':
wavelet_filterbank.c:642:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  642 |         for (i=0;i<enc->nhw_res6_len;i++) enc->nhw_res6[i]=highres[i];
      |                   ^
wavelet_filterbank.c:646:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  646 |         for (i=0;i<enc->nhw_res6_len;i++) scan_run[i]=enc->nhw_res6[i]>>1;
      |                   ^
wavelet_filterbank.c:650:27: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  650 |         for (i=1,count=1;i<enc->nhw_res6_len-1;i++)
      |                           ^
wavelet_filterbank.c:664:26: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
  664 |         for (i=0,scan=0;i<enc->nhw_res6_len;i++)
      |                          ^
wavelet_filterbank.c:648:28: warning: '*scan_run' may be used uninitialized [-Wmaybe-uninitialized]
  648 |         highres[0]=scan_run[0];
      |                    ~~~~~~~~^~~
wavelet_filterbank.c:648:28: warning: '*scan_run' may be used uninitialized [-Wmaybe-uninitialized]

Now, I see those are only warnings, so not critical, BUT will you mind doing a review of the code in order to reduce those? Gcc is very helpful in pointing out ambiguous statements, and having a clean code is a comfortable starting point for anyone willing to provide any patch/pullRequest, so they're sure any new compiler remarks come from their newly added code.

rcanut commented 2 months ago

Hi,

Many thanks for your interest in NHW and for pointing out some compiler warnings.I'll remove this week the unused variables.It may take more time for me to remove the uninitializations...

Many thanks again for your time. Cheers, Raphael