From 1d0eab1dcc26344309f624a95d91f97d72f4b847 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 18 Jan 2003 01:37:42 +0000 Subject: [PATCH] bugs Originally committed as revision 1469 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/dsputil.c | 7 ++++--- libavcodec/motion_est.c | 5 +++-- libavcodec/motion_est_template.c | 4 ++-- libavcodec/mpegvideo.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index e960696e1a..efdb438c9b 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -1894,10 +1894,11 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int run++; } i= scantable[last]; - - assert(level); - + level= temp[i] + 64; + + assert(level - 64); + if((level&(~127)) == 0){ bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; }else diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 4dcc08d596..630d4fe239 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1,7 +1,7 @@ /* * Motion estimation * Copyright (c) 2000,2001 Fabrice Bellard. - * Copyright (c) 2002 Michael Niedermayer + * Copyright (c) 2002-2003 Michael Niedermayer * * * This library is free software; you can redistribute it and/or @@ -313,6 +313,7 @@ static inline int get_penalty_factor(MpegEncContext *s, int type){ case FF_CMP_DCT: case FF_CMP_SATD: case FF_CMP_SSE: + case FF_CMP_PSNR: return s->qscale*8; case FF_CMP_BIT: return 1; @@ -1030,7 +1031,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, } #endif }else{ - s->scene_change_score+= 20; + s->scene_change_score+= s->qscale; mb_type|= MB_TYPE_INTRA; mx = 0; my = 0; diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c index d1ca6e7fbd..6711785f61 100644 --- a/libavcodec/motion_est_template.c +++ b/libavcodec/motion_est_template.c @@ -160,7 +160,7 @@ static int RENAME(hpel_motion_search)(MpegEncContext * s, if(s->avctx->me_cmp != s->avctx->me_sub_cmp){ CMP_HPEL(dmin, 0, 0, mx, my, size); - if(mx || my) + if(mx || my || size>0) dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor; } @@ -290,7 +290,7 @@ static int RENAME(qpel_motion_search)(MpegEncContext * s, if(s->avctx->me_cmp != s->avctx->me_sub_cmp){ CMP_QPEL(dmin, 0, 0, mx, my, size); - if(mx || my) + if(mx || my || size>0) dmin += (mv_penalty[4*mx - pred_x] + mv_penalty[4*my - pred_y])*penalty_factor; } diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 44d88f2f0e..48efd28648 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -2592,7 +2592,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y) s->block_last_index[4]= s->block_last_index[5]= 0; s->block[4][0]= - s->block[5][0]= 128; + s->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale; } #ifdef CONFIG_ENCODERS