Browse code

avformat/gifdec: correct r_frame_rate for single frame gifs

Fixes Ticket4650

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2015/08/10 11:18:21
Showing 1 changed files
... ...
@@ -52,6 +52,9 @@ typedef struct GIFDemuxContext {
52 52
     int total_iter;
53 53
     int iter_count;
54 54
     int ignore_loop;
55
+
56
+    int nb_frames;
57
+    int last_duration;
55 58
 } GIFDemuxContext;
56 59
 
57 60
 /**
... ...
@@ -279,6 +282,9 @@ parse_keyframe:
279 279
             pkt->stream_index = 0;
280 280
             pkt->duration = gdc->delay;
281 281
 
282
+            gdc->nb_frames ++;
283
+            gdc->last_duration = pkt->duration;
284
+
282 285
             /* Graphic Control Extension's scope is single frame.
283 286
              * Remove its influence. */
284 287
             gdc->delay = gdc->default_delay;
... ...
@@ -299,6 +305,9 @@ resync:
299 299
     }
300 300
 
301 301
     if ((ret >= 0 && !frame_parsed) || ret == AVERROR_EOF) {
302
+        if (gdc->nb_frames == 1) {
303
+            s->streams[0]->r_frame_rate = (AVRational) {100, gdc->last_duration};
304
+        }
302 305
         /* This might happen when there is no image block
303 306
          * between extension blocks and GIF_TRAILER or EOF */
304 307
         if (!gdc->ignore_loop && (block_label == GIF_TRAILER || avio_feof(pb))