blob: 4cbfc9c6aef32ff98223038a533a68c97fb9fd7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include "lame_encoder.h"
#include <stdexcept>
EncoderLame::EncoderLame() {
gfp = lame_init();
int error = lame_init_params(gfp);
if(error < 0) {
throw std::runtime_error("failed to initialize LAME");
}
}
EncoderLame::~EncoderLame() {
lame_close(gfp);
}
size_t EncoderLame::encode(uint8_t *input, size_t input_size, uint8_t *output, size_t output_size) {
size_t size = lame_encode_buffer_interleaved(gfp, (short*)input, input_size / 4, output, output_size);
return size;
}
size_t EncoderLame::flush(uint8_t *output, size_t output_size) {
size_t size = lame_encode_flush(gfp, output, output_size);
return size;
}
|