aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/CommandLineOptions/IncDecVolumeOption
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2014-03-14 11:32:44 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2014-03-14 11:32:44 +0000
commit876f0db1fbde0d49685166583dc054ac869c0f72 (patch)
tree69b8858ef64d519381e63eea2395c198180dfcb7 /src/plugins/CommandLineOptions/IncDecVolumeOption
parentc36e23256030757d569b2dc563bfa97b82f23cf8 (diff)
downloadqmmp-876f0db1fbde0d49685166583dc054ac869c0f72.tar.gz
qmmp-876f0db1fbde0d49685166583dc054ac869c0f72.tar.bz2
qmmp-876f0db1fbde0d49685166583dc054ac869c0f72.zip
enabled sid plugin for win32 platform
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4166 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/CommandLineOptions/IncDecVolumeOption')
0 files changed, 0 insertions, 0 deletions
rialuser02@90c681e8-e032-0410-971d-27865f9a5e38> 2013-02-18 15:28:27 +0000 added opus plugin' href='/qmmp/commit/src/plugins/Input/opus/opusmetadatamodel.cpp?h=main&id=424a86e0a9492c745e575b3042840a381563221b'>424a86e0a
4190ca4ef

424a86e0a





4190ca4ef




424a86e0a




6bc7fa911
4190ca4ef
424a86e0a
4190ca4ef

424a86e0a
4190ca4ef



424a86e0a










4190ca4ef



424a86e0a







845322411
424a86e0a

































4190ca4ef
424a86e0a
4190ca4ef

424a86e0a


4190ca4ef
424a86e0a












845322411
424a86e0a
845322411
5ab2d1dfa



845322411
4190ca4ef
845322411
424a86e0a
845322411
424a86e0a
845322411
424a86e0a



845322411
424a86e0a







845322411
424a86e0a








845322411
424a86e0a








5ab2d1dfa


4190ca4ef


424a86e0a






424a86e0a
















4190ca4ef
424a86e0a
424a86e0a
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
                                                                            
                                                                            
                                                                            
















                                                                             
                   
                       


                               


                              


                                                                                                  

                                                                    





                                       




                      




                                                            
                                                          
                                   
     

                                                                                             
                                      



                                                                                                             










                                           



                                                  







                                                                            
                                                                                      

































                                                                                       
                                                                                                
 

                        


                                         
  












                                                           
                                                
                      
                                                 



                                                          
                                                                                  
                     
                                                
                       
                                                  
                     
                                                



                                                       
                                                                               







                                                         
                                                                                 








                                                                           
                                                 








                              


                                                  


                             






                               
















                                                 
              
                       
 
/***************************************************************************
 *   Copyright (C) 2013-2016 by Ilya Kotov                                 *
 *   forkotov02@ya.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 <QtGlobal>
#include <taglib/tag.h>
#include <taglib/fileref.h>
#include <taglib/opusfile.h>
#include <taglib/xiphcomment.h>
#include <taglib/tmap.h>
#include "opusmetadatamodel.h"

OpusMetaDataModel::OpusMetaDataModel(const QString &path, QObject *parent) : MetaDataModel(parent)
{
    m_path = path;
    m_file = new TagLib::Ogg::Opus::File(QStringToFileName(m_path));
    m_tags << new VorbisCommentModel(m_file);
}

OpusMetaDataModel::~OpusMetaDataModel()
{
    while(!m_tags.isEmpty())
        delete m_tags.takeFirst();
    if(m_file)
    {
        delete m_file;
        m_file = 0;
    }
}

QHash<QString, QString> OpusMetaDataModel::audioProperties()
{
    QHash<QString, QString> ap;
    TagLib::Ogg::Opus::File f (QStringToFileName(m_path));
    if(m_file && m_file->isValid())
    {
        QString text = QString("%1").arg(m_file->audioProperties()->length()/60);
        text +=":"+QString("%1").arg(m_file->audioProperties()->length()%60,2,10,QChar('0'));
        ap.insert(tr("Length"), text);
        ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(m_file->audioProperties()->sampleRate()));
        ap.insert(tr("Channels"), QString("%1").arg(m_file->audioProperties()->channels()));
        ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(m_file->audioProperties()->bitrate()));
        ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(m_file->length()/1024));
    }
    return ap;
}

QList<TagModel* > OpusMetaDataModel::tags()
{
    return m_tags;
}

QPixmap OpusMetaDataModel::cover()
{
    if(!m_file || !m_file->isValid())
        return QPixmap();

    TagLib::Ogg::XiphComment *tag = m_file->tag();
    if(!tag)
        return QPixmap();
    TagLib::StringList list = tag->fieldListMap()["METADATA_BLOCK_PICTURE"];
    if(list.isEmpty())
        return QPixmap();
    for(uint i = 0; i < list.size(); ++i)
    {
        TagLib::String value = list[i];
        QByteArray block = QByteArray::fromBase64(TStringToQString(value).toLatin1());
        if(block.size() < 32)
            continue;
        qint64 pos = 0;
        if(readPictureBlockField(block, pos) != 3) //picture type, use front cover only
            continue;
        pos += 4;
        int mimeLength = readPictureBlockField(block, pos); //mime type length
        pos += 4;
        pos += mimeLength; //skip mime type
        int descLength = readPictureBlockField(block, pos); //description length
        pos += 4;
        pos += descLength; //skip description
        pos += 4; //width
        pos += 4; //height
        pos += 4; //color depth
        pos += 4; //the number of colors used
        int length = readPictureBlockField(block, pos); //picture size
        pos += 4;
        QPixmap cover;
        cover.loadFromData(block.mid(pos, length)); //read binary picture data
        return cover;
    }
    return QPixmap();
}

ulong OpusMetaDataModel::readPictureBlockField(QByteArray data, int offset)
{
    return (((uchar)data.data()[offset] & 0xff) << 24) |
           (((uchar)data.data()[offset+1] & 0xff) << 16) |
           (((uchar)data.data()[offset+2] & 0xff) << 16) |
           ((uchar)data.data()[offset+3] & 0xff);

}

VorbisCommentModel::VorbisCommentModel(TagLib::Ogg::Opus::File *file) : TagModel(TagModel::Save)
{
    m_file = file;
    m_tag = file->tag();
}

VorbisCommentModel::~VorbisCommentModel()
{}

const QString VorbisCommentModel::name()