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

Michael Niedermayer michaelni at gmx.at
Sat Aug 25 23:03:56 CEST 2012


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)

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


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120825/f41370c9/attachment.asc>


More information about the ffmpeg-devel mailing list