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

Side by Side Diff: media/base/bit_reader_core.cc

Issue 1754523004: media: Add fuzzer test for bit_reader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use TestRandom Created 4 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/bit_reader_core.h" 5 #include "media/base/bit_reader_core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 reg_next_ = 0; 79 reg_next_ = 0;
80 80
81 // Next, skip an integer number of bytes. 81 // Next, skip an integer number of bytes.
82 const int nbytes = num_bits / 8; 82 const int nbytes = num_bits / 8;
83 if (nbytes > 0) { 83 if (nbytes > 0) {
84 const uint8_t* byte_stream_window; 84 const uint8_t* byte_stream_window;
85 const int window_size = 85 const int window_size =
86 byte_stream_provider_->GetBytes(nbytes, &byte_stream_window); 86 byte_stream_provider_->GetBytes(nbytes, &byte_stream_window);
87 DCHECK_GE(window_size, 0); 87 DCHECK_GE(window_size, 0);
88 DCHECK_LE(window_size, nbytes); 88 DCHECK_LE(window_size, nbytes);
89 if (window_size < nbytes) 89 if (window_size < nbytes) {
90 // Note that some bytes were consumed.
91 bits_read_ += 8 * window_size;
90 return false; 92 return false;
93 }
91 num_bits -= 8 * nbytes; 94 num_bits -= 8 * nbytes;
92 bits_read_ += 8 * nbytes; 95 bits_read_ += 8 * nbytes;
93 } 96 }
94 97
95 // Skip the remaining bits. 98 // Skip the remaining bits.
96 return SkipBitsSmall(num_bits); 99 return SkipBitsSmall(num_bits);
97 } 100 }
98 101
99 int BitReaderCore::bits_read() const { 102 int BitReaderCore::bits_read() const {
100 return bits_read_; 103 return bits_read_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 nbits_next_ = 0; 184 nbits_next_ = 0;
182 return; 185 return;
183 } 186 }
184 187
185 nbits_ += free_nbits; 188 nbits_ += free_nbits;
186 reg_next_ <<= free_nbits; 189 reg_next_ <<= free_nbits;
187 nbits_next_ -= free_nbits; 190 nbits_next_ -= free_nbits;
188 } 191 }
189 192
190 } // namespace media 193 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698