[FFmpeg-devel] [PATCH 1/2] lavc/qsvdec: update HDR side data on output AVFrame for AV1 decoding

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue May 21 09:14:48 EEST 2024


Xiang, Haihao:
> +static int qsv_export_hdr_side_data_av1(AVCodecContext *avctx, mfxExtMasteringDisplayColourVolume *mdcv,
> +                                        mfxExtContentLightLevelInfo *clli, AVFrame *frame)
> +{
> +    if (mdcv->InsertPayloadToggle) {
> +        AVMasteringDisplayMetadata *mastering = av_mastering_display_metadata_create_side_data(frame);
> +        const int chroma_den   = 1 << 16;
> +        const int max_luma_den = 1 << 8;
> +        const int min_luma_den = 1 << 14;
> +        int i;

Iterators with loop scope should be preferred if possible (like here).

> +
> +        if (!mastering)
> +            return AVERROR(ENOMEM);
> +
> +        for (i = 0; i < 3; i++) {
> +            mastering->display_primaries[i][0] = av_make_q(mdcv->DisplayPrimariesX[i], chroma_den);
> +            mastering->display_primaries[i][1] = av_make_q(mdcv->DisplayPrimariesY[i], chroma_den);
> +        }
> +
> +        mastering->white_point[0] = av_make_q(mdcv->WhitePointX, chroma_den);
> +        mastering->white_point[1] = av_make_q(mdcv->WhitePointY, chroma_den);
> +
> +        mastering->max_luminance = av_make_q(mdcv->MaxDisplayMasteringLuminance, max_luma_den);
> +        mastering->min_luminance = av_make_q(mdcv->MinDisplayMasteringLuminance, min_luma_den);
> +
> +        mastering->has_luminance = 1;
> +        mastering->has_primaries = 1;
> +    }
> +



More information about the ffmpeg-devel mailing list