[FFmpeg-devel] [PATCH 5/6] src_buffer: move buffer copy in a separate function.
Nicolas George
nicolas.george at normalesup.org
Fri Apr 27 21:48:09 CEST 2012
This will make merging with the audio part easier.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavfilter/src_buffer.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
index 2ff2b89..a6ebb57 100644
--- a/libavfilter/src_buffer.c
+++ b/libavfilter/src_buffer.c
@@ -134,11 +134,30 @@ static int check_format_change(AVFilterContext *buffer_filter,
}
}
+static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
+ AVFilterBufferRef *ref)
+{
+ AVFilterLink *outlink = ctx->outputs[0];
+ AVFilterBufferRef *buf = NULL;
+
+ switch (outlink->type) {
+
+ case AVMEDIA_TYPE_VIDEO:
+ buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
+ ref->video->w, ref->video->h);
+ av_image_copy(buf->data, buf->linesize,
+ (void*)ref->data, ref->linesize,
+ ref->format, ref->video->w, ref->video->h);
+ avfilter_copy_buffer_ref_props(buf, ref);
+
+ }
+ return buf;
+}
+
int av_src_buffer_add_ref(AVFilterContext *buffer_filter,
AVFilterBufferRef *picref, int flags)
{
BufferSourceContext *c = buffer_filter->priv;
- AVFilterLink *outlink = buffer_filter->outputs[0];
AVFilterBufferRef *buf;
int ret;
@@ -159,14 +178,7 @@ int av_src_buffer_add_ref(AVFilterContext *buffer_filter,
ret = check_format_change(buffer_filter, picref);
if (ret < 0)
return ret;
- /* TODO reindent */
- buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
- picref->video->w, picref->video->h);
- av_image_copy(buf->data, buf->linesize,
- (void*)picref->data, picref->linesize,
- picref->format, picref->video->w, picref->video->h);
- avfilter_copy_buffer_ref_props(buf, picref);
-
+ buf = copy_buffer_ref(buffer_filter, picref);
}
if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
--
1.7.2.5
More information about the ffmpeg-devel
mailing list