From 691eff1ae20c8561674b379c0f8c13026622d11e Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 16 Oct 2013 10:59:24 +0000 Subject: vorbis: added peak overflow support git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3798 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/vorbis/decoder_vorbis.cpp | 29 +++++++++++++++++++++++ src/plugins/Input/vorbis/decoder_vorbis.h | 1 + src/plugins/Input/vorbis/decodervorbisfactory.cpp | 4 ++-- 3 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/plugins/Input') diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp index dc91ea384..73e19dd92 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.cpp +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -235,3 +235,32 @@ qint64 DecoderVorbis::read(char *data, qint64 maxSize) m_bitrate = ov_bitrate_instant(&oggfile) / 1000; return len; } + +qint64 DecoderVorbis::read(float *data, qint64 samples) +{ + len = -1; + float **pcm = 0; + while (len < 0) + len = ov_read_float(&oggfile, &pcm, samples, &m_section); + + if(len == 0) + return 0; + + int channels = audioParameters().channels(); + + for(int i = 0; i < channels; ++i) + { + float *ptr = &data[i]; + for(int j = 0; j < len; ++j) + { + *ptr = pcm[i][j]; + ptr += channels; + } + } + + if (m_section != m_last_section) + updateTags(); + + m_bitrate = ov_bitrate_instant(&oggfile) / 1000; + return len*channels; +} diff --git a/src/plugins/Input/vorbis/decoder_vorbis.h b/src/plugins/Input/vorbis/decoder_vorbis.h index c968379d5..e29e5e728 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.h +++ b/src/plugins/Input/vorbis/decoder_vorbis.h @@ -25,6 +25,7 @@ public: private: virtual qint64 read(char *data, qint64 maxSize); + virtual qint64 read(float *data, qint64 samples); virtual void seek(qint64 time); // helper functions diff --git a/src/plugins/Input/vorbis/decodervorbisfactory.cpp b/src/plugins/Input/vorbis/decodervorbisfactory.cpp index e069c7761..17d5af27e 100644 --- a/src/plugins/Input/vorbis/decodervorbisfactory.cpp +++ b/src/plugins/Input/vorbis/decodervorbisfactory.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2012 by Ilya Kotov * + * Copyright (C) 2008-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -64,7 +64,7 @@ Decoder *DecoderVorbisFactory::create(const QString &url, QIODevice *input) if(!url.contains("://")) //local file { ReplayGainReader rg(url); - d->setReplayGainInfo(rg.replayGainInfo()); + d->setReplayGainInfo(rg.replayGainInfo(), true); } return d; } -- cgit v1.2.3-13-gbd6f