ADPCM Codecs
Loading...
Searching...
No Matches
src
adpcm
ByteWriter.h
1
/*
2
* ByteWriter (byte stream writer)
3
* Adapted from the FFmpeg bytestream functions:
4
* copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
5
* Copyright (c) 2012 Aneesh Dogra (lionaneesh) <lionaneesh@gmail.com>
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*/
12
13
#pragma once
14
15
#include <stdint.h>
16
17
#include "config-adpcm.h"
18
19
namespace
adpcm_ffmpeg {
20
26
class
ByteWriter
{
27
public
:
28
explicit
ByteWriter
(
uint8_t
*&
position
) : pos_(
position
) {}
29
30
void
putByte(
uint32_t
v
) {
put<1, false>
(
v
); }
31
void
putLe16(
uint32_t
v
) {
put<2, false>
(
v
); }
32
void
putLe32(
uint32_t
v
) {
put<4, false>
(
v
); }
33
34
private
:
35
uint8_t
*&pos_;
36
37
template
<
int
N,
bool
BigEndian>
38
void
put(
uint32_t
v
) {
39
for
(
int
i = 0; i <
N
; i++) {
40
const
int
shift =
BigEndian
? 8 * (
N
- 1 - i) : 8 * i;
41
pos_[i] = (
uint8_t
)(
v
>> shift);
42
}
43
pos_ +=
N
;
44
}
45
};
46
47
}
// namespace adpcm_ffmpeg
adpcm_ffmpeg::ADPCMVector
Vector implementation which provides the most important methods as defined by std::vector....
Definition
ADPCMVector.h:16
adpcm_ffmpeg::ByteWriter
Writer for a memory buffer. The writer advances the caller's pointer, so it can be combined with dire...
Definition
ByteWriter.h:26
Generated by
1.9.8