Revision a03cbe5f libavcodec/oggvorbis.c

View differences:

libavcodec/oggvorbis.c
200 200

  
201 201
static int oggvorbis_decode_init(AVCodecContext *avccontext) {
202 202
    OggVorbisContext *context = avccontext->priv_data ;
203
    uint8_t *p= avccontext->extradata;
204
    int i;
203 205

  
204 206
    vorbis_info_init(&context->vi) ;
205 207
    vorbis_comment_init(&context->vc) ;
206
    context->op.packetno= 0;
208

  
209
    for(i=0; i<3; i++){
210
        context->op.b_o_s= i==0;
211
        context->op.bytes= *(p++)<<8;
212
        context->op.bytes+=*(p++);
213
        context->op.packet= p;
214
        p += context->op.bytes;
215

  
216
	if(vorbis_synthesis_headerin(&context->vi, &context->vc, &context->op)<0){
217
            av_log(avccontext, AV_LOG_ERROR, "%d. vorbis header damaged\n", i+1);
218
            return -1;
219
        }
220
    }
221
    avccontext->channels = context->vi.channels;
222
    avccontext->sample_rate = context->vi.rate;
223

  
224
    vorbis_synthesis_init(&context->vd, &context->vi);
225
    vorbis_block_init(&context->vd, &context->vb); 
207 226

  
208 227
    return 0 ;
209 228
}
......
251 270
    
252 271
    op->packet = buf;
253 272
    op->bytes  = buf_size;
254
    op->b_o_s  = op->packetno == 0;
255 273

  
256 274
//    av_log(avccontext, AV_LOG_DEBUG, "%d %d %d %lld %lld %d %d\n", op->bytes, op->b_o_s, op->e_o_s, op->granulepos, op->packetno, buf_size, context->vi.rate);
257 275
    
258 276
/*    for(i=0; i<op->bytes; i++)
259 277
      av_log(avccontext, AV_LOG_DEBUG, "%02X ", op->packet[i]);
260 278
    av_log(avccontext, AV_LOG_DEBUG, "\n");*/
261
    if(op->packetno < 3) {
262
	if(vorbis_synthesis_headerin(&context->vi, &context->vc, op)<0){
263
            av_log(avccontext, AV_LOG_ERROR, "%lld. vorbis header damaged\n", op->packetno+1);
264
            return -1;
265
        }
266
	avccontext->channels = context->vi.channels ;
267
	avccontext->sample_rate = context->vi.rate ;
268
        op->packetno++;
269
	return buf_size ;
270
    }
271

  
272
    if(op->packetno == 3) {
273
//	av_log(avccontext, AV_LOG_INFO, "vorbis_decode: %d channel, %ldHz, encoder `%s'\n",
274
//		context->vi.channels, context->vi.rate, context->vc.vendor);
275

  
276
	vorbis_synthesis_init(&context->vd, &context->vi) ;
277
	vorbis_block_init(&context->vd, &context->vb); 
278
    }
279 279

  
280 280
    if(vorbis_synthesis(&context->vb, op) == 0)
281 281
	vorbis_synthesis_blockin(&context->vd, &context->vb) ;
......
290 290
        vorbis_synthesis_read(&context->vd, samples) ;
291 291
    }
292 292

  
293
    op->packetno++;
294 293
    *data_size = total_bytes ;   
295 294
    return buf_size ;
296 295
}

Also available in: Unified diff