Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_tokenize.c

Issue 232133009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <assert.h>
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
16 #include "vpx_mem/vpx_mem.h"
17
18 #include "vp9/common/vp9_entropy.h"
19 #include "vp9/common/vp9_pred_common.h"
20 #include "vp9/common/vp9_seg_common.h"
21
22 #include "vp9/encoder/vp9_cost.h"
16 #include "vp9/encoder/vp9_onyx_int.h" 23 #include "vp9/encoder/vp9_onyx_int.h"
17 #include "vp9/encoder/vp9_tokenize.h" 24 #include "vp9/encoder/vp9_tokenize.h"
18 #include "vpx_mem/vpx_mem.h"
19
20 #include "vp9/common/vp9_pred_common.h"
21 #include "vp9/common/vp9_seg_common.h"
22 #include "vp9/common/vp9_entropy.h"
23 25
24 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; 26 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2];
25 const TOKENVALUE *vp9_dct_value_tokens_ptr; 27 const TOKENVALUE *vp9_dct_value_tokens_ptr;
26 static int16_t dct_value_cost[DCT_MAX_VALUE * 2]; 28 static int16_t dct_value_cost[DCT_MAX_VALUE * 2];
27 const int16_t *vp9_dct_value_cost_ptr; 29 const int16_t *vp9_dct_value_cost_ptr;
28 30
29 // Array indices are identical to previously-existing CONTEXT_NODE indices 31 // Array indices are identical to previously-existing CONTEXT_NODE indices
30 const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { 32 const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = {
31 -EOB_TOKEN, 2, // 0 = EOB 33 -EOB_TOKEN, 2, // 0 = EOB
32 -ZERO_TOKEN, 4, // 1 = ZERO 34 -ZERO_TOKEN, 4, // 1 = ZERO
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 {0, 0, 0, 0} // EOB_TOKEN 101 {0, 0, 0, 0} // EOB_TOKEN
100 }; 102 };
101 103
102 struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS]; 104 struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS];
103 105
104 void vp9_coef_tree_initialize() { 106 void vp9_coef_tree_initialize() {
105 init_bit_trees(); 107 init_bit_trees();
106 vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree); 108 vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree);
107 } 109 }
108 110
109 static void fill_value_tokens() { 111 void vp9_tokenize_initialize() {
110 TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE; 112 TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE;
111 const vp9_extra_bit *const e = vp9_extra_bits; 113 const vp9_extra_bit *const e = vp9_extra_bits;
112 114
113 int i = -DCT_MAX_VALUE; 115 int i = -DCT_MAX_VALUE;
114 int sign = 1; 116 int sign = 1;
115 117
116 do { 118 do {
117 if (!i) 119 if (!i)
118 sign = 0; 120 sign = 0;
119 121
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } while (++i < DCT_MAX_VALUE); 155 } while (++i < DCT_MAX_VALUE);
154 156
155 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; 157 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE;
156 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; 158 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE;
157 } 159 }
158 160
159 struct tokenize_b_args { 161 struct tokenize_b_args {
160 VP9_COMP *cpi; 162 VP9_COMP *cpi;
161 MACROBLOCKD *xd; 163 MACROBLOCKD *xd;
162 TOKENEXTRA **tp; 164 TOKENEXTRA **tp;
163 uint8_t *token_cache;
164 }; 165 };
165 166
166 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, 167 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize,
167 TX_SIZE tx_size, void *arg) { 168 TX_SIZE tx_size, void *arg) {
168 struct tokenize_b_args* const args = arg; 169 struct tokenize_b_args* const args = arg;
169 MACROBLOCKD *const xd = args->xd; 170 MACROBLOCKD *const xd = args->xd;
170 struct macroblock_plane *p = &args->cpi->mb.plane[plane]; 171 struct macroblock_plane *p = &args->cpi->mb.plane[plane];
171 struct macroblockd_plane *pd = &xd->plane[plane]; 172 struct macroblockd_plane *pd = &xd->plane[plane];
172 int aoff, loff; 173 int aoff, loff;
173 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); 174 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);
(...skipping 30 matching lines...) Expand all
204 const int eob_max = 16 << (tx_size << 1); 205 const int eob_max = 16 << (tx_size << 1);
205 return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max; 206 return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
206 } 207 }
207 208
208 static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize, 209 static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
209 TX_SIZE tx_size, void *arg) { 210 TX_SIZE tx_size, void *arg) {
210 struct tokenize_b_args* const args = arg; 211 struct tokenize_b_args* const args = arg;
211 VP9_COMP *cpi = args->cpi; 212 VP9_COMP *cpi = args->cpi;
212 MACROBLOCKD *xd = args->xd; 213 MACROBLOCKD *xd = args->xd;
213 TOKENEXTRA **tp = args->tp; 214 TOKENEXTRA **tp = args->tp;
214 uint8_t *token_cache = args->token_cache; 215 uint8_t token_cache[32 * 32];
215 struct macroblock_plane *p = &cpi->mb.plane[plane]; 216 struct macroblock_plane *p = &cpi->mb.plane[plane];
216 struct macroblockd_plane *pd = &xd->plane[plane]; 217 struct macroblockd_plane *pd = &xd->plane[plane];
217 MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; 218 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
218 int pt; /* near block/prev token context index */ 219 int pt; /* near block/prev token context index */
219 int c; 220 int c;
220 TOKENEXTRA *t = *tp; /* store tokens starting here */ 221 TOKENEXTRA *t = *tp; /* store tokens starting here */
221 int eob = p->eobs[block]; 222 int eob = p->eobs[block];
222 const PLANE_TYPE type = pd->plane_type; 223 const PLANE_TYPE type = pd->plane_type;
223 const int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); 224 const int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
224 const int segment_id = mbmi->segment_id; 225 const int segment_id = mbmi->segment_id;
225 const int16_t *scan, *nb; 226 const int16_t *scan, *nb;
226 const scan_order *so; 227 const scan_order *so;
227 const int ref = is_inter_block(mbmi); 228 const int ref = is_inter_block(mbmi);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 int *skippable; 290 int *skippable;
290 }; 291 };
291 292
292 static void is_skippable(int plane, int block, 293 static void is_skippable(int plane, int block,
293 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, 294 BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
294 void *argv) { 295 void *argv) {
295 struct is_skippable_args *args = argv; 296 struct is_skippable_args *args = argv;
296 args->skippable[0] &= (!args->x->plane[plane].eobs[block]); 297 args->skippable[0] &= (!args->x->plane[plane].eobs[block]);
297 } 298 }
298 299
299 static int sb_is_skippable(MACROBLOCK *x, BLOCK_SIZE bsize) {
300 int result = 1;
301 struct is_skippable_args args = {x, &result};
302 vp9_foreach_transformed_block(&x->e_mbd, bsize, is_skippable, &args);
303 return result;
304 }
305
306 int vp9_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { 300 int vp9_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
307 int result = 1; 301 int result = 1;
308 struct is_skippable_args args = {x, &result}; 302 struct is_skippable_args args = {x, &result};
309 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable, 303 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable,
310 &args); 304 &args);
311 return result; 305 return result;
312 } 306 }
313 307
314 void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, 308 void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run,
315 BLOCK_SIZE bsize) { 309 BLOCK_SIZE bsize) {
316 VP9_COMMON *const cm = &cpi->common; 310 VP9_COMMON *const cm = &cpi->common;
317 MACROBLOCKD *const xd = &cpi->mb.e_mbd; 311 MACROBLOCKD *const xd = &cpi->mb.e_mbd;
318 MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; 312 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
319 TOKENEXTRA *t_backup = *t; 313 TOKENEXTRA *t_backup = *t;
320 const int ctx = vp9_get_skip_context(xd); 314 const int ctx = vp9_get_skip_context(xd);
321 const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, 315 const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id,
322 SEG_LVL_SKIP); 316 SEG_LVL_SKIP);
323 struct tokenize_b_args arg = {cpi, xd, t, cpi->mb.token_cache}; 317 struct tokenize_b_args arg = {cpi, xd, t};
324 if (mbmi->skip) { 318 if (mbmi->skip) {
325 if (!dry_run) 319 if (!dry_run)
326 cm->counts.skip[ctx][1] += skip_inc; 320 cm->counts.skip[ctx][1] += skip_inc;
327 reset_skip_context(xd, bsize); 321 reset_skip_context(xd, bsize);
328 if (dry_run) 322 if (dry_run)
329 *t = t_backup; 323 *t = t_backup;
330 return; 324 return;
331 } 325 }
332 326
333 if (!dry_run) { 327 if (!dry_run) {
334 cm->counts.skip[ctx][0] += skip_inc; 328 cm->counts.skip[ctx][0] += skip_inc;
335 vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg); 329 vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg);
336 } else { 330 } else {
337 vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); 331 vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg);
338 *t = t_backup; 332 *t = t_backup;
339 } 333 }
340 } 334 }
341
342 void vp9_tokenize_initialize() {
343 fill_value_tokens();
344 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_temporal_filter.c ('k') | source/libvpx/vp9/encoder/vp9_treewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698