aboutsummaryrefslogtreecommitdiff
path: root/japanese/gqmpeg
diff options
context:
space:
mode:
Diffstat (limited to 'japanese/gqmpeg')
-rw-r--r--japanese/gqmpeg/Makefile12
-rw-r--r--japanese/gqmpeg/files/extra-patch-src::japanese_tag.c79
-rw-r--r--japanese/gqmpeg/files/extra-patch-src::japanese_tag.h10
-rw-r--r--japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c83
4 files changed, 184 insertions, 0 deletions
diff --git a/japanese/gqmpeg/Makefile b/japanese/gqmpeg/Makefile
index a55598118341..6d551b962c9e 100644
--- a/japanese/gqmpeg/Makefile
+++ b/japanese/gqmpeg/Makefile
@@ -12,6 +12,10 @@ MAINTAINER= katsu@iec.hiroshima-u.ac.jp
PATCH_SITES= http://linuxlovers.yi.org/softarc/
PATCHFILES= gqmpeg-0.9.0-jp_title.patch
+.if defined(WITH_SJIS_TAG)
+EXTRA_PATCHES= ${.CURDIR}/files/extra-patch-*
+.endif
+
MASTERDIR= ${.CURDIR}/../../audio/gqmpeg
MD5_FILE= ${.CURDIR}/distinfo
COMMENT= ${.CURDIR}/pkg-comment
@@ -21,4 +25,12 @@ CONFIGURE_ARGS= --enable-japanese
NOMAN= yes
+.if !defined(WITH_SJIS_TAG)
+pre-everything::
+ @${ECHO_MSG}
+ @${ECHO_MSG} "If you want to save ID3 tags as SJIS(default: EUC),"
+ @${ECHO_MSG} "hit Ctrl-C right now and execute \"make WITH_SJIS_TAG=yes\""
+ @${ECHO_MSG}
+.endif
+
.include "${MASTERDIR}/Makefile"
diff --git a/japanese/gqmpeg/files/extra-patch-src::japanese_tag.c b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.c
new file mode 100644
index 000000000000..cf46e48efd07
--- /dev/null
+++ b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.c
@@ -0,0 +1,79 @@
+--- ./src/japanese_tag.c.orig Fri Jan 5 00:35:31 2001
++++ ./src/japanese_tag.c Fri Jan 4 05:58:49 2002
+@@ -64,6 +64,16 @@
+ *p2 -= cellOffset;
+ }
+
++static void _sjis_rev_shift(int *p1, int *p2)
++{
++ unsigned char c1 = *p1;
++ unsigned char c2 = *p2;
++ int rowOffset = c1 < 95 ? 112 : 176;
++ int cellOffset = c1 % 2 ? (c2 > 95 ? 32 : 31) : 126;
++ *p1 = ((c1 + 1) >> 1) + rowOffset;
++ *p2 += cellOffset;
++}
++
+ static unsigned char *_skip_esc(unsigned char *str, int *esc_in)
+ {
+ int c;
+@@ -139,6 +149,36 @@
+ *str2 = '\0';
+ }
+
++static void _euc2shift(unsigned char const *str, unsigned char *str2)
++{
++ int p1,p2;
++
++ while ((p1 = (int)*str) != '\0') {
++ /* SB-SJIS with SS2 */
++ if (p1 == 0x8e) {
++ if((p2 = (int)*(++str)) == '\0') break;
++ CHAROUT(p1);
++ str++;
++ continue;
++ }
++
++ if ( (p1 >= 161) && ( p1 <= 254) ) {
++ if ((p2 = (int)*(++str)) == '\0') break;
++ if ( (p2 >= 161) && ( p2 <= 254) ) {
++ p1 -= 128, p2 -= 128;
++ _sjis_rev_shift(&p1,&p2);
++ }
++ CHAROUT(p1);
++ CHAROUT(p2);
++ str++;
++ continue;
++ }
++ CHAROUT(p1);
++ str++;
++ }
++ *str2='\0';
++}
++
+ static int _detect(unsigned char *str, int expected)
+ {
+ register int c;
+@@ -313,6 +353,22 @@
+
+ ret = g_strdup(buf);
+ g_free(buf);
++ return ret;
++}
++
++char *to_string_sjis_from_euc(char const *str)
++{
++ char *buf, *ret;
++
++ if(!str) return (NULL);
++
++ buf = (char*)g_malloc(strlen(str)*2 + 1);
++ if (!buf) return NULL;
++
++ _euc2shift((unsigned char *)str, (unsigned char *)buf);
++
++ ret = strdup(buf);
++ free(buf);
+ return ret;
+ }
+
diff --git a/japanese/gqmpeg/files/extra-patch-src::japanese_tag.h b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.h
new file mode 100644
index 000000000000..c495dec1247f
--- /dev/null
+++ b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.h
@@ -0,0 +1,10 @@
+--- ./src/japanese_tag.h.orig Fri Jan 5 00:43:02 2001
++++ ./src/japanese_tag.h Fri Jan 4 04:24:21 2002
+@@ -16,6 +16,7 @@
+ #ifdef ENABLE_JAPANESE_TAGS
+
+ char *to_string_euc(char *str);
++char *to_string_sjis_from_euc(char const *str);
+
+ #endif /* ENABLE_JAPANESE_TAGS */
+
diff --git a/japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c b/japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c
new file mode 100644
index 000000000000..bf6afa130d89
--- /dev/null
+++ b/japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c
@@ -0,0 +1,83 @@
+--- ./src/mpg_tagutil.c.orig Thu Oct 25 10:56:57 2001
++++ ./src/mpg_tagutil.c Fri Jan 4 05:58:35 2002
+@@ -149,6 +149,12 @@
+ FILE *f;
+ gchar buf[130];
+ gint i;
++#ifdef ENABLE_JAPANESE_TAGS
++ gchar tmpbuf[31];
++ gchar *ctp;
++
++ tmpbuf[30] = '\0';
++#endif
+
+ f = fopen(path,"r+");
+ if (!f)
+@@ -209,11 +215,67 @@
+ }
+
+ strncpy(buf, "TAG", 3);
++#ifdef ENABLE_JAPANESE_TAGS
++ if (title && *title) {
++ strncpy(tmpbuf, title, 30);
++ ctp = to_string_sjis_from_euc(tmpbuf);
++ if (ctp) {
++ strncpy(buf + 3, ctp, 30);
++ free(ctp);
++ }
++ else {
++ printf("fail to convert title tag encoding\n");
++ fclose(f);
++ return FALSE;
++ }
++ }
++ if (artist && *artist) {
++ strncpy(tmpbuf, artist, 30);
++ ctp = to_string_sjis_from_euc(tmpbuf);
++ if (ctp) {
++ strncpy(buf + 33, ctp, 30);
++ free(ctp);
++ }
++ else {
++ printf("fail to convert artist tag encoding\n");
++ fclose(f);
++ return FALSE;
++ }
++ }
++ if (album && *album) {
++ strncpy(tmpbuf, album, 30);
++ ctp = to_string_sjis_from_euc(tmpbuf);
++ if (ctp) {
++ strncpy(buf + 63, ctp, 30);
++ free(ctp);
++ }
++ else {
++ printf("fail to convert album tag encoding\n");
++ fclose(f);
++ return FALSE;
++ }
++ }
++ if (year) strncpy(buf + 93, year, 4);
++ if (comment && *comment) {
++ strncpy(tmpbuf, comment, 30);
++ ctp = to_string_sjis_from_euc(tmpbuf);
++ if (ctp) {
++ strncpy(buf + 97, ctp, 30);
++ free(ctp);
++ }
++ else {
++ printf("fail to convert comment tag encoding\n");
++ fclose(f);
++ return FALSE;
++ }
++ }
++#else
+ if (title) strncpy(buf + 3, title, 30);
+ if (artist) strncpy(buf + 33, artist, 30);
+ if (album) strncpy(buf + 63, album, 30);
+ if (year) strncpy(buf + 93, year, 4);
+ if (comment) strncpy(buf + 97, comment, 30);
++#endif
+
+ for (i=0; i<128; i++)
+ {