Index: webrtc/modules/video_coding/utility/vp8_header_parser.cc |
diff --git a/webrtc/modules/video_coding/utility/vp8_header_parser.cc b/webrtc/modules/video_coding/utility/vp8_header_parser.cc |
index 631385d0f25095903e676f79dc24e04ea1e1c6cd..ddddfd07aa793d6f5279c5e29c982496272ac93f 100644 |
--- a/webrtc/modules/video_coding/utility/vp8_header_parser.cc |
+++ b/webrtc/modules/video_coding/utility/vp8_header_parser.cc |
@@ -35,7 +35,7 @@ static void VP8LoadFinalBytes(VP8BitReader* const br) { |
} |
} |
-static void VP8LoadNewBytes(VP8BitReader* const br) { |
+static bool VP8LoadNewBytes(VP8BitReader* const br) { |
int BITS = 24; |
// Read 'BITS' bits at a time. |
if (br->buf_ + sizeof(uint32_t) <= br->buf_end_) { |
@@ -55,6 +55,11 @@ static void VP8LoadNewBytes(VP8BitReader* const br) { |
} else { |
VP8LoadFinalBytes(br); |
} |
+ if (br->bits_ < 0) { |
+ br->eof_ = 1; |
pbos-webrtc
2016/04/19 23:11:50
Actually, does this happen from VP8LoadFinalBytes?
jackychen_
2016/04/20 00:27:18
I'm not sure. So to be safe, I put the check here.
|
+ return false; |
+ } |
+ return true; |
} |
static void VP8InitBitReader(VP8BitReader* const br, |
@@ -73,9 +78,9 @@ static void VP8InitBitReader(VP8BitReader* const br, |
static int VP8GetBit(VP8BitReader* const br, int prob) { |
uint8_t range = br->range_; |
if (br->bits_ < 0) { |
- VP8LoadNewBytes(br); |
+ if (!VP8LoadNewBytes(br)) |
+ return 0; |
} |
- |
const int pos = br->bits_; |
const uint8_t split = (range * prob) >> 8; |
const uint8_t value = static_cast<uint8_t>(br->value_ >> pos); |