Mercurial > mplayer.hg
comparison libass/ass_render.c @ 20629:e8885ec63928
Introduce MSGT_ASS, use it for all libass messages.
author | eugeni |
---|---|
date | Fri, 03 Nov 2006 18:15:33 +0000 |
parents | 5cbf1c33a668 |
children | 402484a85b9f |
comparison
equal
deleted
inserted
replaced
20628:782c697bd4c2 | 20629:e8885ec63928 |
---|---|
203 { | 203 { |
204 ass_track_t* track = frame_context.track; | 204 ass_track_t* track = frame_context.track; |
205 if (track->PlayResX && track->PlayResY) | 205 if (track->PlayResX && track->PlayResY) |
206 return; | 206 return; |
207 if (!track->PlayResX && !track->PlayResY) { | 207 if (!track->PlayResX && !track->PlayResY) { |
208 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Neither PlayResX nor PlayResY defined. Assuming 384x288. \n"); | 208 mp_msg(MSGT_ASS, MSGL_WARN, "Neither PlayResX nor PlayResY defined. Assuming 384x288. \n"); |
209 track->PlayResX = 384; | 209 track->PlayResX = 384; |
210 track->PlayResY = 288; | 210 track->PlayResY = 288; |
211 } else { | 211 } else { |
212 double orig_aspect = (global_settings->aspect * frame_context.height * frame_context.orig_width) / | 212 double orig_aspect = (global_settings->aspect * frame_context.height * frame_context.orig_width) / |
213 frame_context.orig_height / frame_context.width; | 213 frame_context.orig_height / frame_context.width; |
214 if (!track->PlayResY) { | 214 if (!track->PlayResY) { |
215 track->PlayResY = track->PlayResX / orig_aspect + .5; | 215 track->PlayResY = track->PlayResX / orig_aspect + .5; |
216 mp_msg(MSGT_GLOBAL, MSGL_WARN, "PlayResY undefined, setting %d \n", track->PlayResY); | 216 mp_msg(MSGT_ASS, MSGL_WARN, "PlayResY undefined, setting %d \n", track->PlayResY); |
217 } else if (!track->PlayResX) { | 217 } else if (!track->PlayResX) { |
218 track->PlayResX = track->PlayResY * orig_aspect + .5; | 218 track->PlayResX = track->PlayResY * orig_aspect + .5; |
219 mp_msg(MSGT_GLOBAL, MSGL_WARN, "PlayResX undefined, setting %d \n", track->PlayResX); | 219 mp_msg(MSGT_ASS, MSGL_WARN, "PlayResX undefined, setting %d \n", track->PlayResX); |
220 } | 220 } |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 ass_renderer_t* ass_renderer_init(ass_library_t* library) | 224 ass_renderer_t* ass_renderer_init(ass_library_t* library) |
231 memset(&frame_context, 0, sizeof(frame_context)); | 231 memset(&frame_context, 0, sizeof(frame_context)); |
232 memset(&text_info, 0, sizeof(text_info)); | 232 memset(&text_info, 0, sizeof(text_info)); |
233 | 233 |
234 error = FT_Init_FreeType( &ft ); | 234 error = FT_Init_FreeType( &ft ); |
235 if ( error ) { | 235 if ( error ) { |
236 mp_msg(MSGT_GLOBAL, MSGL_FATAL, "FT_Init_FreeType failed\n"); | 236 mp_msg(MSGT_ASS, MSGL_FATAL, "FT_Init_FreeType failed\n"); |
237 goto ass_init_exit; | 237 goto ass_init_exit; |
238 } | 238 } |
239 | 239 |
240 priv = calloc(1, sizeof(ass_renderer_t)); | 240 priv = calloc(1, sizeof(ass_renderer_t)); |
241 if (!priv) { | 241 if (!priv) { |
253 ass_glyph_cache_init(); | 253 ass_glyph_cache_init(); |
254 | 254 |
255 text_info.glyphs = calloc(MAX_GLYPHS, sizeof(glyph_info_t)); | 255 text_info.glyphs = calloc(MAX_GLYPHS, sizeof(glyph_info_t)); |
256 | 256 |
257 ass_init_exit: | 257 ass_init_exit: |
258 if (priv) mp_msg(MSGT_GLOBAL, MSGL_INFO, "[ass] Init\n"); | 258 if (priv) mp_msg(MSGT_ASS, MSGL_INFO, "[ass] Init\n"); |
259 else mp_msg(MSGT_GLOBAL, MSGL_ERR, "[ass] Init failed\n"); | 259 else mp_msg(MSGT_ASS, MSGL_ERR, "[ass] Init failed\n"); |
260 | 260 |
261 return priv; | 261 return priv; |
262 } | 262 } |
263 | 263 |
264 void ass_renderer_done(ass_renderer_t* priv) | 264 void ass_renderer_done(ass_renderer_t* priv) |
331 b_x1 = bm->w; | 331 b_x1 = bm->w; |
332 b_y1 = bm->h; | 332 b_y1 = bm->h; |
333 | 333 |
334 tmp = dst_x - clip_x0; | 334 tmp = dst_x - clip_x0; |
335 if (tmp < 0) { | 335 if (tmp < 0) { |
336 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "clip left\n"); | 336 mp_msg(MSGT_ASS, MSGL_DBG2, "clip left\n"); |
337 b_x0 = - tmp; | 337 b_x0 = - tmp; |
338 } | 338 } |
339 tmp = dst_y - clip_y0; | 339 tmp = dst_y - clip_y0; |
340 if (tmp < 0) { | 340 if (tmp < 0) { |
341 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "clip top\n"); | 341 mp_msg(MSGT_ASS, MSGL_DBG2, "clip top\n"); |
342 b_y0 = - tmp; | 342 b_y0 = - tmp; |
343 } | 343 } |
344 tmp = clip_x1 - dst_x - bm->w; | 344 tmp = clip_x1 - dst_x - bm->w; |
345 if (tmp < 0) { | 345 if (tmp < 0) { |
346 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "clip right\n"); | 346 mp_msg(MSGT_ASS, MSGL_DBG2, "clip right\n"); |
347 b_x1 = bm->w + tmp; | 347 b_x1 = bm->w + tmp; |
348 } | 348 } |
349 tmp = clip_y1 - dst_y - bm->h; | 349 tmp = clip_y1 - dst_y - bm->h; |
350 if (tmp < 0) { | 350 if (tmp < 0) { |
351 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "clip bottom\n"); | 351 mp_msg(MSGT_ASS, MSGL_DBG2, "clip bottom\n"); |
352 b_y1 = bm->h + tmp; | 352 b_y1 = bm->h + tmp; |
353 } | 353 } |
354 | 354 |
355 if ((b_y0 >= b_y1) || (b_x0 >= b_x1)) | 355 if ((b_y0 >= b_y1) || (b_x0 >= b_x1)) |
356 return tail; | 356 return tail; |
621 error = FT_Stroker_New( ass_renderer->ftlibrary, &render_context.stroker ); | 621 error = FT_Stroker_New( ass_renderer->ftlibrary, &render_context.stroker ); |
622 #else // < 2.2 | 622 #else // < 2.2 |
623 error = FT_Stroker_New( render_context.face->memory, &render_context.stroker ); | 623 error = FT_Stroker_New( render_context.face->memory, &render_context.stroker ); |
624 #endif | 624 #endif |
625 if (error) { | 625 if (error) { |
626 mp_msg(MSGT_GLOBAL, MSGL_V, "failed to get stroker\n"); | 626 mp_msg(MSGT_ASS, MSGL_V, "failed to get stroker\n"); |
627 render_context.stroker = 0; | 627 render_context.stroker = 0; |
628 } | 628 } |
629 } | 629 } |
630 if (render_context.stroker) | 630 if (render_context.stroker) |
631 FT_Stroker_Set( render_context.stroker, b, | 631 FT_Stroker_Set( render_context.stroker, b, |
769 if (*p == ',') { | 769 if (*p == ',') { |
770 skip(','); | 770 skip(','); |
771 t1 = strtoll(p, &p, 10); | 771 t1 = strtoll(p, &p, 10); |
772 skip(','); | 772 skip(','); |
773 t2 = strtoll(p, &p, 10); | 773 t2 = strtoll(p, &p, 10); |
774 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "movement6: (%d, %d) -> (%d, %d), (%" PRId64 " .. %" PRId64 ")\n", | 774 mp_msg(MSGT_ASS, MSGL_DBG2, "movement6: (%d, %d) -> (%d, %d), (%" PRId64 " .. %" PRId64 ")\n", |
775 x1, y1, x2, y2, (int64_t)t1, (int64_t)t2); | 775 x1, y1, x2, y2, (int64_t)t1, (int64_t)t2); |
776 } else { | 776 } else { |
777 t1 = 0; | 777 t1 = 0; |
778 t2 = render_context.event->Duration; | 778 t2 = render_context.event->Duration; |
779 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "movement: (%d, %d) -> (%d, %d)\n", x1, y1, x2, y2); | 779 mp_msg(MSGT_ASS, MSGL_DBG2, "movement: (%d, %d) -> (%d, %d)\n", x1, y1, x2, y2); |
780 } | 780 } |
781 skip(')'); | 781 skip(')'); |
782 delta_t = t2 - t1; | 782 delta_t = t2 - t1; |
783 t = frame_context.time - render_context.event->Start; | 783 t = frame_context.time - render_context.event->Start; |
784 if (t < t1) | 784 if (t < t1) |
793 render_context.detect_collisions = 0; | 793 render_context.detect_collisions = 0; |
794 render_context.evt_type = EVENT_POSITIONED; | 794 render_context.evt_type = EVENT_POSITIONED; |
795 } else if (mystrcmp(&p, "frx") || mystrcmp(&p, "fry")) { | 795 } else if (mystrcmp(&p, "frx") || mystrcmp(&p, "fry")) { |
796 double val; | 796 double val; |
797 mystrtod(&p, &val); | 797 mystrtod(&p, &val); |
798 mp_msg(MSGT_GLOBAL, MSGL_V, "frx/fry unimplemented \n"); | 798 mp_msg(MSGT_ASS, MSGL_V, "frx/fry unimplemented \n"); |
799 } else if (mystrcmp(&p, "frz") || mystrcmp(&p, "fr")) { | 799 } else if (mystrcmp(&p, "frz") || mystrcmp(&p, "fr")) { |
800 double angle; | 800 double angle; |
801 double val; | 801 double val; |
802 mystrtod(&p, &val); | 802 mystrtod(&p, &val); |
803 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "setting rotation to %.2f\n", val * pwr); | 803 mp_msg(MSGT_ASS, MSGL_DBG2, "setting rotation to %.2f\n", val * pwr); |
804 angle = M_PI * val / 180; | 804 angle = M_PI * val / 180; |
805 render_context.rotation = angle * pwr; | 805 render_context.rotation = angle * pwr; |
806 } else if (mystrcmp(&p, "fn")) { | 806 } else if (mystrcmp(&p, "fn")) { |
807 char* start = p; | 807 char* start = p; |
808 char* family; | 808 char* family; |
829 } | 829 } |
830 // FIXME: simplify | 830 // FIXME: simplify |
831 } else if (mystrcmp(&p, "an")) { | 831 } else if (mystrcmp(&p, "an")) { |
832 int val = strtol(p, &p, 10); | 832 int val = strtol(p, &p, 10); |
833 int v = (val - 1) / 3; // 0, 1 or 2 for vertical alignment | 833 int v = (val - 1) / 3; // 0, 1 or 2 for vertical alignment |
834 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "an %d\n", val); | 834 mp_msg(MSGT_ASS, MSGL_DBG2, "an %d\n", val); |
835 if (v != 0) v = 3 - v; | 835 if (v != 0) v = 3 - v; |
836 val = ((val - 1) % 3) + 1; // horizontal alignment | 836 val = ((val - 1) % 3) + 1; // horizontal alignment |
837 val += v*4; | 837 val += v*4; |
838 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "align %d\n", val); | 838 mp_msg(MSGT_ASS, MSGL_DBG2, "align %d\n", val); |
839 render_context.alignment = val; | 839 render_context.alignment = val; |
840 } else if (mystrcmp(&p, "a")) { | 840 } else if (mystrcmp(&p, "a")) { |
841 int val = strtol(p, &p, 10); | 841 int val = strtol(p, &p, 10); |
842 render_context.alignment = val; | 842 render_context.alignment = val; |
843 } else if (mystrcmp(&p, "pos")) { | 843 } else if (mystrcmp(&p, "pos")) { |
845 skip('('); | 845 skip('('); |
846 v1 = strtol(p, &p, 10); | 846 v1 = strtol(p, &p, 10); |
847 skip(','); | 847 skip(','); |
848 v2 = strtol(p, &p, 10); | 848 v2 = strtol(p, &p, 10); |
849 skip(')'); | 849 skip(')'); |
850 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "pos(%d, %d)\n", v1, v2); | 850 mp_msg(MSGT_ASS, MSGL_DBG2, "pos(%d, %d)\n", v1, v2); |
851 render_context.evt_type = EVENT_POSITIONED; | 851 render_context.evt_type = EVENT_POSITIONED; |
852 render_context.detect_collisions = 0; | 852 render_context.detect_collisions = 0; |
853 render_context.pos_x = v1; | 853 render_context.pos_x = v1; |
854 render_context.pos_y = v2; | 854 render_context.pos_y = v2; |
855 } else if (mystrcmp(&p, "fad")) { | 855 } else if (mystrcmp(&p, "fad")) { |
891 skip('('); | 891 skip('('); |
892 v1 = strtol(p, &p, 10); | 892 v1 = strtol(p, &p, 10); |
893 skip(','); | 893 skip(','); |
894 v2 = strtol(p, &p, 10); | 894 v2 = strtol(p, &p, 10); |
895 skip(')'); | 895 skip(')'); |
896 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "org(%d, %d)\n", v1, v2); | 896 mp_msg(MSGT_ASS, MSGL_DBG2, "org(%d, %d)\n", v1, v2); |
897 // render_context.evt_type = EVENT_POSITIONED; | 897 // render_context.evt_type = EVENT_POSITIONED; |
898 render_context.org_x = v1; | 898 render_context.org_x = v1; |
899 render_context.org_y = v2; | 899 render_context.org_y = v2; |
900 } else if (mystrcmp(&p, "t")) { | 900 } else if (mystrcmp(&p, "t")) { |
901 double v[3]; | 901 double v[3]; |
958 } | 958 } |
959 } else if (mystrcmp(&p, "c")) { | 959 } else if (mystrcmp(&p, "c")) { |
960 uint32_t val; | 960 uint32_t val; |
961 if (!strtocolor(&p, &val)) | 961 if (!strtocolor(&p, &val)) |
962 val = render_context.style->PrimaryColour; | 962 val = render_context.style->PrimaryColour; |
963 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "color: %X\n", val); | 963 mp_msg(MSGT_ASS, MSGL_DBG2, "color: %X\n", val); |
964 change_color(&render_context.c[0], val, pwr); | 964 change_color(&render_context.c[0], val, pwr); |
965 } else if ((*p >= '1') && (*p <= '4') && (++p) && (mystrcmp(&p, "c") || mystrcmp(&p, "a"))) { | 965 } else if ((*p >= '1') && (*p <= '4') && (++p) && (mystrcmp(&p, "c") || mystrcmp(&p, "a"))) { |
966 char n = *(p-2); | 966 char n = *(p-2); |
967 int cidx = n - '1'; | 967 int cidx = n - '1'; |
968 char cmd = *(p-1); | 968 char cmd = *(p-1); |
977 default : val = 0; break; // impossible due to assert; avoid compilation warning | 977 default : val = 0; break; // impossible due to assert; avoid compilation warning |
978 } | 978 } |
979 switch (cmd) { | 979 switch (cmd) { |
980 case 'c': change_color(render_context.c + cidx, val, pwr); break; | 980 case 'c': change_color(render_context.c + cidx, val, pwr); break; |
981 case 'a': change_alpha(render_context.c + cidx, val >> 24, pwr); break; | 981 case 'a': change_alpha(render_context.c + cidx, val >> 24, pwr); break; |
982 default: mp_msg(MSGT_GLOBAL, MSGL_WARN, "Bad command: %c%c\n", n, cmd); break; | 982 default: mp_msg(MSGT_ASS, MSGL_WARN, "Bad command: %c%c\n", n, cmd); break; |
983 } | 983 } |
984 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "single c/a at %f: %c%c = %X \n", pwr, n, cmd, render_context.c[cidx]); | 984 mp_msg(MSGT_ASS, MSGL_DBG2, "single c/a at %f: %c%c = %X \n", pwr, n, cmd, render_context.c[cidx]); |
985 } else if (mystrcmp(&p, "r")) { | 985 } else if (mystrcmp(&p, "r")) { |
986 reset_render_context(); | 986 reset_render_context(); |
987 } else if (mystrcmp(&p, "be")) { | 987 } else if (mystrcmp(&p, "be")) { |
988 int val; | 988 int val; |
989 if (mystrtoi(&p, 10, &val)) | 989 if (mystrtoi(&p, 10, &val)) |
1056 p++; | 1056 p++; |
1057 continue; | 1057 continue; |
1058 } else | 1058 } else |
1059 break; | 1059 break; |
1060 } else if (*p != '\\') | 1060 } else if (*p != '\\') |
1061 mp_msg(MSGT_GLOBAL, MSGL_V, "Unable to parse: \"%s\" \n", p); | 1061 mp_msg(MSGT_ASS, MSGL_V, "Unable to parse: \"%s\" \n", p); |
1062 if (*p == 0) | 1062 if (*p == 0) |
1063 break; | 1063 break; |
1064 } | 1064 } |
1065 } | 1065 } |
1066 if (*p == '\t') { | 1066 if (*p == '\t') { |
1098 } | 1098 } |
1099 | 1099 |
1100 if (strncmp(event->Effect, "Banner;", 7) == 0) { | 1100 if (strncmp(event->Effect, "Banner;", 7) == 0) { |
1101 int delay; | 1101 int delay; |
1102 if (cnt < 1) { | 1102 if (cnt < 1) { |
1103 mp_msg(MSGT_GLOBAL, MSGL_V, "Error parsing effect: %s \n", event->Effect); | 1103 mp_msg(MSGT_ASS, MSGL_V, "Error parsing effect: %s \n", event->Effect); |
1104 return; | 1104 return; |
1105 } | 1105 } |
1106 if (cnt >= 2 && v[1] == 0) // right-to-left | 1106 if (cnt >= 2 && v[1] == 0) // right-to-left |
1107 render_context.scroll_direction = SCROLL_RL; | 1107 render_context.scroll_direction = SCROLL_RL; |
1108 else // left-to-right | 1108 else // left-to-right |
1118 if (strncmp(event->Effect, "Scroll up;", 10) == 0) { | 1118 if (strncmp(event->Effect, "Scroll up;", 10) == 0) { |
1119 render_context.scroll_direction = SCROLL_BT; | 1119 render_context.scroll_direction = SCROLL_BT; |
1120 } else if (strncmp(event->Effect, "Scroll down;", 12) == 0) { | 1120 } else if (strncmp(event->Effect, "Scroll down;", 12) == 0) { |
1121 render_context.scroll_direction = SCROLL_TB; | 1121 render_context.scroll_direction = SCROLL_TB; |
1122 } else { | 1122 } else { |
1123 mp_msg(MSGT_GLOBAL, MSGL_V, "Unknown transition effect: %s \n", event->Effect); | 1123 mp_msg(MSGT_ASS, MSGL_V, "Unknown transition effect: %s \n", event->Effect); |
1124 return; | 1124 return; |
1125 } | 1125 } |
1126 // parse scroll up/down parameters | 1126 // parse scroll up/down parameters |
1127 { | 1127 { |
1128 int delay; | 1128 int delay; |
1129 int y0, y1; | 1129 int y0, y1; |
1130 if (cnt < 3) { | 1130 if (cnt < 3) { |
1131 mp_msg(MSGT_GLOBAL, MSGL_V, "Error parsing effect: %s \n", event->Effect); | 1131 mp_msg(MSGT_ASS, MSGL_V, "Error parsing effect: %s \n", event->Effect); |
1132 return; | 1132 return; |
1133 } | 1133 } |
1134 delay = v[2]; | 1134 delay = v[2]; |
1135 if (delay == 0) delay = 1; // ? | 1135 if (delay == 0) delay = 1; // ? |
1136 render_context.scroll_shift = (frame_context.time - render_context.event->Start) / delay; | 1136 render_context.scroll_shift = (frame_context.time - render_context.event->Start) / delay; |
1252 | 1252 |
1253 return 0; | 1253 return 0; |
1254 } | 1254 } |
1255 | 1255 |
1256 // not found, get a new outline glyph from face | 1256 // not found, get a new outline glyph from face |
1257 // mp_msg(MSGT_GLOBAL, MSGL_INFO, "miss, index = %d, symbol = %c, adv = (%d, %d)\n", index, symbol, advance->x, advance->y); | 1257 // mp_msg(MSGT_ASS, MSGL_INFO, "miss, index = %d, symbol = %c, adv = (%d, %d)\n", index, symbol, advance->x, advance->y); |
1258 | 1258 |
1259 error = FT_Load_Glyph(render_context.face, index, FT_LOAD_NO_BITMAP ); | 1259 error = FT_Load_Glyph(render_context.face, index, FT_LOAD_NO_BITMAP ); |
1260 if (error) { | 1260 if (error) { |
1261 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Error loading glyph\n"); | 1261 mp_msg(MSGT_ASS, MSGL_WARN, "Error loading glyph\n"); |
1262 return error; | 1262 return error; |
1263 } | 1263 } |
1264 | 1264 |
1265 #if (FREETYPE_MAJOR > 2) || \ | 1265 #if (FREETYPE_MAJOR > 2) || \ |
1266 ((FREETYPE_MAJOR == 2) && (FREETYPE_MINOR >= 2)) || \ | 1266 ((FREETYPE_MAJOR == 2) && (FREETYPE_MINOR >= 2)) || \ |
1271 FT_GlyphSlot_Oblique(render_context.face->glyph); | 1271 FT_GlyphSlot_Oblique(render_context.face->glyph); |
1272 } | 1272 } |
1273 #endif | 1273 #endif |
1274 error = FT_Get_Glyph(render_context.face->glyph, &(info->glyph)); | 1274 error = FT_Get_Glyph(render_context.face->glyph, &(info->glyph)); |
1275 if (error) { | 1275 if (error) { |
1276 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Error getting glyph\n"); | 1276 mp_msg(MSGT_ASS, MSGL_WARN, "Error getting glyph\n"); |
1277 return error; | 1277 return error; |
1278 } | 1278 } |
1279 | 1279 |
1280 info->advance.x = info->glyph->advance.x >> 10; | 1280 info->advance.x = info->glyph->advance.x >> 10; |
1281 info->advance.y = info->glyph->advance.y >> 10; | 1281 info->advance.y = info->glyph->advance.y >> 10; |
1282 | 1282 |
1283 if (render_context.stroker) { | 1283 if (render_context.stroker) { |
1284 info->outline_glyph = info->glyph; | 1284 info->outline_glyph = info->glyph; |
1285 error = FT_Glyph_Stroke( &(info->outline_glyph), render_context.stroker, 0 ); // don't destroy original | 1285 error = FT_Glyph_Stroke( &(info->outline_glyph), render_context.stroker, 0 ); // don't destroy original |
1286 if (error) { | 1286 if (error) { |
1287 mp_msg(MSGT_GLOBAL, MSGL_WARN, "FT_Glyph_Stroke error %d \n", error); | 1287 mp_msg(MSGT_ASS, MSGL_WARN, "FT_Glyph_Stroke error %d \n", error); |
1288 } | 1288 } |
1289 } else { | 1289 } else { |
1290 info->outline_glyph = 0; | 1290 info->outline_glyph = 0; |
1291 } | 1291 } |
1292 | 1292 |
1359 len = (cur->bbox.xMax + cur->pos.x) - s_offset; | 1359 len = (cur->bbox.xMax + cur->pos.x) - s_offset; |
1360 | 1360 |
1361 if (cur->symbol == '\n') { | 1361 if (cur->symbol == '\n') { |
1362 break_type = 2; | 1362 break_type = 2; |
1363 break_at = i; | 1363 break_at = i; |
1364 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "forced line break at %d\n", break_at); | 1364 mp_msg(MSGT_ASS, MSGL_DBG2, "forced line break at %d\n", break_at); |
1365 } | 1365 } |
1366 | 1366 |
1367 if (len >= max_text_width) { | 1367 if (len >= max_text_width) { |
1368 break_type = 1; | 1368 break_type = 1; |
1369 break_at = last_space; | 1369 break_at = last_space; |
1370 if (break_at == -1) | 1370 if (break_at == -1) |
1371 break_at = i - 1; | 1371 break_at = i - 1; |
1372 if (break_at == -1) | 1372 if (break_at == -1) |
1373 break_at = 0; | 1373 break_at = 0; |
1374 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "overfill at %d\n", i); | 1374 mp_msg(MSGT_ASS, MSGL_DBG2, "overfill at %d\n", i); |
1375 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "line break at %d\n", break_at); | 1375 mp_msg(MSGT_ASS, MSGL_DBG2, "line break at %d\n", break_at); |
1376 } | 1376 } |
1377 | 1377 |
1378 if (break_at != -1) { | 1378 if (break_at != -1) { |
1379 // need to use one more line | 1379 // need to use one more line |
1380 // marking break_at+1 as start of a new line | 1380 // marking break_at+1 as start of a new line |
1449 if (cur->linebreak) { | 1449 if (cur->linebreak) { |
1450 int height = text_info.lines[cur_line - 1].desc + text_info.lines[cur_line].asc; | 1450 int height = text_info.lines[cur_line - 1].desc + text_info.lines[cur_line].asc; |
1451 cur_line ++; | 1451 cur_line ++; |
1452 pen_shift_x = - cur->pos.x; | 1452 pen_shift_x = - cur->pos.x; |
1453 pen_shift_y += (height >> 6) + global_settings->line_spacing; | 1453 pen_shift_y += (height >> 6) + global_settings->line_spacing; |
1454 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "shifting from %d to %d by (%d, %d)\n", i, text_info.length - 1, pen_shift_x, pen_shift_y); | 1454 mp_msg(MSGT_ASS, MSGL_DBG2, "shifting from %d to %d by (%d, %d)\n", i, text_info.length - 1, pen_shift_x, pen_shift_y); |
1455 } | 1455 } |
1456 cur->pos.x += pen_shift_x; | 1456 cur->pos.x += pen_shift_x; |
1457 cur->pos.y += pen_shift_y; | 1457 cur->pos.y += pen_shift_y; |
1458 } | 1458 } |
1459 } | 1459 } |
1506 x = x_start; | 1506 x = x_start; |
1507 } else if (s1->effect_type == EF_KARAOKE_KF) { | 1507 } else if (s1->effect_type == EF_KARAOKE_KF) { |
1508 dt /= (tm_end - tm_start); | 1508 dt /= (tm_end - tm_start); |
1509 x = x_start + (x_end - x_start) * dt; | 1509 x = x_start + (x_end - x_start) * dt; |
1510 } else { | 1510 } else { |
1511 mp_msg(MSGT_GLOBAL, MSGL_ERR, "Unknown effect type (internal error) \n"); | 1511 mp_msg(MSGT_ASS, MSGL_ERR, "Unknown effect type (internal error) \n"); |
1512 continue; | 1512 continue; |
1513 } | 1513 } |
1514 | 1514 |
1515 for (cur2 = s1; cur2 <= e1; ++cur2) { | 1515 for (cur2 = s1; cur2 <= e1; ++cur2) { |
1516 cur2->effect_type = s1->effect_type; | 1516 cur2->effect_type = s1->effect_type; |
1599 int last_break; | 1599 int last_break; |
1600 int alignment, halign, valign; | 1600 int alignment, halign, valign; |
1601 int device_x = 0, device_y = 0; | 1601 int device_x = 0, device_y = 0; |
1602 | 1602 |
1603 if (event->Style >= frame_context.track->n_styles) { | 1603 if (event->Style >= frame_context.track->n_styles) { |
1604 mp_msg(MSGT_GLOBAL, MSGL_WARN, "No style found!\n"); | 1604 mp_msg(MSGT_ASS, MSGL_WARN, "No style found!\n"); |
1605 return 1; | 1605 return 1; |
1606 } | 1606 } |
1607 if (!event->Text) { | 1607 if (!event->Text) { |
1608 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Empty event!\n"); | 1608 mp_msg(MSGT_ASS, MSGL_WARN, "Empty event!\n"); |
1609 return 1; | 1609 return 1; |
1610 } | 1610 } |
1611 | 1611 |
1612 init_render_context(event); | 1612 init_render_context(event); |
1613 | 1613 |
1633 break; | 1633 break; |
1634 | 1634 |
1635 use_kerning = FT_HAS_KERNING(render_context.face); | 1635 use_kerning = FT_HAS_KERNING(render_context.face); |
1636 | 1636 |
1637 if (text_info.length >= MAX_GLYPHS) { | 1637 if (text_info.length >= MAX_GLYPHS) { |
1638 mp_msg(MSGT_GLOBAL, MSGL_WARN, "\nMAX_GLYPHS reached: event %d, start = %llu, duration = %llu\n Text = %s\n", | 1638 mp_msg(MSGT_ASS, MSGL_WARN, "\nMAX_GLYPHS reached: event %d, start = %llu, duration = %llu\n Text = %s\n", |
1639 (int)(event - frame_context.track->events), event->Start, event->Duration, event->Text); | 1639 (int)(event - frame_context.track->events), event->Start, event->Duration, event->Text); |
1640 break; | 1640 break; |
1641 } | 1641 } |
1642 | 1642 |
1643 glyph_index = FT_Get_Char_Index( render_context.face, code); | 1643 glyph_index = FT_Get_Char_Index( render_context.face, code); |
1794 int scr_y = y2scr(frame_context.track->PlayResY / 2); | 1794 int scr_y = y2scr(frame_context.track->PlayResY / 2); |
1795 device_y = scr_y - (bbox.yMax - bbox.yMin) / 2; | 1795 device_y = scr_y - (bbox.yMax - bbox.yMin) / 2; |
1796 } else { // subtitle | 1796 } else { // subtitle |
1797 int scr_y; | 1797 int scr_y; |
1798 if (valign != VALIGN_SUB) | 1798 if (valign != VALIGN_SUB) |
1799 mp_msg(MSGT_GLOBAL, MSGL_V, "Invalid valign, supposing 0 (subtitle)\n"); | 1799 mp_msg(MSGT_ASS, MSGL_V, "Invalid valign, supposing 0 (subtitle)\n"); |
1800 scr_y = y2scr_sub(frame_context.track->PlayResY - MarginV); | 1800 scr_y = y2scr_sub(frame_context.track->PlayResY - MarginV); |
1801 device_y = scr_y; | 1801 device_y = scr_y; |
1802 device_y -= (text_info.height >> 6); | 1802 device_y -= (text_info.height >> 6); |
1803 device_y += (text_info.lines[0].asc >> 6); | 1803 device_y += (text_info.lines[0].asc >> 6); |
1804 } | 1804 } |
1811 | 1811 |
1812 // positioned events are totally different | 1812 // positioned events are totally different |
1813 if (render_context.evt_type == EVENT_POSITIONED) { | 1813 if (render_context.evt_type == EVENT_POSITIONED) { |
1814 int base_x = 0; | 1814 int base_x = 0; |
1815 int base_y = 0; | 1815 int base_y = 0; |
1816 mp_msg(MSGT_GLOBAL, MSGL_DBG2, "positioned event at %d, %d\n", render_context.pos_x, render_context.pos_y); | 1816 mp_msg(MSGT_ASS, MSGL_DBG2, "positioned event at %d, %d\n", render_context.pos_x, render_context.pos_y); |
1817 get_base_point(bbox, alignment, &base_x, &base_y); | 1817 get_base_point(bbox, alignment, &base_x, &base_y); |
1818 device_x = x2scr(render_context.pos_x) - base_x; | 1818 device_x = x2scr(render_context.pos_x) - base_x; |
1819 device_y = y2scr(render_context.pos_y) - base_y; | 1819 device_y = y2scr(render_context.pos_y) - base_y; |
1820 } | 1820 } |
1821 | 1821 |
2144 if (priv->height > 0) { // it's a fixed event | 2144 if (priv->height > 0) { // it's a fixed event |
2145 segment_t s; | 2145 segment_t s; |
2146 s.a = priv->top; | 2146 s.a = priv->top; |
2147 s.b = priv->top + priv->height; | 2147 s.b = priv->top + priv->height; |
2148 if (priv->height != imgs[i].height) { // no, it's not | 2148 if (priv->height != imgs[i].height) { // no, it's not |
2149 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Achtung! Event height has changed! \n"); | 2149 mp_msg(MSGT_ASS, MSGL_WARN, "Achtung! Event height has changed! \n"); |
2150 priv->top = 0; | 2150 priv->top = 0; |
2151 priv->height = 0; | 2151 priv->height = 0; |
2152 } | 2152 } |
2153 for (j = 0; j < cnt_used; ++j) | 2153 for (j = 0; j < cnt_used; ++j) |
2154 if (overlap(&s, used + j)) { // no, it's not | 2154 if (overlap(&s, used + j)) { // no, it's not |
2210 if ( (event->Start <= now) && (now < (event->Start + event->Duration)) ) { | 2210 if ( (event->Start <= now) && (now < (event->Start + event->Duration)) ) { |
2211 if (cnt < MAX_EVENTS) { | 2211 if (cnt < MAX_EVENTS) { |
2212 rc = ass_render_event(event, eimg + cnt); | 2212 rc = ass_render_event(event, eimg + cnt); |
2213 if (!rc) ++cnt; | 2213 if (!rc) ++cnt; |
2214 } else { | 2214 } else { |
2215 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Too many simultaneous events \n"); | 2215 mp_msg(MSGT_ASS, MSGL_WARN, "Too many simultaneous events \n"); |
2216 break; | 2216 break; |
2217 } | 2217 } |
2218 } | 2218 } |
2219 } | 2219 } |
2220 | 2220 |