If a stream starts with a xing/info frame, this should be skipped. Otherwise a frame's worth of silence will be inserted at the start of the output.
Unified · Split
| @@ -363,6 +363,24 @@ static int sox_mp3_inputtag(sox_format_t * ft) · 362 unmodified lines | |||
| 363 | return rc; | 363 | return rc; |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | static sox_bool sox_mp3_vbrtag(sox_format_t *ft) | ||
| 367 | { | ||
| 368 | priv_t *p = ft->priv; | ||
| 369 | struct mad_bitptr *anc = &p->Stream.anc_ptr; | ||
| 370 | |||
| 371 | if (p->Frame.header.layer != MAD_LAYER_III) | ||
| 372 | return sox_false; | ||
| 373 | |||
| 374 | if (p->Stream.anc_bitlen < 32) | ||
| 375 | return sox_false; | ||
| 376 | |||
| 377 | if (!memcmp(anc->byte, "Xing", 4) || | ||
| 378 | !memcmp(anc->byte, "Info", 4)) | ||
| 379 | return sox_true; | ||
| 380 | |||
| 381 | return sox_false; | ||
| 382 | } | ||
| 383 | |||
| 366 | static int startread(sox_format_t * ft) | 384 | static int startread(sox_format_t * ft) |
| 367 | { | 385 | { |
| 368 | priv_t *p = (priv_t *) ft->priv; | 386 | priv_t *p = (priv_t *) ft->priv; |
| @@ -457,18 +475,20 @@ static int startread(sox_format_t * ft) · 88 unmodified lines | |||
| 457 | return SOX_EOF; | 475 | return SOX_EOF; |
| 458 | } | 476 | } |
| 459 | 477 | ||
| 460 | p->FrameCount=1; | ||
| 461 | |||
| 462 | p->mad_timer_add(&p->Timer,p->Frame.header.duration); | ||
| 463 | p->mad_synth_frame(&p->Synth,&p->Frame); | ||
| 464 | ft->signal.precision = MP3_MAD_PRECISION; | 478 | ft->signal.precision = MP3_MAD_PRECISION; |
| 465 | ft->signal.rate=p->Synth.pcm.samplerate; | 479 | ft->signal.rate=p->Frame.header.samplerate; |
| 466 | if (ignore_length) | 480 | if (ignore_length) |
| 467 | ft->signal.length = SOX_UNSPEC; | 481 | ft->signal.length = SOX_UNSPEC; |
| 468 | else { | 482 | else { |
| 469 | ft->signal.length *= ft->signal.channels; /* Keep separate from line above! */ | 483 | ft->signal.length *= ft->signal.channels; /* Keep separate from line above! */ |
| 470 | } | 484 | } |
| 471 | 485 | ||
| 486 | if (!sox_mp3_vbrtag(ft)) | ||
| 487 | p->Stream.next_frame = p->Stream.this_frame; | ||
| 488 | |||
| 489 | p->mad_frame_init(&p->Frame); | ||
| 490 | sox_mp3_input(ft); | ||
| 491 | |||
| 472 | p->cursamp = 0; | 492 | p->cursamp = 0; |
| 473 | 493 | ||
| 474 | return SOX_SUCCESS; | 494 | return SOX_SUCCESS; |