+} \
+ \
+static void rgb_name ## _to_gray(AVPicture *dst, AVPicture *src, \
+ int width, int height) \
+{ \
+ const unsigned char *p; \
+ unsigned char *q; \
+ int r, g, b, dst_wrap, src_wrap; \
+ int x, y; \
+ \
+ p = src->data[0]; \
+ src_wrap = src->linesize[0] - BPP * width; \
+ \
+ q = dst->data[0]; \
+ dst_wrap = dst->linesize[0] - width; \
+ \
+ for(y=0;y<height;y++) { \
+ for(x=0;x<width;x++) { \
+ RGB_IN(r, g, b, p); \
+ q[0] = (FIX(0.29900) * r + FIX(0.58700) * g + \
+ FIX(0.11400) * b + ONE_HALF) >> SCALEBITS; \
+ q++; \
+ p += BPP; \
+ } \
+ p += src_wrap; \
+ q += dst_wrap; \
+ } \
+} \
+ \
+static void gray_to_ ## rgb_name(AVPicture *dst, AVPicture *src, \
+ int width, int height) \
+{ \
+ const unsigned char *p; \
+ unsigned char *q; \
+ int r, dst_wrap, src_wrap; \
+ int x, y; \
+ \
+ p = src->data[0]; \
+ src_wrap = src->linesize[0] - width; \
+ \
+ q = dst->data[0]; \
+ dst_wrap = dst->linesize[0] - BPP * width; \
+ \
+ for(y=0;y<height;y++) { \
+ for(x=0;x<width;x++) { \
+ r = p[0]; \
+ RGB_OUT(q, r, r, r); \
+ q += BPP; \
+ p ++; \
+ } \
+ p += src_wrap; \
+ q += dst_wrap; \
+ } \