* then swap buffers */
vlc_mutex_lock( &p_vout->change_lock );
#ifdef DEBUG_VIDEO
- intf_DbgMsg( "picture %p, subpicture %p\n", p_pic, p_subpic );
+ intf_DbgMsg( "picture %p, subpicture %p in buffer %d, display=%d\n", p_pic, p_subpic,
+ p_vout->i_buffer_index, b_display && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) );
#endif
if( b_display && !(p_vout->i_changes & VOUT_NODISPLAY_CHANGE) )
{
int i_area; /* area index */
int i_data_index; /* area data index */
int i_data_size; /* area data size, in 256 bytes blocs */
- u64 * p_data; /* area data */
+ u64 * p_data; /* area data, for clearing */
+ byte_t * p_data8; /* area data, for clearing (slow) */
/* Choose buffer and set display dimensions */
p_buffer = &p_vout->p_buffer[ p_vout->i_buffer_index ];
for( i_area = 0; i_area < p_buffer->i_areas; i_area++ )
{
#ifdef DEBUG_VIDEO
- intf_DbgMsg("clearing picture %p area: %d-%d\n", p_pic,
- p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area]);
+ intf_DbgMsg("clearing picture %p area in buffer %d: %d-%d\n", p_pic,
+ p_vout->i_buffer_index, p_buffer->pi_area_begin[i_area], p_buffer->pi_area_end[i_area] );
#endif
+ i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) * p_vout->i_bytes_per_line;
p_data = (u64*) (p_buffer->p_data + p_vout->i_bytes_per_line * p_buffer->pi_area_begin[i_area]);
- i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) *
- p_vout->i_bytes_per_line / 256;
- for( i_data_index = 0; i_data_index < i_data_size; i_data_index++ )
+ for( i_data_index = i_data_size / 256; i_data_index-- ; )
{
/* Clear 256 bytes block */
*p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
*p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
*p_data++ = 0; *p_data++ = 0; *p_data++ = 0; *p_data++ = 0;
}
- i_data_size = (p_buffer->pi_area_end[i_area] - p_buffer->pi_area_begin[i_area] + 1) *
- p_vout->i_bytes_per_line % 256 / 4;
- for( i_data_index = 0; i_data_index < i_data_size; i_data_index++ )
+ for( i_data_index = (i_data_size % 256) / 16; i_data_index--; )
{
- /* Clear remaining 4 bytes blocks */
- *p_data++ = 0;
+ /* Clear remaining 16 bytes blocks */
+ *p_data++ = 0; *p_data++ = 0;
+ }
+ p_data8 = (byte_t *)p_data;
+ for( i_data_index = i_data_size % 16; i_data_index--; )
+ {
+ /* Clear remaining bytes */
+ *p_data8++ = 0;
}
}
#ifdef DEBUG_VIDEO
/* Print picture date and rendering time */
- intf_DbgMsg("picture %p rendered (%ld us), display date: %s\n", p_pic,
- (long) (mdate() - render_time), mstrtime( psz_date, p_pic->date ));
+ intf_DbgMsg("picture %p rendered in buffer %d (%ld us), display date: %s\n", p_pic,
+ p_vout->i_buffer_index, (long) (mdate() - render_time),
+ mstrtime( psz_date, p_pic->date ));
#endif
}
{117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
};
+/* Margins in convertion tables - these margins are used in case a RGB convertion
+ * would give a value outside the 0-255 range. */
+#define RED_MARGIN 178
+#define GREEN_MARGIN 135
+#define BLUE_MARGIN 224
+#define GRAY_MARGIN 384
+
+//??
#define SHIFT 20
#define U_GREEN_COEF ((int)(-0.391 * (1<<SHIFT) / 1.164))
#define U_BLUE_COEF ((int)(2.018 * (1<<SHIFT) / 1.164))
{
case 15:
case 16:
- tables_size = sizeof( u16 ) * (1024 * (p_vout->b_grayscale ? 1 : 3) + 1935);
+ tables_size = sizeof( u16 ) * (p_vout->b_grayscale ? 1034 : 1935);
break;
case 24:
case 32:
#ifndef DEBUG
default:
#endif
- tables_size = sizeof( u32 ) * (1024 * (p_vout->b_grayscale ? 1 : 3) + 1935);
+ tables_size = sizeof( u32 ) * (p_vout->b_grayscale ? 1024 : 1935);
break;
#ifdef DEBUG
default:
{
case 15:
case 16:
- p_vout->yuv.yuv.gray16.p_gray = (u16 *)p_vout->yuv.p_base + 384;
- for( i_index = -384; i_index < 640; i_index++)
+ p_vout->yuv.yuv.p_gray16 = (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
+ for( i_index = -GRAY_MARGIN; i_index < 256 + GRAY_MARGIN; i_index++)
{
- p_vout->yuv.yuv.gray16.p_gray[ i_index ] =
+ p_vout->yuv.yuv.p_gray16[ i_index ] =
((pi_gamma[CLIP_BYTE( i_index )] >> i_red_right) << i_red_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_green_right) << i_green_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_blue_right) << i_blue_left);
break;
case 24:
case 32:
- p_vout->yuv.yuv.gray32.p_gray = (u32 *)p_vout->yuv.p_base + 384;
- for( i_index = -384; i_index < 640; i_index++)
+ p_vout->yuv.yuv.p_gray32 = (u32 *)p_vout->yuv.p_base + GRAY_MARGIN;
+ for( i_index = -GRAY_MARGIN; i_index < 256 + GRAY_MARGIN; i_index++)
{
- p_vout->yuv.yuv.gray32.p_gray[ i_index ] =
+ p_vout->yuv.yuv.p_gray32[ i_index ] =
((pi_gamma[CLIP_BYTE( i_index )] >> i_red_right) << i_red_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_green_right) << i_green_left) |
((pi_gamma[CLIP_BYTE( i_index )] >> i_blue_right) << i_blue_left);
{
case 15:
case 16:
- p_vout->yuv.yuv.rgb16.p_red = (u16 *)p_vout->yuv.p_base + 384;
- p_vout->yuv.yuv.rgb16.p_green = (u16 *)p_vout->yuv.p_base + 1024 + 384;
- p_vout->yuv.yuv.rgb16.p_blue = (u16 *)p_vout->yuv.p_base + 2*1024 + 384;
- p_vout->yuv.yuv2.p_rgb16 = (u16 *)p_vout->yuv.p_base + 3*1024;
- for( i_index = -384; i_index < 640; i_index++)
+ p_vout->yuv.yuv.p_rgb16 = (u16 *)p_vout->yuv.p_base;
+ for( i_index = 0; i_index < RED_MARGIN; i_index++ )
{
- p_vout->yuv.yuv.rgb16.p_red[i_index] = (pi_gamma[CLIP_BYTE(i_index)]>>i_red_right)<<i_red_left;
- p_vout->yuv.yuv.rgb16.p_green[i_index] = (pi_gamma[CLIP_BYTE(i_index)]>>i_green_right)<<i_green_left;
- p_vout->yuv.yuv.rgb16.p_blue[i_index] = (pi_gamma[CLIP_BYTE(i_index)]>>i_blue_right)<<i_blue_left;
+ p_vout->yuv.yuv.p_rgb16[1501 - RED_MARGIN + i_index] = (pi_gamma[0]>>i_red_right)<<i_red_left;
+ p_vout->yuv.yuv.p_rgb16[1501 + 256 + i_index] = (pi_gamma[255]>>i_red_right)<<i_red_left;
}
- for( i_index = 0; i_index < 178; i_index++ )
+ for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
{
- p_vout->yuv.yuv2.p_rgb16[1501 - 178 + i_index] = (pi_gamma[0]>>i_red_right)<<i_red_left;
- p_vout->yuv.yuv2.p_rgb16[1501 + 256 + i_index] = (pi_gamma[255]>>i_red_right)<<i_red_left;
+ p_vout->yuv.yuv.p_rgb16[135 - GREEN_MARGIN + i_index] = (pi_gamma[0]>>i_green_right)<<i_green_left;
+ p_vout->yuv.yuv.p_rgb16[135 + 256 + i_index] = (pi_gamma[255]>>i_green_right)<<i_green_left;
}
- for( i_index = 0; i_index < 135; i_index++ )
+ for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
{
- p_vout->yuv.yuv2.p_rgb16[135 - 135 + i_index] = (pi_gamma[0]>>i_green_right)<<i_green_left;
- p_vout->yuv.yuv2.p_rgb16[135 + 256 + i_index] = (pi_gamma[255]>>i_green_right)<<i_green_left;
- }
- for( i_index = 0; i_index < 224; i_index++ )
- {
- p_vout->yuv.yuv2.p_rgb16[818 - 224 + i_index] = (pi_gamma[0]>>i_blue_right)<<i_blue_left;
- p_vout->yuv.yuv2.p_rgb16[818 + 256 + i_index] = (pi_gamma[255]>>i_blue_right)<<i_blue_left;
+ p_vout->yuv.yuv.p_rgb16[818 - BLUE_MARGIN + i_index] = (pi_gamma[0]>>i_blue_right)<<i_blue_left;
+ p_vout->yuv.yuv.p_rgb16[818 + BLUE_MARGIN + i_index] = (pi_gamma[255]>>i_blue_right)<<i_blue_left;
}
for( i_index = 0; i_index < 256; i_index++ )
{
- p_vout->yuv.yuv2.p_rgb16[1501 + i_index] = (pi_gamma[i_index]>>i_red_right)<<i_red_left;
- p_vout->yuv.yuv2.p_rgb16[135 + i_index] = (pi_gamma[i_index]>>i_green_right)<<i_green_left;
- p_vout->yuv.yuv2.p_rgb16[818 + i_index] = (pi_gamma[i_index]>>i_blue_right)<<i_blue_left;
+ p_vout->yuv.yuv.p_rgb16[1501 + i_index] = (pi_gamma[i_index]>>i_red_right)<<i_red_left;
+ p_vout->yuv.yuv.p_rgb16[135 + i_index] = (pi_gamma[i_index]>>i_green_right)<<i_green_left;
+ p_vout->yuv.yuv.p_rgb16[818 + i_index] = (pi_gamma[i_index]>>i_blue_right)<<i_blue_left;
}
break;
case 24:
case 32:
- p_vout->yuv.yuv.rgb32.p_red = (u32 *)p_vout->yuv.p_base + 384;
- p_vout->yuv.yuv.rgb32.p_green = (u32 *)p_vout->yuv.p_base + 1024 + 384;
- p_vout->yuv.yuv.rgb32.p_blue = (u32 *)p_vout->yuv.p_base + 2*1024 + 384;
- p_vout->yuv.yuv2.p_rgb32 = (u32 *)p_vout->yuv.p_base + 3*1024;
- for( i_index = -384; i_index < 640; i_index++)
+ p_vout->yuv.yuv.p_rgb32 = (u32 *)p_vout->yuv.p_base;
+ for( i_index = 0; i_index < RED_MARGIN; i_index++ )
+ {
+ p_vout->yuv.yuv.p_rgb32[1501 - RED_MARGIN + i_index] = (pi_gamma[0]>>i_red_right)<<i_red_left;
+ p_vout->yuv.yuv.p_rgb32[1501 + 256 + i_index] = (pi_gamma[255]>>i_red_right)<<i_red_left;
+ }
+ for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
{
- p_vout->yuv.yuv.rgb32.p_red[i_index] = (pi_gamma[CLIP_BYTE(i_index)]>>i_red_right)<<i_red_left;
- p_vout->yuv.yuv.rgb32.p_green[i_index] = (pi_gamma[CLIP_BYTE(i_index)]>>i_green_right)<<i_green_left;
- p_vout->yuv.yuv.rgb32.p_blue[i_index] = (pi_gamma[CLIP_BYTE(i_index)]>>i_blue_right)<<i_blue_left;
+ p_vout->yuv.yuv.p_rgb32[135 - GREEN_MARGIN + i_index] = (pi_gamma[0]>>i_green_right)<<i_green_left;
+ p_vout->yuv.yuv.p_rgb32[135 + 256 + i_index] = (pi_gamma[255]>>i_green_right)<<i_green_left;
}
- //?? walken's yuv
+ for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
+ {
+ p_vout->yuv.yuv.p_rgb32[818 - BLUE_MARGIN + i_index] = (pi_gamma[0]>>i_blue_right)<<i_blue_left;
+ p_vout->yuv.yuv.p_rgb32[818 + BLUE_MARGIN + i_index] = (pi_gamma[255]>>i_blue_right)<<i_blue_left;
+ }
+ for( i_index = 0; i_index < 256; i_index++ )
+ {
+ p_vout->yuv.yuv.p_rgb32[1501 + i_index] = (pi_gamma[i_index]>>i_red_right)<<i_red_left;
+ p_vout->yuv.yuv.p_rgb32[135 + i_index] = (pi_gamma[i_index]>>i_green_right)<<i_green_left;
+ p_vout->yuv.yuv.p_rgb32[818 + i_index] = (pi_gamma[i_index]>>i_blue_right)<<i_blue_left;
+ }
break;
}
}
u16 * p_gray; /* gray table */
int i_x, i_y; /* picture coordinates */
- p_gray = p_vout->yuv.yuv.gray16.p_gray;
+ p_gray = p_vout->yuv.yuv.p_gray16;
CONVERT_YUV_GRAY
}
u32 * p_gray; /* gray table */
int i_x, i_y; /* picture coordinates */
- p_gray = p_vout->yuv.yuv.gray32.p_gray;
+ p_gray = p_vout->yuv.yuv.p_gray32;
CONVERT_YUV_GRAY
}
*/
i_pic_line_width -= i_pic_width;
i_chroma_width = i_width / 2;
- p_yuv = p_vout->yuv.yuv2.p_rgb16;
+ p_yuv = p_vout->yuv.yuv.p_rgb16;
/*
* Set scalings
}
/* If line is odd, rewind U and V samples */
- if( i_y & 0x1 )
+ if( !(i_y & 0x1) )
{
p_u -= i_chroma_width;
p_v -= i_chroma_width;
{
/* Height reduction: skip next source line */
p_y += i_width;
- if( ! (++i_y & 0x1) )
+ if( ++i_y & 0x1 )
{
p_u += i_chroma_width;
p_v += i_chroma_width;
* calculated to minimize the cache interactions of the 3 tables.
*/
-static int rgbTable32 (int table [1935],
- int redMask, int greenMask, int blueMask,
- unsigned char gamma[256])
-{
- int redRight;
- int redLeft;
- int greenRight;
- int greenLeft;
- int blueRight;
- int blueLeft;
- int * redTable;
- int * greenTable;
- int * blueTable;
- int i;
- int y;
-
- MaskToShift (&redRight, &redLeft, redMask);
- MaskToShift (&greenRight, &greenLeft, greenMask);
- MaskToShift (&blueRight, &blueLeft, blueMask);
-
-
- /*
- * green blue red +- 2 just to be sure
- * green = 0-525 [151-370]
- * blue = 594-1297 [834-1053] <834-29>
- * red = 1323-1934 [1517-1736] <493-712>
- */
-
- redTable = table + 1501;
- greenTable = table + 135;
- blueTable = table + 818;
-
- for (i = 0; i < 178; i++) {
- redTable[i-178] = 0;
- redTable[i+256] = redMask;
- }
- for (i = 0; i < 135; i++) {
- greenTable[i-135] = 0;
- greenTable[i+256] = greenMask;
- }
- for (i = 0; i < 224; i++) {
- blueTable[i-224] = 0;
- blueTable[i+256] = blueMask;
- }
-
- for (i = 0; i < 256; i++) {
- y = gamma[i];
- redTable[i] = ((y >> redRight) << redLeft);
- greenTable[i] = ((y >> greenRight) << greenLeft);
- blueTable[i] = ((y >> blueRight) << blueLeft);
- }
-
- return 0;
-}
-
-
static void yuvToRgb24 (unsigned char * Y,
unsigned char * U, unsigned char * V,
char * dest, int table[1935], int width)