On Sat, Sep 24, 2016 at 01:58:08PM +0200, Luca Barbato wrote:
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -88,13 +88,21 @@
>  
> +#define IS_10BIT(pix_fmt) (pix_fmt == AV_PIX_FMT_P010 ||    \
> +                           pix_fmt == AV_PIX_FMT_YUV444P16)
> +
> +#define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P || \
> +                            pix_fmt == AV_PIX_FMT_YUV444P16)
> +
> @@ -704,9 +712,45 @@ static int nvenc_setup_hevc_config(AVCodecContext *avctx)
>  
> -    /* No other profile is supported in the current SDK version 5 */
> -    cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
> -    avctx->profile  = FF_PROFILE_HEVC_MAIN;
> +    switch (ctx->profile) {
> +    case NV_ENC_HEVC_PROFILE_MAIN:
> +        cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
> +        avctx->profile  = FF_PROFILE_HEVC_MAIN;
> +        break;
> +
> +    #if NVENCAPI_MAJOR_VERSION > 6
> +    case NV_ENC_HEVC_PROFILE_MAIN_10:

Please move the #if to the first column, like we do everywhere else.

> +        cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID;

Please move the #if to the first column, like we do everywhere else.

> +    // force setting profile for various input formats
> +    if (ctx->data_pix_fmt == AV_PIX_FMT_YUV420P ||
> +        ctx->data_pix_fmt == AV_PIX_FMT_NV12) {
> +        cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
> +        avctx->profile  = FF_PROFILE_HEVC_MAIN;
> +    #if NVENCAPI_MAJOR_VERSION > 6
> +    } else if (ctx->data_pix_fmt == AV_PIX_FMT_P010) {
> +        cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID;
> +        avctx->profile  = FF_PROFILE_HEVC_MAIN_10;
> +    } else if (IS_YUV444(ctx->data_pix_fmt)) {
> +        cc->profileGUID = NV_ENC_HEVC_PROFILE_FREXT_GUID;
> +        avctx->profile  = FF_PROFILE_HEVC_REXT;
> +    #endif
> +    }

IMO this would be more readable as a switch/case statement.

> +    #if NVENCAPI_MAJOR_VERSION > 6
> +    hevc->chromaFormatIDC = IS_YUV444(ctx->data_pix_fmt) ? 3 : 1;
> +
> +    hevc->pixelBitDepthMinus8 = IS_10BIT(ctx->data_pix_fmt) ? 2 : 0;

align

Patch itself LGTM.

Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to