|
|
|
@@ -27,6 +27,8 @@ |
|
|
|
#include "hevcdec.h" |
|
|
|
#include "hwaccel.h" |
|
|
|
#include "vaapi_decode.h" |
|
|
|
#include "vaapi_hevc.h" |
|
|
|
#include "h265_profile_level.h" |
|
|
|
|
|
|
|
typedef struct VAAPIDecodePictureHEVC { |
|
|
|
#if VA_CHECK_VERSION(1, 2, 0) |
|
|
|
@@ -487,6 +489,82 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx, |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel *h265_raw_ptl) |
|
|
|
{ |
|
|
|
h265_raw_ptl->general_profile_space = general_ptl->profile_space; |
|
|
|
h265_raw_ptl->general_tier_flag = general_ptl->tier_flag; |
|
|
|
h265_raw_ptl->general_profile_idc = general_ptl->profile_idc; |
|
|
|
|
|
|
|
memcpy(h265_raw_ptl->general_profile_compatibility_flag, |
|
|
|
general_ptl->profile_compatibility_flag, 32 * sizeof(uint8_t)); |
|
|
|
|
|
|
|
#define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name |
|
|
|
copy_field(progressive_source_flag); |
|
|
|
copy_field(interlaced_source_flag); |
|
|
|
copy_field(non_packed_constraint_flag); |
|
|
|
copy_field(frame_only_constraint_flag); |
|
|
|
copy_field(max_12bit_constraint_flag); |
|
|
|
copy_field(max_10bit_constraint_flag); |
|
|
|
copy_field(max_422chroma_constraint_flag); |
|
|
|
copy_field(max_420chroma_constraint_flag); |
|
|
|
copy_field(max_monochrome_constraint_flag); |
|
|
|
copy_field(intra_constraint_flag); |
|
|
|
copy_field(one_picture_only_constraint_flag); |
|
|
|
copy_field(lower_bit_rate_constraint_flag); |
|
|
|
copy_field(max_14bit_constraint_flag); |
|
|
|
copy_field(inbld_flag); |
|
|
|
copy_field(level_idc); |
|
|
|
#undef copy_field |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Find exact va_profile for HEVC Range Extension |
|
|
|
*/ |
|
|
|
VAProfile ff_vaapi_parse_hevc_rext_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; |
|
|
|
H265RawProfileTierLevel h265_raw_ptl = {0}; |
|
|
|
|
|
|
|
/* convert PTLCommon to H265RawProfileTierLevel */ |
|
|
|
ptl_convert(general_ptl, &h265_raw_ptl); |
|
|
|
|
|
|
|
profile = ff_h265_get_profile(&h265_raw_ptl); |
|
|
|
if (!profile) { |
|
|
|
av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n"); |
|
|
|
goto end; |
|
|
|
} else { |
|
|
|
av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n", profile->name); |
|
|
|
} |
|
|
|
|
|
|
|
#if VA_CHECK_VERSION(1, 2, 0) |
|
|
|
if (!strcmp(profile->name, "Main 4:2:2 10") || |
|
|
|
!strcmp(profile->name, "Main 4:2:2 10 Intra")) |
|
|
|
return VAProfileHEVCMain422_10; |
|
|
|
else if (!strcmp(profile->name, "Main 4:4:4") || |
|
|
|
!strcmp(profile->name, "Main 4:4:4 Intra")) |
|
|
|
return VAProfileHEVCMain444; |
|
|
|
else if (!strcmp(profile->name, "Main 4:4:4 10") || |
|
|
|
!strcmp(profile->name, "Main 4:4:4 10 Intra")) |
|
|
|
return VAProfileHEVCMain444_10; |
|
|
|
#else |
|
|
|
av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is " |
|
|
|
"not supported with this VA version.\n", profile->name); |
|
|
|
#endif |
|
|
|
|
|
|
|
end: |
|
|
|
if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) { |
|
|
|
// Default to selecting Main profile if profile mismatch is allowed |
|
|
|
return VAProfileHEVCMain; |
|
|
|
} else |
|
|
|
return VAProfileNone; |
|
|
|
} |
|
|
|
|
|
|
|
const AVHWAccel ff_hevc_vaapi_hwaccel = { |
|
|
|
.name = "hevc_vaapi", |
|
|
|
.type = AVMEDIA_TYPE_VIDEO, |
|
|
|
|