[MPlayer-dev-eng] [PATCH] mencoder vfw codecs configuration data support

Gianluigi Tiesi mplayer at netfarm.it
Tue Oct 24 09:49:43 CEST 2006


This patch adds a new option to mencoder when used with -ovc vfw
like -xvfwopts codecs=vp6vfw.dll:compdata=settings.mcf

also using compdata=dialog, on win32 shows the codec
configure dialog before starting the encoding.
Attached also a small program that can be compiled
with mingw, msvc2005 and with wingcc (yes it works also
on linux) that can generate settings files by
displaying the settings dialog.
The patch follows the same code style of the original file.

Regards

-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
diff -NuBr -x.svn -xhelp_mp.h -xlibdha -x'*.so' -x'*.log' -x'*.a' -x'*.exe' -x'*.o' -xconfigure.log -xconfig.mak -x.cvsignore -xconfig.h -xcodecs.conf.h -xversion.h -x.depend main/libmpcodecs/ve_vfw.c sherpya/libmpcodecs/ve_vfw.c
--- main/libmpcodecs/ve_vfw.c	2006-07-02 11:43:19.625328000 +0200
+++ sherpya/libmpcodecs/ve_vfw.c	2006-10-24 07:29:43.281280000 +0200
@@ -3,6 +3,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <sys/stat.h>
 
 #include "config.h"
 
@@ -28,11 +29,13 @@
 //===========================================================================//
 
 static char *vfw_param_codec = NULL;
+static char *vfw_param_compdata = NULL;
 
 #include "m_option.h"
 
 m_option_t vfwopts_conf[]={
     {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
+    {"compdata", &vfw_param_compdata, CONF_TYPE_STRING, 0, 0, 0, NULL},
     {NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
@@ -47,11 +50,14 @@
 static int encoder_frameno=0;
 
 //int init_vfw_encoder(char *dll_name, BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih)
-static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, BITMAPINFOHEADER *input_bih,unsigned int out_fourcc)
+static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, char *compdatafile, BITMAPINFOHEADER *input_bih,unsigned int out_fourcc)
 {
   HRESULT ret;
   BITMAPINFOHEADER* output_bih=NULL;
   int temp_len;
+  FILE *fd=NULL;
+  char *drvdata=NULL;
+  struct stat st;
 
 //sh_video = malloc(sizeof(sh_video_t));
 
@@ -92,6 +98,47 @@
 }
 #endif
 
+  if(compdatafile){
+    if (!strncmp(compdatafile, "dialog", 6)){
+      if (ICSendMessage(encoder_hic, ICM_CONFIGURE, -1, 0) != ICERR_OK){
+        mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor doesn't have a configure dialog!\n");
+        return NULL;
+      }
+      if (ICSendMessage(encoder_hic, ICM_CONFIGURE, 0, 0) != ICERR_OK){
+        mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor configure dialog failed!\n");
+        return NULL;
+      }
+    }
+    else {
+      if (stat(compdatafile, &st) < 0){
+        mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor data file not found!\n");
+        return NULL;
+      }
+      fd = fopen(compdatafile, "rb");
+      if (!fd){
+        mp_msg(MSGT_WIN32,MSGL_ERR,"Cannot open Compressor data file!\n");
+        return NULL;
+      }
+      drvdata = (char *) malloc(st.st_size);
+      if (fread(drvdata, st.st_size, 1, fd) != 1) {
+        mp_msg(MSGT_WIN32,MSGL_ERR,"Cannot read Compressor data file!\n");
+        fclose(fd);
+        free(drvdata);
+        return NULL;
+      }
+      fclose(fd);
+      mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor data %d bytes\n", st.st_size);
+      if (!(temp_len = (unsigned int) ICSendMessage(encoder_hic, ICM_SETSTATE, (LPARAM) drvdata, (int) st.st_size))){
+        mp_msg(MSGT_WIN32,MSGL_ERR,"ICSetState failed!\n");
+        fclose(fd);
+        free(drvdata);
+        return NULL;
+      }
+      free(drvdata);
+      mp_msg(MSGT_WIN32,MSGL_INFO,"ICSetState ret: %d\n", temp_len);
+    }
+  }
+
   temp_len = ICCompressGetFormatSize(encoder_hic, input_bih);
   mp_msg(MSGT_WIN32,MSGL_INFO,"ICCompressGetFormatSize ret: %d\n", temp_len);
 
@@ -274,7 +321,7 @@
     }
 //    mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3'));
 //    mux_v->bih=vfw_open_encoder("AvidAVICodec.dll",vfw_bih, 0);
-    mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_bih, 0);
+    mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_param_compdata, vfw_bih, 0);
     if(!mux_v->bih) return 0;
 
     return 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vfw2menc.tar.gz
Type: application/octet-stream
Size: 10222 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20061024/284fd091/attachment.obj>


More information about the MPlayer-dev-eng mailing list