Mercurial > mplayer.hg
annotate libmpcodecs/vd_vfw.c @ 25194:e816d546c4fe
ao_null: Make duration of "buffered" audio constant
Choose the "buffer size" for the amount of audio the driver accepts so
that it corresponds to about 0.2 seconds of playback based on the
number of channels, sample size and samplerate.
author | uau |
---|---|
date | Sat, 01 Dec 2007 01:39:39 +0000 |
parents | d555579c8c98 |
children | 9e739bdb049c |
rev | line source |
---|---|
4968 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "config.h" | |
5 #include "mp_msg.h" | |
6 #include "help_mp.h" | |
7 | |
7471 | 8 #include "vd_internal.h" |
9 | |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
18771
diff
changeset
|
10 #include "loader/wine/driver.h" |
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
18771
diff
changeset
|
11 #include "loader/wine/vfw.h" |
4968 | 12 |
7176 | 13 static vd_info_t info = { |
7260 | 14 #ifdef BUILD_VFWEX |
15 "Win32/VfWex video codecs", | |
16 "vfwex", | |
17 #else | |
4968 | 18 "Win32/VfW video codecs", |
19 "vfw", | |
7260 | 20 #endif |
7229 | 21 "A'rpi & Alex", |
7260 | 22 "avifile.sf.net", |
4968 | 23 "win32 codecs" |
24 }; | |
25 | |
7260 | 26 #ifdef BUILD_VFWEX |
27 LIBVD_EXTERN(vfwex) | |
28 #else | |
4968 | 29 LIBVD_EXTERN(vfw) |
7260 | 30 #endif |
4968 | 31 |
7229 | 32 typedef struct { |
33 BITMAPINFOHEADER *o_bih; | |
34 HIC handle; | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
35 unsigned char *palette; |
7229 | 36 } vd_vfw_ctx; |
37 | |
38 static int vfw_set_postproc(sh_video_t* sh, int quality) | |
39 { | |
40 vd_vfw_ctx *priv = sh->context; | |
41 // Works only with opendivx/divx4 based DLL | |
7273 | 42 return ICSendMessage(priv->handle, ICM_USER+80, (long)(&quality), 0); |
7229 | 43 } |
44 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
45 static void set_csp(BITMAPINFOHEADER *o_bih,unsigned int outfmt){ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
46 int yuv = 0; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
47 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
48 switch (outfmt) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
49 { |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
50 /* planar format */ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
51 case IMGFMT_YV12: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
52 case IMGFMT_I420: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
53 case IMGFMT_IYUV: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
54 o_bih->biBitCount=12; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
55 yuv=1; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
56 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
57 case IMGFMT_YVU9: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
58 case IMGFMT_IF09: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
59 o_bih->biBitCount=9; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
60 yuv=1; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
61 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
62 /* packed format */ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
63 case IMGFMT_YUY2: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
64 case IMGFMT_UYVY: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
65 case IMGFMT_YVYU: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
66 o_bih->biBitCount=16; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
67 yuv=1; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
68 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
69 /* rgb/bgr format */ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
70 case IMGFMT_RGB8: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
71 case IMGFMT_BGR8: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
72 o_bih->biBitCount=8; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
73 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
74 case IMGFMT_RGB15: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
75 case IMGFMT_RGB16: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
76 case IMGFMT_BGR15: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
77 case IMGFMT_BGR16: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
78 o_bih->biBitCount=16; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
79 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
80 case IMGFMT_RGB24: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
81 case IMGFMT_BGR24: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
82 o_bih->biBitCount=24; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
83 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
84 case IMGFMT_RGB32: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
85 case IMGFMT_BGR32: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
86 o_bih->biBitCount=32; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
87 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
88 default: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
89 mp_msg(MSGT_WIN32,MSGL_ERR,"Unsupported image format: %s\n", vo_format_name(outfmt)); |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
90 return; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
91 } |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
92 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
93 o_bih->biSizeImage = abs(o_bih->biWidth * o_bih->biHeight * (o_bih->biBitCount/8)); |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
94 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
95 // Note: we cannot rely on sh->outfmtidx here, it's undefined at this stage!!! |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
96 // if (yuv && !(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK)) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
97 if (yuv) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
98 o_bih->biCompression = outfmt; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
99 else |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
100 o_bih->biCompression = 0; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
101 } |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
102 |
4968 | 103 // to set/get/query special features/parameters |
104 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
105 vd_vfw_ctx *priv = sh->context; |
4968 | 106 switch(cmd){ |
107 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
108 return 9; | |
109 case VDCTRL_SET_PP_LEVEL: | |
110 vfw_set_postproc(sh,10*(*((int*)arg))); | |
111 return CONTROL_OK; | |
7262
5fc42290c305
enabled csp-query support, but only for formats with 'query' flag set
arpi
parents:
7260
diff
changeset
|
112 #if 1 |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
113 // FIXME: make this optional... |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
114 case VDCTRL_QUERY_FORMAT: |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
115 { |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
116 HRESULT ret; |
7262
5fc42290c305
enabled csp-query support, but only for formats with 'query' flag set
arpi
parents:
7260
diff
changeset
|
117 if(!(sh->codec->outflags[sh->outfmtidx]&CODECS_FLAG_QUERY)) |
5fc42290c305
enabled csp-query support, but only for formats with 'query' flag set
arpi
parents:
7260
diff
changeset
|
118 return CONTROL_UNKNOWN; // do not query! |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
119 set_csp(priv->o_bih,*((int*)arg)); |
7260 | 120 #ifdef BUILD_VFWEX |
121 ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih); | |
122 #else | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
123 ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih); |
7260 | 124 #endif |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
125 if (ret) |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
126 { |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
127 mp_msg(MSGT_WIN32, MSGL_DBG2, "ICDecompressQuery failed:: Error %d\n", (int)ret); |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
128 return CONTROL_FALSE; |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
129 } |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
130 return CONTROL_TRUE; |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
131 } |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
132 #endif |
4968 | 133 } |
134 return CONTROL_UNKNOWN; | |
135 } | |
136 | |
17977
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
17932
diff
changeset
|
137 extern void print_video_header(BITMAPINFOHEADER *h, int verbose_level); |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
138 |
4968 | 139 // init driver |
140 static int init(sh_video_t *sh){ | |
7229 | 141 HRESULT ret; |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
142 // unsigned int outfmt=sh->codec->outfmt[sh->outfmtidx]; |
7229 | 143 int i, o_bih_len; |
144 vd_vfw_ctx *priv; | |
145 | |
15344 | 146 /* Hack for VSSH codec: new dll can't decode old files |
147 * In my samples old files have no extradata, so use that info | |
148 * to decide what dll should be used (here and in vd_dshow). | |
149 */ | |
150 if (!strcmp(sh->codec->dll, "vssh264.dll") && (sh->bih->biSize > 40)) | |
151 return 0; | |
152 | |
7229 | 153 priv = malloc(sizeof(vd_vfw_ctx)); |
154 if (!priv) | |
155 return 0; | |
156 memset(priv, 0, sizeof(vd_vfw_ctx)); | |
157 sh->context = priv; | |
158 | |
159 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Codec init =======\n"); | |
160 | |
7390 | 161 |
162 // win32_codec_name = sh->codec->dll; | |
7229 | 163 // sh->hic = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_FASTDECOMPRESS); |
7390 | 164 // priv->handle = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_DECOMPRESS); |
7471 | 165 priv->handle = ICOpen( (long)(sh->codec->dll), sh->bih->biCompression, ICMODE_DECOMPRESS); |
7229 | 166 if(!priv->handle){ |
167 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n"); | |
168 return 0; | |
169 } | |
170 | |
171 // sh->bih->biBitCount=32; | |
172 | |
173 o_bih_len = ICDecompressGetFormatSize(priv->handle, sh->bih); | |
174 | |
24801 | 175 if(o_bih_len < sizeof(BITMAPINFOHEADER)){ |
176 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormatSize returned a bogus value: %d\n", o_bih_len); | |
177 return 0; | |
178 } | |
179 | |
7229 | 180 priv->o_bih = malloc(o_bih_len); |
181 memset(priv->o_bih, 0, o_bih_len); | |
182 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
183 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormatSize ret: %d\n", o_bih_len); |
7229 | 184 |
185 ret = ICDecompressGetFormat(priv->handle, sh->bih, priv->o_bih); | |
186 if(ret < 0){ | |
187 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret); | |
188 for (i=0; i < o_bih_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", priv->o_bih[i]); | |
189 return 0; | |
190 } | |
191 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n"); | |
192 | |
193 #if 0 | |
194 // workaround for pegasus MJPEG: | |
195 if(!sh_video->o_bih.biWidth) sh_video->o_bih.biWidth=sh_video->bih->biWidth; | |
196 if(!sh_video->o_bih.biHeight) sh_video->o_bih.biHeight=sh_video->bih->biHeight; | |
197 if(!sh_video->o_bih.biPlanes) sh_video->o_bih.biPlanes=sh_video->bih->biPlanes; | |
198 #endif | |
199 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
200 // ok let libvo and vd core to handshake and decide the optimal csp: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
201 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; |
7229 | 202 |
203 if (!(sh->codec->outflags[sh->outfmtidx]&CODECS_FLAG_FLIP)) { | |
204 priv->o_bih->biHeight=-sh->bih->biHeight; // flip image! | |
205 } | |
206 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
207 // ok, let's set the choosen colorspace: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
208 set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]); |
7229 | 209 |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
210 // fake it to RGB for broken DLLs (divx3) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
211 if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
212 priv->o_bih->biCompression = 0; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
213 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
214 // sanity check: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
215 #if 1 |
7260 | 216 #ifdef BUILD_VFWEX |
217 ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih); | |
218 #else | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
219 ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih); |
7260 | 220 #endif |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
221 if (ret) |
7229 | 222 { |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
223 mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressQuery failed: Error %d\n", (int)ret); |
7229 | 224 // return 0; |
225 } else | |
226 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressQuery OK\n"); | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
227 #endif |
7229 | 228 |
7260 | 229 #ifdef BUILD_VFWEX |
230 ret = ICDecompressBeginEx(priv->handle, sh->bih, priv->o_bih); | |
231 #else | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
232 ret = ICDecompressBegin(priv->handle, sh->bih, priv->o_bih); |
7260 | 233 #endif |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
234 if (ret) |
7229 | 235 { |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
236 mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressBegin failed: Error %d\n", (int)ret); |
7229 | 237 // return 0; |
238 } | |
239 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
240 // for broken codecs set it again: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
241 if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
242 set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]); |
7229 | 243 |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
244 mp_msg(MSGT_WIN32, MSGL_V, "Input format:\n"); |
17977
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
17932
diff
changeset
|
245 if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(sh->bih,MSGL_V); |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
246 mp_msg(MSGT_WIN32, MSGL_V, "Output format:\n"); |
17977
f70772d02eaa
Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents:
17932
diff
changeset
|
247 if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(priv->o_bih,MSGL_V); |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
248 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
249 // set postprocessing level in xvid/divx4 .dll |
7273 | 250 ICSendMessage(priv->handle, ICM_USER+80, (long)(&divx_quality), 0); |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
251 |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
252 // don't do this palette mess always, it makes div3 dll crashing... |
7789
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
253 if(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_BGR8){ |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
254 if(ICDecompressGetPalette(priv->handle, sh->bih, priv->o_bih)){ |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
255 priv->palette = (unsigned char*)(priv->o_bih+1); |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
256 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetPalette OK\n"); |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
257 } else { |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
258 if(sh->bih->biSize>=40+4*4) |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
259 priv->palette = (unsigned char*)(sh->bih+1); |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
260 } |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
261 } |
7229 | 262 |
4968 | 263 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n"); |
5153 | 264 return 1; |
4968 | 265 } |
266 | |
267 // uninit driver | |
268 static void uninit(sh_video_t *sh){ | |
7229 | 269 HRESULT ret; |
270 vd_vfw_ctx *priv = sh->context; | |
271 | |
7260 | 272 #ifdef BUILD_VFWEX |
273 ret = ICDecompressEndEx(priv->handle); | |
274 #else | |
7229 | 275 ret = ICDecompressEnd(priv->handle); |
7260 | 276 #endif |
7229 | 277 if (ret) |
278 { | |
17366 | 279 mp_msg(MSGT_WIN32, MSGL_WARN, "ICDecompressEnd failed: %ld\n", ret); |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
280 return; |
7229 | 281 } |
282 | |
283 ret = ICClose(priv->handle); | |
284 if (ret) | |
285 { | |
17366 | 286 mp_msg(MSGT_WIN32, MSGL_WARN, "ICClose failed: %ld\n", ret); |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
287 return; |
7229 | 288 } |
289 | |
290 free(priv->o_bih); | |
291 free(priv); | |
4968 | 292 } |
293 | |
294 // decode a frame | |
295 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
7229 | 296 vd_vfw_ctx *priv = sh->context; |
4968 | 297 mp_image_t* mpi; |
7229 | 298 HRESULT ret; |
299 | |
4968 | 300 if(len<=0) return NULL; // skipped frame |
301 | |
6105
b77b984120f9
iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents:
5769
diff
changeset
|
302 mpi=mpcodecs_get_image(sh, |
b77b984120f9
iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents:
5769
diff
changeset
|
303 (sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC) ? |
b77b984120f9
iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents:
5769
diff
changeset
|
304 MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH, |
4968 | 305 sh->disp_w, sh->disp_h); |
306 if(!mpi){ // temporary! | |
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:
17977
diff
changeset
|
307 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec); |
4968 | 308 return NULL; |
309 } | |
310 | |
311 // set stride: (trick discovered by Andreas Ackermann - thanx!) | |
312 sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8); | |
7229 | 313 priv->o_bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8); |
4968 | 314 |
7229 | 315 sh->bih->biSizeImage = len; |
7390 | 316 |
7260 | 317 #ifdef BUILD_VFWEX |
318 ret = ICDecompressEx(priv->handle, | |
319 #else | |
7229 | 320 ret = ICDecompress(priv->handle, |
7260 | 321 #endif |
7229 | 322 ( (sh->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) | |
323 ( ((flags&3)==2 && !(sh->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ), | |
324 sh->bih, data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]); | |
325 | |
326 if ((int)ret){ | |
17366 | 327 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%ld\n",ret); |
4968 | 328 return NULL; |
329 } | |
330 | |
7229 | 331 // export palette: |
7275
fb25090e525d
1000l - planar YUV support fixed (indeo 3,4,5, i263 etc)
arpi
parents:
7273
diff
changeset
|
332 if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){ |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
333 if (priv->palette) |
7229 | 334 { |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
335 mpi->planes[1] = priv->palette; |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
336 mpi->flags |= MP_IMGFLAG_RGB_PALETTE; |
7229 | 337 mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Found and copied palette\n"); |
338 } | |
339 else | |
6232 | 340 mpi->planes[1]=NULL; |
7275
fb25090e525d
1000l - planar YUV support fixed (indeo 3,4,5, i263 etc)
arpi
parents:
7273
diff
changeset
|
341 } |
fb25090e525d
1000l - planar YUV support fixed (indeo 3,4,5, i263 etc)
arpi
parents:
7273
diff
changeset
|
342 |
4968 | 343 return mpi; |
344 } |