screen_data_t *p_data;
int i_chroma, i_bits_per_pixel;
- p_sys->p_data = p_data = malloc( sizeof( screen_data_t ) );
+ p_sys->p_data = p_data = calloc( 1, sizeof( screen_data_t ) );
if( !p_data )
return VLC_ENOMEM;
- memset( p_data, 0, sizeof( screen_data_t ) );
/* Get the device context for the whole screen */
p_data->hdc_src = CreateDC( "DISPLAY", NULL, NULL, NULL );
if( !p_data->hdc_src )
{
msg_Err( p_demux, "cannot get device context" );
+ free( p_data );
return VLC_EGENERIC;
}
if( !p_data->hdc_dst )
{
msg_Err( p_demux, "cannot get compat device context" );
+ free( p_data );
ReleaseDC( 0, p_data->hdc_src );
return VLC_EGENERIC;
}
switch( i_bits_per_pixel )
{
case 8: /* FIXME: set the palette */
- i_chroma = VLC_FOURCC('R','G','B','2'); break;
+ i_chroma = VLC_CODEC_RGB8; break;
case 15:
case 16: /* Yes it is really 15 bits (when using BI_RGB) */
- i_chroma = VLC_FOURCC('R','V','1','5'); break;
+ i_chroma = VLC_CODEC_RGB15; break;
case 24:
- i_chroma = VLC_FOURCC('R','V','2','4'); break;
+ i_chroma = VLC_CODEC_RGB24; break;
case 32:
- i_chroma = VLC_FOURCC('R','V','3','2'); break;
+ i_chroma = VLC_CODEC_RGB32; break;
default:
msg_Err( p_demux, "unknown screen depth %i",
p_sys->fmt.video.i_bits_per_pixel );
+ DeleteDC( p_data->hdc_dst );
ReleaseDC( 0, p_data->hdc_src );
- ReleaseDC( 0, p_data->hdc_dst );
+ free( p_data );
return VLC_EGENERIC;
}
switch( i_chroma )
{
- case VLC_FOURCC('R','V','1','5'):
+ case VLC_CODEC_RGB15:
p_sys->fmt.video.i_rmask = 0x7c00;
p_sys->fmt.video.i_gmask = 0x03e0;
p_sys->fmt.video.i_bmask = 0x001f;
break;
- case VLC_FOURCC('R','V','2','4'):
+ case VLC_CODEC_RGB24:
p_sys->fmt.video.i_rmask = 0x00ff0000;
p_sys->fmt.video.i_gmask = 0x0000ff00;
p_sys->fmt.video.i_bmask = 0x000000ff;
break;
- case VLC_FOURCC('R','V','3','2'):
+ case VLC_CODEC_RGB32:
p_sys->fmt.video.i_rmask = 0x00ff0000;
p_sys->fmt.video.i_gmask = 0x0000ff00;
p_sys->fmt.video.i_bmask = 0x000000ff;
if( p_data->bmi.bmiHeader.biSize == 0 )
{
- vlc_value_t val;
+ int i_val;
/* Create the bitmap info header */
p_data->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
p_data->bmi.bmiHeader.biWidth = p_sys->fmt.video.i_width;
p_data->bmi.bmiHeader.biClrUsed = 0;
p_data->bmi.bmiHeader.biClrImportant = 0;
- var_Create( p_demux, "screen-fragment-size",
- VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
- var_Get( p_demux, "screen-fragment-size", &val );
- p_data->i_fragment_size =
- val.i_int > 0 ? val.i_int : p_sys->fmt.video.i_height;
- p_data->i_fragment_size =
- val.i_int > p_sys->fmt.video.i_height ? p_sys->fmt.video.i_height :
- p_data->i_fragment_size;
+ i_val = var_CreateGetInteger( p_demux, "screen-fragment-size" );
+ p_data->i_fragment_size = i_val > 0 ? i_val : p_sys->fmt.video.i_height;
+ p_data->i_fragment_size = i_val > p_sys->fmt.video.i_height ?
+ p_sys->fmt.video.i_height :
+ p_data->i_fragment_size;
p_sys->f_fps *= (p_sys->fmt.video.i_height/p_data->i_fragment_size);
p_sys->i_incr = 1000000 / p_sys->f_fps;
p_data->i_fragment = 0;
if( !( p_data->p_block = CaptureBlockNew( p_demux ) ) )
{
msg_Warn( p_demux, "cannot get block" );
- return 0;
+ return NULL;
}
}
p_sys->fmt.video.i_width, p_data->i_fragment_size,
p_data->hdc_src, p_sys->i_left, p_sys->i_top +
p_data->i_fragment * p_data->i_fragment_size,
- IS_WINNT ? SRCCOPY | CAPTUREBLT : SRCCOPY ) )
+ SRCCOPY | CAPTUREBLT ) )
{
msg_Err( p_demux, "error during BitBlt()" );
return NULL;