From 4ccde216cddac98604a944b4fdc2588deaaa1fe5 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 5 May 2004 19:53:40 +0000 Subject: support decoding mpeg4 with buggy dc clipping Originally committed as revision 3108 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/avcodec.h | 3 ++- libavcodec/h263.c | 7 ++++++- libavcodec/h263dec.c | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 6738293f50..10992f686e 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -17,7 +17,7 @@ extern "C" { #define FFMPEG_VERSION_INT 0x000408 #define FFMPEG_VERSION "0.4.8" -#define LIBAVCODEC_BUILD 4712 +#define LIBAVCODEC_BUILD 4713 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -849,6 +849,7 @@ typedef struct AVCodecContext { #define FF_BUG_DIRECT_BLOCKSIZE 512 #define FF_BUG_EDGE 1024 #define FF_BUG_HPEL_CHROMA 2048 +#define FF_BUG_DC_CLIP 4096 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100% /** diff --git a/libavcodec/h263.c b/libavcodec/h263.c index 8cb9d5646c..59d746272c 100644 --- a/libavcodec/h263.c +++ b/libavcodec/h263.c @@ -2440,7 +2440,12 @@ static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *di } } level *=scale; - if(level&(~2047)) level= level<0 ? 0 : 2047; + if(level&(~2047)){ + if(level<0) + level=0; + else if(!(s->workaround_bugs&FF_BUG_DC_CLIP)) + level=2047; + } dc_val[0]= level; return ret; diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 0f45479c8f..ea8badb9dc 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -548,6 +548,9 @@ retry: if(s->xvid_build && s->xvid_build<=12) s->workaround_bugs|= FF_BUG_EDGE; + if(s->xvid_build && s->xvid_build<=32) + s->workaround_bugs|= FF_BUG_DC_CLIP; + #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ @@ -562,6 +565,9 @@ retry: if(s->lavc_build && s->lavc_build<4670){ s->workaround_bugs|= FF_BUG_EDGE; } + + if(s->lavc_build && s->lavc_build<=4712) + s->workaround_bugs|= FF_BUG_DC_CLIP; if(s->divx_version) s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE; -- cgit v1.2.3