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.*/
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
#include "./config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "entcode.h"
|
#include "aom_dsp/entcode.h"
|
||||||
|
|
||||||
/*CDFs for uniform probability distributions of small sizes (2 through 16,
|
/*CDFs for uniform probability distributions of small sizes (2 through 16,
|
||||||
inclusive).*/
|
inclusive).*/
|
||||||
const uint16_t OD_UNIFORM_CDFS_Q15[135] = {
|
const uint16_t OD_UNIFORM_CDFS_Q15[135] = {
|
||||||
16384, 32768,
|
16384, 32768, 10923, 21845, 32768, 8192, 16384, 24576, 32768, 6554, 13107,
|
||||||
10923, 21845, 32768,
|
19661, 26214, 32768, 5461, 10923, 16384, 21845, 27307, 32768, 4681, 9362,
|
||||||
8192, 16384, 24576, 32768,
|
14043, 18725, 23406, 28087, 32768, 4096, 8192, 12288, 16384, 20480, 24576,
|
||||||
6554, 13107, 19661, 26214, 32768,
|
28672, 32768, 3641, 7282, 10923, 14564, 18204, 21845, 25486, 29127, 32768,
|
||||||
5461, 10923, 16384, 21845, 27307, 32768,
|
3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 2979,
|
||||||
4681, 9362, 14043, 18725, 23406, 28087, 32768,
|
5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 2731,
|
||||||
4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768,
|
5461, 8192, 10923, 13653, 16384, 19115, 21845, 24576, 27307, 30037, 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,
|
2521, 5041, 7562, 10082, 12603, 15124, 17644, 20165, 22686, 25206, 27727,
|
||||||
30247, 32768,
|
30247, 32768, 2341, 4681, 7022, 9362, 11703, 14043, 16384, 18725, 21065,
|
||||||
2341, 4681, 7022, 9362, 11703, 14043, 16384, 18725, 21065, 23406, 25746,
|
23406, 25746, 28087, 30427, 32768, 2185, 4369, 6554, 8738, 10923, 13107,
|
||||||
28087, 30427, 32768,
|
15292, 17476, 19661, 21845, 24030, 26214, 28399, 30583, 32768, 2048, 4096,
|
||||||
2185, 4369, 6554, 8738, 10923, 13107, 15292, 17476, 19661, 21845, 24030,
|
6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528, 24576, 26624,
|
||||||
26214, 28399, 30583, 32768,
|
28672, 30720, 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
|
/*Given the current total integer number of bits used and the current value of
|
||||||
|
|
|
@ -108,8 +108,7 @@ extern const uint16_t OD_UNIFORM_CDFS_Q15[135];
|
||||||
/*Returns a Q15 CDF for a uniform probability distribution of the given size.
|
/*Returns a Q15 CDF for a uniform probability distribution of the given size.
|
||||||
n: The size of the distribution.
|
n: The size of the distribution.
|
||||||
This must be at least 2, and no more than 16.*/
|
This must be at least 2, and no more than 16.*/
|
||||||
# define OD_UNIFORM_CDF_Q15(n) \
|
#define OD_UNIFORM_CDF_Q15(n) (OD_UNIFORM_CDFS_Q15 + ((n) * ((n)-1) >> 1) - 1)
|
||||||
(OD_UNIFORM_CDFS_Q15 + ((n)*((n) - 1) >> 1) - 1)
|
|
||||||
|
|
||||||
/*See entcode.c for further documentation.*/
|
/*See entcode.c for further documentation.*/
|
||||||
|
|
||||||
|
|
|
@ -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.*/
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
#include "./config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "entdec.h"
|
#include "aom_dsp/entdec.h"
|
||||||
#if OD_ACCOUNTING
|
#if OD_ACCOUNTING
|
||||||
# include "accounting.h"
|
#include "./accounting.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*A range decoder.
|
/*A range decoder.
|
||||||
|
@ -87,7 +87,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
#if OD_ACCOUNTING
|
#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) {
|
static void od_process_accounting(od_ec_dec *dec, char *str) {
|
||||||
if (dec->acct != NULL) {
|
if (dec->acct != NULL) {
|
||||||
uint32_t tell;
|
uint32_t tell;
|
||||||
|
@ -98,7 +99,8 @@ static void od_process_accounting(od_ec_dec *dec, char *str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
/*This is meant to be a large, positive constant that can still be efficiently
|
/*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.
|
ret: The value to return.
|
||||||
Return: ret.
|
Return: ret.
|
||||||
This allows the compiler to jump to this function via a tail-call.*/
|
This allows the compiler to jump to this function via a tail-call.*/
|
||||||
static int od_ec_dec_normalize_(od_ec_dec *dec,
|
static int od_ec_dec_normalize_(od_ec_dec *dec, od_ec_window dif, unsigned rng,
|
||||||
od_ec_window dif, unsigned rng, int ret OD_ACC_STR) {
|
int ret OD_ACC_STR) {
|
||||||
int d;
|
int d;
|
||||||
OD_ASSERT(rng <= 65535U);
|
OD_ASSERT(rng <= 65535U);
|
||||||
d = 16 - OD_ILOG_NZ(rng);
|
d = 16 - OD_ILOG_NZ(rng);
|
||||||
|
@ -157,8 +159,8 @@ static int od_ec_dec_normalize_(od_ec_dec *dec,
|
||||||
/*Initializes the decoder.
|
/*Initializes the decoder.
|
||||||
buf: The input buffer to use.
|
buf: The input buffer to use.
|
||||||
Return: 0 on success, or a negative value on error.*/
|
Return: 0 on success, or a negative value on error.*/
|
||||||
void od_ec_dec_init(od_ec_dec *dec,
|
void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf,
|
||||||
const unsigned char *buf, uint32_t storage) {
|
uint32_t storage) {
|
||||||
dec->buf = buf;
|
dec->buf = buf;
|
||||||
dec->eptr = buf + storage;
|
dec->eptr = buf + storage;
|
||||||
dec->end_window = 0;
|
dec->end_window = 0;
|
||||||
|
@ -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.
|
nsyms: The number of symbols in the alphabet.
|
||||||
This should be at most 16.
|
This should be at most 16.
|
||||||
Return: The decoded symbol s.*/
|
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;
|
od_ec_window dif;
|
||||||
unsigned r;
|
unsigned r;
|
||||||
unsigned c;
|
unsigned c;
|
||||||
|
@ -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.
|
nsyms: The number of symbols in the alphabet.
|
||||||
This should be at most 16.
|
This should be at most 16.
|
||||||
Return: The decoded symbol s.*/
|
Return: The decoded symbol s.*/
|
||||||
int od_ec_decode_cdf_unscaled_(od_ec_dec *dec,
|
int od_ec_decode_cdf_unscaled_(od_ec_dec *dec, const uint16_t *cdf,
|
||||||
const uint16_t *cdf, int nsyms OD_ACC_STR) {
|
int nsyms OD_ACC_STR) {
|
||||||
od_ec_window dif;
|
od_ec_window dif;
|
||||||
unsigned r;
|
unsigned r;
|
||||||
unsigned c;
|
unsigned c;
|
||||||
|
@ -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.
|
ftb: The number of bits of precision in the cumulative distribution.
|
||||||
This must be no more than 15.
|
This must be no more than 15.
|
||||||
Return: The decoded symbol s.*/
|
Return: The decoded symbol s.*/
|
||||||
int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec, const uint16_t *cdf,
|
||||||
const uint16_t *cdf, int nsyms, unsigned ftb OD_ACC_STR) {
|
int nsyms, unsigned ftb OD_ACC_STR) {
|
||||||
od_ec_window dif;
|
od_ec_window dif;
|
||||||
unsigned r;
|
unsigned r;
|
||||||
unsigned c;
|
unsigned c;
|
||||||
|
@ -420,8 +423,7 @@ int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
||||||
do {
|
do {
|
||||||
u = v;
|
u = v;
|
||||||
v = cdf[++ret] * (uint32_t)r >> ftb;
|
v = cdf[++ret] * (uint32_t)r >> ftb;
|
||||||
}
|
} while (v <= c);
|
||||||
while (v <= c);
|
|
||||||
OD_ASSERT(v <= r);
|
OD_ASSERT(v <= r);
|
||||||
r = v - u;
|
r = v - u;
|
||||||
dif -= (od_ec_window)u << (OD_EC_WINDOW_SIZE - 16);
|
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.
|
nsyms: The number of symbols in the alphabet.
|
||||||
This should be at most 16.
|
This should be at most 16.
|
||||||
Return: The decoded symbol s.*/
|
Return: The decoded symbol s.*/
|
||||||
int od_ec_decode_cdf_q15_(od_ec_dec *dec,
|
int od_ec_decode_cdf_q15_(od_ec_dec *dec, const uint16_t *cdf,
|
||||||
const uint16_t *cdf, int nsyms OD_ACC_STR) {
|
int nsyms OD_ACC_STR) {
|
||||||
return od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, 15, acc_str);
|
return od_ec_decode_cdf_unscaled_dyadic(dec, cdf, nsyms, 15, acc_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,8 +498,7 @@ uint32_t od_ec_dec_bits_(od_ec_dec *dec, unsigned ftb OD_ACC_STR) {
|
||||||
}
|
}
|
||||||
window |= (od_ec_window) * --eptr << available;
|
window |= (od_ec_window) * --eptr << available;
|
||||||
available += 8;
|
available += 8;
|
||||||
}
|
} while (available <= OD_EC_WINDOW_SIZE - 8);
|
||||||
while (available <= OD_EC_WINDOW_SIZE - 8);
|
|
||||||
dec->eptr = eptr;
|
dec->eptr = eptr;
|
||||||
}
|
}
|
||||||
ret = (uint32_t)window & (((uint32_t)1 << ftb) - 1);
|
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
|
This will always be slightly larger than the exact value (e.g., all
|
||||||
rounding error is in the positive direction).*/
|
rounding error is in the positive direction).*/
|
||||||
int od_ec_dec_tell(od_ec_dec *dec) {
|
int od_ec_dec_tell(od_ec_dec *dec) {
|
||||||
return ((dec->end - dec->eptr) + (dec->bptr - dec->buf))*8
|
return ((dec->end - dec->eptr) + (dec->bptr - dec->buf)) * 8 - dec->cnt -
|
||||||
- dec->cnt - dec->nend_bits + dec->tell_offs;
|
dec->nend_bits + dec->tell_offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Returns the number of bits "used" by the decoded symbols so far.
|
/*Returns the number of bits "used" by the decoded symbols so far.
|
||||||
|
|
|
@ -25,9 +25,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||||
#if !defined(_entdec_H)
|
#if !defined(_entdec_H)
|
||||||
#define _entdec_H (1)
|
#define _entdec_H (1)
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
# include "entcode.h"
|
#include "aom_dsp/entcode.h"
|
||||||
#if OD_ACCOUNTING
|
#if OD_ACCOUNTING
|
||||||
# include "accounting.h"
|
#include "./accounting.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -40,20 +40,28 @@ typedef struct od_ec_dec od_ec_dec;
|
||||||
#define OD_ACC_STR , char *acc_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(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_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(dec, cdf, nsyms, str) \
|
||||||
# define od_ec_decode_cdf_q15(dec, cdf, nsyms, str) od_ec_decode_cdf_q15_(dec, cdf, nsyms, str)
|
od_ec_decode_cdf_(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_q15(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)
|
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_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_ec_dec_bits(dec, ftb, str) od_ec_dec_bits_(dec, ftb, str)
|
||||||
#else
|
#else
|
||||||
#define OD_ACC_STR
|
#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(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_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(dec, cdf, nsyms, str) \
|
||||||
# define od_ec_decode_cdf_q15(dec, cdf, nsyms, str) od_ec_decode_cdf_q15_(dec, cdf, nsyms)
|
od_ec_decode_cdf_(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_q15(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)
|
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_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_ec_dec_bits(dec, ftb, str) od_ec_dec_bits_(dec, ftb)
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,29 +101,37 @@ struct od_ec_dec {
|
||||||
|
|
||||||
/*See entdec.c for further documentation.*/
|
/*See entdec.c for further documentation.*/
|
||||||
|
|
||||||
void od_ec_dec_init(od_ec_dec *dec,
|
void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf, uint32_t storage)
|
||||||
const unsigned char *buf, uint32_t storage)
|
|
||||||
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||||
|
|
||||||
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_(od_ec_dec *dec, unsigned fz,
|
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_(od_ec_dec *dec, unsigned fz,
|
||||||
unsigned ft OD_ACC_STR) OD_ARG_NONNULL(1);
|
unsigned ft OD_ACC_STR)
|
||||||
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_q15_(od_ec_dec *dec, unsigned fz OD_ACC_STR)
|
|
||||||
OD_ARG_NONNULL(1);
|
OD_ARG_NONNULL(1);
|
||||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_(od_ec_dec *dec,
|
OD_WARN_UNUSED_RESULT int od_ec_decode_bool_q15_(od_ec_dec *dec,
|
||||||
const uint16_t *cdf, int nsyms OD_ACC_STR) OD_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
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,
|
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,
|
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);
|
const uint16_t *cdf,
|
||||||
OD_WARN_UNUSED_RESULT int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
|
int nsyms OD_ACC_STR)
|
||||||
const uint16_t *cdf, int nsyms, unsigned _ftb 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_ARG_NONNULL(1) OD_ARG_NONNULL(2);
|
||||||
|
|
||||||
OD_WARN_UNUSED_RESULT uint32_t od_ec_dec_uint_(od_ec_dec *dec,
|
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,
|
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);
|
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);
|
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.*/
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
#include "./config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "entenc.h"
|
#include "aom_dsp/entenc.h"
|
||||||
|
|
||||||
/*A range encoder.
|
/*A range encoder.
|
||||||
See entdec.c and the references for implementation details \cite{Mar79,MNW98}.
|
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.
|
necessary), and stores them back in the encoder context.
|
||||||
low: The new value of low.
|
low: The new value of low.
|
||||||
rng: The new value of the range.*/
|
rng: The new value of the range.*/
|
||||||
static void od_ec_enc_normalize(od_ec_enc *enc,
|
static void od_ec_enc_normalize(od_ec_enc *enc, od_ec_window low,
|
||||||
od_ec_window low, unsigned rng) {
|
unsigned rng) {
|
||||||
int d;
|
int d;
|
||||||
int c;
|
int c;
|
||||||
int s;
|
int s;
|
||||||
|
@ -123,8 +123,7 @@ void od_ec_enc_init(od_ec_enc *enc, uint32_t size) {
|
||||||
enc->storage = 0;
|
enc->storage = 0;
|
||||||
enc->error = -1;
|
enc->error = -1;
|
||||||
}
|
}
|
||||||
enc->precarry_buf =
|
enc->precarry_buf = (uint16_t *)malloc(sizeof(*enc->precarry_buf) * size);
|
||||||
(uint16_t *)malloc(sizeof(*enc->precarry_buf)*size);
|
|
||||||
enc->precarry_storage = size;
|
enc->precarry_storage = size;
|
||||||
if (size > 0 && enc->precarry_buf == NULL) {
|
if (size > 0 && enc->precarry_buf == NULL) {
|
||||||
enc->precarry_storage = 0;
|
enc->precarry_storage = 0;
|
||||||
|
@ -170,8 +169,8 @@ void od_ec_enc_clear(od_ec_enc *enc) {
|
||||||
value will fall.
|
value will fall.
|
||||||
ft: The sum of the frequencies of all the symbols.
|
ft: The sum of the frequencies of all the symbols.
|
||||||
This must be at least 16384, and no more than 32768.*/
|
This must be at least 16384, and no more than 32768.*/
|
||||||
static void od_ec_encode(od_ec_enc *enc,
|
static void od_ec_encode(od_ec_enc *enc, unsigned fl, unsigned fh,
|
||||||
unsigned fl, unsigned fh, unsigned ft) {
|
unsigned ft) {
|
||||||
od_ec_window l;
|
od_ec_window l;
|
||||||
unsigned r;
|
unsigned r;
|
||||||
int s;
|
int s;
|
||||||
|
@ -251,8 +250,8 @@ static void od_ec_encode_q15(od_ec_enc *enc, unsigned fl, unsigned fh) {
|
||||||
be encoded.
|
be encoded.
|
||||||
ft: The sum of the frequencies of all the symbols.
|
ft: The sum of the frequencies of all the symbols.
|
||||||
This must be at least 2 and no more than 32768.*/
|
This must be at least 2 and no more than 32768.*/
|
||||||
static void od_ec_encode_unscaled(od_ec_enc *enc,
|
static void od_ec_encode_unscaled(od_ec_enc *enc, unsigned fl, unsigned fh,
|
||||||
unsigned fl, unsigned fh, unsigned ft) {
|
unsigned ft) {
|
||||||
int s;
|
int s;
|
||||||
OD_ASSERT(fl < fh);
|
OD_ASSERT(fl < fh);
|
||||||
OD_ASSERT(fh <= ft);
|
OD_ASSERT(fh <= ft);
|
||||||
|
@ -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.
|
must be at least 16384, and no more than 32768.
|
||||||
nsyms: The number of symbols in the alphabet.
|
nsyms: The number of symbols in the alphabet.
|
||||||
This should be at most 16.*/
|
This should be at most 16.*/
|
||||||
void od_ec_encode_cdf(od_ec_enc *enc, int s,
|
void od_ec_encode_cdf(od_ec_enc *enc, int s, const uint16_t *cdf, int nsyms) {
|
||||||
const uint16_t *cdf, int nsyms) {
|
|
||||||
OD_ASSERT(s >= 0);
|
OD_ASSERT(s >= 0);
|
||||||
OD_ASSERT(s < nsyms);
|
OD_ASSERT(s < nsyms);
|
||||||
od_ec_encode(enc, s > 0 ? cdf[s - 1] : 0, cdf[s], cdf[nsyms - 1]);
|
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.
|
must be exactly 32768.
|
||||||
nsyms: The number of symbols in the alphabet.
|
nsyms: The number of symbols in the alphabet.
|
||||||
This should be at most 16.*/
|
This should be at most 16.*/
|
||||||
void od_ec_encode_cdf_q15(od_ec_enc *enc, int s,
|
void od_ec_encode_cdf_q15(od_ec_enc *enc, int s, const uint16_t *cdf,
|
||||||
const uint16_t *cdf, int nsyms) {
|
int nsyms) {
|
||||||
(void)nsyms;
|
(void)nsyms;
|
||||||
OD_ASSERT(s >= 0);
|
OD_ASSERT(s >= 0);
|
||||||
OD_ASSERT(s < nsyms);
|
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.
|
must be at least 2, and no more than 32768.
|
||||||
nsyms: The number of symbols in the alphabet.
|
nsyms: The number of symbols in the alphabet.
|
||||||
This should be at most 16.*/
|
This should be at most 16.*/
|
||||||
void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s,
|
void od_ec_encode_cdf_unscaled(od_ec_enc *enc, int s, const uint16_t *cdf,
|
||||||
const uint16_t *cdf, int nsyms) {
|
int nsyms) {
|
||||||
OD_ASSERT(s >= 0);
|
OD_ASSERT(s >= 0);
|
||||||
OD_ASSERT(s < nsyms);
|
OD_ASSERT(s < nsyms);
|
||||||
od_ec_encode_unscaled(enc, s > 0 ? cdf[s - 1] : 0, cdf[s], cdf[nsyms - 1]);
|
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.
|
ftb: The number of bits of precision in the cumulative distribution.
|
||||||
This must be no more than 15.*/
|
This must be no more than 15.*/
|
||||||
void od_ec_encode_cdf_unscaled_dyadic(od_ec_enc *enc, int s,
|
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;
|
(void)nsyms;
|
||||||
OD_ASSERT(s >= 0);
|
OD_ASSERT(s >= 0);
|
||||||
OD_ASSERT(s < nsyms);
|
OD_ASSERT(s < nsyms);
|
||||||
OD_ASSERT(ftb <= 15);
|
OD_ASSERT(ftb <= 15);
|
||||||
OD_ASSERT(cdf[nsyms - 1] == 1U << ftb);
|
OD_ASSERT(cdf[nsyms - 1] == 1U << ftb);
|
||||||
od_ec_encode_q15(enc,
|
od_ec_encode_q15(enc, s > 0 ? cdf[s - 1] << (15 - ftb) : 0,
|
||||||
s > 0 ? cdf[s - 1] << (15 - ftb) : 0, cdf[s] << (15 - ftb));
|
cdf[s] << (15 - ftb));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Encodes a raw unsigned integer in the stream.
|
/*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;
|
ft1 = (int)(ft >> ftb) + 1;
|
||||||
od_ec_encode_cdf_q15(enc, (int)(fl >> ftb), OD_UNIFORM_CDF_Q15(ft1), ft1);
|
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);
|
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.
|
/*Encodes a sequence of raw bits in the stream.
|
||||||
|
@ -455,8 +455,8 @@ void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb) {
|
||||||
enc->end_offs = 0;
|
enc->end_offs = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OD_COPY(new_buf + new_storage - end_offs,
|
OD_COPY(new_buf + new_storage - end_offs, buf + storage - end_offs,
|
||||||
buf + storage - end_offs, end_offs);
|
end_offs);
|
||||||
storage = new_storage;
|
storage = new_storage;
|
||||||
free(buf);
|
free(buf);
|
||||||
enc->buf = buf = new_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;
|
buf[storage - ++end_offs] = (unsigned char)end_window;
|
||||||
end_window >>= 8;
|
end_window >>= 8;
|
||||||
nend_bits -= 8;
|
nend_bits -= 8;
|
||||||
}
|
} while (nend_bits >= 8);
|
||||||
while (nend_bits >= 8);
|
|
||||||
enc->end_offs = end_offs;
|
enc->end_offs = end_offs;
|
||||||
}
|
}
|
||||||
OD_ASSERT(nend_bits + ftb <= OD_EC_WINDOW_SIZE);
|
OD_ASSERT(nend_bits + ftb <= OD_EC_WINDOW_SIZE);
|
||||||
|
@ -504,14 +503,14 @@ void od_ec_enc_patch_initial_bits(od_ec_enc *enc, unsigned val, int nbits) {
|
||||||
/*The first byte has been finalized.*/
|
/*The first byte has been finalized.*/
|
||||||
enc->precarry_buf[0] =
|
enc->precarry_buf[0] =
|
||||||
(uint16_t)((enc->precarry_buf[0] & ~mask) | val << shift);
|
(uint16_t)((enc->precarry_buf[0] & ~mask) | val << shift);
|
||||||
}
|
} else if (9 + enc->cnt + (enc->rng == 0x8000) > nbits) {
|
||||||
else if (9 + enc->cnt + (enc->rng == 0x8000) > nbits) {
|
|
||||||
/*The first byte has yet to be output.*/
|
/*The first byte has yet to be output.*/
|
||||||
enc->low = (enc->low & ~((od_ec_window)mask << (16 + enc->cnt))) |
|
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.*/
|
/*The encoder hasn't even encoded _nbits of data yet.*/
|
||||||
else enc->error = -1;
|
enc->error = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OD_MEASURE_EC_OVERHEAD
|
#if OD_MEASURE_EC_OVERHEAD
|
||||||
|
@ -543,7 +542,8 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
||||||
uint32_t tell;
|
uint32_t tell;
|
||||||
/* Don't count the 1 bit we lose to raw bits as overhead. */
|
/* Don't count the 1 bit we lose to raw bits as overhead. */
|
||||||
tell = od_ec_enc_tell(enc) - 1;
|
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",
|
fprintf(stderr, "efficiency: %f bits/symbol\n",
|
||||||
(double)tell / enc->nb_symbols);
|
(double)tell / enc->nb_symbols);
|
||||||
}
|
}
|
||||||
|
@ -585,8 +585,7 @@ unsigned char *od_ec_enc_done(od_ec_enc *enc, uint32_t *nbytes) {
|
||||||
s -= 8;
|
s -= 8;
|
||||||
c -= 8;
|
c -= 8;
|
||||||
n >>= 8;
|
n >>= 8;
|
||||||
}
|
} while (s > 0);
|
||||||
while (s > 0);
|
|
||||||
}
|
}
|
||||||
/*Make sure there's enough room for the entropy-coded bits and the raw
|
/*Make sure there's enough room for the entropy-coded bits and the raw
|
||||||
bits.*/
|
bits.*/
|
||||||
|
|
|
@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
|
||||||
#if !defined(_entenc_H)
|
#if !defined(_entenc_H)
|
||||||
#define _entenc_H (1)
|
#define _entenc_H (1)
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
# include "entcode.h"
|
#include "aom_dsp/entcode.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -79,18 +79,18 @@ 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)
|
void od_ec_encode_bool_q15(od_ec_enc *enc, int val, unsigned fz_q15)
|
||||||
OD_ARG_NONNULL(1);
|
OD_ARG_NONNULL(1);
|
||||||
void od_ec_encode_cdf(od_ec_enc *enc, int s,
|
void od_ec_encode_cdf(od_ec_enc *enc, int s, const uint16_t *cdf, int nsyms)
|
||||||
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);
|
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);
|
||||||
|
|
||||||
void od_ec_enc_uint(od_ec_enc *enc, uint32_t fl, uint32_t ft)
|
void od_ec_enc_uint(od_ec_enc *enc, uint32_t fl, uint32_t ft) OD_ARG_NONNULL(1);
|
||||||
OD_ARG_NONNULL(1);
|
|
||||||
|
|
||||||
void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb)
|
void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb)
|
||||||
OD_ARG_NONNULL(1);
|
OD_ARG_NONNULL(1);
|
||||||
|
@ -98,7 +98,8 @@ void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb)
|
||||||
void od_ec_enc_patch_initial_bits(od_ec_enc *enc, unsigned val, int nbits)
|
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,
|
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 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_WARN_UNUSED_RESULT uint32_t od_ec_enc_tell_frac(od_ec_enc *enc)
|
||||||
|
|
|
@ -65,7 +65,8 @@ extern uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2];
|
||||||
/*Enable special features for gcc and compatible compilers.*/
|
/*Enable special features for gcc and compatible compilers.*/
|
||||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
|
||||||
#define OD_GNUC_PREREQ(maj, min, pat) \
|
#define OD_GNUC_PREREQ(maj, min, pat) \
|
||||||
((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= ((maj) << 16) + ((min) << 8) + pat)
|
((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= \
|
||||||
|
((maj) << 16) + ((min) << 8) + pat) // NOLINT
|
||||||
#else
|
#else
|
||||||
#define OD_GNUC_PREREQ(maj, min, pat) (0)
|
#define OD_GNUC_PREREQ(maj, min, pat) (0)
|
||||||
#endif
|
#endif
|
||||||
|
@ -95,16 +96,14 @@ void od_fatal_impl(const char *_str, const char *_file, int _line);
|
||||||
if (!(_cond)) { \
|
if (!(_cond)) { \
|
||||||
OD_FATAL("assertion failed: " #_cond); \
|
OD_FATAL("assertion failed: " #_cond); \
|
||||||
} \
|
} \
|
||||||
} \
|
} while (0)
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define OD_ASSERT2(_cond, _message) \
|
#define OD_ASSERT2(_cond, _message) \
|
||||||
do { \
|
do { \
|
||||||
if (!(_cond)) { \
|
if (!(_cond)) { \
|
||||||
OD_FATAL("assertion failed: " #_cond "\n" _message); \
|
OD_FATAL("assertion failed: " #_cond "\n" _message); \
|
||||||
} \
|
} \
|
||||||
} \
|
} while (0)
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define OD_ALWAYS_TRUE(_cond) OD_ASSERT(_cond)
|
#define OD_ALWAYS_TRUE(_cond) OD_ASSERT(_cond)
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче