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

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

Issue 168343002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 6 years, 10 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
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_thread.c ('k') | source/libvpx/vp9/encoder/vp9_block.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 15 matching lines...) Expand all
26 #include "vp9/common/vp9_pragmas.h" 26 #include "vp9/common/vp9_pragmas.h"
27 27
28 #include "vp9/encoder/vp9_mcomp.h" 28 #include "vp9/encoder/vp9_mcomp.h"
29 #include "vp9/encoder/vp9_encodemv.h" 29 #include "vp9/encoder/vp9_encodemv.h"
30 #include "vp9/encoder/vp9_bitstream.h" 30 #include "vp9/encoder/vp9_bitstream.h"
31 #include "vp9/encoder/vp9_segmentation.h" 31 #include "vp9/encoder/vp9_segmentation.h"
32 #include "vp9/encoder/vp9_subexp.h" 32 #include "vp9/encoder/vp9_subexp.h"
33 #include "vp9/encoder/vp9_tokenize.h" 33 #include "vp9/encoder/vp9_tokenize.h"
34 #include "vp9/encoder/vp9_write_bit_buffer.h" 34 #include "vp9/encoder/vp9_write_bit_buffer.h"
35 35
36
37 #if defined(SECTIONBITS_OUTPUT)
38 unsigned __int64 Sectionbits[500];
39 #endif
40
41 #ifdef ENTROPY_STATS 36 #ifdef ENTROPY_STATS
42 vp9_coeff_stats tree_update_hist[TX_SIZES][PLANE_TYPES]; 37 vp9_coeff_stats tree_update_hist[TX_SIZES][PLANE_TYPES];
43 extern unsigned int active_section; 38 extern unsigned int active_section;
44 #endif 39 #endif
45 40
46 static struct vp9_token intra_mode_encodings[INTRA_MODES]; 41 static struct vp9_token intra_mode_encodings[INTRA_MODES];
47 static struct vp9_token switchable_interp_encodings[SWITCHABLE_FILTERS]; 42 static struct vp9_token switchable_interp_encodings[SWITCHABLE_FILTERS];
48 static struct vp9_token partition_encodings[PARTITION_TYPES]; 43 static struct vp9_token partition_encodings[PARTITION_TYPES];
49 static struct vp9_token inter_mode_encodings[INTER_MODES]; 44 static struct vp9_token inter_mode_encodings[INTER_MODES];
50 45
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const vp9_prob *const tx_probs = get_tx_probs2(max_tx_size, xd, 97 const vp9_prob *const tx_probs = get_tx_probs2(max_tx_size, xd,
103 &cpi->common.fc.tx_probs); 98 &cpi->common.fc.tx_probs);
104 vp9_write(w, tx_size != TX_4X4, tx_probs[0]); 99 vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
105 if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) { 100 if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) {
106 vp9_write(w, tx_size != TX_8X8, tx_probs[1]); 101 vp9_write(w, tx_size != TX_8X8, tx_probs[1]);
107 if (tx_size != TX_8X8 && max_tx_size >= TX_32X32) 102 if (tx_size != TX_8X8 && max_tx_size >= TX_32X32)
108 vp9_write(w, tx_size != TX_16X16, tx_probs[2]); 103 vp9_write(w, tx_size != TX_16X16, tx_probs[2]);
109 } 104 }
110 } 105 }
111 106
112 static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m, 107 static int write_skip(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
113 vp9_writer *w) { 108 vp9_writer *w) {
114 const MACROBLOCKD *const xd = &cpi->mb.e_mbd; 109 const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
115 if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) { 110 if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) {
116 return 1; 111 return 1;
117 } else { 112 } else {
118 const int skip = m->mbmi.skip_coeff; 113 const int skip = m->mbmi.skip;
119 vp9_write(w, skip, vp9_get_skip_prob(&cpi->common, xd)); 114 vp9_write(w, skip, vp9_get_skip_prob(&cpi->common, xd));
120 return skip; 115 return skip;
121 } 116 }
122 } 117 }
123 118
124 void vp9_update_skip_probs(VP9_COMMON *cm, vp9_writer *w) { 119 void vp9_update_skip_probs(VP9_COMMON *cm, vp9_writer *w) {
125 int k; 120 int k;
126 121
127 for (k = 0; k < MBSKIP_CONTEXTS; ++k) 122 for (k = 0; k < SKIP_CONTEXTS; ++k)
128 vp9_cond_prob_diff_update(w, &cm->fc.mbskip_probs[k], cm->counts.mbskip[k]); 123 vp9_cond_prob_diff_update(w, &cm->fc.skip_probs[k], cm->counts.skip[k]);
129 } 124 }
130 125
131 static void update_switchable_interp_probs(VP9_COMP *cpi, vp9_writer *w) { 126 static void update_switchable_interp_probs(VP9_COMP *cpi, vp9_writer *w) {
132 VP9_COMMON *const cm = &cpi->common; 127 VP9_COMMON *const cm = &cpi->common;
133 int j; 128 int j;
134 for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) 129 for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
135 prob_diff_update(vp9_switchable_interp_tree, 130 prob_diff_update(vp9_switchable_interp_tree,
136 cm->fc.switchable_interp_prob[j], 131 cm->fc.switchable_interp_prob[j],
137 cm->counts.switchable_interp[j], SWITCHABLE_FILTERS, w); 132 cm->counts.switchable_interp[j], SWITCHABLE_FILTERS, w);
138 } 133 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 VP9_COMMON *const cm = &cpi->common; 246 VP9_COMMON *const cm = &cpi->common;
252 const nmv_context *nmvc = &cm->fc.nmvc; 247 const nmv_context *nmvc = &cm->fc.nmvc;
253 MACROBLOCK *const x = &cpi->mb; 248 MACROBLOCK *const x = &cpi->mb;
254 MACROBLOCKD *const xd = &x->e_mbd; 249 MACROBLOCKD *const xd = &x->e_mbd;
255 struct segmentation *seg = &cm->seg; 250 struct segmentation *seg = &cm->seg;
256 MB_MODE_INFO *const mi = &m->mbmi; 251 MB_MODE_INFO *const mi = &m->mbmi;
257 const MV_REFERENCE_FRAME rf = mi->ref_frame[0]; 252 const MV_REFERENCE_FRAME rf = mi->ref_frame[0];
258 const MV_REFERENCE_FRAME sec_rf = mi->ref_frame[1]; 253 const MV_REFERENCE_FRAME sec_rf = mi->ref_frame[1];
259 const MB_PREDICTION_MODE mode = mi->mode; 254 const MB_PREDICTION_MODE mode = mi->mode;
260 const int segment_id = mi->segment_id; 255 const int segment_id = mi->segment_id;
261 int skip_coeff; 256 int skip;
262 const BLOCK_SIZE bsize = mi->sb_type; 257 const BLOCK_SIZE bsize = mi->sb_type;
263 const int allow_hp = cm->allow_high_precision_mv; 258 const int allow_hp = cm->allow_high_precision_mv;
264 259
265 #ifdef ENTROPY_STATS 260 #ifdef ENTROPY_STATS
266 active_section = 9; 261 active_section = 9;
267 #endif 262 #endif
268 263
269 if (seg->update_map) { 264 if (seg->update_map) {
270 if (seg->temporal_update) { 265 if (seg->temporal_update) {
271 const int pred_flag = mi->seg_id_predicted; 266 const int pred_flag = mi->seg_id_predicted;
272 vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd); 267 vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
273 vp9_write(bc, pred_flag, pred_prob); 268 vp9_write(bc, pred_flag, pred_prob);
274 if (!pred_flag) 269 if (!pred_flag)
275 write_segment_id(bc, seg, segment_id); 270 write_segment_id(bc, seg, segment_id);
276 } else { 271 } else {
277 write_segment_id(bc, seg, segment_id); 272 write_segment_id(bc, seg, segment_id);
278 } 273 }
279 } 274 }
280 275
281 skip_coeff = write_skip_coeff(cpi, segment_id, m, bc); 276 skip = write_skip(cpi, segment_id, m, bc);
282 277
283 if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) 278 if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME))
284 vp9_write(bc, rf != INTRA_FRAME, vp9_get_intra_inter_prob(cm, xd)); 279 vp9_write(bc, rf != INTRA_FRAME, vp9_get_intra_inter_prob(cm, xd));
285 280
286 if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT && 281 if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
287 !(rf != INTRA_FRAME && 282 !(rf != INTRA_FRAME &&
288 (skip_coeff || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) { 283 (skip || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) {
289 write_selected_tx_size(cpi, m, mi->tx_size, bsize, bc); 284 write_selected_tx_size(cpi, m, mi->tx_size, bsize, bc);
290 } 285 }
291 286
292 if (rf == INTRA_FRAME) { 287 if (rf == INTRA_FRAME) {
293 #ifdef ENTROPY_STATS 288 #ifdef ENTROPY_STATS
294 active_section = 6; 289 active_section = 6;
295 #endif 290 #endif
296 291
297 if (bsize >= BLOCK_8X8) { 292 if (bsize >= BLOCK_8X8) {
298 write_intra_mode(bc, mode, cm->fc.y_mode_prob[size_group_lookup[bsize]]); 293 write_intra_mode(bc, mode, cm->fc.y_mode_prob[size_group_lookup[bsize]]);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 const struct segmentation *const seg = &cm->seg; 375 const struct segmentation *const seg = &cm->seg;
381 MODE_INFO *m = mi_8x8[0]; 376 MODE_INFO *m = mi_8x8[0];
382 const int ym = m->mbmi.mode; 377 const int ym = m->mbmi.mode;
383 const int segment_id = m->mbmi.segment_id; 378 const int segment_id = m->mbmi.segment_id;
384 MODE_INFO *above_mi = mi_8x8[-xd->mode_info_stride]; 379 MODE_INFO *above_mi = mi_8x8[-xd->mode_info_stride];
385 MODE_INFO *left_mi = xd->left_available ? mi_8x8[-1] : NULL; 380 MODE_INFO *left_mi = xd->left_available ? mi_8x8[-1] : NULL;
386 381
387 if (seg->update_map) 382 if (seg->update_map)
388 write_segment_id(bc, seg, m->mbmi.segment_id); 383 write_segment_id(bc, seg, m->mbmi.segment_id);
389 384
390 write_skip_coeff(cpi, segment_id, m, bc); 385 write_skip(cpi, segment_id, m, bc);
391 386
392 if (m->mbmi.sb_type >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT) 387 if (m->mbmi.sb_type >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT)
393 write_selected_tx_size(cpi, m, m->mbmi.tx_size, m->mbmi.sb_type, bc); 388 write_selected_tx_size(cpi, m, m->mbmi.tx_size, m->mbmi.sb_type, bc);
394 389
395 if (m->mbmi.sb_type >= BLOCK_8X8) { 390 if (m->mbmi.sb_type >= BLOCK_8X8) {
396 const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, 0); 391 const MB_PREDICTION_MODE A = vp9_above_block_mode(m, above_mi, 0);
397 const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, 0); 392 const MB_PREDICTION_MODE L = vp9_left_block_mode(m, left_mi, 0);
398 write_intra_mode(bc, ym, vp9_kf_y_mode_prob[A][L]); 393 write_intra_mode(bc, ym, vp9_kf_y_mode_prob[A][L]);
399 } else { 394 } else {
400 int idx, idy; 395 int idx, idy;
401 const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[m->mbmi.sb_type]; 396 const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[m->mbmi.sb_type];
402 const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[m->mbmi.sb_type]; 397 const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[m->mbmi.sb_type];
403 for (idy = 0; idy < 2; idy += num_4x4_blocks_high) { 398 for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
404 for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) { 399 for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
405 int i = idy * 2 + idx; 400 int i = idy * 2 + idx;
406 const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, i); 401 const MB_PREDICTION_MODE A = vp9_above_block_mode(m, above_mi, i);
407 const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, i); 402 const MB_PREDICTION_MODE L = vp9_left_block_mode(m, left_mi, i);
408 const int bm = m->bmi[i].as_mode; 403 const int bm = m->bmi[i].as_mode;
409 write_intra_mode(bc, bm, vp9_kf_y_mode_prob[A][L]); 404 write_intra_mode(bc, bm, vp9_kf_y_mode_prob[A][L]);
410 } 405 }
411 } 406 }
412 } 407 }
413 408
414 write_intra_mode(bc, m->mbmi.uv_mode, vp9_kf_uv_mode_prob[ym]); 409 write_intra_mode(bc, m->mbmi.uv_mode, vp9_kf_uv_mode_prob[ym]);
415 } 410 }
416 411
417 static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile, 412 static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile,
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 1286
1292 first_part_size = write_compressed_header(cpi, data); 1287 first_part_size = write_compressed_header(cpi, data);
1293 data += first_part_size; 1288 data += first_part_size;
1294 vp9_wb_write_literal(&saved_wb, first_part_size, 16); 1289 vp9_wb_write_literal(&saved_wb, first_part_size, 16);
1295 1290
1296 data += encode_tiles(cpi, data); 1291 data += encode_tiles(cpi, data);
1297 1292
1298 *size = data - dest; 1293 *size = data - dest;
1299 } 1294 }
1300 1295
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_thread.c ('k') | source/libvpx/vp9/encoder/vp9_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698