OSDN Git Service

Update MediaInfo binaries to v0.7.53 (2012-01-24), compiled with ICL 12.1.6 and MSVC...
[lamexp/LameXP.git] / src / Registry_Decoder.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2012 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.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "Registry_Decoder.h"
23
24 #include "Decoder_AAC.h"
25 #include "Decoder_AC3.h"
26 #include "Decoder_ADPCM.h"
27 #include "Decoder_ALAC.h"
28 #include "Decoder_Avisynth.h"
29 #include "Decoder_FLAC.h"
30 #include "Decoder_MAC.h"
31 #include "Decoder_MP3.h"
32 #include "Decoder_Musepack.h"
33 #include "Decoder_Shorten.h"
34 #include "Decoder_Speex.h"
35 #include "Decoder_TTA.h"
36 #include "Decoder_Vorbis.h"
37 #include "Decoder_Wave.h"
38 #include "Decoder_WavPack.h"
39 #include "Decoder_WMA.h"
40 #include "PlaylistImporter.h"
41
42 #include <QString>
43 #include <QStringList>
44 #include <QRegExp>
45
46 #define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); }
47 #define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList())
48
49 AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
50 {
51         PROBE_DECODER(MP3Decoder);
52         PROBE_DECODER(VorbisDecoder);
53         PROBE_DECODER(AACDecoder);
54         PROBE_DECODER(AC3Decoder);
55         PROBE_DECODER(FLACDecoder);
56         PROBE_DECODER(WavPackDecoder);
57         PROBE_DECODER(MusepackDecoder);
58         PROBE_DECODER(ShortenDecoder);
59         PROBE_DECODER(MACDecoder);
60         PROBE_DECODER(TTADecoder);
61         PROBE_DECODER(SpeexDecoder);
62         PROBE_DECODER(ALACDecoder);
63         PROBE_DECODER(WMADecoder);
64         PROBE_DECODER(ADPCMDecoder);
65         PROBE_DECODER(WaveDecoder);
66         PROBE_DECODER(AvisynthDecoder);
67         
68         return NULL;
69 }
70
71 QStringList DecoderRegistry::getSupportedTypes(void)
72 {
73         QStringList types;
74
75         types << GET_FILETYPES(WaveDecoder);
76         types << GET_FILETYPES(MP3Decoder);
77         types << GET_FILETYPES(VorbisDecoder);
78         types << GET_FILETYPES(AACDecoder);
79         types << GET_FILETYPES(AC3Decoder);
80         types << GET_FILETYPES(FLACDecoder);
81         types << GET_FILETYPES(WavPackDecoder);
82         types << GET_FILETYPES(MusepackDecoder);
83         types << GET_FILETYPES(ShortenDecoder);
84         types << GET_FILETYPES(MACDecoder);
85         types << GET_FILETYPES(TTADecoder);
86         types << GET_FILETYPES(SpeexDecoder);
87         types << GET_FILETYPES(ALACDecoder);
88         types << GET_FILETYPES(WMADecoder);
89         types << GET_FILETYPES(ADPCMDecoder);
90         types << GET_FILETYPES(AvisynthDecoder);
91
92         QStringList extensions;
93         extensions << QString(PlaylistImporter::supportedExtensions).split(" ", QString::SkipEmptyParts);
94         QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);
95
96         for(int i = 0; i < types.count(); i++)
97         {
98                 if(regExp.lastIndexIn(types.at(i)) >= 0)
99                 {
100                         extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts);
101                 }
102         }
103
104         if(!extensions.empty())
105         {
106                 extensions.removeDuplicates();
107                 extensions.sort();
108                 types.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions.join(" ")));
109         }
110         
111         types << QString("%1 (%2)").arg(tr("Playlists"), PlaylistImporter::supportedExtensions);
112         types << QString("%1 (*.*)").arg(tr("All files"));
113
114         return types;
115 }