Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: webrtc/modules/video_coding/utility/vp8_header_parser.cc

Issue 1888313002: Fix the issue of undefined-shift in VP8GetBit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Use error_ to save bitReader status. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/utility/vp8_header_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1338e6ff47064c46842409d96aaf1adc0de0dd64 100644
--- a/webrtc/modules/video_coding/utility/vp8_header_parser.cc
+++ b/webrtc/modules/video_coding/utility/vp8_header_parser.cc
@@ -66,6 +66,7 @@ static void VP8InitBitReader(VP8BitReader* const br,
br->value_ = 0;
br->bits_ = -8; // To load the very first 8bits.
br->eof_ = 0;
+ br->error_ = false;
pbos-webrtc 2016/04/18 19:25:33 Is this already covered by the eof_ flag? If so we
jackychen_ 2016/04/18 20:49:47 Not really, the error here might not be the same w
pbos-webrtc 2016/04/18 20:52:02 Have you diagnosed the actual error that happens?
VP8LoadNewBytes(br);
}
@@ -75,7 +76,10 @@ static int VP8GetBit(VP8BitReader* const br, int prob) {
if (br->bits_ < 0) {
VP8LoadNewBytes(br);
}
-
+ if (br->bits_ < 0) {
pbos-webrtc 2016/04/18 19:25:33 Shouldn't this be set inside VP8LoadNewBytes when
jackychen_ 2016/04/18 20:49:47 I want to stop the operation on br->bits here sinc
+ br->error_ = true;
+ 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);
@@ -195,6 +199,10 @@ bool GetQp(const uint8_t* buf, size_t length, int* qp) {
LOG(LS_WARNING) << "Failed to get QP, end of file reached.";
return false;
}
+ if (br.error_) {
+ LOG(LS_WARNING) << "Failed to get QP, invalid bitstream.";
pbos-webrtc 2016/04/18 20:56:46 Are you sure that this isn't because the stream is
+ return false;
+ }
*qp = base_q0;
return true;
}
« no previous file with comments | « webrtc/modules/video_coding/utility/vp8_header_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698