in Vp9UncompressedHeaderParser fix reading delta quantization parameter

delta_q is encoded as signed integer (s(4)) that uses extra bit for the
sign. See VP9 Bitstream Specification section 6.2.10 Delta quantizer syntax

Bug: None
Change-Id: Ib458c2a2ded3c4d6c153b6bedd29c48ef12cc538
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231125
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34908}
This commit is contained in:
Danil Chapovalov
2021-09-02 13:37:54 +02:00
committed by WebRTC LUCI CQ
parent d3bf4d4142
commit cd4ab49ee7
2 changed files with 6 additions and 3 deletions

View File

@ -145,7 +145,10 @@ void Vp9ReadQp(BitstreamReader& br, Vp9UncompressedHeader* frame_info) {
frame_info->is_lossless = frame_info->base_qp == 0;
for (int i = 0; i < 3; ++i) {
if (br.Read<bool>()) { // if delta_coded
if (br.ReadBits(4) != 0) {
// delta_q is a signed integer with leading 4 bits containing absolute
// value and last bit containing sign. There are are two ways to represent
// zero with such encoding.
if ((br.ReadBits(5) & 0b1111'0) != 0) { // delta_q
frame_info->is_lossless = false;
}
}

View File

@ -72,7 +72,7 @@ TEST(Vp9UncompressedHeaderParserTest, FrameWithSegmentation) {
TEST(Vp9UncompressedHeaderParserTest, SegmentationWithDefaultPredProbs) {
const uint8_t kHeader[] = {0x90, 0x49, 0x83, 0x42, 0x80, 0x2e,
0x30, 0x0, 0xb0, 0x0, 0x37, 0xff,
0xd, 0x0, 0x0, 0x0, 0x0, 0x0};
0x06, 0x80, 0x0, 0x0, 0x0, 0x0};
absl::optional<Vp9UncompressedHeader> frame_info =
ParseUncompressedVp9Header(kHeader);
ASSERT_TRUE(frame_info.has_value());
@ -82,7 +82,7 @@ TEST(Vp9UncompressedHeaderParserTest, SegmentationWithDefaultPredProbs) {
TEST(Vp9UncompressedHeaderParserTest, SegmentationWithSkipLevel) {
const uint8_t kHeader[] = {0x90, 0x49, 0x83, 0x42, 0x80, 0x2e, 0x30, 0x00,
0xb0, 0x00, 0x37, 0xff, 0x0d, 0x00, 0x02, 0x10,
0xb0, 0x00, 0x37, 0xff, 0x06, 0x80, 0x01, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
absl::optional<Vp9UncompressedHeader> frame_info =
ParseUncompressedVp9Header(kHeader);