Apply QpParser for H.265 streams.
Video stream encoder now parses Qp for H.265 streams as well.
Bug: webrtc:13485
Change-Id: I0db4e0e34e70d189f8e99b4b182fd3ea14b8c734
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330883
Commit-Queue: Jianlin Qiu <jianlin.qiu@intel.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41355}
diff --git a/modules/video_coding/utility/qp_parser.cc b/modules/video_coding/utility/qp_parser.cc
index 3b9aaa3..a531b54 100644
--- a/modules/video_coding/utility/qp_parser.cc
+++ b/modules/video_coding/utility/qp_parser.cc
@@ -37,7 +37,10 @@
} else if (codec_type == kVideoCodecH264) {
return h264_parsers_[spatial_idx].Parse(frame_data, frame_size);
} else if (codec_type == kVideoCodecH265) {
- // TODO(bugs.webrtc.org/13485)
+ // H.265 bitstream parser is conditionally built.
+#ifdef RTC_ENABLE_H265
+ return h265_parsers_[spatial_idx].Parse(frame_data, frame_size);
+#endif
}
return absl::nullopt;
@@ -52,4 +55,15 @@
return bitstream_parser_.GetLastSliceQp();
}
+#ifdef RTC_ENABLE_H265
+absl::optional<uint32_t> QpParser::H265QpParser::Parse(
+ const uint8_t* frame_data,
+ size_t frame_size) {
+ MutexLock lock(&mutex_);
+ bitstream_parser_.ParseBitstream(
+ rtc::ArrayView<const uint8_t>(frame_data, frame_size));
+ return bitstream_parser_.GetLastSliceQp();
+}
+#endif
+
} // namespace webrtc
diff --git a/modules/video_coding/utility/qp_parser.h b/modules/video_coding/utility/qp_parser.h
index f132ff9..210fe02 100644
--- a/modules/video_coding/utility/qp_parser.h
+++ b/modules/video_coding/utility/qp_parser.h
@@ -15,6 +15,9 @@
#include "api/video/video_codec_constants.h"
#include "api/video/video_codec_type.h"
#include "common_video/h264/h264_bitstream_parser.h"
+#ifdef RTC_ENABLE_H265
+#include "common_video/h265/h265_bitstream_parser.h"
+#endif
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@@ -38,6 +41,21 @@
};
H264QpParser h264_parsers_[kMaxSimulcastStreams];
+
+#ifdef RTC_ENABLE_H265
+ // A thread safe wrapper for H.265 bitstream parser.
+ class H265QpParser {
+ public:
+ absl::optional<uint32_t> Parse(const uint8_t* frame_data,
+ size_t frame_size);
+
+ private:
+ Mutex mutex_;
+ H265BitstreamParser bitstream_parser_ RTC_GUARDED_BY(mutex_);
+ };
+
+ H265QpParser h265_parsers_[kMaxSimulcastStreams];
+#endif
};
} // namespace webrtc