本文整理汇总了C++中taglib::ByteVector::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ ByteVector::mid方法的具体用法?C++ ByteVector::mid怎么用?C++ ByteVector::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::ByteVector
的用法示例。
在下文中一共展示了ByteVector::mid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractAPE
/*
** Extracts cover art embedded in APE tags.
**
*/
bool CCover::ExtractAPE(TagLib::APE::Tag* tag, const std::wstring& target)
{
const TagLib::APE::ItemListMap& listMap = tag->itemListMap();
if (listMap.contains("COVER ART (FRONT)"))
{
const TagLib::ByteVector nullStringTerminator(1, 0);
TagLib::ByteVector item = listMap["COVER ART (FRONT)"].value();
int pos = item.find(nullStringTerminator); // Skip the filename
if (++pos > 0)
{
const TagLib::ByteVector& pic = item.mid(pos);
return WriteCover(pic, target);
}
}
return false;
}
示例2: ExtractAPE
/*
** Extracts cover art embedded in APE tags.
**
*/
bool QCoverArt::ExtractAPE(TagLib::APE::Tag* tag)
{
const TagLib::APE::ItemListMap& listMap = tag->itemListMap();
if (listMap.contains("COVER ART (FRONT)"))
{
const TagLib::ByteVector nullStringTerminator(1, 0);
TagLib::ByteVector item = listMap["COVER ART (FRONT)"].value();
int pos = item.find(nullStringTerminator); // Skip the filename
if (++pos > 0)
{
const TagLib::ByteVector& pic = item.mid(pos);
img.loadFromData((const unsigned char*)pic.data(), pic.size());
return true;
}
}
return false;
}
示例3: desc
static Meta::ReplayGainTagMap readID3v2Tags( TagLib::ID3v2::Tag *tag )
{
Meta::ReplayGainTagMap map;
{ // ID3v2.4.0 native replay gain tag support (as written by Quod Libet, for example).
TagLib::ID3v2::FrameList frames = tag->frameListMap()["RVA2"];
frames.append(tag->frameListMap()["XRVA"]);
if ( !frames.isEmpty() )
{
for ( unsigned int i = 0; i < frames.size(); ++i )
{
// we have to parse this frame ourselves
// ID3v2 frame header is 10 bytes, so skip that
TagLib::ByteVector data = frames[i]->render().mid( 10 );
unsigned int offset = 0;
QString desc( data.data() );
offset += desc.count() + 1;
unsigned int channel = data.mid( offset, 1 ).toUInt( true );
// channel 1 is the main volume - the only one we care about
if ( channel == 1 )
{
++offset;
qint16 adjustment512 = data.mid( offset, 2 ).toShort( true );
qreal adjustment = ( (qreal)adjustment512 ) / 512.0;
offset += 2;
unsigned int peakBits = data.mid( offset, 1 ).toUInt( true );
++offset;
bool ok = false;
qreal peak = readRVA2PeakValue( data.mid( offset ), peakBits, &ok );
if ( ok )
{
if ( desc.toLower() == "album" )
{
map[Meta::ReplayGain_Album_Gain] = adjustment;
map[Meta::ReplayGain_Album_Peak] = peakToDecibels( peak );
}
else if ( desc.toLower() == "track" || !map.contains( Meta::ReplayGain_Track_Gain ) )
{
map[Meta::ReplayGain_Track_Gain] = adjustment;
map[Meta::ReplayGain_Track_Peak] = peakToDecibels( peak );
}
}
}
}
if ( !map.isEmpty() )
return map;
}
}
{ // Foobar2000-style ID3v2.3.0 tags
TagLib::ID3v2::FrameList frames = tag->frameListMap()["TXXX"];
for ( TagLib::ID3v2::FrameList::Iterator it = frames.begin(); it != frames.end(); ++it ) {
TagLib::ID3v2::UserTextIdentificationFrame* frame =
dynamic_cast<TagLib::ID3v2::UserTextIdentificationFrame*>( *it );
if ( frame && frame->fieldList().size() >= 2 )
{
QString desc = TStringToQString( frame->description() ).toLower();
if ( desc == "replaygain_album_gain" )
maybeAddGain( frame->fieldList()[1], Meta::ReplayGain_Album_Gain, &map );
if ( desc == "replaygain_album_peak" )
maybeAddPeak( frame->fieldList()[1], Meta::ReplayGain_Album_Peak, &map );
if ( desc == "replaygain_track_gain" )
maybeAddGain( frame->fieldList()[1], Meta::ReplayGain_Track_Gain, &map );
if ( desc == "replaygain_track_peak" )
maybeAddPeak( frame->fieldList()[1], Meta::ReplayGain_Track_Peak, &map );
}
}
}
return map;
}