Commit 09ab8e1e authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* modules/access/screen/mac.c:

  * Plugin now works perfectly in milj. of colors
  * Works in thousands of colors, in inverse colors
parent 3ea1b0e9
...@@ -55,7 +55,9 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -55,7 +55,9 @@ int screen_InitCapture( demux_t *p_demux )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data; screen_data_t *p_data;
int i_chroma; int i_chroma, i_bbp, i_offset;
i_chroma = i_bbp = i_offset = 0;
p_sys->p_data = p_data = p_sys->p_data = p_data =
(screen_data_t *)malloc( sizeof( screen_data_t ) ); (screen_data_t *)malloc( sizeof( screen_data_t ) );
...@@ -77,25 +79,27 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -77,25 +79,27 @@ int screen_InitCapture( demux_t *p_demux )
switch( CGDisplaySamplesPerPixel(p_data->displayID) * CGDisplayBitsPerSample(p_data->displayID) ) switch( CGDisplaySamplesPerPixel(p_data->displayID) * CGDisplayBitsPerSample(p_data->displayID) )
{ {
case 8: /* FIXME: set the palette */ /* TODO figure out 256 colors (who uses it anyways) */
i_chroma = VLC_FOURCC('R','G','B','2'); break; case 15: /* TODO this is not RV16, but BGR16 */
case 15: i_chroma = VLC_FOURCC('R','V','1','6');
i_chroma = VLC_FOURCC('R','V','1','5'); break; i_bbp = 16;
case 16: i_offset = 8;
i_chroma = VLC_FOURCC('R','V','1','6'); break; break;
case 24: case 24:
i_chroma = VLC_FOURCC('R','V','2','4'); break;
case 32: case 32:
i_chroma = VLC_FOURCC('R','V','3','2'); break; i_chroma = VLC_FOURCC('R','V','3','2');
i_bbp = 32;
i_offset = 4;
break;
default: default:
msg_Err( p_demux, "unknown screen depth" ); msg_Err( p_demux, "unknown screen depth: %d", CGDisplaySamplesPerPixel(p_data->displayID) * CGDisplayBitsPerSample(p_data->displayID) );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
GetBackColor(&p_data->oldBackColor); GetBackColor(&p_data->oldBackColor);
GetPenState(&p_data->oldState); GetPenState(&p_data->oldState);
// ForeColor(blackColor); ForeColor(blackColor);
// BackColor(whiteColor); BackColor(whiteColor);
p_data->gMainDevice = GetMainDevice(); p_data->gMainDevice = GetMainDevice();
p_data->gDeviceState = HGetState((Handle)p_data->gMainDevice); p_data->gDeviceState = HGetState((Handle)p_data->gMainDevice);
...@@ -107,12 +111,12 @@ int screen_InitCapture( demux_t *p_demux ) ...@@ -107,12 +111,12 @@ int screen_InitCapture( demux_t *p_demux )
LockPixels(p_data->LocalBufferPix); LockPixels(p_data->LocalBufferPix);
es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma ); es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma );
p_sys->fmt.video.i_width = CGDisplayPixelsWide(p_data->displayID); p_sys->fmt.video.i_width = CGDisplayPixelsWide(p_data->displayID) + i_offset;
p_sys->fmt.video.i_visible_width = CGDisplayPixelsWide(p_data->displayID);
p_sys->fmt.video.i_height = CGDisplayPixelsHigh(p_data->displayID); p_sys->fmt.video.i_height = CGDisplayPixelsHigh(p_data->displayID);
p_sys->fmt.video.i_bits_per_pixel = CGDisplaySamplesPerPixel(p_data->displayID) * CGDisplayBitsPerSample(p_data->displayID); p_sys->fmt.video.i_bits_per_pixel = i_bbp;
GetForeColor(&p_data->oldForeColor); GetForeColor(&p_data->oldForeColor);
assert(CGSNewConnection(NULL, &p_data->gConnection) == kCGErrorSuccess);
HSetState( (Handle)p_data->gMainDevice, p_data->gDeviceState ); HSetState( (Handle)p_data->gMainDevice, p_data->gDeviceState );
SetPenState( &p_data->oldState); SetPenState( &p_data->oldState);
...@@ -126,7 +130,6 @@ int screen_CloseCapture( demux_t *p_demux ) ...@@ -126,7 +130,6 @@ int screen_CloseCapture( demux_t *p_demux )
{ {
screen_data_t *p_data = (screen_data_t *)p_demux->p_sys->p_data; screen_data_t *p_data = (screen_data_t *)p_demux->p_sys->p_data;
assert(CGSReleaseConnection(p_data->gConnection) == kCGErrorSuccess);
if(p_data->LocalBufferPix) UnlockPixels(p_data->LocalBufferPix); p_data->LocalBufferPix = NULL; if(p_data->LocalBufferPix) UnlockPixels(p_data->LocalBufferPix); p_data->LocalBufferPix = NULL;
if(p_data->LocalBufferGW) DisposeGWorld(p_data->LocalBufferGW); p_data->LocalBufferGW = NULL; if(p_data->LocalBufferGW) DisposeGWorld(p_data->LocalBufferGW); p_data->LocalBufferGW = NULL;
...@@ -140,7 +143,7 @@ block_t *screen_Capture( demux_t *p_demux ) ...@@ -140,7 +143,7 @@ block_t *screen_Capture( demux_t *p_demux )
block_t *p_block; block_t *p_block;
int i_size; int i_size;
i_size = p_sys->fmt.video.i_height * CGDisplayBytesPerRow(p_data->displayID); i_size = p_sys->fmt.video.i_height * p_sys->fmt.video.i_width * 32 / 8;
if( !( p_block = block_New( p_demux, i_size ) ) ) if( !( p_block = block_New( p_demux, i_size ) ) )
{ {
...@@ -151,9 +154,10 @@ block_t *screen_Capture( demux_t *p_demux ) ...@@ -151,9 +154,10 @@ block_t *screen_Capture( demux_t *p_demux )
GetForeColor(&p_data->oldForeColor); GetForeColor(&p_data->oldForeColor);
GetBackColor(&p_data->oldBackColor); GetBackColor(&p_data->oldBackColor);
GetPenState(&p_data->oldState); GetPenState(&p_data->oldState);
// ForeColor(blackColor); ForeColor(blackColor);
// BackColor(whiteColor); BackColor(whiteColor);
assert(CGSNewConnection(NULL, &p_data->gConnection) == kCGErrorSuccess);
p_data->gMainDevice = GetMainDevice(); p_data->gMainDevice = GetMainDevice();
p_data->gDeviceState = HGetState((Handle)p_data->gMainDevice); p_data->gDeviceState = HGetState((Handle)p_data->gMainDevice);
HLock((Handle)p_data->gMainDevice); HLock((Handle)p_data->gMainDevice);
...@@ -168,6 +172,7 @@ block_t *screen_Capture( demux_t *p_demux ) ...@@ -168,6 +172,7 @@ block_t *screen_Capture( demux_t *p_demux )
RGBForeColor( &p_data->oldForeColor ); RGBForeColor( &p_data->oldForeColor );
RGBBackColor( &p_data->oldBackColor ); RGBBackColor( &p_data->oldBackColor );
assert(CGSReleaseConnection(p_data->gConnection) == kCGErrorSuccess);
memcpy( p_block->p_buffer, (**p_data->LocalBufferPix).baseAddr, i_size ); memcpy( p_block->p_buffer, (**p_data->LocalBufferPix).baseAddr, i_size );
return p_block; return p_block;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment