It supersedes av_vsrc_buffer_add_frame and handles both audio and video.
Showing the changes to libavfilter/src_buffer.c (1 of 2 files). Show all
Unified · Split
| @@ -303,28 +303,38 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf) · 302 unmodified lines | ||
| 303 | 303 | #if CONFIG_AVCODEC |
| 304 | 304 | #include "avcodec.h" |
| 305 | 305 | |
| 306 | −int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, | |
| 307 | − const AVFrame *frame, int flags) | |
| 306 | +int av_buffersrc_add_frame(AVFilterContext *buffer_src, | |
| 307 | + const AVFrame *frame, int flags) | |
| 308 | 308 | { |
| 309 | − BufferSourceContext *c = buffer_src->priv; | |
| 310 | 309 | AVFilterBufferRef *picref; |
| 311 | 310 | int ret; |
| 312 | 311 | |
| 313 | − if (!frame) { | |
| 314 | − c->eof = 1; | |
| 315 | − return 0; | |
| 316 | − } else if (c->eof) | |
| 317 | − return AVERROR(EINVAL); | |
| 312 | + if (!frame) /* NULL for EOF */ | |
| 313 | + return av_buffersrc_add_ref(buffer_src, NULL, flags); | |
| 318 | 314 | |
| 319 | − picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE); | |
| 315 | + switch (buffer_src->outputs[0]->type) { | |
| 316 | + case AVMEDIA_TYPE_VIDEO: | |
| 317 | + picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE); | |
| 318 | + break; | |
| 319 | + case AVMEDIA_TYPE_AUDIO: | |
| 320 | + picref = avfilter_get_audio_buffer_ref_from_frame(frame, AV_PERM_WRITE); | |
| 321 | + break; | |
| 322 | + default: | |
| 323 | + return AVERROR(ENOSYS); | |
| 324 | + } | |
| 320 | 325 | if (!picref) |
| 321 | 326 | return AVERROR(ENOMEM); |
| 322 | − ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref, flags); | |
| 327 | + ret = av_buffersrc_add_ref(buffer_src, picref, flags); | |
| 323 | 328 | picref->buf->data[0] = NULL; |
| 324 | 329 | avfilter_unref_buffer(picref); |
| 325 | − | |
| 326 | 330 | return ret; |
| 327 | 331 | } |
| 332 | + | |
| 333 | +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, | |
| 334 | + const AVFrame *frame, int flags) | |
| 335 | +{ | |
| 336 | + return av_buffersrc_add_frame(buffer_src, frame, 0); | |
| 337 | +} | |
| 328 | 338 | #endif |
| 329 | 339 | |
| 330 | 340 | unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src) |