History

lavfi: move AVFilterLink.{frame,sample}_count_{in,out} to FilterLink

Anton Khirnov committed 2 years ago

Commit 42cbf661 parent a23d56556 files · +209 −116Browse files

Unified · Split

56 files
  1. libavfilter/af_adrc.c +2 −1
  2. libavfilter/af_afftdn.c +2 −1
  3. libavfilter/af_ashowinfo.c +3 −1
  4. libavfilter/af_dynaudnorm.c +2 −1
  5. libavfilter/af_volume.c +3 −1
  6. libavfilter/asrc_sine.c +2 −1
  7. libavfilter/avf_showfreqs.c +3 −2
  8. libavfilter/avfilter.c +9 −7
  9. libavfilter/avfilter.h +0 −10
  10. libavfilter/avfiltergraph.c +2 −2
  11. libavfilter/f_graphmonitor.c +12 −12
  12. libavfilter/f_latency.c +4 −2
  13. libavfilter/f_loop.c +4 −2
  14. libavfilter/f_metadata.c +4 −2
  15. libavfilter/f_segment.c +6 −4
  16. libavfilter/f_select.c +3 −1
  17. libavfilter/f_sendcmd.c +3 −1
  18. libavfilter/f_streamselect.c +2 −1
  19. libavfilter/filters.h +10 −0
  20. libavfilter/qrencode.c +2 −1
  21. libavfilter/vf_bbox.c +3 −1
  22. libavfilter/vf_blackdetect.c +3 −1
  23. libavfilter/vf_blend.c +2 −1
  24. libavfilter/vf_blockdetect.c +4 −1
  25. libavfilter/vf_blurdetect.c +4 −1
  26. libavfilter/vf_crop.c +3 −1
  27. libavfilter/vf_datascope.c +3 −1
  28. libavfilter/vf_delogo.c +3 −1
  29. libavfilter/vf_detelecine.c +2 −1
  30. libavfilter/vf_drawtext.c +6 −3
  31. libavfilter/vf_eq.c +2 −1
  32. libavfilter/vf_fade.c +6 −4
  33. libavfilter/vf_fftfilt.c +3 −1
  34. libavfilter/vf_fieldhint.c +10 −7
  35. libavfilter/vf_fieldmatch.c +4 −3
  36. libavfilter/vf_find_rect.c +4 −1
  37. libavfilter/vf_framestep.c +2 −1
  38. libavfilter/vf_freezeframes.c +5 −3
  39. libavfilter/vf_geq.c +4 −1
  40. libavfilter/vf_hue.c +2 −1
  41. libavfilter/vf_libplacebo.c +4 −2
  42. libavfilter/vf_overlay.c +3 −1
  43. libavfilter/vf_overlay_cuda.c +2 −1
  44. libavfilter/vf_perspective.c +5 −2
  45. libavfilter/vf_quirc.c +2 −1
  46. libavfilter/vf_rotate.c +3 −1
  47. libavfilter/vf_scale.c +8 −4
  48. libavfilter/vf_scale_npp.c +5 −3
  49. libavfilter/vf_showinfo.c +2 −1
  50. libavfilter/vf_swaprect.c +3 −1
  51. libavfilter/vf_telecine.c +2 −1
  52. libavfilter/vf_tinterlace.c +4 −3
  53. libavfilter/vf_vignette.c +2 −1
  54. libavfilter/vf_weave.c +2 −1
  55. libavfilter/vf_zoompan.c +6 −3
  56. libavfilter/vsrc_mptestsrc.c +3 −2
libavfilter/af_adrc.c+2−1
@@ -363,6 +363,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 362 unmodified lines
363363 {
364364 AVFilterContext *ctx = inlink->dst;
365365 AVFilterLink *outlink = ctx->outputs[0];
366+ FilterLink *outl = ff_filter_link(outlink);
366367 AudioDRCContext *s = ctx->priv;
367368 AVFrame *out;
368369 int ret;
@@ -373,7 +374,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 4 unmodified lines
373374 goto fail;
374375 }
375376
376− s->var_values[VAR_SN] = outlink->sample_count_in;
377+ s->var_values[VAR_SN] = outl->sample_count_in;
377378 s->var_values[VAR_T] = s->var_values[VAR_SN] * (double)1/outlink->sample_rate;
378379
379380 s->in = in;
libavfilter/af_afftdn.c+2−1
@@ -355,8 +355,9 @@ static void process_frame(AVFilterContext *ctx, · 354 unmodified lines
355355 double *prior, double *prior_band_excit, int track_noise)
356356 {
357357 AVFilterLink *outlink = ctx->outputs[0];
358+ FilterLink *outl = ff_filter_link(outlink);
358359 const double *abs_var = dnch->abs_var;
359− const double ratio = outlink->frame_count_out ? s->ratio : 1.0;
360+ const double ratio = outl->frame_count_out ? s->ratio : 1.0;
360361 const double rratio = 1. - ratio;
361362 const int *bin2band = s->bin2band;
362363 double *noisy_data = dnch->noisy_data;
libavfilter/af_ashowinfo.c+3−1
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838
3939 #include "audio.h"
4040 #include "avfilter.h"
41+#include "filters.h"
4142 #include "internal.h"
4243
4344 typedef struct AShowInfoContext {
@@ -173,6 +174,7 @@ static void dump_unknown(AVFilterContext *ctx, AVFrameSideData *sd) · 129 unmodified lines
173174
174175 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
175176 {
177+ FilterLink *inl = ff_filter_link(inlink);
176178 AVFilterContext *ctx = inlink->dst;
177179 AShowInfoContext *s = ctx->priv;
178180 char chlayout_str[128];
@@ -203,7 +205,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) · 24 unmodified lines
203205 "n:%"PRId64" pts:%s pts_time:%s "
204206 "fmt:%s channels:%d chlayout:%s rate:%d nb_samples:%d "
205207 "checksum:%08"PRIX32" ",
206− inlink->frame_count_out,
208+ inl->frame_count_out,
207209 av_ts2str(buf->pts), av_ts2timestr(buf->pts, &inlink->time_base),
208210 av_get_sample_fmt_name(buf->format), buf->ch_layout.nb_channels, chlayout_str,
209211 buf->sample_rate, buf->nb_samples,
libavfilter/af_dynaudnorm.c+2−1
@@ -725,6 +725,7 @@ static void perform_compression(DynamicAudioNormalizerContext *s, AVFrame *frame · 724 unmodified lines
725725
726726 static int analyze_frame(AVFilterContext *ctx, AVFilterLink *outlink, AVFrame **frame)
727727 {
728+ FilterLink *outl = ff_filter_link(outlink);
728729 DynamicAudioNormalizerContext *s = ctx->priv;
729730 AVFrame *analyze_frame;
730731
@@ -780,7 +781,7 @@ static int analyze_frame(AVFilterContext *ctx, AVFilterLink *outlink, AVFrame ** · 49 unmodified lines
780781 analyze_frame = *frame;
781782 }
782783
783− s->var_values[VAR_SN] = outlink->sample_count_in;
784+ s->var_values[VAR_SN] = outl->sample_count_in;
784785 s->var_values[VAR_T] = s->var_values[VAR_SN] * (double)1/outlink->sample_rate;
785786
786787 if (s->channels_coupled) {
libavfilter/af_volume.c+3−1
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535
3636 #include "audio.h"
3737 #include "avfilter.h"
38+#include "filters.h"
3839 #include "formats.h"
3940 #include "internal.h"
4041 #include "af_volume.h"
@@ -328,6 +329,7 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar · 287 unmodified lines
328329
329330 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
330331 {
332+ FilterLink *inl = ff_filter_link(inlink);
331333 AVFilterContext *ctx = inlink->dst;
332334 VolumeContext *vol = inlink->dst->priv;
333335 AVFilterLink *outlink = inlink->dst->outputs[0];
@@ -380,7 +382,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf) · 46 unmodified lines
380382 }
381383 vol->var_values[VAR_PTS] = TS2D(buf->pts);
382384 vol->var_values[VAR_T ] = TS2T(buf->pts, inlink->time_base);
383− vol->var_values[VAR_N ] = inlink->frame_count_out;
385+ vol->var_values[VAR_N ] = inl->frame_count_out;
384386
385387 #if FF_API_FRAME_PKT
386388 FF_DISABLE_DEPRECATION_WARNINGS
libavfilter/asrc_sine.c+2−1
@@ -207,10 +207,11 @@ static av_cold int config_props(AVFilterLink *outlink) · 206 unmodified lines
207207 static int activate(AVFilterContext *ctx)
208208 {
209209 AVFilterLink *outlink = ctx->outputs[0];
210+ FilterLink *outl = ff_filter_link(outlink);
210211 SineContext *sine = ctx->priv;
211212 AVFrame *frame;
212213 double values[VAR_VARS_NB] = {
213− [VAR_N] = outlink->frame_count_in,
214+ [VAR_N] = outl->frame_count_in,
214215 [VAR_PTS] = sine->pts,
215216 [VAR_T] = sine->pts * av_q2d(outlink->time_base),
216217 [VAR_TB] = av_q2d(outlink->time_base),
libavfilter/avf_showfreqs.c+3−2
@@ -298,6 +298,7 @@ static inline void plot_freq(ShowFreqsContext *s, int ch, · 297 unmodified lines
298298 double a, int f, uint8_t fg[4], int *prev_y,
299299 AVFrame *out, AVFilterLink *outlink)
300300 {
301+ FilterLink *outl = ff_filter_link(outlink);
301302 const int w = s->w;
302303 const float min = s->minamp;
303304 const float avg = s->avg_data[ch][f];
@@ -337,12 +338,12 @@ static inline void plot_freq(ShowFreqsContext *s, int ch, · 33 unmodified lines
337338
338339 switch (s->avg) {
339340 case 0:
340− y = s->avg_data[ch][f] = !outlink->frame_count_in ? y : FFMIN(0, y);
341+ y = s->avg_data[ch][f] = !outl->frame_count_in ? y : FFMIN(0, y);
341342 break;
342343 case 1:
343344 break;
344345 default:
345− s->avg_data[ch][f] = avg + y * (y - avg) / (FFMIN(outlink->frame_count_in + 1, s->avg) * (float)y);
346+ s->avg_data[ch][f] = avg + y * (y - avg) / (FFMIN(outl->frame_count_in + 1, s->avg) * (float)y);
346347 y = av_clip(s->avg_data[ch][f], 0, outlink->h - 1);
347348 break;
348349 }
libavfilter/avfilter.c+9−7
@@ -991,6 +991,7 @@ static int default_filter_frame(AVFilterLink *link, AVFrame *frame) · 990 unmodified lines
991991
992992 static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
993993 {
994+ FilterLink *l = ff_filter_link(link);
994995 int (*filter_frame)(AVFilterLink *, AVFrame *);
995996 AVFilterContext *dstctx = link->dst;
996997 AVFilterPad *dst = link->dstpad;
@@ -1012,7 +1013,7 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame) · 15 unmodified lines
10121013 (dstctx->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC))
10131014 filter_frame = default_filter_frame;
10141015 ret = filter_frame(link, frame);
1015− link->frame_count_out++;
1016+ l->frame_count_out++;
10161017 return ret;
10171018
10181019 fail:
@@ -1058,8 +1059,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) · 39 unmodified lines
10581059 }
10591060
10601061 li->frame_blocked_in = link->frame_wanted_out = 0;
1061− link->frame_count_in++;
1062− link->sample_count_in += frame->nb_samples;
1062+ li->l.frame_count_in++;
1063+ li->l.sample_count_in += frame->nb_samples;
10631064 filter_unblock(link->dst);
10641065 ret = ff_framequeue_add(&li->fifo, frame);
10651066 if (ret < 0) {
@@ -1163,7 +1164,7 @@ static int ff_filter_frame_to_filter(AVFilterLink *link) · 97 unmodified lines
11631164 filter_unblock(dst);
11641165 /* AVFilterPad.filter_frame() expect frame_count_out to have the value
11651166 before the frame; ff_filter_frame_framed() will re-increment it. */
1166− link->frame_count_out--;
1167+ li->l.frame_count_out--;
11671168 ret = ff_filter_frame_framed(link, frame);
11681169 if (ret < 0 && ret != li->status_out) {
11691170 link_set_out_status(link, ret, AV_NOPTS_VALUE);
@@ -1444,8 +1445,8 @@ static void consume_update(FilterLinkInternal *li, const AVFrame *frame) · 274 unmodified lines
14441445 ff_inlink_process_commands(link, frame);
14451446 if (link == link->dst->inputs[0])
14461447 link->dst->is_disabled = !ff_inlink_evaluate_timeline_at_frame(link, frame);
1447− link->frame_count_out++;
1448− link->sample_count_out += frame->nb_samples;
1448+ li->l.frame_count_out++;
1449+ li->l.sample_count_out += frame->nb_samples;
14491450 }
14501451
14511452 int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
@@ -1552,6 +1553,7 @@ int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame) · 100 unmodified lines
15521553
15531554 int ff_inlink_evaluate_timeline_at_frame(AVFilterLink *link, const AVFrame *frame)
15541555 {
1556+ FilterLink *l = ff_filter_link(link);
15551557 AVFilterContext *dstctx = link->dst;
15561558 int64_t pts = frame->pts;
15571559 #if FF_API_FRAME_PKT
@@ -1563,7 +1565,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 5 unmodified lines
15631565 if (!dstctx->enable_str)
15641566 return 1;
15651567
1566− dstctx->var_values[VAR_N] = link->frame_count_out;
1568+ dstctx->var_values[VAR_N] = l->frame_count_out;
15671569 dstctx->var_values[VAR_T] = pts == AV_NOPTS_VALUE ? NAN : pts * av_q2d(link->time_base);
15681570 dstctx->var_values[VAR_W] = link->w;
15691571 dstctx->var_values[VAR_H] = link->h;
libavfilter/avfilter.h+0−10
@@ -600,16 +600,6 @@ struct AVFilterLink { · 599 unmodified lines
600600 */
601601 struct AVFilterGraph *graph;
602602
603− /**
604− * Number of past frames sent through the link.
605− */
606− int64_t frame_count_in, frame_count_out;
607−
608− /**
609− * Number of past samples sent through the link.
610− */
611− int64_t sample_count_in, sample_count_out;
612−
613603 /**
614604 * True if a frame is currently wanted on the output of this filter.
615605 * Set when ff_request_frame() is called by the output,
libavfilter/avfiltergraph.c+2−2
@@ -1402,8 +1402,8 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph) · 1401 unmodified lines
14021402 return AVERROR_EOF;
14031403 av_assert1(!oldest->dst->filter->activate);
14041404 av_assert1(oldesti->age_index >= 0);
1405− frame_count = oldest->frame_count_out;
1406− while (frame_count == oldest->frame_count_out) {
1405+ frame_count = oldesti->l.frame_count_out;
1406+ while (frame_count == oldesti->l.frame_count_out) {
14071407 r = ff_filter_graph_run_once(graph);
14081408 if (r == AVERROR(EAGAIN) &&
14091409 !oldest->frame_wanted_out && !oldesti->frame_blocked_in &&
libavfilter/f_graphmonitor.c+12−12
@@ -308,33 +308,33 @@ static int draw_items(AVFilterContext *ctx, · 307 unmodified lines
308308 drawtext(out, xpos, ypos, buffer, len, frames > 0 ? frames >= 10 ? frames >= 50 ? s->red : s->yellow : s->green : s->white);
309309 xpos += len * 8;
310310 }
311− if ((flags & FLAG_FCIN) && (!(mode & MODE_NOZERO) || l->frame_count_in)) {
312− len = snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, l->frame_count_in);
311+ if ((flags & FLAG_FCIN) && (!(mode & MODE_NOZERO) || fl->frame_count_in)) {
312+ len = snprintf(buffer, sizeof(buffer)-1, " | in: %"PRId64, fl->frame_count_in);
313313 drawtext(out, xpos, ypos, buffer, len, s->white);
314314 xpos += len * 8;
315315 }
316− if ((flags & FLAG_FCOUT) && (!(mode & MODE_NOZERO) || l->frame_count_out)) {
317− len = snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, l->frame_count_out);
316+ if ((flags & FLAG_FCOUT) && (!(mode & MODE_NOZERO) || fl->frame_count_out)) {
317+ len = snprintf(buffer, sizeof(buffer)-1, " | out: %"PRId64, fl->frame_count_out);
318318 drawtext(out, xpos, ypos, buffer, len, s->white);
319319 xpos += len * 8;
320320 }
321− if ((flags & FLAG_FC_DELTA) && (!(mode & MODE_NOZERO) || (l->frame_count_in - l->frame_count_out))) {
322− len = snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, l->frame_count_in - l->frame_count_out);
321+ if ((flags & FLAG_FC_DELTA) && (!(mode & MODE_NOZERO) || (fl->frame_count_in - fl->frame_count_out))) {
322+ len = snprintf(buffer, sizeof(buffer)-1, " | delta: %"PRId64, fl->frame_count_in - fl->frame_count_out);
323323 drawtext(out, xpos, ypos, buffer, len, s->white);
324324 xpos += len * 8;
325325 }
326− if ((flags & FLAG_SCIN) && (!(mode & MODE_NOZERO) || l->sample_count_in)) {
327− len = snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, l->sample_count_in);
326+ if ((flags & FLAG_SCIN) && (!(mode & MODE_NOZERO) || fl->sample_count_in)) {
327+ len = snprintf(buffer, sizeof(buffer)-1, " | sin: %"PRId64, fl->sample_count_in);
328328 drawtext(out, xpos, ypos, buffer, len, s->white);
329329 xpos += len * 8;
330330 }
331− if ((flags & FLAG_SCOUT) && (!(mode & MODE_NOZERO) || l->sample_count_out)) {
332− len = snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, l->sample_count_out);
331+ if ((flags & FLAG_SCOUT) && (!(mode & MODE_NOZERO) || fl->sample_count_out)) {
332+ len = snprintf(buffer, sizeof(buffer)-1, " | sout: %"PRId64, fl->sample_count_out);
333333 drawtext(out, xpos, ypos, buffer, len, s->white);
334334 xpos += len * 8;
335335 }
336− if ((flags & FLAG_SC_DELTA) && (!(mode & MODE_NOZERO) || (l->sample_count_in - l->sample_count_out))) {
337− len = snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, l->sample_count_in - l->sample_count_out);
336+ if ((flags & FLAG_SC_DELTA) && (!(mode & MODE_NOZERO) || (fl->sample_count_in - fl->sample_count_out))) {
337+ len = snprintf(buffer, sizeof(buffer)-1, " | sdelta: %"PRId64, fl->sample_count_in - fl->sample_count_out);
338338 drawtext(out, xpos, ypos, buffer, len, s->white);
339339 xpos += len * 8;
340340 }
libavfilter/f_latency.c+4−2
@@ -46,6 +46,7 @@ static int activate(AVFilterContext *ctx) · 45 unmodified lines
4646 {
4747 LatencyContext *s = ctx->priv;
4848 AVFilterLink *inlink = ctx->inputs[0];
49+ FilterLink *inl = ff_filter_link(inlink);
4950 AVFilterLink *outlink = ctx->outputs[0];
5051
5152 FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
@@ -53,14 +54,15 @@ static int activate(AVFilterContext *ctx) · 1 unmodified line
5354 if (!ctx->is_disabled && ctx->inputs[0]->src &&
5455 ctx->inputs[0]->src->nb_inputs > 0) {
5556 AVFilterLink *prevlink = ctx->inputs[0]->src->inputs[0];
57+ FilterLink *prevl = ff_filter_link(prevlink);
5658 int64_t delta = 0;
5759
5860 switch (prevlink->type) {
5961 case AVMEDIA_TYPE_AUDIO:
60− delta = prevlink->sample_count_in - inlink->sample_count_out;
62+ delta = prevl->sample_count_in - inl->sample_count_out;
6163 break;
6264 case AVMEDIA_TYPE_VIDEO:
63− delta = prevlink->frame_count_in - inlink->frame_count_out;
65+ delta = prevl->frame_count_in - inl->frame_count_out;
6466 break;
6567 }
6668
libavfilter/f_loop.c+4−2
@@ -144,6 +144,7 @@ static int push_samples(AVFilterContext *ctx, int nb_samples) · 143 unmodified lines
144144
145145 static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
146146 {
147+ FilterLink *inl = ff_filter_link(inlink);
147148 AVFilterContext *ctx = inlink->dst;
148149 AVFilterLink *outlink = ctx->outputs[0];
149150 LoopContext *s = ctx->priv;
@@ -158,7 +159,7 @@ static int afilter_frame(AVFilterLink *inlink, AVFrame *frame) · 8 unmodified lines
158159 int drain = 0;
159160
160161 if (s->start < 0)
161− s->start = inlink->sample_count_out - written;
162+ s->start = inl->sample_count_out - written;
162163
163164 ret = av_audio_fifo_write(s->fifo, (void **)frame->extended_data, written);
164165 if (ret < 0)
@@ -374,6 +375,7 @@ static int push_frame(AVFilterContext *ctx) · 209 unmodified lines
374375
375376 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
376377 {
378+ FilterLink *inl = ff_filter_link(inlink);
377379 AVFilterContext *ctx = inlink->dst;
378380 AVFilterLink *outlink = ctx->outputs[0];
379381 FilterLink *outl = ff_filter_link(outlink);
@@ -381,7 +383,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 1 unmodified line
381383 int64_t duration;
382384 int ret = 0;
383385
384− if (((s->start >= 0 && inlink->frame_count_out >= s->start) ||
386+ if (((s->start >= 0 && inl->frame_count_out >= s->start) ||
385387 (s->time_pts != AV_NOPTS_VALUE &&
386388 frame->pts >= s->time_pts)) &&
387389 s->size > 0 && s->loop != 0) {
libavfilter/f_metadata.c+4−2
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include "libavformat/avio.h"
3737 #include "avfilter.h"
3838 #include "audio.h"
39+#include "filters.h"
3940 #include "internal.h"
4041 #include "video.h"
4142
@@ -303,6 +304,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 261 unmodified lines
303304
304305 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
305306 {
307+ FilterLink *inl = ff_filter_link(inlink);
306308 AVFilterContext *ctx = inlink->dst;
307309 AVFilterLink *outlink = ctx->outputs[0];
308310 MetadataContext *s = ctx->priv;
@@ -336,14 +338,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 27 unmodified lines
336338 case METADATA_PRINT:
337339 if (!s->key && e) {
338340 s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
339− inlink->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
341+ inl->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
340342 s->print(ctx, "%s=%s\n", e->key, e->value);
341343 while ((e = av_dict_iterate(*metadata, e)) != NULL) {
342344 s->print(ctx, "%s=%s\n", e->key, e->value);
343345 }
344346 } else if (e && e->value && (!s->value || (e->value && s->compare(s, e->value, s->value)))) {
345347 s->print(ctx, "frame:%-4"PRId64" pts:%-7s pts_time:%s\n",
346− inlink->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
348+ inl->frame_count_out, av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
347349 s->print(ctx, "%s=%s\n", s->key, e->value);
348350 }
349351 return ff_filter_frame(outlink, frame);
libavfilter/f_segment.c+6−4
@@ -162,6 +162,7 @@ static int current_segment_finished(AVFilterContext *ctx, AVFrame *frame) · 161 unmodified lines
162162 {
163163 SegmentContext *s = ctx->priv;
164164 AVFilterLink *inlink = ctx->inputs[0];
165+ FilterLink *inl = ff_filter_link(inlink);
165166 int ret = 0;
166167
167168 if (s->use_timestamps) {
@@ -169,10 +170,10 @@ static int current_segment_finished(AVFilterContext *ctx, AVFrame *frame) · 1 unmodified line
169170 } else {
170171 switch (inlink->type) {
171172 case AVMEDIA_TYPE_VIDEO:
172− ret = inlink->frame_count_out - 1 >= s->points[s->current_point];
173+ ret = inl->frame_count_out - 1 >= s->points[s->current_point];
173174 break;
174175 case AVMEDIA_TYPE_AUDIO:
175− ret = inlink->sample_count_out - frame->nb_samples >= s->points[s->current_point];
176+ ret = inl->sample_count_out - frame->nb_samples >= s->points[s->current_point];
176177 break;
177178 }
178179 }
@@ -183,6 +184,7 @@ static int current_segment_finished(AVFilterContext *ctx, AVFrame *frame) · 4 unmodified lines
183184 static int activate(AVFilterContext *ctx)
184185 {
185186 AVFilterLink *inlink = ctx->inputs[0];
187+ FilterLink *inl = ff_filter_link(inlink);
186188 SegmentContext *s = ctx->priv;
187189 AVFrame *frame = NULL;
188190 int ret, status;
@@ -199,14 +201,14 @@ static int activate(AVFilterContext *ctx) · 10 unmodified lines
199201 ret = ff_inlink_consume_frame(inlink, &frame);
200202 break;
201203 case AVMEDIA_TYPE_AUDIO:
202− diff = s->points[s->current_point] - inlink->sample_count_out;
204+ diff = s->points[s->current_point] - inl->sample_count_out;
203205 while (diff <= 0) {
204206 ff_outlink_set_status(ctx->outputs[s->current_point], AVERROR_EOF, s->last_pts);
205207 s->current_point++;
206208 if (s->current_point >= s->nb_points)
207209 return AVERROR(EINVAL);
208210
209− diff = s->points[s->current_point] - inlink->sample_count_out;
211+ diff = s->points[s->current_point] - inl->sample_count_out;
210212 }
211213 if (s->use_timestamps) {
212214 max_samples = av_rescale_q(diff, av_make_q(1, inlink->sample_rate), inlink->time_base);
libavfilter/f_select.c+3−1
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "libavutil/pixdesc.h"
3535 #include "avfilter.h"
3636 #include "audio.h"
37+#include "filters.h"
3738 #include "formats.h"
3839 #include "internal.h"
3940 #include "video.h"
@@ -342,6 +343,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) · 302 unmodified lines
342343 {
343344 SelectContext *select = ctx->priv;
344345 AVFilterLink *inlink = ctx->inputs[0];
346+ FilterLink *inl = ff_filter_link(inlink);
345347 double res;
346348
347349 if (isnan(select->var_values[VAR_START_PTS]))
@@ -349,7 +351,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) · 1 unmodified line
349351 if (isnan(select->var_values[VAR_START_T]))
350352 select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base);
351353
352− select->var_values[VAR_N ] = inlink->frame_count_out;
354+ select->var_values[VAR_N ] = inl->frame_count_out;
353355 select->var_values[VAR_PTS] = TS2D(frame->pts);
354356 select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base);
355357 #if FF_API_FRAME_PKT
libavfilter/f_sendcmd.c+3−1
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include "libavutil/opt.h"
3434 #include "libavutil/parseutils.h"
3535 #include "avfilter.h"
36+#include "filters.h"
3637 #include "internal.h"
3738 #include "audio.h"
3839 #include "video.h"
@@ -488,6 +489,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 449 unmodified lines
488489
489490 static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
490491 {
492+ FilterLink *inl = ff_filter_link(inlink);
491493 AVFilterContext *ctx = inlink->dst;
492494 SendCmdContext *s = ctx->priv;
493495 int64_t ts;
@@ -535,7 +537,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref) · 41 unmodified lines
535537 double end = TS2T(interval->end_ts, AV_TIME_BASE_Q);
536538 double current = TS2T(ref->pts, inlink->time_base);
537539
538− var_values[VAR_N] = inlink->frame_count_in;
540+ var_values[VAR_N] = inl->frame_count_in;
539541 #if FF_API_FRAME_PKT
540542 FF_DISABLE_DEPRECATION_WARNINGS
541543 var_values[VAR_POS] = ref->pkt_pos == -1 ? NAN : ref->pkt_pos;
libavfilter/f_streamselect.c+2−1
@@ -65,11 +65,12 @@ static int process_frame(FFFrameSync *fs) · 64 unmodified lines
6565
6666 for (j = 0; j < ctx->nb_inputs; j++) {
6767 for (i = 0; i < s->nb_map; i++) {
68+ FilterLink *outl = ff_filter_link(ctx->outputs[i]);
6869 if (s->map[i] == j) {
6970 AVFrame *out;
7071
7172 if (s->is_audio && s->last_pts[j] == in[j]->pts &&
72− ctx->outputs[i]->frame_count_in > 0)
73+ outl->frame_count_in > 0)
7374 continue;
7475 out = av_frame_clone(in[j]);
7576 if (!out)
libavfilter/filters.h+10−0
@@ -70,6 +70,16 @@ typedef struct FilterLink { · 69 unmodified lines
7070 */
7171 int max_samples;
7272
73+ /**
74+ * Number of past frames sent through the link.
75+ */
76+ int64_t frame_count_in, frame_count_out;
77+
78+ /**
79+ * Number of past samples sent through the link.
80+ */
81+ int64_t sample_count_in, sample_count_out;
82+
7383 /**
7484 * Frame rate of the stream on the link, or 1/0 if unknown or variable.
7585 *
libavfilter/qrencode.c+2−1
@@ -780,12 +780,13 @@ static int qrencode_query_formats(AVFilterContext *ctx) · 779 unmodified lines
780780
781781 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
782782 {
783+ FilterLink *inl = ff_filter_link(inlink);
783784 AVFilterContext *ctx = inlink->dst;
784785 AVFilterLink *outlink = ctx->outputs[0];
785786 QREncodeContext *qr = ctx->priv;
786787 int ret;
787788
788− V(n) = inlink->frame_count_out;
789+ V(n) = inl->frame_count_out;
789790 V(t) = frame->pts == AV_NOPTS_VALUE ?
790791 NAN : frame->pts * av_q2d(inlink->time_base);
791792 V(pict_type) = frame->pict_type;
libavfilter/vf_bbox.c+3−1
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/timestamp.h"
2929 #include "avfilter.h"
3030 #include "bbox.h"
31+#include "filters.h"
3132 #include "internal.h"
3233
3334 typedef struct BBoxContext {
@@ -75,6 +76,7 @@ static const enum AVPixelFormat pix_fmts[] = { · 41 unmodified lines
7576
7677 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
7778 {
79+ FilterLink *inl = ff_filter_link(inlink);
7880 AVFilterContext *ctx = inlink->dst;
7981 BBoxContext *bbox = ctx->priv;
8082 FFBoundingBox box;
@@ -88,7 +90,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 7 unmodified lines
8890 h = box.y2 - box.y1 + 1;
8991
9092 av_log(ctx, AV_LOG_INFO,
91− "n:%"PRId64" pts:%s pts_time:%s", inlink->frame_count_out,
93+ "n:%"PRId64" pts:%s pts_time:%s", inl->frame_count_out,
9294 av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base));
9395
9496 if (has_bbox) {
libavfilter/vf_blackdetect.c+3−1
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/pixdesc.h"
3131 #include "libavutil/timestamp.h"
3232 #include "avfilter.h"
33+#include "filters.h"
3334 #include "internal.h"
3435 #include "video.h"
3536
@@ -173,6 +174,7 @@ static int black_counter(AVFilterContext *ctx, void *arg, · 137 unmodified lines
173174
174175 static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
175176 {
177+ FilterLink *inl = ff_filter_link(inlink);
176178 AVFilterContext *ctx = inlink->dst;
177179 BlackDetectContext *s = ctx->priv;
178180 double picture_black_ratio = 0;
@@ -195,7 +197,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 16 unmodified lines
195197
196198 av_log(ctx, AV_LOG_DEBUG,
197199 "frame:%"PRId64" picture_black_ratio:%f pts:%s t:%s type:%c\n",
198− inlink->frame_count_out, picture_black_ratio,
200+ inl->frame_count_out, picture_black_ratio,
199201 av_ts2str(picref->pts), av_ts2timestr(picref->pts, &s->time_base),
200202 av_get_picture_type_char(picref->pict_type));
201203
libavfilter/vf_blend.c+2−1
@@ -174,10 +174,11 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) · 173 unmodified lines
174174 const uint8_t *top = td->top->data[td->plane];
175175 const uint8_t *bottom = td->bottom->data[td->plane];
176176 uint8_t *dst = td->dst->data[td->plane];
177+ FilterLink *inl = ff_filter_link(td->inlink);
177178 double values[VAR_VARS_NB];
178179 SliceParams sliceparam = {.values = &values[0], .starty = slice_start, .e = td->param->e ? td->param->e[jobnr] : NULL};
179180
180− values[VAR_N] = td->inlink->frame_count_out;
181+ values[VAR_N] = inl->frame_count_out;
181182 values[VAR_T] = td->dst->pts == AV_NOPTS_VALUE ? NAN : td->dst->pts * av_q2d(td->inlink->time_base);
182183 values[VAR_W] = td->w;
183184 values[VAR_H] = td->h;
libavfilter/vf_blockdetect.c+4−1
@@ -32,6 +32,8 @@ · 31 unmodified lines
3232 #include "libavutil/mem.h"
3333 #include "libavutil/opt.h"
3434 #include "libavutil/pixdesc.h"
35+
36+#include "filters.h"
3537 #include "internal.h"
3638 #include "video.h"
3739
@@ -198,6 +200,7 @@ static void set_meta(AVDictionary **metadata, const char *key, float d) · 160 unmodified lines
198200
199201 static int blockdetect_filter_frame(AVFilterLink *inlink, AVFrame *in)
200202 {
203+ FilterLink *inl = ff_filter_link(inlink);
201204 AVFilterContext *ctx = inlink->dst;
202205 BLKContext *s = ctx->priv;
203206 AVFilterLink *outlink = ctx->outputs[0];
@@ -236,7 +239,7 @@ static int blockdetect_filter_frame(AVFilterLink *inlink, AVFrame *in) · 32 unmodified lines
236239
237240 set_meta(metadata, "lavfi.block", block);
238241
239− s->nb_frames = inlink->frame_count_in;
242+ s->nb_frames = inl->frame_count_in;
240243
241244 return ff_filter_frame(outlink, in);
242245 }
libavfilter/vf_blurdetect.c+4−1
@@ -34,6 +34,8 @@ · 33 unmodified lines
3434 #include "libavutil/opt.h"
3535 #include "libavutil/pixdesc.h"
3636 #include "libavutil/qsort.h"
37+
38+#include "filters.h"
3739 #include "internal.h"
3840 #include "edge_common.h"
3941 #include "video.h"
@@ -256,6 +258,7 @@ static void set_meta(AVDictionary **metadata, const char *key, float d) · 216 unmodified lines
256258
257259 static int blurdetect_filter_frame(AVFilterLink *inlink, AVFrame *in)
258260 {
261+ FilterLink *inl = ff_filter_link(inlink);
259262 AVFilterContext *ctx = inlink->dst;
260263 BLRContext *s = ctx->priv;
261264 AVFilterLink *outlink = ctx->outputs[0];
@@ -316,7 +319,7 @@ static int blurdetect_filter_frame(AVFilterLink *inlink, AVFrame *in) · 54 unmodified lines
316319
317320 set_meta(metadata, "lavfi.blur", blur);
318321
319− s->nb_frames = inlink->frame_count_in;
322+ s->nb_frames = inl->frame_count_in;
320323
321324 return ff_filter_frame(outlink, in);
322325 }
libavfilter/vf_crop.c+3−1
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include <stdio.h>
2727
2828 #include "avfilter.h"
29+#include "filters.h"
2930 #include "formats.h"
3031 #include "internal.h"
3132 #include "video.h"
@@ -255,12 +256,13 @@ static int config_output(AVFilterLink *link) · 223 unmodified lines
255256
256257 static int filter_frame(AVFilterLink *link, AVFrame *frame)
257258 {
259+ FilterLink *l = ff_filter_link(link);
258260 AVFilterContext *ctx = link->dst;
259261 CropContext *s = ctx->priv;
260262 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
261263 int i;
262264
263− s->var_values[VAR_N] = link->frame_count_out;
265+ s->var_values[VAR_N] = l->frame_count_out;
264266 s->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
265267 NAN : frame->pts * av_q2d(link->time_base);
266268 #if FF_API_FRAME_PKT
libavfilter/vf_datascope.c+3−1
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/xga_font_data.h"
2626 #include "avfilter.h"
2727 #include "drawutils.h"
28+#include "filters.h"
2829 #include "formats.h"
2930 #include "internal.h"
3031 #include "video.h"
@@ -1038,6 +1039,7 @@ static void draw_scope(OscilloscopeContext *s, int x0, int y0, int x1, int y1, · 1007 unmodified lines
10381039
10391040 static int oscilloscope_filter_frame(AVFilterLink *inlink, AVFrame *frame)
10401041 {
1042+ FilterLink *inl = ff_filter_link(inlink);
10411043 AVFilterContext *ctx = inlink->dst;
10421044 OscilloscopeContext *s = ctx->priv;
10431045 AVFilterLink *outlink = ctx->outputs[0];
@@ -1047,7 +1049,7 @@ static int oscilloscope_filter_frame(AVFilterLink *inlink, AVFrame *frame) · 3 unmodified lines
10471049 int i, c;
10481050
10491051 s->nb_values = 0;
1050− draw_scope(s, s->x1, s->y1, s->x2, s->y2, frame, s->values, inlink->frame_count_in & 1);
1052+ draw_scope(s, s->x1, s->y1, s->x2, s->y2, frame, s->values, inl->frame_count_in & 1);
10511053 ff_blend_rectangle(&s->draw, &s->dark, frame->data, frame->linesize,
10521054 frame->width, frame->height,
10531055 s->ox, s->oy, s->width, s->height + 20 * s->statistics);
libavfilter/vf_delogo.c+3−1
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include "libavutil/pixdesc.h"
3434 #include "libavutil/eval.h"
3535 #include "avfilter.h"
36+#include "filters.h"
3637 #include "internal.h"
3738 #include "video.h"
3839 static const char * const var_names[] = {
@@ -286,6 +287,7 @@ static int config_input(AVFilterLink *inlink) · 247 unmodified lines
286287
287288 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
288289 {
290+ FilterLink *inl = ff_filter_link(inlink);
289291 DelogoContext *s = inlink->dst->priv;
290292 AVFilterLink *outlink = inlink->dst->outputs[0];
291293 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
@@ -297,7 +299,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines
297299 AVRational sar;
298300 int ret;
299301
300− s->var_values[VAR_N] = inlink->frame_count_out;
302+ s->var_values[VAR_N] = inl->frame_count_out;
301303 s->var_values[VAR_T] = TS2T(in->pts, inlink->time_base);
302304 s->x = av_expr_eval(s->x_pexpr, s->var_values, s);
303305 s->y = av_expr_eval(s->y_pexpr, s->var_values, s);
libavfilter/vf_detelecine.c+2−1
@@ -193,6 +193,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 192 unmodified lines
193193 {
194194 AVFilterContext *ctx = inlink->dst;
195195 AVFilterLink *outlink = ctx->outputs[0];
196+ FilterLink *outl = ff_filter_link(outlink);
196197 DetelecineContext *s = ctx->priv;
197198 int i, len = 0, ret = 0, out = 0;
198199
@@ -332,7 +333,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 133 unmodified lines
332333
333334 av_frame_copy_props(frame, inpicref);
334335 frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
335− av_rescale(outlink->frame_count_in, s->ts_unit.num,
336+ av_rescale(outl->frame_count_in, s->ts_unit.num,
336337 s->ts_unit.den);
337338 ret = ff_filter_frame(outlink, frame);
338339 }
libavfilter/vf_drawtext.c+6−3
@@ -60,6 +60,7 @@ · 59 unmodified lines
6060 #include "libavutil/detection_bbox.h"
6161 #include "avfilter.h"
6262 #include "drawutils.h"
63+#include "filters.h"
6364 #include "formats.h"
6465 #include "internal.h"
6566 #include "textutils.h"
@@ -1553,6 +1554,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame) · 1487 unmodified lines
15531554 {
15541555 DrawTextContext *s = ctx->priv;
15551556 AVFilterLink *inlink = ctx->inputs[0];
1557+ FilterLink *inl = ff_filter_link(inlink);
15561558 int x = 0, y = 0, ret;
15571559 int shift_x64, shift_y64;
15581560 int x64, y64;
@@ -1596,7 +1598,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame) · 37 unmodified lines
15961598
15971599 if (s->tc_opt_string) {
15981600 char tcbuf[AV_TIMECODE_STR_SIZE];
1599− av_timecode_make_string(&s->tc, tcbuf, inlink->frame_count_out);
1601+ av_timecode_make_string(&s->tc, tcbuf, inl->frame_count_out);
16001602 av_bprint_clear(bp);
16011603 av_bprintf(bp, "%s%s", s->text, tcbuf);
16021604 }
@@ -1828,6 +1830,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame) · 225 unmodified lines
18281830
18291831 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
18301832 {
1833+ FilterLink *inl = ff_filter_link(inlink);
18311834 AVFilterContext *ctx = inlink->dst;
18321835 AVFilterLink *outlink = ctx->outputs[0];
18331836 DrawTextContext *s = ctx->priv;
@@ -1848,7 +1851,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 14 unmodified lines
18481851 }
18491852 }
18501853
1851− if (s->reload && !(inlink->frame_count_out % s->reload)) {
1854+ if (s->reload && !(inl->frame_count_out % s->reload)) {
18521855 if ((ret = ff_load_textfile(ctx, (const char *)s->textfile, &s->text, NULL)) < 0) {
18531856 av_frame_free(&frame);
18541857 return ret;
@@ -1862,7 +1865,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 7 unmodified lines
18621865 #endif
18631866 }
18641867
1865− s->var_values[VAR_N] = inlink->frame_count_out + s->start_number;
1868+ s->var_values[VAR_N] = inl->frame_count_out + s->start_number;
18661869 s->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
18671870 NAN : frame->pts * av_q2d(inlink->time_base);
18681871
libavfilter/vf_eq.c+2−1
@@ -221,6 +221,7 @@ static const enum AVPixelFormat pixel_fmts_eq[] = { · 220 unmodified lines
221221
222222 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
223223 {
224+ FilterLink *inl = ff_filter_link(inlink);
224225 AVFilterContext *ctx = inlink->dst;
225226 AVFilterLink *outlink = inlink->dst->outputs[0];
226227 EQContext *eq = ctx->priv;
@@ -237,7 +238,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 10 unmodified lines
237238 av_frame_copy_props(out, in);
238239 desc = av_pix_fmt_desc_get(inlink->format);
239240
240− eq->var_values[VAR_N] = inlink->frame_count_out;
241+ eq->var_values[VAR_N] = inl->frame_count_out;
241242 #if FF_API_FRAME_PKT
242243 FF_DISABLE_DEPRECATION_WARNINGS
243244 {
libavfilter/vf_fade.c+6−4
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333 #include "libavutil/pixdesc.h"
3434 #include "avfilter.h"
3535 #include "drawutils.h"
36+#include "filters.h"
3637 #include "formats.h"
3738 #include "internal.h"
3839 #include "video.h"
@@ -442,6 +443,7 @@ static int config_input(AVFilterLink *inlink) · 403 unmodified lines
442443
443444 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
444445 {
446+ FilterLink *inl = ff_filter_link(inlink);
445447 AVFilterContext *ctx = inlink->dst;
446448 FadeContext *s = ctx->priv;
447449
@@ -449,7 +451,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 1 unmodified line
449451 if (s->fade_state == VF_FADE_WAITING) {
450452 s->factor=0;
451453 if (frame->pts >= s->start_time_pts
452− && inlink->frame_count_out >= s->start_frame) {
454+ && inl->frame_count_out >= s->start_frame) {
453455 // Time to start fading
454456 s->fade_state = VF_FADE_FADING;
455457
@@ -460,15 +462,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 4 unmodified lines
460462
461463 // Save start frame in case we are starting based on time and fading based on frames
462464 if (s->start_time_pts != 0 && s->start_frame == 0) {
463− s->start_frame = inlink->frame_count_out;
465+ s->start_frame = inl->frame_count_out;
464466 }
465467 }
466468 }
467469 if (s->fade_state == VF_FADE_FADING) {
468470 if (s->duration_pts == 0) {
469471 // Fading based on frame count
470− s->factor = (inlink->frame_count_out - s->start_frame) * s->fade_per_frame;
471− if (inlink->frame_count_out > s->start_frame + s->nb_frames) {
472+ s->factor = (inl->frame_count_out - s->start_frame) * s->fade_per_frame;
473+ if (inl->frame_count_out > s->start_frame + s->nb_frames) {
472474 s->fade_state = VF_FADE_DONE;
473475 }
474476
libavfilter/vf_fftfilt.c+3−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 * FFT domain filtering.
2525 */
2626
27+#include "filters.h"
2728 #include "internal.h"
2829 #include "video.h"
2930 #include "libavutil/common.h"
@@ -284,10 +285,11 @@ static av_cold int initialize(AVFilterContext *ctx) · 254 unmodified lines
284285
285286 static void do_eval(FFTFILTContext *s, AVFilterLink *inlink, int plane)
286287 {
288+ FilterLink *l = ff_filter_link(inlink);
287289 double values[VAR_VARS_NB];
288290 int i, j;
289291
290− values[VAR_N] = inlink->frame_count_out;
292+ values[VAR_N] = l->frame_count_out;
291293 values[VAR_W] = s->planewidth[plane];
292294 values[VAR_H] = s->planeheight[plane];
293295 values[VAR_WS] = s->rdft_hlen[plane];
libavfilter/vf_fieldhint.c+10−7
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/opt.h"
2626 #include "libavutil/pixdesc.h"
2727 #include "avfilter.h"
28+#include "filters.h"
2829 #include "formats.h"
2930 #include "internal.h"
3031 #include "video.h"
@@ -113,8 +114,10 @@ static int config_input(AVFilterLink *inlink) · 82 unmodified lines
113114
114115 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
115116 {
117+ FilterLink *inl = ff_filter_link(inlink);
116118 AVFilterContext *ctx = inlink->dst;
117119 AVFilterLink *outlink = ctx->outputs[0];
120+ FilterLink *outl = ff_filter_link(outlink);
118121 FieldHintContext *s = ctx->priv;
119122 AVFrame *out, *top, *bottom;
120123 char buf[1024] = { 0 };
@@ -152,9 +155,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 31 unmodified lines
152155 }
153156 switch (s->mode) {
154157 case ABSOLUTE_HINT:
155− if (tf > outlink->frame_count_in + 1 || tf < FFMAX(0, outlink->frame_count_in - 1) ||
156− bf > outlink->frame_count_in + 1 || bf < FFMAX(0, outlink->frame_count_in - 1)) {
157− av_log(ctx, AV_LOG_ERROR, "Out of range frames %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inlink->frame_count_out);
158+ if (tf > outl->frame_count_in + 1 || tf < FFMAX(0, outl->frame_count_in - 1) ||
159+ bf > outl->frame_count_in + 1 || bf < FFMAX(0, outl->frame_count_in - 1)) {
160+ av_log(ctx, AV_LOG_ERROR, "Out of range frames %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inl->frame_count_out);
158161 return AVERROR_INVALIDDATA;
159162 }
160163 break;
@@ -162,7 +165,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 1 unmodified line
162165 case RELATIVE_HINT:
163166 if (tf > 1 || tf < -1 ||
164167 bf > 1 || bf < -1) {
165− av_log(ctx, AV_LOG_ERROR, "Out of range %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inlink->frame_count_out);
168+ av_log(ctx, AV_LOG_ERROR, "Out of range %"PRId64" and/or %"PRId64" on line %"PRId64" for %"PRId64". input frame.\n", tf, bf, s->line, inl->frame_count_out);
166169 return AVERROR_INVALIDDATA;
167170 }
168171 break;
@@ -175,7 +178,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 6 unmodified lines
175178 fseek(s->hint, 0, SEEK_SET);
176179 continue;
177180 }
178− av_log(ctx, AV_LOG_ERROR, "Missing entry for %"PRId64". input frame.\n", inlink->frame_count_out);
181+ av_log(ctx, AV_LOG_ERROR, "Missing entry for %"PRId64". input frame.\n", inl->frame_count_out);
179182 return AVERROR_INVALIDDATA;
180183 }
181184 }
@@ -187,8 +190,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines
187190
188191 switch (s->mode) {
189192 case ABSOLUTE_HINT:
190− top = s->frame[tf - outlink->frame_count_in + 1];
191− bottom = s->frame[bf - outlink->frame_count_in + 1];
193+ top = s->frame[tf - outl->frame_count_in + 1];
194+ bottom = s->frame[bf - outl->frame_count_in + 1];
192195 break;
193196 case PATTERN_HINT:
194197 case RELATIVE_HINT:
libavfilter/vf_fieldmatch.c+4−3
@@ -681,6 +681,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 680 unmodified lines
681681 {
682682 AVFilterContext *ctx = inlink->dst;
683683 AVFilterLink *outlink = ctx->outputs[0];
684+ FilterLink *outl = ff_filter_link(outlink);
684685 FieldMatchContext *fm = ctx->priv;
685686 int combs[] = { -1, -1, -1, -1, -1 };
686687 int order, field, i, match, interlaced_frame, sc = 0, ret = 0;
@@ -753,7 +754,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 66 unmodified lines
753754
754755 /* scene change check */
755756 if (fm->combmatch == COMBMATCH_SC) {
756− if (fm->lastn == outlink->frame_count_in - 1) {
757+ if (fm->lastn == outl->frame_count_in - 1) {
757758 if (fm->lastscdiff > fm->scthresh)
758759 sc = 1;
759760 } else if (luma_abs_diff(fm->prv, fm->src) > fm->scthresh) {
@@ -761,7 +762,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 1 unmodified line
761762 }
762763
763764 if (!sc) {
764− fm->lastn = outlink->frame_count_in;
765+ fm->lastn = outl->frame_count_in;
765766 fm->lastscdiff = luma_abs_diff(fm->src, fm->nxt);
766767 sc = fm->lastscdiff > fm->scthresh;
767768 }
@@ -831,7 +832,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 63 unmodified lines
831832 if (interlaced_frame) {
832833 dst->flags |= AV_FRAME_FLAG_INTERLACED;
833834 av_log(ctx, AV_LOG_WARNING, "Frame #%"PRId64" at %s is still interlaced\n",
834− outlink->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base));
835+ outl->frame_count_in, av_ts2timestr(in->pts, &inlink->time_base));
835836 #if FF_API_INTERLACED_FRAME
836837 FF_DISABLE_DEPRECATION_WARNINGS
837838 dst->top_field_first = field;
libavfilter/vf_find_rect.c+4−1
@@ -24,6 +24,8 @@ · 23 unmodified lines
2424
2525 #include "libavutil/mem.h"
2626 #include "libavutil/opt.h"
27+
28+#include "filters.h"
2729 #include "internal.h"
2830 #include "video.h"
2931
@@ -172,6 +174,7 @@ static float search(FOCContext *foc, int pass, int maxpass, int xmin, int xmax, · 142 unmodified lines
172174
173175 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
174176 {
177+ FilterLink *inl = ff_filter_link(inlink);
175178 AVFilterContext *ctx = inlink->dst;
176179 FOCContext *foc = ctx->priv;
177180 float best_score;
@@ -208,7 +211,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 30 unmodified lines
208211 }
209212
210213 av_log(ctx, AV_LOG_INFO, "Found at n=%"PRId64" pts_time=%f x=%d y=%d with score=%f\n",
211− inlink->frame_count_out, TS2D(in->pts) * av_q2d(inlink->time_base),
214+ inl->frame_count_out, TS2D(in->pts) * av_q2d(inlink->time_base),
212215 best_x, best_y, best_score);
213216 foc->last_x = best_x;
214217 foc->last_y = best_y;
libavfilter/vf_framestep.c+2−1
@@ -64,9 +64,10 @@ static int config_output_props(AVFilterLink *outlink) · 63 unmodified lines
6464
6565 static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
6666 {
67+ FilterLink *inl = ff_filter_link(inlink);
6768 FrameStepContext *framestep = inlink->dst->priv;
6869
69− if (!(inlink->frame_count_out % framestep->frame_step)) {
70+ if (!(inl->frame_count_out % framestep->frame_step)) {
7071 return ff_filter_frame(inlink->dst->outputs[0], ref);
7172 } else {
7273 av_frame_free(&ref);
libavfilter/vf_freezeframes.c+5−3
@@ -74,12 +74,14 @@ static int config_output(AVFilterLink *outlink) · 73 unmodified lines
7474
7575 static int activate(AVFilterContext *ctx)
7676 {
77+ FilterLink *inl0 = ff_filter_link(ctx->inputs[0]);
78+ FilterLink *inl1 = ff_filter_link(ctx->inputs[1]);
7779 AVFilterLink *outlink = ctx->outputs[0];
7880 FreezeFramesContext *s = ctx->priv;
7981 AVFrame *frame = NULL;
80− int drop = ctx->inputs[0]->frame_count_out >= s->first &&
81− ctx->inputs[0]->frame_count_out <= s->last;
82− int replace = ctx->inputs[1]->frame_count_out == s->replace;
82+ int drop = inl0->frame_count_out >= s->first &&
83+ inl0->frame_count_out <= s->last;
84+ int replace = inl1->frame_count_out == s->replace;
8385 int ret;
8486
8587 FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
libavfilter/vf_geq.c+4−1
@@ -32,6 +32,8 @@ · 31 unmodified lines
3232 #include "libavutil/mem.h"
3333 #include "libavutil/opt.h"
3434 #include "libavutil/pixdesc.h"
35+
36+#include "filters.h"
3537 #include "formats.h"
3638 #include "internal.h"
3739 #include "video.h"
@@ -453,13 +455,14 @@ static int slice_geq_filter(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 415 unmodified lines
453455 static int geq_filter_frame(AVFilterLink *inlink, AVFrame *in)
454456 {
455457 int plane;
458+ FilterLink *inl = ff_filter_link(inlink);
456459 AVFilterContext *ctx = inlink->dst;
457460 const int nb_threads = FFMIN(MAX_NB_THREADS, ff_filter_get_nb_threads(ctx));
458461 GEQContext *geq = ctx->priv;
459462 AVFilterLink *outlink = inlink->dst->outputs[0];
460463 AVFrame *out;
461464
462− geq->values[VAR_N] = inlink->frame_count_out,
465+ geq->values[VAR_N] = inl->frame_count_out,
463466 geq->values[VAR_T] = in->pts == AV_NOPTS_VALUE ? NAN : in->pts * av_q2d(inlink->time_base),
464467
465468 geq->picref = in;
libavfilter/vf_hue.c+2−1
@@ -360,6 +360,7 @@ static void apply_lut10(HueContext *s, · 359 unmodified lines
360360
361361 static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
362362 {
363+ FilterLink *inl = ff_filter_link(inlink);
363364 HueContext *hue = inlink->dst->priv;
364365 AVFilterLink *outlink = inlink->dst->outputs[0];
365366 AVFrame *outpic;
@@ -381,7 +382,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) · 15 unmodified lines
381382 av_frame_copy_props(outpic, inpic);
382383 }
383384
384− hue->var_values[VAR_N] = inlink->frame_count_out;
385+ hue->var_values[VAR_N] = inl->frame_count_out;
385386 hue->var_values[VAR_T] = TS2T(inpic->pts, inlink->time_base);
386387 hue->var_values[VAR_PTS] = TS2D(inpic->pts);
387388
libavfilter/vf_libplacebo.c+4−2
@@ -742,6 +742,7 @@ static const AVFrame *ref_frame(const struct pl_frame_mix *mix) · 741 unmodified lines
742742 static void update_crops(AVFilterContext *ctx, LibplaceboInput *in,
743743 struct pl_frame *target, double target_pts)
744744 {
745+ FilterLink *outl = ff_filter_link(ctx->outputs[0]);
745746 LibplaceboContext *s = ctx->priv;
746747 const AVFrame *ref = ref_frame(&in->mix);
747748
@@ -761,7 +762,7 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, · 13 unmodified lines
761762 av_q2d(in->link->sample_aspect_ratio) : 1.0;
762763 s->var_values[VAR_IN_T] = s->var_values[VAR_T] = image_pts;
763764 s->var_values[VAR_OUT_T] = s->var_values[VAR_OT] = target_pts;
764− s->var_values[VAR_N] = ctx->outputs[0]->frame_count_out;
765+ s->var_values[VAR_N] = outl->frame_count_out;
765766
766767 /* Clear these explicitly to avoid leaking previous frames' state */
767768 s->var_values[VAR_CROP_W] = s->var_values[VAR_CW] = NAN;
@@ -1000,6 +1001,7 @@ static int libplacebo_activate(AVFilterContext *ctx) · 232 unmodified lines
10001001 int ret, ok = 0, retry = 0;
10011002 LibplaceboContext *s = ctx->priv;
10021003 AVFilterLink *outlink = ctx->outputs[0];
1004+ FilterLink *outl = ff_filter_link(outlink);
10031005 int64_t pts, out_pts;
10041006
10051007 FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
@@ -1012,7 +1014,7 @@ static int libplacebo_activate(AVFilterContext *ctx) · 6 unmodified lines
10121014
10131015 if (ff_outlink_frame_wanted(outlink)) {
10141016 if (s->fps.num) {
1015− out_pts = outlink->frame_count_out;
1017+ out_pts = outl->frame_count_out;
10161018 } else {
10171019 /* Determine the PTS of the next frame from any active input */
10181020 out_pts = INT64_MAX;
libavfilter/vf_overlay.c+3−1
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 #include "libavutil/opt.h"
3737 #include "libavutil/timestamp.h"
3838 #include "internal.h"
39+#include "filters.h"
3940 #include "drawutils.h"
4041 #include "framesync.h"
4142 #include "video.h"
@@ -881,6 +882,7 @@ static int do_blend(FFFrameSync *fs) · 839 unmodified lines
881882 AVFrame *mainpic, *second;
882883 OverlayContext *s = ctx->priv;
883884 AVFilterLink *inlink = ctx->inputs[0];
885+ FilterLink *inl = ff_filter_link(inlink);
884886 int ret;
885887
886888 ret = ff_framesync_dualinput_get_writable(fs, &mainpic, &second);
@@ -891,7 +893,7 @@ static int do_blend(FFFrameSync *fs) · 4 unmodified lines
891893
892894 if (s->eval_mode == EVAL_MODE_FRAME) {
893895
894− s->var_values[VAR_N] = inlink->frame_count_out;
896+ s->var_values[VAR_N] = inl->frame_count_out;
895897 s->var_values[VAR_T] = mainpic->pts == AV_NOPTS_VALUE ?
896898 NAN : mainpic->pts * av_q2d(inlink->time_base);
897899 #if FF_API_FRAME_PKT
libavfilter/vf_overlay_cuda.c+2−1
@@ -236,6 +236,7 @@ static int overlay_cuda_blend(FFFrameSync *fs) · 235 unmodified lines
236236 OverlayCUDAContext *ctx = avctx->priv;
237237 AVFilterLink *outlink = avctx->outputs[0];
238238 AVFilterLink *inlink = avctx->inputs[0];
239+ FilterLink *inl = ff_filter_link(inlink);
239240
240241 CudaFunctions *cu = ctx->hwctx->internal->cuda_dl;
241242 CUcontext dummy, cuda_ctx = ctx->hwctx->cuda_ctx;
@@ -270,7 +271,7 @@ static int overlay_cuda_blend(FFFrameSync *fs) · 28 unmodified lines
270271 }
271272
272273 if (ctx->eval_mode == EVAL_MODE_FRAME) {
273− ctx->var_values[VAR_N] = inlink->frame_count_out;
274+ ctx->var_values[VAR_N] = inl->frame_count_out;
274275 ctx->var_values[VAR_T] = input_main->pts == AV_NOPTS_VALUE ?
275276 NAN : input_main->pts * av_q2d(inlink->time_base);
276277
libavfilter/vf_perspective.c+5−2
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/pixdesc.h"
2727 #include "libavutil/opt.h"
2828 #include "avfilter.h"
29+#include "filters.h"
2930 #include "internal.h"
3031 #include "video.h"
3132
@@ -122,13 +123,15 @@ enum { VAR_W, VAR_H, VAR_IN, VAR_ON, VAR_VARS_ · 90 unmodified lines
122123
123124 static int calc_persp_luts(AVFilterContext *ctx, AVFilterLink *inlink)
124125 {
126+ FilterLink *inl = ff_filter_link(inlink);
125127 PerspectiveContext *s = ctx->priv;
126128 AVFilterLink *outlink = ctx->outputs[0];
129+ FilterLink *outl = ff_filter_link(outlink);
127130 double (*ref)[2] = s->ref;
128131
129132 double values[VAR_VARS_NB] = { [VAR_W] = inlink->w, [VAR_H] = inlink->h,
130− [VAR_IN] = inlink->frame_count_out + 1,
131− [VAR_ON] = outlink->frame_count_in + 1 };
133+ [VAR_IN] = inl->frame_count_out + 1,
134+ [VAR_ON] = outl->frame_count_in + 1 };
132135 const int h = values[VAR_H];
133136 const int w = values[VAR_W];
134137 double x0, x1, x2, x3, x4, x5, x6, x7, x8, q;
libavfilter/vf_quirc.c+2−1
@@ -89,6 +89,7 @@ static int query_formats(AVFilterContext *ctx) · 88 unmodified lines
8989
9090 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
9191 {
92+ FilterLink *inl = ff_filter_link(inlink);
9293 AVFilterContext *ctx = inlink->dst;
9394 AVFilterLink *outlink = ctx->outputs[0];
9495 QuircContext *quirc = ctx->priv;
@@ -104,7 +105,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 9 unmodified lines
104105
105106 codes_count = quirc_count(quirc->quirc);
106107 av_log(ctx, AV_LOG_VERBOSE,
107− "Found count %d codes in image #%ld\n", codes_count, inlink->frame_count_out);
108+ "Found count %d codes in image #%ld\n", codes_count, inl->frame_count_out);
108109
109110 if (codes_count) {
110111 int i, j;
libavfilter/vf_rotate.c+3−1
@@ -33,6 +33,7 @@ · 32 unmodified lines
3333
3434 #include "avfilter.h"
3535 #include "drawutils.h"
36+#include "filters.h"
3637 #include "internal.h"
3738 #include "video.h"
3839
@@ -501,6 +502,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs) · 462 unmodified lines
501502
502503 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
503504 {
505+ FilterLink *inl = ff_filter_link(inlink);
504506 AVFilterContext *ctx = inlink->dst;
505507 AVFilterLink *outlink = ctx->outputs[0];
506508 AVFrame *out;
@@ -515,7 +517,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 8 unmodified lines
515517 }
516518 av_frame_copy_props(out, in);
517519
518− rot->var_values[VAR_N] = inlink->frame_count_out;
520+ rot->var_values[VAR_N] = inl->frame_count_out;
519521 rot->var_values[VAR_T] = TS2T(in->pts, inlink->time_base);
520522 rot->angle = res = av_expr_eval(rot->angle_expr, rot->var_values, rot);
521523
libavfilter/vf_scale.c+8−4
@@ -879,6 +879,7 @@ static int scale_field(ScaleContext *scale, AVFrame *dst, AVFrame *src, · 878 unmodified lines
879879 static int scale_frame(AVFilterLink *link, AVFrame **frame_in,
880880 AVFrame **frame_out)
881881 {
882+ FilterLink *inl = ff_filter_link(link);
882883 AVFilterContext *ctx = link->dst;
883884 ScaleContext *scale = ctx->priv;
884885 AVFilterLink *outlink = ctx->outputs[0];
@@ -938,7 +939,7 @@ static int scale_frame(AVFilterLink *link, AVFrame **frame_in, · 53 unmodified lines
938939 }
939940
940941 if (ctx->filter == &ff_vf_scale2ref) {
941− scale->var_values[VAR_S2R_MAIN_N] = link->frame_count_out;
942+ scale->var_values[VAR_S2R_MAIN_N] = inl->frame_count_out;
942943 scale->var_values[VAR_S2R_MAIN_T] = TS2T(in->pts, link->time_base);
943944 #if FF_API_FRAME_PKT
944945 FF_DISABLE_DEPRECATION_WARNINGS
@@ -946,7 +947,7 @@ FF_DISABLE_DEPRECATION_WARNINGS · 1 unmodified line
946947 FF_ENABLE_DEPRECATION_WARNINGS
947948 #endif
948949 } else {
949− scale->var_values[VAR_N] = link->frame_count_out;
950+ scale->var_values[VAR_N] = inl->frame_count_out;
950951 scale->var_values[VAR_T] = TS2T(in->pts, link->time_base);
951952 #if FF_API_FRAME_PKT
952953 FF_DISABLE_DEPRECATION_WARNINGS
@@ -1035,6 +1036,8 @@ static int do_scale(FFFrameSync *fs) · 82 unmodified lines
10351036
10361037 if (ref) {
10371038 AVFilterLink *reflink = ctx->inputs[1];
1039+ FilterLink *rl = ff_filter_link(reflink);
1040+
10381041 frame_changed = ref->width != reflink->w ||
10391042 ref->height != reflink->h ||
10401043 ref->format != reflink->format ||
@@ -1058,7 +1061,7 @@ static int do_scale(FFFrameSync *fs) · 17 unmodified lines
10581061 }
10591062
10601063 if (scale->eval_mode == EVAL_MODE_FRAME) {
1061− scale->var_values[VAR_REF_N] = reflink->frame_count_out;
1064+ scale->var_values[VAR_REF_N] = rl->frame_count_out;
10621065 scale->var_values[VAR_REF_T] = TS2T(ref->pts, reflink->time_base);
10631066 #if FF_API_FRAME_PKT
10641067 FF_DISABLE_DEPRECATION_WARNINGS
@@ -1097,6 +1100,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 32 unmodified lines
10971100
10981101 static int filter_frame_ref(AVFilterLink *link, AVFrame *in)
10991102 {
1103+ FilterLink *l = ff_filter_link(link);
11001104 ScaleContext *scale = link->dst->priv;
11011105 AVFilterLink *outlink = link->dst->outputs[1];
11021106 int frame_changed;
@@ -1122,7 +1126,7 @@ static int filter_frame_ref(AVFilterLink *link, AVFrame *in) · 19 unmodified lines
11221126 }
11231127
11241128 if (scale->eval_mode == EVAL_MODE_FRAME) {
1125− scale->var_values[VAR_N] = link->frame_count_out;
1129+ scale->var_values[VAR_N] = l->frame_count_out;
11261130 scale->var_values[VAR_T] = TS2T(in->pts, link->time_base);
11271131 #if FF_API_FRAME_PKT
11281132 FF_DISABLE_DEPRECATION_WARNINGS
libavfilter/vf_scale_npp.c+5−3
@@ -791,6 +791,7 @@ static int (*const nppscale_process[])(AVFilterContext *ctx, NPPScaleStageContex · 790 unmodified lines
791791
792792 static int nppscale_scale(AVFilterLink *link, AVFrame *out, AVFrame *in)
793793 {
794+ FilterLink *inl = ff_filter_link(link);
794795 AVFilterContext *ctx = link->dst;
795796 NPPScaleContext *s = ctx->priv;
796797 AVFilterLink *outlink = ctx->outputs[0];
@@ -840,7 +841,7 @@ static int nppscale_scale(AVFilterLink *link, AVFrame *out, AVFrame *in) · 43 unmodified lines
840841 }
841842
842843 if (ctx->filter == &ff_vf_scale2ref_npp) {
843− s->var_values[VAR_S2R_MAIN_N] = link->frame_count_out;
844+ s->var_values[VAR_S2R_MAIN_N] = inl->frame_count_out;
844845 s->var_values[VAR_S2R_MAIN_T] = TS2T(in->pts, link->time_base);
845846 #if FF_API_FRAME_PKT
846847 FF_DISABLE_DEPRECATION_WARNINGS
@@ -848,7 +849,7 @@ FF_DISABLE_DEPRECATION_WARNINGS · 1 unmodified line
848849 FF_ENABLE_DEPRECATION_WARNINGS
849850 #endif
850851 } else {
851− s->var_values[VAR_N] = link->frame_count_out;
852+ s->var_values[VAR_N] = inl->frame_count_out;
852853 s->var_values[VAR_T] = TS2T(in->pts, link->time_base);
853854 #if FF_API_FRAME_PKT
854855 FF_DISABLE_DEPRECATION_WARNINGS
@@ -947,6 +948,7 @@ fail: · 92 unmodified lines
947948
948949 static int nppscale_filter_frame_ref(AVFilterLink *link, AVFrame *in)
949950 {
951+ FilterLink *inl = ff_filter_link(link);
950952 NPPScaleContext *scale = link->dst->priv;
951953 AVFilterLink *outlink = link->dst->outputs[1];
952954 int frame_changed;
@@ -968,7 +970,7 @@ static int nppscale_filter_frame_ref(AVFilterLink *link, AVFrame *in) · 15 unmodified lines
968970 }
969971
970972 if (scale->eval_mode == EVAL_MODE_FRAME) {
971− scale->var_values[VAR_N] = link->frame_count_out;
973+ scale->var_values[VAR_N] = inl->frame_count_out;
972974 scale->var_values[VAR_T] = TS2T(in->pts, link->time_base);
973975 #if FF_API_FRAME_PKT
974976 FF_DISABLE_DEPRECATION_WARNINGS
libavfilter/vf_showinfo.c+2−1
@@ -728,6 +728,7 @@ static void update_sample_stats(int depth, int be, const uint8_t *src, int len, · 727 unmodified lines
728728
729729 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
730730 {
731+ FilterLink *inl = ff_filter_link(inlink);
731732 AVFilterContext *ctx = inlink->dst;
732733 ShowInfoContext *s = ctx->priv;
733734 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
@@ -761,7 +762,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 27 unmodified lines
761762 "n:%4"PRId64" pts:%7s pts_time:%-7s duration:%7"PRId64
762763 " duration_time:%-7s "
763764 "fmt:%s cl:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c ",
764− inlink->frame_count_out,
765+ inl->frame_count_out,
765766 av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base),
766767 frame->duration, av_ts2timestr(frame->duration, &inlink->time_base),
767768 desc->name, av_chroma_location_name(frame->chroma_location),
libavfilter/vf_swaprect.c+3−1
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include "libavutil/opt.h"
2626
2727 #include "avfilter.h"
28+#include "filters.h"
2829 #include "formats.h"
2930 #include "internal.h"
3031 #include "video.h"
@@ -78,6 +79,7 @@ enum { VAR_W, VAR_H, VAR_A, VAR_N, VAR_T, · 47 unmodified lines
7879
7980 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
8081 {
82+ FilterLink *inl = ff_filter_link(inlink);
8183 AVFilterContext *ctx = inlink->dst;
8284 AVFilterLink *outlink = ctx->outputs[0];
8385 SwapRectContext *s = ctx->priv;
@@ -97,7 +99,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 13 unmodified lines
9799 var_values[VAR_A] = (float) inlink->w / inlink->h;
98100 var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? av_q2d(inlink->sample_aspect_ratio) : 1;
99101 var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
100− var_values[VAR_N] = inlink->frame_count_out;
102+ var_values[VAR_N] = inl->frame_count_out;
101103 var_values[VAR_T] = in->pts == AV_NOPTS_VALUE ? NAN : in->pts * av_q2d(inlink->time_base);
102104 #if FF_API_FRAME_PKT
103105 FF_DISABLE_DEPRECATION_WARNINGS
libavfilter/vf_telecine.c+2−1
@@ -167,6 +167,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref) · 166 unmodified lines
167167 {
168168 AVFilterContext *ctx = inlink->dst;
169169 AVFilterLink *outlink = ctx->outputs[0];
170+ FilterLink *outl = ff_filter_link(outlink);
170171 TelecineContext *s = ctx->priv;
171172 int i, len, ret = 0, nout = 0;
172173
@@ -281,7 +282,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 108 unmodified lines
281282 else
282283 frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
283284 frame->pts = ((s->start_time == AV_NOPTS_VALUE) ? 0 : s->start_time) +
284− av_rescale(outlink->frame_count_in, s->ts_unit.num,
285+ av_rescale(outl->frame_count_in, s->ts_unit.num,
285286 s->ts_unit.den);
286287 ret = ff_filter_frame(outlink, frame);
287288 }
libavfilter/vf_tinterlace.c+4−3
@@ -376,6 +376,7 @@ void copy_picture_field(TInterlaceContext *tinterlace, · 375 unmodified lines
376376
377377 static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
378378 {
379+ FilterLink *inl = ff_filter_link(inlink);
379380 AVFilterContext *ctx = inlink->dst;
380381 AVFilterLink *outlink = ctx->outputs[0];
381382 FilterLink *l = ff_filter_link(outlink);
@@ -418,12 +419,12 @@ FF_ENABLE_DEPRECATION_WARNINGS · 36 unmodified lines
418419 copy_picture_field(tinterlace, out->data, out->linesize,
419420 (const uint8_t **)cur->data, cur->linesize,
420421 inlink->format, inlink->w, inlink->h,
421− FIELD_UPPER_AND_LOWER, 1, tinterlace->mode == MODE_MERGEX2 ? (1 + inlink->frame_count_out) & 1 ? FIELD_LOWER : FIELD_UPPER : FIELD_UPPER, tinterlace->flags);
422+ FIELD_UPPER_AND_LOWER, 1, tinterlace->mode == MODE_MERGEX2 ? (1 + inl->frame_count_out) & 1 ? FIELD_LOWER : FIELD_UPPER : FIELD_UPPER, tinterlace->flags);
422423 /* write even frame lines into the lower field of the new frame */
423424 copy_picture_field(tinterlace, out->data, out->linesize,
424425 (const uint8_t **)next->data, next->linesize,
425426 inlink->format, inlink->w, inlink->h,
426− FIELD_UPPER_AND_LOWER, 1, tinterlace->mode == MODE_MERGEX2 ? (1 + inlink->frame_count_out) & 1 ? FIELD_UPPER : FIELD_LOWER : FIELD_LOWER, tinterlace->flags);
427+ FIELD_UPPER_AND_LOWER, 1, tinterlace->mode == MODE_MERGEX2 ? (1 + inl->frame_count_out) & 1 ? FIELD_UPPER : FIELD_LOWER : FIELD_LOWER, tinterlace->flags);
427428 if (tinterlace->mode != MODE_MERGEX2)
428429 av_frame_free(&tinterlace->next);
429430 break;
@@ -445,7 +446,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 15 unmodified lines
445446 out->height = outlink->h;
446447 out->sample_aspect_ratio = av_mul_q(cur->sample_aspect_ratio, av_make_q(2, 1));
447448
448− field = (1 + outlink->frame_count_in) & 1 ? FIELD_UPPER : FIELD_LOWER;
449+ field = (1 + l->frame_count_in) & 1 ? FIELD_UPPER : FIELD_LOWER;
449450 full = out->color_range == AVCOL_RANGE_JPEG || ff_fmt_is_in(out->format, full_scale_yuvj_pix_fmts);
450451 /* copy upper and lower fields */
451452 copy_picture_field(tinterlace, out->data, out->linesize,
libavfilter/vf_vignette.c+2−1
@@ -150,12 +150,13 @@ static double get_natural_factor(const VignetteContext *s, int x, int y) · 149 unmodified lines
150150
151151 static void update_context(VignetteContext *s, AVFilterLink *inlink, AVFrame *frame)
152152 {
153+ FilterLink *inl = ff_filter_link(inlink);
153154 int x, y;
154155 float *dst = s->fmap;
155156 int dst_linesize = s->fmap_linesize;
156157
157158 if (frame) {
158− s->var_values[VAR_N] = inlink->frame_count_out;
159+ s->var_values[VAR_N] = inl->frame_count_out;
159160 s->var_values[VAR_T] = TS2T(frame->pts, inlink->time_base);
160161 s->var_values[VAR_PTS] = TS2D(frame->pts);
161162 } else {
libavfilter/vf_weave.c+2−1
@@ -100,12 +100,13 @@ typedef struct ThreadData { · 99 unmodified lines
100100 static int weave_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
101101 {
102102 AVFilterLink *inlink = ctx->inputs[0];
103+ FilterLink *inl = ff_filter_link(inlink);
103104 WeaveContext *s = ctx->priv;
104105 ThreadData *td = arg;
105106 AVFrame *in = td->in;
106107 AVFrame *out = td->out;
107108
108− const int weave = (s->double_weave && !(inlink->frame_count_out & 1));
109+ const int weave = (s->double_weave && !(inl->frame_count_out & 1));
109110 const int field1 = weave ? s->first_field : (!s->first_field);
110111 const int field2 = weave ? (!s->first_field) : s->first_field;
111112
libavfilter/vf_zoompan.c+6−3
@@ -156,6 +156,7 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va · 155 unmodified lines
156156 {
157157 ZPContext *s = ctx->priv;
158158 AVFilterLink *outlink = ctx->outputs[0];
159+ FilterLink *outl = ff_filter_link(outlink);
159160 AVFilterLink *inlink = ctx->inputs[0];
160161 int64_t pts = s->frame_count;
161162 int k, x, y, w, h, ret = 0;
@@ -172,7 +173,7 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va · 10 unmodified lines
172173 var_values[VAR_OUT_TIME] = pts * av_q2d(outlink->time_base);
173174 var_values[VAR_TIME] = var_values[VAR_OT] = var_values[VAR_OUT_TIME];
174175 var_values[VAR_FRAME] = i;
175− var_values[VAR_ON] = outlink->frame_count_in;
176+ var_values[VAR_ON] = outl->frame_count_in;
176177
177178 *zoom = av_expr_eval(s->zoom_expr, var_values, NULL);
178179
@@ -260,7 +261,9 @@ static int activate(AVFilterContext *ctx) · 81 unmodified lines
260261 {
261262 ZPContext *s = ctx->priv;
262263 AVFilterLink *inlink = ctx->inputs[0];
264+ FilterLink *inl = ff_filter_link(inlink);
263265 AVFilterLink *outlink = ctx->outputs[0];
266+ FilterLink *outl = ff_filter_link(outlink);
264267 int status, ret = 0;
265268 int64_t pts;
266269
@@ -283,8 +286,8 @@ static int activate(AVFilterContext *ctx) · 16 unmodified lines
283286 s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = s->in->height;
284287 s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = s->w;
285288 s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = s->h;
286− s->var_values[VAR_IN] = inlink->frame_count_out - 1;
287− s->var_values[VAR_ON] = outlink->frame_count_in;
289+ s->var_values[VAR_IN] = inl->frame_count_out - 1;
290+ s->var_values[VAR_ON] = outl->frame_count_in;
288291 s->var_values[VAR_PX] = s->x;
289292 s->var_values[VAR_PY] = s->y;
290293 s->var_values[VAR_X] = 0;
libavfilter/vsrc_mptestsrc.c+3−2
@@ -292,12 +292,13 @@ static int config_props(AVFilterLink *outlink) · 291 unmodified lines
292292
293293 static int request_frame(AVFilterLink *outlink)
294294 {
295+ FilterLink *outl = ff_filter_link(outlink);
295296 MPTestContext *test = outlink->src->priv;
296297 AVFrame *picref;
297298 int w = WIDTH, h = HEIGHT,
298299 cw = AV_CEIL_RSHIFT(w, test->hsub), ch = AV_CEIL_RSHIFT(h, test->vsub);
299− uint64_t frame = outlink->frame_count_in / test->max_frames;
300− uint64_t mod = outlink->frame_count_in % test->max_frames;
300+ uint64_t frame = outl->frame_count_in / test->max_frames;
301+ uint64_t mod = outl->frame_count_in % test->max_frames;
301302 enum test_type tt = test->test;
302303 int i;
303304

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t