annotate libmpcodecs/ve_vfw.c @ 8795:b4512aa07711

mosu: Fixed OGG/OGM seeking for XCDs in which the OGG/OGM does not start at pos 0 in the stream
author mosu
date Sun, 05 Jan 2003 13:48:13 +0000
parents 27da710563c2
children c671e9adbe22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
1 #include <stdio.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
2 #include <stdlib.h>
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
3 #include <string.h>
7238
6f44ed6c4568 FreeBSD fix
nexus
parents: 7231
diff changeset
4 #include <unistd.h>
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
5 #include <inttypes.h>
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
6
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
7 #include "../config.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
8 #ifdef USE_WIN32DLL
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
9
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
10 #include "../mp_msg.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
11
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
12 #include "codec-cfg.h"
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
13 //#include "stream.h"
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
14 //#include "demuxer.h"
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
15 //#include "stheader.h"
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
16
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
17 #include "loader.h"
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
18 //#include "wine/mmreg.h"
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
19 #include "wine/vfw.h"
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
20 #include "wine/avifmt.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
21
5607
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
22 #include "img_format.h"
1972c3475d93 mp_image.h and img_format.h moved to libmpcodecs
arpi
parents: 5565
diff changeset
23 #include "mp_image.h"
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
24 #include "vf.h"
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
25
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
26 #include "muxer.h"
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
27
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
28 extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 6083
diff changeset
29
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
30 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
31
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
32 static char *vfw_param_codec = NULL;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
33
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
34 #include "cfgparser.h"
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
35
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
36 struct config vfwopts_conf[]={
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
37 {"codec", &vfw_param_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
38 {NULL, NULL, 0, 0, 0, 0, NULL}
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
39 };
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
40
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
41 struct vf_priv_s {
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8123
diff changeset
42 muxer_stream_t* mux;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
43 BITMAPINFOHEADER* bih;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
44 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
45
7557
f296ff05bcd0 warning fixes
arpi
parents: 7390
diff changeset
46 static HIC encoder_hic;
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
47 static void* encoder_buf=NULL;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
48 static int encoder_buf_size=0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
49 static int encoder_frameno=0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
50
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
51 //int init_vfw_encoder(char *dll_name, BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih)
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
52 static BITMAPINFOHEADER* vfw_open_encoder(char *dll_name, BITMAPINFOHEADER *input_bih,unsigned int out_fourcc)
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
53 {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
54 HRESULT ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
55 BITMAPINFOHEADER* output_bih=NULL;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
56 int temp_len;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
57
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
58 //sh_video = malloc(sizeof(sh_video_t));
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
59
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
60 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Encoder init =======\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
61
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
62 // memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER));
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
63 // output_bih->biSize = sizeof(BITMAPINFOHEADER);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
64
7390
2357ee501582 fixed to comply with new loader
alex
parents: 7368
diff changeset
65 // encoder_hic = ICOpen( 0x63646976, out_fourcc, ICMODE_COMPRESS);
7557
f296ff05bcd0 warning fixes
arpi
parents: 7390
diff changeset
66 encoder_hic = ICOpen( (long) dll_name, out_fourcc, ICMODE_COMPRESS);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
67 if(!encoder_hic){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
68 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
69 return NULL;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
70 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
71 printf("HIC: %x\n", encoder_hic);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
72
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
73 #if 1
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
74 {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
75 ICINFO icinfo;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
76
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
77 ret = ICGetInfo(encoder_hic, &icinfo, sizeof(ICINFO));
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
78 printf("%ld - %ld - %d\n", ret, icinfo.dwSize, sizeof(ICINFO));
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
79 printf("Compressor type: %.4lx\n", icinfo.fccType);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
80 printf("Compressor subtype: %.4lx\n", icinfo.fccHandler);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
81 printf("Compressor flags: %lu, version %lu, ICM version: %lu\n",
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
82 icinfo.dwFlags, icinfo.dwVersion, icinfo.dwVersionICM);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
83 //printf("Compressor name: %s\n", icinfo.szName);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
84 //printf("Compressor description: %s\n", icinfo.szDescription);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
85
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
86 printf("Flags:");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
87 if (icinfo.dwFlags & VIDCF_QUALITY)
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
88 printf(" quality");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
89 if (icinfo.dwFlags & VIDCF_FASTTEMPORALD)
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
90 printf(" fast-decompr");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
91 if (icinfo.dwFlags & VIDCF_QUALITYTIME)
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
92 printf(" temp-quality");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
93 printf("\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
94 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
95 #endif
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
96
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
97 temp_len = ICCompressGetFormatSize(encoder_hic, input_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
98 printf("ICCompressGetFormatSize ret: %d\n", temp_len);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
99
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
100 if (temp_len < sizeof(BITMAPINFOHEADER)) temp_len=sizeof(BITMAPINFOHEADER);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
101
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
102 output_bih = malloc(temp_len+4);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
103 memset(output_bih,0,temp_len);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
104 output_bih->biSize = temp_len; //sizeof(BITMAPINFOHEADER);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
105
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
106 return output_bih;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
107 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
108
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
109 static int vfw_start_encoder(BITMAPINFOHEADER *input_bih, BITMAPINFOHEADER *output_bih){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
110 HRESULT ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
111 int temp_len=output_bih->biSize;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
112 int i;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
113
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
114 ret = ICCompressGetFormat(encoder_hic, input_bih, output_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
115 if(ret < 0){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
116 unsigned char* temp=(unsigned char*)output_bih;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
117 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
118 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
119 return 0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
120 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
121 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressGetFormat OK\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
122
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
123 if (temp_len > sizeof(BITMAPINFOHEADER))
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
124 {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
125 unsigned char* temp=(unsigned char*)output_bih;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
126 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
127 temp_len-sizeof(BITMAPINFOHEADER));
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
128 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
129 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
130
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
131 // if(verbose) {
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
132 printf("Starting compression:\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
133 printf(" Input format:\n");
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
134 printf(" biSize %d\n", input_bih->biSize);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
135 printf(" biWidth %d\n", input_bih->biWidth);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
136 printf(" biHeight %d\n", input_bih->biHeight);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
137 printf(" biPlanes %d\n", input_bih->biPlanes);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
138 printf(" biBitCount %d\n", input_bih->biBitCount);
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
139 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
140 printf(" biSizeImage %d\n", input_bih->biSizeImage);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
141 printf(" Output format:\n");
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
142 printf(" biSize %d\n", output_bih->biSize);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
143 printf(" biWidth %d\n", output_bih->biWidth);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
144 printf(" biHeight %d\n", output_bih->biHeight);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
145 printf(" biPlanes %d\n", output_bih->biPlanes);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
146 printf(" biBitCount %d\n", output_bih->biBitCount);
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
147 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
148 printf(" biSizeImage %d\n", output_bih->biSizeImage);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
149 // }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
150
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
151 output_bih->biWidth=input_bih->biWidth;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
152 output_bih->biHeight=input_bih->biHeight;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
153
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
154 ret = ICCompressQuery(encoder_hic, input_bih, output_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
155 if(ret){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
156 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressQuery failed: Error %d\n", (int)ret);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
157 return 0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
158 } else
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
159 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressQuery OK\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
160
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
161 ret = ICCompressBegin(encoder_hic, input_bih, output_bih);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
162 if(ret){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
163 mp_msg(MSGT_WIN32,MSGL_ERR,"ICCompressBegin failed: Error %d\n", (int)ret);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
164 // return 0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
165 } else
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
166 mp_msg(MSGT_WIN32,MSGL_V,"ICCompressBegin OK\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
167
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
168 printf(" Output format after query/begin:\n");
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
169 printf(" biSize %d\n", output_bih->biSize);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
170 printf(" biWidth %d\n", output_bih->biWidth);
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
171 printf(" biHeight %d\n", output_bih->biHeight);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
172 printf(" biPlanes %d\n", output_bih->biPlanes);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
173 printf(" biBitCount %d\n", output_bih->biBitCount);
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7557
diff changeset
174 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
175 printf(" biSizeImage %d\n", output_bih->biSizeImage);
7231
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
176
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
177 encoder_buf_size=input_bih->biSizeImage;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
178 encoder_buf=malloc(encoder_buf_size);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
179 encoder_frameno=0;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
180
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
181 mp_msg(MSGT_WIN32,MSGL_V,"VIDEO CODEC Init OK!!! ;-)\n");
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
182 return 1;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
183 }
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
184
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
185 static int vfw_encode_frame(BITMAPINFOHEADER* biOutput,void* OutBuf,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
186 BITMAPINFOHEADER* biInput,void* Image,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
187 long* keyframe, int quality){
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
188 HRESULT ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
189
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
190 //long VFWAPIV ICCompress(
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
191 // HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpOutputBuf,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
192 // LPBITMAPINFOHEADER lpbiInput,void* lpImage,long* lpckid,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
193 // long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
194 // LPBITMAPINFOHEADER lpbiInputPrev,void* lpImagePrev
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
195 //);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
196
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
197 // 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
198
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
199 ret=ICCompress(encoder_hic, 0,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
200 biOutput, OutBuf,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
201 biInput, Image,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
202 NULL, keyframe, encoder_frameno, 0, quality,
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
203 biInput, encoder_buf);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
204
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
205 // printf("ok. size=%d\n",biOutput->biSizeImage);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
206
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
207 memcpy(encoder_buf,Image,encoder_buf_size);
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
208 ++encoder_frameno;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
209
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
210 return (int)ret;
1e84415320d8 merged with dll_init.c
alex
parents: 7127
diff changeset
211 }
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
212 #define mux_v (vf->priv->mux)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
213 #define vfw_bih (vf->priv->bih)
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
214
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
215 static int config(struct vf_instance_s* vf,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
216 int width, int height, int d_width, int d_height,
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
217 unsigned int flags, unsigned int outfmt){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
218
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
219 vfw_bih->biWidth=width;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
220 vfw_bih->biHeight=height;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
221 vfw_bih->biSizeImage=width*height*((vfw_bih->biBitCount+7)/8);
5551
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
222
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
223 if(!vfw_start_encoder(vfw_bih, mux_v->bih)) return 0;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
224
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
225 // mux_v->bih->biWidth=width;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
226 // mux_v->bih->biHeight=height;
73978162b6a1 soem fixes
arpi
parents: 5550
diff changeset
227 // mux_v->bih->biSizeImage=width*height*((mux_v->bih->biBitCount+7)/8);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
228
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
229 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
230 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
231
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
232 static int control(struct vf_instance_s* vf, int request, void* data){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
233
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
234 return CONTROL_UNKNOWN;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
235 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
236
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
237 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
5565
0b301fec999a capabilities support -> automatic insertion of scale, expand, pp
arpi
parents: 5551
diff changeset
238 if(fmt==IMGFMT_BGR24) return 3 | VFCAP_FLIPPED;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
239 return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
240 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
241
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7238
diff changeset
242 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
243 long flags=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
244 int ret;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
245 // flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
246 ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
247 mencoder_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
7368
a894e99c1e51 changing return type of put_image void->int
arpi
parents: 7238
diff changeset
248 return 1;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
249 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
250
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
251 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
252
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
253 static int vf_open(vf_instance_t *vf, char* args){
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
254 vf->config=config;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
255 vf->control=control;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
256 vf->query_format=query_format;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
257 vf->put_image=put_image;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
258 vf->priv=malloc(sizeof(struct vf_priv_s));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
259 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
260 vf->priv->mux=(muxer_stream_t*)args;
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
261
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
262 vfw_bih=malloc(sizeof(BITMAPINFOHEADER));
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
263 vfw_bih->biSize=sizeof(BITMAPINFOHEADER);
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
264 vfw_bih->biWidth=0; // FIXME ?
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
265 vfw_bih->biHeight=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
266 vfw_bih->biPlanes=1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
267 vfw_bih->biBitCount=24;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
268 vfw_bih->biCompression=0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
269 // vfw_bih->biSizeImage=vo_w*vo_h*((vfw_bih->biBitCount+7)/8);
6083
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
270
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
271 if (!vfw_param_codec)
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
272 {
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
273 printf("No VfW codec specified! It's required!\n");
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
274 return 0;
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
275 }
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
276 // 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
277 // mux_v->bih=vfw_open_encoder("AvidAVICodec.dll",vfw_bih, 0);
6aa4fc282fc7 added support for codec selection
alex
parents: 5607
diff changeset
278 mux_v->bih = vfw_open_encoder(vfw_param_codec, vfw_bih, 0);
5550
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
279 if(!mux_v->bih) return 0;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
280
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
281 return 1;
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
282 }
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
283
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
284 vf_info_t ve_info_vfw = {
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
285 "Win32/VfW encoders",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
286 "vfw",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
287 "A'rpi",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
288 "for internal use by mencoder",
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
289 vf_open
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
290 };
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
291
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
292 //===========================================================================//
7d1dfb59c6c0 encoders
arpi
parents:
diff changeset
293 #endif