From ceb142c9bded9f0803d79658403f368dd3d60fae Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sat, 8 Jul 2023 12:33:37 +0200 Subject: [PATCH] Remove functions documented (but not marked) as deprecated Clean up other stuff with comments about binary incompatibility, but only as far as to mostly keep source compatibility. --- taglib/ape/apeitem.cpp | 7 -- taglib/ape/apeitem.h | 6 -- taglib/ape/apeproperties.cpp | 5 - taglib/ape/apeproperties.h | 12 +-- taglib/asf/asfproperties.cpp | 10 -- taglib/asf/asfproperties.h | 15 +-- taglib/asf/asftag.h | 4 +- taglib/audioproperties.cpp | 25 +++++ taglib/audioproperties.h | 18 +++- taglib/fileref.h | 1 + taglib/flac/flacfile.h | 3 +- taglib/flac/flacproperties.cpp | 14 +-- taglib/flac/flacproperties.h | 22 +--- taglib/it/itfile.cpp | 10 -- taglib/it/itfile.h | 12 --- taglib/it/itproperties.cpp | 25 ----- taglib/it/itproperties.h | 5 - taglib/mod/modproperties.cpp | 15 --- taglib/mod/modproperties.h | 3 - taglib/mp4/mp4properties.cpp | 6 -- taglib/mp4/mp4properties.h | 12 +-- taglib/mpc/mpcproperties.cpp | 12 --- taglib/mpc/mpcproperties.h | 20 +--- taglib/mpeg/id3v2/frames/chapterframe.h | 2 +- taglib/mpeg/id3v2/frames/commentsframe.h | 2 +- taglib/mpeg/id3v2/frames/podcastframe.h | 2 +- .../mpeg/id3v2/frames/relativevolumeframe.cpp | 30 ------ .../mpeg/id3v2/frames/relativevolumeframe.h | 33 ------ .../mpeg/id3v2/frames/tableofcontentsframe.h | 2 +- .../id3v2/frames/textidentificationframe.h | 4 +- .../id3v2/frames/uniquefileidentifierframe.h | 2 +- .../id3v2/frames/unsynchronizedlyricsframe.h | 2 +- taglib/mpeg/id3v2/frames/urllinkframe.h | 4 +- taglib/mpeg/id3v2/id3v2frame.cpp | 64 ++--------- taglib/mpeg/id3v2/id3v2frame.h | 53 +--------- taglib/mpeg/id3v2/id3v2framefactory.cpp | 9 +- taglib/mpeg/id3v2/id3v2framefactory.h | 11 +- taglib/mpeg/id3v2/id3v2tag.cpp | 6 +- taglib/mpeg/mpegfile.cpp | 5 - taglib/mpeg/mpegfile.h | 19 +--- taglib/mpeg/mpegproperties.cpp | 5 - taglib/mpeg/mpegproperties.h | 12 +-- taglib/ogg/oggpage.cpp | 65 +++++++++++- taglib/ogg/opus/opusproperties.cpp | 5 - taglib/ogg/opus/opusproperties.h | 12 +-- taglib/ogg/speex/speexproperties.cpp | 5 - taglib/ogg/speex/speexproperties.h | 12 +-- taglib/ogg/vorbis/vorbisfile.h | 4 + taglib/ogg/vorbis/vorbisproperties.cpp | 5 - taglib/ogg/vorbis/vorbisproperties.h | 18 ++-- taglib/ogg/xiphcomment.cpp | 5 - taglib/ogg/xiphcomment.h | 7 +- taglib/riff/aiff/aiffproperties.cpp | 5 - taglib/riff/aiff/aiffproperties.h | 12 +-- taglib/riff/wav/wavproperties.cpp | 5 - taglib/riff/wav/wavproperties.h | 12 +-- taglib/s3m/s3mproperties.cpp | 25 ----- taglib/s3m/s3mproperties.h | 5 - taglib/tag.h | 9 +- taglib/tagunion.cpp | 41 +------ taglib/tagunion.h | 4 +- taglib/toolkit/tbytevector.cpp | 54 ---------- taglib/toolkit/tbytevector.h | 8 -- taglib/toolkit/tbytevectorlist.cpp | 6 -- taglib/toolkit/tbytevectorlist.h | 9 +- taglib/toolkit/tfile.cpp | 100 +----------------- taglib/toolkit/tfile.h | 9 +- taglib/toolkit/tlist.tcc | 3 +- taglib/toolkit/tmap.tcc | 9 +- taglib/toolkit/trefcounter.h | 34 ------ taglib/toolkit/tstring.cpp | 5 - taglib/toolkit/tstring.h | 11 +- taglib/trueaudio/trueaudioproperties.h | 6 +- taglib/wavpack/wavpackproperties.cpp | 5 - taglib/wavpack/wavpackproperties.h | 12 +-- taglib/xm/xmproperties.cpp | 25 ----- taglib/xm/xmproperties.h | 5 - tests/test_apetag.cpp | 7 +- 78 files changed, 187 insertions(+), 906 deletions(-) diff --git a/taglib/ape/apeitem.cpp b/taglib/ape/apeitem.cpp index 341da34b..40b2db37 100644 --- a/taglib/ape/apeitem.cpp +++ b/taglib/ape/apeitem.cpp @@ -54,13 +54,6 @@ APE::Item::Item() : { } -APE::Item::Item(const String &key, const String &value) : - d(new ItemPrivate()) -{ - d->key = key; - d->text.append(value); -} - APE::Item::Item(const String &key, const StringList &values) : d(new ItemPrivate()) { diff --git a/taglib/ape/apeitem.h b/taglib/ape/apeitem.h index 2445b506..fe69aefd 100644 --- a/taglib/ape/apeitem.h +++ b/taglib/ape/apeitem.h @@ -56,12 +56,6 @@ namespace TagLib { */ Item(); - /*! - * Constructs a text item with \a key and \a value. - */ - // BIC: Remove this, StringList has a constructor from a single string - Item(const String &key, const String &value); - /*! * Constructs a text item with \a key and \a values. */ diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp index f9e16a71..5256a5f3 100644 --- a/taglib/ape/apeproperties.cpp +++ b/taglib/ape/apeproperties.cpp @@ -75,11 +75,6 @@ APE::Properties::~Properties() delete d; } -int APE::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int APE::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/ape/apeproperties.h b/taglib/ape/apeproperties.h index 230b10d6..2fd05038 100644 --- a/taglib/ape/apeproperties.h +++ b/taglib/ape/apeproperties.h @@ -61,22 +61,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/asf/asfproperties.cpp b/taglib/asf/asfproperties.cpp index 11eab17e..20aa2974 100644 --- a/taglib/asf/asfproperties.cpp +++ b/taglib/asf/asfproperties.cpp @@ -67,11 +67,6 @@ ASF::Properties::~Properties() delete d; } -int ASF::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int ASF::Properties::lengthInMilliseconds() const { return d->length; @@ -121,11 +116,6 @@ bool ASF::Properties::isEncrypted() const // private members //////////////////////////////////////////////////////////////////////////////// -void ASF::Properties::setLength(int /*length*/) -{ - debug("ASF::Properties::setLength() -- This method is deprecated. Do not use."); -} - void ASF::Properties::setLengthInMilliseconds(int value) { d->length = value; diff --git a/taglib/asf/asfproperties.h b/taglib/asf/asfproperties.h index 9cc5c609..51f4b9b3 100644 --- a/taglib/asf/asfproperties.h +++ b/taglib/asf/asfproperties.h @@ -78,22 +78,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. @@ -148,9 +138,6 @@ namespace TagLib { bool isEncrypted() const; #ifndef DO_NOT_DOCUMENT - // deprecated - void setLength(int value); - void setLengthInMilliseconds(int value); void setBitrate(int value); void setSampleRate(int value); diff --git a/taglib/asf/asftag.h b/taglib/asf/asftag.h index 7f2e355a..297ea6de 100644 --- a/taglib/asf/asftag.h +++ b/taglib/asf/asftag.h @@ -152,7 +152,8 @@ namespace TagLib { virtual bool isEmpty() const; /*! - * \deprecated Use attributeListMap() const, contains(), removeItem(), + * \warning You should not modify this data structure directly, instead + * use attributeListMap() const, contains(), removeItem(), * attribute(), setAttribute(), addAttribute(). */ AttributeListMap &attributeListMap(); @@ -161,7 +162,6 @@ namespace TagLib { * Returns a reference to the item list map. This is an AttributeListMap of * all of the items in the tag. */ - // BIC: return by value const AttributeListMap &attributeListMap() const; /*! diff --git a/taglib/audioproperties.cpp b/taglib/audioproperties.cpp index 70a876ae..a47a5d1e 100644 --- a/taglib/audioproperties.cpp +++ b/taglib/audioproperties.cpp @@ -41,6 +41,31 @@ AudioProperties::~AudioProperties() } +int AudioProperties::length() const +{ + return lengthInSeconds(); +} + +int AudioProperties::lengthInSeconds() const +{ + return lengthInMilliseconds() / 1000; +} + +int AudioProperties::lengthInMilliseconds() const +{ + return 0; +} + +int AudioProperties::bitrate() const +{ + return 0; +} + +int AudioProperties::sampleRate() const +{ + return 0; +} + //////////////////////////////////////////////////////////////////////////////// // protected methods //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/audioproperties.h b/taglib/audioproperties.h index f23ae542..4b91b144 100644 --- a/taglib/audioproperties.h +++ b/taglib/audioproperties.h @@ -64,32 +64,42 @@ namespace TagLib { */ virtual ~AudioProperties(); + /*! + * Returns the length of the file in seconds. The length is rounded down to + * the nearest whole second. + * + * \note This method is just an alias of lengthInSeconds(). + * + * \deprecated Use lengthInSeconds(). + */ + virtual int length() const; + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. * * \see lengthInMilliseconds() */ - virtual int lengthInSeconds() const = 0; + virtual int lengthInSeconds() const; /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - virtual int lengthInMilliseconds() const = 0; + virtual int lengthInMilliseconds() const; /*! * Returns the most appropriate bit rate for the file in kb/s. For constant * bitrate formats this is simply the bitrate of the file. For variable * bitrate formats this is either the average or nominal bitrate. */ - virtual int bitrate() const = 0; + virtual int bitrate() const; /*! * Returns the sample rate in Hz. */ - virtual int sampleRate() const = 0; + virtual int sampleRate() const; /*! * Returns the number of audio channels. diff --git a/taglib/fileref.h b/taglib/fileref.h index dd4e61da..0f04b38a 100644 --- a/taglib/fileref.h +++ b/taglib/fileref.h @@ -288,6 +288,7 @@ namespace TagLib { * * \deprecated Use FileRef(FileName, bool, AudioProperties::ReadStyle). */ + // Kept because it is used for the C bindings static File *create(FileName fileName, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average); diff --git a/taglib/flac/flacfile.h b/taglib/flac/flacfile.h index a667a01c..bd553555 100644 --- a/taglib/flac/flacfile.h +++ b/taglib/flac/flacfile.h @@ -104,7 +104,7 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor + // BIC: merge with the above constructor, kept for source compatibility File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average); @@ -121,7 +121,6 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average); diff --git a/taglib/flac/flacproperties.cpp b/taglib/flac/flacproperties.cpp index c864072e..c494211c 100644 --- a/taglib/flac/flacproperties.cpp +++ b/taglib/flac/flacproperties.cpp @@ -55,30 +55,18 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -FLAC::Properties::Properties(ByteVector data, offset_t streamLength, ReadStyle style) : +FLAC::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) : AudioProperties(style), d(new PropertiesPrivate()) { read(data, streamLength); } -FLAC::Properties::Properties(File *, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ - debug("FLAC::Properties::Properties() - This constructor is no longer used."); -} - FLAC::Properties::~Properties() { delete d; } -int FLAC::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int FLAC::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/flac/flacproperties.h b/taglib/flac/flacproperties.h index f620184b..442da6ea 100644 --- a/taglib/flac/flacproperties.h +++ b/taglib/flac/flacproperties.h @@ -50,37 +50,19 @@ namespace TagLib { * Create an instance of FLAC::Properties with the data read from the * ByteVector \a data. */ - // BIC: switch to const reference - Properties(ByteVector data, offset_t streamLength, ReadStyle style = Average); - - /*! - * Create an instance of FLAC::Properties with the data read from the - * FLAC::File \a file. - */ - // BIC: remove - Properties(File *file, ReadStyle style = Average); + Properties(const ByteVector &data, offset_t streamLength, ReadStyle style = Average); /*! * Destroys this FLAC::Properties instance. */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index ace324ff..81f7a60f 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -73,16 +73,6 @@ Mod::Tag *IT::File::tag() const return &d->tag; } -PropertyMap IT::File::properties() const -{ - return d->tag.properties(); -} - -PropertyMap IT::File::setProperties(const PropertyMap &properties) -{ - return d->tag.setProperties(properties); -} - IT::Properties *IT::File::audioProperties() const { return &d->properties; diff --git a/taglib/it/itfile.h b/taglib/it/itfile.h index 29e575f7..1691a181 100644 --- a/taglib/it/itfile.h +++ b/taglib/it/itfile.h @@ -67,18 +67,6 @@ namespace TagLib { Mod::Tag *tag() const; - /*! - * Forwards to Mod::Tag::properties(). - * BIC: will be removed once File::toDict() is made virtual - */ - PropertyMap properties() const; - - /*! - * Forwards to Mod::Tag::setProperties(). - * BIC: will be removed once File::setProperties() is made virtual - */ - PropertyMap setProperties(const PropertyMap &); - /*! * Returns the IT::Properties for this file. If no audio properties * were read then this will return a null pointer. diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index c317b660..23b224ac 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -79,31 +79,6 @@ IT::Properties::~Properties() delete d; } -int IT::Properties::length() const -{ - return 0; -} - -int IT::Properties::lengthInSeconds() const -{ - return 0; -} - -int IT::Properties::lengthInMilliseconds() const -{ - return 0; -} - -int IT::Properties::bitrate() const -{ - return 0; -} - -int IT::Properties::sampleRate() const -{ - return 0; -} - int IT::Properties::channels() const { return d->channels; diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index d4bce6de..58f9361e 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -55,11 +55,6 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; int channels() const; unsigned short lengthInPatterns() const; diff --git a/taglib/mod/modproperties.cpp b/taglib/mod/modproperties.cpp index c6bf3947..05b2ddcf 100644 --- a/taglib/mod/modproperties.cpp +++ b/taglib/mod/modproperties.cpp @@ -55,21 +55,6 @@ Mod::Properties::~Properties() delete d; } -int Mod::Properties::length() const -{ - return 0; -} - -int Mod::Properties::lengthInSeconds() const -{ - return 0; -} - -int Mod::Properties::lengthInMilliseconds() const -{ - return 0; -} - int Mod::Properties::bitrate() const { return 0; diff --git a/taglib/mod/modproperties.h b/taglib/mod/modproperties.h index 51bd924b..5825e3bf 100644 --- a/taglib/mod/modproperties.h +++ b/taglib/mod/modproperties.h @@ -37,9 +37,6 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; int bitrate() const; int sampleRate() const; int channels() const; diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 38814944..b24cfe24 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -101,12 +101,6 @@ MP4::Properties::sampleRate() const return d->sampleRate; } -int -MP4::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int MP4::Properties::lengthInMilliseconds() const { diff --git a/taglib/mp4/mp4properties.h b/taglib/mp4/mp4properties.h index decb3618..0f9c349e 100644 --- a/taglib/mp4/mp4properties.h +++ b/taglib/mp4/mp4properties.h @@ -47,22 +47,12 @@ namespace TagLib { Properties(File *file, Atoms *atoms, ReadStyle style = Average); virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 4ccb5812..6ddf9a35 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -66,13 +66,6 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -MPC::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) : - AudioProperties(style), - d(new PropertiesPrivate()) -{ - readSV7(data, streamLength); -} - MPC::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) : AudioProperties(style), d(new PropertiesPrivate()) @@ -93,11 +86,6 @@ MPC::Properties::~Properties() delete d; } -int MPC::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int MPC::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/mpc/mpcproperties.h b/taglib/mpc/mpcproperties.h index cca2fb5c..452413b8 100644 --- a/taglib/mpc/mpcproperties.h +++ b/taglib/mpc/mpcproperties.h @@ -48,14 +48,6 @@ namespace TagLib { class TAGLIB_EXPORT Properties : public AudioProperties { public: - /*! - * Create an instance of MPC::Properties with the data read from the - * ByteVector \a data. - * - * This constructor is deprecated. It only works for MPC version up to 7. - */ - Properties(const ByteVector &data, offset_t streamLength, ReadStyle style = Average); - /*! * Create an instance of MPC::Properties with the data read directly * from a MPC::File. @@ -67,22 +59,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/mpeg/id3v2/frames/chapterframe.h b/taglib/mpeg/id3v2/frames/chapterframe.h index 90c3fc79..08b11911 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.h +++ b/taglib/mpeg/id3v2/frames/chapterframe.h @@ -220,7 +220,7 @@ namespace TagLib { virtual String toString() const; - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * CHAP frames each have a unique element ID. This searches for a CHAP diff --git a/taglib/mpeg/id3v2/frames/commentsframe.h b/taglib/mpeg/id3v2/frames/commentsframe.h index e29f8eb1..74c7ff48 100644 --- a/taglib/mpeg/id3v2/frames/commentsframe.h +++ b/taglib/mpeg/id3v2/frames/commentsframe.h @@ -145,7 +145,7 @@ namespace TagLib { * - otherwise, the key will be "COMMENT:" * - The single value will be the frame's text(). */ - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * Comments each have a unique description. This searches for a comment diff --git a/taglib/mpeg/id3v2/frames/podcastframe.h b/taglib/mpeg/id3v2/frames/podcastframe.h index a4a02f40..960748c0 100644 --- a/taglib/mpeg/id3v2/frames/podcastframe.h +++ b/taglib/mpeg/id3v2/frames/podcastframe.h @@ -57,7 +57,7 @@ namespace TagLib { */ virtual String toString() const; - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; protected: // Reimplementations. diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index 9cefdd2c..f9b54cdf 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -90,61 +90,31 @@ short RelativeVolumeFrame::volumeAdjustmentIndex(ChannelType type) const return d->channels.contains(type) ? d->channels[type].volumeAdjustment : 0; } -short RelativeVolumeFrame::volumeAdjustmentIndex() const -{ - return volumeAdjustmentIndex(MasterVolume); -} - void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index, ChannelType type) { d->channels[type].volumeAdjustment = index; } -void RelativeVolumeFrame::setVolumeAdjustmentIndex(short index) -{ - setVolumeAdjustmentIndex(index, MasterVolume); -} - float RelativeVolumeFrame::volumeAdjustment(ChannelType type) const { return d->channels.contains(type) ? static_cast(d->channels[type].volumeAdjustment) / static_cast(512) : 0; } -float RelativeVolumeFrame::volumeAdjustment() const -{ - return volumeAdjustment(MasterVolume); -} - void RelativeVolumeFrame::setVolumeAdjustment(float adjustment, ChannelType type) { d->channels[type].volumeAdjustment = static_cast(adjustment * static_cast(512)); } -void RelativeVolumeFrame::setVolumeAdjustment(float adjustment) -{ - setVolumeAdjustment(adjustment, MasterVolume); -} - RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume(ChannelType type) const { return d->channels.contains(type) ? d->channels[type].peakVolume : PeakVolume(); } -RelativeVolumeFrame::PeakVolume RelativeVolumeFrame::peakVolume() const -{ - return peakVolume(MasterVolume); -} - void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak, ChannelType type) { d->channels[type].peakVolume = peak; } -void RelativeVolumeFrame::setPeakVolume(const PeakVolume &peak) -{ - setPeakVolume(peak, MasterVolume); -} - String RelativeVolumeFrame::identification() const { return d->identification; diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.h b/taglib/mpeg/id3v2/frames/relativevolumeframe.h index d797ea9f..503eed35 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.h +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.h @@ -128,14 +128,6 @@ namespace TagLib { */ List channels() const; - /* - * There was a terrible API goof here, and while this can't be changed to - * the way it appears below for binary compatibility reasons, let's at - * least pretend that it looks clean. - */ - -#ifdef DOXYGEN - /*! * Returns the relative volume adjustment "index". As indicated by the * ID3v2 standard this is a 16-bit signed integer that reflects the @@ -209,31 +201,6 @@ namespace TagLib { */ void setPeakVolume(const PeakVolume &peak, ChannelType type = MasterVolume); -#else - - // BIC: Combine each of the following pairs of functions (or maybe just - // rework this junk altogether). - - short volumeAdjustmentIndex(ChannelType type) const; - short volumeAdjustmentIndex() const; - - void setVolumeAdjustmentIndex(short index, ChannelType type); - void setVolumeAdjustmentIndex(short index); - - float volumeAdjustment(ChannelType type) const; - float volumeAdjustment() const; - - void setVolumeAdjustment(float adjustment, ChannelType type); - void setVolumeAdjustment(float adjustment); - - PeakVolume peakVolume(ChannelType type) const; - PeakVolume peakVolume() const; - - void setPeakVolume(const PeakVolume &peak, ChannelType type); - void setPeakVolume(const PeakVolume &peak); - -#endif - /*! * Returns the identification for this frame. */ diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.h b/taglib/mpeg/id3v2/frames/tableofcontentsframe.h index 1f327e91..18279f73 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.h +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.h @@ -222,7 +222,7 @@ namespace TagLib { virtual String toString() const; - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * CTOC frames each have a unique element ID. This searches for a CTOC diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.h b/taglib/mpeg/id3v2/frames/textidentificationframe.h index cc73f59a..4c783be7 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.h +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.h @@ -195,7 +195,7 @@ namespace TagLib { */ static const KeyConversionMap &involvedPeopleMap(); - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; protected: // Reimplementations. @@ -289,7 +289,7 @@ namespace TagLib { * in the value list, in order to be compatible with TagLib which copies * the description() into the fieldList(). */ - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * Searches for the user defined text frame with the description \a description diff --git a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h index cdbf1eb1..6ab855d6 100644 --- a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h +++ b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h @@ -94,7 +94,7 @@ namespace TagLib { virtual String toString() const; - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * UFID frames each have a unique owner. This searches for a UFID diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h index 8ee378b6..ae9bcb1a 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h @@ -145,7 +145,7 @@ namespace TagLib { * Note that currently the language() field is not supported by the PropertyMap * interface. */ - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * LyricsFrames each have a unique description. This searches for a lyrics diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.h b/taglib/mpeg/id3v2/frames/urllinkframe.h index c9f75ab5..2026bc98 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.h +++ b/taglib/mpeg/id3v2/frames/urllinkframe.h @@ -69,7 +69,7 @@ namespace TagLib { virtual void setText(const String &s); virtual String toString() const; - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; protected: virtual void parseFields(const ByteVector &data); @@ -160,7 +160,7 @@ namespace TagLib { * characters), the returned map will contain an entry "WXXX/" * in its unsupportedData() list. */ - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * Searches for the user defined url frame with the description \a description diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index 7c215454..9e3ac82a 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -80,16 +80,6 @@ namespace // static methods //////////////////////////////////////////////////////////////////////////////// -unsigned int Frame::headerSize() -{ - return Header::size(); -} - -unsigned int Frame::headerSize(unsigned int version) -{ - return Header::size(version); -} - ByteVector Frame::textDelimiter(String::Type t) { if(t == String::UTF16 || t == String::UTF16BE || t == String::UTF16LE) @@ -106,6 +96,11 @@ const String Frame::urlPrefix("URL:"); // public members //////////////////////////////////////////////////////////////////////////////// +unsigned int Frame::headerSize() +{ + return d->header->size(); +} + Frame *Frame::createTextualFrame(const String &key, const StringList &values) //static { // check if the key is contained in the key<=>frameID mapping @@ -235,7 +230,7 @@ void Frame::parse(const ByteVector &data) ByteVector Frame::fieldData(const ByteVector &frameData) const { - unsigned int headerSize = Header::size(d->header->version()); + unsigned int headerSize = d->header->size(); unsigned int frameDataOffset = headerSize; unsigned int frameDataLength = size(); @@ -287,14 +282,9 @@ String Frame::readStringField(const ByteVector &data, String::Type encoding, int return str; } -String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding) // static +String::Type Frame::checkTextEncoding(const StringList &fields, String::Type encoding) const { - return checkEncoding(fields, encoding, 4); -} - -String::Type Frame::checkEncoding(const StringList &fields, String::Type encoding, unsigned int version) // static -{ - if((encoding == String::UTF8 || encoding == String::UTF16BE) && version != 4) + if((encoding == String::UTF8 || encoding == String::UTF16BE) && header()->version() != 4) return String::UTF16; if(encoding != String::Latin1) @@ -302,7 +292,7 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { if(!(*it).isLatin1()) { - if(version == 4) { + if(header()->version() == 4) { debug("Frame::checkEncoding() -- Rendering using UTF8."); return String::UTF8; } @@ -314,11 +304,6 @@ String::Type Frame::checkEncoding(const StringList &fields, String::Type encodin return String::Latin1; } -String::Type Frame::checkTextEncoding(const StringList &fields, String::Type encoding) const -{ - return checkEncoding(fields, encoding, header()->version()); -} - namespace { const std::pair frameTranslation[] = { @@ -479,24 +464,6 @@ PropertyMap Frame::asProperties() const return m; } const ByteVector &id = frameID(); - // workaround until this function is virtual - if(id == "TXXX") - return dynamic_cast< const UserTextIdentificationFrame* >(this)->asProperties(); - // Apple proprietary WFED (Podcast URL), MVNM (Movement Name), MVIN (Movement Number), GRP1 (Grouping) are in fact text frames. - if(id[0] == 'T' || id == "WFED" || id == "MVNM" || id == "MVIN" || id == "GRP1") - return dynamic_cast< const TextIdentificationFrame* >(this)->asProperties(); - if(id == "WXXX") - return dynamic_cast< const UserUrlLinkFrame* >(this)->asProperties(); - if(id[0] == 'W') - return dynamic_cast< const UrlLinkFrame* >(this)->asProperties(); - if(id == "COMM") - return dynamic_cast< const CommentsFrame* >(this)->asProperties(); - if(id == "USLT") - return dynamic_cast< const UnsynchronizedLyricsFrame* >(this)->asProperties(); - if(id == "UFID") - return dynamic_cast< const UniqueFileIdentifierFrame* >(this)->asProperties(); - if(id == "PCST") - return dynamic_cast< const PodcastFrame* >(this)->asProperties(); PropertyMap m; m.unsupportedData().append(id); return m; @@ -555,17 +522,12 @@ public: }; //////////////////////////////////////////////////////////////////////////////// -// static members (Frame::Header) +// public members (Frame::Header) //////////////////////////////////////////////////////////////////////////////// unsigned int Frame::Header::size() { - return size(4); -} - -unsigned int Frame::Header::size(unsigned int version) -{ - switch(version) { + switch(d->version) { case 0: case 1: case 2: @@ -577,10 +539,6 @@ unsigned int Frame::Header::size(unsigned int version) } } -//////////////////////////////////////////////////////////////////////////////// -// public members (Frame::Header) -//////////////////////////////////////////////////////////////////////////////// - Frame::Header::Header(const ByteVector &data, unsigned int version) : d(new HeaderPrivate()) { diff --git a/taglib/mpeg/id3v2/id3v2frame.h b/taglib/mpeg/id3v2/id3v2frame.h index 23a4a350..c2db6593 100644 --- a/taglib/mpeg/id3v2/id3v2frame.h +++ b/taglib/mpeg/id3v2/id3v2frame.h @@ -85,21 +85,8 @@ namespace TagLib { /*! * Returns the size of the frame header - * - * \deprecated This is only accurate for ID3v2.3 or ID3v2.4. Please use - * the call below which accepts an ID3v2 version number. In the next - * non-binary compatible release this will be made into a non-static - * member that checks the internal ID3v2 version. */ - static unsigned int headerSize(); // BIC: make non-static - - /*! - * Returns the size of the frame header for the given ID3v2 version. - * - * \deprecated Please see the explanation above. - */ - // BIC: remove - static unsigned int headerSize(unsigned int version); + unsigned int headerSize(); /*! * Sets the data that will be used as the frame. Since the length is not @@ -229,24 +216,6 @@ namespace TagLib { String readStringField(const ByteVector &data, String::Type encoding, int *position = 0); - /*! - * Checks a the list of string values to see if they can be used with the - * specified encoding and returns the recommended encoding. - */ - // BIC: remove and make non-static - static String::Type checkEncoding(const StringList &fields, - String::Type encoding); - - /*! - * Checks a the list of string values to see if they can be used with the - * specified encoding and returns the recommended encoding. This method - * also checks the ID3v2 version and makes sure the encoding can be used - * in the specified version. - */ - // BIC: remove and make non-static - static String::Type checkEncoding(const StringList &fields, - String::Type encoding, unsigned int version); - /*! * Checks a the list of string values to see if they can be used with the * specified encoding and returns the recommended encoding. This method @@ -261,9 +230,8 @@ namespace TagLib { * Parses the contents of this frame as PropertyMap. If that fails, the returned * PropertyMap will be empty, and its unsupportedData() will contain this frame's * ID. - * BIC: Will be a virtual function in future releases. */ - PropertyMap asProperties() const; + virtual PropertyMap asProperties() const; /*! * Returns an appropriate ID3 frame ID for the given free-form tag key. This method @@ -390,23 +358,8 @@ namespace TagLib { /*! * Returns the size of the frame header in bytes. - * - * \deprecated Please use the version of this method that accepts a - * version. This is only accurate for ID3v2.3 and ID3v2.4. This will be - * removed in the next binary incompatible release (2.0) and will be - * replaced with a non-static method that checks the frame version. */ - // BIC: make non-static - static unsigned int size(); - - /*! - * Returns the size of the frame header in bytes for the ID3v2 version - * that's given. - * - * \deprecated Please see the explanation in the version above. - */ - // BIC: remove - static unsigned int size(unsigned int version); + unsigned int size(); /*! * Returns true if the flag for tag alter preservation is set. diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index 59655611..730784d0 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -115,11 +115,6 @@ FrameFactory *FrameFactory::instance() return &factory; } -Frame *FrameFactory::createFrame(const ByteVector &origData, Header *tagHeader) const -{ - return createFrame(origData, const_cast(tagHeader)); -} - Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHeader) const { ByteVector data = origData; @@ -159,9 +154,9 @@ Frame *FrameFactory::createFrame(const ByteVector &origData, const Header *tagHe if(version > 3 && (tagHeader->unsynchronisation() || header->unsynchronisation())) { // Data lengths are not part of the encoded data, but since they are synch-safe // integers they will be never actually encoded. - ByteVector frameData = data.mid(Frame::Header::size(version), header->frameSize()); + ByteVector frameData = data.mid(header->size(), header->frameSize()); frameData = SynchData::decode(frameData); - data = data.mid(0, Frame::Header::size(version)) + frameData; + data = data.mid(0, header->size()) + frameData; } // TagLib doesn't mess with encrypted frames, so just treat them diff --git a/taglib/mpeg/id3v2/id3v2framefactory.h b/taglib/mpeg/id3v2/id3v2framefactory.h index 950c9ca4..59d09b1e 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.h +++ b/taglib/mpeg/id3v2/id3v2framefactory.h @@ -67,25 +67,18 @@ namespace TagLib { public: static FrameFactory *instance(); - /*! - * \deprecated Use createFrame(const ByteVector &, const Header *) const. - */ - // BIC: remove - Frame *createFrame(const ByteVector &data, Header *tagHeader) const; /*! * Create a frame based on \a data. \a tagHeader should be a valid * ID3v2::Header instance. */ - // BIC: make virtual - Frame *createFrame(const ByteVector &data, const Header *tagHeader) const; + virtual Frame *createFrame(const ByteVector &data, const Header *tagHeader) const; /*! * After a tag has been read, this tries to rebuild some of them * information, most notably the recording date, from frames that * have been deprecated and can't be upgraded directly. */ - // BIC: Make virtual - void rebuildAggregateFrames(ID3v2::Tag *tag) const; + virtual void rebuildAggregateFrames(ID3v2::Tag *tag) const; /*! * Returns the default text encoding for text frames. If setTextEncoding() diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index 2047e14a..66e35119 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -656,7 +656,7 @@ ByteVector ID3v2::Tag::render(Version version) const } if(!(*it)->header()->tagAlterPreservation()) { const ByteVector frameData = (*it)->render(); - if(frameData.size() == Frame::headerSize((*it)->header()->version())) { + if(frameData.size() == (*it)->headerSize()) { debug("An empty ID3v2 frame \'" + String((*it)->header()->frameID()) + "\' has been discarded"); continue; @@ -789,7 +789,7 @@ void ID3v2::Tag::parse(const ByteVector &origData) // Make sure that there is at least enough room in the remaining frame data for // a frame header. - while(frameDataPosition < frameDataLength - Frame::headerSize(d->header.majorVersion())) { + while(frameDataPosition < frameDataLength - d->header.size()) { // If the next data is position is 0, assume that we've hit the padding // portion of the frame data. @@ -815,7 +815,7 @@ void ID3v2::Tag::parse(const ByteVector &origData) return; } - frameDataPosition += frame->size() + Frame::headerSize(d->header.majorVersion()); + frameDataPosition += frame->size() + frame->headerSize(); addFrame(frame); } diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index febe5713..ebc73985 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -323,11 +323,6 @@ APE::Tag *MPEG::File::APETag(bool create) return d->tag.access(APEIndex, create); } -bool MPEG::File::strip(int tags) -{ - return strip(tags, true); -} - bool MPEG::File::strip(int tags, bool freeMemory) { if(readOnly()) { diff --git a/taglib/mpeg/mpegfile.h b/taglib/mpeg/mpegfile.h index 92d9b1d1..1f99c130 100644 --- a/taglib/mpeg/mpegfile.h +++ b/taglib/mpeg/mpegfile.h @@ -93,7 +93,7 @@ namespace TagLib { * * \note In the current implementation, \a propertiesStyle is ignored. */ - // BIC: merge with the above constructor + // BIC: merge with the above constructor, kept for source compatibility File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties = true, Properties::ReadStyle propertiesStyle = Properties::Average); @@ -255,20 +255,6 @@ namespace TagLib { */ APE::Tag *APETag(bool create = false); - /*! - * This will strip the tags that match the OR-ed together TagTypes from the - * file. By default it strips all tags. It returns true if the tags are - * successfully stripped. - * - * This is equivalent to strip(tags, true) - * - * \note This will also invalidate pointers to the ID3 and APE tags - * as their memory will be freed. - * - * \note This will update the file immediately. - */ - bool strip(int tags = AllTags); - /*! * This will strip the tags that match the OR-ed together TagTypes from the * file. By default it strips all tags. It returns true if the tags are @@ -279,8 +265,7 @@ namespace TagLib { * * \note This will update the file immediately. */ - // BIC: merge with the method above - bool strip(int tags, bool freeMemory); + bool strip(int tags = AllTags, bool freeMemory = true); /*! * Returns the position in the file of the first MPEG frame. diff --git a/taglib/mpeg/mpegproperties.cpp b/taglib/mpeg/mpegproperties.cpp index bbd0c5a8..babad890 100644 --- a/taglib/mpeg/mpegproperties.cpp +++ b/taglib/mpeg/mpegproperties.cpp @@ -84,11 +84,6 @@ MPEG::Properties::~Properties() delete d; } -int MPEG::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int MPEG::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/mpeg/mpegproperties.h b/taglib/mpeg/mpegproperties.h index 5aa75b82..8e23c4a1 100644 --- a/taglib/mpeg/mpegproperties.h +++ b/taglib/mpeg/mpegproperties.h @@ -59,22 +59,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/ogg/oggpage.cpp b/taglib/ogg/oggpage.cpp index 1f7fcf51..affb55a3 100644 --- a/taglib/ogg/oggpage.cpp +++ b/taglib/ogg/oggpage.cpp @@ -34,6 +34,69 @@ using namespace TagLib; +namespace { + +/*! + * Returns a CRC checksum of the byte vector's \a data. + * + * \note This uses an uncommon variant of CRC32 specializes in Ogg. + */ +unsigned int pageChecksum(const ByteVector &data) +{ + static const unsigned int crcTable[256] = { + 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, + 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, + 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, + 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, + 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, + 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, + 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, + 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, + 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, + 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, + 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, + 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, + 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, + 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, + 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, + 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, + 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, + 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, + 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, + 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, + 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, + 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, + 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, + 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, + 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, + 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, + 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, + 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, + 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, + 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, + 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, + 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, + 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, + 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, + 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, + 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, + 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, + 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, + 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, + 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, + 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, + 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, + 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 + }; + + unsigned int sum = 0; + for(ByteVector::ConstIterator it = data.begin(); it != data.end(); ++it) + sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; + return sum; +} + +} // namespace + class Ogg::Page::PagePrivate { public: @@ -189,7 +252,7 @@ ByteVector Ogg::Page::render() const // the entire page with the 4 bytes reserved for the checksum zeroed and then // inserted in bytes 22-25 of the page header. - const ByteVector checksum = ByteVector::fromUInt(data.checksum(), false); + const ByteVector checksum = ByteVector::fromUInt(::pageChecksum(data), false); std::copy(checksum.begin(), checksum.end(), data.begin() + 22); return data; diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index d6d004f9..4cd3f7af 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -71,11 +71,6 @@ Opus::Properties::~Properties() delete d; } -int Ogg::Opus::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int Ogg::Opus::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/ogg/opus/opusproperties.h b/taglib/ogg/opus/opusproperties.h index 9e2f9385..106af2ac 100644 --- a/taglib/ogg/opus/opusproperties.h +++ b/taglib/ogg/opus/opusproperties.h @@ -61,22 +61,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/ogg/speex/speexproperties.cpp b/taglib/ogg/speex/speexproperties.cpp index 0a7cf8f2..0464c3c7 100644 --- a/taglib/ogg/speex/speexproperties.cpp +++ b/taglib/ogg/speex/speexproperties.cpp @@ -77,11 +77,6 @@ Speex::Properties::~Properties() delete d; } -int Speex::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int Speex::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/ogg/speex/speexproperties.h b/taglib/ogg/speex/speexproperties.h index 8e6d18d4..ada3de09 100644 --- a/taglib/ogg/speex/speexproperties.h +++ b/taglib/ogg/speex/speexproperties.h @@ -61,22 +61,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/ogg/vorbis/vorbisfile.h b/taglib/ogg/vorbis/vorbisfile.h index a166db4d..70186ee5 100644 --- a/taglib/ogg/vorbis/vorbisfile.h +++ b/taglib/ogg/vorbis/vorbisfile.h @@ -39,6 +39,8 @@ namespace TagLib { * documentation. The typedef below will make this work with the current code. * In the next BIC version of TagLib this will be really moved into the Ogg * namespace. + * Kept for source compatibility, the typedef in vorbisproperties.h was not + * correct in TagLib 1. */ #ifdef DOXYGEN @@ -144,6 +146,8 @@ namespace TagLib { * To keep compatibility with the current version put Vorbis in the Ogg namespace * only in the docs and provide a typedef to make it work. In the next BIC * version this will be removed and it will only exist in the Ogg namespace. + * Kept for source compatibility, the typedef in vorbisproperties.h was not + * correct in TagLib 1. */ #ifdef DOXYGEN diff --git a/taglib/ogg/vorbis/vorbisproperties.cpp b/taglib/ogg/vorbis/vorbisproperties.cpp index 5fd9db56..88f2230f 100644 --- a/taglib/ogg/vorbis/vorbisproperties.cpp +++ b/taglib/ogg/vorbis/vorbisproperties.cpp @@ -80,11 +80,6 @@ Vorbis::Properties::~Properties() delete d; } -int Vorbis::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int Vorbis::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/ogg/vorbis/vorbisproperties.h b/taglib/ogg/vorbis/vorbisproperties.h index 09e987bf..a57364b0 100644 --- a/taglib/ogg/vorbis/vorbisproperties.h +++ b/taglib/ogg/vorbis/vorbisproperties.h @@ -36,6 +36,8 @@ namespace TagLib { * documentation. The typedef below will make this work with the current code. * In the next BIC version of TagLib this will be really moved into the Ogg * namespace. + * Kept for source compatibility, the typedef in vorbisproperties.h was not + * correct in TagLib 1. */ #ifdef DOXYGEN @@ -67,22 +69,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. @@ -137,12 +129,14 @@ namespace TagLib { * To keep compatibility with the current version put Vorbis in the Ogg namespace * only in the docs and provide a typedef to make it work. In the next BIC * version this will be removed and it will only exist in the Ogg namespace. + * Kept for source compatibility, the typedef in vorbisproperties.h was not + * correct in TagLib 1. */ #ifdef DOXYGEN } #else - namespace Ogg { namespace Vorbis { typedef TagLib::AudioProperties AudioProperties; } } + namespace Ogg { namespace Vorbis { typedef TagLib::Vorbis::Properties Properties; } } #endif } // namespace TagLib diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index 690f586a..8187c383 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -344,11 +344,6 @@ List Ogg::XiphComment::pictureList() return d->pictureList; } -ByteVector Ogg::XiphComment::render() const -{ - return render(true); -} - ByteVector Ogg::XiphComment::render(bool addFramingBit) const { ByteVector data; diff --git a/taglib/ogg/xiphcomment.h b/taglib/ogg/xiphcomment.h index 307af65a..79550a12 100644 --- a/taglib/ogg/xiphcomment.h +++ b/taglib/ogg/xiphcomment.h @@ -212,11 +212,6 @@ namespace TagLib { */ bool contains(const String &key) const; - /*! - * Renders the comment to a ByteVector suitable for inserting into a file. - */ - ByteVector render() const; // BIC: remove and merge with below - /*! * Renders the comment to a ByteVector suitable for inserting into a file. * @@ -224,7 +219,7 @@ namespace TagLib { * be appended. However some formats (notably FLAC) do not work with this * in place. */ - ByteVector render(bool addFramingBit) const; + ByteVector render(bool addFramingBit = true) const; /*! diff --git a/taglib/riff/aiff/aiffproperties.cpp b/taglib/riff/aiff/aiffproperties.cpp index 1198939b..20e4c992 100644 --- a/taglib/riff/aiff/aiffproperties.cpp +++ b/taglib/riff/aiff/aiffproperties.cpp @@ -69,11 +69,6 @@ RIFF::AIFF::Properties::~Properties() delete d; } -int RIFF::AIFF::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int RIFF::AIFF::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/riff/aiff/aiffproperties.h b/taglib/riff/aiff/aiffproperties.h index 5a29ea5d..c4db7699 100644 --- a/taglib/riff/aiff/aiffproperties.h +++ b/taglib/riff/aiff/aiffproperties.h @@ -57,22 +57,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/riff/wav/wavproperties.cpp b/taglib/riff/wav/wavproperties.cpp index f517b690..926951f0 100644 --- a/taglib/riff/wav/wavproperties.cpp +++ b/taglib/riff/wav/wavproperties.cpp @@ -77,11 +77,6 @@ RIFF::WAV::Properties::~Properties() delete d; } -int RIFF::WAV::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int RIFF::WAV::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/riff/wav/wavproperties.h b/taglib/riff/wav/wavproperties.h index 2f7a1ed7..65240885 100644 --- a/taglib/riff/wav/wavproperties.h +++ b/taglib/riff/wav/wavproperties.h @@ -60,22 +60,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index e3e443cb..84a97c1f 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -73,31 +73,6 @@ S3M::Properties::~Properties() delete d; } -int S3M::Properties::length() const -{ - return 0; -} - -int S3M::Properties::lengthInSeconds() const -{ - return 0; -} - -int S3M::Properties::lengthInMilliseconds() const -{ - return 0; -} - -int S3M::Properties::bitrate() const -{ - return 0; -} - -int S3M::Properties::sampleRate() const -{ - return 0; -} - int S3M::Properties::channels() const { return d->channels; diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index fda5952f..ec50a2d7 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -48,11 +48,6 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; int channels() const; unsigned short lengthInPatterns() const; diff --git a/taglib/tag.h b/taglib/tag.h index a4458800..1c3ab06d 100644 --- a/taglib/tag.h +++ b/taglib/tag.h @@ -58,17 +58,14 @@ namespace TagLib { * The default implementation in this class considers only the usual built-in * tags (artist, album, ...) and only one value per key. */ - PropertyMap properties() const; + virtual PropertyMap properties() const; /*! * Removes unsupported properties, or a subset of them, from the tag. * The parameter \a properties must contain only entries from * properties().unsupportedData(). - * BIC: Will become virtual in future releases. Currently the non-virtual - * standard implementation of TagLib::Tag does nothing, since there are - * no unsupported elements. */ - void removeUnsupportedProperties(const StringList& properties); + virtual void removeUnsupportedProperties(const StringList& properties); /*! * Sets the tags of this File to those specified in \a properties. This default @@ -76,7 +73,7 @@ namespace TagLib { * (artist, album, ...), and only one value per key; the rest will be contained * in the returned PropertyMap. */ - PropertyMap setProperties(const PropertyMap &properties); + virtual PropertyMap setProperties(const PropertyMap &properties); /*! * Returns the track name; if no track name is present in the tag diff --git a/taglib/tagunion.cpp b/taglib/tagunion.cpp index 85741b0d..3a022550 100644 --- a/taglib/tagunion.cpp +++ b/taglib/tagunion.cpp @@ -110,27 +110,9 @@ void TagUnion::set(int index, Tag *tag) PropertyMap TagUnion::properties() const { - // This is an ugly workaround but we can't add a virtual function. - // Should be virtual in taglib2. - for(size_t i = 0; i < 3; ++i) { - if(d->tags[i] && !d->tags[i]->isEmpty()) { - - if(dynamic_cast(d->tags[i])) - return dynamic_cast(d->tags[i])->properties(); - - if(dynamic_cast(d->tags[i])) - return dynamic_cast(d->tags[i])->properties(); - - if(dynamic_cast(d->tags[i])) - return dynamic_cast(d->tags[i])->properties(); - - if(dynamic_cast(d->tags[i])) - return dynamic_cast(d->tags[i])->properties(); - - if(dynamic_cast(d->tags[i])) - return dynamic_cast(d->tags[i])->properties(); + return d->tags[i]->properties(); } } @@ -139,27 +121,9 @@ PropertyMap TagUnion::properties() const void TagUnion::removeUnsupportedProperties(const StringList &unsupported) { - // This is an ugly workaround but we can't add a virtual function. - // Should be virtual in taglib2. - for(size_t i = 0; i < 3; ++i) { - if(d->tags[i]) { - - if(dynamic_cast(d->tags[i])) - dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - - else if(dynamic_cast(d->tags[i])) - dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - - else if(dynamic_cast(d->tags[i])) - dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - - else if(dynamic_cast(d->tags[i])) - dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); - - else if(dynamic_cast(d->tags[i])) - dynamic_cast(d->tags[i])->removeUnsupportedProperties(unsupported); + d->tags[i]->removeUnsupportedProperties(unsupported); } } } @@ -245,4 +209,3 @@ bool TagUnion::isEmpty() const return true; } - diff --git a/taglib/tagunion.h b/taglib/tagunion.h index b8b361ac..95ae1e55 100644 --- a/taglib/tagunion.h +++ b/taglib/tagunion.h @@ -56,8 +56,8 @@ namespace TagLib { void set(int index, Tag *tag); - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &unsupported); + virtual PropertyMap properties() const; + virtual void removeUnsupportedProperties(const StringList &unsupported); virtual String title() const; virtual String artist() const; diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index c911cb4c..70fc4ec4 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -660,60 +660,6 @@ bool ByteVector::isEmpty() const return (d->length == 0); } -unsigned int ByteVector::checksum() const -{ - static const unsigned int crcTable[256] = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, - 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, - 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, - 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, - 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, - 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, - 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, - 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, - 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, - 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, - 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, - 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, - 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, - 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, - 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, - 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, - 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, - 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, - 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, - 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, - 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, - 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 - }; - - unsigned int sum = 0; - for(ByteVector::ConstIterator it = begin(); it != end(); ++it) - sum = (sum << 8) ^ crcTable[((sum >> 24) & 0xff) ^ static_cast(*it)]; - return sum; -} - unsigned int ByteVector::toUInt(bool mostSignificantByteFirst) const { return toNumber(*this, 0, mostSignificantByteFirst); diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index 56b9f41e..734a3be5 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -277,14 +277,6 @@ namespace TagLib { */ bool isEmpty() const; - /*! - * Returns a CRC checksum of the byte vector's data. - * - * \note This uses an uncommon variant of CRC32 specializes in Ogg. - */ - // BIC: Remove or make generic. - unsigned int checksum() const; - /*! * Converts the first 4 bytes of the vector to an unsigned integer. * diff --git a/taglib/toolkit/tbytevectorlist.cpp b/taglib/toolkit/tbytevectorlist.cpp index 1881376f..8b2f71e1 100644 --- a/taglib/toolkit/tbytevectorlist.cpp +++ b/taglib/toolkit/tbytevectorlist.cpp @@ -36,12 +36,6 @@ class ByteVectorListPrivate // static members //////////////////////////////////////////////////////////////////////////////// -ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &pattern, - int byteAlign) -{ - return split(v, pattern, byteAlign, 0); -} - ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &pattern, int byteAlign, int max) { diff --git a/taglib/toolkit/tbytevectorlist.h b/taglib/toolkit/tbytevectorlist.h index 27fc64ab..54a21c68 100644 --- a/taglib/toolkit/tbytevectorlist.h +++ b/taglib/toolkit/tbytevectorlist.h @@ -65,12 +65,6 @@ namespace TagLib { */ ByteVector toByteVector(const ByteVector &separator = " ") const; - /*! - * Splits the ByteVector \a v into several strings at \a pattern. This will - * not include the pattern in the returned ByteVectors. - */ - static ByteVectorList split(const ByteVector &v, const ByteVector &pattern, - int byteAlign = 1); /*! * Splits the ByteVector \a v into several strings at \a pattern. This will * not include the pattern in the returned ByteVectors. \a max is the @@ -78,9 +72,8 @@ namespace TagLib { * is 2 then a maximum of 1 match will be found and the vector will be split * on that match. */ - // BIC: merge with the function above static ByteVectorList split(const ByteVector &v, const ByteVector &pattern, - int byteAlign, int max); + int byteAlign = 1, int max = 0); private: class ByteVectorListPrivate; ByteVectorListPrivate *d; diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index ae477ebc..af98b495 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -110,114 +110,16 @@ FileName File::name() const PropertyMap File::properties() const { - // ugly workaround until this method is virtual - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); - if(dynamic_cast(this)) - return dynamic_cast(this)->properties(); return tag()->properties(); } void File::removeUnsupportedProperties(const StringList &properties) { - // here we only consider those formats that could possibly contain - // unsupported properties - if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast(this)) - dynamic_cast(this)->removeUnsupportedProperties(properties); - else - tag()->removeUnsupportedProperties(properties); + tag()->removeUnsupportedProperties(properties); } PropertyMap File::setProperties(const PropertyMap &properties) { - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); - if(dynamic_cast(this)) - return dynamic_cast(this)->setProperties(properties); return tag()->setProperties(properties); } diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h index 3bb35158..bbad5fcc 100644 --- a/taglib/toolkit/tfile.h +++ b/taglib/toolkit/tfile.h @@ -105,17 +105,15 @@ namespace TagLib { * to remove (a subset of) them. * For files that contain more than one tag (e.g. an MP3 with both an ID3v1 and an ID3v2 * tag) only the most "modern" one will be exported (ID3v2 in this case). - * BIC: Will be made virtual in future releases. */ - PropertyMap properties() const; + virtual PropertyMap properties() const; /*! * Removes unsupported properties, or a subset of them, from the file's metadata. * The parameter \a properties must contain only entries from * properties().unsupportedData(). - * BIC: Will be mad virtual in future releases. */ - void removeUnsupportedProperties(const StringList& properties); + virtual void removeUnsupportedProperties(const StringList& properties); /*! * Sets the tags of this File to those specified in \a properties. Calls the @@ -129,9 +127,8 @@ namespace TagLib { * (ID3v2 for MP3 files). Older formats will be updated as well, if they exist, but won't * be taken into account for the return value of this function. * See the documentation of the subclass implementations for detailed descriptions. - * BIC: will become pure virtual in the future */ - PropertyMap setProperties(const PropertyMap &properties); + virtual PropertyMap setProperties(const PropertyMap &properties); /*! * Returns a pointer to this file's audio properties. This should be diff --git a/taglib/toolkit/tlist.tcc b/taglib/toolkit/tlist.tcc index 478f0983..4ab05afe 100644 --- a/taglib/toolkit/tlist.tcc +++ b/taglib/toolkit/tlist.tcc @@ -39,8 +39,7 @@ namespace TagLib { // A base for the generic and specialized private class types. New // non-templatized members should be added here. -// BIC change to RefCounter -class ListPrivateBase : public RefCounterOld +class ListPrivateBase : public RefCounter { public: ListPrivateBase() : autoDelete(false) {} diff --git a/taglib/toolkit/tmap.tcc b/taglib/toolkit/tmap.tcc index 79649139..5367a185 100644 --- a/taglib/toolkit/tmap.tcc +++ b/taglib/toolkit/tmap.tcc @@ -31,18 +31,17 @@ namespace TagLib { // public members //////////////////////////////////////////////////////////////////////////////// -// BIC change to RefCounter template template -class Map::MapPrivate : public RefCounterOld +class Map::MapPrivate : public RefCounter { public: - MapPrivate() : RefCounterOld() {} + MapPrivate() : RefCounter() {} #ifdef WANT_CLASS_INSTANTIATION_OF_MAP - MapPrivate(const std::map& m) : RefCounterOld(), map(m) {} + MapPrivate(const std::map& m) : RefCounter(), map(m) {} std::map map; #else - MapPrivate(const std::map& m) : RefCounterOld(), map(m) {} + MapPrivate(const std::map& m) : RefCounter(), map(m) {} std::map map; #endif }; diff --git a/taglib/toolkit/trefcounter.h b/taglib/toolkit/trefcounter.h index b3ce8833..2d23a908 100644 --- a/taglib/toolkit/trefcounter.h +++ b/taglib/toolkit/trefcounter.h @@ -74,41 +74,7 @@ namespace TagLib RefCounterPrivate *d; }; - // BIC this old class is needed by tlist.tcc and tmap.tcc - class RefCounterOld - { - public: - RefCounterOld() : refCount(1) {} - -#ifdef TAGLIB_ATOMIC_MAC - void ref() { OSAtomicIncrement32Barrier(const_cast(&refCount)); } - bool deref() { return ! OSAtomicDecrement32Barrier(const_cast(&refCount)); } - int32_t count() { return refCount; } - private: - volatile int32_t refCount; -#elif defined(TAGLIB_ATOMIC_WIN) - void ref() { InterlockedIncrement(&refCount); } - bool deref() { return ! InterlockedDecrement(&refCount); } - long count() { return refCount; } - private: - volatile long refCount; -#elif defined(TAGLIB_ATOMIC_GCC) - void ref() { __sync_add_and_fetch(&refCount, 1); } - bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); } - int count() { return refCount; } - private: - volatile int refCount; -#else - void ref() { refCount++; } - bool deref() { return ! --refCount; } - int count() { return refCount; } - private: - unsigned int refCount; -#endif - }; - } // namespace TagLib #endif // DO_NOT_DOCUMENT #endif - diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index e7ca3682..4b313ee2 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -482,11 +482,6 @@ ByteVector String::data(Type t) const } } -int String::toInt() const -{ - return toInt(0); -} - int String::toInt(bool *ok) const { const wchar_t *begin = d->data.c_str(); diff --git a/taglib/toolkit/tstring.h b/taglib/toolkit/tstring.h index d31ec600..0c8d785a 100644 --- a/taglib/toolkit/tstring.h +++ b/taglib/toolkit/tstring.h @@ -338,15 +338,6 @@ namespace TagLib { */ ByteVector data(Type t) const; - /*! - * Convert the string to an integer. - * - * Returns the integer if the conversion was successful or 0 if the - * string does not represent a number. - */ - // BIC: merge with the method below - int toInt() const; - /*! * Convert the string to an integer. * @@ -354,7 +345,7 @@ namespace TagLib { * true and returns the integer. Otherwise it sets \a *ok to false * and the result is undefined. */ - int toInt(bool *ok) const; + int toInt(bool *ok = 0) const; /*! * Returns a string with the leading and trailing whitespace stripped. diff --git a/taglib/trueaudio/trueaudioproperties.h b/taglib/trueaudio/trueaudioproperties.h index 5e664002..99123d00 100644 --- a/taglib/trueaudio/trueaudioproperties.h +++ b/taglib/trueaudio/trueaudioproperties.h @@ -66,16 +66,14 @@ namespace TagLib { * * \see lengthInMilliseconds() */ - // BIC: make virtual - int lengthInSeconds() const; + virtual int lengthInSeconds() const; /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp index af317b93..b35dd0f2 100644 --- a/taglib/wavpack/wavpackproperties.cpp +++ b/taglib/wavpack/wavpackproperties.cpp @@ -78,11 +78,6 @@ WavPack::Properties::~Properties() delete d; } -int WavPack::Properties::lengthInSeconds() const -{ - return d->length / 1000; -} - int WavPack::Properties::lengthInMilliseconds() const { return d->length; diff --git a/taglib/wavpack/wavpackproperties.h b/taglib/wavpack/wavpackproperties.h index de192df6..86917923 100644 --- a/taglib/wavpack/wavpackproperties.h +++ b/taglib/wavpack/wavpackproperties.h @@ -62,22 +62,12 @@ namespace TagLib { */ virtual ~Properties(); - /*! - * Returns the length of the file in seconds. The length is rounded down to - * the nearest whole second. - * - * \see lengthInMilliseconds() - */ - // BIC: make virtual - int lengthInSeconds() const; - /*! * Returns the length of the file in milliseconds. * * \see lengthInSeconds() */ - // BIC: make virtual - int lengthInMilliseconds() const; + virtual int lengthInMilliseconds() const; /*! * Returns the average bit rate of the file in kb/s. diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index 93d84986..4360f773 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -69,31 +69,6 @@ XM::Properties::~Properties() delete d; } -int XM::Properties::length() const -{ - return 0; -} - -int XM::Properties::lengthInSeconds() const -{ - return 0; -} - -int XM::Properties::lengthInMilliseconds() const -{ - return 0; -} - -int XM::Properties::bitrate() const -{ - return 0; -} - -int XM::Properties::sampleRate() const -{ - return 0; -} - int XM::Properties::channels() const { return d->channels; diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index 8d953f28..235820e5 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -43,11 +43,6 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); virtual ~Properties(); - int length() const; - int lengthInSeconds() const; - int lengthInMilliseconds() const; - int bitrate() const; - int sampleRate() const; int channels() const; unsigned short lengthInPatterns() const; diff --git a/tests/test_apetag.cpp b/tests/test_apetag.cpp index a39e237c..05a8abac 100644 --- a/tests/test_apetag.cpp +++ b/tests/test_apetag.cpp @@ -90,7 +90,7 @@ public: void testPropertyInterface2() { APE::Tag tag; - APE::Item item1 = APE::Item("TRACK", "17"); + APE::Item item1 = APE::Item("TRACK", String("17")); tag.setItem("TRACK", item1); APE::Item item2 = APE::Item(); @@ -118,7 +118,7 @@ public: tag.removeUnsupportedProperties(properties.unsupportedData()); CPPUNIT_ASSERT(!tag.itemListMap().contains("TESTBINARY")); - APE::Item item3 = APE::Item("TRACKNUMBER", "29"); + APE::Item item3 = APE::Item("TRACKNUMBER", String("29")); tag.setItem("TRACKNUMBER", item3); properties = tag.properties(); CPPUNIT_ASSERT_EQUAL((unsigned int)2, properties["TRACKNUMBER"].size()); @@ -152,7 +152,7 @@ public: void testTextBinary() { - APE::Item item = APE::Item("DUMMY", "Test Text"); + APE::Item item = APE::Item("DUMMY", String("Test Text")); CPPUNIT_ASSERT_EQUAL(String("Test Text"), item.toString()); CPPUNIT_ASSERT_EQUAL(ByteVector(), item.binaryData()); @@ -188,4 +188,3 @@ public: }; CPPUNIT_TEST_SUITE_REGISTRATION(TestAPETag); -