dump_obu: Calculate and report OBU overhead.

Change-Id: Ib315f9fdcadc83dcc4ed39e59757c0f8a99116ac
diff --git a/tools/obu_parser.cc b/tools/obu_parser.cc
index 0bef559..fe288f9 100644
--- a/tools/obu_parser.cc
+++ b/tools/obu_parser.cc
@@ -152,10 +152,11 @@
   }
 }
 
-bool DumpObu(const uint8_t *data, int length) {
+bool DumpObu(const uint8_t *data, int length, int *obu_overhead_bytes) {
   const int kObuHeaderLengthSizeBytes = 1;
   const int kMinimumBytesRequired = 1 + kObuHeaderLengthSizeBytes;
   int consumed = 0;
+  int obu_overhead = 0;
   ObuHeader obu_header;
   while (consumed < length) {
     const int remaining = length - consumed;
@@ -180,6 +181,8 @@
     const size_t length_field_size = kObuLengthFieldSizeBytes;
 #endif  // CONFIG_OBU_SIZING
 
+    obu_overhead += length_field_size;
+
     if (current_obu_length > remaining) {
       fprintf(stderr,
               "OBU parsing failed at offset %d with bad length of %d "
@@ -196,6 +199,8 @@
       return false;
     }
 
+    ++obu_overhead;
+
     if (obu_header.has_extension) {
       const uint8_t obu_ext_header_byte =
           *(data + consumed + kObuHeaderLengthSizeBytes);
@@ -205,6 +210,8 @@
                 consumed);
         return false;
       }
+
+      ++obu_overhead;
     }
 
     PrintObuHeader(&obu_header);
@@ -213,6 +220,8 @@
     consumed += current_obu_length;
   }
 
+  if (obu_overhead_bytes) *obu_overhead_bytes = obu_overhead;
+
   return true;
 }