aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/fileops
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-12-13 17:41:10 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-12-13 17:41:10 +0000
commit0910b79d3e3287886d9d0796c2c4c3ed822e97bc (patch)
tree26f85e0e47cca0316bd9fe6e51ff73c967dde092 /src/plugins/General/fileops
parenta55ba50ce1f08d80962cac410ded386cfeaa682d (diff)
downloadqmmp-0910b79d3e3287886d9d0796c2c4c3ed822e97bc.tar.gz
qmmp-0910b79d3e3287886d9d0796c2c4c3ed822e97bc.tar.bz2
qmmp-0910b79d3e3287886d9d0796c2c4c3ed822e97bc.zip
added replay gain api
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1444 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/fileops')
0 files changed, 0 insertions, 0 deletions
02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> 2011-10-01 12:33:51 +0000 implemented converter settings, fixed build' href='/qmmp/commit/src/plugins/General/converter/converter.cpp?id=e3ab83869f4b74e485964720f941fed22ce035ea'>e3ab83869
9638e8ae7
489f0c707

6046e5ac1
9638e8ae7

489f0c707

c6cf7ca90





















9638e8ae7


db5b68f07





9638e8ae7

db5b68f07
9638e8ae7

db5b68f07
9638e8ae7










61cfbabec
cf5262c78





9638e8ae7














cf5262c78
9638e8ae7








cf5262c78
9638e8ae7




db5b68f07
9638e8ae7




db5b68f07












9638e8ae7

db5b68f07

b614c431e
e3ab83869
9638e8ae7


db5b68f07
9638e8ae7
e3ab83869
db5b68f07

e3ab83869


db5b68f07
e3ab83869
db5b68f07



e3ab83869

489f0c707
db5b68f07




b614c431e

e3ab83869
db5b68f07
831419a68















db5b68f07
b614c431e
c495f5b07


b614c431e
db5b68f07

b614c431e

9638e8ae7

cf5262c78









9638e8ae7
6046e5ac1
9638e8ae7

1be335756


9638e8ae7







c495f5b07
9638e8ae7


b614c431e
9638e8ae7






c495f5b07
cf5262c78
9638e8ae7
c495f5b07
9638e8ae7


c6cf7ca90
c495f5b07
b614c431e
9638e8ae7
db5b68f07









489f0c707
c495f5b07















489f0c707












6046e5ac1
d818f0b17
6046e5ac1





489f0c707

9638e8ae7
db5b68f07
9638e8ae7

c6cf7ca90
9638e8ae7

c6cf7ca90


9638e8ae7


c6cf7ca90

b614c431e

9638e8ae7








c6cf7ca90


















9638e8ae7










c6cf7ca90
b614c431e




9638e8ae7






db5b68f07







9638e8ae7


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
                                                                            
                                                                            














                                                                            
                                                                            



                                                                             
                           

                                    

                                     
                   

                           
                            

                      

                                                                                            





















                                                                        


                                                       





                                                                       

                              
                         

 
                                                                  










                                                         
                                                          





                                                                      














                                                                                                       
                              








                                                                                          
                              




                                     
                                      




                              












                                  

                     

                                        
                                                                 
 


                                                
                                                     
                                                        
                                               

                                                         


                                                                                   
                                                                     
         



                                                      

         
                                                                     




                                                                                                         

                                     
                                                                               
                                                                                   















                                                                                                          
                                                       
                                                       


                                                                                                          
 

                                                                                       

                         

                                                               









                                                                                                 
 
                                                                                 

                                                                   


                                                                                                   







                                                  
                                                                                                         


                                                       
                                                  






                                                                   
                                                           
                                                  
                           
                                                           


                     
                                                                 
                                                       
                                              
                       









                                                                                                        
 















                                                               












                                                                                      
 
                                                                   





                                                                                                      

             
     
                                         

 
                                                                    

                              


                                                                                             


                         

                                                                                                       

                         








                                                                                    


















                                                                                             










                                                                 
                                              




                                       






                                                                  







                             


                 
/***************************************************************************
 *   Copyright (C) 2011-2013 by Ilya Kotov                                 *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 ***************************************************************************/

#include <stdio.h>
#include <QStringList>
#include <QDesktopServices>
#include <qmmp/inputsourcefactory.h>
#include <qmmp/decoderfactory.h>
#include <qmmp/metadatamanager.h>
#include <qmmpui/metadataformatter.h>
#include <QtEndian>
#include <taglib/fileref.h>
#include <taglib/tag.h>
#include <taglib/mpegfile.h>
#include "converter.h"

#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8)

//static functions
static inline void s8_to_s16_2(qint8 *in, qint16 *out, qint64 samples)
{
    for(qint64 i = 0; i < samples; ++i)
        out[i] = in[i] << 8;
    return;
}

static inline void s24_to_s16_2(qint32 *in, qint16 *out, qint64 samples)
{
    for(qint64 i = 0; i < samples; ++i)
        out[i] = in[i] >> 8;
    return;
}

static inline void s32_to_s16_2(qint32 *in, qint16 *out, qint64 samples)
{
    for(qint64 i = 0; i < samples; ++i)
        out[i] = in[i] >> 16;
    return;
}

Converter::Converter(QObject *parent) : QThread(parent)
{}

Converter::~Converter()
{
    stop();
}

void Converter::add(const QStringList &urls, const QVariantMap &preset)
{
    foreach(QString url, urls)
        add(url, preset);
}

void Converter::add(const QString &url, const QVariantMap &preset)
{
    InputSource *source = InputSource::create(url, this);
    if(!source->initialize())
    {
        delete source;
        qWarning("Converter: Invalid url");
        return;
    }

    if(source->ioDevice())
    {
        if(!source->ioDevice()->open(QIODevice::ReadOnly))
        {
            source->deleteLater();
            qWarning("Converter: cannot open input stream, error: %s",
                     qPrintable(source->ioDevice()->errorString()));
            return;
        }
    }

    DecoderFactory *factory = 0;

    if(!source->url().contains("://"))
        factory = Decoder::findByPath(source->url());
    if(!factory)
        factory = Decoder::findByMime(source->contentType());
    if(!factory && source->ioDevice() && source->url().contains("://")) //ignore content of local files
        factory = Decoder::findByContent(source->ioDevice());
    if(!factory && source->url().contains("://"))
        factory = Decoder::findByProtocol(source->url().section("://",0,0));
    if(!factory)
    {
        qWarning("Converter: unsupported file format");
        source->deleteLater();
        return;
    }