From 0cea267e341ad74998f31f77054756e2354541c3 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Wed, 13 Jun 2001 18:22:38 +0000 Subject: added support for YUY2 image format CVS patchset: 170 CVS date: 2001/06/13 18:22:38 --- src/video_out/video_out_aa.c | 60 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/video_out/video_out_aa.c b/src/video_out/video_out_aa.c index fbcd64e54..beae84a6e 100644 --- a/src/video_out/video_out_aa.c +++ b/src/video_out/video_out_aa.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_aa.c,v 1.4 2001/06/13 17:53:42 guenter Exp $ + * $Id: video_out_aa.c,v 1.5 2001/06/13 18:22:38 guenter Exp $ * * video_out_aa.c, ascii-art output plugin for xine * @@ -56,6 +56,8 @@ typedef struct aa_frame_s { int ratio_code; + int format; + } aa_frame_t; typedef struct { @@ -76,7 +78,7 @@ typedef struct { */ static uint32_t aa_get_capabilities (vo_driver_t *this) { - return VO_CAP_YV12; + return VO_CAP_YV12 | VO_CAP_YUY2; } static void *malloc_aligned (size_t alignment, size_t size, void **mem) { @@ -93,6 +95,17 @@ static void *malloc_aligned (size_t alignment, size_t size, void **mem) { static void aa_dispose_frame (vo_frame_t *vo_img) { /* fixme: implement */ + + aa_frame_t *frame = (aa_frame_t *)vo_img; + + if (frame->mem[0]) + free (frame->mem[0]); + if (frame->mem[1]) + free (frame->mem[1]); + if (frame->mem[2]) + free (frame->mem[2]); + + free (frame); } static vo_frame_t *aa_alloc_frame(vo_driver_t *this) { @@ -116,7 +129,8 @@ static void aa_update_frame_format (vo_driver_t *this, vo_frame_t *img, aa_frame_t *frame = (aa_frame_t *) img; - if ((frame->width != width) || (frame->height != height)) { + if ((frame->width != width) || (frame->height != height) + || (frame->format != format)) { if (frame->mem[0]) { free (frame->mem[0]); @@ -132,13 +146,23 @@ static void aa_update_frame_format (vo_driver_t *this, vo_frame_t *img, frame->mem[2] = NULL; } - image_size = width * height; frame->width = width; frame->height = height; - - frame->vo_frame.base[0] = malloc_aligned(16,image_size, (void**) &frame->mem[0]); - frame->vo_frame.base[1] = malloc_aligned(16,image_size/4, (void**) &frame->mem[1]); - frame->vo_frame.base[2] = malloc_aligned(16,image_size/4, (void**) &frame->mem[2]); + frame->format = format; + + + if (format == IMGFMT_YV12) { + image_size = width * height; + frame->vo_frame.base[0] = malloc_aligned(16,image_size, (void**) &frame->mem[0]); + frame->vo_frame.base[1] = malloc_aligned(16,image_size/4, (void**) &frame->mem[1]); + frame->vo_frame.base[2] = malloc_aligned(16,image_size/4, (void**) &frame->mem[2]); + } else if (format == IMGFMT_YUY2) { + image_size = width * 2 * height; + frame->vo_frame.base[0] = malloc_aligned(16,image_size, (void**) &frame->mem[0]); + } else { + printf ("alert! unsupported image format %04x\n", format); + exit (1); + } frame->ratio_code = ratio_code; @@ -167,12 +191,24 @@ static void aa_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { aa_imgwidth (this->context), aa_imgheight (this->context)); */ - for (y = 0; ycontext); y++) { - for (x = 0; xcontext); x++) { + + if (frame->format == IMGFMT_YV12) { + for (y = 0; ycontext); y++) { + for (x = 0; xcontext); x++) { + + *img++ = src_image[((int)((double) x * x_fact) + + frame->width * (int)((double) y * y_fact))]; + + } + } + } else { + for (y = 0; ycontext); y++) { + for (x = 0; xcontext); x++) { - *img++ = src_image[((int)((double) x * x_fact) + - frame->width * (int)((double) y * y_fact))]; + *img++ = src_image[((int)((double) x * x_fact) * 2 + + frame->width * 2 * (int)((double) y * y_fact))]; + } } } -- cgit v1.2.3