[FFmpeg-soc] [soc]: r1632 - in libavfilter: Makefile allfilters.h avfilter.c vf_hflip.c
benoit
subversion at mplayerhq.hu
Fri Dec 21 10:21:30 CET 2007
Author: benoit
Date: Fri Dec 21 10:21:29 2007
New Revision: 1632
Log:
Add horizontal flip filter.
Added:
libavfilter/vf_hflip.c
Modified:
libavfilter/Makefile
libavfilter/allfilters.h
libavfilter/avfilter.c
Modified: libavfilter/Makefile
==============================================================================
--- libavfilter/Makefile (original)
+++ libavfilter/Makefile Fri Dec 21 10:21:29 2007
@@ -12,6 +12,7 @@ OBJS = avfilter.o \
OBJS-yes = vf_crop.o \
vf_fifo.o \
vf_fps.o \
+ vf_hflip.o \
vf_negate.o \
vf_overlay.o \
vf_passthrough.o \
Modified: libavfilter/allfilters.h
==============================================================================
--- libavfilter/allfilters.h (original)
+++ libavfilter/allfilters.h Fri Dec 21 10:21:29 2007
@@ -27,6 +27,7 @@ extern AVFilter avfilter_vf_fps;
extern AVFilter avfilter_vf_graph;
extern AVFilter avfilter_vf_graphdesc;
extern AVFilter avfilter_vf_graphfile;
+extern AVFilter avfilter_vf_hflip;
extern AVFilter avfilter_vf_negate;
extern AVFilter avfilter_vf_overlay;
extern AVFilter avfilter_vf_passthrough;
Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c (original)
+++ libavfilter/avfilter.c Fri Dec 21 10:21:29 2007
@@ -278,6 +278,7 @@ void avfilter_init(void)
avfilter_register(&avfilter_vf_graph);
avfilter_register(&avfilter_vf_graphdesc);
avfilter_register(&avfilter_vf_graphfile);
+ avfilter_register(&avfilter_vf_hflip);
avfilter_register(&avfilter_vf_negate);
avfilter_register(&avfilter_vf_overlay);
avfilter_register(&avfilter_vf_passthrough);
Added: libavfilter/vf_hflip.c
==============================================================================
--- (empty file)
+++ libavfilter/vf_hflip.c Fri Dec 21 10:21:29 2007
@@ -0,0 +1,92 @@
+/*
+ * Horizontal flip filter
+ * Copyright (c) 2007 Benoit Fouet
+ *
+ * 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; /**< chroma subsampling along width */
+ int vsub; /**< chroma subsampling along height */
+} FlipContext;
+
+static int config_props(AVFilterLink *link)
+{
+ FlipContext *flip = link->dst->priv;
+
+ avcodec_get_chroma_sub_sample(link->format, &flip->hsub, &flip->vsub);
+
+ return avfilter_config_link(link->dst->outputs[0]);
+}
+
+static void draw_slice(AVFilterLink *link, int y, int h)
+{
+ FlipContext *flip = link->dst->priv;
+ AVFilterPicRef *in = link->cur_pic;
+ AVFilterPicRef *out = link->dst->outputs[0]->outpic;
+ uint8_t *inrow, *outrow;
+ int i, j, plane;
+
+ /* luma plane */
+ outrow = out->data[0] + y * out->linesize[0];
+ inrow = in-> data[0] + y * in-> linesize[0] + in->w-y;
+ for(i = 0; i < h; i++) {
+ for(j = 0; j < link->w; j++)
+ outrow[j] = inrow[-j];
+ inrow += in-> linesize[0];
+ outrow += out->linesize[0];
+ }
+
+ /* chroma planes */
+ for(plane = 1; plane < 4; plane++) {
+ if (in->data[plane]) {
+ outrow = out->data[plane] + (y>>flip->vsub) * out->linesize[plane];
+ inrow = in-> data[plane] + (y>>flip->vsub) * in-> linesize[plane] +
+ ((link->w-y) >> flip->hsub);
+
+ for(i = 0; i < h >> flip->vsub; i++) {
+ for(j = 0; j < link->w >> flip->hsub; j++)
+ outrow[j] = inrow[-j];
+ outrow += out->linesize[plane];
+ inrow += in-> linesize[plane];
+ }
+ }
+ }
+
+ avfilter_draw_slice(link->dst->outputs[0], y, h);
+}
+
+AVFilter avfilter_vf_hflip =
+{
+ .name = "hflip",
+ .author = "Benoit Fouet",
+ .priv_size = sizeof(FlipContext),
+
+ .inputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO,
+ .draw_slice = draw_slice,
+ .config_props = config_props,
+ .min_perms = AV_PERM_READ, },
+ { .name = NULL}},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO, },
+ { .name = NULL}},
+};
+
More information about the FFmpeg-soc
mailing list