Export h.265 bitstream parser APIs.

This exports neccessary API as dependency for h.265 parameter sets tracker to be submitted at CL:5307256.

Bug: webrtc:13485
Change-Id: I042599472f17d12ece4fa862c3715497502a5d76
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/340004
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Jianlin Qiu <jianlin.qiu@intel.com>
Cr-Commit-Position: refs/heads/main@{#41814}
This commit is contained in:
Qiu Jianlin 2024-02-23 10:34:57 +08:00 committed by WebRTC LUCI CQ
parent 91ebd5fd12
commit c32a509da0
6 changed files with 25 additions and 11 deletions

View File

@ -542,4 +542,13 @@ absl::optional<int> H265BitstreamParser::GetLastSliceQp() const {
return parsed_qp;
}
absl::optional<uint32_t> H265BitstreamParser::GetLastSlicePpsId() const {
if (!last_slice_pps_id_) {
RTC_LOG(LS_ERROR) << "Failed to parse PPS id from bitstream.";
return absl::nullopt;
}
return last_slice_pps_id_;
}
} // namespace webrtc

View File

@ -22,12 +22,13 @@
#include "common_video/h265/h265_sps_parser.h"
#include "common_video/h265/h265_vps_parser.h"
#include "rtc_base/containers/flat_map.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
// Stateful H265 bitstream parser (due to VPS/SPS/PPS). Used to parse out QP
// values from the bitstream.
class H265BitstreamParser : public BitstreamParser {
class RTC_EXPORT H265BitstreamParser : public BitstreamParser {
public:
H265BitstreamParser();
~H265BitstreamParser() override;
@ -36,6 +37,8 @@ class H265BitstreamParser : public BitstreamParser {
void ParseBitstream(rtc::ArrayView<const uint8_t> bitstream) override;
absl::optional<int> GetLastSliceQp() const override;
absl::optional<uint32_t> GetLastSlicePpsId() const;
static absl::optional<uint32_t> ParsePpsIdFromSliceSegmentLayerRbsp(
const uint8_t* data,
size_t length,

View File

@ -16,6 +16,7 @@
#include "common_video/h265/h265_inline.h"
#include "rtc_base/buffer.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@ -76,11 +77,11 @@ struct NaluIndex {
};
// Returns a vector of the NALU indices in the given buffer.
std::vector<NaluIndex> FindNaluIndices(const uint8_t* buffer,
RTC_EXPORT std::vector<NaluIndex> FindNaluIndices(const uint8_t* buffer,
size_t buffer_size);
// Get the NAL type from the header byte immediately following start sequence.
NaluType ParseNaluType(uint8_t data);
RTC_EXPORT NaluType ParseNaluType(uint8_t data);
// Methods for parsing and writing RBSP. See section 7.4.2 of the H.265 spec.
//

View File

@ -15,11 +15,12 @@
#include "api/array_view.h"
#include "common_video/h265/h265_sps_parser.h"
#include "rtc_base/bitstream_reader.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
// A class for parsing out picture parameter set (PPS) data from a H265 NALU.
class H265PpsParser {
class RTC_EXPORT H265PpsParser {
public:
// The parsed state of the PPS. Only some select values are stored.
// Add more as they are actually needed.

View File

@ -16,6 +16,7 @@
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "rtc_base/bitstream_reader.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@ -42,7 +43,7 @@ enum H265ProfileIdc {
};
// A class for parsing out sequence parameter set (SPS) data from an H265 NALU.
class H265SpsParser {
class RTC_EXPORT H265SpsParser {
public:
struct ProfileTierLevel {
ProfileTierLevel();
@ -74,7 +75,7 @@ class H265SpsParser {
// The parsed state of the SPS. Only some select values are stored.
// Add more as they are actually needed.
struct SpsState {
struct RTC_EXPORT SpsState {
SpsState() = default;
uint32_t sps_max_sub_layers_minus1 = 0;
@ -124,8 +125,6 @@ class H265SpsParser {
// performed.
static absl::optional<SpsState> ParseSpsInternal(
rtc::ArrayView<const uint8_t> buffer);
static bool ParseProfileTierLevel(BitstreamReader& reader,
uint32_t sps_max_sub_layers_minus1);
// From Table A.8 - General tier and level limits.
static int GetMaxLumaPs(int general_level_idc);

View File

@ -13,15 +13,16 @@
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
// A class for parsing out video parameter set (VPS) data from an H265 NALU.
class H265VpsParser {
class RTC_EXPORT H265VpsParser {
public:
// The parsed state of the VPS. Only some select values are stored.
// Add more as they are actually needed.
struct VpsState {
struct RTC_EXPORT VpsState {
VpsState();
uint32_t id = 0;