Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-06-02 17:43:21 +0400
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2011-06-06 03:35:27 +0400
commit27bcf55f459e038e81f09c17e72e6d44898b9015 (patch)
tree34ba7668ad2c828fc1ff087901e5b59fbee3d030 /libavfilter/vsrc_buffer.c
parent612d0782fc885aaa0bbb8f8966d425ea91a606cf (diff)
vsrc_buffer: add flags param to av_vsrc_buffer_add_video_buffer_ref
The new flags parameter allows to specify if the video ref to add should overwrite the cache, if the flag is not set vsrc_buffer will complain and abort; otherwise it will clean the already cached video ref before to overwrite it, thus avoiding a leak.
Diffstat (limited to 'libavfilter/vsrc_buffer.c')
-rw-r--r--libavfilter/vsrc_buffer.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 9ba7d4ee47..246444b3ac 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -37,18 +37,23 @@ typedef struct {
char sws_param[256];
} BufferSourceContext;
-int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilterBufferRef *picref)
+int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter,
+ AVFilterBufferRef *picref, int flags)
{
BufferSourceContext *c = buffer_filter->priv;
AVFilterLink *outlink = buffer_filter->outputs[0];
int ret;
if (c->picref) {
- av_log(buffer_filter, AV_LOG_ERROR,
- "Buffering several frames is not supported. "
- "Please consume all available frames before adding a new one.\n"
- );
- //return -1;
+ if (flags & AV_VSRC_BUF_FLAG_OVERWRITE) {
+ avfilter_unref_buffer(c->picref);
+ c->picref = NULL;
+ } else {
+ av_log(buffer_filter, AV_LOG_ERROR,
+ "Buffering several frames is not supported. "
+ "Please consume all available frames before adding a new one.\n");
+ return AVERROR(EINVAL);
+ }
}
if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
@@ -109,14 +114,15 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilter
#if CONFIG_AVCODEC
#include "avcodec.h"
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, const AVFrame *frame)
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
+ const AVFrame *frame, int flags)
{
int ret;
AVFilterBufferRef *picref =
avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
if (!picref)
return AVERROR(ENOMEM);
- ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref);
+ ret = av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref, flags);
picref->buf->data[0] = NULL;
avfilter_unref_buffer(picref);