diff options
author | Scott LaVarnway <slavarnway@google.com> | 2012-12-03 12:05:48 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2012-12-03 12:05:48 -0800 |
commit | 9961ad479a475fb035bfc3c46059abe0436ed57b (patch) | |
tree | 7d98d25ba1eae4632970b6109d7102eca621505f /vp8 | |
parent | 7891fb5eda2b086060cf71ff76ddea6aaa8acc1c (diff) | |
parent | fe91e47bc781be9e5085137dc34b09d3358963a7 (diff) | |
download | libvpx-9961ad479a475fb035bfc3c46059abe0436ed57b.tar libvpx-9961ad479a475fb035bfc3c46059abe0436ed57b.tar.gz libvpx-9961ad479a475fb035bfc3c46059abe0436ed57b.tar.bz2 libvpx-9961ad479a475fb035bfc3c46059abe0436ed57b.zip |
Merge "Moving rd_thresh_mult, rd_threshes to macroblock struct"
Diffstat (limited to 'vp8')
-rw-r--r-- | vp8/encoder/block.h | 5 | ||||
-rw-r--r-- | vp8/encoder/encodeframe.c | 6 | ||||
-rw-r--r-- | vp8/encoder/ethreading.c | 7 | ||||
-rw-r--r-- | vp8/encoder/firstpass.c | 2 | ||||
-rw-r--r-- | vp8/encoder/onyx_if.c | 4 | ||||
-rw-r--r-- | vp8/encoder/onyx_int.h | 4 | ||||
-rw-r--r-- | vp8/encoder/pickinter.c | 44 | ||||
-rw-r--r-- | vp8/encoder/rdopt.c | 62 | ||||
-rw-r--r-- | vp8/encoder/rdopt.h | 2 |
9 files changed, 77 insertions, 59 deletions
diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index c01b606a9..f70498150 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -18,6 +18,8 @@ #include "vp8/common/entropy.h" #include "vpx_ports/mem.h" +#define MAX_MODES 20 + /* motion search site */ typedef struct { @@ -136,6 +138,9 @@ typedef struct macroblock int64_t intra_error; int count_mb_ref_frame_usage[MAX_REF_FRAMES]; + 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); diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index 1a234ca29..d91f1c696 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -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 ); @@ -765,7 +764,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); @@ -804,7 +803,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; diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index 021b3b094..24516deae 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -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++) { diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index b668c8f3b..30bf8a6ef 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -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); } diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 8947c4f12..f84bdc910 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -1924,7 +1924,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 @@ -3385,7 +3385,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; } } diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index 2918e28bf..0035a6105 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -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 ; diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 3f09a9f19..e4574f298 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -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]; } diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 7d806067f..15055f046 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -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); - - 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]; + int best_adjustment = (x->rd_thresh_mult[best_mode_index] >> 2); + + 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 */ diff --git a/vp8/encoder/rdopt.h b/vp8/encoder/rdopt.h index d7b044253..1e11fa77d 100644 --- a/vp8/encoder/rdopt.h +++ b/vp8/encoder/rdopt.h @@ -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); |