Index: media/base/bit_reader.cc |
diff --git a/media/base/bit_reader.cc b/media/base/bit_reader.cc |
index 83ca40e315bdba854f385816019a8c28c114f82f..4e27af3f87785c175c7d5a12e0cbcda9b99bbe7c 100644 |
--- a/media/base/bit_reader.cc |
+++ b/media/base/bit_reader.cc |
@@ -17,6 +17,18 @@ BitReader::BitReader(const uint8_t* data, int size) |
BitReader::~BitReader() {} |
+bool BitReader::ReadString(int num_bits, std::string* str) { |
ddorwin
2016/04/12 00:40:47
Why not just pass in num_bytes?
dougsteed
2016/05/08 23:18:44
All the other public functions are in terms of bit
|
+ int num_bytes = num_bits / 8; |
+ DCHECK_EQ(num_bits % 8, 0); |
ddorwin
2016/04/12 00:40:47
Move the DCHECKs up to first line - they are check
dougsteed
2016/05/08 23:18:43
Done.
|
+ DCHECK(str); |
+ str->resize(num_bytes); |
+ char* ptr = &str->front(); |
ddorwin
2016/04/12 00:40:47
Then add a note to .h that the num_ value must be
ddorwin
2016/04/12 00:40:47
Calling front() on an empty string has undefined b
dougsteed
2016/05/08 23:18:43
Done.
|
+ while (num_bytes--) |
ddorwin
2016/04/12 00:40:47
With the nesting, it's probably best to add braces
dougsteed
2016/05/08 23:18:43
Done.
|
+ if (!ReadBits(8, ptr++)) |
ddorwin
2016/04/12 00:40:47
Should we note in the .h that this does not guaran
dougsteed
2016/05/08 23:18:43
Done.
|
+ return false; |
+ return true; |
+} |
+ |
int BitReader::GetBytes(int max_nbytes, const uint8_t** out) { |
DCHECK_GE(max_nbytes, 0); |
DCHECK(out); |