-
-
-
-#define DOWNSAMPLE(type, temp_type, components, max) \
-{ \
- temp_type r; \
- temp_type g; \
- temp_type b; \
- temp_type a; \
- type **in_rows = (type**)src->get_rows(); \
- type **out_rows = (type**)dst->get_rows(); \
- \
- for(int i = 0; i < h; i += downsample) \
- { \
- int y1 = MAX(i, 0); \
- int y2 = MIN(i + downsample, h); \
- \
- \
- for(int j = 0; \
- j < w; \
- j += downsample) \
- { \
- int x1 = MAX(j, 0); \
- int x2 = MIN(j + downsample, w); \
- \
- temp_type scale = (x2 - x1) * (y2 - y1); \
- if(x2 > x1 && y2 > y1) \
- { \
- \
-/* Read in values */ \
- r = 0; \
- g = 0; \
- b = 0; \
- if(components == 4) a = 0; \
- \
- for(int k = y1; k < y2; k++) \
- { \
- type *row = in_rows[k] + x1 * components; \
- for(int l = x1; l < x2; l++) \
- { \
- r += *row++; \
- g += *row++; \
- b += *row++; \
- if(components == 4) a += *row++; \
- } \
- } \
- \
-/* Write average */ \
- r /= scale; \
- g /= scale; \
- b /= scale; \
- if(components == 4) a /= scale; \
- \
- type *row = out_rows[y1 / downsample] + \
- x1 / downsample * components; \
- *row++ = r; \
- *row++ = g; \
- *row++ = b; \
- if(components == 4) *row++ = a; \
- } \
- } \
-/*printf("DOWNSAMPLE 3 %d\n", i);*/ \
- } \
-}
-
-
-
-
-void MotionHVScan::downsample_frame(VFrame *dst,
- VFrame *src,
- int downsample)