From: Paul Wilkins Date: Fri, 18 Mar 2016 17:25:46 +0000 (-0700) Subject: Fix some HBD scaling bugs. X-Git-Tag: v1.6.0~278^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee35f4dede9bfe50f5461c8c5df6e6a041f98326;p=libvpx Fix some HBD scaling bugs. Fixed a bug for HBD in stats output and scaling of a threshold within the first pass code. Change-Id: Icd0463d78cc9ce4661b027b0612c55c0628d212f --- diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 6454ad65d..6fc642048 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -3090,7 +3090,27 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { #endif // CONFIG_VP9_HIGHBITDEPTH - if (cpi->twopass.total_left_stats.coded_error != 0.0) + if (cpi->twopass.total_left_stats.coded_error != 0.0) { + double dc_quant_devisor; +#if CONFIG_VP9_HIGHBITDEPTH + switch (cm->bit_depth) { + case VPX_BITS_8: + dc_quant_devisor = 4.0; + break; + case VPX_BITS_10: + dc_quant_devisor = 16.0; + break; + case VPX_BITS_12: + dc_quant_devisor = 64.0; + break; + default: + assert(0 && "bit_depth must be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); + break; + } +#else + dc_quant_devisor = 4.0; +#endif + fprintf(f, "%10u %dx%d %10d %10d %d %d %10d %10d %10d %10d" "%10"PRId64" %10"PRId64" %5d %5d %10"PRId64" " "%10"PRId64" %10"PRId64" %10d " @@ -3116,7 +3136,8 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { (cpi->rc.starting_buffer_level - cpi->rc.bits_off_target), cpi->rc.total_actual_bits, cm->base_qindex, vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth), - (double)vp9_dc_quant(cm->base_qindex, 0, cm->bit_depth) / 4.0, + (double)vp9_dc_quant(cm->base_qindex, 0, cm->bit_depth) / + dc_quant_devisor, vp9_convert_qindex_to_q(cpi->twopass.active_worst_quality, cm->bit_depth), cpi->rc.avg_q, @@ -3131,7 +3152,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { cpi->twopass.kf_zeromotion_pct, cpi->twopass.fr_content_type, cm->lf.filter_level); - + } fclose(f); if (0) { diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 9d3b15407..10fd6c02c 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -490,7 +490,35 @@ static void set_first_pass_params(VP9_COMP *cpi) { cpi->rc.frames_to_key = INT_MAX; } +// This threshold is used to track blocks where to all intents and purposes +// the intra prediction error 0. Though the metric we test against +// is technically a sse we are mainly interested in blocks where all the pixels +// int he 8 bit domain have an error of <= 1 (where error = sse) so a +// linear scaling for 10 and 12 bit gives similar results. #define UL_INTRA_THRESH 50 +#if CONFIG_VP9_HIGHBITDEPTH +static int get_ul_intra_threshold(VP9_COMMON *cm) { + int ret_val = UL_INTRA_THRESH; + if (cm->use_highbitdepth) { + switch (cm->bit_depth) { + case VPX_BITS_8: + ret_val = UL_INTRA_THRESH; + break; + case VPX_BITS_10: + ret_val = UL_INTRA_THRESH >> 2; + break; + case VPX_BITS_12: + ret_val = UL_INTRA_THRESH >> 4; + break; + default: + assert(0 && "cm->bit_depth should be VPX_BITS_8, " + "VPX_BITS_10 or VPX_BITS_12"); + } + } + return ret_val; +} +#endif // CONFIG_VP9_HIGHBITDEPTH + #define INVALID_ROW -1 void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { int mb_row, mb_col; @@ -681,7 +709,11 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { // domain). In natural videos this is uncommon, but it is much more // common in animations, graphics and screen content, so may be used // as a signal to detect these types of content. +#if CONFIG_VP9_HIGHBITDEPTH + if (this_error < get_ul_intra_threshold(cm)) { +#else if (this_error < UL_INTRA_THRESH) { +#endif ++intra_skip_count; } else if ((mb_col > 0) && (image_data_start_row == INVALID_ROW)) { image_data_start_row = mb_row;