diff options
Diffstat (limited to 'xbmc/utils/BitstreamReader.h')
| -rw-r--r-- | xbmc/utils/BitstreamReader.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/xbmc/utils/BitstreamReader.h b/xbmc/utils/BitstreamReader.h new file mode 100644 index 0000000..89fa2b2 --- /dev/null +++ b/xbmc/utils/BitstreamReader.h | |||
| @@ -0,0 +1,49 @@ | |||
| 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 | |||
| 13 | class CBitstreamReader | ||
| 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 | |||
| 21 | private: | ||
| 22 | const uint8_t *buffer, *start; | ||
| 23 | int offbits, length, oflow; | ||
| 24 | }; | ||
| 25 | |||
| 26 | const uint8_t* find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); | ||
| 27 | |||
| 28 | //////////////////////////////////////////////////////////////////////////////////////////// | ||
| 29 | //! @todo refactor this so as not to need these ffmpeg routines. | ||
| 30 | //! These are not exposed in ffmpeg's API so we dupe them here. | ||
| 31 | |||
| 32 | /* | ||
| 33 | * AVC helper functions for muxers | ||
| 34 | * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@smartjog.com> | ||
| 35 | * This is part of FFmpeg | ||
| 36 | * | ||
| 37 | * SPDX-License-Identifier: LGPL-2.1-or-later | ||
| 38 | * See LICENSES/README.md for more information. | ||
| 39 | */ | ||
| 40 | constexpr uint32_t BS_RB24(const uint8_t* x) | ||
| 41 | { | ||
| 42 | return (x[0] << 16) | (x[1] << 8) | x[2]; | ||
| 43 | } | ||
| 44 | |||
| 45 | constexpr uint32_t BS_RB32(const uint8_t* x) | ||
| 46 | { | ||
| 47 | return (x[1] << 24) | (x[1] << 16) | (x[2] << 8) | x[3]; | ||
| 48 | } | ||
| 49 | |||
