diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-03-21 20:35:56 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-03-21 20:35:56 +0000 |
| commit | c06ecb1cccf9b6bbfaa0a56403e8926ba974db1f (patch) | |
| tree | 8f6d9b92771fb3c6263c4616a667bc7b7f74a2c1 /src/plugins/Input | |
| parent | 025866f86ad797ee879fad4a6d5530b1aeda3f90 (diff) | |
| download | qmmp-c06ecb1cccf9b6bbfaa0a56403e8926ba974db1f.tar.gz qmmp-c06ecb1cccf9b6bbfaa0a56403e8926ba974db1f.tar.bz2 qmmp-c06ecb1cccf9b6bbfaa0a56403e8926ba974db1f.zip | |
musepack sv8 support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@864 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input')
| -rw-r--r-- | src/plugins/Input/modplug/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/plugins/Input/mpc/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | src/plugins/Input/mpc/decoder_mpc.cpp | 102 | ||||
| -rw-r--r-- | src/plugins/Input/mpc/decoder_mpc.h | 10 | ||||
| -rw-r--r-- | src/plugins/Input/mpc/mpc.pro | 4 |
5 files changed, 110 insertions, 20 deletions
diff --git a/src/plugins/Input/modplug/CMakeLists.txt b/src/plugins/Input/modplug/CMakeLists.txt index 393b4e4c9..c385ddf03 100644 --- a/src/plugins/Input/modplug/CMakeLists.txt +++ b/src/plugins/Input/modplug/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 2.4.7) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) - + # qt plugin ADD_DEFINITIONS( -Wall ) diff --git a/src/plugins/Input/mpc/CMakeLists.txt b/src/plugins/Input/mpc/CMakeLists.txt index 942833edd..2e318673a 100644 --- a/src/plugins/Input/mpc/CMakeLists.txt +++ b/src/plugins/Input/mpc/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 2.4.7) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) - + # qt plugin ADD_DEFINITIONS( -Wall ) @@ -29,7 +29,15 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) # libmpc -CHECK_INCLUDE_FILE_CXX(mpcdec/mpcdec.h MPC_FOUND) +CHECK_INCLUDE_FILE_CXX(mpc/mpcdec.h MPC_NEW_FOUND) +IF(NOT MPC_NEW_FOUND) +CHECK_INCLUDE_FILE_CXX(mpcdec/mpcdec.h MPC_OLD_FOUND) +ADD_DEFINITIONS(-DMPC_OLD_API) +ENDIF(NOT MPC_NEW_FOUND) + +IF(MPC_NEW_FOUND OR MPC_OLD_FOUND) +SET(MPC_FOUND TRUE CACHE INTERNAL "mpc") +ENDIF(MPC_NEW_FOUND OR MPC_OLD_FOUND) include_directories(${TAGLIB_INCLUDE_DIRS}) link_directories(${TAGLIB_LIBRARY_DIRS}) diff --git a/src/plugins/Input/mpc/decoder_mpc.cpp b/src/plugins/Input/mpc/decoder_mpc.cpp index d8d739c1c..26b0c71b6 100644 --- a/src/plugins/Input/mpc/decoder_mpc.cpp +++ b/src/plugins/Input/mpc/decoder_mpc.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -60,38 +60,65 @@ inline static void copyBuffer(MPC_SAMPLE_FORMAT* pInBuf, char* pOutBuf, unsigned // mpc callbacks + + +#ifdef MPC_OLD_API static mpc_int32_t mpc_callback_read (void *data, void *buffer, mpc_int32_t size) { DecoderMPC *dmpc = (DecoderMPC *) data; +#else +static mpc_int32_t mpc_callback_read (mpc_reader *reader, void *buffer, mpc_int32_t size) +{ + DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif qint64 res; res = dmpc->input()->read((char *)buffer, size); return res; } - +#ifdef MPC_OLD_API static mpc_bool_t mpc_callback_seek (void *data, mpc_int32_t offset) { DecoderMPC *dmpc = (DecoderMPC *) data; - - return dmpc->input()->seek(offset); // ? TRUE : FALSE; +#else +static mpc_bool_t mpc_callback_seek (mpc_reader *reader, mpc_int32_t offset) +{ + DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif + return dmpc->input()->seek(offset); } - +#ifdef MPC_OLD_API static mpc_int32_t mpc_callback_tell (void *data) { DecoderMPC *dmpc = (DecoderMPC *) data; +#else +static mpc_int32_t mpc_callback_tell (mpc_reader *reader) +{ + DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return dmpc->input()->pos (); } - +#ifdef MPC_OLD_API static mpc_bool_t mpc_callback_canseek (void *data) { DecoderMPC *dmpc = (DecoderMPC *) data; +#else +static mpc_bool_t mpc_callback_canseek (mpc_reader *reader) +{ + DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return !dmpc->input()->isSequential () ; } - +#ifdef MPC_OLD_API static mpc_int32_t mpc_callback_get_size (void *data) { DecoderMPC *dmpc = (DecoderMPC *) data; +#else +static mpc_int32_t mpc_callback_get_size (mpc_reader *reader) +{ + DecoderMPC *dmpc = (DecoderMPC *) reader->data; +#endif return dmpc->input()->size(); } @@ -124,6 +151,11 @@ DecoderMPC::~DecoderMPC() deinit(); if (data()) { +#ifndef MPC_OLD_API + if (data()->demuxer) + mpc_demux_exit (data()->demuxer); + data()->demuxer = 0; +#endif delete data(); m_data = 0; } @@ -173,7 +205,6 @@ void DecoderMPC::flush(bool final) { output()->recycler()->cond()->wakeOne(); } - output()->recycler()->mutex()->unlock(); } } @@ -222,22 +253,31 @@ bool DecoderMPC::initialize() m_data->reader.get_size = mpc_callback_get_size; m_data->reader.data = this; +#ifdef MPC_OLD_API mpc_streaminfo_init (&m_data->info); - if (mpc_streaminfo_read (&m_data->info, &m_data->reader) != ERROR_CODE_OK) return FALSE; +#else + m_data->demuxer = mpc_demux_init (&m_data->reader); + + if (!m_data->demuxer) + return FALSE; + mpc_demux_get_info (m_data->demuxer, &m_data->info); +#endif + chan = data()->info.channels; configure(data()->info.sample_freq, chan, 16); +#ifdef MPC_OLD_API mpc_decoder_setup (&data()->decoder, &data()->reader); //mpc_decoder_scale_output (&data()->decoder, 3.0); - if (!mpc_decoder_initialize (&data()->decoder, &data()->info)) { qWarning("DecoderMPC: cannot get info."); return FALSE; } +#endif m_totalTime = mpc_streaminfo_get_length(&data()->info) * 1000; inited = TRUE; qDebug("DecoderMPC: initialize succes"); @@ -270,9 +310,13 @@ void DecoderMPC::deinit() void DecoderMPC::run() { +#ifdef MPC_OLD_API mpc_uint32_t vbrAcc = 0; mpc_uint32_t vbrUpd = 0; - +#else + mpc_frame_info frame; + mpc_status err; +#endif mutex()->lock (); if (!inited) { @@ -288,20 +332,46 @@ void DecoderMPC::run() if (seekTime >= 0.0) { +#ifdef MPC_OLD_API mpc_decoder_seek_seconds(&data()->decoder, seekTime/1000); +#else + mpc_demux_seek_second(data()->demuxer, (double)seekTime/1000); +#endif seekTime = -1.0; } +#ifdef MPC_OLD_API MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH]; - len = mpc_decoder_decode (&data()->decoder, buffer, &vbrAcc, &vbrUpd); - copyBuffer(buffer, (char *) (output_buf + output_at), len); - len = len * 4; - +#else + MPC_SAMPLE_FORMAT buffer[MPC_DECODER_BUFFER_LENGTH]; + frame.buffer = (MPC_SAMPLE_FORMAT *) &buffer; + len = 0; + while (!len) + { + err = mpc_demux_decode (m_data->demuxer, &frame); + if (err != MPC_STATUS_OK || frame.bits == -1) + { + len = 0; + qDebug("finished"); + break; + } + else + { + len = frame.samples; + copyBuffer(frame.buffer, (char *) (output_buf + output_at), len); + len = len * 4; + } + } +#endif if (len > 0) { - bitrate = vbrUpd * data()->info.sample_freq / 1152; +#ifdef MPC_OLD_API + bitrate = vbrUpd * data()->info.sample_freq / 1152000; +#else + bitrate = frame.bits * data()->info.sample_freq / 1152000; +#endif output_at += len; output_bytes += len; diff --git a/src/plugins/Input/mpc/decoder_mpc.h b/src/plugins/Input/mpc/decoder_mpc.h index 052f634c8..fccc74610 100644 --- a/src/plugins/Input/mpc/decoder_mpc.h +++ b/src/plugins/Input/mpc/decoder_mpc.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -21,13 +21,21 @@ #ifndef DECODER_MPC_H #define DECODER_MPC_H +#ifdef MPC_OLD_API #include <mpcdec/mpcdec.h> +#else +#include <mpc/mpcdec.h> +#endif #include <qmmp/decoder.h> struct mpc_data { +#ifdef MPC_OLD_API mpc_decoder decoder; +#else + mpc_demux *demuxer; +#endif mpc_reader reader; mpc_streaminfo info; }; diff --git a/src/plugins/Input/mpc/mpc.pro b/src/plugins/Input/mpc/mpc.pro index 4aba0930f..0317d3bf2 100644 --- a/src/plugins/Input/mpc/mpc.pro +++ b/src/plugins/Input/mpc/mpc.pro @@ -33,5 +33,9 @@ isEmpty (LIB_DIR){ LIB_DIR = /lib } +exists(/usr/include/mpcdec/mpcdec.h){ +DEFINES += MPC_OLD_API +} + target.path = $$LIB_DIR/qmmp/Input INSTALLS += target |
