annotate libmpcodecs/ve_vfw.c @ 33644:c15dabfa2380

Do a proper calculation of free RAM to be used as V4L buffers. The code uses sysinfo to query the available RAM, however it used ancient form available is some early development 2.3.x kernels. Newer form reports the size in memory units (usually same as page size), as result the code would fallback to 2 buffers even on multi GB system. The commit does: Improve the check in configure to ensure that we do use sysinfo struct with present mem_unit. Use free ram instead of total ram (to avoid swapping). Tweak memory constants and simplify code.
author iive
date Sun, 26 Jun 2011 14:42:35 +0000
parents c42345605c7a
children cc8dfde2b6c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
19 #include <stdio.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
20 #include <stdlib.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
21 #include <string.h>
7238
6f44ed6c4568 FreeBSD fix
nexus
parents: 7231
diff changeset
22 #include <unistd.h>
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
23 #include <inttypes.h>
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
24 #include <sys/stat.h>
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
25
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
26 #include "config.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
27
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 15212
diff changeset
28 #include "mp_msg.h"
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
29 #include "help_mp.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
30
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
31 #include "codec-cfg.h"
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 22577
diff changeset
32 //#include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
33 //#include "libmpdemux/demuxer.h"
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
34 //#include "libmpdemux/stheader.h"
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
35
22577
a033e5519802 Include loader/ prefix in #include path everywhere.
diego
parents: 22252
diff changeset
36 #include "loader/loader.h"
a033e5519802 Include loader/ prefix in #include path everywhere.
diego
parents: 22252
diff changeset
37 //#include "loader/wine/mmreg.h"
a033e5519802 Include loader/ prefix in #include path everywhere.
diego
parents: 22252
diff changeset
38 #include "loader/wine/vfw.h"
26146
20a126aaa756 ve_vfw.c: #include aviheader.h instead of wine avifmt.h
uau
parents: 25262
diff changeset
39 #include "libmpdemux/aviheader.h"
24770
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
40 #include "loader/wine/winerror.h"
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
41 #include "loader/wine/objbase.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
42
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
43 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
44 #include "mp_image.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
45 #include "vf.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
46
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 22577
diff changeset
47 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
48 #include "libmpdemux/muxer.h"
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
49
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
50 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
51
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
52 static char *vfw_param_codec = NULL;
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
53 static char *vfw_param_compdata = NULL;
24770
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
54 static HRESULT CoInitRes = -1;
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
55
10594
57bdcdb061d7 Removed the historic cfgparser and switched full to the new config parser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.
alex
parents: 9014
diff changeset
56 #include "m_option.h"
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
57
30955
4e59a7aebadb Mark encoder-related m_option_t struct arrays as const.
diego
parents: 30702
diff changeset
58 const m_option_t vfwopts_conf[]={
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
59 {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
60 {"compdata", &vfw_param_compdata, CONF_TYPE_STRING, 0, 0, 0, NULL},
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
61 {NULL, NULL, 0, 0, 0, 0, NULL}
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
62 };
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
63
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
64 struct vf_priv_s {
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
65 muxer_stream_t* mux;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
66 BITMAPINFOHEADER* bih;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
67 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
68
7557
f296ff05bcd0 warning fixes
arpi
parents: 7390
diff changeset
69 static HIC encoder_hic;
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
70 static void* encoder_buf=NULL;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
71 static int encoder_buf_size=0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
72 static int encoder_frameno=0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
73
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
74 //int init_vfw_encoder(char *dll_name, BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih)
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
75 static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, char *compdatafile, BITMAPINFOHEADER *input_bih,unsigned int out_fourcc)
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
76 {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
77 HRESULT ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
78 BITMAPINFOHEADER* output_bih=NULL;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
79 int temp_len;
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
80 FILE *fd=NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
81 char *drvdata=NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
82 struct stat st;
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
83
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
84 //sh_video = malloc(sizeof(sh_video_t));
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
85
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
86 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n");
24770
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
87 CoInitRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
88 // memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
89 // output_bih->biSize = sizeof(BITMAPINFOHEADER);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
90
7390
2357ee501582 fixed to comply with new loader
alex
parents: 7368
diff changeset
91 // encoder_hic = ICOpen( 0x63646976, out_fourcc, ICMODE_COMPRESS);
7557
f296ff05bcd0 warning fixes
arpi
parents: 7390
diff changeset
92 encoder_hic = ICOpen( (long) dll_name, out_fourcc, ICMODE_COMPRESS);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
93 if(!encoder_hic){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
94 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
95 return NULL;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
96 }
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
97 mp_msg(MSGT_WIN32,MSGL_INFO,"HIC: %x\n", encoder_hic);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
98
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
99 {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
100 ICINFO icinfo;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
101
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
102 ret = ICGetInfo(encoder_hic, &icinfo, sizeof(ICINFO));
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
103 mp_msg(MSGT_WIN32,MSGL_INFO,"%ld - %ld - %d\n", ret, icinfo.dwSize, sizeof(ICINFO));
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
104 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorType, icinfo.fccType);
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
105 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorSubtype, icinfo.fccHandler);
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
106 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorFlags,
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
107 icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
108 //printf("Compressor name: %s\n", icinfo.szName);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
109 //printf("Compressor description: %s\n", icinfo.szDescription);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
110
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
111 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Flags);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
112 if (icinfo.dwFlags & VIDCF_QUALITY)
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
113 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Quality);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
114 if (icinfo.dwFlags & VIDCF_FASTTEMPORALD)
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
115 mp_msg(MSGT_WIN32,MSGL_INFO," fast-decompr");
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
116 if (icinfo.dwFlags & VIDCF_QUALITYTIME)
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
117 mp_msg(MSGT_WIN32,MSGL_INFO," temp-quality");
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
118 mp_msg(MSGT_WIN32,MSGL_INFO,"\n");
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
119 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
120
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
121 if(compdatafile){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
122 if (!strncmp(compdatafile, "dialog", 6)){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
123 if (ICSendMessage(encoder_hic, ICM_CONFIGURE, -1, 0) != ICERR_OK){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
124 mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor doesn't have a configure dialog!\n");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
125 return NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
126 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
127 if (ICSendMessage(encoder_hic, ICM_CONFIGURE, 0, 0) != ICERR_OK){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
128 mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor configure dialog failed!\n");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
129 return NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
130 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
131 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
132 else {
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
133 if (stat(compdatafile, &st) < 0){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
134 mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor data file not found!\n");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
135 return NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
136 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
137 fd = fopen(compdatafile, "rb");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
138 if (!fd){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
139 mp_msg(MSGT_WIN32,MSGL_ERR,"Cannot open Compressor data file!\n");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
140 return NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
141 }
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30642
diff changeset
142 drvdata = malloc(st.st_size);
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
143 if (fread(drvdata, st.st_size, 1, fd) != 1) {
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
144 mp_msg(MSGT_WIN32,MSGL_ERR,"Cannot read Compressor data file!\n");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
145 fclose(fd);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
146 free(drvdata);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
147 return NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
148 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
149 fclose(fd);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
150 mp_msg(MSGT_WIN32,MSGL_ERR,"Compressor data %d bytes\n", st.st_size);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
151 if (!(temp_len = (unsigned int) ICSendMessage(encoder_hic, ICM_SETSTATE, (LPARAM) drvdata, (int) st.st_size))){
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
152 mp_msg(MSGT_WIN32,MSGL_ERR,"ICSetState failed!\n");
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
153 free(drvdata);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
154 return NULL;
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
155 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
156 free(drvdata);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
157 mp_msg(MSGT_WIN32,MSGL_INFO,"ICSetState ret: %d\n", temp_len);
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
158 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
159 }
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
160
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
161 temp_len = ICCompressGetFormatSize(encoder_hic, input_bih);
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
162 mp_msg(MSGT_WIN32,MSGL_INFO,"ICCompressGetFormatSize ret: %d\n", temp_len);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
163
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
164 if (temp_len < sizeof(BITMAPINFOHEADER)) temp_len=sizeof(BITMAPINFOHEADER);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
165
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
166 output_bih = malloc(temp_len+4);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
167 memset(output_bih,0,temp_len);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
168 output_bih->biSize = temp_len; //sizeof(BITMAPINFOHEADER);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
169
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
170 return output_bih;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
171 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
172
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
173 static int vfw_start_encoder(BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
174 HRESULT ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
175 int temp_len=output_bih->biSize;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
176 int i;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
177
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
178 ret = ICCompressGetFormat(encoder_hic, input_bih, output_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
179 if(ret < 0){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
180 unsigned char* temp=(unsigned char*)output_bih;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
181 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressGetFormat failed: Error %d (0x%X)\n", (int)ret, (int)ret);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
182 for (i=0; i < temp_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", temp[i]);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
183 return 0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
184 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
185 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressGetFormat OK\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26148
diff changeset
186
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
187 if (temp_len > sizeof(BITMAPINFOHEADER))
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
188 {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
189 unsigned char* temp=(unsigned char*)output_bih;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
190 mp_msg(MSGT_WIN32, MSGL_V, "Extra info in o_bih (%d bytes)!\n",
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
191 temp_len-sizeof(BITMAPINFOHEADER));
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
192 for(i=sizeof(output_bih);i<temp_len;i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02X ",temp[i]);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
193 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
194
17969
843e0427b5b9 Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents: 17906
diff changeset
195 // if( mp_msg_test(MSGT_WIN32,MSGL_V) ) {
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
196 printf("Starting compression:\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
197 printf(" Input format:\n");
25262
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
198 printf(" biSize %ld\n", input_bih->biSize);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
199 printf(" biWidth %ld\n", input_bih->biWidth);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
200 printf(" biHeight %ld\n", input_bih->biHeight);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
201 printf(" biPlanes %d\n", input_bih->biPlanes);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
202 printf(" biBitCount %d\n", input_bih->biBitCount);
25262
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
203 printf(" biCompression 0x%lx ('%.4s')\n", input_bih->biCompression, (char *)&input_bih->biCompression);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
204 printf(" biSizeImage %ld\n", input_bih->biSizeImage);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
205 printf(" Output format:\n");
25262
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
206 printf(" biSize %ld\n", output_bih->biSize);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
207 printf(" biWidth %ld\n", output_bih->biWidth);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
208 printf(" biHeight %ld\n", output_bih->biHeight);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
209 printf(" biPlanes %d\n", output_bih->biPlanes);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
210 printf(" biBitCount %d\n", output_bih->biBitCount);
25262
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
211 printf(" biCompression 0x%lx ('%.4s')\n", output_bih->biCompression, (char *)&output_bih->biCompression);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
212 printf(" biSizeImage %ld\n", output_bih->biSizeImage);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
213 // }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
214
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
215 output_bih->biWidth=input_bih->biWidth;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
216 output_bih->biHeight=input_bih->biHeight;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
217
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
218 ret = ICCompressQuery(encoder_hic, input_bih, output_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
219 if(ret){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
220 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressQuery failed: Error %d\n", (int)ret);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
221 return 0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
222 } else
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
223 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressQuery OK\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
224
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
225 ret = ICCompressBegin(encoder_hic, input_bih, output_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
226 if(ret){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
227 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressBegin failed: Error %d\n", (int)ret);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
228 // return 0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
229 } else
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
230 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressBegin OK\n");
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
231 mp_msg(MSGT_WIN32,MSGL_INFO," Output format after query/begin:\n");
25262
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
232 mp_msg(MSGT_WIN32,MSGL_INFO," biSize %ld\n", output_bih->biSize);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
233 mp_msg(MSGT_WIN32,MSGL_INFO," biWidth %ld\n", output_bih->biWidth);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
234 mp_msg(MSGT_WIN32,MSGL_INFO," biHeight %ld\n", output_bih->biHeight);
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
235 mp_msg(MSGT_WIN32,MSGL_INFO," biPlanes %d\n", output_bih->biPlanes);
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
236 mp_msg(MSGT_WIN32,MSGL_INFO," biBitCount %d\n", output_bih->biBitCount);
25262
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
237 mp_msg(MSGT_WIN32,MSGL_INFO," biCompression 0x%lx ('%.4s')\n", output_bih->biCompression, (char *)&output_bih->biCompression);
f1922d2b1925 Use correct printf length modifiers, fixes the following warnings:
diego
parents: 24770
diff changeset
238 mp_msg(MSGT_WIN32,MSGL_INFO," biSizeImage %ld\n", output_bih->biSizeImage);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26148
diff changeset
239
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
240 encoder_buf_size=input_bih->biSizeImage;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
241 encoder_buf=malloc(encoder_buf_size);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
242 encoder_frameno=0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
243
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
244 mp_msg(MSGT_WIN32,MSGL_V,"VIDEO CODEC Init OK!!! ;-)\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
245 return 1;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
246 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
247
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
248 static int vfw_encode_frame(BITMAPINFOHEADER* biOutput,void* OutBuf,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
249 BITMAPINFOHEADER* biInput,void* Image,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
250 long* keyframe, int quality){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
251 HRESULT ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
252
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
253 //long VFWAPIV ICCompress(
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
254 // HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
255 // LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
256 // long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
257 // LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
258 //);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
259
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
260 // printf("vfw_encode_frame(%p,%p, %p,%p, %p,%d)\n",biOutput,OutBuf,biInput,Image,keyframe,quality);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
261
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
262 ret=ICCompress(encoder_hic, 0,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
263 biOutput, OutBuf,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
264 biInput, Image,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
265 NULL, keyframe, encoder_frameno, 0, quality,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
266 biInput, encoder_buf);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
267
26148
d3b951d9b4d3 Fix printf format string mismatch, eliminates the warning:
diego
parents: 26146
diff changeset
268 // printf("ok. size=%ld\n",biOutput->biSizeImage);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
269
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
270 memcpy(encoder_buf,Image,encoder_buf_size);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
271 ++encoder_frameno;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
272
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
273 return (int)ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
274 }
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
275 #define mux_v (vf->priv->mux)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
276 #define vfw_bih (vf->priv->bih)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
277
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30566
diff changeset
278 static int config(struct vf_instance *vf,
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
279 int width, int height, int d_width, int d_height,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
280 unsigned int flags, unsigned int outfmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
281
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
282 vfw_bih->biWidth=width;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
283 vfw_bih->biHeight=height;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
284 vfw_bih->biSizeImage=width*height*((vfw_bih->biBitCount+7)/8);
12061
656a1b45b309 Use aspect from encoder for AVI vprp header
ranma
parents: 10594
diff changeset
285 mux_v->aspect = (float)d_width/d_height;
5551
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
286
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
287 if(!vfw_start_encoder(vfw_bih, mux_v->bih)) return 0;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
288
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
289 // mux_v->bih->biWidth=width;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
290 // mux_v->bih->biHeight=height;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
291 // mux_v->bih->biSizeImage=width*height*((mux_v->bih->biBitCount+7)/8);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
292
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
293 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
294 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
295
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30566
diff changeset
296 static int control(struct vf_instance *vf, int request, void* data){
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
297
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
298 return CONTROL_UNKNOWN;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
299 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
300
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30566
diff changeset
301 static int query_format(struct vf_instance *vf, unsigned int fmt){
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14878
diff changeset
302 if(fmt==IMGFMT_BGR24) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIPPED;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
303 return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
304 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
305
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30566
diff changeset
306 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
307 long flags=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
308 int ret;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
309 // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
310 ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
311 // if (ret != ICERR_OK)
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
312 // return 0;
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17487
diff changeset
313 muxer_write_chunk(mux_v,mux_v->bih->biSizeImage,flags, pts, pts);
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7238
diff changeset
314 return 1;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
315 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
316
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30566
diff changeset
317 static void uninit(struct vf_instance *vf)
24770
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
318 {
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
319 HRESULT ret;
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
320
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
321 if(encoder_hic){
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
322 if(encoder_buf){
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
323 ret=ICCompressEnd(encoder_hic);
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
324 if(ret) mp_msg(MSGT_WIN32, MSGL_WARN, "ICCompressEnd failed: %ld\n", ret);
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
325 free(encoder_buf);
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
326 encoder_buf=NULL;
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
327 }
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
328 ret=ICClose(encoder_hic);
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
329 if(ret) mp_msg(MSGT_WIN32, MSGL_WARN, "ICClose failed: %ld\n", ret);
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
330 encoder_hic=0;
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
331 if ((CoInitRes == S_OK) || (CoInitRes == S_FALSE)) CoUninitialize();
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
332 }
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
333 }
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
334
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
335 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
336
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
337 static int vf_open(vf_instance_t *vf, char* args){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
338 vf->config=config;
14878
5723c4b2a2ea fixes for encoding of multiple files
henry
parents: 14549
diff changeset
339 vf->default_caps=VFCAP_CONSTANT;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
340 vf->control=control;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
341 vf->query_format=query_format;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
342 vf->put_image=put_image;
24770
6a8be4b73d07 Add Coinitialize function to vfw encoder and win32 loader.
compn
parents: 22799
diff changeset
343 vf->uninit=uninit;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
344 vf->priv=malloc(sizeof(struct vf_priv_s));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
345 memset(vf->priv,0,sizeof(struct vf_priv_s));
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
346 vf->priv->mux=(muxer_stream_t*)args;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
347
14549
acf3241be19b Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents: 12061
diff changeset
348 vfw_bih=calloc(1, sizeof(BITMAPINFOHEADER));
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
349 vfw_bih->biSize=sizeof(BITMAPINFOHEADER);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
350 vfw_bih->biWidth=0; // FIXME ?
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
351 vfw_bih->biHeight=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
352 vfw_bih->biPlanes=1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
353 vfw_bih->biBitCount=24;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
354 vfw_bih->biCompression=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
355 // vfw_bih->biSizeImage=vo_w*vo_h*((vfw_bih->biBitCount+7)/8);
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
356
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
357 if (!vfw_param_codec)
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
358 {
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
359 mp_msg(MSGT_WIN32,MSGL_WARN, MSGTR_MPCODECS_NoVfwCodecSpecified);
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
360 return 0;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
361 }
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
362 // mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3'));
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
363 // mux_v->bih=vfw_open_encoder("AvidAVICodec.dll",vfw_bih, 0);
22252
c5a591c4a372 Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents: 21660
diff changeset
364 mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_param_compdata, vfw_bih, 0);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
365 if(!mux_v->bih) return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
366
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
367 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
368 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
369
32033
c42345605c7a Mark video encoder vf_info_t structs as const.
diego
parents: 30955
diff changeset
370 const vf_info_t ve_info_vfw = {
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
371 "Win32/VfW encoders",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
372 "vfw",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
373 "A'rpi",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
374 "for internal use by mencoder",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
375 vf_open
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
376 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
377
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
378 //===========================================================================//