Mercurial > hg > svcore
comparison data/fileio/MP3FileReader.cpp @ 1307:c84629395040 mp3-gapless
Handle trimming the padding from end as well
author | Chris Cannam |
---|---|
date | Tue, 29 Nov 2016 13:34:51 +0000 |
parents | b325e91505b5 |
children | aa1b1fc2d018 |
comparison
equal
deleted
inserted
replaced
1306:b325e91505b5 | 1307:c84629395040 |
---|---|
70 m_completion = 0; | 70 m_completion = 0; |
71 m_done = false; | 71 m_done = false; |
72 m_reporter = reporter; | 72 m_reporter = reporter; |
73 | 73 |
74 if (m_gaplessMode == Gapless) { | 74 if (m_gaplessMode == Gapless) { |
75 CodedAudioFileReader::setSamplesToTrim(DEFAULT_DECODER_DELAY, 0); | 75 CodedAudioFileReader::setFramesToTrim(DEFAULT_DECODER_DELAY, 0); |
76 } | 76 } |
77 | 77 |
78 struct stat stat; | 78 struct stat stat; |
79 if (::stat(m_path.toLocal8Bit().data(), &stat) == -1 || stat.st_size == 0) { | 79 if (::stat(m_path.toLocal8Bit().data(), &stat) == -1 || stat.st_size == 0) { |
80 m_error = QString("File %1 does not exist.").arg(m_path); | 80 m_error = QString("File %1 does not exist.").arg(m_path); |
373 { | 373 { |
374 DecoderData *data = (DecoderData *)dp; | 374 DecoderData *data = (DecoderData *)dp; |
375 return data->reader->filter(stream, frame); | 375 return data->reader->filter(stream, frame); |
376 } | 376 } |
377 | 377 |
378 static string toMagic(uint32_t fourcc) | 378 static string toMagic(unsigned long fourcc) |
379 { | 379 { |
380 string magic("...."); | 380 string magic("...."); |
381 for (int i = 0; i < 4; ++i) { | 381 for (int i = 0; i < 4; ++i) { |
382 magic[3-i] = char((fourcc >> (8*i)) & 0xff); | 382 magic[3-i] = char((fourcc >> (8*i)) & 0xff); |
383 } | 383 } |
435 | 435 |
436 for (int skip = 0; skip < 5 + 12; ++skip) { | 436 for (int skip = 0; skip < 5 + 12; ++skip) { |
437 (void)mad_bit_read(&ptr, 8); | 437 (void)mad_bit_read(&ptr, 8); |
438 } | 438 } |
439 | 439 |
440 uint32_t delay = mad_bit_read(&ptr, 12); | 440 auto delay = mad_bit_read(&ptr, 12); |
441 uint32_t padding = mad_bit_read(&ptr, 12); | 441 auto padding = mad_bit_read(&ptr, 12); |
442 | 442 |
443 sv_frame_t delayToDrop = DEFAULT_DECODER_DELAY + delay; | 443 sv_frame_t delayToDrop = DEFAULT_DECODER_DELAY + delay; |
444 sv_frame_t paddingToDrop = padding - DEFAULT_DECODER_DELAY; | 444 sv_frame_t paddingToDrop = padding - DEFAULT_DECODER_DELAY; |
445 if (paddingToDrop < 0) paddingToDrop = 0; | 445 if (paddingToDrop < 0) paddingToDrop = 0; |
446 | 446 |
449 | 449 |
450 SVDEBUG << "MP3FileReader: Will be trimming " << delayToDrop | 450 SVDEBUG << "MP3FileReader: Will be trimming " << delayToDrop |
451 << " samples from start and " << paddingToDrop | 451 << " samples from start and " << paddingToDrop |
452 << " from end" << endl; | 452 << " from end" << endl; |
453 | 453 |
454 CodedAudioFileReader::setSamplesToTrim(delayToDrop, paddingToDrop); | 454 CodedAudioFileReader::setFramesToTrim(delayToDrop, paddingToDrop); |
455 | 455 |
456 } else { | 456 } else { |
457 SVDEBUG << "MP3FileReader: Xing frame has no LAME metadata" << endl; | 457 SVDEBUG << "MP3FileReader: Xing frame has no LAME metadata" << endl; |
458 } | 458 } |
459 | 459 |