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