[FFmpeg-cvslog] movenc: Don't rely on the fragment index for vc1 info gathering

Martin Storsjö git at videolan.org
Tue Mar 10 11:39:50 CET 2015


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Tue Jan 20 15:54:03 2015 +0100| [0c5e380c2c266d2e8a13c000cc527529db837f10] | committer: Martin Storsjö

movenc: Don't rely on the fragment index for vc1 info gathering

The previous use of the mov->fragments field, for determining whether
written packets were part of the first fragment or not, didn't
work as intended when using the empty_moov flag.

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 libavformat/movenc.c |   11 +++++++----
 libavformat/movenc.h |    2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 67c7214..3a9d015 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3050,7 +3050,7 @@ static int mov_parse_mpeg2_frame(AVPacket *pkt, uint32_t *flags)
     return 0;
 }
 
-static void mov_parse_vc1_frame(AVPacket *pkt, MOVTrack *trk, int fragment)
+static void mov_parse_vc1_frame(AVPacket *pkt, MOVTrack *trk)
 {
     const uint8_t *start, *next, *end = pkt->data + pkt->size;
     int seq = 0, entry = 0;
@@ -3070,10 +3070,13 @@ static void mov_parse_vc1_frame(AVPacket *pkt, MOVTrack *trk, int fragment)
             break;
         }
     }
-    if (!trk->entry && !fragment) {
+    if (!trk->entry && trk->vc1_info.first_packet_seen)
+        trk->vc1_info.first_frag_written = 1;
+    if (!trk->entry && !trk->vc1_info.first_frag_written) {
         /* First packet in first fragment */
         trk->vc1_info.first_packet_seq   = seq;
         trk->vc1_info.first_packet_entry = entry;
+        trk->vc1_info.first_packet_seen  = 1;
     } else if ((seq && !trk->vc1_info.packet_seq) ||
                (entry && !trk->vc1_info.packet_entry)) {
         int i;
@@ -3084,7 +3087,7 @@ static void mov_parse_vc1_frame(AVPacket *pkt, MOVTrack *trk, int fragment)
             trk->vc1_info.packet_seq = 1;
         if (entry)
             trk->vc1_info.packet_entry = 1;
-        if (!fragment) {
+        if (!trk->vc1_info.first_frag_written) {
             /* First fragment */
             if ((!seq   || trk->vc1_info.first_packet_seq) &&
                 (!entry || trk->vc1_info.first_packet_entry)) {
@@ -3409,7 +3412,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         trk->start_cts = pkt->pts - pkt->dts;
 
     if (enc->codec_id == AV_CODEC_ID_VC1) {
-        mov_parse_vc1_frame(pkt, trk, mov->fragments);
+        mov_parse_vc1_frame(pkt, trk);
     } else if (pkt->flags & AV_PKT_FLAG_KEY) {
         if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
             trk->entry > 0) { // force sync sample for the first key frame
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 682820e..3ac5305 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -131,6 +131,8 @@ typedef struct MOVTrack {
     struct {
         int     first_packet_seq;
         int     first_packet_entry;
+        int     first_packet_seen;
+        int     first_frag_written;
         int     packet_seq;
         int     packet_entry;
         int     slices;



More information about the ffmpeg-cvslog mailing list