[FFmpeg-devel] [PATCH] avcodec/mpeg12dec: move fast mode from CODEC_FLAG2_FAST to a private option
Michael Niedermayer
michaelni at gmx.at
Fri Jan 24 18:30:40 CET 2014
The private option is more appropriately called "fast_crash"
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavcodec/mpeg12dec.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 77b4825..f26fe1c 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -57,6 +57,7 @@ typedef struct Mpeg1Context {
int tmpgexs;
int first_slice;
int extradata_decoded;
+ int crash;
} Mpeg1Context;
#define MB_TYPE_ZERO_MV 0x20000000
@@ -684,6 +685,7 @@ static inline int get_qscale(MpegEncContext *s)
static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
{
+ Mpeg1Context *s1 = (Mpeg1Context*)s;
int i, j, k, cbp, val, mb_type, motion_type;
const int mb_block_count = 4 + (1 << s->chroma_format);
@@ -784,7 +786,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
}
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (s->flags2 & CODEC_FLAG2_FAST) {
+ if (s1->crash) {
for (i = 0; i < 6; i++) {
mpeg2_fast_decode_block_intra(s, *s->pblocks[i], i);
}
@@ -1000,7 +1002,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
}
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (s->flags2 & CODEC_FLAG2_FAST) {
+ if (s1->crash) {
for (i = 0; i < 6; i++) {
if (cbp & 32) {
mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i);
@@ -1023,7 +1025,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
}
}
} else {
- if (s->flags2 & CODEC_FLAG2_FAST) {
+ if (s1->crash) {
for (i = 0; i < 6; i++) {
if (cbp & 32) {
mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i);
@@ -2641,6 +2643,34 @@ static const AVProfile mpeg2_video_profiles[] = {
{ FF_PROFILE_UNKNOWN },
};
+static const AVOption mpeg12_options[] = {
+ {"fast_crash", "Enable speed tricks that can cause crashes", offsetof(Mpeg1Context, crash), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM},
+ {NULL}
+};
+
+static const AVClass mpeg1_class = {
+ .class_name = "MPEG1 Video Decoder",
+ .item_name = av_default_item_name,
+ .option = mpeg12_options,
+ .version = LIBAVUTIL_VERSION_INT,
+ .category = AV_CLASS_CATEGORY_DECODER,
+};
+
+static const AVClass mpeg2_class = {
+ .class_name = "MPEG2 Video Decoder",
+ .item_name = av_default_item_name,
+ .option = mpeg12_options,
+ .version = LIBAVUTIL_VERSION_INT,
+ .category = AV_CLASS_CATEGORY_DECODER,
+};
+
+static const AVClass mpeg12_class = {
+ .class_name = "MPEG1+2 Video Decoder",
+ .item_name = av_default_item_name,
+ .option = mpeg12_options,
+ .version = LIBAVUTIL_VERSION_INT,
+ .category = AV_CLASS_CATEGORY_DECODER,
+};
AVCodec ff_mpeg1video_decoder = {
.name = "mpeg1video",
@@ -2656,7 +2686,8 @@ AVCodec ff_mpeg1video_decoder = {
CODEC_CAP_SLICE_THREADS,
.flush = flush,
.max_lowres = 3,
- .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
+ .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
+ .priv_class = &mpeg1_class,
};
AVCodec ff_mpeg2video_decoder = {
@@ -2674,6 +2705,7 @@ AVCodec ff_mpeg2video_decoder = {
.flush = flush,
.max_lowres = 3,
.profiles = NULL_IF_CONFIG_SMALL(mpeg2_video_profiles),
+ .priv_class = &mpeg2_class,
};
//legacy decoder
@@ -2689,6 +2721,7 @@ AVCodec ff_mpegvideo_decoder = {
.capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
.flush = flush,
.max_lowres = 3,
+ .priv_class = &mpeg12_class,
};
#if FF_API_XVMC
--
1.7.9.5
More information about the ffmpeg-devel
mailing list