Commit 0b499c9b authored by Ronald S. Bultje's avatar Ronald S. Bultje Committed by Martin Storsjö

h264: Make it possible to compile without error_resilience

Error resilience is enabled by the h264 decoder, unless explicitly
disabled. --disable-everything --enable-decoder=h264 will produce
a h264 decoder with error resilience enabled, while
--disable-everything --enable-decoder=h264 --disable-error-resilience
will produce a h264 decoder with error resilience disabled.
Signed-off-by: 's avatarMartin Storsjö <martin@martin.st>
parent f1e93986
...@@ -122,6 +122,7 @@ Component options: ...@@ -122,6 +122,7 @@ Component options:
--disable-w32threads disable Win32 threads [auto] --disable-w32threads disable Win32 threads [auto]
--disable-network disable network support [no] --disable-network disable network support [no]
--disable-dct disable DCT code --disable-dct disable DCT code
--disable-error-resilience disable error resilience code
--disable-lsp disable LSP code --disable-lsp disable LSP code
--disable-lzo disable LZO decoder code --disable-lzo disable LZO decoder code
--disable-mdct disable MDCT code --disable-mdct disable MDCT code
...@@ -1091,6 +1092,7 @@ CONFIG_LIST=" ...@@ -1091,6 +1092,7 @@ CONFIG_LIST="
$PROGRAM_LIST $PROGRAM_LIST
dct dct
doc doc
error_resilience
fft fft
gpl gpl
gray gray
...@@ -1349,7 +1351,6 @@ CONFIG_EXTRA=" ...@@ -1349,7 +1351,6 @@ CONFIG_EXTRA="
aandcttables aandcttables
ac3dsp ac3dsp
audio_frame_queue audio_frame_queue
error_resilience
gcrypt gcrypt
golomb golomb
gplv3 gplv3
...@@ -1544,7 +1545,8 @@ h263_decoder_select="error_resilience h263_parser mpegvideo" ...@@ -1544,7 +1545,8 @@ h263_decoder_select="error_resilience h263_parser mpegvideo"
h263_encoder_select="aandcttables mpegvideoenc" h263_encoder_select="aandcttables mpegvideoenc"
h263i_decoder_select="h263_decoder" h263i_decoder_select="h263_decoder"
h263p_encoder_select="h263_encoder" h263p_encoder_select="h263_encoder"
h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel videodsp" h264_decoder_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
h264_decoder_suggest="error_resilience"
huffyuv_encoder_select="huffman" huffyuv_encoder_select="huffman"
iac_decoder_select="fft mdct sinewin" iac_decoder_select="fft mdct sinewin"
imc_decoder_select="fft mdct sinewin" imc_decoder_select="fft mdct sinewin"
...@@ -1601,8 +1603,8 @@ shorten_decoder_select="golomb" ...@@ -1601,8 +1603,8 @@ shorten_decoder_select="golomb"
sipr_decoder_select="lsp" sipr_decoder_select="lsp"
svq1_decoder_select="mpegvideo" svq1_decoder_select="mpegvideo"
svq1_encoder_select="aandcttables mpegvideoenc" svq1_encoder_select="aandcttables mpegvideoenc"
svq3_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo videodsp" svq3_decoder_select="golomb h264chroma h264dsp h264pred h264qpel mpegvideo videodsp"
svq3_decoder_suggest="zlib" svq3_decoder_suggest="error_resilience zlib"
theora_decoder_select="vp3_decoder" theora_decoder_select="vp3_decoder"
tiff_decoder_suggest="zlib" tiff_decoder_suggest="zlib"
tiff_encoder_suggest="zlib" tiff_encoder_suggest="zlib"
...@@ -1691,7 +1693,7 @@ wmv3_vdpau_decoder_select="vc1_vdpau_decoder" ...@@ -1691,7 +1693,7 @@ wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
# parsers # parsers
h264_parser_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel videodsp" h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
mpeg4video_parser_select="error_resilience mpegvideo" mpeg4video_parser_select="error_resilience mpegvideo"
mpegvideo_parser_select="error_resilience mpegvideo" mpegvideo_parser_select="error_resilience mpegvideo"
vc1_parser_select="mpegvideo" vc1_parser_select="mpegvideo"
......
...@@ -1314,45 +1314,47 @@ static int context_init(H264Context *h) ...@@ -1314,45 +1314,47 @@ static int context_init(H264Context *h)
h->ref_cache[1][scan8[7] + 1] = h->ref_cache[1][scan8[7] + 1] =
h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE; h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
/* init ER */ if (CONFIG_ERROR_RESILIENCE) {
er->avctx = h->avctx; /* init ER */
er->dsp = &h->dsp; er->avctx = h->avctx;
er->decode_mb = h264_er_decode_mb; er->dsp = &h->dsp;
er->opaque = h; er->decode_mb = h264_er_decode_mb;
er->quarter_sample = 1; er->opaque = h;
er->quarter_sample = 1;
er->mb_num = h->mb_num;
er->mb_width = h->mb_width; er->mb_num = h->mb_num;
er->mb_height = h->mb_height; er->mb_width = h->mb_width;
er->mb_stride = h->mb_stride; er->mb_height = h->mb_height;
er->b8_stride = h->mb_width * 2 + 1; er->mb_stride = h->mb_stride;
er->b8_stride = h->mb_width * 2 + 1;
FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy, (h->mb_num + 1) * sizeof(int),
fail); // error ressilience code looks cleaner with this
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) * FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy, (h->mb_num + 1) * sizeof(int),
h->mb_stride + h->mb_width; fail); // error ressilience code looks cleaner with this
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table, er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
mb_array_size * sizeof(uint8_t), fail); h->mb_stride + h->mb_width;
FF_ALLOC_OR_GOTO(h->avctx, er->mbintra_table, mb_array_size, fail); FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
memset(er->mbintra_table, 1, mb_array_size); mb_array_size * sizeof(uint8_t), fail);
FF_ALLOCZ_OR_GOTO(h->avctx, er->mbskip_table, mb_array_size + 2, fail); FF_ALLOC_OR_GOTO(h->avctx, er->mbintra_table, mb_array_size, fail);
memset(er->mbintra_table, 1, mb_array_size);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer, h->mb_height * h->mb_stride, FF_ALLOCZ_OR_GOTO(h->avctx, er->mbskip_table, mb_array_size + 2, fail);
fail);
FF_ALLOCZ_OR_GOTO(h->avctx, h->dc_val_base, yc_size * sizeof(int16_t), fail); FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer, h->mb_height * h->mb_stride,
er->dc_val[0] = h->dc_val_base + h->mb_width * 2 + 2; fail);
er->dc_val[1] = h->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size; FF_ALLOCZ_OR_GOTO(h->avctx, h->dc_val_base, yc_size * sizeof(int16_t), fail);
for (i = 0; i < yc_size; i++) er->dc_val[0] = h->dc_val_base + h->mb_width * 2 + 2;
h->dc_val_base[i] = 1024; er->dc_val[1] = h->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
for (i = 0; i < yc_size; i++)
h->dc_val_base[i] = 1024;
}
return 0; return 0;
...@@ -1768,7 +1770,8 @@ static int h264_frame_start(H264Context *h) ...@@ -1768,7 +1770,8 @@ static int h264_frame_start(H264Context *h)
if ((ret = ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0) if ((ret = ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
return ret; return ret;
ff_er_frame_start(&h->er); if (CONFIG_ERROR_RESILIENCE)
ff_er_frame_start(&h->er);
assert(h->linesize && h->uvlinesize); assert(h->linesize && h->uvlinesize);
...@@ -2801,7 +2804,7 @@ static int field_end(H264Context *h, int in_setup) ...@@ -2801,7 +2804,7 @@ static int field_end(H264Context *h, int in_setup)
* past end by one (callers fault) and resync_mb_y != 0 * past end by one (callers fault) and resync_mb_y != 0
* causes problems for the first MB line, too. * causes problems for the first MB line, too.
*/ */
if (!FIELD_PICTURE(h)) { if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h)) {
h->er.cur_pic = h->cur_pic_ptr; h->er.cur_pic = h->cur_pic_ptr;
h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL; h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL;
h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL; h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL;
...@@ -4090,10 +4093,12 @@ static void decode_finish_row(H264Context *h) ...@@ -4090,10 +4093,12 @@ static void decode_finish_row(H264Context *h)
static void er_add_slice(H264Context *h, int startx, int starty, static void er_add_slice(H264Context *h, int startx, int starty,
int endx, int endy, int status) int endx, int endy, int status)
{ {
#if CONFIG_ERROR_RESILIENCE
ERContext *er = &h->er; ERContext *er = &h->er;
er->ref_count = h->ref_count[0]; er->ref_count = h->ref_count[0];
ff_er_add_slice(er, startx, starty, endx, endy, status); ff_er_add_slice(er, startx, starty, endx, endy, status);
#endif
} }
static int decode_slice(struct AVCodecContext *avctx, void *arg) static int decode_slice(struct AVCodecContext *avctx, void *arg)
......
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