Thread: [Redbutton-devel] SF.net SVN: redbutton: [60] redbutton-browser/trunk/MHEGDisplay.c
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-05-15 13:07:44
|
Revision: 60 Author: skilvington Date: 2006-05-15 06:07:39 -0700 (Mon, 15 May 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=60&view=rev Log Message: ----------- more TODO Modified Paths: -------------- redbutton-browser/trunk/MHEGDisplay.c Modified: redbutton-browser/trunk/MHEGDisplay.c =================================================================== --- redbutton-browser/trunk/MHEGDisplay.c 2006-05-15 10:55:48 UTC (rev 59) +++ redbutton-browser/trunk/MHEGDisplay.c 2006-05-15 13:07:39 UTC (rev 60) @@ -846,6 +846,8 @@ } /* get X to draw the XImage onto a Pixmap */ +/* TODO */ +/* this should be the Visual that matches PictStandardARGB32, not d->vis (the Window Visual) */ if((ximg = XCreateImage(d->dpy, d->vis, 32, ZPixmap, 0, xdata, width, height, 32, 0)) == NULL) fatal("XCreateImage failed"); bitmap->image = XCreatePixmap(d->dpy, d->win, width, height, 32); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-05-15 19:01:54
|
Revision: 62 Author: skilvington Date: 2006-05-15 12:01:46 -0700 (Mon, 15 May 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=62&view=rev Log Message: ----------- use correct RGB masks for bitmaps Modified Paths: -------------- redbutton-browser/trunk/MHEGDisplay.c Modified: redbutton-browser/trunk/MHEGDisplay.c =================================================================== --- redbutton-browser/trunk/MHEGDisplay.c 2006-05-15 16:12:00 UTC (rev 61) +++ redbutton-browser/trunk/MHEGDisplay.c 2006-05-15 19:01:46 UTC (rev 62) @@ -846,10 +846,13 @@ } /* get X to draw the XImage onto a Pixmap */ -/* TODO */ -/* this should be the Visual that matches PictStandardARGB32, not d->vis (the Window Visual) */ - if((ximg = XCreateImage(d->dpy, d->vis, 32, ZPixmap, 0, xdata, width, height, 32, 0)) == NULL) + if((ximg = XCreateImage(d->dpy, NULL, 32, ZPixmap, 0, xdata, width, height, 32, 0)) == NULL) fatal("XCreateImage failed"); + /* passed NULL Visual to XCreateImage, so set the rgb masks now */ + ximg->red_mask = pic_format->direct.redMask; + ximg->green_mask = pic_format->direct.greenMask; + ximg->blue_mask = pic_format->direct.blueMask; + /* create the Pixmap */ bitmap->image = XCreatePixmap(d->dpy, d->win, width, height, 32); gc = XCreateGC(d->dpy, bitmap->image, 0, NULL); XPutImage(d->dpy, bitmap->image, gc, ximg, 0, 0, 0, 0, width, height); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <ski...@us...> - 2006-09-11 10:07:11
|
Revision: 145
http://svn.sourceforge.net/redbutton/?rev=145&view=rev
Author: skilvington
Date: 2006-09-11 03:07:05 -0700 (Mon, 11 Sep 2006)
Log Message:
-----------
use ffmpeg's PIX_FMT_RGBA32 as our intermediate MHEGBitmap pixel format
Modified Paths:
--------------
redbutton-browser/trunk/MHEGDisplay.c
Modified: redbutton-browser/trunk/MHEGDisplay.c
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.c 2006-09-01 16:55:19 UTC (rev 144)
+++ redbutton-browser/trunk/MHEGDisplay.c 2006-09-11 10:07:05 UTC (rev 145)
@@ -732,6 +732,7 @@
MHEGBitmap *b;
png_uint_32 width, height;
unsigned char *rgba;
+ unsigned int i;
/* nothing to do */
if(png == NULL || png->size == 0)
@@ -747,7 +748,25 @@
/*
* we now have an array of 32-bit RGBA pixels in network byte order
* ie if pix is a char *: pix[0] = R, pix[1] = G, pix[2] = B, pix[3] = A
+ * we need to convert it to ffmpeg's PIX_FMT_RGBA32 format
+ * ffmpeg always stores PIX_FMT_RGBA32 as
+ * (A << 24) | (R << 16) | (G << 8) | B
+ * no matter what byte order our CPU uses. ie,
+ * it is stored as BGRA on little endian CPU architectures and ARGB on big endian CPUs
*/
+ for(i=0; i<width*height; i++)
+ {
+ uint8_t r = rgba[(i * 4) + 0];
+ uint8_t g = rgba[(i * 4) + 1];
+ uint8_t b = rgba[(i * 4) + 2];
+ uint8_t a = rgba[(i * 4) + 3];
+/* TODO */
+/* if we still need to do r=g=b=0 when a=0, do it here */
+ uint32_t pix = (a << 24) | (r << 16) | (g << 8) | b;
+ *((uint32_t *) &rgba[i * 4]) = pix;
+ }
+
+ /* convert the PIX_FMT_RGBA32 data to a MHEGBitmap */
b = MHEGBitmap_fromRGBA(d, rgba, width, height);
/* clean up */
@@ -777,7 +796,6 @@
unsigned int height;
int nbytes;
unsigned char *rgba = NULL;
- unsigned int i;
/* nothing to do */
if(mpeg == NULL || mpeg->size == 0)
@@ -827,25 +845,7 @@
rgba = safe_malloc(nbytes);
avpicture_fill((AVPicture *) rgb_frame, rgba, PIX_FMT_RGBA32, width, height);
img_convert((AVPicture *) rgb_frame, PIX_FMT_RGBA32, (AVPicture*) yuv_frame, codec_ctx->pix_fmt, width, height);
- /*
- * ffmpeg always stores PIX_FMT_RGBA32 as
- * (A << 24) | (R << 16) | (G << 8) | B
- * no matter what byte order our CPU uses. ie,
- * it is stored as BGRA on little endian CPU architectures and ARGB on big endian CPUs
- * we need RGBA, so swap the components as needed
- */
- for(i=0; i<width*height; i++)
- {
- uint32_t pix = *((uint32_t *) &rgba[(i * 4)]);
- rgba[(i * 4) + 0] = (pix >> 16) & 0xff; /* R */
- rgba[(i * 4) + 1] = (pix >> 8) & 0xff; /* G */
- rgba[(i * 4) + 2] = pix & 0xff; /* B */
- rgba[(i * 4) + 3] = 0xff; /* opaque */
- }
- /*
- * we now have an array of 32-bit RGBA pixels in network byte order
- * ie if pix is a char *: pix[0] = R, pix[1] = G, pix[2] = B, pix[3] = A
- */
+ /* convert the PIX_FMT_RGBA32 data to a MHEGBitmap */
b = MHEGBitmap_fromRGBA(d, rgba, width, height);
}
@@ -872,8 +872,11 @@
}
/*
- * construct a MHEGBitmap from an array of 32-bit RGBA pixels in network byte order
- * ie if pix is a char *: pix[0] = R, pix[1] = G, pix[2] = B, pix[3] = A
+ * construct a MHEGBitmap from an array of ffmpeg's PIX_FMT_RGBA32 pixels
+ * ffmpeg always stores PIX_FMT_RGBA32 as
+ * (A << 24) | (R << 16) | (G << 8) | B
+ * no matter what byte order our CPU uses. ie,
+ * it is stored as BGRA on little endian CPU architectures and ARGB on big endian CPUs
*/
MHEGBitmap *
@@ -881,8 +884,9 @@
{
MHEGBitmap *bitmap;
unsigned char *xdata;
+ uint32_t rgba_pix;
uint32_t xpix;
- unsigned char r, g, b, a;
+ uint8_t r, g, b, a;
unsigned int i, npixs;
XImage *ximg;
XRenderPictFormat *pic_format;
@@ -900,7 +904,7 @@
xdata = safe_malloc(npixs * 4);
/*
* copy the pixels, converting them to our XRender RGBA order as we go
- * even if the XRender pixel layout is the same as the PNG one we still process each pixel
+ * even if the XRender pixel layout is the same as the ffmpeg one we still process each pixel
* because we want to make sure transparent pixels have 0 for their RGB components
* otherwise, if we scale up the bitmap in fullscreen mode and apply our bilinear filter,
* we may end up with a border around the image
@@ -910,10 +914,11 @@
*/
for(i=0; i<npixs; i++)
{
- r = rgba[(i * 4) + 0];
- g = rgba[(i * 4) + 1];
- b = rgba[(i * 4) + 2];
- a = rgba[(i * 4) + 3];
+ rgba_pix = *((uint32_t *) &rgba[i * 4]);
+ a = (rgba_pix >> 24) & 0xff;
+ r = (rgba_pix >> 16) & 0xff;
+ g = (rgba_pix >> 8) & 0xff;
+ b = rgba_pix & 0xff;
/* is it transparent */
if(a == 0)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-10 16:26:56
|
Revision: 321
http://redbutton.svn.sourceforge.net/redbutton/?rev=321&view=rev
Author: skilvington
Date: 2007-08-10 09:26:50 -0700 (Fri, 10 Aug 2007)
Log Message:
-----------
make sure ffmpeg doesn't read passed the end of our buffer
Modified Paths:
--------------
redbutton-browser/trunk/MHEGDisplay.c
Modified: redbutton-browser/trunk/MHEGDisplay.c
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.c 2007-07-16 16:00:42 UTC (rev 320)
+++ redbutton-browser/trunk/MHEGDisplay.c 2007-08-10 16:26:50 UTC (rev 321)
@@ -852,6 +852,7 @@
AVCodec *codec;
AVFrame *yuv_frame;
AVFrame *rgb_frame;
+ unsigned char *padded;
unsigned char *data;
unsigned int size;
int used;
@@ -880,8 +881,13 @@
if((rgb_frame = avcodec_alloc_frame()) == NULL)
fatal("Out of memory");
+ /* ffmpeg may read passed the end of the buffer, so pad it out */
+ padded = safe_malloc(mpeg->size + FF_INPUT_BUFFER_PADDING_SIZE);
+ memcpy(padded, mpeg->data, mpeg->size);
+ memset(padded + mpeg->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
/* decode the YUV frame */
- data = mpeg->data;
+ data = padded;
size = mpeg->size;
do
{
@@ -914,6 +920,7 @@
}
/* clean up */
+ safe_free(padded);
safe_free(rgba);
av_free(yuv_frame);
av_free(rgb_frame);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-01 18:10:54
|
Revision: 271
http://svn.sourceforge.net/redbutton/?rev=271&view=rev
Author: skilvington
Date: 2007-04-01 11:10:29 -0700 (Sun, 01 Apr 2007)
Log Message:
-----------
remove duplicate code
Modified Paths:
--------------
redbutton-browser/trunk/MHEGDisplay.c
Modified: redbutton-browser/trunk/MHEGDisplay.c
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.c 2007-04-01 10:06:49 UTC (rev 270)
+++ redbutton-browser/trunk/MHEGDisplay.c 2007-04-01 18:10:29 UTC (rev 271)
@@ -388,7 +388,7 @@
MHEGDisplay_clearScreen(MHEGDisplay *d)
{
XYPosition pos = {0, 0};
- OriginalBoxSize box = {d->xres, d->yres};
+ OriginalBoxSize box;
MHEGColour black;
box.x_length = d->xres;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-04-02 08:30:26
|
Revision: 272
http://svn.sourceforge.net/redbutton/?rev=272&view=rev
Author: skilvington
Date: 2007-04-02 01:30:24 -0700 (Mon, 02 Apr 2007)
Log Message:
-----------
fillRectangle scales coords if needed
Modified Paths:
--------------
redbutton-browser/trunk/MHEGDisplay.c
Modified: redbutton-browser/trunk/MHEGDisplay.c
===================================================================
--- redbutton-browser/trunk/MHEGDisplay.c 2007-04-01 18:10:29 UTC (rev 271)
+++ redbutton-browser/trunk/MHEGDisplay.c 2007-04-02 08:30:24 UTC (rev 272)
@@ -388,12 +388,9 @@
MHEGDisplay_clearScreen(MHEGDisplay *d)
{
XYPosition pos = {0, 0};
- OriginalBoxSize box;
+ OriginalBoxSize box = {MHEG_XRES, MHEG_YRES};
MHEGColour black;
- box.x_length = d->xres;
- box.y_length = d->yres;
-
MHEGColour_black(&black);
MHEGDisplay_fillRectangle(d, &pos, &box, &black);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|