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}
This commit is contained in:
Qiu Jianlin 2023-12-11 16:21:03 +08:00 committed by WebRTC LUCI CQ
parent 9ae1e41205
commit ddf6084096
2 changed files with 33 additions and 1 deletions

View File

@ -37,7 +37,10 @@ absl::optional<uint32_t> QpParser::Parse(VideoCodecType codec_type,
} 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 @@ absl::optional<uint32_t> QpParser::H264QpParser::Parse(
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

View File

@ -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 @@ class QpParser {
};
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