Hi

On Fri, Dec 06, 2024 at 03:32:02PM +0100, Niklas Haas wrote:
> From: Niklas Haas <g...@haasn.dev>
> 
> Provide default values for the fields added in the previous commit.
> ---
>  libswscale/utils.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/libswscale/utils.c b/libswscale/utils.c
> index 428cf1c7f5..182f92396a 100644
> --- a/libswscale/utils.c
> +++ b/libswscale/utils.c
> @@ -2654,6 +2654,8 @@ int ff_range_add(RangeList *rl, unsigned int start, 
> unsigned int len)
>  SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
>  {
>      const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
> +    const AVColorPrimariesDesc *primaries;
> +
>      SwsFormat fmt = {
>          .width  = frame->width,
>          .height = frame->height,
> @@ -2710,6 +2712,25 @@ SwsFormat ff_fmt_from_frame(const AVFrame *frame, int 
> field)
>          fmt.interlaced = 1;
>      }
>  
> +    /* Set luminance and gamut information */
> +    fmt.color.min_luma = av_make_q(0, 1);
> +    switch (fmt.color.trc) {
> +    case AVCOL_TRC_SMPTE2084:
> +        fmt.color.max_luma = av_make_q(10000, 1); break;
> +    case AVCOL_TRC_ARIB_STD_B67:
> +        fmt.color.max_luma = av_make_q( 1000, 1); break; /* HLG reference 
> display */
> +    default:
> +        fmt.color.max_luma = av_make_q(  203, 1); break; /* SDR reference 
> brightness */
> +    }
> +
> +    primaries = av_csp_primaries_desc_from_id(fmt.color.prim);
> +    if (primaries)
> +        fmt.color.gamut = primaries->prim;
> +
> +    /* PQ is always scaled down to absolute zero, so ignore mastering 
> metadata */
> +    if (fmt.color.trc == AVCOL_TRC_SMPTE2084)
> +        fmt.color.min_luma = av_make_q(0, 1);

This makes sense after subsequent patches, but here it sets
min_luma to 0 after it is set to 0, maybe this hunk should be in another patch
or something else

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
than the original author, trying to rewrite it will not make it better.

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to