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 "media/base/bit_reader.h" 6 7 namespace media { 8 BitReader(const uint8 * data,int size)9BitReader::BitReader(const uint8* data, int size) 10 : initial_size_(size), 11 data_(data), 12 bytes_left_(size), 13 bit_reader_core_(this) { 14 DCHECK(data != NULL); 15 DCHECK_GE(size, 0); 16 } 17 ~BitReader()18BitReader::~BitReader() {} 19 GetBytes(int max_nbytes,const uint8 ** out)20int BitReader::GetBytes(int max_nbytes, const uint8** out) { 21 DCHECK_GE(max_nbytes, 0); 22 DCHECK(out); 23 24 int nbytes = max_nbytes; 25 if (nbytes > bytes_left_) 26 nbytes = bytes_left_; 27 28 *out = data_; 29 data_ += nbytes; 30 bytes_left_ -= nbytes; 31 return nbytes; 32 } 33 34 } // namespace media 35