[FFmpeg-devel] [PATCH v2 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF

Tomas Härdin tjoppen at acc.umu.se
Mon Sep 14 13:24:14 EEST 2020


ons 2020-09-09 klockan 15:56 +0100 skrev Harry Mallon:
> Described in Annex B SMPTE ST 2067-21:2020
> 
> Signed-off-by: Harry Mallon <harry.mallon at codex.online>

>          av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs);
> @@ -1272,6 +1276,42 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int
>                  rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K)
>                  descriptor->pix_fmt = AV_PIX_FMT_XYZ12;
>          }
> +        if (IS_KLV_KEY(uid, ff_mxf_mastering_display_prefix)) {
> +            if (!descriptor->mastering) {
> +                descriptor->mastering = av_mastering_display_metadata_alloc();
> +                if (!descriptor->mastering)
> +                    return AVERROR(ENOMEM);
> +            }
> +            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[0].uid)) {
> +                for (int i = 0; i < 3; i++) {
> +                    /* Order: large x, large y, other (i.e. RGB) */
> +                    descriptor->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +                    descriptor->mastering->display_primaries[i][1] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +                }
> +                /* Check we have seen mxf_mastering_display_white_point_chromaticity */
> +                if (descriptor->mastering->white_point[0].den != 0)
> +                    descriptor->mastering->has_primaries = 1;
> +            }
> +            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[1].uid)) {
> +                descriptor->mastering->white_point[0] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +                descriptor->mastering->white_point[1] = av_make_q(avio_rb16(pb), FF_MXF_MASTERING_CHROMA_DEN);
> +                /* Check we have seen mxf_mastering_display_primaries */
> +                if (descriptor->mastering->display_primaries[0][0].den != 0)
> +                    descriptor->mastering->has_primaries = 1;
> +            }
> +            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[2].uid)) {
> +                descriptor->mastering->max_luminance = av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
> +                /* Check we have seen mxf_mastering_display_minimum_luminance */
> +                if (descriptor->mastering->min_luminance.den != 0)
> +                    descriptor->mastering->has_luminance = 1;
> +            }
> +            if (IS_KLV_KEY(uid, ff_mxf_mastering_display_local_tags[3].uid)) {
> +                descriptor->mastering->min_luminance = av_make_q(avio_rb32(pb), FF_MXF_MASTERING_LUMA_DEN);
> +                /* Check we have seen mxf_mastering_display_maximum_luminance */
> +                if (descriptor->mastering->max_luminance.den != 0)
> +                    descriptor->mastering->has_luminance = 1;
> +            }
> +        }

Much nicer :)

Patch looks OK to me

/Tomas



More information about the ffmpeg-devel mailing list