aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-07-29 01:50:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-07-29 01:50:53 +0200
commit2dd2abe391ccf1b9140c6eea95767b5a8c503ddd (patch)
tree0b3886285001ed05025bd4a338f3a5105d0c7a8b /libavcodec
parent4105443872be75a8d1141facc43b54641304c722 (diff)
parent2a11952f457658d58303c8e5b4e10fb4599eef4f (diff)
downloadffmpeg-2dd2abe391ccf1b9140c6eea95767b5a8c503ddd.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: h263dec: Propagate AV_LOG_ERRORs from slice decoding through frame decoding with sufficient error recognition x86: cabac: don't load/store context values in asm H.264: optimize CABAC x86 asm for Atom vp3/theora: flush after seek. doc/fftools-common-opts: wording fixes missing from the previous commit. doc: document using AVOptions in fftools. cmdutils: add codec_opts parameter to setup_find_stream_info_opts() cmdutils: clarify documentation for filter_codec_opts() cmdutils: clarify documentation for setup_find_stream_info_opts() lavf: add forgotten attribute_deprecated to av_find_stream_info() Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h1
-rw-r--r--libavcodec/h263dec.c6
-rw-r--r--libavcodec/h264_cabac.c2
-rw-r--r--libavcodec/options.c1
-rw-r--r--libavcodec/vp3.c22
-rw-r--r--libavcodec/x86/cabac.h27
-rw-r--r--libavcodec/x86/h264_i386.h43
7 files changed, 49 insertions, 53 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c854958c60..1dec91a460 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1493,6 +1493,7 @@ typedef struct AVCodecContext {
#define FF_ER_COMPLIANT 2
#define FF_ER_AGGRESSIVE 3
#define FF_ER_VERY_AGGRESSIVE 4
+#define FF_ER_EXPLODE 5
/**
* Called at the beginning of each frame to get a buffer for it.
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 13d15daed2..e32e4e6a4c 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -650,7 +650,7 @@ retry:
s->mb_x=0;
s->mb_y=0;
- decode_slice(s);
+ ret = decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
@@ -666,7 +666,7 @@ retry:
if(s->msmpeg4_version<4 && s->h263_pred)
ff_mpeg4_clean_buffers(s);
- decode_slice(s);
+ if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
}
if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
@@ -730,7 +730,7 @@ assert(s->current_picture.pict_type == s->pict_type);
av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time);
#endif
- return get_consumed_bytes(s, buf_size);
+ return (ret && avctx->error_recognition >= FF_ER_EXPLODE)?ret:get_consumed_bytes(s, buf_size);
}
AVCodec ff_h263_decoder = {
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 524ed94c54..6bbf87f0ba 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1649,7 +1649,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS)
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index,
- last_coeff_ctx_base-significant_coeff_ctx_base, sig_off);
+ last_coeff_ctx_base, sig_off);
} else {
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index,
last_coeff_ctx_base-significant_coeff_ctx_base);
diff --git a/libavcodec/options.c b/libavcodec/options.c
index be60b96fe4..2ecb5877c4 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -184,6 +184,7 @@ static const AVOption options[]={
{"compliant", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"},
{"aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"},
{"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"},
+{"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"},
{"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
{"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
{"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX},
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 148f1179e3..b9af998bc5 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2321,6 +2321,26 @@ static av_cold int theora_decode_init(AVCodecContext *avctx)
return vp3_decode_init(avctx);
}
+static void vp3_decode_flush(AVCodecContext *avctx)
+{
+ Vp3DecodeContext *s = avctx->priv_data;
+
+ if (s->golden_frame.data[0]) {
+ if (s->golden_frame.data[0] == s->last_frame.data[0])
+ memset(&s->last_frame, 0, sizeof(AVFrame));
+ if (s->current_frame.data[0] == s->golden_frame.data[0])
+ memset(&s->current_frame, 0, sizeof(AVFrame));
+ ff_thread_release_buffer(avctx, &s->golden_frame);
+ }
+ if (s->last_frame.data[0]) {
+ if (s->current_frame.data[0] == s->last_frame.data[0])
+ memset(&s->current_frame, 0, sizeof(AVFrame));
+ ff_thread_release_buffer(avctx, &s->last_frame);
+ }
+ if (s->current_frame.data[0])
+ ff_thread_release_buffer(avctx, &s->current_frame);
+}
+
AVCodec ff_theora_decoder = {
"theora",
AVMEDIA_TYPE_VIDEO,
@@ -2332,6 +2352,7 @@ AVCodec ff_theora_decoder = {
vp3_decode_frame,
CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
NULL,
+ .flush = vp3_decode_flush,
.long_name = NULL_IF_CONFIG_SMALL("Theora"),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
};
@@ -2348,6 +2369,7 @@ AVCodec ff_vp3_decoder = {
vp3_decode_frame,
CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS,
NULL,
+ .flush = vp3_decode_flush,
.long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
};
diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h
index 52bea9c53d..ae3f4b6e9e 100644
--- a/libavcodec/x86/cabac.h
+++ b/libavcodec/x86/cabac.h
@@ -34,8 +34,8 @@
"cmova %%ecx , "range" \n\t"\
"sbb %%ecx , %%ecx \n\t"\
"and %%ecx , "tmp" \n\t"\
- "sub "tmp" , "low" \n\t"\
- "xor %%ecx , "ret" \n\t"
+ "xor %%ecx , "ret" \n\t"\
+ "sub "tmp" , "low" \n\t"
#else /* HAVE_FAST_CMOV */
#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp)\
"mov "tmp" , %%ecx \n\t"\
@@ -62,21 +62,20 @@
"movzbl " MANGLE(ff_h264_norm_shift) "("range"), %%ecx \n\t"\
"shl %%cl , "range" \n\t"\
"movzbl "MANGLE(ff_h264_mlps_state)"+128("ret"), "tmp" \n\t"\
- "mov "tmpbyte" , "statep" \n\t"\
"shl %%cl , "low" \n\t"\
+ "mov "tmpbyte" , "statep" \n\t"\
"test "lowword" , "lowword" \n\t"\
" jnz 1f \n\t"\
"mov "byte"("cabac"), %%"REG_c" \n\t"\
+ "add $2 , "byte "("cabac") \n\t"\
"movzwl (%%"REG_c") , "tmp" \n\t"\
- "bswap "tmp" \n\t"\
- "shr $15 , "tmp" \n\t"\
- "sub $0xFFFF , "tmp" \n\t"\
- "add $2 , %%"REG_c" \n\t"\
- "mov %%"REG_c" , "byte "("cabac") \n\t"\
"lea -1("low") , %%ecx \n\t"\
"xor "low" , %%ecx \n\t"\
"shr $15 , %%ecx \n\t"\
+ "bswap "tmp" \n\t"\
+ "shr $15 , "tmp" \n\t"\
"movzbl " MANGLE(ff_h264_norm_shift) "(%%ecx), %%ecx \n\t"\
+ "sub $0xFFFF , "tmp" \n\t"\
"neg %%ecx \n\t"\
"add $7 , %%ecx \n\t"\
"shl %%cl , "tmp" \n\t"\
@@ -88,19 +87,13 @@
static av_always_inline int get_cabac_inline_x86(CABACContext *c,
uint8_t *const state)
{
- int bit, low, range, tmp;
+ int bit, tmp;
__asm__ volatile(
- "movl %a6(%5), %2 \n\t"
- "movl %a7(%5), %1 \n\t"
BRANCHLESS_GET_CABAC("%0", "%5", "(%4)", "%1", "%w1", "%2",
- "%3", "%b3", "%a8")
- "movl %2, %a6(%5) \n\t"
- "movl %1, %a7(%5) \n\t"
-
- :"=&r"(bit), "=&r"(low), "=&r"(range), "=&q"(tmp)
+ "%3", "%b3", "%a6")
+ :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp)
:"r"(state), "r"(c),
- "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
"i"(offsetof(CABACContext, bytestream))
: "%"REG_c, "memory"
);
diff --git a/libavcodec/x86/h264_i386.h b/libavcodec/x86/h264_i386.h
index c2477ac96b..38908a42e2 100644
--- a/libavcodec/x86/h264_i386.h
+++ b/libavcodec/x86/h264_i386.h
@@ -45,23 +45,18 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
int minusindex= 4-(intptr_t)index;
int bit;
x86_reg coeff_count;
- int low;
- int range;
__asm__ volatile(
- "movl %a11(%6), %5 \n\t"
- "movl %a12(%6), %3 \n\t"
-
"2: \n\t"
BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3",
- "%w3", "%5", "%k0", "%b0", "%a13")
+ "%w3", "%5", "%k0", "%b0", "%a11")
"test $1, %4 \n\t"
" jz 3f \n\t"
"add %10, %1 \n\t"
BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3",
- "%w3", "%5", "%k0", "%b0", "%a13")
+ "%w3", "%5", "%k0", "%b0", "%a11")
"sub %10, %1 \n\t"
"mov %2, %0 \n\t"
@@ -72,8 +67,7 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
"test $1, %4 \n\t"
" jnz 4f \n\t"
- "add $4, %0 \n\t"
- "mov %0, %2 \n\t"
+ "add $4, %2 \n\t"
"3: \n\t"
"add $1, %1 \n\t"
@@ -86,13 +80,9 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
"4: \n\t"
"add %9, %k0 \n\t"
"shr $2, %k0 \n\t"
-
- "movl %5, %a11(%6) \n\t"
- "movl %3, %a12(%6) \n\t"
:"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
- "=&r"(low), "=&r"(bit), "=&r"(range)
+ "+&r"(c->low), "=&r"(bit), "+&r"(c->range)
:"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
- "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
"i"(offsetof(CABACContext, bytestream))
: "%"REG_c, "memory"
);
@@ -101,18 +91,13 @@ static int decode_significance_x86(CABACContext *c, int max_coeff,
static int decode_significance_8x8_x86(CABACContext *c,
uint8_t *significant_coeff_ctx_base,
- int *index, x86_reg last_off, const uint8_t *sig_off){
+ int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){
int minusindex= 4-(intptr_t)index;
int bit;
x86_reg coeff_count;
- int low;
- int range;
x86_reg last=0;
x86_reg state;
__asm__ volatile(
- "movl %a12(%7), %5 \n\t"
- "movl %a13(%7), %3 \n\t"
-
"mov %1, %6 \n\t"
"2: \n\t"
@@ -121,18 +106,17 @@ static int decode_significance_8x8_x86(CABACContext *c,
"add %9, %6 \n\t"
BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3",
- "%w3", "%5", "%k0", "%b0", "%a14")
+ "%w3", "%5", "%k0", "%b0", "%a12")
"mov %1, %k6 \n\t"
"test $1, %4 \n\t"
" jz 3f \n\t"
"movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t"
- "add %9, %6 \n\t"
"add %11, %6 \n\t"
BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3",
- "%w3", "%5", "%k0", "%b0", "%a14")
+ "%w3", "%5", "%k0", "%b0", "%a12")
"mov %2, %0 \n\t"
"mov %1, %k6 \n\t"
@@ -141,8 +125,7 @@ static int decode_significance_8x8_x86(CABACContext *c,
"test $1, %4 \n\t"
" jnz 4f \n\t"
- "add $4, %0 \n\t"
- "mov %0, %2 \n\t"
+ "add $4, %2 \n\t"
"3: \n\t"
"addl $1, %k6 \n\t"
@@ -154,13 +137,9 @@ static int decode_significance_8x8_x86(CABACContext *c,
"4: \n\t"
"addl %8, %k0 \n\t"
"shr $2, %k0 \n\t"
-
- "movl %5, %a12(%7) \n\t"
- "movl %3, %a13(%7) \n\t"
- :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit),
- "=&r"(range), "=&r"(state)
- :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off),
- "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
+ :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit),
+ "+&r"(c->range), "=&r"(state)
+ :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base),
"i"(offsetof(CABACContext, bytestream))
: "%"REG_c, "memory"
);