The new function is a wrapper around av_vsrc_buffer_add_video_buffer_ref(), and allows to simplify the act of pushing AVFrame data to the source buffer.
Showing the changes to libavfilter/vsrc_buffer.c (1 of 5 files). Show all
Unified · Split
| @@ -106,6 +106,23 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilter · 105 unmodified lines | ||
| 106 | 106 | return 0; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | +#if CONFIG_AVCODEC | |
| 110 | +#include "avcodec.h" | |
| 111 | + | |
| 112 | +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, const AVFrame *frame) | |
| 113 | +{ | |
| 114 | + AVFilterBufferRef *picref = | |
| 115 | + avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE); | |
| 116 | + if (!picref) | |
| 117 | + return AVERROR(ENOMEM); | |
| 118 | + av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref); | |
| 119 | + picref->buf->data[0] = NULL; | |
| 120 | + avfilter_unref_buffer(picref); | |
| 121 | + | |
| 122 | + return 0; | |
| 123 | +} | |
| 124 | +#endif | |
| 125 | + | |
| 109 | 126 | static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) |
| 110 | 127 | { |
| 111 | 128 | BufferSourceContext *c = ctx->priv; |