22#include <vorbis/vorbisenc.h>
43 int i, hsizes[3], ret;
44 unsigned char *headers[3], *extradata = avccontext->
extradata;
51 vorbis_info_init(&context->
vi) ;
52 vorbis_comment_init(&context->
vc) ;
54 if(p[0] == 0 && p[1] == 30) {
56 for(
i = 0;
i < 3;
i++){
57 hsizes[
i] = bytestream_get_be16((
const uint8_t **)&p);
58 sizesum += 2 + hsizes[
i];
70 unsigned int sizesum = 1;
74 while((*p == 0xFF) && (sizesum < avccontext->extradata_size)) {
85 "vorbis header sizes damaged\n");
94 "vorbis header sizes: %d, %d, %d, / extradata_len is %d \n",
97 headers[0] = extradata +
offset;
98 headers[1] = extradata +
offset + hsizes[0];
99 headers[2] = extradata +
offset + hsizes[0] + hsizes[1];
102 "vorbis initial header len is wrong: %d\n", *p);
108 context->
op.b_o_s=
i==0;
109 context->
op.bytes = hsizes[
i];
110 context->
op.packet = headers[
i];
111 if(vorbis_synthesis_headerin(&context->
vi, &context->
vc, &context->
op)<0){
118 if (context->
vi.rate <= 0 || context->
vi.rate > INT_MAX) {
131 vorbis_synthesis_init(&context->
vd, &context->
vi);
132 vorbis_block_init(&context->
vd, &context->
vb);
143 int *got_frame_ptr,
AVPacket *avpkt)
148 int samples, total_samples;
156 frame->nb_samples = 8192*4;
169 if(vorbis_synthesis(&context->
vb,
op) == 0)
170 vorbis_synthesis_blockin(&context->
vd, &context->
vb) ;
174 while((samples = vorbis_synthesis_pcmout(&context->
vd, &pcm)) > 0) {
175 for (
int ch = 0; ch < context->
vi.channels; ch++)
176 memcpy((
float *)
frame->extended_data[ch] + total_samples, pcm[ch], samples *
sizeof(
float));
177 total_samples += samples ;
178 vorbis_synthesis_read(&context->
vd, samples) ;
181 frame->nb_samples = total_samples;
182 *got_frame_ptr = total_samples > 0;
191 vorbis_block_clear(&context->
vb);
192 vorbis_dsp_clear(&context->
vd);
193 vorbis_info_clear(&context->
vi) ;
194 vorbis_comment_clear(&context->
vc) ;
201 .p.name =
"libvorbis",
const FFCodec ff_libvorbis_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_FLTP
float, planar
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
static int oggvorbis_decode_frame(AVCodecContext *avccontext, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static int oggvorbis_decode_close(AVCodecContext *avccontext)
static av_cold int oggvorbis_decode_init(AVCodecContext *avccontext)
static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize, int64_t *fpos)
find the next Ogg packet
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Rational number (pair of numerator and denominator).
vorbis_block vb
vorbis_block used for analysis
vorbis_comment vc
VorbisComment info.
vorbis_info vi
vorbis_info used during init
vorbis_dsp_state vd
DSP state used for analysis.
static void error(const char *err)