changeset 2087:fbf7ce9401ff

divx.dll o_bih workaround, postprocessing support
author arpi
date Fri, 05 Oct 2001 00:08:58 +0000
parents ae67940c9d12
children c42b1e60934a
files dec_video.c dll_init.c dll_init.h
diffstat 3 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dec_video.c	Thu Oct 04 22:25:13 2001 +0000
+++ b/dec_video.c	Fri Oct 05 00:08:58 2001 +0000
@@ -95,6 +95,11 @@
 
 int get_video_quality_max(sh_video_t *sh_video){
  switch(sh_video->codec->driver){
+#ifdef USE_WIN32DLL
+  case VFM_VFW:
+  case VFM_VFWEX:
+      return 6;
+#endif
 #ifdef USE_DIRECTSHOW
   case VFM_DSHOW:
       return 4;
@@ -111,6 +116,12 @@
 
 void set_video_quality(sh_video_t *sh_video,int quality){
  switch(sh_video->codec->driver){
+#ifdef USE_WIN32DLL
+  case VFM_VFW:
+  case VFM_VFWEX:
+   vfw_set_postproc(sh_video,10*quality);
+  break;
+#endif
 #ifdef USE_DIRECTSHOW
   case VFM_DSHOW: {
    if(quality<0 || quality>4) quality=4;
--- a/dll_init.c	Thu Oct 04 22:25:13 2001 +0000
+++ b/dll_init.c	Fri Oct 05 00:08:58 2001 +0000
@@ -23,6 +23,8 @@
 #include "libvo/img_format.h"
 #include "linux/shmem.h"
 
+extern int divx_quality;
+
 // ACM audio and VfW video codecs initialization
 // based on the avifile library [http://divx.euro.ru]
 
@@ -141,12 +143,12 @@
         return len;
 }
 
-
-
 int init_vfw_video_codec(sh_video_t *sh_video,int ex){
   HRESULT ret;
   int yuv=0;
   unsigned int outfmt=sh_video->codec->outfmt[sh_video->outfmtidx];
+  unsigned char temp[1024];
+  int i;
 
   mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Codec init =======\n");
 
@@ -163,13 +165,21 @@
 
 //  sh_video->bih.biBitCount=32;
 
-  ret = ICDecompressGetFormat(sh_video->hic, sh_video->bih, &sh_video->o_bih);
+  // Note: DivX.DLL overwrites 4 bytes _AFTER_ the o_bih header, so it corrupts
+  // the sh_video struct content. We call it with an 1024-byte temp space and
+  // then copy out the data we need:
+  memset(temp,0x77,1024);
+
+  ret = ICDecompressGetFormat(sh_video->hic, sh_video->bih, temp);
   if(ret){
     mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret);
     return 0;
   }
   mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n");
   
+  memcpy(&sh_video->o_bih,temp,sizeof(sh_video->o_bih));
+  // for(i=0;i<1024;i++) printf("%02X ",temp[i]);
+  
 //  printf("ICM_DECOMPRESS_QUERY=0x%X",ICM_DECOMPRESS_QUERY);
 
 //  sh_video->o_bih.biWidth=sh_video->bih.biWidth;
@@ -292,11 +302,18 @@
     sh_video->o_bih.biCompression = outfmt;
 
 //  avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!!
-  
+
+  ICSendMessage(sh_video->hic, ICM_USER+80, (long)(&divx_quality) ,NULL);
+
   mp_msg(MSGT_WIN32,MSGL_V,"VIDEO CODEC Init OK!!! ;-)\n");
   return 1;
 }
 
+int vfw_set_postproc(sh_video_t* sh_video,int quality){
+  // Works only with opendivx/divx4 based DLL
+  return ICSendMessage(sh_video->hic, ICM_USER+80, (long)(&quality) ,NULL);
+}
+
 int vfw_decode_video(sh_video_t* sh_video,void* start,int in_size,int drop_frame,int ex){
     HRESULT ret;
 
--- a/dll_init.h	Thu Oct 04 22:25:13 2001 +0000
+++ b/dll_init.h	Fri Oct 05 00:08:58 2001 +0000
@@ -8,3 +8,4 @@
 
 int init_vfw_video_codec(sh_video_t *sh_video,int ex);
 int vfw_decode_video(sh_video_t* sh_video,void* start,int in_size,int drop_frame,int ex);
+int vfw_set_postproc(sh_video_t* sh_video,int quality);