adpcm: Only increment heap_pos after finding a good enough sample
authorMartin Storsjö <martin@martin.st>
Fri, 19 Nov 2010 17:36:29 +0000 (17:36 +0000)
committerMartin Storsjö <martin@martin.st>
Fri, 19 Nov 2010 17:36:29 +0000 (17:36 +0000)
This increases the PSNR slightly (about 0.1 dB) for trellis sizes
below 8, and gives equal PSNR for sizes above that.

Originally committed as revision 25769 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/adpcm.c

index 6a6c77b5741857562df23daaffd0758e1a53f5d9..5e7c54f75449b3cb44bbdc2418447be032bc3f2c 100644 (file)
@@ -401,9 +401,10 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
                     } else {\
                         /* Try to replace one of the leaf nodes with the new \
                          * one, but try a different slot each time. */\
                     } else {\
                         /* Try to replace one of the leaf nodes with the new \
                          * one, but try a different slot each time. */\
-                        pos = (frontier >> 1) + (heap_pos++ & ((frontier >> 1) - 1));\
+                        pos = (frontier >> 1) + (heap_pos & ((frontier >> 1) - 1));\
                         if (ssd > nodes_next[pos]->ssd)\
                             goto next_##NAME;\
                         if (ssd > nodes_next[pos]->ssd)\
                             goto next_##NAME;\
+                        heap_pos++;\
                     }\
                     *h = generation;\
                     u = nodes_next[pos];\
                     }\
                     *h = generation;\
                     u = nodes_next[pos];\