From 32013b621c3e2eaa7071024905e6c7bb756b32c4 Mon Sep 17 00:00:00 2001 From: ramiro Date: Thu, 16 Sep 2010 23:25:04 +0000 Subject: vo_mga: use libswscale interface for g200 (untested) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32280 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/mga_template.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/libvo/mga_template.c b/libvo/mga_template.c index 82dd54eed1..cf000551a4 100644 --- a/libvo/mga_template.c +++ b/libvo/mga_template.c @@ -19,6 +19,7 @@ #include "fastmemcpy.h" #include "cpudetect.h" #include "libswscale/swscale.h" +#include "libavcore/imgutils.h" #include "libmpcodecs/vf_scale.h" #include "mp_msg.h" #include "old_vo_wrapper.h" @@ -41,6 +42,8 @@ static uint32_t drwBorderWidth,drwDepth; #endif static uint32_t drwcX,drwcY,dwidth,dheight; +static struct SwsContext *sws_ctx; + static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31; x0+=mga_vid_config.src_width*(vo_panscan_x>>1)/(vo_dwidth+vo_panscan_x); @@ -66,25 +69,18 @@ static void draw_osd(void) } -#if 0 // Should use libswscale's interface to NV12 static void draw_slice_g200(uint8_t *image[], int stride[], int width,int height,int x,int y) { - uint8_t *dest; uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31; + int dst_stride[4] = { bespitch, bespitch }; + uint8_t *dst[4]; - dest = vid_data + bespitch*y + x; - mem2agpcpy_pic(dest, image[0], width, height, bespitch, stride[0]); - - width/=2;height/=2;x/=2;y/=2; - - dest = vid_data + bespitch*mga_vid_config.src_height + bespitch*y + 2*x; + av_image_fill_pointers(dst, PIX_FMT_NV12, mga_vid_config.src_height, + vid_data, dst_stride); - interleaveBytes(image[1],image[2],dest, - width, height, - stride[1], stride[2], bespitch); + sws_scale(sws_ctx, image, stride, y, height, dst, dst_stride); } -#endif static void draw_slice_g400(uint8_t *image[], int stride[], int w,int h,int x,int y) @@ -127,11 +123,9 @@ draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) w,h,x,y); #endif -#if 0 if (mga_vid_config.card_type == MGA_G200) draw_slice_g200(src,stride,w,h,x,y); else -#endif draw_slice_g400(src,stride,w,h,x,y); return 0; } @@ -423,8 +417,16 @@ static int mga_init(int width,int height,unsigned int format){ } } if (mga_vid_config.card_type == MGA_G200) { - mp_msg(MSGT_VO, MSGL_FATAL, "G200 cards support is currently broken. patches welcome.\n"); - return -1; + sws_ctx = sws_getContext(width, height, PIX_FMT_YUV420P, + width, height, PIX_FMT_NV12, + SWS_BILINEAR, NULL, NULL, NULL); + if (!sws_ctx) { + mp_msg(MSGT_VO, MSGL_FATAL, + "Could not get swscale context to scale for G200.\n"); + return -1; + } + mp_msg(MSGT_VO, MSGL_WARN, "G200 cards support is untested. " + "Please report whether it works.\n"); } mp_msg(MSGT_VO,MSGL_V,"[MGA] Using %d buffers.\n",mga_vid_config.num_frames); @@ -453,6 +455,9 @@ static int mga_uninit(void){ close(f); f = -1; } + if (sws_ctx) { + sws_freeContext(sws_ctx); + } return 0; } -- cgit v1.2.3