diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/video_out/Makefile.am | 6 | ||||
-rw-r--r-- | src/video_out/video_out_syncfb.c | 14 | ||||
-rw-r--r-- | src/video_out/video_out_xshm.c | 59 | ||||
-rw-r--r-- | src/video_out/yuv2rgb.c | 28 | ||||
-rw-r--r-- | src/video_out/yuv2rgb_mlib.c | 288 | ||||
-rw-r--r-- | src/video_out/yuv2rgb_mmx.c | 8 |
6 files changed, 366 insertions, 37 deletions
diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am index f6d884699..b946f20e9 100644 --- a/src/video_out/Makefile.am +++ b/src/video_out/Makefile.am @@ -1,4 +1,5 @@ -CFLAGS = @GLOBAL_CFLAGS@ @X_CFLAGS@ -DXINE_COMPILE +CFLAGS = @GLOBAL_CFLAGS@ @X_CFLAGS@ @LIBMPEG2_CFLAGS@ -DXINE_COMPILE +DEBUG_CFLAGS = @DEBUG_CFLAGS@ @X_CFLAGS@ @LIBMPEG2_CFLAGS@ -DXINE_COMPILE LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic @@ -28,7 +29,8 @@ xineplug_vo_out_xv_la_SOURCES = video_out_xv.c xineplug_vo_out_xv_la_LIBADD = $(XV_LIB) $(X_LIBS) -lXext xineplug_vo_out_xv_la_LDFLAGS = -avoid-version -module -xineplug_vo_out_xshm_la_SOURCES = yuv2rgb.c yuv2rgb_mmx.c video_out_xshm.c +xineplug_vo_out_xshm_la_SOURCES = yuv2rgb.c yuv2rgb_mmx.c yuv2rgb_mlib.c \ + video_out_xshm.c xineplug_vo_out_xshm_la_LIBADD = $(X_LIBS) -lXext xineplug_vo_out_xshm_la_LDFLAGS = -avoid-version -module diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c index ae3435d72..a7ec000a1 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.6 2001/06/21 17:34:24 guenter Exp $ + * $Id: video_out_syncfb.c,v 1.7 2001/07/04 14:01:50 uid56437 Exp $ * * video_out_syncfb.c, Matrox G400 video extension interface for xine * @@ -211,9 +211,6 @@ static void setup_window_mga () { XWindowAttributes wattr; - Atom prop; - MWMHints mwmhints; - XGetWindowAttributes(_mga_priv.lDisplay, DefaultRootWindow(_mga_priv.lDisplay), &wattr); _display.width = wattr.width; @@ -349,6 +346,9 @@ printf("setup_window_mga: unscaled size should be %d x %d \n",_mga_priv.orig_wid #if 0 // create a simple window without anything. Just make overlay clickable. :) if (!_window.clasped_window) { + Atom prop; + MWMHints mwmhints; + _window.clasped_window = XCreateSimpleWindow(_mga_priv.lDisplay, RootWindow(_mga_priv.lDisplay, _display.default_screen), 0, 0, _mga_priv.dest_width, _mga_priv.dest_height, 0, 0, 0); // gVideoWin = _window.clasped_window; @@ -484,14 +484,14 @@ static void mga_update_frame_format (vo_driver_t *this_gen, vo_frame_t *frame_ge exit (1); } - frame->vo_frame.base[0] = (char *) shmat(frame->id, 0, 0); + frame->vo_frame.base[0] = shmat(frame->id, 0, 0); if (frame->vo_frame.base[0] == NULL) { fprintf(stderr, "syncfb: shared memory error (address error NULL)\n"); exit (1); } - if (frame->vo_frame.base[0] == ((char *) -1)) { + if (frame->vo_frame.base[0] == (void *) -1) { fprintf(stderr, "syncfb: shared memory error (address error)\n"); exit (1); } @@ -547,7 +547,7 @@ static void mga_display_frame(vo_driver_t *this, vo_frame_t *frame_gen) { ioctl(_mga_priv.fd,SYNCFB_COMMIT_BUFFER,&_mga_priv.bufinfo); } /* Image is copied so release buffer */ - frame->vo_frame.displayed (frame); + frame->vo_frame.displayed (&frame->vo_frame); } #if 0 diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index 8dea4b5a5..b4f9d5e65 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.12 2001/06/25 09:51:47 guenter Exp $ + * $Id: video_out_xshm.c,v 1.13 2001/07/04 14:01:50 uid56437 Exp $ * * video_out_xshm.c, X11 shared memory extension interface for xine * @@ -69,7 +69,6 @@ typedef struct xshm_frame_s { XImage *image; uint8_t *rgb_dst; - int rgb_row; int stripe_inc; XShmSegmentInfo shminfo; @@ -312,6 +311,24 @@ static void dispose_ximage (xshm_driver_t *this, } } +#ifdef ARCH_X86 +#undef DETAILED_TIMING /* define as 1 to get cpu cycle timing for */ + /* the yuv2rgb conversion below */ + +#define CPU_MHZ 908 /* your cpu's frequency, in Mhz */ + /* My A7V board operates the 900Mhz T'bird */ + /* at 908Mhz? */ +#endif + +#ifdef DETAILED_TIMING +static inline uint64_t rdtsc() +{ + uint64_t tsc; + __asm__ __volatile__("rdtsc" : "=A"(tsc)); + return tsc; +} +#endif + /* * and now, the driver functions */ @@ -324,25 +341,20 @@ 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; - } +#ifdef DETAILED_TIMING + uint64_t tsc = rdtsc(); + uint32_t cycles; #endif this->yuv2rgb->yuv2rgb_fun (this->yuv2rgb, frame->rgb_dst, src[0], src[1], src[2]); + +#ifdef DETAILED_TIMING + cycles = rdtsc() - tsc; + printf("yuv2rgb: %u cycles, %d µsec\n", cycles, cycles/CPU_MHZ); +#endif 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) { @@ -402,6 +414,22 @@ static void xshm_calc_output_size (xshm_driver_t *this) { if (this->delivered_width == 0 && this->delivered_height == 0) return; /* ConfigureNotify/VisibilityNotify, no decoder output size known */ + +#if 0 + /* + * quick hack to allow testing of unscaled yuv2rgb conversion routines + */ + if (getenv("VIDEO_OUT_NOSCALE")) { + this->output_width = this->delivered_width; + this->output_height = this->delivered_height; + this->output_xoffset = 0; + this->output_yoffset = 0; + this->ratio_factor = 1.0; + return; + } +#endif + + image_ratio = (double) this->delivered_width / (double) this->delivered_height; @@ -563,7 +591,6 @@ 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; } } diff --git a/src/video_out/yuv2rgb.c b/src/video_out/yuv2rgb.c index 7abfdac0e..ce88f95c5 100644 --- a/src/video_out/yuv2rgb.c +++ b/src/video_out/yuv2rgb.c @@ -23,6 +23,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <inttypes.h> #include "yuv2rgb.h" @@ -95,13 +96,17 @@ int yuv2rgb_setup (yuv2rgb_t *this, this->step_dx = source_width * 32768 / dest_width; this->step_dy = source_height * 32768 / dest_height; - this->y_buffer = my_malloc_aligned (16, dest_width, &this->y_chunk); + /* + * space for two y-lines (for yuv2rgb_mlib) + * u,v subsampled 2:1 + */ + this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk); if (!this->y_buffer) return 0; - this->u_buffer = my_malloc_aligned (16, dest_width, &this->u_chunk); + this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk); if (!this->u_buffer) return 0; - this->v_buffer = my_malloc_aligned (16, dest_width, &this->v_chunk); + this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk); if (!this->v_buffer) return 0; } @@ -121,7 +126,7 @@ static void scale_line (uint8_t *source, uint8_t *dest, while (width) { - *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; + *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; dx += step; while (dx > 32768) { @@ -231,7 +236,7 @@ static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, dy += this->step_dy; _dst += this->rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); @@ -357,7 +362,7 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, dy += this->step_dy; _dst += this->rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); @@ -483,7 +488,7 @@ static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, dy += this->step_dy; _dst += this->rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); @@ -609,7 +614,7 @@ static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, dy += this->step_dy; _dst += this->rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); @@ -832,6 +837,13 @@ yuv2rgb_t *yuv2rgb_init (int mode) { printf ("yuv2rgb: using MMX for colorspace transform\n"); } #endif +#if HAVE_MLIB + if (this->yuv2rgb_fun == NULL) { + yuv2rgb_init_mlib (this, mode); + if (this->yuv2rgb_fun != NULL) + printf ("yuv2rgb: using medialib for colorspace transform\n"); + } +#endif if (this->yuv2rgb_fun == NULL) { printf ("yuv2rgb: no accelerated colorspace conversion found\n"); yuv2rgb_c_init (this, mode); diff --git a/src/video_out/yuv2rgb_mlib.c b/src/video_out/yuv2rgb_mlib.c new file mode 100644 index 000000000..7d0b56fa7 --- /dev/null +++ b/src/video_out/yuv2rgb_mlib.c @@ -0,0 +1,288 @@ +/* + * yuv2rgb_mlib.c + * Copyright (C) 2000-2001 Silicon Integrated System Corp. + * All Rights Reserved. + * + * Author: Juergen Keil <jk@tools.de> + * + * This file is part of xine, a free unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#if HAVE_MLIB + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <inttypes.h> +#include <mlib_video.h> + +#include "attributes.h" +#include "yuv2rgb.h" + + +static void scale_line (uint8_t *source, uint8_t *dest, + int width, int step) { + + unsigned p1; + unsigned p2; + int dx; + + p1 = *source++; + p2 = *source++; + dx = 0; + + while (width) { + + /* + printf ("scale_line, width = %d\n", width); + printf ("scale_line, dx = %d, p1 = %d, p2 = %d\n", dx, p1, p2); + */ + + *dest = (p1 * (32768 - dx) + p2 * dx) / 32768; + + dx += step; + while (dx > 32768) { + dx -= 32768; + p1 = p2; + p2 = *source++; + } + + dest ++; + width --; + } +} + + + +static void mlib_yuv420_rgb24 (yuv2rgb_t *this, + uint8_t * image, uint8_t * py, + uint8_t * pu, uint8_t * pv) +{ + int height; + int dy; + mlib_status mlib_stat; + + if (this->do_scale) { + dy = 0; + height = this->source_height >> 1; + + while (--height >= 0) { + scale_line (pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + pu += this->uv_stride; + + scale_line (pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + pv += this->uv_stride; + + scale_line (py, this->y_buffer, + this->dest_width, this->step_dx); + py += this->y_stride; + scale_line (py, this->y_buffer + this->dest_width, + this->dest_width, this->step_dx); + py += this->y_stride; + + mlib_stat = mlib_VideoColorYUV2RGB420(image, + this->y_buffer, + this->u_buffer, + this->v_buffer, + this->dest_width & ~1, 2, + this->rgb_stride, + this->dest_width, + this->dest_width >> 1); + dy += this->step_dy; + image += this->rgb_stride; + + while (dy < 32768) { + memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*6); + dy += this->step_dy; + image += this->rgb_stride; + } + dy -= 32768; + + dy += this->step_dy; + image += this->rgb_stride; + + while (dy < 32768) { + memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*3); + dy += this->step_dy; + image += this->rgb_stride; + } + dy -= 32768; + } + } else { + mlib_stat = mlib_VideoColorYUV2RGB420(image, py, pu, pv, + this->source_width, + this->source_height, + this->rgb_stride, + this->y_stride, + this->uv_stride); + } +} + +static void mlib_yuv420_argb32 (yuv2rgb_t *this, + uint8_t * image, uint8_t * py, + uint8_t * pu, uint8_t * pv) +{ + int height; + int dy; + mlib_status mlib_stat; + + if (this->do_scale) { + dy = 0; + height = this->source_height >> 1; + + while (--height >= 0) { + scale_line (pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + pu += this->uv_stride; + + scale_line (pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + pv += this->uv_stride; + + scale_line (py, this->y_buffer, + this->dest_width, this->step_dx); + py += this->y_stride; + scale_line (py, this->y_buffer + this->dest_width, + this->dest_width, this->step_dx); + py += this->y_stride; + + mlib_stat = mlib_VideoColorYUV2ARGB420(image, + this->y_buffer, + this->u_buffer, + this->v_buffer, + this->dest_width & ~1, 2, + this->rgb_stride, + this->dest_width, + this->dest_width >> 1); + dy += this->step_dy; + image += this->rgb_stride; + + while (dy < 32768) { + memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8); + dy += this->step_dy; + image += this->rgb_stride; + } + dy -= 32768; + + dy += this->step_dy; + image += this->rgb_stride; + + while (dy < 32768) { + memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4); + dy += this->step_dy; + image += this->rgb_stride; + } + dy -= 32768; + } + } else { + mlib_stat = mlib_VideoColorYUV2ARGB420(image, py, pu, pv, + this->source_width, + this->source_height, + this->rgb_stride, + this->y_stride, + this->uv_stride); + } +} + +static void mlib_yuv420_abgr32 (yuv2rgb_t *this, + uint8_t * image, uint8_t * py, + uint8_t * pu, uint8_t * pv) +{ + int height; + int dy; + mlib_status mlib_stat; + + if (this->do_scale) { + dy = 0; + height = this->source_height >> 1; + + while (--height >= 0) { + scale_line (pu, this->u_buffer, + this->dest_width >> 1, this->step_dx); + pu += this->uv_stride; + + scale_line (pv, this->v_buffer, + this->dest_width >> 1, this->step_dx); + pv += this->uv_stride; + + scale_line (py, this->y_buffer, + this->dest_width, this->step_dx); + py += this->y_stride; + scale_line (py, this->y_buffer + this->dest_width, + this->dest_width, this->step_dx); + py += this->y_stride; + + mlib_stat = mlib_VideoColorYUV2ABGR420(image, + this->y_buffer, + this->u_buffer, + this->v_buffer, + this->dest_width & ~1, 2, + this->rgb_stride, + this->dest_width, + this->dest_width >> 1); + dy += this->step_dy; + image += this->rgb_stride; + + while (dy < 32768) { + memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*8); + dy += this->step_dy; + image += this->rgb_stride; + } + dy -= 32768; + + dy += this->step_dy; + image += this->rgb_stride; + + while (dy < 32768) { + memcpy (image, (uint8_t*)image-this->rgb_stride, this->dest_width*4); + dy += this->step_dy; + image += this->rgb_stride; + } + dy -= 32768; + } + } else { + mlib_stat = mlib_VideoColorYUV2ABGR420(image, py, pu, pv, + this->source_width, + this->source_height, + this->rgb_stride, + this->y_stride, + this->uv_stride); + } +} + + +void yuv2rgb_init_mlib (yuv2rgb_t *this, int mode) +{ + switch (mode) { + case MODE_24_RGB: + this->yuv2rgb_fun = mlib_yuv420_rgb24; + break; + case MODE_32_RGB: + this->yuv2rgb_fun = mlib_yuv420_argb32; + break; + case MODE_32_BGR: + this->yuv2rgb_fun = mlib_yuv420_abgr32; + break; + } +} + + +#endif /* HAVE_MLIB */ diff --git a/src/video_out/yuv2rgb_mmx.c b/src/video_out/yuv2rgb_mmx.c index 7cbebf8c1..0a21f874f 100644 --- a/src/video_out/yuv2rgb_mmx.c +++ b/src/video_out/yuv2rgb_mmx.c @@ -425,7 +425,7 @@ static inline void yuv420_rgb16 (yuv2rgb_t *this, dy += this->step_dy; image += rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (image, image-rgb_stride, this->dest_width*2); @@ -531,7 +531,7 @@ static inline void yuv420_rgb15 (yuv2rgb_t *this, dy += this->step_dy; image += rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (image, image-rgb_stride, this->dest_width*2); @@ -635,7 +635,7 @@ static inline void yuv420_rgb24 (yuv2rgb_t *this, dy += this->step_dy; image += rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (image, image-rgb_stride, this->dest_width*3); @@ -740,7 +740,7 @@ static inline void yuv420_argb32 (yuv2rgb_t *this, dy += this->step_dy; image += rgb_stride; - while (dy <= 32768) { + while (dy < 32768) { memcpy (image, image-rgb_stride, this->dest_width*4); |