summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-02 20:34:20 +0200
committerwm4 <wm4@nowhere>2013-06-03 22:40:07 +0200
commit5e2c211a4e1d67748348295b191acb2dfb76d024 (patch)
tree03cf782755f696df4fcbe65d10f5a063832e41e4
parentd5520d20b26e7363882e9f1ebce7a5524a12321b (diff)
downloadmpv-5e2c211a4e1d67748348295b191acb2dfb76d024.tar.bz2
mpv-5e2c211a4e1d67748348295b191acb2dfb76d024.tar.xz
sd_lavc_conv: strip style header
Normally, libavcodec subtitle converters will output a style header like this as part of the extradata: Style: Default,Arial,16,&Hffffff,&Hffffff,&H0,&H0,0,0,0,1,1,0,2,10,10,10,0,0 We don't want that, so use some bruteforce to get rid of them.
-rw-r--r--sub/sd_lavc_conv.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sub/sd_lavc_conv.c b/sub/sd_lavc_conv.c
index 744aa83440..9c7a6f2c5f 100644
--- a/sub/sd_lavc_conv.c
+++ b/sub/sd_lavc_conv.c
@@ -27,6 +27,7 @@
#include "talloc.h"
#include "core/mp_msg.h"
#include "core/av_common.h"
+#include "core/bstr.h"
#include "sd.h"
struct sd_lavc_priv {
@@ -55,6 +56,19 @@ static bool supports_format(const char *format)
#endif
}
+// Disable style definitions generated by the libavcodec converter.
+// We always want the user defined style instead.
+static void disable_styles(bstr header)
+{
+ while (header.len) {
+ int n = bstr_find(header, bstr0("\nStyle: "));
+ if (n < 0)
+ break;
+ header.start[n + 1] = '#'; // turn into a comment
+ header = bstr_cut(header, 2);
+ }
+}
+
static int init(struct sd *sd)
{
struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
@@ -76,6 +90,11 @@ static int init(struct sd *sd)
sd->output_codec = "ass";
sd->output_extradata = avctx->subtitle_header;
sd->output_extradata_len = avctx->subtitle_header_size;
+ if (sd->output_extradata) {
+ sd->output_extradata = talloc_memdup(sd, sd->output_extradata,
+ sd->output_extradata_len);
+ disable_styles((bstr){sd->output_extradata, sd->output_extradata_len});
+ }
return 0;
error: