i420_rgb.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #define CMAP_RGB2_SIZE 256
00026
00027
00028
00029
00030
00031
00032
00033 struct filter_sys_t
00034 {
00035 uint8_t *p_buffer;
00036 int *p_offset;
00037
00038 #ifdef MODULE_NAME_IS_i420_rgb
00039
00040 void *p_base;
00041 uint8_t *p_rgb8;
00042 uint16_t *p_rgb16;
00043 uint32_t *p_rgb32;
00044
00045
00046
00047
00048
00049 uint16_t p_rgb_r[CMAP_RGB2_SIZE];
00050 uint16_t p_rgb_g[CMAP_RGB2_SIZE];
00051 uint16_t p_rgb_b[CMAP_RGB2_SIZE];
00052 #endif
00053 };
00054
00055
00056
00057
00058 #ifdef MODULE_NAME_IS_i420_rgb
00059 void I420_RGB8 ( filter_t *, picture_t *, picture_t * );
00060 void I420_RGB16_dither ( filter_t *, picture_t *, picture_t * );
00061 void I420_RGB16 ( filter_t *, picture_t *, picture_t * );
00062 void I420_RGB32 ( filter_t *, picture_t *, picture_t * );
00063 #else // if defined(MODULE_NAME_IS_i420_rgb_mmx)
00064 void I420_R5G5B5 ( filter_t *, picture_t *, picture_t * );
00065 void I420_R5G6B5 ( filter_t *, picture_t *, picture_t * );
00066 void I420_A8R8G8B8 ( filter_t *, picture_t *, picture_t * );
00067 void I420_R8G8B8A8 ( filter_t *, picture_t *, picture_t * );
00068 void I420_B8G8R8A8 ( filter_t *, picture_t *, picture_t * );
00069 void I420_A8B8G8R8 ( filter_t *, picture_t *, picture_t * );
00070 #endif
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 #define CONVERT_Y_PIXEL( BPP ) \
00081 \
00082 p_ybase = p_yuv + *p_y++; \
00083 *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128)>>SHIFT) + i_red] | \
00084 p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) \
00085 + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128)>>SHIFT) + i_blue];
00086
00087 #define CONVERT_YUV_PIXEL( BPP ) \
00088 \
00089 i_uval = *p_u++; \
00090 i_vval = *p_v++; \
00091 i_red = (V_RED_COEF * i_vval) >> SHIFT; \
00092 i_green = (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT; \
00093 i_blue = (U_BLUE_COEF * i_uval) >> SHIFT; \
00094 CONVERT_Y_PIXEL( BPP ) \
00095
00096 #define CONVERT_Y_PIXEL_DITHER( BPP ) \
00097 \
00098 p_ybase = p_yuv + *p_y++; \
00099 *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128+p_dither[i_real_y])>>SHIFT) + i_red] | \
00100 p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128+p_dither[i_real_y])>>SHIFT) \
00101 + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128+p_dither[i_real_y])>>SHIFT) + i_blue];
00102
00103 #define CONVERT_YUV_PIXEL_DITHER( BPP ) \
00104 \
00105 i_uval = *p_u++; \
00106 i_vval = *p_v++; \
00107 i_red = (V_RED_COEF * i_vval) >> SHIFT; \
00108 i_green = (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT; \
00109 i_blue = (U_BLUE_COEF * i_uval) >> SHIFT; \
00110 CONVERT_Y_PIXEL_DITHER( BPP ) \
00111
00112 #define CONVERT_4YUV_PIXEL( CHROMA ) \
00113 *p_pic++ = p_lookup[ \
00114 (((*p_y++ + dither10[i_real_y]) >> 4) << 7) \
00115 + ((*p_u + dither20[i_real_y]) >> 5) * 9 \
00116 + ((*p_v + dither20[i_real_y]) >> 5) ]; \
00117 *p_pic++ = p_lookup[ \
00118 (((*p_y++ + dither11[i_real_y]) >> 4) << 7) \
00119 + ((*p_u++ + dither21[i_real_y]) >> 5) * 9 \
00120 + ((*p_v++ + dither21[i_real_y]) >> 5) ]; \
00121 *p_pic++ = p_lookup[ \
00122 (((*p_y++ + dither12[i_real_y]) >> 4) << 7) \
00123 + ((*p_u + dither22[i_real_y]) >> 5) * 9 \
00124 + ((*p_v + dither22[i_real_y]) >> 5) ]; \
00125 *p_pic++ = p_lookup[ \
00126 (((*p_y++ + dither13[i_real_y]) >> 4) << 7) \
00127 + ((*p_u++ + dither23[i_real_y]) >> 5) * 9 \
00128 + ((*p_v++ + dither23[i_real_y]) >> 5) ]; \
00129
00130 #define CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00131 *p_pic++ = p_lookup[ \
00132 ( ((*p_y + dither10[i_real_y]) >> 4) << 7) \
00133 + ((*p_u + dither20[i_real_y]) >> 5) * 9 \
00134 + ((*p_v + dither20[i_real_y]) >> 5) ]; \
00135 p_y += *p_offset++; \
00136 p_u += *p_offset; \
00137 p_v += *p_offset++; \
00138 *p_pic++ = p_lookup[ \
00139 ( ((*p_y + dither11[i_real_y]) >> 4) << 7) \
00140 + ((*p_u + dither21[i_real_y]) >> 5) * 9 \
00141 + ((*p_v + dither21[i_real_y]) >> 5) ]; \
00142 p_y += *p_offset++; \
00143 p_u += *p_offset; \
00144 p_v += *p_offset++; \
00145 *p_pic++ = p_lookup[ \
00146 ( ((*p_y + dither12[i_real_y]) >> 4) << 7) \
00147 + ((*p_u + dither22[i_real_y]) >> 5) * 9 \
00148 + ((*p_v + dither22[i_real_y]) >> 5) ]; \
00149 p_y += *p_offset++; \
00150 p_u += *p_offset; \
00151 p_v += *p_offset++; \
00152 *p_pic++ = p_lookup[ \
00153 ( ((*p_y + dither13[i_real_y]) >> 4) << 7) \
00154 + ((*p_u + dither23[i_real_y]) >> 5) * 9 \
00155 + ((*p_v + dither23[i_real_y]) >> 5) ]; \
00156 p_y += *p_offset++; \
00157 p_u += *p_offset; \
00158 p_v += *p_offset++; \
00159
00160
00161
00162
00163
00164
00165
00166 #define SCALE_WIDTH \
00167 if( b_hscale ) \
00168 { \
00169
00170 \
00171 p_buffer = p_buffer_start; \
00172 p_offset = p_offset_start; \
00173 for( i_x = p_filter->fmt_out.video.i_width / 16; i_x--; ) \
00174 { \
00175 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00176 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00177 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00178 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00179 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00180 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00181 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00182 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00183 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00184 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00185 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00186 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00187 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00188 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00189 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00190 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00191 } \
00192 for( i_x = p_filter->fmt_out.video.i_width & 15; i_x--; ) \
00193 { \
00194 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00195 } \
00196 p_pic = (void*)((uint8_t*)p_pic + i_right_margin ); \
00197 } \
00198 else \
00199 { \
00200
00201 \
00202 p_pic = (void*)((uint8_t*)p_pic + p_dest->p->i_pitch ); \
00203 } \
00204
00205
00206
00207
00208
00209
00210 #define SCALE_WIDTH_DITHER( CHROMA ) \
00211 if( b_hscale ) \
00212 { \
00213 \
00214 p_offset = p_offset_start; \
00215 for( i_x = p_filter->fmt_out.video.i_width / 16; i_x--; ) \
00216 { \
00217 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00218 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00219 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00220 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00221 } \
00222 } \
00223 else \
00224 { \
00225 for( i_x = p_filter->fmt_in.video.i_width / 16; i_x--; ) \
00226 { \
00227 CONVERT_4YUV_PIXEL( CHROMA ) \
00228 CONVERT_4YUV_PIXEL( CHROMA ) \
00229 CONVERT_4YUV_PIXEL( CHROMA ) \
00230 CONVERT_4YUV_PIXEL( CHROMA ) \
00231 } \
00232 } \
00233 \
00234 p_pic = (void*)((uint8_t*)p_pic + i_right_margin ); \
00235 \
00236 \
00237 i_real_y = (i_real_y + 1) & 0x3; \
00238
00239
00240
00241
00242
00243
00244
00245
00246 #define SCALE_HEIGHT( CHROMA, BPP ) \
00247 \
00248 if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \
00249 { \
00250 p_u -= i_chroma_width; \
00251 p_v -= i_chroma_width; \
00252 } \
00253 \
00254
00255
00256
00257 \
00258 switch( i_vscale ) \
00259 { \
00260 case -1: \
00261 while( (i_scale_count -= p_filter->fmt_out.video.i_height) > 0 ) \
00262 { \
00263 \
00264 p_y += p_filter->fmt_in.video.i_width; \
00265 i_y++; \
00266 if( (CHROMA == 420) || (CHROMA == 422) ) \
00267 { \
00268 if( i_y & 0x1 ) \
00269 { \
00270 p_u += i_chroma_width; \
00271 p_v += i_chroma_width; \
00272 } \
00273 } \
00274 else if( CHROMA == 444 ) \
00275 { \
00276 p_u += p_filter->fmt_in.video.i_width; \
00277 p_v += p_filter->fmt_in.video.i_width; \
00278 } \
00279 } \
00280 i_scale_count += p_filter->fmt_in.video.i_height; \
00281 break; \
00282 case 1: \
00283 while( (i_scale_count -= p_filter->fmt_in.video.i_height) > 0 ) \
00284 { \
00285 \
00286 vlc_memcpy( p_pic, p_pic_start, p_filter->fmt_out.video.i_width * BPP ); \
00287 p_pic = (void*)((uint8_t*)p_pic + p_dest->p->i_pitch ); \
00288 } \
00289 i_scale_count += p_filter->fmt_out.video.i_height; \
00290 break; \
00291 } \
00292
00293
00294
00295
00296
00297
00298
00299 #define SCALE_HEIGHT_DITHER( CHROMA ) \
00300 \
00301 \
00302 if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \
00303 { \
00304 p_u -= i_chroma_width; \
00305 p_v -= i_chroma_width; \
00306 } \
00307 \
00308
00309
00310
00311 \
00312 \
00313 switch( i_vscale ) \
00314 { \
00315 case -1: \
00316 while( (i_scale_count -= p_filter->fmt_out.video.i_height) > 0 ) \
00317 { \
00318 \
00319 p_y += p_filter->fmt_in.video.i_width; \
00320 i_y++; \
00321 if( (CHROMA == 420) || (CHROMA == 422) ) \
00322 { \
00323 if( i_y & 0x1 ) \
00324 { \
00325 p_u += i_chroma_width; \
00326 p_v += i_chroma_width; \
00327 } \
00328 } \
00329 else if( CHROMA == 444 ) \
00330 { \
00331 p_u += p_filter->fmt_in.video.i_width; \
00332 p_v += p_filter->fmt_in.video.i_width; \
00333 } \
00334 } \
00335 i_scale_count += p_filter->fmt_in.video.i_height; \
00336 break; \
00337 case 1: \
00338 while( (i_scale_count -= p_filter->fmt_in.video.i_height) > 0 ) \
00339 { \
00340 p_y -= p_filter->fmt_in.video.i_width; \
00341 p_u -= i_chroma_width; \
00342 p_v -= i_chroma_width; \
00343 SCALE_WIDTH_DITHER( CHROMA ); \
00344 } \
00345 i_scale_count += p_filter->fmt_out.video.i_height; \
00346 break; \
00347 } \
00348