1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2012 Christian König.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved.
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software.
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* implementation of a median filter for noise reduction */
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef vl_median_filter_h
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define vl_median_filter_h
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum vl_median_filter_shape
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   VL_MEDIAN_FILTER_BOX,
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   VL_MEDIAN_FILTER_CROSS,
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   VL_MEDIAN_FILTER_X,
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   VL_MEDIAN_FILTER_HORIZONTAL,
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   VL_MEDIAN_FILTER_VERTICAL
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct vl_median_filter
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_context *pipe;
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct pipe_vertex_buffer quad;
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *rs_state;
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *blend;
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *sampler;
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *ves;
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   void *vs, *fs;
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgbool
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvl_median_filter_init(struct vl_median_filter *filter, struct pipe_context *pipe,
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                      unsigned width, unsigned height, unsigned size,
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                      enum vl_median_filter_shape shape);
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvl_median_filter_cleanup(struct vl_median_filter *filter);
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvl_median_filter_render(struct vl_median_filter *filter,
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        struct pipe_sampler_view *src,
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                        struct pipe_surface *dst);
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* vl_median_filter_h */
71