- VC1Context * const v = avctx->priv_data;
- MpegEncContext * const s = &v->s;
- struct vaapi_context * const vactx = avctx->hwaccel_context;
- VAPictureParameterBufferVC1 *pic_param;
-
- dprintf(avctx, "vaapi_vc1_start_frame()\n");
-
- vactx->slice_param_size = sizeof(VASliceParameterBufferVC1);
-
- /* Fill in VAPictureParameterBufferVC1 */
- pic_param = ff_vaapi_alloc_picture(vactx, sizeof(VAPictureParameterBufferVC1));
- if (!pic_param)
- return -1;
- pic_param->forward_reference_picture = 0xffffffff;
- pic_param->backward_reference_picture = 0xffffffff;
- pic_param->inloop_decoded_picture = 0xffffffff;
- 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;
- 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 = v->ttfrm;
- 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;
+ const VC1Context *v = avctx->priv_data;
+ const MpegEncContext *s = &v->s;
+ VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private;
+ VAPictureParameterBufferVC1 pic_param;
+ int err;
+
+ pic->output_surface = ff_vaapi_get_surface_id(s->current_picture_ptr->f);
+
+ pic_param = (VAPictureParameterBufferVC1) {
+ .forward_reference_picture = VA_INVALID_ID,
+ .backward_reference_picture = VA_INVALID_ID,
+ .inloop_decoded_picture = VA_INVALID_ID,
+ .sequence_fields.bits = {
+ .pulldown = v->broadcast,
+ .interlace = v->interlace,
+ .tfcntrflag = v->tfcntrflag,
+ .finterpflag = v->finterpflag,
+ .psf = v->psf,
+ .multires = v->multires,
+ .overlap = v->overlap,
+ .syncmarker = v->resync_marker,
+ .rangered = v->rangered,
+ .max_b_frames = s->avctx->max_b_frames,
+ .profile = v->profile,
+ },
+ .coded_width = s->avctx->coded_width,
+ .coded_height = s->avctx->coded_height,
+ .entrypoint_fields.bits = {
+ .broken_link = v->broken_link,
+ .closed_entry = v->closed_entry,
+ .panscan_flag = v->panscanflag,
+ .loopfilter = s->loop_filter,
+ },
+ .conditional_overlap_flag = v->condover,
+ .fast_uvmc_flag = v->fastuvmc,
+ .range_mapping_fields.bits = {
+ .luma_flag = v->range_mapy_flag,
+ .luma = v->range_mapy,
+ .chroma_flag = v->range_mapuv_flag,
+ .chroma = v->range_mapuv,
+ },
+ .b_picture_fraction = v->bfraction_lut_index,
+ .cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0,
+ .mb_mode_table = 0, /* XXX: interlaced frame */
+ .range_reduction_frame = v->rangeredfrm,
+ .rounding_control = v->rnd,
+ .post_processing = v->postproc,
+ .picture_resolution_index = v->respic,
+ .luma_scale = v->lumscale,
+ .luma_shift = v->lumshift,
+ .picture_fields.bits = {
+ .picture_type = vc1_get_PTYPE(v),
+ .frame_coding_mode = v->fcm,
+ .top_field_first = v->tff,
+ .is_first_field = v->fcm == 0, /* XXX: interlaced frame */
+ .intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP,
+ },
+ .raw_coding.flags = {
+ .mv_type_mb = v->mv_type_is_raw,
+ .direct_mb = v->dmb_is_raw,
+ .skip_mb = v->skip_is_raw,
+ .field_tx = 0, /* XXX: interlaced frame */
+ .forward_mb = 0, /* XXX: interlaced frame */
+ .ac_pred = v->acpred_is_raw,
+ .overflags = v->overflg_is_raw,
+ },
+ .bitplane_present.flags = {
+ .bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v),
+ .bp_direct_mb = vc1_has_DIRECTMB_bitplane(v),
+ .bp_skip_mb = vc1_has_SKIPMB_bitplane(v),
+ .bp_field_tx = 0, /* XXX: interlaced frame */
+ .bp_forward_mb = 0, /* XXX: interlaced frame */
+ .bp_ac_pred = vc1_has_ACPRED_bitplane(v),
+ .bp_overflags = vc1_has_OVERFLAGS_bitplane(v),
+ },
+ .reference_fields.bits = {
+ .reference_distance_flag = v->refdist_flag,
+ .reference_distance = 0, /* XXX: interlaced frame */
+ .num_reference_pictures = 0, /* XXX: interlaced frame */
+ .reference_field_pic_indicator = 0, /* XXX: interlaced frame */
+ },
+ .mv_fields.bits = {
+ .mv_mode = vc1_get_MVMODE(v),
+ .mv_mode2 = vc1_get_MVMODE2(v),
+ .mv_table = s->mv_table_index,
+ .two_mv_block_pattern_table = 0, /* XXX: interlaced frame */
+ .four_mv_switch = 0, /* XXX: interlaced frame */
+ .four_mv_block_pattern_table = 0, /* XXX: interlaced frame */
+ .extended_mv_flag = v->extended_mv,
+ .extended_mv_range = v->mvrange,
+ .extended_dmv_flag = v->extended_dmv,
+ .extended_dmv_range = 0, /* XXX: interlaced frame */
+ },
+ .pic_quantizer_fields.bits = {
+ .dquant = v->dquant,
+ .quantizer = v->quantizer_mode,
+ .half_qp = v->halfpq,
+ .pic_quantizer_scale = v->pq,
+ .pic_quantizer_type = v->pquantizer,
+ .dq_frame = v->dquantfrm,
+ .dq_profile = v->dqprofile,
+ .dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0,
+ .dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0,
+ .dq_binary_level = v->dqbilevel,
+ .alt_pic_quantizer = v->altpq,
+ },
+ .transform_fields.bits = {
+ .variable_sized_transform_flag = v->vstransform,
+ .mb_level_transform_type_flag = v->ttmbf,
+ .frame_level_transform_type = vc1_get_TTFRM(v),
+ .transform_ac_codingset_idx1 = v->c_ac_table_index,
+ .transform_ac_codingset_idx2 = v->y_ac_table_index,
+ .intra_transform_dc_table = v->s.dc_table_index,
+ },
+ };