00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025 #define CMAP_RGB2_SIZE 256
00026
00033 struct chroma_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;
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 E_(I420_RGB8) ( vout_thread_t *, picture_t *, picture_t * );
00060 void E_(I420_RGB16_dither) ( vout_thread_t *, picture_t *, picture_t * );
00061 #endif
00062 void E_(I420_RGB16) ( vout_thread_t *, picture_t *, picture_t * );
00063 void E_(I420_RGB32) ( vout_thread_t *, picture_t *, picture_t * );
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #define CONVERT_Y_PIXEL( BPP ) \
00074 \
00075 p_ybase = p_yuv + *p_y++; \
00076 *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128)>>SHIFT) + i_red] | \
00077 p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) \
00078 + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128)>>SHIFT) + i_blue];
00079
00080 #define CONVERT_YUV_PIXEL( BPP ) \
00081 \
00082 i_uval = *p_u++; \
00083 i_vval = *p_v++; \
00084 i_red = (V_RED_COEF * i_vval) >> SHIFT; \
00085 i_green = (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT; \
00086 i_blue = (U_BLUE_COEF * i_uval) >> SHIFT; \
00087 CONVERT_Y_PIXEL( BPP ) \
00088
00089 #define CONVERT_Y_PIXEL_DITHER( BPP ) \
00090 \
00091 p_ybase = p_yuv + *p_y++; \
00092 *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128+p_dither[i_real_y])>>SHIFT) + i_red] | \
00093 p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128+p_dither[i_real_y])>>SHIFT) \
00094 + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128+p_dither[i_real_y])>>SHIFT) + i_blue];
00095
00096 #define CONVERT_YUV_PIXEL_DITHER( BPP ) \
00097 \
00098 i_uval = *p_u++; \
00099 i_vval = *p_v++; \
00100 i_red = (V_RED_COEF * i_vval) >> SHIFT; \
00101 i_green = (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT; \
00102 i_blue = (U_BLUE_COEF * i_uval) >> SHIFT; \
00103 CONVERT_Y_PIXEL_DITHER( BPP ) \
00104
00105 #define CONVERT_4YUV_PIXEL( CHROMA ) \
00106 *p_pic++ = p_lookup[ \
00107 (((*p_y++ + dither10[i_real_y]) >> 4) << 7) \
00108 + ((*p_u + dither20[i_real_y]) >> 5) * 9 \
00109 + ((*p_v + dither20[i_real_y]) >> 5) ]; \
00110 *p_pic++ = p_lookup[ \
00111 (((*p_y++ + dither11[i_real_y]) >> 4) << 7) \
00112 + ((*p_u++ + dither21[i_real_y]) >> 5) * 9 \
00113 + ((*p_v++ + dither21[i_real_y]) >> 5) ]; \
00114 *p_pic++ = p_lookup[ \
00115 (((*p_y++ + dither12[i_real_y]) >> 4) << 7) \
00116 + ((*p_u + dither22[i_real_y]) >> 5) * 9 \
00117 + ((*p_v + dither22[i_real_y]) >> 5) ]; \
00118 *p_pic++ = p_lookup[ \
00119 (((*p_y++ + dither13[i_real_y]) >> 4) << 7) \
00120 + ((*p_u++ + dither23[i_real_y]) >> 5) * 9 \
00121 + ((*p_v++ + dither23[i_real_y]) >> 5) ]; \
00122
00123 #define CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00124 *p_pic++ = p_lookup[ \
00125 ( ((*p_y + dither10[i_real_y]) >> 4) << 7) \
00126 + ((*p_u + dither20[i_real_y]) >> 5) * 9 \
00127 + ((*p_v + dither20[i_real_y]) >> 5) ]; \
00128 p_y += *p_offset++; \
00129 p_u += *p_offset; \
00130 p_v += *p_offset++; \
00131 *p_pic++ = p_lookup[ \
00132 ( ((*p_y + dither11[i_real_y]) >> 4) << 7) \
00133 + ((*p_u + dither21[i_real_y]) >> 5) * 9 \
00134 + ((*p_v + dither21[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 + dither12[i_real_y]) >> 4) << 7) \
00140 + ((*p_u + dither22[i_real_y]) >> 5) * 9 \
00141 + ((*p_v + dither22[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 + dither13[i_real_y]) >> 4) << 7) \
00147 + ((*p_u + dither23[i_real_y]) >> 5) * 9 \
00148 + ((*p_v + dither23[i_real_y]) >> 5) ]; \
00149 p_y += *p_offset++; \
00150 p_u += *p_offset; \
00151 p_v += *p_offset++; \
00152
00153
00154
00155
00156
00157
00158
00159 #define SCALE_WIDTH \
00160 if( b_hscale ) \
00161 { \
00162
00163 \
00164 p_buffer = p_buffer_start; \
00165 p_offset = p_offset_start; \
00166 for( i_x = p_vout->output.i_width / 16; i_x--; ) \
00167 { \
00168 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00169 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00170 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00171 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00172 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00173 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00174 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
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 } \
00185 for( i_x = p_vout->output.i_width & 15; i_x--; ) \
00186 { \
00187 *p_pic++ = *p_buffer; p_buffer += *p_offset++; \
00188 } \
00189 p_pic = (void*)((uint8_t*)p_pic + i_right_margin ); \
00190 } \
00191 else \
00192 { \
00193
00194 \
00195 p_pic = (void*)((uint8_t*)p_pic + p_dest->p->i_pitch ); \
00196 } \
00197
00198
00199
00200
00201
00202
00203 #define SCALE_WIDTH_DITHER( CHROMA ) \
00204 if( b_hscale ) \
00205 { \
00206 \
00207 p_offset = p_offset_start; \
00208 for( i_x = p_vout->output.i_width / 16; i_x--; ) \
00209 { \
00210 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00211 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00212 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00213 CONVERT_4YUV_PIXEL_SCALE( CHROMA ) \
00214 } \
00215 } \
00216 else \
00217 { \
00218 for( i_x = p_vout->render.i_width / 16; i_x--; ) \
00219 { \
00220 CONVERT_4YUV_PIXEL( CHROMA ) \
00221 CONVERT_4YUV_PIXEL( CHROMA ) \
00222 CONVERT_4YUV_PIXEL( CHROMA ) \
00223 CONVERT_4YUV_PIXEL( CHROMA ) \
00224 } \
00225 } \
00226 \
00227 p_pic = (void*)((uint8_t*)p_pic + i_right_margin ); \
00228 \
00229 \
00230 i_real_y = (i_real_y + 1) & 0x3; \
00231
00232
00233
00234
00235
00236
00237
00238
00239 #define SCALE_HEIGHT( CHROMA, BPP ) \
00240 \
00241 if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \
00242 { \
00243 p_u -= i_chroma_width; \
00244 p_v -= i_chroma_width; \
00245 } \
00246 \
00247
00248
00249
00250 \
00251 switch( i_vscale ) \
00252 { \
00253 case -1: \
00254 while( (i_scale_count -= p_vout->output.i_height) > 0 ) \
00255 { \
00256 \
00257 p_y += p_vout->render.i_width; \
00258 i_y++; \
00259 if( (CHROMA == 420) || (CHROMA == 422) ) \
00260 { \
00261 if( i_y & 0x1 ) \
00262 { \
00263 p_u += i_chroma_width; \
00264 p_v += i_chroma_width; \
00265 } \
00266 } \
00267 else if( CHROMA == 444 ) \
00268 { \
00269 p_u += p_vout->render.i_width; \
00270 p_v += p_vout->render.i_width; \
00271 } \
00272 } \
00273 i_scale_count += p_vout->render.i_height; \
00274 break; \
00275 case 1: \
00276 while( (i_scale_count -= p_vout->render.i_height) > 0 ) \
00277 { \
00278 \
00279 p_vout->p_vlc->pf_memcpy( p_pic, p_pic_start, \
00280 p_vout->output.i_width * BPP ); \
00281 p_pic = (void*)((uint8_t*)p_pic + p_dest->p->i_pitch ); \
00282 } \
00283 i_scale_count += p_vout->output.i_height; \
00284 break; \
00285 } \
00286
00287
00288
00289
00290
00291
00292
00293 #define SCALE_HEIGHT_DITHER( CHROMA ) \
00294 \
00295 \
00296 if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \
00297 { \
00298 p_u -= i_chroma_width; \
00299 p_v -= i_chroma_width; \
00300 } \
00301 \
00302
00303
00304
00305 \
00306 \
00307 switch( i_vscale ) \
00308 { \
00309 case -1: \
00310 while( (i_scale_count -= p_vout->output.i_height) > 0 ) \
00311 { \
00312 \
00313 p_y += p_vout->render.i_width; \
00314 i_y++; \
00315 if( (CHROMA == 420) || (CHROMA == 422) ) \
00316 { \
00317 if( i_y & 0x1 ) \
00318 { \
00319 p_u += i_chroma_width; \
00320 p_v += i_chroma_width; \
00321 } \
00322 } \
00323 else if( CHROMA == 444 ) \
00324 { \
00325 p_u += p_vout->render.i_width; \
00326 p_v += p_vout->render.i_width; \
00327 } \
00328 } \
00329 i_scale_count += p_vout->render.i_height; \
00330 break; \
00331 case 1: \
00332 while( (i_scale_count -= p_vout->render.i_height) > 0 ) \
00333 { \
00334 p_y -= p_vout->render.i_width; \
00335 p_u -= i_chroma_width; \
00336 p_v -= i_chroma_width; \
00337 SCALE_WIDTH_DITHER( CHROMA ); \
00338 } \
00339 i_scale_count += p_vout->output.i_height; \
00340 break; \
00341 } \
00342