changeset 1422:d02e0dcaf077

libvo2 support
author arpi
date Mon, 30 Jul 2001 02:00:54 +0000
parents ea0a0b9e6fbc
children 3a347b949c5d
files cfg-mplayer.h configure dec_video.c find_sub.c mplayer.c
diffstat 5 files changed, 108 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Sun Jul 29 21:07:34 2001 +0000
+++ b/cfg-mplayer.h	Mon Jul 30 02:00:54 2001 +0000
@@ -27,11 +27,19 @@
 extern char *lirc_configfile;
 #endif
 
+#ifndef USE_LIBVO2
 extern int vo_doublebuffering;
 extern int vo_fsmode;
 extern int vo_dbpp;
+#endif
+
+#ifdef USE_SUB
+extern int sub_unicode;
+#endif
+
+#ifdef USE_OSD
 extern int osd_level;
-extern int sub_unicode;
+#endif
 
 extern char *ao_outputfilename;
 extern int ao_pcm_waveheader;
@@ -77,14 +85,18 @@
 	{"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 @@
         {"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
--- a/configure	Sun Jul 29 21:07:34 2001 +0000
+++ b/configure	Mon Jul 30 02:00:54 2001 +0000
@@ -1795,6 +1795,9 @@
 
 /* -------- Generated by ./configure ----------- */
 
+#define USE_OSD
+#define USE_SUB
+
 /* Common data directory (for fonts, etc) */
 #define DATADIR "$_datadir"
 
--- a/dec_video.c	Sun Jul 29 21:07:34 2001 +0000
+++ b/dec_video.c	Mon Jul 30 02:00:54 2001 +0000
@@ -28,7 +28,11 @@
 //#include <inttypes.h>
 //#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 @@
   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 @@
       } 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;
--- a/find_sub.c	Sun Jul 29 21:07:34 2001 +0000
+++ b/find_sub.c	Mon Jul 30 02:00:54 2001 +0000
@@ -2,6 +2,10 @@
 //             .SUB 
 //**************************************************************************//
 
+#include "config.h"
+
+#ifdef USE_OSD
+
 #include <stdio.h>
 
 #include "libvo/video_out.h"
@@ -104,3 +108,4 @@
     vo_sub=NULL; // no sub here
 }
 
+#endif
--- a/mplayer.c	Sun Jul 29 21:07:34 2001 +0000
+++ b/mplayer.c	Mon Jul 30 02:00:54 2001 +0000
@@ -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 @@
 
 #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 @@
 
 //**************************************************************************//
 
+#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 @@
    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 @@
 
 // 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 @@
  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 @@
       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 @@
       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 @@
   }
 }
 
+#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 @@
       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 @@
 }
 
 // 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(!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 ( subtitles == NULL ) subtitles=sub_read_file(get_path("default.sub")); // try default:
   }
-
+#endif
 
 if(vcd_track){
 //============ Open VideoCD track ==============
@@ -812,7 +846,11 @@
     int ret;
     out_fmt=sh_video->codec->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 @@
      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 @@
     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 @@
      }
    #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 @@
      GUI_MSG( mplCantInitVideoDriver )
      exit(1);
    }
+#endif
    if(verbose) printf("INFO: Video OUT driver init OK!\n");
 
    fflush(stdout);
@@ -1292,7 +1342,11 @@
       }
 
         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 @@
   }
 #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 @@
              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 @@
         }
         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 @@
         current_module=NULL;
       }
 
+#ifdef USE_OSD
         // Set OSD:
       if(osd_level){
         int len=((demuxer->movi_end-demuxer->movi_start)>>8);
@@ -1535,6 +1596,7 @@
           vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len;
         }
       }
+#endif
       
       c_total=0;
       max_pts_correction=0.1;
@@ -1545,6 +1607,7 @@
   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 @@
   }
 //  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 @@
       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;