aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-01-10 16:14:10 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-01-10 16:14:10 +0000
commitcf28884e3bf4edf48f6fa43fe075e7a1d279fd88 (patch)
tree1b8b46469294c693dce27231f65ed92167480172
parent9cbe3e1bd9bd2068b99402b9b935e1450c7c79d4 (diff)
downloadqmmp-cf28884e3bf4edf48f6fa43fe075e7a1d279fd88.tar.gz
qmmp-cf28884e3bf4edf48f6fa43fe075e7a1d279fd88.tar.bz2
qmmp-cf28884e3bf4edf48f6fa43fe075e7a1d279fd88.zip
src plugin: added 32-bit samples support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3144 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/plugins/Effect/srconverter/srconverter.cpp52
-rw-r--r--src/plugins/Effect/srconverter/srconverter.h3
2 files changed, 40 insertions, 15 deletions
diff --git a/src/plugins/Effect/srconverter/srconverter.cpp b/src/plugins/Effect/srconverter/srconverter.cpp
index f5731e499..969cd5eb0 100644
--- a/src/plugins/Effect/srconverter/srconverter.cpp
+++ b/src/plugins/Effect/srconverter/srconverter.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2007-2012 by Ilya Kotov *
+ * Copyright (C) 2007-2013 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -22,7 +22,6 @@
#include <math.h>
#include <stdlib.h>
#include <qmmp/qmmp.h>
-
#include "srconverter.h"
SRConverter::SRConverter() : Effect()
@@ -31,6 +30,7 @@ SRConverter::SRConverter() : Effect()
SRC_ZERO_ORDER_HOLD, SRC_LINEAR};
m_src_state = 0;
m_srcError = 0;
+ m_sz = 0;
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
m_overSamplingFs = settings.value("SRC/sample_rate",48000).toInt();
m_converter_type = converter_type_array[settings.value("SRC/engine", 0).toInt()];
@@ -38,40 +38,60 @@ SRConverter::SRConverter() : Effect()
SRConverter::~SRConverter()
{
- src_reset (m_src_state) ;
freeSRC();
m_src_data.data_in = 0;
m_src_data.data_out = 0;
m_src_data.end_of_input = 0;
m_src_data.input_frames = 0;
m_src_data.output_frames = 0;
+ m_sz = 0;
}
void SRConverter::applyEffect(Buffer *b)
{
if (m_src_state && b->nbytes > 0)
{
- m_src_data.input_frames = b->nbytes / 2 / channels();
+ m_src_data.end_of_input = 0;
+ m_src_data.input_frames = b->nbytes / m_sz / channels();
m_src_data.data_in = new float [m_src_data.input_frames * channels()];
m_src_data.output_frames = m_src_data.src_ratio * m_src_data.input_frames + 1;
- m_src_data.end_of_input = 0;
m_src_data.data_out = new float [m_src_data.output_frames * channels()];
- src_short_to_float_array((short*) b->data, m_src_data.data_in,
- m_src_data.input_frames * channels());
+
+
+ if(format() == Qmmp::PCM_S16LE)
+ {
+ src_short_to_float_array((short*) b->data, m_src_data.data_in,
+ m_src_data.input_frames * channels());
+ }
+ else
+ {
+ src_int_to_float_array((int*) b->data, m_src_data.data_in,
+ m_src_data.input_frames * channels());
+ }
+
if ((m_srcError = src_process(m_src_state, &m_src_data)) > 0)
{
qWarning("SRConverter: src_process(): %s\n", src_strerror(m_srcError));
}
else
{
- qint16 *out_data = new qint16 [m_src_data.output_frames_gen * channels()];
- src_float_to_short_array(m_src_data.data_out, out_data,
- m_src_data.output_frames_gen*channels());
- b->nbytes = m_src_data.output_frames_gen * channels() * 2;
+ uchar *out_data = new uchar[m_src_data.output_frames_gen * channels() * m_sz];;
+ if(format() == Qmmp::PCM_S16LE)
+ {
+ src_float_to_short_array(m_src_data.data_out, (short*)out_data,
+ m_src_data.output_frames_gen * channels());
+
+ }
+ else
+ {
+ src_float_to_int_array(m_src_data.data_out, (int*)out_data,
+ m_src_data.output_frames_gen * channels());
+ }
+ b->nbytes = m_src_data.output_frames_gen * channels() * m_sz;
if(b->nbytes > b->size)
{
delete [] b->data;
- b->data = (uchar *) out_data;
+ b->data = out_data;
}
else
{
@@ -88,7 +108,7 @@ void SRConverter::applyEffect(Buffer *b)
void SRConverter::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
{
freeSRC();
- if(freq != m_overSamplingFs)
+ if(freq != m_overSamplingFs && format != Qmmp::PCM_S8)
{
m_src_state = src_new(m_converter_type, chan, &m_srcError);
if (m_src_state)
@@ -100,11 +120,15 @@ void SRConverter::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
qDebug("SRConverter: src_new(): %s", src_strerror(m_srcError));
}
Effect::configure(m_overSamplingFs, chan, format);
+ m_sz = audioParameters().sampleSize();
}
void SRConverter::freeSRC()
{
if (m_src_state)
- m_src_state = src_delete(m_src_state);
+ {
+ src_reset(m_src_state);
+ src_delete(m_src_state);
+ }
m_src_state = 0;
}
diff --git a/src/plugins/Effect/srconverter/srconverter.h b/src/plugins/Effect/srconverter/srconverter.h
index 0f5e17e15..f25ebc491 100644
--- a/src/plugins/Effect/srconverter/srconverter.h
+++ b/src/plugins/Effect/srconverter/srconverter.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2007-2012 by Ilya Kotov *
+ * Copyright (C) 2007-2013 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -43,6 +43,7 @@ private:
quint32 m_overSamplingFs;
int m_srcError;
int m_converter_type;
+ int m_sz; //sample size
quint32 m_freq;
};