1 /*
2 * Copyright (c) 2002 Mark Hills <mark@pogo.org.uk>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <vorbis/vorbisenc.h>
22
26
28 vorbis_info
vi;
/**< vorbis_info used during init */
29 vorbis_dsp_state
vd;
/**< DSP state used for analysis */
30 vorbis_block
vb;
/**< vorbis_block used for analysis */
31 vorbis_comment
vc;
/**< VorbisComment info */
34
36
40 int i, hsizes[3],
ret;
42
46 }
47
48 vorbis_info_init(&
context->vi) ;
49 vorbis_comment_init(&
context->vc) ;
50
51 if(p[0] == 0 && p[1] == 30) {
52 int sizesum = 0;
53 for(
i = 0;
i < 3;
i++){
54 hsizes[
i] = bytestream_get_be16((
const uint8_t **)&p);
55 sizesum += 2 + hsizes[
i];
60 }
61
64 }
65 } else if(*p == 2) {
67 unsigned int sizesum = 1;
68 p++;
71 while((*p == 0xFF) && (sizesum < avccontext->extradata_size)) {
74 sizesum += 1 + 0xFF;
75 p++;
76 }
79 sizesum += 1 + *p;
82 "vorbis header sizes damaged\n");
85 }
86 p++;
87 }
89 #if 0
91 "vorbis header sizes: %d, %d, %d, / extradata_len is %d \n",
93 #endif
97 } else {
99 "vorbis initial header len is wrong: %d\n", *p);
102 }
103
112 }
113 }
114
119
122
123 return 0 ;
124
128 }
129
130
133 ogg_int16_t *ptr, *
data = (ogg_int16_t*)buf ;
134 float *mono ;
135
139
140 for(j = 0 ; j <
samples ; j++) {
143 }
144 }
145
146 return 0 ;
147 }
148
150 int *got_frame_ptr,
AVPacket *avpkt)
151 {
154 float **pcm ;
156 int samples, total_samples, total_bytes;
159
161 //FIXME flush
162 return 0;
163 }
164
165 frame->nb_samples = 8192*4;
169
170
173
174 // av_log(avccontext, AV_LOG_DEBUG, "%d %d %d %"PRId64" %"PRId64" %d %d\n", op->bytes, op->b_o_s, op->e_o_s, op->granulepos, op->packetno, buf_size, context->vi.rate);
175
176 /* for(i=0; i<op->bytes; i++)
177 av_log(avccontext, AV_LOG_DEBUG, "%02X ", op->packet[i]);
178 av_log(avccontext, AV_LOG_DEBUG, "\n");*/
179
180 if(vorbis_synthesis(&
context->vb,
op) == 0)
182
183 total_samples = 0 ;
184 total_bytes = 0 ;
185
186 while((
samples = vorbis_synthesis_pcmout(&
context->vd, &pcm)) > 0) {
191 }
192
193 frame->nb_samples = total_samples;
194 *got_frame_ptr = total_samples > 0;
196 }
197
198
201
202 vorbis_block_clear(&
context->vb);
203 vorbis_dsp_clear(&
context->vd);
204 vorbis_info_clear(&
context->vi) ;
205 vorbis_comment_clear(&
context->vc) ;
206
207 return 0 ;
208 }
209
210
221 };