kodi
BitstreamWriter.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  CBitstreamWriter(uint8_t *buffer, unsigned int buffer_size, int writer_le);
17  void WriteBits(int n, unsigned int value);
18  void SkipBits(int n);
19  void FlushBits();
20 
21 private:
22  int writer_le;
23  uint32_t bit_buf = 0;
24  int bit_left = 32;
25  uint8_t *buf, *buf_ptr;
26 };
27 
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 #define BS_WB32(p, d) { \
41  ((uint8_t*)(p))[3] = (d); \
42  ((uint8_t*)(p))[2] = (d) >> 8; \
43  ((uint8_t*)(p))[1] = (d) >> 16; \
44  ((uint8_t*)(p))[0] = (d) >> 24; }
45 
46 #define BS_WL32(p, d) { \
47  ((uint8_t*)(p))[0] = (d); \
48  ((uint8_t*)(p))[1] = (d) >> 8; \
49  ((uint8_t*)(p))[2] = (d) >> 16; \
50  ((uint8_t*)(p))[3] = (d) >> 24; }
Definition: BitstreamWriter.h:13