[Redbutton-devel] SF.net SVN: redbutton: [320] redbutton-browser/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-07-16 16:00:45
|
Revision: 320
http://svn.sourceforge.net/redbutton/?rev=320&view=rev
Author: skilvington
Date: 2007-07-16 09:00:42 -0700 (Mon, 16 Jul 2007)
Log Message:
-----------
factor out converting MHEG coords to screen coords
Modified Paths:
--------------
redbutton-browser/trunk/MHEGCanvas.c
redbutton-browser/trunk/MHEGDisplay.c
redbutton-browser/trunk/MHEGDisplay.h
redbutton-browser/trunk/MHEGStreamPlayer.c
Modified: redbutton-browser/trunk/MHEGCanvas.c
===================================================================
--- redbutton-browser/trunk/MHEGCanvas.c 2007-06-26 14:30:03 UTC (rev 319)
+++ redbutton-browser/trunk/MHEGCanvas.c 2007-07-16 16:00:42 UTC (rev 320)
@@ -21,8 +21,8 @@
MHEGDisplay *d = MHEGEngine_getDisplay();
/* scale width/height if fullscreen */
- c->width = (width * d->xres) / MHEG_XRES;
- c->height = (height * d->yres) / MHEG_YRES;
+ c->width = MHEGDisplay_scaleX(d, width);
+ c->height = MHEGDisplay_scaleY(d, height);
/* no border set yet */
c->border = 0;
@@ -83,7 +83,7 @@
error("MHEGCanvas_setBorder: LineStyle %d not supported (using a solid line)", style);
/* scale width if fullscreen */
- c->border = (width * d->xres) / MHEG_XRES;
+ c->border = MHEGDisplay_scaleX(d, width);
/* draw the border */
gcvals.foreground = pixel_value(c->pic_format, colour);
@@ -160,11 +160,11 @@
error("MHEGCanvas_drawArc: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
- width = (width * d->xres) / MHEG_XRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
+ width = MHEGDisplay_scaleX(d, width);
/* set up the GC values */
gcvals.foreground = pixel_value(c->pic_format, colour);
@@ -200,11 +200,11 @@
error("MHEGCanvas_drawSector: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
- width = (width * d->xres) / MHEG_XRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
+ width = MHEGDisplay_scaleX(d, width);
/* fill it */
gcvals.foreground = pixel_value(c->pic_format, fill_col);
@@ -265,11 +265,11 @@
error("MHEGCanvas_drawLine: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- x1 = (p1->x_position * d->xres) / MHEG_XRES;
- y1 = (p1->y_position * d->yres) / MHEG_YRES;
- x2 = (p2->x_position * d->xres) / MHEG_XRES;
- y2 = (p2->y_position * d->yres) / MHEG_YRES;
- width = (width * d->xres) / MHEG_XRES;
+ x1 = MHEGDisplay_scaleX(d, p1->x_position);
+ y1 = MHEGDisplay_scaleY(d, p1->y_position);
+ x2 = MHEGDisplay_scaleX(d, p2->x_position);
+ y2 = MHEGDisplay_scaleY(d, p2->y_position);
+ width = MHEGDisplay_scaleX(d, width);
/* set up the GC values */
gcvals.foreground = pixel_value(c->pic_format, colour);
@@ -298,11 +298,11 @@
error("MHEGCanvas_drawOval: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
- width = (width * d->xres) / MHEG_XRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
+ width = MHEGDisplay_scaleX(d, width);
/* fill it */
gcvals.foreground = pixel_value(c->pic_format, fill_col);
@@ -344,7 +344,7 @@
error("MHEGCanvas_drawPolygon: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- width = (width * d->xres) / MHEG_XRES;
+ width = MHEGDisplay_scaleX(d, width);
/* convert the XYPosition list into an array of XPoint's */
nxpts = 0;
@@ -361,8 +361,8 @@
for(i=0; i<nxpts; i++)
{
/* scale up if fullscreen */
- xpts[i].x = (pos->item.x_position * d->xres) / MHEG_XRES;
- xpts[i].y = (pos->item.y_position * d->yres) / MHEG_YRES;
+ xpts[i].x = MHEGDisplay_scaleX(d, pos->item.x_position);
+ xpts[i].y = MHEGDisplay_scaleY(d, pos->item.y_position);
pos = pos->next;
}
@@ -376,8 +376,8 @@
if(width > 0)
{
/* close the polygon */
- xpts[nxpts].x = (xy_list->item.x_position * d->xres) / MHEG_XRES;
- xpts[nxpts].y = (xy_list->item.y_position * d->yres) / MHEG_YRES;
+ xpts[nxpts].x = MHEGDisplay_scaleX(d, xy_list->item.x_position);
+ xpts[nxpts].y = MHEGDisplay_scaleY(d, xy_list->item.y_position);
/* set the line width and colour */
gcvals.foreground = pixel_value(c->pic_format, line_col);
gcvals.line_width = width;
@@ -414,7 +414,7 @@
error("MHEGCanvas_drawPolyline: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- width = (width * d->xres) / MHEG_XRES;
+ width = MHEGDisplay_scaleX(d, width);
/* convert the XYPosition list into an array of XPoint's */
nxpts = 0;
@@ -430,8 +430,8 @@
for(i=0; i<nxpts; i++)
{
/* scale up if fullscreen */
- xpts[i].x = (pos->item.x_position * d->xres) / MHEG_XRES;
- xpts[i].y = (pos->item.y_position * d->yres) / MHEG_YRES;
+ xpts[i].x = MHEGDisplay_scaleX(d, pos->item.x_position);
+ xpts[i].y = MHEGDisplay_scaleY(d, pos->item.y_position);
pos = pos->next;
}
@@ -466,11 +466,11 @@
error("MHEGCanvas_drawRectangle: LineStyle %d not supported (using a solid line)", style);
/* scale up if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
- width = (width * d->xres) / MHEG_XRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
+ width = MHEGDisplay_scaleX(d, width);
/* fill it */
gcvals.foreground = pixel_value(c->pic_format, fill_col);
Modified: redbutton-browser/trunk/MHEGDisplay.c
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.c 2007-06-26 14:30:03 UTC (rev 319)
+++ redbutton-browser/trunk/MHEGDisplay.c 2007-07-16 16:00:42 UTC (rev 320)
@@ -367,10 +367,10 @@
unsigned int w, h;
/* scale if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
/*
* if video is being displayed, the current frame will already be in d->contents
@@ -426,10 +426,10 @@
XRectangle clip;
/* scale if fullscreen */
- clip.x = (pos->x_position * d->xres) / MHEG_XRES;
- clip.y = (pos->y_position * d->yres) / MHEG_YRES;
- clip.width = (box->x_length * d->xres) / MHEG_XRES;
- clip.height = (box->y_length * d->yres) / MHEG_YRES;
+ clip.x = MHEGDisplay_scaleX(d, pos->x_position);
+ clip.y = MHEGDisplay_scaleY(d, pos->y_position);
+ clip.width = MHEGDisplay_scaleX(d, box->x_length);
+ clip.height = MHEGDisplay_scaleY(d, box->y_length);
XRenderSetPictureClipRectangles(d->dpy, d->next_overlay_pic, 0, 0, &clip, 1);
@@ -478,11 +478,11 @@
display_colour(&rcol, col);
/* scale if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (len * d->xres) / MHEG_XRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, len);
/* aspect ratio */
- h = (width * d->yres) / MHEG_YRES;
+ h = MHEGDisplay_scaleY(d, width);
/* TODO */
if(style != LineStyle_solid)
@@ -515,11 +515,11 @@
display_colour(&rcol, col);
/* scale if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- h = (len * d->yres) / MHEG_YRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ h = MHEGDisplay_scaleY(d, len);
/* aspect ratio */
- w = (width * d->xres) / MHEG_XRES;
+ w = MHEGDisplay_scaleX(d, width);
/* TODO */
if(style != LineStyle_solid)
@@ -550,10 +550,10 @@
display_colour(&rcol, col);
/* scale if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
XRenderFillRectangle(d->dpy, PictOpOver, d->next_overlay_pic, &rcol, x, y, w, h);
@@ -574,10 +574,10 @@
unsigned int w, h;
/* scale if fullscreen */
- x = (pos->x_position * d->xres) / MHEG_XRES;
- y = (pos->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
+ x = MHEGDisplay_scaleX(d, pos->x_position);
+ y = MHEGDisplay_scaleY(d, pos->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
XRenderFillRectangle(d->dpy, PictOpSrc, d->next_overlay_pic, &rcol, x, y, w, h);
@@ -603,12 +603,12 @@
* scale up if fullscreen
* the bitmap itself is scaled when it is created in MHEGDisplay_newBitmap()
*/
- src_x = (src->x_position * d->xres) / MHEG_XRES;
- src_y = (src->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
- dst_x = (dst->x_position * d->xres) / MHEG_XRES;
- dst_y = (dst->y_position * d->yres) / MHEG_YRES;
+ src_x = MHEGDisplay_scaleX(d, src->x_position);
+ src_y = MHEGDisplay_scaleY(d, src->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
+ dst_x = MHEGDisplay_scaleX(d, dst->x_position);
+ dst_y = MHEGDisplay_scaleY(d, dst->y_position);
XRenderComposite(d->dpy, PictOpOver, bitmap->image_pic, None, d->next_overlay_pic,
src_x, src_y, src_x, src_y, dst_x, dst_y, w, h);
@@ -631,12 +631,12 @@
* scale up if fullscreen
* the canvas image itself is scaled when it is created
*/
- src_x = (src->x_position * d->xres) / MHEG_XRES;
- src_y = (src->y_position * d->yres) / MHEG_YRES;
- w = (box->x_length * d->xres) / MHEG_XRES;
- h = (box->y_length * d->yres) / MHEG_YRES;
- dst_x = (dst->x_position * d->xres) / MHEG_XRES;
- dst_y = (dst->y_position * d->yres) / MHEG_YRES;
+ src_x = MHEGDisplay_scaleX(d, src->x_position);
+ src_y = MHEGDisplay_scaleY(d, src->y_position);
+ w = MHEGDisplay_scaleX(d, box->x_length);
+ h = MHEGDisplay_scaleY(d, box->y_length);
+ dst_x = MHEGDisplay_scaleX(d, dst->x_position);
+ dst_y = MHEGDisplay_scaleY(d, dst->y_position);
XRenderComposite(d->dpy, PictOpOver, canvas->contents_pic, None, d->next_overlay_pic,
src_x, src_y, src_x, src_y, dst_x, dst_y, w, h);
@@ -679,9 +679,9 @@
display_colour(&rcol, &text->col);
/* scale the x origin if fullscreen */
- orig_x = (pos->x_position * d->xres) / MHEG_XRES;
+ orig_x = MHEGDisplay_scaleX(d, pos->x_position);
/* y coord does not change */
- y = ((pos->y_position + text->y) * d->yres) / MHEG_YRES;
+ y = MHEGDisplay_scaleY(d, pos->y_position + text->y);
/* set the text foreground colour */
XRenderFillRectangle(d->dpy, PictOpSrc, d->textfg_pic, &rcol, 0, 0, 1, 1);
@@ -735,7 +735,7 @@
/* render it */
XftUnlockFace(font->font);
/* round up/down the X coord */
- scrn_x = (x * d->xres) / MHEG_XRES;
+ scrn_x = MHEGDisplay_scaleX(d, x);
scrn_x = (scrn_x + (face->units_per_EM / 2)) / face->units_per_EM;
XftGlyphRender(d->dpy, PictOpOver, d->textfg_pic, font->font, d->next_overlay_pic,
0, 0, orig_x + scrn_x, y,
@@ -1021,6 +1021,7 @@
/* if we are using fullscreen mode, scale the image */
if(d->fullscreen)
{
+printf("TODO: MHEGBitmap_fromRGBA: take aspect ratio into account\n");
/* set up the matrix to scale it */
XTransform xform;
/* X */
Modified: redbutton-browser/trunk/MHEGDisplay.h
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.h 2007-06-26 14:30:03 UTC (rev 319)
+++ redbutton-browser/trunk/MHEGDisplay.h 2007-07-16 16:00:42 UTC (rev 320)
@@ -89,5 +89,9 @@
/* utils */
bool intersects(XYPosition *, OriginalBoxSize *, XYPosition *, OriginalBoxSize *, XYPosition *, OriginalBoxSize *);
+/* convert X/Y coords from MHEG resolution (0->720, 0->576) to output resolution */
+#define MHEGDisplay_scaleX(DPY, X) (((X) * (DPY)->xres) / MHEG_XRES)
+#define MHEGDisplay_scaleY(DPY, Y) (((Y) * (DPY)->yres) / MHEG_YRES)
+
#endif /* __MHEGDISPLAY_H__ */
Modified: redbutton-browser/trunk/MHEGStreamPlayer.c
===================================================================
--- redbutton-browser/trunk/MHEGStreamPlayer.c 2007-06-26 14:30:03 UTC (rev 319)
+++ redbutton-browser/trunk/MHEGStreamPlayer.c 2007-07-16 16:00:42 UTC (rev 320)
@@ -630,11 +630,8 @@
}
pthread_mutex_unlock(&p->video->inst.scaled_lock);
/* scale up if fullscreen */
- if(d->fullscreen)
- {
- out_width = (out_width * d->xres) / MHEG_XRES;
- out_height = (out_height * d->yres) / MHEG_YRES;
- }
+ out_width = MHEGDisplay_scaleX(d, out_width);
+ out_height = MHEGDisplay_scaleY(d, out_height);
MHEGVideoOutput_prepareFrame(&vo, vf, out_width, out_height);
/* remember the PTS for this frame */
last_pts = vf->pts;
@@ -669,15 +666,12 @@
off_y = p->video->inst.VideoDecodeOffset.y_position;
pthread_mutex_unlock(&p->video->inst.bbox_lock);
/* scale if fullscreen */
- if(d->fullscreen)
- {
- out_x = (out_x * d->xres) / MHEG_XRES;
- out_y = (out_y * d->yres) / MHEG_YRES;
- vid_width = (vid_width * d->xres) / MHEG_XRES;
- vid_height = (vid_height * d->yres) / MHEG_YRES;
- off_x = (off_x * d->xres) / MHEG_XRES;
- off_y = (off_y * d->yres) / MHEG_YRES;
- }
+ out_x = MHEGDisplay_scaleX(d, out_x);
+ out_y = MHEGDisplay_scaleY(d, out_y);
+ vid_width = MHEGDisplay_scaleX(d, vid_width);
+ vid_height = MHEGDisplay_scaleY(d, vid_height);
+ off_x = MHEGDisplay_scaleX(d, off_x);
+ off_y = MHEGDisplay_scaleY(d, off_y);
/* if the frame is smaller or larger than the VideoClass, centre it */
out_x += (vid_width - out_width) / 2;
out_y += (vid_height - out_height) / 2;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|