rdopt/pickinter: factor out some common setup

Add new get_predictor_pointers() and get_reference_search_order()
functions for code shared between the two implementations.

Change-Id: I1ebe76aa8f168b1f5cfabc00d05d8f19a0d4d207
This commit is contained in:
John Koleszar 2012-01-11 14:38:58 -08:00
parent bd5bfd94b8
commit 4ade079633
3 changed files with 61 additions and 83 deletions

View File

@ -491,10 +491,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int saddone=0;
int sr=0; //search range got from mv_pred(). It uses step_param levels. (0-7)
unsigned char *y_buffer[4];
unsigned char *u_buffer[4];
unsigned char *v_buffer[4];
int i;
unsigned char *plane[4][3];
int ref_frame_map[4];
int sign_bias = 0;
@ -516,16 +513,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
vpx_memset(&best_mbmode, 0, sizeof(best_mbmode));
/* Setup search priorities */
i=0;
ref_frame_map[i++] = INTRA_FRAME;
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
ref_frame_map[i++] = LAST_FRAME;
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
ref_frame_map[i++] = GOLDEN_FRAME;
if (cpi->ref_frame_flags & VP8_ALT_FLAG) // &&(cpi->source_alt_ref_active || cpi->oxcf.number_of_layers > 1)
ref_frame_map[i++] = ALTREF_FRAME;
for(; i<4; i++)
ref_frame_map[i] = -1;
get_reference_search_order(cpi, ref_frame_map);
/* Check to see if there is at least 1 valid reference frame that we need
* to calculate near_mvs.
@ -543,30 +531,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
sign_bias = cpi->common.ref_frame_sign_bias[ref_frame_map[1]];
}
// set up all the refframe dependent pointers.
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
{
YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
u_buffer[LAST_FRAME] = lst_yv12->u_buffer + recon_uvoffset;
v_buffer[LAST_FRAME] = lst_yv12->v_buffer + recon_uvoffset;
}
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
{
YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset;
v_buffer[GOLDEN_FRAME] = gld_yv12->v_buffer + recon_uvoffset;
}
if (cpi->ref_frame_flags & VP8_ALT_FLAG)
{
YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
u_buffer[ALTREF_FRAME] = alt_yv12->u_buffer + recon_uvoffset;
v_buffer[ALTREF_FRAME] = alt_yv12->v_buffer + recon_uvoffset;
}
get_predictor_pointers(cpi, plane, recon_yoffset, recon_uvoffset);
cpi->mbs_tested_so_far++; // Count of the number of MBs tested so far this frame
@ -610,9 +575,9 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
// everything but intra
if (x->e_mbd.mode_info_context->mbmi.ref_frame)
{
x->e_mbd.pre.y_buffer = y_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
x->e_mbd.pre.u_buffer = u_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
x->e_mbd.pre.v_buffer = v_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
x->e_mbd.pre.y_buffer = plane[this_ref_frame][0];
x->e_mbd.pre.u_buffer = plane[this_ref_frame][1];
x->e_mbd.pre.v_buffer = plane[this_ref_frame][2];
if (sign_bias !=
cpi->common.ref_frame_sign_bias[x->e_mbd.mode_info_context->mbmi.ref_frame])

View File

@ -1716,6 +1716,7 @@ static void rd_update_mvcount(VP8_COMP *cpi, MACROBLOCK *x, int_mv *best_ref_mv)
}
}
void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int recon_uvoffset, int *returnrate,
int *returndistortion, int *returnintra)
@ -1751,9 +1752,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int saddone=0;
int sr=0; //search range got from mv_pred(). It uses step_param levels. (0-7)
unsigned char *y_buffer[4];
unsigned char *u_buffer[4];
unsigned char *v_buffer[4];
unsigned char *plane[4][3];
int ref_frame_map[4];
int sign_bias = 0;
@ -1762,16 +1761,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
vpx_memset(&best_bmodes, 0, sizeof(best_bmodes));
/* Setup search priorities */
i=0;
ref_frame_map[i++] = INTRA_FRAME;
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
ref_frame_map[i++] = LAST_FRAME;
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
ref_frame_map[i++] = GOLDEN_FRAME;
if (cpi->ref_frame_flags & VP8_ALT_FLAG)
ref_frame_map[i++] = ALTREF_FRAME;
for(; i<4; i++)
ref_frame_map[i] = -1;
get_reference_search_order(cpi, ref_frame_map);
/* Check to see if there is at least 1 valid reference frame that we need
* to calculate near_mvs.
@ -1789,32 +1779,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
sign_bias = cpi->common.ref_frame_sign_bias[ref_frame_map[1]];
}
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
{
YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.lst_fb_idx];
y_buffer[LAST_FRAME] = lst_yv12->y_buffer + recon_yoffset;
u_buffer[LAST_FRAME] = lst_yv12->u_buffer + recon_uvoffset;
v_buffer[LAST_FRAME] = lst_yv12->v_buffer + recon_uvoffset;
}
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
{
YV12_BUFFER_CONFIG *gld_yv12 = &cpi->common.yv12_fb[cpi->common.gld_fb_idx];
y_buffer[GOLDEN_FRAME] = gld_yv12->y_buffer + recon_yoffset;
u_buffer[GOLDEN_FRAME] = gld_yv12->u_buffer + recon_uvoffset;
v_buffer[GOLDEN_FRAME] = gld_yv12->v_buffer + recon_uvoffset;
}
if (cpi->ref_frame_flags & VP8_ALT_FLAG)
{
YV12_BUFFER_CONFIG *alt_yv12 = &cpi->common.yv12_fb[cpi->common.alt_fb_idx];
y_buffer[ALTREF_FRAME] = alt_yv12->y_buffer + recon_yoffset;
u_buffer[ALTREF_FRAME] = alt_yv12->u_buffer + recon_uvoffset;
v_buffer[ALTREF_FRAME] = alt_yv12->v_buffer + recon_uvoffset;
}
get_predictor_pointers(cpi, plane, recon_yoffset, recon_uvoffset);
*returnintra = INT_MAX;
cpi->mbs_tested_so_far++; // Count of the number of MBs tested so far this frame
@ -1861,9 +1826,9 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* everything but intra */
if (x->e_mbd.mode_info_context->mbmi.ref_frame)
{
x->e_mbd.pre.y_buffer = y_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
x->e_mbd.pre.u_buffer = u_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
x->e_mbd.pre.v_buffer = v_buffer[x->e_mbd.mode_info_context->mbmi.ref_frame];
x->e_mbd.pre.y_buffer = plane[this_ref_frame][0];
x->e_mbd.pre.u_buffer = plane[this_ref_frame][1];
x->e_mbd.pre.v_buffer = plane[this_ref_frame][2];
if (sign_bias !=
cpi->common.ref_frame_sign_bias[x->e_mbd.mode_info_context->mbmi.ref_frame])

View File

@ -69,6 +69,54 @@ extern void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue);
extern void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int recon_uvoffset, int *returnrate, int *returndistortion, int *returnintra);
extern void vp8_rd_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate);
static void get_plane_pointers(const YV12_BUFFER_CONFIG *fb,
unsigned char *plane[3],
unsigned int recon_yoffset,
unsigned int recon_uvoffset)
{
plane[0] = fb->y_buffer + recon_yoffset;
plane[1] = fb->u_buffer + recon_uvoffset;
plane[2] = fb->u_buffer + recon_uvoffset;
}
static void get_predictor_pointers(const VP8_COMP *cpi,
unsigned char *plane[4][3],
unsigned int recon_yoffset,
unsigned int recon_uvoffset)
{
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.lst_fb_idx],
plane[LAST_FRAME], recon_yoffset, recon_uvoffset);
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.gld_fb_idx],
plane[GOLDEN_FRAME], recon_yoffset, recon_uvoffset);
if (cpi->ref_frame_flags & VP8_ALT_FLAG)
get_plane_pointers(&cpi->common.yv12_fb[cpi->common.alt_fb_idx],
plane[ALTREF_FRAME], recon_yoffset, recon_uvoffset);
}
static void get_reference_search_order(const VP8_COMP *cpi,
int ref_frame_map[4])
{
int i=0;
ref_frame_map[i++] = INTRA_FRAME;
if (cpi->ref_frame_flags & VP8_LAST_FLAG)
ref_frame_map[i++] = LAST_FRAME;
if (cpi->ref_frame_flags & VP8_GOLD_FLAG)
ref_frame_map[i++] = GOLDEN_FRAME;
if (cpi->ref_frame_flags & VP8_ALT_FLAG)
ref_frame_map[i++] = ALTREF_FRAME;
for(; i<4; i++)
ref_frame_map[i] = -1;
}
extern void vp8_mv_pred
(
VP8_COMP *cpi,