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

Side by Side Diff: trunk/src/media/filters/h264_bitstream_buffer_unittest.cc

Issue 357903003: Revert 279958 "Revert "Revert 279650 "Add VaapiVideoEncodeAccele..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/media/filters/h264_bitstream_buffer.cc ('k') | trunk/src/media/filters/h264_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 "media/filters/h264_bitstream_buffer.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace media {
9
10 namespace {
11 const uint64 kTestPattern = 0xfedcba0987654321;
12 }
13
14 class H264BitstreamBufferAppendBitsTest
15 : public ::testing::TestWithParam<size_t> {};
16
17 // TODO(posciak): More tests!
18
19 TEST_P(H264BitstreamBufferAppendBitsTest, AppendAndVerifyBits) {
20 H264BitstreamBuffer b;
21 uint64 num_bits = GetParam();
22 // TODO(posciak): Tests for >64 bits.
23 ASSERT_LE(num_bits, 64u);
24 uint64 num_bytes = (num_bits + 7) / 8;
25
26 b.AppendBits(num_bits, kTestPattern);
27 b.FlushReg();
28
29 EXPECT_EQ(b.BytesInBuffer(), num_bytes);
30
31 uint8* ptr = b.data();
32 uint64 got = 0;
33 uint64 expected = kTestPattern;
34
35 if (num_bits < 64)
36 expected &= ((1ull << num_bits) - 1);
37
38 while (num_bits > 8) {
39 got |= (*ptr & 0xff);
40 num_bits -= 8;
41 got <<= (num_bits > 8 ? 8 : num_bits);
42 ptr++;
43 }
44 if (num_bits > 0) {
45 uint64 temp = (*ptr & 0xff);
46 temp >>= (8 - num_bits);
47 got |= temp;
48 }
49 EXPECT_EQ(got, expected) << std::hex << "0x" << got << " vs 0x" << expected;
50 }
51
52 INSTANTIATE_TEST_CASE_P(AppendNumBits,
53 H264BitstreamBufferAppendBitsTest,
54 ::testing::Range(static_cast<uint64>(1),
55 static_cast<uint64>(65)));
56 } // namespace media
OLDNEW
« no previous file with comments | « trunk/src/media/filters/h264_bitstream_buffer.cc ('k') | trunk/src/media/filters/h264_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698