[FFmpeg-cvslog] avformat/apngdec: use packet pts and duration instead of altering stream framerate.

Benoit Fouet git at videolan.org
Wed Nov 26 13:34:26 CET 2014


ffmpeg | branch: master | Benoit Fouet <benoit.fouet at free.fr> | Wed Nov 26 11:22:45 2014 +0100| [8b8cb30d11885b406ce0dd896b42992386d98594] | committer: Michael Niedermayer

avformat/apngdec: use packet pts and duration instead of altering stream framerate.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8b8cb30d11885b406ce0dd896b42992386d98594
---

 libavformat/apngdec.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index dac71f1..8aa70a0 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -44,6 +44,9 @@ typedef struct APNGDemuxContext {
     int max_fps;
     int default_fps;
 
+    int64_t pkt_pts;
+    int pkt_duration;
+
     int is_key_frame;
 
     /*
@@ -163,6 +166,9 @@ static int apng_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
+    /* set the timebase to something large enough (1/100,000 of second)
+     * to hopefully cope with all sane frame durations */
+    avpriv_set_pts_info(st, 64, 1, 100000);
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id   = AV_CODEC_ID_APNG;
     st->codec->width      = avio_rb32(pb);
@@ -266,9 +272,9 @@ static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket
         delay_num = 1;
         delay_den = ctx->default_fps;
     }
-    s->streams[0]->r_frame_rate.num = delay_den;
-    s->streams[0]->r_frame_rate.den = delay_num;
-    pkt->duration = 1;
+    ctx->pkt_duration = av_rescale_q(delay_num,
+                                     (AVRational){ 1, delay_den },
+                                     s->streams[0]->time_base);
 
     av_log(s, AV_LOG_DEBUG, "%s: "
             "sequence_number: %"PRId32", "
@@ -379,6 +385,9 @@ static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         if (ctx->is_key_frame)
             pkt->flags |= AV_PKT_FLAG_KEY;
+        pkt->pts = ctx->pkt_pts;
+        pkt->duration = ctx->pkt_duration;
+        ctx->pkt_pts += ctx->pkt_duration;
         return ret;
     case MKTAG('I', 'E', 'N', 'D'):
         ctx->cur_loop++;



More information about the ffmpeg-cvslog mailing list