Improve LEB128 support and test coverage.

Also some minor cosmetic changes and style fixes.

BUG=aomedia:1125

Change-Id: Ide24057736376accd2f9907ef87b5a725ab3f3c2
diff --git a/aom/aom_integer.h b/aom/aom_integer.h
index 130b1b4..10b7040 100644
--- a/aom/aom_integer.h
+++ b/aom/aom_integer.h
@@ -81,8 +81,9 @@
 // Returns size of uint32_t when encoded using LEB128.
 size_t aom_uleb_size_in_bytes(uint64_t value);
 
-// Returns decoded LEB128 value.
-void aom_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value);
+// Returns -1 upon decode failure, or 0 and decoded LEB128 value via last
+// argument when decode is successful.
+int aom_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value);
 
 // Encodes LEB128 integer. Returns 0 when successful, and -1 upon failure.
 int aom_uleb_encode(uint64_t value, size_t available, uint8_t *coded_value,
diff --git a/aom/src/aom_integer.c b/aom/src/aom_integer.c
index 10b0003..5aa9f1e 100644
--- a/aom/src/aom_integer.c
+++ b/aom/src/aom_integer.c
@@ -23,14 +23,21 @@
   return size;
 }
 
-void aom_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value) {
+int aom_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value) {
+  int status = -1;
+
   if (buffer && value) {
     for (size_t i = 0; i < kMaximumLeb128Size && i < available; ++i) {
       const uint8_t decoded_byte = *(buffer + i) & kLeb128ByteMask;
       *value |= decoded_byte << (i * 7);
-      if ((*(buffer + i) >> 7) == 0) break;
+      if ((*(buffer + i) >> 7) == 0) {
+        status = 0;
+        break;
+      }
     }
   }
+
+  return status;
 }
 
 int aom_uleb_encode(uint64_t value, size_t available, uint8_t *coded_value,