Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/BitWriter.h
Line
Count
Source (jump to first uncovered line)
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef BIT_WRITER_H_
6
#define BIT_WRITER_H_
7
8
#include "mozilla/RefPtr.h"
9
10
namespace mozilla
11
{
12
13
class MediaByteBuffer;
14
15
class BitWriter
16
{
17
public:
18
  explicit BitWriter(MediaByteBuffer* aBuffer);
19
  virtual ~BitWriter();
20
  void WriteBits(uint64_t aValue, size_t aBits);
21
0
  void WriteBit(bool aValue) { WriteBits(aValue, 1); }
22
  void WriteU8(uint8_t aValue) { WriteBits(aValue, 8); }
23
0
  void WriteU32(uint32_t aValue) { WriteBits(aValue, 32); }
24
0
  void WriteU64(uint64_t aValue) { WriteBits(aValue, 64); }
25
26
  // Write unsigned integer into Exp-Golomb-coded. 2^32-2 at most
27
  void WriteUE(uint32_t aValue);
28
29
  // Write RBSP trailing bits.
30
  void CloseWithRbspTrailing();
31
32
  // Return the number of bits written so far;
33
0
  size_t BitCount() const { return mPosition * 8 + mBitIndex; }
34
35
private:
36
  RefPtr<MediaByteBuffer> mBuffer;
37
  size_t mPosition = 0;
38
  uint8_t mBitIndex = 0;
39
};
40
41
} // namespace mozilla
42
43
#endif // BIT_WRITER_H_