summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-09 22:19:38 +0100
committerwm4 <wm4@nowhere>2015-03-09 22:19:38 +0100
commit0d94ff48077ba683bfd4d0b9ff7ded895ba20919 (patch)
tree732c670d0f21437470a890eb9008ca6b80862c00
parent4567ad1e3c373ee185d3ba7f044222442ea55534 (diff)
downloadlibass-0d94ff48077ba683bfd4d0b9ff7ded895ba20919.tar.bz2
libass-0d94ff48077ba683bfd4d0b9ff7ded895ba20919.tar.xz
Ignore extra coordinates in drawings
If there's an odd number of values, ignore the extra value, instead of shifting all values after the next command. While such drawings are boken strictly speaking, VSFilter handles them gracefully, and what libass did before this commit made no sense anyway. Test case: {\an7\pos(0.01,0.7)\c&H5A493D&\p1\iclip(11,m 857379 -744112 l 517759 -744112 517759 -942768 857379 -942768 m 851235 -422238 l 689105 -422238 689105 -620546 851235 -620546 m 679889 -421552 l 517411 -421552 517411 -620894 679889 -620894 -55984 m 860113 425634 l 519459 425634 519459 226640 860113 226640 m 868305 992080 l 465361 992080 465361 793936 868305 793936 m 841343 1317200 l 520145 1317200 520145 1118206 841343 1118206 m 411662 -245762 b 411662 -242373 408918 -239618 405518 -239618 l 342931 -239618 b 339532 -239618 336787 -242373 336787 -245762 l 336787 -308226 b 336787 -311626 339532 -314370 342931 -314370 l 405518 -314370 b 408918 -314370 411662 -311626 411662 -308226 m 414929 -907440 b 414929 -904051 412174 -901296 408785 -901296 l 346198 -901296 b 342798 -901296 340054 -904051 340054 -907440 l 340054 -969904 b 340054 -973294 342798 -976048 346198 -976048 l 408785 -976048 b 412174 -976048 414929 -973294 414929 -969904 m 414417 -585904 b 414417 -582515 411652 -579760 408252 -579760 l 345450 -579760 b 342041 -579760 339286 -582515 339286 -585904 l 339286 -648368 b 339286 -651758 342041 -654512 345450 -654512 l 408252 -654512 b 411652 -654512 414417 -651758 414417 -648368 m 414929 -44997 b 414929 -41597 412174 -38832 408785 -38832 l 346198 -38832 b 342798 -38832 340054 -41597 340054 -44997 l 340054 -107676 b 340054 -111075 342798 -113840 346198 -113840 l 408785 -113840 b 412174 -113840 414929 -111075 414929 -107676 m 415932 261456 b 415932 264845 413178 267600 409788 267600 l 347191 267600 b 343802 267600 341047 264845 341047 261456 l 341047 198992 b 341047 195602 343802 192848 347191 192848 l 409788 192848 b 413178 192848 415932 195602 415932 198992 m 414929 564048 b 414929 567437 412174 570192 408785 570192 l 346198 570192 b 342798 570192 340054 567437 340054 564048 l 340054 501584 b 340054 498194 342798 495440 346198 495440 l 408785 495440 b 412174 495440 414929 498194 414929 501584 m 414929 781136 b 414929 784525 412174 787280 408785 787280 l 346198 787280 b 342798 787280 340054 784525 340054 781136 l 340054 718672 b 340054 715282 342798 712528 346198 712528 l 408785 712528 b 412174 712528 414929 715282 414929 718672 m 414929 1133525 b 414929 1136914 412174 1139669 408785 1139669 l 346198 1139669 b 342798 1139669 340054 1136914 340054 1133525 l 340054 1071061 b 340054 1067661 342798 1064917 346198 1064917 l 408785 1064917 b 412174 1064917 414929 1067661 414929 1071061)}m 0 0 l 1280 0 1280 720 0 720 0 0{\p0}
-rw-r--r--libass/ass_drawing.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libass/ass_drawing.c b/libass/ass_drawing.c
index e2676df..51bca83 100644
--- a/libass/ass_drawing.c
+++ b/libass/ass_drawing.c
@@ -140,6 +140,7 @@ static ASS_DrawingToken *drawing_tokenize(char *str)
ASS_DrawingToken *root = NULL, *tail = NULL, *spline_start = NULL;
while (p && *p) {
+ int got_coord = 0;
if (*p == 'c' && spline_start) {
// Close b-splines: add the first three points of the b-spline
// back to the end
@@ -157,10 +158,12 @@ static ASS_DrawingToken *drawing_tokenize(char *str)
} else if (!is_set && mystrtod(&p, &val)) {
point.x = double_to_d6(val);
is_set = 1;
+ got_coord = 1;
p--;
} else if (is_set == 1 && mystrtod(&p, &val)) {
point.y = double_to_d6(val);
is_set = 2;
+ got_coord = 1;
p--;
} else if (*p == 'm')
type = TOKEN_MOVE;
@@ -178,6 +181,10 @@ static ASS_DrawingToken *drawing_tokenize(char *str)
// This is not harmful at all, since it can be ommitted with
// similar result (the spline is extended anyway).
+ // Ignore the odd extra value, it makes no sense.
+ if (!got_coord)
+ is_set = 0;
+
if (type != -1 && is_set == 2) {
if (root) {
tail->next = calloc(1, sizeof(ASS_DrawingToken));