summaryrefslogtreecommitdiffstats
path: root/sub/sd_ass.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-05 23:56:28 +0100
committerwm4 <wm4@nowhere>2015-12-05 23:56:28 +0100
commit94c062d0d2a7369ffbde17a330aeb05973e44ab9 (patch)
tree9eb08087b11d8ce8df5c1d985a768184297814c6 /sub/sd_ass.c
parent04934e86dd154d1824253ba468c8f76eadc3076a (diff)
downloadmpv-94c062d0d2a7369ffbde17a330aeb05973e44ab9.tar.bz2
mpv-94c062d0d2a7369ffbde17a330aeb05973e44ab9.tar.xz
sub: move subtitle FPS adjustment to sd_ass.c
I feel like it's better there. Note that there is no reduced functionality, as bitmaps subs (i.e. not handled by sd_ass.c) were never fully read on init, and thus never went through sub_read_all_packets(). On the other hand, this might lead to confusion, as --sub-fps etc. will now also affect muxed subtitles (which makes not much sense).
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r--sub/sd_ass.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 11943613f9..261d0e1b2d 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -29,6 +29,7 @@
#include "options/options.h"
#include "common/common.h"
#include "common/msg.h"
+#include "demux/stheader.h"
#include "video/csputils.h"
#include "video/mp_image.h"
#include "dec_sub.h"
@@ -46,6 +47,7 @@ struct sd_ass_priv {
char last_text[500];
struct mp_image_params video_params;
struct mp_image_params last_params;
+ double sub_speed;
};
static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts);
@@ -117,6 +119,19 @@ static int init(struct sd *sd)
pthread_mutex_unlock(sd->ass_lock);
+ ctx->sub_speed = 1.0;
+
+ if (sd->video_fps && sd->sh && sd->sh->sub->frame_based > 0) {
+ MP_VERBOSE(sd, "Frame based format, dummy FPS: %f, video FPS: %f\n",
+ sd->sh->sub->frame_based, sd->video_fps);
+ ctx->sub_speed *= sd->sh->sub->frame_based / sd->video_fps;
+ }
+
+ if (opts->sub_fps && sd->video_fps)
+ ctx->sub_speed *= opts->sub_fps / sd->video_fps;
+
+ ctx->sub_speed *= opts->sub_speed;
+
return 0;
}
@@ -251,6 +266,8 @@ static long long find_timestamp(struct sd *sd, double pts)
if (pts == MP_NOPTS_VALUE)
return 0;
+ pts /= priv->sub_speed;
+
long long ts = llrint(pts * 1000);
if (!sd->opts->sub_fix_timing)
@@ -528,10 +545,11 @@ static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
switch (cmd) {
case SD_CTRL_SUB_STEP: {
double *a = arg;
- long long res = ass_step_sub(ctx->ass_track, a[0] * 1000 + 0.5, a[1]);
+ long long ts = llrint(a[0] * (1000.0 / ctx->sub_speed));
+ long long res = ass_step_sub(ctx->ass_track, ts, a[1]);
if (!res)
return false;
- a[0] = res / 1000.0;
+ a[0] = res / (1000.0 / ctx->sub_speed);
return true;
}
case SD_CTRL_SET_VIDEO_PARAMS: