aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-17 05:48:27 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-17 19:13:16 +0200
commit1aa640c7d785c39e0e19407521132d77b594e654 (patch)
treecd0e2657493e2c80f11c056b630cd3bb52674452 /libavfilter
parent90550856e5182487bdfbb0527110e4b94ac5ec0f (diff)
downloadffmpeg-1aa640c7d785c39e0e19407521132d77b594e654.tar.gz
avfilter/internal: Combine get_(audio|video)_buffer into union
These fields are mutually exclusive, so putting them in a union is possible and makes AVFilterPad smaller. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/audio.c4
-rw-r--r--libavfilter/avf_concat.c6
-rw-r--r--libavfilter/f_interleave.c4
-rw-r--r--libavfilter/internal.h20
-rw-r--r--libavfilter/vf_format.c4
-rw-r--r--libavfilter/vf_hwmap.c2
-rw-r--r--libavfilter/vf_pad.c2
-rw-r--r--libavfilter/vf_scale_cuda.c2
-rw-r--r--libavfilter/vf_swapuv.c2
-rw-r--r--libavfilter/vf_transpose.c2
-rw-r--r--libavfilter/vf_transpose_opencl.c2
-rw-r--r--libavfilter/vf_transpose_vaapi.c2
-rw-r--r--libavfilter/vf_vflip.c2
-rw-r--r--libavfilter/vf_xfade_opencl.c4
-rw-r--r--libavfilter/video.c4
15 files changed, 31 insertions, 31 deletions
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index 0deed5683b..5289b94067 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -88,8 +88,8 @@ AVFrame *ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
AVFrame *ret = NULL;
- if (link->dstpad->get_audio_buffer)
- ret = link->dstpad->get_audio_buffer(link, nb_samples);
+ if (link->dstpad->get_buffer.audio)
+ ret = link->dstpad->get_buffer.audio(link, nb_samples);
if (!ret)
ret = ff_default_get_audio_buffer(link, nb_samples);
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 333a0b090c..5f4e2f74df 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -313,9 +313,11 @@ static av_cold int init(AVFilterContext *ctx)
for (str = 0; str < cat->nb_streams[type]; str++) {
AVFilterPad pad = {
.type = type,
- .get_video_buffer = get_video_buffer,
- .get_audio_buffer = get_audio_buffer,
};
+ if (type == AVMEDIA_TYPE_VIDEO)
+ pad.get_buffer.video = get_video_buffer;
+ else
+ pad.get_buffer.audio = get_audio_buffer;
pad.name = av_asprintf("in%d:%c%d", seg, "va"[type], str);
if ((ret = ff_insert_inpad(ctx, ctx->nb_inputs, &pad)) < 0) {
av_freep(&pad.name);
diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index 259952b591..56c30a39c8 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -167,9 +167,9 @@ static av_cold int init(AVFilterContext *ctx)
switch (outpad->type) {
case AVMEDIA_TYPE_VIDEO:
- inpad.get_video_buffer = ff_null_get_video_buffer; break;
+ inpad.get_buffer.video = ff_null_get_video_buffer; break;
case AVMEDIA_TYPE_AUDIO:
- inpad.get_audio_buffer = ff_null_get_audio_buffer; break;
+ inpad.get_buffer.audio = ff_null_get_audio_buffer; break;
default:
av_assert0(0);
}
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index c2be4a18fc..69c45b2073 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -61,20 +61,18 @@ struct AVFilterPad {
enum AVMediaType type;
/**
- * Callback function to get a video buffer. If NULL, the filter system will
- * use ff_default_get_video_buffer().
+ * Callback functions to get a video/audio buffers. If NULL,
+ * the filter system will use ff_default_get_video_buffer() for video
+ * and ff_default_get_audio_buffer() for audio.
*
- * Input video pads only.
- */
- AVFrame *(*get_video_buffer)(AVFilterLink *link, int w, int h);
-
- /**
- * Callback function to get an audio buffer. If NULL, the filter system will
- * use ff_default_get_audio_buffer().
+ * The state of the union is determined by type.
*
- * Input audio pads only.
+ * Input pads only.
*/
- AVFrame *(*get_audio_buffer)(AVFilterLink *link, int nb_samples);
+ union {
+ AVFrame *(*video)(AVFilterLink *link, int w, int h);
+ AVFrame *(*audio)(AVFilterLink *link, int nb_samples);
+ } get_buffer;
/**
* Filtering callback. This is where a filter receives a frame with
diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index 6c5475b84a..0128a94e06 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -149,7 +149,7 @@ static const AVFilterPad avfilter_vf_format_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = ff_null_get_video_buffer,
+ .get_buffer.video = ff_null_get_video_buffer,
},
{ NULL }
};
@@ -188,7 +188,7 @@ static const AVFilterPad avfilter_vf_noformat_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = ff_null_get_video_buffer,
+ .get_buffer.video = ff_null_get_video_buffer,
},
{ NULL }
};
diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c
index d829b47b44..2bcce15f6a 100644
--- a/libavfilter/vf_hwmap.c
+++ b/libavfilter/vf_hwmap.c
@@ -404,7 +404,7 @@ static const AVFilterPad hwmap_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = hwmap_get_buffer,
+ .get_buffer.video = hwmap_get_buffer,
.filter_frame = hwmap_filter_frame,
},
{ NULL }
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 871f2930af..9e76bed4a1 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -438,7 +438,7 @@ static const AVFilterPad avfilter_vf_pad_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_input,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.filter_frame = filter_frame,
},
{ NULL }
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index ecb3d62256..16f345402d 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -623,7 +623,7 @@ static const AVFilterPad cudascale_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = cudascale_filter_frame,
- .get_video_buffer = cudascale_get_video_buffer,
+ .get_buffer.video = cudascale_get_video_buffer,
},
{ NULL }
};
diff --git a/libavfilter/vf_swapuv.c b/libavfilter/vf_swapuv.c
index 34868eb0c9..d0c869b13c 100644
--- a/libavfilter/vf_swapuv.c
+++ b/libavfilter/vf_swapuv.c
@@ -97,7 +97,7 @@ static const AVFilterPad swapuv_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.filter_frame = filter_frame,
},
{ NULL }
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 5c551ce823..ed4b25cb60 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -383,7 +383,7 @@ static const AVFilterPad avfilter_vf_transpose_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.filter_frame = filter_frame,
},
{ NULL }
diff --git a/libavfilter/vf_transpose_opencl.c b/libavfilter/vf_transpose_opencl.c
index 2877d3c826..17c237ffd3 100644
--- a/libavfilter/vf_transpose_opencl.c
+++ b/libavfilter/vf_transpose_opencl.c
@@ -256,7 +256,7 @@ static const AVFilterPad transpose_opencl_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.filter_frame = &transpose_opencl_filter_frame,
.config_props = &ff_opencl_filter_config_input,
},
diff --git a/libavfilter/vf_transpose_vaapi.c b/libavfilter/vf_transpose_vaapi.c
index 79413e0eeb..0d11c6b674 100644
--- a/libavfilter/vf_transpose_vaapi.c
+++ b/libavfilter/vf_transpose_vaapi.c
@@ -257,7 +257,7 @@ static const AVFilterPad transpose_vaapi_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = &transpose_vaapi_filter_frame,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.config_props = &ff_vaapi_vpp_config_input,
},
{ NULL }
diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c
index 95a693a7e1..c590e84763 100644
--- a/libavfilter/vf_vflip.c
+++ b/libavfilter/vf_vflip.c
@@ -129,7 +129,7 @@ static const AVFilterPad avfilter_vf_vflip_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.filter_frame = filter_frame,
.config_props = config_input,
},
diff --git a/libavfilter/vf_xfade_opencl.c b/libavfilter/vf_xfade_opencl.c
index 5b64ea2f08..684d067d48 100644
--- a/libavfilter/vf_xfade_opencl.c
+++ b/libavfilter/vf_xfade_opencl.c
@@ -402,13 +402,13 @@ static const AVFilterPad xfade_opencl_inputs[] = {
{
.name = "main",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.config_props = &ff_opencl_filter_config_input,
},
{
.name = "xfade",
.type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = get_video_buffer,
+ .get_buffer.video = get_video_buffer,
.config_props = &ff_opencl_filter_config_input,
},
{ NULL }
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 810cc87f52..7ef04144e4 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -101,8 +101,8 @@ AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h)
FF_TPRINTF_START(NULL, get_video_buffer); ff_tlog_link(NULL, link, 0);
- if (link->dstpad->get_video_buffer)
- ret = link->dstpad->get_video_buffer(link, w, h);
+ if (link->dstpad->get_buffer.video)
+ ret = link->dstpad->get_buffer.video(link, w, h);
if (!ret)
ret = ff_default_get_video_buffer(link, w, h);