Merge pull request #26166 from ksooo/improve-plugin-ctx-menus
[xbmc.git] / xbmc / utils / BitstreamReader.h
blob1a3232992d0a9cfb39bb4ffd94da80f89c8dc61d
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <stdint.h>
13 class CBitstreamReader
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; }
23 private:
24 const uint8_t *buffer, *start;
25 int offbits = 0, length, oflow = 0;
26 int m_posBits{0};
29 const uint8_t* find_start_code(const uint8_t* p, const uint8_t* end, uint32_t* state);