mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Merge branch 'master' into taglib2
Conflicts: bindings/c/tag_c.cpp taglib/fileref.cpp taglib/toolkit/tbytevector.cpp taglib/toolkit/tstring.cpp
This commit is contained in:
commit
2316a9661a
@ -21,6 +21,7 @@ option(BUILD_EXAMPLES "Build the examples" OFF)
|
||||
|
||||
option(NO_ITUNES_HACKS "Disable workarounds for iTunes bugs" OFF)
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
set(TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
|
||||
|
||||
## the following are directories where stuff will be installed to
|
||||
|
@ -19,7 +19,6 @@
|
||||
* USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <fileref.h>
|
||||
#include <tfile.h>
|
||||
|
@ -23,7 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "asfproperties.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tpropertymap.h>
|
||||
#include "asftag.h"
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "taglib_config.h"
|
||||
|
||||
#include "tfile.h"
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include "mp4file.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "taglib_config.h"
|
||||
#include <tdebug.h>
|
||||
#include <tstring.h>
|
||||
#include <tpropertymap.h>
|
||||
|
@ -23,8 +23,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "taglib_config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
|
@ -23,8 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "taglib_config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <tdebug.h>
|
||||
|
||||
#include "id3v2framefactory.h"
|
||||
|
@ -23,6 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <tfile.h>
|
||||
|
||||
#include "id3v2tag.h"
|
||||
|
@ -23,7 +23,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
@ -31,19 +33,11 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(HAVE_MSC_BYTESWAP)
|
||||
# include <stdlib.h>
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# include <byteswap.h>
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
#include "tsmartptr.h"
|
||||
#include "tutils.h"
|
||||
|
||||
#include "tbytevector.h"
|
||||
|
||||
// This is a bit ugly to keep writing over and over again.
|
||||
@ -189,113 +183,6 @@ size_t findVector(
|
||||
return ByteVector::npos;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T byteSwap(T x)
|
||||
{
|
||||
// There should be 16,32 and 64-bit versions.
|
||||
debug("byteSwap<T>() -- Non specialized version should not be called");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline ushort byteSwap<ushort>(ushort x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_16)
|
||||
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_16(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt16(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap16(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
inline uint byteSwap<uint>(uint x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_32)
|
||||
|
||||
return __builtin_bswap32(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ulong(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_32(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt32(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap32(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x & 0xff000000u) >> 24)
|
||||
| ((x & 0x00ff0000u) >> 8)
|
||||
| ((x & 0x0000ff00u) << 8)
|
||||
| ((x & 0x000000ffu) << 24);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
inline ulonglong byteSwap<ulonglong>(ulonglong x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_64)
|
||||
|
||||
return __builtin_bswap64(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_uint64(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_64(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt64(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap64(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x & 0xff00000000000000ull) >> 56)
|
||||
| ((x & 0x00ff000000000000ull) >> 40)
|
||||
| ((x & 0x0000ff0000000000ull) >> 24)
|
||||
| ((x & 0x000000ff00000000ull) >> 8)
|
||||
| ((x & 0x00000000ff000000ull) << 8)
|
||||
| ((x & 0x0000000000ff0000ull) << 24)
|
||||
| ((x & 0x000000000000ff00ull) << 40)
|
||||
| ((x & 0x00000000000000ffull) << 56);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
enum Endianness {
|
||||
@ -320,7 +207,7 @@ inline T toNumber(const ByteVector &v, size_t offset)
|
||||
::memcpy(&tmp, v.data() + offset, sizeof(T));
|
||||
|
||||
if(swap)
|
||||
return byteSwap<T>(tmp);
|
||||
return byteSwap(tmp);
|
||||
else
|
||||
return tmp;
|
||||
}
|
||||
@ -352,7 +239,7 @@ inline ByteVector fromNumber(T value)
|
||||
#endif
|
||||
|
||||
if(swap)
|
||||
value = byteSwap<T>(value);
|
||||
value = byteSwap(value);
|
||||
|
||||
return ByteVector(reinterpret_cast<const char *>(&value), sizeof(T));
|
||||
}
|
||||
@ -839,7 +726,7 @@ float ByteVector::toFloat32BE(size_t offset) const
|
||||
::memcpy(&tmp, data() + offset, 4);
|
||||
|
||||
# if SYSTEM_BYTEORDER == 1
|
||||
tmp.i = byteSwap<uint>(tmp.i);
|
||||
tmp.i = byteSwap(tmp.i);
|
||||
# endif
|
||||
|
||||
return tmp.f;
|
||||
@ -900,7 +787,7 @@ double ByteVector::toFloat64BE(size_t offset) const
|
||||
::memcpy(&tmp, data() + offset, 8);
|
||||
|
||||
# if SYSTEM_BYTEORDER == 1
|
||||
tmp.i = byteSwap<ulonglong>(tmp.i);
|
||||
tmp.i = byteSwap(tmp.i);
|
||||
# endif
|
||||
|
||||
return tmp.f;
|
||||
|
@ -23,7 +23,9 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "tdebug.h"
|
||||
#include "tstring.h"
|
||||
|
@ -23,7 +23,10 @@
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "trefcounter.h"
|
||||
|
||||
#if defined(HAVE_STD_ATOMIC)
|
||||
|
@ -25,27 +25,20 @@
|
||||
|
||||
// This class assumes that std::basic_string<T> has a contiguous and null-terminated buffer.
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "tstring.h"
|
||||
#include "tdebug.h"
|
||||
#include "tstringlist.h"
|
||||
#include "tsmartptr.h"
|
||||
#include "tutils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(HAVE_MSC_BYTESWAP)
|
||||
# include <stdlib.h>
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# include <byteswap.h>
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STD_CODECVT
|
||||
# include <codecvt>
|
||||
#else
|
||||
@ -54,34 +47,6 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
inline TagLib::ushort byteSwap(TagLib::ushort x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_16)
|
||||
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_16(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt16(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap16(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned short combine(unsigned char c1, unsigned char c2)
|
||||
{
|
||||
|
151
taglib/toolkit/tutils.h
Normal file
151
taglib/toolkit/tutils.h
Normal file
@ -0,0 +1,151 @@
|
||||
/***************************************************************************
|
||||
copyright : (C) 2013 by Tsuda Kageyu
|
||||
email : tsuda.kageyu@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* This library is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License version *
|
||||
* 2.1 as published by the Free Software Foundation. *
|
||||
* *
|
||||
* This library 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 *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
|
||||
* 02110-1301 USA *
|
||||
* *
|
||||
* Alternatively, this file is available under the Mozilla Public *
|
||||
* License Version 1.1. You may obtain a copy of the License at *
|
||||
* http://www.mozilla.org/MPL/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TAGLIB_TUTILS_H
|
||||
#define TAGLIB_TUTILS_H
|
||||
|
||||
// THIS FILE IS NOT A PART OF THE TAGLIB API
|
||||
|
||||
#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MSC_BYTESWAP)
|
||||
# include <stdlib.h>
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
# include <byteswap.h>
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
namespace TagLib
|
||||
{
|
||||
|
||||
inline ushort byteSwap(ushort x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_16)
|
||||
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_16(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt16(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap16(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x >> 8) & 0xff) | ((x & 0xff) << 8);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint byteSwap(uint x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_32)
|
||||
|
||||
return __builtin_bswap32(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_ulong(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_32(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt32(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap32(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x & 0xff000000u) >> 24)
|
||||
| ((x & 0x00ff0000u) >> 8)
|
||||
| ((x & 0x0000ff00u) << 8)
|
||||
| ((x & 0x000000ffu) << 24);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline ulonglong byteSwap(ulonglong x)
|
||||
{
|
||||
#if defined(HAVE_GCC_BYTESWAP_64)
|
||||
|
||||
return __builtin_bswap64(x);
|
||||
|
||||
#elif defined(HAVE_MSC_BYTESWAP)
|
||||
|
||||
return _byteswap_uint64(x);
|
||||
|
||||
#elif defined(HAVE_GLIBC_BYTESWAP)
|
||||
|
||||
return __bswap_64(x);
|
||||
|
||||
#elif defined(HAVE_MAC_BYTESWAP)
|
||||
|
||||
return OSSwapInt64(x);
|
||||
|
||||
#elif defined(HAVE_OPENBSD_BYTESWAP)
|
||||
|
||||
return swap64(x);
|
||||
|
||||
#else
|
||||
|
||||
return ((x & 0xff00000000000000ull) >> 56)
|
||||
| ((x & 0x00ff000000000000ull) >> 40)
|
||||
| ((x & 0x0000ff0000000000ull) >> 24)
|
||||
| ((x & 0x000000ff00000000ull) >> 8)
|
||||
| ((x & 0x00000000ff000000ull) << 8)
|
||||
| ((x & 0x0000000000ff0000ull) << 24)
|
||||
| ((x & 0x000000000000ff00ull) << 40)
|
||||
| ((x & 0x00000000000000ffull) << 56);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,6 +1,9 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <config.h>
|
||||
// so evil :(
|
||||
#define protected public
|
||||
#include <id3v2tag.h>
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user