View | Details | Raw Unified | Return to bug 28700
Collapse All | Expand All

(-)taglib-1.8/config-taglib.h.cmake (+2 lines)
Lines 3-8 Link Here
3
/* Define if you have libz */
3
/* Define if you have libz */
4
#cmakedefine   HAVE_ZLIB 1
4
#cmakedefine   HAVE_ZLIB 1
5
#cmakedefine   HAVE_LIBRCC 1
6
5
#cmakedefine   NO_ITUNES_HACKS 1
7
#cmakedefine   NO_ITUNES_HACKS 1
6
#cmakedefine   WITH_ASF 1
8
#cmakedefine   WITH_ASF 1
7
#cmakedefine   WITH_MP4 1
9
#cmakedefine   WITH_MP4 1
(-)taglib-1.8/ConfigureChecks.cmake (+2 lines)
Lines 14-19 Link Here
14
	set(HAVE_ZLIB 0)
14
	set(HAVE_ZLIB 0)
15
endif()
15
endif()
16
SET(HAVE_LIBRCC 1)
17
16
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
18
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
17
find_package(CppUnit)
19
find_package(CppUnit)
18
if(NOT CppUnit_FOUND AND BUILD_TESTS)
20
if(NOT CppUnit_FOUND AND BUILD_TESTS)
(-)taglib-1.8/taglib/CMakeLists.txt (-1 / +3 lines)
Lines 35-40 Link Here
35
  audioproperties.h
35
  audioproperties.h
36
  taglib_export.h
36
  taglib_export.h
37
  ${CMAKE_BINARY_DIR}/taglib_config.h
37
  ${CMAKE_BINARY_DIR}/taglib_config.h
38
  toolkit/rccpatch.h
38
  toolkit/taglib.h
39
  toolkit/taglib.h
39
  toolkit/tstring.h
40
  toolkit/tstring.h
40
  toolkit/tlist.h
41
  toolkit/tlist.h
Lines 269-274 Link Here
269
)
270
)
270
set(toolkit_SRCS
271
set(toolkit_SRCS
272
  toolkit/rccpatch.cpp
271
  toolkit/tstring.cpp
273
  toolkit/tstring.cpp
272
  toolkit/tstringlist.cpp
274
  toolkit/tstringlist.cpp
273
  toolkit/tbytevector.cpp
275
  toolkit/tbytevector.cpp
Lines 296-302 Link Here
296
add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
298
add_library(tag ${tag_LIB_SRCS} ${tag_HDRS})
297
if(ZLIB_FOUND)
299
if(ZLIB_FOUND)
298
	target_link_libraries(tag ${ZLIB_LIBRARIES})
300
	target_link_libraries(tag rcc ${ZLIB_LIBRARIES})
299
endif()
301
endif()
300
set_target_properties(tag PROPERTIES
302
set_target_properties(tag PROPERTIES
(-)taglib-1.8/taglib/mpeg/id3v1/id3v1tag.cpp (-3 / +4 lines)
Lines 64-80 Link Here
64
String ID3v1::StringHandler::parse(const ByteVector &data) const
64
String ID3v1::StringHandler::parse(const ByteVector &data) const
65
{
65
{
66
  return String(data, String::Latin1).stripWhiteSpace();
66
  return String(data, String::Latin1ID3).stripWhiteSpace();
67
}
67
}
68
ByteVector ID3v1::StringHandler::render(const String &s) const
68
ByteVector ID3v1::StringHandler::render(const String &s) const
69
{
69
{
70
  if(!s.isLatin1())
70
  if(!s.isLatin1())
71
  {
71
  {
72
   if (String::ID3WType(String::Latin1) == String::Latin1)
72
    return ByteVector();
73
    return ByteVector();
73
  }
74
  }
74
  return s.data(String::Latin1);
75
  return s.data(String::Latin1ID3);
75
}
76
}
76
////////////////////////////////////////////////////////////////////////////////
77
////////////////////////////////////////////////////////////////////////////////
Lines 247-253 Link Here
247
    d->track = uchar(data[offset + 29]);
248
    d->track = uchar(data[offset + 29]);
248
  }
249
  }
249
  else
250
  else
250
    d->comment = data.mid(offset, 30);
251
    d->comment = TagPrivate::stringHandler->parse(data.mid(offset, 30));
251
  offset += 30;
252
  offset += 30;
(-)taglib-1.8/taglib/mpeg/id3v2/frames/commentsframe.cpp (-4 / +6 lines)
Lines 150-159 Link Here
150
    return;
150
    return;
151
  }
151
  }
152
  d->textEncoding = String::Type(data[0]);
152
  d->textEncoding = String::ID3Type(data[0]);
153
  d->language = data.mid(1, 3);
153
  d->language = data.mid(1, 3);
154
  int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
154
  int byteAlign = (d->textEncoding == String::Latin1 || d->textEncoding == String::Latin1ID3 || d->textEncoding == String::Latin1ID3V2 || d->textEncoding == String::UTF8) ? 1 : 2;
155
  ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
155
  ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
Lines 174-183 Link Here
174
  String::Type encoding = d->textEncoding;
174
  String::Type encoding = d->textEncoding;
175
  encoding = String::ID3WType(encoding);
176
175
  encoding = checkTextEncoding(d->description, encoding);
177
  encoding = checkTextEncoding(d->description, encoding);
176
  encoding = checkTextEncoding(d->text, encoding);
178
  encoding = checkTextEncoding(d->text, encoding);
177
179
178
  v.append(char(encoding));
180
  v.append(char(String::ID3RealType(encoding)));
179
  v.append(d->language.size() == 3 ? d->language : "XXX");
181
  v.append(d->language.size() == 3 ? d->language : "XXX");
180
  v.append(d->description.data(encoding));
182
  v.append(d->description.data(encoding));
181
  v.append(textDelimiter(encoding));
183
  v.append(textDelimiter(encoding));
(-)taglib-1.8/taglib/mpeg/id3v2/frames/textidentificationframe.cpp (-4 / +7 lines)
Lines 187-198 Link Here
187
  // read the string data type (the first byte of the field data)
187
  // read the string data type (the first byte of the field data)
188
  d->textEncoding = String::Type(data[0]);
188
  d->textEncoding = String::ID3Type(data[0]);
189
  // split the byte array into chunks based on the string type (two byte delimiter
189
  // split the byte array into chunks based on the string type (two byte delimiter
190
  // for unicode encodings)
190
  // for unicode encodings)
191
  int byteAlign = d->textEncoding == String::Latin1 || d->textEncoding == String::UTF8 ? 1 : 2;
191
  int byteAlign = (d->textEncoding == String::Latin1 || d->textEncoding == String::Latin1ID3 || d->textEncoding == String::Latin1ID3V2 || d->textEncoding == String::UTF8) ? 1 : 2;
192
  // build a small counter to strip nulls off the end of the field
192
  // build a small counter to strip nulls off the end of the field
Lines 223-233 Link Here
223
ByteVector TextIdentificationFrame::renderFields() const
223
ByteVector TextIdentificationFrame::renderFields() const
224
{
224
{
225
  String::Type encoding = checkTextEncoding(d->fieldList, d->textEncoding);
225
  String::Type encoding = d->textEncoding;
226
227
  encoding = String::ID3WType(encoding);
228
  encoding = checkTextEncoding(d->fieldList, encoding);
226
  ByteVector v;
229
  ByteVector v;
227
  v.append(char(encoding));
230
  v.append(char(String::ID3RealType(encoding)));
228
  for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {
231
  for(StringList::ConstIterator it = d->fieldList.begin(); it != d->fieldList.end(); it++) {
(-)taglib-1.8/taglib/toolkit/rccpatch.cpp (+192 lines)
Line 0 Link Here
1
#include <stdlib.h>
2
3
#include <string>
4
#include "tstring.h"
5
#include "tbytevector.h"
6
7
#ifndef HAVE_LIBRCC
8
# include <config.h>
9
#endif
10
11
#ifdef HAVE_LIBRCC
12
# include <librcc.h>
13
# include <string.h>
14
#endif /* HAVE_LIBRCC */
15
16
17
#ifdef HAVE_LIBRCC
18
# define ID3_CLASS 0
19
# define ID3V2_CLASS 1
20
# define UTF_CLASS 2
21
# define OUT_CLASS 3
22
static rcc_class classes[] = {
23
    { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
24
    { "id3v2", RCC_CLASS_STANDARD, "id3", NULL, "ID3 v.2 Encoding", 0 },
25
    { "utf", RCC_CLASS_KNOWN, "UTF-8", NULL, "Unicode Encoding", 0},
26
    { "out", RCC_CLASS_TRANSLATE_LOCALE, "LC_CTYPE", NULL, "Output Encoding", 0 },
27
    { NULL, RCC_CLASS_STANDARD, NULL, NULL, NULL, 0 }
28
};
29
30
static int rcc_initialized = 0;
31
32
static rcc_context ctx = NULL;
33
#endif /* HAVE_LIBRCC */
34
35
36
void rccPatchFree() {
37
#ifdef HAVE_LIBRCC
38
    if (rcc_initialized) {
39
       rccFree();
40
       rcc_initialized = 0;
41
    }
42
#endif /* HAVE_LIBRCC */
43
}
44
45
void rccPatchInit() {
46
#ifdef HAVE_LIBRCC
47
    if (rcc_initialized) return;
48
    rccInit();
49
    rccInitDefaultContext(NULL, 0, 0, classes, 0);
50
    rccLoad(NULL, "xmms");
51
    rccInitDb4(NULL, NULL, 0);
52
    rcc_initialized = 1;
53
#endif /* HAVE_LIBRCC */
54
}
55
56
void rccPatchSetContext(void *newctx) {
57
#ifdef HAVE_LIBRCC
58
    if (newctx) {
59
	ctx = (rcc_context)newctx;
60
	rcc_initialized = 1;
61
    }
62
#endif /* HAVE_LIBRCC */
63
}
64
65
static void rccPatchTryInit() {
66
#ifdef HAVE_LIBRCC
67
    if (!rcc_initialized) {
68
	rccPatchInit();
69
	if (rcc_initialized) atexit(rccPatchFree);
70
    }
71
#endif /* HAVE_LIBRCC */
72
}
73
74
75
TagLib::ByteVector rccPatchRecodeOutput(const std::string &s) {
76
    TagLib::ByteVector v;
77
#ifdef HAVE_LIBRCC
78
    size_t rlen;
79
    char *res;
80
81
    rccPatchTryInit();
82
83
    res = rccSizedRecode(ctx, UTF_CLASS, OUT_CLASS, s.c_str(), s.length(), &rlen);
84
    if (res) v.setData(res, rlen);
85
    else v.setData(s.c_str(), s.length());
86
87
    return v;
88
#else
89
    v.setData("", 0);
90
91
    return v;
92
#endif /* HAVE_LIBRCC */
93
}
94
95
TagLib::ByteVector rccPatchRecodeOutputID3(const std::string &s, bool v2 = false) {
96
    TagLib::ByteVector v;
97
#ifdef HAVE_LIBRCC
98
    size_t rlen;
99
    char *res;
100
101
    rccPatchTryInit();
102
103
    res = rccSizedRecode(ctx, UTF_CLASS, v2?ID3V2_CLASS:ID3_CLASS, s.c_str(), s.length(), &rlen);
104
    if (res) v.setData(res, rlen);
105
    else v.setData(s.c_str(), s.length());
106
107
    return v;
108
#else
109
    v.setData("", 0);
110
111
    return v;
112
#endif /* HAVE_LIBRCC */
113
}
114
115
TagLib::ByteVector rccPatchRecodeInput(const std::string &s) {
116
    TagLib::ByteVector v;
117
#ifdef HAVE_LIBRCC
118
    size_t rlen;
119
    char *res;
120
121
    rccPatchTryInit();
122
123
    res = rccSizedRecode(ctx, OUT_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
124
    if (res) v.setData(res, rlen);
125
    else
126
#endif /* HAVE_LIBRCC */
127
    v.setData("", 0);
128
129
    return v;
130
}
131
132
TagLib::ByteVector rccPatchRecodeInputID3(const std::string &s, bool v2 = false) {
133
    TagLib::ByteVector v;
134
#ifdef HAVE_LIBRCC
135
    size_t rlen;
136
    char *res;
137
138
    rccPatchTryInit();
139
140
    res = rccSizedRecode(ctx, v2?ID3V2_CLASS:ID3_CLASS, UTF_CLASS, s.c_str(), s.length(), &rlen);
141
    if (res) v.setData(res, rlen);
142
    else
143
#endif /* HAVE_LIBRCC */
144
    v.setData("", 0);
145
146
    return v;
147
}
148
149
TagLib::String::Type rccPatchGetLocaleType() {
150
#ifdef HAVE_LIBRCC
151
    size_t len;
152
    char charset[32];
153
154
    rccPatchTryInit();
155
156
    if (!rccLocaleGetCharset(charset, NULL, 31)) {
157
	if (!strncmp(charset, "UTF", 3)) {
158
	    len = strlen(charset);
159
160
	    if (charset[len-1]=='8') return TagLib::String::UTF8;
161
	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
162
	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
163
	    if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
164
	}
165
	return TagLib::String::Latin1;
166
    }
167
#endif /* HAVE_LIBRCC */
168
    return TagLib::String::UTF8;
169
}
170
171
TagLib::String::Type rccPatchGetID3Type() {
172
#ifdef HAVE_LIBRCC
173
    size_t len;
174
    const char *charset;
175
176
    rccPatchTryInit();
177
178
    charset = rccGetCurrentCharsetName(ctx, ID3V2_CLASS);
179
    if (charset) {
180
	if (!strncmp(charset, "UTF", 3)) {
181
	    len = strlen(charset);
182
183
	    if (charset[len-1]=='8') return TagLib::String::UTF8;
184
	    if (!strcmp(charset+(len-2),"16")) return TagLib::String::UTF16;
185
	    if (!strcmp(charset+(len-4),"16LE")) return TagLib::String::UTF16LE;
186
	    if (!strcmp(charset+(len-4),"16BE")) return TagLib::String::UTF16BE;
187
	}
188
	return TagLib::String::Latin1ID3V2;
189
    }
190
#endif /* HAVE_LIBRCC */
191
    return TagLib::String::Latin1;
192
}
(-)taglib-1.8/taglib/toolkit/rccpatch.h (+20 lines)
Line 0 Link Here
1
#ifndef _RCC_PATCH_H
2
#define _RCC_PATCH_H
3
4
#include <string.h>
5
#include "tstring.h"
6
#include "tbytevector.h"
7
8
void rccPatchFree();
9
void rccPatchInit();
10
void rccPatchSetContext(void *newctx);
11
12
TagLib::ByteVector rccPatchRecodeOutput(const std::string &s);
13
TagLib::ByteVector rccPatchRecodeInput(const std::string &s);
14
TagLib::ByteVector rccPatchRecodeOutputID3(const std::string &s, bool v2 = false);
15
TagLib::ByteVector rccPatchRecodeInputID3(const std::string &s, bool v2 = false);
16
17
TagLib::String::Type rccPatchGetLocaleType();
18
TagLib::String::Type rccPatchGetID3Type();
19
20
#endif /* _RCC_PATCH_H */
(-)taglib-1.8/taglib/toolkit/tstring.cpp (-3 / +60 lines)
Lines 23-28 Link Here
23
 *   http://www.mozilla.org/MPL/                                           *
23
 *   http://www.mozilla.org/MPL/                                           *
24
 ***************************************************************************/
24
 ***************************************************************************/
25
#include "rccpatch.h"
25
#include "tstring.h"
26
#include "tstring.h"
26
#include "unicode.h"
27
#include "unicode.h"
27
#include "tdebug.h"
28
#include "tdebug.h"
Lines 168-174 Link Here
168
  if(v.isEmpty())
169
  if(v.isEmpty())
169
    return;
170
    return;
170
  if(t == Latin1 || t == UTF8) {
171
  if(t == Latin1 || t == Latin1ID3 || t == Latin1ID3V2 || t == UTF8) {
171
    int length = 0;
172
    int length = 0;
172
    d->data.resize(v.size());
173
    d->data.resize(v.size());
Lines 397-406 Link Here
397
{
398
{
398
  ByteVector v;
399
  ByteVector v;
399
  switch(t) {
400
  if (t == Locale) t = rccPatchGetLocaleType();
401
  switch(t) {
402
  case Locale:
400
  case Latin1:
403
  case Latin1:
404
  case Latin1ID3:
405
  case Latin1ID3V2:
401
  {
406
  {
407
    std::string s = to8Bit(true);
408
    if (t == Latin1ID3) v = rccPatchRecodeOutputID3(s, false);
409
    else if (t == Latin1ID3V2) v = rccPatchRecodeOutputID3(s, true);
410
    else /* if (t == Latin1(Locale) */ v = rccPatchRecodeOutput(s);
411
412
    if (v.size()) return v;
413
402
    for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
414
    for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++)
403
      v.append(char(*it));
415
      v.append(char(*it));
404
    break;
416
    break;
Lines 750-755 Link Here
750
void String::prepare(Type t)
762
void String::prepare(Type t)
751
{
763
{
764
  if (t == Locale) t = rccPatchGetLocaleType();
765
766
  if ((t == Latin1)||(t == Latin1ID3)||(t == Latin1ID3V2)) {
767
    std::string s = to8Bit(false);
768
    ByteVector v;
769
770
    if (t == Latin1ID3) v = rccPatchRecodeInputID3(s, false);
771
    else if (t == Latin1ID3V2) v = rccPatchRecodeInputID3(s, true);
772
    else /* Latin1 converted from Locale */ v = rccPatchRecodeInput(s);
773
774
    if (v.size()) {
775
	int length = 0;
776
	d->data.resize(v.size());
777
	wstring::iterator targetIt = d->data.begin();
778
	for(ByteVector::ConstIterator it = v.begin(); it != v.end() && (*it); ++it) {
779
    	    *targetIt = uchar(*it);
780
    	    ++targetIt;
781
    	     ++length;
782
	}
783
	d->data.resize(length);
784
        t = UTF8;
785
    }
786
  }
787
752
  switch(t) {
788
  switch(t) {
753
  case UTF16:
789
  case UTF16:
754
  {
790
  {
Lines 839-844 Link Here
839
std::ostream &operator<<(std::ostream &s, const String &str)
875
std::ostream &operator<<(std::ostream &s, const String &str)
840
{
876
{
841
  s << str.to8Bit();
877
  ByteVector bv = str.data(String::Locale);
878
  s << bv;
842
  return s;
879
  return s;
843
}
880
}
881
882
String::Type String::ID3Type(int i) {
883
	if (i == Latin1) return Latin1ID3V2;
884
	return Type(i);
885
};
886
887
String::Type String::ID3WType(Type type) {
888
    Type rcc_type = rccPatchGetID3Type();
889
    if ((rcc_type == Latin1ID3)||(rcc_type == Latin1ID3V2)) {
890
	if (type == Latin1) return rcc_type;
891
	return type;
892
    }
893
894
    return rcc_type;
895
};
896
897
String::Type String::ID3RealType(Type type) {
898
    if ((type == Latin1ID3)||(type == Latin1ID3V2)) return Latin1;
899
    return type;
900
}
(-)taglib-1.8/taglib/toolkit/tstring.h (+16 lines)
Lines 90-95 Link Here
90
     */
90
     */
91
    enum Type {
91
    enum Type {
92
      /*!
92
      /*!
93
       * Determine using current locale settings
94
       */
95
      Locale = -1,
96
      /*!
97
       * Latin1 for ID3 tags.
98
       */
99
      Latin1ID3 = 65,
100
      /*!
101
       * Latin1 for ID3 tags.
102
       */
103
      Latin1ID3V2 = 66,
104
      /*!
93
       * IS08859-1, or <i>Latin1</i> encoding.  8 bit characters.
105
       * IS08859-1, or <i>Latin1</i> encoding.  8 bit characters.
94
       */
106
       */
95
      Latin1 = 0,
107
      Latin1 = 0,
Lines 112-117 Link Here
112
      UTF16LE = 4
124
      UTF16LE = 4
113
    };
125
    };
126
    static Type ID3Type(int i);
127
    static Type ID3WType(Type type);
128
    static Type ID3RealType(Type type);
129
114
    /*!
130
    /*!
115
     * Constructs an empty String.
131
     * Constructs an empty String.
116
     */
132
     */

Return to bug 28700