summaryrefslogtreecommitdiff
path: root/libavcodec/h264_slice.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-24 20:36:10 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-25 19:07:31 +0100
commite944ab796d9624b269424c5a6e2e82cf393b2884 (patch)
tree09723b4e0a6223081f032bc1f8f89af2531ad8d3 /libavcodec/h264_slice.c
parentc4fcfa47df24bbef354ae3ae3e1fe839c95519fb (diff)
avcodec/h264dec: Move ERContext to H264Context
Since 7be2d2a70cd20d88fd826a83f87037d14681a579 only one context is used. Moving it to H264Context from H264SliceContext is natural. One could access the ERContext from H264SliceContext via H264SliceContext.h264->er; yet H264SliceContext.h264 should naturally be const-qualified, because slice threads should not modify the main context. The ERContext is an exception to this, as ff_er_add_slice() is intended to be called simultaneously by multiple threads. And for this one needs a pointer whose pointed-to-type is not const-qualified. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r--libavcodec/h264_slice.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index f6104dde89..d56722a5c2 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -537,7 +537,7 @@ static int h264_frame_start(H264Context *h)
h->cur_pic_ptr = pic;
ff_h264_unref_picture(h, &h->cur_pic);
if (CONFIG_ERROR_RESILIENCE) {
- ff_h264_set_erpic(&h->slice_ctx[0].er.cur_pic, NULL);
+ ff_h264_set_erpic(&h->er.cur_pic, NULL);
}
if ((ret = ff_h264_ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
@@ -549,9 +549,9 @@ static int h264_frame_start(H264Context *h)
}
if (CONFIG_ERROR_RESILIENCE && h->enable_er) {
- ff_er_frame_start(&h->slice_ctx[0].er);
- ff_h264_set_erpic(&h->slice_ctx[0].er.last_pic, NULL);
- ff_h264_set_erpic(&h->slice_ctx[0].er.next_pic, NULL);
+ ff_er_frame_start(&h->er);
+ ff_h264_set_erpic(&h->er.last_pic, NULL);
+ ff_h264_set_erpic(&h->er.next_pic, NULL);
}
for (i = 0; i < 16; i++) {
@@ -1004,11 +1004,7 @@ static int h264_slice_header_init(H264Context *h)
ff_videodsp_init(&h->vdsp, sps->bit_depth_luma);
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
- ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
- if (ret < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
- goto fail;
- }
+ ff_h264_slice_context_init(h, &h->slice_ctx[0]);
} else {
for (i = 0; i < h->nb_slice_ctx; i++) {
H264SliceContext *sl = &h->slice_ctx[i];
@@ -1018,10 +1014,7 @@ static int h264_slice_header_init(H264Context *h)
sl->mvd_table[0] = h->mvd_table[0] + i * 8 * 2 * h->mb_stride;
sl->mvd_table[1] = h->mvd_table[1] + i * 8 * 2 * h->mb_stride;
- if ((ret = ff_h264_slice_context_init(h, sl)) < 0) {
- av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
- goto fail;
- }
+ ff_h264_slice_context_init(h, sl);
}
}
@@ -2667,7 +2660,7 @@ static void decode_finish_row(const H264Context *h, H264SliceContext *sl)
ff_h264_draw_horiz_band(h, sl, top, height);
- if (h->droppable || sl->h264->slice_ctx[0].er.error_occurred)
+ if (h->droppable || h->er.error_occurred)
return;
ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1,
@@ -2682,9 +2675,7 @@ static void er_add_slice(H264SliceContext *sl,
return;
if (CONFIG_ERROR_RESILIENCE) {
- ERContext *er = &sl->h264->slice_ctx[0].er;
-
- ff_er_add_slice(er, startx, starty, endx, endy, status);
+ ff_er_add_slice(sl->er, startx, starty, endx, endy, status);
}
}
@@ -2713,13 +2704,13 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
sl->is_complex = FRAME_MBAFF(h) || h->picture_structure != PICT_FRAME ||
(CONFIG_GRAY && (h->flags & AV_CODEC_FLAG_GRAY));
- if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->slice_ctx[0].er.error_status_table) {
+ if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && sl->er->error_status_table) {
const int start_i = av_clip(sl->resync_mb_x + sl->resync_mb_y * h->mb_width, 0, h->mb_num - 1);
if (start_i) {
- int prev_status = h->slice_ctx[0].er.error_status_table[h->slice_ctx[0].er.mb_index2xy[start_i - 1]];
+ int prev_status = sl->er->error_status_table[sl->er->mb_index2xy[start_i - 1]];
prev_status &= ~ VP_START;
if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END))
- h->slice_ctx[0].er.error_occurred = 1;
+ sl->er->error_occurred = 1;
}
}