* We have to do that before the "dummy" in-between frame allocation,
* since that can modify h->cur_pic_ptr. */
if (h->first_field) {
+ int last_field = last_pic_structure == PICT_BOTTOM_FIELD;
av_assert0(h->cur_pic_ptr);
av_assert0(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
/* Mark old field/frame as completed */
- if (h->cur_pic_ptr->tf.owner == h->avctx) {
- ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
- last_pic_structure == PICT_BOTTOM_FIELD);
+ if (h->cur_pic_ptr->tf.owner[last_field] == h->avctx) {
+ ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, last_field);
}
/* figure out if we have a complementary field pair */
return AVERROR_INVALIDDATA;
}
} else {
+ int field = h->picture_structure == PICT_BOTTOM_FIELD;
release_unused_pictures(h, 0);
+ h->cur_pic_ptr->tf.owner[field] = h->avctx;
}
/* Some macroblocks can be accessed before they're available in case
* of lost slices, MBAFF or threading. */
}
if ((pps->weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) ||
(pps->weighted_bipred_idc == 1 &&
- sl->slice_type_nos == AV_PICTURE_TYPE_B))
- ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count,
+ sl->slice_type_nos == AV_PICTURE_TYPE_B)) {
+ ret = ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count,
sl->slice_type_nos, &sl->pwt, h->avctx);
+ if (ret < 0)
+ return ret;
+ }
sl->explicit_ref_marking = 0;
if (nal->ref_idc) {
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
- ff_h264_direct_ref_list_init(h, sl);
+ if (!h->setup_finished)
+ ff_h264_direct_ref_list_init(h, sl);
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&