45 va_pic->picture_id = VA_INVALID_ID;
46 va_pic->flags = VA_PICTURE_HEVC_INVALID;
47 va_pic->pic_order_cnt = 0;
53 va_pic->pic_order_cnt = pic->
poc;
54 va_pic->flags = rps_type;
57 va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
60 va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
63 va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
75 return VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE;
80 return VA_PICTURE_HEVC_RPS_ST_CURR_AFTER;
85 return VA_PICTURE_HEVC_RPS_LT_CURR;
117 VAPictureParameterBufferHEVC *pp = frame_data->
pic_param;
124 VASurfaceID pid = pp->ReferenceFrames[i].picture_id;
125 int poc = pp->ReferenceFrames[i].pic_order_cnt;
137 pp->pic_fields.value = 0;
138 pp->slice_parsing_fields.value = 0;
143 pp->pic_width_in_luma_samples = h->
ps.
sps->
width;
144 pp->pic_height_in_luma_samples = h->
ps.
sps->
height;
189 memset(pp->column_width_minus1, 0,
sizeof(pp->column_width_minus1));
190 memset(pp->row_height_minus1, 0,
sizeof(pp->row_height_minus1));
219 pp->slice_parsing_fields.bits.sample_adaptive_offset_enabled_flag = h->
ps.
sps->
sao_enabled;
221 pp->slice_parsing_fields.bits.pps_disable_deblocking_filter_flag = h->
ps.
pps->
disable_dbf;
228 pp->slice_parsing_fields.bits.RapPicFlag = 1;
230 pp->slice_parsing_fields.bits.RapPicFlag = 0;
234 pp->slice_parsing_fields.bits.IdrPicFlag = 1;
236 pp->slice_parsing_fields.bits.IdrPicFlag = 0;
240 pp->slice_parsing_fields.bits.IntraPicFlag = 1;
242 pp->slice_parsing_fields.bits.IntraPicFlag = 0;
252 pp->pic_fields.bits.NoPicReorderingFlag = 0;
253 pp->pic_fields.bits.NoBiPredFlag = 0;
265 VAPictureParameterBufferHEVC *pic_param;
266 VAIQMatrixBufferHEVC *iq_matrix;
270 ff_dlog(avctx,
"vaapi_hevc_start_frame()\n");
294 for (i = 0; i < 6; ++i) {
295 for (j = 0; j < 16; ++j) {
297 iq_matrix->ScalingList4x4[i][j] = scaling_list->
sl[0][i][pos];
299 for (j = 0; j < 64; ++j) {
301 iq_matrix->ScalingList8x8[i][j] = scaling_list->
sl[1][i][pos];
302 iq_matrix->ScalingList16x16[i][j] = scaling_list->
sl[2][i][pos];
304 iq_matrix->ScalingList32x32[i][j] = scaling_list->
sl[3][i * 3][pos];
307 iq_matrix->ScalingListDC16x16[i] = scaling_list->
sl_dc[0][i];
309 iq_matrix->ScalingListDC32x32[i] = scaling_list->
sl_dc[1][i * 3];
324 ff_dlog(avctx,
"vaapi_hevc_end_frame()\n");
342 VASliceParameterBufferHEVC *slice_param,
347 memset(slice_param->delta_luma_weight_l0, 0,
sizeof(slice_param->delta_luma_weight_l0));
348 memset(slice_param->delta_luma_weight_l1, 0,
sizeof(slice_param->delta_luma_weight_l1));
349 memset(slice_param->luma_offset_l0, 0,
sizeof(slice_param->luma_offset_l0));
350 memset(slice_param->luma_offset_l1, 0,
sizeof(slice_param->luma_offset_l1));
351 memset(slice_param->delta_chroma_weight_l0, 0,
sizeof(slice_param->delta_chroma_weight_l0));
352 memset(slice_param->delta_chroma_weight_l1, 0,
sizeof(slice_param->delta_chroma_weight_l1));
353 memset(slice_param->ChromaOffsetL0, 0,
sizeof(slice_param->ChromaOffsetL0));
354 memset(slice_param->ChromaOffsetL1, 0,
sizeof(slice_param->ChromaOffsetL1));
356 slice_param->delta_chroma_log2_weight_denom = 0;
357 slice_param->luma_log2_weight_denom = 0;
371 for (i = 0; i < 15 && i < sh->
nb_refs[
L0]; ++i) {
381 for (i = 0; i < 15 && i < sh->
nb_refs[
L1]; ++i) {
403 VASliceParameterBufferHEVC *slice_param;
410 ff_dlog(avctx,
"vaapi_hevc_decode_slice(): buffer %p, size %d\n", buffer, size);
420 slice_param->slice_data_flag = VA_SLICE_DATA_FLAG_ALL;
427 slice_param->LongSliceFlags.value = 0;
429 slice_param->LongSliceFlags.fields.slice_type = sh->
slice_type;
430 slice_param->LongSliceFlags.fields.color_plane_id = sh->
colour_plane_id;
432 slice_param->LongSliceFlags.fields.cabac_init_flag = sh->
cabac_init_flag;
435 slice_param->LongSliceFlags.fields.collocated_from_l0_flag = sh->
collocated_list ==
L0 ? 1 : 0;
446 slice_param->collocated_ref_idx = 0xFF;
452 slice_param->slice_beta_offset_div2 = sh->
beta_offset / 2;
453 slice_param->slice_tc_offset_div2 = sh->
tc_offset / 2;
456 slice_param->five_minus_max_num_merge_cand = 0;
461 slice_param->num_ref_idx_l0_active_minus1 = sh->
nb_refs[
L0] ? sh->
nb_refs[
L0] - 1 : 0;
462 slice_param->num_ref_idx_l1_active_minus1 = sh->
nb_refs[
L1] ? sh->
nb_refs[
L1] - 1 : 0;
464 memset(slice_param->RefPicList, 0xFF,
sizeof(slice_param->RefPicList));
467 for (list_idx = 0; list_idx < nb_list; ++list_idx) {
470 for (i = 0; i < rpl->
nb_refs; ++i) {
479 .
name =
"hevc_vaapi",
VASliceParameterBufferBase * ff_vaapi_alloc_slice(FFVAContext *vactx, const uint8_t *buffer, uint32_t size)
Allocate a new slice descriptor for the input slice.
unsigned int log2_min_cb_size
int ff_vaapi_context_fini(AVCodecContext *avctx)
Common AVHWAccel.uninit() implementation.
static int vaapi_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Initialize and start decoding a frame with VA API.
int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface)
int max_dec_pic_buffering
static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_type)
unsigned int * row_height
RowHeight.
void * hwaccel_picture_private
const uint8_t ff_hevc_diag_scan4x4_x[16]
uint8_t weighted_bipred_flag
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
static void init_vaapi_pic(VAPictureHEVC *va_pic)
Initialize an empty VA API picture.
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
struct HEVCFrame * ref[MAX_REFS]
uint8_t entropy_coding_sync_enabled_flag
int log2_parallel_merge_level
log2_parallel_merge_level_minus2 + 2
unsigned int log2_max_trafo_size
static void fill_vaapi_ReferenceFrames(const HEVCContext *h, VAPictureParameterBufferHEVC *pp)
unsigned int slice_param_size
Size of a slice parameter element.
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
unsigned int log2_min_pcm_cb_size
uint8_t scaling_list_data_present_flag
static int get_bits_count(const GetBitContext *s)
void * ff_vaapi_alloc_iq_matrix(FFVAContext *vactx, unsigned int size)
Allocate a new IQ matrix buffer.
static FFVAContext * ff_vaapi_get_context(AVCodecContext *avctx)
Extract vaapi_context from an AVCodecContext.
int interlaced_frame
The content of the picture is interlaced.
uint8_t loop_filter_disable_flag
uint8_t transquant_bypass_enable_flag
static int vaapi_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Decode the given hevc slice with VA API.
#define HEVC_FRAME_FLAG_LONG_REF
unsigned int log2_max_poc_lsb
static int vaapi_hevc_end_frame(AVCodecContext *avctx)
End a hardware decoding based frame.
void ff_vaapi_common_end_frame(AVCodecContext *avctx)
Common AVHWAccel.end_frame() implementation.
int ff_vaapi_context_init(AVCodecContext *avctx)
Common AVHWAccel.init() implementation.
static int fill_pred_weight_table(HEVCContext *const h, VASliceParameterBufferHEVC *slice_param, SliceHeader *const sh)
uint8_t tiles_enabled_flag
uint8_t lists_modification_present_flag
#define HEVC_FRAME_FLAG_SHORT_REF
const char * name
Name of the hardware accelerated codec.
int max_transform_hierarchy_depth_inter
int num_tile_columns
num_tile_columns_minus1 + 1
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
Extract VASurfaceID from an AVFrame.
uint8_t cu_qp_delta_enabled_flag
static void fill_picture_parameters(const HEVCContext *h, VAPictureParameterBufferHEVC *pp)
uint8_t sign_data_hiding_flag
uint8_t output_flag_present_flag
#define FF_ARRAY_ELEMS(a)
uint8_t constrained_intra_pred_flag
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
uint8_t transform_skip_enabled_flag
VAPictureParameterBufferHEVC * pic_param
main external API structure.
int num_extra_slice_header_bits
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 sps_temporal_mvp_enabled_flag
int num_tile_rows
num_tile_rows_minus1 + 1
const uint8_t ff_hevc_diag_scan8x8_y[64]
int ff_vaapi_commit_slices(FFVAContext *vactx)
static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
unsigned int log2_min_tb_size
enum NALUnitType nal_unit_type
uint8_t scaling_list_enable_flag
struct HEVCSPS::@52 temporal_layer[MAX_SUB_LAYERS]
void * ff_vaapi_alloc_pic_param(FFVAContext *vactx, unsigned int size)
Allocate a new picture parameter buffer.
int tc_offset
tc_offset_div2 * 2
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
HEVCLocalContext * HEVClc
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
unsigned int * column_width
ColumnWidth.
uint8_t slice_header_extension_present_flag
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
AVHWAccel ff_hevc_vaapi_hwaccel
int diff_cu_qp_delta_depth
const uint8_t ff_hevc_diag_scan8x8_x[64]
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
VASliceParameterBufferHEVC * last_slice_param
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
const uint8_t ff_hevc_diag_scan4x4_y[16]
uint8_t dependent_slice_segments_enabled_flag