On Sat, Nov 24, 2018 at 11:04:38PM +0100, Martin Vignali wrote:
>  proresenc_anatoliy.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 46 insertions(+), 3 deletions(-)
> 44fe346a2be4d3d3ce2c903daf9cd599437627cc  
> 0013-avcodec-prores_aw-only-set-color-prim-trc-space.patch
> From 119a246e570ff346490aef88710d8c8b4aae34e7 Mon Sep 17 00:00:00 2001
> From: Martin Vignali <martin.vign...@gmail.com>
> Date: Sat, 24 Nov 2018 22:48:08 +0100
> Subject: [PATCH 13/14] avcodec/prores_aw : only set color prim, trc, space 
>  values if supported
> 
> set to unspecified if frame have another value
> ---
>  libavcodec/proresenc_anatoliy.c | 49 
> ++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 46 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
> index 8047f1c242..8098336b3b 100644
> --- a/libavcodec/proresenc_anatoliy.c
> +++ b/libavcodec/proresenc_anatoliy.c
> @@ -656,6 +656,7 @@ static int prores_encode_frame(AVCodecContext *avctx, 
> AVPacket *pkt,
>                                 const AVFrame *pict, int *got_packet)
>  {
>      ProresContext *ctx = avctx->priv_data;
> +    int color_primaries = 0, color_trc = 0, colorspace = 0;/* unspecified by 
> default */
>      int header_size = 148;
>      uint8_t *buf;
>      int pic_size, ret;
> @@ -686,9 +687,51 @@ static int prores_encode_frame(AVCodecContext *avctx, 
> AVPacket *pkt,
>          *buf++ = 0x82; // 422, not interlaced
>      }
>      *buf++ = 0; /* reserved */
> -    *buf++ = pict->color_primaries;
> -    *buf++ = pict->color_trc;
> -    *buf++ = pict->colorspace;
> +
> +    switch (pict->color_primaries) {
> +    case AVCOL_PRI_RESERVED0:
> +    case AVCOL_PRI_BT709:
> +    case AVCOL_PRI_UNSPECIFIED:
> +    case AVCOL_PRI_BT470BG:
> +    case AVCOL_PRI_SMPTE170M:
> +    case AVCOL_PRI_BT2020:
> +    case AVCOL_PRI_SMPTE431:
> +    case AVCOL_PRI_SMPTE432:
> +        color_primaries = pict->color_primaries;
> +        break;
> +    default:
> +        av_log(avctx, AV_LOG_DEBUG,
> +               "Frame color primaries %d are not supported in prores frame. 
> Set prores frame value to unspecified\n", pict->color_primaries);
> +        break;
> +    }
> +
> +    switch (pict->color_trc) {
> +    case AVCOL_TRC_RESERVED0:
> +    case AVCOL_TRC_BT709:
> +    case AVCOL_TRC_UNSPECIFIED:
> +        color_trc = pict->color_trc;
> +        break;
> +    default:
> +        av_log(avctx, AV_LOG_DEBUG,
> +                "Frame color_trc %d are not supported in prores frame. Set 
> prores frame value to unspecified\n", pict->color_trc);
> +        break;
> +    }
> +
> +    switch (pict->colorspace) {
> +    case AVCOL_SPC_BT709:
> +    case AVCOL_SPC_UNSPECIFIED:
> +    case AVCOL_SPC_SMPTE170M:
> +    case AVCOL_SPC_BT2020_NCL:
> +        colorspace = pict->colorspace;
> +        break;
> +    default:
> +        av_log(avctx, AV_LOG_DEBUG,
> +                "Frame colorspace %d are not supported in prores frame. Set 
> prores frame value to unspecified\n", pict->colorspace);
> +        break;
> +    }
> +    *buf++ = color_primaries;
> +    *buf++ = color_trc;
> +    *buf++ = colorspace;

we maybe should write a generic function that takes a list of supported types
and the undefined one and then does the check, debug print and all that
that could be used in other encoders too.
just an idea, that can be done later

the patch
LGTM

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle

Attachment: signature.asc
Description: PGP signature

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

Reply via email to