[FFmpeg-devel] [PATCH] extends Generic/CDDI/MPEG2 essence descriptors
Michael Niedermayer
michael at niedermayer.cc
Wed Jun 1 17:48:48 CEST 2016
On Thu, Apr 21, 2016 at 05:03:01PM +0300, Maksym Veremeyenko wrote:
> Hi,
>
> attached patches extends Generic/CDDI/MPEG2 essence descriptors with
> additional items. These items required by AMWA AS-10 MXF
> specification.
>
> --
> Maksym Veremeyenko
>
[...]
> mxfenc.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 90 insertions(+), 1 deletion(-)
> 0df0bfaa318361ecec5c47572650b3563b0f8a74 0001-Extend-Generic-CDCI-picture-essence-descriptors-with.patch
> From eb3ef1f423864bd8d79d6170bbc137ac0be62f0b Mon Sep 17 00:00:00 2001
> From: Maksym Veremeyenko <verem at m1.tv>
> Date: Wed, 20 Apr 2016 14:24:40 +0300
> Subject: [PATCH 1/2] Extend Generic/CDCI picture essence descriptors with
> additional items
does this fix something ?
>
> ---
> libavformat/mxfenc.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 90 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 36a43e4..ec42cf5 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -419,10 +419,27 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
> { 0x3201, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x06,0x01,0x00,0x00,0x00,0x00}}, /* Picture Essence Coding */
> { 0x3212, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x03,0x01,0x06,0x00,0x00,0x00}}, /* Field Dominance (Opt) */
> { 0x3215, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x05,0x01,0x13,0x00,0x00,0x00,0x00}}, /* Signal Standard */
> + { 0x3216, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x08,0x00,0x00,0x00}}, /* StoredF2Offset */
> + { 0x3205, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x08,0x00,0x00,0x00}}, /* Sampled Width */
> + { 0x3204, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x07,0x00,0x00,0x00}}, /* Sampled Height */
> + { 0x3206, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x09,0x00,0x00,0x00}}, /* SampledXOffset */
> + { 0x3207, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0A,0x00,0x00,0x00}}, /* SampledYOffset */
> + { 0x320A, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x0D,0x00,0x00,0x00}}, /* DisplayXOffset */
> + { 0x3217, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x01,0x03,0x02,0x07,0x00,0x00,0x00}}, /* DisplayF2Offset */
> + { 0x3210, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x02,0x01,0x01,0x01,0x02,0x00}}, /* Capture Gamma */
> + { 0x3211, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x01,0x00,0x00,0x00,0x00}}, /* Image Alignment Offset */
> + { 0x3213, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x02,0x00,0x00,0x00,0x00}}, /* Image Start Offset */
> + { 0x3214, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x03,0x00,0x00,0x00,0x00}}, /* Image End Offset */
> // CDCI Picture Essence Descriptor
> { 0x3301, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x0A,0x00,0x00,0x00}}, /* Component Depth */
> { 0x3302, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x05,0x00,0x00,0x00}}, /* Horizontal Subsampling */
> { 0x3303, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x01,0x06,0x00,0x00,0x00}}, /* Color Siting */
> + { 0x3308, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x01,0x10,0x00,0x00,0x00}}, /* Vertical Subsampling */
> + { 0x330B, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x03,0x01,0x02,0x01,0x0A,0x00,0x00,0x00}}, /* ReversedByteOrder */
> + { 0x3307, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x18,0x01,0x04,0x00,0x00,0x00,0x00}}, /* PaddingBits */
> + { 0x3304, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x03,0x00,0x00,0x00}}, /* Black Ref Level */
> + { 0x3305, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x01,0x04,0x01,0x05,0x03,0x04,0x00,0x00,0x00}}, /* White Ref level */
> + { 0x3306, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x04,0x01,0x05,0x03,0x05,0x00,0x00,0x00}}, /* Color Range */
> // Generic Sound Essence Descriptor
> { 0x3D02, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x04,0x02,0x03,0x01,0x04,0x00,0x00,0x00}}, /* Locked/Unlocked */
> { 0x3D03, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x05,0x04,0x02,0x03,0x01,0x01,0x01,0x00,0x00}}, /* Audio sampling rate */
> @@ -452,6 +469,11 @@ static const MXFLocalTagPair mxf_user_comments_local_tag[] = {
> { 0x5003, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0A,0x01,0x00,0x00}}, /* Value */
> };
>
> +static const uint8_t capture_gamma_ITU470[] = // MXF-Profile ARD_ZDF_SDF02 - v1.0.pdf
> + {06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x01,0x00,0x00};
> +static const uint8_t capture_gamma_ITU709[] = // MXF-Profile ARD_ZDF_HDF01a - v1.1.pdf, also used in SMPTE 170M, 274M and 296M
> + {06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x01,0x01,0x01,0x02,0x00,0x00};
> +
> static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value)
> {
> avio_write(pb, uuid_base, 12);
> @@ -1013,7 +1035,7 @@ 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;
> + unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5+8+8+8+8+8+8+8+20+8+8+8+8+5+6+8+8+8;
> if (sc->interlaced && sc->field_dominance)
> desc_size += 5;
> if (sc->signal_standard)
> @@ -1100,6 +1122,73 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
> avio_w8(pb, sc->field_dominance);
> }
>
> + /* StoredF2Offset */
> + mxf_write_local_tag(pb, 4, 0x3216);
> + avio_wb32(pb, 0);
> +
> + /* Sampled Width */
> + mxf_write_local_tag(pb, 4, 0x3205);
> + avio_wb32(pb, st->codecpar->width);
> +
> + /* Sampled Height */
> + mxf_write_local_tag(pb, 4, 0x3204);
> + avio_wb32(pb, display_height);
> +
> + /* SampledXOffset */
> + mxf_write_local_tag(pb, 4, 0x3206);
> + avio_wb32(pb, 0);
> +
> + /* SampledYOffset */
> + mxf_write_local_tag(pb, 4, 0x3207);
> + avio_wb32(pb, 0);
> +
> + /* DisplayXOffset */
> + mxf_write_local_tag(pb, 4, 0x320A);
> + avio_wb32(pb, 0);
> +
> + /* DisplayF2Offset */
> + mxf_write_local_tag(pb, 4, 0x3217);
> + avio_wb32(pb, 0);
are these the default values ?
if so why store them ?
> +
> + /* Capture Gamma */
> + mxf_write_local_tag(pb, 16, 0x3210);
> + avio_write(pb, (720 == st->codecpar->height || 1080 == st->codecpar->height)?capture_gamma_ITU709:capture_gamma_ITU470, 16);
[...]
> +
> + /* Vertical Subsampling */
> + mxf_write_local_tag(pb, 4, 0x3308);
> + avio_wb32(pb, (AV_PIX_FMT_YUV422P == st->codecpar->format)?1:(AV_PIX_FMT_YUV420P == st->codecpar->format)?2:0);
Vertical Subsampling an be obtained from AVPixFmtDescriptor
> +
> + /* ReversedByteOrder */
> + mxf_write_local_tag(pb, 1, 0x330B);
> + avio_w8(pb, 0);
> +
> + /* PaddingBits */
> + mxf_write_local_tag(pb, 2, 0x3307);
> + avio_wb16(pb, 0);
> +
> + /* Black Ref Level */
> + mxf_write_local_tag(pb, 4, 0x3304);
> + avio_wb32(pb, (8 == sc->component_depth)?16:64);
> +
> + /* White Ref level */
> + mxf_write_local_tag(pb, 4, 0x3305);
> + avio_wb32(pb, (8 == sc->component_depth)?235:940);
> +
> + /* Color Range */
> + mxf_write_local_tag(pb, 4, 0x3306);
> + avio_wb32(pb, (8 == sc->component_depth)?225:897);
why do these not use the AVColor* fields ?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160601/4537636e/attachment.sig>
More information about the ffmpeg-devel
mailing list