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