Commit e94767ae authored by Yaowu Xu's avatar Yaowu Xu Committed by Gerrit Code Review

Merge "Change return type of tell and tell_frac to uint32_t." into nextgenv2

parents 66b1fcc9 b244f396
......@@ -103,7 +103,7 @@ static INLINE int aom_reader_has_error(aom_reader *r) {
}
// Returns the position in the bit reader in bits.
static INLINE ptrdiff_t aom_reader_tell(const aom_reader *r) {
static INLINE uint32_t aom_reader_tell(const aom_reader *r) {
#if CONFIG_ANS
(void)r;
assert(0 && "aom_reader_tell() is unimplemented for ANS");
......@@ -116,7 +116,7 @@ static INLINE ptrdiff_t aom_reader_tell(const aom_reader *r) {
}
// Returns the position in the bit reader in 1/8th bits.
static INLINE ptrdiff_t aom_reader_tell_frac(const aom_reader *r) {
static INLINE uint32_t aom_reader_tell_frac(const aom_reader *r) {
#if CONFIG_ANS
(void)r;
assert(0 && "aom_reader_tell_frac() is unimplemented for ANS");
......
......@@ -28,10 +28,10 @@ const uint8_t *aom_daala_reader_find_end(daala_reader *r) {
return r->buffer_end;
}
ptrdiff_t aom_daala_reader_tell(const daala_reader *r) {
uint32_t aom_daala_reader_tell(const daala_reader *r) {
return od_ec_dec_tell(&r->ec);
}
ptrdiff_t aom_daala_reader_tell_frac(const daala_reader *r) {
uint32_t aom_daala_reader_tell_frac(const daala_reader *r) {
return od_ec_dec_tell_frac(&r->ec);
}
......@@ -36,8 +36,8 @@ typedef struct daala_reader daala_reader;
int aom_daala_reader_init(daala_reader *r, const uint8_t *buffer, int size);
const uint8_t *aom_daala_reader_find_end(daala_reader *r);
ptrdiff_t aom_daala_reader_tell(const daala_reader *r);
ptrdiff_t aom_daala_reader_tell_frac(const daala_reader *r);
uint32_t aom_daala_reader_tell(const daala_reader *r);
uint32_t aom_daala_reader_tell_frac(const daala_reader *r);
static INLINE int aom_daala_read(daala_reader *r, int prob) {
if (prob == 128) {
......
......@@ -12,6 +12,7 @@
#ifndef AOM_DSP_DKBOOLREADER_H_
#define AOM_DSP_DKBOOLREADER_H_
#include <assert.h>
#include <stddef.h>
#include <limits.h>
......@@ -67,10 +68,11 @@ void aom_dk_reader_fill(struct aom_dk_reader *r);
const uint8_t *aom_dk_reader_find_end(struct aom_dk_reader *r);
static INLINE ptrdiff_t aom_dk_reader_tell(const struct aom_dk_reader *r) {
const size_t bits_read = (r->buffer - r->buffer_start) * CHAR_BIT;
static INLINE uint32_t aom_dk_reader_tell(const struct aom_dk_reader *r) {
const uint32_t bits_read = (r->buffer - r->buffer_start) * CHAR_BIT;
const int count =
(r->count < LOTS_OF_BITS) ? r->count : r->count - LOTS_OF_BITS;
assert(r->buffer >= r->buffer_start);
return bits_read - (count + CHAR_BIT);
}
......@@ -78,7 +80,7 @@ static INLINE ptrdiff_t aom_dk_reader_tell(const struct aom_dk_reader *r) {
3 => 1/8th bits.*/
#define DK_BITRES (3)
static INLINE ptrdiff_t aom_dk_reader_tell_frac(const struct aom_dk_reader *r) {
static INLINE uint32_t aom_dk_reader_tell_frac(const struct aom_dk_reader *r) {
uint32_t num_bits;
uint32_t range;
int l;
......
......@@ -110,15 +110,15 @@ TEST(AV1, TestTell) {
aom_stop_encode(&bw);
aom_reader br;
aom_reader_init(&br, bw_buffer, kBufferSize, NULL, NULL);
ptrdiff_t last_tell = aom_reader_tell(&br);
ptrdiff_t last_tell_frac = aom_reader_tell_frac(&br);
uint32_t last_tell = aom_reader_tell(&br);
uint32_t last_tell_frac = aom_reader_tell_frac(&br);
double frac_diff_total = 0;
GTEST_ASSERT_GE(aom_reader_tell(&br), 0);
GTEST_ASSERT_LE(aom_reader_tell(&br), 1);
GTEST_ASSERT_GE(aom_reader_tell(&br), 0u);
GTEST_ASSERT_LE(aom_reader_tell(&br), 1u);
for (int i = 0; i < kSymbols; i++) {
aom_read(&br, p, NULL);
ptrdiff_t tell = aom_reader_tell(&br);
ptrdiff_t tell_frac = aom_reader_tell_frac(&br);
uint32_t tell = aom_reader_tell(&br);
uint32_t tell_frac = aom_reader_tell_frac(&br);
GTEST_ASSERT_GE(tell, last_tell) << "tell: " << tell
<< ", last_tell: " << last_tell;
GTEST_ASSERT_GE(tell_frac, last_tell_frac)
......@@ -131,7 +131,7 @@ TEST(AV1, TestTell) {
fabs(((tell_frac - last_tell_frac) / 8.0) + log2(probability));
last_tell_frac = tell_frac;
}
const int expected = (int)(-kSymbols * log2(probability));
const uint32_t expected = (uint32_t)(-kSymbols * log2(probability));
// Last tell should be close to the expected value.
GTEST_ASSERT_LE(last_tell - expected, 20) << " last_tell: " << last_tell;
// The average frac_diff error should be pretty small.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment