return 0;
}
+static av_cold int h264_decode_end(AVCodecContext *avctx)
+{
+ H264Context *h = avctx->priv_data;
+ int i;
+
+ ff_h264_remove_all_refs(h);
+ ff_h264_free_tables(h);
+
+ for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
+ ff_h264_unref_picture(h, &h->DPB[i]);
+ av_frame_free(&h->DPB[i].f);
+ }
+ memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
+
+ h->cur_pic_ptr = NULL;
+
+ av_freep(&h->slice_ctx);
+ h->nb_slice_ctx = 0;
+
+ ff_h264_sei_uninit(&h->sei);
+
+ for (i = 0; i < MAX_SPS_COUNT; i++)
+ av_buffer_unref(&h->ps.sps_list[i]);
+
+ for (i = 0; i < MAX_PPS_COUNT; i++)
+ av_buffer_unref(&h->ps.pps_list[i]);
+
+ av_buffer_unref(&h->ps.sps_ref);
+ av_buffer_unref(&h->ps.pps_ref);
+
+ ff_h2645_packet_uninit(&h->pkt);
+
+ ff_h264_unref_picture(h, &h->cur_pic);
+ av_frame_free(&h->cur_pic.f);
+ ff_h264_unref_picture(h, &h->last_pic_for_ec);
+ av_frame_free(&h->last_pic_for_ec.f);
+
+ return 0;
+}
+
static AVOnce h264_vlc_init = AV_ONCE_INIT;
av_cold int ff_h264_decode_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
- /* set defaults */
- if (!avctx->has_b_frames)
- h->low_delay = 1;
-
ret = ff_thread_once(&h264_vlc_init, ff_h264_decode_init_vlc);
if (ret != 0) {
av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
if (h->ps.sps && h->ps.sps->bitstream_restriction_flag &&
h->avctx->has_b_frames < h->ps.sps->num_reorder_frames) {
h->avctx->has_b_frames = h->ps.sps->num_reorder_frames;
- h->low_delay = 0;
}
avctx->internal->allocate_progress = 1;
H264Picture *cur = h->cur_pic_ptr;
int i, pics, out_of_order, out_idx;
- h->cur_pic_ptr->f->pict_type = h->pict_type;
-
if (h->next_output_pic)
return;
h->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
h->avctx->has_b_frames = FFMAX(h->avctx->has_b_frames, sps->num_reorder_frames);
}
- h->low_delay = !h->avctx->has_b_frames;
for (i = 0; 1; i++) {
if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
} else if(h->avctx->has_b_frames < out_of_order && !sps->bitstream_restriction_flag){
av_log(h->avctx, AV_LOG_INFO, "Increasing reorder buffer to %d\n", out_of_order);
h->avctx->has_b_frames = out_of_order;
- h->low_delay = 0;
}
pics = 0;
if (out_of_order || pics > h->avctx->has_b_frames) {
out->reference &= ~DELAYED_PIC_REF;
- // for frame threading, the owner must be the second field's thread or
- // else the first thread can release the picture and reuse it unsafely
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
}
goto end;
context_count = 0;
}
- /* Slice could not be decoded in parallel mode, restart. Note
- * that rbsp_buffer is not transferred, but since we no longer
- * run in parallel mode this should not be an issue. */
+ /* Slice could not be decoded in parallel mode, restart. */
sl = &h->slice_ctx[0];
goto again;
}
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
- &h->low_delay,
+ NULL,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
}
return get_consumed_bytes(buf_index, buf_size);
}
-av_cold void ff_h264_free_context(H264Context *h)
-{
- int i;
-
- ff_h264_free_tables(h);
-
- for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
- ff_h264_unref_picture(h, &h->DPB[i]);
- av_frame_free(&h->DPB[i].f);
- }
- memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
-
- h->cur_pic_ptr = NULL;
-
- for (i = 0; i < h->nb_slice_ctx; i++)
- av_freep(&h->slice_ctx[i].rbsp_buffer);
- av_freep(&h->slice_ctx);
- h->nb_slice_ctx = 0;
-
- ff_h264_sei_uninit(&h->sei);
-
- for (i = 0; i < MAX_SPS_COUNT; i++)
- av_buffer_unref(&h->ps.sps_list[i]);
-
- for (i = 0; i < MAX_PPS_COUNT; i++)
- av_buffer_unref(&h->ps.pps_list[i]);
-
- av_buffer_unref(&h->ps.sps_ref);
- av_buffer_unref(&h->ps.pps_ref);
-
- ff_h2645_packet_uninit(&h->pkt);
-}
-
-static av_cold int h264_decode_end(AVCodecContext *avctx)
-{
- H264Context *h = avctx->priv_data;
-
- ff_h264_remove_all_refs(h);
- ff_h264_free_context(h);
-
- ff_h264_unref_picture(h, &h->cur_pic);
- av_frame_free(&h->cur_pic.f);
- ff_h264_unref_picture(h, &h->last_pic_for_ec);
- av_frame_free(&h->last_pic_for_ec.f);
-
- return 0;
-}
-
#define OFFSET(x) offsetof(H264Context, x)
#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption h264_options[] = {