[Mplayer-cvslog] CVS: main mencoder.c,1.1,1.2

Arpi of Ize arpi at mplayer.dev.hu
Tue Oct 30 22:22:34 CET 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv23776

Modified Files:
	mencoder.c 
Log Message:
simplified

Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mencoder.c	29 Oct 2001 01:11:18 -0000	1.1
+++ mencoder.c	30 Oct 2001 21:22:28 -0000	1.2
@@ -13,7 +13,6 @@
 
 #include "stream.h"
 #include "demuxer.h"
-#include "parse_es.h"
 #include "stheader.h"
 
 #include "aviwrite.h"
@@ -22,29 +21,7 @@
 
 #include <encore2.h>
 
-char *get_path(char *filename){
-	char *homedir;
-	char *buff;
-	static char *config_dir = "/.mplayer";
-	int len;
-
-	if ((homedir = getenv("HOME")) == NULL)
-		return NULL;
-	len = strlen(homedir) + strlen(config_dir) + 1;
-	if (filename == NULL) {
-		if ((buff = (char *) malloc(len)) == NULL)
-			return NULL;
-		sprintf(buff, "%s%s", homedir, config_dir);
-	} else {
-		len += strlen(filename) + 1;
-		if ((buff = (char *) malloc(len)) == NULL)
-			return NULL;
-		sprintf(buff, "%s%s/%s", homedir, config_dir, filename);
-	}
-	return buff;
-}
-
-#define ABS(x) (((x)>=0)?(x):(-(x)))
+#include "get_path.c"
 
 //--------------------------
 
@@ -58,9 +35,6 @@
 // AVI demuxer params:
 static float c_total=0;
 int delay_corrected=1;
-extern int index_mode;  // -1=untouched  0=don't use index  1=use (geneate) index
-extern int force_ni;
-extern int pts_from_bps;
 
 char *audio_codec=NULL; // override audio codec
 char *video_codec=NULL; // override video codec
@@ -80,22 +54,11 @@
 static int total_time_usage_start=0;
 static int benchmark=0;
 
-int divx_quality=0;
 int force_fps=0;
 
 #include "libmpeg2/mpeg2.h"
 #include "libmpeg2/mpeg2_internal.h"
 
-extern picture_t *picture;	// exported from libmpeg2/decode.c
-
-int frameratecode2framerate[16] = {
-  0,
-  // Official mpeg1/2 framerates:
-  24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, 60*10000,
-  // libmpeg3's "Unofficial economy rates":
-  1*10000,5*10000,10*10000,12*10000,15*10000,0,0
-};
-
 static unsigned char* vo_image=NULL;
 static unsigned char* vo_image_ptr=NULL;
 static int vo_w,vo_h;
@@ -339,113 +302,27 @@
 
 while(!eof){
 
-    float frame_time=1;
-    float pts1=d_video->pts;
+    float frame_time=0;
     int blit_frame=0;
     float a_pts=0;
     float v_pts=0;
 
-//    current_module="decode_video";
-    
-  //--------------------  Decode a frame: -----------------------
-
-  if(demuxer->file_format==DEMUXER_TYPE_MPEG_ES || demuxer->file_format==DEMUXER_TYPE_MPEG_PS){
-        int in_frame=0;
-        float newfps;
-        //videobuf_len=0;
-        while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
-          int i=sync_video_packet(d_video);
-	  void* buffer=&videobuffer[videobuf_len+4];
-          if(in_frame){
-            if(i<0x101 || i>=0x1B0){  // not slice code -> end of frame
-#if 1
-              // send END OF FRAME code:
-              videobuffer[videobuf_len+0]=0;
-              videobuffer[videobuf_len+1]=0;
-              videobuffer[videobuf_len+2]=1;
-              videobuffer[videobuf_len+3]=0xFF;
-              videobuf_len+=4;
-#endif
-              if(!i) eof=2; // EOF
-              break;
-            }
-          } else {
-            //if(i==0x100) in_frame=1; // picture startcode
-            if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode
-            else if(!i){ eof=3; break;} // EOF
-          }
-          if(!read_video_packet(d_video)){ eof=4; break;} // EOF
-          //printf("read packet 0x%X, len=%d\n",i,videobuf_len);
-	  if(sh_video->codec->driver!=VFM_MPEG){
-	    // if not libmpeg2:
-	    switch(i){
-	      case 0x1B3: header_process_sequence_header (picture, buffer);break;
-	      case 0x1B5: header_process_extension (picture, buffer);break;
-	    }
-	  }
-        }
-        
-        //if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug
-        //printf("--- SEND %d bytes\n",videobuf_len);
-
-    blit_frame=decode_video(&video_out,sh_video,videobuffer,videobuf_len,0);
-
-    // get mpeg fps:
-    newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;
-    if(ABS(sh_video->fps-newfps)>0.01f) {
-            mp_msg(MSGT_CPLAYER,MSGL_WARN,"Warning! FPS changed %5.3f -> %5.3f  (%f) [%d]  \n",sh_video->fps,newfps,sh_video->fps-newfps,picture->frame_rate_code);
-            sh_video->fps=newfps;
-            sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code];
-    }
-
-    // fix mpeg2 frametime:
-    frame_time=(picture->display_time)*0.01f;
-    picture->display_time=100;
-    videobuf_len=0;
-
-  } else {
-      // frame-based file formats: (AVI,ASF,MOV)
-    unsigned char* start=NULL;
-    int in_size=ds_get_packet(d_video,&start);
-    if(in_size<0){ eof=5;break;}
-    //if(in_size>max_framesize) max_framesize=in_size;
-    if(mux_v->codec){
-	// convert
-	blit_frame=decode_video(&video_out,sh_video,start,in_size,0);
-    } else {
-	// copy
-	mux_v->buffer=start;
-	aviwrite_write_chunk(muxer,mux_v,muxer_f,in_size,(sh_video->ds->flags&1)?0x10:0);
-    }
-  }
-  if(eof) break;
-
-//------------------------ frame decoded. --------------------
-
-    // Increase video timers:
-    sh_video->num_frames+=frame_time;
-    ++sh_video->num_frames_decoded;
-    frame_time*=sh_video->frametime;
-    if(demuxer->file_format==DEMUXER_TYPE_ASF && !force_fps){
-        // .ASF files has no fixed FPS - just frame durations!
-        float d=d_video->pts-pts1;
-        if(d>=0 && d<5) frame_time=d;
-        if(d>0){
-          if(verbose)
-            if((int)sh_video->fps==1000)
-              mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\rASF framerate: %d fps             \n",(int)(1.0f/d));
-          sh_video->frametime=d; // 1ms
-          sh_video->fps=1.0f/d;
-        }
-    } else
-    if(demuxer->file_format==DEMUXER_TYPE_MOV && !force_fps){
-        // .MOV files has no fixed FPS - just frame durations!
-        float d=d_video->pts-pts1;
-	frame_time=d;
+    //--------------------  Decode a frame: -----------------------
+    {   unsigned char* start=NULL;
+	int in_size;
+	// get it!
+//	current_module="video_read_frame";
+        in_size=video_read_frame(sh_video,&frame_time,&start,force_fps);
+	if(in_size<0){ eof=1; break; }
+	if(in_size>max_framesize) max_framesize=in_size; // stats
+	// decode:
+//	current_module="decode_video";
+//	printf("Decode! %p  %d  \n",start,in_size);
+	blit_frame=decode_video(video_out,sh_video,start,in_size,drop_frame);
     }
+    //------------------------ frame decoded. --------------------
+    
     sh_video->timer+=frame_time;
-
-    if(demuxer->file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time;
 
     if(pts_from_bps){
         unsigned int samples=(sh_audio->audio.dwSampleSize)?




More information about the MPlayer-cvslog mailing list