diff mbox series

[FFmpeg-devel] avfilter: add more usage of ff_null_get_*_buffer()

Message ID CAPYw7P4vpp06uS4t1JAkLiX3mxHsYQq33yOpjrxxFJ0hKJtirw@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] avfilter: add more usage of ff_null_get_*_buffer() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Paul B Mahol May 15, 2023, 9:20 p.m. UTC
Attached.
diff mbox series

Patch

From 27c37fe14f6e631e581002ef8fa942095efe0338 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Mon, 15 May 2023 22:30:07 +0200
Subject: [PATCH 3/3] avfilter: add more usage of ff_null_get_*_buffer()

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/af_aformat.c |  1 +
 libavfilter/af_anull.c   |  1 +
 libavfilter/af_astats.c  |  1 +
 libavfilter/f_loop.c     |  1 +
 libavfilter/settb.c      |  2 ++
 libavfilter/trim.c       |  1 +
 libavfilter/vf_fps.c     |  1 +
 libavfilter/vf_null.c    |  1 +
 libavfilter/vf_scale.c   | 10 ++++++++++
 libavfilter/vf_tpad.c    | 10 ++++++++++
 10 files changed, 29 insertions(+)

diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
index a14e4c1240..ce061ffc56 100644
--- a/libavfilter/af_aformat.c
+++ b/libavfilter/af_aformat.c
@@ -180,6 +180,7 @@  static const AVFilterPad avfilter_af_aformat_inputs[] = {
     {
         .name = "default",
         .type = AVMEDIA_TYPE_AUDIO,
+        .get_buffer.audio = ff_null_get_audio_buffer,
     },
 };
 
diff --git a/libavfilter/af_anull.c b/libavfilter/af_anull.c
index 78c5faeb23..d0f32bac19 100644
--- a/libavfilter/af_anull.c
+++ b/libavfilter/af_anull.c
@@ -31,6 +31,7 @@  static const AVFilterPad avfilter_af_anull_inputs[] = {
     {
         .name = "default",
         .type = AVMEDIA_TYPE_AUDIO,
+        .get_buffer.audio = ff_null_get_audio_buffer,
     },
 };
 
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index f3f2bd743b..0354a20a8b 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -833,6 +833,7 @@  static const AVFilterPad astats_inputs[] = {
         .name         = "default",
         .type         = AVMEDIA_TYPE_AUDIO,
         .filter_frame = filter_frame,
+        .get_buffer.audio = ff_null_get_audio_buffer,
     },
 };
 
diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 33b66fa534..1ad9ef84be 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -481,6 +481,7 @@  static const AVFilterPad inputs[] = {
     {
         .name = "default",
         .type = AVMEDIA_TYPE_VIDEO,
+        .get_buffer.video = ff_null_get_video_buffer,
     },
 };
 
diff --git a/libavfilter/settb.c b/libavfilter/settb.c
index 23cb02689b..7e5793b50c 100644
--- a/libavfilter/settb.c
+++ b/libavfilter/settb.c
@@ -169,6 +169,7 @@  static const AVFilterPad avfilter_vf_settb_inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
+        .get_buffer.video = ff_null_get_video_buffer,
     },
 };
 
@@ -201,6 +202,7 @@  static const AVFilterPad avfilter_af_asettb_inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_AUDIO,
+        .get_buffer.audio = ff_null_get_audio_buffer,
     },
 };
 
diff --git a/libavfilter/trim.c b/libavfilter/trim.c
index ee6e821cd2..d5181e2c49 100644
--- a/libavfilter/trim.c
+++ b/libavfilter/trim.c
@@ -195,6 +195,7 @@  static const AVFilterPad trim_inputs[] = {
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = trim_filter_frame,
         .config_props = config_input,
+        .get_buffer.video = ff_null_get_video_buffer,
     },
 };
 
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 2bfb6d29e7..65a1eecb99 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -380,6 +380,7 @@  static const AVFilterPad avfilter_vf_fps_inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
+        .get_buffer.video = ff_null_get_video_buffer,
     },
 };
 
diff --git a/libavfilter/vf_null.c b/libavfilter/vf_null.c
index fa80e2a102..7bc201595d 100644
--- a/libavfilter/vf_null.c
+++ b/libavfilter/vf_null.c
@@ -30,6 +30,7 @@  static const AVFilterPad avfilter_vf_null_inputs[] = {
     {
         .name = "default",
         .type = AVMEDIA_TYPE_VIDEO,
+        .get_buffer.video = ff_null_get_video_buffer,
     },
 };
 
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index b0221e8538..6fb8d5ca94 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -988,6 +988,15 @@  static void *child_next(void *obj, void *prev)
     return NULL;
 }
 
+static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
+{
+    ScaleContext *s = inlink->dst->priv;
+
+    return !s->sws ?
+        ff_null_get_video_buffer   (inlink, w, h) :
+        ff_default_get_video_buffer(inlink, w, h);
+}
+
 #define OFFSET(x) offsetof(ScaleContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
@@ -1053,6 +1062,7 @@  static const AVFilterPad avfilter_vf_scale_inputs[] = {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = filter_frame,
+        .get_buffer.video = get_video_buffer,
     },
 };
 
diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index f0c065f0c3..420ff9aede 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -202,11 +202,21 @@  static av_cold void uninit(AVFilterContext *ctx)
     av_frame_free(&s->cache_stop);
 }
 
+static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
+{
+    TPadContext *s = inlink->dst->priv;
+
+    return ((!s->eof && !s->pad_start) || ((s->pad_stop == 0 || s->stop_mode) && (s->pad_start == 0 || s->start_mode))) ?
+        ff_null_get_video_buffer   (inlink, w, h) :
+        ff_default_get_video_buffer(inlink, w, h);
+}
+
 static const AVFilterPad tpad_inputs[] = {
     {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .config_props = config_input,
+        .get_buffer.video = get_video_buffer,
     },
 };
 
-- 
2.39.1