# HG changeset patch # User reimar # Date 1261164573 0 # Node ID 7119354805e75faf4397fabba4e71e24432f252e # Parent 538fb3475fa7fe5a23b9e1295cbf3c856d56960d Use on-stack subtitle struct for temporary storage for passing subtitles on for rendering by libass. This avoids mangling the static subtitle struct that is supposed to contain the subtitles that will actually be displayed and it also minimally reduces memory usage by freeing the subtitle lines again as early as possible. diff -r 538fb3475fa7 -r 7119354805e7 mpcommon.c --- a/mpcommon.c Fri Dec 18 15:57:52 2009 +0000 +++ b/mpcommon.c Fri Dec 18 19:29:33 2009 +0000 @@ -190,12 +190,13 @@ (long long)((endpts-subpts)*1000 + 0.5)); } else { // plaintext subs with libass if (subpts != MP_NOPTS_VALUE) { + subtitle tmp_subs = {0}; if (endpts == MP_NOPTS_VALUE) endpts = subpts + 3; - sub_clear_text(&subs, MP_NOPTS_VALUE); - sub_add_text(&subs, packet, len, endpts); - subs.start = subpts * 100; - subs.end = endpts * 100; - ass_process_subtitle(ass_track, &subs); + sub_add_text(&tmp_subs, packet, len, endpts); + tmp_subs.start = subpts * 100; + tmp_subs.end = endpts * 100; + ass_process_subtitle(ass_track, &tmp_subs); + sub_clear_text(&tmp_subs, MP_NOPTS_VALUE); } } continue;