Commit e90d17d2 authored by John Koleszar's avatar John Koleszar
Browse files

Move intra block mode selection to pickinter.c

This commit moves the intra block mode selection from encodeframe.c
to pickinter.c (in the non-RD case). This allowed pick_intra_mbuv_mode
and pick_intra4x4mby_modes to be made static, and is a step towards
refactoring intra mode selection in the main pickinter loop. Gave a
small perf increase (~0.5%).

Change-Id: I0b67dae1f8a74902378da7bdf565e39ab832dda7
parent 7368dd4f
......@@ -1034,7 +1034,15 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
Error4x4 = vp8_rd_pick_intra4x4mby_modes(cpi, x, &rate4x4, &rate4x4_tokenonly, &dist4x4, Error16x16);
rate += (Error4x4 < Error16x16) ? rate4x4 : rate16x16;
if (Error4x4 < Error16x16)
{
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
rate += rate4x4;
}
else
{
rate += rate16x16;
}
if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
{
......@@ -1043,46 +1051,12 @@ int vp8cx_encode_intra_macro_block(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
}
}
else
{
int rate2, best_distortion;
MB_PREDICTION_MODE mode, best_mode = DC_PRED;
int this_rd;
Error16x16 = INT_MAX;
vp8_pick_intra_mbuv_mode(x);
for (mode = DC_PRED; mode <= TM_PRED; mode ++)
{
int distortion2;
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);
rate2 = x->mbmode_cost[x->e_mbd.frame_type][mode];
this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
vp8_pick_intra_mode(cpi, x, &rate);
if (Error16x16 > this_rd)
{
Error16x16 = this_rd;
best_mode = mode;
best_distortion = distortion2;
}
}
x->e_mbd.mode_info_context->mbmi.mode = best_mode;
Error4x4 = vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate2, &best_distortion);
}
if (Error4x4 < Error16x16)
{
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED)
vp8_encode_intra4x4mby(IF_RTCD(&cpi->rtcd), x);
}
else
{
vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
}
vp8_encode_intra16x16mbuv(IF_RTCD(&cpi->rtcd), x);
sum_intra_stats(cpi, x);
......
......@@ -221,7 +221,7 @@ static int pick_intra4x4block(
}
int vp8_pick_intra4x4mby_modes
static int pick_intra4x4mby_modes
(
const VP8_ENCODER_RTCD *rtcd,
MACROBLOCK *mb,
......@@ -275,7 +275,7 @@ int vp8_pick_intra4x4mby_modes
return error;
}
void vp8_pick_intra_mbuv_mode(MACROBLOCK *mb)
static void pick_intra_mbuv_mode(MACROBLOCK *mb)
{
MACROBLOCKD *x = &mb->e_mbd;
......@@ -659,10 +659,9 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
switch (this_mode)
{
case B_PRED:
// Pass best so far to vp8_pick_intra4x4mby_modes to use as breakout
// Pass best so far to pick_intra4x4mby_modes to use as breakout
distortion2 = *returndistortion;
vp8_pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x,
&rate, &distortion2);
pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate, &distortion2);
if (distortion2 == INT_MAX)
{
......@@ -956,7 +955,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
if (best_mbmode.mode <= B_PRED)
{
/* set mode_info_context->mbmi.uv_mode */
vp8_pick_intra_mbuv_mode(x);
pick_intra_mbuv_mode(x);
}
if (x->e_mbd.mode_info_context->mbmi.mode == B_PRED)
......@@ -968,3 +967,40 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
}
update_mvcount(cpi, &x->e_mbd, &frame_best_ref_mv[xd->mode_info_context->mbmi.ref_frame]);
}
void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
{
int error4x4, error16x16 = INT_MAX;
int rate, distortion, best_distortion;
MB_PREDICTION_MODE mode, best_mode = DC_PRED;
int this_rd;
pick_intra_mbuv_mode(x);
for (mode = DC_PRED; mode <= TM_PRED; mode ++)
{
x->e_mbd.mode_info_context->mbmi.mode = mode;
RECON_INVOKE(&cpi->common.rtcd.recon, build_intra_predictors_mby)
(&x->e_mbd);
distortion = VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16prederror)
(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16);
rate = x->mbmode_cost[x->e_mbd.frame_type][mode];
this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
if (error16x16 > this_rd)
{
error16x16 = this_rd;
best_mode = mode;
best_distortion = distortion;
}
}
x->e_mbd.mode_info_context->mbmi.mode = best_mode;
error4x4 = pick_intra4x4mby_modes(IF_RTCD(&cpi->rtcd), x, &rate,
&best_distortion);
if (error4x4 < error16x16)
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
*rate_ = rate;
}
......@@ -14,7 +14,6 @@
#include "vpx_ports/config.h"
#include "vp8/common/onyxc_int.h"
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_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra);
extern void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate);
#endif
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