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

Jakub Stachowski qbast at go2.pl
Sat Apr 21 12:46:07 CEST 2012


W dniu 2012-04-14 21:04, Mashiat Sarker Shakkhar pisze:
> On 4/15/2012 12:38 AM, Jakub Stachowski wrote:
> [...]
>> For first test I used WMA file from bug #1055:
>> Decoded with dBpoweramp or Microsoft's wmal2pcm.exe I got 1410612
>> samples.
>> Decoded with ffmpeg (without taking skip value): 1413120
>> During decoding last frame, get_bits1() returned 460 samples to skip.
>> Difference is 2048+460 samples, so it should skip one full frame (I
>> wonder which one) and 460 from last one?
>
> Are you just assuming that samples_per_frame = 2048 or did you check?
>
>>
>> Next test: hand-crafted file with 15000 samples. All of them zeros apart
>> from last 14 bytes, then encoded with MS Expression Encoder
>> wmal2pcm.exe decoded it perfectly
>> ffmpeg after taking skip value into account also created file with right
>> length, however all samples were 0 (last 14 non-zero bytes got
>> destroyed).
>
> Why don't you share your WIP patch or git tree with us? If possible do
> share the samples too.
>
>>
>> So it is step in right direction, but not completely correct yet.
>
> I'd say you are stepping in the right direction. May be there are quirks
> that we are not aware of. It's easy enough to compare the bitstream
> reads with refcode. Share your code so that I can test.

This was not a quirk in bitstream, but a simple bug in decoder. In rare 
case when no frame was decoded in current packet, last frame would be 
written out again.
Attached patch fixes that and with it (and my WIP patch to use skip 
value in last frame) applied, test file from bug #1055 decodes perfectly.

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

-------------- next part --------------
>From 69e72720b448177dd5d8e2488251c8ca23e59a9c Mon Sep 17 00:00:00 2001
From: Jakub Stachowski <qbast at go2.pl>
Date: Sat, 21 Apr 2012 12:37:25 +0200
Subject: [PATCH] Ensure that last frame is not written again if nothing was
 decoded in current packet.

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

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index c70a895..7c55c84 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -1180,6 +1180,8 @@ static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr,
     int buf_size       = avpkt->size;
     int num_bits_prev_frame, packet_sequence_number, spliced_packet;
 
+    s->frame.nb_samples = 0;
+
     // flush frames from last packet
     if ( !buf && s->num_saved_bits > get_bits_count(&s->gb)) {
         int next=decode_frame(s);
-- 
1.7.7



More information about the ffmpeg-devel mailing list