From a615c4049998f51e5123d7051020d38c35603f3d Mon Sep 17 00:00:00 2001 From: Attila Nagy Date: Wed, 25 May 2011 12:54:34 +0300 Subject: [PATCH 1/3] Use var8x8 instead of get8x8var in VP8_UVSSE 'sum' returned by get8x8var is not used and var8x8 has optimizations for more platforms. Change-Id: I4a907fb1a05f285669fb0b95dc71d42182c980f6 --- vp8/encoder/rdopt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index db0395d94..f0514ad8c 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -464,11 +464,10 @@ int VP8_UVSSE(MACROBLOCK *x, const vp8_variance_rtcd_vtable_t *rtcd) } else { - int sum2, sum1; - VARIANCE_INVOKE(rtcd, get8x8var)(uptr, pre_stride, - upred_ptr, uv_stride, &sse2, &sum2); - VARIANCE_INVOKE(rtcd, get8x8var)(vptr, pre_stride, - vpred_ptr, uv_stride, &sse1, &sum1); + VARIANCE_INVOKE(rtcd, var8x8)(uptr, pre_stride, + upred_ptr, uv_stride, &sse2); + VARIANCE_INVOKE(rtcd, var8x8)(vptr, pre_stride, + vpred_ptr, uv_stride, &sse1); sse2 += sse1; } return sse2; From b6679879b8a6bb16d4c70f516806be6b7aaba6f6 Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Wed, 25 May 2011 09:26:29 -0400 Subject: [PATCH 2/3] Return sse value in vp8_variance SSE2 functions Minor modification. Change-Id: I09511d38fd1451d5c4106a48acdb3f766ce59cb7 --- vp8/encoder/arm/variance_arm.h | 4 ++-- vp8/encoder/encodeframe.c | 2 +- vp8/encoder/pickinter.c | 12 +++++------- vp8/encoder/variance.h | 22 +++++++++++++++------- vp8/encoder/x86/variance_mmx.c | 17 ++++++++--------- vp8/encoder/x86/variance_sse2.c | 13 +++++++------ vp8/encoder/x86/variance_ssse3.c | 2 +- vp8/encoder/x86/variance_x86.h | 6 +++--- 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/vp8/encoder/arm/variance_arm.h b/vp8/encoder/arm/variance_arm.h index 86de27476..ad0d37193 100644 --- a/vp8/encoder/arm/variance_arm.h +++ b/vp8/encoder/arm/variance_arm.h @@ -83,10 +83,10 @@ extern prototype_variance(vp8_variance_halfpixvar16x16_hv_neon); //extern prototype_getmbss(vp8_get_mb_ss_c); extern prototype_variance(vp8_mse16x16_neon); -extern prototype_sad(vp8_get16x16pred_error_neon); +extern prototype_get16x16prederror(vp8_get16x16pred_error_neon); //extern prototype_variance2(vp8_get8x8var_c); //extern prototype_variance2(vp8_get16x16var_c); -extern prototype_sad(vp8_get4x4sse_cs_neon); +extern prototype_get16x16prederror(vp8_get4x4sse_cs_neon); #if !CONFIG_RUNTIME_CPU_DETECT #undef vp8_variance_sad4x4 diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index 672ceeca0..1bb026048 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -1079,7 +1079,7 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t) x->e_mbd.mode_info_context->mbmi.mode = mode; RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby) (&x->e_mbd); - distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16, 0x7fffffff); + distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16); rate2 = x->mbmode_cost[x->e_mbd.frame_type][mode]; this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 666948060..d1dc7ae03 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -101,8 +101,7 @@ unsigned int vp8_get16x16pred_error_c const unsigned char *src_ptr, int src_stride, const unsigned char *ref_ptr, - int ref_stride, - int max_sad + int ref_stride ) { unsigned pred_error = 0; @@ -134,8 +133,7 @@ unsigned int vp8_get4x4sse_cs_c const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, - int recon_stride, - int max_sad + int recon_stride ) { int distortion = 0; @@ -163,7 +161,7 @@ static int get_prediction_error(BLOCK *be, BLOCKD *b, const vp8_variance_rtcd_vt sptr = (*(be->base_src) + be->src); dptr = b->predictor; - return VARIANCE_INVOKE(rtcd, get4x4sse_cs)(sptr, be->src_stride, dptr, 16, 0x7fffffff); + return VARIANCE_INVOKE(rtcd, get4x4sse_cs)(sptr, be->src_stride, dptr, 16); } @@ -672,7 +670,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, distortion2 = VARIANCE_INVOKE (&cpi->rtcd.variance, get16x16prederror)( x->src.y_buffer, x->src.y_stride, - x->e_mbd.predictor, 16, 0x7fffffff); + x->e_mbd.predictor, 16); this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); if (this_rd < best_intra_rd) @@ -695,7 +693,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, case TM_PRED: RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby) (&x->e_mbd); - distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16, 0x7fffffff); + distortion2 = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16); rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode]; this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); diff --git a/vp8/encoder/variance.h b/vp8/encoder/variance.h index da5a5364a..0d7d977d7 100644 --- a/vp8/encoder/variance.h +++ b/vp8/encoder/variance.h @@ -101,6 +101,15 @@ #define prototype_getmbss(sym) unsigned int (sym)(const short *) +#define prototype_get16x16prederror(sym)\ + unsigned int (sym)\ + (\ + const unsigned char *src_ptr, \ + int source_stride, \ + const unsigned char *ref_ptr, \ + int ref_stride \ + ) + #if ARCH_X86 || ARCH_X86_64 #include "x86/variance_x86.h" #endif @@ -302,7 +311,7 @@ extern prototype_variance(vp8_variance_mse16x16); #ifndef vp8_variance_get16x16prederror #define vp8_variance_get16x16prederror vp8_get16x16pred_error_c #endif -extern prototype_sad(vp8_variance_get16x16prederror); +extern prototype_get16x16prederror(vp8_variance_get16x16prederror); #ifndef vp8_variance_get8x8var #define vp8_variance_get8x8var vp8_get8x8var_c @@ -317,7 +326,7 @@ extern prototype_variance2(vp8_variance_get16x16var); #ifndef vp8_variance_get4x4sse_cs #define vp8_variance_get4x4sse_cs vp8_get4x4sse_cs_c #endif -extern prototype_sad(vp8_variance_get4x4sse_cs); +extern prototype_get16x16prederror(vp8_variance_get4x4sse_cs); #ifndef vp8_ssimpf #define vp8_ssimpf ssim_parms_c @@ -337,9 +346,8 @@ typedef prototype_variance(*vp8_variance_fn_t); typedef prototype_variance2(*vp8_variance2_fn_t); typedef prototype_subpixvariance(*vp8_subpixvariance_fn_t); typedef prototype_getmbss(*vp8_getmbss_fn_t); - -typedef prototype_ssimpf(*vp8_ssimpf_fn_t) - +typedef prototype_ssimpf(*vp8_ssimpf_fn_t); +typedef prototype_get16x16prederror(*vp8_get16x16prederror_fn_t); typedef struct { @@ -368,10 +376,10 @@ typedef struct vp8_getmbss_fn_t getmbss; vp8_variance_fn_t mse16x16; - vp8_sad_fn_t get16x16prederror; + vp8_get16x16prederror_fn_t get16x16prederror; vp8_variance2_fn_t get8x8var; vp8_variance2_fn_t get16x16var; - vp8_sad_fn_t get4x4sse_cs; + vp8_get16x16prederror_fn_t get4x4sse_cs; vp8_sad_multi_fn_t sad16x16x3; vp8_sad_multi_fn_t sad16x8x3; diff --git a/vp8/encoder/x86/variance_mmx.c b/vp8/encoder/x86/variance_mmx.c index cc8c1d0e3..4a89868c2 100644 --- a/vp8/encoder/x86/variance_mmx.c +++ b/vp8/encoder/x86/variance_mmx.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include "vpx_config.h" #include "vp8/encoder/variance.h" #include "vp8/common/pragmas.h" #include "vpx_ports/mem.h" @@ -34,7 +34,7 @@ extern void filter_block1d_v6_mmx short *vp7_filter ); -extern unsigned int vp8_get_mb_ss_mmx(short *src_ptr); +extern unsigned int vp8_get_mb_ss_mmx(const short *src_ptr); extern unsigned int vp8_get8x8var_mmx ( const unsigned char *src_ptr, @@ -78,20 +78,19 @@ extern void vp8_filter_block2d_bil_var_mmx ); extern unsigned int vp8_get16x16pred_error_mmx ( - unsigned char *src_ptr, + const unsigned char *src_ptr, int src_stride, - unsigned char *ref_ptr, + const unsigned char *ref_ptr, int ref_stride ); - unsigned int vp8_get16x16var_mmx( const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, int recon_stride, - unsigned *SSE, - unsigned *SUM + unsigned int *SSE, + int *SUM ) { unsigned int sse0, sse1, sse2, sse3, var; @@ -176,7 +175,7 @@ unsigned int vp8_variance16x16_mmx( int source_stride, const unsigned char *ref_ptr, int recon_stride, - int *sse) + unsigned int *sse) { unsigned int sse0, sse1, sse2, sse3, var; int sum0, sum1, sum2, sum3, avg; @@ -401,7 +400,7 @@ unsigned int vp8_sub_pixel_variance8x16_mmx int yoffset, const unsigned char *dst_ptr, int dst_pixels_per_line, - int *sse + unsigned int *sse ) { int xsum; diff --git a/vp8/encoder/x86/variance_sse2.c b/vp8/encoder/x86/variance_sse2.c index 0edda3062..dfc0915b9 100644 --- a/vp8/encoder/x86/variance_sse2.c +++ b/vp8/encoder/x86/variance_sse2.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include "vpx_config.h" #include "vp8/encoder/variance.h" #include "vp8/common/pragmas.h" #include "vpx_ports/mem.h" @@ -148,30 +148,31 @@ unsigned int vp8_variance4x4_wmt( const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, - int recon_stride) + int recon_stride, + unsigned int *sse) { unsigned int var; int avg; vp8_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ; + *sse = var; return (var - ((avg * avg) >> 4)); } - - unsigned int vp8_variance8x8_wmt ( const unsigned char *src_ptr, int source_stride, const unsigned char *ref_ptr, - int recon_stride) + int recon_stride, + unsigned int *sse) { unsigned int var; int avg; vp8_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ; - + *sse = var; return (var - ((avg * avg) >> 6)); } diff --git a/vp8/encoder/x86/variance_ssse3.c b/vp8/encoder/x86/variance_ssse3.c index eb5d486bf..73f2e01a2 100644 --- a/vp8/encoder/x86/variance_ssse3.c +++ b/vp8/encoder/x86/variance_ssse3.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include "vpx_config.h" #include "vp8/encoder/variance.h" #include "vp8/common/pragmas.h" #include "vpx_ports/mem.h" diff --git a/vp8/encoder/x86/variance_x86.h b/vp8/encoder/x86/variance_x86.h index 3560f7413..77e05e1e8 100644 --- a/vp8/encoder/x86/variance_x86.h +++ b/vp8/encoder/x86/variance_x86.h @@ -41,10 +41,10 @@ extern prototype_variance(vp8_variance_halfpixvar16x16_hv_mmx); extern prototype_subpixvariance(vp8_sub_pixel_mse16x16_mmx); extern prototype_getmbss(vp8_get_mb_ss_mmx); extern prototype_variance(vp8_mse16x16_mmx); -extern prototype_sad(vp8_get16x16pred_error_mmx); +extern prototype_get16x16prederror(vp8_get16x16pred_error_mmx); extern prototype_variance2(vp8_get8x8var_mmx); extern prototype_variance2(vp8_get16x16var_mmx); -extern prototype_sad(vp8_get4x4sse_cs_mmx); +extern prototype_get16x16prederror(vp8_get4x4sse_cs_mmx); #if !CONFIG_RUNTIME_CPU_DETECT #undef vp8_variance_sad4x4 @@ -148,7 +148,7 @@ extern prototype_variance(vp8_variance_halfpixvar16x16_hv_wmt); extern prototype_subpixvariance(vp8_sub_pixel_mse16x16_wmt); extern prototype_getmbss(vp8_get_mb_ss_sse2); extern prototype_variance(vp8_mse16x16_wmt); -extern prototype_sad(vp8_get16x16pred_error_sse2); +extern prototype_get16x16prederror(vp8_get16x16pred_error_sse2); extern prototype_variance2(vp8_get8x8var_sse2); extern prototype_variance2(vp8_get16x16var_sse2); From 22c05c0575313d9e76737bc1cd144a6efab2f657 Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Wed, 25 May 2011 09:35:54 -0700 Subject: [PATCH 3/3] remove code not in use Change-Id: I6e5e86235d341cce3b02abda26dbeb71940ed955 --- vp8/encoder/bitstream.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index 284025d4e..ec2bb94a7 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -40,9 +40,6 @@ const int vp8cx_base_skip_false_prob[128] = 53, 50, 47, 44, 41, 38, 35, 32, 30, 28, 26, 24, 22, 20, 18, 16, }; -#ifdef VP8REF -#define __int64 long long -#endif #if defined(SECTIONBITS_OUTPUT) unsigned __int64 Sectionbits[500];