Fix AVC PPS parser unit test.

This fixes PPS parser unit test case that retrieves PPS id from slice header.

Bug: webrtc:14951
Change-Id: I7aeea9fe15307a683e71f4c4f3c4b89d0471eda4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255904
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39437}
This commit is contained in:
Qiu Jianlin 2023-03-01 18:06:06 +08:00 committed by WebRTC LUCI CQ
parent c0f8813870
commit cec9d00769

View File

@ -10,6 +10,8 @@
#include "common_video/h264/pps_parser.h" #include "common_video/h264/pps_parser.h"
#include <vector>
#include "common_video/h264/h264_common.h" #include "common_video/h264/h264_common.h"
#include "rtc_base/bit_buffer.h" #include "rtc_base/bit_buffer.h"
#include "rtc_base/buffer.h" #include "rtc_base/buffer.h"
@ -213,10 +215,19 @@ TEST_F(PpsParserTest, MaxPps) {
} }
TEST_F(PpsParserTest, PpsIdFromSlice) { TEST_F(PpsParserTest, PpsIdFromSlice) {
std::vector<H264::NaluIndex> nalu_indices =
H264::FindNaluIndices(kH264BitstreamChunk, sizeof(kH264BitstreamChunk));
EXPECT_EQ(nalu_indices.size(), 3ull);
for (const auto& index : nalu_indices) {
H264::NaluType nalu_type =
H264::ParseNaluType(kH264BitstreamChunk[index.payload_start_offset]);
if (nalu_type == H264::NaluType::kIdr) {
absl::optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice( absl::optional<uint32_t> pps_id = PpsParser::ParsePpsIdFromSlice(
kH264BitstreamChunk, sizeof(kH264BitstreamChunk)); kH264BitstreamChunk + index.payload_start_offset, index.payload_size);
ASSERT_TRUE(pps_id); EXPECT_EQ(pps_id, 0u);
EXPECT_EQ(2u, *pps_id); break;
}
}
} }
} // namespace webrtc } // namespace webrtc