Commit 830e548b authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '582683b6'

* commit '582683b6':
  h264: move remaining ER stuff into the per-slice context

Conflicts:
	libavcodec/h264.h
	libavcodec/h264_picture.c
	libavcodec/h264_slice.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 44309dd2 582683b6
...@@ -401,10 +401,6 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp) ...@@ -401,10 +401,6 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp)
hx = h->thread_context[i]; hx = h->thread_context[i];
if (!hx) if (!hx)
continue; continue;
av_freep(&hx->dc_val_base);
av_freep(&hx->er.mb_index2xy);
av_freep(&hx->er.error_status_table);
av_freep(&hx->er.er_temp_buffer);
if (free_rbsp) { if (free_rbsp) {
av_freep(&hx->rbsp_buffer); av_freep(&hx->rbsp_buffer);
...@@ -417,6 +413,11 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp) ...@@ -417,6 +413,11 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp)
for (i = 0; i < h->nb_slice_ctx; i++) { for (i = 0; i < h->nb_slice_ctx; i++) {
H264SliceContext *sl = &h->slice_ctx[i]; H264SliceContext *sl = &h->slice_ctx[i];
av_freep(&sl->dc_val_base);
av_freep(&sl->er.mb_index2xy);
av_freep(&sl->er.error_status_table);
av_freep(&sl->er.er_temp_buffer);
av_freep(&sl->bipred_scratchpad); av_freep(&sl->bipred_scratchpad);
av_freep(&sl->edge_emu_buffer); av_freep(&sl->edge_emu_buffer);
av_freep(&sl->top_borders[0]); av_freep(&sl->top_borders[0]);
...@@ -499,23 +500,21 @@ fail: ...@@ -499,23 +500,21 @@ fail:
* Init context * Init context
* Allocate buffers which are not shared amongst multiple threads. * Allocate buffers which are not shared amongst multiple threads.
*/ */
int ff_h264_context_init(H264Context *h) int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
{ {
ERContext *er = &h->er; ERContext *er = &sl->er;
int mb_array_size = h->mb_height * h->mb_stride; int mb_array_size = h->mb_height * h->mb_stride;
int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1); int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
int c_size = h->mb_stride * (h->mb_height + 1); int c_size = h->mb_stride * (h->mb_height + 1);
int yc_size = y_size + 2 * c_size; int yc_size = y_size + 2 * c_size;
int x, y, i; int x, y, i;
for (i = 0; i < h->nb_slice_ctx; i++) { sl->ref_cache[0][scan8[5] + 1] =
h->slice_ctx[i].ref_cache[0][scan8[5] + 1] = sl->ref_cache[0][scan8[7] + 1] =
h->slice_ctx[i].ref_cache[0][scan8[7] + 1] = sl->ref_cache[0][scan8[13] + 1] =
h->slice_ctx[i].ref_cache[0][scan8[13] + 1] = sl->ref_cache[1][scan8[5] + 1] =
h->slice_ctx[i].ref_cache[1][scan8[5] + 1] = sl->ref_cache[1][scan8[7] + 1] =
h->slice_ctx[i].ref_cache[1][scan8[7] + 1] = sl->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
h->slice_ctx[i].ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
}
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
/* init ER */ /* init ER */
...@@ -547,13 +546,13 @@ int ff_h264_context_init(H264Context *h) ...@@ -547,13 +546,13 @@ int ff_h264_context_init(H264Context *h)
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer, FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride, fail); h->mb_height * h->mb_stride, fail);
FF_ALLOCZ_OR_GOTO(h->avctx, h->dc_val_base, FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
yc_size * sizeof(int16_t), fail); yc_size * sizeof(int16_t), fail);
er->dc_val[0] = h->dc_val_base + h->mb_width * 2 + 2; er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = h->dc_val_base + y_size + h->mb_stride + 1; er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size; er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++) for (i = 0; i < yc_size; i++)
h->dc_val_base[i] = 1024; sl->dc_val_base[i] = 1024;
} }
return 0; return 0;
...@@ -1906,7 +1905,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data, ...@@ -1906,7 +1905,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
return ret; return ret;
*got_frame = 1; *got_frame = 1;
if (CONFIG_MPEGVIDEO) { if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->avctx, pict, h->er.mbskip_table, ff_print_debug_info2(h->avctx, pict, NULL,
h->next_output_pic->mb_type, h->next_output_pic->mb_type,
h->next_output_pic->qscale_table, h->next_output_pic->qscale_table,
h->next_output_pic->motion_val, h->next_output_pic->motion_val,
......
...@@ -336,6 +336,7 @@ typedef struct H264Picture { ...@@ -336,6 +336,7 @@ typedef struct H264Picture {
typedef struct H264SliceContext { typedef struct H264SliceContext {
struct H264Context *h264; struct H264Context *h264;
GetBitContext gb; GetBitContext gb;
ERContext er;
int slice_num; int slice_num;
int slice_type; int slice_type;
...@@ -435,6 +436,7 @@ typedef struct H264SliceContext { ...@@ -435,6 +436,7 @@ typedef struct H264SliceContext {
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
const uint8_t *intra_pcm_ptr; const uint8_t *intra_pcm_ptr;
int16_t *dc_val_base;
uint8_t *bipred_scratchpad; uint8_t *bipred_scratchpad;
uint8_t *edge_emu_buffer; uint8_t *edge_emu_buffer;
...@@ -487,7 +489,6 @@ typedef struct H264Context { ...@@ -487,7 +489,6 @@ typedef struct H264Context {
H264ChromaContext h264chroma; H264ChromaContext h264chroma;
H264QpelContext h264qpel; H264QpelContext h264qpel;
GetBitContext gb; GetBitContext gb;
ERContext er;
H264Picture *DPB; H264Picture *DPB;
H264Picture *cur_pic_ptr; H264Picture *cur_pic_ptr;
...@@ -774,7 +775,6 @@ typedef struct H264Context { ...@@ -774,7 +775,6 @@ typedef struct H264Context {
uint8_t parse_history[6]; uint8_t parse_history[6];
int parse_history_count; int parse_history_count;
int parse_last_mb; int parse_last_mb;
int16_t *dc_val_base;
AVBufferPool *qscale_table_pool; AVBufferPool *qscale_table_pool;
AVBufferPool *mb_type_pool; AVBufferPool *mb_type_pool;
...@@ -1161,7 +1161,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup); ...@@ -1161,7 +1161,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src); int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
void ff_h264_unref_picture(H264Context *h, H264Picture *pic); void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
int ff_h264_context_init(H264Context *h); int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl);
int ff_h264_set_parameter_from_sps(H264Context *h); int ff_h264_set_parameter_from_sps(H264Context *h);
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height); void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height);
......
...@@ -199,22 +199,22 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) ...@@ -199,22 +199,22 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) { if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
int use_last_pic = h->last_pic_for_ec.f.buf[0] && !sl->ref_count[0]; int use_last_pic = h->last_pic_for_ec.f.buf[0] && !sl->ref_count[0];
ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr); ff_h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);
if (use_last_pic) { if (use_last_pic) {
ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec); ff_h264_set_erpic(&sl->er.last_pic, &h->last_pic_for_ec);
COPY_PICTURE(&sl->ref_list[0][0], &h->last_pic_for_ec); COPY_PICTURE(&sl->ref_list[0][0], &h->last_pic_for_ec);
} else if (sl->ref_count[0]) { } else if (sl->ref_count[0]) {
ff_h264_set_erpic(&h->er.last_pic, &sl->ref_list[0][0]); ff_h264_set_erpic(&sl->er.last_pic, &sl->ref_list[0][0]);
} else } else
ff_h264_set_erpic(&h->er.last_pic, NULL); ff_h264_set_erpic(&sl->er.last_pic, NULL);
if (sl->ref_count[1]) if (sl->ref_count[1])
ff_h264_set_erpic(&h->er.next_pic, &sl->ref_list[1][0]); ff_h264_set_erpic(&sl->er.next_pic, &sl->ref_list[1][0]);
h->er.ref_count = sl->ref_count[0]; sl->er.ref_count = sl->ref_count[0];
ff_er_frame_end(&h->er); ff_er_frame_end(&sl->er);
if (use_last_pic) if (use_last_pic)
memset(&sl->ref_list[0][0], 0, sizeof(h->last_pic_for_ec)); memset(&sl->ref_list[0][0], 0, sizeof(h->last_pic_for_ec));
} }
......
...@@ -545,12 +545,12 @@ int ff_h264_update_thread_context(AVCodecContext *dst, ...@@ -545,12 +545,12 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
memset(&h->er, 0, sizeof(h->er));
memset(&h->cur_pic, 0, sizeof(h->cur_pic)); memset(&h->cur_pic, 0, sizeof(h->cur_pic));
memset(&h->last_pic_for_ec, 0, sizeof(h->last_pic_for_ec)); memset(&h->last_pic_for_ec, 0, sizeof(h->last_pic_for_ec));
h->slice_ctx = orig_slice_ctx; h->slice_ctx = orig_slice_ctx;
memset(&h->slice_ctx[0].er, 0, sizeof(h->slice_ctx[0].er));
memset(&h->slice_ctx[0].mb, 0, sizeof(h->slice_ctx[0].mb)); memset(&h->slice_ctx[0].mb, 0, sizeof(h->slice_ctx[0].mb));
memset(&h->slice_ctx[0].mb_luma_dc, 0, sizeof(h->slice_ctx[0].mb_luma_dc)); memset(&h->slice_ctx[0].mb_luma_dc, 0, sizeof(h->slice_ctx[0].mb_luma_dc));
memset(&h->slice_ctx[0].mb_padding, 0, sizeof(h->slice_ctx[0].mb_padding)); memset(&h->slice_ctx[0].mb_padding, 0, sizeof(h->slice_ctx[0].mb_padding));
...@@ -587,7 +587,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst, ...@@ -587,7 +587,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
av_log(dst, AV_LOG_ERROR, "Could not allocate memory\n"); av_log(dst, AV_LOG_ERROR, "Could not allocate memory\n");
return ret; return ret;
} }
ret = ff_h264_context_init(h); ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
if (ret < 0) { if (ret < 0) {
av_log(dst, AV_LOG_ERROR, "context_init() failed.\n"); av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
return ret; return ret;
...@@ -741,16 +741,16 @@ static int h264_frame_start(H264Context *h) ...@@ -741,16 +741,16 @@ static int h264_frame_start(H264Context *h)
h->cur_pic_ptr = pic; h->cur_pic_ptr = pic;
ff_h264_unref_picture(h, &h->cur_pic); ff_h264_unref_picture(h, &h->cur_pic);
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
ff_h264_set_erpic(&h->er.cur_pic, NULL); ff_h264_set_erpic(&h->slice_ctx[0].er.cur_pic, NULL);
} }
if ((ret = ff_h264_ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0) if ((ret = ff_h264_ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
return ret; return ret;
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
ff_er_frame_start(&h->er); ff_er_frame_start(&h->slice_ctx[0].er);
ff_h264_set_erpic(&h->er.last_pic, NULL); ff_h264_set_erpic(&h->slice_ctx[0].er.last_pic, NULL);
ff_h264_set_erpic(&h->er.next_pic, NULL); ff_h264_set_erpic(&h->slice_ctx[0].er.next_pic, NULL);
} }
assert(h->linesize && h->uvlinesize); assert(h->linesize && h->uvlinesize);
...@@ -1202,7 +1202,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) ...@@ -1202,7 +1202,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
h->slice_context_count = nb_slices; h->slice_context_count = nb_slices;
if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) { if (!HAVE_THREADS || !(h->avctx->active_thread_type & FF_THREAD_SLICE)) {
ret = ff_h264_context_init(h); ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]);
if (ret < 0) { if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n"); av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
goto fail; goto fail;
...@@ -1248,7 +1248,7 @@ static int h264_slice_header_init(H264Context *h, int reinit) ...@@ -1248,7 +1248,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
} }
for (i = 0; i < h->slice_context_count; i++) for (i = 0; i < h->slice_context_count; i++)
if ((ret = ff_h264_context_init(h->thread_context[i])) < 0) { if ((ret = ff_h264_slice_context_init(h, &h->slice_ctx[i])) < 0) {
av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n"); av_log(h->avctx, AV_LOG_ERROR, "context_init() failed.\n");
goto fail; goto fail;
} }
...@@ -2371,19 +2371,19 @@ static void decode_finish_row(H264Context *h, H264SliceContext *sl) ...@@ -2371,19 +2371,19 @@ static void decode_finish_row(H264Context *h, H264SliceContext *sl)
ff_h264_draw_horiz_band(h, sl, top, height); ff_h264_draw_horiz_band(h, sl, top, height);
if (h->droppable || h->er.error_occurred) if (h->droppable || sl->er.error_occurred)
return; return;
ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1, ff_thread_report_progress(&h->cur_pic_ptr->tf, top + height - 1,
h->picture_structure == PICT_BOTTOM_FIELD); h->picture_structure == PICT_BOTTOM_FIELD);
} }
static void er_add_slice(H264Context *h, H264SliceContext *sl, static void er_add_slice(H264SliceContext *sl,
int startx, int starty, int startx, int starty,
int endx, int endy, int status) int endx, int endy, int status)
{ {
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
ERContext *er = &h->er; ERContext *er = &sl->er;
ff_er_add_slice(er, startx, starty, endx, endy, status); ff_er_add_slice(er, startx, starty, endx, endy, status);
} }
...@@ -2408,13 +2408,13 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2408,13 +2408,13 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
avctx->codec_id != AV_CODEC_ID_H264 || avctx->codec_id != AV_CODEC_ID_H264 ||
(CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY)); (CONFIG_GRAY && (h->flags & CODEC_FLAG_GRAY));
if (!(h->avctx->active_thread_type & FF_THREAD_SLICE) && h->picture_structure == PICT_FRAME && h->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); 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) { if (start_i) {
int prev_status = h->er.error_status_table[h->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; prev_status &= ~ VP_START;
if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END))
h->er.error_occurred = 1; sl->er.error_occurred = 1;
} }
} }
...@@ -2452,7 +2452,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2452,7 +2452,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if ((h->workaround_bugs & FF_BUG_TRUNCATED) && if ((h->workaround_bugs & FF_BUG_TRUNCATED) &&
sl->cabac.bytestream > sl->cabac.bytestream_end + 2) { sl->cabac.bytestream > sl->cabac.bytestream_end + 2) {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1,
sl->mb_y, ER_MB_END); sl->mb_y, ER_MB_END);
if (sl->mb_x >= lf_x_start) if (sl->mb_x >= lf_x_start)
loop_filter(h, sl, lf_x_start, sl->mb_x + 1); loop_filter(h, sl, lf_x_start, sl->mb_x + 1);
...@@ -2465,7 +2465,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2465,7 +2465,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
"error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n", "error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n",
sl->mb_x, sl->mb_y, sl->mb_x, sl->mb_y,
sl->cabac.bytestream_end - sl->cabac.bytestream); sl->cabac.bytestream_end - sl->cabac.bytestream);
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x,
sl->mb_y, ER_MB_ERROR); sl->mb_y, ER_MB_ERROR);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
...@@ -2485,7 +2485,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2485,7 +2485,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (eos || sl->mb_y >= h->mb_height) { if (eos || sl->mb_y >= h->mb_height) {
tprintf(h->avctx, "slice end %d %d\n", tprintf(h->avctx, "slice end %d %d\n",
get_bits_count(&sl->gb), sl->gb.size_in_bits); get_bits_count(&sl->gb), sl->gb.size_in_bits);
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x - 1,
sl->mb_y, ER_MB_END); sl->mb_y, ER_MB_END);
if (sl->mb_x > lf_x_start) if (sl->mb_x > lf_x_start)
loop_filter(h, sl, lf_x_start, sl->mb_x); loop_filter(h, sl, lf_x_start, sl->mb_x);
...@@ -2512,7 +2512,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2512,7 +2512,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if (ret < 0) { if (ret < 0) {
av_log(h->avctx, AV_LOG_ERROR, av_log(h->avctx, AV_LOG_ERROR,
"error while decoding MB %d %d\n", sl->mb_x, sl->mb_y); "error while decoding MB %d %d\n", sl->mb_x, sl->mb_y);
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x,
sl->mb_y, ER_MB_ERROR); sl->mb_y, ER_MB_ERROR);
return ret; return ret;
} }
...@@ -2533,12 +2533,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2533,12 +2533,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if ( get_bits_left(&sl->gb) == 0 if ( get_bits_left(&sl->gb) == 0
|| get_bits_left(&sl->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { || get_bits_left(&sl->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y,
sl->mb_x - 1, sl->mb_y, ER_MB_END); sl->mb_x - 1, sl->mb_y, ER_MB_END);
return 0; return 0;
} else { } else {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y,
sl->mb_x, sl->mb_y, ER_MB_END); sl->mb_x, sl->mb_y, ER_MB_END);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -2551,14 +2551,14 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2551,14 +2551,14 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
get_bits_count(&sl->gb), sl->gb.size_in_bits); get_bits_count(&sl->gb), sl->gb.size_in_bits);
if (get_bits_left(&sl->gb) == 0) { if (get_bits_left(&sl->gb) == 0) {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y,
sl->mb_x - 1, sl->mb_y, ER_MB_END); sl->mb_x - 1, sl->mb_y, ER_MB_END);
if (sl->mb_x > lf_x_start) if (sl->mb_x > lf_x_start)
loop_filter(h, sl, lf_x_start, sl->mb_x); loop_filter(h, sl, lf_x_start, sl->mb_x);
return 0; return 0;
} else { } else {
er_add_slice(h, sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x, er_add_slice(sl, sl->resync_mb_x, sl->resync_mb_y, sl->mb_x,
sl->mb_y, ER_MB_ERROR); sl->mb_y, ER_MB_ERROR);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -2594,8 +2594,9 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count) ...@@ -2594,8 +2594,9 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
av_assert0(context_count > 0); av_assert0(context_count > 0);
for (i = 1; i < context_count; i++) { for (i = 1; i < context_count; i++) {
hx = h->thread_context[i]; hx = h->thread_context[i];
sl = &h->slice_ctx[i];
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
hx->er.error_count = 0; sl->er.error_count = 0;
} }
hx->x264_build = h->x264_build; hx->x264_build = h->x264_build;
} }
...@@ -2611,7 +2612,7 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count) ...@@ -2611,7 +2612,7 @@ int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
h->picture_structure = hx->picture_structure; h->picture_structure = hx->picture_structure;
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
for (i = 1; i < context_count; i++) for (i = 1; i < context_count; i++)
h->er.error_count += h->thread_context[i]->er.error_count; h->slice_ctx[0].er.error_count += h->slice_ctx[i].er.error_count;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment