[Mplayer-cvslog] CVS: main codec-cfg.c,1.22,1.23 mplayer.c,1.168,1.169

Arpi of Ize arpi at mplayerhq.banki.hu
Sat Jun 30 02:16:42 CEST 2001


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

Modified Files:
	codec-cfg.c mplayer.c 
Log Message:
optional libavcodec (ffmpeg) support

Index: codec-cfg.c
===================================================================
RCS file: /cvsroot/mplayer/main/codec-cfg.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- codec-cfg.c	27 May 2001 23:29:03 -0000	1.22
+++ codec-cfg.c	30 Jun 2001 00:16:39 -0000	1.23
@@ -207,6 +207,7 @@
 		"vfw",
 		"odivx",
 		"dshow",
+		"ffmpeg",
 		NULL
 	};
         char **drv=audioflag?audiodrv:videodrv;

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- mplayer.c	29 Jun 2001 21:35:30 -0000	1.168
+++ mplayer.c	30 Jun 2001 00:16:39 -0000	1.169
@@ -65,6 +65,13 @@
 #include "DirectShow/DS_AudioDec.h"
 #endif
 
+#ifdef USE_LIBAVCODEC
+#include "libavcodec/avcodec.h"
+    AVCodec *lavc_codec=NULL;
+    AVCodecContext lavc_context;
+    AVPicture lavc_picture;
+#endif
+
 #include "opendivx/decore.h"
 
 
@@ -1279,6 +1286,34 @@
    if(verbose) printf("INFO: OpenDivX video codec init OK!\n");
    break;
  }
+ case 5: {  // FFmpeg's libavcodec
+#ifndef USE_LIBAVCODEC
+   fprintf(stderr,"MPlayer was compiled WITHOUT libavcodec support!\n");
+   exit(1);
+#else
+   if(verbose) printf("FFmpeg's libavcodec video codec\n");
+    avcodec_init();
+    avcodec_register_all();
+    lavc_codec = avcodec_find_decoder_by_name(sh_video->codec->dll);
+    if(!lavc_codec){
+	fprintf(stderr,"Can't find codec '%s' in libavcodec...\n",sh_video->codec->dll);
+	exit(1);
+    }
+    memset(&lavc_context, 0, sizeof(lavc_context));
+    lavc_context.width=sh_video->disp_w;
+    lavc_context.height=sh_video->disp_h;
+    printf("libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height);
+    /* open it */
+    if (avcodec_open(&lavc_context, lavc_codec) < 0) {
+        fprintf(stderr, "could not open codec\n");
+        exit(1);
+    }
+   
+   if(verbose) printf("INFO: libavcodec init OK!\n");
+   break;
+#endif
+ }
+
  case 1: {
    // init libmpeg2:
 #ifdef MPEG12_POSTPROC
@@ -1709,6 +1744,35 @@
         video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
       t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
     }
+    break;
+  }
+#endif
+#ifdef USE_LIBAVCODEC
+  case 5: {        // libavcodec
+    unsigned char* start=NULL;
+    unsigned int t=GetTimer();
+    unsigned int t2;
+    int got_picture=0;
+    int in_size=ds_get_packet(d_video,&start);
+    if(in_size<0){ eof=1;break;}
+    if(in_size>max_framesize) max_framesize=in_size;
+
+    if(d_video->flags) if(verbose) printf("***keyframe***\n");
+
+    if(drop_frame<2){
+        int ret = avcodec_decode_video(&lavc_context, &lavc_picture,
+	     &got_picture, start, in_size);
+	if(ret<0) fprintf(stderr, "Error while decoding frame!\n");
+    }
+
+    current_module="draw_frame";
+
+    if(!drop_frame && got_picture){
+      t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
+      video_out->draw_slice(lavc_picture.data,lavc_picture.linesize,sh_video->disp_w,sh_video->disp_h,0,0);
+      t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
+    }
+    
     break;
   }
 #endif


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list