Enable QP parsing from CABAC bitstreams

This was added a while back in d020f3fea but dissapeared during a
rebase. This CL adds it back.

BUG=webrtc:6338
R=magjed@webrtc.org

Review-Url: https://codereview.webrtc.org/2521283002
Cr-Commit-Position: refs/heads/master@{#15194}
This commit is contained in:
kthelgason 2016-11-22 06:53:31 -08:00 committed by Commit bot
parent 04c0722cf1
commit ab6996dc10
2 changed files with 32 additions and 3 deletions

View File

@ -242,9 +242,12 @@ H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu(
}
}
}
// cabac not supported: entropy_coding_mode_flag == 0 asserted above.
// if (entropy_coding_mode_flag && slice_type != I && slice_type != SI)
// cabac_init_idc
if (pps_->entropy_coding_mode_flag &&
slice_type != H264::SliceType::kI && slice_type != H264::SliceType::kSi) {
// cabac_init_idc: ue(v)
RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp));
}
int32_t last_slice_qp_delta;
RETURN_INV_ON_FAIL(
slice_reader.ReadSignedExponentialGolomb(&last_slice_qp_delta));

View File

@ -27,11 +27,23 @@ uint8_t kH264BitstreamChunk[] = {
0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8,
};
uint8_t kH264BitstreamChunkCabac[] = {
0x00, 0x00, 0x00, 0x01, 0x27, 0x64, 0x00, 0x0d, 0xac, 0x52, 0x30, 0x50,
0x7e, 0xc0, 0x5a, 0x81, 0x01, 0x01, 0x18, 0x56, 0xbd, 0xef, 0x80, 0x80,
0x00, 0x00, 0x00, 0x01, 0x28, 0xfe, 0x09, 0x8b,
};
// Contains enough of the image slice to contain slice QP.
uint8_t kH264BitstreamNextImageSliceChunk[] = {
0x00, 0x00, 0x00, 0x01, 0x41, 0xe2, 0x01, 0x16, 0x0e, 0x3e, 0x2b, 0x86,
};
// Contains enough of the image slice to contain slice QP.
uint8_t kH264BitstreamNextImageSliceChunkCabac[] = {
0x00, 0x00, 0x00, 0x01, 0x21, 0xe1, 0x05, 0x11, 0x3f, 0x9a, 0xae, 0x46,
0x70, 0xbf, 0xc1, 0x4a, 0x16, 0x8f, 0x51, 0xf4, 0xca, 0xfb, 0xa3, 0x65,
};
TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) {
H264BitstreamParser h264_parser;
int qp;
@ -59,4 +71,18 @@ TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) {
EXPECT_EQ(37, qp);
}
TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) {
H264BitstreamParser h264_parser;
h264_parser.ParseBitstream(kH264BitstreamChunkCabac,
sizeof(kH264BitstreamChunkCabac));
int qp;
EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
// Parse an additional image slice.
h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCabac,
sizeof(kH264BitstreamNextImageSliceChunkCabac));
ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
EXPECT_EQ(24, qp);
}
} // namespace webrtc