Commit 6da7625c authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'a4d34e21'

* commit 'a4d34e21':
  h264: disable ER by default

Conflicts:
	libavcodec/h264.c
	libavcodec/h264_picture.c
	libavcodec/h264_slice.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 95989463 a4d34e21
......@@ -702,6 +702,12 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
ff_h264_flush_change(h);
if (h->enable_er) {
av_log(avctx, AV_LOG_WARNING,
"Error resilience is enabled. It is unsafe and unsupported and may crash. "
"Use it at your own risk\n");
}
return 0;
}
......@@ -1925,6 +1931,22 @@ static av_cold int h264_decode_end(AVCodecContext *avctx)
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[] = {
{"is_avc", "is avc", offsetof(H264Context, is_avc), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
{"nal_length_size", "nal_length_size", offsetof(H264Context, nal_length_size), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 4, 0},
{ "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VD },
{ NULL },
};
static const AVClass h264_class = {
.class_name = "H264 Decoder",
.item_name = av_default_item_name,
.option = h264_options,
.version = LIBAVUTIL_VERSION_INT,
};
static const AVProfile profiles[] = {
{ FF_PROFILE_H264_BASELINE, "Baseline" },
{ FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
......@@ -1942,19 +1964,6 @@ static const AVProfile profiles[] = {
{ FF_PROFILE_UNKNOWN },
};
static const AVOption h264_options[] = {
{"is_avc", "is avc", offsetof(H264Context, is_avc), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
{"nal_length_size", "nal_length_size", offsetof(H264Context, nal_length_size), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 4, 0},
{NULL}
};
static const AVClass h264_class = {
.class_name = "H264 Decoder",
.item_name = av_default_item_name,
.option = h264_options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_h264_decoder = {
.name = "h264",
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
......
......@@ -788,6 +788,8 @@ typedef struct H264Context {
int parse_history_count;
int parse_last_mb;
int enable_er;
AVBufferPool *qscale_table_pool;
AVBufferPool *mb_type_pool;
AVBufferPool *motion_val_pool;
......
......@@ -196,7 +196,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
* past end by one (callers fault) and resync_mb_y != 0
* causes problems for the first MB line, too.
*/
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new) {
if (!FIELD_PICTURE(h) && h->current_slice && !h->sps.new && h->enable_er) {
int use_last_pic = h->last_pic_for_ec.f.buf[0] && !sl->ref_count[0];
ff_h264_set_erpic(&sl->er.cur_pic, h->cur_pic_ptr);
......
......@@ -583,6 +583,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
return ret;
}
h->enable_er = h1->enable_er;
h->workaround_bugs = h1->workaround_bugs;
h->low_delay = h1->low_delay;
h->droppable = h1->droppable;
......@@ -711,7 +712,7 @@ static int h264_frame_start(H264Context *h)
h->slice_ctx[i].uvlinesize = h->cur_pic_ptr->f.linesize[1];
}
if (CONFIG_ERROR_RESILIENCE) {
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);
......@@ -2283,6 +2284,9 @@ static void er_add_slice(H264SliceContext *sl,
int startx, int starty,
int endx, int endy, int status)
{
if (!sl->h264->enable_er)
return;
if (CONFIG_ERROR_RESILIENCE) {
ERContext *er = &sl->er;
......
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