21 #include <vorbis/vorbisenc.h>
38 #define OGGVORBIS_FRAME_SIZE 64
40 #define BUFFER_SIZE (1024 * 64)
78 case OV_EINVAL:
return AVERROR(EINVAL);
79 case OV_EIMPL:
return AVERROR(EINVAL);
100 if ((ret = vorbis_encode_setup_vbr(vi, avctx->
channels,
109 if ((ret = vorbis_encode_setup_managed(vi, avctx->
channels,
115 if (minrate == -1 && maxrate == -1)
116 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE2_SET,
NULL)))
122 cfreq = avctx->
cutoff / 1000.0;
123 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq)))
129 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &s->
iblock)))
153 "output stream will have incorrect "
154 "channel layout.\n", name);
157 "will use Vorbis channel layout for "
162 if ((ret = vorbis_encode_setup_init(vi)))
173 return 1 + l / 255 + l;
182 vorbis_analysis_wrote(&s->
vd, 0);
184 vorbis_block_clear(&s->
vb);
185 vorbis_dsp_clear(&s->
vd);
186 vorbis_info_clear(&s->
vi);
190 #if FF_API_OLD_ENCODE_AUDIO
206 vorbis_info_init(&s->
vi);
211 if ((ret = vorbis_analysis_init(&s->
vd, &s->
vi))) {
217 if ((ret = vorbis_block_init(&s->
vd, &s->
vb))) {
223 vorbis_comment_init(&s->
vc);
227 if ((ret = vorbis_analysis_headerout(&s->
vd, &s->
vc, &header, &header_comm,
246 memcpy(&p[offset], header.packet, header.bytes);
247 offset += header.bytes;
248 memcpy(&p[offset], header_comm.packet, header_comm.bytes);
249 offset += header_comm.bytes;
250 memcpy(&p[offset], header_code.packet, header_code.bytes);
251 offset += header_code.bytes;
259 vorbis_comment_clear(&s->
vc);
270 #if FF_API_OLD_ENCODE_AUDIO
295 int c, channels = s->
vi.channels;
297 buffer = vorbis_analysis_buffer(&s->
vd, samples);
298 for (c = 0; c < channels; c++) {
299 int co = (channels > 8) ? c :
302 samples *
sizeof(*buffer[c]));
304 if ((ret = vorbis_analysis_wrote(&s->
vd, samples)) < 0) {
312 if ((ret = vorbis_analysis_wrote(&s->
vd, 0)) < 0) {
320 while ((ret = vorbis_analysis_blockout(&s->
vd, &s->
vb)) == 1) {
321 if ((ret = vorbis_analysis(&s->
vb,
NULL)) < 0)
323 if ((ret = vorbis_bitrate_addblock(&s->
vb)) < 0)
327 while ((ret = vorbis_bitrate_flushpacket(&s->
vd, &op)) == 1) {
387 .priv_class = &
class,