Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: webrtc/modules/video_coding/utility/h264_bitstream_parser_unittest.cc

Issue 2373393002: Support for parsing CABAC coded bitstreams (Closed)
Patch Set: Add support for CABAC in bitstream parser Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 0xe8, 0x06, 0xd0, 0xa1, 0x35, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x06, 25 0xe8, 0x06, 0xd0, 0xa1, 0x35, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x06,
26 0xe2, 0x00, 0x00, 0x00, 0x01, 0x65, 0xb8, 0x40, 0xf0, 0x8c, 0x03, 0xf2, 26 0xe2, 0x00, 0x00, 0x00, 0x01, 0x65, 0xb8, 0x40, 0xf0, 0x8c, 0x03, 0xf2,
27 0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8, 27 0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8,
28 }; 28 };
29 29
30 // Contains enough of the image slice to contain slice QP. 30 // Contains enough of the image slice to contain slice QP.
31 uint8_t kH264BitstreamNextImageSliceChunk[] = { 31 uint8_t kH264BitstreamNextImageSliceChunk[] = {
32 0x00, 0x00, 0x00, 0x01, 0x41, 0xe2, 0x01, 0x16, 0x0e, 0x3e, 0x2b, 0x86, 32 0x00, 0x00, 0x00, 0x01, 0x41, 0xe2, 0x01, 0x16, 0x0e, 0x3e, 0x2b, 0x86,
33 }; 33 };
34 34
35 uint8_t kH264BitstreamChunkCABAC[] = {
stefan-webrtc 2016/09/30 13:33:09 s/CABAC/Cabac/
36 0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x80, 0x20, 0xda, 0x01, 0x40, 0x16,
37 0xe8, 0x06, 0xd0, 0xa1, 0x35, 0x00, 0x00, 0x00, 0x01, 0x68, 0xfe, 0x06,
38 0xe2, 0x00, 0x00, 0x00, 0x01, 0x65, 0xb8, 0x40, 0xf0, 0x8c, 0x03, 0xf2,
39 0x75, 0x67, 0xad, 0x41, 0x64, 0x24, 0x0e, 0xa0, 0xb2, 0x12, 0x1e, 0xf8,
40 };
41
42 // Contains enough of the image slice to contain slice QP.
43 uint8_t kH264BitstreamNextImageSliceChunkCABAC[] = {
44 0x00, 0x00, 0x00, 0x01, 0x41, 0xe2, 0x01, 0x16, 0x0e, 0x3e, 0x2b, 0x86,
45 };
46
35 TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) { 47 TEST(H264BitstreamParserTest, ReportsNoQpWithoutParsedSlices) {
36 H264BitstreamParser h264_parser; 48 H264BitstreamParser h264_parser;
37 int qp; 49 int qp;
38 EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp)); 50 EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
39 } 51 }
40 52
41 TEST(H264BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) { 53 TEST(H264BitstreamParserTest, ReportsNoQpWithOnlyParsedPpsAndSpsSlices) {
42 H264BitstreamParser h264_parser; 54 H264BitstreamParser h264_parser;
43 h264_parser.ParseBitstream(kH264SpsPps, sizeof(kH264SpsPps)); 55 h264_parser.ParseBitstream(kH264SpsPps, sizeof(kH264SpsPps));
44 int qp; 56 int qp;
45 EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp)); 57 EXPECT_FALSE(h264_parser.GetLastSliceQp(&qp));
46 } 58 }
47 59
48 TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) { 60 TEST(H264BitstreamParserTest, ReportsLastSliceQpForImageSlices) {
49 H264BitstreamParser h264_parser; 61 H264BitstreamParser h264_parser;
50 h264_parser.ParseBitstream(kH264BitstreamChunk, sizeof(kH264BitstreamChunk)); 62 h264_parser.ParseBitstream(kH264BitstreamChunk, sizeof(kH264BitstreamChunk));
51 int qp; 63 int qp;
52 ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp)); 64 ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
53 EXPECT_EQ(35, qp); 65 EXPECT_EQ(35, qp);
54 66
55 // Parse an additional image slice. 67 // Parse an additional image slice.
56 h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunk, 68 h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunk,
57 sizeof(kH264BitstreamNextImageSliceChunk)); 69 sizeof(kH264BitstreamNextImageSliceChunk));
58 ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp)); 70 ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
59 EXPECT_EQ(37, qp); 71 EXPECT_EQ(37, qp);
60 } 72 }
61 73
74 TEST(H264BitstreamParserTest, ReportsLastSliceQpForCABACImageSlices) {
75 H264BitstreamParser h264_parser;
76 h264_parser.ParseBitstream(kH264BitstreamChunkCABAC,
77 sizeof(kH264BitstreamChunkCABAC));
78 int qp;
79 ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
80 EXPECT_EQ(35, qp);
81
82 // Parse an additional image slice.
83 h264_parser.ParseBitstream(kH264BitstreamNextImageSliceChunkCABAC,
84 sizeof(kH264BitstreamNextImageSliceChunkCABAC));
85 ASSERT_TRUE(h264_parser.GetLastSliceQp(&qp));
86 EXPECT_EQ(20, qp);
87 }
88
62 } // namespace webrtc 89 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698