[FFmpeg-soc] MXF muxer version 0.0.2
Michael Niedermayer
michaelni at gmx.at
Sat Aug 16 21:47:42 CEST 2008
On Sat, Aug 16, 2008 at 10:50:12PM +0800, zhentan feng wrote:
> Hi,
> Here is the new version patch against FFmpeg trunk.
> modify code according to 0.0.1 patch reviews.
>
> thanks
> --
> Best wishes~
> Index: libavformat/mxfenc.c
> ===================================================================
> --- libavformat/mxfenc.c (revision 14787)
> +++ libavformat/mxfenc.c (working copy)
> @@ -31,9 +31,182 @@
>
> //#define DEBUG
>
> +#include "mxf.h"
> +
> +typedef uint8_t UMID[32];
> +
> +typedef struct {
> + int local_tag;
> + UID uid;
> +} MXFLocalTagPair;
ok
> +
> +typedef struct {
> + UID track_essence_element_key;
unused
> +} MXFStreamContext;
> +
[...]
> +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 };
ok
> +
> +/**
> + * complete key for operation pattern, partitions, and primer pack
> + */
> +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 primer_pack_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x05,0x01,0x00 };
ok
[...]
> +static void mxf_generate_uuid(AVFormatContext *s, UID uuid)
> +{
> + MXFContext *mxf = s->priv_data;
> + int i;
> +
> + for (i = 0; i < 16; i++) {
> + mxf->random_state= mxf->random_state*1664525+10139042;
> + uuid[i]= mxf->random_state>>24;
> + }
> + // the 7th byte is version according to ISO 11578
> + uuid[6] &= 0x0f;
> + uuid[6] |= 0x40;
> +
> + // the 8th byte is variant for current use according to ISO 11578
> + uuid[8] &= 0x3f;
> + uuid[8] |= 0x80;
> +}
> +
> +static void mxf_generate_umid(AVFormatContext *s, UMID umid)
> +{
> + memcpy(umid, umid_base, 16);
> + mxf_generate_uuid(s, umid + 16);
> +}
The remaining uses of these 2 functions can also be replaced by
mxf_write_uuid()
> +
> +static void mxf_write_uuid(ByteIOContext *pb, enum CodecID type, int value)
> +{
> + put_buffer(pb, uuid_base, 12);
> + put_be16(pb, type);
> + put_be16(pb, value);
> +}
ok
[...]
> +static int klv_encode_ber_length(ByteIOContext *pb, uint64_t len)
> +{
> + // Determine the best BER size
> + int size;
> + if (len < 128) {
> + //short form
> + put_byte(pb, len);
> + return 1;
> + }
> +
> + size = (av_log2(len) >> 3) + 1;
> +
> + // long form
> + put_byte(pb, 0x80 + size);
> + while(size) {
> + size --;
> + put_byte(pb, len >> 8 * size & 0xff);
> + }
> + return 0;
> +}
> +
> static const MXFCodecUL *mxf_get_essence_container_ul(enum CodecID type)
> {
> - const MXFCodecUL *uls = mxf_essence_container_uls;
> + const MXFCodecUL *uls = ff_mxf_essence_container_uls;
> while (uls->id != CODEC_ID_NONE) {
> if (uls->id == type)
> break;
> @@ -42,29 +215,48 @@
> return uls;
> }
>
> +static int mxf_write_primer_pack(AVFormatContext *s)
> +{
> + ByteIOContext *pb = s->pb;
> + int local_tag_number, i = 0;
> +
> + local_tag_number = sizeof(mxf_local_tag_batch) / sizeof(MXFLocalTagPair);
> +
> + put_buffer(pb, primer_pack_key, 16);
> + klv_encode_ber_length(pb, local_tag_number * 18 + 8);
> +
> + put_be32(pb, local_tag_number); // local_tag num
> + put_be32(pb, 18); // item size, always 18 according to the specs
> +
> + for (i = 0; i < local_tag_number; i++) {
> + put_be16(pb, mxf_local_tag_batch[i].local_tag);
> + put_buffer(pb, mxf_local_tag_batch[i].uid, 16);
> + }
> + return 0;
> +}
> +
> +static void mxf_write_local_tag(ByteIOContext *pb, int value_size, int tag)
> +{
> + put_be16(pb, tag);
> + put_be16(pb, value_size);
> +}
> +
> static void mxf_free(AVFormatContext *s)
> {
> MXFContext *mxf = s->priv_data;
> AVStream *st;
> int i;
>
> - av_freep(&mxf->reference.identification);
> - av_freep(mxf->reference.package);
> - av_freep(&mxf->reference.package);
> - av_freep(&mxf->reference.content_storage);
> for (i = 0; i < s->nb_streams; i++) {
> st = s->streams[i];
> av_freep(&st->priv_data);
> }
> - av_freep(mxf->reference.sub_desc);
> - av_freep(&mxf->reference.sub_desc);
> - av_freep(&mxf->reference.mul_desc);
> av_freep(&mxf->essence_container_uls);
> }
>
> static const MXFDataDefinitionUL *mxf_get_data_definition_ul(enum CodecType type)
> {
> - const MXFDataDefinitionUL *uls = mxf_data_definition_uls;
> + const MXFDataDefinitionUL *uls = ff_mxf_data_definition_uls;
> while (uls->type != CODEC_TYPE_DATA) {
> if (type == uls->type)
> break;
ok
> @@ -73,6 +265,657 @@
> return uls;
> }
>
> +static int mxf_write_preface(AVFormatContext *s, KLVPacket *klv)
> +{
> + MXFContext *mxf = s->priv_data;
> + ByteIOContext *pb = s->pb;
> +
> + AV_WB24(klv->key + 13, 0x012f00);
> +
> + put_buffer(pb, klv->key, 16);
put_buffer(pb, header_metadata_key, 13);
put_be24(pb, 0x012f00);
similarly for the other functions, this also makes passing "KLVPacket *klv"
into each function unneeded
[...]
> +static int mxf_write_track(AVFormatContext *s, KLVPacket *klv, int stream_index, enum MXFMetadataSetType type)
> +{
> + ByteIOContext *pb = s->pb;
> + AVStream *st;
> + MXFStreamContext *sc;
> + const MXFCodecUL *element;
> + int i = 0;
> + int track_number_sign[sizeof(mxf_essence_element_key)/sizeof(MXFCodecUL)] = { 0 };
> +
> + AV_WB24(klv->key + 13, 0x013b00);
> +
> + put_buffer(pb, klv->key, 16);
> + klv_encode_ber_length(pb, 80);
> +
> + st = s->streams[stream_index];
> + sc = st->priv_data;
> +
> + // write track uid
> + mxf_write_local_tag(pb, 16, 0x3C0A);
> + mxf_write_uuid(pb, Track * type, stream_index);
> +#ifdef DEBUG
> + PRINT_KEY(s, "track key", klv->key);
> + PRINT_KEY(s, "track uid", pb->buf_ptr - 16);
> +#endif
> + // write track id
> + mxf_write_local_tag(pb, 4, 0x4801);
> + put_be32(pb, stream_index);
> +
> + mxf_write_local_tag(pb, 4, 0x4804);
> + if (type != MaterialPackage) {
> + for (element = mxf_essence_element_key; element->id != CODEC_ID_NONE; element++) {
> + if (st->codec->codec_id== element->id) {
> + // write track number
> + put_buffer(pb, element->uid + 12, 3);
> + put_byte(pb, element->uid[15] + track_number_sign[i]);
track_number_sign will always be 0 here, i suspect this is not intended ...
[...]
> + if (type == SourcePackage) {
> + // write source package uid, end of the reference
> + mxf_write_local_tag(pb, 32, 0x1101);
[...]
> + } else {
> + mxf_write_local_tag(pb, 32, 0x1101);
can be factored out
[...]
> +static int mxf_write_mpeg_video_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index)
> +{
> + ByteIOContext *pb = s->pb;
> + AVStream *st;
> +
> + st = s->streams[stream_index];
> +
> + put_buffer(pb, desc_tbl->key, 16);
> + klv_encode_ber_length(pb, 96);
> +
> + mxf_write_local_tag(pb, 16, 0x3C0A);
> + mxf_write_uuid(pb, SubDescriptor, stream_index);
> +
> + mxf_write_local_tag(pb, 4, 0x3006);
> + put_be32(pb, stream_index);
[...]
> +static int mxf_write_wav_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index)
> +{
> + ByteIOContext *pb = s->pb;
> + AVStream *st;
> +
> + st = s->streams[stream_index];
> +
> + put_buffer(pb, desc_tbl->key, 16);
> + klv_encode_ber_length(pb, 96);
> +
> + mxf_write_local_tag(pb, 16, 0x3C0A);
> + mxf_write_uuid(pb, SubDescriptor, stream_index);
> +
> + mxf_write_local_tag(pb, 4, 0x3006);
> + put_be32(pb, stream_index);
duplicate
[...]
> + for (i = 0; i < s->nb_streams; i++) {
> + sc = s->streams[i]->priv_data;
> + }
> + return ret;
the loop does nothing
[...]
> +static int mxf_add_essence_container_ul(MXFContext *mxf, const MXFCodecUL *codec_ul)
> +{
> + mxf->essence_container_uls = av_realloc(mxf->essence_container_uls, (mxf->essence_container_count + 1) * 16);
> + if (!mxf->essence_container_uls)
> + return AVERROR(ENOMEM);
> + memcpy(mxf->essence_container_uls[mxf->essence_container_count], codec_ul->uid, 16);
> + mxf->essence_container_count++;
> + return mxf->essence_container_count;
> +}
> +
> +static int mxf_build_essence_container_refs(AVFormatContext *s)
> +{
> + MXFContext *mxf = s->priv_data;
> + AVStream *st;
> + int i;
> + const MXFCodecUL *codec_ul = NULL;
> +
> + for (codec_ul = ff_mxf_essence_container_uls; codec_ul->id; codec_ul++) {
> + for (i = 0; i < s->nb_streams; i++) {
> + st = s->streams[i];
> + if (st->codec->codec_id == codec_ul->id) {
> + if (mxf_add_essence_container_ul(mxf, codec_ul) < 0 )
> + return -1;
this should be put_buffer() and
mxf_build_essence_container_refs should be called when the list needs
to be stored.
[...]
> @@ -87,6 +930,41 @@
> return 0;
> }
>
> +static int mxf_update_header_partition(AVFormatContext *s, int64_t footer_partition_offset)
> +{
> + MXFContext *mxf = s->priv_data;
> + ByteIOContext *pb = s->pb;
> +
> + if (!url_is_streamed(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);
> + } else {
> + av_log(s, AV_LOG_ERROR, "update header partition failed, non streamble out put\n");
> + return -1;
> + }
we should support streamed files, not fail for them. I belive the footer
partition is optional and when there is none also no pointer needs to point
to one.
> + return 0;
> +}
> +
> +
> +static int mux_write_footer(AVFormatContext *s)
> +{
> + ByteIOContext *pb = s->pb;
> +
> + int64_t this_partition = url_ftell(pb);
please rename this variable as well
[...]
> Index: libavformat/mxfdec.c
> ===================================================================
> --- libavformat/mxfdec.c (revision 14787)
> +++ libavformat/mxfdec.c (working copy)
> @@ -46,24 +46,8 @@
> //#define DEBUG
>
> #include "libavutil/aes.h"
> -#include "libavcodec/bytestream.h"
> -#include "avformat.h"
> +#include "mxf.h"
>
> -typedef uint8_t UID[16];
> -
> -enum MXFMetadataSetType {
> - AnyType,
> - MaterialPackage,
> - SourcePackage,
> - SourceClip,
> - TimecodeComponent,
> - Sequence,
> - MultipleDescriptor,
> - Descriptor,
> - Track,
> - CryptoContext,
> -};
> -
> typedef struct {
> UID uid;
> enum MXFMetadataSetType type;
> @@ -143,29 +127,12 @@
> int local_tags_count;
> } MXFContext;
>
> -typedef struct {
> - UID key;
> - offset_t offset;
> - uint64_t length;
> -} KLVPacket;
> -
> enum MXFWrappingScheme {
> Frame,
> Clip,
> };
>
> typedef struct {
> - UID uid;
> - unsigned matching_len;
> - enum CodecID id;
> -} MXFCodecUL;
> -
> -typedef struct {
> - UID uid;
> - enum CodecType type;
> -} MXFDataDefinitionUL;
> -
> -typedef struct {
> const UID key;
> int (*read)();
> int ctx_size;
> @@ -184,9 +151,6 @@
>
> #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
>
> -#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, \
> - (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15])
> -
> static int64_t klv_decode_ber_length(ByteIOContext *pb)
> {
> uint64_t size = get_byte(pb);
> @@ -619,48 +583,6 @@
> return 0;
> }
>
> -/* SMPTE RP224 http://www.smpte-ra.org/mdd/index.html */
> -static const MXFDataDefinitionUL mxf_data_definition_uls[] = {
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x01,0x00,0x00,0x00 }, CODEC_TYPE_VIDEO },
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x02,0x00,0x00,0x00 }, CODEC_TYPE_AUDIO },
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x05,0x01,0x03,0x02,0x02,0x02,0x02,0x00,0x00 }, CODEC_TYPE_AUDIO },
> - { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, CODEC_TYPE_DATA },
> -};
> -
> -static const MXFCodecUL mxf_codec_uls[] = {
> - /* PictureEssenceCoding */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP at ML Long GoP */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* D-10 50Mbps PAL */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP at HL Long GoP */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* 422P at HL I-Frame */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x03 }, 14, CODEC_ID_MPEG4 }, /* XDCAM proxy_pal030926.mxf */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, 13, CODEC_ID_DVVIDEO }, /* DV25 IEC PAL */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, CODEC_ID_JPEG2000 }, /* JPEG2000 Codestream */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_RAWVIDEO }, /* Uncompressed */
> - /* SoundEssenceCompression */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE }, /* Uncompressed */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE },
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x02,0x02,0x01,0x7E,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16BE }, /* From Omneon MXF file */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x04,0x04,0x02,0x02,0x02,0x03,0x01,0x01,0x00 }, 15, CODEC_ID_PCM_ALAW }, /* XDCAM Proxy C0023S01.mxf */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, CODEC_ID_AC3 },
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, CODEC_ID_MP2 }, /* MP2 or MP3 */
> - //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */
> - { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE },
> -};
> -
> -static const MXFCodecUL mxf_picture_essence_container_uls[] = {
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Frame wrapped */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14, CODEC_ID_DVVIDEO }, /* DV 625 25mbps */
> - { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE },
> -};
> -
> -static const MXFCodecUL mxf_sound_essence_container_uls[] = {
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */
> - { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */
> - { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE },
> -};
> -
> /*
> * Match an uid independently of the version byte and up to len common bytes
> * Returns: boolean
> @@ -807,7 +729,7 @@
> #ifdef DEBUG
> PRINT_KEY(mxf->fc, "data definition ul", source_track->sequence->data_definition_ul);
> #endif
> - st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
> + st->codec->codec_type = mxf_get_codec_type(ff_mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
>
> source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref, AnyType);
> if (source_package->descriptor) {
> @@ -849,14 +771,14 @@
> }
> }
> /* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */
> - codec_ul = mxf_get_codec_ul(mxf_codec_uls, &descriptor->essence_codec_ul);
> + codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->essence_codec_ul);
> st->codec->codec_id = codec_ul->id;
> if (descriptor->extradata) {
> st->codec->extradata = descriptor->extradata;
> st->codec->extradata_size = descriptor->extradata_size;
> }
> if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
> - container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
> + container_ul = mxf_get_codec_ul(ff_mxf_essence_container_uls, essence_container_ul);
> if (st->codec->codec_id == CODEC_ID_NONE)
> st->codec->codec_id = container_ul->id;
> st->codec->width = descriptor->width;
> @@ -864,7 +786,7 @@
> st->codec->bits_per_sample = descriptor->bits_per_sample; /* Uncompressed */
> st->need_parsing = AVSTREAM_PARSE_HEADERS;
> } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
> - container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
> + container_ul = mxf_get_codec_ul(ff_mxf_essence_container_uls, essence_container_ul);
> if (st->codec->codec_id == CODEC_ID_NONE)
> st->codec->codec_id = container_ul->id;
> st->codec->channels = descriptor->channels;
ok
> Index: libavformat/mxf.c
> ===================================================================
> --- libavformat/mxf.c (revision 0)
> +++ libavformat/mxf.c (revision 0)
> @@ -0,0 +1,66 @@
> +/*
> + * MXF
> + * Copyright (c) 2008 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * SMPTE RP224 http://www.smpte-ra.org/mdd/index.html
> + */
> +
> +#include "mxf.h"
> +
> +const MXFDataDefinitionUL ff_mxf_data_definition_uls[] = {
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x01,0x00,0x00,0x00 }, CODEC_TYPE_VIDEO },
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x01,0x03,0x02,0x02,0x02,0x00,0x00,0x00 }, CODEC_TYPE_AUDIO },
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x05,0x01,0x03,0x02,0x02,0x02,0x02,0x00,0x00 }, CODEC_TYPE_AUDIO },
> + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, CODEC_TYPE_DATA },
> +};
> +
> +const MXFCodecUL ff_mxf_codec_uls[] = {
> + /* PictureEssenceCoding */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP at ML Long GoP */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* D-10 50Mbps PAL */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP at HL Long GoP */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* 422P at HL I-Frame */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x03 }, 14, CODEC_ID_MPEG4 }, /* XDCAM proxy_pal030926.mxf */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, 13, CODEC_ID_DVVIDEO }, /* DV25 IEC PAL */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, CODEC_ID_JPEG2000 }, /* JPEG2000 Codestream */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_RAWVIDEO }, /* Uncompressed */
> + /* SoundEssenceCompression */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE }, /* Uncompressed */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE },
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x02,0x02,0x01,0x7E,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16BE }, /* From Omneon MXF file */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x04,0x04,0x02,0x02,0x02,0x03,0x01,0x01,0x00 }, 15, CODEC_ID_PCM_ALAW }, /* XDCAM Proxy C0023S01.mxf */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, CODEC_ID_AC3 },
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, CODEC_ID_MP2 }, /* MP2 or MP3 */
> + //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */
> + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE },
> +};
> +
> +const MXFCodecUL ff_mxf_essence_container_uls[] = {
> + // video essence container uls
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Frame wrapped */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14, CODEC_ID_DVVIDEO }, /* DV 625 25mbps */
> + // sound essence container uls
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */
> + { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */
> + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE },
> +};
> +
ok (with svn cp)
[...]
> Index: libavformat/mxf.h
> ===================================================================
> --- libavformat/mxf.h (revision 0)
> +++ libavformat/mxf.h (revision 0)
> @@ -0,0 +1,70 @@
> +/*
> + * MXF
> + * Copyright (c) 2008 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +#ifndef FFMPEG_MXF_H
> +#define FFMPEG_MXF_H
> +
> +#include "avformat.h"
> +#include "libavcodec/bytestream.h"
> +
> +typedef uint8_t UID[16];
> +
> +enum MXFMetadataSetType {
> + AnyType,
> + MaterialPackage,
> + SourcePackage,
> + SourceClip,
> + TimecodeComponent,
> + Sequence,
> + MultipleDescriptor,
> + Descriptor,
> + Track,
> + CryptoContext,
> + Preface,
> + Identification,
> + ContentStorage,
> + SubDescriptor,
> +};
> +
> +typedef struct {
> + UID key;
> + offset_t offset;
> + uint64_t length;
> +} KLVPacket;
> +
> +typedef struct {
> + UID uid;
> + unsigned matching_len;
> + enum CodecID id;
> +} MXFCodecUL;
> +
> +typedef struct {
> + UID uid;
> + enum CodecType type;
> +} MXFDataDefinitionUL;
> +
> +extern const MXFDataDefinitionUL ff_mxf_data_definition_uls[];
> +extern const MXFCodecUL ff_mxf_codec_uls[];
> +extern const MXFCodecUL ff_mxf_essence_container_uls[];
> +
> +#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, \
> + (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15])
> +
> +#endif /* FFMPEG_MXF_H */
ok (with svn cp ...)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080816/5a8d3ab7/attachment.pgp>
More information about the FFmpeg-soc
mailing list