[FFmpeg-devel] [PATCH] adpcm: Reset the ssd back to zero more often
Michael Niedermayer
michaelni
Mon Nov 22 04:16:36 CET 2010
On Thu, Nov 18, 2010 at 04:01:31PM +0200, Martin Storsjo wrote:
> If using very large trellis sizes (e.g. -trellis 15), the frontier
> is so large that the difference between the best and the worst
> trellis node in the frontier is large enough to cause wraparound.
>
> Resetting at (1<<20) is enough to avoid the issue at -trellis 16
> with the sample I'm testing, therefore doing the resets at (1<<18)
> to have some extra safety margin.
>
> This doesn't incur any noticeable slowdown.
> ---
> I noticed this while testing the optimizations that Michael suggested
> (using a hash to find out which samples to skip), which made the
> encoder fast enough to actually be able to try out the maximum
> trellis levels.
>
> libavcodec/adpcm.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index 56eb602..f6e3cb7 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -444,7 +444,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
> nodes_next = u;
>
> // prevent overflow
> - if(nodes[0]->ssd > (1<<28)) {
> + if(nodes[0]->ssd > (1<<18)) {
> for(j=1; j<frontier && nodes[j]; j++)
> nodes[j]->ssd -= nodes[0]->ssd;
> nodes[0]->ssd = 0;
what if this is always performed and the subtraction added into some existing
code.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- 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/20101122/c5cb7888/attachment.pgp>
More information about the ffmpeg-devel
mailing list