From patchwork Thu Apr 4 08:10:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 12611 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4366F446B6E for ; Thu, 4 Apr 2019 11:09:22 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1FC9068AE19; Thu, 4 Apr 2019 11:09:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A6E2568ADAE for ; Thu, 4 Apr 2019 11:09:15 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 01:09:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="333685716" Received: from media_lj_kbl.sh.intel.com ([10.239.13.101]) by fmsmga006.fm.intel.com with ESMTP; 04 Apr 2019 01:09:12 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2019 16:10:35 +0800 Message-Id: <20190404081035.19453-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH, v3 RFC 2/2] lavc/vaapi_decode: find exact va_profile for HEVC_REXT X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Use the profile constraint flags to determine the exact va_profile for HEVC_REXT. Directly cast PTLCommon to H265RawProfileTierLevel, and use ff_h265_get_profile to get the exact profile. Signed-off-by: Linjie Fu --- [v2]: use constraint flags to determine the exact profile, expose the codec-specific stuff at the beginning. [v3]: move the VA version check to fix the compile issue. [RFC]: is it acceptable to cast PTLCommon to H265RawProfileTierLevel for convenience? The members in PTLCommon should be strictly matched in H265RawProfileTierLevel. libavcodec/vaapi_decode.c | 73 +++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 69512e1d45..47db6c874a 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -24,6 +24,8 @@ #include "decode.h" #include "internal.h" #include "vaapi_decode.h" +#include "hevcdec.h" +#include "h265_profile_level.h" int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx, @@ -401,6 +403,33 @@ static const struct { #undef MAP }; +/* + * Find exact va_profile for HEVC Range Extension + */ +static VAProfile vaapi_decode_find_exact_profile(AVCodecContext *avctx) +{ + const HEVCContext *h = avctx->priv_data; + const HEVCSPS *sps = h->ps.sps; + const PTL *ptl = &(sps->ptl); + const PTLCommon *general_ptl = &(ptl->general_ptl); + const H265ProfileDescriptor *profile; + + /* PTLCommon should match the member sequence in H265RawProfileTierLevel*/ + profile = ff_h265_get_profile((H265RawProfileTierLevel *)general_ptl); + +#if VA_CHECK_VERSION(1, 2, 0) + if (!strcmp(profile->name, "Main 4:2:2 10")) + return VAProfileHEVCMain422_10; + else if (!strcmp(profile->name, "Main 4:4:4")) + return VAProfileHEVCMain444; + else if (!strcmp(profile->name, "Main 4:4:4 10")) + return VAProfileHEVCMain444_10; +#else + av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is " + "not supported with this VA version.\n", profile->name); +#endif + return VAProfileNone; +} /* * Set *va_config and the frames_ref fields from the current codec parameters * in avctx. @@ -447,24 +476,38 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, matched_va_profile = VAProfileNone; exact_match = 0; - for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) { - int profile_match = 0; - if (avctx->codec_id != vaapi_profile_map[i].codec_id) - continue; - if (avctx->profile == vaapi_profile_map[i].codec_profile || - vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN) - profile_match = 1; - for (j = 0; j < profile_count; j++) { - if (vaapi_profile_map[i].va_profile == profile_list[j]) { - exact_match = profile_match; + if (avctx->profile == FF_PROFILE_HEVC_REXT) { + /* find the exact va_profile for HEVC_REXT */ + VAProfile va_profile = vaapi_decode_find_exact_profile(avctx); + for (i = 0; i < profile_count; i++) { + if (va_profile == profile_list[i]) { + exact_match = 1; + matched_va_profile = va_profile; + matched_ff_profile = FF_PROFILE_HEVC_REXT; break; } } - if (j < profile_count) { - matched_va_profile = vaapi_profile_map[i].va_profile; - matched_ff_profile = vaapi_profile_map[i].codec_profile; - if (exact_match) - break; + } else { + /* find the exact va_profile according to codec_id and profile */ + for (i = 0; i < FF_ARRAY_ELEMS(vaapi_profile_map); i++) { + int profile_match = 0; + if (avctx->codec_id != vaapi_profile_map[i].codec_id) + continue; + if (avctx->profile == vaapi_profile_map[i].codec_profile || + vaapi_profile_map[i].codec_profile == FF_PROFILE_UNKNOWN) + profile_match = 1; + for (j = 0; j < profile_count; j++) { + if (vaapi_profile_map[i].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; + if (exact_match) + break; + } } } av_freep(&profile_list);