Mercurial > mplayer.hg
annotate dec_video.c @ 3448:837bc55b5913
updated for latest dshow api changes
author | arpi |
---|---|
date | Mon, 10 Dec 2001 21:58:37 +0000 |
parents | 62b452b7ddf9 |
children | 8b7e5884cf34 |
rev | line source |
---|---|
3062 | 1 |
2 //#define NEW_DSHOW | |
2775 | 3 |
4 #include "config.h" | |
1294 | 5 |
6 #include <stdio.h> | |
2775 | 7 #ifdef HAVE_MALLOC_H |
8 #include <malloc.h> | |
9 #endif | |
1294 | 10 #include <stdlib.h> |
1430 | 11 #include <unistd.h> |
1294 | 12 |
1567 | 13 #include "mp_msg.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
14 #include "help_mp.h" |
1294 | 15 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
16 #include "linux/timer.h" |
1496 | 17 #include "linux/shmem.h" |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
18 |
2563 | 19 extern int verbose; // defined in mplayer.c |
20 | |
1294 | 21 #include "stream.h" |
22 #include "demuxer.h" | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
23 #include "parse_es.h" |
1294 | 24 |
25 #include "codec-cfg.h" | |
26 #include "stheader.h" | |
27 | |
1422 | 28 #ifdef USE_LIBVO2 |
29 #include "libvo2/libvo2.h" | |
30 #else | |
1294 | 31 #include "libvo/video_out.h" |
1422 | 32 #endif |
1294 | 33 |
2563 | 34 #include "dec_video.h" |
35 | |
36 // =================================================================== | |
37 | |
38 extern double video_time_usage; | |
39 extern double vout_time_usage; | |
40 | |
41 extern int frameratecode2framerate[16]; | |
42 | |
43 #include "dll_init.h" | |
44 | |
45 //#include <inttypes.h> | |
46 //#include "libvo/img_format.h" | |
47 | |
1294 | 48 #include "libmpeg2/mpeg2.h" |
49 #include "libmpeg2/mpeg2_internal.h" | |
50 | |
2184 | 51 #include "postproc/postprocess.h" |
52 | |
3144 | 53 #include "cpudetect.h" |
54 | |
1294 | 55 extern picture_t *picture; // exported from libmpeg2/decode.c |
56 | |
2563 | 57 int divx_quality=0; |
1294 | 58 |
59 #ifdef USE_DIRECTSHOW | |
3442 | 60 static void* ds_vdec=NULL; |
3062 | 61 #ifdef NEW_DSHOW |
62 #else | |
1294 | 63 #include "loader/DirectShow/DS_VideoDec.h" |
64 #endif | |
3062 | 65 #endif |
1294 | 66 |
67 #ifdef USE_LIBAVCODEC | |
2496 | 68 #ifdef USE_LIBAVCODEC_SO |
69 #include <libffmpeg/avcodec.h> | |
70 #else | |
1294 | 71 #include "libavcodec/avcodec.h" |
2496 | 72 #endif |
1927 | 73 static AVCodec *lavc_codec=NULL; |
74 static AVCodecContext lavc_context; | |
75 static AVPicture lavc_picture; | |
76 int avcodec_inited=0; | |
1294 | 77 #endif |
2228 | 78 #ifdef FF_POSTPROCESS |
79 unsigned int lavc_pp=0; | |
80 #endif | |
1294 | 81 |
1349 | 82 #ifndef NEW_DECORE |
1294 | 83 #include "opendivx/decore.h" |
1349 | 84 #else |
85 #include <decore.h> | |
86 #endif | |
1294 | 87 |
2378 | 88 #ifdef USE_XANIM |
89 #include "xacodec.h" | |
90 #endif | |
91 | |
2938
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
92 #ifdef USE_TV |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
93 #include "libmpdemux/tv.h" |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
94 |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
95 extern int tv_param_on; |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
96 extern tvi_handle_t *tv_handler; |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
97 #endif |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
98 |
1948 | 99 void AVI_Decode_RLE8(char *image,char *delta,int tdsize, |
100 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel); | |
101 | |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
102 void AVI_Decode_Video1_16( |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
103 char *encoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
104 int encoded_size, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
105 char *decoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
106 int width, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
107 int height, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
108 int bytes_per_pixel); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
109 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
110 void AVI_Decode_Video1_8( |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
111 char *encoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
112 int encoded_size, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
113 char *decoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
114 int width, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
115 int height, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
116 unsigned char *palette_map, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
117 int bytes_per_pixel); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
118 |
3172 | 119 void AVI_Decode_Fli( |
120 unsigned char *encoded, | |
121 int encoded_size, | |
122 unsigned char *decoded, | |
123 int width, | |
124 int height, | |
125 int bytes_per_pixel); | |
126 | |
127 | |
1294 | 128 //**************************************************************************// |
129 // The OpenDivX stuff: | |
130 //**************************************************************************// | |
131 | |
132 #ifndef NEW_DECORE | |
133 | |
134 static unsigned char *opendivx_src[3]; | |
135 static int opendivx_stride[3]; | |
136 | |
137 // callback, the opendivx decoder calls this for each frame: | |
138 void convert_linux(unsigned char *puc_y, int stride_y, | |
139 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
140 unsigned char *bmp, int width_y, int height_y){ | |
141 | |
142 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
143 | |
144 opendivx_src[0]=puc_y; | |
145 opendivx_src[1]=puc_u; | |
146 opendivx_src[2]=puc_v; | |
147 | |
148 opendivx_stride[0]=stride_y; | |
149 opendivx_stride[1]=stride_uv; | |
150 opendivx_stride[2]=stride_uv; | |
151 } | |
152 #endif | |
153 | |
1429 | 154 int get_video_quality_max(sh_video_t *sh_video){ |
155 switch(sh_video->codec->driver){ | |
2087 | 156 #ifdef USE_WIN32DLL |
157 case VFM_VFW: | |
158 case VFM_VFWEX: | |
2184 | 159 return 9; // for Divx.dll (divx4) |
2087 | 160 #endif |
1429 | 161 #ifdef USE_DIRECTSHOW |
162 case VFM_DSHOW: | |
163 return 4; | |
164 #endif | |
165 #ifdef MPEG12_POSTPROC | |
166 case VFM_MPEG: | |
2184 | 167 return GET_PP_QUALITY_MAX; |
1429 | 168 #endif |
2228 | 169 #ifdef FF_POSTPROCESS |
170 case VFM_FFMPEG: | |
171 return GET_PP_QUALITY_MAX; | |
172 #endif | |
1429 | 173 case VFM_DIVX4: |
174 case VFM_ODIVX: | |
2184 | 175 #ifdef NEW_DECORE |
176 return 9; // for divx4linux | |
177 #else | |
178 return GET_PP_QUALITY_MAX; // for opendivx | |
179 #endif | |
1429 | 180 } |
181 return 0; | |
182 } | |
183 | |
184 void set_video_quality(sh_video_t *sh_video,int quality){ | |
185 switch(sh_video->codec->driver){ | |
2087 | 186 #ifdef USE_WIN32DLL |
187 case VFM_VFW: | |
188 case VFM_VFWEX: | |
189 vfw_set_postproc(sh_video,10*quality); | |
190 break; | |
191 #endif | |
1429 | 192 #ifdef USE_DIRECTSHOW |
193 case VFM_DSHOW: { | |
194 if(quality<0 || quality>4) quality=4; | |
3062 | 195 DS_VideoDecoder_SetValue(ds_vdec,"Quality",quality); |
1429 | 196 } |
197 break; | |
198 #endif | |
199 #ifdef MPEG12_POSTPROC | |
200 case VFM_MPEG: { | |
2184 | 201 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX; |
202 picture->pp_options=getPpModeForQuality(quality); | |
1429 | 203 } |
204 break; | |
205 #endif | |
2228 | 206 #ifdef FF_POSTPROCESS |
207 case VFM_FFMPEG: | |
208 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX; | |
209 lavc_pp=getPpModeForQuality(quality); | |
210 break; | |
211 #endif | |
1429 | 212 case VFM_DIVX4: |
213 case VFM_ODIVX: { | |
214 DEC_SET dec_set; | |
2184 | 215 #ifdef NEW_DECORE |
216 if(quality<0 || quality>9) quality=9; | |
217 dec_set.postproc_level=quality*10; | |
218 #else | |
219 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX; | |
220 dec_set.postproc_level=getPpModeForQuality(quality); | |
221 #endif | |
1429 | 222 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); |
223 } | |
224 break; | |
225 } | |
226 } | |
227 | |
228 int set_video_colors(sh_video_t *sh_video,char *item,int value){ | |
1431 | 229 #ifdef USE_DIRECTSHOW |
2295 | 230 if(sh_video->codec->driver==VFM_DSHOW){ |
3062 | 231 DS_VideoDecoder_SetValue(ds_vdec,item,value); |
1429 | 232 return 1; |
233 } | |
1431 | 234 #endif |
2938
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
235 |
2295 | 236 #ifdef NEW_DECORE |
237 #ifdef DECORE_VERSION | |
238 #if DECORE_VERSION >= 20011010 | |
239 if(sh_video->codec->driver==VFM_DIVX4){ | |
240 int option; | |
241 if(!strcmp(item,"Brightness")) option=DEC_GAMMA_BRIGHTNESS; | |
242 else if(!strcmp(item, "Contrast")) option=DEC_GAMMA_CONTRAST; | |
243 else if(!strcmp(item,"Saturation")) option=DEC_GAMMA_SATURATION; | |
244 else return 0; | |
245 value = (value * 256) / 100 - 128; | |
246 decore(0x123, DEC_OPT_GAMMA, (void *)option, (void *) value); | |
247 return 1; | |
248 } | |
249 #endif | |
250 #endif | |
251 #endif | |
2938
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
252 |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
253 #ifdef USE_TV |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
254 |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
255 if (tv_param_on == 1) |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
256 { |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
257 if (!strcmp(item, "Brightness")) |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
258 { |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
259 tv_set_color_options(tv_handler, TV_COLOR_BRIGHTNESS, value); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
260 return(1); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
261 } |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
262 if (!strcmp(item, "Hue")) |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
263 { |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
264 tv_set_color_options(tv_handler, TV_COLOR_HUE, value); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
265 return(1); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
266 } |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
267 if (!strcmp(item, "Saturation")) |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
268 { |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
269 tv_set_color_options(tv_handler, TV_COLOR_SATURATION, value); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
270 return(1); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
271 } |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
272 if (!strcmp(item, "Contrast")) |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
273 { |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
274 tv_set_color_options(tv_handler, TV_COLOR_CONTRAST, value); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
275 return(1); |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
276 } |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
277 } |
757c3ab1a45a
added support for setting color values on tv interface
alex
parents:
2827
diff
changeset
|
278 #endif |
1429 | 279 return 0; |
280 } | |
1294 | 281 |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
282 void uninit_video(sh_video_t *sh_video){ |
1654 | 283 if(!sh_video->inited) return; |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
284 mp_msg(MSGT_DECVIDEO,MSGL_V,"uninit video: %d \n",sh_video->codec->driver); |
1654 | 285 switch(sh_video->codec->driver){ |
1666 | 286 #ifdef USE_LIBAVCODEC |
1654 | 287 case VFM_FFMPEG: |
288 if (avcodec_close(&lavc_context) < 0) | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
289 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); |
1654 | 290 break; |
1666 | 291 #endif |
1669 | 292 #ifdef USE_DIRECTSHOW |
1664 | 293 case VFM_DSHOW: // Win32/DirectShow |
3062 | 294 if(ds_vdec){ DS_VideoDecoder_Destroy(ds_vdec); ds_vdec=NULL; } |
1664 | 295 break; |
1666 | 296 #endif |
1654 | 297 case VFM_MPEG: |
298 mpeg2_free_image_buffers (picture); | |
299 break; | |
2563 | 300 #ifdef USE_XANIM |
301 case VFM_XANIM: | |
302 xacodec_exit(); | |
303 break; | |
304 #endif | |
1654 | 305 } |
306 if(sh_video->our_out_buffer){ | |
307 free(sh_video->our_out_buffer); | |
308 sh_video->our_out_buffer=NULL; | |
309 } | |
310 sh_video->inited=0; | |
311 } | |
312 | |
1294 | 313 int init_video(sh_video_t *sh_video){ |
314 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; | |
315 | |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
316 sh_video->our_out_buffer=NULL; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
317 |
1294 | 318 switch(sh_video->codec->driver){ |
2659 | 319 case VFM_XANIM: { |
2378 | 320 #ifdef USE_XANIM |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
321 int ret=xacodec_init_video(sh_video,out_fmt); |
2378 | 322 if(!ret) return 0; |
2659 | 323 #else |
2660 | 324 // mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_NoXAnimSupport); |
325 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "MPlayer was compiled WIHTOUT XAnim support!\n"); | |
2659 | 326 return 0; |
327 #endif | |
2378 | 328 break; |
329 } | |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
330 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
331 case VFM_VFW: { |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
332 if(!init_vfw_video_codec(sh_video,0)) { |
1294 | 333 return 0; |
334 } | |
1567 | 335 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n"); |
1294 | 336 break; |
337 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
338 case VFM_VFWEX: { |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
339 if(!init_vfw_video_codec(sh_video,1)) { |
1297 | 340 return 0; |
341 } | |
1567 | 342 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32Ex video codec init OK!\n"); |
1297 | 343 break; |
344 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
345 case VFM_DSHOW: { // Win32/DirectShow |
1294 | 346 #ifndef USE_DIRECTSHOW |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
347 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDShowSupport); |
1294 | 348 return 0; |
349 #else | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
350 int bpp; |
3448 | 351 if(!(ds_vdec=DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, 0))){ |
1294 | 352 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
353 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_video->codec->dll); |
1567 | 354 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); |
355 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); | |
356 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); | |
1294 | 357 return 0; |
358 } | |
359 | |
360 switch(out_fmt){ | |
361 case IMGFMT_YUY2: | |
362 case IMGFMT_UYVY: | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
363 bpp=16; |
3062 | 364 DS_VideoDecoder_SetDestFmt(ds_vdec,16,out_fmt);break; // packed YUV |
1294 | 365 case IMGFMT_YV12: |
366 case IMGFMT_I420: | |
367 case IMGFMT_IYUV: | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
368 bpp=12; |
3062 | 369 DS_VideoDecoder_SetDestFmt(ds_vdec,12,out_fmt);break; // planar YUV |
1294 | 370 default: |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
371 bpp=((out_fmt&255)+7)&(~7); |
3062 | 372 DS_VideoDecoder_SetDestFmt(ds_vdec,out_fmt&255,0); // RGB/BGR |
1294 | 373 } |
374 | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
375 sh_video->our_out_buffer = (char*)memalign(64,sh_video->disp_w*sh_video->disp_h*bpp/8); // FIXME!!! |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
376 |
3062 | 377 DS_SetAttr_DivX("Quality",divx_quality); |
1294 | 378 |
3062 | 379 DS_VideoDecoder_StartInternal(ds_vdec); |
1294 | 380 // printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) ); |
381 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); | |
382 | |
1567 | 383 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n"); |
1294 | 384 break; |
385 #endif | |
386 } | |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
387 #else /* !USE_WIN32DLL */ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
388 case VFM_VFW: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
389 case VFM_DSHOW: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
390 case VFM_VFWEX: |
2006 | 391 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoWfvSupport); |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1297
diff
changeset
|
392 return 0; |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
393 #endif /* !USE_WIN32DLL */ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
394 case VFM_ODIVX: { // OpenDivX |
1567 | 395 mp_msg(MSGT_DECVIDEO,MSGL_V,"OpenDivX video codec\n"); |
1294 | 396 { DEC_PARAM dec_param; |
397 DEC_SET dec_set; | |
1349 | 398 memset(&dec_param,0,sizeof(dec_param)); |
1294 | 399 #ifdef NEW_DECORE |
400 dec_param.output_format=DEC_USER; | |
401 #else | |
402 dec_param.color_depth = 32; | |
403 #endif | |
404 dec_param.x_dim = sh_video->bih->biWidth; | |
405 dec_param.y_dim = sh_video->bih->biHeight; | |
406 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
407 dec_set.postproc_level = divx_quality; | |
408 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
1349 | 409 } |
1567 | 410 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); |
1349 | 411 break; |
412 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
413 case VFM_DIVX4: { // DivX4Linux |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
414 #ifndef NEW_DECORE |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
415 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDivx4Support); |
1631 | 416 return 0; |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
417 #else |
1567 | 418 mp_msg(MSGT_DECVIDEO,MSGL_V,"DivX4Linux video codec\n"); |
1349 | 419 { DEC_PARAM dec_param; |
420 DEC_SET dec_set; | |
421 int bits=16; | |
422 memset(&dec_param,0,sizeof(dec_param)); | |
423 switch(out_fmt){ | |
424 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break; | |
425 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break; | |
426 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break; | |
427 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break; | |
428 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break; | |
429 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break; | |
430 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break; | |
431 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break; | |
432 default: | |
1567 | 433 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",out_fmt); |
1349 | 434 return 0; |
435 } | |
436 dec_param.x_dim = sh_video->bih->biWidth; | |
437 dec_param.y_dim = sh_video->bih->biHeight; | |
438 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
439 dec_set.postproc_level = divx_quality; | |
440 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
441 sh_video->our_out_buffer = (char*)memalign(64,((bits*dec_param.x_dim+7)/8)*dec_param.y_dim); |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
442 // sh_video->our_out_buffer = shmem_alloc(dec_param.x_dim*dec_param.y_dim*5); |
1294 | 443 } |
1567 | 444 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); |
1294 | 445 break; |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
446 #endif |
1294 | 447 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
448 case VFM_FFMPEG: { // FFmpeg's libavcodec |
1294 | 449 #ifndef USE_LIBAVCODEC |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
450 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoLAVCsupport); |
1631 | 451 return 0; |
1294 | 452 #else |
1567 | 453 mp_msg(MSGT_DECVIDEO,MSGL_V,"FFmpeg's libavcodec video codec\n"); |
1654 | 454 if(!avcodec_inited){ |
455 avcodec_init(); | |
456 avcodec_register_all(); | |
457 avcodec_inited=1; | |
458 } | |
1294 | 459 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_video->codec->dll); |
460 if(!lavc_codec){ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
461 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_video->codec->dll); |
1631 | 462 return 0; |
1294 | 463 } |
464 memset(&lavc_context, 0, sizeof(lavc_context)); | |
1462 | 465 // sh_video->disp_h/=2; // !! |
1294 | 466 lavc_context.width=sh_video->disp_w; |
467 lavc_context.height=sh_video->disp_h; | |
1567 | 468 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height); |
1294 | 469 /* open it */ |
470 if (avcodec_open(&lavc_context, lavc_codec) < 0) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
471 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec); |
1631 | 472 return 0; |
1294 | 473 } |
2228 | 474 #ifdef FF_POSTPROCESS |
475 lavc_pp=divx_quality; | |
476 #endif | |
1567 | 477 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); |
1294 | 478 break; |
479 #endif | |
480 } | |
481 | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
482 case VFM_MPEG: { |
1294 | 483 // init libmpeg2: |
2567 | 484 mpeg2_init(); |
1294 | 485 #ifdef MPEG12_POSTPROC |
486 picture->pp_options=divx_quality; | |
487 #else | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
488 if(divx_quality) mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_MpegPPhint); |
1294 | 489 #endif |
2567 | 490 // send seq header to the decoder: |
491 mpeg2_decode_data(NULL,videobuffer,videobuffer+videobuf_len,0); | |
1294 | 492 mpeg2_allocate_image_buffers (picture); |
493 break; | |
494 } | |
1488 | 495 case VFM_RAW: { |
3397
39abf443aac4
vfm_raw hack: set outfmt if format != 0x0 (for tv input)
alex
parents:
3303
diff
changeset
|
496 if (sh_video->format != 0x0) |
39abf443aac4
vfm_raw hack: set outfmt if format != 0x0 (for tv input)
alex
parents:
3303
diff
changeset
|
497 /* set out_fmt */ |
39abf443aac4
vfm_raw hack: set outfmt if format != 0x0 (for tv input)
alex
parents:
3303
diff
changeset
|
498 sh_video->codec->outfmt[sh_video->outfmtidx] = sh_video->format; |
1488 | 499 break; |
500 } | |
1948 | 501 case VFM_RLE: { |
502 int bpp=((out_fmt&255)+7)/8; // RGB only | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
503 sh_video->our_out_buffer = (char*)memalign(64,sh_video->disp_w*sh_video->disp_h*bpp); // FIXME!!! |
1949 | 504 if(bpp==2){ // 15 or 16 bpp ==> palette conversion! |
505 unsigned int* pal=(unsigned int*)(((char*)sh_video->bih)+40); | |
3303 | 506 int cols=(sh_video->bih->biSize-40)/4; |
507 //int cols=1<<(sh_video->bih->biBitCount); | |
1949 | 508 int i; |
509 if(cols>256) cols=256; | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1949
diff
changeset
|
510 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols); |
1949 | 511 for(i=0;i<cols;i++){ |
512 unsigned int c=pal[i]; | |
513 unsigned int b=c&255; | |
514 unsigned int g=(c>>8)&255; | |
515 unsigned int r=(c>>16)&255; | |
516 if((out_fmt&255)==15) | |
517 pal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3)); | |
518 else | |
519 pal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3)); | |
520 } | |
521 } | |
1948 | 522 break; |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
523 case VFM_MSVIDC: { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
524 int bpp=((out_fmt&255)+7)/8; // RGB only |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
525 sh_video->our_out_buffer = |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
526 (char*)memalign(64, sh_video->disp_w*sh_video->disp_h*bpp); // FIXME!!! |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
527 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
528 break; |
3172 | 529 case VFM_FLI: { |
530 int bpp=((out_fmt&255)+7)/8; // RGB only | |
531 sh_video->our_out_buffer = | |
532 (char*)memalign(64, sh_video->disp_w*sh_video->disp_h*bpp); // FIXME!!! | |
533 } | |
534 break; | |
1948 | 535 } |
1294 | 536 } |
1654 | 537 sh_video->inited=1; |
1294 | 538 return 1; |
539 } | |
540 | |
1422 | 541 #ifdef USE_LIBVO2 |
542 int decode_video(vo2_handle_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ | |
543 #else | |
1294 | 544 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
1422 | 545 #endif |
1294 | 546 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; |
1360 | 547 int planar=(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420); |
1294 | 548 int blit_frame=0; |
549 | |
1360 | 550 uint8_t* planes_[3]; |
551 uint8_t** planes=planes_; | |
552 int stride_[3]; | |
553 int* stride=stride_; | |
554 | |
555 unsigned int t=GetTimer(); | |
556 unsigned int t2; | |
557 | |
2794 | 558 //printf("decode_frame(start: %p, size: %d, w: %d, h: %d)\n", |
559 // start, in_size, sh_video->disp_w, sh_video->disp_h); | |
560 | |
1294 | 561 //-------------------- Decode a frame: ----------------------- |
562 switch(sh_video->codec->driver){ | |
2378 | 563 #ifdef USE_XANIM |
564 case VFM_XANIM: { | |
2384 | 565 xacodec_image_t* image=xacodec_decode_frame(start,in_size,drop_frame?1:0); |
566 if(image){ | |
567 blit_frame=2; | |
568 planes=image->planes; | |
569 stride=image->stride; | |
570 } | |
2378 | 571 break; |
572 } | |
573 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
574 case VFM_ODIVX: { |
1294 | 575 // OpenDivX |
576 DEC_FRAME dec_frame; | |
577 #ifdef NEW_DECORE | |
578 DEC_PICTURE dec_pic; | |
579 #endif | |
580 // let's decode | |
581 dec_frame.length = in_size; | |
582 dec_frame.bitstream = start; | |
1349 | 583 dec_frame.render_flag = drop_frame?0:1; |
584 | |
1294 | 585 #ifdef NEW_DECORE |
586 dec_frame.bmp=&dec_pic; | |
587 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
1349 | 588 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); |
589 #else | |
1360 | 590 opendivx_src[0]=NULL; |
1349 | 591 decore(0x123, 0, &dec_frame, NULL); |
1294 | 592 #endif |
1360 | 593 |
594 if(!drop_frame) | |
1294 | 595 |
1349 | 596 // let's display |
1294 | 597 #ifdef NEW_DECORE |
598 if(dec_pic.y){ | |
1360 | 599 planes[0]=dec_pic.y; |
600 planes[1]=dec_pic.u; | |
601 planes[2]=dec_pic.v; | |
1294 | 602 stride[0]=dec_pic.stride_y; |
603 stride[1]=stride[2]=dec_pic.stride_uv; | |
1360 | 604 blit_frame=2; |
1294 | 605 } |
606 #else | |
607 if(opendivx_src[0]){ | |
1360 | 608 planes=opendivx_src; stride=opendivx_stride; |
609 blit_frame=2; | |
1294 | 610 } |
611 #endif | |
612 | |
613 break; | |
614 } | |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
615 #ifdef NEW_DECORE |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
616 case VFM_DIVX4: { |
1349 | 617 // DivX4Linux |
618 DEC_FRAME dec_frame; | |
619 // let's decode | |
620 dec_frame.length = in_size; | |
621 dec_frame.bitstream = start; | |
622 dec_frame.render_flag = drop_frame?0:1; | |
623 dec_frame.bmp=sh_video->our_out_buffer; | |
624 dec_frame.stride=sh_video->disp_w; | |
625 // printf("Decoding DivX4 frame\n"); | |
626 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
1360 | 627 if(!drop_frame) blit_frame=3; |
1349 | 628 break; |
629 } | |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
630 #endif |
1294 | 631 #ifdef USE_DIRECTSHOW |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
632 case VFM_DSHOW: { // W32/DirectShow |
3062 | 633 if(drop_frame<2) |
634 DS_VideoDecoder_DecodeInternal(ds_vdec, start, in_size, 0, drop_frame ? 0 : sh_video->our_out_buffer); | |
1362
11673118f37f
Fix segfault in DShow video decoder. Using directshow, the
jkeil
parents:
1360
diff
changeset
|
635 if(!drop_frame && sh_video->our_out_buffer) blit_frame=3; |
1294 | 636 break; |
637 } | |
638 #endif | |
639 #ifdef USE_LIBAVCODEC | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
640 case VFM_FFMPEG: { // libavcodec |
1294 | 641 int got_picture=0; |
1567 | 642 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"Calling ffmpeg...\n"); |
1294 | 643 if(drop_frame<2 && in_size>0){ |
644 int ret = avcodec_decode_video(&lavc_context, &lavc_picture, | |
645 &got_picture, start, in_size); | |
1489 | 646 if(verbose>1){ |
1462 | 647 unsigned char *x="???"; |
648 switch(lavc_context.pix_fmt){ | |
649 case PIX_FMT_YUV420P: x="YUV420P";break; | |
650 case PIX_FMT_YUV422: x="YUV422";break; | |
651 case PIX_FMT_RGB24: x="RGB24";break; | |
652 case PIX_FMT_BGR24: x="BGR24";break; | |
1465 | 653 #ifdef PIX_FMT_YUV422P |
1462 | 654 case PIX_FMT_YUV422P: x="YUV422P";break; |
655 case PIX_FMT_YUV444P: x="YUV444P";break; | |
1465 | 656 #endif |
1462 | 657 } |
1567 | 658 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"DONE -> got_picture=%d format=0x%X (%s) \n",got_picture, |
1462 | 659 lavc_context.pix_fmt,x); |
660 } | |
1567 | 661 if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n"); |
1360 | 662 if(!drop_frame && got_picture){ |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
663 // if(!drop_frame){ |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
664 if(planar){ |
2228 | 665 #ifdef FF_POSTPROCESS |
666 if(lavc_pp){ | |
667 // postprocess | |
2291 | 668 int w=(sh_video->disp_w+15)&(~15); |
669 int h=(sh_video->disp_h+15)&(~15); | |
670 int xoff=0; //(w-sh_video->disp_w)/2; | |
671 int yoff=0; //(h-sh_video->disp_h)/2; | |
672 if(!sh_video->our_out_buffer){ | |
673 sh_video->our_out_buffer = (char*)memalign(64,w*h*3/2); | |
674 memset(sh_video->our_out_buffer,0,w*h*3/2); | |
675 } | |
676 stride[0]=w; | |
677 stride[1]=stride[2]=w/2; | |
678 planes[0]=sh_video->our_out_buffer+stride[0]*yoff+xoff; | |
679 planes[2]=sh_video->our_out_buffer+w*h+stride[2]*(yoff>>1)+(xoff>>1); | |
680 planes[1]=planes[2]+w*h/4; | |
2228 | 681 postprocess(lavc_picture.data,lavc_picture.linesize[0], |
2291 | 682 planes,stride[0], |
2228 | 683 sh_video->disp_w,sh_video->disp_h, |
684 &quant_store[0][0],MBC+1,lavc_pp); | |
685 } else | |
686 #endif | |
687 { | |
688 planes=lavc_picture.data; | |
689 stride=lavc_picture.linesize; | |
690 //stride[1]=stride[2]=0; | |
691 //stride[0]/=2; | |
692 } | |
693 blit_frame=2; | |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
694 } else { |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
695 int y; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
696 // temporary hack - FIXME |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
697 if(!sh_video->our_out_buffer) |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
698 sh_video->our_out_buffer = (char*)memalign(64,sh_video->disp_w*sh_video->disp_h*2); |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
699 for(y=0;y<sh_video->disp_h;y++){ |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
700 unsigned char *s0=lavc_picture.data[0]+lavc_picture.linesize[0]*y; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
701 unsigned char *s1=lavc_picture.data[1]+lavc_picture.linesize[1]*y; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
702 unsigned char *s2=lavc_picture.data[2]+lavc_picture.linesize[2]*y; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
703 unsigned char *d=sh_video->our_out_buffer+y*2*sh_video->disp_w; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
704 int x; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
705 for(x=0;x<sh_video->disp_w/2;x++){ |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
706 d[4*x+0]=s0[2*x+0]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
707 d[4*x+1]=s1[x]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
708 d[4*x+2]=s0[2*x+1]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
709 d[4*x+3]=s2[x]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
710 } |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
711 } |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
712 blit_frame=3; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
713 } |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
714 |
1360 | 715 } |
1294 | 716 } |
717 break; | |
718 } | |
719 #endif | |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
720 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
721 case VFM_VFWEX: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
722 case VFM_VFW: |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1297
diff
changeset
|
723 { |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
724 int ret; |
1360 | 725 if(!in_size) break; |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
726 if((ret=vfw_decode_video(sh_video,start,in_size,drop_frame,(sh_video->codec->driver==VFM_VFWEX) ))){ |
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
727 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",ret); |
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
728 break; |
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
729 } |
1360 | 730 if(!drop_frame) blit_frame=3; |
1294 | 731 break; |
732 } | |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1297
diff
changeset
|
733 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
734 case VFM_MPEG: |
1873 | 735 if(out_fmt==IMGFMT_MPEGPES){ |
736 // hardware decoding: | |
737 static vo_mpegpes_t packet; | |
738 mpeg2_decode_data(video_out, start, start+in_size,3); // parse headers | |
739 packet.data=start; | |
740 packet.size=in_size-4; | |
741 packet.timestamp=sh_video->timer*90000.0; | |
742 packet.id=0x1E0; //+sh_video->ds->id; | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
2044
diff
changeset
|
743 planes[0]=(uint8_t*)(&packet); |
1873 | 744 blit_frame=2; |
745 } else { | |
746 // software decoding: | |
2019
7de4eceac32f
mpeg2-interlaced patch by Ivan Kalvatchev <iive@yahoo.com>
arpi
parents:
2006
diff
changeset
|
747 if( |
7de4eceac32f
mpeg2-interlaced patch by Ivan Kalvatchev <iive@yahoo.com>
arpi
parents:
2006
diff
changeset
|
748 mpeg2_decode_data(video_out, start, start+in_size,drop_frame) > 0 // decode |
7de4eceac32f
mpeg2-interlaced patch by Ivan Kalvatchev <iive@yahoo.com>
arpi
parents:
2006
diff
changeset
|
749 && (!drop_frame) |
7de4eceac32f
mpeg2-interlaced patch by Ivan Kalvatchev <iive@yahoo.com>
arpi
parents:
2006
diff
changeset
|
750 ) blit_frame=1; |
1873 | 751 } |
1294 | 752 break; |
1488 | 753 case VFM_RAW: |
2794 | 754 // planes[0]=start; |
755 // blit_frame=2; | |
756 sh_video->our_out_buffer = start; | |
757 blit_frame=3; | |
1488 | 758 break; |
1948 | 759 case VFM_RLE: |
760 //void AVI_Decode_RLE8(char *image,char *delta,int tdsize, | |
761 // unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel); | |
762 AVI_Decode_RLE8(sh_video->our_out_buffer,start,in_size, | |
763 (int*)(((char*)sh_video->bih)+40), | |
764 sh_video->disp_w,sh_video->disp_h,((out_fmt&255)+7)/8); | |
765 blit_frame=3; | |
766 break; | |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
767 case VFM_MSVIDC: |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
768 if (sh_video->bih->biBitCount == 16) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
769 AVI_Decode_Video1_16( |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
770 start, in_size, sh_video->our_out_buffer, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
771 sh_video->disp_w, sh_video->disp_h, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
772 ((out_fmt&255)+7)/8); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
773 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
774 AVI_Decode_Video1_8( |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
775 start, in_size, sh_video->our_out_buffer, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
776 sh_video->disp_w, sh_video->disp_h, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
777 (char *)sh_video->bih+40, ((out_fmt&255)+7)/8); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
778 blit_frame = 3; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
779 break; |
3172 | 780 case VFM_FLI: |
781 AVI_Decode_Fli( | |
782 start, in_size, sh_video->our_out_buffer, | |
783 sh_video->disp_w, sh_video->disp_h, | |
784 ((out_fmt&255)+7)/8); | |
785 blit_frame = 3; | |
786 break; | |
1294 | 787 } // switch |
788 //------------------------ frame decoded. -------------------- | |
789 | |
3160 | 790 #ifdef ARCH_X86 |
1367 | 791 // some codecs is broken, and doesn't restore MMX state :( |
792 // it happens usually with broken/damaged files. | |
3144 | 793 if(gCpuCaps.has3DNow){ |
794 __asm __volatile ("femms\n\t":::"memory"); | |
795 } | |
796 else if(gCpuCaps.hasMMX){ | |
797 __asm __volatile ("emms\n\t":::"memory"); | |
798 } | |
3160 | 799 #endif |
1367 | 800 |
1360 | 801 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; |
802 | |
803 switch(blit_frame){ | |
804 case 3: | |
805 if(planar){ | |
806 stride[0]=sh_video->disp_w; | |
807 stride[1]=stride[2]=sh_video->disp_w/2; | |
808 planes[0]=sh_video->our_out_buffer; | |
809 planes[2]=planes[0]+sh_video->disp_w*sh_video->disp_h; | |
810 planes[1]=planes[2]+sh_video->disp_w*sh_video->disp_h/4; | |
2716 | 811 } else { |
1360 | 812 planes[0]=sh_video->our_out_buffer; |
2716 | 813 if(sh_video->bih && sh_video->bih->biSize==1064) |
814 planes[1]=&sh_video->bih[1]; // pointer to palette | |
815 else | |
816 planes[1]=NULL; | |
817 } | |
3073 | 818 //#define VFM_RAW_POSTPROC |
819 #ifdef VFM_RAW_POSTPROC | |
820 if (sh_video->codec->driver == VFM_RAW) | |
821 { | |
822 mp_dbg(MSGT_DECVIDEO, MSGL_V, "Postprocessing raw %s!\n", | |
823 vo_format_name(out_fmt)); | |
824 switch(out_fmt) | |
825 { | |
826 case IMGFMT_YV12: | |
827 postprocess(planes, stride[0], planes, stride[0], | |
828 sh_video->disp_w, sh_video->disp_h, planes[0], | |
829 0, /*0x20000*/divx_quality); | |
830 break; | |
831 // case IMGFMT_UYVY: | |
832 // uyvytoyv12(start, planes[0], planes[1], planes[2], | |
833 // sh_video->disp_w, sh_video->disp_h, stride[0], stride[1], | |
834 // sh_video->disp_w*2); | |
835 // postprocess(planes, stride[0], planes, stride[0], | |
836 // sh_video->disp_w, sh_video->disp_h, planes[0], | |
837 // 0, /*0x20000*/divx_quality); | |
838 // break; | |
839 default: | |
840 mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Unsuitable outformat (%s) for raw pp!\n", | |
841 vo_format_name(out_fmt)); | |
842 } | |
843 } | |
844 #endif | |
1360 | 845 case 2: |
1422 | 846 #ifdef USE_LIBVO2 |
847 if(planar) | |
848 vo2_draw_slice(video_out,planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
849 else | |
850 vo2_draw_frame(video_out,planes[0],sh_video->disp_w,sh_video->disp_w,sh_video->disp_h); | |
851 #else | |
1360 | 852 if(planar) |
853 video_out->draw_slice(planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
854 else | |
855 video_out->draw_frame(planes); | |
1422 | 856 #endif |
1360 | 857 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; |
858 blit_frame=1; | |
859 break; | |
860 } | |
861 | |
1294 | 862 return blit_frame; |
863 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
864 |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
2794
diff
changeset
|
865 |