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)
188 unsigned char *luma_weight_flag,
189 short luma_weight[32],
190 short luma_offset[32],
191 unsigned char *chroma_weight_flag,
192 short chroma_weight[32][2],
193 short chroma_offset[32][2])
201 for (i = 0; i < sl->
ref_count[list]; i++) {
211 for (j = 0; j < 2; j++) {
217 chroma_offset[i][j] = 0;
230 VAPictureParameterBufferH264 *pic_param;
231 VAIQMatrixBufferH264 *iq_matrix;
233 ff_dlog(avctx,
"vaapi_h264_start_frame()\n");
244 pic_param->picture_width_in_mbs_minus1 = h->
mb_width - 1;
245 pic_param->picture_height_in_mbs_minus1 = h->
mb_height - 1;
249 pic_param->seq_fields.value = 0;
254 pic_param->seq_fields.bits.mb_adaptive_frame_field_flag = h->
sps.
mb_aff;
256 pic_param->seq_fields.bits.MinLumaBiPredSize8x8 = h->
sps.
level_idc >= 31;
258 pic_param->seq_fields.bits.pic_order_cnt_type = h->
sps.
poc_type;
259 pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = h->
sps.
log2_max_poc_lsb - 4;
263 pic_param->slice_group_change_rate_minus1 = 0;
264 pic_param->pic_init_qp_minus26 = h->
pps.
init_qp - 26;
265 pic_param->pic_init_qs_minus26 = h->
pps.
init_qs - 26;
268 pic_param->pic_fields.value = 0;
269 pic_param->pic_fields.bits.entropy_coding_mode_flag = h->
pps.
cabac;
278 pic_param->pic_fields.bits.reference_pic_flag = h->
nal_ref_idc != 0;
285 memcpy(iq_matrix->ScalingList4x4, h->
pps.
scaling_matrix4,
sizeof(iq_matrix->ScalingList4x4));
286 memcpy(iq_matrix->ScalingList8x8[0], h->
pps.
scaling_matrix8[0],
sizeof(iq_matrix->ScalingList8x8[0]));
287 memcpy(iq_matrix->ScalingList8x8[1], h->
pps.
scaling_matrix8[3],
sizeof(iq_matrix->ScalingList8x8[0]));
299 ff_dlog(avctx,
"vaapi_h264_end_frame()\n");
322 VASliceParameterBufferH264 *slice_param;
324 ff_dlog(avctx,
"vaapi_h264_decode_slice(): buffer %p, size %d\n",
349 &slice_param->luma_weight_l0_flag, slice_param->luma_weight_l0, slice_param->luma_offset_l0,
350 &slice_param->chroma_weight_l0_flag, slice_param->chroma_weight_l0, slice_param->chroma_offset_l0);
352 &slice_param->luma_weight_l1_flag, slice_param->luma_weight_l1, slice_param->luma_offset_l1,
353 &slice_param->chroma_weight_l1_flag, slice_param->chroma_weight_l1, slice_param->chroma_offset_l1);
358 .
name =
"h264_vaapi",
int long_ref
1->long term reference 0->short term reference
int luma_weight[48][2][2]
int chroma_qp_index_offset[2]
AVHWAccel ff_h264_vaapi_hwaccel
HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the b...
int ff_vaapi_render_picture(struct vaapi_context *vactx, VASurfaceID surface)
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)
#define FF_ARRAY_ELEMS(a)
This structure is used to share data between the FFmpeg library and the client video application...
H264Picture * long_ref[32]
int luma_weight_flag[2]
7.4.3.2 luma_weight_lX_flag
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
void * hwaccel_context
Hardware accelerator context.
int gaps_in_frame_num_allowed_flag
int slice_alpha_c0_offset
int bit_depth_chroma
bit_depth_chroma_minus8 + 8
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
H.264 / AVC / MPEG4 part10 codec.
int mb_aff
mb_adaptive_frame_field_flag
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.
void * ff_vaapi_alloc_pic_param(struct vaapi_context *vactx, unsigned int size)
Allocate a new picture parameter buffer.
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.
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
Extract VASurfaceID from an AVFrame.
unsigned int slice_param_size
Size of a VASliceParameterBuffer element.
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
int chroma_log2_weight_denom
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.
VASliceParameterBufferBase * ff_vaapi_alloc_slice(struct vaapi_context *vactx, const uint8_t *buffer, uint32_t size)
Allocate a new slice descriptor for the input slice.
H264Picture * cur_pic_ptr
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
int transform_8x8_mode
transform_8x8_mode_flag
int ff_vaapi_commit_slices(struct vaapi_context *vactx)
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.
void * ff_vaapi_alloc_iq_matrix(struct vaapi_context *vactx, unsigned int size)
Allocate a new IQ matrix buffer.
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 luma_log2_weight_denom
int chroma_weight[48][2][2][2]
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 chroma_weight_flag[2]
7.4.3.2 chroma_weight_lX_flag
int short_ref_count
number of actual short term references
int mb_slice_group_map_type