]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/buffersrc.c
avfilter/buffersrc: deprecate sws_param option
[ffmpeg] / libavfilter / buffersrc.c
index e95d9c4f491ceda9c7e11b78efbe0b7177e3c26b..64940d91e20d4d7b8ca651e6303970aa624da5a5 100644 (file)
@@ -43,7 +43,6 @@
 
 typedef struct BufferSourceContext {
     const AVClass    *class;
-    AVFrame          *queued_frame;
     AVRational        time_base;     ///< time_base to set in the output link
     AVRational        frame_rate;    ///< frame_rate to set in the output link
     unsigned          nb_failed_requests;
@@ -52,7 +51,9 @@ typedef struct BufferSourceContext {
     int               w, h;
     enum AVPixelFormat  pix_fmt;
     AVRational        pixel_aspect;
+#if FF_API_SWS_PARAM_OPTION
     char              *sws_param;
+#endif
 
     AVBufferRef *hw_frames_ctx;
 
@@ -63,7 +64,6 @@ typedef struct BufferSourceContext {
     uint64_t channel_layout;
     char    *channel_layout_str;
 
-    int got_format_from_params;
     int eof;
 } BufferSourceContext;
 
@@ -105,7 +105,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par
     switch (ctx->filter->outputs[0].type) {
     case AVMEDIA_TYPE_VIDEO:
         if (param->format != AV_PIX_FMT_NONE) {
-            s->got_format_from_params = 1;
             s->pix_fmt = param->format;
         }
         if (param->width > 0)
@@ -125,7 +124,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par
         break;
     case AVMEDIA_TYPE_AUDIO:
         if (param->format != AV_SAMPLE_FMT_NONE) {
-            s->got_format_from_params = 1;
             s->sample_fmt = param->format;
         }
         if (param->sample_rate > 0)
@@ -241,11 +239,11 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx,
         }
     }
 
-    av_assert0(s->queued_frame == NULL);
-    s->queued_frame = copy;
-    if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0)
+    ret = ff_filter_frame(ctx->outputs[0], copy);
+    if (ret < 0) {
+        av_frame_free(&copy);
         return ret;
-    av_assert0(s->queued_frame == NULL);
+    }
 
     if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
         ret = push_frame(ctx->graph);
@@ -269,16 +267,22 @@ static av_cold int init_video(AVFilterContext *ctx)
 {
     BufferSourceContext *c = ctx->priv;
 
-    if (!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) || !c->w || !c->h ||
+    if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h ||
         av_q2d(c->time_base) <= 0) {
         av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");
         return AVERROR(EINVAL);
     }
 
-    av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d sar:%d/%d sws_param:%s\n",
+    av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d sar:%d/%d\n",
            c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
            c->time_base.num, c->time_base.den, c->frame_rate.num, c->frame_rate.den,
-           c->pixel_aspect.num, c->pixel_aspect.den, (char *)av_x_if_null(c->sws_param, ""));
+           c->pixel_aspect.num, c->pixel_aspect.den);
+
+#if FF_API_SWS_PARAM_OPTION
+    if (c->sws_param)
+        av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and ignored\n");
+#endif
+
     return 0;
 }
 
@@ -300,7 +304,9 @@ static const AVOption buffer_options[] = {
     { "pixel_aspect",  "sample aspect ratio",    OFFSET(pixel_aspect),     AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
     { "time_base",     NULL,                     OFFSET(time_base),        AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
     { "frame_rate",    NULL,                     OFFSET(frame_rate),       AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
+#if FF_API_SWS_PARAM_OPTION
     { "sws_param",     NULL,                     OFFSET(sws_param),        AV_OPT_TYPE_STRING,                    .flags = V },
+#endif
     { NULL },
 };
 
@@ -322,7 +328,7 @@ static av_cold int init_audio(AVFilterContext *ctx)
     BufferSourceContext *s = ctx->priv;
     int ret = 0;
 
-    if (!(s->sample_fmt != AV_SAMPLE_FMT_NONE || s->got_format_from_params)) {
+    if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
         av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n");
         return AVERROR(EINVAL);
     }
@@ -369,7 +375,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
 static av_cold void uninit(AVFilterContext *ctx)
 {
     BufferSourceContext *s = ctx->priv;
-    av_assert0(s->queued_frame == NULL);
     av_buffer_unref(&s->hw_frames_ctx);
 }
 
@@ -440,19 +445,11 @@ static int config_props(AVFilterLink *link)
 static int request_frame(AVFilterLink *link)
 {
     BufferSourceContext *c = link->src->priv;
-    AVFrame *frame;
-    int ret;
 
-    if (!c->queued_frame) {
-        if (c->eof)
-            return AVERROR_EOF;
-        c->nb_failed_requests++;
-        return AVERROR(EAGAIN);
-    }
-    frame = c->queued_frame;
-    c->queued_frame = NULL;
-    ret = ff_filter_frame(link, frame);
-    return ret;
+    if (c->eof)
+        return AVERROR_EOF;
+    c->nb_failed_requests++;
+    return AVERROR(EAGAIN);
 }
 
 static const AVFilterPad avfilter_vsrc_buffer_outputs[] = {