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

Side by Side Diff: media/mp4/avc_unittest.cc

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Code review changes; add offset_byte_queue_unittest.cc Created 8 years, 6 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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string.h>
6
7 #include "base/basictypes.h"
8 #include "media/mp4/avc.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/gtest/include/gtest/gtest-param-test.h"
11
12 using media::mp4::ConvertAVCCToAnnexB;
13
14 const static uint8 kNALU1[] = { 0x01, 0x02, 0x03 };
15 const static uint8 kNALU2[] = { 0x04, 0x05, 0x06, 0x07 };
16 const static uint8 kExpected[] = {
17 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03,
18 0x00, 0x00, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07 };
19
20 class AVCCConversionTest : public testing::TestWithParam<uint32> {
21 protected:
22 void MakeInputForLength(uint32 length_size, std::vector<uint8>* buf) {
23 buf->clear();
24 for (uint32 i = 1; i < length_size; i++) {
25 buf->push_back(0);
26 }
27 buf->push_back(sizeof(kNALU1));
28 buf->insert(buf->end(), kNALU1, kNALU1 + sizeof(kNALU1));
29
30 for (uint32 i = 1; i < length_size; i++) {
31 buf->push_back(0);
32 }
33 buf->push_back(sizeof(kNALU2));
34 buf->insert(buf->end(), kNALU2, kNALU2 + sizeof(kNALU2));
35 }
36 };
37
38 TEST_P(AVCCConversionTest, ParseCorrectly) {
39 std::vector<uint8> buf;
40 MakeInputForLength(GetParam(), &buf);
41 EXPECT_TRUE(ConvertAVCCToAnnexB(GetParam(), &buf));
42 ASSERT_EQ(buf.size(), sizeof(kExpected));
43 ASSERT_EQ(0, memcmp(kExpected, &buf[0], sizeof(kExpected)));
44 }
45
46 TEST_P(AVCCConversionTest, ParsePartial) {
47 std::vector<uint8> buf;
48 MakeInputForLength(GetParam(), &buf);
49 buf.pop_back();
50 EXPECT_FALSE(ConvertAVCCToAnnexB(GetParam(), &buf));
51 // This actually still works for one-byte sizes.
52 if (GetParam() != 1) {
53 MakeInputForLength(GetParam(), &buf);
54 buf.erase(buf.end() - (sizeof(kNALU2) + 1), buf.end());
55 EXPECT_FALSE(ConvertAVCCToAnnexB(GetParam(), &buf));
56 }
57 }
58
59 TEST_P(AVCCConversionTest, ParseEmpty) {
60 std::vector<uint8> buf;
61 EXPECT_TRUE(ConvertAVCCToAnnexB(GetParam(), &buf));
62 EXPECT_EQ(0u, buf.size());
63 }
64
65 INSTANTIATE_TEST_CASE_P(AVCCConversionTestValues,
66 AVCCConversionTest,
67 ::testing::Values(1, 2, 4));
OLDNEW
« no previous file with comments | « media/mp4/avc.cc ('k') | media/mp4/box_definitions.h » ('j') | media/mp4/box_reader_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698