[FFmpeg-devel] [PATCH 1/8] avfilter/avfilter: add a side_data field to AVFilterLink
James Almer
jamrial at gmail.com
Fri Jan 10 20:34:52 EET 2025
This will be used to propagate global side data through the filterchain.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavfilter/avfilter.c | 16 +++++++++++++++-
libavfilter/avfilter.h | 3 +++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 235c9ea14a..02779453b5 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -206,6 +206,7 @@ static void link_free(AVFilterLink **link)
ff_framequeue_free(&li->fifo);
ff_frame_pool_uninit(&li->frame_pool);
av_channel_layout_uninit(&(*link)->ch_layout);
+ av_frame_side_data_free(&(*link)->side_data, &(*link)->nb_side_data);
av_buffer_unref(&li->l.hw_frames_ctx);
@@ -376,7 +377,20 @@ int ff_filter_config_links(AVFilterContext *filter)
"callbacks on all outputs\n");
return AVERROR(EINVAL);
}
- } else if ((ret = config_link(link)) < 0) {
+ }
+
+ if (inlink && inlink->nb_side_data && !link->nb_side_data) {
+ for (i = 0; i < inlink->nb_side_data; i++) {
+ ret = av_frame_side_data_clone(&link->side_data, &link->nb_side_data,
+ inlink->side_data[i], 0);
+ if (ret < 0) {
+ av_frame_side_data_free(&link->side_data, &link->nb_side_data);
+ return ret;
+ }
+ }
+ }
+
+ if (config_link && (ret = config_link(link)) < 0) {
av_log(link->src, AV_LOG_ERROR,
"Failed to configure output pad on %s\n",
link->src->name);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index b88b31a834..9b8d75c68b 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -613,6 +613,9 @@ struct AVFilterLink {
*/
AVRational time_base;
+ AVFrameSideData **side_data;
+ int nb_side_data;
+
/*****************************************************************
* All fields below this line are not part of the public API. They
* may not be used outside of libavfilter and can be changed and
--
2.47.1
More information about the ffmpeg-devel
mailing list