From 98d4f09a7ab7cf06e96aa883f21cbb3e4b5f88e3 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Thu, 23 Apr 2015 10:26:57 -0700 Subject: [PATCH] Replace vp9_get_bit_depth with vp9_ceil_log2. The current name is confusing with regard to high bit depth buffers. Change-Id: Ieacd55ec22c81bd2f013f2e3d73a095affc93689 --- vp9/common/vp9_palette.c | 2 +- vp9/common/vp9_palette.h | 2 +- vp9/decoder/vp9_decodemv.c | 10 +++++----- vp9/encoder/vp9_bitstream.c | 10 +++++----- vp9/encoder/vp9_rdopt.c | 12 ++++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/vp9/common/vp9_palette.c b/vp9/common/vp9_palette.c index 317baa069..e09c271d8 100644 --- a/vp9/common/vp9_palette.c +++ b/vp9/common/vp9_palette.c @@ -131,7 +131,7 @@ int vp9_palette_color_lookup(uint8_t *dic, int n, uint8_t val, int bits) { return -1; } -int vp9_get_bit_depth(int n) { +int vp9_ceil_log2(int n) { int i = 1, p = 2; while (p < n) { i++; diff --git a/vp9/common/vp9_palette.h b/vp9/common/vp9_palette.h index 6970ddda8..3edc81ce4 100644 --- a/vp9/common/vp9_palette.h +++ b/vp9/common/vp9_palette.h @@ -20,7 +20,7 @@ void vp9_insertion_sort(double *data, int n); void vp9_palette_color_insertion(uint8_t *old_colors, int *m, int *count, MB_MODE_INFO *mbmi); int vp9_palette_color_lookup(uint8_t *dic, int n, uint8_t val, int bits); -int vp9_get_bit_depth(int n); +int vp9_ceil_log2(int n); int vp9_k_means(double *data, double *centroids, int *indices, int n, int k, int dim, int max_itr); void vp9_calc_indices(double *data, double *centroids, int *indices, diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 1094212ac..0d08fc447 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -311,7 +311,7 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm, if (m1 > 0) { for (i = 0; i < m1; i++) mbmi->palette_indexed_colors[i] = - vp9_read_literal(r, vp9_get_bit_depth(cm->current_palette_size)); + vp9_read_literal(r, vp9_ceil_log2(cm->current_palette_size)); if (mbmi->palette_delta_bitdepth > 0) { int s; for (i = 0; i < m1; i++) { @@ -343,7 +343,7 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm, cm->current_palette_count, mbmi); color_map[0] = vp9_read_literal(r, - vp9_get_bit_depth(mbmi->palette_size[0])); + vp9_ceil_log2(mbmi->palette_size[0])); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, @@ -387,7 +387,7 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm, int color_order[PALETTE_MAX_SIZE]; uint8_t *color_map = xd->plane[1].color_index_map; - color_map[0] = vp9_read_literal(r, vp9_get_bit_depth(n)); + color_map[0] = vp9_read_literal(r, vp9_ceil_log2(n)); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, @@ -1386,7 +1386,7 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm, mbmi->palette_colors[i] = vp9_read_literal(r, 8); color_map[0] = vp9_read_literal(r, - vp9_get_bit_depth(mbmi->palette_size[0])); + vp9_ceil_log2(mbmi->palette_size[0])); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, @@ -1435,7 +1435,7 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm, int color_order[PALETTE_MAX_SIZE]; uint8_t *color_map = xd->plane[1].color_index_map; - color_map[0] = vp9_read_literal(r, vp9_get_bit_depth(n)); + color_map[0] = vp9_read_literal(r, vp9_ceil_log2(n)); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 1d5fb43af..fd1e71eab 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -494,7 +494,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi, memcpy(buffer, mbmi->palette_color_map, rows * cols * sizeof(buffer[0])); - vp9_write_literal(w, buffer[0], vp9_get_bit_depth(n)); + vp9_write_literal(w, buffer[0], vp9_ceil_log2(n)); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(buffer, cols, i, j, n, @@ -532,7 +532,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi, if (xd->plane[1].subsampling_x && xd->plane[1].subsampling_y) { memcpy(buffer, mbmi->palette_uv_color_map, rows * cols * sizeof(buffer[0])); - vp9_write_literal(w, buffer[0], vp9_get_bit_depth(n)); + vp9_write_literal(w, buffer[0], vp9_ceil_log2(n)); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(buffer, cols, i, j, n, @@ -916,7 +916,7 @@ static void write_mb_modes_kf(const VP9_COMMON *cm, if (m1 > 0) { for (i = 0; i < m1; i++) vp9_write_literal(w, mbmi->palette_indexed_colors[i], - vp9_get_bit_depth(mbmi->current_palette_size)); + vp9_ceil_log2(mbmi->current_palette_size)); if (mbmi->palette_delta_bitdepth > 0) { for (i = 0; i < m1; i++) { vp9_write_bit(w, mbmi->palette_color_delta[i] < 0); @@ -932,7 +932,7 @@ static void write_mb_modes_kf(const VP9_COMMON *cm, memcpy(buffer, mbmi->palette_color_map, rows * cols * sizeof(buffer[0])); - vp9_write_literal(w, buffer[0], vp9_get_bit_depth(n)); + vp9_write_literal(w, buffer[0], vp9_ceil_log2(n)); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(buffer, cols, i, j, n, @@ -970,7 +970,7 @@ static void write_mb_modes_kf(const VP9_COMMON *cm, if (xd->plane[1].subsampling_x && xd->plane[1].subsampling_y) { memcpy(buffer, mbmi->palette_uv_color_map, rows * cols * sizeof(buffer[0])); - vp9_write_literal(w, buffer[0], vp9_get_bit_depth(n)); + vp9_write_literal(w, buffer[0], vp9_ceil_log2(n)); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(buffer, cols, i, j, n, diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index d447899e5..c2332593a 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -1932,7 +1932,7 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x, m2++; } } - total_bits = m1 * vp9_get_bit_depth(cpi->common.current_palette_size) + + total_bits = m1 * vp9_ceil_log2(cpi->common.current_palette_size) + m1 * (bits == 0 ? 0 : bits + 1) + m2 * 8; if (total_bits <= best_total_bits) { best_total_bits = total_bits; @@ -2020,11 +2020,11 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x, this_rate = this_rate_tokenonly + (1 + vp9_encode_uniform_cost(MIN(k + 1, 8), m1) + PALETTE_DELTA_BIT - + vp9_get_bit_depth(mic->mbmi.current_palette_size) * m1 + + + vp9_ceil_log2(mic->mbmi.current_palette_size) * m1 + best_bits * m1 + 8 * m2) * vp9_cost_bit(128, 0) + palette_size_cost[k - 2]; color_map = xd->plane[0].color_index_map; - this_rate += vp9_get_bit_depth(k) * vp9_cost_bit(128, 0); + this_rate += vp9_ceil_log2(k) * vp9_cost_bit(128, 0); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, @@ -2539,7 +2539,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x, this_rate = this_rate_tokenonly + (1 + 2 * 8 * n) * vp9_cost_bit(128, 0) + palette_size_cost[n - 2]; - this_rate += vp9_get_bit_depth(n) * vp9_cost_bit(128, 0); + this_rate += vp9_ceil_log2(n) * vp9_cost_bit(128, 0); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, @@ -5571,7 +5571,7 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, (1 + PALETTE_DELTA_BIT + n * m2) * vp9_cost_bit(128, 0) + palette_size_cost[n - 2]; color_map = xd->plane[0].color_index_map; - rate_y += vp9_get_bit_depth(n) * vp9_cost_bit(128, 0); + rate_y += vp9_ceil_log2(n) * vp9_cost_bit(128, 0); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { @@ -7110,7 +7110,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, vp9_cost_bit(cm->fc.palette_enabled_prob [bsize - BLOCK_8X8][palette_ctx], 1); color_map = xd->plane[0].color_index_map; - total_rate_y += vp9_get_bit_depth(k) * vp9_cost_bit(128, 0); + total_rate_y += vp9_ceil_log2(k) * vp9_cost_bit(128, 0); for (i = 0; i < rows; i++) { for (j = (i == 0 ? 1 : 0); j < cols; j++) { color_ctx = vp9_get_palette_color_context(color_map, cols, i, j, n, -- 2.49.0