summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-21 21:34:55 +0200
committerwm4 <wm4@nowhere>2013-06-25 00:11:56 +0200
commit98388c0c073906f4485420485e27a14e8d957a2d (patch)
treeb2bd98d6b502d106e07ef17b0a918464e69756ac /sub
parentb37147744e34c0f23acb391de6bd04a0a1dc8cca (diff)
downloadmpv-98388c0c073906f4485420485e27a14e8d957a2d.tar.bz2
mpv-98388c0c073906f4485420485e27a14e8d957a2d.tar.xz
subreader: turn into actual demuxer
subreader.c (before this commit renamed to demux_subreader.c) was special cased to the -sub option. The plan is using the normal demuxer codepath for all subtitle formats (so we can prefer libavformat demuxers for most formats). There are some subtle changes. The probe size is restricted to 32 KB (instead of unlimitted + giving up after 100 lines of input). For formats like MicroDVD, the video FPS isn't used anymore, because it's not available on the subtitle demuxer level. Instead, hardcode it to 23.976 FPS (libavformat seems to do the same). The user can probably still use -sub-fps to fix the timing. Checking the file extension for ".utf"/".utf8"/".utf-8" is simply removed (seems worthless, was in the way, and I've never seen this anywhere).
Diffstat (limited to 'sub')
-rw-r--r--sub/dec_sub.c65
1 files changed, 0 insertions, 65 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index bfd6d90d03..dd1168d0ad 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -25,7 +25,6 @@
#include "sd.h"
#include "sub.h"
#include "dec_sub.h"
-#include "demux/subreader.h"
#include "core/options.h"
#include "core/mp_msg.h"
@@ -138,68 +137,6 @@ static void print_chain(struct dec_sub *sub)
mp_msg(MSGT_OSD, MSGL_V, "\n");
}
-// Subtitles read with subreader.c
-static void read_sub_data(struct dec_sub *sub, struct sub_data *subdata)
-{
- assert(sub_accept_packets_in_advance(sub));
- char *temp = NULL;
-
- struct sd *sd = sub_get_last_sd(sub);
-
- sd->no_remove_duplicates = true;
-
- for (int i = 0; i < subdata->sub_num; i++) {
- subtitle *st = &subdata->subtitles[i];
- // subdata is in 10 ms ticks, pts is in seconds
- double t = subdata->sub_uses_time ? 0.01 : (1 / subdata->fallback_fps);
-
- int len = 0;
- for (int j = 0; j < st->lines; j++)
- len += st->text[j] ? strlen(st->text[j]) : 0;
-
- len += 2 * st->lines; // '\N', including the one after the last line
- len += 6; // {\anX}
- len += 1; // '\0'
-
- if (talloc_get_size(temp) < len) {
- talloc_free(temp);
- temp = talloc_array(NULL, char, len);
- }
-
- char *p = temp;
- char *end = p + len;
-
- if (st->alignment)
- p += snprintf(p, end - p, "{\\an%d}", st->alignment);
-
- for (int j = 0; j < st->lines; j++)
- p += snprintf(p, end - p, "%s\\N", st->text[j]);
-
- if (st->lines > 0)
- p -= 2; // remove last "\N"
- *p = 0;
-
- struct demux_packet pkt = {0};
- pkt.pts = st->start * t;
- pkt.duration = (st->end - st->start) * t;
- pkt.buffer = temp;
- pkt.len = strlen(temp);
-
- sub_decode(sub, &pkt);
- }
-
- // Hack for broken FFmpeg packet format: make sd_ass keep the subtitle
- // events on reset(), even though broken FFmpeg ASS packets were received
- // (from sd_lavc_conv.c). Normally, these events are removed on seek/reset,
- // but this is obviously unwanted in this case.
- if (sd && sd->driver->fix_events)
- sd->driver->fix_events(sd);
-
- sd->no_remove_duplicates = false;
-
- talloc_free(temp);
-}
-
static int sub_init_decoder(struct dec_sub *sub, struct sd *sd)
{
sd->driver = NULL;
@@ -242,8 +179,6 @@ void sub_init_from_sh(struct dec_sub *sub, struct sh_sub *sh)
// Try adding new converters until a decoder is reached
if (sd->driver->get_bitmaps || sd->driver->get_text) {
print_chain(sub);
- if (sh->sub_data)
- read_sub_data(sub, sh->sub_data);
return;
}
init_sd = (struct sd) {