aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDjordje Senicic2016-03-23 06:15:25 -0500
committerDjordje Senicic2016-03-23 06:15:25 -0500
commit42db17095af031d8b5942b556b4546ba0c149d02 (patch)
treee3d3d5e6615f44720f9b913f21ca478fd2b94a8a
parent5a10937564728c0c5446de867b7b53fe0733c88c (diff)
downloadgst-plugin-dsp66-42db17095af031d8b5942b556b4546ba0c149d02.tar.gz
gst-plugin-dsp66-42db17095af031d8b5942b556b4546ba0c149d02.tar.xz
gst-plugin-dsp66-42db17095af031d8b5942b556b4546ba0c149d02.zip
Add conv5x5 kernel
-rw-r--r--src/gstdsp66videokernel.c2
-rw-r--r--src/gstdsp66videokernel.h4
-rw-r--r--src/kernels/oclconv/conv.cl22
-rw-r--r--src/kernels/oclconv/oclconv.cpp6
4 files changed, 32 insertions, 2 deletions
diff --git a/src/gstdsp66videokernel.c b/src/gstdsp66videokernel.c
index 525c768..48c7764 100644
--- a/src/gstdsp66videokernel.c
+++ b/src/gstdsp66videokernel.c
@@ -61,11 +61,13 @@ enum
61static const GEnumValue dsp66_video_kernel_filtersizes[] = { 61static const GEnumValue dsp66_video_kernel_filtersizes[] = {
62 {GST_DSP66_VIDEO_KERNEL_FILTERSIZE_5, "Kernel of 5 neighbour pixels", "5"}, 62 {GST_DSP66_VIDEO_KERNEL_FILTERSIZE_5, "Kernel of 5 neighbour pixels", "5"},
63 {GST_DSP66_VIDEO_KERNEL_FILTERSIZE_9, "Kernel of 9 neighbour pixels", "9"}, 63 {GST_DSP66_VIDEO_KERNEL_FILTERSIZE_9, "Kernel of 9 neighbour pixels", "9"},
64 {GST_DSP66_VIDEO_KERNEL_FILTERSIZE_25, "Kernel of 25 neighbour pixels", "25"},
64 {0, NULL, NULL}, 65 {0, NULL, NULL},
65}; 66};
66static const GEnumValue dsp66_video_kerneltype[] = { 67static const GEnumValue dsp66_video_kerneltype[] = {
67 {GST_DSP66_VIDEO_KERNELTYPE_MEDIAN, "Kernel median", "0"}, 68 {GST_DSP66_VIDEO_KERNELTYPE_MEDIAN, "Kernel median", "0"},
68 {GST_DSP66_VIDEO_KERNELTYPE_SOBEL, "Kernel sobel", "1"}, 69 {GST_DSP66_VIDEO_KERNELTYPE_SOBEL, "Kernel sobel", "1"},
70 {GST_DSP66_VIDEO_KERNELTYPE_CONV, "Kernel conv", "2"},
69 {0, NULL, NULL}, 71 {0, NULL, NULL},
70}; 72};
71 73
diff --git a/src/gstdsp66videokernel.h b/src/gstdsp66videokernel.h
index 7cb2c72..9d79b15 100644
--- a/src/gstdsp66videokernel.h
+++ b/src/gstdsp66videokernel.h
@@ -46,11 +46,13 @@ typedef enum
46{ 46{
47 GST_DSP66_VIDEO_KERNEL_FILTERSIZE_5 = 5, 47 GST_DSP66_VIDEO_KERNEL_FILTERSIZE_5 = 5,
48 GST_DSP66_VIDEO_KERNEL_FILTERSIZE_9 = 9, 48 GST_DSP66_VIDEO_KERNEL_FILTERSIZE_9 = 9,
49 GST_DSP66_VIDEO_KERNEL_FILTERSIZE_25 = 25
49} GstDsp66VideoKernelFilterSize; 50} GstDsp66VideoKernelFilterSize;
50 51
51typedef enum { 52typedef enum {
52 GST_DSP66_VIDEO_KERNELTYPE_MEDIAN = 0, 53 GST_DSP66_VIDEO_KERNELTYPE_MEDIAN = 0,
53 GST_DSP66_VIDEO_KERNELTYPE_SOBEL 54 GST_DSP66_VIDEO_KERNELTYPE_SOBEL = 1,
55 GST_DSP66_VIDEO_KERNELTYPE_CONV = 2
54} GstDsp66VideoKernelType; 56} GstDsp66VideoKernelType;
55 57
56struct _GstDsp66VideoKernel { 58struct _GstDsp66VideoKernel {
diff --git a/src/kernels/oclconv/conv.cl b/src/kernels/oclconv/conv.cl
index bc9aced..6c86e52 100644
--- a/src/kernels/oclconv/conv.cl
+++ b/src/kernels/oclconv/conv.cl
@@ -29,7 +29,8 @@
29#define PIX_SWAP(a,b) { unsigned char temp=(a);(a)=(b);(b)=temp; } 29#define PIX_SWAP(a,b) { unsigned char temp=(a);(a)=(b);(b)=temp; }
30 30
31void IMG_median_3x3_8 (const unsigned char *restrict in_data, int cols, unsigned char * restrict out_data); 31void IMG_median_3x3_8 (const unsigned char *restrict in_data, int cols, unsigned char * restrict out_data);
32void IMG_sobel_3x3_8 (const unsigned char *restrict in_data, unsigned char * restrict out_data, int rows, int cols); 32void IMG_sobel_3x3_8 (const unsigned char *restrict in_data, unsigned char *restrict out_data, int rows, int cols);
33void IMG_conv_3x3_i8_c8s (const unsigned char *restrict in_data, unsigned char *restrict out_data, int cols, const char *restrict mask, int shift);
33 34
34kernel void Median3x3(global const uchar* src, global uchar *dest, 35kernel void Median3x3(global const uchar* src, global uchar *dest,
35 const int width, const int height, 36 const int width, const int height,
@@ -52,6 +53,25 @@ kernel void Sobel3x3(global const uchar* src, global uchar *dest,
52 IMG_sobel_3x3_8((const unsigned char *)src, (const unsigned char *)dest, width, height); 53 IMG_sobel_3x3_8((const unsigned char *)src, (const unsigned char *)dest, width, height);
53} 54}
54 55
56kernel void Conv5x5(global const uchar* src, global uchar *dest,
57 const int width, const int height,
58 const int dstride, const int sstride)
59{
60 int i;
61 const char conv_mask5x5[25] = {
62 1, 4, 6, 4, 1,
63 4,16,24,16, 4,
64 6,24,36,24, 6,
65 4,16,24,16, 4,
66 1, 4, 6, 4, 1
67 };
68 for (i = 0; i < height; i++) {
69 IMG_conv_5x5_i8_c8s ((const unsigned char *)src, (unsigned char *)dest, width, sstride, conv_mask5x5, 8);
70 src += sstride;
71 dest += dstride;
72 }
73}
74
55kernel void Median2x2 (global const uchar* src, global uchar *dest, 75kernel void Median2x2 (global const uchar* src, global uchar *dest,
56 const int width, const int height, 76 const int width, const int height,
57 const int dstride, const int sstride) 77 const int dstride, const int sstride)
diff --git a/src/kernels/oclconv/oclconv.cpp b/src/kernels/oclconv/oclconv.cpp
index 601ea32..c7b722c 100644
--- a/src/kernels/oclconv/oclconv.cpp
+++ b/src/kernels/oclconv/oclconv.cpp
@@ -108,6 +108,12 @@ int oclconv_kernel(int kernel_type, int filter_size,
108 retval = oclconv_imgproc("Sobel3x3", data_in, data_out, width, height, sstride, dstride); 108 retval = oclconv_imgproc("Sobel3x3", data_in, data_out, width, height, sstride, dstride);
109 } 109 }
110 break; 110 break;
111 case 2: /* conv */
112 if(filter_size == 25) {
113 retval = oclconv_imgproc("Conv5x5", data_in, data_out, width, height, sstride, dstride);
114 return 0;
115 }
116 break;
111 default: 117 default:
112 break; 118 break;
113 } 119 }