diff options
author | xiaomings@google.com <xiaomings@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 19:43:45 +0000 |
---|---|---|
committer | xiaomings@google.com <xiaomings@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-19 19:43:45 +0000 |
commit | 279a07fae05681f3d40f1466e3c4aa8e3e67028b (patch) | |
tree | 1081535465632787800ab0fd933e69dd88f2c051 /media/base/bit_reader_unittest.cc | |
parent | 968ff687d1cd2608cfbe8af26b8f352587074f40 (diff) | |
download | chromium_src-279a07fae05681f3d40f1466e3c4aa8e3e67028b.zip chromium_src-279a07fae05681f3d40f1466e3c4aa8e3e67028b.tar.gz chromium_src-279a07fae05681f3d40f1466e3c4aa8e3e67028b.tar.bz2 |
Add HE AAC support to ISO BMFF.
Was https://chromiumcodereview.appspot.com/10753005/.
The original cl also includes abstraction of BitReader class used by H264Parser. It includes bugs that break the H264Parser.
In this cl I removed the abstraction and make the BitReader used by H264Parser independent to the one used by esds parser because of:
1. The original cl introduce bugs.
2. Even if we fix the bugs, we may not be able to make the generalized class as fast as the old one while keeping the abstraction.
3. The H264 bit stream use very special syntax on escaping and trailing zero bits, which might not be a good candidate for abstraction.
BUG=134445
TEST=BitReaderTest, AACTest
Review URL: https://chromiumcodereview.appspot.com/10780026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/bit_reader_unittest.cc')
-rw-r--r-- | media/base/bit_reader_unittest.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/media/base/bit_reader_unittest.cc b/media/base/bit_reader_unittest.cc new file mode 100644 index 0000000..48e8c5e --- /dev/null +++ b/media/base/bit_reader_unittest.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/bit_reader.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace media { + +TEST(BitReaderTest, NormalOperationTest) { + uint8 value8; + uint64 value64; + // 0101 0101 1001 1001 repeats 4 times + uint8 buffer[] = {0x55, 0x99, 0x55, 0x99, 0x55, 0x99, 0x55, 0x99}; + BitReader reader1(buffer, 6); // Initialize with 6 bytes only + + EXPECT_TRUE(reader1.ReadBits(1, &value8)); + EXPECT_EQ(value8, 0); + EXPECT_TRUE(reader1.ReadBits(8, &value8)); + EXPECT_EQ(value8, 0xab); // 1010 1011 + EXPECT_TRUE(reader1.ReadBits(7, &value64)); + EXPECT_TRUE(reader1.ReadBits(32, &value64)); + EXPECT_EQ(value64, 0x55995599u); + EXPECT_FALSE(reader1.ReadBits(1, &value8)); + value8 = 0xff; + EXPECT_TRUE(reader1.ReadBits(0, &value8)); + EXPECT_EQ(value8, 0); + + BitReader reader2(buffer, 8); + EXPECT_TRUE(reader2.ReadBits(64, &value64)); + EXPECT_EQ(value64, 0x5599559955995599ull); + EXPECT_FALSE(reader2.ReadBits(1, &value8)); + EXPECT_TRUE(reader2.ReadBits(0, &value8)); +} + +TEST(BitReaderTest, ReadBeyondEndTest) { + uint8 value8; + uint8 buffer[] = {0x12}; + BitReader reader1(buffer, sizeof(buffer)); + + EXPECT_TRUE(reader1.ReadBits(4, &value8)); + EXPECT_FALSE(reader1.ReadBits(5, &value8)); + EXPECT_FALSE(reader1.ReadBits(1, &value8)); + EXPECT_TRUE(reader1.ReadBits(0, &value8)); +} + +} // namespace media |