[FFmpeg-devel] [PATCH] brstm: Fix last packet samples calculation

jamal jamrial at gmail.com
Sun Dec 16 01:20:17 CET 2012


On 15/12/12 8:30 PM, Derek Buitenhuis wrote:
> On 15/12/2012 6:21 PM, jamal wrote:
>> Subject: [PATCH] brstm: Fix last packet samples calculation
>>
>> This fixes the calculation of samples in the last packet
>> of non-stereo streams.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
> 
> That's not really what I meant. That's pretty much:
> 
>     Fix bug
> 
>     This fixes bug when N is true.
> 
> An example, in this case, of what a good commit message could be is:
> 
>     brstm: Fix calculates of number of samples for the last block
> 
>     Previously, despite actually reading the number of channels from the file,
>     we had hardcoded it to 2 during calculation of the remaining samples for
>     the last block.
> 
>     Instead, use the number of channels we read in earlier to calculate it.
> 
> Patch itself looks OK.
> 
> - Derek

Sorry, i'm not exactly eloquent so i generally try to avoid writing lengthy descriptions.
I took your example and changed it a bit (But you can use yours if you prefer).

Regards.
-------------- next part --------------
>From 92a7ca4f2685d1f0d664524d26d8afb76e086d02 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial at gmail.com>
Date: Sat, 15 Dec 2012 21:15:04 -0300
Subject: [PATCH] brstm: Fix calculation of number of samples for the last block

Despite actually reading the number of channels from the file we had
hardcoded it to 2 in the calculation of samples for the last block.

Use instead the number of channels we read earlier to calculate it.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/brstm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/brstm.c b/libavformat/brstm.c
index 0a874d3..80f73ed 100644
--- a/libavformat/brstm.c
+++ b/libavformat/brstm.c
@@ -245,7 +245,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     b->current_block++;
     if (b->current_block == b->block_count) {
         size    = b->last_block_used_bytes;
-        samples = size / 16 * 14;
+        samples = size / (8 * codec->channels) * 14;
     } else if (b->current_block < b->block_count) {
         size    = b->block_size;
         samples = b->samples_per_block;
-- 
1.8.0.msysgit.0



More information about the ffmpeg-devel mailing list