Mercurial > mplayer.hg
annotate libmpcodecs/vd_vfw.c @ 30526:68e260df472b
Just use goto instead of reimplementing it badly with a do { } while (0) and
break.
author | reimar |
---|---|
date | Sun, 14 Feb 2010 11:17:12 +0000 |
parents | cc27da5d7286 |
children | ac4bcd2064ce |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30073
diff
changeset
|
18 |
4968 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 | |
22 #include "config.h" | |
23 #include "mp_msg.h" | |
24 #include "help_mp.h" | |
25 | |
7471 | 26 #include "vd_internal.h" |
27 | |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
18771
diff
changeset
|
28 #include "loader/wine/driver.h" |
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
18771
diff
changeset
|
29 #include "loader/wine/vfw.h" |
4968 | 30 |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
31 static const vd_info_t info = { |
7260 | 32 #ifdef BUILD_VFWEX |
33 "Win32/VfWex video codecs", | |
34 "vfwex", | |
35 #else | |
4968 | 36 "Win32/VfW video codecs", |
37 "vfw", | |
7260 | 38 #endif |
7229 | 39 "A'rpi & Alex", |
7260 | 40 "avifile.sf.net", |
4968 | 41 "win32 codecs" |
42 }; | |
43 | |
7260 | 44 #ifdef BUILD_VFWEX |
45 LIBVD_EXTERN(vfwex) | |
46 #else | |
4968 | 47 LIBVD_EXTERN(vfw) |
7260 | 48 #endif |
4968 | 49 |
7229 | 50 typedef struct { |
51 BITMAPINFOHEADER *o_bih; | |
52 HIC handle; | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
53 unsigned char *palette; |
7229 | 54 } vd_vfw_ctx; |
55 | |
56 static int vfw_set_postproc(sh_video_t* sh, int quality) | |
57 { | |
58 vd_vfw_ctx *priv = sh->context; | |
59 // Works only with opendivx/divx4 based DLL | |
7273 | 60 return ICSendMessage(priv->handle, ICM_USER+80, (long)(&quality), 0); |
7229 | 61 } |
62 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
63 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
|
64 int yuv = 0; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
65 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
66 switch (outfmt) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
67 { |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
68 /* planar format */ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
69 case IMGFMT_YV12: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
70 case IMGFMT_I420: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
71 case IMGFMT_IYUV: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
72 o_bih->biBitCount=12; |
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 case IMGFMT_YVU9: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
76 case IMGFMT_IF09: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
77 o_bih->biBitCount=9; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
78 yuv=1; |
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 /* packed format */ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
81 case IMGFMT_YUY2: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
82 case IMGFMT_UYVY: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
83 case IMGFMT_YVYU: |
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 yuv=1; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
86 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
87 /* rgb/bgr format */ |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
88 case IMGFMT_RGB8: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
89 case IMGFMT_BGR8: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
90 o_bih->biBitCount=8; |
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 case IMGFMT_RGB15: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
93 case IMGFMT_RGB16: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
94 case IMGFMT_BGR15: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
95 case IMGFMT_BGR16: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
96 o_bih->biBitCount=16; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
97 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
98 case IMGFMT_RGB24: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
99 case IMGFMT_BGR24: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
100 o_bih->biBitCount=24; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
101 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
102 case IMGFMT_RGB32: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
103 case IMGFMT_BGR32: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
104 o_bih->biBitCount=32; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
105 break; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
106 default: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
107 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
|
108 return; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
109 } |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
110 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
111 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
|
112 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
113 // 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
|
114 // 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
|
115 if (yuv) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
116 o_bih->biCompression = outfmt; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
117 else |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
118 o_bih->biCompression = 0; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
119 } |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
120 |
4968 | 121 // to set/get/query special features/parameters |
122 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
|
123 vd_vfw_ctx *priv = sh->context; |
4968 | 124 switch(cmd){ |
125 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
126 return 9; | |
127 case VDCTRL_SET_PP_LEVEL: | |
128 vfw_set_postproc(sh,10*(*((int*)arg))); | |
129 return CONTROL_OK; | |
7262
5fc42290c305
enabled csp-query support, but only for formats with 'query' flag set
arpi
parents:
7260
diff
changeset
|
130 #if 1 |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
131 // 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
|
132 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
|
133 { |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
134 HRESULT ret; |
7262
5fc42290c305
enabled csp-query support, but only for formats with 'query' flag set
arpi
parents:
7260
diff
changeset
|
135 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
|
136 return CONTROL_UNKNOWN; // do not query! |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
137 set_csp(priv->o_bih,*((int*)arg)); |
7260 | 138 #ifdef BUILD_VFWEX |
139 ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih); | |
140 #else | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
141 ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih); |
7260 | 142 #endif |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
143 if (ret) |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
144 { |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
145 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
|
146 return CONTROL_FALSE; |
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
147 } |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
148 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
|
149 } |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
150 #endif |
4968 | 151 } |
152 return CONTROL_UNKNOWN; | |
153 } | |
154 | |
28051 | 155 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
|
156 |
4968 | 157 // init driver |
158 static int init(sh_video_t *sh){ | |
7229 | 159 HRESULT ret; |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
160 // unsigned int outfmt=sh->codec->outfmt[sh->outfmtidx]; |
7229 | 161 int i, o_bih_len; |
162 vd_vfw_ctx *priv; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
163 |
15344 | 164 /* Hack for VSSH codec: new dll can't decode old files |
165 * In my samples old files have no extradata, so use that info | |
166 * to decide what dll should be used (here and in vd_dshow). | |
167 */ | |
168 if (!strcmp(sh->codec->dll, "vssh264.dll") && (sh->bih->biSize > 40)) | |
169 return 0; | |
170 | |
7229 | 171 priv = malloc(sizeof(vd_vfw_ctx)); |
172 if (!priv) | |
173 return 0; | |
174 memset(priv, 0, sizeof(vd_vfw_ctx)); | |
175 sh->context = priv; | |
176 | |
177 mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Codec init =======\n"); | |
178 | |
7390 | 179 |
180 // win32_codec_name = sh->codec->dll; | |
7229 | 181 // sh->hic = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_FASTDECOMPRESS); |
7390 | 182 // priv->handle = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_DECOMPRESS); |
7471 | 183 priv->handle = ICOpen( (long)(sh->codec->dll), sh->bih->biCompression, ICMODE_DECOMPRESS); |
7229 | 184 if(!priv->handle){ |
185 mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n"); | |
186 return 0; | |
187 } | |
188 | |
189 // sh->bih->biBitCount=32; | |
190 | |
191 o_bih_len = ICDecompressGetFormatSize(priv->handle, sh->bih); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
192 |
24801 | 193 if(o_bih_len < sizeof(BITMAPINFOHEADER)){ |
194 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormatSize returned a bogus value: %d\n", o_bih_len); | |
195 return 0; | |
196 } | |
197 | |
7229 | 198 priv->o_bih = malloc(o_bih_len); |
199 memset(priv->o_bih, 0, o_bih_len); | |
200 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
201 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormatSize ret: %d\n", o_bih_len); |
7229 | 202 |
203 ret = ICDecompressGetFormat(priv->handle, sh->bih, priv->o_bih); | |
204 if(ret < 0){ | |
205 mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret); | |
206 for (i=0; i < o_bih_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", priv->o_bih[i]); | |
207 return 0; | |
208 } | |
209 mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n"); | |
210 | |
211 #if 0 | |
212 // workaround for pegasus MJPEG: | |
213 if(!sh_video->o_bih.biWidth) sh_video->o_bih.biWidth=sh_video->bih->biWidth; | |
214 if(!sh_video->o_bih.biHeight) sh_video->o_bih.biHeight=sh_video->bih->biHeight; | |
215 if(!sh_video->o_bih.biPlanes) sh_video->o_bih.biPlanes=sh_video->bih->biPlanes; | |
216 #endif | |
217 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
218 // 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
|
219 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; |
7229 | 220 |
221 if (!(sh->codec->outflags[sh->outfmtidx]&CODECS_FLAG_FLIP)) { | |
222 priv->o_bih->biHeight=-sh->bih->biHeight; // flip image! | |
223 } | |
224 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
225 // ok, let's set the choosen colorspace: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
226 set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]); |
7229 | 227 |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
228 // fake it to RGB for broken DLLs (divx3) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
229 if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
230 priv->o_bih->biCompression = 0; |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
231 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
232 // sanity check: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
233 #if 1 |
7260 | 234 #ifdef BUILD_VFWEX |
235 ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih); | |
236 #else | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
237 ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih); |
7260 | 238 #endif |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
239 if (ret) |
7229 | 240 { |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
241 mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressQuery failed: Error %d\n", (int)ret); |
7229 | 242 // return 0; |
243 } else | |
244 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
|
245 #endif |
7229 | 246 |
7260 | 247 #ifdef BUILD_VFWEX |
248 ret = ICDecompressBeginEx(priv->handle, sh->bih, priv->o_bih); | |
249 #else | |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
250 ret = ICDecompressBegin(priv->handle, sh->bih, priv->o_bih); |
7260 | 251 #endif |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
252 if (ret) |
7229 | 253 { |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
254 mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressBegin failed: Error %d\n", (int)ret); |
7229 | 255 // return 0; |
256 } | |
257 | |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
258 // for broken codecs set it again: |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
259 if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK) |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
260 set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]); |
7229 | 261 |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
262 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
|
263 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
|
264 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
|
265 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
|
266 |
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
267 // set postprocessing level in xvid/divx4 .dll |
7273 | 268 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
|
269 |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
270 // 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
|
271 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
|
272 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
|
273 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
|
274 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
|
275 } else { |
17956aff04e1
bypass palette from bih, when codec cannot give it in o_bih
arpi
parents:
7471
diff
changeset
|
276 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
|
277 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
|
278 } |
7249
06a8e6a01180
fixed some problems with colorspace/init order, some cleanup
arpi
parents:
7243
diff
changeset
|
279 } |
7229 | 280 |
4968 | 281 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n"); |
5153 | 282 return 1; |
4968 | 283 } |
284 | |
285 // uninit driver | |
286 static void uninit(sh_video_t *sh){ | |
7229 | 287 HRESULT ret; |
288 vd_vfw_ctx *priv = sh->context; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
289 |
7260 | 290 #ifdef BUILD_VFWEX |
291 ret = ICDecompressEndEx(priv->handle); | |
292 #else | |
7229 | 293 ret = ICDecompressEnd(priv->handle); |
7260 | 294 #endif |
7229 | 295 if (ret) |
296 { | |
17366 | 297 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
|
298 return; |
7229 | 299 } |
300 | |
301 ret = ICClose(priv->handle); | |
302 if (ret) | |
303 { | |
17366 | 304 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
|
305 return; |
7229 | 306 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
307 |
7229 | 308 free(priv->o_bih); |
309 free(priv); | |
4968 | 310 } |
311 | |
312 // decode a frame | |
313 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
7229 | 314 vd_vfw_ctx *priv = sh->context; |
4968 | 315 mp_image_t* mpi; |
7229 | 316 HRESULT ret; |
317 | |
4968 | 318 if(len<=0) return NULL; // skipped frame |
319 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
320 mpi=mpcodecs_get_image(sh, |
6105
b77b984120f9
iive is right - we shouldn't use IP buffering for vfw. it was changed
arpi
parents:
5769
diff
changeset
|
321 (sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC) ? |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
322 MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH, |
4968 | 323 sh->disp_w, sh->disp_h); |
324 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
|
325 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec); |
4968 | 326 return NULL; |
327 } | |
328 | |
329 // set stride: (trick discovered by Andreas Ackermann - thanx!) | |
330 sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8); | |
7229 | 331 priv->o_bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8); |
4968 | 332 |
7229 | 333 sh->bih->biSizeImage = len; |
7390 | 334 |
7260 | 335 #ifdef BUILD_VFWEX |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
336 ret = ICDecompressEx(priv->handle, |
7260 | 337 #else |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
338 ret = ICDecompress(priv->handle, |
7260 | 339 #endif |
7229 | 340 ( (sh->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) | |
341 ( ((flags&3)==2 && !(sh->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ), | |
342 sh->bih, data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]); | |
343 | |
344 if ((int)ret){ | |
17366 | 345 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%ld\n",ret); |
4968 | 346 return NULL; |
347 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
348 |
7229 | 349 // export palette: |
7275
fb25090e525d
1000l - planar YUV support fixed (indeo 3,4,5, i263 etc)
arpi
parents:
7273
diff
changeset
|
350 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
|
351 if (priv->palette) |
7229 | 352 { |
7243
5f1f724f7046
correct palette handling and query_format support (now huffyuv, cram and mwv1 is working nice)
alex
parents:
7230
diff
changeset
|
353 mpi->planes[1] = priv->palette; |
7229 | 354 mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Found and copied palette\n"); |
355 } | |
356 else | |
6232 | 357 mpi->planes[1]=NULL; |
7275
fb25090e525d
1000l - planar YUV support fixed (indeo 3,4,5, i263 etc)
arpi
parents:
7273
diff
changeset
|
358 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
359 |
4968 | 360 return mpi; |
361 } |