| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | 11 |
| 12 #include <math.h> | 12 #include <math.h> |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 #include <assert.h> | 15 #include <assert.h> |
| 16 #include "vp9/encoder/vp9_onyx_int.h" | 16 #include "vp9/encoder/vp9_onyx_int.h" |
| 17 #include "vp9/encoder/vp9_tokenize.h" | 17 #include "vp9/encoder/vp9_tokenize.h" |
| 18 #include "vpx_mem/vpx_mem.h" | 18 #include "vpx_mem/vpx_mem.h" |
| 19 | 19 |
| 20 #include "vp9/common/vp9_pred_common.h" | 20 #include "vp9/common/vp9_pred_common.h" |
| 21 #include "vp9/common/vp9_seg_common.h" | 21 #include "vp9/common/vp9_seg_common.h" |
| 22 #include "vp9/common/vp9_entropy.h" | 22 #include "vp9/common/vp9_entropy.h" |
| 23 | 23 |
| 24 /* Global event counters used for accumulating statistics across several | 24 /* Global event counters used for accumulating statistics across several |
| 25 compressions, then generating vp9_context.c = initial stats. */ | 25 compressions, then generating vp9_context.c = initial stats. */ |
| 26 | 26 |
| 27 #ifdef ENTROPY_STATS | 27 #ifdef ENTROPY_STATS |
| 28 vp9_coeff_accum context_counters[TX_SIZE_MAX_SB][BLOCK_TYPES]; | 28 vp9_coeff_accum context_counters[TX_SIZES][BLOCK_TYPES]; |
| 29 extern vp9_coeff_stats tree_update_hist[TX_SIZE_MAX_SB][BLOCK_TYPES]; | 29 extern vp9_coeff_stats tree_update_hist[TX_SIZES][BLOCK_TYPES]; |
| 30 #endif /* ENTROPY_STATS */ | 30 #endif /* ENTROPY_STATS */ |
| 31 | 31 |
| 32 DECLARE_ALIGNED(16, extern const uint8_t, | 32 DECLARE_ALIGNED(16, extern const uint8_t, |
| 33 vp9_pt_energy_class[MAX_ENTROPY_TOKENS]); | 33 vp9_pt_energy_class[MAX_ENTROPY_TOKENS]); |
| 34 | 34 |
| 35 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; | 35 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; |
| 36 const TOKENVALUE *vp9_dct_value_tokens_ptr; | 36 const TOKENVALUE *vp9_dct_value_tokens_ptr; |
| 37 static int dct_value_cost[DCT_MAX_VALUE * 2]; | 37 static int dct_value_cost[DCT_MAX_VALUE * 2]; |
| 38 const int *vp9_dct_value_cost_ptr; | 38 const int *vp9_dct_value_cost_ptr; |
| 39 | 39 |
| 40 static void fill_value_tokens() { | 40 static void fill_value_tokens() { |
| 41 | 41 |
| 42 TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE; | 42 TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE; |
| 43 vp9_extra_bit *const e = vp9_extra_bits; | 43 const vp9_extra_bit *const e = vp9_extra_bits; |
| 44 | 44 |
| 45 int i = -DCT_MAX_VALUE; | 45 int i = -DCT_MAX_VALUE; |
| 46 int sign = 1; | 46 int sign = 1; |
| 47 | 47 |
| 48 do { | 48 do { |
| 49 if (!i) | 49 if (!i) |
| 50 sign = 0; | 50 sign = 0; |
| 51 | 51 |
| 52 { | 52 { |
| 53 const int a = sign ? -i : i; | 53 const int a = sign ? -i : i; |
| 54 int eb = sign; | 54 int eb = sign; |
| 55 | 55 |
| 56 if (a > 4) { | 56 if (a > 4) { |
| 57 int j = 4; | 57 int j = 4; |
| 58 | 58 |
| 59 while (++j < 11 && e[j].base_val <= a) {} | 59 while (++j < 11 && e[j].base_val <= a) {} |
| 60 | 60 |
| 61 t[i].token = --j; | 61 t[i].token = --j; |
| 62 eb |= (a - e[j].base_val) << 1; | 62 eb |= (a - e[j].base_val) << 1; |
| 63 } else | 63 } else |
| 64 t[i].token = a; | 64 t[i].token = a; |
| 65 | 65 |
| 66 t[i].extra = eb; | 66 t[i].extra = eb; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // initialize the cost for extra bits for all possible coefficient value. | 69 // initialize the cost for extra bits for all possible coefficient value. |
| 70 { | 70 { |
| 71 int cost = 0; | 71 int cost = 0; |
| 72 vp9_extra_bit *p = vp9_extra_bits + t[i].token; | 72 const vp9_extra_bit *p = vp9_extra_bits + t[i].token; |
| 73 | 73 |
| 74 if (p->base_val) { | 74 if (p->base_val) { |
| 75 const int extra = t[i].extra; | 75 const int extra = t[i].extra; |
| 76 const int length = p->len; | 76 const int length = p->len; |
| 77 | 77 |
| 78 if (length) | 78 if (length) |
| 79 cost += treed_cost(p->tree, p->prob, extra >> 1, length); | 79 cost += treed_cost(p->tree, p->prob, extra >> 1, length); |
| 80 | 80 |
| 81 cost += vp9_cost_bit(vp9_prob_half, extra & 1); /* sign */ | 81 cost += vp9_cost_bit(vp9_prob_half, extra & 1); /* sign */ |
| 82 dct_value_cost[i + DCT_MAX_VALUE] = cost; | 82 dct_value_cost[i + DCT_MAX_VALUE] = cost; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } | 85 } |
| 86 | 86 |
| 87 } while (++i < DCT_MAX_VALUE); | 87 } while (++i < DCT_MAX_VALUE); |
| 88 | 88 |
| 89 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; | 89 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; |
| 90 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; | 90 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; |
| 91 } | 91 } |
| 92 | 92 |
| 93 struct tokenize_b_args { | 93 struct tokenize_b_args { |
| 94 VP9_COMP *cpi; | 94 VP9_COMP *cpi; |
| 95 MACROBLOCKD *xd; | 95 MACROBLOCKD *xd; |
| 96 TOKENEXTRA **tp; | 96 TOKENEXTRA **tp; |
| 97 TX_SIZE tx_size; | 97 TX_SIZE tx_size; |
| 98 int dry_run; | |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, | 100 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, |
| 102 int ss_txfrm_size, void *arg) { | 101 TX_SIZE tx_size, void *arg) { |
| 102 struct tokenize_b_args* const args = arg; |
| 103 MACROBLOCKD *const xd = args->xd; |
| 104 struct macroblockd_plane *pd = &xd->plane[plane]; |
| 105 int aoff, loff; |
| 106 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); |
| 107 set_contexts(xd, pd, plane_bsize, tx_size, pd->eobs[block] > 0, aoff, loff); |
| 108 } |
| 109 |
| 110 static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize, |
| 111 TX_SIZE tx_size, void *arg) { |
| 103 struct tokenize_b_args* const args = arg; | 112 struct tokenize_b_args* const args = arg; |
| 104 VP9_COMP *cpi = args->cpi; | 113 VP9_COMP *cpi = args->cpi; |
| 105 MACROBLOCKD *xd = args->xd; | 114 MACROBLOCKD *xd = args->xd; |
| 106 TOKENEXTRA **tp = args->tp; | 115 TOKENEXTRA **tp = args->tp; |
| 107 TX_SIZE tx_size = ss_txfrm_size / 2; | 116 struct macroblockd_plane *pd = &xd->plane[plane]; |
| 108 int dry_run = args->dry_run; | |
| 109 | |
| 110 MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; | 117 MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; |
| 111 int pt; /* near block/prev token context index */ | 118 int pt; /* near block/prev token context index */ |
| 112 int c = 0, rc = 0; | 119 int c = 0, rc = 0; |
| 113 TOKENEXTRA *t = *tp; /* store tokens starting here */ | 120 TOKENEXTRA *t = *tp; /* store tokens starting here */ |
| 114 const int eob = xd->plane[plane].eobs[block]; | 121 const int eob = pd->eobs[block]; |
| 115 const PLANE_TYPE type = xd->plane[plane].plane_type; | 122 const PLANE_TYPE type = pd->plane_type; |
| 116 const int16_t *qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); | 123 const int16_t *qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block); |
| 117 const BLOCK_SIZE_TYPE sb_type = (mbmi->sb_type < BLOCK_SIZE_SB8X8) ? | |
| 118 BLOCK_SIZE_SB8X8 : mbmi->sb_type; | |
| 119 const int bwl = b_width_log2(sb_type); | |
| 120 const int off = block >> (2 * tx_size); | |
| 121 const int mod = bwl - tx_size - xd->plane[plane].subsampling_x; | |
| 122 const int aoff = (off & ((1 << mod) - 1)) << tx_size; | |
| 123 const int loff = (off >> mod) << tx_size; | |
| 124 ENTROPY_CONTEXT *A = xd->plane[plane].above_context + aoff; | |
| 125 ENTROPY_CONTEXT *L = xd->plane[plane].left_context + loff; | |
| 126 int seg_eob; | 124 int seg_eob; |
| 127 const int segment_id = mbmi->segment_id; | 125 const int segment_id = mbmi->segment_id; |
| 128 const int16_t *scan, *nb; | 126 const int16_t *scan, *nb; |
| 129 vp9_coeff_count *counts; | 127 vp9_coeff_count *const counts = cpi->coef_counts[tx_size]; |
| 130 vp9_coeff_probs_model *coef_probs; | 128 vp9_coeff_probs_model *const coef_probs = cpi->common.fc.coef_probs[tx_size]; |
| 131 const int ref = mbmi->ref_frame[0] != INTRA_FRAME; | 129 const int ref = is_inter_block(mbmi); |
| 132 ENTROPY_CONTEXT above_ec, left_ec; | 130 ENTROPY_CONTEXT above_ec, left_ec; |
| 133 uint8_t token_cache[1024]; | 131 uint8_t token_cache[1024]; |
| 134 const uint8_t *band_translate; | 132 const uint8_t *band_translate; |
| 133 ENTROPY_CONTEXT *A, *L; |
| 134 int aoff, loff; |
| 135 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); |
| 136 |
| 137 A = pd->above_context + aoff; |
| 138 L = pd->left_context + loff; |
| 139 |
| 135 assert((!type && !plane) || (type && plane)); | 140 assert((!type && !plane) || (type && plane)); |
| 136 | 141 |
| 137 counts = cpi->coef_counts[tx_size]; | |
| 138 coef_probs = cpi->common.fc.coef_probs[tx_size]; | |
| 139 switch (tx_size) { | 142 switch (tx_size) { |
| 140 default: | |
| 141 case TX_4X4: | 143 case TX_4X4: |
| 142 above_ec = A[0] != 0; | 144 above_ec = A[0] != 0; |
| 143 left_ec = L[0] != 0; | 145 left_ec = L[0] != 0; |
| 144 seg_eob = 16; | 146 seg_eob = 16; |
| 145 scan = get_scan_4x4(get_tx_type_4x4(type, xd, block)); | 147 scan = get_scan_4x4(get_tx_type_4x4(type, xd, block)); |
| 146 band_translate = vp9_coefband_trans_4x4; | 148 band_translate = vp9_coefband_trans_4x4; |
| 147 break; | 149 break; |
| 148 case TX_8X8: | 150 case TX_8X8: |
| 149 above_ec = (A[0] + A[1]) != 0; | 151 above_ec = !!*(uint16_t *)A; |
| 150 left_ec = (L[0] + L[1]) != 0; | 152 left_ec = !!*(uint16_t *)L; |
| 151 seg_eob = 64; | 153 seg_eob = 64; |
| 152 scan = get_scan_8x8(get_tx_type_8x8(type, xd)); | 154 scan = get_scan_8x8(get_tx_type_8x8(type, xd)); |
| 153 band_translate = vp9_coefband_trans_8x8plus; | 155 band_translate = vp9_coefband_trans_8x8plus; |
| 154 break; | 156 break; |
| 155 case TX_16X16: | 157 case TX_16X16: |
| 156 above_ec = (A[0] + A[1] + A[2] + A[3]) != 0; | 158 above_ec = !!*(uint32_t *)A; |
| 157 left_ec = (L[0] + L[1] + L[2] + L[3]) != 0; | 159 left_ec = !!*(uint32_t *)L; |
| 158 seg_eob = 256; | 160 seg_eob = 256; |
| 159 scan = get_scan_16x16(get_tx_type_16x16(type, xd)); | 161 scan = get_scan_16x16(get_tx_type_16x16(type, xd)); |
| 160 band_translate = vp9_coefband_trans_8x8plus; | 162 band_translate = vp9_coefband_trans_8x8plus; |
| 161 break; | 163 break; |
| 162 case TX_32X32: | 164 case TX_32X32: |
| 163 above_ec = (A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7]) != 0; | 165 above_ec = !!*(uint64_t *)A; |
| 164 left_ec = (L[0] + L[1] + L[2] + L[3] + L[4] + L[5] + L[6] + L[7]) != 0; | 166 left_ec = !!*(uint64_t *)L; |
| 165 seg_eob = 1024; | 167 seg_eob = 1024; |
| 166 scan = vp9_default_scan_32x32; | 168 scan = vp9_default_scan_32x32; |
| 167 band_translate = vp9_coefband_trans_8x8plus; | 169 band_translate = vp9_coefband_trans_8x8plus; |
| 168 break; | 170 break; |
| 171 default: |
| 172 assert(!"Invalid transform size"); |
| 169 } | 173 } |
| 170 | 174 |
| 171 pt = combine_entropy_contexts(above_ec, left_ec); | 175 pt = combine_entropy_contexts(above_ec, left_ec); |
| 172 nb = vp9_get_coef_neighbors_handle(scan); | 176 nb = vp9_get_coef_neighbors_handle(scan); |
| 173 | 177 |
| 174 if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)) | 178 if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) |
| 175 seg_eob = 0; | 179 seg_eob = 0; |
| 176 | 180 |
| 177 c = 0; | 181 c = 0; |
| 178 do { | 182 do { |
| 179 const int band = get_coef_band(band_translate, c); | 183 const int band = get_coef_band(band_translate, c); |
| 180 int token; | 184 int token; |
| 181 int v = 0; | 185 int v = 0; |
| 182 rc = scan[c]; | 186 rc = scan[c]; |
| 183 if (c) | 187 if (c) |
| 184 pt = get_coef_context(nb, token_cache, c); | 188 pt = get_coef_context(nb, token_cache, c); |
| 185 if (c < eob) { | 189 if (c < eob) { |
| 186 v = qcoeff_ptr[rc]; | 190 v = qcoeff_ptr[rc]; |
| 187 assert(-DCT_MAX_VALUE <= v && v < DCT_MAX_VALUE); | 191 assert(-DCT_MAX_VALUE <= v && v < DCT_MAX_VALUE); |
| 188 | 192 |
| 189 t->extra = vp9_dct_value_tokens_ptr[v].extra; | 193 t->extra = vp9_dct_value_tokens_ptr[v].extra; |
| 190 token = vp9_dct_value_tokens_ptr[v].token; | 194 token = vp9_dct_value_tokens_ptr[v].token; |
| 191 } else { | 195 } else { |
| 192 token = DCT_EOB_TOKEN; | 196 token = DCT_EOB_TOKEN; |
| 193 } | 197 } |
| 194 | 198 |
| 195 t->token = token; | 199 t->token = token; |
| 196 t->context_tree = coef_probs[type][ref][band][pt]; | 200 t->context_tree = coef_probs[type][ref][band][pt]; |
| 197 t->skip_eob_node = (c > 0) && (token_cache[scan[c - 1]] == 0); | 201 t->skip_eob_node = (c > 0) && (token_cache[scan[c - 1]] == 0); |
| 198 | 202 |
| 199 assert(vp9_coef_encodings[t->token].len - t->skip_eob_node > 0); | 203 assert(vp9_coef_encodings[t->token].len - t->skip_eob_node > 0); |
| 200 | 204 |
| 201 if (!dry_run) { | 205 ++counts[type][ref][band][pt][token]; |
| 202 ++counts[type][ref][band][pt][token]; | 206 if (!t->skip_eob_node) |
| 203 if (!t->skip_eob_node) | 207 ++cpi->common.counts.eob_branch[tx_size][type][ref][band][pt]; |
| 204 ++cpi->common.counts.eob_branch[tx_size][type][ref][band][pt]; | 208 |
| 205 } | 209 token_cache[rc] = vp9_pt_energy_class[token]; |
| 206 token_cache[scan[c]] = vp9_pt_energy_class[token]; | |
| 207 ++t; | 210 ++t; |
| 208 } while (c < eob && ++c < seg_eob); | 211 } while (c < eob && ++c < seg_eob); |
| 209 | 212 |
| 210 *tp = t; | 213 *tp = t; |
| 211 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { | 214 |
| 212 set_contexts_on_border(xd, bsize, plane, tx_size, c, aoff, loff, A, L); | 215 set_contexts(xd, pd, plane_bsize, tx_size, c > 0, aoff, loff); |
| 213 } else { | |
| 214 for (pt = 0; pt < (1 << tx_size); pt++) { | |
| 215 A[pt] = L[pt] = c > 0; | |
| 216 } | |
| 217 } | |
| 218 } | 216 } |
| 219 | 217 |
| 220 struct is_skippable_args { | 218 struct is_skippable_args { |
| 221 MACROBLOCKD *xd; | 219 MACROBLOCKD *xd; |
| 222 int *skippable; | 220 int *skippable; |
| 223 }; | 221 }; |
| 222 |
| 224 static void is_skippable(int plane, int block, | 223 static void is_skippable(int plane, int block, |
| 225 BLOCK_SIZE_TYPE bsize, int ss_txfrm_size, void *argv) { | 224 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, |
| 225 void *argv) { |
| 226 struct is_skippable_args *args = argv; | 226 struct is_skippable_args *args = argv; |
| 227 args->skippable[0] &= (!args->xd->plane[plane].eobs[block]); | 227 args->skippable[0] &= (!args->xd->plane[plane].eobs[block]); |
| 228 } | 228 } |
| 229 | 229 |
| 230 int vp9_sb_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { | 230 int vp9_sb_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE bsize) { |
| 231 int result = 1; | 231 int result = 1; |
| 232 struct is_skippable_args args = {xd, &result}; | 232 struct is_skippable_args args = {xd, &result}; |
| 233 foreach_transformed_block(xd, bsize, is_skippable, &args); | 233 foreach_transformed_block(xd, bsize, is_skippable, &args); |
| 234 return result; | 234 return result; |
| 235 } | 235 } |
| 236 | 236 |
| 237 int vp9_sby_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { | 237 int vp9_is_skippable_in_plane(MACROBLOCKD *xd, BLOCK_SIZE bsize, |
| 238 int plane) { |
| 238 int result = 1; | 239 int result = 1; |
| 239 struct is_skippable_args args = {xd, &result}; | 240 struct is_skippable_args args = {xd, &result}; |
| 240 foreach_transformed_block_in_plane(xd, bsize, 0, is_skippable, &args); | 241 foreach_transformed_block_in_plane(xd, bsize, plane, is_skippable, &args); |
| 241 return result; | |
| 242 } | |
| 243 | |
| 244 int vp9_sbuv_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) { | |
| 245 int result = 1; | |
| 246 struct is_skippable_args args = {xd, &result}; | |
| 247 foreach_transformed_block_uv(xd, bsize, is_skippable, &args); | |
| 248 return result; | 242 return result; |
| 249 } | 243 } |
| 250 | 244 |
| 251 void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, | 245 void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, |
| 252 BLOCK_SIZE_TYPE bsize) { | 246 BLOCK_SIZE bsize) { |
| 253 VP9_COMMON *const cm = &cpi->common; | 247 VP9_COMMON *const cm = &cpi->common; |
| 254 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 248 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
| 255 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; | 249 MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; |
| 256 TOKENEXTRA *t_backup = *t; | 250 TOKENEXTRA *t_backup = *t; |
| 257 const int mb_skip_context = vp9_get_pred_context_mbskip(xd); | 251 const int mb_skip_context = vp9_get_pred_context_mbskip(xd); |
| 258 const int skip_inc = !vp9_segfeature_active(&xd->seg, mbmi->segment_id, | 252 const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, |
| 259 SEG_LVL_SKIP); | 253 SEG_LVL_SKIP); |
| 260 const TX_SIZE txfm_size = mbmi->txfm_size; | 254 struct tokenize_b_args arg = {cpi, xd, t, mbmi->txfm_size}; |
| 261 struct tokenize_b_args arg = { cpi, xd, t, txfm_size, dry_run }; | |
| 262 | 255 |
| 263 mbmi->mb_skip_coeff = vp9_sb_is_skippable(xd, bsize); | 256 mbmi->skip_coeff = vp9_sb_is_skippable(xd, bsize); |
| 264 if (mbmi->mb_skip_coeff) { | 257 if (mbmi->skip_coeff) { |
| 265 if (!dry_run) | 258 if (!dry_run) |
| 266 cm->counts.mbskip[mb_skip_context][1] += skip_inc; | 259 cm->counts.mbskip[mb_skip_context][1] += skip_inc; |
| 267 vp9_reset_sb_tokens_context(xd, bsize); | 260 reset_skip_context(xd, bsize); |
| 268 if (dry_run) | 261 if (dry_run) |
| 269 *t = t_backup; | 262 *t = t_backup; |
| 270 return; | 263 return; |
| 271 } | 264 } |
| 272 | 265 |
| 273 if (!dry_run) | 266 if (!dry_run) { |
| 274 cm->counts.mbskip[mb_skip_context][0] += skip_inc; | 267 cm->counts.mbskip[mb_skip_context][0] += skip_inc; |
| 275 | 268 foreach_transformed_block(xd, bsize, tokenize_b, &arg); |
| 276 foreach_transformed_block(xd, bsize, tokenize_b, &arg); | 269 } else { |
| 277 | 270 foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); |
| 278 if (dry_run) | |
| 279 *t = t_backup; | 271 *t = t_backup; |
| 272 } |
| 280 } | 273 } |
| 281 | 274 |
| 282 #ifdef ENTROPY_STATS | 275 #ifdef ENTROPY_STATS |
| 283 void init_context_counters(void) { | 276 void init_context_counters(void) { |
| 284 FILE *f = fopen("context.bin", "rb"); | 277 FILE *f = fopen("context.bin", "rb"); |
| 285 if (!f) { | 278 if (!f) { |
| 286 vp9_zero(context_counters); | 279 vp9_zero(context_counters); |
| 287 } else { | 280 } else { |
| 288 fread(context_counters, sizeof(context_counters), 1, f); | 281 fread(context_counters, sizeof(context_counters), 1, f); |
| 289 fclose(f); | 282 fclose(f); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 411 |
| 419 f = fopen("context.bin", "wb"); | 412 f = fopen("context.bin", "wb"); |
| 420 fwrite(context_counters, sizeof(context_counters), 1, f); | 413 fwrite(context_counters, sizeof(context_counters), 1, f); |
| 421 fclose(f); | 414 fclose(f); |
| 422 } | 415 } |
| 423 #endif | 416 #endif |
| 424 | 417 |
| 425 void vp9_tokenize_initialize() { | 418 void vp9_tokenize_initialize() { |
| 426 fill_value_tokens(); | 419 fill_value_tokens(); |
| 427 } | 420 } |
| OLD | NEW |