comparison libmpdemux/demux_ogg.c @ 17785:adc0e54034f0

in demux_ogg_read_packet initialize data to whole packet, reduces code and fixes missing initialization in else + header packet case.
author reimar
date Wed, 08 Mar 2006 22:23:21 +0000
parents b849a99cdc3c
children 3fe3b2b3a6ce
comparison
equal deleted inserted replaced
17784:1b42df5780e3 17785:adc0e54034f0
328 return id; 328 return id;
329 329
330 } 330 }
331 331
332 static unsigned char* demux_ogg_read_packet(ogg_stream_t* os,ogg_packet* pack,void *context,float* pts,int* flags, int samplesize) { 332 static unsigned char* demux_ogg_read_packet(ogg_stream_t* os,ogg_packet* pack,void *context,float* pts,int* flags, int samplesize) {
333 unsigned char* data; 333 unsigned char* data = pack->packet;
334 334
335 *pts = 0; 335 *pts = 0;
336 *flags = 0; 336 *flags = 0;
337 337
338 if(os->vorbis) { 338 if(os->vorbis) {
339 data = pack->packet;
340 if(*pack->packet & PACKET_TYPE_HEADER) 339 if(*pack->packet & PACKET_TYPE_HEADER)
341 os->hdr_packets++; 340 os->hdr_packets++;
342 else if (context ) 341 else if (context )
343 { 342 {
344 vorbis_info *vi = &((ov_struct_t*)context)->vi; 343 vorbis_info *vi = &((ov_struct_t*)context)->vi;
354 *pts = pack->granulepos / (float)vi->rate; 353 *pts = pack->granulepos / (float)vi->rate;
355 os->lastsize = blocksize; 354 os->lastsize = blocksize;
356 os->lastpos = pack->granulepos; 355 os->lastpos = pack->granulepos;
357 } 356 }
358 } else if (os->speex) { 357 } else if (os->speex) {
359 data = pack->packet; 358 // whole packet (default)
360 # ifdef HAVE_OGGTHEORA 359 # ifdef HAVE_OGGTHEORA
361 } else if (os->theora) { 360 } else if (os->theora) {
362 /* we pass complete packets to theora, mustn't strip the header! */ 361 /* we pass complete packets to theora, mustn't strip the header! */
363 data = pack->packet;
364 os->lastsize = 1; 362 os->lastsize = 1;
365 363
366 /* header packets beginn on 1-bit: thus check (*data&0x80). We don't 364 /* header packets beginn on 1-bit: thus check (*data&0x80). We don't
367 have theora_state st, until all header packets were passed to the 365 have theora_state st, until all header packets were passed to the
368 decoder. */ 366 decoder. */
387 } 385 }
388 #endif /* HAVE_OGGTHEORA */ 386 #endif /* HAVE_OGGTHEORA */
389 # ifdef HAVE_FLAC 387 # ifdef HAVE_FLAC
390 } else if (os->flac) { 388 } else if (os->flac) {
391 /* we pass complete packets to flac, mustn't strip the header! */ 389 /* we pass complete packets to flac, mustn't strip the header! */
392 data = pack->packet;
393 #endif /* HAVE_FLAC */ 390 #endif /* HAVE_FLAC */
394 } else { 391 } else {
395 if(*pack->packet & PACKET_TYPE_HEADER) 392 if(*pack->packet & PACKET_TYPE_HEADER)
396 os->hdr_packets++; 393 os->hdr_packets++;
397 else { 394 else {