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

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: 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 "base/basictypes.h"
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 Group w/ other base includes
strobe_ 2012/06/07 16:33:54 Done.
6
7 #include "string.h"
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 Use <> & place before all other includes.
strobe_ 2012/06/07 16:33:54 Done.
8 #include "base/logging.h"
9 #include "media/mp4/avc.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using media::mp4::ConvertAVCCToAnnexB;
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 Remove and put tests in media::mp4 namespace
strobe_ 2012/06/07 22:04:22 Done.
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> {
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 Use int here and various other places below.
strobe_ 2012/06/07 22:04:22 Done.
21 protected:
22 void MakeInputForLength(uint32 length_size, std::vector<uint8>* buf) {
23 buf->clear();
24 for (uint32 i = 1; i < length_size; i++) {
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 nit: remove {}
strobe_ 2012/06/07 22:04:22 Done.
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++) {
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 nit: remove {}
strobe_ 2012/06/07 22:04:22 Done.
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.
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 I'm not sure what this comment is trying to tell m
strobe_ 2012/06/07 22:04:22 Done.
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

Powered by Google App Engine
This is Rietveld 408576698