[Mplayer-cvslog] CVS: main/libvo vo_dxr3.c,1.74,1.75

David Holm mswitch at mplayer.dev.hu
Tue Mar 26 19:47:45 CET 2002


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

Modified Files:
	vo_dxr3.c 
Log Message:
XorA added the option of switching between fame/avcodec without
recompiling. Docs updated accordingly


Index: vo_dxr3.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_dxr3.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- vo_dxr3.c	25 Mar 2002 05:13:19 -0000	1.74
+++ vo_dxr3.c	26 Mar 2002 18:47:42 -0000	1.75
@@ -6,6 +6,10 @@
  */
 
 /* ChangeLog added 2002-01-10
+ * 2002-03-26:
+ *  XorA added an option parser and support for selecting encoder
+ *  codec. We thank him again.
+ *
  * 2002-03-25:
  *  A couple of bugfixes by XorA
  *
@@ -83,11 +87,9 @@
 #include "../postproc/swscale.h"
 #include "../cpudetect.h"
 
-#ifndef USE_LIBAVCODEC
-#  define USE_LIBFAME
-#else
-#  undef USE_LIBFAME
-#endif
+#define USE_LIBFAME
+
+/* Libfame codec initialisation */
 #ifdef USE_LIBFAME
 #include "../libfame/fame.h"
 static unsigned char *outbuf = NULL;
@@ -95,7 +97,10 @@
 static fame_yuv_t fame_yuv;
 static fame_context_t *fame_ctx = NULL;
 static fame_object_t *fame_obj;
-#elif USE_LIBAVCODEC
+#endif
+
+/* libavcodec codec initialisation */
+#ifdef USE_LIBAVCODEC
 #ifdef USE_LIBAVCODEC_SO
 #include <libffmpeg/avcodec.h>
 #else
@@ -116,6 +121,21 @@
 #endif
 
 LIBVO_EXTERN (dxr3)
+/* codec control */
+enum MpegCodec
+{
+  MPG_CODEC_NON,
+  MPG_CODEC_AVCODEC,
+  MPG_CODEC_FAME
+};
+
+#if defined(USE_LIBFAME)
+static int mpeg_codec = MPG_CODEC_FAME;
+#elif defined(USE_LIBAVCODEC)
+static int mpeg_codec = MPG_CODEC_AVCODEC;
+#else
+statuc int mpeg_codec = MPG_CODEC_NONE;
+#endif
 
 /* Resolutions and positions */
 static int v_width, v_height;
@@ -284,7 +304,11 @@
 		picture_linesize[0] = s_width;
 		picture_linesize[1] = s_width / 2;
 		picture_linesize[2] = s_width / 2;
+		switch(mpeg_codec)
+		{
 #ifdef USE_LIBFAME
+		case MPG_CODEC_FAME:
+		  printf("VO: [dxr3] Using FAME\n");
 		fame_ctx = fame_open();
 		if (!fame_ctx) {
 			printf("VO: [dxr3] Cannot open libFAME!\n");
@@ -340,7 +364,11 @@
 		fame_yuv.y = picture_data[0];
 		fame_yuv.u = picture_data[1];
 		fame_yuv.v = picture_data[2];
-#elif USE_LIBAVCODEC
+		break;
+#endif
+#ifdef USE_LIBAVCODEC
+		case MPG_CODEC_AVCODEC:
+		  printf("VO: [dxr3] Using AVCODEC\n");
 		avc_codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
 		if (!avc_codec) {
 			printf("VO: [dxr3] Unable to find mpeg1video codec\n");
@@ -376,7 +404,10 @@
 		avc_picture.data[0] = picture_data[0];
 		avc_picture.data[1] = picture_data[1];
 		avc_picture.data[2] = picture_data[2];
+		break;
 #endif
+		}
+
 		sws = getSwsContextFromCmdLine(v_width, v_height, img_format, s_width, s_height, IMGFMT_YV12);
 		if (!sws) {
 			printf("vo_vesa: Can't initialize SwScaler\n");
@@ -441,13 +472,21 @@
 		int size, srcStride = (img_format == IMGFMT_YUY2) ? (v_width * 2) : (v_width * 3);
 		sws->swScale(sws, src, &srcStride, 0, v_height, picture_data, picture_linesize);
 		draw_osd();
+		switch(mpeg_codec)
+		{
 #ifdef USE_LIBFAME
+		case MPG_CODEC_FAME:
 		size = fame_encode_frame(fame_ctx, &fame_yuv, NULL);
 		write(fd_video, outbuf, size);
-#elif USE_LIBAVCODEC
+		break;
+#endif
+#ifdef USE_LIBAVCODEC
+		case MPG_CODEC_AVCODEC:
 		size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture);
 		write(fd_video, picture_data[0], size);
+		break;
 #endif
+		}
 		return 0;
 	}
 	return -1;
@@ -455,20 +494,29 @@
 
 static void flip_page(void)
 {
+  int size;
 	if (!noprebuf) {
 		ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts);
 	}
 	if (img_format == IMGFMT_YV12) {
+		switch(mpeg_codec)
+		{
 #ifdef USE_LIBFAME
-		int size = fame_encode_frame(fame_ctx, &fame_yuv, NULL);
+		case MPG_CODEC_FAME:
+		size = fame_encode_frame(fame_ctx, &fame_yuv, NULL);
 		write(fd_video, outbuf, size);
-#elif USE_LIBAVCODEC
-		int size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture);
+		break;
+#endif
+#ifdef USE_LIBAVCODEC
+		case MPG_CODEC_AVCODEC:
+		size = avcodec_encode_video(avc_context, picture_data[0], avc_outbuf_size, &avc_picture);
 		if (!noprebuf) {
 			ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts);
 		}
 		write(fd_video, picture_data[0], size);
+		break;
 #endif
+		}
 	}
 }
 
@@ -487,15 +535,24 @@
 	if (sws) {
 		freeSwsContext(sws);
 	}
+
+	switch(mpeg_codec)
+	{
 #ifdef USE_LIBFAME
+	case MPG_CODEC_FAME:
 	if (fame_ctx) {
 		fame_close(fame_ctx);
 	}
-#elif USE_LIBAVCODEC
+	break;
+#endif
+#ifdef USE_LIBAVCODEC
+	case MPG_CODEC_AVCODEC:
 	if (avc_context) {
 		avcodec_close(avc_context);
 	}
+	break;
 #endif
+	}
 	if (picture_data[0]) {
 		free(picture_data[0]);
 	}
@@ -522,13 +579,39 @@
 
 	GetCpuCaps(&cpucaps);
 	/* Open the control interface */
-	if ((arg && !strcmp("noprebuf", arg)) || cpucaps.has3DNowExt) {
+	if (arg && !strncmp("noprebuf", arg,8)) {
 		printf("VO: [dxr3] Disabling prebuffering.\n");
 		noprebuf = 1;
 		fdflags |= O_NONBLOCK;
+		arg=strchr(arg,':');
+		if(arg) arg++;
 	}
 
-	if (arg && !noprebuf) {
+	if(cpucaps.has3DNowExt)
+	{
+		printf("VO: [dxr3] fast AMD special disabling prebuffering.\n");
+		noprebuf = 1;
+		fdflags |= O_NONBLOCK;
+	}
+
+#if defined(USE_LIBFAME)
+	printf("VO: [dxr3] FAME supported\n");
+	if (arg && !strncmp("fame",arg,4)) {
+	  mpeg_codec=MPG_CODEC_FAME;
+	  arg=strchr(arg,':');
+	  if(arg) arg++;
+	}
+#endif
+#if defined(USE_LIBAVCODEC)
+	printf("VO: [dxr3] AVCODEC supported\n");
+	if (arg && !strncmp("avcodec",arg,7)) {
+	  mpeg_codec=MPG_CODEC_AVCODEC;
+	  arg=strchr(arg,':');
+	  if(arg) arg++;
+	}
+#endif
+
+	if (arg && arg[0]) {
 		printf("VO: [dxr3] Forcing use of device %s\n", arg);
 		sprintf(devname, "/dev/em8300-%s", arg);
 	} else {
@@ -590,10 +673,11 @@
 		}
 	}
 
-#if !defined(USE_LIBFAME) && defined(USE_LIBAVCODEC)
-	avcodec_init();
-	avcodec_register_all();
-#endif
+	if(mpeg_codec==MPG_CODEC_AVCODEC)
+	{
+		avcodec_init();
+		avcodec_register_all();
+	}
 	
 	return 0;
 }




More information about the MPlayer-cvslog mailing list