[FFmpeg-cvslog] r17118 - trunk/libavformat/mxfenc.c

bcoudurier subversion
Tue Feb 10 06:35:28 CET 2009


Author: bcoudurier
Date: Tue Feb 10 06:35:28 2009
New Revision: 17118

Log:
move up mxf_write_klv_fill and align index, rip and primer pack

Modified:
   trunk/libavformat/mxfenc.c

Modified: trunk/libavformat/mxfenc.c
==============================================================================
--- trunk/libavformat/mxfenc.c	Tue Feb 10 06:22:38 2009	(r17117)
+++ trunk/libavformat/mxfenc.c	Tue Feb 10 06:35:28 2009	(r17118)
@@ -973,6 +973,22 @@ static void mxf_write_index_table_segmen
     }
 }
 
+static void mxf_write_klv_fill(AVFormatContext *s)
+{
+    unsigned pad = klv_fill_size(url_ftell(s->pb));
+    if (pad) {
+        put_buffer(s->pb, klv_fill_key, 16);
+        pad -= 16;
+        pad -= klv_ber_length(pad);
+        klv_encode_ber_length(s->pb, pad);
+        for (; pad > 7; pad -= 8)
+            put_be64(s->pb, 0);
+        for (; pad; pad--)
+            put_byte(s->pb, 0);
+        assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
+    }
+}
+
 static void mxf_write_partition(AVFormatContext *s, int bodysid,
                                 int indexsid, unsigned index_byte_count,
                                 const uint8_t *key, int write_metadata)
@@ -1023,6 +1039,8 @@ static void mxf_write_partition(AVFormat
         int64_t pos, start = url_ftell(s->pb);
         unsigned header_byte_count;
 
+        mxf_write_klv_fill(s);
+
         mxf_write_primer_pack(s);
         mxf_write_header_metadata_sets(s);
         pos = url_ftell(s->pb);
@@ -1207,22 +1225,6 @@ static int mxf_write_header(AVFormatCont
     return 0;
 }
 
-static void mxf_write_klv_fill(AVFormatContext *s)
-{
-    unsigned pad = klv_fill_size(url_ftell(s->pb));
-    if (pad) {
-        put_buffer(s->pb, klv_fill_key, 16);
-        pad -= 16;
-        pad -= klv_ber_length(pad);
-        klv_encode_ber_length(s->pb, pad);
-        for (; pad > 7; pad -= 8)
-            put_be64(s->pb, 0);
-        for (; pad; pad--)
-            put_byte(s->pb, 0);
-        assert(!(url_ftell(s->pb) & (KAG_SIZE-1)));
-    }
-}
-
 static const uint8_t system_metadata_pack_key[]        = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x03,0x01,0x04,0x01,0x01,0x00 };
 static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x43,0x01,0x01,0x0D,0x01,0x03,0x01,0x04,0x01,0x02,0x01 };
 
@@ -1368,14 +1370,19 @@ static int mxf_write_footer(AVFormatCont
 
     // add encoded ber length
     index_byte_count += 16 + klv_ber_length(index_byte_count);
+    index_byte_count += klv_fill_size(index_byte_count);
 
     mxf_write_klv_fill(s);
 
     mxf->footer_partition_offset = url_ftell(pb);
     mxf_write_partition(s, 0, 2, index_byte_count, footer_partition_key, 0);
 
+    mxf_write_klv_fill(s);
+
     mxf_write_index_table_segment(s);
 
+    mxf_write_klv_fill(s);
+
     mxf_write_random_index_pack(s);
 
     if (!url_is_streamed(s->pb)) {




More information about the ffmpeg-cvslog mailing list