Added FLAC::Properties::signature()

BUG:160172


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1148630 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Lukáš Lalinský
2010-07-11 10:26:35 +00:00
parent 1d10bde500
commit 7426a64d2b
7 changed files with 53 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public:
int sampleRate;
int sampleWidth;
int channels;
ByteVector signature;
};
////////////////////////////////////////////////////////////////////////////////
@ -100,6 +101,11 @@ int FLAC::Properties::channels() const
return d->channels;
}
ByteVector FLAC::Properties::signature() const
{
return d->signature;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
@ -147,4 +153,6 @@ void FLAC::Properties::read()
// Real bitrate:
d->bitrate = d->length > 0 ? ((d->streamLength * 8UL) / d->length) / 1000 : 0;
d->signature = d->data.mid(pos, 32);
}

View File

@ -77,6 +77,12 @@ namespace TagLib {
*/
int sampleWidth() const;
/*!
* Returns the MD5 signature of the uncompressed audio stream as read
* from the stream info header header.
*/
ByteVector signature() const;
private:
Properties(const Properties &);
Properties &operator=(const Properties &);

View File

@ -42,6 +42,8 @@
#define DATA(x) (&(x->data[0]))
namespace TagLib {
static const char hexTable[17] = "0123456789abcdef";
static const uint crcTable[256] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
@ -653,6 +655,20 @@ ByteVector &ByteVector::operator=(const char *data)
return *this;
}
ByteVector ByteVector::toHex() const
{
ByteVector encoded(size() * 2);
uint j = 0;
for(uint i = 0; i < size(); i++) {
unsigned char c = d->data[i];
encoded[j++] = hexTable[(c >> 4) & 0x0F];
encoded[j++] = hexTable[(c ) & 0x0F];
}
return encoded;
}
////////////////////////////////////////////////////////////////////////////////
// protected members
////////////////////////////////////////////////////////////////////////////////

View File

@ -385,6 +385,11 @@ namespace TagLib {
*/
static ByteVector null;
/*!
* Returns a hex-encoded copy of the byte vector.
*/
ByteVector toHex() const;
protected:
/*
* If this ByteVector is being shared via implicit sharing, do a deep copy