27 #include <vorbis/vorbisenc.h>
46 #define OGGVORBIS_FRAME_SIZE 64
48 #define BUFFER_SIZE (1024 * 64)
82 case OV_EINVAL:
return AVERROR(EINVAL);
83 case OV_EIMPL:
return AVERROR(EINVAL);
104 if ((ret = vorbis_encode_setup_vbr(vi, avctx->
channels,
113 if ((ret = vorbis_encode_setup_managed(vi, avctx->
channels,
119 if (minrate == -1 && maxrate == -1)
120 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE2_SET,
NULL)))
126 cfreq = avctx->
cutoff / 1000.0;
127 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq)))
133 if ((ret = vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &s->
iblock)))
137 if ((ret = vorbis_encode_setup_init(vi)))
148 return 1 + l / 255 + l;
157 vorbis_analysis_wrote(&s->
vd, 0);
159 vorbis_block_clear(&s->
vb);
160 vorbis_dsp_clear(&s->
vd);
161 vorbis_info_clear(&s->
vi);
165 #if FF_API_OLD_ENCODE_AUDIO
181 vorbis_info_init(&s->
vi);
186 if ((ret = vorbis_analysis_init(&s->
vd, &s->
vi))) {
192 if ((ret = vorbis_block_init(&s->
vd, &s->
vb))) {
198 vorbis_comment_init(&s->
vc);
201 if ((ret = vorbis_analysis_headerout(&s->
vd, &s->
vc, &header, &header_comm,
220 memcpy(&p[offset], header.packet, header.bytes);
221 offset += header.bytes;
222 memcpy(&p[offset], header_comm.packet, header_comm.bytes);
223 offset += header_comm.bytes;
224 memcpy(&p[offset], header_code.packet, header_code.bytes);
225 offset += header_code.bytes;
233 vorbis_comment_clear(&s->
vc);
244 #if FF_API_OLD_ENCODE_AUDIO
259 const AVFrame *frame,
int *got_packet_ptr)
269 int c, channels = s->
vi.channels;
271 buffer = vorbis_analysis_buffer(&s->
vd, samples);
272 for (c = 0; c < channels; c++) {
273 int co = (channels > 8) ? c :
276 samples *
sizeof(*buffer[c]));
278 if ((ret = vorbis_analysis_wrote(&s->
vd, samples)) < 0) {
286 if ((ret = vorbis_analysis_wrote(&s->
vd, 0)) < 0) {
294 while ((ret = vorbis_analysis_blockout(&s->
vd, &s->
vb)) == 1) {
295 if ((ret = vorbis_analysis(&s->
vb,
NULL)) < 0)
297 if ((ret = vorbis_bitrate_addblock(&s->
vb)) < 0)
301 while ((ret = vorbis_bitrate_flushpacket(&s->
vd, &op)) == 1) {
361 .priv_class = &
class,