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

Side by Side Diff: media/mpeg2/mpeg2ts_crc.cc

Issue 23566013: Mpeg2 TS stream parser for media source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from patch set #3 Created 7 years, 3 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) 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 #include "base/logging.h"
damienv1 2013/09/10 15:28:25 Not needed anymore, to be removed.
damienv1 2013/09/10 21:03:48 Done.
8
9 namespace media {
10 namespace mpeg2ts {
11
12 Mpeg2TsCrc::Mpeg2TsCrc()
13 : crc_(0xffffffffu) {
14 }
15
16 void Mpeg2TsCrc::Update(uint8 data) {
17 const uint32_t kCrcPoly = 0x4c11db7;
18
19 // Align the bits to the MSB.
20 int nbits = 8;
21 uint32 data_msb_aligned = data;
22 data_msb_aligned <<= (32 - nbits);
23
24 while (nbits > 0) {
25 if ((data_msb_aligned ^ crc_) & 0x80000000) {
26 crc_ <<= 1;
27 crc_ ^= kCrcPoly;
28 } else {
29 crc_ <<= 1;
30 }
31
32 data_msb_aligned <<= 1;
33 nbits--;
34 }
35 }
36
37 bool Mpeg2TsCrc::IsValid() {
38 return (crc_ == 0);
39 }
40
41 } // namespace mpeg2ts
42 } // namespace media
43
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698