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}
This commit is contained in:
@ -296,35 +296,24 @@ void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
void H264BitstreamParser::ParseBitstream(
|
||||||
rtc::ArrayView<const uint8_t> bitstream) {
|
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 {
|
absl::optional<int> H264BitstreamParser::GetLastSliceQp() const {
|
||||||
int qp;
|
if (!last_slice_qp_delta_ || !pps_)
|
||||||
bool success = GetLastSliceQp(&qp);
|
return absl::nullopt;
|
||||||
return success ? absl::optional<int>(qp) : 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
|
} // namespace webrtc
|
||||||
|
@ -31,11 +31,6 @@ class H264BitstreamParser : public BitstreamParser {
|
|||||||
H264BitstreamParser();
|
H264BitstreamParser();
|
||||||
~H264BitstreamParser() override;
|
~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;
|
void ParseBitstream(rtc::ArrayView<const uint8_t> bitstream) override;
|
||||||
absl::optional<int> GetLastSliceQp() const override;
|
absl::optional<int> GetLastSliceQp() const override;
|
||||||
|
|
||||||
|
@ -46,43 +46,39 @@ uint8_t kH264BitstreamNextImageSliceChunkCabac[] = {
|
|||||||
|
|
||||||
TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) {
|
TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) {
|
||||||
H264BitstreamParser h264_parser;
|
H264BitstreamParser h264_parser;
|
||||||
int qp;
|
EXPECT_FALSE(h264_parser.GetLastSliceQp().has_value());
|
||||||
EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(H264BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) {
|
TEST(H264BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) {
|
||||||
H264BitstreamParser h264_parser;
|
H264BitstreamParser h264_parser;
|
||||||
h264_parser.ParseBitstream(kH264SpsPps, sizeof(kH264SpsPps));
|
h264_parser.ParseBitstream(kH264SpsPps);
|
||||||
int qp;
|
EXPECT_FALSE(h264_parser.GetLastSliceQp().has_value());
|
||||||
EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) {
|
TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) {
|
||||||
H264BitstreamParser h264_parser;
|
H264BitstreamParser h264_parser;
|
||||||
h264_parser.ParseBitstream(kH264BitstreamChunk, sizeof(kH264BitstreamChunk));
|
h264_parser.ParseBitstream(kH264BitstreamChunk);
|
||||||
int qp;
|
absl::optional<int> qp = h264_parser.GetLastSliceQp();
|
||||||
ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
|
ASSERT_TRUE(qp.has_value());
|
||||||
EXPECT_EQ(35, qp);
|
EXPECT_EQ(35, *qp);
|
||||||
|
|
||||||
// Parse an additional image slice.
|
// Parse an additional image slice.
|
||||||
h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunk,
|
h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunk);
|
||||||
sizeof(kH264BitstreamNextImageSliceChunk));
|
qp = h264_parser.GetLastSliceQp();
|
||||||
ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
|
ASSERT_TRUE(qp.has_value());
|
||||||
EXPECT_EQ(37, qp);
|
EXPECT_EQ(37, *qp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) {
|
TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) {
|
||||||
H264BitstreamParser h264_parser;
|
H264BitstreamParser h264_parser;
|
||||||
h264_parser.ParseBitstream(kH264BitstreamChunkCabac,
|
h264_parser.ParseBitstream(kH264BitstreamChunkCabac);
|
||||||
sizeof(kH264BitstreamChunkCabac));
|
EXPECT_FALSE(h264_parser.GetLastSliceQp().has_value());
|
||||||
int qp;
|
|
||||||
EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
|
|
||||||
|
|
||||||
// Parse an additional image slice.
|
// Parse an additional image slice.
|
||||||
h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac,
|
h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac);
|
||||||
sizeof(kH264BitstreamNextImageSliceChunkCabac));
|
absl::optional<int> qp = h264_parser.GetLastSliceQp();
|
||||||
ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
|
ASSERT_TRUE(qp.has_value());
|
||||||
EXPECT_EQ(24, qp);
|
EXPECT_EQ(24, *qp);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -294,13 +294,9 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
|
|||||||
// the input one.
|
// the input one.
|
||||||
RTC_DCHECK_EQ(av_frame_->reordered_opaque, frame_timestamp_us);
|
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.
|
// TODO(sakal): Maybe it is possible to get QP directly from FFmpeg.
|
||||||
h264_bitstream_parser_.ParseBitstream(input_image.data(), input_image.size());
|
h264_bitstream_parser_.ParseBitstream(input_image);
|
||||||
int qp_int;
|
absl::optional<int> qp = h264_bitstream_parser_.GetLastSliceQp();
|
||||||
if (h264_bitstream_parser_.GetLastSliceQp(&qp_int)) {
|
|
||||||
qp.emplace(qp_int);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain the |video_frame| containing the decoded image.
|
// Obtain the |video_frame| containing the decoded image.
|
||||||
VideoFrame* input_frame =
|
VideoFrame* input_frame =
|
||||||
|
@ -481,9 +481,9 @@ int32_t H264EncoderImpl::Encode(
|
|||||||
// |encoded_images_[i]._length| == 0.
|
// |encoded_images_[i]._length| == 0.
|
||||||
if (encoded_images_[i].size() > 0) {
|
if (encoded_images_[i].size() > 0) {
|
||||||
// Parse QP.
|
// Parse QP.
|
||||||
h264_bitstream_parser_.ParseBitstream(encoded_images_[i].data(),
|
h264_bitstream_parser_.ParseBitstream(encoded_images_[i]);
|
||||||
encoded_images_[i].size());
|
encoded_images_[i].qp_ =
|
||||||
h264_bitstream_parser_.GetLastSliceQp(&encoded_images_[i].qp_);
|
h264_bitstream_parser_.GetLastSliceQp().value_or(-1);
|
||||||
|
|
||||||
// Deliver encoded image.
|
// Deliver encoded image.
|
||||||
CodecSpecificInfo codec_specific;
|
CodecSpecificInfo codec_specific;
|
||||||
|
@ -249,12 +249,8 @@ absl::optional<uint8_t> VideoDecoderWrapper::ParseQP(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVideoCodecH264: {
|
case kVideoCodecH264: {
|
||||||
h264_bitstream_parser_.ParseBitstream(input_image.data(),
|
h264_bitstream_parser_.ParseBitstream(input_image);
|
||||||
input_image.size());
|
qp = h264_bitstream_parser_.GetLastSliceQp();
|
||||||
int qp_int;
|
|
||||||
if (h264_bitstream_parser_.GetLastSliceQp(&qp_int)) {
|
|
||||||
qp = qp_int;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -309,8 +309,9 @@ int VideoEncoderWrapper::ParseQp(rtc::ArrayView<const uint8_t> buffer) {
|
|||||||
success = vp9::GetQp(buffer.data(), buffer.size(), &qp);
|
success = vp9::GetQp(buffer.data(), buffer.size(), &qp);
|
||||||
break;
|
break;
|
||||||
case kVideoCodecH264:
|
case kVideoCodecH264:
|
||||||
h264_bitstream_parser_.ParseBitstream(buffer.data(), buffer.size());
|
h264_bitstream_parser_.ParseBitstream(buffer);
|
||||||
success = h264_bitstream_parser_.GetLastSliceQp(&qp);
|
qp = h264_bitstream_parser_.GetLastSliceQp().value_or(-1);
|
||||||
|
success = (qp >= 0);
|
||||||
break;
|
break;
|
||||||
default: // Default is to not provide QP.
|
default: // Default is to not provide QP.
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -802,10 +802,8 @@ NSUInteger GetMaxSampleRate(const webrtc::H264::ProfileLevelId &profile_level_id
|
|||||||
RTCVideoContentTypeUnspecified;
|
RTCVideoContentTypeUnspecified;
|
||||||
frame.flags = webrtc::VideoSendTiming::kInvalid;
|
frame.flags = webrtc::VideoSendTiming::kInvalid;
|
||||||
|
|
||||||
int qp;
|
_h264BitstreamParser.ParseBitstream(*buffer);
|
||||||
_h264BitstreamParser.ParseBitstream(buffer->data(), buffer->size());
|
frame.qp = @(_h264BitstreamParser.GetLastSliceQp().value_or(-1));
|
||||||
_h264BitstreamParser.GetLastSliceQp(&qp);
|
|
||||||
frame.qp = @(qp);
|
|
||||||
|
|
||||||
BOOL res = _callback(frame, codecSpecificInfo);
|
BOOL res = _callback(frame, codecSpecificInfo);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||||
H264BitstreamParser h264_bitstream_parser;
|
H264BitstreamParser h264_bitstream_parser;
|
||||||
h264_bitstream_parser.ParseBitstream(data, size);
|
h264_bitstream_parser.ParseBitstream(
|
||||||
int qp;
|
rtc::ArrayView<const uint8_t>(data, size));
|
||||||
h264_bitstream_parser.GetLastSliceQp(&qp);
|
h264_bitstream_parser.GetLastSliceQp();
|
||||||
}
|
}
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Reference in New Issue
Block a user