1 /*
2  *  Copyright (c) 2015 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 MODULES_VIDEO_CODING_UTILITY_VP8_HEADER_PARSER_H_
12 #define MODULES_VIDEO_CODING_UTILITY_VP8_HEADER_PARSER_H_
13 
14 #include <stdint.h>
15 #include <stdio.h>
16 
17 namespace webrtc {
18 
19 namespace vp8 {
20 
21 typedef struct VP8BitReader VP8BitReader;
22 struct VP8BitReader {
23   // Boolean decoder.
24   uint32_t value_;  // Current value (2 bytes).
25   uint32_t range_;  // Current range (always in [128..255] interval).
26   int bits_;        // Number of bits shifted out of value, at most 7.
27   // Read buffer.
28   const uint8_t* buf_;      // Next byte to be read.
29   const uint8_t* buf_end_;  // End of read buffer.
30 };
31 
32 // Gets the QP, QP range: [0, 127].
33 // Returns true on success, false otherwise.
34 bool GetQp(const uint8_t* buf, size_t length, int* qp);
35 
36 }  // namespace vp8
37 
38 }  // namespace webrtc
39 
40 #endif  // MODULES_VIDEO_CODING_UTILITY_VP8_HEADER_PARSER_H_
41