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 |
11 #include <assert.h> | 11 #include <assert.h> |
12 #include "vp9/encoder/vp9_boolhuff.h" | 12 #include "vp9/encoder/vp9_boolhuff.h" |
13 #include "vp9/common/vp9_entropy.h" | 13 #include "vp9/common/vp9_entropy.h" |
14 | 14 |
15 #if defined(SECTIONBITS_OUTPUT) | 15 #if defined(SECTIONBITS_OUTPUT) |
16 unsigned __int64 Sectionbits[500]; | 16 unsigned __int64 Sectionbits[500]; |
17 | 17 |
18 #endif | 18 #endif |
19 | 19 |
20 #ifdef ENTROPY_STATS | 20 #ifdef ENTROPY_STATS |
21 unsigned int active_section = 0; | 21 unsigned int active_section = 0; |
22 #endif | 22 #endif |
23 | 23 |
24 const unsigned int vp9_prob_cost[256] = { | 24 const unsigned int vp9_prob_cost[256] = { |
25 2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161, 1129,
1099, 1072, 1046, | 25 2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161, |
26 1023, 1000, 979, 959, 940, 922, 905, 889, 873, 858, 843, 829, 816,
803, 790, 778, | 26 1129, 1099, 1072, 1046, 1023, 1000, 979, 959, 940, 922, 905, 889, |
27 767, 755, 744, 733, 723, 713, 703, 693, 684, 675, 666, 657, 649,
641, 633, 625, | 27 873, 858, 843, 829, 816, 803, 790, 778, 767, 755, 744, 733, |
28 617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541, 534,
528, 522, 516, | 28 723, 713, 703, 693, 684, 675, 666, 657, 649, 641, 633, 625, |
29 511, 505, 499, 494, 488, 483, 477, 472, 467, 462, 457, 452, 447,
442, 437, 433, | 29 617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541, |
30 428, 424, 419, 415, 410, 406, 401, 397, 393, 389, 385, 381, 377,
373, 369, 365, | 30 534, 528, 522, 516, 511, 505, 499, 494, 488, 483, 477, 472, |
31 361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321, 317,
314, 311, 307, | 31 467, 462, 457, 452, 447, 442, 437, 433, 428, 424, 419, 415, |
32 304, 301, 297, 294, 291, 288, 285, 281, 278, 275, 272, 269, 266,
263, 260, 257, | 32 410, 406, 401, 397, 393, 389, 385, 381, 377, 373, 369, 365, |
33 255, 252, 249, 246, 243, 240, 238, 235, 232, 229, 227, 224, 221,
219, 216, 214, | 33 361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321, |
34 211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184, 181,
179, 177, 174, | 34 317, 314, 311, 307, 304, 301, 297, 294, 291, 288, 285, 281, |
35 172, 170, 168, 165, 163, 161, 159, 156, 154, 152, 150, 148, 145,
143, 141, 139, | 35 278, 275, 272, 269, 266, 263, 260, 257, 255, 252, 249, 246, |
36 137, 135, 133, 131, 129, 127, 125, 123, 121, 119, 117, 115, 113,
111, 109, 107, | 36 243, 240, 238, 235, 232, 229, 227, 224, 221, 219, 216, 214, |
37 105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84, 82,
81, 79, 77, | 37 211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184, |
38 75, 73, 72, 70, 68, 66, 65, 63, 61, 60, 58, 56, 55,
53, 51, 50, | 38 181, 179, 177, 174, 172, 170, 168, 165, 163, 161, 159, 156, |
39 48, 46, 45, 43, 41, 40, 38, 37, 35, 33, 32, 30, 29,
27, 25, 24, | 39 154, 152, 150, 148, 145, 143, 141, 139, 137, 135, 133, 131, |
40 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4,
3, 1, 1 | 40 129, 127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107, |
41 }; | 41 105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84, |
| 42 82, 81, 79, 77, 75, 73, 72, 70, 68, 66, 65, 63, |
| 43 61, 60, 58, 56, 55, 53, 51, 50, 48, 46, 45, 43, |
| 44 41, 40, 38, 37, 35, 33, 32, 30, 29, 27, 25, 24, |
| 45 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, |
| 46 4, 3, 1, 1}; |
42 | 47 |
43 void vp9_start_encode(vp9_writer *br, uint8_t *source) { | 48 void vp9_start_encode(vp9_writer *br, uint8_t *source) { |
44 br->lowvalue = 0; | 49 br->lowvalue = 0; |
45 br->range = 255; | 50 br->range = 255; |
46 br->value = 0; | 51 br->value = 0; |
47 br->count = -24; | 52 br->count = -24; |
48 br->buffer = source; | 53 br->buffer = source; |
49 br->pos = 0; | 54 br->pos = 0; |
50 vp9_write_bit(br, 0); | 55 vp9_write_bit(br, 0); |
51 } | 56 } |
52 | 57 |
53 void vp9_stop_encode(vp9_writer *br) { | 58 void vp9_stop_encode(vp9_writer *br) { |
54 int i; | 59 int i; |
55 | 60 |
56 for (i = 0; i < 32; i++) | 61 for (i = 0; i < 32; i++) |
57 vp9_write_bit(br, 0); | 62 vp9_write_bit(br, 0); |
58 | 63 |
59 // Ensure there's no ambigous collision with any index marker bytes | 64 // Ensure there's no ambigous collision with any index marker bytes |
60 if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0) | 65 if ((br->buffer[br->pos - 1] & 0xe0) == 0xc0) |
61 br->buffer[br->pos++] = 0; | 66 br->buffer[br->pos++] = 0; |
62 } | 67 } |
63 | 68 |
OLD | NEW |