changeset 4396:a34ee37a164e libavformat

force first track to be video and simplify
author bcoudurier
date Sun, 08 Feb 2009 02:38:07 +0000
parents 2a72b8b7a69d
children 6d1626886974
files mxfenc.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mxfenc.c	Sun Feb 08 02:34:56 2009 +0000
+++ b/mxfenc.c	Sun Feb 08 02:38:07 2009 +0000
@@ -124,7 +124,6 @@
     int header_written;
     MXFIndexEntry *index_entries;
     unsigned edit_units_count;
-    int edit_unit_start;  ///< index of the stream starting edit unit
     uint64_t timestamp;   ///< timestamp, as year(16),month(8),day(8),hour(8),minutes(8),msec/4(8)
 } MXFContext;
 
@@ -921,7 +920,7 @@
         if (sc->temporal_reordering)
             temporal_reordering = 1;
         put_byte(pb, i);
-        if (mxf->edit_unit_start)
+        if (i == 0)
             put_be32(pb, KAG_SIZE); // system item size including klv fill
         else
             put_be32(pb, 0); // element delta
@@ -1181,6 +1180,10 @@
         st->priv_data = sc;
 
         if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+            if (i != 0) {
+                av_log(s, AV_LOG_ERROR, "video stream must be first track\n");
+                return -1;
+            }
             if (fabs(av_q2d(st->codec->time_base) - 1/25.0) < 0.0001) {
                 samples_per_frame = PAL_samples_per_frame;
                 mxf->time_base = (AVRational){ 1, 25 };
@@ -1191,7 +1194,6 @@
                 av_log(s, AV_LOG_ERROR, "unsupported video frame rate\n");
                 return -1;
             }
-            mxf->edit_unit_start = st->index;
             av_set_pts_info(st, 64, mxf->time_base.num, mxf->time_base.den);
         } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
             if (st->codec->sample_rate != 48000) {
@@ -1350,7 +1352,7 @@
 
     mxf_write_klv_fill(s);
 
-    if (st->index == mxf->edit_unit_start) {
+    if (st->index == 0) {
         mxf->index_entries[mxf->edit_units_count].offset = url_ftell(pb);
         mxf->index_entries[mxf->edit_units_count].slice_offset[st->index] = 0;
 
@@ -1466,12 +1468,11 @@
     if (stream_count && (s->nb_streams == stream_count || flush)) {
         pktl = s->packet_buffer;
         if (s->nb_streams != stream_count) {
-            MXFContext *mxf = s->priv_data;
             AVPacketList *first = NULL;
             // find first packet in edit unit
             while (pktl) {
                 AVStream *st = s->streams[pktl->pkt.stream_index];
-                if (st->index == mxf->edit_unit_start)
+                if (st->index == 0)
                     break;
                 else if (!first)
                     first = pktl;