[FFmpeg-devel] [PATCH] lavfi/buffersink: deprecate non-AVOption init.

Nicolas George george at nsup.org
Tue Sep 12 12:40:55 EEST 2017


Signed-off-by: Nicolas George <george at nsup.org>
---
 doc/APIchanges           |  3 +++
 libavfilter/buffersink.c | 10 ++++++++++
 libavfilter/buffersink.h | 12 ++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index cc67cbf6f8..be136ca11e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-09-12 - xxxxxxx - lavfi 6.XXX.100 - buffersink.h
+  Deprecate non-AVOption init of buffersink.
+
 2017-09-08 - xxxxxxx - lavfi 6.103.100 - buffersrc.h
   Add av_buffersrc_close().
 
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index 0f87b5439a..0d5380c681 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -127,6 +127,8 @@ int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx,
     return get_frame_internal(ctx, frame, 0, nb_samples);
 }
 
+FF_DISABLE_DEPRECATION_WARNINGS
+
 AVBufferSinkParams *av_buffersink_params_alloc(void)
 {
     static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
@@ -147,6 +149,8 @@ AVABufferSinkParams *av_abuffersink_params_alloc(void)
     return params;
 }
 
+FF_ENABLE_DEPRECATION_WARNINGS
+
 static av_cold int common_init(AVFilterContext *ctx)
 {
     BufferSinkContext *buf = ctx->priv;
@@ -201,6 +205,7 @@ MAKE_AVFILTERLINK_ACCESSOR(int              , sample_rate        )
 
 MAKE_AVFILTERLINK_ACCESSOR(AVBufferRef *    , hw_frames_ctx      )
 
+FF_DISABLE_DEPRECATION_WARNINGS
 static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
 {
     BufferSinkContext *buf = ctx->priv;
@@ -208,12 +213,14 @@ static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
     int ret;
 
     if (params) {
+        av_log(ctx, AV_LOG_WARNING, "non-AVOption init of buffersink is deprecated\n");
         if ((ret = av_opt_set_int_list(buf, "pix_fmts", params->pixel_fmts, AV_PIX_FMT_NONE, 0)) < 0)
             return ret;
     }
 
     return common_init(ctx);
 }
+FF_ENABLE_DEPRECATION_WARNINGS
 
 #define CHECK_LIST_SIZE(field) \
         if (buf->field ## _size % sizeof(*buf->field)) { \
@@ -244,6 +251,7 @@ static int vsink_query_formats(AVFilterContext *ctx)
     return 0;
 }
 
+FF_DISABLE_DEPRECATION_WARNINGS
 static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
 {
     BufferSinkContext *buf = ctx->priv;
@@ -251,6 +259,7 @@ static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
     int ret;
 
     if (params) {
+        av_log(ctx, AV_LOG_WARNING, "non-AVOption init of abuffersink is deprecated\n");
         if ((ret = av_opt_set_int_list(buf, "sample_fmts",     params->sample_fmts,  AV_SAMPLE_FMT_NONE, 0)) < 0 ||
             (ret = av_opt_set_int_list(buf, "sample_rates",    params->sample_rates,    -1, 0)) < 0 ||
             (ret = av_opt_set_int_list(buf, "channel_layouts", params->channel_layouts, -1, 0)) < 0 ||
@@ -260,6 +269,7 @@ static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
     }
     return common_init(ctx);
 }
+FF_ENABLE_DEPRECATION_WARNINGS
 
 static int asink_query_formats(AVFilterContext *ctx)
 {
diff --git a/libavfilter/buffersink.h b/libavfilter/buffersink.h
index 21d6bb505b..d607bca631 100644
--- a/libavfilter/buffersink.h
+++ b/libavfilter/buffersink.h
@@ -61,8 +61,10 @@ int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flag
 
 /**
  * Struct to use for initializing a buffersink context.
+ *
+ * @deprecated Use av_opt_set() on the newly created filter.
  */
-typedef struct AVBufferSinkParams {
+attribute_deprecated typedef struct AVBufferSinkParams {
     const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
 } AVBufferSinkParams;
 
@@ -71,12 +73,14 @@ typedef struct AVBufferSinkParams {
  *
  * Must be freed with av_free().
  */
-AVBufferSinkParams *av_buffersink_params_alloc(void);
+attribute_deprecated AVBufferSinkParams *av_buffersink_params_alloc(void);
 
 /**
  * Struct to use for initializing an abuffersink context.
+ *
+ * @deprecated Use av_opt_set() on the newly created filter.
  */
-typedef struct AVABufferSinkParams {
+attribute_deprecated typedef struct AVABufferSinkParams {
     const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
     const int64_t *channel_layouts;         ///< list of allowed channel layouts, terminated by -1
     const int *channel_counts;              ///< list of allowed channel counts, terminated by -1
@@ -89,7 +93,7 @@ typedef struct AVABufferSinkParams {
  *
  * Must be freed with av_free().
  */
-AVABufferSinkParams *av_abuffersink_params_alloc(void);
+attribute_deprecated AVABufferSinkParams *av_abuffersink_params_alloc(void);
 
 /**
  * Set the frame size for an audio buffer sink.
-- 
2.14.1



More information about the ffmpeg-devel mailing list