Delete deprecated H264BitstreamParser methods

Bug: webrtc:10439
Change-Id: I1513907f03f9adfcf5657298e69d60519af764ef
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/198121
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32934}
diff --git a/common_video/h264/h264_bitstream_parser.cc b/common_video/h264/h264_bitstream_parser.cc
index 5a75f48..b0ada92 100644
--- a/common_video/h264/h264_bitstream_parser.cc
+++ b/common_video/h264/h264_bitstream_parser.cc
@@ -296,35 +296,24 @@
   }
 }
 
-void H264BitstreamParser::ParseBitstream(const uint8_t* bitstream,
-                                         size_t length) {
-  std::vector<H264::NaluIndex> nalu_indices =
-      H264::FindNaluIndices(bitstream, length);
-  for (const H264::NaluIndex& index : nalu_indices)
-    ParseSlice(&bitstream[index.payload_start_offset], index.payload_size);
-}
-
-bool H264BitstreamParser::GetLastSliceQp(int* qp) const {
-  if (!last_slice_qp_delta_ || !pps_)
-    return false;
-  const int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
-  if (parsed_qp < kMinQpValue || parsed_qp > kMaxQpValue) {
-    RTC_LOG(LS_ERROR) << "Parsed invalid QP from bitstream.";
-    return false;
-  }
-  *qp = parsed_qp;
-  return true;
-}
-
 void H264BitstreamParser::ParseBitstream(
     rtc::ArrayView<const uint8_t> bitstream) {
-  ParseBitstream(bitstream.data(), bitstream.size());
+  std::vector<H264::NaluIndex> nalu_indices =
+      H264::FindNaluIndices(bitstream.data(), bitstream.size());
+  for (const H264::NaluIndex& index : nalu_indices)
+    ParseSlice(bitstream.data() + index.payload_start_offset,
+               index.payload_size);
 }
 
 absl::optional<int> H264BitstreamParser::GetLastSliceQp() const {
-  int qp;
-  bool success = GetLastSliceQp(&qp);
-  return success ? absl::optional<int>(qp) : absl::nullopt;
+  if (!last_slice_qp_delta_ || !pps_)
+    return absl::nullopt;
+  const int qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
+  if (qp < kMinQpValue || qp > kMaxQpValue) {
+    RTC_LOG(LS_ERROR) << "Parsed invalid QP from bitstream.";
+    return absl::nullopt;
+  }
+  return qp;
 }
 
 }  // namespace webrtc
diff --git a/common_video/h264/h264_bitstream_parser.h b/common_video/h264/h264_bitstream_parser.h
index 4819066..0542782 100644
--- a/common_video/h264/h264_bitstream_parser.h
+++ b/common_video/h264/h264_bitstream_parser.h
@@ -31,11 +31,6 @@
   H264BitstreamParser();
   ~H264BitstreamParser() override;
 
-  // These are here for backwards-compatability for the time being.
-  void ParseBitstream(const uint8_t* bitstream, size_t length);
-  bool GetLastSliceQp(int* qp) const;
-
-  // New interface.
   void ParseBitstream(rtc::ArrayView<const uint8_t> bitstream) override;
   absl::optional<int> GetLastSliceQp() const override;
 
diff --git a/common_video/h264/h264_bitstream_parser_unittest.cc b/common_video/h264/h264_bitstream_parser_unittest.cc
index 1509d67..3f4f202 100644
--- a/common_video/h264/h264_bitstream_parser_unittest.cc
+++ b/common_video/h264/h264_bitstream_parser_unittest.cc
@@ -46,43 +46,39 @@
 
 TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) {
   H264BitstreamParser h264_parser;
-  int qp;
-  EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
+  EXPECT_FALSE(h264_parser.GetLastSliceQp().has_value());
 }
 
 TEST(H264BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) {
   H264BitstreamParser h264_parser;
-  h264_parser.ParseBitstream(kH264SpsPps, sizeof(kH264SpsPps));
-  int qp;
-  EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
+  h264_parser.ParseBitstream(kH264SpsPps);
+  EXPECT_FALSE(h264_parser.GetLastSliceQp().has_value());
 }
 
 TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) {
   H264BitstreamParser h264_parser;
-  h264_parser.ParseBitstream(kH264BitstreamChunk, sizeof(kH264BitstreamChunk));
-  int qp;
-  ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
-  EXPECT_EQ(35, qp);
+  h264_parser.ParseBitstream(kH264BitstreamChunk);
+  absl::optional<int> qp = h264_parser.GetLastSliceQp();
+  ASSERT_TRUE(qp.has_value());
+  EXPECT_EQ(35, *qp);
 
   // Parse an additional image slice.
-  h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunk,
-                             sizeof(kH264BitstreamNextImageSliceChunk));
-  ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
-  EXPECT_EQ(37, qp);
+  h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunk);
+  qp = h264_parser.GetLastSliceQp();
+  ASSERT_TRUE(qp.has_value());
+  EXPECT_EQ(37, *qp);
 }
 
 TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) {
   H264BitstreamParser h264_parser;
-  h264_parser.ParseBitstream(kH264BitstreamChunkCabac,
-                             sizeof(kH264BitstreamChunkCabac));
-  int qp;
-  EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
+  h264_parser.ParseBitstream(kH264BitstreamChunkCabac);
+  EXPECT_FALSE(h264_parser.GetLastSliceQp().has_value());
 
   // Parse an additional image slice.
-  h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac,
-                             sizeof(kH264BitstreamNextImageSliceChunkCabac));
-  ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
-  EXPECT_EQ(24, qp);
+  h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac);
+  absl::optional<int> qp = h264_parser.GetLastSliceQp();
+  ASSERT_TRUE(qp.has_value());
+  EXPECT_EQ(24, *qp);
 }
 
 }  // namespace webrtc
diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc
index 9002b87..8c7a39b 100644
--- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc
@@ -294,13 +294,9 @@
   // the input one.
   RTC_DCHECK_EQ(av_frame_->reordered_opaque, frame_timestamp_us);
 
-  absl::optional<uint8_t> qp;
   // TODO(sakal): Maybe it is possible to get QP directly from FFmpeg.
-  h264_bitstream_parser_.ParseBitstream(input_image.data(), input_image.size());
-  int qp_int;
-  if (h264_bitstream_parser_.GetLastSliceQp(&qp_int)) {
-    qp.emplace(qp_int);
-  }
+  h264_bitstream_parser_.ParseBitstream(input_image);
+  absl::optional<int> qp = h264_bitstream_parser_.GetLastSliceQp();
 
   // Obtain the |video_frame| containing the decoded image.
   VideoFrame* input_frame =
diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
index ea784c1..3f4f660 100644
--- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc
+++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
@@ -481,9 +481,9 @@
     // |encoded_images_[i]._length| == 0.
     if (encoded_images_[i].size() > 0) {
       // Parse QP.
-      h264_bitstream_parser_.ParseBitstream(encoded_images_[i].data(),
-                                            encoded_images_[i].size());
-      h264_bitstream_parser_.GetLastSliceQp(&encoded_images_[i].qp_);
+      h264_bitstream_parser_.ParseBitstream(encoded_images_[i]);
+      encoded_images_[i].qp_ =
+          h264_bitstream_parser_.GetLastSliceQp().value_or(-1);
 
       // Deliver encoded image.
       CodecSpecificInfo codec_specific;
diff --git a/sdk/android/src/jni/video_decoder_wrapper.cc b/sdk/android/src/jni/video_decoder_wrapper.cc
index 3aa18ab..4eb70f7 100644
--- a/sdk/android/src/jni/video_decoder_wrapper.cc
+++ b/sdk/android/src/jni/video_decoder_wrapper.cc
@@ -249,12 +249,8 @@
       break;
     }
     case kVideoCodecH264: {
-      h264_bitstream_parser_.ParseBitstream(input_image.data(),
-                                            input_image.size());
-      int qp_int;
-      if (h264_bitstream_parser_.GetLastSliceQp(&qp_int)) {
-        qp = qp_int;
-      }
+      h264_bitstream_parser_.ParseBitstream(input_image);
+      qp = h264_bitstream_parser_.GetLastSliceQp();
       break;
     }
     default:
diff --git a/sdk/android/src/jni/video_encoder_wrapper.cc b/sdk/android/src/jni/video_encoder_wrapper.cc
index 3bdfdc3..4a1faeb 100644
--- a/sdk/android/src/jni/video_encoder_wrapper.cc
+++ b/sdk/android/src/jni/video_encoder_wrapper.cc
@@ -309,8 +309,9 @@
       success = vp9::GetQp(buffer.data(), buffer.size(), &qp);
       break;
     case kVideoCodecH264:
-      h264_bitstream_parser_.ParseBitstream(buffer.data(), buffer.size());
-      success = h264_bitstream_parser_.GetLastSliceQp(&qp);
+      h264_bitstream_parser_.ParseBitstream(buffer);
+      qp = h264_bitstream_parser_.GetLastSliceQp().value_or(-1);
+      success = (qp >= 0);
       break;
     default:  // Default is to not provide QP.
       success = false;
diff --git a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
index 03a7926..01d48c1 100644
--- a/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
+++ b/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
@@ -802,10 +802,8 @@
                                                                   RTCVideoContentTypeUnspecified;
   frame.flags = webrtc::VideoSendTiming::kInvalid;
 
-  int qp;
-  _h264BitstreamParser.ParseBitstream(buffer->data(), buffer->size());
-  _h264BitstreamParser.GetLastSliceQp(&qp);
-  frame.qp = @(qp);
+  _h264BitstreamParser.ParseBitstream(*buffer);
+  frame.qp = @(_h264BitstreamParser.GetLastSliceQp().value_or(-1));
 
   BOOL res = _callback(frame, codecSpecificInfo);
   if (!res) {
diff --git a/test/fuzzers/h264_bitstream_parser_fuzzer.cc b/test/fuzzers/h264_bitstream_parser_fuzzer.cc
index a9384d7..cd1128c 100644
--- a/test/fuzzers/h264_bitstream_parser_fuzzer.cc
+++ b/test/fuzzers/h264_bitstream_parser_fuzzer.cc
@@ -14,8 +14,8 @@
 namespace webrtc {
 void FuzzOneInput(const uint8_t* data, size_t size) {
   H264BitstreamParser h264_bitstream_parser;
-  h264_bitstream_parser.ParseBitstream(data, size);
-  int qp;
-  h264_bitstream_parser.GetLastSliceQp(&qp);
+  h264_bitstream_parser.ParseBitstream(
+      rtc::ArrayView<const uint8_t>(data, size));
+  h264_bitstream_parser.GetLastSliceQp();
 }
 }  // namespace webrtc