Bump version.
[LameXP.git] / src / Registry_Decoder.cpp
blob2a812692ca960fcc17a8f84f7a91d7daa99cb1fb
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "Registry_Decoder.h"
25 #include "Decoder_AAC.h"
26 #include "Decoder_AC3.h"
27 #include "Decoder_ADPCM.h"
28 #include "Decoder_ALAC.h"
29 #include "Decoder_Avisynth.h"
30 #include "Decoder_FLAC.h"
31 #include "Decoder_MAC.h"
32 #include "Decoder_MP3.h"
33 #include "Decoder_Musepack.h"
34 #include "Decoder_Shorten.h"
35 #include "Decoder_Speex.h"
36 #include "Decoder_TTA.h"
37 #include "Decoder_Vorbis.h"
38 #include "Decoder_Wave.h"
39 #include "Decoder_WavPack.h"
40 #include "Decoder_Opus.h"
41 #include "Decoder_WMA.h"
42 #include "PlaylistImporter.h"
43 #include "Model_Settings.h"
45 #include <QString>
46 #include <QStringList>
47 #include <QRegExp>
49 #define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); }
50 #define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList())
52 AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
54 PROBE_DECODER(MP3Decoder);
55 PROBE_DECODER(VorbisDecoder);
56 PROBE_DECODER(AACDecoder);
57 PROBE_DECODER(AC3Decoder);
58 PROBE_DECODER(FLACDecoder);
59 PROBE_DECODER(WavPackDecoder);
60 PROBE_DECODER(MusepackDecoder);
61 PROBE_DECODER(ShortenDecoder);
62 PROBE_DECODER(MACDecoder);
63 PROBE_DECODER(TTADecoder);
64 PROBE_DECODER(SpeexDecoder);
65 PROBE_DECODER(ALACDecoder);
66 PROBE_DECODER(WMADecoder);
67 PROBE_DECODER(ADPCMDecoder);
68 PROBE_DECODER(WaveDecoder);
69 PROBE_DECODER(OpusDecoder);
70 PROBE_DECODER(AvisynthDecoder);
72 return NULL;
75 QStringList DecoderRegistry::getSupportedTypes(void)
77 QStringList types;
79 types << GET_FILETYPES(WaveDecoder);
80 types << GET_FILETYPES(MP3Decoder);
81 types << GET_FILETYPES(VorbisDecoder);
82 types << GET_FILETYPES(AACDecoder);
83 types << GET_FILETYPES(AC3Decoder);
84 types << GET_FILETYPES(FLACDecoder);
85 types << GET_FILETYPES(WavPackDecoder);
86 types << GET_FILETYPES(MusepackDecoder);
87 types << GET_FILETYPES(ShortenDecoder);
88 types << GET_FILETYPES(MACDecoder);
89 types << GET_FILETYPES(TTADecoder);
90 types << GET_FILETYPES(SpeexDecoder);
91 types << GET_FILETYPES(ALACDecoder);
92 types << GET_FILETYPES(WMADecoder);
93 types << GET_FILETYPES(ADPCMDecoder);
94 types << GET_FILETYPES(OpusDecoder);
95 types << GET_FILETYPES(AvisynthDecoder);
97 QStringList extensions;
98 extensions << QString(PlaylistImporter::supportedExtensions).split(" ", QString::SkipEmptyParts);
99 QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);
101 for(int i = 0; i < types.count(); i++)
103 if(regExp.lastIndexIn(types.at(i)) >= 0)
105 extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts);
109 if(!extensions.empty())
111 extensions.removeDuplicates();
112 extensions.sort();
113 types.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions.join(" ")));
116 types << QString("%1 (%2)").arg(tr("Playlists"), PlaylistImporter::supportedExtensions);
117 types << QString("%1 (*.*)").arg(tr("All files"));
119 return types;
122 void DecoderRegistry::configureDecoders(const SettingsModel *settings)
124 OpusDecoder::setDisableResampling(settings->opusDisableResample());