[FFmpeg-cvslog] lavf: move the packet keyframe setting code.

Anton Khirnov git at videolan.org
Sat Feb 25 04:28:17 CET 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Feb 15 08:38:51 2012 +0100| [655b24c01cea2af7e56ac4ffe3d6fdc475223bcc] | committer: Anton Khirnov

lavf: move the packet keyframe setting code.

compute_pkt_fields() is for unreliable estimates or guessing. The
keyframe information from the parser is (at least in theory) reliable,
so it should be used even when the other guessing is disabled with the
AVFMT_FLAG_NOFILLIN flag.

Therefore, move setting the packet keyframe flag based on parser
information from compute_pkt_fields() to read_frame_internal().

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

 libavformat/utils.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index d6aab56..0515c45 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -984,14 +984,6 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
     /* update flags */
     if(is_intra_only(st->codec))
         pkt->flags |= AV_PKT_FLAG_KEY;
-    else if (pc) {
-        pkt->flags = 0;
-        /* keyframe computation */
-        if (pc->key_frame == 1)
-            pkt->flags |= AV_PKT_FLAG_KEY;
-        else if (pc->key_frame == -1 && pc->pict_type == AV_PICTURE_TYPE_I)
-            pkt->flags |= AV_PKT_FLAG_KEY;
-    }
     if (pc)
         pkt->convergence_duration = pc->convergence_duration;
 }
@@ -1053,6 +1045,10 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                     pkt->pts = st->parser->pts;
                     pkt->dts = st->parser->dts;
                     pkt->pos = st->parser->pos;
+                    if (st->parser->key_frame == 1 ||
+                        (st->parser->key_frame == -1 &&
+                         st->parser->pict_type == AV_PICTURE_TYPE_I))
+                        pkt->flags |= AV_PKT_FLAG_KEY;
                     if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){
                         s->cur_st = NULL;
                         pkt->destruct= st->cur_pkt.destruct;



More information about the ffmpeg-cvslog mailing list