Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
Hey Carl, On Wed, Aug 22, 2018 at 12:00 PM, Carl Eugen Hoyos wrote: > 2018-07-06 19:17 GMT+02:00, Carl Eugen Hoyos : > > 2018-07-04 20:35 GMT+02:00, Baptiste Coudurier > > : > >> --- > >> libavformat/mxfenc.c | 80 +--- > >> 1 file changed, 39 insertions(+), 41 deletions(-) > > > > Does any of the patches fix ticket #6693? > > Ping? > > Or #6781? I haven't tested, so I don't know. -- Baptiste ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
2018-07-06 19:17 GMT+02:00, Carl Eugen Hoyos : > 2018-07-04 20:35 GMT+02:00, Baptiste Coudurier > : >> --- >> libavformat/mxfenc.c | 80 +--- >> 1 file changed, 39 insertions(+), 41 deletions(-) > > Does any of the patches fix ticket #6693? Ping? Or #6781? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
On Wed, Jul 4, 2018 at 6:21 PM, Michael Niedermayer wrote: > On Wed, Jul 04, 2018 at 11:35:03AM -0700, Baptiste Coudurier wrote: > > --- > > libavformat/mxfenc.c | 80 +--- > > 1 file changed, 39 insertions(+), 41 deletions(-) > > > > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c > > index 77f60f5874..b98d234f03 100644 > > --- a/libavformat/mxfenc.c > > +++ b/libavformat/mxfenc.c > > @@ -1104,14 +1104,16 @@ static void > > mxf_write_multi_descriptor(AVFormatContext > *s) > > mxf_write_uuid(pb, SubDescriptor, i); > > } > > > > -static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, > const UID key, unsigned size) > > +static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream > *st, const UID key) > > { > > MXFContext *mxf = s->priv_data; > > MXFStreamContext *sc = st->priv_data; > > AVIOContext *pb = s->pb; > > +int64_t pos; > > > > avio_write(pb, key, 16); > > -klv_encode_ber4_length(pb, size+20+8+12+20); > > +klv_encode_ber4_length(pb, 0); > > +pos = avio_tell(pb); > > > > mxf_write_local_tag(pb, 16, 0x3C0A); > > mxf_write_uuid(pb, SubDescriptor, st->index); > > @@ -1136,6 +1138,8 @@ static void mxf_write_generic_desc(AVFormatContext > *s, AVStream *st, const UID k > > > > mxf_write_local_tag(pb, 16, 0x3004); > > avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, > 16); > > + > > +return pos; > > } > > > > static const UID mxf_mpegvideo_descriptor_key = { > 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 > }; > > @@ -1172,7 +1176,7 @@ static int get_trc(UID ul, enum > AVColorTransferCharacteristic trc) > > } > > } > > > > -static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, > const UID key, unsigned size) > > +static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, > const UID key) > > { > > MXFStreamContext *sc = st->priv_data; > > AVIOContext *pb = s->pb; > > @@ -1180,25 +1184,10 @@ static void mxf_write_cdci_common(AVFormatContext > *s, AVStream *st, const UID ke > > int stored_height = (st->codecpar->height+15)/16*16; > > int display_height; > > int f1, f2; > > -unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6; > > UID transfer_ul = {0}; > > +int64_t pos = mxf_write_generic_desc(s, st, key); > > > > -if (sc->interlaced && sc->field_dominance) > > -desc_size += 5; > > -if (sc->signal_standard) > > -desc_size += 5; > > -if (sc->interlaced) > > -desc_size += 8; > > -if (sc->v_chroma_sub_sample) > > -desc_size += 8; > > -if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) > > -desc_size += 8 * 3; > > -if (s->oformat == &ff_mxf_d10_muxer) > > -desc_size += 8 + 8 + 8; > > -if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0) > > -desc_size += 20; > > - > > -mxf_write_generic_desc(s, st, key, desc_size); > > +get_trc(transfer_ul, st->codecpar->color_trc); > > nice simplification! > Applied. -- Baptiste ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
2018-07-04 20:35 GMT+02:00, Baptiste Coudurier : > --- > libavformat/mxfenc.c | 80 +--- > 1 file changed, 39 insertions(+), 41 deletions(-) Does any of the patches fix ticket #6693? Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
On Wed, Jul 04, 2018 at 11:35:03AM -0700, Baptiste Coudurier wrote: > --- > libavformat/mxfenc.c | 80 +--- > 1 file changed, 39 insertions(+), 41 deletions(-) > > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c > index 77f60f5874..b98d234f03 100644 > --- a/libavformat/mxfenc.c > +++ b/libavformat/mxfenc.c > @@ -1104,14 +1104,16 @@ static void > mxf_write_multi_descriptor(AVFormatContext *s) > mxf_write_uuid(pb, SubDescriptor, i); > } > > -static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const > UID key, unsigned size) > +static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream *st, > const UID key) > { > MXFContext *mxf = s->priv_data; > MXFStreamContext *sc = st->priv_data; > AVIOContext *pb = s->pb; > +int64_t pos; > > avio_write(pb, key, 16); > -klv_encode_ber4_length(pb, size+20+8+12+20); > +klv_encode_ber4_length(pb, 0); > +pos = avio_tell(pb); > > mxf_write_local_tag(pb, 16, 0x3C0A); > mxf_write_uuid(pb, SubDescriptor, st->index); > @@ -1136,6 +1138,8 @@ static void mxf_write_generic_desc(AVFormatContext *s, > AVStream *st, const UID k > > mxf_write_local_tag(pb, 16, 0x3004); > avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16); > + > +return pos; > } > > static const UID mxf_mpegvideo_descriptor_key = { > 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 > }; > @@ -1172,7 +1176,7 @@ static int get_trc(UID ul, enum > AVColorTransferCharacteristic trc) > } > } > > -static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const > UID key, unsigned size) > +static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const > UID key) > { > MXFStreamContext *sc = st->priv_data; > AVIOContext *pb = s->pb; > @@ -1180,25 +1184,10 @@ static void mxf_write_cdci_common(AVFormatContext *s, > AVStream *st, const UID ke > int stored_height = (st->codecpar->height+15)/16*16; > int display_height; > int f1, f2; > -unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6; > UID transfer_ul = {0}; > +int64_t pos = mxf_write_generic_desc(s, st, key); > > -if (sc->interlaced && sc->field_dominance) > -desc_size += 5; > -if (sc->signal_standard) > -desc_size += 5; > -if (sc->interlaced) > -desc_size += 8; > -if (sc->v_chroma_sub_sample) > -desc_size += 8; > -if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) > -desc_size += 8 * 3; > -if (s->oformat == &ff_mxf_d10_muxer) > -desc_size += 8 + 8 + 8; > -if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0) > -desc_size += 20; > - > -mxf_write_generic_desc(s, st, key, desc_size); > +get_trc(transfer_ul, st->codecpar->color_trc); nice simplification! [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
--- libavformat/mxfenc.c | 80 +--- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 77f60f5874..b98d234f03 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -1104,14 +1104,16 @@ static void mxf_write_multi_descriptor(AVFormatContext *s) mxf_write_uuid(pb, SubDescriptor, i); } -static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID key, unsigned size) +static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID key) { MXFContext *mxf = s->priv_data; MXFStreamContext *sc = st->priv_data; AVIOContext *pb = s->pb; +int64_t pos; avio_write(pb, key, 16); -klv_encode_ber4_length(pb, size+20+8+12+20); +klv_encode_ber4_length(pb, 0); +pos = avio_tell(pb); mxf_write_local_tag(pb, 16, 0x3C0A); mxf_write_uuid(pb, SubDescriptor, st->index); @@ -1136,6 +1138,8 @@ static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID k mxf_write_local_tag(pb, 16, 0x3004); avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, 16); + +return pos; } static const UID mxf_mpegvideo_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 }; @@ -1172,7 +1176,7 @@ static int get_trc(UID ul, enum AVColorTransferCharacteristic trc) } } -static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size) +static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key) { MXFStreamContext *sc = st->priv_data; AVIOContext *pb = s->pb; @@ -1180,25 +1184,10 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke int stored_height = (st->codecpar->height+15)/16*16; int display_height; int f1, f2; -unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6; UID transfer_ul = {0}; +int64_t pos = mxf_write_generic_desc(s, st, key); -if (sc->interlaced && sc->field_dominance) -desc_size += 5; -if (sc->signal_standard) -desc_size += 5; -if (sc->interlaced) -desc_size += 8; -if (sc->v_chroma_sub_sample) -desc_size += 8; -if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) -desc_size += 8 * 3; -if (s->oformat == &ff_mxf_d10_muxer) -desc_size += 8 + 8 + 8; -if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0) -desc_size += 20; - -mxf_write_generic_desc(s, st, key, desc_size); +get_trc(transfer_ul, st->codecpar->color_trc); mxf_write_local_tag(pb, 4, 0x3203); avio_wb32(pb, stored_width); @@ -1352,11 +1341,22 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke avio_w8(pb, sc->field_dominance); } +return pos; +} + +static void mxf_update_klv_size(AVIOContext *pb, int64_t pos) +{ +int64_t cur_pos = avio_tell(pb); +int size = cur_pos - pos; +avio_seek(pb, pos - 4, SEEK_SET); +klv_encode_ber4_length(pb, size); +avio_seek(pb, cur_pos, SEEK_SET); } static void mxf_write_cdci_desc(AVFormatContext *s, AVStream *st) { -mxf_write_cdci_common(s, st, mxf_cdci_descriptor_key, 0); +int64_t pos = mxf_write_cdci_common(s, st, mxf_cdci_descriptor_key); +mxf_update_klv_size(s->pb, pos); } static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) @@ -1364,10 +1364,9 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) AVIOContext *pb = s->pb; MXFStreamContext *sc = st->priv_data; int profile_and_level = (st->codecpar->profile<<4) | st->codecpar->level; +int64_t pos = mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key); if (st->codecpar->codec_id != AV_CODEC_ID_H264) { -mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5); - // bit rate mxf_write_local_tag(pb, 4, 0x8000); avio_wb32(pb, sc->video_bit_rate); @@ -1377,26 +1376,19 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st) if (!st->codecpar->profile) profile_and_level |= 0x80; // escape bit avio_w8(pb, profile_and_level); -} else { -mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 0); } + +mxf_update_klv_size(pb, pos); } -static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size) +static int64_t mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, const UID key) { AVIOContext *pb = s->pb; MXFContext *mxf = s->priv_data; int show_warnings = !mxf->footer_partition_offset; -int duration_size = 0; +int64_t pos = mxf_write_generic_desc(s, st, key); -if (s->oformat == &ff_mxf_opatom_muxer) -duration_size = 12; -if (s->oformat == &ff_mxf_d10_muxer) -size += 5