[FFmpeg-soc] [soc]: r1668 - in libavfilter: Makefile allfilters.h avfilter.c vf_format.c vf_passthrough.c

koorogi subversion at mplayerhq.hu
Mon Dec 24 22:42:57 CET 2007


Author: koorogi
Date: Mon Dec 24 22:42:56 2007
New Revision: 1668

Log:
Change the passthrough filter to a noformat filter.  It's now similar to
the mplayer noformat filter except that the default behavior if no formats
are specified is to allow allow all formats (ie. virtually the same as the
old passthrough behavior)


Added:
   libavfilter/vf_format.c
      - copied, changed from r1639, /libavfilter/vf_passthrough.c
Removed:
   libavfilter/vf_passthrough.c
Modified:
   libavfilter/Makefile
   libavfilter/allfilters.h
   libavfilter/avfilter.c

Modified: libavfilter/Makefile
==============================================================================
--- libavfilter/Makefile	(original)
+++ libavfilter/Makefile	Mon Dec 24 22:42:56 2007
@@ -14,8 +14,8 @@ OBJS-yes = vf_crop.o \
            vf_fps.o \
            vf_hflip.o \
            vf_negate.o \
+           vf_format.o \
            vf_overlay.o \
-           vf_passthrough.o \
            vf_scale.o \
            vf_slicify.o \
            vf_split.o \

Modified: libavfilter/allfilters.h
==============================================================================
--- libavfilter/allfilters.h	(original)
+++ libavfilter/allfilters.h	Mon Dec 24 22:42:56 2007
@@ -29,8 +29,8 @@ extern AVFilter avfilter_vf_graphdesc;
 extern AVFilter avfilter_vf_graphfile;
 extern AVFilter avfilter_vf_hflip;
 extern AVFilter avfilter_vf_negate;
+extern AVFilter avfilter_vf_noformat;
 extern AVFilter avfilter_vf_overlay;
-extern AVFilter avfilter_vf_passthrough;
 extern AVFilter avfilter_vf_scale;
 extern AVFilter avfilter_vf_slicify;
 extern AVFilter avfilter_vf_split;

Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c	(original)
+++ libavfilter/avfilter.c	Mon Dec 24 22:42:56 2007
@@ -298,8 +298,8 @@ void avfilter_init(void)
     avfilter_register(&avfilter_vf_graphfile);
     avfilter_register(&avfilter_vf_hflip);
     avfilter_register(&avfilter_vf_negate);
+    avfilter_register(&avfilter_vf_noformat);
     avfilter_register(&avfilter_vf_overlay);
-    avfilter_register(&avfilter_vf_passthrough);
     avfilter_register(&avfilter_vf_scale);
     avfilter_register(&avfilter_vf_slicify);
     avfilter_register(&avfilter_vf_split);

Copied: libavfilter/vf_format.c (from r1639, /libavfilter/vf_passthrough.c)
==============================================================================
--- /libavfilter/vf_passthrough.c	(original)
+++ libavfilter/vf_format.c	Mon Dec 24 22:42:56 2007
@@ -1,5 +1,5 @@
 /*
- * Video passthrough filter
+ * Video noformat filter
  * copyright (c) 2007 Bobby Bingham
  *
  * This file is part of FFmpeg.
@@ -24,6 +24,67 @@
 
 #include "avfilter.h"
 
+typedef struct
+{
+    /** nonzero for each format included in the list */
+    uint8_t formats[PIX_FMT_NB];
+} FormatContext;
+
+static int init(AVFilterContext *ctx, const char *args, void *opaque)
+{
+    FormatContext *format = ctx->priv;
+    const char *cur, *sep;
+    char name[32];
+    int fmt;
+
+    /* parse the list of formats */
+    for(cur = args; cur; cur = sep) {
+        if(!(sep = strchr(cur, ':')))
+            fmt = avcodec_get_pix_fmt(cur);
+        else {
+            if(sep-cur > 32) {
+                av_log(ctx, AV_LOG_ERROR, "format name too long\n");
+                sep ++;
+                continue;
+            }
+            memcpy(name, cur, sep-cur);
+            name[sep-cur] = 0;
+            fmt = avcodec_get_pix_fmt(name);
+            sep ++;
+        }
+
+        if(fmt >= PIX_FMT_NB) {
+            av_log(ctx, AV_LOG_ERROR, "unknown pixel format\n");
+            continue;
+        }
+
+        format->formats[fmt] = 1;
+    }
+
+    return 0;
+}
+
+static AVFilterFormats *make_format_list(FormatContext *format, uint8_t val)
+{
+    AVFilterFormats *ret;
+    int i;
+
+    ret = av_mallocz(sizeof(AVFilterFormats));
+    ret->formats = av_malloc(sizeof(int) * PIX_FMT_NB);
+
+    for(i = 0; i < PIX_FMT_NB; i ++)
+        if(format->formats[i] == val)
+            ret->formats[ret->format_count ++] = i;
+
+    return ret;
+}
+
+static int query_formats_noformat(AVFilterContext *ctx)
+{
+    avfilter_set_common_formats(ctx, make_format_list(ctx->priv, 0));
+    return 0;
+}
+
 static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
 {
     avfilter_start_frame(link->dst->outputs[0], picref);
@@ -39,11 +100,17 @@ static void draw_slice(AVFilterLink *lin
     avfilter_draw_slice(link->dst->outputs[0], y, h);
 }
 
-AVFilter avfilter_vf_passthrough =
+AVFilter avfilter_vf_noformat =
 {
-    .name      = "passthrough",
+    .name      = "noformat",
     .author    = "Bobby Bingham",
 
+    .init      = init,
+
+    .query_formats = query_formats_noformat,
+
+    .priv_size = sizeof(FormatContext),
+
     .inputs    = (AVFilterPad[]) {{ .name            = "default",
                                     .type            = AV_PAD_VIDEO,
                                     .start_frame     = start_frame,



More information about the FFmpeg-soc mailing list