mirror of https://github.com/mpv-player/mpv
sd_srt, sd_microdvd: set ASS script resolution
Both converters can output \pos and deal with font sizes, so they assume a specific script resolution (PlayResX/PlayResY). The implicit assumption was that a specific resolution was guaranteed. The MP_ASS_FONT_PLAYRESY constant is connected to this. Better make it explicit, so that the implicit dependency on MP_ASS_FONT_PLAYRESY is removed. (Unfortunately, libavcodec sub converters still don't set PlayResX/PlayResY explicitly, so the value set by that constant can't be declared as arbitrary yet.) PlayResY=288 is most likely the SSA natural script resolution (or something like this?), as well as the libass and VSFilter default. PlayResX=384 is the fallback value set by libass if PlayResY is set to 288, and PlayResX is unset.
This commit is contained in:
parent
61dfe12179
commit
f3871193fc
|
@ -27,7 +27,8 @@
|
|||
#include "config.h"
|
||||
#include "subreader.h"
|
||||
|
||||
// font sizes and explicit tags in subassconvert.c assume this size (?)
|
||||
// This is probably arbitrary.
|
||||
// sd_lavc_conv might indirectly still assume this PlayResY, though.
|
||||
#define MP_ASS_FONT_PLAYRESY 288
|
||||
|
||||
#define MP_ASS_RGBA(r, g, b, a) \
|
||||
|
|
|
@ -309,6 +309,12 @@ static void convert_microdvd(const char *orig, char *dest, int dest_buffer_size)
|
|||
new_line.buf[new_line.len] = 0;
|
||||
}
|
||||
|
||||
static const char *microdvd_ass_extradata =
|
||||
"[Script Info]\n"
|
||||
"ScriptType: v4.00+\n"
|
||||
"PlayResX: 384\n"
|
||||
"PlayResY: 288\n";
|
||||
|
||||
static bool supports_format(const char *format)
|
||||
{
|
||||
return format && strcmp(format, "microdvd") == 0;
|
||||
|
@ -317,6 +323,8 @@ static bool supports_format(const char *format)
|
|||
static int init(struct sd *sd)
|
||||
{
|
||||
sd->output_codec = "ass-text";
|
||||
sd->output_extradata = (char *)microdvd_ass_extradata;
|
||||
sd->output_extradata_len = strlen(sd->output_extradata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -437,6 +437,12 @@ static void convert_subrip(const char *orig, char *dest, int dest_buffer_size)
|
|||
new_line.buf[new_line.len] = 0;
|
||||
}
|
||||
|
||||
static const char *srt_ass_extradata =
|
||||
"[Script Info]\n"
|
||||
"ScriptType: v4.00+\n"
|
||||
"PlayResX: 384\n"
|
||||
"PlayResY: 288\n";
|
||||
|
||||
static bool supports_format(const char *format)
|
||||
{
|
||||
return format && (strcmp(format, "subrip") == 0 ||
|
||||
|
@ -446,6 +452,8 @@ static bool supports_format(const char *format)
|
|||
static int init(struct sd *sd)
|
||||
{
|
||||
sd->output_codec = "ass-text";
|
||||
sd->output_extradata = (char *)srt_ass_extradata;
|
||||
sd->output_extradata_len = strlen(sd->output_extradata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue