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

Unified Diff: webrtc/common_video/h264/h264_bitstream_parser.cc

Issue 2532973002: Sanity check parsed QP values from H264 bitstream (Closed)
Patch Set: +const Created 4 years, 1 month 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 | « no previous file | webrtc/common_video/h264/pps_parser.cc » ('j') | webrtc/common_video/h264/pps_parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_video/h264/h264_bitstream_parser.cc
diff --git a/webrtc/common_video/h264/h264_bitstream_parser.cc b/webrtc/common_video/h264/h264_bitstream_parser.cc
index 048cdd2f6ea58da64b7d4b37507c2e6078a88865..e6bc946274da990dfe9867f7fdf94bad2e94df7c 100644
--- a/webrtc/common_video/h264/h264_bitstream_parser.cc
+++ b/webrtc/common_video/h264/h264_bitstream_parser.cc
@@ -19,6 +19,10 @@
#include "webrtc/common_video/h264/h264_common.h"
#include "webrtc/base/logging.h"
+namespace {
+const int kMaxAbsQpDeltaValue = 51;
+}
+
namespace webrtc {
#define RETURN_ON_FAIL(x, res) \
@@ -251,6 +255,12 @@ H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu(
int32_t last_slice_qp_delta;
RETURN_INV_ON_FAIL(
slice_reader.ReadSignedExponentialGolomb(&last_slice_qp_delta));
+ if (abs(last_slice_qp_delta) > kMaxAbsQpDeltaValue) {
pbos-webrtc 2016/11/29 15:31:50 "The value of slice_qp_delta shall be limited such
pbos-webrtc 2016/11/29 16:12:42 Sorry, e.g. should this range be depending on pps_
+ // Something has gone wrong, and the parsed value is invalid.
+ LOG(LS_WARNING) << "Parsed QP value out of range.";
+ return kInvalidStream;
+ }
+
last_slice_qp_delta_ = rtc::Optional<int32_t>(last_slice_qp_delta);
return kOk;
}
« no previous file with comments | « no previous file | webrtc/common_video/h264/pps_parser.cc » ('j') | webrtc/common_video/h264/pps_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698