OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 5 |
6 /* | 6 /* |
7 * Copyright (c) 2010, The WebM Project authors. All rights reserved. | 7 * Copyright (c) 2010, The WebM Project authors. All rights reserved. |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions are | 10 * modification, are permitted provided that the following conditions are |
(...skipping 22 matching lines...) Expand all Loading... |
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
37 */ | 37 */ |
38 | 38 |
39 // This file is modified from the dboolhuff.{c,h} from the WebM's libvpx | 39 // This file is modified from the dboolhuff.{c,h} from the WebM's libvpx |
40 // project. (http://www.webmproject.org/code) | 40 // project. (http://www.webmproject.org/code) |
41 // It is used to decode bits from a vp8 stream. | 41 // It is used to decode bits from a vp8 stream. |
42 | 42 |
| 43 #include <limits.h> |
| 44 |
43 #include <algorithm> | 45 #include <algorithm> |
44 | 46 |
45 #include "base/numerics/safe_conversions.h" | 47 #include "base/numerics/safe_conversions.h" |
46 #include "media/filters/vp8_bool_decoder.h" | 48 #include "media/filters/vp8_bool_decoder.h" |
47 | 49 |
48 namespace media { | 50 namespace media { |
49 | 51 |
50 #define VP8_BD_VALUE_BIT \ | 52 #define VP8_BD_VALUE_BIT \ |
51 static_cast<int>(sizeof(Vp8BoolDecoder::value_) * CHAR_BIT) | 53 static_cast<int>(sizeof(Vp8BoolDecoder::value_) * CHAR_BIT) |
52 | 54 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // occupied, 8 for the algorithm and 8 in the buffer. | 199 // occupied, 8 for the algorithm and 8 in the buffer. |
198 // | 200 // |
199 // When reading a byte from the user's buffer, |count_| is filled with 8 and | 201 // When reading a byte from the user's buffer, |count_| is filled with 8 and |
200 // one byte is filled into the |value_| buffer. When we reach the end of the | 202 // one byte is filled into the |value_| buffer. When we reach the end of the |
201 // data, |count_| is additionally filled with VP8_LOTS_OF_BITS. So when | 203 // data, |count_| is additionally filled with VP8_LOTS_OF_BITS. So when |
202 // |count_| == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted. | 204 // |count_| == VP8_LOTS_OF_BITS - 1, the user's data has been exhausted. |
203 return (count_ > VP8_BD_VALUE_BIT) && (count_ < VP8_LOTS_OF_BITS); | 205 return (count_ > VP8_BD_VALUE_BIT) && (count_ < VP8_LOTS_OF_BITS); |
204 } | 206 } |
205 | 207 |
206 } // namespace media | 208 } // namespace media |
OLD | NEW |