diff mbox

[FFmpeg-devel] lavc/videotoolboxenc: add hdr10, linear, hlg color transfer function for videotoolboxenc

Message ID 20190626105759.97113-1-lance.lmwang@gmail.com
State Accepted
Commit 391b67fcb58f95b5cc65b75070fd9a3dce4f8ac6
Headers show

Commit Message

Limin Wang June 26, 2019, 10:57 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Below is the testing ffmpeg command for the setting:
./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc linear linear.ts
./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 configure                    |  6 ++++++
 libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

Comments

Limin Wang July 8, 2019, 10:51 a.m. UTC | #1
Richard Kern, please help to review the patch.

On Wed, Jun 26, 2019 at 06:57:59PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Below is the testing ffmpeg command for the setting:
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc linear linear.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  configure                    |  6 ++++++
>  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/configure b/configure
> index 7cea9d4d73..0a5e940c0c 100755
> --- a/configure
> +++ b/configure
> @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
>  TYPES_LIST="
>      kCMVideoCodecType_HEVC
>      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> +    kCVImageBufferTransferFunction_Linear
>      socklen_t
>      struct_addrinfo
>      struct_group_source_req
> @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
>      check_lib coreservices CoreServices/CoreServices.h UTGetOSTypeFromString "-framework CoreServices"
>      check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia"
>      check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> +    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> +    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> +    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
>  }
>  
>  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index f8ccdea52d..0dc6eb4cf4 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext *avctx,
>              *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
>              break;
>  
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> +        case AVCOL_TRC_SMPTE2084:
> +            *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> +            break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> +        case AVCOL_TRC_LINEAR:
> +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> +            break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> +        case AVCOL_TRC_ARIB_STD_B67:
> +            *transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> +            break;
> +#endif
> +
>          case AVCOL_TRC_GAMMA22:
>              gamma = 2.2;
>              *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> -- 
> 2.21.0
>
Aman Karmani July 9, 2019, 11:40 p.m. UTC | #2
On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang@gmail.com> wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> Below is the testing ffmpeg command for the setting:
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> -colorspace bt2020_ncl -color_trc linear linear.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
>

Patch looks reasonable to me. Will commit in a few days if no one else
comments.

Aman


>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  configure                    |  6 ++++++
>  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/configure b/configure
> index 7cea9d4d73..0a5e940c0c 100755
> --- a/configure
> +++ b/configure
> @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
>  TYPES_LIST="
>      kCMVideoCodecType_HEVC
>      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> +    kCVImageBufferTransferFunction_Linear
>      socklen_t
>      struct_addrinfo
>      struct_group_source_req
> @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
>      check_lib coreservices CoreServices/CoreServices.h
> UTGetOSTypeFromString "-framework CoreServices"
>      check_func_headers CoreMedia/CMFormatDescription.h
> kCMVideoCodecType_HEVC "-framework CoreMedia"
>      check_func_headers CoreVideo/CVPixelBuffer.h
> kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> +    check_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> +    check_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> +    check_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
>  }
>
>  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index f8ccdea52d..0dc6eb4cf4 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext
> *avctx,
>              *transfer_fnc =
> kCVImageBufferTransferFunction_SMPTE_240M_1995;
>              break;
>
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> +        case AVCOL_TRC_SMPTE2084:
> +            *transfer_fnc =
> kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> +            break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> +        case AVCOL_TRC_LINEAR:
> +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> +            break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> +        case AVCOL_TRC_ARIB_STD_B67:
> +            *transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> +            break;
> +#endif
> +
>          case AVCOL_TRC_GAMMA22:
>              gamma = 2.2;
>              *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> --
> 2.21.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Dennis Mungai July 10, 2019, 2:17 a.m. UTC | #3
On Wed, Jul 10, 2019, 03:05 Aman Gupta <ffmpeg@tmm1.net> wrote:

> On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang@gmail.com> wrote:
>
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > Below is the testing ffmpeg command for the setting:
> > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > -colorspace bt2020_ncl -color_trc linear linear.ts
> > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> >
>
> Patch looks reasonable to me. Will commit in a few days if no one else
> comments.
>
> Aman
>
>
> >
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  configure                    |  6 ++++++
> >  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
> >  2 files changed, 22 insertions(+)
> >
> > diff --git a/configure b/configure
> > index 7cea9d4d73..0a5e940c0c 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
> >  TYPES_LIST="
> >      kCMVideoCodecType_HEVC
> >      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> > +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> > +    kCVImageBufferTransferFunction_Linear
> >      socklen_t
> >      struct_addrinfo
> >      struct_group_source_req
> > @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
> >      check_lib coreservices CoreServices/CoreServices.h
> > UTGetOSTypeFromString "-framework CoreServices"
> >      check_func_headers CoreMedia/CMFormatDescription.h
> > kCMVideoCodecType_HEVC "-framework CoreMedia"
> >      check_func_headers CoreVideo/CVPixelBuffer.h
> > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> > +    check_func_headers CoreVideo/CVImageBuffer.h
> > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> > +    check_func_headers CoreVideo/CVImageBuffer.h
> > kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> > +    check_func_headers CoreVideo/CVImageBuffer.h
> > kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
> >  }
> >
> >  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> > index f8ccdea52d..0dc6eb4cf4 100644
> > --- a/libavcodec/videotoolboxenc.c
> > +++ b/libavcodec/videotoolboxenc.c
> > @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext
> > *avctx,
> >              *transfer_fnc =
> > kCVImageBufferTransferFunction_SMPTE_240M_1995;
> >              break;
> >
> > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> > +        case AVCOL_TRC_SMPTE2084:
> > +            *transfer_fnc =
> > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> > +            break;
> > +#endif
> > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> > +        case AVCOL_TRC_LINEAR:
> > +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> > +            break;
> > +#endif
> > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> > +        case AVCOL_TRC_ARIB_STD_B67:
> > +            *transfer_fnc =
> kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> > +            break;
> > +#endif
> > +
> >          case AVCOL_TRC_GAMMA22:
> >              gamma = 2.2;
> >              *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> > --
> > 2.21.0
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>

A while back, a similar patch was rejected for NVENC (from the same author)
on the basis of such functionality not being suitably placed as an encoder
feature.

Looking back at other implementations, eg hevc_vaapi, the same is indeed
allowed, where SEI metadata retention for HDR is present.

To the OP: If the patch for NVENC were refactored in a manner similar to
this, abstracting details such as master display info for HDR (something
that was specifically flagged as not suitable as an encoder feature), it
might pass the patch review and be merged.

Are there specific limitations (as implemented) that block such a feature
in NVENC? Perhaps the initial patch with mastering display controls for HDR
was written that way to circumvent such a limitation.

Regards,

Dennis

>
Hendrik Leppkes July 10, 2019, 7:59 a.m. UTC | #4
On Wed, Jul 10, 2019 at 4:23 AM Dennis Mungai <dmngaie@gmail.com> wrote:
>
> On Wed, Jul 10, 2019, 03:05 Aman Gupta <ffmpeg@tmm1.net> wrote:
>
> > On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang@gmail.com> wrote:
> >
> > > From: Limin Wang <lance.lmwang@gmail.com>
> > >
> > > Below is the testing ffmpeg command for the setting:
> > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > -colorspace bt2020_ncl -color_trc linear linear.ts
> > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> > >
> >
> > Patch looks reasonable to me. Will commit in a few days if no one else
> > comments.
> >
> > Aman
> >
> >
> > >
> > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > ---
> > >  configure                    |  6 ++++++
> > >  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
> > >  2 files changed, 22 insertions(+)
> > >
> > > diff --git a/configure b/configure
> > > index 7cea9d4d73..0a5e940c0c 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
> > >  TYPES_LIST="
> > >      kCMVideoCodecType_HEVC
> > >      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> > > +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > > +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> > > +    kCVImageBufferTransferFunction_Linear
> > >      socklen_t
> > >      struct_addrinfo
> > >      struct_group_source_req
> > > @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
> > >      check_lib coreservices CoreServices/CoreServices.h
> > > UTGetOSTypeFromString "-framework CoreServices"
> > >      check_func_headers CoreMedia/CMFormatDescription.h
> > > kCMVideoCodecType_HEVC "-framework CoreMedia"
> > >      check_func_headers CoreVideo/CVPixelBuffer.h
> > > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
> > >  }
> > >
> > >  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> > > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> > > index f8ccdea52d..0dc6eb4cf4 100644
> > > --- a/libavcodec/videotoolboxenc.c
> > > +++ b/libavcodec/videotoolboxenc.c
> > > @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext
> > > *avctx,
> > >              *transfer_fnc =
> > > kCVImageBufferTransferFunction_SMPTE_240M_1995;
> > >              break;
> > >
> > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> > > +        case AVCOL_TRC_SMPTE2084:
> > > +            *transfer_fnc =
> > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> > > +            break;
> > > +#endif
> > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> > > +        case AVCOL_TRC_LINEAR:
> > > +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> > > +            break;
> > > +#endif
> > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> > > +        case AVCOL_TRC_ARIB_STD_B67:
> > > +            *transfer_fnc =
> > kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> > > +            break;
> > > +#endif
> > > +
> > >          case AVCOL_TRC_GAMMA22:
> > >              gamma = 2.2;
> > >              *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> > > --
> > > 2.21.0
> > >
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >
>
> A while back, a similar patch was rejected for NVENC (from the same author)
> on the basis of such functionality not being suitably placed as an encoder
> feature.
>
> Looking back at other implementations, eg hevc_vaapi, the same is indeed
> allowed, where SEI metadata retention for HDR is present.
>
> To the OP: If the patch for NVENC were refactored in a manner similar to
> this, abstracting details such as master display info for HDR (something
> that was specifically flagged as not suitable as an encoder feature), it
> might pass the patch review and be merged.
>
> Are there specific limitations (as implemented) that block such a feature
> in NVENC? Perhaps the initial patch with mastering display controls for HDR
> was written that way to circumvent such a limitation.
>

I think you are confusing the type of patches here. This does nothing
but extend existing functionality to forward a few more values in
basically an enum that was already being set.
The other patch was about parsing user inputs and generating SEI data,
which should arguably be done in a central place instead of every
encoder individually.

- Hendrik
Dennis Mungai July 10, 2019, 9:29 a.m. UTC | #5
On Wed, Jul 10, 2019, 11:06 Hendrik Leppkes <h.leppkes@gmail.com> wrote:

> On Wed, Jul 10, 2019 at 4:23 AM Dennis Mungai <dmngaie@gmail.com> wrote:
> >
> > On Wed, Jul 10, 2019, 03:05 Aman Gupta <ffmpeg@tmm1.net> wrote:
> >
> > > On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang@gmail.com> wrote:
> > >
> > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > >
> > > > Below is the testing ffmpeg command for the setting:
> > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > -colorspace bt2020_ncl -color_trc linear linear.ts
> > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> > > >
> > >
> > > Patch looks reasonable to me. Will commit in a few days if no one else
> > > comments.
> > >
> > > Aman
> > >
> > >
> > > >
> > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > ---
> > > >  configure                    |  6 ++++++
> > > >  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
> > > >  2 files changed, 22 insertions(+)
> > > >
> > > > diff --git a/configure b/configure
> > > > index 7cea9d4d73..0a5e940c0c 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
> > > >  TYPES_LIST="
> > > >      kCMVideoCodecType_HEVC
> > > >      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> > > > +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > > > +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> > > > +    kCVImageBufferTransferFunction_Linear
> > > >      socklen_t
> > > >      struct_addrinfo
> > > >      struct_group_source_req
> > > > @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
> > > >      check_lib coreservices CoreServices/CoreServices.h
> > > > UTGetOSTypeFromString "-framework CoreServices"
> > > >      check_func_headers CoreMedia/CMFormatDescription.h
> > > > kCMVideoCodecType_HEVC "-framework CoreMedia"
> > > >      check_func_headers CoreVideo/CVPixelBuffer.h
> > > > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework
> CoreVideo"
> > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework
> CoreVideo"
> > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
> > > >  }
> > > >
> > > >  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> > > > diff --git a/libavcodec/videotoolboxenc.c
> b/libavcodec/videotoolboxenc.c
> > > > index f8ccdea52d..0dc6eb4cf4 100644
> > > > --- a/libavcodec/videotoolboxenc.c
> > > > +++ b/libavcodec/videotoolboxenc.c
> > > > @@ -915,6 +915,22 @@ static int
> get_cv_transfer_function(AVCodecContext
> > > > *avctx,
> > > >              *transfer_fnc =
> > > > kCVImageBufferTransferFunction_SMPTE_240M_1995;
> > > >              break;
> > > >
> > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> > > > +        case AVCOL_TRC_SMPTE2084:
> > > > +            *transfer_fnc =
> > > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> > > > +            break;
> > > > +#endif
> > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> > > > +        case AVCOL_TRC_LINEAR:
> > > > +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> > > > +            break;
> > > > +#endif
> > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> > > > +        case AVCOL_TRC_ARIB_STD_B67:
> > > > +            *transfer_fnc =
> > > kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> > > > +            break;
> > > > +#endif
> > > > +
> > > >          case AVCOL_TRC_GAMMA22:
> > > >              gamma = 2.2;
> > > >              *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> > > > --
> > > > 2.21.0
> > > >
> > > > _______________________________________________
> > > > ffmpeg-devel mailing list
> > > > ffmpeg-devel@ffmpeg.org
> > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > >
> > > > To unsubscribe, visit link above, or email
> > > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > >
> >
> > A while back, a similar patch was rejected for NVENC (from the same
> author)
> > on the basis of such functionality not being suitably placed as an
> encoder
> > feature.
> >
> > Looking back at other implementations, eg hevc_vaapi, the same is indeed
> > allowed, where SEI metadata retention for HDR is present.
> >
> > To the OP: If the patch for NVENC were refactored in a manner similar to
> > this, abstracting details such as master display info for HDR (something
> > that was specifically flagged as not suitable as an encoder feature), it
> > might pass the patch review and be merged.
> >
> > Are there specific limitations (as implemented) that block such a feature
> > in NVENC? Perhaps the initial patch with mastering display controls for
> HDR
> > was written that way to circumvent such a limitation.
> >
>
> I think you are confusing the type of patches here. This does nothing
> but extend existing functionality to forward a few more values in
> basically an enum that was already being set.
> The other patch was about parsing user inputs and generating SEI data,
> which should arguably be done in a central place instead of every
> encoder individually.
>
> - Hendrik
>

Thanks for the clarification.

>
Rick Kern July 17, 2019, 1:36 a.m. UTC | #6
On Wed, Jul 10, 2019 at 5:29 AM Dennis Mungai <dmngaie@gmail.com> wrote:

> On Wed, Jul 10, 2019, 11:06 Hendrik Leppkes <h.leppkes@gmail.com> wrote:
>
> > On Wed, Jul 10, 2019 at 4:23 AM Dennis Mungai <dmngaie@gmail.com> wrote:
> > >
> > > On Wed, Jul 10, 2019, 03:05 Aman Gupta <ffmpeg@tmm1.net> wrote:
> > >
> > > > On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang@gmail.com> wrote:
> > > >
> > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > >
> > > > > Below is the testing ffmpeg command for the setting:
> > > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > > -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> > > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > > -colorspace bt2020_ncl -color_trc linear linear.ts
> > > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > > -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> > > > >
> > > >
> > > > Patch looks reasonable to me. Will commit in a few days if no one
> else
> > > > comments.
> > > >
> > > > Aman
> > > >
> > > >
> > > > >
> > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > ---
> > > > >  configure                    |  6 ++++++
> > > > >  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
> > > > >  2 files changed, 22 insertions(+)
> > > > >
> > > > > diff --git a/configure b/configure
> > > > > index 7cea9d4d73..0a5e940c0c 100755
> > > > > --- a/configure
> > > > > +++ b/configure
> > > > > @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
> > > > >  TYPES_LIST="
> > > > >      kCMVideoCodecType_HEVC
> > > > >      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> > > > > +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > > > > +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> > > > > +    kCVImageBufferTransferFunction_Linear
> > > > >      socklen_t
> > > > >      struct_addrinfo
> > > > >      struct_group_source_req
> > > > > @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
> > > > >      check_lib coreservices CoreServices/CoreServices.h
> > > > > UTGetOSTypeFromString "-framework CoreServices"
> > > > >      check_func_headers CoreMedia/CMFormatDescription.h
> > > > > kCMVideoCodecType_HEVC "-framework CoreMedia"
> > > > >      check_func_headers CoreVideo/CVPixelBuffer.h
> > > > > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework
> > CoreVideo"
> > > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework
> > CoreVideo"
> > > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > > kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework
> CoreVideo"
> > > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > > kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
> > > > >  }
> > > > >
> > > > >  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> > > > > diff --git a/libavcodec/videotoolboxenc.c
> > b/libavcodec/videotoolboxenc.c
> > > > > index f8ccdea52d..0dc6eb4cf4 100644
> > > > > --- a/libavcodec/videotoolboxenc.c
> > > > > +++ b/libavcodec/videotoolboxenc.c
> > > > > @@ -915,6 +915,22 @@ static int
> > get_cv_transfer_function(AVCodecContext
> > > > > *avctx,
> > > > >              *transfer_fnc =
> > > > > kCVImageBufferTransferFunction_SMPTE_240M_1995;
> > > > >              break;
> > > > >
> > > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> > > > > +        case AVCOL_TRC_SMPTE2084:
> > > > > +            *transfer_fnc =
> > > > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> > > > > +            break;
> > > > > +#endif
> > > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> > > > > +        case AVCOL_TRC_LINEAR:
> > > > > +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> > > > > +            break;
> > > > > +#endif
> > > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> > > > > +        case AVCOL_TRC_ARIB_STD_B67:
> > > > > +            *transfer_fnc =
> > > > kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> > > > > +            break;
> > > > > +#endif
> > > > > +
> > > > >          case AVCOL_TRC_GAMMA22:
> > > > >              gamma = 2.2;
> > > > >              *transfer_fnc =
> kCVImageBufferTransferFunction_UseGamma;
> > > > > --
> > > > > 2.21.0
> > > > >
> > > > > _______________________________________________
> > > > > ffmpeg-devel mailing list
> > > > > ffmpeg-devel@ffmpeg.org
> > > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > >
> > > > > To unsubscribe, visit link above, or email
> > > > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > > >
> > >
> > > A while back, a similar patch was rejected for NVENC (from the same
> > author)
> > > on the basis of such functionality not being suitably placed as an
> > encoder
> > > feature.
> > >
> > > Looking back at other implementations, eg hevc_vaapi, the same is
> indeed
> > > allowed, where SEI metadata retention for HDR is present.
> > >
> > > To the OP: If the patch for NVENC were refactored in a manner similar
> to
> > > this, abstracting details such as master display info for HDR
> (something
> > > that was specifically flagged as not suitable as an encoder feature),
> it
> > > might pass the patch review and be merged.
> > >
> > > Are there specific limitations (as implemented) that block such a
> feature
> > > in NVENC? Perhaps the initial patch with mastering display controls for
> > HDR
> > > was written that way to circumvent such a limitation.
> > >
> >
> > I think you are confusing the type of patches here. This does nothing
> > but extend existing functionality to forward a few more values in
> > basically an enum that was already being set.
> > The other patch was about parsing user inputs and generating SEI data,
> > which should arguably be done in a central place instead of every
> > encoder individually.
> >
> > - Hendrik
> >
>
> Thanks for the clarification.
>


Testing for the new transfer functions when compiling for OSX 10.12 reports
the color settings as "yuv420p(tv, bt2020nc/bt2020/reserved)" in ffprobe.
Is "reserved" (0) the expected default when the transfer function isn't
supported?



>
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Limin Wang July 17, 2019, 2:29 a.m. UTC | #7
On Tue, Jul 16, 2019 at 09:36:32PM -0400, Rick Kern wrote:
> On Wed, Jul 10, 2019 at 5:29 AM Dennis Mungai <dmngaie@gmail.com> wrote:
> 
> > On Wed, Jul 10, 2019, 11:06 Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> >
> > > On Wed, Jul 10, 2019 at 4:23 AM Dennis Mungai <dmngaie@gmail.com> wrote:
> > > >
> > > > On Wed, Jul 10, 2019, 03:05 Aman Gupta <ffmpeg@tmm1.net> wrote:
> > > >
> > > > > On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang@gmail.com> wrote:
> > > > >
> > > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > > >
> > > > > > Below is the testing ffmpeg command for the setting:
> > > > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > > > -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> > > > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > > > -colorspace bt2020_ncl -color_trc linear linear.ts
> > > > > > ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020
> > > > > > -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> > > > > >
> > > > >
> > > > > Patch looks reasonable to me. Will commit in a few days if no one
> > else
> > > > > comments.
> > > > >
> > > > > Aman
> > > > >
> > > > >
> > > > > >
> > > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > > ---
> > > > > >  configure                    |  6 ++++++
> > > > > >  libavcodec/videotoolboxenc.c | 16 ++++++++++++++++
> > > > > >  2 files changed, 22 insertions(+)
> > > > > >
> > > > > > diff --git a/configure b/configure
> > > > > > index 7cea9d4d73..0a5e940c0c 100755
> > > > > > --- a/configure
> > > > > > +++ b/configure
> > > > > > @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
> > > > > >  TYPES_LIST="
> > > > > >      kCMVideoCodecType_HEVC
> > > > > >      kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> > > > > > +    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > > > > > +    kCVImageBufferTransferFunction_ITU_R_2100_HLG
> > > > > > +    kCVImageBufferTransferFunction_Linear
> > > > > >      socklen_t
> > > > > >      struct_addrinfo
> > > > > >      struct_group_source_req
> > > > > > @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
> > > > > >      check_lib coreservices CoreServices/CoreServices.h
> > > > > > UTGetOSTypeFromString "-framework CoreServices"
> > > > > >      check_func_headers CoreMedia/CMFormatDescription.h
> > > > > > kCMVideoCodecType_HEVC "-framework CoreMedia"
> > > > > >      check_func_headers CoreVideo/CVPixelBuffer.h
> > > > > > kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework
> > > CoreVideo"
> > > > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework
> > > CoreVideo"
> > > > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > > > kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework
> > CoreVideo"
> > > > > > +    check_func_headers CoreVideo/CVImageBuffer.h
> > > > > > kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
> > > > > >  }
> > > > > >
> > > > > >  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> > > > > > diff --git a/libavcodec/videotoolboxenc.c
> > > b/libavcodec/videotoolboxenc.c
> > > > > > index f8ccdea52d..0dc6eb4cf4 100644
> > > > > > --- a/libavcodec/videotoolboxenc.c
> > > > > > +++ b/libavcodec/videotoolboxenc.c
> > > > > > @@ -915,6 +915,22 @@ static int
> > > get_cv_transfer_function(AVCodecContext
> > > > > > *avctx,
> > > > > >              *transfer_fnc =
> > > > > > kCVImageBufferTransferFunction_SMPTE_240M_1995;
> > > > > >              break;
> > > > > >
> > > > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> > > > > > +        case AVCOL_TRC_SMPTE2084:
> > > > > > +            *transfer_fnc =
> > > > > > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> > > > > > +            break;
> > > > > > +#endif
> > > > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> > > > > > +        case AVCOL_TRC_LINEAR:
> > > > > > +            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
> > > > > > +            break;
> > > > > > +#endif
> > > > > > +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> > > > > > +        case AVCOL_TRC_ARIB_STD_B67:
> > > > > > +            *transfer_fnc =
> > > > > kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> > > > > > +            break;
> > > > > > +#endif
> > > > > > +
> > > > > >          case AVCOL_TRC_GAMMA22:
> > > > > >              gamma = 2.2;
> > > > > >              *transfer_fnc =
> > kCVImageBufferTransferFunction_UseGamma;
> > > > > > --
> > > > > > 2.21.0
> > > > > >
> > > > > > _______________________________________________
> > > > > > ffmpeg-devel mailing list
> > > > > > ffmpeg-devel@ffmpeg.org
> > > > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > > >
> > > > > > To unsubscribe, visit link above, or email
> > > > > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > > > >
> > > >
> > > > A while back, a similar patch was rejected for NVENC (from the same
> > > author)
> > > > on the basis of such functionality not being suitably placed as an
> > > encoder
> > > > feature.
> > > >
> > > > Looking back at other implementations, eg hevc_vaapi, the same is
> > indeed
> > > > allowed, where SEI metadata retention for HDR is present.
> > > >
> > > > To the OP: If the patch for NVENC were refactored in a manner similar
> > to
> > > > this, abstracting details such as master display info for HDR
> > (something
> > > > that was specifically flagged as not suitable as an encoder feature),
> > it
> > > > might pass the patch review and be merged.
> > > >
> > > > Are there specific limitations (as implemented) that block such a
> > feature
> > > > in NVENC? Perhaps the initial patch with mastering display controls for
> > > HDR
> > > > was written that way to circumvent such a limitation.
> > > >
> > >
> > > I think you are confusing the type of patches here. This does nothing
> > > but extend existing functionality to forward a few more values in
> > > basically an enum that was already being set.
> > > The other patch was about parsing user inputs and generating SEI data,
> > > which should arguably be done in a central place instead of every
> > > encoder individually.
> > >
> > > - Hendrik
> > >
> >
> > Thanks for the clarification.
> >
> 
> 
> Testing for the new transfer functions when compiling for OSX 10.12 reports
> the color settings as "yuv420p(tv, bt2020nc/bt2020/reserved)" in ffprobe.
> Is "reserved" (0) the expected default when the transfer function isn't
> supported?
mac 10.13 support:
kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
kCVImageBufferTransferFunction_ITU_R_2100_HLG

OSX 10.14 support:
kCVImageBufferTransferFunction_Linear

For 10.12, the HAVE_* macros should be detected as 0 if correct.

> 
> 
> >
> > >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Vittorio Giovara July 17, 2019, 2:53 p.m. UTC | #8
On Tue, Jul 16, 2019 at 10:29 PM Limin Wang <lance.lmwang@gmail.com> wrote:

> On Tue, Jul 16, 2019 at 09:36:32PM -0400, Rick Kern wrote:
> > Testing for the new transfer functions when compiling for OSX 10.12
> reports
> > the color settings as "yuv420p(tv, bt2020nc/bt2020/reserved)" in ffprobe.
> > Is "reserved" (0) the expected default when the transfer function isn't
> > supported?
> mac 10.13 support:
> kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> kCVImageBufferTransferFunction_ITU_R_2100_HLG
>
> OSX 10.14 support:
> kCVImageBufferTransferFunction_Linear
>
> For 10.12, the HAVE_* macros should be detected as 0 if correct.
>

0 is a reserved value in the color specification and should be avoided if
possible.
Would it be possible to fallback on 2 (unknown) when these macros are not
found?
Limin Wang July 17, 2019, 10:57 p.m. UTC | #9
On Wed, Jul 17, 2019 at 10:53:08AM -0400, Vittorio Giovara wrote:
> On Tue, Jul 16, 2019 at 10:29 PM Limin Wang <lance.lmwang@gmail.com> wrote:
> 
> > On Tue, Jul 16, 2019 at 09:36:32PM -0400, Rick Kern wrote:
> > > Testing for the new transfer functions when compiling for OSX 10.12
> > reports
> > > the color settings as "yuv420p(tv, bt2020nc/bt2020/reserved)" in ffprobe.
> > > Is "reserved" (0) the expected default when the transfer function isn't
> > > supported?
> > mac 10.13 support:
> > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > kCVImageBufferTransferFunction_ITU_R_2100_HLG
> >
> > OSX 10.14 support:
> > kCVImageBufferTransferFunction_Linear
> >
> > For 10.12, the HAVE_* macros should be detected as 0 if correct.
> >
> 
> 0 is a reserved value in the color specification and should be avoided if
> possible.
> Would it be possible to fallback on 2 (unknown) when these macros are not
> found?

My old mac pro don't support hevc, so I can test it. Please check the
HAVE* is 0

➜  ffmpeg.git git:(videotoolboxenc_v2) ✗ sw_vers -productVersion
10.11.6
➜  ffmpeg.git git:(videotoolboxenc_v2) ✗ grep "HAVE_KCV*" config.h
#define HAVE_KCMVIDEOCODECTYPE_HEVC 1
#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0
#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0
#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0
#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0

I have submited another patch to fix it, please try whether it's OK.

> -- 
> Vittorio
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Limin Wang July 18, 2019, 6:50 a.m. UTC | #10
On Wed, Jul 17, 2019 at 10:53:08AM -0400, Vittorio Giovara wrote:
> On Tue, Jul 16, 2019 at 10:29 PM Limin Wang <lance.lmwang@gmail.com> wrote:
> 
> > On Tue, Jul 16, 2019 at 09:36:32PM -0400, Rick Kern wrote:
> > > Testing for the new transfer functions when compiling for OSX 10.12
> > reports
> > > the color settings as "yuv420p(tv, bt2020nc/bt2020/reserved)" in ffprobe.
> > > Is "reserved" (0) the expected default when the transfer function isn't
> > > supported?
> > mac 10.13 support:
> > kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> > kCVImageBufferTransferFunction_ITU_R_2100_HLG
> >
> > OSX 10.14 support:
> > kCVImageBufferTransferFunction_Linear
> >
> > For 10.12, the HAVE_* macros should be detected as 0 if correct.
> >
> 
> 0 is a reserved value in the color specification and should be avoided if
> possible.
> Would it be possible to fallback on 2 (unknown) when these macros are not
> found?

OSX have defined it as string and no such string map to 2(unknown), so if we 
failed to get the map string, it'll set to NULL and we'll not set the interface. 
Or we should check the result and failed the init to avoid it.

but it's not related to the patch, without it, you should get the same result.


> -- 
> Vittorio
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/configure b/configure
index 7cea9d4d73..0a5e940c0c 100755
--- a/configure
+++ b/configure
@@ -2260,6 +2260,9 @@  TOOLCHAIN_FEATURES="
 TYPES_LIST="
     kCMVideoCodecType_HEVC
     kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
+    kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
+    kCVImageBufferTransferFunction_ITU_R_2100_HLG
+    kCVImageBufferTransferFunction_Linear
     socklen_t
     struct_addrinfo
     struct_group_source_req
@@ -6044,6 +6047,9 @@  enabled videotoolbox && {
     check_lib coreservices CoreServices/CoreServices.h UTGetOSTypeFromString "-framework CoreServices"
     check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia"
     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
 }
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index f8ccdea52d..0dc6eb4cf4 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -915,6 +915,22 @@  static int get_cv_transfer_function(AVCodecContext *avctx,
             *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
             break;
 
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
+        case AVCOL_TRC_SMPTE2084:
+            *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
+            break;
+#endif
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
+        case AVCOL_TRC_LINEAR:
+            *transfer_fnc = kCVImageBufferTransferFunction_Linear;
+            break;
+#endif
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
+        case AVCOL_TRC_ARIB_STD_B67:
+            *transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
+            break;
+#endif
+
         case AVCOL_TRC_GAMMA22:
             gamma = 2.2;
             *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;