From 25486c1da7801b6dcf89058d5c1b9ff11054f66f Mon Sep 17 00:00:00 2001 From: atmos4 Date: Thu, 29 Nov 2001 19:18:48 +0000 Subject: [PATCH] Support for YV12 with DXR3, patch by D. Holm. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3209 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/DXR3 | 25 +++++++------- configure | 1 + libvo/vo_dxr3.c | 88 ++++++++++++++++++++++++------------------------- 3 files changed, 58 insertions(+), 56 deletions(-) diff --git a/DOCS/DXR3 b/DOCS/DXR3 index eda43cf0eb..12b6622045 100644 --- a/DOCS/DXR3 +++ b/DOCS/DXR3 @@ -1,6 +1,10 @@ DXR3/H+ video/audio output plugins manual by David Holm ======================================================= +2001-11-29: thanks to Felix Buenemann I managed to + optimize the odivx playback as well as add + support for the rest of the codecs! + 2001-11-28: ffmpeg replaced with mp1e, divx playback won't get much faster than this, huge thanks goes out to Ivan Kalvachev for helping me @@ -51,15 +55,17 @@ These days, you have two uses for this card: the CVS version since most of the time I use the latest features which are only available through cvs) - * Second, if you want DivX playback you need to download and install - RTE from zapping.sourceforge.net compile and install it BEFORE - running configure in the mplayer dir. + * Second, if you want to be able to play back anything other than + mpeg12 (vcd/dvd) through your dxr3 you need to install RTE from + zapping.sourceforge.net compile and install it BEFORE running + configure in the mplayer dir. With RTE you should be able to play + any movie supported by MPlayer. * Run /configure and make sure that DXR3/H+ support =yes and optionally that mp1e rte = yes, if it's = no, please mail me your configure.log and I'll fix it. - From here on compilation (of at least my code ;) should go without + From here on compilation (of at least my code ;) should go without any problems. @@ -82,17 +88,12 @@ section will have to specify "-vc mpeg12" if you want to playback any of these video types _without_ "-vo dxr3"! DIVX Notes -When playing divx's add "-vc odivx" +When playing divx's add "-vc odivx" for maximum performance. I've switched to mp1e from ffmpeg so it should be lightning fast now. Other codecs: -Currently they don't work. I'm working on implementing libvo2 which -will be a much more convenient and faster way of working with -vo<->codec interaction. If libvo2 takes longer to develop than I -have estimated perhaps I'll add more codec support to libvo. Otherwise -you'll just have to wait for libvo2. (there is an implementation -for other codecs, but I think it's pretty broken currently ;) - +No "-vc " switches should be required as mplayer will autodetect. +If you find an unsupported codec please contact me! 4. Contacting me diff --git a/configure b/configure index b76a0fd94b..3d15ee460e 100755 --- a/configure +++ b/configure @@ -1751,6 +1751,7 @@ if test "$_dxr3" = yes ; then _ld_dxr3='-ldxr3' _vosrc="$_vosrc vo_dxr3.c" _aosrc="$_aosrc ao_dxr3.c" + _vomodules="dxr3 $_vomodules" _aomodules="dxr3 $_aomodules" else _def_dxr3='#undef HAVE_DXR3' diff --git a/libvo/vo_dxr3.c b/libvo/vo_dxr3.c index 1036b4661d..a268c560b2 100644 --- a/libvo/vo_dxr3.c +++ b/libvo/vo_dxr3.c @@ -4,9 +4,6 @@ * * Copyright (C) 2001 David Holm * - * libav - MPEG-PS multiplexer, part of ffmpeg - * Copyright Gerard Lantau (see http://ffmpeg.sf.net) - * */ #include "fastmemcpy.h" @@ -124,7 +121,7 @@ init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, u s_height = scr_height; spubuf = malloc(53220); /* 53220 bytes is the standardized max size of a subpic */ - if( format == IMGFMT_YV12 ) + if( format == IMGFMT_YV12 || format == IMGFMT_YUY2 ) { #ifdef USE_MP1E int size; @@ -194,7 +191,7 @@ init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, u } rte_set_input( mp1e_context, RTE_VIDEO, RTE_PUSH, TRUE, NULL, NULL, NULL ); - rte_set_output( mp1e_context, write_dxr3, NULL, NULL ); + rte_set_output( mp1e_context, (void*)write_dxr3, NULL, NULL ); if( !rte_init_context( mp1e_context ) ) { @@ -205,16 +202,18 @@ init(uint32_t scr_width, uint32_t scr_height, uint32_t width, uint32_t height, u osd_w=scr_width; d_pos_x=(c_width-(int)scr_width)/2; - if(d_pos_x<0){ - s_pos_x=-d_pos_x;d_pos_x=0; - osd_w=c_width; + if(d_pos_x<0) + { + s_pos_x=-d_pos_x;d_pos_x=0; + osd_w=c_width; } else s_pos_x=0; osd_h=scr_height; d_pos_y=(c_height-(int)scr_height)/2; - if(d_pos_y<0){ - s_pos_y=-d_pos_y;d_pos_y=0; - osd_h=c_height; + if(d_pos_y<0) + { + s_pos_y=-d_pos_y;d_pos_y=0; + osd_h=c_height; } else s_pos_y=0; printf("VO: [dxr3] position mapping: %d;%d => %d;%d\n",s_pos_x,s_pos_y,d_pos_x,d_pos_y); @@ -279,6 +278,27 @@ static uint32_t draw_frame(uint8_t * src[]) return 0; } + else if( img_format == IMGFMT_YUY2 ) + { + int w=v_width,h=v_height; + unsigned char *s,*dY,*dU,*dV; + + if(d_pos_x+w>picture_linesize[0]) w=picture_linesize[0]-d_pos_x; + if(d_pos_y+h>c_height) h=c_height-d_pos_y; + + s = src[0]+s_pos_x+s_pos_y*(w*2); + dY = picture_data[0]+d_pos_x+d_pos_y*picture_linesize[0]; + dU = picture_data[1]+(d_pos_x/2)+(d_pos_y/2)*picture_linesize[1]; + dV = picture_data[2]+(d_pos_x/2)+(d_pos_y/2)*picture_linesize[2]; + + yuy2toyv12( s, dY, dU, dV, w, h, picture_linesize[0], picture_linesize[1], w*2 ); + + mp1e_buffer.data = picture_data[0]; + mp1e_buffer.time = vo_pts/90000.0; + mp1e_buffer.user_data = NULL; + rte_push_video_buffer( mp1e_context, &mp1e_buffer ); + return 0; + } printf( "VO: [dxr3] Error in draw_frame(...)\n" ); return -1; @@ -297,7 +317,6 @@ static void flip_page (void) static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0 ) { - int y; unsigned char* s; unsigned char* d; @@ -309,38 +328,18 @@ static uint32_t draw_slice( uint8_t *srcimg[], int stride[], int w, int h, int x if(x0+w>picture_linesize[0]) w=picture_linesize[0]-x0; if(y0+h>c_height) h=c_height-y0; - // Y s=srcimg[0]+s_pos_x+s_pos_y*stride[0]; d=picture_data[0]+x0+y0*picture_linesize[0]; - for( y = 0; y < h; y++) - { - memcpy(d,s,w); - s+=stride[0]; - d+=picture_linesize[0]; - } - - w/=2;h/=2;x0/=2;y0/=2; + memcpy(d,s,(w*h)); - // U - s=srcimg[1]+(s_pos_x/2)+(s_pos_y/2)*stride[1]; - d=picture_data[1]+x0+y0*picture_linesize[1]; - for( y = 0; y < h; y++) - { - memcpy(d,s,w); - s+=stride[1]; - d+=picture_linesize[1]; - } - - // V - s=srcimg[2]+(s_pos_x/2)+(s_pos_y/2)*stride[2]; - d=picture_data[2]+x0+y0*picture_linesize[2]; - for(y=0;y