Commit d1abe62d authored by Yunqing Wang's avatar Yunqing Wang

Define RDCOST only once

Clean up the code.

Change-Id: I7db048efa4d972b528d553a7921bc45979621129
parent a9ce3e38
...@@ -1188,7 +1188,7 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t) ...@@ -1188,7 +1188,7 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
(&x->e_mbd); (&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, 0x7fffffff);
rate2 = x->mbmode_cost[x->e_mbd.frame_type][mode]; rate2 = x->mbmode_cost[x->e_mbd.frame_type][mode];
this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
if (Error16x16 > this_rd) if (Error16x16 > this_rd)
{ {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "vp8/common/reconintra.h" #include "vp8/common/reconintra.h"
#include "dct.h" #include "dct.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "rdopt.h"
#if CONFIG_RUNTIME_CPU_DETECT #if CONFIG_RUNTIME_CPU_DETECT
#define IF_RTCD(x) (x) #define IF_RTCD(x) (x)
...@@ -230,7 +231,6 @@ void vp8_stuff_inter16x16(MACROBLOCK *x) ...@@ -230,7 +231,6 @@ void vp8_stuff_inter16x16(MACROBLOCK *x)
} }
#if !(CONFIG_REALTIME_ONLY) #if !(CONFIG_REALTIME_ONLY)
#define RDCOST(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) )
#define RDTRUNC(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF ) #define RDTRUNC(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF )
typedef struct vp8_token_state vp8_token_state; typedef struct vp8_token_state vp8_token_state;
......
...@@ -194,7 +194,7 @@ static int pick_intra4x4block( ...@@ -194,7 +194,7 @@ static int pick_intra4x4block(
rate = mode_costs[mode]; rate = mode_costs[mode];
vp8_predict_intra4x4(b, mode, b->predictor); vp8_predict_intra4x4(b, mode, b->predictor);
distortion = get_prediction_error(be, b, &rtcd->variance); distortion = get_prediction_error(be, b, &rtcd->variance);
this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate, distortion); this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
if (this_rd < best_rd) if (this_rd < best_rd)
{ {
...@@ -252,7 +252,7 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int ...@@ -252,7 +252,7 @@ int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *mb, int
if (i == 16) if (i == 16)
{ {
*best_dist = distortion; *best_dist = distortion;
error = RD_ESTIMATE(mb->rdmult, mb->rddiv, cost, distortion); error = RDCOST(mb->rdmult, mb->rddiv, cost, distortion);
} }
else else
{ {
...@@ -643,7 +643,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re ...@@ -643,7 +643,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re
} }
else else
{ {
this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
if (this_rd < best_intra_rd) if (this_rd < best_intra_rd)
{ {
...@@ -667,7 +667,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re ...@@ -667,7 +667,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re
(&x->e_mbd); (&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, 0x7fffffff);
rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode]; rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.mode];
this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
if (this_rd < best_intra_rd) if (this_rd < best_intra_rd)
{ {
...@@ -813,7 +813,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re ...@@ -813,7 +813,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int re
distortion2 = get_inter_mbpred_error(x, &cpi->fn_ptr[BLOCK_16X16], (unsigned int *)(&sse)); distortion2 = get_inter_mbpred_error(x, &cpi->fn_ptr[BLOCK_16X16], (unsigned int *)(&sse));
this_rd = RD_ESTIMATE(x->rdmult, x->rddiv, rate2, distortion2); this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
if (cpi->active_map_enabled && x->active_ptr[0] == 0) if (cpi->active_map_enabled && x->active_ptr[0] == 0)
{ {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "vpx_ports/config.h" #include "vpx_ports/config.h"
#include "vp8/common/onyxc_int.h" #include "vp8/common/onyxc_int.h"
#define RD_ESTIMATE(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) )
extern int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *, MACROBLOCK *mb, int *Rate, int *Distortion); extern int vp8_pick_intra4x4mby_modes(const VP8_ENCODER_RTCD *, MACROBLOCK *mb, int *Rate, int *Distortion);
extern void vp8_pick_intra_mbuv_mode(MACROBLOCK *mb); extern void vp8_pick_intra_mbuv_mode(MACROBLOCK *mb);
extern void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra); extern void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "vp8/common/g_common.h" #include "vp8/common/g_common.h"
#include "variance.h" #include "variance.h"
#include "mcomp.h" #include "mcomp.h"
#include "rdopt.h"
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "dct.h" #include "dct.h"
#include "vp8/common/systemdependent.h" #include "vp8/common/systemdependent.h"
...@@ -46,13 +46,8 @@ ...@@ -46,13 +46,8 @@
extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x); extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x);
extern void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x); extern void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x);
#define RDCOST(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) )
#define MAXF(a,b) (((a) > (b)) ? (a) : (b)) #define MAXF(a,b) (((a) > (b)) ? (a) : (b))
static const int auto_speed_thresh[17] = static const int auto_speed_thresh[17] =
{ {
1000, 1000,
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#ifndef __INC_RDOPT_H #ifndef __INC_RDOPT_H
#define __INC_RDOPT_H #define __INC_RDOPT_H
#define RDCOST(RM,DM,R,D) ( ((128+(R)*(RM)) >> 8) + (DM)*(D) )
extern void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue); extern void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue);
extern int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *rate, int *rate_to, int *distortion, int best_rd); extern int vp8_rd_pick_intra4x4mby_modes(VP8_COMP *cpi, MACROBLOCK *mb, int *rate, int *rate_to, int *distortion, int best_rd);
extern int vp8_rd_pick_intra16x16mby_mode(VP8_COMP *cpi, MACROBLOCK *x, int *returnrate, int *rate_to, int *returndistortion); extern int vp8_rd_pick_intra16x16mby_mode(VP8_COMP *cpi, MACROBLOCK *x, int *returnrate, int *rate_to, int *returndistortion);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment