summaryrefslogtreecommitdiffstats
path: root/sub/sd_spu.c
diff options
context:
space:
mode:
authorRudolf Polzer <divVerent@xonotic.org>2013-11-01 16:02:47 +0100
committerRudolf Polzer <divverent@xonotic.org>2013-11-07 12:56:07 +0100
commit633fde4ae541ddfe57f8111fe9b5b1fba89e6fc6 (patch)
treec00e88cd5efb55528a9f34c279101d31cb4b05be /sub/sd_spu.c
parent49caa0a775be06539a7cd30875f1c80368a7ac55 (diff)
downloadmpv-633fde4ae541ddfe57f8111fe9b5b1fba89e6fc6.tar.bz2
mpv-633fde4ae541ddfe57f8111fe9b5b1fba89e6fc6.tar.xz
sd_lavc, sd_spu: make dvdsub stretching conditional on --stretch-dvd-subs.
We found that the stretching - although it usually improves the looks of the fonts - is incorrect. On DVD, subtitles can cover the full area of the picture, and they have the same pixel aspect as the movie itself. Too bad many commercially released DVDs use bitmap fonts made with the wrong pixel aspect (i.e. assuming 1:1) - --stretch-dvd-subs will make these more pretty then.
Diffstat (limited to 'sub/sd_spu.c')
-rw-r--r--sub/sd_spu.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/sub/sd_spu.c b/sub/sd_spu.c
index 52e2b728ed..717e4652b9 100644
--- a/sub/sd_spu.c
+++ b/sub/sd_spu.c
@@ -21,12 +21,14 @@
#include "talloc.h"
#include "mpvcore/options.h"
#include "demux/stheader.h"
+#include "video/mp_image.h"
#include "sd.h"
#include "sub.h"
#include "spudec.h"
struct sd_spu_priv {
void *spudec;
+ struct mp_image_params video_params;
};
static bool is_dvd_sub(const char *t)
@@ -72,8 +74,22 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
spudec_set_forced_subs_only(priv->spudec, opts->forced_subs_only);
spudec_heartbeat(priv->spudec, pts * 90000);
- if (spudec_visible(priv->spudec))
- spudec_get_indexed(priv->spudec, &d, res);
+ if (spudec_visible(priv->spudec)) {
+ double xscale = 1;
+ double yscale = 1;
+ if (opts->stretch_dvd_subs) {
+ // For DVD subs, try to keep the subtitle PAR at display PAR.
+ double video_par =
+ (priv->video_params.d_w / (double)priv->video_params.d_h)
+ / (priv->video_params.w / (double)priv->video_params.h);
+ if (video_par > 1.0) {
+ xscale /= video_par;
+ } else {
+ yscale *= video_par;
+ }
+ }
+ spudec_get_indexed(priv->spudec, &d, xscale, yscale, res);
+ }
}
static void reset(struct sd *sd)
@@ -91,12 +107,25 @@ static void uninit(struct sd *sd)
talloc_free(priv);
}
+static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
+{
+ struct sd_spu_priv *priv = sd->priv;
+ switch (cmd) {
+ case SD_CTRL_SET_VIDEO_PARAMS:
+ priv->video_params = *(struct mp_image_params *)arg;
+ return CONTROL_OK;
+ default:
+ return CONTROL_UNKNOWN;
+ }
+}
+
const struct sd_functions sd_spu = {
.name = "spu",
.supports_format = supports_format,
.init = init,
.decode = decode,
.get_bitmaps = get_bitmaps,
+ .control = control,
.reset = reset,
.uninit = uninit,
};