Clear existing format issue in the codebase
Fix the clang-format warnings on the existing codes. Change-Id: I8e9e781b6f68f41a7fbd0a2116f6b35290d73dc8
This commit is contained in:
Родитель
00b46f7e02
Коммит
f4b2926d01
|
@ -23,34 +23,27 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#include "./config.h"
|
||||
#endif
|
||||
|
||||
#include "entcode.h"
|
||||
#include "aom_dsp/entcode.h"
|
||||
|
||||
/*CDFs for uniform probability distributions of small sizes (2 through 16,
|
||||
inclusive).*/
|
||||
const uint16_t OD_UNIFORM_CDFS_Q15[135] = {
|
||||
16384, 32768,
|
||||
10923, 21845, 32768,
|
||||
8192, 16384, 24576, 32768,
|
||||
6554, 13107, 19661, 26214, 32768,
|
||||
5461, 10923, 16384, 21845, 27307, 32768,
|
||||
4681, 9362, 14043, 18725, 23406, 28087, 32768,
|
||||
4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768,
|
||||
3641, 7282, 10923, 14564, 18204, 21845, 25486, 29127, 32768,
|
||||
3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768,
|
||||
2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768,
|
||||
2731, 5461, 8192, 10923, 13653, 16384, 19115, 21845, 24576, 27307, 30037,
|
||||
32768,
|
||||
2521, 5041, 7562, 10082, 12603, 15124, 17644, 20165, 22686, 25206, 27727,
|
||||
30247, 32768,
|
||||
2341, 4681, 7022, 9362, 11703, 14043, 16384, 18725, 21065, 23406, 25746,
|
||||
28087, 30427, 32768,
|
||||
2185, 4369, 6554, 8738, 10923, 13107, 15292, 17476, 19661, 21845, 24030,
|
||||
26214, 28399, 30583, 32768,
|
||||
2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
|
||||
24576, 26624, 28672, 30720, 32768
|
||||
16384, 32768, 10923, 21845, 32768, 8192, 16384, 24576, 32768, 6554, 13107,
|
||||
19661, 26214, 32768, 5461, 10923, 16384, 21845, 27307, 32768, 4681, 9362,
|
||||
14043, 18725, 23406, 28087, 32768, 4096, 8192, 12288, 16384, 20480, 24576,
|
||||
28672, 32768, 3641, 7282, 10923, 14564, 18204, 21845, 25486, 29127, 32768,
|
||||
3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 2979,
|
||||
5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 2731,
|
||||
5461, 8192, 10923, 13653, 16384, 19115, 21845, 24576, 27307, 30037, 32768,
|
||||
2521, 5041, 7562, 10082, 12603, 15124, 17644, 20165, 22686, 25206, 27727,
|
||||
30247, 32768, 2341, 4681, 7022, 9362, 11703, 14043, 16384, 18725, 21065,
|
||||
23406, 25746, 28087, 30427, 32768, 2185, 4369, 6554, 8738, 10923, 13107,
|
||||
15292, 17476, 19661, 21845, 24030, 26214, 28399, 30583, 32768, 2048, 4096,
|
||||
6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528, 24576, 26624,
|
||||
28672, 30720, 32768
|
||||
};
|
||||
|
||||
/*Given the current total integer number of bits used and the current value of
|
||||
|
@ -82,7 +75,7 @@ uint32_t od_ec_tell_frac(uint32_t nbits_total, uint32_t rng) {
|
|||
l = 0;
|
||||
for (i = OD_BITRES; i-- > 0;) {
|
||||
int b;
|
||||
rng = rng*rng >> 15;
|
||||
rng = rng * rng >> 15;
|
||||
b = (int)(rng >> 16);
|
||||
l = l << 1 | b;
|
||||
rng >>= b;
|
||||
|
|
|
@ -23,10 +23,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||
|
||||
#if !defined(_entcode_H)
|
||||
# define _entcode_H (1)
|
||||
# include <limits.h>
|
||||
# include <stddef.h>
|
||||
# include "av1/common/odintrin.h"
|
||||
#define _entcode_H (1)
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include "av1/common/odintrin.h"
|
||||
|
||||
/*Set this flag 1 to enable a "reduced overhead" version of the entropy coder.
|
||||
This uses a partition function that more accurately follows the input
|
||||
|
@ -81,39 +81,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
|||
(vs. 0.022% for the division-based partition function with r much greater
|
||||
than ft).
|
||||
It improves performance on ntt-short-1 by about 0.3%.*/
|
||||
# define OD_EC_REDUCED_OVERHEAD (1)
|
||||
#define OD_EC_REDUCED_OVERHEAD (1)
|
||||
|
||||
/*OPT: od_ec_window must be at least 32 bits, but if you have fast arithmetic
|
||||
on a larger type, you can speed up the decoder by using it here.*/
|
||||
typedef uint32_t od_ec_window;
|
||||
|
||||
# define OD_EC_WINDOW_SIZE ((int)sizeof(od_ec_window)*CHAR_BIT)
|
||||
#define OD_EC_WINDOW_SIZE ((int)sizeof(od_ec_window) * CHAR_BIT)
|
||||
|
||||
/*Unsigned subtraction with unsigned saturation.
|
||||
This implementation of the macro is intentionally chosen to increase the
|
||||
number of common subexpressions in the reduced-overhead partition function.
|
||||
This matters for C code, but it would not for hardware with a saturating
|
||||
subtraction instruction.*/
|
||||
#define OD_SUBSATU(a, b) ((a) - OD_MINI(a, b))
|
||||
#define OD_SUBSATU(a, b) ((a)-OD_MINI(a, b))
|
||||
|
||||
/*The number of bits to use for the range-coded part of unsigned integers.*/
|
||||
# define OD_EC_UINT_BITS (4)
|
||||
#define OD_EC_UINT_BITS (4)
|
||||
|
||||
/*The resolution of fractional-precision bit usage measurements, i.e.,
|
||||
3 => 1/8th bits.*/
|
||||
# define OD_BITRES (3)
|
||||
#define OD_BITRES (3)
|
||||
|
||||
extern const uint16_t OD_UNIFORM_CDFS_Q15[135];
|
||||
|
||||
/*Returns a Q15 CDF for a uniform probability distribution of the given size.
|
||||
n: The size of the distribution.
|
||||
This must be at least 2, and no more than 16.*/
|
||||
# define OD_UNIFORM_CDF_Q15(n) \
|
||||
(OD_UNIFORM_CDFS_Q15 + ((n)*((n) - 1) >> 1) - 1)
|
||||
#define OD_UNIFORM_CDF_Q15(n) (OD_UNIFORM_CDFS_Q15 + ((n) * ((n)-1) >> 1) - 1)
|
||||
|
||||
/*See entcode.c for further documentation.*/
|
||||
|
||||
OD_WARN_UNUSED_RESULT uint32_t od_ec_tell_frac(uint32_t nbits_total,
|
||||
uint32_t rng);
|
||||
uint32_t rng);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,12 +23,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#include "./config.h"
|
||||
#endif
|
||||
|
||||
#include "entdec.h"
|
||||
#include "aom_dsp/entdec.h"
|
||||
#if OD_ACCOUNTING
|
||||
# include "accounting.h"
|
||||
#include "./accounting.h"
|
||||
#endif
|
||||
|
||||
/*A range decoder.
|
||||
|
@ -87,7 +87,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
|||
}*/
|
||||
|
||||
#if OD_ACCOUNTING
|
||||
# define od_ec_dec_normalize(dec, dif, rng, ret, str) od_ec_dec_normalize_(dec, dif, rng, ret, str)
|
||||
#define od_ec_dec_normalize(dec, dif, rng, ret, str) \
|
||||
od_ec_dec_normalize_(dec, dif, rng, ret, str)
|
||||
static void od_process_accounting(od_ec_dec *dec, char *str) {
|
||||
if (dec->acct != NULL) {
|
||||
uint32_t tell;
|
||||
|
@ -98,7 +99,8 @@ static void od_process_accounting(od_ec_dec *dec, char *str) {
|
|||
}
|
||||
}
|
||||
#else
|
||||
# define od_ec_dec_normalize(dec, dif, rng, ret, str) od_ec_dec_normalize_(dec, dif, rng, ret)
|
||||
#define od_ec_dec_normalize(dec, dif, rng, ret, str) \
|
||||
od_ec_dec_normalize_(dec, dif, rng, ret)
|
||||
#endif
|
||||
|
||||
/*This is meant to be a large, positive constant that can still be efficiently
|
||||
|
@ -139,8 +141,8 @@ static void od_ec_dec_refill(od_ec_dec *dec) {
|
|||
ret: The value to return.
|
||||
Return: ret.
|
||||
This allows the compiler to jump to this function via a tail-call.*/
|
||||
static int od_ec_dec_normalize_(od_ec_dec *dec,
|
||||
od_ec_window dif, unsigned rng, int ret OD_ACC_STR) {
|
||||
static int od_ec_dec_normalize_(od_ec_dec *dec, od_ec_window dif, unsigned rng,
|
||||
int ret OD_ACC_STR) {
|
||||
int d;
|
||||
OD_ASSERT(rng <= 65535U);
|
||||
d = 16 - OD_ILOG_NZ(rng);
|
||||
|
@ -157,8 +159,8 @@ static int od_ec_dec_normalize_(od_ec_dec *dec,
|
|||
/*Initializes the decoder.
|
||||
buf: The input buffer to use.
|
||||
Return: 0 on success, or a negative value on error.*/
|
||||
void od_ec_dec_init(od_ec_dec *dec,
|
||||
const unsigned char *buf, uint32_t storage) {
|
||||
void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf,
|
||||
uint32_t storage) {
|
||||
dec->buf = buf;
|
||||
dec->eptr = buf + storage;
|
||||
dec->end_window = 0;
|
||||
|
@ -205,7 +207,7 @@ int od_ec_decode_bool_(od_ec_dec *dec, unsigned fz, unsigned ft OD_ACC_STR) {
|
|||
unsigned d;
|
||||
unsigned e;
|
||||
d = r - ft;
|
||||
e = OD_SUBSATU(2*d, ft);
|
||||
e = OD_SUBSATU(2 * d, ft);
|
||||
v = fz + OD_MINI(fz, e) + OD_MINI(OD_SUBSATU(fz, e) >> 1, d);
|
||||
}
|
||||
#else
|
||||
|
@ -254,7 +256,8 @@ int od_ec_decode_bool_q15_(od_ec_dec *dec, unsigned fz OD_ACC_STR) {
|
|||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.
|
||||
Return: The decoded symbol s.*/
|
||||
int od_ec_decode_cdf_(od_ec_dec *dec, const uint16_t *cdf, int nsyms OD_ACC_STR) {
|
||||
int od_ec_decode_cdf_(od_ec_dec *dec, const uint16_t *cdf,
|
||||
int nsyms OD_ACC_STR) {
|
||||
od_ec_window dif;
|
||||
unsigned r;
|
||||
unsigned c;
|
||||
|
@ -285,7 +288,7 @@ int od_ec_decode_cdf_(od_ec_dec *dec, const uint16_t *cdf, int nsyms OD_ACC_STR)
|
|||
c = (unsigned)(dif >> (OD_EC_WINDOW_SIZE - 16));
|
||||
q = OD_MAXI((int)(c >> 1), (int)(c - d));
|
||||
#if OD_EC_REDUCED_OVERHEAD
|
||||
e = OD_SUBSATU(2*d, ft);
|
||||
e = OD_SUBSATU(2 * d, ft);
|
||||
/*The correctness of this inverse partition function is not obvious, but it
|
||||
was checked exhaustively for all possible values of r, ft, and c.
|
||||
TODO: It should be possible to optimize this better than the compiler,
|
||||
|
@ -293,10 +296,10 @@ int od_ec_decode_cdf_(od_ec_dec *dec, const uint16_t *cdf, int nsyms OD_ACC_STR)
|
|||
will not use them).
|
||||
It would also be nice to get rid of the 32-bit dividend, as it requires a
|
||||
32x32->64 bit multiply to invert.*/
|
||||
q = OD_MAXI((int)q, (int)((2*(int32_t)c + 1 - (int32_t)e)/3));
|
||||
q = OD_MAXI((int)q, (int)((2 * (int32_t)c + 1 - (int32_t)e) / 3));
|
||||
#endif
|
||||
q >>= s;
|
||||
OD_ASSERT(q < ft >> s);
|
||||
OD_ASSERT(q<ft>> s);
|
||||
fl = 0;
|
||||
ret = 0;
|
||||
for (fh = cdf[ret]; fh <= q; fh = cdf[++ret]) fl = fh;
|
||||
|
@ -323,8 +326,8 @@ int od_ec_decode_cdf_(od_ec_dec *dec, const uint16_t *cdf, int nsyms OD_ACC_STR)
|
|||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.
|
||||
Return: The decoded symbol s.*/
|
||||
int od_ec_decode_cdf_unscaled_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms OD_ACC_STR) {
|
||||
int od_ec_decode_cdf_unscaled_(od_ec_dec *dec, const uint16_t *cdf,
|
||||
int nsyms OD_ACC_STR) {
|
||||
od_ec_window dif;
|
||||
unsigned r;
|
||||
unsigned c;
|
||||
|
@ -359,12 +362,12 @@ int od_ec_decode_cdf_unscaled_(od_ec_dec *dec,
|
|||
c = (unsigned)(dif >> (OD_EC_WINDOW_SIZE - 16));
|
||||
q = OD_MAXI((int)(c >> 1), (int)(c - d));
|
||||
#if OD_EC_REDUCED_OVERHEAD
|
||||
e = OD_SUBSATU(2*d, ft);
|
||||
e = OD_SUBSATU(2 * d, ft);
|
||||
/*TODO: See TODO above.*/
|
||||
q = OD_MAXI((int)q, (int)((2*(int32_t)c + 1 - (int32_t)e)/3));
|
||||
q = OD_MAXI((int)q, (int)((2 * (int32_t)c + 1 - (int32_t)e) / 3));
|
||||
#endif
|
||||
q >>= s;
|
||||
OD_ASSERT(q < ft >> s);
|
||||
OD_ASSERT(q<ft>> s);
|
||||
fl = 0;
|
||||
ret = 0;
|
||||
for (fh = cdf[ret]; fh <= q; fh = cdf[++ret]) fl = fh;
|
||||
|
@ -399,8 +402,8 @@ int od_ec_decode_cdf_unscaled_(od_ec_dec *dec,
|
|||
ftb: The number of bits of precision in the cumulative distribution.
|
||||
This must be no more than 15.
|
||||
Return: The decoded symbol s.*/
|
||||
int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms, unsigned ftb OD_ACC_STR) {
|
||||
int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec, const uint16_t *cdf,
|
||||
int nsyms, unsigned ftb OD_ACC_STR) {
|
||||
od_ec_window dif;
|
||||
unsigned r;
|
||||
unsigned c;
|
||||
|
@ -419,9 +422,8 @@ int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
|||
ret = -1;
|
||||
do {
|
||||
u = v;
|
||||
v = cdf[++ret]*(uint32_t)r >> ftb;
|
||||
}
|
||||
while (v <= c);
|
||||
v = cdf[++ret] * (uint32_t)r >> ftb;
|
||||
} while (v <= c);
|
||||
OD_ASSERT(v <= r);
|
||||
r = v - u;
|
||||
dif -= (od_ec_window)u << (OD_EC_WINDOW_SIZE - 16);
|
||||
|
@ -441,8 +443,8 @@ int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
|||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.
|
||||
Return: The decoded symbol s.*/
|
||||
int od_ec_decode_cdf_q15_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms OD_ACC_STR) {
|
||||
int od_ec_decode_cdf_q15_(od_ec_dec *dec, const uint16_t *cdf,
|
||||
int nsyms OD_ACC_STR) {
|
||||
return od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, 15, acc_str);
|
||||
}
|
||||
|
||||
|
@ -494,10 +496,9 @@ uint32_t od_ec_dec_bits_(od_ec_dec *dec, unsigned ftb OD_ACC_STR) {
|
|||
available = OD_EC_LOTS_OF_BITS;
|
||||
break;
|
||||
}
|
||||
window |= (od_ec_window)*--eptr << available;
|
||||
window |= (od_ec_window) * --eptr << available;
|
||||
available += 8;
|
||||
}
|
||||
while (available <= OD_EC_WINDOW_SIZE - 8);
|
||||
} while (available <= OD_EC_WINDOW_SIZE - 8);
|
||||
dec->eptr = eptr;
|
||||
}
|
||||
ret = (uint32_t)window & (((uint32_t)1 << ftb) - 1);
|
||||
|
@ -518,8 +519,8 @@ uint32_t od_ec_dec_bits_(od_ec_dec *dec, unsigned ftb OD_ACC_STR) {
|
|||
This will always be slightly larger than the exact value (e.g., all
|
||||
rounding error is in the positive direction).*/
|
||||
int od_ec_dec_tell(od_ec_dec *dec) {
|
||||
return ((dec->end - dec->eptr) + (dec->bptr - dec->buf))*8
|
||||
- dec->cnt - dec->nend_bits + dec->tell_offs;
|
||||
return ((dec->end - dec->eptr) + (dec->bptr - dec->buf)) * 8 - dec->cnt -
|
||||
dec->nend_bits + dec->tell_offs;
|
||||
}
|
||||
|
||||
/*Returns the number of bits "used" by the decoded symbols so far.
|
||||
|
|
|
@ -23,11 +23,11 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||
|
||||
#if !defined(_entdec_H)
|
||||
# define _entdec_H (1)
|
||||
# include <limits.h>
|
||||
# include "entcode.h"
|
||||
#define _entdec_H (1)
|
||||
#include <limits.h>
|
||||
#include "aom_dsp/entcode.h"
|
||||
#if OD_ACCOUNTING
|
||||
# include "accounting.h"
|
||||
#include "./accounting.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -37,25 +37,33 @@ extern "C" {
|
|||
typedef struct od_ec_dec od_ec_dec;
|
||||
|
||||
#if OD_ACCOUNTING
|
||||
# define OD_ACC_STR , char *acc_str
|
||||
# define od_ec_decode_bool(dec, fz, ft, str) od_ec_decode_bool_(dec, fz, ft, str)
|
||||
# define od_ec_decode_bool_q15(dec, fz, str) od_ec_decode_bool_q15_(dec, fz, str)
|
||||
# define od_ec_decode_cdf(dec, cdf, nsyms, str) od_ec_decode_cdf_(dec, cdf, nsyms, str)
|
||||
# define od_ec_decode_cdf_q15(dec, cdf, nsyms, str) od_ec_decode_cdf_q15_(dec, cdf, nsyms, str)
|
||||
# define od_ec_decode_cdf_unscaled(dec, cdf, nsyms, str) od_ec_decode_cdf_unscaled_(dec, cdf, nsyms, str)
|
||||
# define od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, ftb, str) od_ec_decode_cdf_unscaled_dyadic_(dec, cdf, nsyms, ftb, str)
|
||||
# define od_ec_dec_uint(dec, ft, str) od_ec_dec_uint_(dec, ft, str)
|
||||
# define od_ec_dec_bits(dec, ftb, str) od_ec_dec_bits_(dec, ftb, str)
|
||||
#define OD_ACC_STR , char *acc_str
|
||||
#define od_ec_decode_bool(dec, fz, ft, str) od_ec_decode_bool_(dec, fz, ft, str)
|
||||
#define od_ec_decode_bool_q15(dec, fz, str) od_ec_decode_bool_q15_(dec, fz, str)
|
||||
#define od_ec_decode_cdf(dec, cdf, nsyms, str) \
|
||||
od_ec_decode_cdf_(dec, cdf, nsyms, str)
|
||||
#define od_ec_decode_cdf_q15(dec, cdf, nsyms, str) \
|
||||
od_ec_decode_cdf_q15_(dec, cdf, nsyms, str)
|
||||
#define od_ec_decode_cdf_unscaled(dec, cdf, nsyms, str) \
|
||||
od_ec_decode_cdf_unscaled_(dec, cdf, nsyms, str)
|
||||
#define od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, ftb, str) \
|
||||
od_ec_decode_cdf_unscaled_dyadic_(dec, cdf, nsyms, ftb, str)
|
||||
#define od_ec_dec_uint(dec, ft, str) od_ec_dec_uint_(dec, ft, str)
|
||||
#define od_ec_dec_bits(dec, ftb, str) od_ec_dec_bits_(dec, ftb, str)
|
||||
#else
|
||||
# define OD_ACC_STR
|
||||
# define od_ec_decode_bool(dec, fz, ft, str) od_ec_decode_bool_(dec, fz, ft)
|
||||
# define od_ec_decode_bool_q15(dec, fz, str) od_ec_decode_bool_q15_(dec, fz)
|
||||
# define od_ec_decode_cdf(dec, cdf, nsyms, str) od_ec_decode_cdf_(dec, cdf, nsyms)
|
||||
# define od_ec_decode_cdf_q15(dec, cdf, nsyms, str) od_ec_decode_cdf_q15_(dec, cdf, nsyms)
|
||||
# define od_ec_decode_cdf_unscaled(dec, cdf, nsyms, str) od_ec_decode_cdf_unscaled_(dec, cdf, nsyms)
|
||||
# define od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, ftb, str) od_ec_decode_cdf_unscaled_dyadic_(dec, cdf, nsyms, ftb)
|
||||
# define od_ec_dec_uint(dec, ft, str) od_ec_dec_uint_(dec, ft)
|
||||
# define od_ec_dec_bits(dec, ftb, str) od_ec_dec_bits_(dec, ftb)
|
||||
#define OD_ACC_STR
|
||||
#define od_ec_decode_bool(dec, fz, ft, str) od_ec_decode_bool_(dec, fz, ft)
|
||||
#define od_ec_decode_bool_q15(dec, fz, str) od_ec_decode_bool_q15_(dec, fz)
|
||||
#define od_ec_decode_cdf(dec, cdf, nsyms, str) \
|
||||
od_ec_decode_cdf_(dec, cdf, nsyms)
|
||||
#define od_ec_decode_cdf_q15(dec, cdf, nsyms, str) \
|
||||
od_ec_decode_cdf_q15_(dec, cdf, nsyms)
|
||||
#define od_ec_decode_cdf_unscaled(dec, cdf, nsyms, str) \
|
||||
od_ec_decode_cdf_unscaled_(dec, cdf, nsyms)
|
||||
#define od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, ftb, str) \
|
||||
od_ec_decode_cdf_unscaled_dyadic_(dec, cdf, nsyms, ftb)
|
||||
#define od_ec_dec_uint(dec, ft, str) od_ec_dec_uint_(dec, ft)
|
||||
#define od_ec_dec_bits(dec, ftb, str) od_ec_dec_bits_(dec, ftb)
|
||||
#endif
|
||||
|
||||
/*The entropy decoder context.*/
|
||||
|
@ -93,29 +101,37 @@ struct od_ec_dec {
|
|||
|
||||
/*See entdec.c for further documentation.*/
|
||||
|
||||
void od_ec_dec_init(od_ec_dec *dec,
|
||||
const unsigned char *buf, uint32_t storage)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf, uint32_t storage)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_(od_ec_dec *dec, unsigned fz,
|
||||
unsigned ft OD_ACC_STR) OD_ARG_NONNULL(1);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_q15_(od_ec_dec *dec, unsigned fz OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms OD_ACC_STR) OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
unsigned ft OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_q15_(od_ec_dec *dec,
|
||||
unsigned fz OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_(od_ec_dec *dec, const uint16_t *cdf,
|
||||
int nsyms OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_q15_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms OD_ACC_STR) OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
const uint16_t *cdf,
|
||||
int nsyms OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_unscaled_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms OD_ACC_STR) OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
||||
const uint16_t *cdf, int nsyms, unsigned _ftb OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
const uint16_t *cdf,
|
||||
int nsyms OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_unscaled_dyadic_(
|
||||
od_ec_dec *dec, const uint16_t *cdf, int nsyms, unsigned _ftb OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
|
||||
OD_WARN_UNUSED_RESULT uint32_t od_ec_dec_uint_(od_ec_dec *dec,
|
||||
uint32_t ft OD_ACC_STR) OD_ARG_NONNULL(1);
|
||||
uint32_t ft OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1);
|
||||
|
||||
OD_WARN_UNUSED_RESULT uint32_t od_ec_dec_bits_(od_ec_dec *dec,
|
||||
unsigned ftb OD_ACC_STR) OD_ARG_NONNULL(1);
|
||||
unsigned ftb OD_ACC_STR)
|
||||
OD_ARG_NONNULL(1);
|
||||
|
||||
OD_WARN_UNUSED_RESULT int od_ec_dec_tell(od_ec_dec *dec) OD_ARG_NONNULL(1);
|
||||
uint32_t od_ec_dec_tell_frac(od_ec_dec *dec) OD_ARG_NONNULL(1);
|
||||
|
|
|
@ -23,12 +23,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#include "./config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "entenc.h"
|
||||
#include "aom_dsp/entenc.h"
|
||||
|
||||
/*A range encoder.
|
||||
See entdec.c and the references for implementation details \cite{Mar79,MNW98}.
|
||||
|
@ -60,8 +60,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
|||
necessary), and stores them back in the encoder context.
|
||||
low: The new value of low.
|
||||
rng: The new value of the range.*/
|
||||
static void od_ec_enc_normalize(od_ec_enc *enc,
|
||||
od_ec_window low, unsigned rng) {
|
||||
static void od_ec_enc_normalize(od_ec_enc *enc, od_ec_window low,
|
||||
unsigned rng) {
|
||||
int d;
|
||||
int c;
|
||||
int s;
|
||||
|
@ -83,8 +83,8 @@ static void od_ec_enc_normalize(od_ec_enc *enc,
|
|||
storage = enc->precarry_storage;
|
||||
offs = enc->offs;
|
||||
if (offs + 2 > storage) {
|
||||
storage = 2*storage + 2;
|
||||
buf = (uint16_t *)realloc(buf, sizeof(*buf)*storage);
|
||||
storage = 2 * storage + 2;
|
||||
buf = (uint16_t *)realloc(buf, sizeof(*buf) * storage);
|
||||
if (buf == NULL) {
|
||||
enc->error = -1;
|
||||
enc->offs = 0;
|
||||
|
@ -117,14 +117,13 @@ static void od_ec_enc_normalize(od_ec_enc *enc,
|
|||
size: The initial size of the buffer, in bytes.*/
|
||||
void od_ec_enc_init(od_ec_enc *enc, uint32_t size) {
|
||||
od_ec_enc_reset(enc);
|
||||
enc->buf = (unsigned char *)malloc(sizeof(*enc->buf)*size);
|
||||
enc->buf = (unsigned char *)malloc(sizeof(*enc->buf) * size);
|
||||
enc->storage = size;
|
||||
if (size > 0 && enc->buf == NULL) {
|
||||
enc->storage = 0;
|
||||
enc->error = -1;
|
||||
}
|
||||
enc->precarry_buf =
|
||||
(uint16_t *)malloc(sizeof(*enc->precarry_buf)*size);
|
||||
enc->precarry_buf = (uint16_t *)malloc(sizeof(*enc->precarry_buf) * size);
|
||||
enc->precarry_storage = size;
|
||||
if (size > 0 && enc->precarry_buf == NULL) {
|
||||
enc->precarry_storage = 0;
|
||||
|
@ -170,8 +169,8 @@ void od_ec_enc_clear(od_ec_enc *enc) {
|
|||
value will fall.
|
||||
ft: The sum of the frequencies of all the symbols.
|
||||
This must be at least 16384, and no more than 32768.*/
|
||||
static void od_ec_encode(od_ec_enc *enc,
|
||||
unsigned fl, unsigned fh, unsigned ft) {
|
||||
static void od_ec_encode(od_ec_enc *enc, unsigned fl, unsigned fh,
|
||||
unsigned ft) {
|
||||
od_ec_window l;
|
||||
unsigned r;
|
||||
int s;
|
||||
|
@ -194,7 +193,7 @@ static void od_ec_encode(od_ec_enc *enc,
|
|||
#if OD_EC_REDUCED_OVERHEAD
|
||||
{
|
||||
unsigned e;
|
||||
e = OD_SUBSATU(2*d, ft);
|
||||
e = OD_SUBSATU(2 * d, ft);
|
||||
u = fl + OD_MINI(fl, e) + OD_MINI(OD_SUBSATU(fl, e) >> 1, d);
|
||||
v = fh + OD_MINI(fh, e) + OD_MINI(OD_SUBSATU(fh, e) >> 1, d);
|
||||
}
|
||||
|
@ -206,7 +205,7 @@ static void od_ec_encode(od_ec_enc *enc,
|
|||
l += u;
|
||||
od_ec_enc_normalize(enc, l, r);
|
||||
#if OD_MEASURE_EC_OVERHEAD
|
||||
enc->entropy -= OD_LOG2((double)(fh - fl)/ft);
|
||||
enc->entropy -= OD_LOG2((double)(fh - fl) / ft);
|
||||
enc->nb_symbols++;
|
||||
#endif
|
||||
}
|
||||
|
@ -237,7 +236,7 @@ static void od_ec_encode_q15(od_ec_enc *enc, unsigned fl, unsigned fh) {
|
|||
l += u;
|
||||
od_ec_enc_normalize(enc, l, r);
|
||||
#if OD_MEASURE_EC_OVERHEAD
|
||||
enc->entropy -= OD_LOG2((double)(fh - fl)/32768.);
|
||||
enc->entropy -= OD_LOG2((double)(fh - fl) / 32768.);
|
||||
enc->nb_symbols++;
|
||||
#endif
|
||||
}
|
||||
|
@ -251,8 +250,8 @@ static void od_ec_encode_q15(od_ec_enc *enc, unsigned fl, unsigned fh) {
|
|||
be encoded.
|
||||
ft: The sum of the frequencies of all the symbols.
|
||||
This must be at least 2 and no more than 32768.*/
|
||||
static void od_ec_encode_unscaled(od_ec_enc *enc,
|
||||
unsigned fl, unsigned fh, unsigned ft) {
|
||||
static void od_ec_encode_unscaled(od_ec_enc *enc, unsigned fl, unsigned fh,
|
||||
unsigned ft) {
|
||||
int s;
|
||||
OD_ASSERT(fl < fh);
|
||||
OD_ASSERT(fh <= ft);
|
||||
|
@ -288,7 +287,7 @@ void od_ec_encode_bool(od_ec_enc *enc, int val, unsigned fz, unsigned ft) {
|
|||
unsigned d;
|
||||
unsigned e;
|
||||
d = r - ft;
|
||||
e = OD_SUBSATU(2*d, ft);
|
||||
e = OD_SUBSATU(2 * d, ft);
|
||||
v = fz + OD_MINI(fz, e) + OD_MINI(OD_SUBSATU(fz, e) >> 1, d);
|
||||
}
|
||||
#else
|
||||
|
@ -298,7 +297,7 @@ void od_ec_encode_bool(od_ec_enc *enc, int val, unsigned fz, unsigned ft) {
|
|||
r = val ? r - v : v;
|
||||
od_ec_enc_normalize(enc, l, r);
|
||||
#if OD_MEASURE_EC_OVERHEAD
|
||||
enc->entropy -= OD_LOG2((double)(val ? ft - fz : fz)/ft);
|
||||
enc->entropy -= OD_LOG2((double)(val ? ft - fz : fz) / ft);
|
||||
enc->nb_symbols++;
|
||||
#endif
|
||||
}
|
||||
|
@ -325,7 +324,7 @@ void od_ec_encode_bool_q15(od_ec_enc *enc, int val, unsigned fz) {
|
|||
r = val ? r - v : v;
|
||||
od_ec_enc_normalize(enc, l, r);
|
||||
#if OD_MEASURE_EC_OVERHEAD
|
||||
enc->entropy -= OD_LOG2((double)(val ? 32768 - fz : fz)/32768.);
|
||||
enc->entropy -= OD_LOG2((double)(val ? 32768 - fz : fz) / 32768.);
|
||||
enc->nb_symbols++;
|
||||
#endif
|
||||
}
|
||||
|
@ -338,8 +337,7 @@ void od_ec_encode_bool_q15(od_ec_enc *enc, int val, unsigned fz) {
|
|||
must be at least 16384, and no more than 32768.
|
||||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.*/
|
||||
void od_ec_encode_cdf(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms) {
|
||||
void od_ec_encode_cdf(od_ec_enc *enc, int s, const uint16_t *cdf, int nsyms) {
|
||||
OD_ASSERT(s >= 0);
|
||||
OD_ASSERT(s < nsyms);
|
||||
od_ec_encode(enc, s > 0 ? cdf[s - 1] : 0, cdf[s], cdf[nsyms - 1]);
|
||||
|
@ -358,8 +356,8 @@ void od_ec_encode_cdf(od_ec_enc *enc, int s,
|
|||
must be exactly 32768.
|
||||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.*/
|
||||
void od_ec_encode_cdf_q15(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms) {
|
||||
void od_ec_encode_cdf_q15(od_ec_enc *enc, int s, const uint16_t *cdf,
|
||||
int nsyms) {
|
||||
(void)nsyms;
|
||||
OD_ASSERT(s >= 0);
|
||||
OD_ASSERT(s < nsyms);
|
||||
|
@ -375,8 +373,8 @@ void od_ec_encode_cdf_q15(od_ec_enc *enc, int s,
|
|||
must be at least 2, and no more than 32768.
|
||||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.*/
|
||||
void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms) {
|
||||
void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s, const uint16_t *cdf,
|
||||
int nsyms) {
|
||||
OD_ASSERT(s >= 0);
|
||||
OD_ASSERT(s < nsyms);
|
||||
od_ec_encode_unscaled(enc, s > 0 ? cdf[s - 1] : 0, cdf[s], cdf[nsyms - 1]);
|
||||
|
@ -394,14 +392,15 @@ void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s,
|
|||
ftb: The number of bits of precision in the cumulative distribution.
|
||||
This must be no more than 15.*/
|
||||
void od_ec_encode_cdf_unscaled_dyadic(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms, unsigned ftb) {
|
||||
const uint16_t *cdf, int nsyms,
|
||||
unsigned ftb) {
|
||||
(void)nsyms;
|
||||
OD_ASSERT(s >= 0);
|
||||
OD_ASSERT(s < nsyms);
|
||||
OD_ASSERT(ftb <= 15);
|
||||
OD_ASSERT(cdf[nsyms - 1] == 1U << ftb);
|
||||
od_ec_encode_q15(enc,
|
||||
s > 0 ? cdf[s - 1] << (15 - ftb) : 0, cdf[s] << (15 - ftb));
|
||||
od_ec_encode_q15(enc, s > 0 ? cdf[s - 1] << (15 - ftb) : 0,
|
||||
cdf[s] << (15 - ftb));
|
||||
}
|
||||
|
||||
/*Encodes a raw unsigned integer in the stream.
|
||||
|
@ -420,8 +419,9 @@ void od_ec_enc_uint(od_ec_enc *enc, uint32_t fl, uint32_t ft) {
|
|||
ft1 = (int)(ft >> ftb) + 1;
|
||||
od_ec_encode_cdf_q15(enc, (int)(fl >> ftb), OD_UNIFORM_CDF_Q15(ft1), ft1);
|
||||
od_ec_enc_bits(enc, fl & (((uint32_t)1 << ftb) - 1), ftb);
|
||||
} else {
|
||||
od_ec_encode_cdf_q15(enc, (int)fl, OD_UNIFORM_CDF_Q15(ft), (int)ft);
|
||||
}
|
||||
else od_ec_encode_cdf_q15(enc, (int)fl, OD_UNIFORM_CDF_Q15(ft), (int)ft);
|
||||
}
|
||||
|
||||
/*Encodes a sequence of raw bits in the stream.
|
||||
|
@ -448,15 +448,15 @@ void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb) {
|
|||
if (end_offs + (OD_EC_WINDOW_SIZE >> 3) >= storage) {
|
||||
unsigned char *new_buf;
|
||||
uint32_t new_storage;
|
||||
new_storage = 2*storage + (OD_EC_WINDOW_SIZE >> 3);
|
||||
new_buf = (unsigned char *)malloc(sizeof(*new_buf)*new_storage);
|
||||
new_storage = 2 * storage + (OD_EC_WINDOW_SIZE >> 3);
|
||||
new_buf = (unsigned char *)malloc(sizeof(*new_buf) * new_storage);
|
||||
if (new_buf == NULL) {
|
||||
enc->error = -1;
|
||||
enc->end_offs = 0;
|
||||
return;
|
||||
}
|
||||
OD_COPY(new_buf + new_storage - end_offs,
|
||||
buf + storage - end_offs, end_offs);
|
||||
OD_COPY(new_buf + new_storage - end_offs, buf + storage - end_offs,
|
||||
end_offs);
|
||||
storage = new_storage;
|
||||
free(buf);
|
||||
enc->buf = buf = new_buf;
|
||||
|
@ -467,8 +467,7 @@ void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb) {
|
|||
buf[storage - ++end_offs] = (unsigned char)end_window;
|
||||
end_window >>= 8;
|
||||
nend_bits -= 8;
|
||||
}
|
||||
while (nend_bits >= 8);
|
||||
} while (nend_bits >= 8);
|
||||
enc->end_offs = end_offs;
|
||||
}
|
||||
OD_ASSERT(nend_bits + ftb <= OD_EC_WINDOW_SIZE);
|
||||
|
@ -503,19 +502,19 @@ void od_ec_enc_patch_initial_bits(od_ec_enc *enc, unsigned val, int nbits) {
|
|||
if (enc->offs > 0) {
|
||||
/*The first byte has been finalized.*/
|
||||
enc->precarry_buf[0] =
|
||||
(uint16_t)((enc->precarry_buf[0] & ~mask) | val << shift);
|
||||
}
|
||||
else if (9 + enc->cnt + (enc->rng == 0x8000) > nbits) {
|
||||
(uint16_t)((enc->precarry_buf[0] & ~mask) | val << shift);
|
||||
} else if (9 + enc->cnt + (enc->rng == 0x8000) > nbits) {
|
||||
/*The first byte has yet to be output.*/
|
||||
enc->low = (enc->low & ~((od_ec_window)mask << (16 + enc->cnt))) |
|
||||
(od_ec_window)val << (16 + enc->cnt + shift);
|
||||
(od_ec_window)val << (16 + enc->cnt + shift);
|
||||
} else {
|
||||
/*The encoder hasn't even encoded _nbits of data yet.*/
|
||||
enc->error = -1;
|
||||
}
|
||||
/*The encoder hasn't even encoded _nbits of data yet.*/
|
||||
else enc->error = -1;
|
||||
}
|
||||
|
||||
#if OD_MEASURE_EC_OVERHEAD
|
||||
# include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/*Indicates that there are no more symbols to encode.
|
||||
|
@ -543,9 +542,10 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
|||
uint32_t tell;
|
||||
/* Don't count the 1 bit we lose to raw bits as overhead. */
|
||||
tell = od_ec_enc_tell(enc) - 1;
|
||||
fprintf(stderr, "overhead: %f%%\n", 100*(tell-enc->entropy)/enc->entropy);
|
||||
fprintf(stderr, "overhead: %f%%\n",
|
||||
100 * (tell - enc->entropy) / enc->entropy);
|
||||
fprintf(stderr, "efficiency: %f bits/symbol\n",
|
||||
(double)tell/enc->nb_symbols);
|
||||
(double)tell / enc->nb_symbols);
|
||||
}
|
||||
#endif
|
||||
/*We output the minimum number of bits that ensures that the symbols encoded
|
||||
|
@ -568,8 +568,8 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
|||
unsigned n;
|
||||
storage = enc->precarry_storage;
|
||||
if (offs + ((s + 7) >> 3) > storage) {
|
||||
storage = storage*2 + ((s + 7) >> 3);
|
||||
buf = (uint16_t *)realloc(buf, sizeof(*buf)*storage);
|
||||
storage = storage * 2 + ((s + 7) >> 3);
|
||||
buf = (uint16_t *)realloc(buf, sizeof(*buf) * storage);
|
||||
if (buf == NULL) {
|
||||
enc->error = -1;
|
||||
return NULL;
|
||||
|
@ -585,8 +585,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
|||
s -= 8;
|
||||
c -= 8;
|
||||
n >>= 8;
|
||||
}
|
||||
while (s > 0);
|
||||
} while (s > 0);
|
||||
}
|
||||
/*Make sure there's enough room for the entropy-coded bits and the raw
|
||||
bits.*/
|
||||
|
@ -599,7 +598,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
|||
c = OD_MAXI((nend_bits - s + 7) >> 3, 0);
|
||||
if (offs + end_offs + c > storage) {
|
||||
storage = offs + end_offs + c;
|
||||
out = (unsigned char *)realloc(out, sizeof(*out)*storage);
|
||||
out = (unsigned char *)realloc(out, sizeof(*out) * storage);
|
||||
if (out == NULL) {
|
||||
enc->error = -1;
|
||||
return NULL;
|
||||
|
@ -651,7 +650,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
|||
int od_ec_enc_tell(od_ec_enc *enc) {
|
||||
/*The 10 here counteracts the offset of -9 baked into cnt, and adds 1 extra
|
||||
bit, which we reserve for terminating the stream.*/
|
||||
return (enc->offs + enc->end_offs)*8 + enc->cnt + enc->nend_bits + 10;
|
||||
return (enc->offs + enc->end_offs) * 8 + enc->cnt + enc->nend_bits + 10;
|
||||
}
|
||||
|
||||
/*Returns the number of bits "used" by the encoded symbols so far.
|
||||
|
|
|
@ -23,9 +23,9 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||
|
||||
#if !defined(_entenc_H)
|
||||
# define _entenc_H (1)
|
||||
# include <stddef.h>
|
||||
# include "entcode.h"
|
||||
#define _entenc_H (1)
|
||||
#include <stddef.h>
|
||||
#include "aom_dsp/entcode.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -76,33 +76,34 @@ void od_ec_enc_reset(od_ec_enc *enc) OD_ARG_NONNULL(1);
|
|||
void od_ec_enc_clear(od_ec_enc *enc) OD_ARG_NONNULL(1);
|
||||
|
||||
void od_ec_encode_bool(od_ec_enc *enc, int val, unsigned fz, unsigned _ft)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_ARG_NONNULL(1);
|
||||
void od_ec_encode_bool_q15(od_ec_enc *enc, int val, unsigned fz_q15)
|
||||
OD_ARG_NONNULL(1);
|
||||
void od_ec_encode_cdf(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms) OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
void od_ec_encode_cdf_q15(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms) OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms) OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
OD_ARG_NONNULL(1);
|
||||
void od_ec_encode_cdf(od_ec_enc *enc, int s, const uint16_t *cdf, int nsyms)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
void od_ec_encode_cdf_q15(od_ec_enc *enc, int s, const uint16_t *cdf, int nsyms)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s, const uint16_t *cdf,
|
||||
int nsyms) OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
void od_ec_encode_cdf_unscaled_dyadic(od_ec_enc *enc, int s,
|
||||
const uint16_t *cdf, int nsyms, unsigned ftb)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(3);
|
||||
const uint16_t *cdf, int nsyms,
|
||||
unsigned ftb) OD_ARG_NONNULL(1)
|
||||
OD_ARG_NONNULL(3);
|
||||
|
||||
void od_ec_enc_uint(od_ec_enc *enc, uint32_t fl, uint32_t ft)
|
||||
OD_ARG_NONNULL(1);
|
||||
void od_ec_enc_uint(od_ec_enc *enc, uint32_t fl, uint32_t ft) OD_ARG_NONNULL(1);
|
||||
|
||||
void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_ARG_NONNULL(1);
|
||||
|
||||
void od_ec_enc_patch_initial_bits(od_ec_enc *enc, unsigned val, int nbits)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_WARN_UNUSED_RESULT unsigned char *od_ec_enc_done(od_ec_enc *enc,
|
||||
uint32_t *nbytes) OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
uint32_t *nbytes)
|
||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||
|
||||
OD_WARN_UNUSED_RESULT int od_ec_enc_tell(od_ec_enc *enc) OD_ARG_NONNULL(1);
|
||||
OD_WARN_UNUSED_RESULT uint32_t od_ec_enc_tell_frac(od_ec_enc *enc)
|
||||
OD_ARG_NONNULL(1);
|
||||
OD_ARG_NONNULL(1);
|
||||
|
||||
void od_ec_enc_checkpoint(od_ec_enc *dst, const od_ec_enc *src);
|
||||
void od_ec_enc_rollback(od_ec_enc *dst, const od_ec_enc *src);
|
||||
|
|
|
@ -63,69 +63,68 @@ extern uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2];
|
|||
#define OD_LOG2 AOMLOG2
|
||||
|
||||
/*Enable special features for gcc and compatible compilers.*/
|
||||
# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
||||
# define OD_GNUC_PREREQ(maj, min, pat) \
|
||||
((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= ((maj) << 16) + ((min) << 8) + pat)
|
||||
# else
|
||||
# define OD_GNUC_PREREQ(maj, min, pat) (0)
|
||||
# endif
|
||||
|
||||
#if OD_GNUC_PREREQ(3, 4, 0)
|
||||
# define OD_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
||||
#define OD_GNUC_PREREQ(maj, min, pat) \
|
||||
((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= \
|
||||
((maj) << 16) + ((min) << 8) + pat) // NOLINT
|
||||
#else
|
||||
# define OD_WARN_UNUSED_RESULT
|
||||
#define OD_GNUC_PREREQ(maj, min, pat) (0)
|
||||
#endif
|
||||
|
||||
#if OD_GNUC_PREREQ(3, 4, 0)
|
||||
# define OD_ARG_NONNULL(x) __attribute__((__nonnull__(x)))
|
||||
#define OD_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
|
||||
#else
|
||||
# define OD_ARG_NONNULL(x)
|
||||
#define OD_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
# if defined(OD_ENABLE_ASSERTIONS)
|
||||
# if OD_GNUC_PREREQ(2, 5, 0)
|
||||
#if OD_GNUC_PREREQ(3, 4, 0)
|
||||
#define OD_ARG_NONNULL(x) __attribute__((__nonnull__(x)))
|
||||
#else
|
||||
#define OD_ARG_NONNULL(x)
|
||||
#endif
|
||||
|
||||
#if defined(OD_ENABLE_ASSERTIONS)
|
||||
#if OD_GNUC_PREREQ(2, 5, 0)
|
||||
__attribute__((noreturn))
|
||||
# endif
|
||||
#endif
|
||||
void od_fatal_impl(const char *_str, const char *_file, int _line);
|
||||
|
||||
# define OD_FATAL(_str) (od_fatal_impl(_str, __FILE__, __LINE__))
|
||||
#define OD_FATAL(_str) (od_fatal_impl(_str, __FILE__, __LINE__))
|
||||
|
||||
# define OD_ASSERT(_cond) \
|
||||
do { \
|
||||
if (!(_cond)) { \
|
||||
OD_FATAL("assertion failed: " # _cond); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
#define OD_ASSERT(_cond) \
|
||||
do { \
|
||||
if (!(_cond)) { \
|
||||
OD_FATAL("assertion failed: " #_cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
# define OD_ASSERT2(_cond, _message) \
|
||||
do { \
|
||||
if (!(_cond)) { \
|
||||
OD_FATAL("assertion failed: " # _cond "\n" _message); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
#define OD_ASSERT2(_cond, _message) \
|
||||
do { \
|
||||
if (!(_cond)) { \
|
||||
OD_FATAL("assertion failed: " #_cond "\n" _message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
# define OD_ALWAYS_TRUE(_cond) OD_ASSERT(_cond)
|
||||
#define OD_ALWAYS_TRUE(_cond) OD_ASSERT(_cond)
|
||||
|
||||
# else
|
||||
# define OD_ASSERT(_cond)
|
||||
# define OD_ASSERT2(_cond, _message)
|
||||
# define OD_ALWAYS_TRUE(_cond) ((void)(_cond))
|
||||
# endif
|
||||
#else
|
||||
#define OD_ASSERT(_cond)
|
||||
#define OD_ASSERT2(_cond, _message)
|
||||
#define OD_ALWAYS_TRUE(_cond) ((void)(_cond))
|
||||
#endif
|
||||
|
||||
/** Copy n elements of memory from src to dst. The 0* term provides
|
||||
compile-time type checking */
|
||||
#if !defined(OVERRIDE_OD_COPY)
|
||||
# define OD_COPY(dst, src, n) \
|
||||
(memcpy((dst), (src), sizeof(*(dst))*(n) + 0*((dst) - (src))))
|
||||
#define OD_COPY(dst, src, n) \
|
||||
(memcpy((dst), (src), sizeof(*(dst)) * (n) + 0 * ((dst) - (src))))
|
||||
#endif
|
||||
|
||||
/** Copy n elements of memory from src to dst, allowing overlapping regions.
|
||||
The 0* term provides compile-time type checking */
|
||||
#if !defined(OVERRIDE_OD_MOVE)
|
||||
# define OD_MOVE(dst, src, n) \
|
||||
(memmove((dst), (src), sizeof(*(dst))*(n) + 0*((dst) - (src)) ))
|
||||
#define OD_MOVE(dst, src, n) \
|
||||
(memmove((dst), (src), sizeof(*(dst)) * (n) + 0 * ((dst) - (src))))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Загрузка…
Ссылка в новой задаче