summaryrefslogtreecommitdiffstats
path: root/media-sound/mpg123/files/mpg123-ds-rcc65.patch
blob: 41a4d33b153a7b2b18ad4fdf7ba9b239186dce37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
diff -dPNur mpg123-0.65/configure.ac mpg123-0.65-new/configure.ac
--- mpg123-0.65/configure.ac	2007-02-07 10:24:33.000000000 +0100
+++ mpg123-0.65-new/configure.ac	2007-04-15 13:36:52.000000000 +0200
@@ -137,6 +137,21 @@
 AC_CHECK_LIB([m], [sqrt])
 AC_CHECK_LIB([mx], [powf])
 
+# LibRCC
+AC_CHECK_LIB(rcc, rccInit,[
+    AC_CHECK_HEADERS(librcc.h,[
+       LIBRCC_LIBS="-lrcc"
+       LIBRCC_INCLUDES="-DHAVE_LIBRCC"
+    ],[
+       LIBRCC_LIBS=""
+       LIBRCC_INCLUDES=""
+])],[
+    LIBRCC_LIBS=""
+    LIBRCC_INCLUDES=""
+])
+AC_SUBST(LIBRCC_LIBS)
+AC_SUBST(LIBRCC_INCLUDES)
+
 # Check for JACK
 PKG_CHECK_MODULES(JACK, jack, HAVE_JACK=yes, HAVE_JACK=no)
 
diff -dPNur mpg123-0.65/src/id3.c mpg123-0.65-new/src/id3.c
--- mpg123-0.65/src/id3.c	2007-02-07 10:24:33.000000000 +0100
+++ mpg123-0.65-new/src/id3.c	2007-04-15 13:26:06.000000000 +0200
@@ -6,6 +6,7 @@
 #include "stringbuf.h"
 #include "genre.h"
 #include "id3.h"
+#include "rccpatch.h"
 
 struct taginfo
 {
@@ -499,6 +500,8 @@
 void print_id3_tag(unsigned char *id3v1buf)
 {
 	char genre_from_v1 = 0;
+	char *ctitle, *cartist, *calbum, *ccomment;
+	
 	if(!(id3.version || id3v1buf)) return;
 	if(id3v1buf != NULL)
 	{
@@ -688,17 +691,26 @@
 		free_stringbuf(&tmp);
 	}
 
+	if (id3.title.fill) ctitle = rccPatchRecode(id3.title.p);
+	else ctitle = NULL;
+	if (id3.artist.fill) cartist = rccPatchRecode(id3.artist.p);
+	else cartist = NULL;
+	if (id3.album.fill) calbum = rccPatchRecode(id3.album.p);
+	else calbum = NULL;
+	if (id3.comment.fill) ccomment = rccPatchRecode(id3.comment.p);
+	else ccomment = NULL;
+
 	if(param.long_id3)
 	{
 		fprintf(stderr,"\n");
 		/* print id3v2 */
 		/* dammed, I use pointers as bool again! It's so convenient... */
-		fprintf(stderr,"\tTitle:   %s\n", id3.title.fill ? id3.title.p : "");
-		fprintf(stderr,"\tArtist:  %s\n", id3.artist.fill ? id3.artist.p : "");
-		fprintf(stderr,"\tAlbum:   %s\n", id3.album.fill ? id3.album.p : "");
+		fprintf(stderr,"\tTitle:   %s\n", ctitle?ctitle:(id3.title.fill ? id3.title.p : ""));
+		fprintf(stderr,"\tArtist:  %s\n", cartist?cartist:(id3.artist.fill ? id3.artist.p : ""));
+		fprintf(stderr,"\tAlbum:   %s\n", calbum?calbum:(id3.album.fill ? id3.album.p : ""));
 		fprintf(stderr,"\tYear:    %s\n", id3.year.fill ? id3.year.p : "");
 		fprintf(stderr,"\tGenre:   %s\n", id3.genre.fill ? id3.genre.p : "");
-		fprintf(stderr,"\tComment: %s\n", id3.comment.fill ? id3.comment.p : "");
+		fprintf(stderr,"\tComment: %s\n", ccomment?ccomment:(id3.comment.fill ? id3.comment.p : ""));
 		fprintf(stderr,"\n");
 	}
 	else
@@ -708,23 +720,23 @@
 		/* one _could_ circumvent the strlen calls... */
 		if(id3.title.fill && id3.artist.fill && strlen(id3.title.p) <= 30 && strlen(id3.title.p) <= 30)
 		{
-			fprintf(stderr,"Title:   %-30s  Artist: %s\n",id3.title.p,id3.artist.p);
+			fprintf(stderr,"Title:   %-30s  Artist: %s\n",ctitle?ctitle:id3.title.p,cartist?cartist:id3.artist.p);
 		}
 		else
 		{
-			if(id3.title.fill) fprintf(stderr,"Title:   %s\n", id3.title.p);
-			if(id3.artist.fill) fprintf(stderr,"Artist:  %s\n", id3.artist.p);
+			if(id3.title.fill) fprintf(stderr,"Title:   %s\n", ctitle?ctitle:id3.title.p);
+			if(id3.artist.fill) fprintf(stderr,"Artist:  %s\n", cartist?cartist:id3.artist.p);
 		}
 		if (id3.comment.fill && id3.album.fill && strlen(id3.comment.p) <= 30 && strlen(id3.album.p) <= 30)
 		{
-			fprintf(stderr,"Comment: %-30s  Album:  %s\n",id3.comment.p,id3.album.p);
+			fprintf(stderr,"Comment: %-30s  Album:  %s\n",ccomment?ccomment:id3.comment.p,calbum?calbum:id3.album.p);
 		}
 		else
 		{
 			if (id3.comment.fill)
-				fprintf(stderr,"Comment: %s\n", id3.comment.p);
+				fprintf(stderr,"Comment: %s\n", ccomment?ccomment:id3.comment.p);
 			if (id3.album.fill)
-				fprintf(stderr,"Album:   %s\n", id3.album.p);
+				fprintf(stderr,"Album:   %s\n", calbum?calbum:id3.album.p);
 		}
 		if (id3.year.fill && id3.genre.fill && strlen(id3.year.p) <= 30 && strlen(id3.genre.p) <= 30)
 		{
@@ -738,6 +750,11 @@
 				fprintf(stderr,"Genre:   %s\n", id3.genre.p);
 		}
 	}
+	
+	if (ctitle) free(ctitle);
+	if (cartist) free(cartist);
+	if (calbum) free(calbum);
+	if (ccomment) free(ccomment);
 }
 
 /*
diff -dPNur mpg123-0.65/src/Makefile.am mpg123-0.65-new/src/Makefile.am
--- mpg123-0.65/src/Makefile.am	2007-02-07 10:24:33.000000000 +0100
+++ mpg123-0.65-new/src/Makefile.am	2007-04-15 13:38:44.000000000 +0200
@@ -4,8 +4,8 @@
 ## see COPYING and AUTHORS files in distribution or http://mpg123.de
 ## initially written by Nicholas J. Humfrey
 
-AM_CFLAGS = @AUDIO_CFLAGS@
-AM_LDFLAGS = @AUDIO_LIBS@
+AM_CFLAGS = @AUDIO_CFLAGS@ @LIBRCC_INCLUDES@
+AM_LDFLAGS = @AUDIO_LIBS@ @LIBRCC_LIBS@
 mpg123_LDADD = @AUDIO_OBJ@ @CPU_TYPE_LIB@
 mpg123_DEPENDENCIES = @AUDIO_OBJ@ @CPU_TYPE_LIB@
 
@@ -14,6 +14,8 @@
 
 bin_PROGRAMS = mpg123
 mpg123_SOURCES = \
+	rccpatch.c \
+	rccpatch.h \
 	audio.c \
 	audio.h \
 	buffer.c \
diff -dPNur mpg123-0.65/src/mpg123.c mpg123-0.65-new/src/mpg123.c
--- mpg123-0.65/src/mpg123.c	2007-02-07 10:24:33.000000000 +0100
+++ mpg123-0.65-new/src/mpg123.c	2007-04-15 13:30:42.000000000 +0200
@@ -35,6 +35,7 @@
 #include "layer3.h"
 #endif
 #include "playlist.h"
+#include "rccpatch.h"
 #include "id3.h"
 #include "icy.h"
 
@@ -814,15 +815,18 @@
 
 	if(param.remote) {
 		int ret;
+		rccPatchInit();
 		init_id3();
 		init_icy();
 		ret = control_generic(&fr);
 		clear_icy();
 		exit_id3();
+		rccPatchFree();
 		safe_exit(ret);
 	}
 #endif
 
+	rccPatchInit();
 	init_icy();
 	init_id3(); /* prepare id3 memory */
 	while ((fname = get_next_file())) {
@@ -851,7 +855,7 @@
 	}
 }
 #endif
-
+	
 		}
 
 #if !defined(WIN32) && !defined(GENERIC)
@@ -1031,6 +1035,7 @@
     } /* end of loop over input files */
     clear_icy();
     exit_id3(); /* free id3 memory */
+    rccPatchFree();
 #ifndef NOXFERMEM
     if (param.usebuffer) {
       buffer_end();
diff -dPNur mpg123-0.65/src/rccpatch.c mpg123-0.65-new/src/rccpatch.c
--- mpg123-0.65/src/rccpatch.c	1970-01-01 01:00:00.000000000 +0100
+++ mpg123-0.65-new/src/rccpatch.c	2007-04-15 13:13:09.000000000 +0200
@@ -0,0 +1,40 @@
+#include <librcc.h>
+
+#define ID3_CLASS 0
+#define OUT_CLASS 1
+static rcc_class classes[] = {
+    { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
+    { "out", RCC_CLASS_STANDARD, NULL, NULL, "Output Encoding", 0 },
+    { NULL }
+};
+
+static int rcc_initialized = 0;
+
+void rccPatchFree() {
+    if (rcc_initialized) {
+       rccFree();
+       rcc_initialized = 0;
+    }
+}
+
+void rccPatchInit() {
+    if (rcc_initialized) return;
+    rccInit();
+    rccInitDefaultContext(NULL, 0, 0, classes, 0);
+    rccLoad(NULL, "xmms");
+    rccInitDb4(NULL, NULL, 0);
+    rcc_initialized = 1;
+}
+
+static void rccPatchTryInit() {
+    if (!rcc_initialized) {
+	rccPatchInit();
+	if (rcc_initialized) atexit(rccPatchFree);	
+    }
+}
+
+char *rccPatchRecode(const char *str) {
+    char *res;
+    rccPatchTryInit();
+    return rccRecode(NULL, ID3_CLASS, OUT_CLASS, str);
+}
diff -dPNur mpg123-0.65/src/rccpatch.h mpg123-0.65-new/src/rccpatch.h
--- mpg123-0.65/src/rccpatch.h	1970-01-01 01:00:00.000000000 +0100
+++ mpg123-0.65-new/src/rccpatch.h	2007-04-15 13:13:09.000000000 +0200
@@ -0,0 +1,4 @@
+void rccPatchFree();
+void rccPatchInit();
+char *rccPatchRecode(const char *str);
+