comparison mxfenc.c @ 3817:22831cc65a35 libavformat

get essence container ul in header and set it per track, check for unsupported codec
author bcoudurier
date Sat, 30 Aug 2008 23:54:24 +0000
parents 50bdbde13ecf
children ae0d01b63679
comparison
equal deleted inserted replaced
3816:50bdbde13ecf 3817:22831cc65a35
38 UID uid; 38 UID uid;
39 } MXFLocalTagPair; 39 } MXFLocalTagPair;
40 40
41 typedef struct { 41 typedef struct {
42 UID track_essence_element_key; 42 UID track_essence_element_key;
43 const UID *essence_container_ul;
43 } MXFStreamContext; 44 } MXFStreamContext;
44 45
45 typedef struct MXFContext { 46 typedef struct MXFContext {
46 int64_t header_byte_count; 47 int64_t header_byte_count;
47 int64_t header_byte_count_offset; 48 int64_t header_byte_count_offset;
179 put_byte(pb, len >> 8 * size & 0xff); 180 put_byte(pb, len >> 8 * size & 0xff);
180 } 181 }
181 return 0; 182 return 0;
182 } 183 }
183 184
184 static const MXFCodecUL *mxf_get_essence_container_ul(enum CodecID type) 185 static const UID *mxf_get_essence_container_ul(enum CodecID type)
185 { 186 {
186 const MXFCodecUL *uls = ff_mxf_essence_container_uls; 187 const MXFCodecUL *uls = ff_mxf_essence_container_uls;
187 while (uls->id != CODEC_ID_NONE) { 188 while (uls->id != CODEC_ID_NONE) {
188 if (uls->id == type) 189 if (uls->id == type)
189 break; 190 return &uls->uid;
190 uls++; 191 uls++;
191 } 192 }
192 return uls; 193 return NULL;
193 } 194 }
194 195
195 static void mxf_write_primer_pack(AVFormatContext *s) 196 static void mxf_write_primer_pack(AVFormatContext *s)
196 { 197 {
197 ByteIOContext *pb = s->pb; 198 ByteIOContext *pb = s->pb;
599 mxf_write_uuid(pb, SubDescriptor, i); 600 mxf_write_uuid(pb, SubDescriptor, i);
600 } 601 }
601 602
602 static void mxf_write_generic_desc(ByteIOContext *pb, const MXFDescriptorWriteTableEntry *desc_tbl, AVStream *st) 603 static void mxf_write_generic_desc(ByteIOContext *pb, const MXFDescriptorWriteTableEntry *desc_tbl, AVStream *st)
603 { 604 {
604 const MXFCodecUL *codec_ul; 605 MXFStreamContext *sc = st->priv_data;
605 606
606 put_buffer(pb, desc_tbl->key, 16); 607 put_buffer(pb, desc_tbl->key, 16);
607 klv_encode_ber_length(pb, 108); 608 klv_encode_ber_length(pb, 108);
608 609
609 mxf_write_local_tag(pb, 16, 0x3C0A); 610 mxf_write_local_tag(pb, 16, 0x3C0A);
614 615
615 mxf_write_local_tag(pb, 8, 0x3001); 616 mxf_write_local_tag(pb, 8, 0x3001);
616 put_be32(pb, st->time_base.den); 617 put_be32(pb, st->time_base.den);
617 put_be32(pb, st->time_base.num); 618 put_be32(pb, st->time_base.num);
618 619
619 codec_ul = mxf_get_essence_container_ul(st->codec->codec_id);
620 mxf_write_local_tag(pb, 16, 0x3004); 620 mxf_write_local_tag(pb, 16, 0x3004);
621 put_buffer(pb, codec_ul->uid, 16); 621 put_buffer(pb, *sc->essence_container_ul, 16);
622 } 622 }
623 623
624 static void mxf_write_mpegvideo_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index) 624 static void mxf_write_mpegvideo_desc(AVFormatContext *s, const MXFDescriptorWriteTableEntry *desc_tbl, int stream_index)
625 { 625 {
626 ByteIOContext *pb = s->pb; 626 ByteIOContext *pb = s->pb;
767 // set pts information 767 // set pts information
768 if (st->codec->codec_type == CODEC_TYPE_VIDEO) 768 if (st->codec->codec_type == CODEC_TYPE_VIDEO)
769 av_set_pts_info(st, 64, 1, st->codec->time_base.den); 769 av_set_pts_info(st, 64, 1, st->codec->time_base.den);
770 else if (st->codec->codec_type == CODEC_TYPE_AUDIO) 770 else if (st->codec->codec_type == CODEC_TYPE_AUDIO)
771 av_set_pts_info(st, 64, 1, st->codec->sample_rate); 771 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
772 sc->essence_container_ul = mxf_get_essence_container_ul(st->codec->codec_id);
773 if (!sc->essence_container_ul) {
774 av_log(s, AV_LOG_ERROR, "track %d: could not find essence container ul, "
775 "codec not currently supported in container\n", i);
776 return -1;
777 }
772 } 778 }
773 779
774 mxf_write_partition(s, 0, 1, header_partition_key); 780 mxf_write_partition(s, 0, 1, header_partition_key);
775 781
776 // mark the start of the headermetadata and calculate metadata size 782 // mark the start of the headermetadata and calculate metadata size