comparison dec_video.c @ 4911:6078b7894e20

Native Cinepak decoder: Added YV12 support (which is so very close to working), reworked YUY2 support for speed, cleaned up compiler warnings, replaced printf()'s with mp_msg()'s
author melanson
date Sat, 02 Mar 2002 06:40:26 +0000
parents a6b9c1fc6ee9
children a41e0440edfb
comparison
equal deleted inserted replaced
4910:e99d47acfce6 4911:6078b7894e20
1
2 #define USE_MP_IMAGE
1 3
2 #include "config.h" 4 #include "config.h"
3 5
4 #include <stdio.h> 6 #include <stdio.h>
5 #ifdef HAVE_MALLOC_H 7 #ifdef HAVE_MALLOC_H
20 #include "demuxer.h" 22 #include "demuxer.h"
21 #include "parse_es.h" 23 #include "parse_es.h"
22 24
23 #include "codec-cfg.h" 25 #include "codec-cfg.h"
24 26
27 #ifdef USE_LIBVO2
28 #include "libvo2/libvo2.h"
29 #else
25 #include "libvo/video_out.h" 30 #include "libvo/video_out.h"
31 #endif
26 32
27 #include "stheader.h" 33 #include "stheader.h"
28 34
29 #include "dec_video.h" 35 #include "dec_video.h"
36
37 #include "roqav.h"
30 38
31 // =================================================================== 39 // ===================================================================
32 40
33 extern int benchmark; 41 extern int benchmark;
34 extern double video_time_usage; 42 extern double video_time_usage;
37 extern double max_vout_time_usage; 45 extern double max_vout_time_usage;
38 extern double cur_video_time_usage; 46 extern double cur_video_time_usage;
39 extern double cur_vout_time_usage; 47 extern double cur_vout_time_usage;
40 extern vo_vaa_t vo_vaa; 48 extern vo_vaa_t vo_vaa;
41 49
50 extern int frameratecode2framerate[16];
51
52 #include "dll_init.h"
53
54 //#include <inttypes.h>
55 //#include "libvo/img_format.h"
56
57 #include "libmpeg2/mpeg2.h"
58 #include "libmpeg2/mpeg2_internal.h"
59
42 #include "postproc/postprocess.h" 60 #include "postproc/postprocess.h"
43 61
44 #include "cpudetect.h" 62 #include "cpudetect.h"
45 63
64 extern picture_t *picture; // exported from libmpeg2/decode.c
65
46 int divx_quality=0; 66 int divx_quality=0;
47 67
68 #ifdef USE_DIRECTSHOW
69 #include "loader/dshow/DS_VideoDecoder.h"
70 static DS_VideoDecoder* ds_vdec=NULL;
71 #endif
72
73 #ifdef USE_LIBAVCODEC
74 #ifdef USE_LIBAVCODEC_SO
75 #include <libffmpeg/avcodec.h>
76 #else
77 #include "libavcodec/avcodec.h"
78 #endif
79 static AVCodec *lavc_codec=NULL;
80 static AVCodecContext lavc_context;
81 static AVPicture lavc_picture;
82 int avcodec_inited=0;
83 #endif
84 #ifdef FF_POSTPROCESS
85 unsigned int lavc_pp=0;
86 #endif
87
88 #ifdef USE_DIVX
89 #ifndef NEW_DECORE
90 #include "opendivx/decore.h"
91 #else
92 #include <decore.h>
93 #endif
94 #endif
95
96 #ifdef USE_XANIM
97 #include "xacodec.h"
98 #endif
99
100 #ifdef USE_TV
101 #include "libmpdemux/tv.h"
102 extern int tv_param_on;
103 extern tvi_handle_t *tv_handler;
104 #endif
105
106 void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
107 unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
108
109 void AVI_Decode_Video1_16(
110 char *encoded,
111 int encoded_size,
112 char *decoded,
113 int width,
114 int height,
115 int bytes_per_pixel);
116
117 void AVI_Decode_Video1_8(
118 char *encoded,
119 int encoded_size,
120 char *decoded,
121 int width,
122 int height,
123 unsigned char *palette_map,
124 int bytes_per_pixel);
125
126 void *init_fli_decoder(int width, int height);
127
128 void decode_fli_frame(
129 unsigned char *encoded,
130 int encoded_size,
131 unsigned char *decoded,
132 int width,
133 int height,
134 int bytes_per_pixel,
135 void *context);
136
137 void qt_decode_rle(
138 unsigned char *encoded,
139 int encoded_size,
140 unsigned char *decoded,
141 int width,
142 int height,
143 int encoded_bpp,
144 int bytes_per_pixel);
145
146 void decode_nuv(
147 unsigned char *encoded,
148 int encoded_size,
149 unsigned char *decoded,
150 int width,
151 int height);
152
153 void *decode_cinepak_init(void);
154
155 void decode_cinepak(
156 void *context,
157 unsigned char *buf,
158 int size,
159 unsigned char *frame,
160 unsigned int width,
161 unsigned int height,
162 int bit_per_pixel,
163 int stride);
164
165 void decode_cyuv(
166 unsigned char *buf,
167 int size,
168 unsigned char *frame,
169 int width,
170 int height,
171 int bit_per_pixel);
172
173 int qt_init_decode_smc(void);
174
175 void qt_decode_smc(
176 unsigned char *encoded,
177 int encoded_size,
178 unsigned char *decoded,
179 int width,
180 int height,
181 unsigned char *palette_map,
182 int bytes_per_pixel);
183
184 void decode_duck_tm1(
185 unsigned char *encoded,
186 int encoded_size,
187 unsigned char *decoded,
188 int width,
189 int height,
190 int bytes_per_pixel);
191
192 #ifdef HAVE_PNG
193 void decode_mpng(
194 unsigned char *encoded,
195 int encoded_size,
196 unsigned char *decoded,
197 int width,
198 int height,
199 int bytes_per_pixel);
200 #endif
201
202 void qt_decode_rpza(
203 unsigned char *encoded,
204 int encoded_size,
205 unsigned char *decoded,
206 int width,
207 int height,
208 int bytes_per_pixel);
209
210 //**************************************************************************//
211 // The OpenDivX stuff:
212 //**************************************************************************//
213
214 #ifndef NEW_DECORE
215
216 static unsigned char *opendivx_src[3];
217 static int opendivx_stride[3];
218
219 // callback, the opendivx decoder calls this for each frame:
220 void convert_linux(unsigned char *puc_y, int stride_y,
221 unsigned char *puc_u, unsigned char *puc_v, int stride_uv,
222 unsigned char *bmp, int width_y, int height_y){
223
224 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv);
225
226 opendivx_src[0]=puc_y;
227 opendivx_src[1]=puc_u;
228 opendivx_src[2]=puc_v;
229
230 opendivx_stride[0]=stride_y;
231 opendivx_stride[1]=stride_uv;
232 opendivx_stride[2]=stride_uv;
233 }
234 #endif
235
48 int get_video_quality_max(sh_video_t *sh_video){ 236 int get_video_quality_max(sh_video_t *sh_video){
49 // switch(sh_video->codec->driver){ 237 switch(sh_video->codec->driver){
238 #ifdef USE_WIN32DLL
239 case VFM_VFW:
240 case VFM_VFWEX:
241 return 9; // for Divx.dll (divx4)
242 #endif
243 #ifdef USE_DIRECTSHOW
244 case VFM_DSHOW:
245 return 4;
246 #endif
247 #ifdef MPEG12_POSTPROC
248 case VFM_MPEG:
249 return GET_PP_QUALITY_MAX;
250 #endif
251 #ifdef FF_POSTPROCESS
252 case VFM_FFMPEG:
253 return GET_PP_QUALITY_MAX;
254 #endif
255 #ifdef USE_DIVX
256 case VFM_DIVX4:
257 case VFM_ODIVX:
258 #ifdef NEW_DECORE
259 return 9; // for divx4linux
260 #else
261 return GET_PP_QUALITY_MAX; // for opendivx
262 #endif
263 #endif
264 }
50 return 0; 265 return 0;
51 } 266 }
52 267
53 void set_video_quality(sh_video_t *sh_video,int quality){ 268 void set_video_quality(sh_video_t *sh_video,int quality){
54 // switch(sh_video->codec->driver){ 269 switch(sh_video->codec->driver){
270 #ifdef USE_WIN32DLL
271 case VFM_VFW:
272 case VFM_VFWEX:
273 vfw_set_postproc(sh_video,10*quality);
274 break;
275 #endif
276 #ifdef USE_DIRECTSHOW
277 case VFM_DSHOW: {
278 if(quality<0 || quality>4) quality=4;
279 DS_VideoDecoder_SetValue(ds_vdec,"Quality",quality);
280 }
281 break;
282 #endif
283 #ifdef MPEG12_POSTPROC
284 case VFM_MPEG: {
285 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX;
286 picture->pp_options=getPpModeForQuality(quality);
287 }
288 break;
289 #endif
290 #ifdef FF_POSTPROCESS
291 case VFM_FFMPEG:
292 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX;
293 lavc_pp=getPpModeForQuality(quality);
294 break;
295 #endif
296 #ifdef USE_DIVX
297 case VFM_DIVX4:
298 case VFM_ODIVX: {
299 DEC_SET dec_set;
300 #ifdef NEW_DECORE
301 if(quality<0 || quality>9) quality=9;
302 dec_set.postproc_level=quality*10;
303 #else
304 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX;
305 dec_set.postproc_level=getPpModeForQuality(quality);
306 #endif
307 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL);
308 }
309 #endif
310 break;
311 }
55 } 312 }
56 313
57 int set_video_colors(sh_video_t *sh_video,char *item,int value) 314 int set_video_colors(sh_video_t *sh_video,char *item,int value)
58 { 315 {
59 if(vo_vaa.get_video_eq) 316 if(vo_vaa.get_video_eq)
101 return 1; 358 return 1;
102 } 359 }
103 } 360 }
104 } 361 }
105 try_sw_control: 362 try_sw_control:
106 363 #ifdef USE_DIRECTSHOW
107 364 if(sh_video->codec->driver==VFM_DSHOW){
365 DS_VideoDecoder_SetValue(ds_vdec,item,value);
366 return 1;
367 }
368 #endif
369
370 #ifdef NEW_DECORE
371 #ifdef DECORE_VERSION
372 #if DECORE_VERSION >= 20011010
373 if(sh_video->codec->driver==VFM_DIVX4){
374 int option;
375 if(!strcmp(item,"Brightness")) option=DEC_GAMMA_BRIGHTNESS;
376 else if(!strcmp(item, "Contrast")) option=DEC_GAMMA_CONTRAST;
377 else if(!strcmp(item,"Saturation")) option=DEC_GAMMA_SATURATION;
378 else return 0;
379 value = (value * 256) / 100 - 128;
380 decore(0x123, DEC_OPT_GAMMA, (void *)option, (void *) value);
381 return 1;
382 }
383 #endif
384 #endif
385 #endif
386
387 #ifdef USE_TV
388
389 if (tv_param_on == 1)
390 {
391 if (!strcmp(item, "Brightness"))
392 {
393 tv_set_color_options(tv_handler, TV_COLOR_BRIGHTNESS, value);
394 return(1);
395 }
396 if (!strcmp(item, "Hue"))
397 {
398 tv_set_color_options(tv_handler, TV_COLOR_HUE, value);
399 return(1);
400 }
401 if (!strcmp(item, "Saturation"))
402 {
403 tv_set_color_options(tv_handler, TV_COLOR_SATURATION, value);
404 return(1);
405 }
406 if (!strcmp(item, "Contrast"))
407 {
408 tv_set_color_options(tv_handler, TV_COLOR_CONTRAST, value);
409 return(1);
410 }
411 }
412 #endif
108 return 0; 413 return 0;
109 } 414 }
110 415
111 void uninit_video(sh_video_t *sh_video){ 416 void uninit_video(sh_video_t *sh_video){
112 if(!sh_video->inited) return; 417 if(!sh_video->inited) return;
113 mp_msg(MSGT_DECVIDEO,MSGL_V,"uninit video: %d \n",sh_video->codec->driver); 418 mp_msg(MSGT_DECVIDEO,MSGL_V,"uninit video: %d \n",sh_video->codec->driver);
114 // switch(sh_video->codec->driver){ 419 switch(sh_video->codec->driver){
420 #ifdef USE_LIBAVCODEC
421 case VFM_FFMPEG:
422 if (avcodec_close(&lavc_context) < 0)
423 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec);
424 break;
425 #endif
426 #ifdef USE_DIRECTSHOW
427 case VFM_DSHOW: // Win32/DirectShow
428 if(ds_vdec){ DS_VideoDecoder_Destroy(ds_vdec); ds_vdec=NULL; }
429 break;
430 #endif
431 case VFM_MPEG:
432 mpeg2_free_image_buffers (picture);
433 break;
434 #ifdef USE_XANIM
435 case VFM_XANIM:
436 xacodec_exit();
437 break;
438 #endif
439 #ifdef USE_DIVX
440 case VFM_DIVX4:
441 case VFM_ODIVX:
442 decore(0x123,DEC_OPT_RELEASE,NULL,NULL);
443 break;
444 #endif
445 }
446 if(sh_video->our_out_buffer){
447 free(sh_video->our_out_buffer);
448 sh_video->our_out_buffer=NULL;
449 }
115 sh_video->inited=0; 450 sh_video->inited=0;
116 } 451 }
117 452
118 int init_video(sh_video_t *sh_video,int *pitches) 453 int init_video(sh_video_t *sh_video,int *pitches)
119 { 454 {
124 sh_video->our_out_buffer_size=0U; 459 sh_video->our_out_buffer_size=0U;
125 460
126 sh_video->image=new_mp_image(sh_video->disp_w,sh_video->disp_h); 461 sh_video->image=new_mp_image(sh_video->disp_w,sh_video->disp_h);
127 mp_image_setfmt(sh_video->image,out_fmt); 462 mp_image_setfmt(sh_video->image,out_fmt);
128 463
129 //switch(sh_video->codec->driver) 464 switch(sh_video->codec->driver){
130 465 case VFM_ROQVIDEO:
131 466 #ifdef USE_MP_IMAGE
467 sh_video->image->type=MP_IMGTYPE_STATIC;
468 #else
469 sh_video->our_out_buffer_size = sh_video->disp_w * sh_video->disp_h * 1.5;
470 sh_video->our_out_buffer = (char*)memalign(64, sh_video->our_out_buffer_size);
471 #endif
472 sh_video->context = roq_decode_video_init();
473 break;
474 case VFM_CINEPAK: {
475 #ifdef USE_MP_IMAGE
476 sh_video->image->type=MP_IMGTYPE_STATIC;
477 #else
478 int bpp=((out_fmt&255)+7)/8;
479 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*bpp;
480 sh_video->our_out_buffer = (char*)memalign(64, sh_video->our_out_buffer_size);
481 #endif
482 sh_video->context = decode_cinepak_init();
483 break;
484 }
485 case VFM_XANIM: {
486 #ifdef USE_XANIM
487 int ret=xacodec_init_video(sh_video,out_fmt);
488 if(!ret) return 0;
489 #else
490 // mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_NoXAnimSupport);
491 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "MPlayer was compiled WIHTOUT XAnim support!\n");
492 return 0;
493 #endif
494 break;
495 }
496 #ifdef USE_WIN32DLL
497 case VFM_VFW: {
498 if(!init_vfw_video_codec(sh_video,0)) {
499 return 0;
500 }
501 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
502 /* Warning: these pitches tested only with YUY2 fourcc */
503 pitches[0] = 16; pitches[1] = pitches[2] = 8;
504 break;
505 }
506 case VFM_VFWEX: {
507 if(!init_vfw_video_codec(sh_video,1)) {
508 return 0;
509 }
510 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32Ex video codec init OK!\n");
511 /* Warning: these pitches tested only with YUY2 fourcc */
512 pitches[0] = 16; pitches[1] = pitches[2] = 8;
513 break;
514 }
515 case VFM_DSHOW: { // Win32/DirectShow
516 #ifndef USE_DIRECTSHOW
517 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDShowSupport);
518 return 0;
519 #else
520 int bpp;
521 if(!(ds_vdec=DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, 0))){
522 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){
523 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_video->codec->dll);
524 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
525 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n");
526 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n");
527 return 0;
528 }
529
530 #ifdef USE_MP_IMAGE
531 sh_video->image->type=MP_IMGTYPE_STATIC;
532 bpp=sh_video->image->bpp;
533 if(sh_video->image->flags&MP_IMGFLAG_YUV){
534 DS_VideoDecoder_SetDestFmt(ds_vdec,bpp,out_fmt); // YUV
535 } else {
536 DS_VideoDecoder_SetDestFmt(ds_vdec,out_fmt&255,0); // RGB/BGR
537 }
538 #else
539 switch(out_fmt){
540 case IMGFMT_YUY2:
541 case IMGFMT_UYVY:
542 bpp=16;
543 DS_VideoDecoder_SetDestFmt(ds_vdec,16,out_fmt);break; // packed YUV
544 case IMGFMT_YV12:
545 case IMGFMT_I420:
546 case IMGFMT_IYUV:
547 bpp=12;
548 DS_VideoDecoder_SetDestFmt(ds_vdec,12,out_fmt);break; // planar YUV
549 default:
550 bpp=((out_fmt&255)+7)&(~7);
551 DS_VideoDecoder_SetDestFmt(ds_vdec,out_fmt&255,0); // RGB/BGR
552 }
553 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*bpp/8; // FIXME!!!
554 sh_video->our_out_buffer = (char*)memalign(64,sh_video->our_out_buffer_size);
555 #endif
556 /* Warning: these pitches tested only with YUY2 fourcc */
557 pitches[0] = 16; pitches[1] = pitches[2] = 8;
558 DS_SetAttr_DivX("Quality",divx_quality);
559
560 DS_VideoDecoder_StartInternal(ds_vdec);
561 // printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) );
562 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) );
563
564 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n");
565 break;
566 #endif
567 }
568 #else /* !USE_WIN32DLL */
569 case VFM_VFW:
570 case VFM_DSHOW:
571 case VFM_VFWEX:
572 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoWfvSupport);
573 return 0;
574 #endif /* !USE_WIN32DLL */
575 case VFM_ODIVX: { // OpenDivX
576 #ifndef USE_DIVX
577 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"MPlayer was compiled WITHOUT OpenDivx support!\n");
578 return 0;
579 #else
580 mp_msg(MSGT_DECVIDEO,MSGL_V,"OpenDivX video codec\n");
581 { DEC_PARAM dec_param;
582 DEC_SET dec_set;
583 memset(&dec_param,0,sizeof(dec_param));
584 #ifdef NEW_DECORE
585 dec_param.output_format=DEC_USER;
586 #else
587 dec_param.color_depth = 32;
588 #endif
589 dec_param.x_dim = sh_video->bih->biWidth;
590 dec_param.y_dim = sh_video->bih->biHeight;
591 decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
592 dec_set.postproc_level = divx_quality;
593 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
594 }
595 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n");
596 break;
597 #endif
598 }
599 case VFM_DIVX4: { // DivX4Linux
600 #ifndef NEW_DECORE
601 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDivx4Support);
602 return 0;
603 #else
604 mp_msg(MSGT_DECVIDEO,MSGL_V,"DivX4Linux video codec\n");
605 { DEC_PARAM dec_param;
606 DEC_SET dec_set;
607 int bits=16;
608 memset(&dec_param,0,sizeof(dec_param));
609 switch(out_fmt){
610 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break;
611 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break;
612 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break;
613 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break;
614 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break;
615 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break;
616 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break;
617 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break;
618 default:
619 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",out_fmt);
620 return 0;
621 }
622 dec_param.x_dim = sh_video->bih->biWidth;
623 dec_param.y_dim = sh_video->bih->biHeight;
624 decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
625 dec_set.postproc_level = divx_quality;
626 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
627 #ifdef USE_MP_IMAGE
628 sh_video->image->type=MP_IMGTYPE_STATIC;
629 #else
630 sh_video->our_out_buffer_size = ((bits*dec_param.x_dim+7)/8)*dec_param.y_dim;
631 sh_video->our_out_buffer = (char*)memalign(64,sh_video->our_out_buffer_size);
632 // sh_video->our_out_buffer = shmem_alloc(dec_param.x_dim*dec_param.y_dim*5);
633 #endif
634 }
635 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n");
636 break;
637 #endif
638 }
639 case VFM_FFMPEG: { // FFmpeg's libavcodec
640 #ifndef USE_LIBAVCODEC
641 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoLAVCsupport);
642 return 0;
643 #else
644 /* Just because we know that */
645 pitches[0] = 16;
646 pitches[1] = pitches[2] = 8;
647 mp_msg(MSGT_DECVIDEO,MSGL_V,"FFmpeg's libavcodec video codec\n");
648 if(!avcodec_inited){
649 avcodec_init();
650 avcodec_register_all();
651 avcodec_inited=1;
652 }
653 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_video->codec->dll);
654 if(!lavc_codec){
655 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_video->codec->dll);
656 return 0;
657 }
658 memset(&lavc_context, 0, sizeof(lavc_context));
659 // sh_video->disp_h/=2; // !!
660 lavc_context.width=sh_video->disp_w;
661 lavc_context.height=sh_video->disp_h;
662 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",lavc_context.width,lavc_context.height);
663 if (sh_video->format == mmioFOURCC('R', 'V', '1', '3'))
664 lavc_context.sub_id = 3;
665 /* open it */
666 if (avcodec_open(&lavc_context, lavc_codec) < 0) {
667 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantOpenCodec);
668 return 0;
669 }
670 #ifdef FF_POSTPROCESS
671 lavc_pp=divx_quality;
672 #endif
673 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: libavcodec init OK!\n");
674 break;
675 #endif
676 }
677
678 case VFM_MPEG: {
679 // init libmpeg2:
680 mpeg2_init();
681 #ifdef MPEG12_POSTPROC
682 picture->pp_options=divx_quality;
683 #else
684 if(divx_quality) mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_MpegPPhint);
685 #endif
686 /* Just because we know that */
687 pitches[0] = 16;
688 pitches[1] = pitches[2] = 8;
689 // send seq header to the decoder:
690 mpeg2_decode_data(NULL,videobuffer,videobuffer+videobuf_len,0);
691 mpeg2_allocate_image_buffers (picture);
692 break;
693 }
694 case VFM_RAW: {
695 if (sh_video->format != 0x0)
696 /* set out_fmt */
697 sh_video->codec->outfmt[sh_video->outfmtidx] = sh_video->format;
698 break;
699 }
700 case VFM_RLE: {
701 int bpp=((out_fmt&255)+7)/8; // RGB only
702 #ifdef USE_MP_IMAGE
703 sh_video->image->type=MP_IMGTYPE_STATIC;
704 #else
705 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*bpp; // FIXME!!!
706 sh_video->our_out_buffer = (char*)memalign(64,sh_video->our_out_buffer_size);
707 #endif
708 if(bpp==2){ // 15 or 16 bpp ==> palette conversion!
709 unsigned int* pal=(unsigned int*)(((char*)sh_video->bih)+40);
710 int cols=(sh_video->bih->biSize-40)/4;
711 //int cols=1<<(sh_video->bih->biBitCount);
712 int i;
713 if(cols>256) cols=256;
714 mp_msg(MSGT_DECVIDEO,MSGL_V,"RLE: converting palette for %d colors.\n",cols);
715 for(i=0;i<cols;i++){
716 unsigned int c=pal[i];
717 unsigned int b=c&255;
718 unsigned int g=(c>>8)&255;
719 unsigned int r=(c>>16)&255;
720 if((out_fmt&255)==15)
721 pal[i]=((r>>3)<<10)|((g>>3)<<5)|((b>>3));
722 else
723 pal[i]=((r>>3)<<11)|((g>>2)<<5)|((b>>3));
724 }
725 }
726 break;
727 case VFM_FLI:
728 sh_video->context = init_fli_decoder(sh_video->disp_w, sh_video->disp_h);
729 case VFM_MSVIDC:
730 case VFM_QTRLE:
731 case VFM_DUCKTM1:
732 #ifdef HAVE_PNG
733 case VFM_MPNG:
734 #endif
735 case VFM_QTRPZA:
736 {
737 #ifdef USE_MP_IMAGE
738 sh_video->image->type=MP_IMGTYPE_STATIC;
739 #else
740 int bpp=((out_fmt&255)+7)/8; // RGB only
741 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*bpp; // FIXME!!!
742 sh_video->our_out_buffer = (char*)memalign(64,sh_video->our_out_buffer_size);
743 #endif
744 if ((sh_video->codec->driver == VFM_QTRLE) && (sh_video->bih->biBitCount != 24))
745 printf (
746 " *** FYI: This Quicktime file is using %d-bit RLE Animation\n" \
747 " encoding, which is not yet supported by MPlayer. But if you upload\n" \
748 " this Quicktime file to the MPlayer FTP, the team could look at it.\n",
749 sh_video->bih->biBitCount);
750
751 break;
752 }
753 case VFM_QTSMC:
754 {
755 if (qt_init_decode_smc() != 0)
756 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "SMC decoder could not allocate enough memory");
757 #ifdef USE_MP_IMAGE
758 sh_video->image->type=MP_IMGTYPE_STATIC;
759 #else
760 int bpp=((out_fmt&255)+7)/8; // RGB only
761 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*bpp; // FIXME!!!
762 sh_video->our_out_buffer = (char*)memalign(64, sh_video->our_out_buffer_size);
763 #endif
764 break;
765 }
766 case VFM_NUV:
767 #ifdef USE_MP_IMAGE
768 sh_video->image->type=MP_IMGTYPE_STATIC;
769 #else
770 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*3/2;
771 sh_video->our_out_buffer = (char *)memalign(64,sh_video->our_out_buffer_size);
772 #endif
773 break;
774 case VFM_CYUV: {
775 // int bpp=((out_fmt&255)+7)/8;
776 #ifdef USE_MP_IMAGE
777 sh_video->image->type=MP_IMGTYPE_STATIC;
778 #else
779 sh_video->our_out_buffer_size = sh_video->disp_w*sh_video->disp_h*3;
780 sh_video->our_out_buffer = (char*)memalign(64, sh_video->our_out_buffer_size);
781 #endif
782 break;
783 }
784 }
785 }
132 sh_video->inited=1; 786 sh_video->inited=1;
133 return 1; 787 return 1;
134 } 788 }
135 789
136 extern int vaa_use_dr; 790 extern int vaa_use_dr;
152 dstride=(width*2+adp)&~adp; 806 dstride=(width*2+adp)&~adp;
153 if(sstride == dstride) use_dr_422 = 1; 807 if(sstride == dstride) use_dr_422 = 1;
154 } 808 }
155 } 809 }
156 810
811 #ifdef USE_LIBVO2
812 int decode_video(vo2_handle_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){
813 #else
157 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){ 814 int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame){
158 mp_image_t *mpi=NULL; 815 #endif
816
817 mp_image_t *mpi=sh_video->image;
818 unsigned int out_fmt=mpi->imgfmt; //sh_video->codec->outfmt[sh_video->outfmtidx];
819 int planar=(mpi->flags&MP_IMGFLAG_PLANAR)!=0; //(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420);
159 int blit_frame=0; 820 int blit_frame=0;
821 void *vmem;
822 int painted;
823 static int double_buff_num = 0;
824
825 //uint8_t* planes_[3];
826 //uint8_t** planes=planes_;
827 //int stride_[3];
828 //int* stride=stride_;
829
160 unsigned int t=GetTimer(); 830 unsigned int t=GetTimer();
161 unsigned int t2; 831 unsigned int t2;
162 double tt; 832 double tt;
163 833
164 834 painted = 0;
835 #ifdef USE_MP_IMAGE
836 if(mpi->type!=MP_IMGTYPE_EXPORT)
837 if( !(mpi->flags&MP_IMGFLAG_ALLOCATED) && !(mpi->flags&MP_IMGFLAG_DIRECT) ){
838 // allocate image buffer:
839 sh_video->our_out_buffer = (char *)memalign(64, mpi->width*mpi->height*mpi->bpp/8);
840 if((mpi->flags|MP_IMGFLAG_PLANAR) && (mpi->flags|MP_IMGFLAG_YUV)){
841 // planar YUV
842 mpi->stride[0]=mpi->width;
843 mpi->stride[1]=mpi->stride[2]=mpi->width/2;
844 mpi->planes[0]=sh_video->our_out_buffer;
845 mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
846 mpi->planes[2]=mpi->planes[1]+mpi->stride[0]*mpi->height/4;
847 } else {
848 // packed YUV / RGB
849 mpi->stride[0]=mpi->width*mpi->bpp;
850 mpi->planes[0]=sh_video->our_out_buffer;
851 }
852 mpi->flags|=MP_IMGFLAG_ALLOCATED;
853 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"mp_image: allocated %d bytes for %dx%dx%d [0x%X] image\n",
854 mpi->width*mpi->height*mpi->bpp/8, mpi->width, mpi->height, mpi->bpp, mpi->imgfmt);
855 }
856 #endif
857
858 //printf("decode_frame(start: %p, size: %d, w: %d, h: %d)\n",
859 // start, in_size, sh_video->disp_w, sh_video->disp_h);
860
861 //-------------------- Decode a frame: -----------------------
862 switch(sh_video->codec->driver){
863 case VFM_CINEPAK:
864 if (in_size == 0)
865 blit_frame = 0;
866 else
867 {
868 decode_cinepak(sh_video->context, start, in_size, sh_video->our_out_buffer,
869 sh_video->disp_w, sh_video->disp_h, (out_fmt==IMGFMT_YV12)?12:(out_fmt==IMGFMT_YUY2)?16:(out_fmt&255), 0);
870 blit_frame = 3;
871 }
872 break;
873 #ifdef USE_XANIM
874 case VFM_XANIM: {
875 xacodec_image_t* image=xacodec_decode_frame(start,in_size,drop_frame?1:0);
876 if(image){
877 blit_frame=2;
878 //planes=image->planes;
879 //stride=image->stride;
880 mpi->planes[0]=image->planes[0];
881 mpi->planes[1]=image->planes[1];
882 mpi->planes[2]=image->planes[2];
883 mpi->stride[0]=image->stride[0];
884 mpi->stride[1]=image->stride[1];
885 mpi->stride[2]=image->stride[2];
886 }
887 break;
888 }
889 #endif
890 #ifdef USE_DIVX
891 case VFM_ODIVX: {
892 // OpenDivX
893 DEC_FRAME dec_frame;
894 #ifdef NEW_DECORE
895 DEC_PICTURE dec_pic;
896 #endif
897 // let's decode
898 dec_frame.length = in_size;
899 dec_frame.bitstream = start;
900 dec_frame.render_flag = drop_frame?0:1;
901
902 #ifdef NEW_DECORE
903 dec_frame.bmp=&dec_pic;
904 dec_pic.y=dec_pic.u=dec_pic.v=NULL;
905 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
906 #else
907 opendivx_src[0]=NULL;
908 decore(0x123, 0, &dec_frame, NULL);
909 #endif
910
911 if(!drop_frame)
912
913 // let's display
914 #ifdef NEW_DECORE
915 if(dec_pic.y){
916 mpi->planes[0]=dec_pic.y;
917 mpi->planes[1]=dec_pic.u;
918 mpi->planes[2]=dec_pic.v;
919 mpi->stride[0]=dec_pic.stride_y;
920 mpi->stride[1]=mpi->stride[2]=dec_pic.stride_uv;
921 blit_frame=2;
922 }
923 #else
924 if(opendivx_src[0]){
925 // planes=opendivx_src;
926 // stride=opendivx_stride;
927 mpi->planes[0]=opendivx_src[0];
928 mpi->planes[1]=opendivx_src[1];
929 mpi->planes[2]=opendivx_src[2];
930 mpi->stride[0]=opendivx_stride[0];
931 mpi->stride[1]=opendivx_stride[1];
932 mpi->stride[2]=opendivx_stride[2];
933 blit_frame=2;
934 }
935 #endif
936
937 break;
938 }
939 #endif
940 #ifdef NEW_DECORE
941 case VFM_DIVX4: {
942 // DivX4Linux
943 DEC_FRAME dec_frame;
944 // let's decode
945 dec_frame.length = in_size;
946 dec_frame.bitstream = start;
947 dec_frame.render_flag = drop_frame?0:1;
948 dec_frame.bmp=sh_video->our_out_buffer;
949 dec_frame.stride=sh_video->disp_w;
950 // printf("Decoding DivX4 frame\n");
951 decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
952 if(!drop_frame) blit_frame=3;
953 break;
954 }
955 #endif
956 #ifdef USE_DIRECTSHOW
957 case VFM_DSHOW: { // W32/DirectShow
958 if(drop_frame<2)
959 {
960 /* FIXME: WILL WORK ONLY FOR PACKED FOURCC. BUT WHAT ABOUT PLANAR? */
961 vmem = 0;
962 if(use_dr_422)
963 {
964 vmem = bda.dga_addr + bda.offsets[0] + bda.offset.y;
965 if(vo_doublebuffering && bda.num_frames>1)
966 {
967 if(double_buff_num) vmem = bda.dga_addr + bda.offsets[1] + bda.offset.y;
968 else vmem = bda.dga_addr + bda.offsets[0] + bda.offset.y;
969 double_buff_num = double_buff_num ? 0 : 1;
970 }
971 }
972 DS_VideoDecoder_DecodeInternal(ds_vdec, start, in_size, 0, drop_frame ? 0 : vmem ? vmem : sh_video->our_out_buffer);
973 if(vmem) painted = 1;
974 }
975 if(!drop_frame && sh_video->our_out_buffer) blit_frame=3;
976 break;
977 }
978 #endif
979 #ifdef USE_LIBAVCODEC
980 case VFM_FFMPEG: { // libavcodec
981 int got_picture=0;
982 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"Calling ffmpeg...\n");
983 if(drop_frame<2 && in_size>0){
984 int ret = avcodec_decode_video(&lavc_context, &lavc_picture,
985 &got_picture, start, in_size);
986 if(verbose>1){
987 unsigned char *x="???";
988 switch(lavc_context.pix_fmt){
989 case PIX_FMT_YUV420P: x="YUV420P";break;
990 case PIX_FMT_YUV422: x="YUV422";break;
991 case PIX_FMT_RGB24: x="RGB24";break;
992 case PIX_FMT_BGR24: x="BGR24";break;
993 #ifdef PIX_FMT_YUV422P
994 case PIX_FMT_YUV422P: x="YUV422P";break;
995 case PIX_FMT_YUV444P: x="YUV444P";break;
996 #endif
997 }
998 mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"DONE -> got_picture=%d format=0x%X (%s) \n",got_picture,
999 lavc_context.pix_fmt,x);
1000 }
1001 if(ret<0) mp_msg(MSGT_DECVIDEO,MSGL_WARN, "Error while decoding frame!\n");
1002 if(!drop_frame && got_picture){
1003 // if(!drop_frame){
1004 if(planar){
1005 #ifdef FF_POSTPROCESS
1006 #ifdef MBC
1007 if(lavc_pp){
1008 // postprocess
1009 int w=(sh_video->disp_w+15)&(~15);
1010 int h=(sh_video->disp_h+15)&(~15);
1011 int xoff=0; //(w-sh_video->disp_w)/2;
1012 int yoff=0; //(h-sh_video->disp_h)/2;
1013 if(!sh_video->our_out_buffer){
1014 sh_video->our_out_buffer = (char*)memalign(64,w*h*3/2);
1015 memset(sh_video->our_out_buffer,0,w*h*3/2);
1016 }
1017 mpi->stride[0]=w;
1018 mpi->stride[1]=mpi->stride[2]=w/2;
1019 mpi->planes[0]=sh_video->our_out_buffer+mpi->stride[0]*yoff+xoff;
1020 mpi->planes[2]=sh_video->our_out_buffer+w*h+mpi->stride[2]*(yoff>>1)+(xoff>>1);
1021 mpi->planes[1]=mpi->planes[2]+w*h/4;
1022 postprocess(lavc_picture.data,lavc_picture.linesize[0],
1023 mpi->planes,mpi->stride[0],
1024 sh_video->disp_w,sh_video->disp_h,
1025 &quant_store[0][0],MBC+1,lavc_pp);
1026 } else
1027 #endif
1028 #endif
1029 {
1030 //planes=lavc_picture.data;
1031 //stride=lavc_picture.linesize;
1032 mpi->planes[0]=lavc_picture.data[0];
1033 mpi->planes[1]=lavc_picture.data[1];
1034 mpi->planes[2]=lavc_picture.data[2];
1035 mpi->stride[0]=lavc_picture.linesize[0];
1036 mpi->stride[1]=lavc_picture.linesize[1];
1037 mpi->stride[2]=lavc_picture.linesize[2];
1038 if(lavc_context.pix_fmt==PIX_FMT_YUV422P){
1039 mpi->stride[1]*=2;
1040 mpi->stride[2]*=2;
1041 }
1042
1043 //stride[1]=stride[2]=0;
1044 //stride[0]/=2;
1045 }
1046 blit_frame=2;
1047 } else {
1048 int y;
1049 // temporary hack - FIXME
1050 if(!sh_video->our_out_buffer)
1051 sh_video->our_out_buffer = (char*)memalign(64,sh_video->disp_w*sh_video->disp_h*2);
1052 for(y=0;y<sh_video->disp_h;y++){
1053 unsigned char *s0=lavc_picture.data[0]+lavc_picture.linesize[0]*y;
1054 unsigned char *s1=lavc_picture.data[1]+lavc_picture.linesize[1]*y;
1055 unsigned char *s2=lavc_picture.data[2]+lavc_picture.linesize[2]*y;
1056 unsigned char *d=sh_video->our_out_buffer+y*2*sh_video->disp_w;
1057 int x;
1058 for(x=0;x<sh_video->disp_w/2;x++){
1059 d[4*x+0]=s0[2*x+0];
1060 d[4*x+1]=s1[x];
1061 d[4*x+2]=s0[2*x+1];
1062 d[4*x+3]=s2[x];
1063 }
1064 }
1065 blit_frame=3;
1066 }
1067
1068 }
1069 }
1070 break;
1071 }
1072 #endif
1073 #ifdef USE_WIN32DLL
1074 case VFM_VFWEX:
1075 case VFM_VFW:
1076 {
1077 int ret;
1078 if(!in_size) break;
1079 /* FIXME: WILL WORK ONLY FOR PACKED FOURCC. BUT WHAT ABOUT PLANAR? */
1080 vmem = 0;
1081 if(use_dr_422)
1082 {
1083 vmem = bda.dga_addr + bda.offsets[0] + bda.offset.y;
1084 if(vo_doublebuffering && bda.num_frames>1)
1085 {
1086 if(double_buff_num) vmem = bda.dga_addr + bda.offsets[1] + bda.offset.y;
1087 else vmem = bda.dga_addr + bda.offsets[0] + bda.offset.y;
1088 double_buff_num = double_buff_num ? 0 : 1;
1089 }
1090 sh_video->our_out_buffer = vmem;
1091 }
1092 if((ret=vfw_decode_video(sh_video,start,in_size,drop_frame,(sh_video->codec->driver==VFM_VFWEX) ))){
1093 mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%d\n",ret);
1094 break;
1095 }
1096 if(vmem) painted=1;
1097 if(!drop_frame) blit_frame=3;
1098 break;
1099 }
1100 #endif
1101 case VFM_MPEG:
1102 if(out_fmt==IMGFMT_MPEGPES){
1103 // hardware decoding:
1104 static vo_mpegpes_t packet;
1105 mpeg2_decode_data(video_out, start, start+in_size,3); // parse headers
1106 packet.data=start;
1107 packet.size=in_size-4;
1108 packet.timestamp=sh_video->timer*90000.0;
1109 packet.id=0x1E0; //+sh_video->ds->id;
1110 mpi->planes[0]=(uint8_t*)(&packet);
1111 blit_frame=2;
1112 } else {
1113 // software decoding:
1114 if(
1115 mpeg2_decode_data(video_out, start, start+in_size,drop_frame) > 0 // decode
1116 && (!drop_frame)
1117 ) blit_frame=1;
1118 }
1119 break;
1120 case VFM_RAW:
1121 // planes[0]=start;
1122 // blit_frame=2;
1123 sh_video->our_out_buffer = start;
1124 blit_frame=3;
1125 break;
1126 case VFM_RLE:
1127 //void AVI_Decode_RLE8(char *image,char *delta,int tdsize,
1128 // unsigned int *map,int imagex,int imagey,unsigned char x11_bytes_pixel);
1129 AVI_Decode_RLE8(sh_video->our_out_buffer,start,in_size,
1130 (int*)(((char*)sh_video->bih)+40),
1131 sh_video->disp_w,sh_video->disp_h,((out_fmt&255)+7)/8);
1132 blit_frame=3;
1133 break;
1134 case VFM_MSVIDC:
1135 if (sh_video->bih->biBitCount == 16)
1136 AVI_Decode_Video1_16(
1137 start, in_size, sh_video->our_out_buffer,
1138 sh_video->disp_w, sh_video->disp_h,
1139 ((out_fmt&255)+7)/8);
1140 else
1141 AVI_Decode_Video1_8(
1142 start, in_size, sh_video->our_out_buffer,
1143 sh_video->disp_w, sh_video->disp_h,
1144 (char *)sh_video->bih+40, ((out_fmt&255)+7)/8);
1145 blit_frame = 3;
1146 break;
1147 case VFM_FLI:
1148 decode_fli_frame(
1149 start, in_size, sh_video->our_out_buffer,
1150 sh_video->disp_w, sh_video->disp_h,
1151 ((out_fmt&255)+7)/8,
1152 sh_video->context);
1153 blit_frame = 3;
1154 break;
1155 case VFM_NUV:
1156 decode_nuv(
1157 start, in_size, sh_video->our_out_buffer,
1158 sh_video->disp_w, sh_video->disp_h);
1159 blit_frame = 3;
1160 break;
1161 case VFM_QTRLE:
1162 qt_decode_rle(
1163 start, in_size, sh_video->our_out_buffer,
1164 sh_video->disp_w, sh_video->disp_h,
1165 sh_video->bih->biBitCount,
1166 ((out_fmt&255)+7)/8);
1167 blit_frame = 3;
1168 break;
1169 case VFM_QTSMC:
1170 qt_decode_smc(
1171 start, in_size, sh_video->our_out_buffer,
1172 sh_video->disp_w, sh_video->disp_h,
1173 (unsigned char *)sh_video->bih+40,
1174 ((out_fmt&255)+7)/8);
1175 blit_frame = 3;
1176 break;
1177 case VFM_DUCKTM1:
1178 decode_duck_tm1(
1179 start, in_size, sh_video->our_out_buffer,
1180 sh_video->disp_w, sh_video->disp_h,
1181 ((out_fmt&255)+7)/8);
1182 blit_frame = 3;
1183 break;
1184 #ifdef HAVE_PNG
1185 case VFM_MPNG:
1186 decode_mpng(
1187 start, in_size, sh_video->our_out_buffer,
1188 sh_video->disp_w,sh_video->disp_h,
1189 ((out_fmt&255)+7)/8
1190 );
1191 blit_frame = 3;
1192 break;
1193 #endif
1194 case VFM_CYUV:
1195 decode_cyuv(start, in_size, sh_video->our_out_buffer,
1196 sh_video->disp_w, sh_video->disp_h, (out_fmt==IMGFMT_YUY2)?16:(out_fmt&255));
1197 blit_frame = 3;
1198 break;
1199 case VFM_ROQVIDEO:
1200 roq_decode_video(start, in_size, sh_video->our_out_buffer,
1201 sh_video->disp_w, sh_video->disp_h, sh_video->context);
1202 blit_frame = 3;
1203 break;
1204 case VFM_QTRPZA:
1205 qt_decode_rpza(
1206 start, in_size, sh_video->our_out_buffer,
1207 sh_video->disp_w, sh_video->disp_h,
1208 ((out_fmt&255)+7)/8);
1209 blit_frame = 3;
1210 break;
1211 } // switch
165 //------------------------ frame decoded. -------------------- 1212 //------------------------ frame decoded. --------------------
166 1213
167 #ifdef ARCH_X86 1214 #ifdef ARCH_X86
168 // some codecs is broken, and doesn't restore MMX state :( 1215 // some codecs is broken, and doesn't restore MMX state :(
169 // it happens usually with broken/damaged files. 1216 // it happens usually with broken/damaged files.
181 if(benchmark) 1228 if(benchmark)
182 { 1229 {
183 if(tt > max_video_time_usage) max_video_time_usage=tt; 1230 if(tt > max_video_time_usage) max_video_time_usage=tt;
184 cur_video_time_usage=tt; 1231 cur_video_time_usage=tt;
185 } 1232 }
186 1233 if(painted) return 1;
187 if(mpi){ 1234 switch(blit_frame){
188 // if(planar) 1235 case 3:
189 // video_out->draw_slice(mpi->planes,mpi->stride,sh_video->disp_w,sh_video->disp_h,0,0); 1236 if(planar){
190 // else 1237 mpi->stride[0]=sh_video->disp_w;
191 // video_out->draw_frame(mpi->planes); 1238 mpi->stride[1]=mpi->stride[2]=sh_video->disp_w/2;
192 1239 mpi->planes[0]=sh_video->our_out_buffer;
1240 mpi->planes[2]=mpi->planes[0]+sh_video->disp_w*sh_video->disp_h;
1241 mpi->planes[1]=mpi->planes[2]+sh_video->disp_w*sh_video->disp_h/4;
1242 } else {
1243 mpi->planes[0]=sh_video->our_out_buffer;
1244 mpi->stride[0]=sh_video->disp_w*mpi->bpp;
1245 if(sh_video->bih && sh_video->bih->biSize==1064)
1246 mpi->planes[1]=&sh_video->bih[1]; // pointer to palette
1247 else
1248 mpi->planes[1]=NULL;
1249 }
1250 //#define VFM_RAW_POSTPROC
1251 #ifdef VFM_RAW_POSTPROC
1252 if (sh_video->codec->driver == VFM_RAW)
1253 {
1254 mp_dbg(MSGT_DECVIDEO, MSGL_V, "Postprocessing raw %s!\n",
1255 vo_format_name(out_fmt));
1256 switch(out_fmt)
1257 {
1258 case IMGFMT_YV12:
1259 postprocess(planes, stride[0], planes, stride[0],
1260 sh_video->disp_w, sh_video->disp_h, planes[0],
1261 0, /*0x20000*/divx_quality);
1262 break;
1263 // case IMGFMT_UYVY:
1264 // uyvytoyv12(start, planes[0], planes[1], planes[2],
1265 // sh_video->disp_w, sh_video->disp_h, stride[0], stride[1],
1266 // sh_video->disp_w*2);
1267 // postprocess(planes, stride[0], planes, stride[0],
1268 // sh_video->disp_w, sh_video->disp_h, planes[0],
1269 // 0, /*0x20000*/divx_quality);
1270 // break;
1271 default:
1272 mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Unsuitable outformat (%s) for raw pp!\n",
1273 vo_format_name(out_fmt));
1274 }
1275 }
1276 #endif
1277 case 2:
1278 #ifdef USE_LIBVO2
1279 if(planar)
1280 vo2_draw_slice(video_out,planes,stride,sh_video->disp_w,sh_video->disp_h,0,0);
1281 else
1282 vo2_draw_frame(video_out,planes[0],sh_video->disp_w,sh_video->disp_w,sh_video->disp_h);
1283 #else
1284 if(planar)
1285 video_out->draw_slice(mpi->planes,mpi->stride,sh_video->disp_w,sh_video->disp_h,0,0);
1286 else
1287 video_out->draw_frame(mpi->planes);
1288 #endif
193 t2=GetTimer()-t2; 1289 t2=GetTimer()-t2;
194 tt=t2*0.000001f; 1290 tt=t2*0.000001f;
195 vout_time_usage+=tt; 1291 vout_time_usage+=tt;
196 if(benchmark) 1292 if(benchmark)
197 { 1293 {
198 if(tt > max_vout_time_usage) max_vout_time_usage = tt; 1294 if(tt > max_vout_time_usage) max_vout_time_usage = tt;
199 cur_vout_time_usage=tt; 1295 cur_vout_time_usage=tt;
200 } 1296 }
201 blit_frame=1; 1297 blit_frame=1;
1298 break;
202 } 1299 }
203 1300
204 return blit_frame; 1301 return blit_frame;
205 } 1302 }
206 1303