[FFmpeg-soc] [soc]: r1622 - in libavfilter: Makefile avfilter.c avfilter.h avfiltergraph.c avfiltergraph.h defaults.c diffs/03_ffplay_filters.diff diffs/04_ffmpeg_filters.diff vf_crop.c vf_fifo.c vf_fps.c vf_negate.c vf_overlay.c vf_passthrough.c vf_scale.c vf_slicify.c vf_split.c vf_vflip.c
koorogi
subversion at mplayerhq.hu
Thu Dec 20 20:36:26 CET 2007
Author: koorogi
Date: Thu Dec 20 20:36:26 2007
New Revision: 1622
Log:
Rewrite colorspace negotiation.
Modified:
libavfilter/Makefile
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/avfiltergraph.c
libavfilter/avfiltergraph.h
libavfilter/defaults.c
libavfilter/diffs/03_ffplay_filters.diff
libavfilter/diffs/04_ffmpeg_filters.diff
libavfilter/vf_crop.c
libavfilter/vf_fifo.c
libavfilter/vf_fps.c
libavfilter/vf_negate.c
libavfilter/vf_overlay.c
libavfilter/vf_passthrough.c
libavfilter/vf_scale.c
libavfilter/vf_slicify.c
libavfilter/vf_split.c
libavfilter/vf_vflip.c
Modified: libavfilter/Makefile
==============================================================================
--- libavfilter/Makefile (original)
+++ libavfilter/Makefile Thu Dec 20 20:36:26 2007
@@ -6,6 +6,7 @@ OBJS = avfilter.o \
avfiltergraph.o \
avfiltergraphdesc.o \
defaults.o \
+ formats.o \
# TODO: real conditional compilation
OBJS-yes = vf_crop.o \
Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c (original)
+++ libavfilter/avfilter.c Thu Dec 20 20:36:26 2007
@@ -96,18 +96,6 @@ int avfilter_link(AVFilterContext *src,
return 0;
}
-static int common_format(int *fmts0, int *fmts1)
-{
- int i, j;
-
- for(i = 0; fmts0[i] != -1; i ++)
- for(j = 0; fmts1[j] != -1; j ++)
- if(fmts0[i] == fmts1[j])
- return fmts0[i];
-
- return -1;
-}
-
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
unsigned in, unsigned out)
{
@@ -131,57 +119,11 @@ int avfilter_insert_filter(AVFilterLink
int avfilter_config_link(AVFilterLink *link)
{
- int *fmts[3] = {NULL,NULL,NULL};
int (*config_link)(AVFilterLink *);
- int *(*query_formats)(AVFilterLink *link);
-
- AVFilterContext *scale;
- AVFilterLink *link2 = NULL;
if(!link)
return 0;
- /* find a format both filters support */
- if(!(query_formats = link_spad(link).query_formats))
- query_formats = avfilter_default_query_output_formats;
- fmts[0] = query_formats(link);
- fmts[1] = link_dpad(link).query_formats(link);
- if((link->format = common_format(fmts[0], fmts[1])) == -1) {
- /* no common format found. insert scale filter to convert */
- if(!(scale = avfilter_open(&avfilter_vf_scale, NULL)))
- goto format_done;
- if(scale->filter->init(scale, NULL, NULL)) {
- avfilter_destroy(scale);
- goto format_done;
- }
- if(avfilter_insert_filter(link, scale, 0, 0))
- goto format_done;
- link2 = scale->outputs[0];
-
- /* now try again to find working colorspaces.
- * XXX: is it safe to assume that the scale filter always supports the
- * same input and output colorspaces? */
- fmts[2] = scale->input_pads[0].query_formats(link);
- link->format = common_format(fmts[0], fmts[2]);
- link2->format = common_format(fmts[1], fmts[2]);
- }
-
-format_done:
- av_free(fmts[0]);
- av_free(fmts[1]);
- av_free(fmts[2]);
- if(link->format == -1 || (link2 && link2->format == -1)) {
- if(link2) {
- link->dst = link2->dst;
- link->dstpad = link2->dstpad;
- link->dst->inputs[link->dstpad] = link;
- link->format = -1;
- avfilter_destroy(scale);
- av_free(link2);
- }
- return -1;
- }
-
if(!(config_link = link_spad(link).config_props))
config_link = avfilter_default_config_output_link;
if(config_link(link))
@@ -192,18 +134,6 @@ format_done:
if(config_link(link))
return -1;
- if(link2) {
- if(!(config_link = link_spad(link2).config_props))
- config_link = avfilter_default_config_output_link;
- if(config_link(link2))
- return -1;
-
- if(!(config_link = link_dpad(link2).config_props))
- config_link = avfilter_default_config_input_link;
- if(config_link(link2))
- return -1;
- }
-
return 0;
}
@@ -439,18 +369,3 @@ int avfilter_init_filter(AVFilterContext
return 0;
}
-int *avfilter_make_format_list(int len, ...)
-{
- int *ret, i;
- va_list vl;
-
- ret = av_malloc(sizeof(int) * (len + 1));
- va_start(vl, len);
- for(i = 0; i < len; i ++)
- ret[i] = va_arg(vl, int);
- va_end(vl);
- ret[len] = -1;
-
- return ret;
-}
-
Modified: libavfilter/avfilter.h
==============================================================================
--- libavfilter/avfilter.h (original)
+++ libavfilter/avfilter.h Thu Dec 20 20:36:26 2007
@@ -102,6 +102,91 @@ AVFilterPicRef *avfilter_ref_pic(AVFilte
void avfilter_unref_pic(AVFilterPicRef *ref);
/**
+ * A list of supported formats for one end of a filter link. This is used
+ * during the format negotiation process to try to pick the best format to
+ * use to minimize the number of necessary conversions. Each filter gives a
+ * list of the formats supported by each input and output pad. The list
+ * given for each pad need not be distinct - they may be references to the
+ * same list of formats, as is often the case when a filter supports multiple
+ * formats, but will always outut the same format as it is given in input.
+ *
+ * In this way, a list of possible input formats and a list of possible
+ * output formats are associated with each link. When a set of formats is
+ * negotiated over a link, the input and output lists are merged to form a
+ * new list containing only the common elements of each list. In the case
+ * that there were no common elements, a format conversion is necessary.
+ * Otherwise, the lists are merged, and all other links which reference
+ * either of the format lists involved in the merge are also affected.
+ *
+ * For example, consider the filter chain:
+ * filter (a) --> (b) filter (b) --> (c) filter
+ *
+ * where the letters in parenthesis indicate a list of formats supported on
+ * the input or output of the link. Suppose the lists are as follows:
+ * (a) = {A, B}
+ * (b) = {A, B, C}
+ * (c) = {B, C}
+ *
+ * First, the first link's lists are merged, yielding:
+ * filter (a) --> (a) filter (a) --> (c) filter
+ *
+ * Notice that format list (b) now refers to the same list as filter list (a).
+ * Next, the lists for the second link are merged, yielding:
+ * filter (a) --> (a) filter (a) --> (a) filter
+ *
+ * where (a) = {B}.
+ *
+ * Unfortunately, when the format lists at the two ends of a link are merged,
+ * we must ensure that all links which reference either pre-merge format list
+ * get updated as well. Therefore, we have the format list structure store a
+ * pointer to each of the pointers to itself.
+ */
+typedef struct AVFilterFormats AVFilterFormats;
+struct AVFilterFormats
+{
+ unsigned format_count; ///< number of formats
+ int *formats; ///< list of formats
+
+ unsigned refcount; ///< number of references to this list
+ AVFilterFormats ***refs; ///< references to this list
+};
+
+/**
+ * Helper function to create a list of supported formats. This is intended
+ * for use in AVFilter->query_formats().
+ * @param len The number of formats supported
+ * @param ... A list of the supported formats
+ * @return The format list, with no existing references
+ */
+AVFilterFormats *avfilter_make_format_list(int len, ...);
+
+/**
+ * Returns a fairly comprehensive list of colorspaces which are supported by
+ * many of the included filters. This is not truly "all" the colorspaces, but
+ * it is most of them, and it is the most commonly supported large subset.
+ */
+AVFilterFormats *avfilter_all_colorspaces(void);
+
+/**
+ * If a and b share at least one common format, they are merged into a new
+ * format list which is returned. All the references to a and b are updated
+ * to point to this new list, and a and b are deallocated.
+ *
+ * If a and b do not share any common formats, neither is modified, and NULL
+ * is returned.
+ */
+AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
+
+/** Adds *ref as a new reference to f */
+void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref);
+
+/**
+ * Remove *ref as a reference to the format list it currently points to,
+ * deallocate that list if this was the last reference, and set *ref to NULL
+ */
+void avfilter_formats_unref(AVFilterFormats **ref);
+
+/**
* A filter pad used for either input or output
*/
struct AVFilterPad
@@ -140,18 +225,6 @@ struct AVFilterPad
int rej_perms;
/**
- * Callback to get a list of supported formats. The returned list should
- * be terminated by -1 (see avfilter_make_format_list for an easy way to
- * create such a list).
- *
- * This is used for both input and output pads. If ommitted from an output
- * pad, it is assumed that the only format supported is the same format
- * that is being used for the filter's first input. If the filter has no
- * inputs, then this may not be ommitted for its output pads.
- */
- int *(*query_formats)(AVFilterLink *link);
-
- /**
* Callback called before passing the first slice of a new frame. If
* NULL, the filter layer will default to storing a reference to the
* picture inside the link structure.
@@ -219,11 +292,17 @@ void avfilter_default_end_frame(AVFilter
int avfilter_default_config_output_link(AVFilterLink *link);
/** Default handler for config_props() for video inputs */
int avfilter_default_config_input_link (AVFilterLink *link);
-/** Default handler for query_formats() for video outputs */
-int *avfilter_default_query_output_formats(AVFilterLink *link);
/** Default handler for get_video_buffer() for video inputs */
AVFilterPicRef *avfilter_default_get_video_buffer(AVFilterLink *link,
int perms);
+/**
+ * A helper for query_formats() which sets all links to the same list of
+ * formats. If there are no links hooked to this filter, the list of formats is
+ * freed.
+ */
+void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
+/** Default handler for query_formats() */
+int avfilter_default_query_formats(AVFilterContext *ctx);
/**
* Filter definition. This defines the pads a filter contains, and all the
@@ -251,6 +330,15 @@ typedef struct
*/
void (*uninit)(AVFilterContext *ctx);
+ /**
+ * Query formats supported by the filter and its pads. Should set the
+ * in_formats for links connected to its output pads, and out_formats
+ * for links connected to its input pads.
+ *
+ * Should return zero on success.
+ */
+ int (*query_formats)(AVFilterContext *);
+
const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none
const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none
} AVFilter;
@@ -295,6 +383,14 @@ struct AVFilterLink
enum PixelFormat format; ///< agreed upon image colorspace
/**
+ * Lists of formats supported by the input and output filters respectively.
+ * These lists are used for negotiating the format to actually be used,
+ * which will be loaded into the format member, above, when chosen.
+ */
+ AVFilterFormats *in_formats;
+ AVFilterFormats *out_formats;
+
+ /**
* The picture reference currently being sent across the link by the source
* filter. This is used internally by the filter system to allow
* automatic copying of pictures which d not have sufficient permissions
@@ -415,14 +511,15 @@ int avfilter_init_filter(AVFilterContext
void avfilter_destroy(AVFilterContext *filter);
/**
- * Helper function to create a list of supported formats. This is intended
- * for use in AVFilterPad->query_formats().
- * @param len The number of formats supported
- * @param ... A list of the supported formats
- * @return The format list in a form suitable for returning from
- * AVFilterPad->query_formats()
+ * Insert a filter in the middle of an existing link.
+ * @param link The link into which the filter should be inserted
+ * @param filt The filter to be inserted
+ * @param in The input pad on the filter to connect
+ * @param out The output pad on the filter to connect
+ * @return Zero on success
*/
-int *avfilter_make_format_list(int len, ...);
+int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
+ unsigned in, unsigned out);
/**
* Insert a new pad
Modified: libavfilter/avfiltergraph.c
==============================================================================
--- libavfilter/avfiltergraph.c (original)
+++ libavfilter/avfiltergraph.c Thu Dec 20 20:36:26 2007
@@ -58,21 +58,6 @@ static inline AVFilterLink *get_extern_i
return lctx->graph->inputs[link->srcpad];
}
-/** query the formats supported by a filter providing input to the graph */
-static int *link_in_query_formats(AVFilterLink *link)
-{
- AVFilterLink *link2 = get_extern_input_link(link);
- int *(*query_formats)(AVFilterLink *);
-
- if(!link2)
- return avfilter_make_format_list(0);
-
- if(!(query_formats = link2->src->output_pads[link2->srcpad].query_formats))
- query_formats = avfilter_default_query_output_formats;
-
- return query_formats(link2);
-}
-
/** request a frame from a filter providing input to the graph */
static int link_in_request_frame(AVFilterLink *link)
{
@@ -112,17 +97,6 @@ static inline AVFilterLink *get_extern_o
return lctx->graph->outputs[link->dstpad];
}
-/** query the formats supported by a filter taking output from the graph */
-static int *link_out_query_formats(AVFilterLink *link)
-{
- AVFilterLink *link2 = get_extern_output_link(link);
-
- if(!link2)
- return avfilter_make_format_list(0);
-
- return link2->dst->input_pads[link2->dstpad].query_formats(link2);
-}
-
static int link_out_config_props(AVFilterLink *link)
{
AVFilterLink *link2 = get_extern_output_link(link);
@@ -224,15 +198,6 @@ static void graph_in_draw_slice(AVFilter
avfilter_draw_slice(link2, y, height);
}
-static int *graph_in_query_formats(AVFilterLink *link)
-{
- AVFilterLink *link2 = get_intern_input_link(link);
-
- if(!link2 || !link2->dst->input_pads[link2->dstpad].query_formats)
- return avfilter_make_format_list(0);
- return link2->dst->input_pads[link2->dstpad].query_formats(link2);
-}
-
static int graph_in_config_props(AVFilterLink *link)
{
AVFilterLink *link2 = get_intern_input_link(link);
@@ -258,17 +223,6 @@ static AVFilterLink *get_intern_output_l
return graph->link_filter->inputs[link->srcpad];
}
-static int *graph_out_query_formats(AVFilterLink *link)
-{
- AVFilterLink *link2 = get_intern_output_link(link);
-
- if(!link2)
- return avfilter_make_format_list(0);
- if(!link2->src->output_pads[link2->srcpad].query_formats)
- return avfilter_default_query_output_formats(link2);
- return link2->src->output_pads[link2->srcpad].query_formats(link2);
-}
-
static int graph_out_request_frame(AVFilterLink *link)
{
AVFilterLink *link2 = get_intern_output_link(link);
@@ -315,7 +269,6 @@ static int add_graph_input(AVFilterConte
.end_frame = graph_in_end_frame,
.get_video_buffer = graph_in_get_video_buffer,
.draw_slice = graph_in_draw_slice,
- .query_formats = graph_in_query_formats,
.config_props = graph_in_config_props,
/* XXX */
};
@@ -323,7 +276,6 @@ static int add_graph_input(AVFilterConte
{
.name = NULL, /* FIXME? */
.type = AV_PAD_VIDEO,
- .query_formats = link_in_query_formats,
.request_frame = link_in_request_frame,
.config_props = link_in_config_props,
};
@@ -345,7 +297,6 @@ static int add_graph_output(AVFilterCont
.name = name,
.type = AV_PAD_VIDEO,
.request_frame = graph_out_request_frame,
- .query_formats = graph_out_query_formats,
.config_props = graph_out_config_props,
};
AVFilterPad dummy_inpad =
@@ -356,7 +307,6 @@ static int add_graph_output(AVFilterCont
.end_frame = link_out_end_frame,
.draw_slice = link_out_draw_slice,
.get_video_buffer = link_out_get_video_buffer,
- .query_formats = link_out_query_formats,
.config_props = link_out_config_props,
};
@@ -406,6 +356,121 @@ AVFilterContext *avfilter_graph_get_filt
return NULL;
}
+static int query_formats(AVFilterContext *graphctx)
+{
+ GraphContext *graph = graphctx->priv;
+ AVFilterContext *linkfilt = graph->link_filter;
+ int i, j;
+
+ /* ask all the sub-filters for their supported colorspaces */
+ for(i = 0; i < graph->filter_count; i ++) {
+ if(graph->filters[i]->filter->query_formats)
+ graph->filters[i]->filter->query_formats(graph->filters[i]);
+ else
+ avfilter_default_query_formats(graph->filters[i]);
+ }
+
+ /* use these formats on our exported links */
+ for(i = 0; i < linkfilt->input_count; i ++) {
+ avfilter_formats_ref( linkfilt->inputs[i]->in_formats,
+ &linkfilt->inputs[i]->out_formats);
+
+ if(graphctx->outputs[i])
+ avfilter_formats_ref( linkfilt-> inputs[i]->in_formats,
+ &graphctx->outputs[i]->in_formats);
+ }
+ for(i = 0; i < linkfilt->output_count; i ++) {
+ avfilter_formats_ref( linkfilt->outputs[i]->out_formats,
+ &linkfilt->outputs[i]->in_formats);
+
+ if(graphctx->inputs[i])
+ avfilter_formats_ref( linkfilt->outputs[i]->out_formats,
+ &graphctx-> inputs[i]->out_formats);
+ }
+
+ /* go through and merge as many format lists as possible */
+ for(i = 0; i < graph->filter_count; i ++) {
+ AVFilterContext *filter = graph->filters[i];
+
+ for(j = 0; j < filter->input_count; j ++) {
+ AVFilterLink *link;
+ if(!(link = filter->inputs[j]))
+ continue;
+ if(link->in_formats != link->out_formats) {
+ if(!avfilter_merge_formats(link->in_formats,
+ link->out_formats)) {
+ /* couldn't merge format lists. auto-insert scale filter */
+ AVFilterContext *scale;
+
+ if(!(scale = avfilter_open(&avfilter_vf_scale, NULL)))
+ return -1;
+ if(scale->filter->init(scale, NULL, NULL) ||
+ avfilter_insert_filter(link, scale, 0, 0)) {
+ avfilter_destroy(scale);
+ return -1;
+ }
+
+ avfilter_graph_add_filter(graphctx, scale);
+ scale->filter->query_formats(scale);
+ if(avfilter_merge_formats(scale-> inputs[0]->in_formats,
+ scale-> inputs[0]->out_formats) ||
+ avfilter_merge_formats(scale->outputs[0]->in_formats,
+ scale->outputs[0]->out_formats))
+ return -1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static void pick_format(AVFilterLink *link)
+{
+ if(!link || !link->in_formats)
+ return;
+
+ link->in_formats->format_count = 1;
+ link->format = link->in_formats->formats[0];
+
+ avfilter_formats_unref(&link->in_formats);
+ avfilter_formats_unref(&link->out_formats);
+}
+
+static void pick_formats(GraphContext *graph)
+{
+ int i, j;
+
+ for(i = 0; i < graph->filter_count; i ++) {
+ AVFilterContext *filter = graph->filters[i];
+
+ if(filter->filter == &avfilter_vf_graph ||
+ filter->filter == &avfilter_vf_graphfile ||
+ filter->filter == &avfilter_vf_graphdesc)
+ pick_formats(filter->priv);
+
+ for(j = 0; j < filter->input_count; j ++)
+ pick_format(filter->inputs[j]);
+ for(j = 0; j < filter->output_count; j ++)
+ pick_format(filter->outputs[j]);
+ }
+}
+
+int avfilter_graph_config_formats(AVFilterContext *graphctx)
+{
+ GraphContext *graph = graphctx->priv;
+
+ /* Find supported formats from sub-filters, and merge along links */
+ if(query_formats(graphctx))
+ return -1;
+
+ /* Once everything is merged, it's possible that we'll still have
+ * multiple valid choices of colorspace. We pick the first one. */
+ pick_formats(graph);
+
+ return 0;
+}
+
int avfilter_graph_config_links(AVFilterContext *graphctx)
{
GraphContext *graph = graphctx->priv;
@@ -570,6 +635,8 @@ AVFilter avfilter_vf_graph =
.init = init,
.uninit = uninit,
+ .query_formats = query_formats,
+
.inputs = (AVFilterPad[]) {{ .name = NULL, }},
.outputs = (AVFilterPad[]) {{ .name = NULL, }},
};
@@ -667,6 +734,8 @@ AVFilter avfilter_vf_graphdesc =
.init = init_desc,
.uninit = uninit,
+ .query_formats = query_formats,
+
.inputs = (AVFilterPad[]) {{ .name = NULL, }},
.outputs = (AVFilterPad[]) {{ .name = NULL, }},
};
@@ -696,6 +765,8 @@ AVFilter avfilter_vf_graphfile =
.init = init_file,
.uninit = uninit,
+ .query_formats = query_formats,
+
.inputs = (AVFilterPad[]) {{ .name = NULL, }},
.outputs = (AVFilterPad[]) {{ .name = NULL, }},
};
Modified: libavfilter/avfiltergraph.h
==============================================================================
--- libavfilter/avfiltergraph.h (original)
+++ libavfilter/avfiltergraph.h Thu Dec 20 20:36:26 2007
@@ -87,7 +87,12 @@ void avfilter_graph_free_desc(AVFilterGr
void avfilter_graph_add_filter(AVFilterContext *graphctx, AVFilterContext *filter);
/**
- * Configure the colorspace, resolution, etc of all links in the graph
+ * Configure the formats of all the links in the graph
+ */
+int avfilter_graph_config_formats(AVFilterContext *graphctx);
+
+/**
+ * Configure the resolution, etc of all links in the graph
*/
int avfilter_graph_config_links(AVFilterContext *graphctx);
Modified: libavfilter/defaults.c
==============================================================================
--- libavfilter/defaults.c (original)
+++ libavfilter/defaults.c Thu Dec 20 20:36:26 2007
@@ -115,15 +115,40 @@ int avfilter_default_config_input_link(A
}
/**
- * default query_formats() implementation for output video links to simplify
- * the implementation of one input one output video filters */
-int *avfilter_default_query_output_formats(AVFilterLink *link)
+ * A helper for query_formats() which sets all links to the same list of
+ * formats. If there are no links hooked to this filter, the list of formats is
+ * freed.
+ *
+ * FIXME: this will need changed for filters with a mix of pad types
+ * (video + audio, etc)
+ */
+void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
{
- if(link->src->input_count && link->src->inputs[0])
- return avfilter_make_format_list(1, link->src->inputs[0]->format);
- else
- /* XXX: any non-simple filter which would cause this branch to be taken
- * really should implement its own query_formats() for this link */
- return avfilter_make_format_list(0);
+ int count = 0, i;
+
+ for(i = 0; i < ctx->input_count; i ++) {
+ if(ctx->inputs[i]) {
+ avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats);
+ count ++;
+ }
+ }
+ for(i = 0; i < ctx->output_count; i ++) {
+ if(ctx->outputs[i]) {
+ avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats);
+ count ++;
+ }
+ }
+
+ if(!count) {
+ av_free(formats->formats);
+ av_free(formats->refs);
+ av_free(formats);
+ }
+}
+
+int avfilter_default_query_formats(AVFilterContext *ctx)
+{
+ avfilter_set_common_formats(ctx, avfilter_all_colorspaces());
+ return 0;
}
Modified: libavfilter/diffs/03_ffplay_filters.diff
==============================================================================
--- libavfilter/diffs/03_ffplay_filters.diff (original)
+++ libavfilter/diffs/03_ffplay_filters.diff Thu Dec 20 20:36:26 2007
@@ -1,17 +1,18 @@
---- ffplay.c.old2 2007-10-16 20:27:42.000000000 +0200
-+++ ffplay.c 2007-10-16 20:27:51.000000000 +0200
-@@ -27,6 +27,10 @@
+--- ffplay.c.old 2007-12-20 13:17:23.241265187 -0500
++++ ffplay.c 2007-12-20 14:15:32.174812061 -0500
+@@ -27,6 +27,11 @@
#include "swscale.h"
#include "avstring.h"
+#if ENABLE_AVFILTER
+# include "avfilter.h"
++# include "avfiltergraph.h"
+#endif
+
#include "version.h"
#include "cmdutils.h"
-@@ -86,6 +90,10 @@
+@@ -86,6 +91,10 @@
int width, height; /* source height & width */
enum PixelFormat pix_fmt;
int allocated;
@@ -22,7 +23,7 @@
} VideoPicture;
typedef struct SubPicture {
-@@ -168,6 +176,10 @@
+@@ -168,6 +177,10 @@
// QETimer *video_timer;
char filename[1024];
int width, height, xleft, ytop;
@@ -33,7 +34,7 @@
} VideoState;
void show_help(void);
-@@ -207,6 +219,9 @@
+@@ -207,6 +220,9 @@
static int error_resilience = FF_ER_CAREFUL;
static int error_concealment = 3;
static int decoder_reorder_pts= 0;
@@ -43,7 +44,7 @@
/* current context */
static int is_full_screen;
-@@ -653,14 +668,22 @@
+@@ -653,14 +669,22 @@
vp = &is->pictq[is->pictq_rindex];
if (vp->bmp) {
@@ -68,7 +69,7 @@
/* if an active format is indicated, then it overrides the
mpeg format */
#if 0
-@@ -863,9 +886,15 @@
+@@ -863,9 +887,15 @@
} else if(!is_full_screen && screen_width){
w = screen_width;
h = screen_height;
@@ -84,7 +85,7 @@
} else {
w = 640;
h = 480;
-@@ -1171,9 +1200,19 @@
+@@ -1171,9 +1201,19 @@
if (vp->bmp)
SDL_FreeYUVOverlay(vp->bmp);
@@ -104,7 +105,7 @@
#if 0
/* XXX: use generic function */
-@@ -1210,7 +1249,7 @@
+@@ -1210,7 +1250,7 @@
{
VideoPicture *vp;
int dst_pix_fmt;
@@ -113,7 +114,7 @@
static struct SwsContext *img_convert_ctx;
/* wait until we have space to put a new picture */
-@@ -1228,8 +1267,13 @@
+@@ -1228,8 +1268,13 @@
/* alloc or resize hardware picture buffer */
if (!vp->bmp ||
@@ -127,7 +128,7 @@
SDL_Event event;
vp->allocated = 0;
-@@ -1253,6 +1297,12 @@
+@@ -1253,6 +1298,12 @@
/* if the frame is not skipped, then display it */
if (vp->bmp) {
@@ -140,7 +141,7 @@
/* get a pointer on the bitmap */
SDL_LockYUVOverlay (vp->bmp);
-@@ -1264,6 +1314,19 @@
+@@ -1264,6 +1315,19 @@
pict.linesize[0] = vp->bmp->pitches[0];
pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1];
@@ -160,7 +161,7 @@
img_convert_ctx = sws_getCachedContext(img_convert_ctx,
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
dst_pix_fmt, sws_flags, NULL, NULL, NULL);
-@@ -1273,6 +1336,7 @@
+@@ -1273,6 +1337,7 @@
}
sws_scale(img_convert_ctx, src_frame->data, src_frame->linesize,
0, vp->height, pict.data, pict.linesize);
@@ -168,7 +169,7 @@
/* update the bitmap content */
SDL_UnlockYUVOverlay(vp->bmp);
-@@ -1380,6 +1444,134 @@
+@@ -1380,6 +1445,140 @@
return 0;
}
@@ -220,10 +221,12 @@
+ return 0;
+}
+
-+static int *input_query_formats(AVFilterLink *link)
++static int input_query_formats(AVFilterContext *ctx)
+{
-+ FilterPriv *priv = link->src->priv;
-+ return avfilter_make_format_list(1, priv->is->video_st->codec->pix_fmt);
++ FilterPriv *priv = ctx->priv;
++ avfilter_set_common_formats(ctx,
++ avfilter_make_format_list(1, priv->is->video_st->codec->pix_fmt));
++ return 0;
+}
+
+static int input_config_props(AVFilterLink *link)
@@ -247,11 +250,12 @@
+ .init = input_init,
+ .uninit = input_uninit,
+
++ .query_formats = input_query_formats,
++
+ .inputs = (AVFilterPad[]) {{ .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO,
+ .request_frame = input_request_frame,
-+ .query_formats = input_query_formats,
+ .config_props = input_config_props, },
+ { .name = NULL }},
+};
@@ -260,9 +264,11 @@
+{
+}
+
-+static int *output_query_formats(AVFilterLink *link)
++static int output_query_formats(AVFilterContext *ctx)
+{
-+ return avfilter_make_format_list(1, PIX_FMT_YUV420P);
++ avfilter_set_common_formats(ctx,
++ avfilter_make_format_list(1, PIX_FMT_YUV420P));
++ return 0;
+}
+
+static int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
@@ -290,10 +296,11 @@
+ .name = "ffplay_output",
+ .author = "Bobby Bingham",
+
++ .query_formats = output_query_formats,
++
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO,
+ .end_frame = output_end_frame,
-+ .query_formats = output_query_formats,
+ .min_perms = AV_PERM_READ, },
+ { .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = NULL }},
@@ -303,17 +310,16 @@
static int video_thread(void *arg)
{
VideoState *is = arg;
-@@ -1388,10 +1580,45 @@
+@@ -1388,10 +1587,52 @@
double pts;
int ret;
+
+#if ENABLE_AVFILTER
+ AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_graph = NULL;
++ AVFilterContext *graph;
+
+ avfilter_init();
-+ //avfilter_register(&input_filter);
-+ //avfilter_register(&output_filter);
+
+ if(!(filt_src = avfilter_open(&input_filter, "src"))) goto the_end;
+ if(!(filt_out = avfilter_open(&output_filter, "out"))) goto the_end;
@@ -321,6 +327,11 @@
+ if(avfilter_init_filter(filt_src, NULL, is)) goto the_end;
+ if(avfilter_init_filter(filt_out, NULL, frame)) goto the_end;
+
++ if(!(graph = avfilter_open(avfilter_get_by_name("graph"), NULL)))
++ goto the_end;
++ if(avfilter_init_filter(graph, NULL, NULL))
++ goto the_end;
++
+ if(vfilters) {
+ if(!(filt_graph = avfilter_open(avfilter_get_by_name("graph"), NULL)))
+ goto the_end;
@@ -328,13 +339,16 @@
+ goto the_end;
+ if(avfilter_link(filt_src, 0, filt_graph, 0)) goto the_end;
+ if(avfilter_link(filt_graph, 0, filt_out, 0)) goto the_end;
-+ if(avfilter_config_link(filt_src->outputs[0])) goto the_end;
-+ if(avfilter_graph_config_links(filt_graph)) goto the_end;
-+ if(avfilter_config_link(filt_out->inputs[0])) goto the_end;
++
++ avfilter_graph_add_filter(graph, filt_graph);
+ } else {
+ if(avfilter_link(filt_src, 0, filt_out, 0) < 0) goto the_end;
-+ if(avfilter_config_link(filt_src->outputs[0])) goto the_end;
+ }
++ avfilter_graph_add_filter(graph, filt_src);
++ avfilter_graph_add_filter(graph, filt_out);
++ if(avfilter_graph_config_formats(graph)) goto the_end;
++ if(avfilter_graph_config_links(graph)) goto the_end;
++
+ is->out_video_filter = filt_out;
+#endif
+
@@ -349,18 +363,17 @@
if (ret < 0) goto the_end;
pts = pts_int;
-@@ -1404,6 +1631,10 @@
+@@ -1404,6 +1645,9 @@
stream_pause(cur_stream);
}
the_end:
+ #if ENABLE_AVFILTER
-+ if(filt_src) avfilter_destroy(filt_src);
-+ if(filt_out) avfilter_destroy(filt_out);
++ if(graph) avfilter_destroy(graph);
+ #endif
av_free(frame);
return 0;
}
-@@ -2138,6 +2369,12 @@
+@@ -2138,6 +2382,12 @@
/* free all pictures */
for(i=0;i<VIDEO_PICTURE_QUEUE_SIZE; i++) {
vp = &is->pictq[i];
@@ -373,7 +386,7 @@
if (vp->bmp) {
SDL_FreeYUVOverlay(vp->bmp);
vp->bmp = NULL;
-@@ -2494,6 +2731,9 @@
+@@ -2494,6 +2744,9 @@
#endif
{ "sync", HAS_ARG | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
{ "threads", HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
Modified: libavfilter/diffs/04_ffmpeg_filters.diff
==============================================================================
--- libavfilter/diffs/04_ffmpeg_filters.diff (original)
+++ libavfilter/diffs/04_ffmpeg_filters.diff Thu Dec 20 20:36:26 2007
@@ -1,19 +1,18 @@
-Index: ffmpeg.c
-===================================================================
---- ffmpeg.c (revision 11283)
-+++ ffmpeg.c (working copy)
-@@ -36,6 +36,10 @@
+--- ffmpeg.c.old 2007-12-20 13:44:48.061553766 -0500
++++ ffmpeg.c 2007-12-20 14:07:15.792260637 -0500
+@@ -36,6 +36,11 @@
#include "avstring.h"
#include "os_support.h"
+#if ENABLE_AVFILTER
+# include "avfilter.h"
++# include "avfiltergraph.h"
+#endif
+
#if !defined(HAVE_GETRUSAGE) && defined(HAVE_GETPROCESSTIMES)
#include <windows.h>
#endif
-@@ -139,6 +143,7 @@
+@@ -139,6 +144,7 @@
static int loop_input = 0;
static int loop_output = AVFMT_NOOUTPUTLOOP;
static int qp_hist = 0;
@@ -21,7 +20,7 @@ Index: ffmpeg.c
static int intra_only = 0;
static int audio_sample_rate = 44100;
-@@ -275,6 +280,12 @@
+@@ -275,6 +281,12 @@
is not defined */
int64_t pts; /* current pts */
int is_start; /* is 1 at the start and after a discontinuity */
@@ -34,7 +33,7 @@ Index: ffmpeg.c
} AVInputStream;
typedef struct AVInputFile {
-@@ -290,6 +301,241 @@
+@@ -290,6 +302,259 @@
static struct termios oldtty;
#endif
@@ -84,10 +83,12 @@ Index: ffmpeg.c
+ return 0;
+}
+
-+static int *input_query_formats(AVFilterLink *link)
++static int input_query_formats(AVFilterContext *ctx)
+{
-+ FilterInPriv *priv = link->src->priv;
-+ return avfilter_make_format_list(1, priv->ist->st->codec->pix_fmt);
++ FilterInPriv *priv = ctx->priv;
++ avfilter_set_common_formats(ctx,
++ avfilter_make_format_list(1, priv->ist->st->codec->pix_fmt));
++ return 0;
+}
+
+static int input_config_props(AVFilterLink *link)
@@ -111,11 +112,12 @@ Index: ffmpeg.c
+ .init = input_init,
+ .uninit = input_uninit,
+
++ .query_formats = input_query_formats,
++
+ .inputs = (AVFilterPad[]) {{ .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO,
+ .request_frame = input_request_frame,
-+ .query_formats = input_query_formats,
+ .config_props = input_config_props, },
+ { .name = NULL }},
+};
@@ -140,10 +142,12 @@ Index: ffmpeg.c
+{
+}
+
-+static int *output_query_formats(AVFilterLink *link)
++static int output_query_formats(AVFilterContext *ctx)
+{
-+ FilterOutPriv *priv = link->dst->priv;
-+ return avfilter_make_format_list(1, priv->pix_fmt);
++ FilterOutPriv *priv = ctx->priv;
++ avfilter_set_common_formats(ctx,
++ avfilter_make_format_list(1, priv->pix_fmt));
++ return 0;
+}
+
+static int get_filtered_video_pic(AVFilterContext *ctx,
@@ -175,10 +179,11 @@ Index: ffmpeg.c
+ .priv_size = sizeof(FilterOutPriv),
+ .init = output_init,
+
++ .query_formats = output_query_formats,
++
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO,
+ .end_frame = output_end_frame,
-+ .query_formats = output_query_formats,
+ .min_perms = AV_PERM_READ, },
+ { .name = NULL }},
+ .outputs = (AVFilterPad[]) {{ .name = NULL }},
@@ -187,7 +192,10 @@ Index: ffmpeg.c
+static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
+{
+ AVFilterContext *curr_filter;
++ /** filter graph containing the user specified filters */
+ AVFilterContext *filt_graph;
++ /** filter graph containing all filters including input & output */
++ AVFilterContext *filt_graph_all;
+ AVCodecContext *codec = ost->st->codec;
+ AVCodecContext *icodec = ist->st->codec;
+
@@ -243,6 +251,16 @@ Index: ffmpeg.c
+ curr_filter = filt_scale;
+ }
+
++ /* create the overall filter graph */
++ if(!(filt_graph_all = avfilter_open(avfilter_get_by_name("graph"), NULL)))
++ return -1;
++ if(avfilter_init_filter(filt_graph_all, NULL, NULL))
++ return -1;
++
++ /* add input and output filters to the overall graph */
++ avfilter_graph_add_filter(filt_graph_all, curr_filter);
++ avfilter_graph_add_filter(filt_graph_all, ist->out_video_filter);
++
+ if(vfilters) {
+ if(!(filt_graph = avfilter_open(avfilter_get_by_name("graph"), NULL)))
+ return -1;
@@ -252,20 +270,19 @@ Index: ffmpeg.c
+ return -1;
+ if(avfilter_link(filt_graph, 0, ist->out_video_filter, 0))
+ return -1;
-+ if(avfilter_config_link(curr_filter->outputs[0]))
-+ return -1;
-+ if(avfilter_graph_config_links(filt_graph))
-+ return -1;
-+ if(avfilter_config_link(filt_graph->outputs[0]))
-+ return -1;
++
++ avfilter_graph_add_filter(filt_graph_all, filt_graph);
+ } else {
+ if(avfilter_link(curr_filter, 0, ist->out_video_filter, 0) < 0)
+ return -1;
-+ if(avfilter_config_link(curr_filter->outputs[0]))
-+ return -1;
-+
+ }
+
++ /* configure all the filter links */
++ if(avfilter_graph_config_formats(filt_graph_all))
++ return -1;
++ if(avfilter_graph_config_links(filt_graph_all))
++ return -1;
++
+ codec->width = ist->out_video_filter->inputs[0]->w;
+ codec->height = ist->out_video_filter->inputs[0]->h;
+
@@ -276,7 +293,7 @@ Index: ffmpeg.c
static void term_exit(void)
{
#ifdef HAVE_TERMIOS_H
-@@ -635,6 +881,13 @@
+@@ -635,6 +900,13 @@
frame_hook_process(picture2, dec->pix_fmt, dec->width, dec->height,
1000000 * ist->pts / AV_TIME_BASE);
@@ -290,7 +307,7 @@ Index: ffmpeg.c
if (picture != picture2)
*picture = *picture2;
*bufp = buf;
-@@ -745,6 +998,9 @@
+@@ -745,6 +1017,9 @@
if (nb_frames <= 0)
return;
@@ -300,7 +317,7 @@ Index: ffmpeg.c
if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
-@@ -754,6 +1010,7 @@
+@@ -754,6 +1029,7 @@
} else {
formatted_picture = in_picture;
}
@@ -308,7 +325,7 @@ Index: ffmpeg.c
final_picture = formatted_picture;
padding_src = formatted_picture;
-@@ -769,12 +1026,14 @@
+@@ -769,12 +1045,14 @@
}
}
@@ -323,7 +340,7 @@ Index: ffmpeg.c
if (ost->video_pad) {
av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
-@@ -1275,6 +1534,10 @@
+@@ -1275,6 +1553,10 @@
}
}
}
@@ -334,7 +351,7 @@ Index: ffmpeg.c
av_free(buffer_to_free);
/* XXX: allocate the subtitles in the codec ? */
if (subtitle_to_free) {
-@@ -1680,10 +1943,21 @@
+@@ -1680,10 +1962,21 @@
fprintf(stderr, "Cannot get resampling context\n");
exit(1);
}
@@ -356,7 +373,7 @@ Index: ffmpeg.c
break;
case CODEC_TYPE_SUBTITLE:
ost->encoding_needed = 1;
-@@ -3779,6 +4053,9 @@
+@@ -3779,6 +4072,9 @@
#ifdef CONFIG_VHOOK
{ "vhook", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)add_frame_hooker}, "insert video processing module", "module" },
#endif
Modified: libavfilter/vf_crop.c
==============================================================================
--- libavfilter/vf_crop.c (original)
+++ libavfilter/vf_crop.c Thu Dec 20 20:36:26 2007
@@ -49,25 +49,6 @@ static int init(AVFilterContext *ctx, co
return 0;
}
-static int *query_in_formats(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
static int config_input(AVFilterLink *link)
{
CropContext *crop = link->dst->priv;
@@ -171,7 +152,6 @@ AVFilter avfilter_vf_crop =
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.draw_slice = draw_slice,
- .query_formats = query_in_formats,
.config_props = config_input, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
Modified: libavfilter/vf_fifo.c
==============================================================================
--- libavfilter/vf_fifo.c (original)
+++ libavfilter/vf_fifo.c Thu Dec 20 20:36:26 2007
@@ -53,25 +53,6 @@ static void uninit(AVFilterContext *ctx)
}
}
-static int *query_formats(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
{
BufferContext *buf = link->dst->priv;
@@ -129,7 +110,6 @@ AVFilter avfilter_vf_fifo =
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.draw_slice = draw_slice,
- .query_formats = query_formats,
.end_frame = end_frame,
.rej_perms = AV_PERM_REUSE2, },
{ .name = NULL}},
Modified: libavfilter/vf_fps.c
==============================================================================
--- libavfilter/vf_fps.c (original)
+++ libavfilter/vf_fps.c Thu Dec 20 20:36:26 2007
@@ -52,25 +52,6 @@ static void uninit(AVFilterContext *ctx)
if(fps->pic) avfilter_unref_pic(fps->pic);
}
-static int *query_formats(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
{
FPSContext *fps = link->dst->priv;
@@ -112,7 +93,6 @@ AVFilter avfilter_vf_fps =
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
- .query_formats = query_formats,
.end_frame = end_frame, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
Modified: libavfilter/vf_negate.c
==============================================================================
--- libavfilter/vf_negate.c (original)
+++ libavfilter/vf_negate.c Thu Dec 20 20:36:26 2007
@@ -27,13 +27,15 @@ typedef struct
int hsub, vsub;
} NegContext;
-static int *query_formats(AVFilterLink *link)
+static int query_formats(AVFilterContext *ctx)
{
- return avfilter_make_format_list(10,
+ avfilter_set_common_formats(ctx,
+ avfilter_make_format_list(10,
PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
PIX_FMT_YUV411P, PIX_FMT_YUV410P,
PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P);
+ PIX_FMT_YUV440P, PIX_FMT_YUVJ440P));
+ return 0;
}
static int config_props(AVFilterLink *link)
@@ -99,10 +101,11 @@ AVFilter avfilter_vf_negate =
.priv_size = sizeof(NegContext),
+ .query_formats = query_formats,
+
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AV_PAD_VIDEO,
.draw_slice = draw_slice,
- .query_formats = query_formats,
.config_props = config_props,
.min_perms = AV_PERM_READ, },
{ .name = NULL}},
Modified: libavfilter/vf_overlay.c
==============================================================================
--- libavfilter/vf_overlay.c (original)
+++ libavfilter/vf_overlay.c Thu Dec 20 20:36:26 2007
@@ -57,30 +57,6 @@ static void uninit(AVFilterContext *ctx)
avfilter_unref_pic(over->pics[i][j]);
}
-static int *query_formats_main(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
-static int *query_formats_sub(AVFilterLink *link)
-{
- return avfilter_make_format_list(1, link->dst->inputs[0]->format);
-}
-
static int config_input_main(AVFilterLink *link)
{
OverlayContext *over = link->dst->priv;
@@ -226,7 +202,6 @@ AVFilter avfilter_vf_overlay =
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
- .query_formats = query_formats_main,
.config_props = config_input_main,
.end_frame = end_frame,
.min_perms = AV_PERM_READ,
@@ -234,7 +209,6 @@ AVFilter avfilter_vf_overlay =
{ .name = "sub",
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
- .query_formats = query_formats_sub,
.config_props = config_input_sub,
.end_frame = end_frame,
.min_perms = AV_PERM_READ,
Modified: libavfilter/vf_passthrough.c
==============================================================================
--- libavfilter/vf_passthrough.c (original)
+++ libavfilter/vf_passthrough.c Thu Dec 20 20:36:26 2007
@@ -24,25 +24,6 @@
#include "avfilter.h"
-static int *query_formats(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
{
avfilter_start_frame(link->dst->outputs[0], picref);
@@ -67,7 +48,6 @@ AVFilter avfilter_vf_passthrough =
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.draw_slice = draw_slice,
- .query_formats = query_formats,
.end_frame = end_frame, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
Modified: libavfilter/vf_scale.c
==============================================================================
--- libavfilter/vf_scale.c (original)
+++ libavfilter/vf_scale.c Thu Dec 20 20:36:26 2007
@@ -64,23 +64,20 @@ static void uninit(AVFilterContext *ctx)
sws_freeContext(scale->sws);
}
-static int *query_formats(AVFilterLink *link)
+static int query_formats(AVFilterContext *ctx)
{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
+ AVFilterFormats *formats;
+
+ if(ctx->inputs[0]) {
+ formats = avfilter_all_colorspaces();
+ avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats);
+ }
+ if(ctx->outputs[0]) {
+ formats = avfilter_all_colorspaces();
+ avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats);
+ }
+
+ return 0;
}
static int config_props(AVFilterLink *link)
@@ -148,18 +145,18 @@ AVFilter avfilter_vf_scale =
.init = init,
.uninit = uninit,
+ .query_formats = query_formats,
+
.priv_size = sizeof(ScaleContext),
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.end_frame = end_frame,
- .query_formats = query_formats,
.min_perms = AV_PERM_READ, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
.type = AV_PAD_VIDEO,
- .query_formats = query_formats,
.config_props = config_props, },
{ .name = NULL}},
};
Modified: libavfilter/vf_slicify.c
==============================================================================
--- libavfilter/vf_slicify.c (original)
+++ libavfilter/vf_slicify.c Thu Dec 20 20:36:26 2007
@@ -41,9 +41,11 @@ static int init(AVFilterContext *ctx, co
return 0;
}
-static int *query_formats(AVFilterLink *link)
+static int query_formats(AVFilterContext *ctx)
{
- return avfilter_make_format_list(1, PIX_FMT_RGB24);
+ avfilter_set_common_formats(ctx,
+ avfilter_make_format_list(1, PIX_FMT_RGB24));
+ return 0;
}
static int config_props(AVFilterLink *link)
@@ -92,11 +94,12 @@ AVFilter avfilter_vf_slicify =
.init = init,
+ .query_formats = query_formats,
+
.inputs = (AVFilterPad[]) {{ .name = "default",
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.draw_slice = draw_slice,
- .query_formats = query_formats,
.config_props = config_props,
.end_frame = end_frame, },
{ .name = NULL}},
Modified: libavfilter/vf_split.c
==============================================================================
--- libavfilter/vf_split.c (original)
+++ libavfilter/vf_split.c Thu Dec 20 20:36:26 2007
@@ -21,25 +21,6 @@
#include "avfilter.h"
-static int *query_formats(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
{
avfilter_start_frame(link->dst->outputs[0],
@@ -71,7 +52,6 @@ AVFilter avfilter_vf_split =
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.draw_slice = draw_slice,
- .query_formats = query_formats,
.end_frame = end_frame, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
Modified: libavfilter/vf_vflip.c
==============================================================================
--- libavfilter/vf_vflip.c (original)
+++ libavfilter/vf_vflip.c Thu Dec 20 20:36:26 2007
@@ -29,25 +29,6 @@ typedef struct
int vsub; //< chroma subsampling
} FlipContext;
-static int *query_in_formats(AVFilterLink *link)
-{
- return avfilter_make_format_list(31,
- PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P,
- PIX_FMT_YUV411P, PIX_FMT_YUV410P,
- PIX_FMT_YUYV422, PIX_FMT_UYVY422, PIX_FMT_UYYVYY411,
- PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P,
- PIX_FMT_YUV440P, PIX_FMT_YUVJ440P,
- PIX_FMT_RGB32, PIX_FMT_BGR32,
- PIX_FMT_RGB32_1, PIX_FMT_BGR32_1,
- PIX_FMT_RGB24, PIX_FMT_BGR24,
- PIX_FMT_RGB565, PIX_FMT_BGR565,
- PIX_FMT_RGB555, PIX_FMT_BGR555,
- PIX_FMT_RGB8, PIX_FMT_BGR8,
- PIX_FMT_RGB4_BYTE,PIX_FMT_BGR4_BYTE,
- PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE,
- PIX_FMT_GRAY8, PIX_FMT_PAL8);
-}
-
static int config_input(AVFilterLink *link)
{
FlipContext *flip = link->dst->priv;
@@ -94,7 +75,6 @@ AVFilter avfilter_vf_vflip =
.type = AV_PAD_VIDEO,
.start_frame = start_frame,
.draw_slice = draw_slice,
- .query_formats = query_in_formats,
.config_props = config_input, },
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = "default",
More information about the FFmpeg-soc
mailing list