[MPlayer-users] -vo ppm

Nitin nitinpdhavale at softhome.net
Wed Mar 26 15:07:47 CET 2003


Hello everyone!
    If anyone's interested, here's some code for getting .ppm output.

Cheers!
Nitin

----------------------- Cut from the next line -----------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.688
diff -u -r1.688 configure
--- configure	23 Mar 2003 17:14:28 -0000	1.688
+++ configure	26 Mar 2003 21:54:13 -0000
@@ -190,7 +190,8 @@
   --disable-libdv        disable libdv 0.9.5 en/decoding support [autodetect]
   --disable-mad          disable libmad (mpeg audio) support [autodetect]
   --enable-xmms          build with XMMS inputplugin support [disabled]
-  
+  --enable-ppm           enable ppm support[enabled]
+
 Video output:
   --disable-vidix        disable VIDIX stuff [enable on x86 *nix]
   --enable-gl            build with OpenGL render support [autodetect]
@@ -989,6 +990,7 @@
 _win32waveout=auto
 _nas=auto
 _png=auto
+_ppm=no
 _jpg=auto
 _gif=auto
 _gl=auto
@@ -1115,6 +1117,8 @@
   --disable-nas)	_nas=no		;;
   --enable-png)		_png=yes	;;
   --disable-png)	_png=no		;;
+  --enable-ppm)         _ppm=yes        ;;
+  --enable-ppm)         _ppm=no         ;; 
   --enable-jpeg)	_jpg=yes	;;
   --disable-jpeg)	_jpg=no		;;
   --enable-gif)	_gif=yes	;;
@@ -2978,6 +2982,7 @@
 else
   echores "$_png"
 fi
+
 if test "$_png" = yes ; then
   _def_png='#define HAVE_PNG 1'
   _ld_png='-lpng -lz'
@@ -2990,6 +2995,20 @@
   _mkf_png="no"
 fi
 
+echocheck "PPM support"
+echores "$_ppm"
+if test "$_ppm" = yes ; then
+    _def_ppm='#define HAVE_PPM 1'
+    _ld_ppm=''
+    _vosrc="$_vosrc vo_ppm.c"
+    _vomodules="ppm $_vomodules"
+    _mkf_ppm="yes"
+else
+    _def_ppm='#undef HAVE_PPM'
+    _vomodules="ppm $_novomodules"
+    _mkf_ppm="no"
+fi
+
 echocheck "JPEG support"
 if test "$_jpg" = auto ; then
   _jpg=no
@@ -5023,6 +5042,7 @@
 UNRARLIB = $_unrarlib
 
 PNG = $_mkf_png
+PPM = $_mkf_ppm
 JPEG = $_mkf_jpg
 GIF = $_mkf_gif
 
@@ -5046,6 +5066,7 @@
 DXR2_INC = $_inc_dxr2
 DVB_INC = $_inc_dvb
 PNG_LIB = $_ld_png
+PPM_LIB = $_ld_ppm
 JPEG_LIB = $_ld_jpg
 GIF_LIB = $_ld_gif
 SDL_LIB = $_ld_sdl
@@ -5475,6 +5496,9 @@
 
 /* enable PNG support */
 $_def_png
+
+/* enable PPM support */
+$_def_ppm
 
 /* enable JPEG support */
 $_def_jpg
Index: libvo/video_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/video_out.c,v
retrieving revision 1.68
diff -u -r1.68 video_out.c
--- libvo/video_out.c	12 Mar 2003 15:04:05 -0000	1.68
+++ libvo/video_out.c	26 Mar 2003 21:54:13 -0000
@@ -82,6 +82,9 @@
 extern vo_functions_t video_out_dxr2;
 #endif
 extern vo_functions_t video_out_dxr3;
+#ifdef HAVE_PPM
+extern vo_functions_t video_out_ppm;
+#endif
 #ifdef HAVE_JPEG
 extern vo_functions_t video_out_jpeg;
 #endif
@@ -196,6 +199,10 @@
 #endif
 #if defined(CONFIG_VIDIX) && defined(HAVE_X11) 
 	&video_out_xvidix,
+#endif
+
+#ifdef HAVE_PPM
+	&video_out_ppm,
 #endif
         NULL
 };
============================================================
Index: libvo/vo_ppm.c
--- libvo/vo_ppm.c	created
+++ libvo/vo_ppm.c	2003-03-26 11:27:20.000000000 +0000	1.1
@@ -0,0 +1,142 @@
+/* 
+ * video_out_ppm.c, ppm interface
+ * Code drawn from jpeg, x11, png  vo plugins
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "config.h"
+#include "video_out.h"
+#include "video_out_internal.h"
+
+#include "../postproc/swscale.h"
+#include "../postproc/swscale_internal.h"
+#include "../postproc/rgb2rgb.h"
+
+static vo_info_t info = 
+{
+    "PPM file",
+    "ppm",
+    "Nitin Dhavale (dhavale at usc.edu)",
+    ""
+};
+
+LIBVO_EXTERN (ppm)
+     
+static int image_width;
+static int image_height;
+static char header[1024];
+static int framenum = 0;
+
+static uint8_t *image=NULL;
+static uint32_t in_format;
+static uint32_t out_format;
+char vo_ppm_filename[24];
+
+extern char mPipeName[1024];
+
+static context *swsContext=NULL;
+
+const int bpp=24;
+static unsigned int scale_srcW=0, scale_srcH=0;
+
+FILE *out=NULL;
+static uint32_t
+config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, 
uint32_t fullscreen, char *title, uint32_t format)
+{
+  image_height=height;
+  image_width=width;
+
+  // FIX ME
+  yuv2rgb_init(bpp, MODE_RGB);
+  in_format = format;
+  out_format = IMGFMT_RGB24;
+
+  context= sws_getContextFromCmdLine(width, height, in_format, width, height, 
out_format );
+
+  image = malloc(image_width*image_height*3);
+  snprintf (header, 1024, "P6\n\n%d %d\n255\n", image_width, image_height);
+
+  return 0;
+}
+
+static void draw_osd(void)
+{
+}
+
+static void flip_page (void)
+{
+  FILE * f;
+  snprintf (vo_ppm_filename, 24, "%08d.ppm", framenum++);
+  f = fopen (vo_ppm_filename, "wb");  if (f == NULL) return;
+  fwrite (header, strlen (header), 1, f);
+  fwrite (image, image_width, image_height*3, f);
+  fclose(f);
+  return;
+}
+
+static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int 
x,int y)
+{
+  int i, j;
+  int dstStride[3];
+  uint8_t *dst[3];
+
+  dstStride[1] = dstStride[2] = 0;
+  dst[1] = dst[2] = NULL;
+  dstStride[0] = image_width*((bpp+7)/8);
+  dst[0] = image;
+  sws_scale(context, srcimg, stride, y, h, dst, dstStride);
+  return 0;
+}
+
+
+static uint32_t draw_frame(uint8_t * src[])
+{
+  return -1;
+}
+
+static uint32_t
+query_format(uint32_t format)
+{
+  if(format==IMGFMT_YV12) return 1;
+  return 0;
+}
+
+static void
+uninit(void)
+{
+  int n = 0; 
+  
+  if(image){ free(image);image=NULL;}
+}
+
+
+static void check_events(void)
+{
+}
+
+static uint32_t preinit(const char *arg)
+{
+  if(arg) 
+    {
+      printf("vo_ppm: Unknown subdevice: %s\n",arg);
+      return ENOSYS;
+    }
+  return 0;
+}
+
+static uint32_t control(uint32_t request, void *data, ...)
+{
+  switch (request) {
+  case VOCTRL_QUERY_FORMAT:
+    return query_format(*((uint32_t*)data));
+  }
+  return VO_NOTIMPL;
+}




More information about the MPlayer-users mailing list