From ee28bb87b47094abb9cb7549d5a14f3cdf0955d3 Mon Sep 17 00:00:00 2001 From: Scott LaVarnway Date: Mon, 5 Nov 2012 17:30:49 -0800 Subject: [PATCH] Moving _error counts to macroblock struct Change-Id: I28ac1519d1594801fef9a623cb64598d3d751eb0 --- vp8/encoder/block.h | 4 ++-- vp8/encoder/encodeframe.c | 12 ++++++++---- vp8/encoder/ethreading.c | 2 ++ vp8/encoder/onyx_if.c | 37 ++++++++----------------------------- vp8/encoder/onyx_int.h | 2 -- 5 files changed, 20 insertions(+), 37 deletions(-) diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index d5496a7e2..f9d63eb50 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -130,10 +130,10 @@ typedef struct macroblock int skip_true_count; unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */ - int ymode_count [VP8_YMODES]; /* intra MB type cts this frame */ int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */ - + int64_t prediction_error; + int64_t intra_error; void (*short_fdct4x4)(short *input, short *output, int pitch); diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c index 6364f7d7e..732b77b66 100644 --- a/vp8/encoder/encodeframe.c +++ b/vp8/encoder/encodeframe.c @@ -676,6 +676,8 @@ static void init_encode_frame_mb_context(VP8_COMP *cpi) vp8_zero(x->coef_counts); vp8_zero(x->ymode_count); vp8_zero(x->uv_mode_count) + x->prediction_error = 0; + x->intra_error = 0; } static void sum_coef_counts(MACROBLOCK *x, MACROBLOCK *x_thread) @@ -749,8 +751,6 @@ void vp8_encode_frame(VP8_COMP *cpi) xd->subpixel_predict16x16 = vp8_bilinear_predict16x16; } - cpi->prediction_error = 0; - cpi->intra_error = 0; cpi->mb.skip_true_count = 0; cpi->tok_count = 0; @@ -889,6 +889,10 @@ void vp8_encode_frame(VP8_COMP *cpi) cpi->mb_row_ei[i].mb.MVcount[1][mv_vals]; } + cpi->mb.prediction_error += + cpi->mb_row_ei[i].mb.prediction_error; + cpi->mb.intra_error += cpi->mb_row_ei[i].mb.intra_error; + /* add up counts for each thread */ sum_coef_counts(x, &cpi->mb_row_ei[i].mb); } @@ -1252,8 +1256,8 @@ int vp8cx_encode_inter_macroblock &distortion, &intra_error, mb_row, mb_col); } - cpi->prediction_error += distortion; - cpi->intra_error += intra_error; + x->prediction_error += distortion; + x->intra_error += intra_error; if(cpi->oxcf.tuning == VP8_TUNE_SSIM) { diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index 81fbe52c7..39340f236 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -476,6 +476,8 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi, vp8_zero(x->ymode_count); mb->skip_true_count = 0; vp8_zero(mb->MVcount); + mb->prediction_error = 0; + mb->intra_error = 0; } } diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 4235662f1..4e2cd0ff7 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -2864,38 +2864,17 @@ static int decide_key_frame(VP8_COMP *cpi) if ((cpi->compressor_speed == 2) && (cpi->Speed >= 5) && (cpi->sf.RD == 0)) { - double change = 1.0 * abs((int)(cpi->intra_error - cpi->last_intra_error)) / (1 + cpi->last_intra_error); - double change2 = 1.0 * abs((int)(cpi->prediction_error - cpi->last_prediction_error)) / (1 + cpi->last_prediction_error); + double change = 1.0 * abs((int)(cpi->mb.intra_error - + cpi->last_intra_error)) / (1 + cpi->last_intra_error); + double change2 = 1.0 * abs((int)(cpi->mb.prediction_error - + cpi->last_prediction_error)) / (1 + cpi->last_prediction_error); double minerror = cm->MBs * 256; -#if 0 - - if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15 - && cpi->prediction_error > minerror - && (change > .25 || change2 > .25)) - { - FILE *f = fopen("intra_inter.stt", "a"); - - if (cpi->prediction_error <= 0) - cpi->prediction_error = 1; - - fprintf(f, "%d %d %d %d %14.4f\n", - cm->current_video_frame, - (int) cpi->prediction_error, - (int) cpi->intra_error, - (int)((10 * cpi->intra_error) / cpi->prediction_error), - change); - - fclose(f); - } - -#endif - - cpi->last_intra_error = cpi->intra_error; - cpi->last_prediction_error = cpi->prediction_error; + cpi->last_intra_error = cpi->mb.intra_error; + cpi->last_prediction_error = cpi->mb.prediction_error; - if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15 - && cpi->prediction_error > minerror + if (10 * cpi->mb.intra_error / (1 + cpi->mb.prediction_error) < 15 + && cpi->mb.prediction_error > minerror && (change > .25 || change2 > .25)) { /*(change > 1.4 || change < .75)&& cpi->this_frame_percent_intra > cpi->last_frame_percent_intra + 3*/ diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index 395287dbf..5cff899ac 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -363,9 +363,7 @@ typedef struct VP8_COMP CODING_CONTEXT coding_context; /* Rate targetting variables */ - int64_t prediction_error; int64_t last_prediction_error; - int64_t intra_error; int64_t last_intra_error; int this_frame_target; -- 2.40.0