Clear existing format issue in the codebase

Fix the clang-format warnings on the existing codes.

Change-Id: I8e9e781b6f68f41a7fbd0a2116f6b35290d73dc8
This commit is contained in:
Jingning Han 2016-06-20 16:17:09 -07:00
Родитель 00b46f7e02
Коммит f4b2926d01
7 изменённых файлов: 220 добавлений и 212 удалений

Просмотреть файл

@ -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,
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
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

Просмотреть файл

@ -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.
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.*/

Просмотреть файл

@ -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;
@ -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;
@ -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;
@ -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;
@ -420,8 +423,7 @@ int od_ec_decode_cdf_unscaled_dyadic_(od_ec_dec *dec,
do {
u = v;
v = cdf[++ret] * (uint32_t)r >> ftb;
}
while (v <= c);
} 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);
}
@ -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;
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.

Просмотреть файл

@ -25,9 +25,9 @@ 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"
#include "aom_dsp/entcode.h"
#if OD_ACCOUNTING
# include "accounting.h"
#include "./accounting.h"
#endif
#ifdef __cplusplus
@ -40,20 +40,28 @@ typedef struct od_ec_dec od_ec_dec;
#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_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_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
@ -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)
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)
unsigned ft 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_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)
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;
@ -123,8 +123,7 @@ void od_ec_enc_init(od_ec_enc *enc, uint32_t size) {
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;
@ -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);
@ -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.
@ -455,8 +455,8 @@ void od_ec_enc_bits(od_ec_enc *enc, uint32_t fl, unsigned ftb) {
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);
@ -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.*/
enc->precarry_buf[0] =
(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.*/
enc->low = (enc->low & ~((od_ec_window)mask << (16 + enc->cnt))) |
(od_ec_window)val << (16 + enc->cnt + shift);
}
} else {
/*The encoder hasn't even encoded _nbits of data yet.*/
else enc->error = -1;
enc->error = -1;
}
}
#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;
/* 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);
}
@ -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.*/

Просмотреть файл

@ -25,7 +25,7 @@ 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"
#include "aom_dsp/entcode.h"
#ifdef __cplusplus
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);
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);
void od_ec_encode_cdf_unscaled_dyadic(od_ec_enc *enc, int s,
const uint16_t *cdf, int nsyms, unsigned ftb)
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);
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);
@ -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)
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)

Просмотреть файл

@ -65,7 +65,8 @@ extern uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2];
/*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)
((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__ >= \
((maj) << 16) + ((min) << 8) + pat) // NOLINT
#else
#define OD_GNUC_PREREQ(maj, min, pat) (0)
#endif
@ -95,16 +96,14 @@ void od_fatal_impl(const char *_str, const char *_file, int _line);
if (!(_cond)) { \
OD_FATAL("assertion failed: " #_cond); \
} \
} \
while (0)
} while (0)
#define OD_ASSERT2(_cond, _message) \
do { \
if (!(_cond)) { \
OD_FATAL("assertion failed: " #_cond "\n" _message); \
} \
} \
while (0)
} while (0)
#define OD_ALWAYS_TRUE(_cond) OD_ASSERT(_cond)