Update of /cvsroot/freevo/kaa/xine/src/drivers
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9193/src/drivers
Modified Files:
buffer.c
Log Message:
Lame optimization for yuy2 to rgb conversion.
Index: buffer.c
===================================================================
RCS file: /cvsroot/freevo/kaa/xine/src/drivers/buffer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** buffer.c 1 Aug 2005 04:07:12 -0000 1.4
--- buffer.c 1 Aug 2005 13:57:13 -0000 1.5
***************
*** 4,7 ****
--- 4,8 ----
#include "../vo_driver.h"
#include "yuv2rgb.h"
+ #include "../config.h"
//#define STOPWATCH
***************
*** 15,18 ****
--- 16,28 ----
+ #if defined(ARCH_X86) || defined(ARCH_X86_64)
+ #define YUY2_SIZE_THRESHOLD 400*280
+ #else
+ #define YUY2_SIZE_THRESHOLD 2000*2000
+ #endif
+
+
+
+
static void _overlay_blend(vo_driver_t *, vo_frame_t *, vo_overlay_t *);
***************
*** 23,28 ****
int flags;
! unsigned char *yv12_buffer, *yuy2_buffer;
! unsigned char *bgra_buffer;
pthread_mutex_t bgra_lock;
vo_frame_t *passthrough_frame;
--- 33,41 ----
int flags;
! unsigned char *yv12_buffer,
! *yv12_planes[3],
! *yuy2_buffer,
! *bgra_buffer;
! int yv12_strides[3];
pthread_mutex_t bgra_lock;
vo_frame_t *passthrough_frame;
***************
*** 193,196 ****
--- 206,234 ----
+ static void
+ _alloc_yv12(int width, int height, unsigned char **base,
+ unsigned char *planes[3], int strides[3])
+ {
+ int y_size, uv_size;
+
+ strides[0] = 8*((width + 7) / 8);
+ strides[1] = 8*((width + 15) / 16);
+ strides[2] = 8*((width + 15) / 16);
+
+ printf("IN ALLOC: %d %d %d\n", strides[0], strides[1], strides[2]);
+ y_size = strides[0] * height;
+ uv_size = strides[1] * ((height+1)/2);
+
+ if (*base)
+ free(*base);
+
+ *base = (unsigned char *)xine_xmalloc(y_size + 2*uv_size);
+
+ planes[0] = *base;
+ planes[1] = *base + y_size + uv_size;
+ planes[2] = *base + y_size;
+ }
+
+ ////////////
static uint32_t
***************
*** 378,387 ****
frame->yuv2rgb->dest_width != dst_width ||
frame->yuv2rgb->dest_height != dst_height) {
if (frame->bgra_buffer)
free(frame->bgra_buffer);
frame->bgra_buffer = malloc(frame->width*frame->height*4);
frame->yuv2rgb->configure(frame->yuv2rgb, frame->width,
frame->height,
! frame->vo_frame.pitches[0],
! frame->vo_frame.pitches[1],
dst_width, dst_height, 4*(dst_width));
}
--- 416,435 ----
frame->yuv2rgb->dest_width != dst_width ||
frame->yuv2rgb->dest_height != dst_height) {
+
+ int y_stride = frame->vo_frame.pitches[0],
+ uv_stride = frame->vo_frame.pitches[1];
if (frame->bgra_buffer)
free(frame->bgra_buffer);
frame->bgra_buffer = malloc(frame->width*frame->height*4);
+
+ if (frame->format == XINE_IMGFMT_YUY2 && dst_width*dst_height >
YUY2_SIZE_THRESHOLD) {
+ _alloc_yv12(frame->width, frame->height, &frame->yv12_buffer,
+ frame->yv12_planes, frame->yv12_strides);
+ y_stride = frame->yv12_strides[0];
+ uv_stride = frame->yv12_strides[1];
+ }
+
frame->yuv2rgb->configure(frame->yuv2rgb, frame->width,
frame->height,
! y_stride, uv_stride,
dst_width, dst_height, 4*(dst_width));
}
***************
*** 395,400 ****
} else {
stopwatch(0, "yuy2 to bgra32");
! frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->bgra_buffer,
! frame->vo_frame.base[0]);
stopwatch(0, NULL);
}
--- 443,465 ----
} else {
stopwatch(0, "yuy2 to bgra32");
! if (dst_width*dst_height > YUY2_SIZE_THRESHOLD) {
! // Naive optimization: yuv2rgb has an accelerated version
! // but yuy22rgb doesn't. So when the area of the image is
! // greater than the size threshold (determined empirically)
! // first convert the yuy2 image to yv12 and then convert
! // yv12 to rgb, both operations of which are accelerated.
! yuy2_to_yv12(frame->vo_frame.base[0],
frame->vo_frame.pitches[0],
! frame->yv12_planes[0], frame->yv12_strides[0],
! frame->yv12_planes[1], frame->yv12_strides[1],
! frame->yv12_planes[2], frame->yv12_strides[2],
! frame->width, frame->height);
! frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb,
frame->bgra_buffer,
! frame->yv12_planes[0],
! frame->yv12_planes[1],
! frame->yv12_planes[2]);
! } else {
! frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb,
frame->bgra_buffer,
! frame->vo_frame.base[0]);
! }
stopwatch(0, NULL);
}
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog