1
diff -ruN libass-0.9.6-orig/libass/ass.c libass-0.9.6/libass/ass.c
2
--- libass-0.9.6-orig/libass/ass.c 2009-03-13 18:37:09.000000000 +0100
3
+++ libass-0.9.6/libass/ass.c 2009-06-28 02:48:51.000000000 +0200
6
void ass_free_track(ass_track_t* track) {
10
if (track->parser_priv) {
11
if (track->parser_priv->fontname)
12
free(track->parser_priv->fontname);
15
int ass_alloc_style(ass_track_t* track) {
19
assert(track->n_styles <= track->max_styles);
21
if (track->n_styles == track->max_styles) {
22
track->max_styles += ASS_STYLES_ALLOC;
23
track->styles = (ass_style_t*)realloc(track->styles, sizeof(ass_style_t)*track->max_styles);
27
sid = track->n_styles++;
28
memset(track->styles + sid, 0, sizeof(ass_style_t));
32
int ass_alloc_event(ass_track_t* track) {
36
assert(track->n_events <= track->max_events);
38
if (track->n_events == track->max_events) {
39
track->max_events += ASS_EVENTS_ALLOC;
40
track->events = (ass_event_t*)realloc(track->events, sizeof(ass_event_t)*track->max_events);
44
eid = track->n_events++;
45
memset(track->events + eid, 0, sizeof(ass_event_t));
48
if (target->name != NULL) free(target->name); \
49
target->name = strdup(token); \
50
mp_msg(MSGT_ASS, MSGL_DBG2, "%s = %s\n", #name, token);
53
#define COLORVAL(name) ANYVAL(name,string2color)
54
#define INTVAL(name) ANYVAL(name,atoi)
55
#define FPVAL(name) ANYVAL(name,atof)
57
* \param event parsed data goes here
58
* \param str string to parse, zero-terminated
59
* \param n_ignored number of format options to skip at the beginning
62
static int process_event_tail(ass_track_t* track, ass_event_t* event, char* str, int n_ignored)
68
char** list = track->library->style_overrides;
74
for (fs = list; *fs; ++fs) {
75
eq = strrchr(*fs, '=');
79
* \param str string to parse, zero-terminated
80
* Allocates a new style struct.
83
static int process_style(ass_track_t* track, char *str)
89
q = format = strdup(track->style_format);
92
mp_msg(MSGT_ASS, MSGL_V, "[%p] Style: %s\n", track, str);
95
sid = ass_alloc_style(track);
97
style = track->styles + sid;
99
// fill style with some default values
100
style->ScaleX = 100.;
101
style->ScaleY = 100.;
109
// ALIAS(TertiaryColour,OutlineColour) // ignore TertiaryColour; it appears only in SSA, and is overridden by BackColour
114
if ((strcmp(target->Name, "Default")==0) || (strcmp(target->Name, "*Default")==0))
123
static int process_styles_line(ass_track_t* track, char *str)
125
// called directly from demuxer
136
assert(dsize <= size / 4 * 3 + 2);
139
if (track->library->extract_fonts) {
140
ass_add_font(track->library, track->parser_priv->fontname, (char*)buf, dsize);
143
mp_msg(MSGT_ASS, MSGL_V, "fontname: %s\n", track->parser_priv->fontname);
148
if (!track->parser_priv->fontname) {
149
mp_msg(MSGT_ASS, MSGL_V, "Not understood: %s \n", str);
153
memcpy(track->parser_priv->fontdata + track->parser_priv->fontdata_used, str, len);
154
track->parser_priv->fontdata_used += len;
161
* \brief Parse a header line
163
* \param str string to parse, zero-terminated
166
static int process_line(ass_track_t* track, char *str)
168
if (!strncasecmp(str, "[Script Info]", 13)) {
170
* \param size length of data
171
* \param timecode starting time of the event (milliseconds)
172
* \param duration duration of the event (milliseconds)
175
void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration)
179
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_EventFormatHeaderMissing);
184
str = malloc(size + 1);
185
memcpy(str, data, size);
188
event = track->events + eid;
196
event->ReadOrder = atoi(token);
197
if (check_duplicate_event(track, event->ReadOrder))
200
event->Start = timecode;
201
event->Duration = duration;
207
@@ -863,11 +863,11 @@
213
outbuf = malloc(osize);
220
rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
222
icdsc = (iconv_t)(-1);
223
mp_msg(MSGT_ASS,MSGL_V,"LIBSUB: closed iconv descriptor.\n");
245
mp_msg(MSGT_ASS, MSGL_V, "file size: %ld\n", sz);
248
buf = malloc(sz + 1);
252
} while (sz - bytes_read > 0);
266
track = ass_new_track(library);
270
process_text(track, buf);
272
@@ -998,15 +998,15 @@
273
* \param bufsize size of buffer
274
* \param codepage recode buffer contents from given codepage
275
* \return newly allocated track
278
ass_track_t* ass_read_memory(ass_library_t* library, char* buf, size_t bufsize, char* codepage)
290
buf = sub_recode(buf, bufsize, codepage);
291
@@ -1029,7 +1029,7 @@
297
buf = read_file(fname, &bufsize);
300
@@ -1052,7 +1052,7 @@
301
* \param fname file name
302
* \param codepage recode buffer contents from given codepage
303
* \return newly allocated track
306
ass_track_t* ass_read_file(ass_library_t* library, char* fname, char* codepage)
309
@@ -1066,11 +1066,11 @@
315
track->name = strdup(fname);
317
mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_AddedSubtitleFileFname, fname, track->n_styles, track->n_events);
320
// dump_events(forced_tid);
323
@@ -1111,12 +1111,12 @@
325
if (movement == 0) return 0;
326
if (track->n_events == 0) return 0;
330
for (i = 0; (i < track->n_events) && ((long long)(track->events[i].Start + track->events[i].Duration) <= now); ++i) {}
332
for (i = track->n_events - 1; (i >= 0) && ((long long)(track->events[i].Start) > now); --i) {}
335
// -1 and n_events are ok
336
assert(i >= -1); assert(i <= track->n_events);
338
diff -ruN libass-0.9.6-orig/libass/ass.h libass-0.9.6/libass/ass.h
339
--- libass-0.9.6-orig/libass/ass.h 2009-03-13 18:37:09.000000000 +0100
340
+++ libass-0.9.6/libass/ass.h 2009-06-28 02:48:51.000000000 +0200
342
* \param bufsize size of buffer
343
* \param codepage recode buffer contents from given codepage
344
* \return newly allocated track
347
ass_track_t* ass_read_memory(ass_library_t* library, char* buf, size_t bufsize, char* codepage);
349
* \brief read styles from file into already initialized track
350
diff -ruN libass-0.9.6-orig/libass/ass_bitmap.c libass-0.9.6/libass/ass_bitmap.c
351
--- libass-0.9.6-orig/libass/ass_bitmap.c 2009-03-13 18:37:09.000000000 +0100
352
+++ libass-0.9.6/libass/ass_bitmap.c 2009-06-28 02:48:51.000000000 +0200
354
unsigned char* g = bm_g->buffer + (t - bm_g->top) * bm_g->w + (l - bm_g->left);
355
unsigned char* o = bm_o->buffer + (t - bm_o->top) * bm_o->w + (l - bm_o->left);
356
unsigned char* s = bm_s->buffer + (t - bm_s->top) * bm_s->w + (l - bm_s->left);
359
for (y = 0; y < b - t; ++y) {
360
for (x = 0; x < r - l; ++x) {
361
unsigned char c_g, c_o;
364
resize_tmp(priv_blur, (*bm_o)->w, (*bm_o)->h);
365
resize_tmp(priv_blur, (*bm_g)->w, (*bm_g)->h);
371
diff -ruN libass-0.9.6-orig/libass/ass_cache.c libass-0.9.6/libass/ass_cache.c
372
--- libass-0.9.6-orig/libass/ass_cache.c 2009-03-13 18:37:09.000000000 +0100
373
+++ libass-0.9.6/libass/ass_cache.c 2009-06-28 02:48:51.000000000 +0200
375
if (map->count > 0 || map->hit_count + map->miss_count > 0)
376
mp_msg(MSGT_ASS, MSGL_V, "cache statistics: \n total accesses: %d\n hits: %d\n misses: %d\n object count: %d\n",
377
map->hit_count + map->miss_count, map->hit_count, map->miss_count, map->count);
380
for (i = 0; i < map->nbuckets; ++i) {
381
hashmap_item_t* item = map->root[i];
384
* \brief Get a bitmap from bitmap cache.
385
* \param key hash key
386
* \return requested hash val or 0 if not found
389
bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key)
391
return hashmap_find(bitmap_cache, key);
393
* \brief Get a glyph from glyph cache.
394
* \param key hash key
395
* \return requested hash val or 0 if not found
398
glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key)
400
return hashmap_find(glyph_cache, key);
401
diff -ruN libass-0.9.6-orig/libass/ass_cache.h libass-0.9.6/libass/ass_cache.h
402
--- libass-0.9.6-orig/libass/ass_cache.h 2009-03-13 18:37:09.000000000 +0100
403
+++ libass-0.9.6/libass/ass_cache.h 2009-06-28 02:48:51.000000000 +0200
405
int shift_x, shift_y; // shift vector that was added to glyph before applying rotation
406
// = 0, if frx = fry = frx = 0
407
// = (glyph base point) - (rotation origin), otherwise
410
FT_Vector advance; // subpixel shift vector
414
void ass_glyph_cache_reset(void);
415
void ass_glyph_cache_done(void);
417
-typedef struct hashmap_s hashmap_t;
418
+typedef struct hashmap_s hashmap_t;
419
typedef void (*hashmap_item_dtor_t)(void* key, size_t key_size, void* value, size_t value_size);
420
typedef int (*hashmap_key_compare_t)(void* key1, void* key2, size_t key_size);
421
typedef unsigned (*hashmap_hash_t)(void* key, size_t key_size);
422
diff -ruN libass-0.9.6-orig/libass/ass_font.c libass-0.9.6/libass/ass_font.c
423
--- libass-0.9.6-orig/libass/ass_font.c 2009-03-13 18:37:09.000000000 +0100
424
+++ libass-0.9.6/libass/ass_font.c 2009-06-28 02:48:51.000000000 +0200
425
@@ -121,12 +121,14 @@
431
if (font->n_faces == ASS_FONT_MAX_FACES)
435
path = fontconfig_select(fc_priv, font->desc.family, font->desc.treat_family_as_pattern, font->desc.bold,
436
font->desc.italic, &index, ch);
440
mem_idx = find_font(font->library, path);
445
buggy_font_workaround(face);
448
font->faces[font->n_faces++] = face;
449
update_transform(font);
450
face_set_size(face, font->size);
452
fontp = ass_font_cache_find(desc);
457
font.library = library;
458
font.ftlibrary = ftlibrary;
469
@@ -308,18 +310,18 @@
470
case ASS_HINTING_NORMAL: flags = FT_LOAD_FORCE_AUTOHINT; break;
471
case ASS_HINTING_NATIVE: flags = 0; break;
475
error = FT_Load_Glyph(face, index, FT_LOAD_NO_BITMAP | flags);
477
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorLoadingGlyph);
482
#if (FREETYPE_MAJOR > 2) || \
483
((FREETYPE_MAJOR == 2) && (FREETYPE_MINOR >= 2)) || \
484
((FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 1) && (FREETYPE_PATCH >= 10))
485
// FreeType >= 2.1.10 required
486
- if (!(face->style_flags & FT_STYLE_FLAG_ITALIC) &&
487
+ if (!(face->style_flags & FT_STYLE_FLAG_ITALIC) &&
488
(font->desc.italic > 55)) {
489
FT_GlyphSlot_Oblique(face->glyph);
492
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorLoadingGlyph);
500
diff -ruN libass-0.9.6-orig/libass/ass_fontconfig.c libass-0.9.6/libass/ass_fontconfig.c
501
--- libass-0.9.6-orig/libass/ass_fontconfig.c 2009-03-13 18:37:09.000000000 +0100
502
+++ libass-0.9.6/libass/ass_fontconfig.c 2009-06-28 02:48:51.000000000 +0200
504
* \param index out: font index inside a file
505
* \param code: the character that should be present in the font, can be 0
506
* \return font file path
509
static char* _select_font(fc_instance_t* priv, const char* family, int treat_family_as_pattern,
510
unsigned bold, unsigned italic, int* index, uint32_t code)
520
if (treat_family_as_pattern)
527
if (!treat_family_as_pattern) {
528
FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)family);
531
FcPatternAddInteger(pat, FC_WEIGHT, bold);
533
FcDefaultSubstitute(pat);
536
rc = FcConfigSubstitute(priv->config, pat, FcMatchPattern);
539
@@ -160,11 +160,13 @@
542
#if (FC_VERSION >= 20297)
543
- // Remove all extra family names from original pattern.
544
- // After this, FcFontRenderPrepare will select the most relevant family
545
- // name in case there are more than one of them.
546
- for (; family_cnt > 1; --family_cnt)
547
- FcPatternRemove(pat, FC_FAMILY, family_cnt - 1);
548
+ if (!treat_family_as_pattern) {
549
+ // Remove all extra family names from original pattern.
550
+ // After this, FcFontRenderPrepare will select the most relevant family
551
+ // name in case there are more than one of them.
552
+ for (; family_cnt > 1; --family_cnt)
553
+ FcPatternRemove(pat, FC_FAMILY, family_cnt - 1);
557
rpat = FcFontRenderPrepare(priv->config, pat, fset->fonts[curf]);
559
* \param index out: font index inside a file
560
* \param code: the character that should be present in the font, can be 0
561
* \return font file path
564
char* fontconfig_select(fc_instance_t* priv, const char* family, int treat_family_as_pattern,
565
unsigned bold, unsigned italic, int* index, uint32_t code)
567
@@ -247,23 +249,23 @@
568
if (!res && priv->family_default) {
569
res = _select_font(priv, priv->family_default, 0, bold, italic, index, code);
571
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFontFamily,
572
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFontFamily,
573
family, bold, italic, res, *index);
575
if (!res && priv->path_default) {
576
res = priv->path_default;
577
*index = priv->index_default;
578
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFont,
579
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingDefaultFont,
580
family, bold, italic, res, *index);
583
res = _select_font(priv, "Arial", 0, bold, italic, index, code);
585
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingArialFontFamily,
586
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_UsingArialFontFamily,
587
family, bold, italic, res, *index);
590
- mp_msg(MSGT_ASS, MSGL_V, "fontconfig_select: (%s, %d, %d) -> %s, %d\n",
591
+ mp_msg(MSGT_ASS, MSGL_V, "fontconfig_select: (%s, %d, %d) -> %s, %d\n",
592
family, bold, italic, res, *index);
596
* \param idx index of the processed font in library->fontdata
597
* With FontConfig >= 2.4.2, builds a font pattern in memory via FT_New_Memory_Face/FcFreeTypeQueryFace.
598
* With older FontConfig versions, save the font to ~/.mplayer/fonts.
601
static void process_fontdata(fc_instance_t* priv, ass_library_t* library, FT_Library ftlibrary, int idx)
605
} else if (!S_ISDIR(st.st_mode)) {
606
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_NotADirectory, fonts_dir);
610
fname = validate_fname((char*)name);
612
snprintf(buf, 1000, "%s/%s", fonts_dir, fname);
613
@@ -405,14 +407,14 @@
614
* \param family default font family
615
* \param path default font path
616
* \return pointer to fontconfig private data
619
fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path, int fc)
622
fc_instance_t* priv = calloc(1, sizeof(fc_instance_t));
623
const char* dir = library->fonts_dir;
628
mp_msg(MSGT_ASS, MSGL_WARN,
629
MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed);
633
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed);
636
priv = calloc(1, sizeof(fc_instance_t));
639
priv->path_default = strdup(path);
640
priv->index_default = 0;
642
diff -ruN libass-0.9.6-orig/libass/ass_library.c libass-0.9.6/libass/ass_library.c
643
--- libass-0.9.6-orig/libass/ass_library.c 2009-03-13 18:37:09.000000000 +0100
644
+++ libass-0.9.6/libass/ass_library.c 2009-06-28 02:48:51.000000000 +0200
651
if (priv->style_overrides) {
652
for (p = priv->style_overrides; *p; ++p)
654
free(priv->style_overrides);
660
for (p = list, cnt = 0; *p; ++p, ++cnt) {}
662
if (!name || !data || !size)
664
grow_array((void**)&priv->fontdata, priv->num_fontdata, sizeof(*priv->fontdata));
667
priv->fontdata[idx].name = strdup(name);
670
priv->fontdata[idx].data = malloc(size);
671
memcpy(priv->fontdata[idx].data, data, size);
674
priv->fontdata[idx].size = size;
677
priv->num_fontdata ++;
680
diff -ruN libass-0.9.6-orig/libass/ass_render.c libass-0.9.6/libass/ass_render.c
681
--- libass-0.9.6-orig/libass/ass_render.c 2009-03-13 18:37:09.000000000 +0100
682
+++ libass-0.9.6/libass/ass_render.c 2009-06-28 02:51:52.000000000 +0200
684
double blur; // gaussian blur
686
double frx, fry, frz; // rotation
689
bitmap_hash_key_t hash_key;
692
@@ -141,11 +141,11 @@
693
typedef struct render_context_s {
704
int alignment; // alignment overrides go here; if zero, style value will be used
705
double frx, fry, frz;
709
int treat_family_as_pattern;
715
@@ -248,13 +248,13 @@
717
ass_renderer_t* priv = 0;
718
int vmajor, vminor, vpatch;
721
memset(&render_context, 0, sizeof(render_context));
722
memset(&frame_context, 0, sizeof(frame_context));
723
memset(&text_info, 0, sizeof(text_info));
725
error = FT_Init_FreeType( &ft );
728
mp_msg(MSGT_ASS, MSGL_FATAL, MSGTR_LIBASS_FT_Init_FreeTypeFailed);
731
@@ -276,14 +276,14 @@
732
priv->library = library;
733
priv->ftlibrary = ft;
734
// images_root and related stuff is zero-filled in calloc
737
ass_font_cache_init();
738
ass_bitmap_cache_init();
739
ass_composite_cache_init();
740
ass_glyph_cache_init();
742
text_info.glyphs = calloc(MAX_GLYPHS, sizeof(glyph_info_t));
746
if (priv) mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_Init);
747
else mp_msg(MSGT_ASS, MSGL_ERR, MSGTR_LIBASS_InitFailed);
749
static ass_image_t* my_draw_bitmap(unsigned char* bitmap, int bitmap_w, int bitmap_h, int stride, int dst_x, int dst_y, uint32_t color)
751
ass_image_t* img = calloc(1, sizeof(ass_image_t));
756
img->stride = stride;
764
clip_x0 = render_context.clip_x0;
765
clip_y0 = render_context.clip_y0;
772
tmp = dst_x - clip_x0;
774
mp_msg(MSGT_ASS, MSGL_DBG2, "clip left\n");
775
@@ -384,13 +384,13 @@
776
mp_msg(MSGT_ASS, MSGL_DBG2, "clip bottom\n");
781
if ((b_y0 >= b_y1) || (b_x0 >= b_x1))
784
if (brk > b_x0) { // draw left part
785
if (brk > b_x1) brk = b_x1;
786
- img = my_draw_bitmap(bm->buffer + bm->w * b_y0 + b_x0,
787
+ img = my_draw_bitmap(bm->buffer + bm->w * b_y0 + b_x0,
788
brk - b_x0, b_y1 - b_y0, bm->w,
789
dst_x + b_x0, dst_y + b_y0, color);
793
if (brk < b_x1) { // draw right part
794
if (brk < b_x0) brk = b_x0;
795
- img = my_draw_bitmap(bm->buffer + bm->w * b_y0 + brk,
796
+ img = my_draw_bitmap(bm->buffer + bm->w * b_y0 + brk,
797
b_x1 - brk, b_y1 - b_y0, bm->w,
798
dst_x + brk, dst_y + b_y0, color2);
802
composite_hash_key_t hk;
803
composite_hash_val_t *hv;
804
- composite_hash_key_t *nhk;
805
+ composite_hash_val_t chv;
806
int ax = (*last_tail)->dst_x;
807
int ay = (*last_tail)->dst_y;
808
int aw = (*last_tail)->w;
813
+ memset(&hk, 0, sizeof(hk));
814
memcpy(&hk.a, last_hash, sizeof(*last_hash));
815
memcpy(&hk.b, hash, sizeof(*hash));
820
// Insert bitmaps into the cache
821
- nhk = calloc(1, sizeof(*nhk));
822
- memcpy(nhk, &hk, sizeof(*nhk));
823
- hv = calloc(1, sizeof(*hv));
824
- hv->a = (*last_tail)->bitmap;
825
- hv->b = (*tail)->bitmap;
826
- cache_add_composite(nhk, hv);
827
+ chv.a = (*last_tail)->bitmap;
828
+ chv.b = (*tail)->bitmap;
829
+ cache_add_composite( &hk, &chv);
834
pen_x = dst_x + info->pos.x;
835
pen_y = dst_y + info->pos.y;
839
if ((info->effect_type == EF_KARAOKE_KO) && (info->effect_timing <= info->bbox.xMax)) {
843
static void compute_string_bbox( text_info_t* info, FT_BBox *abbox ) {
848
if (text_info.length > 0) {
853
render_context.font = ass_font_new(priv->library, priv->ftlibrary, priv->fontconfig_priv, &desc);
857
if (render_context.font)
858
change_font_size(render_context.font_size);
861
* \brief Calculate alpha value by piecewise linear function
862
* Used for \fad, \fade implementation.
864
-static unsigned interpolate_alpha(long long now,
865
+static unsigned interpolate_alpha(long long now,
866
long long t1, long long t2, long long t3, long long t4,
867
unsigned a1, unsigned a2, unsigned a3)
870
static char* parse_tag(char* p, double pwr) {
871
#define skip_to(x) while ((*p != (x)) && (*p != '}') && (*p != 0)) { ++p;}
872
#define skip(x) if (*p == (x)) ++p; else { return p; }
877
if ((*p == '}') || (*p == 0))
882
- mp_msg(MSGT_ASS, MSGL_DBG2, "movement6: (%f, %f) -> (%f, %f), (%" PRId64 " .. %" PRId64 ")\n",
883
+ mp_msg(MSGT_ASS, MSGL_DBG2, "movement6: (%f, %f) -> (%f, %f), (%" PRId64 " .. %" PRId64 ")\n",
884
x1, y1, x2, y2, (int64_t)t1, (int64_t)t2);
887
@@ -1111,7 +1109,7 @@
888
k = pow(((double)(t - t1)) / delta_t, v3);
891
- p = parse_tag(p, k); // maybe k*pwr ? no, specs forbid nested \t's
892
+ p = parse_tag(p, k); // maybe k*pwr ? no, specs forbid nested \t's
893
skip_to(')'); // in case there is some unknown tag or a comment
895
} else if (mystrcmp(&p, "clip")) {
896
@@ -1293,7 +1291,7 @@
897
while (cnt < 4 && (p = strchr(p, ';'))) {
898
v[cnt++] = atoi(++p);
902
if (strncmp(event->Effect, "Banner;", 7) == 0) {
905
@@ -1406,7 +1404,7 @@
906
render_context.effect_type = EF_NONE;
907
render_context.effect_timing = 0;
908
render_context.effect_skip_timing = 0;
911
apply_transition_effects(event);
914
@@ -1429,6 +1427,7 @@
916
glyph_hash_val_t* val;
917
glyph_hash_key_t key;
918
+ memset(&key, 0, sizeof(key));
919
key.font = render_context.font;
920
key.size = render_context.font_size;
922
@@ -1490,10 +1489,10 @@
924
bitmap_hash_val_t* val;
925
bitmap_hash_key_t* key = &info->hash_key;
928
val = cache_find_bitmap(key);
934
info->bm_o = val->bm_o;
935
@@ -1600,8 +1599,8 @@
937
mp_msg(MSGT_ASS, MSGL_DBG2, "forced line break at %d\n", break_at);
940
- if (len >= max_text_width) {
942
+ if ((len >= max_text_width) && (frame_context.track->WrapStyle != 2)) {
944
break_at = last_space;
946
@@ -1617,7 +1616,7 @@
947
// marking break_at+1 as start of a new line
948
int lead = break_at + 1; // the first symbol of the new line
949
if (text_info.n_lines >= MAX_LINES) {
952
// no more linebreaks
953
for (j = lead; j < text_info.length; ++j)
954
text_info.glyphs[j].linebreak = 0;
955
@@ -1630,7 +1629,7 @@
956
s_offset = s1->bbox.xMin + s1->pos.x;
957
text_info.n_lines ++;
961
if (cur->symbol == ' ')
964
@@ -1676,11 +1675,11 @@
965
if (i == text_info.length)
971
assert(text_info.n_lines >= 1);
978
@@ -1704,7 +1703,7 @@
979
* \brief determine karaoke effects
980
* Karaoke effects cannot be calculated during parse stage (get_next_char()),
981
* so they are done in a separate step.
982
- * Parse stage: when karaoke style override is found, its parameters are stored in the next glyph's
983
+ * Parse stage: when karaoke style override is found, its parameters are stored in the next glyph's
984
* (the first glyph of the karaoke word)'s effect_type and effect_timing.
986
* 1. sets effect_type for all glyphs in the word (_karaoke_ word)
987
@@ -1873,12 +1872,13 @@
989
* \brief Main ass rendering function, glues everything together
990
* \param event event to render
991
+ * \param event_images struct containing resulting images, will also be initialized
992
* Process event, appending resulting ass_image_t's to images_root.
994
static int ass_render_event(ass_event_t* event, event_images_t* event_images)
1002
@@ -1914,7 +1914,7 @@
1004
code = get_next_char(&p);
1005
} while (code && render_context.drawing_mode); // skip everything in drawing mode
1008
// face could have been changed in get_next_char
1009
if (!render_context.font) {
1010
free_render_context();
1011
@@ -1925,7 +1925,7 @@
1014
if (text_info.length >= MAX_GLYPHS) {
1015
- mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_MAX_GLYPHS_Reached,
1016
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_MAX_GLYPHS_Reached,
1017
(int)(event - frame_context.track->events), event->Start, event->Duration, event->Text);
1020
@@ -1951,14 +1951,14 @@
1023
get_outline_glyph(code, text_info.glyphs + text_info.length, &shift);
1026
text_info.glyphs[text_info.length].pos.x = pen.x >> 6;
1027
text_info.glyphs[text_info.length].pos.y = pen.y >> 6;
1030
pen.x += text_info.glyphs[text_info.length].advance.x;
1031
pen.x += double_to_d6(render_context.hspacing);
1032
pen.y += text_info.glyphs[text_info.length].advance.y;
1037
text_info.glyphs[text_info.length].symbol = code;
1038
@@ -2005,23 +2005,23 @@
1039
render_context.effect_timing = 0;
1040
render_context.effect_skip_timing = 0;
1044
if (text_info.length == 0) {
1045
// no valid symbols in the event; this can be smth like {comment}
1046
free_render_context();
1051
// depends on glyph x coordinates being monotonous, so it should be done before line wrap
1052
process_karaoke_effects();
1056
alignment = render_context.alignment;
1057
halign = alignment & 3;
1058
valign = alignment & 12;
1060
- MarginL = (event->MarginL) ? event->MarginL : render_context.style->MarginL;
1061
- MarginR = (event->MarginR) ? event->MarginR : render_context.style->MarginR;
1062
+ MarginL = (event->MarginL) ? event->MarginL : render_context.style->MarginL;
1063
+ MarginR = (event->MarginR) ? event->MarginR : render_context.style->MarginR;
1064
MarginV = (event->MarginV) ? event->MarginV : render_context.style->MarginV;
1066
if (render_context.evt_type != EVENT_HSCROLL) {
1067
@@ -2061,12 +2061,12 @@
1068
} else { // render_context.evt_type == EVENT_HSCROLL
1073
// determing text bounding box
1074
compute_string_bbox(&text_info, &bbox);
1077
// determine device coordinates for text
1080
// x coordinate for everything except positioned events
1081
if (render_context.evt_type == EVENT_NORMAL ||
1082
render_context.evt_type == EVENT_VSCROLL) {
1083
@@ -2111,7 +2111,7 @@
1084
device_x = x2scr_pos(render_context.pos_x) - base_x;
1085
device_y = y2scr_pos(render_context.pos_y) - base_y;
1089
// fix clip coordinates (they depend on alignment)
1090
if (render_context.evt_type == EVENT_NORMAL ||
1091
render_context.evt_type == EVENT_HSCROLL ||
1092
@@ -2138,7 +2138,7 @@
1093
// calculate rotation parameters
1098
if (render_context.have_origin) {
1099
center.x = x2scr(render_context.org_x);
1100
center.y = y2scr(render_context.org_y);
1101
@@ -2166,6 +2166,7 @@
1102
for (i = 0; i < text_info.length; ++i)
1103
get_bitmap_glyph(text_info.glyphs + i);
1105
+ memset(event_images, 0, sizeof(*event_images));
1106
event_images->top = device_y - d6_to_int(text_info.lines[0].asc);
1107
event_images->height = d6_to_int(text_info.height);
1108
event_images->detect_collisions = render_context.detect_collisions;
1109
@@ -2174,7 +2175,7 @@
1110
event_images->imgs = render_text(&text_info, device_x, device_y);
1112
free_render_context();
1118
@@ -2300,7 +2301,7 @@
1120
if (track->n_events == 0)
1121
return 1; // nothing to do
1124
frame_context.ass_priv = priv;
1125
frame_context.width = global_settings->frame_width;
1126
frame_context.height = global_settings->frame_height;
1127
@@ -2316,7 +2317,7 @@
1128
frame_context.time = now;
1130
ass_lazy_track_init();
1133
frame_context.font_scale = global_settings->font_size_coeff *
1134
frame_context.orig_height / frame_context.track->PlayResY;
1135
if (frame_context.track->ScaledBorderAndShadow)
1136
@@ -2426,7 +2427,7 @@
1137
fixed[*cnt].b = s->b + shift;
1139
qsort(fixed, *cnt, sizeof(segment_t), cmp_segment);
1145
@@ -2481,7 +2482,7 @@
1146
priv->top = imgs[i].top;
1147
priv->height = imgs[i].height;
1154
@@ -2554,7 +2555,7 @@
1156
event_images_t* last;
1161
rc = ass_start_frame(priv, track, now);
1163
@@ -2600,7 +2601,7 @@
1166
*detect_change = ass_detect_change(priv);
1169
// free the previous image list
1170
ass_free_images(priv->prev_images_root);
1171
priv->prev_images_root = 0;
1172
diff -ruN libass-0.9.6-orig/libass/ass_types.h libass-0.9.6/libass/ass_types.h
1173
--- libass-0.9.6-orig/libass/ass_types.h 2009-03-13 18:37:09.000000000 +0100
1174
+++ libass-0.9.6/libass/ass_types.h 2009-06-28 02:48:51.000000000 +0200
1176
char* event_format; // event format line
1178
enum {TRACK_TYPE_UNKNOWN = 0, TRACK_TYPE_ASS, TRACK_TYPE_SSA} track_type;
1181
// script header fields
1186
char ScaledBorderAndShadow;
1190
int default_style; // index of default style
1191
char* name; // file name in case of external subs, 0 for streams
1193
diff -ruN libass-0.9.6-orig/libass/ass_utils.c libass-0.9.6/libass/ass_utils.c
1194
--- libass-0.9.6-orig/libass/ass_utils.c 2009-03-13 18:37:09.000000000 +0100
1195
+++ libass-0.9.6/libass/ass_utils.c 2009-06-28 02:48:51.000000000 +0200
1201
- if (*p == '&') ++p;
1203
+ if (*p == '&') ++p;
1204
else mp_msg(MSGT_ASS, MSGL_DBG2, "suspicious color format: \"%s\"\n", p);
1206
- if (*p == 'H' || *p == 'h') {
1208
+ if (*p == 'H' || *p == 'h') {
1210
result = mystrtou32(&p, 16, &color);
1212
result = mystrtou32(&p, 0, &color);
1217
unsigned char* tmp = (unsigned char*)(&color);