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