Mercurial > mplayer.hg
annotate dec_video.c @ 1951:b2b85982fc0e
MTRR autoconfigure
author | nick |
---|---|
date | Tue, 25 Sep 2001 07:20:42 +0000 |
parents | 5ceb384bf163 |
children | 5216f108cb4f |
rev | line source |
---|---|
1294 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
1430 | 4 #include <unistd.h> |
1294 | 5 |
6 #include "config.h" | |
1567 | 7 #include "mp_msg.h" |
1294 | 8 |
9 extern int verbose; // defined in mplayer.c | |
10 extern int divx_quality; | |
11 | |
12 extern double video_time_usage; | |
13 extern double vout_time_usage; | |
14 | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
15 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
|
16 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
17 #include "linux/timer.h" |
1496 | 18 #include "linux/shmem.h" |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1309
diff
changeset
|
19 |
1294 | 20 #include "stream.h" |
21 #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
|
22 #include "parse_es.h" |
1294 | 23 |
24 #include "wine/mmreg.h" | |
25 #include "wine/avifmt.h" | |
26 #include "wine/vfw.h" | |
27 | |
28 #include "codec-cfg.h" | |
29 #include "stheader.h" | |
30 | |
31 //#include <inttypes.h> | |
32 //#include "libvo/img_format.h" | |
33 | |
1422 | 34 #ifdef USE_LIBVO2 |
35 #include "libvo2/libvo2.h" | |
36 #else | |
1294 | 37 #include "libvo/video_out.h" |
1422 | 38 #endif |
1294 | 39 |
40 #include "libmpeg2/mpeg2.h" | |
41 #include "libmpeg2/mpeg2_internal.h" | |
42 | |
43 extern picture_t *picture; // exported from libmpeg2/decode.c | |
44 | |
1297 | 45 extern int init_video_codec(sh_video_t *sh_video,int ex); |
1294 | 46 |
47 #ifdef USE_DIRECTSHOW | |
48 #include "loader/DirectShow/DS_VideoDec.h" | |
49 #endif | |
50 | |
51 #ifdef USE_LIBAVCODEC | |
52 #include "libavcodec/avcodec.h" | |
1927 | 53 static AVCodec *lavc_codec=NULL; |
54 static AVCodecContext lavc_context; | |
55 static AVPicture lavc_picture; | |
56 int avcodec_inited=0; | |
1294 | 57 #endif |
58 | |
1349 | 59 #ifndef NEW_DECORE |
1294 | 60 #include "opendivx/decore.h" |
1349 | 61 #else |
62 #include <decore.h> | |
63 #endif | |
1294 | 64 |
1948 | 65 void AVI_Decode_RLE8(char *image,char *delta,int tdsize, |
66 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel); | |
67 | |
1294 | 68 //**************************************************************************// |
69 // The OpenDivX stuff: | |
70 //**************************************************************************// | |
71 | |
72 #ifndef NEW_DECORE | |
73 | |
74 static unsigned char *opendivx_src[3]; | |
75 static int opendivx_stride[3]; | |
76 | |
77 // callback, the opendivx decoder calls this for each frame: | |
78 void convert_linux(unsigned char *puc_y, int stride_y, | |
79 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
80 unsigned char *bmp, int width_y, int height_y){ | |
81 | |
82 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
83 | |
84 opendivx_src[0]=puc_y; | |
85 opendivx_src[1]=puc_u; | |
86 opendivx_src[2]=puc_v; | |
87 | |
88 opendivx_stride[0]=stride_y; | |
89 opendivx_stride[1]=stride_uv; | |
90 opendivx_stride[2]=stride_uv; | |
91 } | |
92 #endif | |
93 | |
1429 | 94 int get_video_quality_max(sh_video_t *sh_video){ |
95 switch(sh_video->codec->driver){ | |
96 #ifdef USE_DIRECTSHOW | |
97 case VFM_DSHOW: | |
98 return 4; | |
99 #endif | |
100 #ifdef MPEG12_POSTPROC | |
101 case VFM_MPEG: | |
102 #endif | |
103 case VFM_DIVX4: | |
104 case VFM_ODIVX: | |
105 return 6; | |
106 } | |
107 return 0; | |
108 } | |
109 | |
110 void set_video_quality(sh_video_t *sh_video,int quality){ | |
111 switch(sh_video->codec->driver){ | |
112 #ifdef USE_DIRECTSHOW | |
113 case VFM_DSHOW: { | |
114 if(quality<0 || quality>4) quality=4; | |
115 DS_SetValue_DivX("Quality",quality); | |
116 } | |
117 break; | |
118 #endif | |
119 #ifdef MPEG12_POSTPROC | |
120 case VFM_MPEG: { | |
121 if(quality<0 || quality>6) quality=6; | |
122 picture->pp_options=(1<<quality)-1; | |
123 } | |
124 break; | |
125 #endif | |
126 case VFM_DIVX4: | |
127 case VFM_ODIVX: { | |
128 DEC_SET dec_set; | |
129 if(quality<0 || quality>6) quality=6; | |
130 dec_set.postproc_level=(1<<quality)-1; | |
131 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
132 } | |
133 break; | |
134 } | |
135 } | |
136 | |
137 int set_video_colors(sh_video_t *sh_video,char *item,int value){ | |
1431 | 138 #ifdef USE_DIRECTSHOW |
1429 | 139 if(!strcmp(sh_video->codec->name,"divxds")){ |
140 DS_SetValue_DivX(item,value); | |
141 return 1; | |
142 } | |
1431 | 143 #endif |
1429 | 144 return 0; |
145 } | |
1294 | 146 |
1654 | 147 int uninit_video(sh_video_t *sh_video){ |
148 if(!sh_video->inited) return; | |
149 printf("uninit video: %d \n",sh_video->codec->driver); | |
150 switch(sh_video->codec->driver){ | |
1666 | 151 #ifdef USE_LIBAVCODEC |
1654 | 152 case VFM_FFMPEG: |
153 if (avcodec_close(&lavc_context) < 0) | |
154 mp_msg(MSGT_DECVIDEO,MSGL_ERR, "could not close codec\n"); | |
155 break; | |
1666 | 156 #endif |
1669 | 157 #ifdef USE_DIRECTSHOW |
1664 | 158 case VFM_DSHOW: // Win32/DirectShow |
159 DS_VideoDecoder_Close(); | |
160 break; | |
1666 | 161 #endif |
1654 | 162 case VFM_MPEG: |
163 mpeg2_free_image_buffers (picture); | |
164 break; | |
165 } | |
166 if(sh_video->our_out_buffer){ | |
167 free(sh_video->our_out_buffer); | |
168 sh_video->our_out_buffer=NULL; | |
169 } | |
170 sh_video->inited=0; | |
171 } | |
172 | |
1294 | 173 int init_video(sh_video_t *sh_video){ |
174 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; | |
175 | |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
176 sh_video->our_out_buffer=NULL; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
177 |
1294 | 178 switch(sh_video->codec->driver){ |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
179 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
180 case VFM_VFW: { |
1297 | 181 if(!init_video_codec(sh_video,0)) { |
1294 | 182 // GUI_MSG( mplUnknowError ) |
183 return 0; | |
184 } | |
1567 | 185 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n"); |
1294 | 186 break; |
187 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
188 case VFM_VFWEX: { |
1297 | 189 if(!init_video_codec(sh_video,1)) { |
190 // GUI_MSG( mplUnknowError ) | |
191 return 0; | |
192 } | |
1567 | 193 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32Ex video codec init OK!\n"); |
1297 | 194 break; |
195 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
196 case VFM_DSHOW: { // Win32/DirectShow |
1294 | 197 #ifndef USE_DIRECTSHOW |
1567 | 198 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT directshow support!\n"); |
1294 | 199 return 0; |
200 // GUI_MSG( mplCompileWithoutDSSupport ) | |
201 #else | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
202 int bpp; |
1294 | 203 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ |
204 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ | |
1567 | 205 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); |
206 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); | |
207 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); | |
208 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); | |
1294 | 209 return 0; |
210 // #ifdef HAVE_GUI | |
211 // if ( !nogui ) | |
212 // { | |
213 // strcpy( mplShMem->items.videodata.codecdll,sh_video->codec->dll ); | |
214 // mplSendMessage( mplDSCodecNotFound ); | |
215 // usec_sleep( 10000 ); | |
216 // } | |
217 // #endif | |
218 } | |
219 | |
220 switch(out_fmt){ | |
221 case IMGFMT_YUY2: | |
222 case IMGFMT_UYVY: | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
223 bpp=16; |
1294 | 224 DS_VideoDecoder_SetDestFmt(16,out_fmt);break; // packed YUV |
225 case IMGFMT_YV12: | |
226 case IMGFMT_I420: | |
227 case IMGFMT_IYUV: | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
228 bpp=12; |
1294 | 229 DS_VideoDecoder_SetDestFmt(12,out_fmt);break; // planar YUV |
230 default: | |
1547
4b0046db8e64
alloc frame buffer for directshow codec - requires for avifile sync
arpi
parents:
1517
diff
changeset
|
231 bpp=((out_fmt&255)+7)&(~7); |
1294 | 232 DS_VideoDecoder_SetDestFmt(out_fmt&255,0); // RGB/BGR |
233 } | |
234 | |
1653 | 235 sh_video->our_out_buffer = 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
|
236 |
1294 | 237 DS_VideoDecoder_Start(); |
238 | |
239 DS_SetAttr_DivX("Quality",divx_quality); | |
240 // printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) ); | |
241 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); | |
242 | |
1567 | 243 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n"); |
1294 | 244 break; |
245 #endif | |
246 } | |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
247 #else /* !USE_WIN32DLL */ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
248 case VFM_VFW: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
249 case VFM_DSHOW: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
250 case VFM_VFWEX: |
1567 | 251 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Support for win32 codecs disabled, or unavailable on non-x86 platforms!\n"); |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1297
diff
changeset
|
252 return 0; |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
253 #endif /* !USE_WIN32DLL */ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
254 case VFM_ODIVX: { // OpenDivX |
1567 | 255 mp_msg(MSGT_DECVIDEO,MSGL_V,"OpenDivX video codec\n"); |
1294 | 256 { DEC_PARAM dec_param; |
257 DEC_SET dec_set; | |
1349 | 258 memset(&dec_param,0,sizeof(dec_param)); |
1294 | 259 #ifdef NEW_DECORE |
260 dec_param.output_format=DEC_USER; | |
261 #else | |
262 dec_param.color_depth = 32; | |
263 #endif | |
264 dec_param.x_dim = sh_video->bih->biWidth; | |
265 dec_param.y_dim = sh_video->bih->biHeight; | |
266 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
267 dec_set.postproc_level = divx_quality; | |
268 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
1349 | 269 } |
1567 | 270 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); |
1349 | 271 break; |
272 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
273 case VFM_DIVX4: { // DivX4Linux |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
274 #ifndef NEW_DECORE |
1567 | 275 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT DivX4Linux (libdivxdecore.so) support!\n"); |
1631 | 276 return 0; |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
277 #else |
1567 | 278 mp_msg(MSGT_DECVIDEO,MSGL_V,"DivX4Linux video codec\n"); |
1349 | 279 { DEC_PARAM dec_param; |
280 DEC_SET dec_set; | |
281 int bits=16; | |
282 memset(&dec_param,0,sizeof(dec_param)); | |
283 switch(out_fmt){ | |
284 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break; | |
285 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break; | |
286 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break; | |
287 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break; | |
288 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break; | |
289 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break; | |
290 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break; | |
291 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break; | |
292 default: | |
1567 | 293 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",out_fmt); |
1349 | 294 return 0; |
295 } | |
296 dec_param.x_dim = sh_video->bih->biWidth; | |
297 dec_param.y_dim = sh_video->bih->biHeight; | |
298 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
299 dec_set.postproc_level = divx_quality; | |
300 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
1653 | 301 sh_video->our_out_buffer = 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
|
302 // sh_video->our_out_buffer = shmem_alloc(dec_param.x_dim*dec_param.y_dim*5); |
1294 | 303 } |
1567 | 304 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); |
1294 | 305 break; |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
306 #endif |
1294 | 307 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
308 case VFM_FFMPEG: { // FFmpeg's libavcodec |
1294 | 309 #ifndef USE_LIBAVCODEC |
1567 | 310 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT libavcodec support!\n"); |
1631 | 311 return 0; |
1294 | 312 #else |
1567 | 313 mp_msg(MSGT_DECVIDEO,MSGL_V,"FFmpeg's libavcodec video codec\n"); |
1654 | 314 if(!avcodec_inited){ |
315 avcodec_init(); | |
316 avcodec_register_all(); | |
317 avcodec_inited=1; | |
318 } | |
1294 | 319 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_video->codec->dll); |
320 if(!lavc_codec){ | |
1567 | 321 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't find codec '%s' in libavcodec...\n",sh_video->codec->dll); |
1631 | 322 return 0; |
1294 | 323 } |
324 memset(&lavc_context, 0, sizeof(lavc_context)); | |
1462 | 325 // sh_video->disp_h/=2; // !! |
1294 | 326 lavc_context.width=sh_video->disp_w; |
327 lavc_context.height=sh_video->disp_h; | |
1567 | 328 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height); |
1294 | 329 /* open it */ |
330 if (avcodec_open(&lavc_context, lavc_codec) < 0) { | |
1567 | 331 mp_msg(MSGT_DECVIDEO,MSGL_ERR, "could not open codec\n"); |
1631 | 332 return 0; |
1294 | 333 } |
334 | |
1567 | 335 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n"); |
1294 | 336 break; |
337 #endif | |
338 } | |
339 | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
340 case VFM_MPEG: { |
1294 | 341 // init libmpeg2: |
342 #ifdef MPEG12_POSTPROC | |
343 picture->pp_options=divx_quality; | |
344 #else | |
345 if(divx_quality){ | |
1567 | 346 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"WARNING! You requested image postprocessing for an MPEG 1/2 video,\n"); |
347 mp_msg(MSGT_DECVIDEO,MSGL_HINT," but compiled MPlayer without MPEG 1/2 postprocessing support!\n"); | |
348 mp_msg(MSGT_DECVIDEO,MSGL_HINT," #define MPEG12_POSTPROC in config.h, and recompile libmpeg2!\n"); | |
1294 | 349 } |
350 #endif | |
351 mpeg2_allocate_image_buffers (picture); | |
352 break; | |
353 } | |
1488 | 354 case VFM_RAW: { |
355 break; | |
356 } | |
1948 | 357 case VFM_RLE: { |
358 int bpp=((out_fmt&255)+7)/8; // RGB only | |
359 sh_video->our_out_buffer = memalign(64,sh_video->disp_w*sh_video->disp_h*bpp); // FIXME!!! | |
1949 | 360 if(bpp==2){ // 15 or 16 bpp ==> palette conversion! |
361 unsigned int* pal=(unsigned int*)(((char*)sh_video->bih)+40); | |
362 //int cols=(sh_video->bih->biSize-40)/4; | |
363 int cols=1<<(sh_video->bih->biBitCount); | |
364 int i; | |
365 if(cols>256) cols=256; | |
366 printf("RLE: converting palette for %d colors.\n",cols); | |
367 for(i=0;i<cols;i++){ | |
368 unsigned int c=pal[i]; | |
369 unsigned int b=c&255; | |
370 unsigned int g=(c>>8)&255; | |
371 unsigned int r=(c>>16)&255; | |
372 if((out_fmt&255)==15) | |
373 pal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3)); | |
374 else | |
375 pal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3)); | |
376 } | |
377 } | |
1948 | 378 break; |
379 } | |
1294 | 380 } |
1654 | 381 sh_video->inited=1; |
1294 | 382 return 1; |
383 } | |
384 | |
1422 | 385 #ifdef USE_LIBVO2 |
386 int decode_video(vo2_handle_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ | |
387 #else | |
1294 | 388 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ |
1422 | 389 #endif |
1294 | 390 unsigned int out_fmt=sh_video->codec->outfmt[sh_video->outfmtidx]; |
1360 | 391 int planar=(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420); |
1294 | 392 int blit_frame=0; |
393 | |
1360 | 394 uint8_t* planes_[3]; |
395 uint8_t** planes=planes_; | |
396 int stride_[3]; | |
397 int* stride=stride_; | |
398 | |
399 unsigned int t=GetTimer(); | |
400 unsigned int t2; | |
401 | |
1294 | 402 //-------------------- Decode a frame: ----------------------- |
403 switch(sh_video->codec->driver){ | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
404 case VFM_ODIVX: { |
1294 | 405 // OpenDivX |
406 DEC_FRAME dec_frame; | |
407 #ifdef NEW_DECORE | |
408 DEC_PICTURE dec_pic; | |
409 #endif | |
410 // let's decode | |
411 dec_frame.length = in_size; | |
412 dec_frame.bitstream = start; | |
1349 | 413 dec_frame.render_flag = drop_frame?0:1; |
414 | |
1294 | 415 #ifdef NEW_DECORE |
416 dec_frame.bmp=&dec_pic; | |
417 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
1349 | 418 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); |
419 #else | |
1360 | 420 opendivx_src[0]=NULL; |
1349 | 421 decore(0x123, 0, &dec_frame, NULL); |
1294 | 422 #endif |
1360 | 423 |
424 if(!drop_frame) | |
1294 | 425 |
1349 | 426 // let's display |
1294 | 427 #ifdef NEW_DECORE |
428 if(dec_pic.y){ | |
1360 | 429 planes[0]=dec_pic.y; |
430 planes[1]=dec_pic.u; | |
431 planes[2]=dec_pic.v; | |
1294 | 432 stride[0]=dec_pic.stride_y; |
433 stride[1]=stride[2]=dec_pic.stride_uv; | |
1360 | 434 blit_frame=2; |
1294 | 435 } |
436 #else | |
437 if(opendivx_src[0]){ | |
1360 | 438 planes=opendivx_src; stride=opendivx_stride; |
439 blit_frame=2; | |
1294 | 440 } |
441 #endif | |
442 | |
443 break; | |
444 } | |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
445 #ifdef NEW_DECORE |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
446 case VFM_DIVX4: { |
1349 | 447 // DivX4Linux |
448 DEC_FRAME dec_frame; | |
449 // let's decode | |
450 dec_frame.length = in_size; | |
451 dec_frame.bitstream = start; | |
452 dec_frame.render_flag = drop_frame?0:1; | |
453 dec_frame.bmp=sh_video->our_out_buffer; | |
454 dec_frame.stride=sh_video->disp_w; | |
455 // printf("Decoding DivX4 frame\n"); | |
456 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
1360 | 457 if(!drop_frame) blit_frame=3; |
1349 | 458 break; |
459 } | |
1352
5ac130627602
fixed shmem size, and now compiles without divx4linux too :)
arpi
parents:
1349
diff
changeset
|
460 #endif |
1294 | 461 #ifdef USE_DIRECTSHOW |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
462 case VFM_DSHOW: { // W32/DirectShow |
1294 | 463 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
|
464 if(!drop_frame && sh_video->our_out_buffer) blit_frame=3; |
1294 | 465 break; |
466 } | |
467 #endif | |
468 #ifdef USE_LIBAVCODEC | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
469 case VFM_FFMPEG: { // libavcodec |
1294 | 470 int got_picture=0; |
1567 | 471 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"Calling ffmpeg...\n"); |
1294 | 472 if(drop_frame<2 && in_size>0){ |
473 int ret = avcodec_decode_video(&lavc_context, &lavc_picture, | |
474 &got_picture, start, in_size); | |
1489 | 475 if(verbose>1){ |
1462 | 476 unsigned char *x="???"; |
477 switch(lavc_context.pix_fmt){ | |
478 case PIX_FMT_YUV420P: x="YUV420P";break; | |
479 case PIX_FMT_YUV422: x="YUV422";break; | |
480 case PIX_FMT_RGB24: x="RGB24";break; | |
481 case PIX_FMT_BGR24: x="BGR24";break; | |
1465 | 482 #ifdef PIX_FMT_YUV422P |
1462 | 483 case PIX_FMT_YUV422P: x="YUV422P";break; |
484 case PIX_FMT_YUV444P: x="YUV444P";break; | |
1465 | 485 #endif |
1462 | 486 } |
1567 | 487 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"DONE -> got_picture=%d format=0x%X (%s) \n",got_picture, |
1462 | 488 lavc_context.pix_fmt,x); |
489 } | |
1567 | 490 if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n"); |
1360 | 491 if(!drop_frame && got_picture){ |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
492 // if(!drop_frame){ |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
493 if(planar){ |
1360 | 494 planes=lavc_picture.data; |
495 stride=lavc_picture.linesize; | |
1462 | 496 //stride[1]=stride[2]=0; |
497 //stride[0]/=2; | |
1360 | 498 blit_frame=2; |
1454
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
499 } else { |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
500 int y; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
501 // temporary hack - FIXME |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
502 if(!sh_video->our_out_buffer) |
1653 | 503 sh_video->our_out_buffer = 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
|
504 for(y=0;y<sh_video->disp_h;y++){ |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 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
|
509 int x; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
510 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
|
511 d[4*x+0]=s0[2*x+0]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
512 d[4*x+1]=s1[x]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
513 d[4*x+2]=s0[2*x+1]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
514 d[4*x+3]=s2[x]; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
515 } |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
516 } |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
517 blit_frame=3; |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
518 } |
3e5b5be0b61d
temporary hack: YUV422P -> YUY2 converter (for ffmpeg MJPEG testing)
arpi
parents:
1431
diff
changeset
|
519 |
1360 | 520 } |
1294 | 521 } |
522 break; | |
523 } | |
524 #endif | |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1496
diff
changeset
|
525 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
526 case VFM_VFWEX: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
527 case VFM_VFW: |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1297
diff
changeset
|
528 { |
1294 | 529 HRESULT ret; |
530 | |
1360 | 531 if(!in_size) break; |
532 | |
1294 | 533 sh_video->bih->biSizeImage = in_size; |
534 | |
535 // sh_video->bih->biWidth = 1280; | |
536 // sh_video->o_bih.biWidth = 1280; | |
537 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), | |
1297 | 538 |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
539 if(sh_video->codec->driver==VFM_VFWEX) |
1297 | 540 ret = ICDecompressEx(sh_video->hic, |
541 ( (sh_video->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) | | |
542 ( (drop_frame==2 && !(sh_video->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ) , | |
543 sh_video->bih, start, | |
544 &sh_video->o_bih, | |
545 drop_frame ? 0 : sh_video->our_out_buffer); | |
546 else | |
1294 | 547 ret = ICDecompress(sh_video->hic, |
548 ( (sh_video->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) | | |
549 ( (drop_frame==2 && !(sh_video->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ) , | |
550 sh_video->bih, start, | |
551 &sh_video->o_bih, | |
552 drop_frame ? 0 : sh_video->our_out_buffer); | |
553 | |
1567 | 554 if(ret){ mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",(int)ret);break; } |
1360 | 555 |
556 if(!drop_frame) blit_frame=3; | |
1294 | 557 break; |
558 } | |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1297
diff
changeset
|
559 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1401
diff
changeset
|
560 case VFM_MPEG: |
1873 | 561 if(out_fmt==IMGFMT_MPEGPES){ |
562 // hardware decoding: | |
563 static vo_mpegpes_t packet; | |
564 mpeg2_decode_data(video_out, start, start+in_size,3); // parse headers | |
565 packet.data=start; | |
566 packet.size=in_size-4; | |
567 packet.timestamp=sh_video->timer*90000.0; | |
568 packet.id=0x1E0; //+sh_video->ds->id; | |
569 planes[0]=&packet; | |
570 blit_frame=2; | |
571 } else { | |
572 // software decoding: | |
573 mpeg2_decode_data(video_out, start, start+in_size,drop_frame); // decode | |
574 if(!drop_frame) blit_frame=1; | |
575 } | |
1294 | 576 break; |
1488 | 577 case VFM_RAW: |
578 planes[0]=start; | |
579 blit_frame=2; | |
580 break; | |
1948 | 581 case VFM_RLE: |
582 //void AVI_Decode_RLE8(char *image,char *delta,int tdsize, | |
583 // unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel); | |
584 AVI_Decode_RLE8(sh_video->our_out_buffer,start,in_size, | |
585 (int*)(((char*)sh_video->bih)+40), | |
586 sh_video->disp_w,sh_video->disp_h,((out_fmt&255)+7)/8); | |
587 blit_frame=3; | |
588 break; | |
1294 | 589 } // switch |
590 //------------------------ frame decoded. -------------------- | |
591 | |
1367 | 592 #ifdef HAVE_MMX |
593 // some codecs is broken, and doesn't restore MMX state :( | |
594 // it happens usually with broken/damaged files. | |
595 __asm __volatile ("emms;":::"memory"); | |
596 #endif | |
597 | |
1360 | 598 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; |
599 | |
600 switch(blit_frame){ | |
601 case 3: | |
602 if(planar){ | |
603 stride[0]=sh_video->disp_w; | |
604 stride[1]=stride[2]=sh_video->disp_w/2; | |
605 planes[0]=sh_video->our_out_buffer; | |
606 planes[2]=planes[0]+sh_video->disp_w*sh_video->disp_h; | |
607 planes[1]=planes[2]+sh_video->disp_w*sh_video->disp_h/4; | |
608 } else | |
609 planes[0]=sh_video->our_out_buffer; | |
610 case 2: | |
1422 | 611 #ifdef USE_LIBVO2 |
612 if(planar) | |
613 vo2_draw_slice(video_out,planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
614 else | |
615 vo2_draw_frame(video_out,planes[0],sh_video->disp_w,sh_video->disp_w,sh_video->disp_h); | |
616 #else | |
1360 | 617 if(planar) |
618 video_out->draw_slice(planes,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
619 else | |
620 video_out->draw_frame(planes); | |
1422 | 621 #endif |
1360 | 622 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; |
623 blit_frame=1; | |
624 break; | |
625 } | |
626 | |
1294 | 627 return blit_frame; |
628 } | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
629 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
630 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
631 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
|
632 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
|
633 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
634 // 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
|
635 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
|
636 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
|
637 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
|
638 // display info: |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
639 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
|
640 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
|
641 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
|
642 break; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
643 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
644 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
|
645 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
|
646 // Find sequence_header first: |
1658 | 647 videobuf_len=0; videobuf_code_len=0; |
1567 | 648 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
|
649 while(1){ |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
650 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
|
651 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
|
652 if(!i || !skip_video_packet(d_video)){ |
1567 | 653 if(verbose) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); |
654 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPEG: FATAL: EOF while searching for sequence header\n"); | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
655 return 0; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
656 // GUI_MSG( mplMPEGErrorSeqHeaderSearch ) |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
657 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
658 } |
1567 | 659 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
|
660 // 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
|
661 mpeg2_init(); |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
662 // ========= Read & process sequence header & extension ============ |
1658 | 663 if(!videobuffer) videobuffer=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
|
664 if(!videobuffer){ |
1567 | 665 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot allocate shared memory\n"); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
666 return 0; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
667 // GUI_MSG( mplErrorShMemAlloc ) |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
668 } |
1658 | 669 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
670 if(!read_video_packet(d_video)){ |
1567 | 671 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header!\n"); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
672 return 0; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
673 // GUI_MSG( mplMPEGErrorCannotReadSeqHeader ) |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
674 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
675 if(header_process_sequence_header (picture, &videobuffer[4])) { |
1567 | 676 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"bad sequence header!\n"); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
677 return 0; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
678 // GUI_MSG( mplMPEGErrorBadSeqHeader ) |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
679 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
680 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext. |
1462 | 681 // videobuf_len=0; |
682 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
|
683 if(!read_video_packet(d_video)){ |
1567 | 684 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"FATAL: Cannot read sequence header extension!\n"); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
685 return 0; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
686 // GUI_MSG( mplMPEGErrorCannotReadSeqHeaderExt ) |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
687 } |
1462 | 688 if(header_process_extension (picture, &videobuffer[pos+4])) { |
1567 | 689 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"bad sequence header extension!\n"); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
690 return 0; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
691 // GUI_MSG( mplMPEGErrorBadSeqHeaderExt ) |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
692 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
693 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
694 // display info: |
1463 | 695 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
|
696 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
|
697 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
|
698 // 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
|
699 // fprintf(stderr,"FPS not specified (or invalid) in the header! Use the -fps option!\n"); |
1631 | 700 // 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
|
701 // } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
702 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
|
703 } else { |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
704 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
|
705 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
706 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
|
707 sh_video->disp_h=picture->display_picture_height; |
1401 | 708 // bitrate: |
709 if(picture->bitrate!=0x3FFFF) // unspecified/VBR ? | |
710 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
|
711 // info: |
1567 | 712 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate); |
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 break; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
721 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
722 } // 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
|
723 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
724 return 1; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
725 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
726 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
727 |
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 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1367
diff
changeset
|
730 |