[FFmpeg-devel] [PATCH] lavc/videotoolboxenc.c: Add trc for iec61966-2-1 when available

Rick Kern kernrj at gmail.com
Fri Aug 13 15:55:12 EEST 2021


On Fri, Jul 23, 2021 at 4:31 AM Hao Guan <hguandl at gmail.com> wrote:

> Signed-off-by: Hao Guan <hguandl at gmail.com>
> ---
>
> Notes:
>     I have checked out the code about other functions introduced after
> macOS 10.13 and noticed that the availability is checked during configure.
> Therefore I add the check for sRGB function too. It should compile now.
>
>  configure                    | 2 ++
>  libavcodec/videotoolboxenc.c | 5 +++++
>  2 files changed, 7 insertions(+)
>
> diff --git a/configure b/configure
> index bb6b096414..644d9f3537 100755
> --- a/configure
> +++ b/configure
> @@ -2325,6 +2325,7 @@ TYPES_LIST="
>      kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
>      kCVImageBufferTransferFunction_ITU_R_2100_HLG
>      kCVImageBufferTransferFunction_Linear
> +    kCVImageBufferTransferFunction_sRGB
>      socklen_t
>      struct_addrinfo
>      struct_group_source_req
> @@ -6278,6 +6279,7 @@ enabled videotoolbox && {
>      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_func_headers CoreVideo/CVImageBuffer.h
> kCVImageBufferTransferFunction_sRGB "-framework CoreVideo"
>
Instead of being checked at build time, this should be checked at runtime
by adding it to compat_keys in videotoolboxenc.c. The reason is newer MacOS
versions will compile with this symbol, but if the build is targeting an
older MacOS version, it will crash on the older version because it can't
find the symbol.

 }
>
>  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 4eaabed5d8..4cba781e9b 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -977,6 +977,11 @@ static int get_cv_transfer_function(AVCodecContext
> *avctx,
>              *transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
>              break;
>  #endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SRGB
> +        case AVCOL_TRC_IEC61966_2_1:
> +            *transfer_fnc = kCVImageBufferTransferFunction_sRGB;
> +            break;
> +#endif
>
>          case AVCOL_TRC_GAMMA22:
>              gamma = 2.2;
> --
> 2.30.1 (Apple Git-130)
>
> _______________________________________________
> 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