From cc69ea4a93260efbde14aee236ce354a30ce3e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Thu, 19 Aug 2021 13:18:53 +0200 Subject: [PATCH] Fix parsing of vp9 skip level segmentation feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: chromium:1241297 Change-Id: I44c3e8eddcb2467aae7433f3907cff34fa807f69 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229302 Commit-Queue: Erik Språng Reviewed-by: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#34803} --- .../utility/vp9_uncompressed_header_parser.cc | 5 +++++ .../utility/vp9_uncompressed_header_parser_unittest.cc | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/modules/video_coding/utility/vp9_uncompressed_header_parser.cc b/modules/video_coding/utility/vp9_uncompressed_header_parser.cc index b8daf362af..b0650694ec 100644 --- a/modules/video_coding/utility/vp9_uncompressed_header_parser.cc +++ b/modules/video_coding/utility/vp9_uncompressed_header_parser.cc @@ -386,6 +386,11 @@ bool Vp9ReadSegmentationParams(BitstreamReader* br, for (size_t i = 0; i < kVp9MaxSegments; ++i) { for (size_t j = 0; j < kVp9SegLvlMax; ++j) { RETURN_IF_FALSE(br->IfNextBoolean([&] { // feature_enabled + if (kSegmentationFeatureBits[j] == 0) { + // No feature bits used and no sign, just mark it and return. + frame_info->segmentation_features[i][j] = 1; + return true; + } READ_OR_RETURN( br->ReadUnsigned(kSegmentationFeatureBits[j]), [&](uint8_t feature_value) { diff --git a/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc b/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc index e6cf6694cb..913f43eba7 100644 --- a/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc +++ b/modules/video_coding/utility/vp9_uncompressed_header_parser_unittest.cc @@ -84,5 +84,15 @@ TEST(Vp9UncompressedHeaderParserTest, SegmentationWithDefaultPredProbs) { Optional(ElementsAre(255, 255, 255))); } +TEST(Vp9UncompressedHeaderParserTest, SegmentationWithSkipLevel) { + const uint8_t kHeader[] = {0x90, 0x49, 0x83, 0x42, 0x80, 0x2e, 0x30, 0x00, + 0xb0, 0x00, 0x37, 0xff, 0x0d, 0x00, 0x02, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + absl::optional frame_info = + ParseUncompressedVp9Header(kHeader); + ASSERT_TRUE(frame_info.has_value()); + EXPECT_THAT(frame_info->segmentation_features[0][kVp9SegLvlSkip], Eq(1)); +} + } // namespace vp9 } // namespace webrtc