Mercurial > mplayer.hg
annotate libmpcodecs/ve_vfw.c @ 22266:273a5ecea962
dont set 0 nBlockAlign
author | michael |
---|---|
date | Tue, 20 Feb 2007 16:16:53 +0000 |
parents | c5a591c4a372 |
children | a033e5519802 |
rev | line source |
---|---|
5550 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
7238 | 4 #include <unistd.h> |
8585 | 5 #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
|
6 #include <sys/stat.h> |
5550 | 7 |
17012 | 8 #include "config.h" |
5550 | 9 |
17012 | 10 #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
|
11 #include "help_mp.h" |
5550 | 12 |
13 #include "codec-cfg.h" | |
7231 | 14 //#include "stream.h" |
15 //#include "demuxer.h" | |
16 //#include "stheader.h" | |
17 | |
18 #include "loader.h" | |
19 //#include "wine/mmreg.h" | |
20 #include "wine/vfw.h" | |
21 #include "wine/avifmt.h" | |
5550 | 22 |
5607 | 23 #include "img_format.h" |
24 #include "mp_image.h" | |
5550 | 25 #include "vf.h" |
26 | |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
18771
diff
changeset
|
27 #include "stream.h" |
8585 | 28 #include "muxer.h" |
29 | |
5550 | 30 //===========================================================================// |
31 | |
6083 | 32 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
|
33 static char *vfw_param_compdata = NULL; |
6083 | 34 |
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
|
35 #include "m_option.h" |
6083 | 36 |
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
|
37 m_option_t vfwopts_conf[]={ |
6083 | 38 {"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
|
39 {"compdata", &vfw_param_compdata, CONF_TYPE_STRING, 0, 0, 0, NULL}, |
6083 | 40 {NULL, NULL, 0, 0, 0, 0, NULL} |
41 }; | |
42 | |
5550 | 43 struct vf_priv_s { |
8585 | 44 muxer_stream_t* mux; |
5550 | 45 BITMAPINFOHEADER* bih; |
46 }; | |
47 | |
7557 | 48 static HIC encoder_hic; |
7231 | 49 static void* encoder_buf=NULL; |
50 static int encoder_buf_size=0; | |
51 static int encoder_frameno=0; | |
52 | |
53 //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
|
54 static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, char *compdatafile, BITMAPINFOHEADER *input_bih,unsigned int out_fourcc) |
7231 | 55 { |
56 HRESULT ret; | |
57 BITMAPINFOHEADER* output_bih=NULL; | |
58 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
|
59 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
|
60 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
|
61 struct stat st; |
7231 | 62 |
63 //sh_video = malloc(sizeof(sh_video_t)); | |
64 | |
65 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n"); | |
66 | |
67 // memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER)); | |
68 // output_bih->biSize = sizeof(BITMAPINFOHEADER); | |
69 | |
7390 | 70 // encoder_hic = ICOpen( 0x63646976, out_fourcc, ICMODE_COMPRESS); |
7557 | 71 encoder_hic = ICOpen( (long) dll_name, out_fourcc, ICMODE_COMPRESS); |
7231 | 72 if(!encoder_hic){ |
73 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n"); | |
74 return NULL; | |
75 } | |
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
|
76 mp_msg(MSGT_WIN32,MSGL_INFO,"HIC: %x\n", encoder_hic); |
7231 | 77 |
78 #if 1 | |
79 { | |
80 ICINFO icinfo; | |
81 | |
82 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
|
83 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
|
84 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
|
85 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
|
86 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_CompressorFlags, |
7231 | 87 icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM); |
88 //printf("Compressor name: %s\n", icinfo.szName); | |
89 //printf("Compressor description: %s\n", icinfo.szDescription); | |
90 | |
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
|
91 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Flags); |
7231 | 92 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
|
93 mp_msg(MSGT_WIN32,MSGL_INFO,MSGTR_MPCODECS_Quality); |
7231 | 94 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
|
95 mp_msg(MSGT_WIN32,MSGL_INFO," fast-decompr"); |
7231 | 96 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
|
97 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
|
98 mp_msg(MSGT_WIN32,MSGL_INFO,"\n"); |
7231 | 99 } |
100 #endif | |
101 | |
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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 } |
c5a591c4a372
Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents:
21660
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 } |
c5a591c4a372
Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents:
21660
diff
changeset
|
112 } |
c5a591c4a372
Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents:
21660
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 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
|
117 } |
c5a591c4a372
Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents:
21660
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 } |
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 drvdata = (char *) malloc(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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 } |
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 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 } |
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 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
|
139 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
|
140 } |
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 } |
c5a591c4a372
Controllable quality setting of VFW enconding, through the dumped state of the dialog box. Patch by Gianluigi Tiesi
alex
parents:
21660
diff
changeset
|
142 |
7231 | 143 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
|
144 mp_msg(MSGT_WIN32,MSGL_INFO,"ICCompressGetFormatSize ret: %d\n", temp_len); |
7231 | 145 |
146 if (temp_len < sizeof(BITMAPINFOHEADER)) temp_len=sizeof(BITMAPINFOHEADER); | |
147 | |
148 output_bih = malloc(temp_len+4); | |
149 memset(output_bih,0,temp_len); | |
150 output_bih->biSize = temp_len; //sizeof(BITMAPINFOHEADER); | |
151 | |
152 return output_bih; | |
153 } | |
154 | |
155 static int vfw_start_encoder(BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih){ | |
156 HRESULT ret; | |
157 int temp_len=output_bih->biSize; | |
158 int i; | |
159 | |
160 ret = ICCompressGetFormat(encoder_hic, input_bih, output_bih); | |
161 if(ret < 0){ | |
162 unsigned char* temp=(unsigned char*)output_bih; | |
163 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressGetFormat failed: Error %d (0x%X)\n", (int)ret, (int)ret); | |
164 for (i=0; i < temp_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", temp[i]); | |
165 return 0; | |
166 } | |
167 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressGetFormat OK\n"); | |
168 | |
169 if (temp_len > sizeof(BITMAPINFOHEADER)) | |
170 { | |
171 unsigned char* temp=(unsigned char*)output_bih; | |
172 mp_msg(MSGT_WIN32, MSGL_V, "Extra info in o_bih (%d bytes)!\n", | |
173 temp_len-sizeof(BITMAPINFOHEADER)); | |
174 for(i=sizeof(output_bih);i<temp_len;i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02X ",temp[i]); | |
175 } | |
176 | |
17969
843e0427b5b9
Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents:
17906
diff
changeset
|
177 // if( mp_msg_test(MSGT_WIN32,MSGL_V) ) { |
7231 | 178 printf("Starting compression:\n"); |
179 printf(" Input format:\n"); | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
180 printf(" biSize %d\n", input_bih->biSize); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
181 printf(" biWidth %d\n", input_bih->biWidth); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
182 printf(" biHeight %d\n", input_bih->biHeight); |
7231 | 183 printf(" biPlanes %d\n", input_bih->biPlanes); |
184 printf(" biBitCount %d\n", input_bih->biBitCount); | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
185 printf(" biCompression 0x%x ('%.4s')\n", input_bih->biCompression, (char *)&input_bih->biCompression); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
186 printf(" biSizeImage %d\n", input_bih->biSizeImage); |
7231 | 187 printf(" Output format:\n"); |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
188 printf(" biSize %d\n", output_bih->biSize); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
189 printf(" biWidth %d\n", output_bih->biWidth); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
190 printf(" biHeight %d\n", output_bih->biHeight); |
7231 | 191 printf(" biPlanes %d\n", output_bih->biPlanes); |
192 printf(" biBitCount %d\n", output_bih->biBitCount); | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
193 printf(" biCompression 0x%x ('%.4s')\n", output_bih->biCompression, (char *)&output_bih->biCompression); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7557
diff
changeset
|
194 printf(" biSizeImage %d\n", output_bih->biSizeImage); |
7231 | 195 // } |
196 | |
197 output_bih->biWidth=input_bih->biWidth; | |
198 output_bih->biHeight=input_bih->biHeight; | |
199 | |
200 ret = ICCompressQuery(encoder_hic, input_bih, output_bih); | |
201 if(ret){ | |
202 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressQuery failed: Error %d\n", (int)ret); | |
203 return 0; | |
204 } else | |
205 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressQuery OK\n"); | |
206 | |
207 ret = ICCompressBegin(encoder_hic, input_bih, output_bih); | |
208 if(ret){ | |
209 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressBegin failed: Error %d\n", (int)ret); | |
210 // return 0; | |
211 } 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
|
212 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
|
213 mp_msg(MSGT_WIN32,MSGL_INFO," Output format after query/begin:\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
|
214 mp_msg(MSGT_WIN32,MSGL_INFO," biSize %d\n", output_bih->biSize); |
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
|
215 mp_msg(MSGT_WIN32,MSGL_INFO," biWidth %d\n", output_bih->biWidth); |
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
|
216 mp_msg(MSGT_WIN32,MSGL_INFO," biHeight %d\n", output_bih->biHeight); |
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
|
217 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
|
218 mp_msg(MSGT_WIN32,MSGL_INFO," biBitCount %d\n", output_bih->biBitCount); |
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
|
219 mp_msg(MSGT_WIN32,MSGL_INFO," biCompression 0x%x ('%.4s')\n", output_bih->biCompression, (char *)&output_bih->biCompression); |
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
|
220 mp_msg(MSGT_WIN32,MSGL_INFO," biSizeImage %d\n", output_bih->biSizeImage); |
7231 | 221 |
222 encoder_buf_size=input_bih->biSizeImage; | |
223 encoder_buf=malloc(encoder_buf_size); | |
224 encoder_frameno=0; | |
225 | |
226 mp_msg(MSGT_WIN32,MSGL_V,"VIDEO CODEC Init OK!!! ;-)\n"); | |
227 return 1; | |
228 } | |
229 | |
230 static int vfw_encode_frame(BITMAPINFOHEADER* biOutput,void* OutBuf, | |
231 BITMAPINFOHEADER* biInput,void* Image, | |
232 long* keyframe, int quality){ | |
233 HRESULT ret; | |
234 | |
235 //long VFWAPIV ICCompress( | |
236 // HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf, | |
237 // LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid, | |
238 // long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality, | |
239 // LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev | |
240 //); | |
241 | |
242 // printf("vfw_encode_frame(%p,%p, %p,%p, %p,%d)\n",biOutput,OutBuf,biInput,Image,keyframe,quality); | |
243 | |
244 ret=ICCompress(encoder_hic, 0, | |
245 biOutput, OutBuf, | |
246 biInput, Image, | |
247 NULL, keyframe, encoder_frameno, 0, quality, | |
248 biInput, encoder_buf); | |
249 | |
250 // printf("ok. size=%d\n",biOutput->biSizeImage); | |
251 | |
252 memcpy(encoder_buf,Image,encoder_buf_size); | |
253 ++encoder_frameno; | |
254 | |
255 return (int)ret; | |
256 } | |
5550 | 257 #define mux_v (vf->priv->mux) |
258 #define vfw_bih (vf->priv->bih) | |
259 | |
260 static int config(struct vf_instance_s* vf, | |
261 int width, int height, int d_width, int d_height, | |
262 unsigned int flags, unsigned int outfmt){ | |
263 | |
264 vfw_bih->biWidth=width; | |
265 vfw_bih->biHeight=height; | |
266 vfw_bih->biSizeImage=width*height*((vfw_bih->biBitCount+7)/8); | |
12061 | 267 mux_v->aspect = (float)d_width/d_height; |
5551 | 268 |
269 if(!vfw_start_encoder(vfw_bih, mux_v->bih)) return 0; | |
270 | |
271 // mux_v->bih->biWidth=width; | |
272 // mux_v->bih->biHeight=height; | |
273 // mux_v->bih->biSizeImage=width*height*((mux_v->bih->biBitCount+7)/8); | |
5550 | 274 |
275 return 1; | |
276 } | |
277 | |
278 static int control(struct vf_instance_s* vf, int request, void* data){ | |
279 | |
280 return CONTROL_UNKNOWN; | |
281 } | |
282 | |
283 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
14878
diff
changeset
|
284 if(fmt==IMGFMT_BGR24) return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIPPED; |
5550 | 285 return 0; |
286 } | |
287 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17487
diff
changeset
|
288 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5550 | 289 long flags=0; |
290 int ret; | |
291 // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack | |
292 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
|
293 // 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
|
294 // 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
|
295 muxer_write_chunk(mux_v,mux_v->bih->biSizeImage,flags, pts, pts); |
7368 | 296 return 1; |
5550 | 297 } |
298 | |
299 //===========================================================================// | |
300 | |
301 static int vf_open(vf_instance_t *vf, char* args){ | |
302 vf->config=config; | |
14878 | 303 vf->default_caps=VFCAP_CONSTANT; |
5550 | 304 vf->control=control; |
305 vf->query_format=query_format; | |
306 vf->put_image=put_image; | |
307 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
308 memset(vf->priv,0,sizeof(struct vf_priv_s)); | |
8585 | 309 vf->priv->mux=(muxer_stream_t*)args; |
5550 | 310 |
14549
acf3241be19b
Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents:
12061
diff
changeset
|
311 vfw_bih=calloc(1, sizeof(BITMAPINFOHEADER)); |
5550 | 312 vfw_bih->biSize=sizeof(BITMAPINFOHEADER); |
313 vfw_bih->biWidth=0; // FIXME ? | |
314 vfw_bih->biHeight=0; | |
315 vfw_bih->biPlanes=1; | |
316 vfw_bih->biBitCount=24; | |
317 vfw_bih->biCompression=0; | |
318 // vfw_bih->biSizeImage=vo_w*vo_h*((vfw_bih->biBitCount+7)/8); | |
6083 | 319 |
320 if (!vfw_param_codec) | |
321 { | |
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
|
322 mp_msg(MSGT_WIN32,MSGL_WARN, MSGTR_MPCODECS_NoVfwCodecSpecified); |
6083 | 323 return 0; |
324 } | |
5550 | 325 // mux_v->bih=vfw_open_encoder("divxc32.dll",vfw_bih,mmioFOURCC('D', 'I', 'V', '3')); |
6083 | 326 // 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
|
327 mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_param_compdata, vfw_bih, 0); |
5550 | 328 if(!mux_v->bih) return 0; |
329 | |
330 return 1; | |
331 } | |
332 | |
333 vf_info_t ve_info_vfw = { | |
334 "Win32/VfW encoders", | |
335 "vfw", | |
336 "A'rpi", | |
337 "for internal use by mencoder", | |
338 vf_open | |
339 }; | |
340 | |
341 //===========================================================================// |