[FFmpeg-devel] [PATCH] adpcm: Use a hash table to improve chcking for duplicate samples

Michael Niedermayer michaelni
Fri Nov 19 01:52:11 CET 2010


On Thu, Nov 18, 2010 at 11:19:04PM +0200, Martin Storsj? wrote:
> Hi,
> 
> With the attached patch #1, the runtime for -trellis 8 drops from 158 to 
> 21 seconds, for my 30 second sample, see 
> http://albin.abo.fi/~mstorsjo/adpcm-graphs3/hash.pdf for details on that, 
> compared to the current trunk and compared to the old original code. This 
> speeds up things enough to actually be able to run all the way to -trellis 
> 15 within reasonable time (running into the issue with ssd wrapping 
> around, as I sent a patch for earlier), and one notices that it exhausts 
> all testable combinations at around -trellis 10, where the PSNR doesn't 
> really increase any longer.
> 
> As discussed earlier, the skipping when a matching sample is found could 
> also be done only if the ssd actually is worse than for that one. 
> Curiously enough, it gives slightly worse results (and slows things down 
> quite a bit), see 
> http://albin.abo.fi/~mstorsjo/adpcm-graphs3/with_without_check.pdf.
> 
> The second patch gives a slight, 0.1 dB increase in PSNR.
[...]
> @@ -393,6 +407,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
>                          if (ssd > nodes_next[pos]->ssd)\
>                              goto next_##NAME;\
>                      }\
> +                    *h = generation;\
>                      u = nodes_next[pos];\
>                      if(!u) {\
>                          assert(pathn < FREEZE_INTERVAL<<avctx->trellis);\
> @@ -442,6 +457,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
>          u = nodes;
>          nodes = nodes_next;
>          nodes_next = u;
> +        generation++;
>  
>          // prevent overflow
>          if(nodes[0]->ssd > (1<<18)) {
> @@ -463,6 +479,8 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
>              // checking which nodes do so is too slow, so just kill them all.
>              // this also slightly improves quality, but I don't know why.
>              memset(nodes+1, 0, (frontier-1)*sizeof(TrellisNode*));
> +            memset(hash, 0xff, 65536 * sizeof(*hash));
> +            generation = 0;

shouldnt this be
if(generation==255)
        ...
?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101119/ef1b6ad9/attachment.pgp>



More information about the ffmpeg-devel mailing list