]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/gifdec.c
Merge commit 'bd255f9feb4deea4c990e582f0ba3b90d7b64b4c'
[ffmpeg] / libavformat / gifdec.c
old mode 100755 (executable)
new mode 100644 (file)
index f566239..4f4ce2c
@@ -32,8 +32,6 @@
 
 typedef struct GIFDemuxContext {
     const AVClass *class;
-    uint32_t width;
-    uint32_t height;
     /**
      * Time span in hundredths of second before
      * the next frame should be drawn on screen.
@@ -46,8 +44,6 @@ typedef struct GIFDemuxContext {
      */
     int min_delay;
     int default_delay;
-    int total_duration; ///< In hundredths of second.
-    int frame_idx;
 } GIFDemuxContext;
 
 /**
@@ -79,17 +75,17 @@ static int gif_read_header(AVFormatContext *s)
     GIFDemuxContext *gdc = s->priv_data;
     AVIOContext     *pb  = s->pb;
     AVStream        *st;
-    int ret;
+    int width, height, ret;
 
     /* skip 6-byte magick */
     if ((ret = avio_skip(pb, 6)) < 0)
         return ret;
 
     gdc->delay  = gdc->default_delay;
-    gdc->width  = avio_rl16(pb);
-    gdc->height = avio_rl16(pb);
+    width  = avio_rl16(pb);
+    height = avio_rl16(pb);
 
-    if (gdc->width == 0 || gdc->height == 0)
+    if (width == 0 || height == 0)
         return AVERROR_INVALIDDATA;
 
     st = avformat_new_stream(s, NULL);
@@ -101,8 +97,8 @@ static int gif_read_header(AVFormatContext *s)
     avpriv_set_pts_info(st, 64, 1, 100);
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id   = AV_CODEC_ID_GIF;
-    st->codec->width      = gdc->width;
-    st->codec->height     = gdc->height;
+    st->codec->width      = width;
+    st->codec->height     = height;
 
     /* jump to start because gif decoder needs header data too */
     if (avio_seek(pb, 0, SEEK_SET) != 0)
@@ -192,9 +188,6 @@ static int gif_read_packet(AVFormatContext *s, AVPacket *pkt)
             if ((ret = avio_skip(pb, ct_size)) < 0)
                 return ret;
         }
-
-        gdc->total_duration = 0;
-        gdc->frame_idx      = 0;
     } else {
         avio_seek(pb, -ret, SEEK_CUR);
         ret = AVERROR_EOF;
@@ -241,15 +234,11 @@ static int gif_read_packet(AVFormatContext *s, AVPacket *pkt)
                 pkt->flags |= AV_PKT_FLAG_KEY;
 
             pkt->stream_index = 0;
-            pkt->pts = gdc->total_duration;
-            gdc->total_duration += gdc->delay;
             pkt->duration = gdc->delay;
-            pkt->dts = gdc->frame_idx;
 
             /* Graphic Control Extension's scope is single frame.
              * Remove its influence. */
             gdc->delay = gdc->default_delay;
-            gdc->frame_idx++;
             frame_parsed = 1;
 
             break;
@@ -288,5 +277,6 @@ AVInputFormat ff_gif_demuxer = {
     .read_probe     = gif_probe,
     .read_header    = gif_read_header,
     .read_packet    = gif_read_packet,
+    .flags          = AVFMT_GENERIC_INDEX,
     .priv_class     = &demuxer_class,
 };