[FFmpeg-devel] [PATCH 3/3, v5] lavc/vaapi_decode: add profile_parser to find the exact va_profile

Fu, Linjie linjie.fu at intel.com
Mon May 6 09:20:46 EEST 2019


> -----Original Message-----
> From: Fu, Linjie
> Sent: Monday, April 29, 2019 01:53
> To: ffmpeg-devel at ffmpeg.org
> Cc: Fu, Linjie <linjie.fu at intel.com>
> Subject: [PATCH 3/3,v5] lavc/vaapi_decode: add profile_parser to find the
> exact va_profile
> 
> Add function pointer field in vaapi_profile_map[], set profile_parser
> for HEVC_REXT to find the exact va_profile.
> 
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
> SPS range extension fields should be passed to decoder, will use
> VAPictureParameterBufferHEVCExtension consist of base and rext.
> 
>  libavcodec/vaapi_decode.c | 71 ++++++++++++++++++++++-----------------
>  1 file changed, 41 insertions(+), 30 deletions(-)
> 
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index 69512e1d45..7c9cfbc0ed 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -24,7 +24,7 @@
>  #include "decode.h"
>  #include "internal.h"
>  #include "vaapi_decode.h"
> -
> +#include "vaapi_hevc.h"
> 
>  int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
>                                        VAAPIDecodePicture *pic,
> @@ -364,39 +364,44 @@ static const struct {
>      enum AVCodecID codec_id;
>      int codec_profile;
>      VAProfile va_profile;
> +    VAProfile (*profile_parser)(AVCodecContext *avctx);
>  } vaapi_profile_map[] = {
> -#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ##
> v }
> -    MAP(MPEG2VIDEO,  MPEG2_SIMPLE,    MPEG2Simple ),
> -    MAP(MPEG2VIDEO,  MPEG2_MAIN,      MPEG2Main   ),
> -    MAP(H263,        UNKNOWN,         H263Baseline),
> -    MAP(MPEG4,       MPEG4_SIMPLE,    MPEG4Simple ),
> +#define MAP(c, p, v, f) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile
> ## v, f}
> +    MAP(MPEG2VIDEO,  MPEG2_SIMPLE,    MPEG2Simple , NULL ),
> +    MAP(MPEG2VIDEO,  MPEG2_MAIN,      MPEG2Main   , NULL ),
> +    MAP(H263,        UNKNOWN,         H263Baseline, NULL ),
> +    MAP(MPEG4,       MPEG4_SIMPLE,    MPEG4Simple , NULL ),
>      MAP(MPEG4,       MPEG4_ADVANCED_SIMPLE,
> -                               MPEG4AdvancedSimple),
> -    MAP(MPEG4,       MPEG4_MAIN,      MPEG4Main   ),
> +                               MPEG4AdvancedSimple, NULL ),
> +    MAP(MPEG4,       MPEG4_MAIN,      MPEG4Main   , NULL ),
>      MAP(H264,        H264_CONSTRAINED_BASELINE,
> -                           H264ConstrainedBaseline),
> -    MAP(H264,        H264_MAIN,       H264Main    ),
> -    MAP(H264,        H264_HIGH,       H264High    ),
> +                           H264ConstrainedBaseline, NULL ),
> +    MAP(H264,        H264_MAIN,       H264Main    , NULL ),
> +    MAP(H264,        H264_HIGH,       H264High    , NULL ),
>  #if VA_CHECK_VERSION(0, 37, 0)
> -    MAP(HEVC,        HEVC_MAIN,       HEVCMain    ),
> -    MAP(HEVC,        HEVC_MAIN_10,    HEVCMain10  ),
> +    MAP(HEVC,        HEVC_MAIN,       HEVCMain    , NULL ),
> +    MAP(HEVC,        HEVC_MAIN_10,    HEVCMain10  , NULL ),
> +#endif
> +#if VA_CHECK_VERSION(1, 2, 0)
> +    MAP(HEVC,        HEVC_REXT,       None,
> +                              ff_vaapi_parse_rext_profile),
>  #endif
>      MAP(MJPEG,       MJPEG_HUFFMAN_BASELINE_DCT,
> -                                      JPEGBaseline),
> -    MAP(WMV3,        VC1_SIMPLE,      VC1Simple   ),
> -    MAP(WMV3,        VC1_MAIN,        VC1Main     ),
> -    MAP(WMV3,        VC1_COMPLEX,     VC1Advanced ),
> -    MAP(WMV3,        VC1_ADVANCED,    VC1Advanced ),
> -    MAP(VC1,         VC1_SIMPLE,      VC1Simple   ),
> -    MAP(VC1,         VC1_MAIN,        VC1Main     ),
> -    MAP(VC1,         VC1_COMPLEX,     VC1Advanced ),
> -    MAP(VC1,         VC1_ADVANCED,    VC1Advanced ),
> -    MAP(VP8,         UNKNOWN,       VP8Version0_3 ),
> +                                      JPEGBaseline, NULL ),
> +    MAP(WMV3,        VC1_SIMPLE,      VC1Simple   , NULL ),
> +    MAP(WMV3,        VC1_MAIN,        VC1Main     , NULL ),
> +    MAP(WMV3,        VC1_COMPLEX,     VC1Advanced , NULL ),
> +    MAP(WMV3,        VC1_ADVANCED,    VC1Advanced , NULL ),
> +    MAP(VC1,         VC1_SIMPLE,      VC1Simple   , NULL ),
> +    MAP(VC1,         VC1_MAIN,        VC1Main     , NULL ),
> +    MAP(VC1,         VC1_COMPLEX,     VC1Advanced , NULL ),
> +    MAP(VC1,         VC1_ADVANCED,    VC1Advanced , NULL ),
> +    MAP(VP8,         UNKNOWN,       VP8Version0_3 , NULL ),
>  #if VA_CHECK_VERSION(0, 38, 0)
> -    MAP(VP9,         VP9_0,           VP9Profile0 ),
> +    MAP(VP9,         VP9_0,           VP9Profile0 , NULL ),
>  #endif
>  #if VA_CHECK_VERSION(0, 39, 0)
> -    MAP(VP9,         VP9_2,           VP9Profile2 ),
> +    MAP(VP9,         VP9_2,           VP9Profile2 , NULL ),
>  #endif
>  #undef MAP
>  };
> @@ -415,8 +420,8 @@ static int
> vaapi_decode_make_config(AVCodecContext *avctx,
>      VAStatus vas;
>      int err, i, j;
>      const AVCodecDescriptor *codec_desc;
> -    VAProfile *profile_list = NULL, matched_va_profile;
> -    int profile_count, exact_match, matched_ff_profile;
> +    VAProfile *profile_list = NULL, matched_va_profile, tmp_va_profile;
> +    int profile_count, exact_match, matched_ff_profile, tmp_codec_profile;
> 
>      AVHWDeviceContext    *device = (AVHWDeviceContext*)device_ref-
> >data;
>      AVVAAPIDeviceContext *hwctx = device->hwctx;
> @@ -454,15 +459,21 @@ static int
> vaapi_decode_make_config(AVCodecContext *avctx,
>          if (avctx->profile == vaapi_profile_map[i].codec_profile ||
>              vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN)
>              profile_match = 1;
> +
> +        tmp_va_profile = vaapi_profile_map[i].profile_parser ?
> +                         vaapi_profile_map[i].profile_parser(avctx) :
> +                         vaapi_profile_map[i].va_profile;
> +        tmp_codec_profile = vaapi_profile_map[i].codec_profile;
> +
>          for (j = 0; j < profile_count; j++) {
> -            if (vaapi_profile_map[i].va_profile == profile_list[j]) {
> +            if (tmp_va_profile == profile_list[j]) {
>                  exact_match = profile_match;
>                  break;
>              }
>          }
>          if (j < profile_count) {
> -            matched_va_profile = vaapi_profile_map[i].va_profile;
> -            matched_ff_profile = vaapi_profile_map[i].codec_profile;
> +            matched_va_profile = tmp_va_profile;
> +            matched_ff_profile = tmp_codec_profile;
>              if (exact_match)
>                  break;
>          }
> --
> 2.17.1

Any comment for this?
For "the SPS range extension fields should be passed to decoder ",
the whole patch set for 422/422_10/444/444_10 vaapi decode support (gen 11 +)
can be access at intel-media-ci /ffmpeg repo:
https://github.com/intel-media-ci/ffmpeg/pull/41

Thanks in advance.
Linjie


More information about the ffmpeg-devel mailing list