+ mxf_write_essence_container_refs(s);
+
+ if (write_metadata) {
+ // mark the start of the headermetadata and calculate metadata size
+ int64_t pos, start = url_ftell(s->pb);
+ mxf_write_primer_pack(s);
+ mxf_write_header_metadata_sets(s);
+ pos = url_ftell(s->pb);
+ // update header_byte_count
+ url_fseek(pb, header_byte_count_offset, SEEK_SET);
+ put_be64(pb, pos - start);
+ url_fseek(pb, pos, SEEK_SET);
+ }
+
+ put_flush_packet(pb);
+}
+
+static const UID mxf_mpeg2_codec_uls[] = {
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x10,0x00 }, // MP-ML I-Frame
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, // MP-ML Long GOP
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x02,0x02,0x00 }, // 422P-ML I-Frame
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x02,0x03,0x00 }, // 422P-ML Long GOP
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x02,0x00 }, // MP-HL I-Frame
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, // MP-HL Long GOP
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, // 422P-HL I-Frame
+ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x03,0x00 }, // 422P-HL Long GOP
+};
+
+static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx)
+{
+ if (avctx->profile == 4) { // Main
+ if (avctx->level == 8) // Main
+ return avctx->gop_size ?
+ &mxf_mpeg2_codec_uls[1] :
+ &mxf_mpeg2_codec_uls[0];
+ else if (avctx->level == 4) // High
+ return avctx->gop_size ?
+ &mxf_mpeg2_codec_uls[5] :
+ &mxf_mpeg2_codec_uls[4];
+ } else if (avctx->profile == 0) { // 422
+ if (avctx->level == 5) // Main
+ return avctx->gop_size ?
+ &mxf_mpeg2_codec_uls[3] :
+ &mxf_mpeg2_codec_uls[2];
+ else if (avctx->level == 2) // High
+ return avctx->gop_size ?
+ &mxf_mpeg2_codec_uls[7] :
+ &mxf_mpeg2_codec_uls[6];
+ }
+ return NULL;