[FFmpeg-cvslog] r14839 - trunk/libavformat/mxfenc.c
cehoyos
subversion
Tue Aug 19 14:36:18 CEST 2008
Author: cehoyos
Date: Tue Aug 19 14:36:17 2008
New Revision: 14839
Log:
Ok-ed parts from patch by zhentan feng.
Modified:
trunk/libavformat/mxfenc.c
Modified: trunk/libavformat/mxfenc.c
==============================================================================
--- trunk/libavformat/mxfenc.c (original)
+++ trunk/libavformat/mxfenc.c Tue Aug 19 14:36:17 2008
@@ -38,6 +38,16 @@ typedef struct {
UID uid;
} MXFLocalTagPair;
+typedef struct {
+ UID track_essence_element_key;
+} MXFStreamContext;
+
+typedef struct MXFContext {
+ int64_t header_byte_count;
+ int64_t header_byte_count_offset;
+ int64_t header_footer_partition_offset;
+ int essence_container_count;
+} MXFContext;
static const uint8_t uuid_base[] = { 0xAD,0xAB,0x44,0x24,0x2f,0x25,0x4d,0xc7,0x92,0xff,0x29,0xbd };
static const uint8_t umid_base[] = { 0x06,0x0A,0x2B,0x34,0x01,0x01,0x01,0x01,0x01,0x01,0x0F,0x00,0x13,0x00,0x00,0x00 };
@@ -56,6 +66,11 @@ static void mxf_write_uuid(ByteIOContext
put_be16(pb, value);
}
+static void mxf_write_umid(ByteIOContext *pb, enum CodecID type, int value)
+{
+ put_buffer(pb, umid_base, 16);
+ mxf_write_uuid(pb, type, value);
+}
static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)
{
// Determine the best BER size
@@ -114,9 +129,14 @@ static void mxf_write_local_tag(ByteIOCo
put_be16(pb, value_size);
}
+static void mxf_write_metadata_key(ByteIOContext *pb, unsigned int value)
+{
+ put_buffer(pb, header_metadata_key, 13);
+ put_be24(pb, value);
+}
+
static void mxf_free(AVFormatContext *s)
{
- MXFContext *mxf = s->priv_data;
AVStream *st;
int i;
@@ -124,7 +144,6 @@ static void mxf_free(AVFormatContext *s)
st = s->streams[i];
av_freep(&st->priv_data);
}
- av_freep(&mxf->essence_container_uls);
}
static const MXFDataDefinitionUL *mxf_get_data_definition_ul(enum CodecType type)
@@ -152,6 +171,56 @@ static int mux_write_packet(AVFormatCont
return 0;
}
+static int mxf_write_header_metadata_sets(AVFormatContext *s)
+{
+ AVStream *st;
+ MXFStreamContext *sc = NULL;
+ int i;
+ if (mxf_write_preface(s) < 0)
+ return -1;
+
+ if (mxf_write_identification(s) < 0)
+ return -1;
+
+ if (mxf_write_content_storage(s) < 0)
+ return -1;
+
+ for (i = 0; i < s->nb_streams; i++) {
+ st = s->streams[i];
+ sc = av_mallocz(sizeof(MXFStreamContext));
+ if (!sc)
+ return AVERROR(ENOMEM);
+ st->priv_data = sc;
+ // 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);
+ }
+ }
+
+ if (mxf_build_structural_metadata(s, MaterialPackage) < 0)
+ return -1;
+
+ if (mxf_build_structural_metadata(s, SourcePackage) < 0)
+ return -1;
+ return 0;
+}
+
+static int mxf_update_header_partition(AVFormatContext *s, int64_t footer_partition_offset)
+{
+ MXFContext *mxf = s->priv_data;
+ ByteIOContext *pb = s->pb;
+
+ url_fseek(pb, mxf->header_byte_count_offset, SEEK_SET);
+ put_be64(pb, mxf->header_byte_count);
+ put_flush_packet(pb);
+
+ url_fseek(pb, mxf->header_footer_partition_offset, SEEK_SET);
+ put_be64(pb, footer_partition_offset);
+ put_flush_packet(pb);
+ return 0;
+}
AVOutputFormat mxf_muxer = {
"mxf",
NULL_IF_CONFIG_SMALL("Material eXchange Format"),
More information about the ffmpeg-cvslog
mailing list