comparison libmpcodecs/ve_vfw.c @ 24770:6a8be4b73d07

Add Coinitialize function to vfw encoder and win32 loader. Fixes crash when trying to load vp7vfw.dll in vfw2menc. Patch by Gianluigi Tiesi mplayer___netfarm.it http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2007-September/054136.html
author compn
date Wed, 17 Oct 2007 05:14:21 +0000
parents d07cc034ed66
children f1922d2b1925
comparison
equal deleted inserted replaced
24769:c3839c904be4 24770:6a8be4b73d07
17 17
18 #include "loader/loader.h" 18 #include "loader/loader.h"
19 //#include "loader/wine/mmreg.h" 19 //#include "loader/wine/mmreg.h"
20 #include "loader/wine/vfw.h" 20 #include "loader/wine/vfw.h"
21 #include "loader/wine/avifmt.h" 21 #include "loader/wine/avifmt.h"
22 #include "loader/wine/winerror.h"
23 #include "loader/wine/objbase.h"
22 24
23 #include "img_format.h" 25 #include "img_format.h"
24 #include "mp_image.h" 26 #include "mp_image.h"
25 #include "vf.h" 27 #include "vf.h"
26 28
29 31
30 //===========================================================================// 32 //===========================================================================//
31 33
32 static char *vfw_param_codec = NULL; 34 static char *vfw_param_codec = NULL;
33 static char *vfw_param_compdata = NULL; 35 static char *vfw_param_compdata = NULL;
36 static HRESULT CoInitRes = -1;
34 37
35 #include "m_option.h" 38 #include "m_option.h"
36 39
37 m_option_t vfwopts_conf[]={ 40 m_option_t vfwopts_conf[]={
38 {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL}, 41 {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
61 struct stat st; 64 struct stat st;
62 65
63 //sh_video = malloc(sizeof(sh_video_t)); 66 //sh_video = malloc(sizeof(sh_video_t));
64 67
65 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n"); 68 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n");
66 69 CoInitRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
67 // memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER)); 70 // memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
68 // output_bih->biSize = sizeof(BITMAPINFOHEADER); 71 // output_bih->biSize = sizeof(BITMAPINFOHEADER);
69 72
70 // encoder_hic = ICOpen( 0x63646976, out_fourcc, ICMODE_COMPRESS); 73 // encoder_hic = ICOpen( 0x63646976, out_fourcc, ICMODE_COMPRESS);
71 encoder_hic = ICOpen( (long) dll_name, out_fourcc, ICMODE_COMPRESS); 74 encoder_hic = ICOpen( (long) dll_name, out_fourcc, ICMODE_COMPRESS);
293 // return 0; 296 // return 0;
294 muxer_write_chunk(mux_v,mux_v->bih->biSizeImage,flags, pts, pts); 297 muxer_write_chunk(mux_v,mux_v->bih->biSizeImage,flags, pts, pts);
295 return 1; 298 return 1;
296 } 299 }
297 300
301 static void uninit(struct vf_instance_s* vf)
302 {
303 HRESULT ret;
304
305 if(encoder_hic){
306 if(encoder_buf){
307 ret=ICCompressEnd(encoder_hic);
308 if(ret) mp_msg(MSGT_WIN32, MSGL_WARN, "ICCompressEnd failed: %ld\n", ret);
309 free(encoder_buf);
310 encoder_buf=NULL;
311 }
312 ret=ICClose(encoder_hic);
313 if(ret) mp_msg(MSGT_WIN32, MSGL_WARN, "ICClose failed: %ld\n", ret);
314 encoder_hic=0;
315 if ((CoInitRes == S_OK) || (CoInitRes == S_FALSE)) CoUninitialize();
316 }
317 }
318
298 //===========================================================================// 319 //===========================================================================//
299 320
300 static int vf_open(vf_instance_t *vf, char* args){ 321 static int vf_open(vf_instance_t *vf, char* args){
301 vf->config=config; 322 vf->config=config;
302 vf->default_caps=VFCAP_CONSTANT; 323 vf->default_caps=VFCAP_CONSTANT;
303 vf->control=control; 324 vf->control=control;
304 vf->query_format=query_format; 325 vf->query_format=query_format;
305 vf->put_image=put_image; 326 vf->put_image=put_image;
327 vf->uninit=uninit;
306 vf->priv=malloc(sizeof(struct vf_priv_s)); 328 vf->priv=malloc(sizeof(struct vf_priv_s));
307 memset(vf->priv,0,sizeof(struct vf_priv_s)); 329 memset(vf->priv,0,sizeof(struct vf_priv_s));
308 vf->priv->mux=(muxer_stream_t*)args; 330 vf->priv->mux=(muxer_stream_t*)args;
309 331
310 vfw_bih=calloc(1, sizeof(BITMAPINFOHEADER)); 332 vfw_bih=calloc(1, sizeof(BITMAPINFOHEADER));