Add H264 bitstream rewriting to limit frame reordering marker in header

The VUI part an SPS may specify max_num_reorder_frames and
max_dec_frame_buffering. These may cause a decoder to buffer a number
of frame prior allowing decode, leading to delays, even if no frames
using such references (ie B-frames) are sent.

Because of this we update any SPS block emitted by the encoder.

Also, a bunch of refactoring of H264-related code to reduce code
duplication.

BUG=

Review-Url: https://codereview.webrtc.org/1979443004
Cr-Commit-Position: refs/heads/master@{#13010}
diff --git a/webrtc/base/bitbuffer.cc b/webrtc/base/bitbuffer.cc
index 1aa245e..48a1d0c 100644
--- a/webrtc/base/bitbuffer.cc
+++ b/webrtc/base/bitbuffer.cc
@@ -293,4 +293,18 @@
   return WriteBits(val_to_encode, CountBits(val_to_encode) * 2 - 1);
 }
 
+bool BitBufferWriter::WriteSignedExponentialGolomb(int32_t val) {
+  if (val == 0) {
+    return WriteExponentialGolomb(0);
+  } else if (val > 0) {
+    uint32_t signed_val = val;
+    return WriteExponentialGolomb((signed_val * 2) - 1);
+  } else {
+    if (val == std::numeric_limits<int32_t>::min())
+      return false;  // Not supported, would cause overflow.
+    uint32_t signed_val = -val;
+    return WriteExponentialGolomb(signed_val * 2);
+  }
+}
+
 }  // namespace rtc