diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-10-30 17:28:05 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-10-30 17:28:05 +0000 |
| commit | 304dc519d9d68b3861af998a997c5f2a97c9235d (patch) | |
| tree | 8dec3f0d3f5b63ae97432ee9a43482c8e35fee37 /src/plugins/Input/aac/aacfile.cpp | |
| parent | f0d2a4c14b10bffe95250242c13cde032266778f (diff) | |
| download | qmmp-304dc519d9d68b3861af998a997c5f2a97c9235d.tar.gz qmmp-304dc519d9d68b3861af998a997c5f2a97c9235d.tar.bz2 qmmp-304dc519d9d68b3861af998a997c5f2a97c9235d.zip | |
enabled aac plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@605 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/aac/aacfile.cpp')
| -rw-r--r-- | src/plugins/Input/aac/aacfile.cpp | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/src/plugins/Input/aac/aacfile.cpp b/src/plugins/Input/aac/aacfile.cpp index 9cf3184d8..f25c31202 100644 --- a/src/plugins/Input/aac/aacfile.cpp +++ b/src/plugins/Input/aac/aacfile.cpp @@ -25,20 +25,62 @@ #include "aacfile.h" #define MAX_CHANNELS 6 +#define AAC_BUFFER_SIZE 4096 static int adts_sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350,0,0,0}; AACFile::AACFile(QIODevice *i) { + m_isValid = FALSE; m_length = 0; m_bitrate = 0; m_input = i; - parseADTS(); + uchar buf[AAC_BUFFER_SIZE]; + qint64 buf_at = i->peek((char *) buf, AAC_BUFFER_SIZE); + + int tag_size = 0; + if (!memcmp(buf, "ID3", 3)) //TODO parse id3 tag + { + /* high bit is not used */ + tag_size = (buf[6] << 21) | (buf[7] << 14) | + (buf[8] << 7) | (buf[9] << 0); + + tag_size += 10; + if (buf_at - tag_size < 4) + { + qWarning("AACFile: invalid tag size"); + return; + } + memmove (buf, buf + tag_size, buf_at - tag_size); + } + //try to determenate header type; + if (buf[0] == 0xff && ((buf[1] & 0xf6) == 0xf0)) + { + qDebug("AACFile: ADTS header found"); + if (!i->isSequential()) + parseADTS(); + m_isValid = TRUE; + } + else if (memcmp(buf, "ADIF", 4) == 0) + { + qDebug("AACFile: ADIF header found"); + int skip_size = (buf[4] & 0x80) ? 9 : 0; + m_bitrate = ((buf[4 + skip_size] & 0x0F)<<19) | + (buf[5 + skip_size]<<11) | + (buf[6 + skip_size]<<3) | + (buf[7 + skip_size] & 0xE0); + + if (!i->isSequential ()) + m_length = (qint64) (((float)i->size()*8.f)/((float)m_bitrate) + 0.5f); + else + m_length = 0; + m_bitrate = (int)((float)m_bitrate/1000.0f + 0.5f); + m_isValid = TRUE; + } } AACFile::~AACFile() -{ -} +{} qint64 AACFile::length() { @@ -52,7 +94,7 @@ quint32 AACFile::bitrate() void AACFile::parseADTS() { - uchar *buf = new uchar[FAAD_MIN_STREAMSIZE*MAX_CHANNELS]; + uchar buf[FAAD_MIN_STREAMSIZE*MAX_CHANNELS]; qint64 buf_at = 0; int frames, frame_length; int t_framelength = 0; @@ -118,3 +160,8 @@ void AACFile::parseADTS() else m_length = 1; } + +bool AACFile::isValid() +{ + return m_isValid; +} |
