diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-21 17:34:23 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-21 17:34:23 +0000 |
commit | 436b928915f56a8bc56fc7065800fad7e474e158 (patch) | |
tree | 9d0680a8099f22e639058ce366e79032129f13f7 /src/video_out | |
parent | a2c0482e17a5d1d0ea99d06b81e94c0e7b5cb4e2 (diff) | |
download | xine-lib-436b928915f56a8bc56fc7065800fad7e474e158.tar.gz xine-lib-436b928915f56a8bc56fc7065800fad7e474e158.tar.bz2 |
solaris and stability patches provided by Juergen Keil
CVS patchset: 211
CVS date: 2001/06/21 17:34:23
Diffstat (limited to 'src/video_out')
-rw-r--r-- | src/video_out/video_out_syncfb.c | 6 | ||||
-rw-r--r-- | src/video_out/video_out_xshm.c | 45 | ||||
-rw-r--r-- | src/video_out/yuv2rgb.c | 679 | ||||
-rw-r--r-- | src/video_out/yuv2rgb.h | 14 | ||||
-rw-r--r-- | src/video_out/yuv2rgb_mmx.c | 43 |
5 files changed, 595 insertions, 192 deletions
diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c index fa09ddf99..ae3435d72 100644 --- a/src/video_out/video_out_syncfb.c +++ b/src/video_out/video_out_syncfb.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_syncfb.c,v 1.5 2001/06/14 18:32:57 guenter Exp $ + * $Id: video_out_syncfb.c,v 1.6 2001/06/21 17:34:24 guenter Exp $ * * video_out_syncfb.c, Matrox G400 video extension interface for xine * @@ -54,6 +54,10 @@ #include <linux/config.h> /* Check for DEVFS */ #endif +#if defined(__sun) +#include <sys/ioccom.h> +#endif + #include "video_out.h" #include "video_out_x11.h" #include "video_out_syncfb.h" diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index 3284f92e2..3fac1dad7 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_xshm.c,v 1.9 2001/06/14 20:17:06 guenter Exp $ + * $Id: video_out_xshm.c,v 1.10 2001/06/21 17:34:24 guenter Exp $ * * video_out_xshm.c, X11 shared memory extension interface for xine * @@ -69,6 +69,7 @@ typedef struct xshm_frame_s { XImage *image; uint8_t *rgb_dst; + int rgb_row; int stripe_inc; XShmSegmentInfo shminfo; @@ -211,6 +212,8 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, if (shminfo->shmaddr == ((char *) -1)) { printf ("video_out_xshm: shared memory error (address error) when allocating image \n"); printf ("video_out_xshm: => not using MIT Shared Memory extension.\n"); + shmctl (shminfo->shmid, IPC_RMID, 0); + shminfo->shmid = -1; this->use_shm = 0; goto finishShmTesting; } @@ -225,8 +228,22 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, if (gX11Fail) { printf ("video_out_xshm: x11 error during shared memory XImage creation\n"); printf ("video_out_xshm: => not using MIT Shared Memory extension.\n"); + shmdt (shminfo->shmaddr); + shmctl (shminfo->shmid, IPC_RMID, 0); + shminfo->shmid = -1; this->use_shm = 0; + goto finishShmTesting; } + + /* + * Now that the Xserver has learned about and attached to the + * shared memory segment, delete it. It's actually deleted by + * the kernel when all users of that segment have detached from + * it. Gives an automatic shared memory cleanup in case we crash. + */ + shmctl (shminfo->shmid, IPC_RMID, 0); + shminfo->shmid = -1; + finishShmTesting: x11_DeInstallXErrorHandler(this); @@ -283,7 +300,10 @@ static void dispose_ximage (xshm_driver_t *this, XShmDetach (this->display, shminfo); XDestroyImage (myimage); shmdt (shminfo->shmaddr); - shmctl (shminfo->shmid, IPC_RMID, 0); + if (shminfo->shmid >= 0) { + shmctl (shminfo->shmid, IPC_RMID, 0); + shminfo->shmid = -1; + } } else { @@ -304,10 +324,25 @@ static void xshm_frame_copy (vo_frame_t *vo_img, uint8_t **src) { xshm_frame_t *frame = (xshm_frame_t *) vo_img ; xshm_driver_t *this = (xshm_driver_t *) vo_img->instance->driver; +#if 0 +#warning FIXME + /* + * A complete stripe may not fit into the destination rgb image. + * Ignore the stripe for now, instead of crashing inside yuv2rgb_fun(). + */ + if (frame->rgb_row + this->stripe_height > frame->rgb_height) { + printf("xshm_frame_copy: stripe %d..%d out of rgb image bounds %d\n", + frame->rgb_row, frame->rgb_row+this->stripe_height-1, + frame->rgb_height); + return; + } +#endif + this->yuv2rgb->yuv2rgb_fun (this->yuv2rgb, frame->rgb_dst, src[0], src[1], src[2]); frame->rgb_dst += frame->stripe_inc; + frame->rgb_row += this->stripe_height; } static void xshm_frame_field (vo_frame_t *vo_img, int which_field) { @@ -364,6 +399,9 @@ static void xshm_calc_output_size (xshm_driver_t *this) { * aspect ratio calculation */ + if (this->delivered_width == 0 && this->delivered_height == 0) + return; /* ConfigureNotify/VisibilityNotify, no decoder output size known */ + image_ratio = (double) this->delivered_width / (double) this->delivered_height; @@ -525,6 +563,7 @@ static void xshm_update_frame_format (vo_driver_t *this_gen, if (frame->image) { frame->rgb_dst = frame->image->data; + frame->rgb_row = 0; frame->stripe_inc = this->stripe_height * frame->image->bytes_per_line; } } @@ -806,7 +845,7 @@ vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual_gen) { mode = 0; - printf ("video_out_xshm: video mode is %d depth (%d bpp), red: %08x, green: %08x, blue: %08x\n", + printf ("video_out_xshm: video mode is %d depth (%d bpp), red: %08lx, green: %08lx, blue: %08lx\n", this->depth, this->bpp, this->vinfo.red_mask, this->vinfo.green_mask, this->vinfo.blue_mask); diff --git a/src/video_out/yuv2rgb.c b/src/video_out/yuv2rgb.c index e4b60033f..7abfdac0e 100644 --- a/src/video_out/yuv2rgb.c +++ b/src/video_out/yuv2rgb.c @@ -42,23 +42,6 @@ const int32_t Inverse_Table_6_9[8][4] = { {117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */ }; -static void yuv2rgb_c (yuv2rgb_t *this, uint8_t *image, - uint8_t *py, uint8_t *pu, uint8_t *pv) { - - /* int dy = this->step_dy; */ - int height = this->source_height >>= 1; - - do { - this->yuv2rgb_c_internal (this, py, py + this->y_stride, pu, pv, - image, ((uint8_t *)image) + this->rgb_stride, - this->source_width); - - py += 2 * this->y_stride; - pu += this->uv_stride; - pv += this->uv_stride; - image = ((uint8_t *) image) + 2 * this->rgb_stride; - } while (--height); -} static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) { @@ -91,6 +74,19 @@ int yuv2rgb_setup (yuv2rgb_t *this, this->dest_height = dest_height; this->rgb_stride = rgb_stride; + if (this->y_chunk) { + free (this->y_chunk); + this->y_buffer = this->y_chunk = NULL; + } + if (this->u_chunk) { + free (this->u_chunk); + this->u_buffer = this->u_chunk = NULL; + } + if (this->v_chunk) { + free (this->v_chunk); + this->v_buffer = this->v_chunk = NULL; + } + if ((source_width == dest_width) && (source_height == dest_height)) this->do_scale = 0; else { @@ -99,10 +95,6 @@ int yuv2rgb_setup (yuv2rgb_t *this, this->step_dx = source_width * 32768 / dest_width; this->step_dy = source_height * 32768 / dest_height; - if (this->y_chunk) free (this->y_chunk); - if (this->u_chunk) free (this->u_chunk); - if (this->v_chunk) free (this->v_chunk); - this->y_buffer = my_malloc_aligned (16, dest_width, &this->y_chunk); if (!this->y_buffer) return 0; @@ -117,6 +109,34 @@ int yuv2rgb_setup (yuv2rgb_t *this, } +static void scale_line (uint8_t *source, uint8_t *dest, + int width, int step) { + int p1; + int p2; + int dx; + + p1 = *source++; + p2 = *source++; + dx = 0; + + while (width) { + + *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; + + dx += step; + while (dx > 32768) { + dx -= 32768; + p1 = p2; + p2 = *source++; + } + + dest ++; + width --; + } + +} + + #define RGB(i) \ U = pu[i]; \ V = pv[i]; \ @@ -160,164 +180,505 @@ int yuv2rgb_setup (yuv2rgb_t *this, Y = py_2[2*i+1]; \ dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y]; -static void yuv2rgb_c_32 (yuv2rgb_t *this, - uint8_t * py_1, uint8_t * py_2, - uint8_t * pu, uint8_t * pv, - void * _dst_1, void * _dst_2, int width) +static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, + uint8_t * _py, uint8_t * _pu, uint8_t * _pv) { int U, V, Y; + uint8_t * py_1, * py_2, * pu, * pv; uint32_t * r, * g, * b; uint32_t * dst_1, * dst_2; - - width >>= 3; - dst_1 = _dst_1; - dst_2 = _dst_2; - - do { - RGB(0); - DST1(0); - DST2(0); - - RGB(1); - DST2(1); - DST1(1); - - RGB(2); - DST1(2); - DST2(2); - - RGB(3); - DST2(3); - DST1(3); - - pu += 4; - pv += 4; - py_1 += 8; - py_2 += 8; - dst_1 += 8; - dst_2 += 8; - } while (--width); + int width, height; + int dy; + + if (this->do_scale) { + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + dy = 0; + height = this->source_height; + + for (;;) { + dst_1 = (uint32_t*)_dst; + py_1 = this->y_buffer; + pu = this->u_buffer; + pv = this->v_buffer; + + width = this->dest_width >> 3; + + do { + RGB(0); + DST1(0); + + RGB(1); + DST1(1); + + RGB(2); + DST1(2); + + RGB(3); + DST1(3); + + pu += 4; + pv += 4; + py_1 += 8; + dst_1 += 8; + } while (--width); + + dy += this->step_dy; + _dst += this->rgb_stride; + + while (dy <= 32768) { + + memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); + + dy += this->step_dy; + _dst += this->rgb_stride; + } + + if (--height <= 0) + break; + + dy -= 32768; + _py += this->y_stride; + + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + if (!(height & 1)) { + _pu += this->uv_stride; + _pv += this->uv_stride; + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + + } + } + } else { + height = this->source_height >> 1; + do { + dst_1 = (uint32_t*)_dst; + dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); + py_1 = _py; + py_2 = _py + this->y_stride; + pu = _pu; + pv = _pv; + + width = this->source_width >> 3; + do { + RGB(0); + DST1(0); + DST2(0); + + RGB(1); + DST2(1); + DST1(1); + + RGB(2); + DST1(2); + DST2(2); + + RGB(3); + DST2(3); + DST1(3); + + pu += 4; + pv += 4; + py_1 += 8; + py_2 += 8; + dst_1 += 8; + dst_2 += 8; + } while (--width); + + _dst += 2 * this->rgb_stride; + _py += 2 * this->y_stride; + _pu += this->uv_stride; + _pv += this->uv_stride; + + } while (--height); + } } /* This is very near from the yuv2rgb_c_32 code */ -static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, - uint8_t * py_1, uint8_t * py_2, - uint8_t * pu, uint8_t * pv, - void * _dst_1, void * _dst_2, int width) +static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, + uint8_t * _py, uint8_t * _pu, uint8_t * _pv) { int U, V, Y; + uint8_t * py_1, * py_2, * pu, * pv; uint8_t * r, * g, * b; uint8_t * dst_1, * dst_2; - - width >>= 3; - dst_1 = _dst_1; - dst_2 = _dst_2; - - do { - RGB(0); - DST1RGB(0); - DST2RGB(0); - - RGB(1); - DST2RGB(1); - DST1RGB(1); - - RGB(2); - DST1RGB(2); - DST2RGB(2); - - RGB(3); - DST2RGB(3); - DST1RGB(3); - - pu += 4; - pv += 4; - py_1 += 8; - py_2 += 8; - dst_1 += 24; - dst_2 += 24; - } while (--width); + int width, height; + int dy; + + if (this->do_scale) { + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + dy = 0; + height = this->source_height; + + for (;;) { + dst_1 = _dst; + py_1 = this->y_buffer; + pu = this->u_buffer; + pv = this->v_buffer; + + width = this->dest_width >> 3; + + do { + RGB(0); + DST1RGB(0); + + RGB(1); + DST1RGB(1); + + RGB(2); + DST1RGB(2); + + RGB(3); + DST1RGB(3); + + pu += 4; + pv += 4; + py_1 += 8; + dst_1 += 24; + } while (--width); + + dy += this->step_dy; + _dst += this->rgb_stride; + + while (dy <= 32768) { + + memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); + + dy += this->step_dy; + _dst += this->rgb_stride; + } + + if (--height <= 0) + break; + + dy -= 32768; + _py += this->y_stride; + + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + if (!(height & 1)) { + _pu += this->uv_stride; + _pv += this->uv_stride; + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + + } + } + } else { + height = this->source_height >> 1; + do { + dst_1 = _dst; + dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); + py_1 = _py; + py_2 = _py + this->y_stride; + pu = _pu; + pv = _pv; + + width = this->source_width >> 3; + do { + RGB(0); + DST1RGB(0); + DST2RGB(0); + + RGB(1); + DST2RGB(1); + DST1RGB(1); + + RGB(2); + DST1RGB(2); + DST2RGB(2); + + RGB(3); + DST2RGB(3); + DST1RGB(3); + + pu += 4; + pv += 4; + py_1 += 8; + py_2 += 8; + dst_1 += 24; + dst_2 += 24; + } while (--width); + + _dst += 2 * this->rgb_stride; + _py += 2 * this->y_stride; + _pu += this->uv_stride; + _pv += this->uv_stride; + + } while (--height); + } } /* only trivial mods from yuv2rgb_c_24_rgb */ -static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, - uint8_t * py_1, uint8_t * py_2, - uint8_t * pu, uint8_t * pv, - void * _dst_1, void * _dst_2, int width) +static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, + uint8_t * _py, uint8_t * _pu, uint8_t * _pv) { int U, V, Y; + uint8_t * py_1, * py_2, * pu, * pv; uint8_t * r, * g, * b; uint8_t * dst_1, * dst_2; + int width, height; + int dy; + + if (this->do_scale) { + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + dy = 0; + height = this->source_height; + + for (;;) { + dst_1 = _dst; + py_1 = this->y_buffer; + pu = this->u_buffer; + pv = this->v_buffer; + + width = this->dest_width >> 3; + + do { + RGB(0); + DST1BGR(0); + + RGB(1); + DST1BGR(1); + + RGB(2); + DST1BGR(2); + + RGB(3); + DST1BGR(3); + + pu += 4; + pv += 4; + py_1 += 8; + dst_1 += 24; + } while (--width); + + dy += this->step_dy; + _dst += this->rgb_stride; + + while (dy <= 32768) { + + memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); + + dy += this->step_dy; + _dst += this->rgb_stride; + } + + if (--height <= 0) + break; + + dy -= 32768; + _py += this->y_stride; + + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + if (!(height & 1)) { + _pu += this->uv_stride; + _pv += this->uv_stride; + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + + } + } - width >>= 3; - dst_1 = _dst_1; - dst_2 = _dst_2; - - do { - RGB(0); - DST1BGR(0); - DST2BGR(0); - - RGB(1); - DST2BGR(1); - DST1BGR(1); - - RGB(2); - DST1BGR(2); - DST2BGR(2); - - RGB(3); - DST2BGR(3); - DST1BGR(3); - - pu += 4; - pv += 4; - py_1 += 8; - py_2 += 8; - dst_1 += 24; - dst_2 += 24; - } while (--width); + } else { + height = this->source_height >> 1; + do { + dst_1 = _dst; + dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); + py_1 = _py; + py_2 = _py + this->y_stride; + pu = _pu; + pv = _pv; + width = this->source_width >> 3; + do { + RGB(0); + DST1BGR(0); + DST2BGR(0); + + RGB(1); + DST2BGR(1); + DST1BGR(1); + + RGB(2); + DST1BGR(2); + DST2BGR(2); + + RGB(3); + DST2BGR(3); + DST1BGR(3); + + pu += 4; + pv += 4; + py_1 += 8; + py_2 += 8; + dst_1 += 24; + dst_2 += 24; + } while (--width); + + _dst += 2 * this->rgb_stride; + _py += 2 * this->y_stride; + _pu += this->uv_stride; + _pv += this->uv_stride; + + } while (--height); + } } /* This is exactly the same code as yuv2rgb_c_32 except for the types of */ /* r, g, b, dst_1, dst_2 */ -static void yuv2rgb_c_16 (yuv2rgb_t *this, - uint8_t * py_1, uint8_t * py_2, - uint8_t * pu, uint8_t * pv, - void * _dst_1, void * _dst_2, int width) +static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, + uint8_t * _py, uint8_t * _pu, uint8_t * _pv) { int U, V, Y; + uint8_t * py_1, * py_2, * pu, * pv; uint16_t * r, * g, * b; uint16_t * dst_1, * dst_2; - - width >>= 3; - dst_1 = _dst_1; - dst_2 = _dst_2; - - do { - RGB(0); - DST1(0); - DST2(0); - - RGB(1); - DST2(1); - DST1(1); - - RGB(2); - DST1(2); - DST2(2); - - RGB(3); - DST2(3); - DST1(3); - - pu += 4; - pv += 4; - py_1 += 8; - py_2 += 8; - dst_1 += 8; - dst_2 += 8; - } while (--width); + int width, height; + int dy; + + if (this->do_scale) { + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + dy = 0; + height = this->source_height; + + for (;;) { + dst_1 = (uint16_t*)_dst; + py_1 = this->y_buffer; + pu = this->u_buffer; + pv = this->v_buffer; + + width = this->dest_width >> 3; + + do { + RGB(0); + DST1(0); + + RGB(1); + DST1(1); + + RGB(2); + DST1(2); + + RGB(3); + DST1(3); + + pu += 4; + pv += 4; + py_1 += 8; + dst_1 += 8; + } while (--width); + + dy += this->step_dy; + _dst += this->rgb_stride; + + while (dy <= 32768) { + + memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); + + dy += this->step_dy; + _dst += this->rgb_stride; + } + + if (--height <= 0) + break; + + dy -= 32768; + _py += this->y_stride; + + scale_line (_py, this->y_buffer, + this->dest_width, this->step_dx); + + if (!(height & 1)) { + _pu += this->uv_stride; + _pv += this->uv_stride; + + scale_line (_pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + scale_line (_pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + + } + } + } else { + height = this->source_height >> 1; + do { + dst_1 = (uint16_t*)_dst; + dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); + py_1 = _py; + py_2 = _py + this->y_stride; + pu = _pu; + pv = _pv; + width = this->source_width >> 3; + do { + RGB(0); + DST1(0); + DST2(0); + + RGB(1); + DST2(1); + DST1(1); + + RGB(2); + DST1(2); + DST2(2); + + RGB(3); + DST2(3); + DST1(3); + + pu += 4; + pv += 4; + py_1 += 8; + py_2 += 8; + dst_1 += 8; + dst_2 += 8; + } while (--width); + + _dst += 2 * this->rgb_stride; + _py += 2 * this->y_stride; + _pu += this->uv_stride; + _pv += this->uv_stride; + + } while (--height); + } } static int div_round (int dividend, int divisor) @@ -343,8 +704,6 @@ static void yuv2rgb_c_init (yuv2rgb_t *this, int mode) int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2]; int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3]; - this->yuv2rgb_fun = yuv2rgb_c; - for (i = 0; i < 1024; i++) { int j; @@ -356,7 +715,7 @@ static void yuv2rgb_c_init (yuv2rgb_t *this, int mode) switch (mode) { case MODE_32_RGB: case MODE_32_BGR: - this->yuv2rgb_c_internal = yuv2rgb_c_32; + this->yuv2rgb_fun = yuv2rgb_c_32; table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); @@ -377,7 +736,7 @@ static void yuv2rgb_c_init (yuv2rgb_t *this, int mode) case MODE_24_RGB: case MODE_24_BGR: - this->yuv2rgb_c_internal = (mode==MODE_24_RGB) ? yuv2rgb_c_24_rgb : yuv2rgb_c_24_bgr; + this->yuv2rgb_fun = (mode==MODE_24_RGB) ? yuv2rgb_c_24_rgb : yuv2rgb_c_24_bgr; table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); @@ -392,7 +751,7 @@ static void yuv2rgb_c_init (yuv2rgb_t *this, int mode) case MODE_16_BGR: case MODE_15_RGB: case MODE_16_RGB: - this->yuv2rgb_c_internal = yuv2rgb_c_16; + this->yuv2rgb_fun = yuv2rgb_c_16; table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); @@ -452,9 +811,9 @@ yuv2rgb_t *yuv2rgb_init (int mode) { this->matrix_coefficients = 6; - this->y_buffer = NULL; - this->u_buffer = NULL; - this->v_buffer = NULL; + this->y_chunk = this->y_buffer = NULL; + this->y_chunk = this->u_buffer = NULL; + this->y_chunk = this->v_buffer = NULL; /* * auto-probe for the best yuv2rgb function diff --git a/src/video_out/yuv2rgb.h b/src/video_out/yuv2rgb.h index b966eca82..9a2e2fb0a 100644 --- a/src/video_out/yuv2rgb.h +++ b/src/video_out/yuv2rgb.h @@ -36,19 +36,17 @@ struct yuv2rgb_s { int rgb_stride; int step_dx, step_dy; int do_scale; - uint8_t *y_buffer, *y_chunk; - uint8_t *u_buffer, *u_chunk; - uint8_t *v_buffer, *v_chunk; + uint8_t *y_buffer; + uint8_t *u_buffer; + uint8_t *v_buffer; + void *y_chunk; + void *u_chunk; + void *v_chunk; void *table_rV[256]; void *table_gU[256]; int table_gV[256]; void *table_bU[256]; - - void (* yuv2rgb_c_internal) (yuv2rgb_t *this, - uint8_t *, uint8_t *, - uint8_t *, uint8_t *, - void *, void *, int); } ; diff --git a/src/video_out/yuv2rgb_mmx.c b/src/video_out/yuv2rgb_mmx.c index e7c828ff7..5277dd472 100644 --- a/src/video_out/yuv2rgb_mmx.c +++ b/src/video_out/yuv2rgb_mmx.c @@ -403,7 +403,7 @@ static inline void yuv420_rgb16 (yuv2rgb_t *this, this->dest_width >> 1, this->step_dx); scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - do { + for (;;) { y_buf = this->y_buffer; u_buf = this->u_buffer; @@ -432,6 +432,9 @@ static inline void yuv420_rgb16 (yuv2rgb_t *this, image += rgb_stride; } + if (--height <= 0) + break; + dy -= 32768; py += y_stride; @@ -439,7 +442,7 @@ static inline void yuv420_rgb16 (yuv2rgb_t *this, scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - if (height & 1) { + if (!(height & 1)) { pu += uv_stride; pv += uv_stride; @@ -449,8 +452,7 @@ static inline void yuv420_rgb16 (yuv2rgb_t *this, this->dest_width >> 1, this->step_dx); } - height--; - } while (height>0); + } } } @@ -507,7 +509,7 @@ static inline void yuv420_rgb15 (yuv2rgb_t *this, this->dest_width >> 1, this->step_dx); scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - do { + for (;;) { y_buf = this->y_buffer; u_buf = this->u_buffer; @@ -536,14 +538,16 @@ static inline void yuv420_rgb15 (yuv2rgb_t *this, image += rgb_stride; } - dy -= 32768; + if (--height <= 0) + break; + dy -= 32768; py += y_stride; scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - if (height & 1) { + if (!(height & 1)) { pu += uv_stride; pv += uv_stride; @@ -553,8 +557,7 @@ static inline void yuv420_rgb15 (yuv2rgb_t *this, this->dest_width >> 1, this->step_dx); } - height--; - } while (height>0); + } } } @@ -609,7 +612,7 @@ static inline void yuv420_rgb24 (yuv2rgb_t *this, scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - do { + for (;;) { y_buf = this->y_buffer; u_buf = this->u_buffer; @@ -633,21 +636,22 @@ static inline void yuv420_rgb24 (yuv2rgb_t *this, while (dy <= 32768) { - memcpy (image, image-rgb_stride, this->dest_width*4); + memcpy (image, image-rgb_stride, this->dest_width*3); dy += this->step_dy; image += rgb_stride; } + if (--height <= 0) + break; dy -= 32768; - py += y_stride; scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - if (height & 1) { + if (!(height & 1)) { pu += uv_stride; pv += uv_stride; @@ -656,9 +660,8 @@ static inline void yuv420_rgb24 (yuv2rgb_t *this, scale_line (pv, this->v_buffer, this->dest_width >> 1, this->step_dx); } - height--; - } while (height>0); + } } } @@ -714,7 +717,7 @@ static inline void yuv420_argb32 (yuv2rgb_t *this, scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - do { + for (;;) { y_buf = this->y_buffer; u_buf = this->u_buffer; @@ -744,15 +747,16 @@ static inline void yuv420_argb32 (yuv2rgb_t *this, image += rgb_stride; } + if (--height <= 0) + break; dy -= 32768; - py += y_stride; scale_line (py, this->y_buffer, this->dest_width, this->step_dx); - if (height & 1) { + if (!(height & 1)) { pu += uv_stride; pv += uv_stride; @@ -761,9 +765,8 @@ static inline void yuv420_argb32 (yuv2rgb_t *this, scale_line (pv, this->v_buffer, this->dest_width >> 1, this->step_dx); } - height--; - } while (height>0); + } } } |