[FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the initialization postion of profile_string

Li, Zhong zhong.li at intel.com
Mon Nov 5 14:35:32 EET 2018


> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Monday, November 5, 2018 5:39 PM
> To: ffmpeg-devel at ffmpeg.org
> Cc: Fu, Linjie <linjie.fu at intel.com>
> Subject: [FFmpeg-devel] [PATCH] avcodec/vaapi_encode: modify the
> initialization postion of profile_string
> 
> Currently, profile_string was initialized in the "for" loop. If it didn't enter this
> loop or accidently break, profile_string may be uninitialized.
> 
> Modify to initialize the profile_string after the loop to avoid using the
> uninitialized value when calling av_log.
> 
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
>  libavcodec/vaapi_encode.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> 2c34cdce2c..b43b52f0e5 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1066,6 +1066,7 @@ static av_cold int
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>      }
> 
>      av_assert0(ctx->codec->profiles);
> +

Please don't introduce redundant line.

>      for (i = 0; (ctx->codec->profiles[i].av_profile !=
>                   FF_PROFILE_UNKNOWN); i++) {
>          profile = &ctx->codec->profiles[i]; @@ -1080,12 +1081,6 @@
> static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
>              avctx->profile != FF_PROFILE_UNKNOWN)
>              continue;
> 
> -#if VA_CHECK_VERSION(1, 0, 0)
> -        profile_string = vaProfileStr(profile->va_profile);
> -#else
> -        profile_string = "(no profile names)";
> -#endif
> -
>          for (j = 0; j < n; j++) {
>              if (va_profiles[j] == profile->va_profile)
>                  break;
> @@ -1107,6 +1102,11 @@ static av_cold int
> vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
> 
>      avctx->profile  = profile->av_profile;
>      ctx->va_profile = profile->va_profile;
> +#if VA_CHECK_VERSION(1, 0, 0)
> +    profile_string = vaProfileStr(profile->va_profile);
> +#else
> +    profile_string = "(no profile names)"; #endif
>      av_log(avctx, AV_LOG_VERBOSE, "Using VAAPI profile %s (%d).\n",
>             profile_string, ctx->va_profile);
> 
> --
> 2.17.1



More information about the ffmpeg-devel mailing list