diff mbox series

[FFmpeg-devel,7/9] lavc/vaapi_decode: add profile_parser and format map support for HEVC REXT

Message ID 1579071722-13326-1-git-send-email-linjie.fu@intel.com
State New
Headers show
Series [FFmpeg-devel,1/9] lavu/pix_fmt: add new pixel format y210
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Fu, Linjie Jan. 15, 2020, 7:02 a.m. UTC
Add function pointer field in vaapi_profile_map[], set profile_parser
for HEVC_REXT to find the exact va_profile.

Also add format map support.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/vaapi_decode.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1..16a68ca 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,
@@ -256,6 +256,10 @@  static const struct {
 #ifdef VA_FOURCC_YV16
     MAP(YV16, YUV422P),
 #endif
+    MAP(YUY2, YUYV422),
+#ifdef VA_FOURCC_Y210
+    MAP(Y210,    Y210),
+#endif
     // 4:4:0
     MAP(422V, YUV440P),
     // 4:4:4
@@ -364,8 +368,9 @@  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 }
+#define MAP(c, p, v, ...) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v, __VA_ARGS__ }
     MAP(MPEG2VIDEO,  MPEG2_SIMPLE,    MPEG2Simple ),
     MAP(MPEG2VIDEO,  MPEG2_MAIN,      MPEG2Main   ),
     MAP(H263,        UNKNOWN,         H263Baseline),
@@ -381,6 +386,10 @@  static const struct {
     MAP(HEVC,        HEVC_MAIN,       HEVCMain    ),
     MAP(HEVC,        HEVC_MAIN_10,    HEVCMain10  ),
 #endif
+#if VA_CHECK_VERSION(1, 2, 0)
+    MAP(HEVC,        HEVC_REXT,       None,
+                 ff_vaapi_parse_hevc_rext_profile ),
+#endif
     MAP(MJPEG,       MJPEG_HUFFMAN_BASELINE_DCT,
                                       JPEGBaseline),
     MAP(WMV3,        VC1_SIMPLE,      VC1Simple   ),
@@ -415,8 +424,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, va_profile;
+    int profile_count, exact_match, matched_ff_profile, codec_profile;
 
     AVHWDeviceContext    *device = (AVHWDeviceContext*)device_ref->data;
     AVVAAPIDeviceContext *hwctx = device->hwctx;
@@ -454,15 +463,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;
+
+        va_profile = vaapi_profile_map[i].profile_parser ?
+                     vaapi_profile_map[i].profile_parser(avctx) :
+                     vaapi_profile_map[i].va_profile;
+        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 (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 = va_profile;
+            matched_ff_profile = codec_profile;
             if (exact_match)
                 break;
         }