OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" | 10 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 br->bits_ = -8; // To load the very first 8bits. | 67 br->bits_ = -8; // To load the very first 8bits. |
68 br->eof_ = 0; | 68 br->eof_ = 0; |
69 VP8LoadNewBytes(br); | 69 VP8LoadNewBytes(br); |
70 } | 70 } |
71 | 71 |
72 // Read a bit with proba 'prob'. | 72 // Read a bit with proba 'prob'. |
73 static int VP8GetBit(VP8BitReader* const br, int prob) { | 73 static int VP8GetBit(VP8BitReader* const br, int prob) { |
74 uint8_t range = br->range_; | 74 uint8_t range = br->range_; |
75 if (br->bits_ < 0) { | 75 if (br->bits_ < 0) { |
76 VP8LoadNewBytes(br); | 76 VP8LoadNewBytes(br); |
| 77 if (br->eof_) |
| 78 return 0; |
77 } | 79 } |
78 | |
79 const int pos = br->bits_; | 80 const int pos = br->bits_; |
80 const uint8_t split = (range * prob) >> 8; | 81 const uint8_t split = (range * prob) >> 8; |
81 const uint8_t value = static_cast<uint8_t>(br->value_ >> pos); | 82 const uint8_t value = static_cast<uint8_t>(br->value_ >> pos); |
82 int bit; | 83 int bit; |
83 if (value > split) { | 84 if (value > split) { |
84 range -= split + 1; | 85 range -= split + 1; |
85 br->value_ -= static_cast<uint32_t>(split + 1) << pos; | 86 br->value_ -= static_cast<uint32_t>(split + 1) << pos; |
86 bit = 1; | 87 bit = 1; |
87 } else { | 88 } else { |
88 range = split; | 89 range = split; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 LOG(LS_WARNING) << "Failed to get QP, end of file reached."; | 196 LOG(LS_WARNING) << "Failed to get QP, end of file reached."; |
196 return false; | 197 return false; |
197 } | 198 } |
198 *qp = base_q0; | 199 *qp = base_q0; |
199 return true; | 200 return true; |
200 } | 201 } |
201 | 202 |
202 } // namespace vp8 | 203 } // namespace vp8 |
203 | 204 |
204 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |