Commit 72bec029 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '7bbc254d'

* commit '7bbc254d':
  h264: move resync_mb_{x,y} into the per-slice context

Conflicts:
	libavcodec/h264_slice.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents d76559fb 7bbc254d
...@@ -395,6 +395,8 @@ typedef struct H264SliceContext { ...@@ -395,6 +395,8 @@ typedef struct H264SliceContext {
int mb_x, mb_y; int mb_x, mb_y;
int mb_xy; int mb_xy;
int resync_mb_x;
int resync_mb_y;
int mb_skip_run; int mb_skip_run;
int is_complex; int is_complex;
...@@ -571,8 +573,6 @@ typedef struct H264Context { ...@@ -571,8 +573,6 @@ typedef struct H264Context {
int x264_build; int x264_build;
int mb_y; int mb_y;
int resync_mb_x;
int resync_mb_y;
int mb_height, mb_width; int mb_height, mb_width;
int mb_stride; int mb_stride;
int mb_num; int mb_num;
......
...@@ -1756,11 +1756,11 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1756,11 +1756,11 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n"); av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
h->resync_mb_x = sl->mb_x = first_mb_in_slice % h->mb_width; sl->resync_mb_x = sl->mb_x = first_mb_in_slice % h->mb_width;
h->resync_mb_y = sl->mb_y = (first_mb_in_slice / h->mb_width) << sl->resync_mb_y = sl->mb_y = (first_mb_in_slice / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h); FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD) if (h->picture_structure == PICT_BOTTOM_FIELD)
h->resync_mb_y = sl->mb_y = sl->mb_y + 1; sl->resync_mb_y = sl->mb_y = sl->mb_y + 1;
av_assert1(sl->mb_y < h->mb_height); av_assert1(sl->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) { if (h->picture_structure == PICT_FRAME) {
...@@ -1953,9 +1953,9 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex ...@@ -1953,9 +1953,9 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl, H264Contex
sl->slice_num = ++h0->current_slice; sl->slice_num = ++h0->current_slice;
if (sl->slice_num) if (sl->slice_num)
h0->slice_row[(sl->slice_num-1)&(MAX_SLICES-1)]= h->resync_mb_y; h0->slice_row[(sl->slice_num-1)&(MAX_SLICES-1)]= sl->resync_mb_y;
if ( h0->slice_row[sl->slice_num&(MAX_SLICES-1)] + 3 >= h->resync_mb_y if ( h0->slice_row[sl->slice_num&(MAX_SLICES-1)] + 3 >= sl->resync_mb_y
&& h0->slice_row[sl->slice_num&(MAX_SLICES-1)] <= h->resync_mb_y && h0->slice_row[sl->slice_num&(MAX_SLICES-1)] <= sl->resync_mb_y
&& sl->slice_num >= MAX_SLICES) { && sl->slice_num >= MAX_SLICES) {
//in case of ASO this check needs to be updated depending on how we decide to assign slice numbers in this case //in case of ASO this check needs to be updated depending on how we decide to assign slice numbers in this case
av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", sl->slice_num, MAX_SLICES); av_log(h->avctx, AV_LOG_WARNING, "Possibly too many slices (%d >= %d), increase MAX_SLICES and recompile if there are artifacts\n", sl->slice_num, MAX_SLICES);
...@@ -2410,7 +2410,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2410,7 +2410,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
(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 && h->er.error_status_table) {
const int start_i = av_clip(h->resync_mb_x + h->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 = h->er.error_status_table[h->er.mb_index2xy[start_i - 1]];
prev_status &= ~ VP_START; prev_status &= ~ VP_START;
...@@ -2453,7 +2453,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2453,7 +2453,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, h->resync_mb_x, h->resync_mb_y, sl->mb_x - 1, er_add_slice(h, 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);
...@@ -2466,7 +2466,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2466,7 +2466,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, h->resync_mb_x, h->resync_mb_y, sl->mb_x, er_add_slice(h, 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;
} }
...@@ -2486,7 +2486,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2486,7 +2486,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(&h->gb), h->gb.size_in_bits); get_bits_count(&h->gb), h->gb.size_in_bits);
er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, sl->mb_x - 1, er_add_slice(h, 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);
...@@ -2513,7 +2513,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2513,7 +2513,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, h->resync_mb_x, h->resync_mb_y, sl->mb_x, er_add_slice(h, 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;
} }
...@@ -2534,12 +2534,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2534,12 +2534,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
if ( get_bits_left(&h->gb) == 0 if ( get_bits_left(&h->gb) == 0
|| get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) { || get_bits_left(&h->gb) > 0 && !(h->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, er_add_slice(h, 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, h->resync_mb_x, h->resync_mb_y, er_add_slice(h, 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;
...@@ -2552,14 +2552,14 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg) ...@@ -2552,14 +2552,14 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
get_bits_count(&h->gb), h->gb.size_in_bits); get_bits_count(&h->gb), h->gb.size_in_bits);
if (get_bits_left(&h->gb) == 0) { if (get_bits_left(&h->gb) == 0) {
er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, er_add_slice(h, 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, h->resync_mb_x, h->resync_mb_y, sl->mb_x, er_add_slice(h, 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;
......
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