kodi
BitstreamReader.h
1 /*
2  * Copyright (C) 2017-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <stdint.h>
12 
14 {
15 public:
16  CBitstreamReader(const uint8_t *buf, int len);
17  uint32_t ReadBits(int nbits);
18  void SkipBits(int nbits);
19  uint32_t GetBits(int nbits);
20  unsigned int Position() { return m_posBits; }
21  unsigned int AvailableBits() { return length * 8 - m_posBits; }
22 
23 private:
24  const uint8_t *buffer, *start;
25  int offbits = 0, length, oflow = 0;
26  int m_posBits{0};
27 };
28 
29 const uint8_t* find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
30 
34 
35 /*
36  * AVC helper functions for muxers
37  * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@smartjog.com>
38  * This is part of FFmpeg
39  *
40  * SPDX-License-Identifier: LGPL-2.1-or-later
41  * See LICENSES/README.md for more information.
42  */
43 constexpr uint32_t BS_RB24(const uint8_t* x)
44 {
45  return (x[0] << 16) | (x[1] << 8) | x[2];
46 }
47 
48 constexpr uint32_t BS_RB32(const uint8_t* x)
49 {
50  return (x[1] << 24) | (x[1] << 16) | (x[2] << 8) | x[3];
51 }
52 
Definition: BitstreamReader.h:13