summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-04-04 00:49:57 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-04 00:52:54 +0200
commit6da7625cc395692a71c99d179cb76eea6e8b27ca (patch)
treee9cc769a62e44a17288e89aab2139a91e4e79402
parent959894632ae67e356ede734e352eabda6bb55794 (diff)
parenta4d34e218f548d381e09c483e8dc6ad18a8d571c (diff)
Merge commit 'a4d34e218f548d381e09c483e8dc6ad18a8d571c'
* commit 'a4d34e218f548d381e09c483e8dc6ad18a8d571c': h264: disable ER by default Conflicts: libavcodec/h264.c libavcodec/h264_picture.c libavcodec/h264_slice.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/h264.c35
-rw-r--r--libavcodec/h264.h2
-rw-r--r--libavcodec/h264_picture.c2
-rw-r--r--libavcodec/h264_slice.c6
4 files changed, 30 insertions, 15 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 1c990c383d..a795597193 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -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"),
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index d27f0b4f7b..e651d8a4c2 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -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;
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index 127bc45c88..76286ae8f3 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -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);
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index c10568a4ed..3f400def34 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -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;