diff options
author | Rudolf Polzer <divverent@xonotic.org> | 2012-09-27 11:08:59 +0200 |
---|---|---|
committer | Rudolf Polzer <divverent@xonotic.org> | 2012-09-28 13:43:59 +0200 |
commit | c22482e08d4ca0514685e73b68479f0427b1f28f (patch) | |
tree | 9f3c68dfe884fc2df89c9a3160806814b9dd6da2 /TOOLS/vf_dlopen | |
parent | 65ea69f56476aabb0755ae80b7dc565df23ab426 (diff) | |
download | mpv-c22482e08d4ca0514685e73b68479f0427b1f28f.tar.bz2 mpv-c22482e08d4ca0514685e73b68479f0427b1f28f.tar.xz |
TOOLS: fix first frame pts for dlopen/telecine.so
When the first frame of a telecine pattern did not generate an output
frame (because it is a 0 or a 1), this could lead to the first two
output frames getting equal pts values.
When the first frame of a telecine pattern generates exactly one output
frame (i.e. when the telecine pattern starts with 2 or 3), then the
output was correct before this comment, and still is unchanged.
When the first frame of a telecine pattern generates more than one
output frame (i.e. when it starts with 4 to 9), then output pts are
still broken. This is not really solvable without knowing the frame
duration, or delaying output by one frame.
Diffstat (limited to 'TOOLS/vf_dlopen')
-rw-r--r-- | TOOLS/vf_dlopen/telecine.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/TOOLS/vf_dlopen/telecine.c b/TOOLS/vf_dlopen/telecine.c index 109fef2d6b..1b3db26a20 100644 --- a/TOOLS/vf_dlopen/telecine.c +++ b/TOOLS/vf_dlopen/telecine.c @@ -11,7 +11,7 @@ /* * telecine filter * - * usage: -vf dlopen=./telecine.so:t:32 + * usage: -vf dlopen=./telecine.so:t:23 * * Parameter: first parameter is "t" for top field first, "b" for bottom field first * then digits (0-9) for how many fields a frame is to be displayed @@ -44,6 +44,7 @@ typedef struct { int occupied; double lastpts_in; double lastpts_out; + int first_frame_of_group; } tc_data_t; static int tc_config(struct vf_dlopen_context *ctx) @@ -116,9 +117,9 @@ static int tc_put_image(struct vf_dlopen_context *ctx) if (tc->pattern_pos == 0 && !tc->occupied) { // at the start of the pattern, reset pts - double newpts = ctx->inpic.pts - (delta * tc->pts_num) / tc->pts_denom; - // printf("pts reset: %f -> %f (delta: %f)\n", tc->lastpts_out, newpts, newpts - tc->lastpts_out); - tc->lastpts_out = newpts; + // printf("pts reset: %f -> %f (delta: %f)\n", tc->lastpts_out, ctx->inpic.pts, ctx->inpic.pts - tc->lastpts_out); + tc->lastpts_out = ctx->inpic.pts; + tc->first_frame_of_group = 1; } ++tc->pattern_pos; if (!tc->pattern[tc->pattern_pos]) @@ -150,7 +151,10 @@ static int tc_put_image(struct vf_dlopen_context *ctx) (ctx->inpic.planeheight[p] - !tc->firstfield + 1) / 2 ); } - tc->lastpts_out += (delta * tc->pts_num) / tc->pts_denom; + if (tc->first_frame_of_group) + tc->first_frame_of_group = 0; + else + tc->lastpts_out += (delta * tc->pts_num) / tc->pts_denom; ctx->outpic[nout].pts = tc->lastpts_out; // printf("pts written: %f\n", ctx->outpic[nout].pts); ++nout; @@ -167,7 +171,10 @@ static int tc_put_image(struct vf_dlopen_context *ctx) MIN(ctx->inpic.planestride[p], ctx->outpic[nout].planestride[p]), ctx->inpic.planeheight[p] ); - tc->lastpts_out += (delta * tc->pts_num) / tc->pts_denom; + if (tc->first_frame_of_group) + tc->first_frame_of_group = 0; + else + tc->lastpts_out += (delta * tc->pts_num) / tc->pts_denom; ctx->outpic[nout].pts = tc->lastpts_out; // printf("pts written: %f\n", ctx->outpic[nout].pts); ++nout; |