Changeset 7bca0d7b134843b610ce68851bb1e605a347d2c9
- Timestamp:
- 01/02/04 05:44:34 (5 years ago)
- git-parent:
- Files:
-
- modules/codec/ogt/render.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/codec/ogt/render.c
r05f9878 r7bca0d7 3 3 ***************************************************************************** 4 4 * Copyright (C) 2003 VideoLAN 5 * $Id: render.c,v 1. 7 2004/01/01 15:56:56rocky Exp $5 * $Id: render.c,v 1.8 2004/01/02 04:44:34 rocky Exp $ 6 6 * 7 7 * Author: Rocky Bernstein … … 124 124 125 125 dbg_print( (DECODE_DBG_CALL|DECODE_DBG_RENDER), 126 "spu width : %d, height %d, pitch (%d, %d,%d)",127 p_spu->i_width, p_spu->i_height, 126 "spu width x height: (%dx%d), x-y (%d,%d), yuv pitch (%d,%d,%d)", 127 p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y, 128 128 p_pic->Y_PITCH, p_pic->U_PITCH, p_pic->V_PITCH ); 129 129 130 130 131 p_pixel_base = p_pic->p[Y_PLANE].p_pixels + p_spu->i_x + p_spu->i_width 132 + p_pic->p[Y_PLANE].i_pitch * ( p_spu->i_y + p_spu->i_height ); 133 134 i_x_start = p_spu->i_width - p_sys->i_x_end; 135 i_y_start = p_pic->p[Y_PLANE].i_pitch 136 * (p_spu->i_height - p_sys->i_y_end ); 137 138 i_x_end = p_spu->i_width - p_sys->i_x_start; 139 i_y_end = p_pic->p[Y_PLANE].i_pitch 140 * (p_spu->i_height - p_sys->i_y_start ); 131 p_pixel_base = p_pic->p[Y_PLANE].p_pixels + p_spu->i_x 132 + p_pic->p[Y_PLANE].i_pitch * p_spu->i_y; 133 134 i_x_start = p_sys->i_x_start; 135 i_y_start = p_pic->p[Y_PLANE].i_pitch * p_sys->i_y_start; 136 137 i_x_end = p_sys->i_x_end; 138 i_y_end = p_pic->p[Y_PLANE].i_pitch * p_sys->i_y_end; 141 139 142 140 p_source = (ogt_yuvt_t *)p_sys->p_data; 143 141 144 142 /* Draw until we reach the bottom of the subtitle */ 145 for( i_y = p_spu->i_height * p_pic->p[Y_PLANE].i_pitch ;146 i_y ;147 i_y -= p_pic->p[Y_PLANE].i_pitch )143 for( i_y = 0; 144 i_y < p_spu->i_height * p_pic->p[Y_PLANE].i_pitch ; 145 i_y += p_pic->p[Y_PLANE].i_pitch ) 148 146 { 149 147 /* printf("+++begin line: %d,\n", i++); */ 150 148 /* Draw until we reach the end of the line */ 151 for( i_x = p_spu->i_width ; i_x ; i_x--, p_source++ )149 for( i_x = 0; i_x < p_spu->i_width; i_x++, p_source++ ) 152 150 { 153 154 151 if( b_crop 155 152 && ( i_x < i_x_start || i_x > i_x_end … … 173 170 pixel with subtitle pixel. */ 174 171 175 uint8_t *p_pixel = p_pixel_base - i_x - i_y;176 uint 16_t i_colprecomp =177 (uint16_t) ( p_source->plane[Y_PLANE] * MAX_ALPHA );178 *p_pixel = i_colprecomp >> ALPHA_SCALEDOWN;172 /* This is the location that's going to get changed.*/ 173 uint8_t *p_pixel = p_pixel_base + i_x + i_y; 174 175 *p_pixel = p_source->plane[Y_PLANE]; 179 176 180 177 break; … … 185 182 /* Blend in underlying pixel subtitle pixel. */ 186 183 187 /* To be able to scale correctly for full opaqueness, we 188 add 1 to the alpha. This means alpha value 0 won't 189 be completely transparent and is not correct, but 190 that's handled in a special case above anyway. */ 191 192 uint8_t *p_pixel = p_pixel_base - i_x - i_y; 193 uint16_t i_colprecomp = 194 (uint16_t) ( p_source->plane[Y_PLANE] 195 * (uint16_t) (p_source->s.t+1) ); 196 uint16_t i_destalpha = MAX_ALPHA - p_source->s.t; 197 198 *p_pixel = ( i_colprecomp + 199 (uint16_t) (*p_pixel) * i_destalpha ) 200 >> ALPHA_SCALEDOWN; 184 /* This is the location that's going to get changed.*/ 185 uint8_t *p_pixel = p_pixel_base + i_x + i_y; 186 187 /* This is the weighted part of the subtitle. The 188 color plane is 8 bits and transparancy is 4 bits so 189 when multiplied we get up to 12 bits. 190 */ 191 uint16_t i_sub_color = 192 (uint16_t) ( p_source->plane[Y_PLANE] * 193 (uint16_t) (p_source->s.t) ); 194 195 /* This is the weighted part of the underlying pixel. 196 For the same reasons above, the result is up to 12 197 bits. However since the transparancies are 198 inverses, the sum of i_sub_color and i_pixel_color 199 will not exceed 12 bits. 200 */ 201 uint16_t i_pixel_color = 202 (uint16_t) ( *p_pixel * 203 (uint16_t) (MAX_ALPHA - p_source->s.t) ) ; 204 205 /* Scale the 12-bit result back down to 8 bits. A 206 precise scaling after adding the two components, 207 would divide by one less than a power of 2. However 208 to simplify and speed things we use a power of 209 2. This means the boundaries (either all 210 transparent and all opaque) aren't handled properly. 211 But we deal with them in special cases above. */ 212 213 *p_pixel = ( i_sub_color + i_pixel_color ) >> 4; 201 214 break; 202 215 } … … 207 220 208 221 209 #if FIXED210 for ( i_plane = U_PLANE; i_plane <= U_PLANE ; i_plane++ )222 #if 0 223 for ( i_plane = U_PLANE; i_plane <= V_PLANE ; i_plane++ ) 211 224 { 212 225 213 p_pixel_base = p_pic->p[i_plane].p_pixels 214 + ( p_spu->i_x + p_spu->i_width 215 + p_pic->p[i_plane].i_pitch * (p_spu->i_y + p_spu->i_height) )/2 ; 226 p_pixel_base = p_pic->p[i_plane].p_pixels + p_spu->i_x / 2 227 + p_pic->p[i_plane].i_pitch * p_spu->i_y / 2; 216 228 217 i_x_start = (p_spu->i_width - p_sys->i_x_end) >> 1; 218 i_y_start = p_pic->p[i_plane].i_pitch 219 * (p_spu->i_height - p_sys->i_y_end ); 220 221 i_x_end = (p_spu->i_width - p_sys->i_x_start ) >> 1; 222 i_y_end = p_pic->p[i_plane].i_pitch 223 * (p_spu->i_height - p_sys->i_y_start ); 229 i_x_start = p_sys->i_x_start / 2; 230 i_y_start = p_pic->p[Y_PLANE].i_pitch * p_sys->i_y_start; 231 232 i_x_end = p_sys->i_x_end / 2; 233 i_y_end = p_pic->p[Y_PLANE].i_pitch * p_sys->i_y_end; 224 234 225 235 p_source = (ogt_yuvt_t *)p_sys->p_data; 226 236 227 237 /* Draw until we reach the bottom of the subtitle */ 228 for( i_y = p_spu->i_height * p_pic->p[i_plane].i_pitch;229 i_y > 0;230 i_y -= p_pic->p[i_plane].i_pitch )238 for( i_y = 0; 239 i_y < p_spu->i_height * p_pic->p[i_plane].i_pitch ; 240 i_y += p_pic->p[i_plane].i_pitch ) 231 241 { 232 vlc_bool_t high_nibble = VLC_TRUE;233 234 242 /* printf("+++begin line: %d,\n", i++); */ 235 243 /* Draw until we reach the end of the line */ 236 for( i_x = p_spu->i_width / 2 ; i_x > 0 ; i_x--, p_source ++)244 for( i_x = 0; i_x < p_spu->i_width; i_x += 2, p_source += 2 ) 237 245 { 238 239 high_nibble = !high_nibble;240 246 241 247 if( b_crop … … 254 260 /* Completely transparent. Don't change pixel. */ 255 261 break; 256 262 263 default: 257 264 case MAX_ALPHA: 258 265 { … … 261 268 pixel with subtitle pixel. */ 262 269 263 uint8_t *p_pixel = p_pixel_base - (i_x - i_y) / 2; 264 uint16_t i_colprecomp = 265 (uint16_t) (p_source->plane[i_plane] >> 4); 266 267 if (high_nibble) 268 *p_pixel = (i_colprecomp << 4) | ((*p_pixel) & 0x0f); 269 else 270 *p_pixel = (i_colprecomp) | ((*p_pixel) & 0xf0); 271 270 /* This is the location that's going to get changed.*/ 271 uint8_t *p_pixel = p_pixel_base + i_y/2 + i_x/2; 272 uint8_t alpha = p_source->plane[i_plane]; 273 *p_pixel = ( ( *p_pixel * ( 0xFF - alpha ) ) >> 8 ) + 274 ( 0x80 * alpha >> 8 ); 272 275 break; 273 276 } 274 275 default: 277 278 #if 0 276 279 { 277 280 /* Blend in underlying pixel subtitle pixel. */ … … 282 285 is not correct, but that's handled in a special 283 286 case above anyway. */ 284 uint8_t *p_pixel = p_pixel_base - (i_x - i_y) / 2; 285 uint16_t i_colprecomp = (uint16_t) 286 (p_source->plane[i_plane] 287 * (uint16_t) (p_source->s.t+1)) >> (4+4); 288 uint16_t i_destalpha = (MAX_ALPHA - p_source->s.t) >> 4; 287 uint8_t *p_pixel = p_pixel_base + i_y/2 + i_x/2; 288 uint8_t low_val = *p_pixel & 0x0f; 289 uint8_t high_val = *p_pixel & 0xf0 >> 4; 290 uint16_t i_colprecomp = (p_source->plane[i_plane] 291 * (uint16_t) (p_source->s.t+1)) >> 4; 292 uint8_t i_destalpha = MAX_ALPHA - p_source->s.t; 293 uint16_t new_low = ( i_colprecomp + low_val*i_destalpha ) 294 / 2; 295 uint16_t new_high; 289 296 290 if (high_nibble) 291 *p_pixel = 292 (( (i_colprecomp) + 293 (((uint16_t) *p_pixel * i_destalpha) & 0x0f) ) <<4) 294 | ((*p_pixel) & 0x0f); 295 296 else 297 *p_pixel = 298 ( (i_colprecomp) + 299 (((uint16_t) *p_pixel * i_destalpha) & 0x0f) ) 300 | ((*p_pixel) & 0xf0); 297 p_source++; 298 i_colprecomp = (p_source->plane[i_plane] 299 * (uint16_t) (p_source->s.t+1)) >> 4; 300 i_destalpha = MAX_ALPHA - p_source->s.t; 301 new_high = ( i_colprecomp + high_val*i_destalpha ) / 2; 302 303 *p_pixel = (new_high << 4) | new_low; 301 304 break; 302 305 } 306 #endif 303 307 } 304 308 }
