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