Commit 4c462788 authored by Michael Bebenita's avatar Michael Bebenita Committed by Michael Bebenita

Add aom_reader_tell() support.

Change-Id: I59bd910f58c218c649a1de2a7b5fae0397e13cb1
parent c02bf30e
......@@ -79,6 +79,14 @@ static INLINE int aom_reader_has_error(aom_reader *r) {
#endif
}
static INLINE ptrdiff_t aom_reader_tell(const aom_reader *r) {
#if CONFIG_DAALA_EC
return aom_daala_reader_tell(r);
#else
return aom_dk_reader_tell(r);
#endif
}
static INLINE int aom_read(aom_reader *r, int prob) {
#if CONFIG_ANS
return uabs_read(r, prob);
......
......@@ -24,3 +24,7 @@ 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) {
return r->buffer_end;
}
ptrdiff_t aom_daala_reader_tell(const daala_reader *r) {
return od_ec_dec_tell(&r->ec);
}
......@@ -29,6 +29,7 @@ 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);
static INLINE int aom_daala_read(daala_reader *r, int prob) {
if (prob == 128) {
......
......@@ -30,7 +30,7 @@ int aom_dk_reader_init(struct aom_dk_reader *r, const uint8_t *buffer,
return 1;
} else {
r->buffer_end = buffer + size;
r->buffer = buffer;
r->buffer_start = r->buffer = buffer;
r->value = 0;
r->count = -8;
r->range = 255;
......
......@@ -39,6 +39,7 @@ struct aom_dk_reader {
BD_VALUE value;
unsigned int range;
int count;
const uint8_t *buffer_start;
const uint8_t *buffer_end;
const uint8_t *buffer;
aom_decrypt_cb decrypt_cb;
......@@ -54,6 +55,13 @@ 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;
const int count = (r->count < LOTS_OF_BITS) ? r->count
: r->count - LOTS_OF_BITS;
return bits_read + BD_VALUE_SIZE - (count + CHAR_BIT);
}
static INLINE int aom_dk_reader_has_error(struct aom_dk_reader *r) {
// Check if we have reached the end of the buffer.
//
......
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