Merge commit 'f6974fe651d29ef6eb68d66d73f7b6c011062aa0'
authorHendrik Leppkes <h.leppkes@gmail.com>
Sat, 5 Sep 2015 14:22:03 +0000 (16:22 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Sat, 5 Sep 2015 14:22:03 +0000 (16:22 +0200)
* commit 'f6974fe651d29ef6eb68d66d73f7b6c011062aa0':
  lavfi: Drop deprecated AVFilterBuffer* code

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
1  2 
libavfilter/Makefile
libavfilter/audio.c
libavfilter/avfilter.h
libavfilter/buffersink.c
libavfilter/buffersink.h
libavfilter/buffersrc.c
libavfilter/buffersrc.h
libavfilter/internal.h
libavfilter/version.h
libavfilter/video.c

Simple merge
Simple merge
@@@ -742,78 -397,6 +566,15 @@@ void avfilter_link_set_closed(AVFilterL
   */
  int avfilter_config_links(AVFilterContext *filter);
  
- #if FF_API_AVFILTERBUFFER
- /**
-  * Create a buffer reference wrapped around an already allocated image
-  * buffer.
-  *
-  * @param data pointers to the planes of the image to reference
-  * @param linesize linesizes for the planes of the image to reference
-  * @param perms the required access permissions
-  * @param w the width of the image specified by the data and linesize arrays
-  * @param h the height of the image specified by the data and linesize arrays
-  * @param format the pixel format of the image specified by the data and linesize arrays
-  */
- attribute_deprecated
- AVFilterBufferRef *
- avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
-                                           int w, int h, enum AVPixelFormat format);
- /**
-  * Create an audio buffer reference wrapped around an already
-  * allocated samples buffer.
-  *
-  * See avfilter_get_audio_buffer_ref_from_arrays_channels() for a version
-  * that can handle unknown channel layouts.
-  *
-  * @param data           pointers to the samples plane buffers
-  * @param linesize       linesize for the samples plane buffers
-  * @param perms          the required access permissions
-  * @param nb_samples     number of samples per channel
-  * @param sample_fmt     the format of each sample in the buffer to allocate
-  * @param channel_layout the channel layout of the buffer
-  */
- attribute_deprecated
- AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
-                                                              int linesize,
-                                                              int perms,
-                                                              int nb_samples,
-                                                              enum AVSampleFormat sample_fmt,
-                                                              uint64_t channel_layout);
- /**
-  * Create an audio buffer reference wrapped around an already
-  * allocated samples buffer.
-  *
-  * @param data           pointers to the samples plane buffers
-  * @param linesize       linesize for the samples plane buffers
-  * @param perms          the required access permissions
-  * @param nb_samples     number of samples per channel
-  * @param sample_fmt     the format of each sample in the buffer to allocate
-  * @param channels       the number of channels of the buffer
-  * @param channel_layout the channel layout of the buffer,
-  *                       must be either 0 or consistent with channels
-  */
- attribute_deprecated
- AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data,
-                                                                       int linesize,
-                                                                       int perms,
-                                                                       int nb_samples,
-                                                                       enum AVSampleFormat sample_fmt,
-                                                                       int channels,
-                                                                       uint64_t channel_layout);
- #endif
 +#define AVFILTER_CMD_FLAG_ONE   1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
 +#define AVFILTER_CMD_FLAG_FAST  2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
 +
 +/**
 + * Make the filter instance process a command.
 + * It is recommended to use avfilter_graph_send_command().
 + */
 +int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
 +
  /** Initialize the filter system. Register all builtin filters. */
  void avfilter_register_all(void);
  
@@@ -224,351 -137,6 +224,194 @@@ int attribute_align_arg av_buffersink_g
      return ret;
  }
  
- #if FF_API_AVFILTERBUFFER
- FF_DISABLE_DEPRECATION_WARNINGS
- static void compat_free_buffer(AVFilterBuffer *buf)
- {
-     AVFrame *frame = buf->priv;
-     av_frame_free(&frame);
-     av_free(buf);
- }
- static int compat_read(AVFilterContext *ctx,
-                        AVFilterBufferRef **pbuf, int nb_samples, int flags)
- {
-     AVFilterBufferRef *buf;
-     AVFrame *frame;
-     int ret;
-     if (!pbuf)
-         return ff_poll_frame(ctx->inputs[0]);
-     frame = av_frame_alloc();
-     if (!frame)
-         return AVERROR(ENOMEM);
-     if (!nb_samples)
-         ret = av_buffersink_get_frame_flags(ctx, frame, flags);
-     else
-         ret = av_buffersink_get_samples(ctx, frame, nb_samples);
-     if (ret < 0)
-         goto fail;
-     AV_NOWARN_DEPRECATED(
-     if (ctx->inputs[0]->type == AVMEDIA_TYPE_VIDEO) {
-         buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,
-                                                         AV_PERM_READ,
-                                                         frame->width, frame->height,
-                                                         frame->format);
-     } else {
-         buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,
-                                                         frame->linesize[0], AV_PERM_READ,
-                                                         frame->nb_samples,
-                                                         frame->format,
-                                                         frame->channel_layout);
-     }
-     if (!buf) {
-         ret = AVERROR(ENOMEM);
-         goto fail;
-     }
-     avfilter_copy_frame_props(buf, frame);
-     )
-     buf->buf->priv = frame;
-     buf->buf->free = compat_free_buffer;
-     *pbuf = buf;
-     return 0;
- fail:
-     av_frame_free(&frame);
-     return ret;
- }
- int attribute_align_arg av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf)
- {
-     return compat_read(ctx, buf, 0, 0);
- }
- int attribute_align_arg av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf,
-                                                    int nb_samples)
- {
-     return compat_read(ctx, buf, nb_samples, 0);
- }
- int attribute_align_arg av_buffersink_get_buffer_ref(AVFilterContext *ctx,
-                                                      AVFilterBufferRef **bufref, int flags)
- {
-     *bufref = NULL;
-     av_assert0(    !strcmp(ctx->filter->name, "buffersink")
-                 || !strcmp(ctx->filter->name, "abuffersink")
-                 || !strcmp(ctx->filter->name, "ffbuffersink")
-                 || !strcmp(ctx->filter->name, "ffabuffersink"));
-     return compat_read(ctx, bufref, 0, flags);
- }
- FF_ENABLE_DEPRECATION_WARNINGS
- #endif
 +AVBufferSinkParams *av_buffersink_params_alloc(void)
 +{
 +    static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
 +    AVBufferSinkParams *params = av_malloc(sizeof(AVBufferSinkParams));
 +    if (!params)
 +        return NULL;
 +
 +    params->pixel_fmts = pixel_fmts;
 +    return params;
 +}
 +
 +AVABufferSinkParams *av_abuffersink_params_alloc(void)
 +{
 +    AVABufferSinkParams *params = av_mallocz(sizeof(AVABufferSinkParams));
 +
 +    if (!params)
 +        return NULL;
 +    return params;
 +}
 +
 +static av_cold int common_init(AVFilterContext *ctx)
 +{
 +    BufferSinkContext *buf = ctx->priv;
 +
 +    buf->fifo = av_fifo_alloc_array(FIFO_INIT_SIZE, FIFO_INIT_ELEMENT_SIZE);
 +    if (!buf->fifo) {
 +        av_log(ctx, AV_LOG_ERROR, "Failed to allocate fifo\n");
 +        return AVERROR(ENOMEM);
 +    }
 +    buf->warning_limit = 100;
 +    buf->next_pts = AV_NOPTS_VALUE;
 +    return 0;
 +}
 +
 +void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
 +{
 +    AVFilterLink *inlink = ctx->inputs[0];
 +
 +    inlink->min_samples = inlink->max_samples =
 +    inlink->partial_buf_size = frame_size;
 +}
 +
- #if FF_API_AVFILTERBUFFER
- FF_DISABLE_DEPRECATION_WARNINGS
- int attribute_align_arg av_buffersink_poll_frame(AVFilterContext *ctx)
- {
-     BufferSinkContext *buf = ctx->priv;
-     AVFilterLink *inlink = ctx->inputs[0];
-     av_assert0(   !strcmp(ctx->filter->name, "buffersink")
-                || !strcmp(ctx->filter->name, "abuffersink")
-                || !strcmp(ctx->filter->name, "ffbuffersink")
-                || !strcmp(ctx->filter->name, "ffabuffersink"));
-     return av_fifo_size(buf->fifo)/FIFO_INIT_ELEMENT_SIZE + ff_poll_frame(inlink);
- }
- FF_ENABLE_DEPRECATION_WARNINGS
- #endif
 +AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
 +{
 +    av_assert0(   !strcmp(ctx->filter->name, "buffersink")
 +               || !strcmp(ctx->filter->name, "ffbuffersink"));
 +
 +    return ctx->inputs[0]->frame_rate;
 +}
 +
- #if FF_API_AVFILTERBUFFER
- #define ffbuffersink_options buffersink_options
- #define ffabuffersink_options abuffersink_options
- AVFILTER_DEFINE_CLASS(ffbuffersink);
- AVFILTER_DEFINE_CLASS(ffabuffersink);
- static const AVFilterPad ffbuffersink_inputs[] = {
-     {
-         .name      = "default",
-         .type      = AVMEDIA_TYPE_VIDEO,
-         .filter_frame = filter_frame,
-     },
-     { NULL },
- };
- AVFilter ff_vsink_ffbuffersink = {
-     .name      = "ffbuffersink",
-     .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
-     .priv_size = sizeof(BufferSinkContext),
-     .priv_class = &ffbuffersink_class,
-     .init_opaque = vsink_init,
-     .uninit    = uninit,
-     .query_formats = vsink_query_formats,
-     .inputs        = ffbuffersink_inputs,
-     .outputs       = NULL,
- };
- static const AVFilterPad ffabuffersink_inputs[] = {
-     {
-         .name           = "default",
-         .type           = AVMEDIA_TYPE_AUDIO,
-         .filter_frame   = filter_frame,
-     },
-     { NULL },
- };
- AVFilter ff_asink_ffabuffersink = {
-     .name      = "ffabuffersink",
-     .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
-     .init_opaque = asink_init,
-     .uninit    = uninit,
-     .priv_size = sizeof(BufferSinkContext),
-     .priv_class = &ffabuffersink_class,
-     .query_formats = asink_query_formats,
-     .inputs        = ffabuffersink_inputs,
-     .outputs       = NULL,
- };
- #endif /* FF_API_AVFILTERBUFFER */
 +static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
 +{
 +    BufferSinkContext *buf = ctx->priv;
 +    AVBufferSinkParams *params = opaque;
 +    int ret;
 +
 +    if (params) {
 +        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);
 +}
 +
 +#define CHECK_LIST_SIZE(field) \
 +        if (buf->field ## _size % sizeof(*buf->field)) { \
 +            av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
 +                   "should be multiple of %d\n", \
 +                   buf->field ## _size, (int)sizeof(*buf->field)); \
 +            return AVERROR(EINVAL); \
 +        }
 +static int vsink_query_formats(AVFilterContext *ctx)
 +{
 +    BufferSinkContext *buf = ctx->priv;
 +    AVFilterFormats *formats = NULL;
 +    unsigned i;
 +    int ret;
 +
 +    CHECK_LIST_SIZE(pixel_fmts)
 +    if (buf->pixel_fmts_size) {
 +        for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
 +            if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0) {
 +                ff_formats_unref(&formats);
 +                return ret;
 +            }
 +        ff_set_common_formats(ctx, formats);
 +    } else {
 +        ff_default_query_formats(ctx);
 +    }
 +
 +    return 0;
 +}
 +
 +static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
 +{
 +    BufferSinkContext *buf = ctx->priv;
 +    AVABufferSinkParams *params = opaque;
 +    int ret;
 +
 +    if (params) {
 +        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 ||
 +            (ret = av_opt_set_int_list(buf, "channel_counts",  params->channel_counts,  -1, 0)) < 0 ||
 +            (ret = av_opt_set_int(buf, "all_channel_counts", params->all_channel_counts, 0)) < 0)
 +            return ret;
 +    }
 +    return common_init(ctx);
 +}
 +
 +static int asink_query_formats(AVFilterContext *ctx)
 +{
 +    BufferSinkContext *buf = ctx->priv;
 +    AVFilterFormats *formats = NULL;
 +    AVFilterChannelLayouts *layouts = NULL;
 +    unsigned i;
 +    int ret;
 +
 +    CHECK_LIST_SIZE(sample_fmts)
 +    CHECK_LIST_SIZE(sample_rates)
 +    CHECK_LIST_SIZE(channel_layouts)
 +    CHECK_LIST_SIZE(channel_counts)
 +
 +    if (buf->sample_fmts_size) {
 +        for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
 +            if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) {
 +                ff_formats_unref(&formats);
 +                return ret;
 +            }
 +        ff_set_common_formats(ctx, formats);
 +    }
 +
 +    if (buf->channel_layouts_size || buf->channel_counts_size ||
 +        buf->all_channel_counts) {
 +        for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
 +            if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) {
 +                ff_channel_layouts_unref(&layouts);
 +                return ret;
 +            }
 +        for (i = 0; i < NB_ITEMS(buf->channel_counts); i++)
 +            if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) {
 +                ff_channel_layouts_unref(&layouts);
 +                return ret;
 +            }
 +        if (buf->all_channel_counts) {
 +            if (layouts)
 +                av_log(ctx, AV_LOG_WARNING,
 +                       "Conflicting all_channel_counts and list in options\n");
 +            else if (!(layouts = ff_all_channel_counts()))
 +                return AVERROR(ENOMEM);
 +        }
 +        ff_set_common_channel_layouts(ctx, layouts);
 +    }
 +
 +    if (buf->sample_rates_size) {
 +        formats = NULL;
 +        for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
 +            if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) {
 +                ff_formats_unref(&formats);
 +                return ret;
 +            }
 +        ff_set_common_samplerates(ctx, formats);
 +    }
 +
 +    return 0;
 +}
 +
 +#define OFFSET(x) offsetof(BufferSinkContext, x)
 +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 +static const AVOption buffersink_options[] = {
 +    { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
 +    { NULL },
 +};
 +#undef FLAGS
 +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 +static const AVOption abuffersink_options[] = {
 +    { "sample_fmts",     "set the supported sample formats",  OFFSET(sample_fmts),     AV_OPT_TYPE_BINARY, .flags = FLAGS },
 +    { "sample_rates",    "set the supported sample rates",    OFFSET(sample_rates),    AV_OPT_TYPE_BINARY, .flags = FLAGS },
 +    { "channel_layouts", "set the supported channel layouts", OFFSET(channel_layouts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
 +    { "channel_counts",  "set the supported channel counts",  OFFSET(channel_counts),  AV_OPT_TYPE_BINARY, .flags = FLAGS },
 +    { "all_channel_counts", "accept all channel counts", OFFSET(all_channel_counts), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS },
 +    { NULL },
 +};
 +#undef FLAGS
 +
 +AVFILTER_DEFINE_CLASS(buffersink);
 +AVFILTER_DEFINE_CLASS(abuffersink);
 +
  static const AVFilterPad avfilter_vsink_buffer_inputs[] = {
      {
          .name         = "default",
Simple merge
Simple merge
   * @{
   */
  
- #if FF_API_AVFILTERBUFFER
-     /**
-      * Ignored
-      */
-     AV_BUFFERSRC_FLAG_NO_COPY = 2,
- #endif
 +enum {
 +
 +    /**
 +     * Do not check for format changes.
 +     */
 +    AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT = 1,
 +
- #if FF_API_AVFILTERBUFFER
- /**
-  * Add buffer data in picref to buffer_src.
-  *
-  * @param buffer_src  pointer to a buffer source context
-  * @param picref      a buffer reference, or NULL to mark EOF
-  * @param flags       a combination of AV_BUFFERSRC_FLAG_*
-  * @return            >= 0 in case of success, a negative AVERROR code
-  *                    in case of failure
-  */
- attribute_deprecated
- int av_buffersrc_add_ref(AVFilterContext *buffer_src,
-                          AVFilterBufferRef *picref, int flags);
- #endif
 +    /**
 +     * Immediately push the frame to the output.
 +     */
 +    AV_BUFFERSRC_FLAG_PUSH = 4,
 +
 +    /**
 +     * Keep a reference to the frame.
 +     * If the frame if reference-counted, create a new reference; otherwise
 +     * copy the frame data.
 +     */
 +    AV_BUFFERSRC_FLAG_KEEP_REF = 8,
 +
 +};
 +
- #if FF_API_AVFILTERBUFFER
- /**
-  * Add a buffer to a filtergraph.
-  *
-  * @param ctx an instance of the buffersrc filter
-  * @param buf buffer containing frame data to be passed down the filtergraph.
-  * This function will take ownership of buf, the user must not free it.
-  * A NULL buf signals EOF -- i.e. no more frames will be sent to this filter.
-  *
-  * @deprecated use av_buffersrc_write_frame() or av_buffersrc_add_frame()
-  */
- attribute_deprecated
- int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf);
- #endif
 +/**
 + * Get the number of failed requests.
 + *
 + * A failed request is when the request_frame method is called while no
 + * frame is present in the buffer.
 + * The number is reset when a frame is added.
 + */
 +unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src);
 +
  /**
   * Add a frame to the buffer source.
   *
Simple merge
Simple merge
Simple merge