40 va_pic->picture_id = VA_INVALID_ID;
41 va_pic->flags = VA_PICTURE_H264_INVALID;
42 va_pic->TopFieldOrderCnt = 0;
43 va_pic->BottomFieldOrderCnt = 0;
58 if (pic_structure == 0)
67 va_pic->flags |= (pic_structure &
PICT_TOP_FIELD) ? VA_PICTURE_H264_TOP_FIELD : VA_PICTURE_H264_BOTTOM_FIELD;
69 va_pic->flags |= pic->
long_ref ? VA_PICTURE_H264_LONG_TERM_REFERENCE : VA_PICTURE_H264_SHORT_TERM_REFERENCE;
71 va_pic->TopFieldOrderCnt = 0;
73 va_pic->TopFieldOrderCnt = pic->
field_poc[0];
75 va_pic->BottomFieldOrderCnt = 0;
77 va_pic->BottomFieldOrderCnt = pic->
field_poc[1];
100 for (i = 0; i < dpb->
size; i++) {
101 VAPictureH264 *
const va_pic = &dpb->
va_pics[i];
103 VAPictureH264 temp_va_pic;
106 if ((temp_va_pic.flags ^ va_pic->flags) & (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) {
107 va_pic->flags |= temp_va_pic.flags & (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD);
109 if (temp_va_pic.flags & VA_PICTURE_H264_TOP_FIELD) {
110 va_pic->TopFieldOrderCnt = temp_va_pic.TopFieldOrderCnt;
112 va_pic->BottomFieldOrderCnt = temp_va_pic.BottomFieldOrderCnt;
132 dpb.
va_pics = pic_param->ReferenceFrames;
142 for (i = 0; i < 16; i++) {
160 unsigned int ref_count)
162 unsigned int i,
n = 0;
163 for (i = 0; i < ref_count; i++)
164 if (ref_list[i].reference)
166 ref_list[i].reference);
189 unsigned char *luma_weight_flag,
190 short luma_weight[32],
191 short luma_offset[32],
192 unsigned char *chroma_weight_flag,
193 short chroma_weight[32][2],
194 short chroma_offset[32][2])
202 for (i = 0; i < sl->
ref_count[list]; i++) {
212 for (j = 0; j < 2; j++) {
218 chroma_offset[i][j] = 0;
233 VAPictureParameterBufferH264 *pic_param;
234 VAIQMatrixBufferH264 *iq_matrix;
245 pic_param->picture_width_in_mbs_minus1 = h->
mb_width - 1;
246 pic_param->picture_height_in_mbs_minus1 = h->
mb_height - 1;
250 pic_param->seq_fields.value = 0;
255 pic_param->seq_fields.bits.mb_adaptive_frame_field_flag = sps->
mb_aff;
257 pic_param->seq_fields.bits.MinLumaBiPredSize8x8 = sps->
level_idc >= 31;
259 pic_param->seq_fields.bits.pic_order_cnt_type = sps->
poc_type;
260 pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = sps->
log2_max_poc_lsb - 4;
264 pic_param->slice_group_change_rate_minus1 = 0;
265 pic_param->pic_init_qp_minus26 = pps->
init_qp - 26;
266 pic_param->pic_init_qs_minus26 = pps->
init_qs - 26;
269 pic_param->pic_fields.value = 0;
270 pic_param->pic_fields.bits.entropy_coding_mode_flag = pps->
cabac;
271 pic_param->pic_fields.bits.weighted_pred_flag = pps->
weighted_pred;
279 pic_param->pic_fields.bits.reference_pic_flag = h->
nal_ref_idc != 0;
286 memcpy(iq_matrix->ScalingList4x4, pps->
scaling_matrix4,
sizeof(iq_matrix->ScalingList4x4));
287 memcpy(iq_matrix->ScalingList8x8[0], pps->
scaling_matrix8[0],
sizeof(iq_matrix->ScalingList8x8[0]));
288 memcpy(iq_matrix->ScalingList8x8[1], pps->
scaling_matrix8[3],
sizeof(iq_matrix->ScalingList8x8[0]));
323 VASliceParameterBufferH264 *slice_param;
347 &slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,
348 &slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0);
350 &slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1,
351 &slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1);
356 .
name =
"h264_vaapi",
VASliceParameterBufferBase * ff_vaapi_alloc_slice(FFVAContext *vactx, const uint8_t *buffer, uint32_t size)
Allocate a new slice descriptor for the input slice.
int ff_vaapi_context_fini(AVCodecContext *avctx)
Common AVHWAccel.uninit() implementation.
int long_ref
1->long term reference 0->short term reference
int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface)
int chroma_qp_index_offset[2]
int luma_weight_flag[2]
7.4.3.2 luma_weight_lX_flag
AVHWAccel ff_h264_vaapi_hwaccel
int chroma_weight[48][2][2][2]
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
int max_size
Max number of reference frames. This is FF_ARRAY_ELEMS(VAPictureParameterBufferH264.ReferenceFrames)
H264Picture * long_ref[32]
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
static int dpb_add(DPB *dpb, H264Picture *pic)
Append picture to the decoded picture buffer, in a VA API form that merges the second field picture a...
static int vaapi_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Decode the given H.264 slice with VA API.
uint8_t scaling_matrix4[6][16]
int deblocking_filter_parameters_present
deblocking_filter_parameters_present_flag
unsigned int slice_param_size
Size of a slice parameter element.
int gaps_in_frame_num_allowed_flag
int slice_alpha_c0_offset
int bit_depth_chroma
bit_depth_chroma_minus8 + 8
int chroma_weight_flag[2]
7.4.3.2 chroma_weight_lX_flag
int cabac
entropy_coding_mode_flag
static int get_bits_count(const GetBitContext *s)
static void fill_vaapi_pic(VAPictureH264 *va_pic, H264Picture *pic, int pic_structure)
Translate an FFmpeg Picture into its VA API form.
int redundant_pic_cnt_present
redundant_pic_cnt_present_flag
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 luma_weight[48][2][2]
H.264 / AVC / MPEG-4 part10 codec.
int mb_aff
mb_adaptive_frame_field_flag
int chroma_log2_weight_denom
int poc_type
pic_order_cnt_type
int constrained_intra_pred
constrained_intra_pred_flag
void ff_vaapi_common_end_frame(AVCodecContext *avctx)
Common AVHWAccel.end_frame() implementation.
int ff_vaapi_context_init(AVCodecContext *avctx)
Common AVHWAccel.init() implementation.
int deblocking_filter
disable_deblocking_filter_idc with 1 <-> 0
int weighted_pred
weighted_pred_flag
int direct_spatial_mv_pred
int frame_num
frame_num (raw frame_num from slice header)
int residual_color_transform_flag
residual_colour_transform_flag
int delta_pic_order_always_zero_flag
#define FIELD_OR_MBAFF_PICTURE(h)
uint8_t scaling_matrix8[6][64]
int ref_frame_count
num_ref_frames
const char * name
Name of the hardware accelerated codec.
static void fill_vaapi_RefPicList(VAPictureH264 RefPicList[32], H264Ref *ref_list, unsigned int ref_count)
Fill in VA API reference picture lists from the FFmpeg reference picture list.
static int vaapi_h264_end_frame(AVCodecContext *avctx)
End a hardware decoding based frame.
int luma_log2_weight_denom
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
Extract VASurfaceID from an AVFrame.
int size
Current number of reference frames in the DPB.
int init_qp
pic_init_qp_minus26 + 26
H264SliceContext * slice_ctx
int direct_8x8_inference_flag
#define FF_ARRAY_ELEMS(a)
int ff_h264_get_slice_type(const H264SliceContext *sl)
Reconstruct bitstream slice_type.
int pic_order_present
pic_order_present_flag
H264Picture * short_ref[32]
int field_poc[2]
top/bottom POC
main external API structure.
int ff_vaapi_commit_slices(FFVAContext *vactx)
H264Picture * cur_pic_ptr
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
void * ff_vaapi_alloc_pic_param(FFVAContext *vactx, unsigned int size)
Allocate a new picture parameter buffer.
int transform_8x8_mode
transform_8x8_mode_flag
int init_qs
pic_init_qs_minus26 + 26
int pic_id
pic_num (short -> no wrap version of pic_num, pic_num & max_pic_num; long -> long_pic_num) ...
static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, H264Context *h)
Fill in VA API reference frames array.
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
static void fill_vaapi_plain_pred_weight_table(H264Context *h, int list, unsigned char *luma_weight_flag, short luma_weight[32], short luma_offset[32], unsigned char *chroma_weight_flag, short chroma_weight[32][2], short chroma_offset[32][2])
Fill in prediction weight table.
int bit_depth_luma
bit_depth_luma_minus8 + 8
static int vaapi_h264_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Initialize and start decoding a frame with VA API.
static void init_vaapi_pic(VAPictureH264 *va_pic)
Initialize an empty VA API picture.
Decoded Picture Buffer (DPB).
int slice_group_count
num_slice_groups_minus1 + 1
H264Ref ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
VAPictureH264 * va_pics
Pointer to VAPictureParameterBufferH264.ReferenceFrames array.
int short_ref_count
number of actual short term references
int mb_slice_group_map_type