aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/vorbis
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-12-27 17:44:16 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2015-12-27 17:44:16 +0000
commitd55e5c3b1bd791f0f579315c30bf14064eff5824 (patch)
tree212315e4157bcf4accd64994a083599151c8bc40 /src/plugins/Input/vorbis
parent78b5e1b27f7952bad19b53cdb6d0f371acb22ef2 (diff)
downloadqmmp-d55e5c3b1bd791f0f579315c30bf14064eff5824.tar.gz
qmmp-d55e5c3b1bd791f0f579315c30bf14064eff5824.tar.bz2
qmmp-d55e5c3b1bd791f0f579315c30bf14064eff5824.zip
using float output in the mpeg and vorbis plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5917 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/vorbis')
-rw-r--r--src/plugins/Input/vorbis/decoder_vorbis.cpp39
-rw-r--r--src/plugins/Input/vorbis/decoder_vorbis.h5
2 files changed, 16 insertions, 28 deletions
diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp
index 7f77d485f..765572c91 100644
--- a/src/plugins/Input/vorbis/decoder_vorbis.cpp
+++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp
@@ -71,9 +71,8 @@ static long oggtell(void *src)
DecoderVorbis::DecoderVorbis(const QString &url, QIODevice *i)
: Decoder(i)
{
- inited = false;
+ m_inited = false;
m_totalTime = 0;
- m_section = 0;
m_last_section = -1;
m_bitrate = 0;
m_url = url;
@@ -88,7 +87,7 @@ DecoderVorbis::~DecoderVorbis()
bool DecoderVorbis::initialize()
{
qDebug("DecoderVorbis: initialize");
- inited = false;
+ m_inited = false;
m_totalTime = 0;
if (!input())
{
@@ -140,15 +139,15 @@ bool DecoderVorbis::initialize()
qWarning("DecoderVorbis: unsupported number of channels: %d", chan);
return false;
}
- configure(freq, chmap, Qmmp::PCM_S16LE);
- inited = true;
+ configure(freq, chmap, Qmmp::PCM_FLOAT);
+ m_inited = true;
return true;
}
qint64 DecoderVorbis::totalTime()
{
- if (!inited)
+ if (!m_inited)
return 0;
return m_totalTime;
}
@@ -161,7 +160,7 @@ int DecoderVorbis::bitrate()
void DecoderVorbis::deinit()
{
- if (inited)
+ if (m_inited)
ov_clear(&oggfile);
len = 0;
}
@@ -296,23 +295,10 @@ void DecoderVorbis::seek(qint64 time)
qint64 DecoderVorbis::read(unsigned char *data, qint64 maxSize)
{
len = -1;
- while (len < 0)
- len = ov_read(&oggfile, (char *)data, maxSize, 0, 2, 1, &m_section);
-
- if (m_section != m_last_section)
- updateTags();
- m_last_section = m_section;
- if(len > 0)
- m_bitrate = ov_bitrate_instant(&oggfile) / 1000;
- return len;
-}
-
-qint64 DecoderVorbis::read(float *data, qint64 samples)
-{
- len = -1;
float **pcm = 0;
+ int section = 0;
while (len < 0)
- len = ov_read_float(&oggfile, &pcm, samples, &m_section);
+ len = ov_read_float(&oggfile, &pcm, maxSize/sizeof(float), &section);
if(len == 0)
return 0;
@@ -321,7 +307,7 @@ qint64 DecoderVorbis::read(float *data, qint64 samples)
for(int i = 0; i < channels; ++i)
{
- float *ptr = &data[i];
+ float *ptr = (float *) (data + i*sizeof(float));
for(int j = 0; j < len; ++j)
{
*ptr = pcm[i][j];
@@ -329,9 +315,12 @@ qint64 DecoderVorbis::read(float *data, qint64 samples)
}
}
- if (m_section != m_last_section)
+ if (section != m_last_section)
+ {
updateTags();
+ m_last_section = section;
+ }
m_bitrate = ov_bitrate_instant(&oggfile) / 1000;
- return len*channels;
+ return len*sizeof(float)*channels;
}
diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h
index f48fe763a..b7cbfdea3 100644
--- a/src/plugins/Input/vorbis/decoder_vorbis.h
+++ b/src/plugins/Input/vorbis/decoder_vorbis.h
@@ -25,7 +25,6 @@ public:
private:
virtual qint64 read(unsigned char *data, qint64 maxSize);
- virtual qint64 read(float *data, qint64 samples);
virtual void seek(qint64 time);
// helper functions
@@ -37,9 +36,9 @@ private:
OggVorbis_File oggfile;
qint64 m_totalTime;
long len;
- int m_section, m_last_section;
+ int m_last_section;
int m_bitrate;
- bool inited;
+ bool m_inited;
QString m_url;
};