00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <filters/sum.h>
00025
00026 #include <fvutils/color/yuv.h>
00027
00028 #include <cstddef>
00029
00030 namespace firevision {
00031 #if 0
00032 }
00033 #endif
00034
00035
00036
00037
00038
00039
00040
00041
00042 FilterSum::FilterSum()
00043 : Filter("FilterSum", 2)
00044 {
00045 }
00046
00047
00048 void
00049 FilterSum::apply()
00050 {
00051 if ( src[0] == NULL ) return;
00052 if ( src[1] == NULL ) return;
00053 if ( src_roi[0] == NULL ) return;
00054 if ( src_roi[1] == NULL ) return;
00055
00056 register unsigned int h = 0;
00057 register unsigned int w = 0;
00058
00059
00060
00061 register unsigned char *byp = src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step);
00062
00063 register unsigned char *bup = YUV422_PLANAR_U_PLANE(src[0], src_roi[0]->image_width, src_roi[0]->image_height)
00064 + ((src_roi[0]->start.y * src_roi[0]->line_step) / 2 + (src_roi[0]->start.x * src_roi[0]->pixel_step) / 2) ;
00065
00066 register unsigned char *bvp = YUV422_PLANAR_V_PLANE(src[0], src_roi[0]->image_width, src_roi[0]->image_height)
00067 + ((src_roi[0]->start.y * src_roi[0]->line_step) / 2 + (src_roi[0]->start.x * src_roi[0]->pixel_step) / 2);
00068
00069
00070
00071 register unsigned char *fyp = src[1] + (src_roi[1]->start.y * src_roi[1]->line_step) + (src_roi[1]->start.x * src_roi[1]->pixel_step);
00072
00073 register unsigned char *fup = YUV422_PLANAR_U_PLANE(src[1], src_roi[1]->image_width, src_roi[1]->image_height)
00074 + ((src_roi[1]->start.y * src_roi[1]->line_step) / 2 + (src_roi[1]->start.x * src_roi[1]->pixel_step) / 2) ;
00075
00076 register unsigned char *fvp = YUV422_PLANAR_V_PLANE(src[1], src_roi[1]->image_width, src_roi[1]->image_height)
00077 + ((src_roi[1]->start.y * src_roi[1]->line_step) / 2 + (src_roi[1]->start.x * src_roi[1]->pixel_step) / 2);
00078
00079
00080
00081 register unsigned char *dyp = dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step);
00082
00083 register unsigned char *dup = YUV422_PLANAR_U_PLANE(dst, dst_roi->image_width, dst_roi->image_height)
00084 + ((dst_roi->start.y * dst_roi->line_step) / 2 + (dst_roi->start.x * dst_roi->pixel_step) / 2) ;
00085
00086 register unsigned char *dvp = YUV422_PLANAR_V_PLANE(dst, dst_roi->image_width, dst_roi->image_height)
00087 + ((dst_roi->start.y * dst_roi->line_step) / 2 + (dst_roi->start.x * dst_roi->pixel_step) / 2);
00088
00089
00090 unsigned char *lbyp = byp;
00091 unsigned char *lbup = fup;
00092 unsigned char *lbvp = fvp;
00093 unsigned char *lfyp = fyp;
00094 unsigned char *lfup = fup;
00095 unsigned char *lfvp = fvp;
00096 unsigned char *ldyp = dyp;
00097 unsigned char *ldup = dup;
00098 unsigned char *ldvp = dvp;
00099
00100 for (h = 0; (h < src_roi[1]->height) && (h < dst_roi->height); ++h) {
00101 for (w = 0; (w < src_roi[1]->width) && (w < dst_roi->width); w += 2) {
00102 *dyp++ = ((*byp + *fyp) > 255) ? 255 : (*byp + *fyp);
00103 ++byp; ++fyp;
00104 *dyp++ = ((*byp + *fyp) > 255) ? 255 : (*byp + *fyp);
00105 ++byp; ++fyp;
00106
00107 *dup++ = (*fup++ + *bup++) / 2;
00108 *dvp++ = (*fvp++ + *bvp++) / 2;
00109 }
00110
00111 lbyp += src_roi[0]->line_step;
00112 lbup += src_roi[0]->line_step / 2;
00113 lbvp += src_roi[0]->line_step / 2;
00114 lfyp += src_roi[1]->line_step;
00115 lfup += src_roi[1]->line_step / 2;
00116 lfvp += src_roi[1]->line_step / 2;
00117 ldyp += dst_roi->line_step;
00118 ldup += dst_roi->line_step / 2;
00119 ldvp += dst_roi->line_step / 2;
00120 byp = lbyp;
00121 bup = lbup;
00122 bvp = lbvp;
00123 fyp = lfyp;
00124 fup = lfup;
00125 fvp = lfvp;
00126 dyp = ldyp;
00127 dup = ldup;
00128 dvp = ldvp;
00129 }
00130
00131 }
00132
00133 }