[FFmpeg-soc] [soc]: r1036 - in libavfilter: Makefile allfilters.h avfilter.c vf_negate.c
koorogi
subversion at mplayerhq.hu
Mon Aug 20 07:27:17 CEST 2007
Author: koorogi
Date: Mon Aug 20 07:27:17 2007
New Revision: 1036
Log:
Image negating filter
Added:
libavfilter/vf_negate.c
Modified:
libavfilter/Makefile
libavfilter/allfilters.h
libavfilter/avfilter.c
Modified: libavfilter/Makefile
==============================================================================
--- libavfilter/Makefile (original)
+++ libavfilter/Makefile Mon Aug 20 07:27:17 2007
@@ -13,6 +13,7 @@ OBJS-yes = vsrc_dummy.o \
vf_crop.o \
vf_fifo.o \
vf_fps.o \
+ vf_negate.o \
vf_overlay.o \
vf_passthrough.o \
vf_rgb2bgr.o \
Modified: libavfilter/allfilters.h
==============================================================================
--- libavfilter/allfilters.h (original)
+++ libavfilter/allfilters.h Mon Aug 20 07:27:17 2007
@@ -29,6 +29,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_negate;
extern AVFilter avfilter_vf_overlay;
extern AVFilter avfilter_vf_passthrough;
extern AVFilter avfilter_vf_rgb2bgr;
Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c (original)
+++ libavfilter/avfilter.c Mon Aug 20 07:27:17 2007
@@ -329,6 +329,7 @@ void avfilter_init(void)
avfilter_register(&avfilter_vf_graph);
avfilter_register(&avfilter_vf_graphdesc);
avfilter_register(&avfilter_vf_graphfile);
+ avfilter_register(&avfilter_vf_negate);
avfilter_register(&avfilter_vf_overlay);
avfilter_register(&avfilter_vf_passthrough);
avfilter_register(&avfilter_vf_rgb2bgr);
Added: libavfilter/vf_negate.c
==============================================================================
--- (empty file)
+++ libavfilter/vf_negate.c Mon Aug 20 07:27:17 2007
@@ -0,0 +1,111 @@
+/*
+ * Video negative filter
+ * copyright (c) 2007 Bobby Bingham
+ *
+ * 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 offY, offUV;
+ int hsub, vsub;
+} NegContext;
+
+static int *query_formats(AVFilterLink *link)
+{
+ return 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);
+}
+
+static int config_props(AVFilterLink *link)
+{
+ NegContext *neg = link->dst->priv;
+
+ avcodec_get_chroma_sub_sample(link->format, &neg->hsub, &neg->vsub);
+
+ switch(link->format) {
+ case PIX_FMT_YUVJ444P:
+ case PIX_FMT_YUVJ422P:
+ case PIX_FMT_YUVJ420P:
+ case PIX_FMT_YUVJ440P:
+ neg->offY =
+ neg->offUV = 0;
+ break;
+ default:
+ neg->offY = -4;
+ neg->offUV = 1;
+ }
+
+ return 0;
+}
+
+static void draw_slice(AVFilterLink *link, int y, int h)
+{
+ NegContext *neg = 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 */
+ inrow = in-> data[0] + y * in-> linesize[0];
+ outrow = out->data[0] + y * out->linesize[0];
+ for(i = 0; i < h; i ++) {
+ for(j = 0; j < link->w; j ++)
+ outrow[j] = 255 - inrow[j] + neg->offY;
+ inrow += in-> linesize[0];
+ outrow += out->linesize[0];
+ }
+
+ /* chroma planes */
+ for(plane = 1; plane < 3; plane ++) {
+ inrow = in-> data[plane] + (y >> neg->vsub) * in-> linesize[plane];
+ outrow = out->data[plane] + (y >> neg->vsub) * out->linesize[plane];
+
+ for(i = 0; i < h >> neg->vsub; i ++) {
+ for(j = 0; j < link->w >> neg->hsub; j ++)
+ outrow[j] = 255 - inrow[j] + neg->offUV;
+ inrow += in-> linesize[plane];
+ outrow += out->linesize[plane];
+ }
+ }
+}
+
+AVFilter avfilter_vf_negate =
+{
+ .name = "negate",
+ .author = "Bobby Bingham",
+
+ .priv_size = sizeof(NegContext),
+
+ .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}},
+ .outputs = (AVFilterPad[]) {{ .name = "default",
+ .type = AV_PAD_VIDEO, },
+ { .name = NULL}},
+};
+
More information about the FFmpeg-soc
mailing list