blob: 981a951e6fa8f649d251b49f43e36d861bbdd460 [file] [log] [blame]
Yushin Cho77bba8d2016-11-04 16:36:56 -07001/*
2 * Copyright (c) 2001-2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
Nathan E. Egge1078dee2016-03-06 10:59:29 -050011
12#if !defined(_entcode_H)
13#define _entcode_H (1)
14#include <limits.h>
15#include <stddef.h>
16#include "av1/common/odintrin.h"
17
Nathan E. Egge1078dee2016-03-06 10:59:29 -050018/*OPT: od_ec_window must be at least 32 bits, but if you have fast arithmetic
19 on a larger type, you can speed up the decoder by using it here.*/
20typedef uint32_t od_ec_window;
21
22#define OD_EC_WINDOW_SIZE ((int)sizeof(od_ec_window) * CHAR_BIT)
23
Nathan E. Egge1078dee2016-03-06 10:59:29 -050024/*The number of bits to use for the range-coded part of unsigned integers.*/
25#define OD_EC_UINT_BITS (4)
26
27/*The resolution of fractional-precision bit usage measurements, i.e.,
28 3 => 1/8th bits.*/
29#define OD_BITRES (3)
30
Timothy B. Terriberryf9ef4f62017-08-25 11:24:18 -070031/*The value stored in an iCDF is 32768 minus the actual Q15 cumulative
32 probability (an "inverse" CDF).
Timothy B. Terriberry41b4f752017-03-07 17:45:30 -080033 This function converts from one representation to the other (and is its own
34 inverse).*/
Timothy B. Terriberry41b4f752017-03-07 17:45:30 -080035#define OD_ICDF(x) (32768U - (x))
Timothy B. Terriberry41b4f752017-03-07 17:45:30 -080036
Nathan E. Egge1078dee2016-03-06 10:59:29 -050037/*See entcode.c for further documentation.*/
38
39OD_WARN_UNUSED_RESULT uint32_t od_ec_tell_frac(uint32_t nbits_total,
40 uint32_t rng);
41
42#endif