Mercurial > mplayer.hg
comparison libass/ass_render.c @ 28717:7bbe6626f0e0
Support fractional arguments for some override tags.
Done by parsing all integers as doubles first and then converting them to the
nearest integer. Patch by Grigori G (greg chown ath cx).
author | eugeni |
---|---|
date | Fri, 27 Feb 2009 23:06:47 +0000 |
parents | 0a8b23440a61 |
children | e3b5070f671d |
comparison
equal
deleted
inserted
replaced
28716:0a8b23440a61 | 28717:7bbe6626f0e0 |
---|---|
779 int x1, x2, y1, y2; | 779 int x1, x2, y1, y2; |
780 long long t1, t2, delta_t, t; | 780 long long t1, t2, delta_t, t; |
781 double x, y; | 781 double x, y; |
782 double k; | 782 double k; |
783 skip('('); | 783 skip('('); |
784 x1 = strtol(p, &p, 10); | 784 mystrtoi(&p, 10, &x1); |
785 skip(','); | 785 skip(','); |
786 y1 = strtol(p, &p, 10); | 786 mystrtoi(&p, 10, &y1); |
787 skip(','); | 787 skip(','); |
788 x2 = strtol(p, &p, 10); | 788 mystrtoi(&p, 10, &x2); |
789 skip(','); | 789 skip(','); |
790 y2 = strtol(p, &p, 10); | 790 mystrtoi(&p, 10, &y2); |
791 if (*p == ',') { | 791 if (*p == ',') { |
792 skip(','); | 792 skip(','); |
793 t1 = strtoll(p, &p, 10); | 793 mystrtoll(&p, 10, &t1); |
794 skip(','); | 794 skip(','); |
795 t2 = strtoll(p, &p, 10); | 795 mystrtoll(&p, 10, &t2); |
796 mp_msg(MSGT_ASS, MSGL_DBG2, "movement6: (%d, %d) -> (%d, %d), (%" PRId64 " .. %" PRId64 ")\n", | 796 mp_msg(MSGT_ASS, MSGL_DBG2, "movement6: (%d, %d) -> (%d, %d), (%" PRId64 " .. %" PRId64 ")\n", |
797 x1, y1, x2, y2, (int64_t)t1, (int64_t)t2); | 797 x1, y1, x2, y2, (int64_t)t1, (int64_t)t2); |
798 } else { | 798 } else { |
799 t1 = 0; | 799 t1 = 0; |
800 t2 = render_context.event->Duration; | 800 t2 = render_context.event->Duration; |
884 else | 884 else |
885 render_context.alignment = render_context.style->Alignment; | 885 render_context.alignment = render_context.style->Alignment; |
886 } else if (mystrcmp(&p, "pos")) { | 886 } else if (mystrcmp(&p, "pos")) { |
887 int v1, v2; | 887 int v1, v2; |
888 skip('('); | 888 skip('('); |
889 v1 = strtol(p, &p, 10); | 889 mystrtoi(&p, 10, &v1); |
890 skip(','); | 890 skip(','); |
891 v2 = strtol(p, &p, 10); | 891 mystrtoi(&p, 10, &v2); |
892 skip(')'); | 892 skip(')'); |
893 mp_msg(MSGT_ASS, MSGL_DBG2, "pos(%d, %d)\n", v1, v2); | 893 mp_msg(MSGT_ASS, MSGL_DBG2, "pos(%d, %d)\n", v1, v2); |
894 if (render_context.evt_type != EVENT_POSITIONED) { | 894 if (render_context.evt_type != EVENT_POSITIONED) { |
895 render_context.evt_type = EVENT_POSITIONED; | 895 render_context.evt_type = EVENT_POSITIONED; |
896 render_context.detect_collisions = 0; | 896 render_context.detect_collisions = 0; |
900 } else if (mystrcmp(&p, "fad")) { | 900 } else if (mystrcmp(&p, "fad")) { |
901 int a1, a2, a3; | 901 int a1, a2, a3; |
902 long long t1, t2, t3, t4; | 902 long long t1, t2, t3, t4; |
903 if (*p == 'e') ++p; // either \fad or \fade | 903 if (*p == 'e') ++p; // either \fad or \fade |
904 skip('('); | 904 skip('('); |
905 a1 = strtol(p, &p, 10); | 905 mystrtoi(&p, 10, &a1); |
906 skip(','); | 906 skip(','); |
907 a2 = strtol(p, &p, 10); | 907 mystrtoi(&p, 10, &a2); |
908 if (*p == ')') { | 908 if (*p == ')') { |
909 // 2-argument version (\fad, according to specs) | 909 // 2-argument version (\fad, according to specs) |
910 // a1 and a2 are fade-in and fade-out durations | 910 // a1 and a2 are fade-in and fade-out durations |
911 t1 = 0; | 911 t1 = 0; |
912 t4 = render_context.event->Duration; | 912 t4 = render_context.event->Duration; |
917 a3 = 0xFF; | 917 a3 = 0xFF; |
918 } else { | 918 } else { |
919 // 6-argument version (\fade) | 919 // 6-argument version (\fade) |
920 // a1 and a2 (and a3) are opacity values | 920 // a1 and a2 (and a3) are opacity values |
921 skip(','); | 921 skip(','); |
922 a3 = strtol(p, &p, 10); | 922 mystrtoi(&p, 10, &a3); |
923 skip(','); | 923 skip(','); |
924 t1 = strtoll(p, &p, 10); | 924 mystrtoll(&p, 10, &t1); |
925 skip(','); | 925 skip(','); |
926 t2 = strtoll(p, &p, 10); | 926 mystrtoll(&p, 10, &t2); |
927 skip(','); | 927 skip(','); |
928 t3 = strtoll(p, &p, 10); | 928 mystrtoll(&p, 10, &t3); |
929 skip(','); | 929 skip(','); |
930 t4 = strtoll(p, &p, 10); | 930 mystrtoll(&p, 10, &t4); |
931 } | 931 } |
932 skip(')'); | 932 skip(')'); |
933 render_context.fade = interpolate_alpha(frame_context.time - render_context.event->Start, t1, t2, t3, t4, a1, a2, a3); | 933 render_context.fade = interpolate_alpha(frame_context.time - render_context.event->Start, t1, t2, t3, t4, a1, a2, a3); |
934 } else if (mystrcmp(&p, "org")) { | 934 } else if (mystrcmp(&p, "org")) { |
935 int v1, v2; | 935 int v1, v2; |
936 skip('('); | 936 skip('('); |
937 v1 = strtol(p, &p, 10); | 937 mystrtoi(&p, 10, &v1); |
938 skip(','); | 938 skip(','); |
939 v2 = strtol(p, &p, 10); | 939 mystrtoi(&p, 10, &v2); |
940 skip(')'); | 940 skip(')'); |
941 mp_msg(MSGT_ASS, MSGL_DBG2, "org(%d, %d)\n", v1, v2); | 941 mp_msg(MSGT_ASS, MSGL_DBG2, "org(%d, %d)\n", v1, v2); |
942 // render_context.evt_type = EVENT_POSITIONED; | 942 // render_context.evt_type = EVENT_POSITIONED; |
943 render_context.org_x = v1; | 943 render_context.org_x = v1; |
944 render_context.org_y = v2; | 944 render_context.org_y = v2; |
1061 render_context.italic = i; | 1061 render_context.italic = i; |
1062 } else | 1062 } else |
1063 render_context.italic = render_context.style->Italic; | 1063 render_context.italic = render_context.style->Italic; |
1064 update_font(); | 1064 update_font(); |
1065 } else if (mystrcmp(&p, "kf") || mystrcmp(&p, "K")) { | 1065 } else if (mystrcmp(&p, "kf") || mystrcmp(&p, "K")) { |
1066 int val = strtol(p, &p, 10); | 1066 int val = 0; |
1067 mystrtoi(&p, 10, &val); | |
1067 render_context.effect_type = EF_KARAOKE_KF; | 1068 render_context.effect_type = EF_KARAOKE_KF; |
1068 if (render_context.effect_timing) | 1069 if (render_context.effect_timing) |
1069 render_context.effect_skip_timing += render_context.effect_timing; | 1070 render_context.effect_skip_timing += render_context.effect_timing; |
1070 render_context.effect_timing = val * 10; | 1071 render_context.effect_timing = val * 10; |
1071 } else if (mystrcmp(&p, "ko")) { | 1072 } else if (mystrcmp(&p, "ko")) { |
1072 int val = strtol(p, &p, 10); | 1073 int val = 0; |
1074 mystrtoi(&p, 10, &val); | |
1073 render_context.effect_type = EF_KARAOKE_KO; | 1075 render_context.effect_type = EF_KARAOKE_KO; |
1074 if (render_context.effect_timing) | 1076 if (render_context.effect_timing) |
1075 render_context.effect_skip_timing += render_context.effect_timing; | 1077 render_context.effect_skip_timing += render_context.effect_timing; |
1076 render_context.effect_timing = val * 10; | 1078 render_context.effect_timing = val * 10; |
1077 } else if (mystrcmp(&p, "k")) { | 1079 } else if (mystrcmp(&p, "k")) { |
1078 int val = strtol(p, &p, 10); | 1080 int val = 0; |
1081 mystrtoi(&p, 10, &val); | |
1079 render_context.effect_type = EF_KARAOKE; | 1082 render_context.effect_type = EF_KARAOKE; |
1080 if (render_context.effect_timing) | 1083 if (render_context.effect_timing) |
1081 render_context.effect_skip_timing += render_context.effect_timing; | 1084 render_context.effect_skip_timing += render_context.effect_timing; |
1082 render_context.effect_timing = val * 10; | 1085 render_context.effect_timing = val * 10; |
1083 } else if (mystrcmp(&p, "shad")) { | 1086 } else if (mystrcmp(&p, "shad")) { |
1085 if (mystrtoi(&p, 10, &val)) | 1088 if (mystrtoi(&p, 10, &val)) |
1086 render_context.shadow = val; | 1089 render_context.shadow = val; |
1087 else | 1090 else |
1088 render_context.shadow = render_context.style->Shadow; | 1091 render_context.shadow = render_context.style->Shadow; |
1089 } else if (mystrcmp(&p, "pbo")) { | 1092 } else if (mystrcmp(&p, "pbo")) { |
1090 (void)strtol(p, &p, 10); // ignored | 1093 int val = 0; |
1094 mystrtoi(&p, 10, &val); // ignored | |
1091 } else if (mystrcmp(&p, "p")) { | 1095 } else if (mystrcmp(&p, "p")) { |
1092 int val; | 1096 int val; |
1093 if (!mystrtoi(&p, 10, &val)) | 1097 if (!mystrtoi(&p, 10, &val)) |
1094 val = 0; | 1098 val = 0; |
1095 render_context.drawing_mode = !!val; | 1099 render_context.drawing_mode = !!val; |