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