[FFmpeg-devel] [PATCH 4/6] src_buffer: move format change check in a separate function.
Nicolas George
nicolas.george at normalesup.org
Fri Apr 27 21:48:08 CEST 2012
This will make merging the check with the audio part easier.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavfilter/src_buffer.c | 61 +++++++++++++++++++++++++++++++---------------
1 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
index d578a77..2ff2b89 100644
--- a/libavfilter/src_buffer.c
+++ b/libavfilter/src_buffer.c
@@ -70,30 +70,12 @@ typedef struct {
return AVERROR(EINVAL);\
}
-int av_src_buffer_add_ref(AVFilterContext *buffer_filter,
- AVFilterBufferRef *picref, int flags)
+static int check_format_change_video(AVFilterContext *buffer_filter,
+ AVFilterBufferRef *picref)
{
BufferSourceContext *c = buffer_filter->priv;
- AVFilterLink *outlink = buffer_filter->outputs[0];
- AVFilterBufferRef *buf;
int ret;
- if (!picref) {
- c->eof = 1;
- return 0;
- } else if (c->eof)
- return AVERROR(EINVAL);
-
- if (!av_fifo_space(c->fifo) &&
- (ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
- sizeof(buf))) < 0)
- return ret;
-
- if (flags & AV_SRC_BUFFER_FLAG_DIRECT) {
- buf = picref;
- } else {
-
- /* TODO reindent */
if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
AVFilterContext *scale = buffer_filter->outputs[0]->dst;
AVFilterLink *link;
@@ -138,7 +120,46 @@ int av_src_buffer_add_ref(AVFilterContext *buffer_filter,
if ((ret = link->srcpad->config_props(link)) < 0)
return ret;
}
+ return 0;
+}
+static int check_format_change(AVFilterContext *buffer_filter,
+ AVFilterBufferRef *picref)
+{
+ switch (buffer_filter->outputs[0]->type) {
+ case AVMEDIA_TYPE_VIDEO:
+ return check_format_change_video(buffer_filter, picref);
+ default:
+ return AVERROR(ENOSYS);
+ }
+}
+
+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;
+
+ if (!picref) {
+ c->eof = 1;
+ return 0;
+ } else if (c->eof)
+ return AVERROR(EINVAL);
+
+ if (!av_fifo_space(c->fifo) &&
+ (ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
+ sizeof(buf))) < 0)
+ return ret;
+
+ if (flags & AV_SRC_BUFFER_FLAG_DIRECT) {
+ buf = picref;
+ } else {
+ 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,
--
1.7.2.5
More information about the ffmpeg-devel
mailing list