Mercurial > libavcodec.hg
changeset 411:5c8b3a717929 libavcodec
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
author | michaelni |
---|---|
date | Tue, 21 May 2002 23:13:57 +0000 |
parents | 8aba98b353f0 |
children | 868b9247dc24 |
files | avcodec.h h263dec.c mpegvideo.h msmpeg4.c |
diffstat | 4 files changed, 23 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/avcodec.h Tue May 21 23:07:26 2002 +0000 +++ b/avcodec.h Tue May 21 23:13:57 2002 +0000 @@ -5,8 +5,8 @@ #define LIBAVCODEC_VERSION_INT 0x000406 #define LIBAVCODEC_VERSION "0.4.6" -#define LIBAVCODEC_BUILD 4609 -#define LIBAVCODEC_BUILD_STR "4609" +#define LIBAVCODEC_BUILD 4610 +#define LIBAVCODEC_BUILD_STR "4610" enum CodecID { CODEC_ID_NONE, @@ -231,6 +231,8 @@ enum CodecType codec_type; /* see CODEC_TYPE_xxx */ enum CodecID codec_id; /* see CODEC_ID_xxx */ unsigned int codec_tag; /* codec tag, only used if unknown codec */ + + int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */ /* Note: Below are located reserved fields for further usage It requires for ABI !!! @@ -253,7 +255,7 @@ ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12; unsigned int ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5, - ui_res6,ui_res7,ui_res8,ui_res9,ui_res10,ui_res11,ui_res12; + ui_res6,ui_res7,ui_res8,ui_res9,ui_res10,ui_res11; unsigned short int us_res0,us_res1,us_res2,us_res3,us_res4,us_res5, us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12;
--- a/h263dec.c Tue May 21 23:07:26 2002 +0000 +++ b/h263dec.c Tue May 21 23:13:57 2002 +0000 @@ -43,6 +43,7 @@ s->width = avctx->width; s->height = avctx->height; + s->workaround_bugs= avctx->workaround_bugs; /* select sub codec */ switch(avctx->codec->id) { @@ -211,7 +212,11 @@ //fprintf(stderr,"\nFrame: %d\tMB: %d",avctx->frame_number, (s->mb_y * s->mb_width) + s->mb_x); /* DCT & quantize */ if (s->h263_pred && s->msmpeg4_version!=2) { - h263_dc_scale(s); + /* old ffmpeg encoded msmpeg4v3 workaround */ + if(s->workaround_bugs==1 && s->msmpeg4_version==3) + ff_old_msmpeg4_dc_scale(s); + else + h263_dc_scale(s); } else { /* default quantization values */ s->y_dc_scale = 8; @@ -277,9 +282,9 @@ s->has_b_frames=1; for(mb_y=0; mb_y<s->mb_height; mb_y++){ int mb_x; - int y= mb_y*16; + int y= mb_y*16 + 8; for(mb_x=0; mb_x<s->mb_width; mb_x++){ - int x= mb_x*16; + int x= mb_x*16 + 8; uint8_t *ptr= s->last_picture[0]; int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>1) + x; @@ -299,6 +304,7 @@ int y1= y + (my-y)*i/max; ptr[y1*s->linesize + x1]+=100; } + ptr[y*s->linesize + x]+=100; s->mbskip_table[mb_x + mb_y*s->mb_width]=0; } }
--- a/mpegvideo.h Tue May 21 23:07:26 2002 +0000 +++ b/mpegvideo.h Tue May 21 23:13:57 2002 +0000 @@ -99,6 +99,7 @@ float b_quant_factor;/* qscale factor between ips and b frames */ int rc_strategy; int b_frame_strategy; + int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */ /* the following fields are managed internally by the encoder */ /* bit output */ @@ -491,6 +492,7 @@ int msmpeg4_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); int msmpeg4_decode_init_vlc(MpegEncContext *s); +void ff_old_msmpeg4_dc_scale(MpegEncContext *s); /* mjpegenc.c */
--- a/msmpeg4.c Tue May 21 23:07:26 2002 +0000 +++ b/msmpeg4.c Tue May 21 23:13:57 2002 +0000 @@ -15,11 +15,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * msmpeg4v2 stuff by Michael Niedermayer <michaelni@gmx.at> */ #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" + /* * You can also call this codec : MPEG4 with a twist ! * @@ -407,26 +410,20 @@ } } - -#if 0 -/* identical to mpeg4 for msmpeg4v3 but not msmpeg4v2 */ -void msmpeg4_dc_scale(MpegEncContext * s) +/* old ffmpeg msmpeg4v3 mode */ +void ff_old_msmpeg4_dc_scale(MpegEncContext * s) { - if (s->qscale < 5 || s->msmpeg4_version==2){ + if (s->qscale < 5){ s->y_dc_scale = 8; s->c_dc_scale = 8; }else if (s->qscale < 9){ s->y_dc_scale = 2 * s->qscale; s->c_dc_scale = (s->qscale + 13)>>1; - }else if(s->qscale < 25){ + }else{ s->y_dc_scale = s->qscale + 8; s->c_dc_scale = (s->qscale + 13)>>1; - }else{ - s->y_dc_scale = 2 * s->qscale - 16; - s->c_dc_scale = s->qscale - 6; } } -#endif /* dir = 0: left, dir = 1: top prediction */ static int msmpeg4_pred_dc(MpegEncContext * s, int n,