1 #ifndef __OGGPLAY_YUV2RGB_TEMPLATE_H__
2 #define __OGGPLAY_YUV2RGB_TEMPLATE_H__
8 #define restrict __restrict__
13 * Template for YUV to RGB conversion
15 * @param FUNC function name
16 * @param CONVERT a macro that defines the actual conversion function
18 * @param NUM_PIXELS number of pixels processed in one iteration
19 * @param OUT_SHIFT number of pixels to shift after one iteration in rgb data stream
20 * @param Y_SHIFT number of pixels to shift after one iteration in Y data stream
24 #define YUV_CONVERT(FUNC, CONVERT, VANILLA_OUT, NUM_PIXELS, OUT_SHIFT, Y_SHIFT, UV_SHIFT, UV_VERT_SUB)\
26 (FUNC)(const OggPlayYUVChannels* yuv, OggPlayRGBChannels* rgb) \
29 unsigned char* restrict ptry; \
30 unsigned char* restrict ptru; \
31 unsigned char* restrict ptrv; \
32 unsigned char* restrict ptro; \
33 unsigned char *dst, *py, *pu, *pv; \
40 w = yuv->y_width / NUM_PIXELS; \
42 r = yuv->y_width % NUM_PIXELS; \
43 for (i = 0; i < h; ++i) \
49 for (j = 0; j < w; ++j, \
55 /* use the given conversion function */ \
59 * the video frame is not the multiple of NUM_PIXELS, \
60 * thus we have to deal with remaning pixels using \
61 * vanilla implementation. \
64 if (r==1 && yuv->y_width&1) { \
70 j=(yuv->y_width-r); j < yuv->y_width; \
77 VANILLA_YUV2RGB_PIXEL(py[0], ruv, guv, buv) \
78 VANILLA_OUT(dst, r, g, b) \
81 (j%2 && !(j+1==yuv->y_width-1 && yuv->y_width&1)) \
90 ptro += rgb->rgb_width * 4; \
91 ptry += yuv->y_width; \
95 (i & 0x1 && !(i+1==h-1 && h&1)) \
100 ptru += yuv->uv_width; \
101 ptrv += yuv->uv_width; \