| 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 |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 } | 982 } |
| 983 | 983 |
| 984 static void write_frame_size_with_refs(VP9_COMP *cpi, | 984 static void write_frame_size_with_refs(VP9_COMP *cpi, |
| 985 struct vp9_write_bit_buffer *wb) { | 985 struct vp9_write_bit_buffer *wb) { |
| 986 VP9_COMMON *const cm = &cpi->common; | 986 VP9_COMMON *const cm = &cpi->common; |
| 987 int found = 0; | 987 int found = 0; |
| 988 | 988 |
| 989 MV_REFERENCE_FRAME ref_frame; | 989 MV_REFERENCE_FRAME ref_frame; |
| 990 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { | 990 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { |
| 991 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame); | 991 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, ref_frame); |
| 992 found = cm->width == cfg->y_crop_width && | |
| 993 cm->height == cfg->y_crop_height; | |
| 994 | 992 |
| 995 // Set "found" to 0 for temporal svc and for spatial svc key frame | 993 // Set "found" to 0 for temporal svc and for spatial svc key frame |
| 996 if (cpi->use_svc && | 994 if (cpi->use_svc && |
| 997 ((cpi->svc.number_temporal_layers > 1 && | 995 ((cpi->svc.number_temporal_layers > 1 && |
| 998 cpi->oxcf.rc_mode == VPX_CBR) || | 996 cpi->oxcf.rc_mode == VPX_CBR) || |
| 999 (cpi->svc.number_spatial_layers > 1 && | 997 (cpi->svc.number_spatial_layers > 1 && |
| 1000 cpi->svc.layer_context[cpi->svc.spatial_layer_id].is_key_frame) || | 998 cpi->svc.layer_context[cpi->svc.spatial_layer_id].is_key_frame) || |
| 1001 (is_two_pass_svc(cpi) && | 999 (is_two_pass_svc(cpi) && |
| 1002 cpi->svc.encode_empty_frame_state == ENCODING && | 1000 cpi->svc.encode_empty_frame_state == ENCODING && |
| 1003 cpi->svc.layer_context[0].frames_from_key_frame < | 1001 cpi->svc.layer_context[0].frames_from_key_frame < |
| 1004 cpi->svc.number_temporal_layers + 1))) { | 1002 cpi->svc.number_temporal_layers + 1))) { |
| 1005 found = 0; | 1003 found = 0; |
| 1004 } else if (cfg != NULL) { |
| 1005 found = cm->width == cfg->y_crop_width && |
| 1006 cm->height == cfg->y_crop_height; |
| 1006 } | 1007 } |
| 1007 vp9_wb_write_bit(wb, found); | 1008 vp9_wb_write_bit(wb, found); |
| 1008 if (found) { | 1009 if (found) { |
| 1009 break; | 1010 break; |
| 1010 } | 1011 } |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 if (!found) { | 1014 if (!found) { |
| 1014 vp9_wb_write_literal(wb, cm->width - 1, 16); | 1015 vp9_wb_write_literal(wb, cm->width - 1, 16); |
| 1015 vp9_wb_write_literal(wb, cm->height - 1, 16); | 1016 vp9_wb_write_literal(wb, cm->height - 1, 16); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 if (cm->profile > PROFILE_0) { | 1108 if (cm->profile > PROFILE_0) { |
| 1108 write_bitdepth_colorspace_sampling(cm, wb); | 1109 write_bitdepth_colorspace_sampling(cm, wb); |
| 1109 } | 1110 } |
| 1110 | 1111 |
| 1111 vp9_wb_write_literal(wb, get_refresh_mask(cpi), REF_FRAMES); | 1112 vp9_wb_write_literal(wb, get_refresh_mask(cpi), REF_FRAMES); |
| 1112 write_frame_size(cm, wb); | 1113 write_frame_size(cm, wb); |
| 1113 } else { | 1114 } else { |
| 1114 MV_REFERENCE_FRAME ref_frame; | 1115 MV_REFERENCE_FRAME ref_frame; |
| 1115 vp9_wb_write_literal(wb, get_refresh_mask(cpi), REF_FRAMES); | 1116 vp9_wb_write_literal(wb, get_refresh_mask(cpi), REF_FRAMES); |
| 1116 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { | 1117 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { |
| 1117 vp9_wb_write_literal(wb, get_ref_frame_idx(cpi, ref_frame), | 1118 assert(get_ref_frame_map_idx(cpi, ref_frame) != INVALID_IDX); |
| 1119 vp9_wb_write_literal(wb, get_ref_frame_map_idx(cpi, ref_frame), |
| 1118 REF_FRAMES_LOG2); | 1120 REF_FRAMES_LOG2); |
| 1119 vp9_wb_write_bit(wb, cm->ref_frame_sign_bias[ref_frame]); | 1121 vp9_wb_write_bit(wb, cm->ref_frame_sign_bias[ref_frame]); |
| 1120 } | 1122 } |
| 1121 | 1123 |
| 1122 write_frame_size_with_refs(cpi, wb); | 1124 write_frame_size_with_refs(cpi, wb); |
| 1123 | 1125 |
| 1124 vp9_wb_write_bit(wb, cm->allow_high_precision_mv); | 1126 vp9_wb_write_bit(wb, cm->allow_high_precision_mv); |
| 1125 | 1127 |
| 1126 fix_interp_filter(cm, cpi->td.counts); | 1128 fix_interp_filter(cm, cpi->td.counts); |
| 1127 write_interp_filter(cm->interp_filter, wb); | 1129 write_interp_filter(cm->interp_filter, wb); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 | 1238 |
| 1237 first_part_size = write_compressed_header(cpi, data); | 1239 first_part_size = write_compressed_header(cpi, data); |
| 1238 data += first_part_size; | 1240 data += first_part_size; |
| 1239 // TODO(jbb): Figure out what to do if first_part_size > 16 bits. | 1241 // TODO(jbb): Figure out what to do if first_part_size > 16 bits. |
| 1240 vp9_wb_write_literal(&saved_wb, (int)first_part_size, 16); | 1242 vp9_wb_write_literal(&saved_wb, (int)first_part_size, 16); |
| 1241 | 1243 |
| 1242 data += encode_tiles(cpi, data); | 1244 data += encode_tiles(cpi, data); |
| 1243 | 1245 |
| 1244 *size = data - dest; | 1246 *size = data - dest; |
| 1245 } | 1247 } |
| OLD | NEW |