Index: webrtc/base/bitbuffer.cc |
diff --git a/webrtc/base/bitbuffer.cc b/webrtc/base/bitbuffer.cc |
index cd3661343b290ae25aed1e34a04a7390643c5ead..9000c9b87021e3fd9bf99174520b8727900fd6e6 100644 |
--- a/webrtc/base/bitbuffer.cc |
+++ b/webrtc/base/bitbuffer.cc |
@@ -187,6 +187,21 @@ bool BitBuffer::ReadExponentialGolomb(uint32_t* val) { |
return true; |
} |
+bool BitBuffer::ReadSignedExponentialGolomb(int32_t* val) { |
+ // Signed exponential golomb values are just the unsigned values |
+ // mapped to the sequence 0, 1, -1, 2, -2, etc. in order. |
+ uint32_t unsigned_val; |
+ if (!ReadExponentialGolomb(&unsigned_val)) { |
+ return false; |
+ } |
+ if ((unsigned_val & 1) == 0) { |
+ *val = -static_cast<int32_t>(unsigned_val / 2); |
+ } else { |
+ *val = (unsigned_val + 1) / 2; |
+ } |
+ return true; |
+} |
+ |
void BitBuffer::GetCurrentOffset( |
size_t* out_byte_offset, size_t* out_bit_offset) { |
CHECK(out_byte_offset != NULL); |