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 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 } | 1017 } |
1018 | 1018 |
1019 static void write_sync_code(struct vp9_write_bit_buffer *wb) { | 1019 static void write_sync_code(struct vp9_write_bit_buffer *wb) { |
1020 vp9_wb_write_literal(wb, VP9_SYNC_CODE_0, 8); | 1020 vp9_wb_write_literal(wb, VP9_SYNC_CODE_0, 8); |
1021 vp9_wb_write_literal(wb, VP9_SYNC_CODE_1, 8); | 1021 vp9_wb_write_literal(wb, VP9_SYNC_CODE_1, 8); |
1022 vp9_wb_write_literal(wb, VP9_SYNC_CODE_2, 8); | 1022 vp9_wb_write_literal(wb, VP9_SYNC_CODE_2, 8); |
1023 } | 1023 } |
1024 | 1024 |
1025 static void write_profile(BITSTREAM_PROFILE profile, | 1025 static void write_profile(BITSTREAM_PROFILE profile, |
1026 struct vp9_write_bit_buffer *wb) { | 1026 struct vp9_write_bit_buffer *wb) { |
1027 assert(profile < MAX_PROFILES); | 1027 switch (profile) { |
1028 vp9_wb_write_bit(wb, profile & 1); | 1028 case PROFILE_0: |
1029 vp9_wb_write_bit(wb, profile >> 1); | 1029 vp9_wb_write_literal(wb, 0, 2); |
| 1030 break; |
| 1031 case PROFILE_1: |
| 1032 vp9_wb_write_literal(wb, 2, 2); |
| 1033 break; |
| 1034 case PROFILE_2: |
| 1035 vp9_wb_write_literal(wb, 1, 2); |
| 1036 break; |
| 1037 case PROFILE_3: |
| 1038 vp9_wb_write_literal(wb, 6, 3); |
| 1039 break; |
| 1040 default: |
| 1041 assert(0); |
| 1042 } |
1030 } | 1043 } |
1031 | 1044 |
1032 static void write_uncompressed_header(VP9_COMP *cpi, | 1045 static void write_uncompressed_header(VP9_COMP *cpi, |
1033 struct vp9_write_bit_buffer *wb) { | 1046 struct vp9_write_bit_buffer *wb) { |
1034 VP9_COMMON *const cm = &cpi->common; | 1047 VP9_COMMON *const cm = &cpi->common; |
1035 | 1048 |
1036 vp9_wb_write_literal(wb, VP9_FRAME_MARKER, 2); | 1049 vp9_wb_write_literal(wb, VP9_FRAME_MARKER, 2); |
1037 | 1050 |
1038 write_profile(cm->profile, wb); | 1051 write_profile(cm->profile, wb); |
1039 | 1052 |
1040 vp9_wb_write_bit(wb, 0); // show_existing_frame | 1053 vp9_wb_write_bit(wb, 0); // show_existing_frame |
1041 vp9_wb_write_bit(wb, cm->frame_type); | 1054 vp9_wb_write_bit(wb, cm->frame_type); |
1042 vp9_wb_write_bit(wb, cm->show_frame); | 1055 vp9_wb_write_bit(wb, cm->show_frame); |
1043 vp9_wb_write_bit(wb, cm->error_resilient_mode); | 1056 vp9_wb_write_bit(wb, cm->error_resilient_mode); |
1044 | 1057 |
1045 if (cm->frame_type == KEY_FRAME) { | 1058 if (cm->frame_type == KEY_FRAME) { |
1046 const COLOR_SPACE cs = UNKNOWN; | 1059 const COLOR_SPACE cs = UNKNOWN; |
1047 write_sync_code(wb); | 1060 write_sync_code(wb); |
1048 if (cm->profile > PROFILE_1) { | 1061 if (cm->profile > PROFILE_1) { |
1049 assert(cm->bit_depth > BITS_8); | 1062 assert(cm->bit_depth > BITS_8); |
1050 vp9_wb_write_bit(wb, cm->bit_depth - BITS_10); | 1063 vp9_wb_write_bit(wb, cm->bit_depth - BITS_10); |
1051 } | 1064 } |
1052 vp9_wb_write_literal(wb, cs, 3); | 1065 vp9_wb_write_literal(wb, cs, 3); |
1053 if (cs != SRGB) { | 1066 if (cs != SRGB) { |
1054 vp9_wb_write_bit(wb, 0); // 0: [16, 235] (i.e. xvYCC), 1: [0, 255] | 1067 vp9_wb_write_bit(wb, 0); // 0: [16, 235] (i.e. xvYCC), 1: [0, 255] |
1055 if (cm->profile >= PROFILE_1) { | 1068 if (cm->profile == PROFILE_1 || cm->profile == PROFILE_3) { |
1056 vp9_wb_write_bit(wb, cm->subsampling_x); | 1069 vp9_wb_write_bit(wb, cm->subsampling_x); |
1057 vp9_wb_write_bit(wb, cm->subsampling_y); | 1070 vp9_wb_write_bit(wb, cm->subsampling_y); |
1058 vp9_wb_write_bit(wb, 0); // has extra plane | 1071 vp9_wb_write_bit(wb, 0); // has extra plane |
1059 } | 1072 } |
1060 } else { | 1073 } else { |
1061 assert(cm->profile == PROFILE_1); | 1074 assert(cm->profile == PROFILE_1 || cm->profile == PROFILE_3); |
1062 vp9_wb_write_bit(wb, 0); // has extra plane | 1075 vp9_wb_write_bit(wb, 0); // has extra plane |
1063 } | 1076 } |
1064 | 1077 |
1065 write_frame_size(cm, wb); | 1078 write_frame_size(cm, wb); |
1066 } else { | 1079 } else { |
1067 if (!cm->show_frame) | 1080 if (!cm->show_frame) |
1068 vp9_wb_write_bit(wb, cm->intra_only); | 1081 vp9_wb_write_bit(wb, cm->intra_only); |
1069 | 1082 |
1070 if (!cm->error_resilient_mode) | 1083 if (!cm->error_resilient_mode) |
1071 vp9_wb_write_literal(wb, cm->reset_frame_context, 2); | 1084 vp9_wb_write_literal(wb, cm->reset_frame_context, 2); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 first_part_size = write_compressed_header(cpi, data); | 1217 first_part_size = write_compressed_header(cpi, data); |
1205 data += first_part_size; | 1218 data += first_part_size; |
1206 // TODO(jbb): Figure out what to do if first_part_size > 16 bits. | 1219 // TODO(jbb): Figure out what to do if first_part_size > 16 bits. |
1207 vp9_wb_write_literal(&saved_wb, (int)first_part_size, 16); | 1220 vp9_wb_write_literal(&saved_wb, (int)first_part_size, 16); |
1208 | 1221 |
1209 data += encode_tiles(cpi, data); | 1222 data += encode_tiles(cpi, data); |
1210 | 1223 |
1211 *size = data - dest; | 1224 *size = data - dest; |
1212 } | 1225 } |
1213 | 1226 |
OLD | NEW |