You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavfi/vf_libplacebo: fix crop expr PTS calculation
mix->timestamps is expressed relative to the source timebase, which is possibly a different timescale from `base_pts`. We can't mix-and-match here. The only reason this worked in my previous testing was because I was testing on a source file which had an exactly matching timebase. Fix it by always using the exact PTS as tagged on the AVFrame.
This commit is contained in:
@@ -651,7 +651,7 @@ fail:
|
|||||||
|
|
||||||
static void update_crops(AVFilterContext *ctx,
|
static void update_crops(AVFilterContext *ctx,
|
||||||
struct pl_frame_mix *mix, struct pl_frame *target,
|
struct pl_frame_mix *mix, struct pl_frame *target,
|
||||||
uint64_t ref_sig, double base_pts)
|
uint64_t ref_sig, double target_pts)
|
||||||
{
|
{
|
||||||
LibplaceboContext *s = ctx->priv;
|
LibplaceboContext *s = ctx->priv;
|
||||||
|
|
||||||
@@ -659,11 +659,12 @@ static void update_crops(AVFilterContext *ctx,
|
|||||||
// Mutate the `pl_frame.crop` fields in-place. This is fine because we
|
// Mutate the `pl_frame.crop` fields in-place. This is fine because we
|
||||||
// own the entire pl_queue, and hence, the pointed-at frames.
|
// own the entire pl_queue, and hence, the pointed-at frames.
|
||||||
struct pl_frame *image = (struct pl_frame *) mix->frames[i];
|
struct pl_frame *image = (struct pl_frame *) mix->frames[i];
|
||||||
double image_pts = base_pts + mix->timestamps[i];
|
const AVFrame *src = pl_get_mapped_avframe(image);
|
||||||
|
double image_pts = src->pts * av_q2d(ctx->inputs[0]->time_base);
|
||||||
|
|
||||||
/* Update dynamic variables */
|
/* Update dynamic variables */
|
||||||
s->var_values[VAR_IN_T] = s->var_values[VAR_T] = image_pts;
|
s->var_values[VAR_IN_T] = s->var_values[VAR_T] = image_pts;
|
||||||
s->var_values[VAR_OUT_T] = s->var_values[VAR_OT] = base_pts;
|
s->var_values[VAR_OUT_T] = s->var_values[VAR_OT] = target_pts;
|
||||||
s->var_values[VAR_N] = ctx->outputs[0]->frame_count_out;
|
s->var_values[VAR_N] = ctx->outputs[0]->frame_count_out;
|
||||||
|
|
||||||
/* Clear these explicitly to avoid leaking previous frames' state */
|
/* Clear these explicitly to avoid leaking previous frames' state */
|
||||||
|
Reference in New Issue
Block a user