OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_VP9_UNCOMPRESSED_HEADER_PARSER_H_ | |
12 #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_VP9_UNCOMPRESSED_HEADER_PARSER_H_ | |
13 | |
14 #include <stddef.h> | |
15 #include <stdint.h> | |
16 | |
17 #include "webrtc/base/bitbuffer.h" | |
18 #include "webrtc/base/logging.h" | |
19 | |
20 namespace webrtc { | |
21 | |
22 namespace vp9 { | |
23 | |
24 class VP9BitReader : public ::rtc::BitBuffer { | |
25 public: | |
26 VP9BitReader(const uint8_t* buffer, size_t length_) | |
27 : BitBuffer(buffer, length_) {} | |
28 | |
29 uint32_t GetBit() { | |
30 uint32_t bit = 0; | |
31 if (ReadBits(&bit, 1)) | |
32 return bit; | |
33 | |
34 LOG(LS_WARNING) << "Failed to get QP. Reached EOF."; | |
brandtr
2017/05/23 08:59:02
Since this is a general bit reader, maybe make the
jianj1
2017/05/23 17:37:30
Done.
| |
35 return 0; | |
36 } | |
37 | |
38 uint32_t GetValue(int bits) { | |
39 uint32_t value = 0; | |
40 if (ReadBits(&value, bits)) | |
41 return value; | |
42 | |
43 LOG(LS_WARNING) << "Failed to get QP. Reached EOF."; | |
brandtr
2017/05/23 08:59:02
And here.
jianj1
2017/05/23 17:37:30
Done.
| |
44 return 0; | |
45 } | |
46 | |
47 int32_t GetSignedValue(int bits) { | |
48 const int32_t value = static_cast<int>(GetValue(bits)); | |
49 return GetBit() ? -value : value; | |
50 } | |
51 }; | |
52 | |
53 // Gets the QP, QP range: [0, 255]. | |
54 // Returns true on success, false otherwise. | |
55 bool GetQp(const uint8_t* buf, size_t length, int *qp); | |
brandtr
2017/05/23 08:59:02
int* qp
jianj1
2017/05/23 17:37:30
Done.
| |
56 | |
57 } // namespace vp9 | |
58 | |
59 } // namespace webrtc | |
60 | |
61 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_VP9_UNCOMPRESSED_HEADER_PARSER_H_ | |
OLD | NEW |