[FFmpeg-devel] [PATCH] WMA Lossless: reset channel residues between subframes

Jakub Stachowski qbast at go2.pl
Sat Apr 14 16:25:50 CEST 2012


W dniu 2012-04-12 12:14, Mashiat Sarker Shakkhar pisze:
> On 4/12/2012 2:36 PM, Benjamin Larsson wrote:
>> On 04/12/2012 12:24 AM, Jakub Stachowski wrote:
>>> Hello
>>>
>>> Attached patch fixes bug #1055. It causes channel residues to be reset
>>> to 0 if they are not decoded from bitstream (is_channel_coded==0).
>>> Without the patch, residues from last decoded subframe would be used,
>>> which causes bursts of random noise in silent part of some files.
>>> I am not sure if channel residues should not be reset in case of raw
>>> pcm tiles, however I don't have any test file for that.
>>
>> Sounds ok. But Mashiat should look at it also.
>
> I don't really have anything to add. According to Jakub it fixes a bug,
> and looks intuitive.
>

I found a mistake actually - it always clears residues for both channels 
instead only for the one with is_channel_coded==0. I have not found any 
files where this bug manifests itself, but it would overwrite valid 
samples with zeros if only second channel is not coded.
Fix for a fix attached.

By the way: does anybody know if WMA stream contains exact number of 
samples? I tried to fix decoder cutting off last packet from decoded 
data (due not not handling 'flush'), but now have opposite problem - 
last frame is always full length (2048 samples) padded with zeros and I 
found no good way of determining how many samples are valid.

> Shakkhar
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

-------------- next part --------------
>From 450e21f7b12a7a8eb4e283f8b855bd30dc53d564 Mon Sep 17 00:00:00 2001
From: Jakub Stachowski <qbast at go2.pl>
Date: Sat, 14 Apr 2012 15:44:39 +0200
Subject: [PATCH] Clear residues only in not coded channel. This fixes
 overwriting coded residues with zeros if first channel is
 coded and second is not.

---
 libavcodec/wmalosslessdec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 1c8f059..db40287 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -960,7 +960,7 @@ static int decode_subframe(WmallDecodeCtx *s)
                     use_normal_update_speed(s, i);
                 revert_cdlms(s, i, 0, subframe_len);
             } else
-                memset(s->channel_residues, 0, sizeof(s->channel_residues));
+                memset(s->channel_residues[i], 0, sizeof(s->channel_residues[i]));
     }
     if (s->do_mclms)
         revert_mclms(s, subframe_len);
-- 
1.7.7



More information about the ffmpeg-devel mailing list