[Mplayer-cvslog] CVS: main subreader.c, 1.137, 1.138 subreader.h, 1.35, 1.36
Sascha Sommer CVS
syncmail at mplayerhq.hu
Wed Sep 15 15:16:55 CEST 2004
CVS change done by Sascha Sommer CVS
Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv3763
Modified Files:
subreader.c subreader.h
Log Message:
This time is a patch to improve subtitle alignment management. It
implements
SSA alignment styles; note that alignment for SSA files is not actually
supported, but for SAMI files (which use the same alignment codes) it
is.
patch by Salvatore Falco <sfalco at studenti.ing.uniroma1.it>
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- subreader.c 2 Sep 2004 12:18:36 -0000 1.137
+++ subreader.c 15 Sep 2004 13:16:52 -0000 1.138
@@ -100,6 +100,7 @@
int state;
current->lines = current->start = current->end = 0;
+ current->alignment = SUB_ALIGNMENT_BOTTOMCENTER;
state = 0;
/* read the first line */
@@ -173,7 +174,38 @@
s = strchr (s, '>');
if (s) { s++; state = 3; continue; }
break;
- case 5: /* get rid of {...} text */
+ case 5: /* get rid of {...} text, but read the alignment code */
+ if ((*s == '\\') && (*(s + 1) == 'a') && !sub_no_text_pp) {
+ if (stristr(s, "\\a1") != NULL) {
+ current->alignment = SUB_ALIGNMENT_BOTTOMLEFT;
+ s = s + 3;
+ }
+ if (stristr(s, "\\a2") != NULL) {
+ current->alignment = SUB_ALIGNMENT_BOTTOMCENTER;
+ s = s + 3;
+ } else if (stristr(s, "\\a3") != NULL) {
+ current->alignment = SUB_ALIGNMENT_BOTTOMRIGHT;
+ s = s + 3;
+ } else if ((stristr(s, "\\a4") != NULL) || (stristr(s, "\\a5") != NULL) || (stristr(s, "\\a8") != NULL)) {
+ current->alignment = SUB_ALIGNMENT_TOPLEFT;
+ s = s + 3;
+ } else if (stristr(s, "\\a6") != NULL) {
+ current->alignment = SUB_ALIGNMENT_TOPCENTER;
+ s = s + 3;
+ } else if (stristr(s, "\\a7") != NULL) {
+ current->alignment = SUB_ALIGNMENT_TOPRIGHT;
+ s = s + 3;
+ } else if (stristr(s, "\\a9") != NULL) {
+ current->alignment = SUB_ALIGNMENT_MIDDLELEFT;
+ s = s + 3;
+ } else if (stristr(s, "\\a10") != NULL) {
+ current->alignment = SUB_ALIGNMENT_MIDDLECENTER;
+ s = s + 4;
+ } else if (stristr(s, "\\a11") != NULL) {
+ current->alignment = SUB_ALIGNMENT_MIDDLERIGHT;
+ s = s + 4;
+ }
+ }
if (*s == '}') state = 3;
++s;
continue;
@@ -889,11 +921,11 @@
continue;
}
if (strstr(directive, "JL") != NULL) {
- current->alignment = SUB_ALIGNMENT_HLEFT;
+ current->alignment = SUB_ALIGNMENT_BOTTOMLEFT;
} else if (strstr(directive, "JR") != NULL) {
- current->alignment = SUB_ALIGNMENT_HRIGHT;
+ current->alignment = SUB_ALIGNMENT_BOTTOMRIGHT;
} else {
- current->alignment = SUB_ALIGNMENT_HCENTER;
+ current->alignment = SUB_ALIGNMENT_BOTTOMCENTER;
}
strcpy(line2, line1);
p = line2;
@@ -1635,7 +1667,7 @@
memset(&second[sub_num], '\0', sizeof(subtitle));
second[sub_num].start = local_start;
second[sub_num].end = local_end;
- second[sub_num].alignment = SUB_ALIGNMENT_HCENTER;
+ second[sub_num].alignment = first[sub_first].alignment;
n_max = (lines_to_add < SUB_MAX_TEXT) ? lines_to_add : SUB_MAX_TEXT;
for (i = 0, j = 0; j < n_max; ++j) {
if (placeholder[counter][j] != -1) {
Index: subreader.h
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- subreader.h 2 Aug 2004 06:46:48 -0000 1.35
+++ subreader.h 15 Sep 2004 13:16:52 -0000 1.36
@@ -30,9 +30,15 @@
#define MAX_SUBTITLE_FILES 128
#define SUB_MAX_TEXT 10
-#define SUB_ALIGNMENT_HLEFT 1
-#define SUB_ALIGNMENT_HCENTER 0
-#define SUB_ALIGNMENT_HRIGHT 2
+#define SUB_ALIGNMENT_BOTTOMLEFT 1
+#define SUB_ALIGNMENT_BOTTOMCENTER 2
+#define SUB_ALIGNMENT_BOTTOMRIGHT 3
+#define SUB_ALIGNMENT_MIDDLELEFT 4
+#define SUB_ALIGNMENT_MIDDLECENTER 5
+#define SUB_ALIGNMENT_MIDDLERIGHT 6
+#define SUB_ALIGNMENT_TOPLEFT 7
+#define SUB_ALIGNMENT_TOPCENTER 8
+#define SUB_ALIGNMENT_TOPRIGHT 9
typedef struct {
More information about the MPlayer-cvslog
mailing list