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

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

Issue 554673004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 3 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/encoder/vp9_bitstream.h ('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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 write_inter_mode(w, mode, inter_probs); 287 write_inter_mode(w, mode, inter_probs);
288 ++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(mode)]; 288 ++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(mode)];
289 } 289 }
290 } 290 }
291 291
292 if (cm->interp_filter == SWITCHABLE) { 292 if (cm->interp_filter == SWITCHABLE) {
293 const int ctx = vp9_get_pred_context_switchable_interp(xd); 293 const int ctx = vp9_get_pred_context_switchable_interp(xd);
294 vp9_write_token(w, vp9_switchable_interp_tree, 294 vp9_write_token(w, vp9_switchable_interp_tree,
295 cm->fc.switchable_interp_prob[ctx], 295 cm->fc.switchable_interp_prob[ctx],
296 &switchable_interp_encodings[mbmi->interp_filter]); 296 &switchable_interp_encodings[mbmi->interp_filter]);
297 ++cpi->interp_filter_selected[0][mbmi->interp_filter];
297 } else { 298 } else {
298 assert(mbmi->interp_filter == cm->interp_filter); 299 assert(mbmi->interp_filter == cm->interp_filter);
299 } 300 }
300 301
301 if (bsize < BLOCK_8X8) { 302 if (bsize < BLOCK_8X8) {
302 const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize]; 303 const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
303 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize]; 304 const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
304 int idx, idy; 305 int idx, idy;
305 for (idy = 0; idy < 2; idy += num_4x4_h) { 306 for (idy = 0; idy < 2; idy += num_4x4_h) {
306 for (idx = 0; idx < 2; idx += num_4x4_w) { 307 for (idx = 0; idx < 2; idx += num_4x4_w) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 664 }
664 } 665 }
665 666
666 static void update_coef_probs(VP9_COMP *cpi, vp9_writer* w) { 667 static void update_coef_probs(VP9_COMP *cpi, vp9_writer* w) {
667 const TX_MODE tx_mode = cpi->common.tx_mode; 668 const TX_MODE tx_mode = cpi->common.tx_mode;
668 const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode]; 669 const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
669 TX_SIZE tx_size; 670 TX_SIZE tx_size;
670 vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES]; 671 vp9_coeff_stats frame_branch_ct[TX_SIZES][PLANE_TYPES];
671 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES]; 672 vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES];
672 673
673 vp9_clear_system_state();
674
675 for (tx_size = TX_4X4; tx_size <= TX_32X32; ++tx_size) 674 for (tx_size = TX_4X4; tx_size <= TX_32X32; ++tx_size)
676 build_tree_distribution(cpi, tx_size, frame_branch_ct[tx_size], 675 build_tree_distribution(cpi, tx_size, frame_branch_ct[tx_size],
677 frame_coef_probs[tx_size]); 676 frame_coef_probs[tx_size]);
678 677
679 for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size) 678 for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
680 update_coef_probs_common(w, cpi, tx_size, frame_branch_ct[tx_size], 679 update_coef_probs_common(w, cpi, tx_size, frame_branch_ct[tx_size],
681 frame_coef_probs[tx_size]); 680 frame_coef_probs[tx_size]);
682 } 681 }
683 682
684 static void encode_loopfilter(struct loopfilter *lf, 683 static void encode_loopfilter(struct loopfilter *lf,
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 int found = 0; 990 int found = 0;
992 991
993 MV_REFERENCE_FRAME ref_frame; 992 MV_REFERENCE_FRAME ref_frame;
994 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { 993 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
995 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame); 994 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame);
996 found = cm->width == cfg->y_crop_width && 995 found = cm->width == cfg->y_crop_width &&
997 cm->height == cfg->y_crop_height; 996 cm->height == cfg->y_crop_height;
998 997
999 // Set "found" to 0 for temporal svc and for spatial svc key frame 998 // Set "found" to 0 for temporal svc and for spatial svc key frame
1000 if (cpi->use_svc && 999 if (cpi->use_svc &&
1001 (cpi->svc.number_spatial_layers == 1 || 1000 ((cpi->svc.number_temporal_layers > 1 &&
1002 cpi->svc.layer_context[cpi->svc.spatial_layer_id].is_key_frame)) { 1001 cpi->oxcf.rc_mode == VPX_CBR) ||
1002 (cpi->svc.number_spatial_layers > 1 &&
1003 cpi->svc.layer_context[cpi->svc.spatial_layer_id].is_key_frame))) {
1003 found = 0; 1004 found = 0;
1004 } 1005 }
1005 vp9_wb_write_bit(wb, found); 1006 vp9_wb_write_bit(wb, found);
1006 if (found) { 1007 if (found) {
1007 break; 1008 break;
1008 } 1009 }
1009 } 1010 }
1010 1011
1011 if (!found) { 1012 if (!found) {
1012 vp9_wb_write_literal(wb, cm->width - 1, 16); 1013 vp9_wb_write_literal(wb, cm->width - 1, 16);
(...skipping 25 matching lines...) Expand all
1038 vp9_wb_write_literal(wb, 6, 3); 1039 vp9_wb_write_literal(wb, 6, 3);
1039 break; 1040 break;
1040 default: 1041 default:
1041 assert(0); 1042 assert(0);
1042 } 1043 }
1043 } 1044 }
1044 1045
1045 static void write_bitdepth_colorspace_sampling( 1046 static void write_bitdepth_colorspace_sampling(
1046 VP9_COMMON *const cm, struct vp9_write_bit_buffer *wb) { 1047 VP9_COMMON *const cm, struct vp9_write_bit_buffer *wb) {
1047 if (cm->profile >= PROFILE_2) { 1048 if (cm->profile >= PROFILE_2) {
1048 assert(cm->bit_depth > BITS_8); 1049 assert(cm->bit_depth > VPX_BITS_8);
1049 vp9_wb_write_bit(wb, cm->bit_depth - BITS_10); 1050 vp9_wb_write_bit(wb, cm->bit_depth == VPX_BITS_10 ? 0 : 1);
1050 } 1051 }
1051 vp9_wb_write_literal(wb, cm->color_space, 3); 1052 vp9_wb_write_literal(wb, cm->color_space, 3);
1052 if (cm->color_space != SRGB) { 1053 if (cm->color_space != SRGB) {
1053 vp9_wb_write_bit(wb, 0); // 0: [16, 235] (i.e. xvYCC), 1: [0, 255] 1054 vp9_wb_write_bit(wb, 0); // 0: [16, 235] (i.e. xvYCC), 1: [0, 255]
1054 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { 1055 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) {
1055 assert(cm->subsampling_x != 1 || cm->subsampling_y != 1); 1056 assert(cm->subsampling_x != 1 || cm->subsampling_y != 1);
1056 vp9_wb_write_bit(wb, cm->subsampling_x); 1057 vp9_wb_write_bit(wb, cm->subsampling_x);
1057 vp9_wb_write_bit(wb, cm->subsampling_y); 1058 vp9_wb_write_bit(wb, cm->subsampling_y);
1058 vp9_wb_write_bit(wb, 0); // unused 1059 vp9_wb_write_bit(wb, 0); // unused
1059 } else { 1060 } else {
(...skipping 16 matching lines...) Expand all
1076 vp9_wb_write_bit(wb, 0); // show_existing_frame 1077 vp9_wb_write_bit(wb, 0); // show_existing_frame
1077 vp9_wb_write_bit(wb, cm->frame_type); 1078 vp9_wb_write_bit(wb, cm->frame_type);
1078 vp9_wb_write_bit(wb, cm->show_frame); 1079 vp9_wb_write_bit(wb, cm->show_frame);
1079 vp9_wb_write_bit(wb, cm->error_resilient_mode); 1080 vp9_wb_write_bit(wb, cm->error_resilient_mode);
1080 1081
1081 if (cm->frame_type == KEY_FRAME) { 1082 if (cm->frame_type == KEY_FRAME) {
1082 write_sync_code(wb); 1083 write_sync_code(wb);
1083 write_bitdepth_colorspace_sampling(cm, wb); 1084 write_bitdepth_colorspace_sampling(cm, wb);
1084 write_frame_size(cm, wb); 1085 write_frame_size(cm, wb);
1085 } else { 1086 } else {
1086 if (!cm->show_frame) 1087 // In spatial svc if it's not error_resilient_mode then we need to code all
1088 // visible frames as invisible. But we need to keep the show_frame flag so
1089 // that the publisher could know whether it is supposed to be visible.
1090 // So we will code the show_frame flag as it is. Then code the intra_only
1091 // bit here. This will make the bitstream incompatible. In the player we
1092 // will change to show_frame flag to 0, then add an one byte frame with
1093 // show_existing_frame flag which tells the decoder which frame we want to
1094 // show.
1095 if (!cm->show_frame ||
1096 (is_two_pass_svc(cpi) && cm->error_resilient_mode == 0))
1087 vp9_wb_write_bit(wb, cm->intra_only); 1097 vp9_wb_write_bit(wb, cm->intra_only);
1088 1098
1089 if (!cm->error_resilient_mode) 1099 if (!cm->error_resilient_mode)
1090 vp9_wb_write_literal(wb, cm->reset_frame_context, 2); 1100 vp9_wb_write_literal(wb, cm->reset_frame_context, 2);
1091 1101
1092 if (cm->intra_only) { 1102 if (cm->intra_only) {
1093 write_sync_code(wb); 1103 write_sync_code(wb);
1094 1104
1095 // Note for profile 0, 420 8bpp is assumed. 1105 // Note for profile 0, 420 8bpp is assumed.
1096 if (cm->profile > PROFILE_0) { 1106 if (cm->profile > PROFILE_0) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 1235
1226 first_part_size = write_compressed_header(cpi, data); 1236 first_part_size = write_compressed_header(cpi, data);
1227 data += first_part_size; 1237 data += first_part_size;
1228 // TODO(jbb): Figure out what to do if first_part_size > 16 bits. 1238 // TODO(jbb): Figure out what to do if first_part_size > 16 bits.
1229 vp9_wb_write_literal(&saved_wb, (int)first_part_size, 16); 1239 vp9_wb_write_literal(&saved_wb, (int)first_part_size, 16);
1230 1240
1231 data += encode_tiles(cpi, data); 1241 data += encode_tiles(cpi, data);
1232 1242
1233 *size = data - dest; 1243 *size = data - dest;
1234 } 1244 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_bitstream.h ('k') | source/libvpx/vp9/encoder/vp9_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698