[FFmpeg-cvslog] Merge commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d'

Mark Thompson git at videolan.org
Tue Feb 13 00:28:47 EET 2018


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Mon Feb 12 22:28:12 2018 +0000| [bcab11a1a23d8b156198db352bbdb932740a966c] | committer: Mark Thompson

Merge commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d'

* commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d':
  lavfi: Add support for increasing hardware frame pool sizes

Merged-by: Mark Thompson <sw at jkqxz.net>

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

 doc/APIchanges         |  3 +++
 libavfilter/avfilter.c | 23 +++++++++++++++++++++++
 libavfilter/avfilter.h | 16 ++++++++++++++++
 libavfilter/internal.h | 16 ++++++++++++++++
 libavfilter/version.h  |  4 ++--
 5 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index e5c392ead5..8565cbeb09 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-02-xx - xxxxxxx - lavfi 7.12.100 - avfilter.h
+  Add AVFilterContext.extra_hw_frames.
+
 2018-02-xx - xxxxxxx - lavc 58.11.100 - avcodec.h
   Add AVCodecContext.extra_hw_frames.
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index ea75467a75..7553f7c36a 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -676,6 +676,8 @@ static const AVOption avfilter_options[] = {
     { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
     { "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
         { .i64 = 0 }, 0, INT_MAX, FLAGS },
+    { "extra_hw_frames", "Number of extra hardware frames to allocate for the user",
+        OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
     { NULL },
 };
 
@@ -1663,3 +1665,24 @@ const AVClass *avfilter_get_class(void)
 {
     return &avfilter_class;
 }
+
+int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
+                             int default_pool_size)
+{
+    AVHWFramesContext *frames;
+
+    // Must already be set by caller.
+    av_assert0(link->hw_frames_ctx);
+
+    frames = (AVHWFramesContext*)link->hw_frames_ctx->data;
+
+    if (frames->initial_pool_size == 0) {
+        // Dynamic allocation is necessarily supported.
+    } else if (avctx->extra_hw_frames >= 0) {
+        frames->initial_pool_size += avctx->extra_hw_frames;
+    } else {
+        frames->initial_pool_size = default_pool_size;
+    }
+
+    return 0;
+}
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 62eed2168f..2d1195eeeb 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -406,6 +406,22 @@ struct AVFilterContext {
      * a higher value suggests a more urgent activation.
      */
     unsigned ready;
+
+    /**
+     * Sets the number of extra hardware frames which the filter will
+     * allocate on its output links for use in following filters or by
+     * the caller.
+     *
+     * Some hardware filters require all frames that they will use for
+     * output to be defined in advance before filtering starts.  For such
+     * filters, any hardware frame pools used for output must therefore be
+     * of fixed size.  The extra frames set here are on top of any number
+     * that the filter needs internally in order to operate normally.
+     *
+     * This field must be set before the graph containing this filter is
+     * configured.
+     */
+    int extra_hw_frames;
 };
 
 /**
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index f9679ed1d7..498bd3328d 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -411,4 +411,20 @@ static inline int ff_norm_qscale(int qscale, int type)
  */
 int ff_filter_get_nb_threads(AVFilterContext *ctx);
 
+/**
+ * Perform any additional setup required for hardware frames.
+ *
+ * link->hw_frames_ctx must be set before calling this function.
+ * Inside link->hw_frames_ctx, the fields format, sw_format, width and
+ * height must be set.  If dynamically allocated pools are not supported,
+ * then initial_pool_size must also be set, to the minimum hardware frame
+ * pool size necessary for the filter to work (taking into account any
+ * frames which need to stored for use in operations as appropriate).  If
+ * default_pool_size is nonzero, then it will be used as the pool size if
+ * no other modification takes place (this can be used to preserve
+ * compatibility).
+ */
+int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
+                             int default_pool_size);
+
 #endif /* AVFILTER_INTERNAL_H */
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 0f11721822..ca096962bb 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,8 +30,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  11
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MINOR  12
+#define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \


======================================================================

diff --cc doc/APIchanges
index e5c392ead5,d385d73b0c..8565cbeb09
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@@ -15,92 -13,16 +15,95 @@@ libavutil:     2017-10-2
  
  API changes, most recent first:
  
 -2018-02-xx - xxxxxxx - lavfi 7.1.0 - avfilter.h
++2018-02-xx - xxxxxxx - lavfi 7.12.100 - avfilter.h
+   Add AVFilterContext.extra_hw_frames.
+ 
 -2018-02-xx - xxxxxxx - lavc 58.9.0 - avcodec.h
 +2018-02-xx - xxxxxxx - lavc 58.11.100 - avcodec.h
    Add AVCodecContext.extra_hw_frames.
  
 -2017-xx-xx - xxxxxxx - lavc 58.8.0 - avcodec.h
 +2018-02-06 - 0fd475704e - lavd 58.1.100 - avdevice.h
 +  Deprecate use of av_input_audio_device_next(), av_input_video_device_next(),
 +  av_output_audio_device_next(), av_output_video_device_next().
 +  Add av_indev_iterate(), and av_outdev_iterate().
 +
 +2018-xx-xx - xxxxxxx - lavf 58.9.100 - avformat.h
 +  Deprecate use of av_register_input_format(), av_register_output_format(),
 +  av_register_all(), av_iformat_next(), av_oformat_next().
 +  Add av_demuxer_iterate(), and av_muxer_iterate().
 +
 +2018-xx-xx - xxxxxxx - lavc 58.10.100 - avcodec.h
 +  Deprecate use of avcodec_register(), avcodec_register_all(),
 +  av_codec_next(), av_register_codec_parser(), and av_parser_next().
 +  Add av_codec_iterate() and av_parser_iterate().
 +
 +2018-02-xx - xxxxxxx - lavf 58.8.100 - avformat.h
 +  Deprecate the current names of the RTSP "timeout", "stimeout", "user-agent"
 +  options. Introduce "listen_timeout" as replacement for the current "timeout"
 +  option, and "user_agent" as replacement for "user-agent". Once the deprecation
 +  is over, the old "timeout" option will be removed, and "stimeout" will be
 +  renamed to "stimeout" (the "timeout" option will essentially change semantics).
 +
 +2018-01-xx - xxxxxxx - lavf 58.7.100 - avformat.h
 +  Deprecate AVFormatContext filename field which had limited length, use the
 +  new dynamically allocated url field instead.
 +
 +2018-01-xx - xxxxxxx - lavf 58.7.100 - avformat.h
 +  Add url field to AVFormatContext and add ff_format_set_url helper function.
 +
 +2018-01-xx - xxxxxxx - lavf 58.6.100 - avformat.h
 +  Add AVFMTCTX_UNSEEKABLE (for HLS demuxer).
 +
 +2018-xx-xx - xxxxxxx - lavu 56.9.100 - aes_ctr.h
 +  Add method to set the 16-byte IV.
 +
 +2018-01-xx - xxxxxxx - lavf 58.5.100 - avformat.h
 +  Explicitly make avformat_network_init() and avformat_network_deinit() optional.
 +  If these are not called, network initialization and deinitialization is
 +  automatic, and unlike in older versions, fully supported, unless libavformat
 +  is linked to ancient GnuTLS and OpenSSL.
 +
 +2018-01-xx - xxxxxxx - lavf 58.4.100 - avformat.h
 +  Deprecate AVStream.recommended_encoder_configuration. It was useful only for
 +  FFserver, which has been removed.
 +
 +2018-01-xx - xxxxxxx - lavfi 7.11.101 - avfilter.h
 +  Deprecate avfilter_link_get_channels(). Use av_buffersink_get_channels().
 +
 +2017-xx-xx - xxxxxxx - lavr 4.0.0 - avresample.h
 +  Deprecate the entire library. Merged years ago to provide compatibility
 +  with Libav, it remained unmaintained by the FFmpeg project and duplicated
 +  functionality provided by libswresample.
 +
 +  In order to improve consistency and reduce attack surface, it has been deprecated.
 +  Users of this library are asked to migrate to libswresample, which, as well as
 +  providing more functionality, is faster and has higher accuracy.
 +
 +2017-xx-xx - xxxxxxx - lavc 58.9.100 - avcodec.h
 +  Deprecate av_lockmgr_register(). You need to build FFmpeg with threading
 +  support enabled to get basic thread-safety (which is the default build
 +  configuration).
 +
 +2017-12-xx - xxxxxxx - lavu 56.7.100 - cpu.h
 +  AVX-512 flags added.
 +
 +2017-xx-xx - xxxxxxx - lavc 58.8.100 - avcodec.h
 +  The MediaCodec decoders now support AVCodecContext.hw_device_ctx.
 +
 +2017-xx-xx - xxxxxxx - lavu 56.6.100 - hwcontext.h hwcontext_mediacodec.h
 +  Add AV_HWDEVICE_TYPE_MEDIACODEC and a new installed header with
 +  MediaCodec-specific hwcontext definitions.
 +
 +2017-xx-xx - xxxxxxc - lavc 58.7.100 - avcodec.h
 +  Add AV_CODEC_CAP_HARDWARE, AV_CODEC_CAP_HYBRID, and AVCodec.wrapper_name,
 +  and mark all AVCodecs accordingly.
 +
 +2017-xx-xx - xxxxxxx - lavu 56.4.100 / 56.7.0 - stereo3d.h
 +  Add view field to AVStereo3D structure and AVStereo3DView enum.
 +
 +2017-xx-xx - xxxxxxx - lavc 58.6.100 - avcodec.h
    Add const to AVCodecContext.hwaccel.
  
 -2017-xx-xx - xxxxxxx - lavc 58.7.0 - avcodec.h
 +2017-11-xx - xxxxxxx - lavc 58.5.100 - avcodec.h
    Deprecate user visibility of the AVHWAccel structure and the functions
    av_register_hwaccel() and av_hwaccel_next().
  
diff --cc libavfilter/avfilter.c
index ea75467a75,2c4a385ea9..7553f7c36a
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@@ -673,9 -368,8 +673,11 @@@ static const AVOption avfilter_options[
      { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
          { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" },
          { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .unit = "thread_type" },
 +    { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
 +    { "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
 +        { .i64 = 0 }, 0, INT_MAX, FLAGS },
+     { "extra_hw_frames", "Number of extra hardware frames to allocate for the user",
+         OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
      { NULL },
  };
  
diff --cc libavfilter/avfilter.h
index 62eed2168f,46dbadfcdc..2d1195eeeb
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@@ -394,18 -313,20 +394,34 @@@ struct AVFilterContext 
      AVBufferRef *hw_device_ctx;
  
      /**
 +     * Max number of threads allowed in this filter instance.
 +     * If <= 0, its value is ignored.
 +     * Overrides global number of threads set per filter graph.
 +     */
 +    int nb_threads;
 +
 +    /**
 +     * Ready status of the filter.
 +     * A non-0 value means that the filter needs activating;
 +     * a higher value suggests a more urgent activation.
 +     */
 +    unsigned ready;
++
++    /**
+      * Sets the number of extra hardware frames which the filter will
+      * allocate on its output links for use in following filters or by
+      * the caller.
+      *
+      * Some hardware filters require all frames that they will use for
+      * output to be defined in advance before filtering starts.  For such
+      * filters, any hardware frame pools used for output must therefore be
+      * of fixed size.  The extra frames set here are on top of any number
+      * that the filter needs internally in order to operate normally.
+      *
+      * This field must be set before the graph containing this filter is
+      * configured.
+      */
+     int extra_hw_frames;
  };
  
  /**
diff --cc libavfilter/internal.h
index f9679ed1d7,dd021e00a1..498bd3328d
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@@ -385,30 -227,20 +385,46 @@@ void ff_filter_graph_remove_filter(AVFi
  #define FF_FILTER_FLAG_HWFRAME_AWARE (1 << 0)
  
  /**
 + * Run one round of processing on a filter graph.
 + */
 +int ff_filter_graph_run_once(AVFilterGraph *graph);
 +
 +/**
 + * Normalize the qscale factor
 + * FIXME the H264 qscale is a log based scale, mpeg1/2 is not, the code below
 + *       cannot be optimal
 + */
 +static inline int ff_norm_qscale(int qscale, int type)
 +{
 +    switch (type) {
 +    case FF_QSCALE_TYPE_MPEG1: return qscale;
 +    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
 +    case FF_QSCALE_TYPE_H264:  return qscale >> 2;
 +    case FF_QSCALE_TYPE_VP56:  return (63 - qscale + 2) >> 2;
 +    }
 +    return qscale;
 +}
 +
 +/**
 + * Get number of threads for current filter instance.
 + * This number is always same or less than graph->nb_threads.
 + */
 +int ff_filter_get_nb_threads(AVFilterContext *ctx);
 +
++/**
+  * Perform any additional setup required for hardware frames.
+  *
+  * link->hw_frames_ctx must be set before calling this function.
+  * Inside link->hw_frames_ctx, the fields format, sw_format, width and
+  * height must be set.  If dynamically allocated pools are not supported,
+  * then initial_pool_size must also be set, to the minimum hardware frame
+  * pool size necessary for the filter to work (taking into account any
+  * frames which need to stored for use in operations as appropriate).  If
+  * default_pool_size is nonzero, then it will be used as the pool size if
+  * no other modification takes place (this can be used to preserve
+  * compatibility).
+  */
+ int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
+                              int default_pool_size);
+ 
 -
  #endif /* AVFILTER_INTERNAL_H */
diff --cc libavfilter/version.h
index 0f11721822,00e9bf7a99..ca096962bb
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@@ -29,9 -29,9 +29,9 @@@
  
  #include "libavutil/version.h"
  
 -#define LIBAVFILTER_VERSION_MAJOR  7
 -#define LIBAVFILTER_VERSION_MINOR  1
 -#define LIBAVFILTER_VERSION_MICRO  0
 +#define LIBAVFILTER_VERSION_MAJOR   7
- #define LIBAVFILTER_VERSION_MINOR  11
- #define LIBAVFILTER_VERSION_MICRO 101
++#define LIBAVFILTER_VERSION_MINOR  12
++#define LIBAVFILTER_VERSION_MICRO 100
  
  #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                 LIBAVFILTER_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list