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 | |
11 #include "webrtc/base/checks.h" | |
12 #include "webrtc/base/logging.h" | |
pbos-webrtc
2016/04/18 15:10:14
These should go below where they were, vp8_header_
jackychen_
2016/04/18 19:18:17
Done.
| |
10 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" | 13 #include "webrtc/modules/video_coding/utility/vp8_header_parser.h" |
11 | 14 |
12 #include "webrtc/base/logging.h" | |
13 | |
14 namespace webrtc { | 15 namespace webrtc { |
15 | 16 |
16 namespace vp8 { | 17 namespace vp8 { |
17 namespace { | 18 namespace { |
18 const size_t kCommonPayloadHeaderLength = 3; | 19 const size_t kCommonPayloadHeaderLength = 3; |
19 const size_t kKeyPayloadHeaderLength = 10; | 20 const size_t kKeyPayloadHeaderLength = 10; |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 static uint32_t BSwap32(uint32_t x) { | 23 static uint32_t BSwap32(uint32_t x) { |
23 return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24); | 24 return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 br->eof_ = 0; | 69 br->eof_ = 0; |
69 VP8LoadNewBytes(br); | 70 VP8LoadNewBytes(br); |
70 } | 71 } |
71 | 72 |
72 // Read a bit with proba 'prob'. | 73 // Read a bit with proba 'prob'. |
73 static int VP8GetBit(VP8BitReader* const br, int prob) { | 74 static int VP8GetBit(VP8BitReader* const br, int prob) { |
74 uint8_t range = br->range_; | 75 uint8_t range = br->range_; |
75 if (br->bits_ < 0) { | 76 if (br->bits_ < 0) { |
76 VP8LoadNewBytes(br); | 77 VP8LoadNewBytes(br); |
77 } | 78 } |
78 | 79 RTC_CHECK_GE(br->bits_, 0); |
pbos-webrtc
2016/04/18 15:10:14
You can't use this for network data. We cannot cra
jackychen_
2016/04/18 19:18:17
When VP8GetBit read invalid bitstream, it should p
| |
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 |