OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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/mpeg2/mpeg2ts_crc.h" | |
6 | |
7 namespace media { | |
8 namespace mpeg2ts { | |
9 | |
10 Mpeg2TsCrc::Mpeg2TsCrc() | |
11 : crc_(0xffffffffu) { | |
12 } | |
13 | |
14 void Mpeg2TsCrc::Update(uint32 data, int nbits) { | |
15 const uint32_t kCrcPoly = 0x4c11db7; | |
acolwell GONE FROM CHROMIUM
2013/09/05 18:29:10
DCHECK_GT(nbits, 0);
DCHECK_LE(nbits, 32);
damienv1
2013/09/09 23:29:45
Function signature changed: now always receive 8 b
| |
16 | |
17 // Align the bits to the MSB. | |
18 data = data << (32 - nbits); | |
19 | |
20 while (nbits > 0) { | |
21 if ((data ^ crc_) & 0x80000000) { | |
22 crc_ <<= 1; | |
23 crc_ ^= kCrcPoly; | |
24 } else { | |
25 crc_ <<= 1; | |
26 } | |
27 | |
28 data <<= 1; | |
29 nbits--; | |
30 } | |
31 } | |
32 | |
33 bool Mpeg2TsCrc::IsValid() { | |
34 return (crc_ == 0); | |
35 } | |
36 | |
37 } // namespace mpeg2ts | |
38 } // namespace media | |
39 | |
OLD | NEW |