add rgb32 csp support

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13125 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nplourde 2004-08-24 20:42:27 +00:00
parent 2b5bf19dfd
commit 6f6c1a6406
1 changed files with 95 additions and 19 deletions

View File

@ -9,12 +9,12 @@
MPlayer Mac OSX Quartz video out module.
todo: -RGB32 color space support
todo: -key binding to set zoom, a la quicktime
-screen overlay output
-while mouse button down event mplayer is locked, fix that
-Enable live resize
-fix menu
-quit properly when using close button
-RGB32 lost HW accel in fullscreen
-(add sugestion here)
*/
@ -92,6 +92,12 @@ static int device_id;
static WindowRef theWindow = NULL;
static WindowGroupRef winGroup = NULL;
static CGContextRef context;
static CGRect bounds;
static CGDataProviderRef dataProviderRef;
static CGImageAlphaInfo alphaInfo;
static CGImageRef image;
static Rect imgRect; // size of the original image (unscaled)
static Rect dstRect; // size of the displayed image (after scaling)
@ -390,6 +396,11 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
aspect(&d_width,&d_height,A_NOZOOM);
if(image_data)
free(image_data);
image_data = malloc(image_size);
//Create player window//////////////////////////////////////////////////
windowAttrs = kWindowStandardDocumentAttributes
| kWindowStandardHandlerAttribute
@ -420,6 +431,23 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
switch (image_format)
{
case IMGFMT_RGB32:
{
CreateCGContextForPort (GetWindowPort (theWindow), &context);
dataProviderRef = CGDataProviderCreateWithData (0, image_data, imgRect.right * imgRect.bottom * 4, 0);
image = CGImageCreate (imgRect.right,
imgRect.bottom,
8,
image_depth,
((imgRect.right*32)+7)/8,
CGColorSpaceCreateDeviceRGB(),
kCGImageAlphaNoneSkipFirst,
dataProviderRef, 0, 1, kCGRenderingIntentDefault);
break;
}
case IMGFMT_YV12:
case IMGFMT_IYUV:
case IMGFMT_I420:
@ -623,6 +651,13 @@ static void flip_page(void)
{
switch (image_format)
{
case IMGFMT_RGB32:
{
CGContextDrawImage (context, bounds, image);
CGContextFlush (context);
}
break;
case IMGFMT_YV12:
case IMGFMT_IYUV:
case IMGFMT_I420:
@ -676,6 +711,10 @@ static uint32_t draw_frame(uint8_t *src[])
{
switch (image_format)
{
case IMGFMT_RGB32:
memcpy(image_data,src[0],image_size);
return 0;
case IMGFMT_UYVY:
case IMGFMT_YUY2:
memcpy_pic(((char*)P), src[0], imgRect.right * 2, imgRect.bottom, imgRect.right * 2, imgRect.right * 2);
@ -689,6 +728,11 @@ static uint32_t query_format(uint32_t format)
image_format = format;
image_qtcodec = 0;
if (format == IMGFMT_RGB32)
{
return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
}
if ((format == IMGFMT_YV12) || (format == IMGFMT_IYUV) || (format == IMGFMT_I420))
{
image_qtcodec = kMpegYUV420CodecType; //kYUV420CodecType ?;
@ -714,6 +758,14 @@ static void uninit(void)
{
OSErr qterr;
switch (image_format)
{
case IMGFMT_YV12:
case IMGFMT_IYUV:
case IMGFMT_I420:
case IMGFMT_UYVY:
case IMGFMT_YUY2:
{
if (EnterMoviesDone)
{
qterr = CDSequenceEnd(seqId);
@ -722,6 +774,11 @@ static void uninit(void)
mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: CDSequenceEnd (%d)\n", qterr);
}
}
break;
}
default:
break;
}
ShowMenuBar();
}
@ -906,6 +963,20 @@ void window_resized()
RGBForeColor( &blackC );
PaintRect( &winRect );
switch (image_format)
{
case IMGFMT_RGB32:
{
bounds = CGRectMake(dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top);
CreateCGContextForPort (GetWindowPort (theWindow), &context);
break;
}
case IMGFMT_YV12:
case IMGFMT_IYUV:
case IMGFMT_I420:
case IMGFMT_UYVY:
case IMGFMT_YUY2:
{
long scale_X = FixDiv(Long2Fix(dstRect.right - dstRect.left),Long2Fix(imgRect.right));
long scale_Y = FixDiv(Long2Fix(dstRect.bottom - dstRect.top),Long2Fix(imgRect.bottom));
@ -921,6 +992,11 @@ void window_resized()
}
SetDSequenceMatrix(seqId, &matrix);
break;
}
default:
break;
}
}
void window_ontop()