[FFmpeg-soc] [soc]: r3670 - in mxf: avformat.h mxfenc.c

spyfeng subversion at mplayerhq.hu
Fri Aug 29 18:27:16 CEST 2008


Author: spyfeng
Date: Fri Aug 29 18:27:16 2008
New Revision: 3670

Log:
write company name, product name, version string as utf16.
fix Version String and Track Number ULs, the older are wrong.


Modified:
   mxf/avformat.h
   mxf/mxfenc.c

Modified: mxf/avformat.h
==============================================================================
--- mxf/avformat.h	(original)
+++ mxf/avformat.h	Fri Aug 29 18:27:16 2008
@@ -34,6 +34,7 @@
 #define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
 
 #define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
+#define WCS_LIBAVFORMAT_IDENT   L"Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
 /**
  * Returns the LIBAVFORMAT_VERSION_INT constant.
  */

Modified: mxf/mxfenc.c
==============================================================================
--- mxf/mxfenc.c	(original)
+++ mxf/mxfenc.c	Fri Aug 29 18:27:16 2008
@@ -32,6 +32,9 @@
 //#define DEBUG
 
 #include "mxf.h"
+#include <wchar.h>
+
+typedef wchar_t MXFUTF16String;
 
 typedef struct {
     int local_tag;
@@ -96,7 +99,7 @@ static const MXFLocalTagPair mxf_local_t
     { 0x3C09, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x20,0x07,0x01,0x01,0x00,0x00,0x00}}, /* This Generation UID */
     { 0x3C01, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x20,0x07,0x01,0x02,0x01,0x00,0x00}}, /* Company Name */
     { 0x3C02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x20,0x07,0x01,0x03,0x01,0x00,0x00}}, /* Product Name */
-    { 0x3C04, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x20,0x07,0x01,0x04,0x00,0x00,0x00}}, /* Version String */
+    { 0x3C04, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x20,0x07,0x01,0x05,0x01,0x00,0x00}}, /* Version String */
     { 0x3C05, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x20,0x07,0x01,0x07,0x00,0x00,0x00}}, /* Product ID */
     { 0x3C06, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x02,0x03,0x00,0x00}}, /* Modification Date */
     // Content Storage
@@ -112,7 +115,7 @@ static const MXFLocalTagPair mxf_local_t
     { 0x4701, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x02,0x03,0x00,0x00}}, /* Descriptor */
     // Track
     { 0x4801, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x01,0x07,0x01,0x01,0x00,0x00,0x00,0x00}}, /* Track ID */
-    { 0x4804, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x01,0x03,0x00,0x00}}, /* Track Numberr */
+    { 0x4804, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x01,0x04,0x01,0x03,0x00,0x00,0x00,0x00}}, /* Track Numberr */
     { 0x4B01, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x05,0x30,0x04,0x05,0x00,0x00,0x00,0x00}}, /* Edit Rate */
     { 0x4B02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x03,0x01,0x03,0x00,0x00}}, /* Origin */
     { 0x4803, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x02,0x04,0x00,0x00}}, /* Sequence reference */
@@ -324,6 +327,16 @@ static void mxf_write_preface(AVFormatCo
     put_be64(pb, 0);
 }
 
+static void mxf_write_utf16string(ByteIOContext *pb, const MXFUTF16String *value)
+{
+    int i, size = wcslen(value) + 1;
+    for (i = 0; i < size; i++)
+    {
+        put_byte(pb, (value[i] >> 8) & 0xff);
+        put_byte(pb, value[i] & 0xff);
+    }
+}
+
 static void mxf_write_identification(AVFormatContext *s)
 {
     ByteIOContext *pb = s->pb;
@@ -331,14 +344,16 @@ static void mxf_write_identification(AVF
 
     mxf_write_metadata_key(pb, 0x013000);
     PRINT_KEY(s, "identification key", pb->buf_ptr - 16);
-    company_name_len = sizeof("FFmpeg");
-    product_name_len = sizeof("OP1a Muxer");
+    company_name_len = (wcslen(L"FFmpeg") + 1) * 2;
+    product_name_len = (wcslen(L"OP1a Muxer") + 1) * 2;
 
     length = 80 + company_name_len + product_name_len;
-    if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
-        version_string_len = sizeof(LIBAVFORMAT_IDENT);
-        length += 4 + version_string_len;
-    }
+    if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
+        version_string_len = (wcslen(WCS_LIBAVFORMAT_IDENT) + 1) * 2;
+    else
+        version_string_len = (wcslen(L"0.0.0") + 1) * 2;
+
+    length += 4 + version_string_len;
     klv_encode_ber_length(pb, length);
 
     // write uid
@@ -350,15 +365,16 @@ static void mxf_write_identification(AVF
     mxf_write_uuid(pb, Identification, 1);
 
     mxf_write_local_tag(pb, company_name_len, 0x3C01);
-    put_buffer(pb, "FFmpeg", company_name_len);
+    mxf_write_utf16string(pb, L"FFmpeg");
 
     mxf_write_local_tag(pb, product_name_len, 0x3C02);
-    put_buffer(pb, "OP1a Muxer", product_name_len);
+    mxf_write_utf16string(pb, L"OP1a Muxer");
 
-    if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) {
-        mxf_write_local_tag(pb, version_string_len, 0x3C04);
-        put_buffer(pb, LIBAVFORMAT_IDENT, version_string_len);
-    }
+    mxf_write_local_tag(pb, version_string_len, 0x3C04);
+    if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
+        mxf_write_utf16string(pb, WCS_LIBAVFORMAT_IDENT);
+    else
+        mxf_write_utf16string(pb, L"0.0.0");
 
     // write product uid
     mxf_write_local_tag(pb, 16, 0x3C05);



More information about the FFmpeg-soc mailing list