X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fgifdec.c;h=1ac47fee5043ea1cfa9ec17d2e5004a2715c7c22;hb=c10caea2144fefc5e3e80807f301b3bf7a9b2753;hp=bb4c6ec6e6465b3c9cee296569c6d5c78b97d10d;hpb=b3e5d59537cbd375ca508fe2dfca30bcd2d201d3;p=ffmpeg diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c index bb4c6ec6e64..1ac47fee504 100644 --- a/libavformat/gifdec.c +++ b/libavformat/gifdec.c @@ -52,6 +52,9 @@ typedef struct GIFDemuxContext { int total_iter; int iter_count; int ignore_loop; + + int nb_frames; + int last_duration; } GIFDemuxContext; /** @@ -279,6 +282,9 @@ parse_keyframe: pkt->stream_index = 0; pkt->duration = gdc->delay; + gdc->nb_frames ++; + gdc->last_duration = pkt->duration; + /* Graphic Control Extension's scope is single frame. * Remove its influence. */ gdc->delay = gdc->default_delay; @@ -299,6 +305,9 @@ resync: } if ((ret >= 0 && !frame_parsed) || ret == AVERROR_EOF) { + if (gdc->nb_frames == 1) { + s->streams[0]->r_frame_rate = (AVRational) {100, gdc->last_duration}; + } /* This might happen when there is no image block * between extension blocks and GIF_TRAILER or EOF */ if (!gdc->ignore_loop && (block_label == GIF_TRAILER || avio_feof(pb))