summaryrefslogtreecommitdiffstats
path: root/sub/sd_microdvd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sub/sd_microdvd.c')
-rw-r--r--sub/sd_microdvd.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/sub/sd_microdvd.c b/sub/sd_microdvd.c
index c6c8745e32..eba5b67576 100644
--- a/sub/sd_microdvd.c
+++ b/sub/sd_microdvd.c
@@ -25,11 +25,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <ctype.h>
+#include <libavutil/common.h>
#include "core/mp_msg.h"
-#include "subassconvert.h"
#include "core/bstr.h"
-#include "libavutil/common.h"
+#include "sd.h"
struct line {
char *buf;
@@ -61,7 +61,6 @@ static int indexof(const char *s, int c)
return f ? (f - s) : -1;
}
-
/*
* MicroDVD
*
@@ -283,7 +282,7 @@ static void microdvd_close_no_persistent_tags(struct line *new_line,
}
}
-void subassconvert_microdvd(const char *orig, char *dest, int dest_buffer_size)
+static void convert_microdvd(const char *orig, char *dest, int dest_buffer_size)
{
/* line is not const to avoid warnings with strtol, etc.
* orig content won't be changed */
@@ -309,3 +308,30 @@ void subassconvert_microdvd(const char *orig, char *dest, int dest_buffer_size)
}
new_line.buf[new_line.len] = 0;
}
+
+static bool supports_format(const char *format)
+{
+ return format && strcmp(format, "microdvd") == 0;
+}
+
+static int init(struct sd *sd)
+{
+ sd->output_codec = "ass-text";
+ return 0;
+}
+
+static void decode(struct sd *sd, struct demux_packet *packet)
+{
+ char dest[SD_MAX_LINE_LEN];
+ // Assume input buffer is padded with 0
+ convert_microdvd(packet->buffer, dest, sizeof(dest));
+ sd_conv_add_packet(sd, dest, strlen(dest), packet->pts, packet->duration);
+}
+
+const struct sd_functions sd_microdvd = {
+ .supports_format = supports_format,
+ .init = init,
+ .decode = decode,
+ .get_converted = sd_conv_def_get_converted,
+ .reset = sd_conv_def_reset,
+};