From 3a24d31b43d351c025a052c2fb6f362ed4c65366 Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Thu, 2 Mar 2006 15:02:27 +0000 Subject: [PATCH] Two things: - Fix the channel mode, copyright and original flags, as noticed by Bjoern Petersen. - Check in the "findByDescription()" function that I've had sitting around for a while. git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@515068 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeg/id3v2/frames/commentsframe.cpp | 17 +++++++++++++++++ mpeg/id3v2/frames/commentsframe.h | 2 ++ mpeg/mpegheader.cpp | 6 +++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/mpeg/id3v2/frames/commentsframe.cpp b/mpeg/id3v2/frames/commentsframe.cpp index 6abcb54e..0b7faaa1 100644 --- a/mpeg/id3v2/frames/commentsframe.cpp +++ b/mpeg/id3v2/frames/commentsframe.cpp @@ -20,6 +20,7 @@ ***************************************************************************/ #include +#include #include #include "commentsframe.h" @@ -104,6 +105,22 @@ void CommentsFrame::setTextEncoding(String::Type encoding) d->textEncoding = encoding; } +CommentsFrame *CommentsFrame::findByDescription(const ID3v2::Tag *tag, const String &d) // static +{ + ID3v2::FrameList comments = tag->frameList("COMM"); + + for(ID3v2::FrameList::ConstIterator it = comments.begin(); + it != comments.end(); + ++it) + { + CommentsFrame *frame = dynamic_cast(*it); + if(frame && frame->description() == d) + return frame; + } + + return 0; +} + //////////////////////////////////////////////////////////////////////////////// // protected members //////////////////////////////////////////////////////////////////////////////// diff --git a/mpeg/id3v2/frames/commentsframe.h b/mpeg/id3v2/frames/commentsframe.h index 2c8b2c00..d44cf997 100644 --- a/mpeg/id3v2/frames/commentsframe.h +++ b/mpeg/id3v2/frames/commentsframe.h @@ -131,6 +131,8 @@ namespace TagLib { */ void setTextEncoding(String::Type encoding); + static CommentsFrame *findByDescription(const Tag *tag, const String &d); + protected: // Reimplementations. diff --git a/mpeg/mpegheader.cpp b/mpeg/mpegheader.cpp index eb93db45..f575b02f 100644 --- a/mpeg/mpegheader.cpp +++ b/mpeg/mpegheader.cpp @@ -233,12 +233,12 @@ void MPEG::Header::parse(const ByteVector &data) // The channel mode is encoded as a 2 bit value at the end of the 3nd byte, // i.e. xxxxxx11 - d->channelMode = ChannelMode(uchar(data[2]) & 0x3); + d->channelMode = ChannelMode((uchar(data[3]) & 0xC0) >> 6); // TODO: Add mode extension for completeness - d->isCopyrighted = flags[0]; - d->isOriginal = flags[1]; + d->isOriginal = flags[2]; + d->isCopyrighted = flags[3]; // Calculate the frame length