changeset 3817:22831cc65a35 libavformat

get essence container ul in header and set it per track, check for unsupported codec
author bcoudurier
date Sat, 30 Aug 2008 23:54:24 +0000
parents 50bdbde13ecf
children ae0d01b63679
files mxfenc.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mxfenc.c	Sat Aug 30 23:47:58 2008 +0000
+++ b/mxfenc.c	Sat Aug 30 23:54:24 2008 +0000
@@ -40,6 +40,7 @@
 
 typedef struct {
     UID track_essence_element_key;
+    const UID *essence_container_ul;
 } MXFStreamContext;
 
 typedef struct MXFContext {
@@ -181,15 +182,15 @@
     return 0;
 }
 
-static const MXFCodecUL *mxf_get_essence_container_ul(enum CodecID type)
+static const UID *mxf_get_essence_container_ul(enum CodecID type)
 {
     const MXFCodecUL *uls = ff_mxf_essence_container_uls;
     while (uls->id != CODEC_ID_NONE) {
         if (uls->id == type)
-            break;
+            return &uls->uid;
         uls++;
     }
-    return uls;
+    return NULL;
 }
 
 static void mxf_write_primer_pack(AVFormatContext *s)
@@ -601,7 +602,7 @@
 
 static void mxf_write_generic_desc(ByteIOContext *pb, const MXFDescriptorWriteTableEntry *desc_tbl, AVStream *st)
 {
-    const MXFCodecUL *codec_ul;
+    MXFStreamContext *sc = st->priv_data;
 
     put_buffer(pb, desc_tbl->key, 16);
     klv_encode_ber_length(pb, 108);
@@ -616,9 +617,8 @@
     put_be32(pb, st->time_base.den);
     put_be32(pb, st->time_base.num);
 
-    codec_ul = mxf_get_essence_container_ul(st->codec->codec_id);
     mxf_write_local_tag(pb, 16, 0x3004);
-    put_buffer(pb, codec_ul->uid, 16);
+    put_buffer(pb, *sc->essence_container_ul, 16);
 }
 
 static void mxf_write_mpegvideo_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index)
@@ -769,6 +769,12 @@
             av_set_pts_info(st, 64, 1, st->codec->time_base.den);
         else if (st->codec->codec_type == CODEC_TYPE_AUDIO)
             av_set_pts_info(st, 64, 1, st->codec->sample_rate);
+        sc->essence_container_ul = mxf_get_essence_container_ul(st->codec->codec_id);
+        if (!sc->essence_container_ul) {
+            av_log(s, AV_LOG_ERROR, "track %d: could not find essence container ul, "
+                   "codec not currently supported in container\n", i);
+            return -1;
+        }
     }
 
     mxf_write_partition(s, 0, 1, header_partition_key);