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

Aman Gupta ffmpeg at tmm1.net
Wed Jul 10 02:40:55 EEST 2019


On Wed, Jun 26, 2019 at 4:25 AM <lance.lmwang at gmail.com> wrote:

> From: Limin Wang <lance.lmwang at 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 at 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 at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list