[FFmpeg-soc] [soc]: r2821 - mxf/mxfenc.c
spyfeng
subversion at mplayerhq.hu
Sat Jul 19 04:36:03 CEST 2008
Author: spyfeng
Date: Sat Jul 19 04:36:03 2008
New Revision: 2821
Log:
modify comments.
1,add space before and after "//"
2,remove useless comment
Modified:
mxf/mxfenc.c
Modified: mxf/mxfenc.c
==============================================================================
--- mxf/mxfenc.c (original)
+++ mxf/mxfenc.c Sat Jul 19 04:36:03 2008
@@ -1,6 +1,6 @@
/*
- * MXF muxer.
- * Copyright (c) 2008 GUCAS, Zhentan Feng<spyfeng at gmail dot com>.
+ * MXF muxer
+ * Copyright (c) 2008 GUCAS, Zhentan Feng<spyfeng at gmail dot com>
*
* This file is part of FFmpeg.
*
@@ -92,12 +92,12 @@ typedef struct MXFContext {
UID *track_essence_element_key;
} MXFContext;
-static const uint8_t umid_base[] = {0x06, 0x0a, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0f, 0x00, 0x13, 0x00, 0x00, 0x00};//16 bytes
+static const uint8_t umid_base[] = {0x06, 0x0a, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0f, 0x00, 0x13, 0x00, 0x00, 0x00};
/* complete key */
static const uint8_t op1a_ul[] = { 0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00 };
-static const uint8_t header_partition_key[] = { 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, 0x00 };//ClosedComplete
-static const uint8_t footer_partition_key[] = {0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x04, 0x04, 0x00};//ClosedComplete
+static const uint8_t header_partition_key[] = { 0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, 0x00 }; // ClosedComplete
+static const uint8_t footer_partition_key[] = {0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x04, 0x04, 0x00}; // ClosedComplete
static const uint8_t primer_pack_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 };
static const MXFEssenceElementKey mxf_essence_element_key[] = {
@@ -107,7 +107,7 @@ static const MXFEssenceElementKey mxf_es
};
/* partial key for header metadata */
-static const uint8_t header_metadata_key[] = {0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01};//13 bytes
+static const uint8_t header_metadata_key[] = {0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01};
/* SMPTE RP224 http://www.smpte-ra.org/mdd/index.html */
static const MXFDataDefinitionUL mxf_data_definition_uls[] = {
@@ -126,46 +126,46 @@ static const MXFCodecUL mxf_picture_esse
/* SMPTE RP210 http://www.smpte-ra.org/mdd/index.html */
static const MXFLocalTagPair mxf_local_tag_batch[] = {
- //preface set
- { 0x3C0A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x01,0x01,0x15,0x02,0x00,0x00,0x00,0x00}},/* Instance UID */
- { 0x3B02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x02,0x04,0x00,0x00}},/* Last Modified Date */
- { 0x3B05, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x01,0x05,0x00,0x00,0x00}},/* Version */
- { 0x3B06, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x04,0x00,0x00}},/* Identifications reference */
- { 0x3B03, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x02,0x01,0x00,0x00}},/* Content Storage reference */
- { 0x3B09, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x02,0x02,0x03,0x00,0x00,0x00,0x00}},/* Operational Pattern UL */
- { 0x3B0A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x02,0x02,0x10,0x02,0x01,0x00,0x00}},/* Essence Containers UL batch */
- { 0x3B0B, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x02,0x02,0x10,0x02,0x02,0x00,0x00}},/* DM Schemes UL batch */
- //Identification
- { 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 */
- { 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
- { 0x1901, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x05,0x01,0x00,0x00}},/* Package strong reference batch */
- //Essence Container Data
- { 0x2701, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x06,0x01,0x00,0x00,0x00}},/* Linked Package UID */
- { 0x3F07, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x01,0x03,0x04,0x04,0x00,0x00,0x00,0x00}},/* BodySID */
- //Package
- { 0x4401, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x01,0x01,0x15,0x10,0x00,0x00,0x00,0x00}},/* Package UID */
- { 0x4405, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x01,0x03,0x00,0x00}},/* Package Creation Date */
- { 0x4404, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x02,0x05,0x00,0x00}},/* Package Modified Date */
- { 0x4403, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x05,0x00,0x00}},/* Tracks Strong reference array */
- //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 */
- { 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 */
- //Sequence
- { 0x0201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x07,0x01,0x00,0x00,0x00,0x00,0x00}},/* Data Definition UL */
- { 0x0202, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x02,0x01,0x01,0x03,0x00,0x00}},/* Duration */
- { 0x1001, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x09,0x00,0x00}},/* Structural Components reference array */
- //Source Clip
- { 0x1201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x07,0x02,0x01,0x03,0x01,0x0A,0x00,0x00}},/* Start position */
- { 0x1101, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x03,0x01,0x00,0x00,0x00}},/* SourcePackageID */
- { 0x1102, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x03,0x02,0x00,0x00,0x00}},/* SourceTrackID */
+ // preface set
+ { 0x3C0A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x01,0x01,0x15,0x02,0x00,0x00,0x00,0x00}}, /* Instance UID */
+ { 0x3B02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x02,0x04,0x00,0x00}}, /* Last Modified Date */
+ { 0x3B05, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x01,0x02,0x01,0x05,0x00,0x00,0x00}}, /* Version */
+ { 0x3B06, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x04,0x00,0x00}}, /* Identifications reference */
+ { 0x3B03, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x02,0x01,0x00,0x00}}, /* Content Storage reference */
+ { 0x3B09, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x02,0x02,0x03,0x00,0x00,0x00,0x00}}, /* Operational Pattern UL */
+ { 0x3B0A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x02,0x02,0x10,0x02,0x01,0x00,0x00}}, /* Essence Containers UL batch */
+ { 0x3B0B, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x02,0x02,0x10,0x02,0x02,0x00,0x00}}, /* DM Schemes UL batch */
+ // Identification
+ { 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 */
+ { 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
+ { 0x1901, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x05,0x01,0x00,0x00}}, /* Package strong reference batch */
+ // Essence Container Data
+ { 0x2701, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x06,0x01,0x00,0x00,0x00}}, /* Linked Package UID */
+ { 0x3F07, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x01,0x03,0x04,0x04,0x00,0x00,0x00,0x00}}, /* BodySID */
+ // Package
+ { 0x4401, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x01,0x01,0x15,0x10,0x00,0x00,0x00,0x00}}, /* Package UID */
+ { 0x4405, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x01,0x03,0x00,0x00}}, /* Package Creation Date */
+ { 0x4404, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x02,0x05,0x00,0x00}}, /* Package Modified Date */
+ { 0x4403, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x05,0x00,0x00}}, /* Tracks Strong reference array */
+ // 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 */
+ { 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 */
+ // Sequence
+ { 0x0201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x07,0x01,0x00,0x00,0x00,0x00,0x00}}, /* Data Definition UL */
+ { 0x0202, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x02,0x01,0x01,0x03,0x00,0x00}}, /* Duration */
+ { 0x1001, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x06,0x09,0x00,0x00}}, /* Structural Components reference array */
+ // Source Clip
+ { 0x1201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x07,0x02,0x01,0x03,0x01,0x0A,0x00,0x00}}, /* Start position */
+ { 0x1101, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x03,0x01,0x00,0x00,0x00}}, /* SourcePackageID */
+ { 0x1102, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x03,0x02,0x00,0x00,0x00}}, /* SourceTrackID */
};
#define PRINT_KEY(pc, s, x) dprintf(pc, "%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \
@@ -179,13 +179,13 @@ static void mxf_generate_uuid(AVFormatCo
rand_num = av_random(&mxf->random_state);
rand_num = rand_num & 0x00ff;
- //the 7th byte is version according to ISO 11578
+ // the 7th byte is version according to ISO 11578
if (i == 6) {
rand_num &= 0x0f;
rand_num |= 0x40;
}
- //the 8th byte is variant for current use according to ISO 11578
+ // the 8th byte is variant for current use according to ISO 11578
if (i == 8) {
rand_num &= 0x3f;
rand_num |= 0x80;
@@ -230,7 +230,7 @@ static int klv_encode_ber_length(ByteIOC
while (len >>= 8)
size ++;
- //long form
+ // long form
put_byte(pb, 0x80 + (size - 1));
i = size - 1;
while(i) {
@@ -249,13 +249,11 @@ static int mxf_write_primer_pack(AVForma
local_tag_number = sizeof(mxf_local_tag_batch) / sizeof(MXFLocalTagPair);
- //write key and length
put_buffer(pb, primer_pack_key, 16);
klv_encode_ber_length(pb, local_tag_number * 18 + 8);
- //write value
- put_be32(pb, local_tag_number);//local_tag num
- put_be32(pb, 18);//item size, always 18 according to the specs
+ put_be32(pb, local_tag_number); // local_tag num
+ put_be32(pb, 18); // item size, always 18 according to the specs
for (local_tag_batch = mxf_local_tag_batch; i < local_tag_number; local_tag_batch++, i++) {
put_be16(pb, local_tag_batch->local_tag);
@@ -325,7 +323,6 @@ static int mxf_write_preface(AVFormatCon
UID uid;
ByteIOContext *pb = s->pb;
- //write KLV
klv->key[13] = 0x01;
klv->key[14] = 0x2f;
klv->key[15] = 0x00;
@@ -333,7 +330,7 @@ static int mxf_write_preface(AVFormatCon
put_buffer(pb, klv->key, 16);
klv_encode_ber_length(pb, 146);
- //write preface set uid
+ // write preface set uid
mxf_generate_uuid(s, uid);
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, uid, 16);
@@ -342,21 +339,21 @@ static int mxf_write_preface(AVFormatCon
PRINT_KEY(s, "preface uid", uid);
#endif
- //write create date as unknown
+ // write create date as unknown
mxf_write_local_tag(pb, 8, 0x3B02);
put_buffer(pb, 0, 8);
- //write version
+ // write version
mxf_write_local_tag(pb, 2, 0x3B05);
put_be16(pb, 1);
- //write identification_refs
+ // write identification_refs
if (mxf_generate_reference(s, &refs->identification, 1) < 0)
return -1;
mxf_write_local_tag(pb, 16 + 8, 0x3B06);
mxf_write_reference(pb, 1, refs->identification);
- //write content_storage_refs
+ // write content_storage_refs
if (mxf_generate_reference(s, &refs->content_storage, 1) < 0)
return -1;
mxf_write_local_tag(pb, 16, 0x3B03);
@@ -365,13 +362,13 @@ static int mxf_write_preface(AVFormatCon
mxf_write_local_tag(pb, 16, 0x3B09);
put_buffer(pb, op1a_ul, 16);
- //write essence_container_refs
+ // write essence_container_refs
if (mxf_generate_reference(s, &refs->essence_container, 1) < 0)
return -1;
mxf_write_local_tag(pb, 16 + 8, 0x3B0A);
mxf_write_reference(pb, 1, refs->essence_container);
- //write dm_scheme_refs
+ // write dm_scheme_refs
mxf_write_local_tag(pb, 8, 0x3B0B);
put_be64(pb, 0);
return 0;
@@ -398,11 +395,11 @@ static int mxf_write_identification(AVFo
klv_encode_ber_length(pb, length);
- //write uid
+ // write uid
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, *refs->identification, 16);
- //write generation uid
+ // write generation uid
mxf_generate_uuid(s, uid);
mxf_write_local_tag(pb, 16, 0x3C09);
put_buffer(pb, uid, 16);
@@ -416,12 +413,12 @@ static int mxf_write_identification(AVFo
mxf_write_local_tag(pb, version_string_len, 0x3C04);
put_buffer(pb, "version 0.0.1", version_string_len);
- //write product uid
+ // write product uid
mxf_generate_uuid(s, uid);
mxf_write_local_tag(pb, 16, 0x3C05);
put_buffer(pb, uid, 16);
- //write modified date
+ // write modified date
mxf_write_local_tag(pb, 8, 0x3C06);
put_buffer(pb, 0, 8);
return 0;
@@ -440,11 +437,11 @@ static int mxf_write_content_storage(AVF
put_buffer(pb, klv->key, 16);
klv_encode_ber_length(pb, 64);
- //write uid
+ // write uid
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, *refs->content_storage, 16);
- //write package reference
+ // write package reference
if (mxf_generate_reference(s, &refs->package, 2) < 0)
return -1;
mxf_write_local_tag(pb, 16 * 2 + 8, 0x1901);
@@ -467,12 +464,12 @@ static int mxf_write_package(AVFormatCon
put_buffer(pb, klv->key, 16);
klv_encode_ber_length(pb, 92 + 16 * s->nb_streams);
- //write uid
+ // write uid
ref = type == MaterialPackage ? refs->package : & refs->package[1];
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, *ref, 16);
- //write package umid
+ // write package umid
mxf_write_local_tag(pb, 32, 0x4401);
if (type == MaterialPackage) {
mxf_generate_umid(s, umid);
@@ -481,21 +478,21 @@ static int mxf_write_package(AVFormatCon
put_buffer(pb, mxf->top_src_package_uid, 32);
}
- //write create date
+ // write create date
mxf_write_local_tag(pb, 8, 0x4405);
put_buffer(pb, 0, 8);
- //write modified date
+ // write modified date
mxf_write_local_tag(pb, 8, 0x4404);
put_buffer(pb, 0, 8);
- //write track refs
+ // write track refs
if (mxf_generate_reference(s, &refs->track, s->nb_streams) < 0)
return -1;
mxf_write_local_tag(pb, s->nb_streams * 16 + 8, 0x4403);
mxf_write_reference(pb, s->nb_streams, refs->track);
- //every track have 1 sequence and 1 structural componet, malloc memory for the refs pointer
+ // every track have 1 sequence and 1 structural componet, malloc memory for the refs pointer
refs->sequence = av_mallocz(s->nb_streams * sizeof(*refs->sequence));
if (!refs->sequence)
return -1;
@@ -503,12 +500,12 @@ static int mxf_write_package(AVFormatCon
if (refs->structural_component)
return -1;
- //malloc memory for track number sign
+ // malloc memory for track number sign
mxf->track_number_sign = av_mallocz(sizeof(mxf_essence_element_key)/sizeof(MXFEssenceElementKey));
if (!mxf->track_number_sign)
return -1;
- //malloc memory for essence element key of each track
+ // malloc memory for essence element key of each track
mxf->track_essence_element_key = av_mallocz(s->nb_streams * sizeof(UID));
if (!mxf->track_essence_element_key)
return -1;
@@ -524,7 +521,6 @@ static int mxf_write_track(AVFormatConte
const MXFEssenceElementKey *element;
int i = 0;
- //write KLV
klv->key[13] = 0x01;
klv->key[14] = 0x3b;
klv->key[15] = 0x00;
@@ -534,49 +530,49 @@ static int mxf_write_track(AVFormatConte
st = s->streams[stream_index];
- //set pts information
+ // set pts information
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
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);
}
- //write track uid
+ // write track uid
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, refs->track[stream_index], 16);
- //write track id
+ // write track id
mxf_write_local_tag(pb, 4, 0x4801);
put_be32(pb, stream_index + 1);
if (type != MaterialPackage) {
for (element = mxf_essence_element_key; element->type != CODEC_ID_NONE; element++) {
if (st->codec->codec_id== element->type) {
- //write track number
+ // write track number
mxf_write_local_tag(pb, 4, 0x4804);
put_buffer(pb, element->uid + 12, 3);
put_byte(pb, element->uid[15] + mxf->track_number_sign[i]);
mxf->track_number_sign[i] ++;
- //set essence_element key
+ // set essence_element key
memcpy(mxf->track_essence_element_key[stream_index], element->uid, 16);
break;
}
i++;
}
} else {
- put_buffer(pb, 0, 4);//track number of material package is 0
+ put_buffer(pb, 0, 4); // track number of material package is 0
}
mxf_write_local_tag(pb, 8, 0x4B01);
put_be32(pb, st->time_base.num);
put_be32(pb, st->time_base.den);
- //write origin
+ // write origin
mxf_write_local_tag(pb, 8, 0x4B02);
put_be64(pb, 0);
- //write sequence refs
+ // write sequence refs
if (mxf_generate_reference(s, &refs->sequence[stream_index], 1) < 0)
return -1;
mxf_write_local_tag(pb, 16, 0x4803);
@@ -604,7 +600,7 @@ static int mxf_write_sequence(AVFormatCo
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, *refs->sequence[stream_index], 16);
- //find data define uls
+ // find data define uls
data_def_ul = mxf_get_data_definition_ul(mxf_data_definition_uls, st->codec->codec_type);
mxf_write_local_tag(pb, 16, 0x0201);
put_buffer(pb, data_def_ul->uid, 16);
@@ -612,7 +608,7 @@ static int mxf_write_sequence(AVFormatCo
mxf_write_local_tag(pb, 8, 0x0202);
put_be32(pb, st->duration);
- //write structural component
+ // write structural component
if (mxf_generate_reference(s, &refs->structural_component[stream_index], 1) < 0)
return -1;
mxf_write_local_tag(pb, 16 + 8, 0x1001);
@@ -636,7 +632,7 @@ static int mxf_write_structural_componen
st = s->streams[stream_index];
- //write uid
+ // write uid
mxf_write_local_tag(pb, 16, 0x3C0A);
put_buffer(pb, *refs->structural_component[stream_index], 16);
@@ -644,20 +640,20 @@ static int mxf_write_structural_componen
mxf_write_local_tag(pb, 16, 0x0201);
put_buffer(pb, data_def_ul->uid, 16);
- //write start_position
+ // write start_position
mxf_write_local_tag(pb, 8, 0x1201);
put_be64(pb, 0);
- //write duration
+ // write duration
mxf_write_local_tag(pb, 8, 0x0202);
put_be64(pb, st->duration);
if (type == SourcePackage) {
- //write source package uid, end of the reference
+ // write source package uid, end of the reference
mxf_write_local_tag(pb, 32, 0x1101);
put_buffer(pb, 0, 32);
- //write source track id
+ // write source track id
mxf_write_local_tag(pb, 4, 0x1102);
put_be64(pb, 0);
} else {
@@ -716,45 +712,45 @@ static int mxf_write_header_partition(AV
MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb;
int64_t header_metadata_start;
- //for op1a, only 1 essence container
+ // for op1a, only 1 essence container
uint64_t partitionLen = 88 + 16;
// generate Source Package Set UMID for op1a
// will be used by material_package->source_track->sequence->structual_component->source_package_id
mxf_generate_umid(s, mxf->top_src_package_uid);
- //write klv
+ // write klv
put_buffer(pb, header_partition_key, 16);
klv_encode_ber_length(pb, partitionLen);
- //write partition value
- put_be16(pb, 1);//majorVersion
- put_be16(pb, 2);//minorVersion
- put_be32(pb, 1);//kagSize
+ // write partition value
+ put_be16(pb, 1); // majorVersion
+ put_be16(pb, 2); // minorVersion
+ put_be32(pb, 1); // kagSize
- put_be64(pb, 0);//thisPartition
- put_be64(pb, 0);//previousPartition
+ put_be64(pb, 0); // thisPartition
+ put_be64(pb, 0); // previousPartition
- //set offset
+ // set offset
mxf->header_footer_partition_offset = url_ftell(pb);
- put_be64(pb, 0);//footerPartition,update later
+ put_be64(pb, 0); // footerPartition,update later
- //set offset
+ // set offset
mxf->header_byte_count_offset = url_ftell(pb);
- put_be64(pb, 0);//headerByteCount, update later
+ put_be64(pb, 0); // headerByteCount, update later
- //no indexTable
- put_be64(pb, 0);//indexByteCount
- put_be32(pb, 0);//indexSID
- put_be64(pb, 0);//bodyOffset
+ // no indexTable
+ put_be64(pb, 0); // indexByteCount
+ put_be32(pb, 0); // indexSID
+ put_be64(pb, 0); // bodyOffset
- put_be32(pb, 1);//bodySID
- put_buffer(pb, op1a_ul, 16);//operational pattern
+ put_be32(pb, 1); // bodySID
+ put_buffer(pb, op1a_ul, 16); // operational pattern
put_be32(pb,1);
put_be32(pb,16);
put_buffer(pb, mxf_picture_essence_container_uls->uid, 16);
- //mark the start of the headermetadata and calculate metadata size
+ // mark the start of the headermetadata and calculate metadata size
header_metadata_start = url_ftell(s->pb);
mxf_write_primer_pack(s);
if (mxf_write_header_metadata_sets < 0)
@@ -773,7 +769,7 @@ static int mux_write_header(AVFormatCont
ByteIOContext *pb = s->pb;
av_init_random(0xbeefdead, &mxf->random_state);
- //mark the header start position, for some fields update later
+ // mark the header start position, for some fields update later
mxf->header_start = url_ftell(pb);
mxf_write_header_partition(s);
@@ -786,9 +782,9 @@ static int mux_write_packet(AVFormatCont
MXFContext *mxf = s->priv_data;
ByteIOContext *pb = s->pb;
- put_buffer(pb, mxf->track_essence_element_key[pkt->stream_index], 16);//write key
- klv_encode_ber_length(pb, pkt->size);//write length
- put_buffer(pb, pkt->data, pkt->size);//write value
+ put_buffer(pb, mxf->track_essence_element_key[pkt->stream_index], 16); // write key
+ klv_encode_ber_length(pb, pkt->size); // write length
+ put_buffer(pb, pkt->data, pkt->size); // write value
put_flush_packet(pb);
return 0;
@@ -818,27 +814,25 @@ static int mux_write_footer(AVFormatCont
int64_t this_partition = url_ftell(pb) - mxf->header_start;
int64_t partitionLen = 88 + 16;
- //write klv
put_buffer(pb, footer_partition_key, 16);
klv_encode_ber_length(pb, partitionLen);
- //write partition value
- put_be16(pb, 1);//majorVersion
- put_be16(pb, 2);//minorVersion
- put_be32(pb, 1);//kagSize
+ put_be16(pb, 1); // majorVersion
+ put_be16(pb, 2); // minorVersion
+ put_be32(pb, 1); // kagSize
put_be64(pb, this_partition);
- put_be64(pb, 0);//previousPartition
+ put_be64(pb, 0); // previousPartition
put_be64(pb, this_partition);
- put_be64(pb, 0);//header byte count
+ put_be64(pb, 0); // header byte count
- //no indexTable
- put_be64(pb, 0);//indexByteCount
- put_be32(pb, 0);//indexSID
- put_be64(pb, 0);//bodyOffset
+ // no indexTable
+ put_be64(pb, 0); // indexByteCount
+ put_be32(pb, 0); // indexSID
+ put_be64(pb, 0); // bodyOffset
- put_be32(pb, 0);//bodySID
- put_buffer(pb, op1a_ul, 16);//operational pattern
+ put_be32(pb, 0); // bodySID
+ put_buffer(pb, op1a_ul, 16); // operational pattern
put_be32(pb,1);
put_be32(pb,16);
put_buffer(pb, mxf_picture_essence_container_uls->uid, 16);
More information about the FFmpeg-soc
mailing list