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

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: rebase 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
« no previous file with comments | « webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining()); 80 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining());
81 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length)); 81 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
82 EXPECT_EQ(annex_b_test_data + 4, nalu); 82 EXPECT_EQ(annex_b_test_data + 4, nalu);
83 EXPECT_EQ(1u, nalu_length); 83 EXPECT_EQ(1u, nalu_length);
84 EXPECT_EQ(0u, reader.BytesRemaining()); 84 EXPECT_EQ(0u, reader.BytesRemaining());
85 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length)); 85 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
86 EXPECT_EQ(nullptr, nalu); 86 EXPECT_EQ(nullptr, nalu);
87 EXPECT_EQ(0u, nalu_length); 87 EXPECT_EQ(0u, nalu_length);
88 } 88 }
89 89
90 TEST(AnnexBBufferReaderTest, TestReadSingleNalu3ByteHeader) {
91 const uint8_t annex_b_test_data[] = {0x00, 0x00, 0x01, 0xAA};
92 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data));
93 const uint8_t* nalu = nullptr;
94 size_t nalu_length = 0;
95 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining());
96 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
97 EXPECT_EQ(annex_b_test_data + 3, nalu);
98 EXPECT_EQ(1u, nalu_length);
99 EXPECT_EQ(0u, reader.BytesRemaining());
100 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
101 EXPECT_EQ(nullptr, nalu);
102 EXPECT_EQ(0u, nalu_length);
103 }
104
90 TEST(AnnexBBufferReaderTest, TestReadMissingNalu) { 105 TEST(AnnexBBufferReaderTest, TestReadMissingNalu) {
91 // clang-format off 106 // clang-format off
92 const uint8_t annex_b_test_data[] = {0x01, 107 const uint8_t annex_b_test_data[] = {0x01,
93 0x00, 0x01, 108 0x00, 0x01,
94 0x00, 0x00, 0x01,
95 0x00, 0x00, 0x00, 0xFF}; 109 0x00, 0x00, 0x00, 0xFF};
96 // clang-format on 110 // clang-format on
97 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data)); 111 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data));
98 const uint8_t* nalu = nullptr; 112 const uint8_t* nalu = nullptr;
99 size_t nalu_length = 0; 113 size_t nalu_length = 0;
100 EXPECT_EQ(0u, reader.BytesRemaining()); 114 EXPECT_EQ(0u, reader.BytesRemaining());
101 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length)); 115 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
102 EXPECT_EQ(nullptr, nalu); 116 EXPECT_EQ(nullptr, nalu);
103 EXPECT_EQ(0u, nalu_length); 117 EXPECT_EQ(0u, nalu_length);
104 } 118 }
105 119
106 TEST(AnnexBBufferReaderTest, TestReadMultipleNalus) { 120 TEST(AnnexBBufferReaderTest, TestReadMultipleNalus) {
107 // clang-format off 121 // clang-format off
108 const uint8_t annex_b_test_data[] = {0x00, 0x00, 0x00, 0x01, 0xFF, 122 const uint8_t annex_b_test_data[] = {0x00, 0x00, 0x00, 0x01, 0xFF,
109 0x01, 123 0x01,
110 0x00, 0x01, 124 0x00, 0x01,
111 0x00, 0x00, 0x01,
112 0x00, 0x00, 0x00, 0xFF, 125 0x00, 0x00, 0x00, 0xFF,
113 0x00, 0x00, 0x00, 0x01, 0xAA, 0xBB}; 126 0x00, 0x00, 0x01, 0xAA, 0xBB};
114 // clang-format on 127 // clang-format on
115 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data)); 128 AnnexBBufferReader reader(annex_b_test_data, arraysize(annex_b_test_data));
116 const uint8_t* nalu = nullptr; 129 const uint8_t* nalu = nullptr;
117 size_t nalu_length = 0; 130 size_t nalu_length = 0;
118 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining()); 131 EXPECT_EQ(arraysize(annex_b_test_data), reader.BytesRemaining());
119 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length)); 132 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
120 EXPECT_EQ(annex_b_test_data + 4, nalu); 133 EXPECT_EQ(annex_b_test_data + 4, nalu);
121 EXPECT_EQ(11u, nalu_length); 134 EXPECT_EQ(8u, nalu_length);
122 EXPECT_EQ(6u, reader.BytesRemaining()); 135 EXPECT_EQ(6u, reader.BytesRemaining());
123 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length)); 136 EXPECT_TRUE(reader.ReadNalu(&nalu, &nalu_length));
124 EXPECT_EQ(annex_b_test_data + 19, nalu); 137 EXPECT_EQ(annex_b_test_data + 16, nalu);
125 EXPECT_EQ(2u, nalu_length); 138 EXPECT_EQ(2u, nalu_length);
126 EXPECT_EQ(0u, reader.BytesRemaining()); 139 EXPECT_EQ(0u, reader.BytesRemaining());
127 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length)); 140 EXPECT_FALSE(reader.ReadNalu(&nalu, &nalu_length));
128 EXPECT_EQ(nullptr, nalu); 141 EXPECT_EQ(nullptr, nalu);
129 EXPECT_EQ(0u, nalu_length); 142 EXPECT_EQ(0u, nalu_length);
130 } 143 }
131 144
132 TEST(AvccBufferWriterTest, TestEmptyOutputBuffer) { 145 TEST(AvccBufferWriterTest, TestEmptyOutputBuffer) {
133 const uint8_t expected_buffer[] = {0x00}; 146 const uint8_t expected_buffer[] = {0x00};
134 const size_t buffer_size = 1; 147 const size_t buffer_size = 1;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 EXPECT_EQ(buffer_size, writer.BytesRemaining()); 199 EXPECT_EQ(buffer_size, writer.BytesRemaining());
187 EXPECT_FALSE(writer.WriteNalu(NALU_TEST_DATA_0, arraysize(NALU_TEST_DATA_0))); 200 EXPECT_FALSE(writer.WriteNalu(NALU_TEST_DATA_0, arraysize(NALU_TEST_DATA_0)));
188 EXPECT_EQ(buffer_size, writer.BytesRemaining()); 201 EXPECT_EQ(buffer_size, writer.BytesRemaining());
189 EXPECT_EQ(0, 202 EXPECT_EQ(0,
190 memcmp(expected_buffer, buffer.get(), arraysize(expected_buffer))); 203 memcmp(expected_buffer, buffer.get(), arraysize(expected_buffer)));
191 } 204 }
192 205
193 } // namespace webrtc 206 } // namespace webrtc
194 207
195 #endif // WEBRTC_VIDEO_TOOLBOX_SUPPORTED 208 #endif // WEBRTC_VIDEO_TOOLBOX_SUPPORTED
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698