summaryrefslogtreecommitdiffstats
path: root/sub/ass_mp.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-01 19:54:18 +0200
committerwm4 <wm4@nowhere>2013-06-03 22:40:02 +0200
commite19ffa02aa370cbc3b559f85b286ea09b06ab29b (patch)
tree3335cdcc8664d9e3b98631fe8128b138c095069a /sub/ass_mp.c
parent14dd95154820d4ec9afb5200335177b011233049 (diff)
downloadmpv-e19ffa02aa370cbc3b559f85b286ea09b06ab29b.tar.bz2
mpv-e19ffa02aa370cbc3b559f85b286ea09b06ab29b.tar.xz
sub: turn subassconvert_ functions into sub converters
This means subassconvert.c is split in sd_srt.c and sd_microdvd.c. Now this code is involved in the sub conversion chain like sd_movtext is. The invocation of the converter in sd_ass.c is removed. This requires some other changes to make the new sub converter code work with loading external subtitles. Until now, subtitles loaded via subreader.c was assumed to be in plaintext, or for some formats, in ASS (except in -no-ass mode). Then these were added to an ASS_Track. Change this so that subtitles are always in their original format (as far as decoders/converters for them are available), and turn every sub event read by subreader.c as packet to the dec_sub.c subtitle chain. This removes differences between external/demuxed and -ass/-no-ass code paths further.
Diffstat (limited to 'sub/ass_mp.c')
-rw-r--r--sub/ass_mp.c79
1 files changed, 0 insertions, 79 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index 4be89fb004..85105a33ad 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -102,85 +102,6 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
return track;
}
-/**
- * \brief Convert subtitle to ASS_Events for the given track
- * \param track track
- * \param sub subtitle to convert
- * \return event id
- * note: assumes that subtitle is _not_ fps-based; caller must manually correct
- * Start and Duration in other case.
- **/
-static int ass_process_subtitle(ASS_Track *track, subtitle *sub)
-{
- int eid;
- ASS_Event *event;
- int len = 0, j;
- char *p;
- char *end;
-
- eid = ass_alloc_event(track);
- event = track->events + eid;
-
- event->Start = sub->start * 10;
- event->Duration = (sub->end - sub->start) * 10;
- event->Style = track->default_style;
-
- for (j = 0; j < sub->lines; ++j)
- len += sub->text[j] ? strlen(sub->text[j]) : 0;
-
- len += 2 * sub->lines; // '\N', including the one after the last line
- len += 6; // {\anX}
- len += 1; // '\0'
-
- event->Text = malloc(len);
- end = event->Text + len;
- p = event->Text;
-
- if (sub->alignment)
- p += snprintf(p, end - p, "{\\an%d}", sub->alignment);
-
- for (j = 0; j < sub->lines; ++j)
- p += snprintf(p, end - p, "%s\\N", sub->text[j]);
-
- if (sub->lines > 0)
- p -= 2; // remove last "\N"
- *p = 0;
-
- mp_msg(MSGT_ASS, MSGL_V,
- "plaintext event at %" PRId64 ", +%" PRId64 ": %s \n",
- (int64_t) event->Start, (int64_t) event->Duration, event->Text);
-
- return eid;
-}
-
-
-/**
- * \brief Convert subdata to ASS_Track
- * \param subdata subtitles struct from subreader
- * \param fps video framerate
- * \return newly allocated ASS_Track, filled with subtitles from subdata
- */
-ASS_Track *mp_ass_read_subdata(ASS_Library *library, struct MPOpts *opts,
- sub_data *subdata, double fps)
-{
- ASS_Track *track;
- int i;
-
- track = mp_ass_default_track(library, opts);
- track->name = subdata->filename ? strdup(subdata->filename) : 0;
-
- for (i = 0; i < subdata->sub_num; ++i) {
- int eid = ass_process_subtitle(track, subdata->subtitles + i);
- if (eid < 0)
- continue;
- if (!subdata->sub_uses_time) {
- track->events[eid].Start *= 100. / fps;
- track->events[eid].Duration *= 100. / fps;
- }
- }
- return track;
-}
-
ASS_Track *mp_ass_read_stream(ASS_Library *library, const char *fname,
char *charset)
{