* [FFmpeg-devel] [PATCH] Add (and use) av_rescale_ts() and av_rescale_ts_rnd() (PR #20613)
@ 2025-09-26 11:58 Niklas Haas via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Niklas Haas via ffmpeg-devel @ 2025-09-26 11:58 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
PR #20613 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20613
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20613.patch
Supersedes: FFmpeg/FFmpeg#20603
Fixes: FFmpeg/FFmpeg#20589
>From e7cdaf8a842c8c8e9c439e53da70fa61f91f4ce9 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Fri, 26 Sep 2025 13:12:22 +0200
Subject: [PATCH 1/2] avutil/mathematics: add av_rescale_ts() and
av_rescale_ts_rnd()
av_rescale_q() will mangle PTS values that have the form AV_NOPTS_VALUE.
Additionally, av_rescale_q() will currently return INT64_MIN when called on
undefined or negative timebases, but it would arguably be better to return
AV_NOPTS_VALUE in this case as well, as the canonical "NaN" / undefined value.
Supersedes: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20603
---
doc/APIchanges | 3 +++
libavutil/mathematics.c | 16 ++++++++++++++++
libavutil/mathematics.h | 17 +++++++++++++++++
libavutil/version.h | 2 +-
4 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 9d629f766f..1123d4c475 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
+2025-09-xx - xxxxxxxxxx - lavu 60.14.100 - mathematics.h
+ Add av_rescale_ts() and av_rescale_ts_rnd().
+
2025-09-xx - xxxxxxxxxx - lavu 60.13.100 - hwcontext_d3d12va.h
Add resource_flags and heap_flags to AVD3D12VADeviceContext
Add heap_flags to AVD3D12VAFramesContext
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 61aeb7c029..4d88fecfa6 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -144,6 +144,22 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
}
+int64_t av_rescale_ts_rnd(int64_t ts, AVRational src, AVRational dst,
+ enum AVRounding rnd)
+{
+ int64_t p = src.num * (int64_t)dst.den;
+ int64_t q = dst.num * (int64_t)src.den;
+ if (ts == AV_NOPTS_VALUE || p <= 0 || q <= 0);
+ return AV_NOPTS_VALUE;
+
+ return av_rescale_rnd(ts, p, q, rnd);
+}
+
+int64_t av_rescale_ts(int64_t ts, AVRational src, AVRational dst)
+{
+ return av_rescale_ts_rnd(ts, src, dst, AV_ROUND_NEAR_INF);
+}
+
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
{
int64_t a = tb_a.num * (int64_t)tb_b.den;
diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h
index 486de530f2..d056e85bb1 100644
--- a/libavutil/mathematics.h
+++ b/libavutil/mathematics.h
@@ -213,6 +213,23 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
enum AVRounding rnd) av_const;
+/**
+ * Rescale a PTS/DTS value from one timebase to another. Like `av_rescale_q`,
+ * but returns AV_NOPTS_VALUE if `ts` is itself AV_NOPTS_VALUE, or if either of
+ * the two timebases are of an invalid form.
+ *
+ * @see av_rescale_q(), av_rescale_ts_rnd()
+ */
+int64_t av_rescale_ts(int64_t ts, AVRational src, AVRational dst) av_const;
+
+/**
+ * Rescale a PTS/DTS value from one timebase to another with specified rounding.
+ *
+ * @see av_rescale_q(), av_rescale_ts()
+ */
+int64_t av_rescale_ts_rnd(int64_t ts, AVRational src, AVRational dst,
+ enum AVRounding rnd) av_const;
+
/**
* Compare two timestamps each in its own time base.
*
diff --git a/libavutil/version.h b/libavutil/version.h
index 1099715076..176b99aef3 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 60
-#define LIBAVUTIL_VERSION_MINOR 13
+#define LIBAVUTIL_VERSION_MINOR 14
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.49.1
>From 03a06b7ab6e5092e4eea0069824dd9b20a486064 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Fri, 26 Sep 2025 13:47:59 +0200
Subject: [PATCH 2/2] avfilter: use av_rescale_ts for pts rescaling
In order to remain conservative, and to preserve existing behavior wherever
possible I have only replaced usages with this general shape:
out_pts = av_rescale_q(in->pts, ...)
That is, I don't use the new helper when rescaling durations, or when
the source value is a constant, or when the destination will be used
in arithmetic (beyond simply setting a pts value), e.g. in the case
of PTS deltas and differences.
While I'm sure there are more bugs related to AV_NOPTS_VALUE lurking in
the code whenever there is arithmetic on pts values, I have not attempted
to isolate and fix them as part of this patch.
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20589
---
libavfilter/af_adelay.c | 4 ++--
libavfilter/af_aiir.c | 2 +-
libavfilter/af_amix.c | 4 ++--
libavfilter/af_atempo.c | 6 +++---
libavfilter/avf_a3dscope.c | 2 +-
libavfilter/avf_abitscope.c | 2 +-
libavfilter/avf_ahistogram.c | 2 +-
libavfilter/avf_aphasemeter.c | 2 +-
libavfilter/avf_avectorscope.c | 2 +-
libavfilter/avf_concat.c | 2 +-
libavfilter/avf_showcqt.c | 4 ++--
libavfilter/avf_showcwt.c | 6 +++---
libavfilter/avf_showfreqs.c | 2 +-
libavfilter/avf_showspatial.c | 2 +-
libavfilter/avf_showspectrum.c | 4 ++--
libavfilter/avf_showvolume.c | 2 +-
libavfilter/avfilter.c | 4 ++--
libavfilter/f_cue.c | 4 ++--
libavfilter/f_drawgraph.c | 2 +-
libavfilter/f_ebur128.c | 2 +-
libavfilter/f_graphmonitor.c | 2 +-
libavfilter/f_interleave.c | 2 +-
libavfilter/f_loop.c | 2 +-
libavfilter/f_realtime.c | 2 +-
libavfilter/f_select.c | 2 +-
libavfilter/f_sendcmd.c | 2 +-
libavfilter/f_streamselect.c | 2 +-
libavfilter/framequeue.c | 2 +-
libavfilter/framesync.c | 4 ++--
libavfilter/qsvvpp.c | 6 +++---
libavfilter/settb.c | 2 +-
libavfilter/trim.c | 8 ++++----
libavfilter/vf_bm3d.c | 2 +-
libavfilter/vf_colormap.c | 2 +-
libavfilter/vf_coreimage.m | 2 +-
libavfilter/vf_decimate.c | 2 +-
libavfilter/vf_displace.c | 2 +-
libavfilter/vf_estdif.c | 4 ++--
libavfilter/vf_fade.c | 2 +-
libavfilter/vf_fps.c | 4 ++--
libavfilter/vf_framerate.c | 2 +-
libavfilter/vf_frei0r.c | 2 +-
libavfilter/vf_hysteresis.c | 2 +-
libavfilter/vf_interlace_vulkan.c | 2 +-
libavfilter/vf_libplacebo.c | 6 +++---
libavfilter/vf_limitdiff.c | 2 +-
libavfilter/vf_lut2.c | 2 +-
libavfilter/vf_maskedclamp.c | 2 +-
libavfilter/vf_maskedmerge.c | 2 +-
libavfilter/vf_maskedminmax.c | 2 +-
libavfilter/vf_maskedthreshold.c | 2 +-
libavfilter/vf_mergeplanes.c | 2 +-
libavfilter/vf_midequalizer.c | 2 +-
libavfilter/vf_minterpolate.c | 2 +-
libavfilter/vf_mix.c | 4 ++--
libavfilter/vf_morpho.c | 2 +-
libavfilter/vf_multiply.c | 2 +-
libavfilter/vf_overlay_qsv.c | 4 ++--
libavfilter/vf_premultiply.c | 2 +-
libavfilter/vf_remap.c | 2 +-
libavfilter/vf_scale.c | 2 +-
libavfilter/vf_stack.c | 2 +-
libavfilter/vf_stack_qsv.c | 4 ++--
libavfilter/vf_stack_vaapi.c | 2 +-
libavfilter/vf_subtitles.c | 2 +-
libavfilter/vf_threshold.c | 2 +-
libavfilter/vf_tinterlace.c | 4 ++--
libavfilter/vf_tpad.c | 2 +-
libavfilter/vf_untile.c | 2 +-
libavfilter/vf_vif.c | 2 +-
libavfilter/vf_vpp_qsv.c | 4 ++--
libavfilter/vf_xmedian.c | 2 +-
72 files changed, 97 insertions(+), 97 deletions(-)
diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
index c0d076fe64..f1ed7cd3d0 100644
--- a/libavfilter/af_adelay.c
+++ b/libavfilter/af_adelay.c
@@ -335,7 +335,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
return ff_filter_frame(outlink, frame);
}
- s->next_pts = av_rescale_q(frame->pts, inlink->time_base, outlink->time_base);
+ s->next_pts = av_rescale_ts(frame->pts, inlink->time_base, outlink->time_base);
out_frame = ff_get_audio_buffer(outlink, frame->nb_samples);
if (!out_frame) {
@@ -387,7 +387,7 @@ static int activate(AVFilterContext *ctx)
}
if (s->next_pts == AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE)
- s->next_pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ s->next_pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
if (s->padding) {
int nb_samples = FFMIN(s->padding, 2048);
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index f18b6e9286..2b497312cf 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -1410,7 +1410,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if (s->response) {
AVFilterLink *outlink = ctx->outputs[1];
int64_t old_pts = s->video->pts;
- int64_t new_pts = av_rescale_q(out->pts, ctx->inputs[0]->time_base, outlink->time_base);
+ int64_t new_pts = av_rescale_ts(out->pts, ctx->inputs[0]->time_base, outlink->time_base);
if (new_pts > old_pts) {
AVFrame *clone;
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 082d69b97f..ac79e6cebb 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -447,8 +447,8 @@ static int activate(AVFilterContext *ctx)
if ((ret = ff_inlink_consume_frame(ctx->inputs[i], &buf)) > 0) {
if (i == 0) {
- int64_t pts = av_rescale_q(buf->pts, inlink->time_base,
- outlink->time_base);
+ int64_t pts = av_rescale_ts(buf->pts, inlink->time_base,
+ outlink->time_base);
ret = frame_list_add_frame(s->frame_list, buf->nb_samples, pts);
if (ret < 0) {
av_frame_free(&buf);
diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index 768840d99c..b315a0f445 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -1064,9 +1064,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *src_buffer)
const uint8_t *src_end = src + n_in * atempo->stride;
if (atempo->start_pts == AV_NOPTS_VALUE)
- atempo->start_pts = av_rescale_q(src_buffer->pts,
- inlink->time_base,
- outlink->time_base);
+ atempo->start_pts = av_rescale_ts(src_buffer->pts,
+ inlink->time_base,
+ outlink->time_base);
while (src < src_end) {
if (!atempo->dst_buffer) {
diff --git a/libavfilter/avf_a3dscope.c b/libavfilter/avf_a3dscope.c
index fb08720412..ad0f80b02b 100644
--- a/libavfilter/avf_a3dscope.c
+++ b/libavfilter/avf_a3dscope.c
@@ -233,7 +233,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
out->sample_aspect_ratio = (AVRational){1,1};
for (int y = 0; y < outlink->h; y++)
memset(out->data[0] + y * out->linesize[0], 0, outlink->w * 4);
- out->pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
+ out->pts = av_rescale_ts(in->pts, inlink->time_base, outlink->time_base);
out->duration = 1;
projection_matrix(s->fov, half_width / half_height, 0.1f, 1000000.f, s->projection_matrix);
diff --git a/libavfilter/avf_abitscope.c b/libavfilter/avf_abitscope.c
index a4b2109473..ff66e64672 100644
--- a/libavfilter/avf_abitscope.c
+++ b/libavfilter/avf_abitscope.c
@@ -231,7 +231,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
}
- outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
+ outpicref->pts = av_rescale_ts(insamples->pts, inlink->time_base, outlink->time_base);
outpicref->duration = 1;
outpicref->sample_aspect_ratio = (AVRational){1,1};
diff --git a/libavfilter/avf_ahistogram.c b/libavfilter/avf_ahistogram.c
index ce0d82f9ec..49834d372c 100644
--- a/libavfilter/avf_ahistogram.c
+++ b/libavfilter/avf_ahistogram.c
@@ -242,7 +242,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
memset(s->out->data[2] + n * s->out->linesize[0], 127, w);
memset(s->out->data[3] + n * s->out->linesize[0], 0, w);
}
- s->out->pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
+ s->out->pts = av_rescale_ts(in->pts, inlink->time_base, outlink->time_base);
s->out->duration = 1;
s->first = s->frame_count;
diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index eb55d56664..91bfe4fec3 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -329,7 +329,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
if (s->do_video)
- new_pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
+ new_pts = av_rescale_ts(in->pts, inlink->time_base, outlink->time_base);
if (s->do_video && new_pts != s->last_pts) {
AVFrame *clone;
diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c
index 902d461d86..0a092d53d2 100644
--- a/libavfilter/avf_avectorscope.c
+++ b/libavfilter/avf_avectorscope.c
@@ -313,7 +313,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
for (int i = 0; i < outlink->h; i++)
memset(s->outpicref->data[0] + i * s->outpicref->linesize[0], 0, outlink->w * 4);
}
- s->outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
+ s->outpicref->pts = av_rescale_ts(insamples->pts, inlink->time_base, outlink->time_base);
s->outpicref->duration = 1;
ret = ff_inlink_make_frame_writable(outlink, &s->outpicref);
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 531aa071a0..0a1e49f206 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -184,7 +184,7 @@ static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)
AVFilterLink *outlink = ctx->outputs[out_no];
struct concat_in *in = &cat->in[in_no];
- buf->pts = av_rescale_q(buf->pts, inlink->time_base, outlink->time_base);
+ buf->pts = av_rescale_ts(buf->pts, inlink->time_base, outlink->time_base);
buf->duration = av_rescale_q(buf->duration, inlink->time_base, outlink->time_base);
in->pts = buf->pts;
in->nb_frames++;
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index abfae1f8fb..aafcb9cf1c 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -1529,7 +1529,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
if (out) {
int64_t pts = av_rescale_q(insamples->nb_samples - remaining - s->remaining_fill_max,
av_make_q(1, inlink->sample_rate), inlink->time_base);
- out->pts = av_rescale_q(insamples->pts + pts, inlink->time_base, outlink->time_base);
+ out->pts = av_rescale_ts(insamples->pts + pts, inlink->time_base, outlink->time_base);
out->duration = 1;
got_frame = 1;
ret = ff_filter_frame(outlink, out);
@@ -1579,7 +1579,7 @@ static int activate(AVFilterContext *ctx)
if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
if (status == AVERROR_EOF) {
- s->next_pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ s->next_pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
ret = filter_frame(inlink, NULL);
ff_outlink_set_status(outlink, AVERROR_EOF, s->next_pts);
return ret;
diff --git a/libavfilter/avf_showcwt.c b/libavfilter/avf_showcwt.c
index 8edf2fb43b..a4fd4f888f 100644
--- a/libavfilter/avf_showcwt.c
+++ b/libavfilter/avf_showcwt.c
@@ -1184,7 +1184,7 @@ static int output_frame(AVFilterContext *ctx)
const int offset = (s->input_padding_size - s->hop_size) >> 1;
pts_offset = av_rescale_q(pts_offset - offset, av_make_q(1, inlink->sample_rate), inlink->time_base);
- s->outpicref->pts = av_rescale_q(s->in_pts + pts_offset, inlink->time_base, outlink->time_base);
+ s->outpicref->pts = av_rescale_ts(s->in_pts + pts_offset, inlink->time_base, outlink->time_base);
s->outpicref->duration = 1;
}
@@ -1258,7 +1258,7 @@ static int activate(AVFilterContext *ctx)
if (s->hop_index == 0) {
s->in_pts = fin->pts;
if (s->old_pts == AV_NOPTS_VALUE)
- s->old_pts = av_rescale_q(s->in_pts, inlink->time_base, outlink->time_base) - 1;
+ s->old_pts = av_rescale_ts(s->in_pts, inlink->time_base, outlink->time_base) - 1;
}
s->hop_index += fin->nb_samples;
av_frame_free(&fin);
@@ -1291,7 +1291,7 @@ static int activate(AVFilterContext *ctx)
if (status == AVERROR_EOF) {
s->eof = 1;
ff_filter_set_ready(ctx, 10);
- s->eof_pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ s->eof_pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
return 0;
}
}
diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c
index 244b013ada..5495e1bc74 100644
--- a/libavfilter/avf_showfreqs.c
+++ b/libavfilter/avf_showfreqs.c
@@ -400,7 +400,7 @@ static int plot_freqs(AVFilterLink *inlink, int64_t pts)
s->tx_fn(s->fft, s->fft_data[ch], s->fft_input[ch], sizeof(AVComplexFloat));
}
- s->pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ s->pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
if (s->old_pts >= s->pts)
return 0;
s->old_pts = s->pts;
diff --git a/libavfilter/avf_showspatial.c b/libavfilter/avf_showspatial.c
index 491501e337..8ba1808dde 100644
--- a/libavfilter/avf_showspatial.c
+++ b/libavfilter/avf_showspatial.c
@@ -208,7 +208,7 @@ static int draw_spatial(AVFilterLink *inlink, AVFrame *insamples)
int h = s->h - 2;
int w = s->w - 2;
int z = s->win_size / 2;
- int64_t pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
+ int64_t pts = av_rescale_ts(insamples->pts, inlink->time_base, outlink->time_base);
outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!outpicref)
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index ee71d55894..fd925a6088 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -1519,7 +1519,7 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
}
if (s->sliding != FULLFRAME || s->xpos == 0)
- s->pts = outpicref->pts = av_rescale_q(s->in_pts, inlink->time_base, outlink->time_base);
+ s->pts = outpicref->pts = av_rescale_ts(s->in_pts, inlink->time_base, outlink->time_base);
if (s->sliding == LREPLACE) {
s->xpos--;
@@ -1640,7 +1640,7 @@ static int activate(AVFilterContext *ctx)
memset(s->outpicref->data[3] + i * s->outpicref->linesize[3], 0, outlink->w);
}
}
- s->outpicref->pts = av_rescale_q(s->in_pts, inlink->time_base, outlink->time_base);
+ s->outpicref->pts = av_rescale_ts(s->in_pts, inlink->time_base, outlink->time_base);
pts = s->outpicref->pts;
ret = ff_filter_frame(outlink, s->outpicref);
s->outpicref = NULL;
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
index 8472e86a15..836c8b55b3 100644
--- a/libavfilter/avf_showvolume.c
+++ b/libavfilter/avf_showvolume.c
@@ -327,7 +327,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
clear_picture(s, outlink);
}
- s->out->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
+ s->out->pts = av_rescale_ts(insamples->pts, inlink->time_base, outlink->time_base);
s->out->duration = 1;
if ((s->f < 1.) && (s->f > 0.)) {
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 169c2baa42..0949e1eb81 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -515,14 +515,14 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational lin
for (i = 0; i < ctx->nb_inputs; i++) {
FilterLinkInternal * const li = ff_link_internal(ctx->inputs[i]);
if (li->status_out == status)
- r = FFMIN(r, av_rescale_q(li->l.current_pts, ctx->inputs[i]->time_base, link_time_base));
+ r = FFMIN(r, av_rescale_ts(li->l.current_pts, ctx->inputs[i]->time_base, link_time_base));
}
if (r < INT64_MAX)
return r;
av_log(ctx, AV_LOG_WARNING, "EOF timestamp not reliable\n");
for (i = 0; i < ctx->nb_inputs; i++) {
FilterLinkInternal * const li = ff_link_internal(ctx->inputs[i]);
- r = FFMIN(r, av_rescale_q(li->status_in_pts, ctx->inputs[i]->time_base, link_time_base));
+ r = FFMIN(r, av_rescale_ts(li->status_in_pts, ctx->inputs[i]->time_base, link_time_base));
}
if (r < INT64_MAX)
return r;
diff --git a/libavfilter/f_cue.c b/libavfilter/f_cue.c
index 63027c7c2e..d8a279c849 100644
--- a/libavfilter/f_cue.c
+++ b/libavfilter/f_cue.c
@@ -46,7 +46,7 @@ static int activate(AVFilterContext *ctx)
if (ff_inlink_queued_frames(inlink)) {
AVFrame *frame = ff_inlink_peek_frame(inlink, 0);
- int64_t pts = av_rescale_q(frame->pts, inlink->time_base, AV_TIME_BASE_Q);
+ int64_t pts = av_rescale_ts(frame->pts, inlink->time_base, AV_TIME_BASE_Q);
if (!s->status) {
s->first_pts = pts;
@@ -64,7 +64,7 @@ static int activate(AVFilterContext *ctx)
}
if (s->status == 2) {
frame = ff_inlink_peek_frame(inlink, ff_inlink_queued_frames(inlink) - 1);
- pts = av_rescale_q(frame->pts, inlink->time_base, AV_TIME_BASE_Q);
+ pts = av_rescale_ts(frame->pts, inlink->time_base, AV_TIME_BASE_Q);
if (!(pts - s->first_pts < s->buffer && (av_gettime() - s->cue) < 0))
s->status++;
}
diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c
index f781e8c2fe..f04605ffc3 100644
--- a/libavfilter/f_drawgraph.c
+++ b/libavfilter/f_drawgraph.c
@@ -327,7 +327,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if (s->slide == 4)
return 0;
- out_pts = av_rescale_q(in_pts, inlink->time_base, outlink->time_base);
+ out_pts = av_rescale_ts(in_pts, inlink->time_base, outlink->time_base);
if (out_pts == s->prev_pts)
return 0;
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index a352f3831f..f53afe5499 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -889,7 +889,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
}
/* set pts and push frame */
- pic->pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ pic->pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
pic->duration = 1;
clone = av_frame_clone(pic);
if (!clone)
diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c
index 20cdcce79d..a3ada770fa 100644
--- a/libavfilter/f_graphmonitor.c
+++ b/libavfilter/f_graphmonitor.c
@@ -503,7 +503,7 @@ static int activate(AVFilterContext *ctx)
}
if (pts != AV_NOPTS_VALUE) {
- pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
if (s->pts == AV_NOPTS_VALUE)
s->pts = pts;
s->next_pts = pts;
diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index 31e903e6b0..a00032b6e6 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -113,7 +113,7 @@ static int activate(AVFilterContext *ctx)
return AVERROR_INVALIDDATA;
}
- q_pts = av_rescale_q(frame->pts, ctx->inputs[i]->time_base, AV_TIME_BASE_Q);
+ q_pts = av_rescale_ts(frame->pts, ctx->inputs[i]->time_base, AV_TIME_BASE_Q);
if (q_pts < pts) {
pts = q_pts;
input_idx = i;
diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 1984fad70d..f5aca375ab 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -72,7 +72,7 @@ static void update_time(AVFilterContext *ctx, AVRational tb)
LoopContext *s = ctx->priv;
if (s->time != INT64_MAX) {
- int64_t time_pts = av_rescale_q(s->time, AV_TIME_BASE_Q, tb);
+ int64_t time_pts = av_rescale_ts(s->time, AV_TIME_BASE_Q, tb);
if (s->time_pts == AV_NOPTS_VALUE || time_pts < s->time_pts)
s->time_pts = time_pts;
}
diff --git a/libavfilter/f_realtime.c b/libavfilter/f_realtime.c
index e142e0ca57..d83f2abed5 100644
--- a/libavfilter/f_realtime.c
+++ b/libavfilter/f_realtime.c
@@ -42,7 +42,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
RealtimeContext *s = ctx->priv;
if (frame->pts != AV_NOPTS_VALUE) {
- int64_t pts = av_rescale_q(frame->pts, inlink->time_base, AV_TIME_BASE_Q) / s->speed;
+ int64_t pts = av_rescale_ts(frame->pts, inlink->time_base, AV_TIME_BASE_Q) / s->speed;
int64_t now = av_gettime_relative();
int64_t sleep = pts - now + s->delta;
if (!s->inited) {
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 46208a7b76..72f17d56b9 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -350,7 +350,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame)
select->var_values[VAR_PTS] = TS2D(frame->pts);
select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
select->var_values[VAR_KEY] = !!(frame->flags & AV_FRAME_FLAG_KEY);
- select->var_values[VAR_CONCATDEC_SELECT] = get_concatdec_select(frame, av_rescale_q(frame->pts, inlink->time_base, AV_TIME_BASE_Q));
+ select->var_values[VAR_CONCATDEC_SELECT] = get_concatdec_select(frame, av_rescale_ts(frame->pts, inlink->time_base, AV_TIME_BASE_Q));
switch (inlink->type) {
case AVMEDIA_TYPE_AUDIO:
diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index 304658ae3d..01479e2497 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -500,7 +500,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
if (ref->pts == AV_NOPTS_VALUE)
goto end;
- ts = av_rescale_q(ref->pts, inlink->time_base, AV_TIME_BASE_Q);
+ ts = av_rescale_ts(ref->pts, inlink->time_base, AV_TIME_BASE_Q);
#define WITHIN_INTERVAL(ts, start_ts, end_ts) ((ts) >= (start_ts) && (ts) < (end_ts))
diff --git a/libavfilter/f_streamselect.c b/libavfilter/f_streamselect.c
index 7378c9c2fe..ba6ae42861 100644
--- a/libavfilter/f_streamselect.c
+++ b/libavfilter/f_streamselect.c
@@ -75,7 +75,7 @@ static int process_frame(FFFrameSync *fs)
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, ctx->outputs[i]->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, ctx->outputs[i]->time_base);
s->last_pts[j] = in[j]->pts;
ret = ff_filter_frame(ctx->outputs[i], out);
have_out = 1;
diff --git a/libavfilter/framequeue.c b/libavfilter/framequeue.c
index 3363406ba7..93c659dbd3 100644
--- a/libavfilter/framequeue.c
+++ b/libavfilter/framequeue.c
@@ -146,7 +146,7 @@ void ff_framequeue_skip_samples(FFFrameQueue *fq, size_t samples, AVRational tim
if (!planar)
bytes *= b->frame->ch_layout.nb_channels;
if (b->frame->pts != AV_NOPTS_VALUE)
- b->frame->pts += av_rescale_q(samples, av_make_q(1, b->frame->sample_rate), time_base);
+ b->frame->pts += av_rescale_ts(samples, av_make_q(1, b->frame->sample_rate), time_base);
b->frame->nb_samples -= samples;
b->frame->linesize[0] -= bytes;
for (i = 0; i < planes; i++)
diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index 0d5779f830..01bb6f286c 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -248,7 +248,7 @@ static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame)
av_assert0(!fs->in[in].have_next);
av_assert0(frame);
- pts = av_rescale_q(frame->pts, fs->in[in].time_base, fs->time_base);
+ pts = av_rescale_ts(frame->pts, fs->in[in].time_base, fs->time_base);
frame->pts = pts;
fs->in[in].frame_next = frame;
fs->in[in].pts_next = pts;
@@ -399,7 +399,7 @@ int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
return ret;
}
av_assert0(mainpic);
- mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base);
+ mainpic->pts = av_rescale_ts(fs->pts, fs->time_base, ctx->outputs[0]->time_base);
if (ctx->is_disabled)
secondpic = NULL;
*f0 = mainpic;
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index c3685f126c..bc9f3a22e2 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -453,7 +453,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p
}
qsv_frame->surface.Info = s->frame_infos[FF_INLINK_IDX(inlink)];
- qsv_frame->surface.Data.TimeStamp = av_rescale_q(qsv_frame->frame->pts,
+ qsv_frame->surface.Data.TimeStamp = av_rescale_ts(qsv_frame->frame->pts,
inlink->time_base, default_tb);
qsv_frame->surface.Info.PicStruct =
@@ -1014,8 +1014,8 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr
break;
}
- out_frame->frame->pts = av_rescale_q(out_frame->surface.Data.TimeStamp,
- default_tb, outlink->time_base);
+ out_frame->frame->pts = av_rescale_ts(out_frame->surface.Data.TimeStamp,
+ default_tb, outlink->time_base);
out_frame->queued++;
aframe = (QSVAsyncFrame){ sync, out_frame };
diff --git a/libavfilter/settb.c b/libavfilter/settb.c
index 6000c9c5a6..8ba06ad00d 100644
--- a/libavfilter/settb.c
+++ b/libavfilter/settb.c
@@ -112,7 +112,7 @@ static int64_t rescale_pts(AVFilterLink *inlink, AVFilterLink *outlink, int64_t
int64_t new_pts = orig_pts;
if (av_cmp_q(inlink->time_base, outlink->time_base)) {
- new_pts = av_rescale_q(orig_pts, inlink->time_base, outlink->time_base);
+ new_pts = av_rescale_ts(orig_pts, inlink->time_base, outlink->time_base);
av_log(ctx, AV_LOG_DEBUG, "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
inlink ->time_base.num, inlink ->time_base.den, orig_pts,
outlink->time_base.num, outlink->time_base.den, new_pts);
diff --git a/libavfilter/trim.c b/libavfilter/trim.c
index 6d1016ac81..b20fcf68e6 100644
--- a/libavfilter/trim.c
+++ b/libavfilter/trim.c
@@ -151,8 +151,8 @@ static int atrim_filter_frame(AVFilterLink *inlink, AVFrame *frame)
return 0;
if (frame->pts != AV_NOPTS_VALUE)
- pts = av_rescale_q(frame->pts, inlink->time_base,
- (AVRational){ 1, inlink->sample_rate });
+ pts = av_rescale_ts(frame->pts, inlink->time_base,
+ (AVRational){ 1, inlink->sample_rate });
else
pts = s->next_pts;
s->next_pts = pts + frame->nb_samples;
@@ -264,12 +264,12 @@ static int config_input(AVFilterLink *inlink)
s->filter_frame = atrim_filter_frame;
#endif
if (s->start_time != INT64_MAX) {
- int64_t start_pts = av_rescale_q(s->start_time, AV_TIME_BASE_Q, tb);
+ int64_t start_pts = av_rescale_ts(s->start_time, AV_TIME_BASE_Q, tb);
if (s->start_pts == AV_NOPTS_VALUE || start_pts < s->start_pts)
s->start_pts = start_pts;
}
if (s->end_time != INT64_MAX) {
- int64_t end_pts = av_rescale_q(s->end_time, AV_TIME_BASE_Q, tb);
+ int64_t end_pts = av_rescale_ts(s->end_time, AV_TIME_BASE_Q, tb);
if (s->end_pts == AV_NOPTS_VALUE || end_pts > s->end_pts)
s->end_pts = end_pts;
}
diff --git a/libavfilter/vf_bm3d.c b/libavfilter/vf_bm3d.c
index b482f7693a..90ed1e2660 100644
--- a/libavfilter/vf_bm3d.c
+++ b/libavfilter/vf_bm3d.c
@@ -891,7 +891,7 @@ static int process_frame(FFFrameSync *fs)
if ((ret = filter_frame(ctx, &out, src, ref)) < 0)
return ret;
- out->pts = av_rescale_q(src->pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(src->pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_colormap.c b/libavfilter/vf_colormap.c
index e0afc471ef..e6bf607948 100644
--- a/libavfilter/vf_colormap.c
+++ b/libavfilter/vf_colormap.c
@@ -475,7 +475,7 @@ static int process_frame(FFFrameSync *fs)
out = in;
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index 5e043dc3e3..c0e08a95b6 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -279,7 +279,7 @@ static int request_frame(AVFilterLink *link)
AVFrame *frame;
if (ctx->duration >= 0 &&
- av_rescale_q(ctx->pts, ctx->time_base, AV_TIME_BASE_Q) >= ctx->duration) {
+ av_rescale_ts(ctx->pts, ctx->time_base, AV_TIME_BASE_Q) >= ctx->duration) {
return AVERROR_EOF;
}
diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index 9fee8a1472..8cd5909144 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -230,7 +230,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFrame *frame = dm->queue[i].frame;
dm->queue[i].frame = NULL;
if (frame->pts != AV_NOPTS_VALUE && dm->start_pts == AV_NOPTS_VALUE)
- dm->start_pts = av_rescale_q(frame->pts, dm->in_tb, outlink->time_base);
+ dm->start_pts = av_rescale_ts(frame->pts, dm->in_tb, outlink->time_base);
if (dm->ppsrc) {
av_frame_free(&frame);
diff --git a/libavfilter/vf_displace.c b/libavfilter/vf_displace.c
index 055488e6c9..68b8b00acf 100644
--- a/libavfilter/vf_displace.c
+++ b/libavfilter/vf_displace.c
@@ -280,7 +280,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, s->displace_slice, &td, NULL,
FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c
index b8289a6e96..f4668a42ca 100644
--- a/libavfilter/vf_estdif.c
+++ b/libavfilter/vf_estdif.c
@@ -539,8 +539,8 @@ static int request_frame(AVFilterLink *link)
if (!next)
return AVERROR(ENOMEM);
- next->pts = s->prev->pts + av_rescale_q(1, av_inv_q(l->frame_rate),
- ctx->outputs[0]->time_base);
+ next->pts = s->prev->pts + av_rescale_ts(1, av_inv_q(l->frame_rate),
+ ctx->outputs[0]->time_base);
s->eof = 1;
ret = filter_frame(ctx->inputs[0], next);
} else if (ret < 0) {
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index 794586af07..7d843ad12f 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -443,7 +443,7 @@ static int config_input(AVFilterLink *inlink)
if (s->duration)
s->duration_pts = av_rescale_q(s->duration, AV_TIME_BASE_Q, inlink->time_base);
if (s->start_time)
- s->start_time_pts = av_rescale_q(s->start_time, AV_TIME_BASE_Q, inlink->time_base);
+ s->start_time_pts = av_rescale_ts(s->start_time, AV_TIME_BASE_Q, inlink->time_base);
/* use CCIR601/709 black level for studio-level pixel non-alpha components */
s->black_level =
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 0257a8ef78..3ece2e09c5 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -317,8 +317,8 @@ static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlin
static void update_eof_pts(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, AVFilterLink *outlink, int64_t status_pts)
{
int eof_rounding = (s->eof_action == EOF_ACTION_PASS) ? AV_ROUND_UP : s->rounding;
- s->status_pts = av_rescale_q_rnd(status_pts, inlink->time_base, outlink->time_base,
- eof_rounding | AV_ROUND_PASS_MINMAX);
+ s->status_pts = av_rescale_ts_rnd(status_pts, inlink->time_base, outlink->time_base,
+ eof_rounding | AV_ROUND_PASS_MINMAX);
av_log(ctx, AV_LOG_DEBUG, "EOF is at pts %"PRId64"\n", s->status_pts);
}
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index a6598f97bb..def7de05fd 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -326,7 +326,7 @@ retry:
}
if (inpicref) {
- pts = av_rescale_q(inpicref->pts, s->srce_time_base, s->dest_time_base);
+ pts = av_rescale_ts(inpicref->pts, s->srce_time_base, s->dest_time_base);
if (s->f1 && pts == s->pts1) {
av_log(ctx, AV_LOG_WARNING, "Ignoring frame with same PTS.\n");
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 1284e27310..5e2155d9c6 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -489,7 +489,7 @@ static int source_request_frame(AVFilterLink *outlink)
frame->pts = s->pts++;
frame->duration = 1;
- s->update(s->instance, av_rescale_q(frame->pts, s->time_base, (AVRational){1,1000}),
+ s->update(s->instance, av_rescale_ts(frame->pts, s->time_base, (AVRational){1,1000}),
NULL, (uint32_t *)frame->data[0]);
return ff_filter_frame(outlink, frame);
diff --git a/libavfilter/vf_hysteresis.c b/libavfilter/vf_hysteresis.c
index c4e8b1ba63..67595c5884 100644
--- a/libavfilter/vf_hysteresis.c
+++ b/libavfilter/vf_hysteresis.c
@@ -127,7 +127,7 @@ static int process_frame(FFFrameSync *fs)
s->width[p], s->height[p]);
}
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_interlace_vulkan.c b/libavfilter/vf_interlace_vulkan.c
index 7afb30c2d7..d83f01cad6 100644
--- a/libavfilter/vf_interlace_vulkan.c
+++ b/libavfilter/vf_interlace_vulkan.c
@@ -228,7 +228,7 @@ static int interlace_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
if (s->mode == MODE_TFF)
out->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
- out->pts = av_rescale_q(out->pts, inlink->time_base, outlink->time_base);
+ out->pts = av_rescale_ts(out->pts, inlink->time_base, outlink->time_base);
out->duration = av_rescale_q(1, av_inv_q(l->frame_rate), outlink->time_base);
av_frame_free(&s->cur);
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 80d3b273bb..0de473e329 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -1146,7 +1146,7 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input)
if (!s->fps.num) {
/* Internally queue an output frame for the same PTS */
- pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
+ pts = av_rescale_ts(in->pts, inlink->time_base, outlink->time_base);
av_fifo_write(input->out_pts, &pts, 1);
if (s->send_fields && src.first_field != PL_FIELD_NONE) {
@@ -1161,8 +1161,8 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input)
return ret;
if (!input->status && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
- pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base,
- AV_ROUND_UP);
+ pts = av_rescale_ts_rnd(pts, inlink->time_base, outlink->time_base,
+ AV_ROUND_UP);
pl_queue_push(input->queue, NULL); /* Signal EOF to pl_queue */
input->status = status;
input->status_pts = pts;
diff --git a/libavfilter/vf_limitdiff.c b/libavfilter/vf_limitdiff.c
index d823275528..8b1780538a 100644
--- a/libavfilter/vf_limitdiff.c
+++ b/libavfilter/vf_limitdiff.c
@@ -232,7 +232,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, limitdiff_slice, &td, NULL,
FFMIN(s->planeheight[0], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c
index a37c0db949..af0376e5e0 100644
--- a/libavfilter/vf_lut2.c
+++ b/libavfilter/vf_lut2.c
@@ -323,7 +323,7 @@ static int process_frame(FFFrameSync *fs)
FFMIN(s->heightx[1], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c
index 39bd596827..feeebaa13d 100644
--- a/libavfilter/vf_maskedclamp.c
+++ b/libavfilter/vf_maskedclamp.c
@@ -156,7 +156,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, maskedclamp_slice, &td, NULL,
FFMIN(s->height[0], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c
index 93da0a0edf..e91d6e1d7b 100644
--- a/libavfilter/vf_maskedmerge.c
+++ b/libavfilter/vf_maskedmerge.c
@@ -132,7 +132,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, filter_slice, &td, NULL,
FFMIN(s->height[2], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_maskedminmax.c b/libavfilter/vf_maskedminmax.c
index b6762e16bf..ec39911309 100644
--- a/libavfilter/vf_maskedminmax.c
+++ b/libavfilter/vf_maskedminmax.c
@@ -208,7 +208,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, maskedminmax_slice, &td, NULL,
FFMIN(s->planeheight[0], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_maskedthreshold.c b/libavfilter/vf_maskedthreshold.c
index 41c204f6f5..59d6fd20f2 100644
--- a/libavfilter/vf_maskedthreshold.c
+++ b/libavfilter/vf_maskedthreshold.c
@@ -209,7 +209,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, threshold_slice, &td, NULL,
FFMIN(s->planeheight[2], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_mergeplanes.c b/libavfilter/vf_mergeplanes.c
index 0073e46665..3da46791e7 100644
--- a/libavfilter/vf_mergeplanes.c
+++ b/libavfilter/vf_mergeplanes.c
@@ -167,7 +167,7 @@ static int process_frame(FFFrameSync *fs)
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
for (i = 0; i < s->nb_planes; i++) {
const int input = s->map[i].input;
diff --git a/libavfilter/vf_midequalizer.c b/libavfilter/vf_midequalizer.c
index 9720cefdf2..96b77cd34b 100644
--- a/libavfilter/vf_midequalizer.c
+++ b/libavfilter/vf_midequalizer.c
@@ -122,7 +122,7 @@ static int process_frame(FFFrameSync *fs)
s->cchange, s->histogram_size);
}
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index ba5c512e03..b808b44750 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -1170,7 +1170,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *avf_in)
if (!mi_ctx->frames[NB_FRAMES - 1].avf || avf_in->pts < mi_ctx->frames[NB_FRAMES - 1].avf->pts) {
av_log(ctx, AV_LOG_VERBOSE, "Initializing out pts from input pts %"PRId64"\n", avf_in->pts);
- mi_ctx->out_pts = av_rescale_q(avf_in->pts, inlink->time_base, outlink->time_base);
+ mi_ctx->out_pts = av_rescale_ts(avf_in->pts, inlink->time_base, outlink->time_base);
}
if (!mi_ctx->frames[NB_FRAMES - 1].avf)
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 517bb2450f..9cf90700a3 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -298,14 +298,14 @@ static int process_frame(FFFrameSync *fs)
out = av_frame_clone(s->frames[0]);
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
td.in = in;
td.out = out;
diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c
index 098d00dfd1..93be8406c0 100644
--- a/libavfilter/vf_morpho.c
+++ b/libavfilter/vf_morpho.c
@@ -989,7 +989,7 @@ static int do_morpho(FFFrameSync *fs)
}
av_frame_free(&in);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
fail:
av_frame_free(&out);
diff --git a/libavfilter/vf_multiply.c b/libavfilter/vf_multiply.c
index f7db2195db..c6f5880923 100644
--- a/libavfilter/vf_multiply.c
+++ b/libavfilter/vf_multiply.c
@@ -153,7 +153,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, multiply_slice, &td, NULL,
FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index ce4a13e957..989de3ba72 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -317,8 +317,8 @@ static int config_output(AVFilterLink *outlink)
static int filter_callback(AVFilterLink *outlink, AVFrame *frame)
{
QSVOverlayContext *s = outlink->src->priv;
- frame->pts = av_rescale_q(s->fs.pts,
- s->fs.time_base, outlink->time_base);
+ frame->pts = av_rescale_ts(s->fs.pts,
+ s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, frame);
}
diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
index 9b4fc39ccb..77d3299531 100644
--- a/libavfilter/vf_premultiply.c
+++ b/libavfilter/vf_premultiply.c
@@ -686,7 +686,7 @@ static int process_frame(FFFrameSync *fs)
if ((ret = filter_frame(ctx, &out, base, alpha)) < 0)
return ret;
- out->pts = av_rescale_q(base->pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(base->pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_remap.c b/libavfilter/vf_remap.c
index 8146159d93..66c69e343c 100644
--- a/libavfilter/vf_remap.c
+++ b/libavfilter/vf_remap.c
@@ -303,7 +303,7 @@ static int process_frame(FFFrameSync *fs)
ff_filter_execute(ctx, s->remap_slice, &td, NULL,
FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index c0cd1b96c6..4bc9ed0c76 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -951,7 +951,7 @@ static int do_scale(FFFrameSync *fs)
goto err;
av_assert0(out);
- out->pts = av_rescale_q(fs->pts, fs->time_base, outlink->time_base);
+ out->pts = av_rescale_ts(fs->pts, fs->time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
err:
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index a36e1bab64..f452b9ea08 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -183,7 +183,7 @@ static int process_frame(FFFrameSync *fs)
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
out->sample_aspect_ratio = outlink->sample_aspect_ratio;
if (s->fillcolor_enable)
diff --git a/libavfilter/vf_stack_qsv.c b/libavfilter/vf_stack_qsv.c
index 82fb3c09a3..558fef6682 100644
--- a/libavfilter/vf_stack_qsv.c
+++ b/libavfilter/vf_stack_qsv.c
@@ -174,8 +174,8 @@ static int filter_callback(AVFilterLink *outlink, AVFrame *frame)
{
StackQSVContext *sctx = outlink->src->priv;
- frame->pts = av_rescale_q(sctx->base.fs.pts,
- sctx->base.fs.time_base, outlink->time_base);
+ frame->pts = av_rescale_ts(sctx->base.fs.pts,
+ sctx->base.fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, frame);
}
diff --git a/libavfilter/vf_stack_vaapi.c b/libavfilter/vf_stack_vaapi.c
index 9ab4d8ab5b..5453a978b0 100644
--- a/libavfilter/vf_stack_vaapi.c
+++ b/libavfilter/vf_stack_vaapi.c
@@ -112,7 +112,7 @@ static int process_frame(FFFrameSync *fs)
sctx->base.fillcolor[2]);
}
- oframe->pts = av_rescale_q(sctx->base.fs.pts, sctx->base.fs.time_base, outlink->time_base);
+ oframe->pts = av_rescale_ts(sctx->base.fs.pts, sctx->base.fs.time_base, outlink->time_base);
oframe->sample_aspect_ratio = outlink->sample_aspect_ratio;
ret = ff_vaapi_vpp_render_pictures(avctx, params, avctx->nb_inputs, oframe);
diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index dde45357ce..d1e43b701d 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -525,7 +525,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
av_log(ctx, AV_LOG_WARNING, "Error decoding: %s (ignored)\n",
av_err2str(ret));
} else if (got_subtitle) {
- const int64_t start_time = av_rescale_q(sub.pts, AV_TIME_BASE_Q, av_make_q(1, 1000));
+ const int64_t start_time = av_rescale_ts(sub.pts, AV_TIME_BASE_Q, av_make_q(1, 1000));
const int64_t duration = sub.end_display_time;
for (i = 0; i < sub.num_rects; i++) {
char *ass_line = sub.rects[i]->ass;
diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c
index 633deb9474..ae012c1c78 100644
--- a/libavfilter/vf_threshold.c
+++ b/libavfilter/vf_threshold.c
@@ -146,7 +146,7 @@ static int process_frame(FFFrameSync *fs)
FFMIN(s->height[2], ff_filter_get_nb_threads(ctx)));
}
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out);
}
diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
index 7d5217c364..9ddfff06a5 100644
--- a/libavfilter/vf_tinterlace.c
+++ b/libavfilter/vf_tinterlace.c
@@ -506,7 +506,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
if (cur->pts != AV_NOPTS_VALUE)
out->pts = cur->pts*2;
- out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base);
+ out->pts = av_rescale_ts(out->pts, tinterlace->preout_time_base, outlink->time_base);
ff_ccfifo_inject(&tinterlace->cc_fifo, out);
if ((ret = ff_filter_frame(outlink, out)) < 0)
return ret;
@@ -544,7 +544,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
av_assert0(0);
}
- out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base);
+ out->pts = av_rescale_ts(out->pts, tinterlace->preout_time_base, outlink->time_base);
out->duration = av_rescale_q(1, av_inv_q(l->frame_rate), outlink->time_base);
ff_ccfifo_inject(&tinterlace->cc_fifo, out);
ret = ff_filter_frame(outlink, out);
diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 7580fbaa5b..4abf22391b 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -103,7 +103,7 @@ static int activate(AVFilterContext *ctx)
if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
if (status == AVERROR_EOF) {
- pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
if (!s->pad_stop && !s->pad_start) {
ff_outlink_set_status(outlink, status, pts);
return 0;
diff --git a/libavfilter/vf_untile.c b/libavfilter/vf_untile.c
index 6c1bfbabdc..7bc55f1626 100644
--- a/libavfilter/vf_untile.c
+++ b/libavfilter/vf_untile.c
@@ -120,7 +120,7 @@ static int activate(AVFilterContext *ctx)
if (ret < 0)
return ret;
if (ret)
- s->pts = av_rescale_q(s->frame->pts, inlink->time_base, outlink->time_base);
+ s->pts = av_rescale_ts(s->frame->pts, inlink->time_base, outlink->time_base);
}
if (s->frame) {
if (s->current == s->nb_frames - 1) {
diff --git a/libavfilter/vf_vif.c b/libavfilter/vf_vif.c
index 6ec8a8d066..3bc3bef63f 100644
--- a/libavfilter/vf_vif.c
+++ b/libavfilter/vf_vif.c
@@ -539,7 +539,7 @@ static int process_frame(FFFrameSync *fs)
out_frame = do_vif(ctx, main_frame, ref_frame);
}
- out_frame->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out_frame->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
return ff_filter_frame(outlink, out_frame);
}
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 0a33c377c8..1d1c5ca886 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -771,7 +771,7 @@ static int activate(AVFilterContext *ctx)
if (in) {
FilterLink *ol = ff_filter_link(outlink);
if (in->pts != AV_NOPTS_VALUE)
- in->pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
+ in->pts = av_rescale_ts(in->pts, inlink->time_base, outlink->time_base);
if (ol->frame_rate.num && ol->frame_rate.den)
in->duration = av_rescale_q(1, av_inv_q(ol->frame_rate), outlink->time_base);
@@ -798,7 +798,7 @@ not_ready:
return FFERROR_NOT_READY;
eof:
- pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+ pts = av_rescale_ts(pts, inlink->time_base, outlink->time_base);
ff_outlink_set_status(outlink, status, pts);
return 0;
}
diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index f411d063f1..fb33a681a0 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -223,7 +223,7 @@ static int process_frame(FFFrameSync *fs)
}
if (!out)
return AVERROR(ENOMEM);
- out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
+ out->pts = av_rescale_ts(s->fs.pts, s->fs.time_base, outlink->time_base);
if (!ctx->is_disabled) {
td.in = in;
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-26 11:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-26 11:58 [FFmpeg-devel] [PATCH] Add (and use) av_rescale_ts() and av_rescale_ts_rnd() (PR #20613) Niklas Haas via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ http://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git