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