]> granicus.if.org Git - libvpx/commitdiff
Port aom_reader_tell() support
authorMichael Bebenita <mbebenita@mozilla.com>
Wed, 3 Aug 2016 23:13:04 +0000 (16:13 -0700)
committerYaowu Xu <yaowu@google.com>
Tue, 18 Oct 2016 15:50:05 +0000 (08:50 -0700)
This commit ports the following from aom/master:
4c46278 Add aom_reader_tell() support.
b9c9935 Remove an erroneous declaration.
56c9c3b Fix ANS build.

Change-Id: I59bd910f58c218c649a1de2a7b5fae0397e13cb1

aom_dsp/bitreader.h
aom_dsp/buf_ans.h
aom_dsp/daalaboolreader.c
aom_dsp/daalaboolreader.h
aom_dsp/dkboolreader.c
aom_dsp/dkboolreader.h
av1/common/entropymode.h

index 35976eeb1568ad4e057dc527084c86d06cc9dc2e..d2fd5f2fd0fa9d3df212cbd0288d1d404e3cb015 100644 (file)
@@ -79,6 +79,18 @@ static INLINE int aom_reader_has_error(aom_reader *r) {
 #endif
 }
 
+static INLINE ptrdiff_t aom_reader_tell(const aom_reader *r) {
+#if CONFIG_ANS
+  (void)r;
+  assert(0 && "aom_reader_tell() is unimplemented for ANS");
+  return 0;
+#elif 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);
index 58d6e61fc39dd1a5440a84682881f216e2e1f730..e499200bb617ed7801a5b0dcb4883ae15dddd87d 100644 (file)
@@ -28,8 +28,6 @@ extern "C" {
 #define ANS_METHOD_UABS 0
 #define ANS_METHOD_RANS 1
 
-struct aom_internal_error_info *error;
-
 struct buffered_ans_symbol {
   unsigned int method : 1;  // one of ANS_METHOD_UABS or ANS_METHOD_RANS
   // TODO(aconverse): Should be possible to write this in terms of start for ABS
index d9ef8870087b9c73d6c3256e7f06808a4041a233..8e1c7821c772321b48d37d97eac29c766e27e7d3 100644 (file)
@@ -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);
+}
index 0ed0de4ac29364f057cfeb26e08ed90cd82d103e..fd69a274c26cb6c7d7a7597eb2d436b7cc69f990 100644 (file)
@@ -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) {
index 8ec7ffc40651f2763d1aab61d8c70e3cf0ae265c..c3b7782d609537a219077b557b6bb3bbe51c82b1 100644 (file)
@@ -29,7 +29,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;
index fe68ecc0f6a3e3ce41dcb1c3da38ed798625274a..2fd2b378e3547a4d2e4c33c6c2a1ea2ee6efae03 100644 (file)
@@ -45,6 +45,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;
@@ -60,6 +61,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.
   //
index 7821b392932af61636bba5b815f3def76e3b36c0..03fe2bf5f6a53904fa1c45ed8bdefd531e53932d 100644 (file)
@@ -133,8 +133,8 @@ typedef struct frame_contexts {
 #endif  // CONFIG_LOOP_RESTORATION
 #if CONFIG_DAALA_EC
   aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
-  aom_cdf_prob
-      switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
+  aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
+                                    [SWITCHABLE_FILTERS];
   aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
   aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES];
 #endif