[FFmpeg-cvslog] avfilter/avfilter: add a side_data field to AVFilterLink

James Almer git at videolan.org
Sun Jan 26 02:57:02 EET 2025


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Mar 25 09:27:21 2024 -0300| [ef1cb1c9c810b30c5c9356c07eef07dc8edc3aea] | committer: James Almer

avfilter/avfilter: add a side_data field to AVFilterLink

This will be used to propagate global side data through the filterchain.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef1cb1c9c810b30c5c9356c07eef07dc8edc3aea
---

 doc/APIchanges         |  3 +++
 libavfilter/avfilter.c | 18 +++++++++++++++++-
 libavfilter/avfilter.h |  3 +++
 libavfilter/version.h  |  4 ++--
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0104eefe6a..ded81cb68d 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2025-01-25 - xxxxxxxxxx - lavfi 10.7.100 - avfilter.h
+  Add AVFilterLink.side_data and AVFilterLink.nb_side_data
+
 2025-01-05 - xxxxxxxxxx - lavc 59.55.100 - frame.h
   Add AV_FRAME_SIDE_DATA_FLAG_NEW_REF.
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index fbce8d8a83..89b39445e6 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,22 @@ int ff_filter_config_links(AVFilterContext *filter)
                                                     "callbacks on all outputs\n");
                     return AVERROR(EINVAL);
                 }
-            } else if ((ret = config_link(link)) < 0) {
+            }
+
+            /* Copy side data before link->srcpad->config_props() is called, so the filter
+             * may remove it for the next filter in the chain */
+            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 9f349b1b45..4520d5f978 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -413,6 +413,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
diff --git a/libavfilter/version.h b/libavfilter/version.h
index f84dec4805..0050874108 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,8 +31,8 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR   6
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MINOR   7
+#define LIBAVFILTER_VERSION_MICRO 100
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list