changeset 5075:37e15b16e38d

libvo init moved to libmpcodecs
author arpi
date Thu, 14 Mar 2002 23:28:51 +0000
parents 1bf1dd918706
children 54d3d7a207b0
files libmpcodecs/vd.c mplayer.c
diffstat 2 files changed, 122 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd.c	Thu Mar 14 23:09:27 2002 +0000
+++ b/libmpcodecs/vd.c	Thu Mar 14 23:28:51 2002 +0000
@@ -4,6 +4,7 @@
 
 #include "config.h"
 #include "mp_msg.h"
+#include "help_mp.h"
 
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
@@ -89,9 +90,110 @@
 #include "libvo/video_out.h"
 extern int vaa_use_dr;
 
+// libvo opts:
+int fullscreen=0;
+int vidmode=0;
+int softzoom=0;
+int flip=-1;
+int opt_screen_size_x=0;
+int opt_screen_size_y=0;
+int screen_size_xy=0;
+float movie_aspect=-1.0;
+int vo_flags=0;
+
+static vo_tune_info_t vtune;
+
 int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){
+    int i;
+    unsigned int out_fmt=0;
+    int screen_size_x=0;//SCREEN_SIZE_X;
+    int screen_size_y=0;//SCREEN_SIZE_Y;
+    vo_functions_t* video_out=sh->video_out;
+
+    memset(&vtune,0,sizeof(vo_tune_info_t));
+
     mp_msg(MSGT_DECVIDEO,MSGL_INFO,"VDec: vo config request - %d x %d, %s  \n",
 	w,h,vo_format_name(preferred_outfmt));
+
+    // check if libvo and codec has common outfmt:
+    for(i=0;i<CODECS_MAX_OUTFMT;i++){
+	out_fmt=sh->codec->outfmt[i];
+	if(out_fmt==(signed int)0xFFFFFFFF) continue;
+	vo_flags=video_out->control(VOCTRL_QUERY_FORMAT, &out_fmt);
+	mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: query(%s) returned 0x%X\n",vo_format_name(out_fmt),vo_flags);
+	// TODO: check (query) if codec really support this outfmt...
+	if(vo_flags) break;
+    }
+    if(i>=CODECS_MAX_OUTFMT){
+	// TODO: no match - we should use conversion...
+	mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VOincompCodec);
+	return 0;	// failed
+    }
+    sh->outfmtidx=i;
+
+    // autodetect flipping
+    if(flip==-1){
+	flip=0;
+	if(sh->codec->outflags[i]&CODECS_FLAG_FLIP)
+	    if(!(sh->codec->outflags[i]&CODECS_FLAG_NOFLIP))
+		flip=1;
+    }
+
+    // time to do aspect ratio corrections...
+
+  if(movie_aspect>-1.0) sh->aspect = movie_aspect; // cmdline overrides autodetect
+//  if(!sh->aspect) sh->aspect=1.0;
+  screen_size_x = opt_screen_size_x;
+  screen_size_y = opt_screen_size_y;
+  if(screen_size_xy||screen_size_x||screen_size_y){
+   if(screen_size_xy>0){
+     if(screen_size_xy<=8){
+       screen_size_x=screen_size_xy*sh->disp_w;
+       screen_size_y=screen_size_xy*sh->disp_h;
+     } else {
+       screen_size_x=screen_size_xy;
+       screen_size_y=screen_size_xy*sh->disp_h/sh->disp_w;
+     }
+   } else if(!vidmode){
+     if(!screen_size_x) screen_size_x=SCREEN_SIZE_X;
+     if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y;
+     if(screen_size_x<=8) screen_size_x*=sh->disp_w;
+     if(screen_size_y<=8) screen_size_y*=sh->disp_h;
+   }
+  } else {
+    // check source format aspect, calculate prescale ::atmos
+    screen_size_x=sh->disp_w;
+    screen_size_y=sh->disp_h;
+    if(sh->aspect>0.01){
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n",
+             sh->aspect);
+      screen_size_x=(int)((float)sh->disp_h*sh->aspect);
+      screen_size_x+=screen_size_x%2; // round
+      if(screen_size_x<sh->disp_w){
+        screen_size_x=sh->disp_w;
+        screen_size_y=(int)((float)sh->disp_w*(1.0/sh->aspect));
+        screen_size_y+=screen_size_y%2; // round
+      }
+    } else {
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is undefined - no prescaling applied.\n");
+    }
+  }
+
+    // Time to config libvo!
+    mp_msg(MSGT_CPLAYER,MSGL_V,"video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n",
+                      sh->disp_w,sh->disp_h,
+                      screen_size_x,screen_size_y,
+                      fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
+                      "MPlayer",out_fmt);
+
+    if(video_out->config(sh->disp_w,sh->disp_h,
+                      screen_size_x,screen_size_y,
+                      fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
+                      "MPlayer",out_fmt,&vtune)){
+	mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CannotInitVO);
+	return 0; // exit_player(MSGTR_Exit_error);
+    }
+
     return 1;
 }
 
--- a/mplayer.c	Thu Mar 14 23:09:27 2002 +0000
+++ b/mplayer.c	Thu Mar 14 23:28:51 2002 +0000
@@ -249,18 +249,17 @@
 // screen info:
 char* video_driver=NULL; //"mga"; // default
 char* audio_driver=NULL;
-int fullscreen=0;
-static int vidmode=0;
-int softzoom=0;
-static int flip=-1;
-// We need this opt_* because the values are then calculated so the options use the opt_*
-// and before each file we reset the calculated value using this opt_* values
-static int opt_screen_size_x=0;//SCREEN_SIZE_X;
-static int opt_screen_size_y=0;//SCREEN_SIZE_Y;
-static int screen_size_x=0;//SCREEN_SIZE_X;
-static int screen_size_y=0;//SCREEN_SIZE_Y;
-static int screen_size_xy=0;
-static float movie_aspect=-1.0;
+
+// libvo opts: (defiend at libmpcodecs/vd.c)
+extern int opt_screen_size_x;
+extern int opt_screen_size_y;
+extern int screen_size_xy;
+extern float movie_aspect;
+extern int fullscreen;
+extern int vidmode;
+extern int softzoom;
+extern int flip;
+extern int vo_flags;
 
 // sub:
 char *font_name=NULL;
@@ -467,7 +466,7 @@
 int file_format=DEMUXER_TYPE_UNKNOWN;
 
 int delay_corrected=1;
-char* title="MPlayer";
+//char* title="MPlayer";
 
 // movie info:
 int out_fmt=0;
@@ -491,8 +490,6 @@
 int v_blue_intensity=0;
 */
 
-int vo_flags=0;
-
 int rtc_fd=-1;
 
 //float a_frame=0;    // Audio
@@ -501,12 +498,12 @@
 
 int gui_no_filename=0;
 
-vo_tune_info_t vtune;
+//vo_tune_info_t vtune;
 
   mp_msg_init(MSGL_STATUS);
 
   mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s",banner_text);
-  memset(&vtune,0,sizeof(vo_tune_info_t));
+//  memset(&vtune,0,sizeof(vo_tune_info_t));
   /* Test for cpu capabilities (and corresponding OS support) for optimizing */
 #ifdef ARCH_X86
   GetCpuCaps(&gCpuCaps);
@@ -1253,31 +1250,11 @@
 
 mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s video codec: [%s] drv:%d prio:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->priority!=-1?sh_video->codec->priority:0,sh_video->codec->info);
 
-for(i=0;i<CODECS_MAX_OUTFMT;i++){
-//    int ret;
-    out_fmt=sh_video->codec->outfmt[i];
-    if(out_fmt==(signed int)0xFFFFFFFF) continue;
-    vo_flags=video_out->control(VOCTRL_QUERY_FORMAT, &out_fmt);
-    mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug: query(%s) returned 0x%X\n",vo_format_name(out_fmt),vo_flags);
-    if(vo_flags) break;
-}
-if(i>=CODECS_MAX_OUTFMT){
-    mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VOincompCodec);
-    goto goto_next_file; // exit_player(MSGTR_Exit_error);
-}
-sh_video->outfmtidx=i;
+sh_video->video_out=video_out;
 
-if(flip==-1){
-    // autodetect flipping
-    flip=0;
-    if(sh_video->codec->outflags[i]&CODECS_FLAG_FLIP)
-      if(!(sh_video->codec->outflags[i]&CODECS_FLAG_NOFLIP))
-         flip=1;
-}
-
-mp_msg(MSGT_CPLAYER,MSGL_DBG2,"vo_debug1: out_fmt=%s\n",vo_format_name(out_fmt));
-
-if(!init_video(sh_video,&vtune.pitch[0])){
+// init codec:
+//if(!init_video(sh_video,&vtune.pitch[0])){
+if(!init_video(sh_video,NULL)){
      mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CouldntInitVideoCodec);
      goto goto_next_file; // exit_player(MSGTR_Exit_error);
 }
@@ -1295,53 +1272,7 @@
 
 current_module="init_libvo";
 
-#if 0 /* was X11_FULLSCREEN hack -> moved to libvo/vo_xv.c where it belongs ::atmos */
-   if(fullscreen){
-     if(vo_init()){
-       //if(verbose) printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
-     }
-     if(!screen_size_xy) screen_size_xy=vo_screenwidth; // scale with asp.ratio
-   }
-#endif
-   
-  // Set default VGA 1:1 aspect as fallback ::atmos
-  if(movie_aspect>-1.0) sh_video->aspect = movie_aspect; // cmdline overrides autodetect
-//  if(!sh_video->aspect) sh_video->aspect=1.0;
-  screen_size_x = opt_screen_size_x;
-  screen_size_y = opt_screen_size_y;
-  if(screen_size_xy||screen_size_x||screen_size_y){
-   if(screen_size_xy>0){
-     if(screen_size_xy<=8){
-       screen_size_x=screen_size_xy*sh_video->disp_w;
-       screen_size_y=screen_size_xy*sh_video->disp_h;
-     } else {
-       screen_size_x=screen_size_xy;
-       screen_size_y=screen_size_xy*sh_video->disp_h/sh_video->disp_w;
-     }
-   } else if(!vidmode){
-     if(!screen_size_x) screen_size_x=SCREEN_SIZE_X;
-     if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y;
-     if(screen_size_x<=8) screen_size_x*=sh_video->disp_w;
-     if(screen_size_y<=8) screen_size_y*=sh_video->disp_h;
-   }
-  } else {
-    // check source format aspect, calculate prescale ::atmos
-    screen_size_x=sh_video->disp_w;
-    screen_size_y=sh_video->disp_h;
-    if(sh_video->aspect>0.01){
-      mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is %.2f:1 - prescaling to correct movie aspect.\n",
-             sh_video->aspect);
-      screen_size_x=(int)((float)sh_video->disp_h*sh_video->aspect);
-      screen_size_x+=screen_size_x%2; // round
-      if(screen_size_x<sh_video->disp_w){
-        screen_size_x=sh_video->disp_w;
-        screen_size_y=(int)((float)sh_video->disp_w*(1.0/sh_video->aspect));
-        screen_size_y+=screen_size_y%2; // round
-      }
-    } else {
-      mp_msg(MSGT_CPLAYER,MSGL_INFO,"Movie-Aspect is undefined - no prescaling applied.\n");
-    }
-  }
+#if 0
 
    { const vo_info_t *info = video_out->get_info();
      mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name,
@@ -1359,6 +1290,7 @@
     if(strlen(info->comment) > 0)
         mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment);
    }
+#endif
 
 #ifdef HAVE_NEW_GUI
    if ( use_gui )
@@ -1390,19 +1322,6 @@
     }
 #endif
 
-   mp_msg(MSGT_CPLAYER,MSGL_V,"video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n",
-                      sh_video->disp_w,sh_video->disp_h,
-                      screen_size_x,screen_size_y,
-                      fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
-                      title,out_fmt);
-
-   if(video_out->config(sh_video->disp_w,sh_video->disp_h,
-                      screen_size_x,screen_size_y,
-                      fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3),
-                      title,out_fmt,&vtune)){
-     mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CannotInitVO);
-     goto goto_next_file; // exit_player(MSGTR_Exit_error);
-   }
    inited_flags|=INITED_VO;
    mp_msg(MSGT_CPLAYER,MSGL_V,"INFO: Video OUT driver init OK!\n");
    if(video_out->control(VOCTRL_QUERY_VAA, &vo_vaa)==VO_NOTIMPL)