]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/buffersrc.c
doxygen: qdm2: Drop documentation for non-existing function parameters
[ffmpeg] / libavfilter / buffersrc.c
index 7af9f6c5713e0e61e88214239ca9a026994de195..33cb63b46b58e3af8afa6977b964c451eed91c46 100644 (file)
@@ -27,8 +27,8 @@
 #include "avfilter.h"
 #include "buffersrc.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
-#include "vsrc_buffer.h"
 
 #include "libavutil/audioconvert.h"
 #include "libavutil/fifo.h"
@@ -69,25 +69,6 @@ typedef struct {
         return AVERROR(EINVAL);\
     }
 
-#if FF_API_VSRC_BUFFER_ADD_FRAME
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
-                             int64_t pts, AVRational pixel_aspect)
-{
-    int64_t orig_pts = frame->pts;
-    AVRational orig_sar = frame->sample_aspect_ratio;
-    int ret;
-
-    frame->pts = pts;
-    frame->sample_aspect_ratio = pixel_aspect;
-    if ((ret = av_buffersrc_write_frame(buffer_filter, frame)) < 0)
-        return ret;
-    frame->pts = orig_pts;
-    frame->sample_aspect_ratio = orig_sar;
-
-    return 0;
-}
-#endif
-
 int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame)
 {
     BufferSourceContext *c = buffer_filter->priv;
@@ -109,8 +90,11 @@ int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame)
     case AVMEDIA_TYPE_VIDEO:
         CHECK_VIDEO_PARAM_CHANGE(buffer_filter, c, frame->width, frame->height,
                                  frame->format);
-        buf = avfilter_get_video_buffer(buffer_filter->outputs[0], AV_PERM_WRITE,
-                                        c->w, c->h);
+        buf = ff_get_video_buffer(buffer_filter->outputs[0], AV_PERM_WRITE,
+                                  c->w, c->h);
+        if (!buf)
+            return AVERROR(ENOMEM);
+
         av_image_copy(buf->data, buf->linesize, frame->data, frame->linesize,
                       c->pix_fmt, c->w, c->h);
         break;
@@ -119,6 +103,9 @@ int av_buffersrc_write_frame(AVFilterContext *buffer_filter, AVFrame *frame)
                                  frame->format);
         buf = ff_get_audio_buffer(buffer_filter->outputs[0], AV_PERM_WRITE,
                                   frame->nb_samples);
+        if (!buf)
+            return AVERROR(ENOMEM);
+
         av_samples_copy(buf->extended_data, frame->extended_data,
                         0, 0, frame->nb_samples,
                         av_get_channel_layout_nb_channels(frame->channel_layout),
@@ -172,7 +159,7 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf)
     return 0;
 }
 
-static av_cold int init_video(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int init_video(AVFilterContext *ctx, const char *args)
 {
     BufferSourceContext *c = ctx->priv;
     char pix_fmt_str[128];
@@ -197,7 +184,7 @@ static av_cold int init_video(AVFilterContext *ctx, const char *args, void *opaq
     if (!(c->fifo = av_fifo_alloc(sizeof(AVFilterBufferRef*))))
         return AVERROR(ENOMEM);
 
-    av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s\n", c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name);
+    av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s\n", c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name);
     return 0;
 }
 
@@ -218,7 +205,7 @@ static const AVClass abuffer_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-static av_cold int init_audio(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int init_audio(AVFilterContext *ctx, const char *args)
 {
     BufferSourceContext *s = ctx->priv;
     int ret = 0;
@@ -331,6 +318,7 @@ static int request_frame(AVFilterLink *link)
 {
     BufferSourceContext *c = link->src->priv;
     AVFilterBufferRef *buf;
+    int ret = 0;
 
     if (!av_fifo_size(c->fifo)) {
         if (c->eof)
@@ -341,20 +329,20 @@ static int request_frame(AVFilterLink *link)
 
     switch (link->type) {
     case AVMEDIA_TYPE_VIDEO:
-        ff_start_frame(link, avfilter_ref_buffer(buf, ~0));
-        ff_draw_slice(link, 0, link->h, 1);
-        ff_end_frame(link);
+        if ((ret = ff_start_frame(link, buf)) < 0 ||
+            (ret = ff_draw_slice(link, 0, link->h, 1)) < 0 ||
+            (ret = ff_end_frame(link)) < 0)
+            return ret;
         break;
     case AVMEDIA_TYPE_AUDIO:
-        ff_filter_samples(link, avfilter_ref_buffer(buf, ~0));
+        ret = ff_filter_samples(link, buf);
         break;
     default:
+        avfilter_unref_bufferp(&buf);
         return AVERROR(EINVAL);
     }
 
-    avfilter_unref_buffer(buf);
-
-    return 0;
+    return ret;
 }
 
 static int poll_frame(AVFilterLink *link)
@@ -375,13 +363,13 @@ AVFilter avfilter_vsrc_buffer = {
     .init      = init_video,
     .uninit    = uninit,
 
-    .inputs    = (AVFilterPad[]) {{ .name = NULL }},
-    .outputs   = (AVFilterPad[]) {{ .name            = "default",
-                                    .type            = AVMEDIA_TYPE_VIDEO,
-                                    .request_frame   = request_frame,
-                                    .poll_frame      = poll_frame,
-                                    .config_props    = config_props, },
-                                  { .name = NULL}},
+    .inputs    = (const AVFilterPad[]) {{ .name = NULL }},
+    .outputs   = (const AVFilterPad[]) {{ .name            = "default",
+                                          .type            = AVMEDIA_TYPE_VIDEO,
+                                          .request_frame   = request_frame,
+                                          .poll_frame      = poll_frame,
+                                          .config_props    = config_props, },
+                                        { .name = NULL}},
 };
 
 AVFilter avfilter_asrc_abuffer = {
@@ -393,11 +381,11 @@ AVFilter avfilter_asrc_abuffer = {
     .init      = init_audio,
     .uninit    = uninit,
 
-    .inputs    = (AVFilterPad[]) {{ .name = NULL }},
-    .outputs   = (AVFilterPad[]) {{ .name            = "default",
-                                    .type            = AVMEDIA_TYPE_AUDIO,
-                                    .request_frame   = request_frame,
-                                    .poll_frame      = poll_frame,
-                                    .config_props    = config_props, },
-                                  { .name = NULL}},
+    .inputs    = (const AVFilterPad[]) {{ .name = NULL }},
+    .outputs   = (const AVFilterPad[]) {{ .name            = "default",
+                                          .type            = AVMEDIA_TYPE_AUDIO,
+                                          .request_frame   = request_frame,
+                                          .poll_frame      = poll_frame,
+                                          .config_props    = config_props, },
+                                        { .name = NULL}},
 };