mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Patch from Allan to add support for compressed frames.
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@345351 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
cd50355a4c
commit
133f50e356
@ -1,3 +1,18 @@
|
||||
#AM_INIT_AUTOMAKE(taglib,1.0)
|
||||
dnl don't remove the below
|
||||
dnl AC_OUTPUT(taglib/taglib-config)
|
||||
|
||||
AC_DEFUN([AC_HAVE_ZLIB],
|
||||
[
|
||||
AC_DEFINE(HAVE_ZLIB, 1, [have zlib])
|
||||
have_zlib=true
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_NO_ZLIB],
|
||||
[
|
||||
AC_DEFINE(HAVE_ZLIB, 0, [have zlib])
|
||||
have_zlib=false
|
||||
])
|
||||
|
||||
AC_CHECK_HEADER(zlib.h, AC_HAVE_ZLIB, AC_NO_ZLIB)
|
||||
AM_CONDITIONAL(link_zlib, test x$have_zlib = xtrue)
|
||||
|
@ -1,4 +1,4 @@
|
||||
SUBDIRS = frames
|
||||
SUBDIRS = frames
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/taglib \
|
||||
-I$(top_srcdir)/taglib/toolkit \
|
||||
@ -11,13 +11,18 @@ noinst_LTLIBRARIES = libid3v2.la
|
||||
libid3v2_la_SOURCES = \
|
||||
id3v2framefactory.cpp id3v2synchdata.cpp id3v2tag.cpp \
|
||||
id3v2header.cpp id3v2frame.cpp id3v2footer.cpp \
|
||||
id3v2extendedheader.cpp
|
||||
id3v2extendedheader.cpp
|
||||
|
||||
taglib_include_HEADERS = \
|
||||
id3v2extendedheader.h id3v2frame.h id3v2header.h \
|
||||
id3v2synchdata.h id3v2footer.h id3v2framefactory.h id3v2tag.h
|
||||
|
||||
taglib_includedir = $(includedir)/taglib
|
||||
libid3v2_la_LIBADD = ./frames/libframes.la
|
||||
|
||||
if link_zlib
|
||||
zlib = -lz
|
||||
endif
|
||||
|
||||
libid3v2_la_LIBADD = ./frames/libframes.la $(zlib)
|
||||
|
||||
EXTRA_DIST = $(libid3v2_la_SOURCES) $(taglib_include_HEADERS) id3v2.4.0-frames.txt id3v2.4.0-structure.txt
|
||||
|
@ -19,8 +19,14 @@
|
||||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#if HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "id3v2frame.h"
|
||||
@ -156,12 +162,26 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const
|
||||
uint frameDataOffset = headerSize;
|
||||
uint frameDataLength = size();
|
||||
|
||||
if(d->header->dataLengthIndicator()) {
|
||||
if(d->header->compression() || d->header->dataLengthIndicator()) {
|
||||
frameDataLength = frameData.mid(headerSize, 4).toUInt();
|
||||
frameDataOffset += 4;
|
||||
}
|
||||
|
||||
return frameData.mid(frameDataOffset, frameDataLength);
|
||||
#if HAVE_ZLIB
|
||||
if(d->header->compression()) {
|
||||
ByteVector data(frameDataLength);
|
||||
uLongf uLongTmp = frameDataLength;
|
||||
::uncompress((Bytef *) data.data(),
|
||||
(uLongf *) &uLongTmp,
|
||||
(Bytef *) frameData.data() + frameDataOffset,
|
||||
size());
|
||||
return data;
|
||||
#else
|
||||
return frameData.mid(frameDataOffset, frameDataLength);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return frameData.mid(frameDataOffset, frameDataLength);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -258,7 +278,7 @@ void Frame::Header::setData(const ByteVector &data, uint version)
|
||||
case 1:
|
||||
case 2:
|
||||
{
|
||||
// ID3v2.2
|
||||
// ID3v2.2
|
||||
|
||||
if(data.size() < 3) {
|
||||
debug("You must at least specify a frame ID.");
|
||||
|
@ -19,6 +19,8 @@
|
||||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "id3v2framefactory.h"
|
||||
@ -66,16 +68,18 @@ Frame *FrameFactory::createFrame(const ByteVector &data, uint version) const
|
||||
{
|
||||
Frame::Header *header = new Frame::Header(data, version);
|
||||
|
||||
// TagLib doesn't mess with encrypted or compressed frames, so just treat them
|
||||
// TagLib doesn't mess with encrypted frames, so just treat them
|
||||
// as unknown frames.
|
||||
|
||||
#if HAVE_ZLIB == 0
|
||||
if(header->compression()) {
|
||||
debug("Compressed frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
debug("Compressed frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
}
|
||||
#endif
|
||||
if(header->encryption()) {
|
||||
debug("Entrypted frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
debug("Encrypted frames are currently not supported.");
|
||||
return new UnknownFrame(data, header);
|
||||
}
|
||||
|
||||
TagLib::ByteVector frameID = header->frameID();
|
||||
@ -84,7 +88,7 @@ Frame *FrameFactory::createFrame(const ByteVector &data, uint version) const
|
||||
// characters. Also make sure that there is data in the frame.
|
||||
|
||||
if(!frameID.size() == (version < 3 ? 3 : 4) || header->frameSize() <= 0)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
for(ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) {
|
||||
if( (*it < 'A' || *it > 'Z') && (*it < '1' || *it > '9') ) {
|
||||
|
Loading…
Reference in New Issue
Block a user