Moving rd_thresh_mult, rd_threshes to macroblock struct

Change-Id: I650a593162280ab40e71e527ec6518303e2d5723
This commit is contained in:
Scott LaVarnway 2012-11-06 16:27:00 -08:00
Родитель ee28bb87b4
Коммит fe91e47bc7
9 изменённых файлов: 76 добавлений и 58 удалений

Просмотреть файл

@ -18,6 +18,8 @@
#include "vp8/common/entropy.h"
#include "vpx_ports/mem.h"
#define MAX_MODES 20
/* motion search site */
typedef struct
{
@ -135,6 +137,9 @@ typedef struct macroblock
int64_t prediction_error;
int64_t intra_error;
int rd_thresh_mult[MAX_MODES];
int rd_threshes[MAX_MODES];
void (*short_fdct4x4)(short *input, short *output, int pitch);
void (*short_fdct8x4)(short *input, short *output, int pitch);

Просмотреть файл

@ -45,7 +45,6 @@ extern void vp8_auto_select_speed(VP8_COMP *cpi);
extern void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
MACROBLOCK *x,
MB_ROW_COMP *mbr_ei,
int mb_row,
int count);
static void adjust_act_zbin( VP8_COMP *cpi, MACROBLOCK *x );
@ -766,7 +765,7 @@ void vp8_encode_frame(VP8_COMP *cpi)
vp8cx_frame_init_quantizer(cpi);
vp8_initialize_rd_consts(cpi,
vp8_initialize_rd_consts(cpi, x,
vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
vp8cx_initialize_me_consts(cpi, cm->base_qindex);
@ -805,7 +804,8 @@ void vp8_encode_frame(VP8_COMP *cpi)
{
int i;
vp8cx_init_mbrthread_data(cpi, x, cpi->mb_row_ei, 1, cpi->encoding_thread_count);
vp8cx_init_mbrthread_data(cpi, x, cpi->mb_row_ei,
cpi->encoding_thread_count);
for (i = 0; i < cm->mb_rows; i++)
cpi->mt_current_mb_col[i] = -1;

Просмотреть файл

@ -416,13 +416,17 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
zd->block[i].dequant = zd->dequant_uv;
zd->block[24].dequant = zd->dequant_y2;
#endif
vpx_memcpy(z->rd_threshes, x->rd_threshes, sizeof(x->rd_threshes));
vpx_memcpy(z->rd_thresh_mult, x->rd_thresh_mult,
sizeof(x->rd_thresh_mult));
}
}
void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
MACROBLOCK *x,
MB_ROW_COMP *mbr_ei,
int mb_row,
int count
)
{
@ -430,7 +434,6 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
VP8_COMMON *const cm = & cpi->common;
MACROBLOCKD *const xd = & x->e_mbd;
int i;
(void) mb_row;
for (i = 0; i < count; i++)
{

Просмотреть файл

@ -569,7 +569,7 @@ void vp8_first_pass(VP8_COMP *cpi)
/* Initialise the MV cost table to the defaults */
{
int flag[2] = {1, 1};
vp8_initialize_rd_consts(cpi, vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
vp8_initialize_rd_consts(cpi, x, vp8_dc_quant(cm->base_qindex, cm->y1dc_delta_q));
vpx_memcpy(cm->fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cm->fc.mvc, flag);
}

Просмотреть файл

@ -1931,7 +1931,7 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
/* Set starting values of RD threshold multipliers (128 = *1) */
for (i = 0; i < MAX_MODES; i++)
{
cpi->rd_thresh_mult[i] = 128;
cpi->mb.rd_thresh_mult[i] = 128;
}
#ifdef ENTROPY_STATS
@ -3388,7 +3388,7 @@ static void encode_frame_to_data_rate
/* Reset the RD threshold multipliers to default of * 1 (128) */
for (i = 0; i < MAX_MODES; i++)
{
cpi->rd_thresh_mult[i] = 128;
cpi->mb.rd_thresh_mult[i] = 128;
}
}

Просмотреть файл

@ -43,7 +43,7 @@
#define AF_THRESH 25
#define AF_THRESH2 100
#define ARF_DECAY_THRESH 12
#define MAX_MODES 20
#define MIN_THRESHMULT 32
#define MAX_THRESHMULT 512
@ -353,9 +353,7 @@ typedef struct VP8_COMP
unsigned int mode_chosen_counts[MAX_MODES];
unsigned int mbs_tested_so_far;
int rd_thresh_mult[MAX_MODES];
int rd_baseline_thresh[MAX_MODES];
int rd_threshes[MAX_MODES];
int RDMULT;
int RDDIV ;

Просмотреть файл

@ -701,7 +701,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int this_rd = INT_MAX;
int this_ref_frame = ref_frame_map[vp8_ref_frame_order[mode_index]];
if (best_rd <= cpi->rd_threshes[mode_index])
if (best_rd <= x->rd_threshes[mode_index])
continue;
if (this_ref_frame < 0)
@ -754,14 +754,14 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
{
/* Increase the threshold for coding this mode to make it less
* likely to be chosen */
cpi->rd_thresh_mult[mode_index] += 4;
x->rd_thresh_mult[mode_index] += 4;
if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
cpi->rd_threshes[mode_index] =
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
cpi->rd_thresh_mult[mode_index];
x->rd_thresh_mult[mode_index];
continue;
}
}
@ -1109,12 +1109,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Testing this mode gave rise to an improvement in best error
* score. Lower threshold a bit for next time
*/
cpi->rd_thresh_mult[mode_index] =
(cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ?
cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
cpi->rd_threshes[mode_index] =
x->rd_thresh_mult[mode_index] =
(x->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ?
x->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
cpi->rd_thresh_mult[mode_index];
x->rd_thresh_mult[mode_index];
}
/* If the mode did not help improve the best error case then raise the
@ -1122,14 +1122,14 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
*/
else
{
cpi->rd_thresh_mult[mode_index] += 4;
x->rd_thresh_mult[mode_index] += 4;
if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
cpi->rd_threshes[mode_index] =
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
cpi->rd_thresh_mult[mode_index];
x->rd_thresh_mult[mode_index];
}
if (x->skip)
@ -1139,16 +1139,16 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Reduce the activation RD thresholds for the best choice mode */
if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2)))
{
int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 3);
int best_adjustment = (x->rd_thresh_mult[best_mode_index] >> 3);
cpi->rd_thresh_mult[best_mode_index] =
(cpi->rd_thresh_mult[best_mode_index]
x->rd_thresh_mult[best_mode_index] =
(x->rd_thresh_mult[best_mode_index]
>= (MIN_THRESHMULT + best_adjustment)) ?
cpi->rd_thresh_mult[best_mode_index] - best_adjustment :
x->rd_thresh_mult[best_mode_index] - best_adjustment :
MIN_THRESHMULT;
cpi->rd_threshes[best_mode_index] =
x->rd_threshes[best_mode_index] =
(cpi->rd_baseline_thresh[best_mode_index] >> 7) *
cpi->rd_thresh_mult[best_mode_index];
x->rd_thresh_mult[best_mode_index];
}

Просмотреть файл

@ -223,7 +223,7 @@ void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
cpi->mb.sadperbit4 = sad_per_bit4lut[QIndex];
}
void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, int Qvalue)
{
int q;
int i;
@ -279,14 +279,14 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
{
if (cpi->sf.thresh_mult[i] < INT_MAX)
{
cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q / 100;
x->rd_threshes[i] = cpi->sf.thresh_mult[i] * q / 100;
}
else
{
cpi->rd_threshes[i] = INT_MAX;
x->rd_threshes[i] = INT_MAX;
}
cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
cpi->rd_baseline_thresh[i] = x->rd_threshes[i];
}
}
else
@ -297,14 +297,14 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
{
if (cpi->sf.thresh_mult[i] < (INT_MAX / q))
{
cpi->rd_threshes[i] = cpi->sf.thresh_mult[i] * q;
x->rd_threshes[i] = cpi->sf.thresh_mult[i] * q;
}
else
{
cpi->rd_threshes[i] = INT_MAX;
x->rd_threshes[i] = INT_MAX;
}
cpi->rd_baseline_thresh[i] = cpi->rd_threshes[i];
cpi->rd_baseline_thresh[i] = x->rd_threshes[i];
}
}
@ -2022,7 +2022,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int this_ref_frame = ref_frame_map[vp8_ref_frame_order[mode_index]];
/* Test best rd so far against threshold for trying this mode. */
if (best_mode.rd <= cpi->rd_threshes[mode_index])
if (best_mode.rd <= x->rd_threshes[mode_index])
continue;
if (this_ref_frame < 0)
@ -2075,12 +2075,14 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Increase the threshold for coding this mode to make it
* less likely to be chosen
*/
cpi->rd_thresh_mult[mode_index] += 4;
x->rd_thresh_mult[mode_index] += 4;
if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
x->rd_thresh_mult[mode_index];
continue;
}
@ -2170,8 +2172,10 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
int this_rd_thresh;
int distortion;
this_rd_thresh = (vp8_ref_frame_order[mode_index] == 1) ? cpi->rd_threshes[THR_NEW1] : cpi->rd_threshes[THR_NEW3];
this_rd_thresh = (vp8_ref_frame_order[mode_index] == 2) ? cpi->rd_threshes[THR_NEW2] : this_rd_thresh;
this_rd_thresh = (vp8_ref_frame_order[mode_index] == 1) ?
x->rd_threshes[THR_NEW1] : x->rd_threshes[THR_NEW3];
this_rd_thresh = (vp8_ref_frame_order[mode_index] == 2) ?
x->rd_threshes[THR_NEW2] : this_rd_thresh;
tmp_rd = vp8_rd_pick_best_mbsegmentation(cpi, x, &best_ref_mv,
best_mode.yrd, mdcounts,
@ -2464,8 +2468,9 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Testing this mode gave rise to an improvement in best error
* score. Lower threshold a bit for next time
*/
cpi->rd_thresh_mult[mode_index] = (cpi->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ? cpi->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
x->rd_thresh_mult[mode_index] =
(x->rd_thresh_mult[mode_index] >= (MIN_THRESHMULT + 2)) ?
x->rd_thresh_mult[mode_index] - 2 : MIN_THRESHMULT;
}
/* If the mode did not help improve the best error case then raise
@ -2473,13 +2478,14 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
*/
else
{
cpi->rd_thresh_mult[mode_index] += 4;
x->rd_thresh_mult[mode_index] += 4;
if (cpi->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
cpi->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
cpi->rd_threshes[mode_index] = (cpi->rd_baseline_thresh[mode_index] >> 7) * cpi->rd_thresh_mult[mode_index];
if (x->rd_thresh_mult[mode_index] > MAX_THRESHMULT)
x->rd_thresh_mult[mode_index] = MAX_THRESHMULT;
}
x->rd_threshes[mode_index] =
(cpi->rd_baseline_thresh[mode_index] >> 7) *
x->rd_thresh_mult[mode_index];
if (x->skip)
break;
@ -2489,10 +2495,16 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
/* Reduce the activation RD thresholds for the best choice mode */
if ((cpi->rd_baseline_thresh[best_mode_index] > 0) && (cpi->rd_baseline_thresh[best_mode_index] < (INT_MAX >> 2)))
{
int best_adjustment = (cpi->rd_thresh_mult[best_mode_index] >> 2);
int best_adjustment = (x->rd_thresh_mult[best_mode_index] >> 2);
cpi->rd_thresh_mult[best_mode_index] = (cpi->rd_thresh_mult[best_mode_index] >= (MIN_THRESHMULT + best_adjustment)) ? cpi->rd_thresh_mult[best_mode_index] - best_adjustment : MIN_THRESHMULT;
cpi->rd_threshes[best_mode_index] = (cpi->rd_baseline_thresh[best_mode_index] >> 7) * cpi->rd_thresh_mult[best_mode_index];
x->rd_thresh_mult[best_mode_index] =
(x->rd_thresh_mult[best_mode_index] >=
(MIN_THRESHMULT + best_adjustment)) ?
x->rd_thresh_mult[best_mode_index] - best_adjustment :
MIN_THRESHMULT;
x->rd_threshes[best_mode_index] =
(cpi->rd_baseline_thresh[best_mode_index] >> 7) *
x->rd_thresh_mult[best_mode_index];
}
/* Note how often each mode chosen as best */

Просмотреть файл

@ -65,7 +65,7 @@ static void insertsortsad(int arr[],int idx[], int len)
}
}
extern void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue);
extern void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, 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(MACROBLOCK *x, int *rate);