aboutsummaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorLinfeng Zhang <linfengz@google.com>2018-05-01 17:57:51 -0700
committerLinfeng Zhang <linfengz@google.com>2018-05-01 17:57:51 -0700
commit28c563a11c4c1b429ce464eb8076282da641e21e (patch)
treeae3c019af960041aff3f8503e82def0f5f6db56a /vp9
parente4408a07bea94740f5fc1cd05e62aa2dda5f57ff (diff)
downloadlibvpx-28c563a11c4c1b429ce464eb8076282da641e21e.tar.gz
Clean switch cases in vp9 encoder
To save a branch. Change-Id: Ifa2be7583e95c6991784731c654bbd4cce31e993
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_bitstream.c14
-rw-r--r--vp9/encoder/vp9_encodeframe.c55
-rw-r--r--vp9/encoder/vp9_encodemb.c40
-rw-r--r--vp9/encoder/vp9_encoder.c22
-rw-r--r--vp9/encoder/vp9_firstpass.c34
-rw-r--r--vp9/encoder/vp9_mcomp.c4
-rw-r--r--vp9/encoder/vp9_picklpf.c8
-rw-r--r--vp9/encoder/vp9_pickmode.c4
-rw-r--r--vp9/encoder/vp9_quantize.c5
-rw-r--r--vp9/encoder/vp9_ratectrl.c27
-rw-r--r--vp9/encoder/vp9_rd.c21
-rw-r--r--vp9/encoder/vp9_rdopt.c12
12 files changed, 109 insertions, 137 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index abc705363..4e7d99f50 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -459,7 +459,8 @@ static void write_modes_sb(
write_modes_b(cpi, xd, tile, w, tok, tok_end, mi_row, mi_col + bs,
max_mv_magnitude, interp_filter_selected);
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
write_modes_sb(cpi, xd, tile, w, tok, tok_end, mi_row, mi_col, subsize,
max_mv_magnitude, interp_filter_selected);
write_modes_sb(cpi, xd, tile, w, tok, tok_end, mi_row, mi_col + bs,
@@ -469,7 +470,6 @@ static void write_modes_sb(
write_modes_sb(cpi, xd, tile, w, tok, tok_end, mi_row + bs, mi_col + bs,
subsize, max_mv_magnitude, interp_filter_selected);
break;
- default: assert(0);
}
}
@@ -618,9 +618,10 @@ static void update_coef_probs_common(vpx_writer *const bc, VP9_COMP *cpi,
return;
}
- case ONE_LOOP_REDUCED: {
+ default: {
int updates = 0;
int noupdates_before_first = 0;
+ assert(cpi->sf.use_fast_coef_updates == ONE_LOOP_REDUCED);
for (i = 0; i < PLANE_TYPES; ++i) {
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
@@ -670,7 +671,6 @@ static void update_coef_probs_common(vpx_writer *const bc, VP9_COMP *cpi,
}
return;
}
- default: assert(0);
}
}
@@ -1149,8 +1149,10 @@ static void write_profile(BITSTREAM_PROFILE profile,
case PROFILE_0: vpx_wb_write_literal(wb, 0, 2); break;
case PROFILE_1: vpx_wb_write_literal(wb, 2, 2); break;
case PROFILE_2: vpx_wb_write_literal(wb, 1, 2); break;
- case PROFILE_3: vpx_wb_write_literal(wb, 6, 3); break;
- default: assert(0);
+ default:
+ assert(profile == PROFILE_3);
+ vpx_wb_write_literal(wb, 6, 3);
+ break;
}
}
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index fa93c1630..091992dbd 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -385,16 +385,13 @@ static void tree_to_node(void *data, BLOCK_SIZE bsize, variance_node *node) {
node->split[i] = &vt->split[i].part_variances.none;
break;
}
- case BLOCK_4X4: {
+ default: {
v4x4 *vt = (v4x4 *)data;
+ assert(bsize == BLOCK_4X4);
node->part_variances = &vt->part_variances;
for (i = 0; i < 4; i++) node->split[i] = &vt->split[i];
break;
}
- default: {
- assert(0);
- break;
- }
}
}
@@ -885,13 +882,13 @@ static void copy_partitioning_helper(VP9_COMP *cpi, MACROBLOCK *x,
set_block_size(cpi, x, xd, mi_row, mi_col, subsize);
set_block_size(cpi, x, xd, mi_row, mi_col + bs, subsize);
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
copy_partitioning_helper(cpi, x, xd, subsize, mi_row, mi_col);
copy_partitioning_helper(cpi, x, xd, subsize, mi_row + bs, mi_col);
copy_partitioning_helper(cpi, x, xd, subsize, mi_row, mi_col + bs);
copy_partitioning_helper(cpi, x, xd, subsize, mi_row + bs, mi_col + bs);
break;
- default: assert(0);
}
}
}
@@ -1004,7 +1001,8 @@ static int scale_partitioning_svc(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
set_block_size(cpi, x, xd, mi_row_high, mi_col_high + bs_high,
subsize_high);
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition_high == PARTITION_SPLIT);
if (scale_partitioning_svc(cpi, x, xd, subsize_high, mi_row, mi_col,
mi_row_high, mi_col_high))
return 1;
@@ -1020,7 +1018,6 @@ static int scale_partitioning_svc(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
mi_col_high + bs_high))
return 1;
break;
- default: assert(0);
}
}
@@ -1067,13 +1064,13 @@ static void update_partition_svc(VP9_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
prev_part[start_pos] = subsize;
if (mi_col + bs < cm->mi_cols) prev_part[start_pos + bs] = subsize;
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
update_partition_svc(cpi, subsize, mi_row, mi_col);
update_partition_svc(cpi, subsize, mi_row + bs, mi_col);
update_partition_svc(cpi, subsize, mi_row, mi_col + bs);
update_partition_svc(cpi, subsize, mi_row + bs, mi_col + bs);
break;
- default: assert(0);
}
}
}
@@ -1108,13 +1105,13 @@ static void update_prev_partition_helper(VP9_COMP *cpi, BLOCK_SIZE bsize,
prev_part[start_pos] = subsize;
if (mi_col + bs < cm->mi_cols) prev_part[start_pos + bs] = subsize;
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
update_prev_partition_helper(cpi, subsize, mi_row, mi_col);
update_prev_partition_helper(cpi, subsize, mi_row + bs, mi_col);
update_prev_partition_helper(cpi, subsize, mi_row, mi_col + bs);
update_prev_partition_helper(cpi, subsize, mi_row + bs, mi_col + bs);
break;
- default: assert(0);
}
}
}
@@ -2183,7 +2180,8 @@ static void encode_sb(VP9_COMP *cpi, ThreadData *td, const TileInfo *const tile,
subsize, &pc_tree->horizontal[1]);
}
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
if (bsize == BLOCK_8X8) {
encode_b(cpi, tile, td, tp, mi_row, mi_col, output_enabled, subsize,
pc_tree->leaf_split[0]);
@@ -2198,7 +2196,6 @@ static void encode_sb(VP9_COMP *cpi, ThreadData *td, const TileInfo *const tile,
subsize, pc_tree->split[3]);
}
break;
- default: assert(0 && "Invalid partition type."); break;
}
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
@@ -2524,7 +2521,8 @@ static void encode_sb_rt(VP9_COMP *cpi, ThreadData *td,
subsize, &pc_tree->horizontal[1]);
}
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
subsize = get_subsize(bsize, PARTITION_SPLIT);
encode_sb_rt(cpi, td, tile, tp, mi_row, mi_col, output_enabled, subsize,
pc_tree->split[0]);
@@ -2535,7 +2533,6 @@ static void encode_sb_rt(VP9_COMP *cpi, ThreadData *td,
encode_sb_rt(cpi, td, tile, tp, mi_row + hbs, mi_col + hbs,
output_enabled, subsize, pc_tree->split[3]);
break;
- default: assert(0 && "Invalid partition type."); break;
}
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
@@ -2674,7 +2671,8 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
last_part_rdc.rdcost += tmp_rdc.rdcost;
}
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
if (bsize == BLOCK_8X8) {
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &last_part_rdc,
subsize, pc_tree->leaf_split[0], INT64_MAX);
@@ -2704,7 +2702,6 @@ static void rd_use_partition(VP9_COMP *cpi, ThreadData *td,
last_part_rdc.dist += tmp_rdc.dist;
}
break;
- default: assert(0); break;
}
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
@@ -4210,7 +4207,8 @@ static void nonrd_select_partition(VP9_COMP *cpi, ThreadData *td,
}
}
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
subsize = get_subsize(bsize, PARTITION_SPLIT);
nonrd_select_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
subsize, output_enabled, rd_cost,
@@ -4240,7 +4238,6 @@ static void nonrd_select_partition(VP9_COMP *cpi, ThreadData *td,
rd_cost->dist += this_rdc.dist;
}
break;
- default: assert(0 && "Invalid partition type."); break;
}
}
@@ -4329,7 +4326,8 @@ static void nonrd_use_partition(VP9_COMP *cpi, ThreadData *td,
output_enabled, subsize, &pc_tree->horizontal[1]);
}
break;
- case PARTITION_SPLIT:
+ default:
+ assert(partition == PARTITION_SPLIT);
subsize = get_subsize(bsize, PARTITION_SPLIT);
if (bsize == BLOCK_8X8) {
nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost,
@@ -4350,7 +4348,6 @@ static void nonrd_use_partition(VP9_COMP *cpi, ThreadData *td,
dummy_cost, pc_tree->split[3]);
}
break;
- default: assert(0 && "Invalid partition type."); break;
}
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
@@ -4454,7 +4451,8 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
nonrd_use_partition(cpi, td, tile_data, mi, tp, mi_row, mi_col,
BLOCK_64X64, 1, &dummy_rdc, td->pc_root);
break;
- case REFERENCE_PARTITION:
+ default:
+ assert(partition_search_type == REFERENCE_PARTITION);
x->sb_pickmode_part = 1;
set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64);
// Use nonrd_pick_partition on scene-cut for VBR mode.
@@ -4486,7 +4484,6 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
}
break;
- default: assert(0); break;
}
// Update ref_frame usage for inter frame if this group is ARF group.
@@ -4553,16 +4550,12 @@ static int set_var_thresh_from_histogram(VP9_COMP *cpi) {
&var16->sse, &var16->sum);
var16->var = variance_highbd(var16);
break;
- case VPX_BITS_12:
+ default:
+ assert(cm->bit_depth == VPX_BITS_12);
vpx_highbd_12_get16x16var(src, src_stride, last_src, last_stride,
&var16->sse, &var16->sum);
var16->var = variance_highbd(var16);
break;
- default:
- assert(0 &&
- "cm->bit_depth should be VPX_BITS_8, VPX_BITS_10"
- " or VPX_BITS_12");
- return -1;
}
} else {
vpx_get16x16var(src, src_stride, last_src, last_stride, &var16->sse,
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 970077d89..bc2765728 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -358,13 +358,13 @@ void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block, int row, int col,
p->quant_fp, qcoeff, dqcoeff, pd->dequant, eob,
scan_order->scan, scan_order->iscan);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vp9_highbd_quantize_fp(coeff, 16, x->skip_block, p->round_fp,
p->quant_fp, qcoeff, dqcoeff, pd->dequant, eob,
scan_order->scan, scan_order->iscan);
break;
- default: assert(0);
}
return;
}
@@ -388,13 +388,13 @@ void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block, int row, int col,
p->round_fp, p->quant_fp, qcoeff, dqcoeff, pd->dequant,
eob, scan_order->scan, scan_order->iscan);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vp9_quantize_fp(coeff, 16, x->skip_block, p->round_fp, p->quant_fp,
qcoeff, dqcoeff, pd->dequant, eob, scan_order->scan,
scan_order->iscan);
break;
- default: assert(0); break;
}
}
@@ -434,13 +434,13 @@ void vp9_xform_quant_dc(MACROBLOCK *x, int plane, int block, int row, int col,
p->quant_fp[0], qcoeff, dqcoeff, pd->dequant[0],
eob);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vpx_highbd_quantize_dc(coeff, 16, x->skip_block, p->round,
p->quant_fp[0], qcoeff, dqcoeff, pd->dequant[0],
eob);
break;
- default: assert(0);
}
return;
}
@@ -462,12 +462,12 @@ void vp9_xform_quant_dc(MACROBLOCK *x, int plane, int block, int row, int col,
vpx_quantize_dc(coeff, 64, x->skip_block, p->round, p->quant_fp[0],
qcoeff, dqcoeff, pd->dequant[0], eob);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vpx_quantize_dc(coeff, 16, x->skip_block, p->round, p->quant_fp[0],
qcoeff, dqcoeff, pd->dequant[0], eob);
break;
- default: assert(0); break;
}
}
@@ -511,14 +511,14 @@ void vp9_xform_quant(MACROBLOCK *x, int plane, int block, int row, int col,
pd->dequant, eob, scan_order->scan,
scan_order->iscan);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vpx_highbd_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
p->quant, p->quant_shift, qcoeff, dqcoeff,
pd->dequant, eob, scan_order->scan,
scan_order->iscan);
break;
- default: assert(0);
}
return;
}
@@ -544,13 +544,13 @@ void vp9_xform_quant(MACROBLOCK *x, int plane, int block, int row, int col,
p->quant_shift, qcoeff, dqcoeff, pd->dequant, eob,
scan_order->scan, scan_order->iscan);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vpx_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, p->quant,
p->quant_shift, qcoeff, dqcoeff, pd->dequant, eob,
scan_order->scan, scan_order->iscan);
break;
- default: assert(0); break;
}
}
@@ -634,14 +634,14 @@ static void encode_block(int plane, int block, int row, int col,
vp9_highbd_idct8x8_add(dqcoeff, dst16, pd->dst.stride, p->eobs[block],
xd->bd);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
// this is like vp9_short_idct4x4 but has a special case around eob<=1
// which is significant (not just an optimization) for the lossless
// case.
x->highbd_inv_txfm_add(dqcoeff, dst16, pd->dst.stride, p->eobs[block],
xd->bd);
break;
- default: assert(0 && "Invalid transform size");
}
return;
}
@@ -657,13 +657,13 @@ static void encode_block(int plane, int block, int row, int col,
case TX_8X8:
vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
// this is like vp9_short_idct4x4 but has a special case around eob<=1
// which is significant (not just an optimization) for the lossless
// case.
x->inv_txfm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
break;
- default: assert(0 && "Invalid transform size"); break;
}
}
@@ -848,7 +848,8 @@ void vp9_encode_block_intra(int plane, int block, int row, int col,
xd->bd);
}
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
if (!x->skip_recode) {
vpx_highbd_subtract_block(4, 4, src_diff, diff_stride, src,
src_stride, dst, dst_stride, xd->bd);
@@ -876,7 +877,6 @@ void vp9_encode_block_intra(int plane, int block, int row, int col,
}
}
break;
- default: assert(0); return;
}
if (*eob) *(args->skip) = 0;
return;
@@ -930,7 +930,8 @@ void vp9_encode_block_intra(int plane, int block, int row, int col,
if (!x->skip_encode && *eob)
vp9_iht8x8_add(tx_type, dqcoeff, dst, dst_stride, *eob);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
if (!x->skip_recode) {
vpx_subtract_block(4, 4, src_diff, diff_stride, src, src_stride, dst,
dst_stride);
@@ -955,7 +956,6 @@ void vp9_encode_block_intra(int plane, int block, int row, int col,
vp9_iht4x4_16_add(dqcoeff, dst, dst_stride, tx_type);
}
break;
- default: assert(0); break;
}
if (*eob) *(args->skip) = 0;
}
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index a936b0759..b95eb6c59 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -483,14 +483,10 @@ static INLINE void Scale2Ratio(VPX_SCALING mode, int *hr, int *hs) {
*hr = 3;
*hs = 5;
break;
- case ONETWO:
- *hr = 1;
- *hs = 2;
- break;
default:
+ assert(mode == ONETWO);
*hr = 1;
- *hs = 1;
- assert(0);
+ *hs = 2;
break;
}
}
@@ -1726,7 +1722,8 @@ static void highbd_set_var_fns(VP9_COMP *const cpi) {
vpx_highbd_sad4x4x4d_bits10)
break;
- case VPX_BITS_12:
+ default:
+ assert(cm->bit_depth == VPX_BITS_12);
HIGHBD_BFP(BLOCK_32X16, vpx_highbd_sad32x16_bits12,
vpx_highbd_sad32x16_avg_bits12, vpx_highbd_12_variance32x16,
vpx_highbd_12_sub_pixel_variance32x16,
@@ -1805,11 +1802,6 @@ static void highbd_set_var_fns(VP9_COMP *const cpi) {
vpx_highbd_12_sub_pixel_avg_variance4x4,
vpx_highbd_sad4x4x4d_bits12)
break;
-
- default:
- assert(0 &&
- "cm->bit_depth should be VPX_BITS_8, "
- "VPX_BITS_10 or VPX_BITS_12");
}
}
}
@@ -3286,11 +3278,9 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
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");
+ assert(cm->bit_depth == VPX_BITS_12);
+ dc_quant_devisor = 64.0;
break;
}
#else
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 3302fde08..c243a13a4 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -494,11 +494,10 @@ static int scale_sse_threshold(VP9_COMMON *cm, int thresh) {
switch (cm->bit_depth) {
case VPX_BITS_8: ret_val = thresh; break;
case VPX_BITS_10: ret_val = thresh << 4; break;
- case VPX_BITS_12: ret_val = thresh << 8; break;
default:
- assert(0 &&
- "cm->bit_depth should be VPX_BITS_8, "
- "VPX_BITS_10 or VPX_BITS_12");
+ assert(cm->bit_depth == VPX_BITS_12);
+ ret_val = thresh << 8;
+ break;
}
}
#else
@@ -520,11 +519,10 @@ static int get_ul_intra_threshold(VP9_COMMON *cm) {
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");
+ assert(cm->bit_depth == VPX_BITS_12);
+ ret_val = UL_INTRA_THRESH << 4;
+ break;
}
}
#else
@@ -541,11 +539,10 @@ static int get_smooth_intra_threshold(VP9_COMMON *cm) {
switch (cm->bit_depth) {
case VPX_BITS_8: ret_val = SMOOTH_INTRA_THRESH; break;
case VPX_BITS_10: ret_val = SMOOTH_INTRA_THRESH << 4; break;
- case VPX_BITS_12: ret_val = SMOOTH_INTRA_THRESH << 8; break;
default:
- assert(0 &&
- "cm->bit_depth should be VPX_BITS_8, "
- "VPX_BITS_10 or VPX_BITS_12");
+ assert(cm->bit_depth == VPX_BITS_12);
+ ret_val = SMOOTH_INTRA_THRESH << 8;
+ break;
}
}
#else
@@ -971,12 +968,10 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td,
switch (cm->bit_depth) {
case VPX_BITS_8: break;
case VPX_BITS_10: this_error >>= 4; break;
- case VPX_BITS_12: this_error >>= 8; break;
default:
- assert(0 &&
- "cm->bit_depth should be VPX_BITS_8, "
- "VPX_BITS_10 or VPX_BITS_12");
- return;
+ assert(cm->bit_depth == VPX_BITS_12);
+ this_error >>= 8;
+ break;
}
}
#endif // CONFIG_VP9_HIGHBITDEPTH
@@ -3025,12 +3020,13 @@ static void configure_buffer_updates(VP9_COMP *cpi) {
cpi->refresh_alt_ref_frame = 0;
cpi->rc.is_src_frame_alt_ref = 1;
break;
- case ARF_UPDATE:
+ default:
+ assert(twopass->gf_group.update_type[twopass->gf_group.index] ==
+ ARF_UPDATE);
cpi->refresh_last_frame = 0;
cpi->refresh_golden_frame = 0;
cpi->refresh_alt_ref_frame = 1;
break;
- default: assert(0); break;
}
}
diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c
index b42e4c4ea..ba72c0be5 100644
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -2215,7 +2215,8 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
var = bigdia_search(x, mvp_full, step_param, error_per_bit, 1, cost_list,
fn_ptr, 1, ref_mv, tmp_mv);
break;
- case NSTEP:
+ default:
+ assert(method == NSTEP);
var = full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
MAX_MVSEARCH_STEPS - 1 - step_param, 1,
cost_list, fn_ptr, ref_mv, tmp_mv);
@@ -2241,7 +2242,6 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
}
}
break;
- default: assert(0 && "Invalid search method.");
}
if (method != NSTEP && rd && var < var_max)
diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c
index 1c2c55b9e..4e9649065 100644
--- a/vp9/encoder/vp9_picklpf.c
+++ b/vp9/encoder/vp9_picklpf.c
@@ -169,14 +169,10 @@ void vp9_pick_filter_level(const YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi,
case VPX_BITS_10:
filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 4060632, 20);
break;
- case VPX_BITS_12:
+ default:
+ assert(cm->bit_depth == VPX_BITS_12);
filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 16242526, 22);
break;
- default:
- assert(0 &&
- "bit_depth should be VPX_BITS_8, VPX_BITS_10 "
- "or VPX_BITS_12");
- return;
}
#else
int filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 1015158, 18);
diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c
index ccff24ca0..97615a06b 100644
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -726,13 +726,13 @@ static void block_yrd(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *this_rdc,
qcoeff, dqcoeff, pd->dequant, eob, scan_order->scan,
scan_order->iscan);
break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
x->fwd_txfm4x4(src_diff, coeff, diff_stride);
vp9_quantize_fp(coeff, 16, x->skip_block, p->round_fp, p->quant_fp,
qcoeff, dqcoeff, pd->dequant, eob, scan_order->scan,
scan_order->iscan);
break;
- default: assert(0); break;
}
*skippable &= (*eob == 0);
eob_cost += 1;
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 09f61ead2..276022a56 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -204,10 +204,9 @@ static int get_qzbin_factor(int q, vpx_bit_depth_t bit_depth) {
switch (bit_depth) {
case VPX_BITS_8: return q == 0 ? 64 : (quant < 148 ? 84 : 80);
case VPX_BITS_10: return q == 0 ? 64 : (quant < 592 ? 84 : 80);
- case VPX_BITS_12: return q == 0 ? 64 : (quant < 2368 ? 84 : 80);
default:
- assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
- return -1;
+ assert(bit_depth == VPX_BITS_12);
+ return q == 0 ? 64 : (quant < 2368 ? 84 : 80);
}
#else
(void)bit_depth;
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 9fbb48817..599337f80 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -48,18 +48,16 @@
#define MAX_BPB_FACTOR 50
#if CONFIG_VP9_HIGHBITDEPTH
-#define ASSIGN_MINQ_TABLE(bit_depth, name) \
- do { \
- switch (bit_depth) { \
- case VPX_BITS_8: name = name##_8; break; \
- case VPX_BITS_10: name = name##_10; break; \
- case VPX_BITS_12: name = name##_12; break; \
- default: \
- assert(0 && \
- "bit_depth should be VPX_BITS_8, VPX_BITS_10" \
- " or VPX_BITS_12"); \
- name = NULL; \
- } \
+#define ASSIGN_MINQ_TABLE(bit_depth, name) \
+ do { \
+ switch (bit_depth) { \
+ case VPX_BITS_8: name = name##_8; break; \
+ case VPX_BITS_10: name = name##_10; break; \
+ default: \
+ assert(bit_depth == VPX_BITS_12); \
+ name = name##_12; \
+ break; \
+ } \
} while (0)
#else
#define ASSIGN_MINQ_TABLE(bit_depth, name) \
@@ -167,10 +165,9 @@ double vp9_convert_qindex_to_q(int qindex, vpx_bit_depth_t bit_depth) {
switch (bit_depth) {
case VPX_BITS_8: return vp9_ac_quant(qindex, 0, bit_depth) / 4.0;
case VPX_BITS_10: return vp9_ac_quant(qindex, 0, bit_depth) / 16.0;
- case VPX_BITS_12: return vp9_ac_quant(qindex, 0, bit_depth) / 64.0;
default:
- assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
- return -1.0;
+ assert(bit_depth == VPX_BITS_12);
+ return vp9_ac_quant(qindex, 0, bit_depth) / 64.0;
}
#else
return vp9_ac_quant(qindex, 0, bit_depth) / 4.0;
diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c
index dba269809..3407e74c6 100644
--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -174,10 +174,10 @@ int64_t vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) {
switch (cpi->common.bit_depth) {
case VPX_BITS_8: rdmult = 88 * q * q / 24; break;
case VPX_BITS_10: rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 4); break;
- case VPX_BITS_12: rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 8); break;
default:
- assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
- return -1;
+ assert(cpi->common.bit_depth == VPX_BITS_12);
+ rdmult = ROUND_POWER_OF_TWO(88 * q * q / 24, 8);
+ break;
}
#else
int64_t rdmult = 88 * q * q / 24;
@@ -206,10 +206,10 @@ static int compute_rd_thresh_factor(int qindex, vpx_bit_depth_t bit_depth) {
switch (bit_depth) {
case VPX_BITS_8: q = vp9_dc_quant(qindex, 0, VPX_BITS_8) / 4.0; break;
case VPX_BITS_10: q = vp9_dc_quant(qindex, 0, VPX_BITS_10) / 16.0; break;
- case VPX_BITS_12: q = vp9_dc_quant(qindex, 0, VPX_BITS_12) / 64.0; break;
default:
- assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
- return -1;
+ assert(bit_depth == VPX_BITS_12);
+ q = vp9_dc_quant(qindex, 0, VPX_BITS_12) / 64.0;
+ break;
}
#else
(void)bit_depth;
@@ -230,12 +230,11 @@ void vp9_initialize_me_consts(VP9_COMP *cpi, MACROBLOCK *x, int qindex) {
x->sadperbit16 = sad_per_bit16lut_10[qindex];
x->sadperbit4 = sad_per_bit4lut_10[qindex];
break;
- case VPX_BITS_12:
+ default:
+ assert(cpi->common.bit_depth == VPX_BITS_12);
x->sadperbit16 = sad_per_bit16lut_12[qindex];
x->sadperbit4 = sad_per_bit4lut_12[qindex];
break;
- default:
- assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
}
#else
(void)cpi;
@@ -492,13 +491,13 @@ void vp9_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size,
for (i = 0; i < num_4x4_h; i += 4)
t_left[i] = !!*(const uint32_t *)&left[i];
break;
- case TX_32X32:
+ default:
+ assert(tx_size == TX_32X32);
for (i = 0; i < num_4x4_w; i += 8)
t_above[i] = !!*(const uint64_t *)&above[i];
for (i = 0; i < num_4x4_h; i += 8)
t_left[i] = !!*(const uint64_t *)&left[i];
break;
- default: assert(0 && "Invalid transform size."); break;
}
}
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 6ffe6ff2b..c7e205509 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -616,10 +616,10 @@ static void dist_block(const VP9_COMP *cpi, MACROBLOCK *x, int plane,
case TX_16X16:
vp9_highbd_idct16x16_add(dqcoeff, recon16, 32, *eob, xd->bd);
break;
- case TX_32X32:
+ default:
+ assert(tx_size == TX_32X32);
vp9_highbd_idct32x32_add(dqcoeff, recon16, 32, *eob, xd->bd);
break;
- default: assert(0 && "Invalid transform size");
}
}
recon = CONVERT_TO_BYTEPTR(recon16);
@@ -630,13 +630,13 @@ static void dist_block(const VP9_COMP *cpi, MACROBLOCK *x, int plane,
case TX_32X32: vp9_idct32x32_add(dqcoeff, recon, 32, *eob); break;
case TX_16X16: vp9_idct16x16_add(dqcoeff, recon, 32, *eob); break;
case TX_8X8: vp9_idct8x8_add(dqcoeff, recon, 32, *eob); break;
- case TX_4X4:
+ default:
+ assert(tx_size == TX_4X4);
// this is like vp9_short_idct4x4 but has a special case around
// eob<=1, which is significant (not just an optimization) for
// the lossless case.
x->inv_txfm_add(dqcoeff, recon, 32, *eob);
break;
- default: assert(0 && "Invalid transform size"); break;
}
#if CONFIG_VP9_HIGHBITDEPTH
}
@@ -1462,11 +1462,11 @@ static int set_and_cost_bmi_mvs(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
if (is_compound)
this_mv[1].as_int = frame_mv[mode][mi->ref_frame[1]].as_int;
break;
- case ZEROMV:
+ default:
+ assert(mode == ZEROMV);
this_mv[0].as_int = 0;
if (is_compound) this_mv[1].as_int = 0;
break;
- default: break;
}
mi->bmi[i].as_mv[0].as_int = this_mv[0].as_int;