Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavfilter / edge_common.h
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 /**
20  * @file
21  * common functions for edge detection
22  */
23
24 #ifndef AVFILTER_EDGE_COMMON_H
25 #define AVFILTER_EDGE_COMMON_H
26
27 #include "avfilter.h"
28
29 /**
30  * @brief Rounded directions used in av_image_sobel()
31  */
32 enum AVRoundedDirection {
33     DIRECTION_45UP,
34     DIRECTION_45DOWN,
35     DIRECTION_HORIZONTAL,
36     DIRECTION_VERTICAL,
37 };
38
39 /**
40  * Simple sobel operator to get rounded gradients
41  *
42  * @param w             the width of the image in pixels
43  * @param h             the height of the image in pixels
44  * @param dst           data pointers to magnitude image
45  * @param dst_linesize  linesizes for the magnitude image
46  * @param dir           data pointers to direction image
47  * @param dir_linesize  linesizes for the direction image
48  * @param src           data pointers to source image
49  * @param src_linesize  linesizes for the source image
50  */
51 #define PROTO_SOBEL(depth) \
52 void ff_sobel_##depth(int w, int h,                                          \
53                       uint16_t *dst, int dst_linesize,                       \
54                       int8_t *dir, int dir_linesize,                         \
55                       const uint8_t *src, int src_linesize, int src_stride);
56
57 PROTO_SOBEL(8)
58 PROTO_SOBEL(16)
59
60 /**
61  * Filters rounded gradients to drop all non-maxima pixels in the magnitude image
62  * Expects gradients generated by av_image_sobel()
63  * Expects zero's in the destination buffer dst
64  *
65  * @param w             the width of the image in pixels
66  * @param h             the height of the image in pixels
67  * @param dst           data pointers to magnitude image
68  * @param dst_linesize  linesizes for the magnitude image
69  * @param dir           data pointers to direction image
70  * @param dir_linesize  linesizes for the direction image
71  * @param src           data pointers to source image
72  * @param src_linesize  linesizes for the source image
73  */
74 void ff_non_maximum_suppression(int w, int h,
75                                 uint8_t *dst, int dst_linesize,
76                                 const int8_t *dir, int dir_linesize,
77                                 const uint16_t *src, int src_linesize);
78
79 /**
80  * Filters all pixels in src to keep all pixels > high,
81  * and keep all pixels > low where all surrounding pixels > high
82  *
83  * @param low           the low threshold value
84  * @param high          the hegh threshold value
85  * @param w             the width of the image in pixels
86  * @param h             the height of the image in pixels
87  * @param dst           data pointers to destination image
88  * @param dst_linesize  linesizes for the destination image
89  * @param src           data pointers to source image
90  * @param src_linesize  linesizes for the source image
91  */
92 void ff_double_threshold(int low, int high, int w, int h,
93                          uint8_t *dst, int dst_linesize,
94                          const uint8_t *src, int src_linesize);
95
96 /**
97  * Applies gaussian blur.
98  * 5x5 kernels, sigma = 1.4
99  *
100  * @param w             the width of the image in pixels
101  * @param h             the height of the image in pixels
102  * @param dst           data pointers to destination image
103  * @param dst_linesize  linesizes for the destination image
104  * @param src           data pointers to source image
105  * @param src_linesize  linesizes for the source image
106  */
107 #define PROTO_GAUSSIAN_BLUR(depth)                                                   \
108 void ff_gaussian_blur_##depth(int w, int h,                                          \
109                               uint8_t *dst, int dst_linesize,                        \
110                               const uint8_t *src, int src_linesize, int src_stride);
111
112 PROTO_GAUSSIAN_BLUR(8)
113 PROTO_GAUSSIAN_BLUR(16)
114
115 #endif