diff mbox

[FFmpeg-devel,01/23] avcodec: add color_range to AVCodec struct and use it

Message ID 20171212135621.30835-1-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol Dec. 12, 2017, 1:55 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/avcodec.h | 1 +
 libavcodec/utils.c   | 2 ++
 2 files changed, 3 insertions(+)

Comments

wm4 Dec. 12, 2017, 2:07 p.m. UTC | #1
On Tue, 12 Dec 2017 14:55:59 +0100
Paul B Mahol <onemda@gmail.com> wrote:

> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/avcodec.h | 1 +
>  libavcodec/utils.c   | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 5db6a81320..df715fd5ee 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3376,6 +3376,7 @@ typedef struct AVCodec {
>      uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
>      const AVClass *priv_class;              ///< AVClass for the private context
>      const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
> +    const enum AVColorRange *color_ranges;  ///< array of supported color ranges by encoder, or  NULL if unknown, array is terminated by -1

wouldn't it be terminated by AVCOL_RANGE_UNSPECIFIED? (The enum might be
backed by an unsigned integer type, so this is not just bikeshed.)

>  
>      /*****************************************************************
>       * No fields below this line are part of the public API. They
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 873f39f9bd..41cc6fbf2c 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -879,6 +879,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>                  avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
>                  avctx->color_range = AVCOL_RANGE_JPEG;
>          }
> +        if (avctx->codec->color_range)
> +            avctx->color_range = avctx->codec->color_range;
>          if (avctx->codec->supported_samplerates) {
>              for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
>                  if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
Michael Niedermayer Dec. 13, 2017, 1:09 a.m. UTC | #2
On Tue, Dec 12, 2017 at 02:55:59PM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavcodec/avcodec.h | 1 +
>  libavcodec/utils.c   | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 5db6a81320..df715fd5ee 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3376,6 +3376,7 @@ typedef struct AVCodec {
>      uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
>      const AVClass *priv_class;              ///< AVClass for the private context
>      const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
> +    const enum AVColorRange *color_ranges;  ///< array of supported color ranges by encoder, or  NULL if unknown, array is terminated by -1
>  
>      /*****************************************************************
>       * No fields below this line are part of the public API. They
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 873f39f9bd..41cc6fbf2c 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -879,6 +879,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>                  avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
>                  avctx->color_range = AVCOL_RANGE_JPEG;
>          }
> +        if (avctx->codec->color_range)
> +            avctx->color_range = avctx->codec->color_range;

This doesnt build, i can thus not easily bisect some fate failure:

libavcodec/utils.c: In function ‘avcodec_open2’:
libavcodec/utils.c:882:25: error: ‘const struct AVCodec’ has no member named ‘color_range’
         if (avctx->codec->color_range)
                         ^
libavcodec/utils.c:883:46: error: ‘const struct AVCodec’ has no member named ‘color_range’
             avctx->color_range = avctx->codec->color_range;


[...]

 #dimensions 0: 128x128
-#sar 0: 72/72
+#sar 0: 1/1
 0,          0,          0,        1,    49152, 0xe0013dee
Test png-rgb24 failed. Look at tests/data/fate/png-rgb24.err for details.
make: *** [fate-png-rgb24] Error 1
TEST    psd-rgba
TEST    psd-rgba64
TEST    psd-ya8
TEST    psd-ya16
--- ./tests/ref/fate/png-int-rgb24      2017-12-13 00:39:32.256314963 +0100
--
 #dimensions 0: 128x128
-#sar 0: 2835/2835
+#sar 0: 1/1
 0,          0,          0,        1,    49152, 0xe0013dee
Test png-int-rgb24 failed. Look at tests/data/fate/png-int-rgb24.err for details.
make: *** [fate-png-int-rgb24] Error 1
TEST    psd-lena-127x127-rgb24
TEST    psd-lena-rgb-rle-127x127-16b
TEST    psd-lena-rgb-rle-127x127-8b
TEST    psd-lena-rgba-rle-128x128-8b
TEST    psd-lena-256c
--
 0,          0,          0,        1,     1600, 0x01a481a9
 0,          1,          1,        1,     1600, 0x01a481a9
 0,          2,          2,        1,     1600, 0x01a481a9
TEST    lossless-alac
Test pngparser failed. Look at tests/data/fate/pngparser.err for details.
make: *** [fate-pngparser] Error 1
TEST    lossless-meridianaudio
TEST    ralf
TEST    lossless-shorten
TEST    lossless-tak
TEST    lossless-truehd-5.1
diff mbox

Patch

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5db6a81320..df715fd5ee 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3376,6 +3376,7 @@  typedef struct AVCodec {
     uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
     const AVClass *priv_class;              ///< AVClass for the private context
     const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
+    const enum AVColorRange *color_ranges;  ///< array of supported color ranges by encoder, or  NULL if unknown, array is terminated by -1
 
     /*****************************************************************
      * No fields below this line are part of the public API. They
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 873f39f9bd..41cc6fbf2c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -879,6 +879,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
                 avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
                 avctx->color_range = AVCOL_RANGE_JPEG;
         }
+        if (avctx->codec->color_range)
+            avctx->color_range = avctx->codec->color_range;
         if (avctx->codec->supported_samplerates) {
             for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
                 if (avctx->sample_rate == avctx->codec->supported_samplerates[i])