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