[FFmpeg-devel] [PATCH] lavf/ape: Fix last packet duration calculation

Paul B Mahol onemda at gmail.com
Sun Aug 26 12:25:42 CEST 2012


On 8/25/12, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Sat, Aug 25, 2012 at 12:20:38PM +0000, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libavformat/ape.c |    6 ++----
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavformat/ape.c b/libavformat/ape.c
>> index c4a390b..9c05cee 100644
>> --- a/libavformat/ape.c
>> +++ b/libavformat/ape.c
>> @@ -45,7 +45,6 @@ typedef struct {
>>      int nblocks;
>>      int size;
>>      int skip;
>> -    int64_t pts;
>>  } APEFrame;
>>
>>  typedef struct {
>> @@ -344,8 +343,7 @@ static int ape_read_header(AVFormatContext * s)
>>
>>      pts = 0;
>>      for (i = 0; i < ape->totalframes; i++) {
>> -        ape->frames[i].pts = pts;
>> -        av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0,
>> 0, AVINDEX_KEYFRAME);
>> +        av_add_index_entry(st, ape->frames[i].pos, pts, 0, 0,
>> AVINDEX_KEYFRAME);
>>          pts += ape->blocksperframe;
>>      }
>>
>
>> @@ -394,7 +392,7 @@ static int ape_read_packet(AVFormatContext * s,
>> AVPacket * pkt)
>>      AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
>>      ret = avio_read(s->pb, pkt->data + extra_size,
>> ape->frames[ape->currentframe].size);
>>
>> -    pkt->pts = ape->frames[ape->currentframe].pts;
>
> this causes a significant slowdown on slow media, as much more data
> will be read in the hope to find a valid PTS (that will not be found
> before EOF or max_analyze_duration)

That is because of extremly big superframes in ape, I really doubt there
is real slowdown with this patch, because avformat reads whole packet anyway.
>
> you can see this with -v 99
> with pts:
> All info found
> File position after avformat_find_stream_info() is 134672
>
> without pts:
> max_analyze_duration 5000000 reached at 5015510
> File position after avformat_find_stream_info() is 1048576
>

I think this is unrelated bug, current packet duration caclulation is
wrong with ape.

It have many frames in single packet and this does not work correctly at all.


More information about the ffmpeg-devel mailing list