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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc

Issue 2356793002: Add support for 3-byte headers in VideoToolbox NALU parser. (Closed)
Patch Set: Created 4 years, 3 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining()); 81 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining());
82 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length)); 82 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
83 EXPECT_EQ(annex_b_test_data + 4, nalu); 83 EXPECT_EQ(annex_b_test_data + 4, nalu);
84 EXPECT_EQ(1u, nalu_length); 84 EXPECT_EQ(1u, nalu_length);
85 EXPECT_EQ(0u, reader.BytesRemaining()); 85 EXPECT_EQ(0u, reader.BytesRemaining());
86 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length)); 86 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
87 EXPECT_EQ(nullptr, nalu); 87 EXPECT_EQ(nullptr, nalu);
88 EXPECT_EQ(0u, nalu_length); 88 EXPECT_EQ(0u, nalu_length);
89 } 89 }
90 90
91 TEST(AnnexBBufferReaderTest, TestReadSingleNalu3ByteHeader) {
92 const uint8_t annex_b_test_data[] = {0x00, 0x00, 0x01, 0xAA};
93 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data));
94 const uint8_t* nalu = nullptr;
95 size_t nalu_length = 0;
96 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining());
97 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
98 EXPECT_EQ(annex_b_test_data + 3, nalu);
99 EXPECT_EQ(1u, nalu_length);
100 EXPECT_EQ(0u, reader.BytesRemaining());
101 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
102 EXPECT_EQ(nullptr, nalu);
103 EXPECT_EQ(0u, nalu_length);
104 }
105
91 TEST(AnnexBBufferReaderTest, TestReadMissingNalu) { 106 TEST(AnnexBBufferReaderTest, TestReadMissingNalu) {
92 // clang-format off 107 // clang-format off
93 const uint8_t annex_b_test_data[] = {0x01, 108 const uint8_t annex_b_test_data[] = {0x01,
94 0x00, 0x01, 109 0x00, 0x01,
95 0x00, 0x00, 0x01,
96 0x00, 0x00, 0x00, 0xFF}; 110 0x00, 0x00, 0x00, 0xFF};
97 // clang-format on 111 // clang-format on
98 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data)); 112 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data));
99 const uint8_t* nalu = nullptr; 113 const uint8_t* nalu = nullptr;
100 size_t nalu_length = 0; 114 size_t nalu_length = 0;
101 EXPECT_EQ(0u, reader.BytesRemaining()); 115 EXPECT_EQ(0u, reader.BytesRemaining());
102 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length)); 116 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
103 EXPECT_EQ(nullptr, nalu); 117 EXPECT_EQ(nullptr, nalu);
104 EXPECT_EQ(0u, nalu_length); 118 EXPECT_EQ(0u, nalu_length);
105 } 119 }
106 120
107 TEST(AnnexBBufferReaderTest, TestReadMultipleNalus) { 121 TEST(AnnexBBufferReaderTest, TestReadMultipleNalus) {
108 // clang-format off 122 // clang-format off
109 const uint8_t annex_b_test_data[] = {0x00, 0x00, 0x00, 0x01, 0xFF, 123 const uint8_t annex_b_test_data[] = {0x00, 0x00, 0x00, 0x01, 0xFF,
110 0x01, 124 0x01,
111 0x00, 0x01, 125 0x00, 0x01,
112 0x00, 0x00, 0x01,
113 0x00, 0x00, 0x00, 0xFF, 126 0x00, 0x00, 0x00, 0xFF,
114 0x00, 0x00, 0x00, 0x01, 0xAA, 0xBB}; 127 0x00, 0x00, 0x01, 0xAA, 0xBB};
115 // clang-format on 128 // clang-format on
116 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data)); 129 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data));
117 const uint8_t* nalu = nullptr; 130 const uint8_t* nalu = nullptr;
118 size_t nalu_length = 0; 131 size_t nalu_length = 0;
119 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining()); 132 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining());
120 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length)); 133 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
121 EXPECT_EQ(annex_b_test_data + 4, nalu); 134 EXPECT_EQ(annex_b_test_data + 4, nalu);
122 EXPECT_EQ(11u, nalu_length); 135 EXPECT_EQ(8u, nalu_length);
123 EXPECT_EQ(6u, reader.BytesRemaining()); 136 EXPECT_EQ(6u, reader.BytesRemaining());
124 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length)); 137 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
125 EXPECT_EQ(annex_b_test_data + 19, nalu); 138 EXPECT_EQ(annex_b_test_data + 16, nalu);
126 EXPECT_EQ(2u, nalu_length); 139 EXPECT_EQ(2u, nalu_length);
127 EXPECT_EQ(0u, reader.BytesRemaining()); 140 EXPECT_EQ(0u, reader.BytesRemaining());
128 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length)); 141 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
129 EXPECT_EQ(nullptr, nalu); 142 EXPECT_EQ(nullptr, nalu);
130 EXPECT_EQ(0u, nalu_length); 143 EXPECT_EQ(0u, nalu_length);
131 } 144 }
132 145
133 TEST(AvccBufferWriterTest, TestEmptyOutputBuffer) { 146 TEST(AvccBufferWriterTest, TestEmptyOutputBuffer) {
134 const uint8_t expected_buffer[] = {0x00}; 147 const uint8_t expected_buffer[] = {0x00};
135 const size_t buffer_size = 1; 148 const size_t buffer_size = 1;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_EQ(buffer_size, writer.BytesRemaining()); 200 EXPECT_EQ(buffer_size, writer.BytesRemaining());
188 EXPECT_FALSE(writer.WriteNalu(NALU_TEST_DATA_0, arraysize(NALU_TEST_DATA_0))); 201 EXPECT_FALSE(writer.WriteNalu(NALU_TEST_DATA_0, arraysize(NALU_TEST_DATA_0)));
189 EXPECT_EQ(buffer_size, writer.BytesRemaining()); 202 EXPECT_EQ(buffer_size, writer.BytesRemaining());
190 EXPECT_EQ(0, 203 EXPECT_EQ(0,
191 memcmp(expected_buffer, buffer.get(), arraysize(expected_buffer))); 204 memcmp(expected_buffer, buffer.get(), arraysize(expected_buffer)));
192 } 205 }
193 206
194 } // namespace webrtc 207 } // namespace webrtc
195 208
196 #endif // WEBRTC_VIDEO_TOOLBOX_SUPPORTED 209 #endif // WEBRTC_VIDEO_TOOLBOX_SUPPORTED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698