24 #include <va/va_dec_hevc.h> 34 #if VA_CHECK_VERSION(1, 2, 0) 35 VAPictureParameterBufferHEVCExtension
pic_param;
49 va_pic->picture_id = VA_INVALID_ID;
50 va_pic->flags = VA_PICTURE_HEVC_INVALID;
51 va_pic->pic_order_cnt = 0;
57 va_pic->pic_order_cnt = pic->
poc;
58 va_pic->flags = rps_type;
61 va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
64 va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
67 va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
78 return VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE;
83 return VA_PICTURE_HEVC_RPS_ST_CURR_AFTER;
88 return VA_PICTURE_HEVC_RPS_LT_CURR;
127 int pic_param_size, err,
i;
129 VAPictureParameterBufferHEVC *
pic_param = (VAPictureParameterBufferHEVC *)&pic->
pic_param;
133 *pic_param = (VAPictureParameterBufferHEVC) {
134 .pic_width_in_luma_samples = sps->
width,
135 .pic_height_in_luma_samples = sps->
height,
143 .num_short_term_ref_pic_sets = sps->
nb_st_rps,
150 .pcm_sample_bit_depth_luma_minus1 = sps->
pcm.
bit_depth - 1,
156 .pps_tc_offset_div2 = pps->
tc_offset / 2,
158 .bit_depth_luma_minus8 = sps->
bit_depth - 8,
159 .bit_depth_chroma_minus8 = sps->
bit_depth - 8,
182 .slice_parsing_fields.bits = {
190 .sample_adaptive_offset_enabled_flag = sps->
sao_enabled,
192 .pps_disable_deblocking_filter_flag = pps->
disable_dbf,
208 pic_param->column_width_minus1[i] = pps->
column_width[i] - 1;
211 pic_param->row_height_minus1[i] = pps->
row_height[i] - 1;
217 pic_param->st_rps_bits = 0;
220 #if VA_CHECK_VERSION(1, 2, 0) 222 pic->
pic_param.rext = (VAPictureParameterBufferHEVCRext) {
223 .range_extension_pic_fields.bits = {
243 for (i = 0; i < 6; i++)
245 for (i = 0; i < 6; i++)
250 sizeof(pic->
pic_param) :
sizeof(VAPictureParameterBufferHEVC);
253 VAPictureParameterBufferType,
264 VAIQMatrixBufferHEVC iq_matrix;
267 for (i = 0; i < 6; i++) {
268 for (j = 0; j < 16; j++)
269 iq_matrix.ScalingList4x4[i][j] = scaling_list->
sl[0][i][j];
270 for (j = 0; j < 64; j++) {
271 iq_matrix.ScalingList8x8[
i][j] = scaling_list->
sl[1][
i][j];
272 iq_matrix.ScalingList16x16[
i][j] = scaling_list->
sl[2][
i][j];
274 iq_matrix.ScalingList32x32[
i][j] = scaling_list->
sl[3][i * 3][j];
276 iq_matrix.ScalingListDC16x16[
i] = scaling_list->
sl_dc[0][
i];
278 iq_matrix.ScalingListDC32x32[
i] = scaling_list->
sl_dc[1][i * 3];
282 VAIQMatrixBufferType,
283 &iq_matrix,
sizeof(iq_matrix));
306 last_slice_param->LongSliceFlags.fields.LastSliceOfPic = 1;
327 VASliceParameterBufferHEVC *slice_param)
331 memset(slice_param->delta_luma_weight_l0, 0,
sizeof(slice_param->delta_luma_weight_l0));
332 memset(slice_param->delta_luma_weight_l1, 0,
sizeof(slice_param->delta_luma_weight_l1));
333 memset(slice_param->luma_offset_l0, 0,
sizeof(slice_param->luma_offset_l0));
334 memset(slice_param->luma_offset_l1, 0,
sizeof(slice_param->luma_offset_l1));
335 memset(slice_param->delta_chroma_weight_l0, 0,
sizeof(slice_param->delta_chroma_weight_l0));
336 memset(slice_param->delta_chroma_weight_l1, 0,
sizeof(slice_param->delta_chroma_weight_l1));
337 memset(slice_param->ChromaOffsetL0, 0,
sizeof(slice_param->ChromaOffsetL0));
338 memset(slice_param->ChromaOffsetL1, 0,
sizeof(slice_param->ChromaOffsetL1));
340 slice_param->delta_chroma_log2_weight_denom = 0;
341 slice_param->luma_log2_weight_denom = 0;
354 for (i = 0; i < 15 && i < sh->
nb_refs[
L0]; i++) {
364 for (i = 0; i < 15 && i < sh->
nb_refs[
L1]; i++) {
378 VAPictureParameterBufferHEVC *pp = (VAPictureParameterBufferHEVC *)&pic->
pic_param;
385 VASurfaceID pid = pp->ReferenceFrames[
i].picture_id;
386 int poc = pp->ReferenceFrames[
i].pic_order_cnt;
409 int err,
i, list_idx;
423 *last_slice_param = (VASliceParameterBufferHEVC) {
424 .slice_data_size =
size,
425 .slice_data_offset = 0,
426 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
435 .slice_tc_offset_div2 = sh->
tc_offset / 2,
441 .LongSliceFlags.fields = {
458 for (list_idx = 0; list_idx < nb_list; list_idx++) {
467 #if VA_CHECK_VERSION(1, 2, 0) 469 pic->last_slice_param.rext = (VASliceParameterBufferHEVCRext) {
470 .slice_ext_flags.bits = {
471 .cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag,
475 memcpy(
pic->last_slice_param.rext.luma_offset_l0,
pic->last_slice_param.base.luma_offset_l0,
476 sizeof(
pic->last_slice_param.base.luma_offset_l0));
477 memcpy(
pic->last_slice_param.rext.luma_offset_l1,
pic->last_slice_param.base.luma_offset_l1,
478 sizeof(
pic->last_slice_param.base.luma_offset_l1));
479 memcpy(
pic->last_slice_param.rext.ChromaOffsetL0,
pic->last_slice_param.base.ChromaOffsetL0,
480 sizeof(
pic->last_slice_param.base.ChromaOffsetL0));
481 memcpy(
pic->last_slice_param.rext.ChromaOffsetL1,
pic->last_slice_param.base.ChromaOffsetL1,
482 sizeof(
pic->last_slice_param.base.ChromaOffsetL1));
501 #define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name 546 #if VA_CHECK_VERSION(1, 2, 0) 547 if (!strcmp(profile->
name,
"Main 4:2:2 10") ||
548 !strcmp(profile->
name,
"Main 4:2:2 10 Intra"))
549 return VAProfileHEVCMain422_10;
550 else if (!strcmp(profile->
name,
"Main 4:4:4") ||
551 !strcmp(profile->
name,
"Main 4:4:4 Intra"))
552 return VAProfileHEVCMain444;
553 else if (!strcmp(profile->
name,
"Main 4:4:4 10") ||
554 !strcmp(profile->
name,
"Main 4:4:4 10 Intra"))
555 return VAProfileHEVCMain444_10;
558 "not supported with this VA version.\n", profile->
name);
564 return VAProfileHEVCMain;
566 return VAProfileNone;
570 .
name =
"hevc_vaapi",
unsigned int log2_min_cb_size
int extended_precision_processing_flag
uint8_t log2_sao_offset_scale_luma
uint8_t diff_cu_chroma_qp_offset_depth
static int vaapi_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
int max_dec_pic_buffering
int transform_skip_rotation_enabled_flag
#define AV_LOG_WARNING
Something somehow does not look correct.
static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_type)
unsigned int * row_height
RowHeight.
static av_cold int init(AVCodecContext *avctx)
void * hwaccel_picture_private
int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, int type, const void *data, size_t size)
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
uint8_t weighted_bipred_flag
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
static void fill_vaapi_reference_frames(const HEVCContext *h, VAPictureParameterBufferHEVC *pp)
static void init_vaapi_pic(VAPictureHEVC *va_pic)
int explicit_rdpcm_enabled_flag
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
int8_t cr_qp_offset_list[6]
static int FUNC() scaling_list(CodedBitstreamContext *ctx, RWContext *rw, H264RawScalingList *current, int size_of_scaling_list)
uint8_t general_profile_idc
const AVHWAccel ff_hevc_vaapi_hwaccel
uint8_t entropy_coding_sync_enabled_flag
int ff_vaapi_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
int log2_parallel_merge_level
log2_parallel_merge_level_minus2 + 2
static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel *h265_raw_ptl)
uint8_t log2_sao_offset_scale_chroma
unsigned int log2_max_trafo_size
int ff_vaapi_decode_uninit(AVCodecContext *avctx)
uint8_t profile_compatibility_flag[32]
static av_cold int uninit(AVCodecContext *avctx)
uint8_t log2_max_transform_skip_block_size
int ff_vaapi_decode_issue(AVCodecContext *avctx, VAAPIDecodePicture *pic)
struct HEVCFrame * ref[HEVC_MAX_REFS]
static av_cold int end(AVCodecContext *avctx)
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
unsigned int log2_min_pcm_cb_size
struct HEVCSPS::@69 temporal_layer[HEVC_MAX_SUB_LAYERS]
const H265RawProfileTierLevel * ptl
uint8_t scaling_list_data_present_flag
int high_precision_offsets_enabled_flag
static int get_bits_count(const GetBitContext *s)
static void fill_pred_weight_table(const HEVCContext *h, const SliceHeader *sh, VASliceParameterBufferHEVC *slice_param)
#define AV_LOG_VERBOSE
Detailed information.
int interlaced_frame
The content of the picture is interlaced.
uint8_t loop_filter_disable_flag
int8_t cb_qp_offset_list[6]
uint8_t transquant_bypass_enable_flag
static int vaapi_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
unsigned int log2_max_poc_lsb
#define HEVC_FRAME_FLAG_LONG_REF
int persistent_rice_adaptation_enabled_flag
static int vaapi_hevc_end_frame(AVCodecContext *avctx)
uint8_t general_tier_flag
#define HEVC_FRAME_FLAG_SHORT_REF
uint8_t tiles_enabled_flag
#define HWACCEL_CAP_ASYNC_SAFE
uint8_t lists_modification_present_flag
const char * name
Name of the hardware accelerated codec.
int max_transform_hierarchy_depth_inter
int ff_vaapi_decode_init(AVCodecContext *avctx)
uint8_t cu_qp_delta_enabled_flag
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
uint8_t sign_data_hiding_flag
uint8_t output_flag_present_flag
int implicit_rdpcm_enabled_flag
#define FF_ARRAY_ELEMS(a)
uint8_t constrained_intra_pred_flag
VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx)
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
VASurfaceID output_surface
uint8_t transform_skip_enabled_flag
uint16_t num_tile_columns
num_tile_columns_minus1 + 1
Libavcodec external API header.
const uint8_t * last_buffer
VASliceParameterBufferHEVC last_slice_param
main external API structure.
int num_extra_slice_header_bits
VAPictureParameterBufferHEVC pic_param
uint8_t loop_filter_across_tiles_enabled_flag
static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame)
uint8_t num_long_term_ref_pics_sps
uint8_t cross_component_prediction_enabled_flag
int transform_skip_context_enabled_flag
uint8_t sps_temporal_mvp_enabled_flag
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
uint8_t chroma_qp_offset_list_enabled_flag
static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
unsigned int log2_min_tb_size
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
uint8_t general_profile_compatibility_flag[32]
uint8_t scaling_list_enable_flag
int tc_offset
tc_offset_div2 * 2
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
int ff_vaapi_decode_cancel(AVCodecContext *avctx, VAAPIDecodePicture *pic)
HEVCLocalContext * HEVClc
F H1 F F H1 F F F F H1<-F-------F-------F v v v H2 H3 H2^^^F-------F-------F-> H1<-F-------F-------F|||||||||F H1 F|||||||||F H1 Funavailable fullpel samples(outside the picture for example) shall be equalto the closest available fullpel sampleSmaller pel interpolation:--------------------------if diag_mc is set then points which lie on a line between 2 vertically, horizontally or diagonally adjacent halfpel points shall be interpolatedlinearly with rounding to nearest and halfway values rounded up.points which lie on 2 diagonals at the same time should only use the onediagonal not containing the fullpel point F--> O q O<--h1-> O q O<--F v\/v\/v O O O O O O O|/|\|q q q q q|/|\|O O O O O O O^/\^/\^h2--> O q O<--h3-> O q O<--h2 v\/v\/v O O O O O O O|\|/|q q q q q|\|/|O O O O O O O^/\^/\^F--> O q O<--h1-> O q O<--Fthe remaining points shall be bilinearly interpolated from theup to 4 surrounding halfpel and fullpel points, again rounding should be tonearest and halfway values rounded upcompliant Snow decoders MUST support 1-1/8 pel luma and 1/2-1/16 pel chromainterpolation at leastOverlapped block motion compensation:-------------------------------------FIXMELL band prediction:===================Each sample in the LL0 subband is predicted by the median of the left, top andleft+top-topleft samples, samples outside the subband shall be considered tobe 0.To reverse this prediction in the decoder apply the following.for(y=0;y< height;y++){for(x=0;x< width;x++){sample[y][x]+=median(sample[y-1][x], sample[y][x-1], sample[y-1][x]+sample[y][x-1]-sample[y-1][x-1]);}}sample[-1][*]=sample[*][-1]=0;width, height here are the width and height of the LL0 subband not of the finalvideoDequantization:===============FIXMEWavelet Transform:==================Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integertransform and an integer approximation of the symmetric biorthogonal 9/7daubechies wavelet.2D IDWT(inverse discrete wavelet transform)--------------------------------------------The 2D IDWT applies a 2D filter recursively, each time combining the4 lowest frequency subbands into a single subband until only 1 subbandremains.The 2D filter is done by first applying a 1D filter in the vertical directionand then applying it in the horizontal one.------------------------------------------------------------|LL0|HL0|||||||||||||---+---|HL1||L0|H0|HL1||LL1|HL1|||||LH0|HH0|||||||||||||-------+-------|-> L1 H1 LH1 HH1 LH1 HH1 LH1 HH1 L1
unsigned int log2_diff_max_min_coding_block_size
unsigned int log2_max_pcm_cb_size
int max_transform_hierarchy_depth_intra
uint8_t weighted_pred_flag
uint16_t num_tile_rows
num_tile_rows_minus1 + 1
unsigned int * column_width
ColumnWidth.
uint8_t slice_header_extension_present_flag
int cabac_bypass_alignment_enabled_flag
coded frame dimension in various units
uint8_t chroma_qp_offset_list_len_minus1
#define FF_PROFILE_HEVC_REXT
uint8_t sps_strong_intra_smoothing_enable_flag
int top_field_first
If the content is interlaced, is top field displayed first.
uint8_t long_term_ref_pics_present_flag
int diff_cu_qp_delta_depth
#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
Hardware acceleration should still be attempted for decoding when the codec profile does not match th...
int hwaccel_flags
Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated decoding (if active)...
uint8_t general_profile_space
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
const H265ProfileDescriptor * ff_h265_get_profile(const H265RawProfileTierLevel *ptl)
int intra_smoothing_disabled_flag
int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, const void *params_data, size_t params_size, const void *slice_data, size_t slice_size)
uint8_t separate_colour_plane_flag
uint8_t dependent_slice_segments_enabled_flag