From 57207b1f8b29772195c05dd838bd8f5005711445 Mon Sep 17 00:00:00 2001 From: arpi Date: Mon, 30 Jul 2001 02:00:54 +0000 Subject: [PATCH] libvo2 support git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1423 b3059339-0415-0410-9bf9-f77b7e298cf2 --- cfg-mplayer.h | 17 +++++++++++- configure | 3 +++ dec_video.c | 15 +++++++++++ find_sub.c | 5 ++++ mplayer.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 108 insertions(+), 4 deletions(-) diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 6b26ecaebc..645f072a6f 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -27,11 +27,19 @@ extern int fakemono; // defined in dec_audio.c extern char *lirc_configfile; #endif +#ifndef USE_LIBVO2 extern int vo_doublebuffering; extern int vo_fsmode; extern int vo_dbpp; -extern int osd_level; +#endif + +#ifdef USE_SUB extern int sub_unicode; +#endif + +#ifdef USE_OSD +extern int osd_level; +#endif extern char *ao_outputfilename; extern int ao_pcm_waveheader; @@ -77,14 +85,18 @@ struct config conf[]={ {"monitor_dotclock", &monitor_dotclock_str, CONF_TYPE_STRING, 0, 0, 0}, #endif {"encode", &encode_name, CONF_TYPE_STRING, 0, 0, 0}, +#ifdef USE_SUB {"sub", &sub_name, CONF_TYPE_STRING, 0, 0, 0}, {"subdelay", &sub_delay, CONF_TYPE_FLOAT, 0, 0.0, 10.0}, {"subfps", &sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0}, {"noautosub", &sub_auto, CONF_TYPE_FLAG, 0, 1, 0}, {"unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1}, {"nounicode", &sub_unicode, CONF_TYPE_FLAG, 0, 1, 0}, +#endif +#ifdef USE_OSD {"font", &font_name, CONF_TYPE_STRING, 0, 0, 0}, {"ffactor", &font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0}, +#endif {"bg", &play_in_bg, CONF_TYPE_FLAG, 0, 0, 1}, {"nobg", &play_in_bg, CONF_TYPE_FLAG, 0, 1, 0}, {"sb", &seek_to_byte, CONF_TYPE_INT, CONF_MIN, 0, 0}, @@ -168,10 +180,13 @@ struct config conf[]={ {"flip", &flip, CONF_TYPE_FLAG, 0, -1, 1}, {"noflip", &flip, CONF_TYPE_FLAG, 0, -1, 0}, +#ifndef USE_LIBVO2 {"bpp", &vo_dbpp, CONF_TYPE_INT, CONF_RANGE, 0, 32}, {"fsmode", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 15}, {"double", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1}, {"nodouble", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 1, 0}, +#endif + #ifdef HAVE_LIRC {"lircconf", &lirc_configfile, CONF_TYPE_STRING, 0, 0, 0}, #endif diff --git a/configure b/configure index be226b61dd..d61ee4a772 100755 --- a/configure +++ b/configure @@ -1795,6 +1795,9 @@ cat > $CCONF << EOF /* -------- Generated by ./configure ----------- */ +#define USE_OSD +#define USE_SUB + /* Common data directory (for fonts, etc) */ #define DATADIR "$_datadir" diff --git a/dec_video.c b/dec_video.c index 5008152ac9..8724c1a0aa 100644 --- a/dec_video.c +++ b/dec_video.c @@ -28,7 +28,11 @@ extern int frameratecode2framerate[16]; //#include //#include "libvo/img_format.h" +#ifdef USE_LIBVO2 +#include "libvo2/libvo2.h" +#else #include "libvo/video_out.h" +#endif #include "libmpeg2/mpeg2.h" #include "libmpeg2/mpeg2_internal.h" @@ -260,7 +264,11 @@ switch(sh_video->codec->driver){ return 1; } +#ifdef USE_LIBVO2 +int decode_video(vo2_handle_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ +#else int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ +#endif unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; int planar=(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420); int blit_frame=0; @@ -416,10 +424,17 @@ case 3: } else planes[0]=sh_video->our_out_buffer; case 2: +#ifdef USE_LIBVO2 + if(planar) + vo2_draw_slice(video_out,planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); + else + vo2_draw_frame(video_out,planes[0],sh_video->disp_w,sh_video->disp_w,sh_video->disp_h); +#else if(planar) video_out->draw_slice(planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); else video_out->draw_frame(planes); +#endif t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; blit_frame=1; break; diff --git a/find_sub.c b/find_sub.c index 573146486f..e40d2f328e 100644 --- a/find_sub.c +++ b/find_sub.c @@ -2,6 +2,10 @@ // .SUB //**************************************************************************// +#include "config.h" + +#ifdef USE_OSD + #include #include "libvo/video_out.h" @@ -104,3 +108,4 @@ void find_sub(subtitle* subtitles,int key){ vo_sub=NULL; // no sub here } +#endif diff --git a/mplayer.c b/mplayer.c index 00c1818e52..094dd36e4b 100644 --- a/mplayer.c +++ b/mplayer.c @@ -33,10 +33,19 @@ #include "cfgparser.h" #include "cfg-mplayer-def.h" +#ifdef USE_SUB #include "subreader.h" +#endif +#ifdef USE_LIBVO2 +#include "libvo2/libvo2.h" +#else #include "libvo/video_out.h" +#endif + +//#ifdef USE_OSD #include "libvo/sub.h" +//#endif #include "libao2/audio_out.h" @@ -79,7 +88,9 @@ int verbose=0; #define ABS(x) (((x)>=0)?(x):(-(x))) +#ifdef USE_SUB void find_sub(subtitle* subtitles,int key); +#endif static int usec_sleep(int usec_delay) @@ -186,7 +197,11 @@ int frameratecode2framerate[16] = { //**************************************************************************// +#ifdef USE_LIBVO2 +static vo2_handle_t *video_out=NULL; +#else static vo_functions_t *video_out=NULL; +#endif static ao_functions_t *audio_out=NULL; float c_total=0; @@ -321,7 +336,11 @@ void exit_player(char* how){ if ( nogui ) #endif getch2_disable(); +#ifdef USE_LIBVO2 + if(video_out) vo2_close(video_out); +#else if(video_out) video_out->uninit(); +#endif if(audio_out) audio_out->uninit(); if(encode_name) avi_fixate(); #ifdef HAVE_LIRC @@ -367,7 +386,11 @@ extern void skip_audio_frame(sh_audio_t *sh_audio); // dec_video.c: extern int init_video(sh_video_t *sh_video); +#ifdef USE_LIBVO2 +extern int decode_video(vo2_handle_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame); +#else extern int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame); +#endif #include "mixer.h" #include "cfg-mplayer.h" @@ -404,7 +427,9 @@ if ((conffile = get_path("")) == NULL) { int mplayer(int argc,char* argv[], char *envp[]){ #endif +#ifdef USE_SUB static subtitle* subtitles=NULL; +#endif static demuxer_t *demuxer=NULL; @@ -458,6 +483,7 @@ int f; // filedes printf("\n"); } +#ifndef USE_LIBVO2 if(video_driver && strcmp(video_driver,"help")==0){ printf("Available video output drivers:\n"); i=0; @@ -468,6 +494,7 @@ int f; // filedes printf("\n"); exit(0); } +#endif if(audio_driver && strcmp(audio_driver,"help")==0){ printf("Available audio output drivers:\n"); i=0; @@ -489,6 +516,9 @@ if(!filename){ } } +#ifdef USE_LIBVO2 + video_out=vo2_new(video_driver); +#else // check video_out driver name: if (video_driver) if ((i = strcspn(video_driver, ":")) > 0) @@ -513,11 +543,12 @@ if(!filename){ video_out = video_out_drivers[i];break; } } +#endif if(!video_out){ - fprintf(stderr,"Invalid video output driver name: %s\nUse '-vo help' to get a list of available video drivers.\n",video_driver); + fprintf(stderr,"Invalid video output driver name: %s\nUse '-vo help' to get a list of available video drivers.\n",video_driver?video_driver:"?"); return 0; } - + // check audio_out driver name: if (audio_driver) if ((i = strcspn(audio_driver, ":")) > 0) @@ -558,6 +589,7 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){ } // check font +#ifdef USE_OSD if(font_name){ vo_font=read_font_desc(font_name,font_factor,verbose>1); if(!vo_font) fprintf(stderr,"Can't load font: %s\n",font_name); @@ -567,7 +599,9 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){ if(!vo_font) vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1); } +#endif +#ifdef USE_SUB // check .sub if(sub_name){ subtitles=sub_read_file(sub_name); @@ -580,7 +614,7 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){ } if ( subtitles == NULL ) subtitles=sub_read_file(get_path("default.sub")); // try default: } - +#endif if(vcd_track){ //============ Open VideoCD track ============== @@ -812,7 +846,11 @@ for(i=0;icodec->outfmt[i]; if(out_fmt==0xFFFFFFFF) continue; +#ifdef USE_LIBVO2 + ret=vo2_query_format(video_out); +#else ret=video_out->query_format(out_fmt); +#endif if(verbose) printf("vo_debug: query(%s) returned 0x%X\n",vo_format_name(out_fmt),ret); if(ret) break; } @@ -894,6 +932,7 @@ make_pipe(&keyb_fifo_get,&keyb_fifo_put); if(screen_size_y<=8) screen_size_y*=sh_video->disp_h; } +#ifndef USE_LIBVO2 { const vo_info_t *info = video_out->get_info(); printf("VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, sh_video->disp_w,sh_video->disp_h, @@ -913,6 +952,7 @@ make_pipe(&keyb_fifo_get,&keyb_fifo_put); if(strlen(info->comment) > 0) printf("VO: Comment: %s\n", info->comment); } +#endif if(verbose) printf("video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", sh_video->disp_w,sh_video->disp_h, @@ -929,6 +969,15 @@ make_pipe(&keyb_fifo_get,&keyb_fifo_put); } #endif +#ifdef USE_LIBVO2 + if(!vo2_start(video_out, + sh_video->disp_w,sh_video->disp_h,out_fmt,0, + fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3) )){ + fprintf(stderr,"FATAL: Cannot initialize video driver!\n"); + GUI_MSG( mplCantInitVideoDriver ) + exit(1); + } +#else if(video_out->init(sh_video->disp_w,sh_video->disp_h, screen_size_x,screen_size_y, fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), @@ -937,6 +986,7 @@ make_pipe(&keyb_fifo_get,&keyb_fifo_put); GUI_MSG( mplCantInitVideoDriver ) exit(1); } +#endif if(verbose) printf("INFO: Video OUT driver init OK!\n"); fflush(stdout); @@ -1292,7 +1342,11 @@ if(1) } current_module="flip_page"; +#ifdef USE_LIBVO2 + if(blit_frame) vo2_flip(video_out,0); +#else if(blit_frame) video_out->flip_page(); +#endif // usec_sleep(50000); // test only! } @@ -1383,10 +1437,12 @@ if(1) } #endif +#ifdef USE_OSD if(osd_visible){ --osd_visible; if(!osd_visible) vo_osd_progbar_type=-1; // disable } +#endif if(osd_function==OSD_PAUSE){ printf("\n------ PAUSED -------\r");fflush(stdout); @@ -1401,7 +1457,9 @@ if(1) lirc_mp_getinput()<=0 && #endif (!f || getch2(20)<=0) && mplayer_get_key()<=0){ +#ifndef USE_LIBVO2 video_out->check_events(); +#endif if(!f) usec_sleep(1000); // do not eat the CPU } osd_function=OSD_PLAY; @@ -1485,12 +1543,14 @@ if(1) } mixer_setvolume( mixer_l,mixer_r ); +#ifdef USE_OSD if(osd_level){ osd_visible=sh_video->fps; // 1 sec vo_osd_progbar_type=OSD_VOLUME; vo_osd_progbar_value=(mixer_l+mixer_r)*5/4; //printf("volume: %d\n",vo_osd_progbar_value); } +#endif } break; case 'm': @@ -1526,6 +1586,7 @@ if(1) current_module=NULL; } +#ifdef USE_OSD // Set OSD: if(osd_level){ int len=((demuxer->movi_end-demuxer->movi_start)>>8); @@ -1535,6 +1596,7 @@ if(1) vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; } } +#endif c_total=0; max_pts_correction=0.1; @@ -1545,6 +1607,7 @@ if(1) rel_seek_secs=0; //================= Update OSD ==================== +#ifdef USE_OSD if(osd_level>=2){ int pts=d_video->pts; if(pts==osd_last_pts-1) ++pts; else osd_last_pts=pts; @@ -1555,7 +1618,9 @@ if(1) } // for(i=1;i<=11;i++) osd_text_buffer[10+i]=i;osd_text_buffer[10+i]=0; // vo_osd_text=osd_text_buffer; +#endif +#ifdef USE_SUB // find sub if(subtitles && d_video->pts>0){ int pts=d_video->pts; @@ -1564,6 +1629,7 @@ if(1) find_sub(subtitles,sub_uses_time?(100*(pts+sub_delay)):((pts+sub_delay)*sub_fps)); // FIXME! frame counter... current_module=NULL; } +#endif // DVD sub: { unsigned char* packet=NULL;