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

2019-05-05 Thread Fu, Linjie
> -Original Message-
> From: Fu, Linjie
> Sent: Monday, April 29, 2019 01:53
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> 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 
> ---
> 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, ma

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

2019-04-28 Thread Linjie Fu
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 
---
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 =