Unified · Split
| @@ -20,8 +20,8 @@ · 19 unmodified lines | ||
| 20 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | −#include "vaapi_internal.h" | |
| 24 | 23 | #include "internal.h" |
| 24 | +#include "vaapi_decode.h" | |
| 25 | 25 | #include "vc1.h" |
| 26 | 26 | #include "vc1data.h" |
| 27 | 27 | |
| @@ -148,143 +148,165 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t · 120 unmodified lines | ||
| 148 | 148 | { |
| 149 | 149 | const VC1Context *v = avctx->priv_data; |
| 150 | 150 | const MpegEncContext *s = &v->s; |
| 151 | − struct vaapi_context * const vactx = avctx->hwaccel_context; | |
| 152 | − VAPictureParameterBufferVC1 *pic_param; | |
| 153 | − | |
| 154 | − vactx->slice_param_size = sizeof(VASliceParameterBufferVC1); | |
| 155 | − | |
| 156 | − /* Fill in VAPictureParameterBufferVC1 */ | |
| 157 | − pic_param = ff_vaapi_alloc_pic_param(vactx, sizeof(VAPictureParameterBufferVC1)); | |
| 158 | − if (!pic_param) | |
| 159 | − return -1; | |
| 160 | − pic_param->forward_reference_picture = VA_INVALID_ID; | |
| 161 | − pic_param->backward_reference_picture = VA_INVALID_ID; | |
| 162 | − pic_param->inloop_decoded_picture = VA_INVALID_ID; | |
| 163 | − pic_param->sequence_fields.value = 0; /* reset all bits */ | |
| 164 | − pic_param->sequence_fields.bits.pulldown = v->broadcast; | |
| 165 | − pic_param->sequence_fields.bits.interlace = v->interlace; | |
| 166 | − pic_param->sequence_fields.bits.tfcntrflag = v->tfcntrflag; | |
| 167 | − pic_param->sequence_fields.bits.finterpflag = v->finterpflag; | |
| 168 | − pic_param->sequence_fields.bits.psf = v->psf; | |
| 169 | − pic_param->sequence_fields.bits.multires = v->multires; | |
| 170 | − pic_param->sequence_fields.bits.overlap = v->overlap; | |
| 171 | − pic_param->sequence_fields.bits.syncmarker = v->resync_marker; | |
| 172 | − pic_param->sequence_fields.bits.rangered = v->rangered; | |
| 173 | − pic_param->sequence_fields.bits.max_b_frames = s->avctx->max_b_frames; | |
| 174 | − pic_param->sequence_fields.bits.profile = v->profile; | |
| 175 | − pic_param->coded_width = s->avctx->coded_width; | |
| 176 | − pic_param->coded_height = s->avctx->coded_height; | |
| 177 | − pic_param->entrypoint_fields.value = 0; /* reset all bits */ | |
| 178 | − pic_param->entrypoint_fields.bits.broken_link = v->broken_link; | |
| 179 | − pic_param->entrypoint_fields.bits.closed_entry = v->closed_entry; | |
| 180 | − pic_param->entrypoint_fields.bits.panscan_flag = v->panscanflag; | |
| 181 | − pic_param->entrypoint_fields.bits.loopfilter = s->loop_filter; | |
| 182 | − pic_param->conditional_overlap_flag = v->condover; | |
| 183 | − pic_param->fast_uvmc_flag = v->fastuvmc; | |
| 184 | − pic_param->range_mapping_fields.value = 0; /* reset all bits */ | |
| 185 | − pic_param->range_mapping_fields.bits.luma_flag = v->range_mapy_flag; | |
| 186 | − pic_param->range_mapping_fields.bits.luma = v->range_mapy; | |
| 187 | − pic_param->range_mapping_fields.bits.chroma_flag = v->range_mapuv_flag; | |
| 188 | − pic_param->range_mapping_fields.bits.chroma = v->range_mapuv; | |
| 189 | − pic_param->b_picture_fraction = v->bfraction_lut_index; | |
| 190 | − pic_param->cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0; | |
| 191 | − pic_param->mb_mode_table = 0; /* XXX: interlaced frame */ | |
| 192 | − pic_param->range_reduction_frame = v->rangeredfrm; | |
| 193 | − pic_param->rounding_control = v->rnd; | |
| 194 | − pic_param->post_processing = v->postproc; | |
| 195 | − pic_param->picture_resolution_index = v->respic; | |
| 196 | − pic_param->luma_scale = v->lumscale; | |
| 197 | − pic_param->luma_shift = v->lumshift; | |
| 198 | − pic_param->picture_fields.value = 0; /* reset all bits */ | |
| 199 | − pic_param->picture_fields.bits.picture_type = vc1_get_PTYPE(v); | |
| 200 | − pic_param->picture_fields.bits.frame_coding_mode = v->fcm; | |
| 201 | − pic_param->picture_fields.bits.top_field_first = v->tff; | |
| 202 | − pic_param->picture_fields.bits.is_first_field = v->fcm == 0; /* XXX: interlaced frame */ | |
| 203 | − pic_param->picture_fields.bits.intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP; | |
| 204 | − pic_param->raw_coding.value = 0; /* reset all bits */ | |
| 205 | − pic_param->raw_coding.flags.mv_type_mb = v->mv_type_is_raw; | |
| 206 | − pic_param->raw_coding.flags.direct_mb = v->dmb_is_raw; | |
| 207 | − pic_param->raw_coding.flags.skip_mb = v->skip_is_raw; | |
| 208 | − pic_param->raw_coding.flags.field_tx = 0; /* XXX: interlaced frame */ | |
| 209 | − pic_param->raw_coding.flags.forward_mb = 0; /* XXX: interlaced frame */ | |
| 210 | − pic_param->raw_coding.flags.ac_pred = v->acpred_is_raw; | |
| 211 | − pic_param->raw_coding.flags.overflags = v->overflg_is_raw; | |
| 212 | − pic_param->bitplane_present.value = 0; /* reset all bits */ | |
| 213 | − pic_param->bitplane_present.flags.bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v); | |
| 214 | − pic_param->bitplane_present.flags.bp_direct_mb = vc1_has_DIRECTMB_bitplane(v); | |
| 215 | − pic_param->bitplane_present.flags.bp_skip_mb = vc1_has_SKIPMB_bitplane(v); | |
| 216 | − pic_param->bitplane_present.flags.bp_field_tx = 0; /* XXX: interlaced frame */ | |
| 217 | − pic_param->bitplane_present.flags.bp_forward_mb = 0; /* XXX: interlaced frame */ | |
| 218 | − pic_param->bitplane_present.flags.bp_ac_pred = vc1_has_ACPRED_bitplane(v); | |
| 219 | − pic_param->bitplane_present.flags.bp_overflags = vc1_has_OVERFLAGS_bitplane(v); | |
| 220 | − pic_param->reference_fields.value = 0; /* reset all bits */ | |
| 221 | − pic_param->reference_fields.bits.reference_distance_flag = v->refdist_flag; | |
| 222 | − pic_param->reference_fields.bits.reference_distance = 0; /* XXX: interlaced frame */ | |
| 223 | − pic_param->reference_fields.bits.num_reference_pictures = 0; /* XXX: interlaced frame */ | |
| 224 | − pic_param->reference_fields.bits.reference_field_pic_indicator = 0; /* XXX: interlaced frame */ | |
| 225 | − pic_param->mv_fields.value = 0; /* reset all bits */ | |
| 226 | − pic_param->mv_fields.bits.mv_mode = vc1_get_MVMODE(v); | |
| 227 | − pic_param->mv_fields.bits.mv_mode2 = vc1_get_MVMODE2(v); | |
| 228 | − pic_param->mv_fields.bits.mv_table = s->mv_table_index; | |
| 229 | − pic_param->mv_fields.bits.two_mv_block_pattern_table = 0; /* XXX: interlaced frame */ | |
| 230 | − pic_param->mv_fields.bits.four_mv_switch = 0; /* XXX: interlaced frame */ | |
| 231 | − pic_param->mv_fields.bits.four_mv_block_pattern_table = 0; /* XXX: interlaced frame */ | |
| 232 | − pic_param->mv_fields.bits.extended_mv_flag = v->extended_mv; | |
| 233 | − pic_param->mv_fields.bits.extended_mv_range = v->mvrange; | |
| 234 | − pic_param->mv_fields.bits.extended_dmv_flag = v->extended_dmv; | |
| 235 | − pic_param->mv_fields.bits.extended_dmv_range = 0; /* XXX: interlaced frame */ | |
| 236 | − pic_param->pic_quantizer_fields.value = 0; /* reset all bits */ | |
| 237 | − pic_param->pic_quantizer_fields.bits.dquant = v->dquant; | |
| 238 | − pic_param->pic_quantizer_fields.bits.quantizer = v->quantizer_mode; | |
| 239 | − pic_param->pic_quantizer_fields.bits.half_qp = v->halfpq; | |
| 240 | − pic_param->pic_quantizer_fields.bits.pic_quantizer_scale = v->pq; | |
| 241 | − pic_param->pic_quantizer_fields.bits.pic_quantizer_type = v->pquantizer; | |
| 242 | − pic_param->pic_quantizer_fields.bits.dq_frame = v->dquantfrm; | |
| 243 | − pic_param->pic_quantizer_fields.bits.dq_profile = v->dqprofile; | |
| 244 | − pic_param->pic_quantizer_fields.bits.dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0; | |
| 245 | − pic_param->pic_quantizer_fields.bits.dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0; | |
| 246 | − pic_param->pic_quantizer_fields.bits.dq_binary_level = v->dqbilevel; | |
| 247 | − pic_param->pic_quantizer_fields.bits.alt_pic_quantizer = v->altpq; | |
| 248 | − pic_param->transform_fields.value = 0; /* reset all bits */ | |
| 249 | − pic_param->transform_fields.bits.variable_sized_transform_flag = v->vstransform; | |
| 250 | − pic_param->transform_fields.bits.mb_level_transform_type_flag = v->ttmbf; | |
| 251 | − pic_param->transform_fields.bits.frame_level_transform_type = vc1_get_TTFRM(v); | |
| 252 | − pic_param->transform_fields.bits.transform_ac_codingset_idx1 = v->c_ac_table_index; | |
| 253 | − pic_param->transform_fields.bits.transform_ac_codingset_idx2 = v->y_ac_table_index; | |
| 254 | − pic_param->transform_fields.bits.intra_transform_dc_table = v->s.dc_table_index; | |
| 151 | + VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; | |
| 152 | + VAPictureParameterBufferVC1 pic_param; | |
| 153 | + int err; | |
| 154 | + | |
| 155 | + pic->output_surface = ff_vaapi_get_surface_id(s->current_picture_ptr->f); | |
| 156 | + | |
| 157 | + pic_param = (VAPictureParameterBufferVC1) { | |
| 158 | + .forward_reference_picture = VA_INVALID_ID, | |
| 159 | + .backward_reference_picture = VA_INVALID_ID, | |
| 160 | + .inloop_decoded_picture = VA_INVALID_ID, | |
| 161 | + .sequence_fields.bits = { | |
| 162 | + .pulldown = v->broadcast, | |
| 163 | + .interlace = v->interlace, | |
| 164 | + .tfcntrflag = v->tfcntrflag, | |
| 165 | + .finterpflag = v->finterpflag, | |
| 166 | + .psf = v->psf, | |
| 167 | + .multires = v->multires, | |
| 168 | + .overlap = v->overlap, | |
| 169 | + .syncmarker = v->resync_marker, | |
| 170 | + .rangered = v->rangered, | |
| 171 | + .max_b_frames = s->avctx->max_b_frames, | |
| 172 | + .profile = v->profile, | |
| 173 | + }, | |
| 174 | + .coded_width = s->avctx->coded_width, | |
| 175 | + .coded_height = s->avctx->coded_height, | |
| 176 | + .entrypoint_fields.bits = { | |
| 177 | + .broken_link = v->broken_link, | |
| 178 | + .closed_entry = v->closed_entry, | |
| 179 | + .panscan_flag = v->panscanflag, | |
| 180 | + .loopfilter = s->loop_filter, | |
| 181 | + }, | |
| 182 | + .conditional_overlap_flag = v->condover, | |
| 183 | + .fast_uvmc_flag = v->fastuvmc, | |
| 184 | + .range_mapping_fields.bits = { | |
| 185 | + .luma_flag = v->range_mapy_flag, | |
| 186 | + .luma = v->range_mapy, | |
| 187 | + .chroma_flag = v->range_mapuv_flag, | |
| 188 | + .chroma = v->range_mapuv, | |
| 189 | + }, | |
| 190 | + .b_picture_fraction = v->bfraction_lut_index, | |
| 191 | + .cbp_table = v->cbpcy_vlc ? v->cbpcy_vlc - ff_vc1_cbpcy_p_vlc : 0, | |
| 192 | + .mb_mode_table = 0, /* XXX: interlaced frame */ | |
| 193 | + .range_reduction_frame = v->rangeredfrm, | |
| 194 | + .rounding_control = v->rnd, | |
| 195 | + .post_processing = v->postproc, | |
| 196 | + .picture_resolution_index = v->respic, | |
| 197 | + .luma_scale = v->lumscale, | |
| 198 | + .luma_shift = v->lumshift, | |
| 199 | + .picture_fields.bits = { | |
| 200 | + .picture_type = vc1_get_PTYPE(v), | |
| 201 | + .frame_coding_mode = v->fcm, | |
| 202 | + .top_field_first = v->tff, | |
| 203 | + .is_first_field = v->fcm == 0, /* XXX: interlaced frame */ | |
| 204 | + .intensity_compensation = v->mv_mode == MV_PMODE_INTENSITY_COMP, | |
| 205 | + }, | |
| 206 | + .raw_coding.flags = { | |
| 207 | + .mv_type_mb = v->mv_type_is_raw, | |
| 208 | + .direct_mb = v->dmb_is_raw, | |
| 209 | + .skip_mb = v->skip_is_raw, | |
| 210 | + .field_tx = 0, /* XXX: interlaced frame */ | |
| 211 | + .forward_mb = 0, /* XXX: interlaced frame */ | |
| 212 | + .ac_pred = v->acpred_is_raw, | |
| 213 | + .overflags = v->overflg_is_raw, | |
| 214 | + }, | |
| 215 | + .bitplane_present.flags = { | |
| 216 | + .bp_mv_type_mb = vc1_has_MVTYPEMB_bitplane(v), | |
| 217 | + .bp_direct_mb = vc1_has_DIRECTMB_bitplane(v), | |
| 218 | + .bp_skip_mb = vc1_has_SKIPMB_bitplane(v), | |
| 219 | + .bp_field_tx = 0, /* XXX: interlaced frame */ | |
| 220 | + .bp_forward_mb = 0, /* XXX: interlaced frame */ | |
| 221 | + .bp_ac_pred = vc1_has_ACPRED_bitplane(v), | |
| 222 | + .bp_overflags = vc1_has_OVERFLAGS_bitplane(v), | |
| 223 | + }, | |
| 224 | + .reference_fields.bits = { | |
| 225 | + .reference_distance_flag = v->refdist_flag, | |
| 226 | + .reference_distance = 0, /* XXX: interlaced frame */ | |
| 227 | + .num_reference_pictures = 0, /* XXX: interlaced frame */ | |
| 228 | + .reference_field_pic_indicator = 0, /* XXX: interlaced frame */ | |
| 229 | + }, | |
| 230 | + .mv_fields.bits = { | |
| 231 | + .mv_mode = vc1_get_MVMODE(v), | |
| 232 | + .mv_mode2 = vc1_get_MVMODE2(v), | |
| 233 | + .mv_table = s->mv_table_index, | |
| 234 | + .two_mv_block_pattern_table = 0, /* XXX: interlaced frame */ | |
| 235 | + .four_mv_switch = 0, /* XXX: interlaced frame */ | |
| 236 | + .four_mv_block_pattern_table = 0, /* XXX: interlaced frame */ | |
| 237 | + .extended_mv_flag = v->extended_mv, | |
| 238 | + .extended_mv_range = v->mvrange, | |
| 239 | + .extended_dmv_flag = v->extended_dmv, | |
| 240 | + .extended_dmv_range = 0, /* XXX: interlaced frame */ | |
| 241 | + }, | |
| 242 | + .pic_quantizer_fields.bits = { | |
| 243 | + .dquant = v->dquant, | |
| 244 | + .quantizer = v->quantizer_mode, | |
| 245 | + .half_qp = v->halfpq, | |
| 246 | + .pic_quantizer_scale = v->pq, | |
| 247 | + .pic_quantizer_type = v->pquantizer, | |
| 248 | + .dq_frame = v->dquantfrm, | |
| 249 | + .dq_profile = v->dqprofile, | |
| 250 | + .dq_sb_edge = v->dqprofile == DQPROFILE_SINGLE_EDGE ? v->dqsbedge : 0, | |
| 251 | + .dq_db_edge = v->dqprofile == DQPROFILE_DOUBLE_EDGES ? v->dqsbedge : 0, | |
| 252 | + .dq_binary_level = v->dqbilevel, | |
| 253 | + .alt_pic_quantizer = v->altpq, | |
| 254 | + }, | |
| 255 | + .transform_fields.bits = { | |
| 256 | + .variable_sized_transform_flag = v->vstransform, | |
| 257 | + .mb_level_transform_type_flag = v->ttmbf, | |
| 258 | + .frame_level_transform_type = vc1_get_TTFRM(v), | |
| 259 | + .transform_ac_codingset_idx1 = v->c_ac_table_index, | |
| 260 | + .transform_ac_codingset_idx2 = v->y_ac_table_index, | |
| 261 | + .intra_transform_dc_table = v->s.dc_table_index, | |
| 262 | + }, | |
| 263 | + }; | |
| 255 | 264 | |
| 256 | 265 | switch (s->pict_type) { |
| 257 | 266 | case AV_PICTURE_TYPE_B: |
| 258 | − pic_param->backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f); | |
| 267 | + pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_picture.f); | |
| 259 | 268 | // fall-through |
| 260 | 269 | case AV_PICTURE_TYPE_P: |
| 261 | − pic_param->forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f); | |
| 270 | + pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_picture.f); | |
| 262 | 271 | break; |
| 263 | 272 | } |
| 264 | 273 | |
| 265 | − if (pic_param->bitplane_present.value) { | |
| 274 | + err = ff_vaapi_decode_make_param_buffer(avctx, pic, | |
| 275 | + VAPictureParameterBufferType, | |
| 276 | + &pic_param, sizeof(pic_param)); | |
| 277 | + if (err) | |
| 278 | + goto fail; | |
| 279 | + | |
| 280 | + if (pic_param.bitplane_present.value) { | |
| 266 | 281 | uint8_t *bitplane; |
| 267 | 282 | const uint8_t *ff_bp[3]; |
| 268 | 283 | int x, y, n; |
| 284 | + size_t size = (s->mb_width * s->mb_height + 1) / 2; | |
| 285 | + | |
| 286 | + bitplane = av_mallocz(size); | |
| 287 | + if (!bitplane) { | |
| 288 | + err = AVERROR(ENOMEM); | |
| 289 | + goto fail; | |
| 290 | + } | |
| 269 | 291 | |
| 270 | 292 | switch (s->pict_type) { |
| 271 | 293 | case AV_PICTURE_TYPE_P: |
| 272 | − ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; | |
| 273 | − ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; | |
| 274 | − ff_bp[2] = pic_param->bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL; | |
| 294 | + ff_bp[0] = pic_param.bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; | |
| 295 | + ff_bp[1] = pic_param.bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; | |
| 296 | + ff_bp[2] = pic_param.bitplane_present.flags.bp_mv_type_mb ? v->mv_type_mb_plane : NULL; | |
| 275 | 297 | break; |
| 276 | 298 | case AV_PICTURE_TYPE_B: |
| 277 | 299 | if (!v->bi_type) { |
| 278 | − ff_bp[0] = pic_param->bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; | |
| 279 | − ff_bp[1] = pic_param->bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; | |
| 300 | + ff_bp[0] = pic_param.bitplane_present.flags.bp_direct_mb ? v->direct_mb_plane : NULL; | |
| 301 | + ff_bp[1] = pic_param.bitplane_present.flags.bp_skip_mb ? s->mbskip_table : NULL; | |
| 280 | 302 | ff_bp[2] = NULL; /* XXX: interlaced frame (FORWARD plane) */ |
| 281 | 303 | break; |
| 282 | 304 | } |
| 283 | 305 | /* fall-through (BI-type) */ |
| 284 | 306 | case AV_PICTURE_TYPE_I: |
| 285 | 307 | ff_bp[0] = NULL; /* XXX: interlaced frame (FIELDTX plane) */ |
| 286 | − ff_bp[1] = pic_param->bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL; | |
| 287 | − ff_bp[2] = pic_param->bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL; | |
| 308 | + ff_bp[1] = pic_param.bitplane_present.flags.bp_ac_pred ? v->acpred_plane : NULL; | |
| 309 | + ff_bp[2] = pic_param.bitplane_present.flags.bp_overflags ? v->over_flags_plane : NULL; | |
| 288 | 310 | break; |
| 289 | 311 | default: |
| 290 | 312 | ff_bp[0] = NULL; |
| @@ -293,25 +315,51 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t · 2 unmodified lines | ||
| 293 | 315 | break; |
| 294 | 316 | } |
| 295 | 317 | |
| 296 | − bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2); | |
| 297 | − if (!bitplane) | |
| 298 | − return -1; | |
| 299 | − | |
| 300 | 318 | n = 0; |
| 301 | 319 | for (y = 0; y < s->mb_height; y++) |
| 302 | 320 | for (x = 0; x < s->mb_width; x++, n++) |
| 303 | 321 | vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride); |
| 304 | 322 | if (n & 1) /* move last nibble to the high order */ |
| 305 | 323 | bitplane[n/2] <<= 4; |
| 324 | + | |
| 325 | + err = ff_vaapi_decode_make_param_buffer(avctx, pic, | |
| 326 | + VABitPlaneBufferType, | |
| 327 | + bitplane, size); | |
| 328 | + av_free(bitplane); | |
| 329 | + if (err) | |
| 330 | + goto fail; | |
| 306 | 331 | } |
| 307 | 332 | return 0; |
| 333 | + | |
| 334 | +fail: | |
| 335 | + ff_vaapi_decode_cancel(avctx, pic); | |
| 336 | + return err; | |
| 337 | +} | |
| 338 | + | |
| 339 | +static int vaapi_vc1_end_frame(AVCodecContext *avctx) | |
| 340 | +{ | |
| 341 | + VC1Context *v = avctx->priv_data; | |
| 342 | + MpegEncContext *s = &v->s; | |
| 343 | + VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; | |
| 344 | + int ret; | |
| 345 | + | |
| 346 | + ret = ff_vaapi_decode_issue(avctx, pic); | |
| 347 | + if (ret < 0) | |
| 348 | + goto fail; | |
| 349 | + | |
| 350 | + ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); | |
| 351 | + | |
| 352 | +fail: | |
| 353 | + return ret; | |
| 308 | 354 | } |
| 309 | 355 | |
| 310 | 356 | static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) |
| 311 | 357 | { |
| 312 | 358 | const VC1Context *v = avctx->priv_data; |
| 313 | 359 | const MpegEncContext *s = &v->s; |
| 314 | − VASliceParameterBufferVC1 *slice_param; | |
| 360 | + VAAPIDecodePicture *pic = s->current_picture_ptr->hwaccel_picture_private; | |
| 361 | + VASliceParameterBufferVC1 slice_param; | |
| 362 | + int err; | |
| 315 | 363 | |
| 316 | 364 | /* Current bit buffer is beyond any marker for VC-1, so skip it */ |
| 317 | 365 | if (avctx->codec_id == AV_CODEC_ID_VC1 && IS_MARKER(AV_RB32(buffer))) { |
| @@ -319,33 +367,51 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, · 1 unmodified line | ||
| 319 | 367 | size -= 4; |
| 320 | 368 | } |
| 321 | 369 | |
| 322 | − /* Fill in VASliceParameterBufferVC1 */ | |
| 323 | − slice_param = (VASliceParameterBufferVC1 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size); | |
| 324 | − if (!slice_param) | |
| 325 | − return -1; | |
| 326 | − slice_param->macroblock_offset = get_bits_count(&s->gb); | |
| 327 | − slice_param->slice_vertical_position = s->mb_y; | |
| 370 | + slice_param = (VASliceParameterBufferVC1) { | |
| 371 | + .slice_data_size = size, | |
| 372 | + .slice_data_offset = 0, | |
| 373 | + .slice_data_flag = VA_SLICE_DATA_FLAG_ALL, | |
| 374 | + .macroblock_offset = get_bits_count(&s->gb), | |
| 375 | + .slice_vertical_position = s->mb_y, | |
| 376 | + }; | |
| 377 | + | |
| 378 | + err = ff_vaapi_decode_make_slice_buffer(avctx, pic, | |
| 379 | + &slice_param, sizeof(slice_param), | |
| 380 | + buffer, size); | |
| 381 | + if (err < 0) { | |
| 382 | + ff_vaapi_decode_cancel(avctx, pic); | |
| 383 | + return err; | |
| 384 | + } | |
| 385 | + | |
| 328 | 386 | return 0; |
| 329 | 387 | } |
| 330 | 388 | |
| 331 | 389 | #if CONFIG_WMV3_VAAPI_HWACCEL |
| 332 | 390 | AVHWAccel ff_wmv3_vaapi_hwaccel = { |
| 333 | − .name = "wmv3_vaapi", | |
| 334 | − .type = AVMEDIA_TYPE_VIDEO, | |
| 335 | − .id = AV_CODEC_ID_WMV3, | |
| 336 | − .pix_fmt = AV_PIX_FMT_VAAPI, | |
| 337 | − .start_frame = vaapi_vc1_start_frame, | |
| 338 | − .end_frame = ff_vaapi_mpeg_end_frame, | |
| 339 | − .decode_slice = vaapi_vc1_decode_slice, | |
| 391 | + .name = "wmv3_vaapi", | |
| 392 | + .type = AVMEDIA_TYPE_VIDEO, | |
| 393 | + .id = AV_CODEC_ID_WMV3, | |
| 394 | + .pix_fmt = AV_PIX_FMT_VAAPI, | |
| 395 | + .start_frame = &vaapi_vc1_start_frame, | |
| 396 | + .end_frame = &vaapi_vc1_end_frame, | |
| 397 | + .decode_slice = &vaapi_vc1_decode_slice, | |
| 398 | + .frame_priv_data_size = sizeof(VAAPIDecodePicture), | |
| 399 | + .init = &ff_vaapi_decode_init, | |
| 400 | + .uninit = &ff_vaapi_decode_uninit, | |
| 401 | + .priv_data_size = sizeof(VAAPIDecodeContext), | |
| 340 | 402 | }; |
| 341 | 403 | #endif |
| 342 | 404 | |
| 343 | 405 | AVHWAccel ff_vc1_vaapi_hwaccel = { |
| 344 | − .name = "vc1_vaapi", | |
| 345 | − .type = AVMEDIA_TYPE_VIDEO, | |
| 346 | − .id = AV_CODEC_ID_VC1, | |
| 347 | − .pix_fmt = AV_PIX_FMT_VAAPI, | |
| 348 | − .start_frame = vaapi_vc1_start_frame, | |
| 349 | − .end_frame = ff_vaapi_mpeg_end_frame, | |
| 350 | − .decode_slice = vaapi_vc1_decode_slice, | |
| 406 | + .name = "vc1_vaapi", | |
| 407 | + .type = AVMEDIA_TYPE_VIDEO, | |
| 408 | + .id = AV_CODEC_ID_VC1, | |
| 409 | + .pix_fmt = AV_PIX_FMT_VAAPI, | |
| 410 | + .start_frame = &vaapi_vc1_start_frame, | |
| 411 | + .end_frame = &vaapi_vc1_end_frame, | |
| 412 | + .decode_slice = &vaapi_vc1_decode_slice, | |
| 413 | + .frame_priv_data_size = sizeof(VAAPIDecodePicture), | |
| 414 | + .init = &ff_vaapi_decode_init, | |
| 415 | + .uninit = &ff_vaapi_decode_uninit, | |
| 416 | + .priv_data_size = sizeof(VAAPIDecodeContext), | |
| 351 | 417 | }; |