[Ffmpeg-devel] [PATCH] Smacker audio fix

Michael Niedermayer michaelni
Tue Mar 20 19:31:32 CET 2007


Hi

On Tue, Mar 20, 2007 at 10:53:52AM -0700, Mike Melanson wrote:
> Hi,
> 
> A contributor emailed me the attached fix for Smacker audio. The patch 
> fixes the long standing crackling audio problem when decoding 
> Smacker-compressed audio.
> 
> -- 
> 	-Mike Melanson

> Index: libavcodec/smacker.c
> ===================================================================
> --- libavcodec/smacker.c	(revision 8439)
> +++ libavcodec/smacker.c	(working copy)
> @@ -620,15 +620,17 @@
>          }
>      }
>      if(bits) { //decode 16-bit data
> -        pred[0]  = get_bits(&gb, 8);
> +        if(stereo) {
> +            pred[1]  = get_bits(&gb, 8) << 8;
> +            pred[1] |= get_bits(&gb, 8);
> +        }
> +        pred[0]  = get_bits(&gb, 8) << 8;
>          pred[0] |= get_bits(&gb, 8);
>          *samples++ = pred[0];
>          if(stereo) {
> -            pred[1]  = get_bits(&gb, 8);
> -            pred[1] |= get_bits(&gb, 8);
>              *samples++ = pred[1];
>          }

for(i=stereo; i>=0; i--)
    pred[i]= get_bits(&gb, 16);
for(i=0; i<=stereo; i++)
    *samples++ = pred[i];



> -        for(i = 0; i < unp_size / 2; i++) {
> +        for(i = 1 + stereo; i < unp_size / 2; i++) {
>              if(i & stereo) {
>                  if(vlc[2].table)
>                      res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
> @@ -658,13 +660,15 @@
>              }
>          }
>      } else { //8-bit data
> +        if(stereo) {
> +            pred[1] = get_bits(&gb, 8);
> +        }
>          pred[0] = get_bits(&gb, 8);
>          *samples++ = (pred[0] - 0x80) << 8;
>          if(stereo) {
> -            pred[1] = get_bits(&gb, 8);
>              *samples++ = (pred[1] - 0x80) << 8;
>          }

for(i=stereo; i>=0; i--)
    pred[i]= get_bits(&gb, 8);
for(i=0; i<=stereo; i++)
    *samples++ = (pred[i] - 0x80) << 8;


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070320/0e96bf65/attachment.pgp>



More information about the ffmpeg-devel mailing list