/** Initialize and start decoding a frame with VA API. */ static int vaapi_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { HEVCContext * const h = avctx->priv_data; FFVAContext * const vactx = ff_vaapi_get_context(avctx); vaapi_hevc_frame_data *frame_data = h->ref->hwaccel_picture_private; VAPictureParameterBufferHEVC *pic_param; VAIQMatrixBufferHEVC *iq_matrix; ScalingList const * scaling_list; int i, j, pos; ff_dlog(avctx, "vaapi_hevc_start_frame()\n"); vactx->slice_param_size = sizeof(VASliceParameterBufferHEVC); /* Fill in VAPictureParameterBufferHEVC. */ pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferHEVC)); if (!pic_param) return -1; fill_picture_parameters(h, pic_param); frame_data->pic_param = pic_param; /* Fill in VAIQMatrixBufferHEVC. */ if (h->ps.pps->scaling_list_data_present_flag) { scaling_list = &h->ps.pps->scaling_list; } else if (h->ps.sps->scaling_list_enable_flag) { scaling_list = &h->ps.sps->scaling_list; } else { return 0; } iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferHEVC)); if (!iq_matrix) return -1; for (i = 0; i < 6; ++i) { for (j = 0; j < 16; ++j) { pos = 4 * ff_hevc_diag_scan4x4_y[j] + ff_hevc_diag_scan4x4_x[j]; iq_matrix->ScalingList4x4[i][j] = scaling_list->sl[0][i][pos]; } for (j = 0; j < 64; ++j) { pos = 8 * ff_hevc_diag_scan8x8_y[j] + ff_hevc_diag_scan8x8_x[j]; iq_matrix->ScalingList8x8[i][j] = scaling_list->sl[1][i][pos]; iq_matrix->ScalingList16x16[i][j] = scaling_list->sl[2][i][pos]; if (i < 2) { iq_matrix->ScalingList32x32[i][j] = scaling_list->sl[3][i * 3][pos]; } } iq_matrix->ScalingListDC16x16[i] = scaling_list->sl_dc[0][i]; if (i < 2) { iq_matrix->ScalingListDC32x32[i] = scaling_list->sl_dc[1][i * 3]; } } return 0; }
static int vaapi_vp9_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { const VP9SharedContext *h = avctx->priv_data; FFVAContext * const vactx = ff_vaapi_get_context(avctx); VADecPictureParameterBufferVP9 *pic_param; vactx->slice_param_size = sizeof(VASliceParameterBufferVP9); pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VADecPictureParameterBufferVP9)); if (!pic_param) return -1; fill_picture_parameters(avctx, h, pic_param); return 0; }
static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { MpegEncContext * const s = avctx->priv_data; struct vaapi_context * const vactx = avctx->hwaccel_context; VAPictureParameterBufferMPEG4 *pic_param; VAIQMatrixBufferMPEG4 *iq_matrix; int i; av_dlog(avctx, "vaapi_mpeg4_start_frame()\n"); vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG4); /* Fill in VAPictureParameterBufferMPEG4 */ pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG4)); if (!pic_param) return -1; pic_param->vop_width = s->width; pic_param->vop_height = s->height; pic_param->forward_reference_picture = VA_INVALID_ID; pic_param->backward_reference_picture = VA_INVALID_ID; pic_param->vol_fields.value = 0; /* reset all bits */ pic_param->vol_fields.bits.short_video_header = avctx->codec->id == AV_CODEC_ID_H263; pic_param->vol_fields.bits.chroma_format = CHROMA_420; pic_param->vol_fields.bits.interlaced = !s->progressive_sequence; pic_param->vol_fields.bits.obmc_disable = 1; pic_param->vol_fields.bits.sprite_enable = s->vol_sprite_usage; pic_param->vol_fields.bits.sprite_warping_accuracy = s->sprite_warping_accuracy; pic_param->vol_fields.bits.quant_type = s->mpeg_quant; pic_param->vol_fields.bits.quarter_sample = s->quarter_sample; pic_param->vol_fields.bits.data_partitioned = s->data_partitioning; pic_param->vol_fields.bits.reversible_vlc = s->rvlc; pic_param->vol_fields.bits.resync_marker_disable = !s->resync_marker; pic_param->no_of_sprite_warping_points = s->num_sprite_warping_points; for (i = 0; i < s->num_sprite_warping_points && i < 3; i++) { pic_param->sprite_trajectory_du[i] = s->sprite_traj[i][0]; pic_param->sprite_trajectory_dv[i] = s->sprite_traj[i][1]; } pic_param->quant_precision = s->quant_precision; pic_param->vop_fields.value = 0; /* reset all bits */ pic_param->vop_fields.bits.vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I; pic_param->vop_fields.bits.backward_reference_vop_coding_type = s->pict_type == AV_PICTURE_TYPE_B ? s->next_picture.f.pict_type - AV_PICTURE_TYPE_I : 0; pic_param->vop_fields.bits.vop_rounding_type = s->no_rounding; pic_param->vop_fields.bits.intra_dc_vlc_thr = mpeg4_get_intra_dc_vlc_thr(s); pic_param->vop_fields.bits.top_field_first = s->top_field_first; pic_param->vop_fields.bits.alternate_vertical_scan_flag = s->alternate_scan; pic_param->vop_fcode_forward = s->f_code; pic_param->vop_fcode_backward = s->b_code; pic_param->vop_time_increment_resolution = avctx->time_base.den; pic_param->num_macroblocks_in_gob = s->mb_width * ff_h263_get_gob_height(s); pic_param->num_gobs_in_vop = (s->mb_width * s->mb_height) / pic_param->num_macroblocks_in_gob; pic_param->TRB = s->pb_time; pic_param->TRD = s->pp_time; if (s->pict_type == AV_PICTURE_TYPE_B) pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture); if (s->pict_type != AV_PICTURE_TYPE_I) pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture); /* Fill in VAIQMatrixBufferMPEG4 */ /* Only the first inverse quantisation method uses the weighting matrices */ if (pic_param->vol_fields.bits.quant_type) { iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG4)); if (!iq_matrix) return -1; iq_matrix->load_intra_quant_mat = 1; iq_matrix->load_non_intra_quant_mat = 1; for (i = 0; i < 64; i++) { int n = s->dsp.idct_permutation[ff_zigzag_direct[i]]; iq_matrix->intra_quant_mat[i] = s->intra_matrix[n]; iq_matrix->non_intra_quant_mat[i] = s->inter_matrix[n]; } } return 0; }
/** Initialize and start decoding a frame with VA API. */ static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { H264Context * const h = avctx->priv_data; MpegEncContext * const s = &h->s; struct vaapi_context * const vactx = avctx->hwaccel_context; VAPictureParameterBufferH264 *pic_param; VAIQMatrixBufferH264 *iq_matrix; av_dlog(avctx, "start_frame()\n"); vactx->slice_param_size = sizeof(VASliceParameterBufferH264); /* Fill in VAPictureParameterBufferH264. */ pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferH264)); if (!pic_param) return -1; fill_vaapi_pic(&pic_param->CurrPic, s->current_picture_ptr, s->picture_structure); if (fill_vaapi_ReferenceFrames(pic_param, h) < 0) return -1; pic_param->picture_width_in_mbs_minus1 = s->mb_width - 1; pic_param->picture_height_in_mbs_minus1 = s->mb_height - 1; pic_param->bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; pic_param->bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; pic_param->num_ref_frames = h->sps.ref_frame_count; pic_param->seq_fields.value = 0; /* reset all bits */ pic_param->seq_fields.bits.chroma_format_idc = h->sps.chroma_format_idc; pic_param->seq_fields.bits.residual_colour_transform_flag = h->sps.residual_color_transform_flag; /* XXX: only for 4:4:4 high profile? */ pic_param->seq_fields.bits.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag; pic_param->seq_fields.bits.frame_mbs_only_flag = h->sps.frame_mbs_only_flag; pic_param->seq_fields.bits.mb_adaptive_frame_field_flag = h->sps.mb_aff; pic_param->seq_fields.bits.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; pic_param->seq_fields.bits.MinLumaBiPredSize8x8 = h->sps.level_idc >= 31; /* A.3.3.2 */ pic_param->seq_fields.bits.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4; pic_param->seq_fields.bits.pic_order_cnt_type = h->sps.poc_type; pic_param->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; pic_param->seq_fields.bits.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; pic_param->num_slice_groups_minus1 = h->pps.slice_group_count - 1; pic_param->slice_group_map_type = h->pps.mb_slice_group_map_type; pic_param->slice_group_change_rate_minus1 = 0; /* XXX: unimplemented in FFmpeg */ pic_param->pic_init_qp_minus26 = h->pps.init_qp - 26; pic_param->pic_init_qs_minus26 = h->pps.init_qs - 26; pic_param->chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; pic_param->second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; pic_param->pic_fields.value = 0; /* reset all bits */ pic_param->pic_fields.bits.entropy_coding_mode_flag = h->pps.cabac; pic_param->pic_fields.bits.weighted_pred_flag = h->pps.weighted_pred; pic_param->pic_fields.bits.weighted_bipred_idc = h->pps.weighted_bipred_idc; pic_param->pic_fields.bits.transform_8x8_mode_flag = h->pps.transform_8x8_mode; pic_param->pic_fields.bits.field_pic_flag = s->picture_structure != PICT_FRAME; pic_param->pic_fields.bits.constrained_intra_pred_flag = h->pps.constrained_intra_pred; pic_param->pic_fields.bits.pic_order_present_flag = h->pps.pic_order_present; pic_param->pic_fields.bits.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; pic_param->pic_fields.bits.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; pic_param->pic_fields.bits.reference_pic_flag = h->nal_ref_idc != 0; pic_param->frame_num = h->frame_num; /* Fill in VAIQMatrixBufferH264. */ iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferH264)); if (!iq_matrix) return -1; memcpy(iq_matrix->ScalingList4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->ScalingList4x4)); memcpy(iq_matrix->ScalingList8x8, h->pps.scaling_matrix8, sizeof(iq_matrix->ScalingList8x8)); return 0; }
static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { VC1Context * const v = avctx->priv_data; MpegEncContext * const s = &v->s; struct vaapi_context * const vactx = avctx->hwaccel_context; VAPictureParameterBufferVC1 *pic_param; av_dlog(avctx, "vaapi_vc1_start_frame()\n"); vactx->slice_param_size = sizeof(VASliceParameterBufferVC1); /* Fill in VAPictureParameterBufferVC1 */ pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1)); if (!pic_param) return -1; pic_param->forward_reference_picture = VA_INVALID_ID; pic_param->backward_reference_picture = VA_INVALID_ID; pic_param->inloop_decoded_picture = VA_INVALID_ID; pic_param->sequence_fields.value = 0; /* reset all bits */ pic_param->sequence_fields.bits.pulldown = v->broadcast; pic_param->sequence_fields.bits.interlace = v->interlace; pic_param->sequence_fields.bits.tfcntrflag = v->tfcntrflag; pic_param->sequence_fields.bits.finterpflag = v->finterpflag; pic_param->sequence_fields.bits.psf = v->psf; pic_param->sequence_fields.bits.multires = v->multires; pic_param->sequence_fields.bits.overlap = v->overlap; pic_param->sequence_fields.bits.syncmarker = s->resync_marker; pic_param->sequence_fields.bits.rangered = v->rangered; pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames; #if VA_CHECK_VERSION(0,32,0) pic_param->sequence_fields.bits.profile = v->profile; #endif pic_param->coded_width = s->avctx->coded_width; pic_param->coded_height = s->avctx->coded_height; pic_param->entrypoint_fields.value = 0; /* reset all bits */ pic_param->entrypoint_fields.bits.broken_link = v->broken_link; pic_param->entrypoint_fields.bits.closed_entry = v->closed_entry; pic_param->entrypoint_fields.bits.panscan_flag = v->panscanflag; pic_param->entrypoint_fields.bits.loopfilter = s->loop_filter; pic_param->conditional_overlap_flag = v->condover; pic_param->fast_uvmc_flag = v->fastuvmc; pic_param->range_mapping_fields.value = 0; /* reset all bits */ pic_param->range_mapping_fields.bits.luma_flag = v->range_mapy_flag; pic_param->range_mapping_fields.bits.luma = v->range_mapy; pic_param->range_mapping_fields.bits.chroma_flag = v->range_mapuv_flag; pic_param->range_mapping_fields.bits.chroma = v->range_mapuv; pic_param->b_picture_fraction = v->bfraction_lut_index; pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0; pic_param->mb_mode_table = 0; /* XXX: interlaced frame */ pic_param->range_reduction_frame = v->rangeredfrm; pic_param->rounding_control = v->rnd; pic_param->post_processing = v->postproc; pic_param->picture_resolution_index = v->respic; pic_param->luma_scale = v->lumscale; pic_param->luma_shift = v->lumshift; pic_param->picture_fields.value = 0; /* reset all bits */ pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(v); pic_param->picture_fields.bits.frame_coding_mode = v->fcm; pic_param->picture_fields.bits.top_field_first = v->tff; pic_param->picture_fields.bits.is_first_field = v->fcm == 0; /* XXX: interlaced frame */ pic_param->picture_fields.bits.intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP; pic_param->raw_coding.value = 0; /* reset all bits */ pic_param->raw_coding.flags.mv_type_mb = v->mv_type_is_raw; pic_param->raw_coding.flags.direct_mb = v->dmb_is_raw; pic_param->raw_coding.flags.skip_mb = v->skip_is_raw; pic_param->raw_coding.flags.field_tx = 0; /* XXX: interlaced frame */ pic_param->raw_coding.flags.forward_mb = 0; /* XXX: interlaced frame */ pic_param->raw_coding.flags.ac_pred = v->acpred_is_raw; pic_param->raw_coding.flags.overflags = v->overflg_is_raw; pic_param->bitplane_present.value = 0; /* reset all bits */ pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v); pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(v); pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(v); pic_param->bitplane_present.flags.bp_field_tx = 0; /* XXX: interlaced frame */ pic_param->bitplane_present.flags.bp_forward_mb = 0; /* XXX: interlaced frame */ pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(v); pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(v); pic_param->reference_fields.value = 0; /* reset all bits */ pic_param->reference_fields.bits.reference_distance_flag = v->refdist_flag; pic_param->reference_fields.bits.reference_distance = 0; /* XXX: interlaced frame */ pic_param->reference_fields.bits.num_reference_pictures = 0; /* XXX: interlaced frame */ pic_param->reference_fields.bits.reference_field_pic_indicator = 0; /* XXX: interlaced frame */ pic_param->mv_fields.value = 0; /* reset all bits */ pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(v); pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(v); pic_param->mv_fields.bits.mv_table = s->mv_table_index; pic_param->mv_fields.bits.two_mv_block_pattern_table = 0; /* XXX: interlaced frame */ pic_param->mv_fields.bits.four_mv_switch = 0; /* XXX: interlaced frame */ pic_param->mv_fields.bits.four_mv_block_pattern_table = 0; /* XXX: interlaced frame */ pic_param->mv_fields.bits.extended_mv_flag = v->extended_mv; pic_param->mv_fields.bits.extended_mv_range = v->mvrange; pic_param->mv_fields.bits.extended_dmv_flag = v->extended_dmv; pic_param->mv_fields.bits.extended_dmv_range = 0; /* XXX: interlaced frame */ pic_param->pic_quantizer_fields.value = 0; /* reset all bits */ pic_param->pic_quantizer_fields.bits.dquant = v->dquant; pic_param->pic_quantizer_fields.bits.quantizer = v->quantizer_mode; pic_param->pic_quantizer_fields.bits.half_qp = v->halfpq; pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = v->pq; pic_param->pic_quantizer_fields.bits.pic_quantizer_type = v->pquantizer; pic_param->pic_quantizer_fields.bits.dq_frame = v->dquantfrm; pic_param->pic_quantizer_fields.bits.dq_profile = v->dqprofile; pic_param->pic_quantizer_fields.bits.dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0; pic_param->pic_quantizer_fields.bits.dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0; pic_param->pic_quantizer_fields.bits.dq_binary_level = v->dqbilevel; pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = v->altpq; pic_param->transform_fields.value = 0; /* reset all bits */ pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform; pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf; pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(v); pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index; pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index; pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index; switch (s->pict_type) { case AV_PICTURE_TYPE_B: pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture); // fall-through case AV_PICTURE_TYPE_P: pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture); break; } if (pic_param->bitplane_present.value) { uint8_t *bitplane; const uint8_t *ff_bp[3]; int x, y, n; switch (s->pict_type) { case AV_PICTURE_TYPE_P: ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL; break; case AV_PICTURE_TYPE_B: if (!v->bi_type) { ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; ff_bp[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */ break; } /* fall-through (BI-type) */ case AV_PICTURE_TYPE_I: ff_bp[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */ ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL; ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL; break; default: ff_bp[0] = NULL; ff_bp[1] = NULL; ff_bp[2] = NULL; break; } bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2); if (!bitplane) return -1; n = 0; for (y = 0; y < s->mb_height; y++) for (x = 0; x < s->mb_width; x++, n++) vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride); if (n & 1) /* move last nibble to the high order */ bitplane[n/2] <<= 4; } return 0; }
static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { struct MpegEncContext * const s = avctx->priv_data; struct vaapi_context * const vactx = avctx->hwaccel_context; VAPictureParameterBufferMPEG2 *pic_param; VAIQMatrixBufferMPEG2 *iq_matrix; int i; dprintf(avctx, "vaapi_mpeg2_start_frame()\n"); vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG2); /* Fill in VAPictureParameterBufferMPEG2 */ pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferMPEG2)); if (!pic_param) return -1; pic_param->horizontal_size = s->width; pic_param->vertical_size = s->height; pic_param->forward_reference_picture = VA_INVALID_ID; pic_param->backward_reference_picture = VA_INVALID_ID; pic_param->picture_coding_type = s->pict_type; pic_param->f_code = mpeg2_get_f_code(s); pic_param->picture_coding_extension.value = 0; /* reset all bits */ pic_param->picture_coding_extension.bits.intra_dc_precision = s->intra_dc_precision; pic_param->picture_coding_extension.bits.picture_structure = s->picture_structure; pic_param->picture_coding_extension.bits.top_field_first = s->top_field_first; pic_param->picture_coding_extension.bits.frame_pred_frame_dct = s->frame_pred_frame_dct; pic_param->picture_coding_extension.bits.concealment_motion_vectors = s->concealment_motion_vectors; pic_param->picture_coding_extension.bits.q_scale_type = s->q_scale_type; pic_param->picture_coding_extension.bits.intra_vlc_format = s->intra_vlc_format; pic_param->picture_coding_extension.bits.alternate_scan = s->alternate_scan; pic_param->picture_coding_extension.bits.repeat_first_field = s->repeat_first_field; pic_param->picture_coding_extension.bits.progressive_frame = s->progressive_frame; pic_param->picture_coding_extension.bits.is_first_field = mpeg2_get_is_frame_start(s); switch (s->pict_type) { case FF_B_TYPE: pic_param->backward_reference_picture = ff_vaapi_get_surface_id(&s->next_picture); // fall-through case FF_P_TYPE: pic_param->forward_reference_picture = ff_vaapi_get_surface_id(&s->last_picture); break; } /* Fill in VAIQMatrixBufferMPEG2 */ iq_matrix = ff_vaapi_alloc_iq_matrix(vactx, sizeof(VAIQMatrixBufferMPEG2)); if (!iq_matrix) return -1; iq_matrix->load_intra_quantiser_matrix = 1; iq_matrix->load_non_intra_quantiser_matrix = 1; iq_matrix->load_chroma_intra_quantiser_matrix = 1; iq_matrix->load_chroma_non_intra_quantiser_matrix = 1; for (i = 0; i < 64; i++) { int n = s->dsp.idct_permutation[ff_zigzag_direct[i]]; iq_matrix->intra_quantiser_matrix[i] = s->intra_matrix[n]; iq_matrix->non_intra_quantiser_matrix[i] = s->inter_matrix[n]; iq_matrix->chroma_intra_quantiser_matrix[i] = s->chroma_intra_matrix[n]; iq_matrix->chroma_non_intra_quantiser_matrix[i] = s->chroma_inter_matrix[n]; } return 0; }