[FFmpeg-soc] [soc]: r1773 - in libavfilter: Makefile allfilters.h avfilter.c vf_rot90.c

vitor subversion at mplayerhq.hu
Sun Jan 6 14:19:12 CET 2008


Author: vitor
Date: Sun Jan  6 14:19:12 2008
New Revision: 1773

Log:
90 degrees counter-clockwise rotation filter

Added:
   libavfilter/vf_rot90.c
Modified:
   libavfilter/Makefile
   libavfilter/allfilters.h
   libavfilter/avfilter.c

Modified: libavfilter/Makefile
==============================================================================
--- libavfilter/Makefile	(original)
+++ libavfilter/Makefile	Sun Jan  6 14:19:12 2008
@@ -15,6 +15,7 @@ OBJS-yes = vf_crop.o \
            vf_hflip.o \
            vf_negate.o \
            vf_format.o \
+           vf_rot90.o \
            vf_overlay.o \
            vf_scale.o \
            vf_slicify.o \

Modified: libavfilter/allfilters.h
==============================================================================
--- libavfilter/allfilters.h	(original)
+++ libavfilter/allfilters.h	Sun Jan  6 14:19:12 2008
@@ -32,6 +32,7 @@ extern AVFilter avfilter_vf_hflip;
 extern AVFilter avfilter_vf_negate;
 extern AVFilter avfilter_vf_noformat;
 extern AVFilter avfilter_vf_overlay;
+extern AVFilter avfilter_vf_rot90;
 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	Sun Jan  6 14:19:12 2008
@@ -301,6 +301,7 @@ void avfilter_init(void)
     avfilter_register(&avfilter_vf_negate);
     avfilter_register(&avfilter_vf_noformat);
     avfilter_register(&avfilter_vf_overlay);
+    avfilter_register(&avfilter_vf_rot90);
     avfilter_register(&avfilter_vf_scale);
     avfilter_register(&avfilter_vf_slicify);
     avfilter_register(&avfilter_vf_split);

Added: libavfilter/vf_rot90.c
==============================================================================
--- (empty file)
+++ libavfilter/vf_rot90.c	Sun Jan  6 14:19:12 2008
@@ -0,0 +1,89 @@
+/*
+ * 90 degree counter-clock-wise rotation filter
+ * Copyright (c) 2008 Vitor Sessak
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avfilter.h"
+
+typedef struct
+{
+    int hsub, vsub;
+} RotContext;
+
+static int config_props_input(AVFilterLink *link)
+{
+    RotContext *neg = link->dst->priv;
+
+    avcodec_get_chroma_sub_sample(link->format, &neg->hsub, &neg->vsub);
+
+    return 0;
+}
+
+static int config_props_output(AVFilterLink *link)
+{
+    link->w = link->src->inputs[0]->h;
+    link->h = link->src->inputs[0]->w;
+
+    return 0;
+}
+
+static void draw_slice(AVFilterLink *link, int y, int h)
+{
+    RotContext *rot = link->dst->priv;
+    AVFilterPicRef *in  = link->cur_pic;
+    AVFilterPicRef *out = link->dst->outputs[0]->outpic;
+    int i, j, plane;
+
+    /* luma plane */
+    for(i = y; i < h; i ++)
+        for(j = 0; j < link->w; j ++)
+            *(out->data[0] +   j *out->linesize[0] + i) =
+                *(in->data[0]+ i * in->linesize[0] + j);
+
+    /* chroma planes */
+    for(plane = 1; plane < 3; plane ++) {
+        for(i = y >> rot->vsub; i < h >> rot->vsub; i++) {
+            for(j = 0; j < link->w >> rot->hsub; j++)
+                *(out->data[plane] +   j *out->linesize[plane] + i) =
+                    *(in->data[plane]+ i * in->linesize[plane] + j);
+        }
+    }
+
+    avfilter_draw_slice(link->dst->outputs[0], y, h);
+}
+
+AVFilter avfilter_vf_rot90 =
+{
+    .name      = "rot90",
+    .author    = "Vitor Sessak",
+
+    .priv_size = sizeof(RotContext),
+
+    .inputs    = (AVFilterPad[]) {{ .name            = "default",
+                                    .type            = AV_PAD_VIDEO,
+                                    .draw_slice      = draw_slice,
+                                    .config_props    = config_props_input,
+                                    .min_perms       = AV_PERM_READ, },
+                                  { .name = NULL}},
+    .outputs   = (AVFilterPad[]) {{ .name            = "default",
+                                    .config_props    = config_props_output,
+                                    .type            = AV_PAD_VIDEO, },
+                                  { .name = NULL}},
+};
+



More information about the FFmpeg-soc mailing list