comparison dec_video.c @ 3062:7ea7e5fce639

NEW_DSHOW added (for dshow C version)
author arpi
date Thu, 22 Nov 2001 03:15:49 +0000
parents 757c3ab1a45a
children 3c10aeb3f441
comparison
equal deleted inserted replaced
3061:6d8116bbf3b2 3062:7ea7e5fce639
1
2 //#define NEW_DSHOW
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
51 extern picture_t *picture; // exported from libmpeg2/decode.c 53 extern picture_t *picture; // exported from libmpeg2/decode.c
52 54
53 int divx_quality=0; 55 int divx_quality=0;
54 56
55 #ifdef USE_DIRECTSHOW 57 #ifdef USE_DIRECTSHOW
58 #ifdef NEW_DSHOW
59 //#include "loader/dshow/DS_VideoDecoder.h"
60 //static DS_VideoDecoder* ds_vdec=NULL;
61 typedef struct _CodecInfo
62 {
63 char* dll;
64 GUID* guid;
65 }CodecInfo;
66 static void* ds_vdec=NULL;
67 #else
56 #include "loader/DirectShow/DS_VideoDec.h" 68 #include "loader/DirectShow/DS_VideoDec.h"
69 #endif
57 #endif 70 #endif
58 71
59 #ifdef USE_LIBAVCODEC 72 #ifdef USE_LIBAVCODEC
60 #ifdef USE_LIBAVCODEC_SO 73 #ifdef USE_LIBAVCODEC_SO
61 #include <libffmpeg/avcodec.h> 74 #include <libffmpeg/avcodec.h>
175 break; 188 break;
176 #endif 189 #endif
177 #ifdef USE_DIRECTSHOW 190 #ifdef USE_DIRECTSHOW
178 case VFM_DSHOW: { 191 case VFM_DSHOW: {
179 if(quality<0 || quality>4) quality=4; 192 if(quality<0 || quality>4) quality=4;
193 #ifdef NEW_DSHOW
194 DS_VideoDecoder_SetValue(ds_vdec,"Quality",quality);
195 #else
180 DS_SetValue_DivX("Quality",quality); 196 DS_SetValue_DivX("Quality",quality);
197 #endif
181 } 198 }
182 break; 199 break;
183 #endif 200 #endif
184 #ifdef MPEG12_POSTPROC 201 #ifdef MPEG12_POSTPROC
185 case VFM_MPEG: { 202 case VFM_MPEG: {
210 } 227 }
211 } 228 }
212 229
213 int set_video_colors(sh_video_t *sh_video,char *item,int value){ 230 int set_video_colors(sh_video_t *sh_video,char *item,int value){
214 #ifdef USE_DIRECTSHOW 231 #ifdef USE_DIRECTSHOW
232 #ifndef NEW_DSHOW
215 if(sh_video->codec->driver==VFM_DSHOW){ 233 if(sh_video->codec->driver==VFM_DSHOW){
234 #ifdef NEW_DSHOW
235 DS_VideoDecoder_SetValue(ds_vdec,item,value);
236 #else
216 DS_SetValue_DivX(item,value); 237 DS_SetValue_DivX(item,value);
238 #endif
217 return 1; 239 return 1;
218 } 240 }
241 #endif
219 #endif 242 #endif
220 243
221 #ifdef NEW_DECORE 244 #ifdef NEW_DECORE
222 #ifdef DECORE_VERSION 245 #ifdef DECORE_VERSION
223 #if DECORE_VERSION >= 20011010 246 #if DECORE_VERSION >= 20011010
274 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec); 297 mp_msg(MSGT_DECVIDEO,MSGL_ERR, MSGTR_CantCloseCodec);
275 break; 298 break;
276 #endif 299 #endif
277 #ifdef USE_DIRECTSHOW 300 #ifdef USE_DIRECTSHOW
278 case VFM_DSHOW: // Win32/DirectShow 301 case VFM_DSHOW: // Win32/DirectShow
302 #ifdef NEW_DSHOW
303 if(ds_vdec){ DS_VideoDecoder_Destroy(ds_vdec); ds_vdec=NULL; }
304 #else
279 DS_VideoDecoder_Close(); 305 DS_VideoDecoder_Close();
306 #endif
280 break; 307 break;
281 #endif 308 #endif
282 case VFM_MPEG: 309 case VFM_MPEG:
283 mpeg2_free_image_buffers (picture); 310 mpeg2_free_image_buffers (picture);
284 break; 311 break;
331 #ifndef USE_DIRECTSHOW 358 #ifndef USE_DIRECTSHOW
332 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDShowSupport); 359 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_NoDShowSupport);
333 return 0; 360 return 0;
334 #else 361 #else
335 int bpp; 362 int bpp;
363 #ifdef NEW_DSHOW
364 CodecInfo ci;
365 ci.dll=sh_video->codec->dll;
366 ci.guid=&sh_video->codec->guid;
367 if(!(ds_vdec=DS_VideoDecoder_Create(&ci,sh_video->bih, 0, 0))){
368 #else
336 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ 369 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){
370 #endif
337 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ 371 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){
338 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_video->codec->dll); 372 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_video->codec->dll);
339 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); 373 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
340 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); 374 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n");
341 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); 375 // mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n");
344 378
345 switch(out_fmt){ 379 switch(out_fmt){
346 case IMGFMT_YUY2: 380 case IMGFMT_YUY2:
347 case IMGFMT_UYVY: 381 case IMGFMT_UYVY:
348 bpp=16; 382 bpp=16;
383 #ifdef NEW_DSHOW
384 DS_VideoDecoder_SetDestFmt(ds_vdec,16,out_fmt);break; // packed YUV
385 #else
349 DS_VideoDecoder_SetDestFmt(16,out_fmt);break; // packed YUV 386 DS_VideoDecoder_SetDestFmt(16,out_fmt);break; // packed YUV
387 #endif
350 case IMGFMT_YV12: 388 case IMGFMT_YV12:
351 case IMGFMT_I420: 389 case IMGFMT_I420:
352 case IMGFMT_IYUV: 390 case IMGFMT_IYUV:
353 bpp=12; 391 bpp=12;
392 #ifdef NEW_DSHOW
393 DS_VideoDecoder_SetDestFmt(ds_vdec,12,out_fmt);break; // planar YUV
394 #else
354 DS_VideoDecoder_SetDestFmt(12,out_fmt);break; // planar YUV 395 DS_VideoDecoder_SetDestFmt(12,out_fmt);break; // planar YUV
396 #endif
355 default: 397 default:
356 bpp=((out_fmt&255)+7)&(~7); 398 bpp=((out_fmt&255)+7)&(~7);
399 #ifdef NEW_DSHOW
400 DS_VideoDecoder_SetDestFmt(ds_vdec,out_fmt&255,0); // RGB/BGR
401 #else
357 DS_VideoDecoder_SetDestFmt(out_fmt&255,0); // RGB/BGR 402 DS_VideoDecoder_SetDestFmt(out_fmt&255,0); // RGB/BGR
403 #endif
358 } 404 }
359 405
360 sh_video->our_out_buffer = (char*)memalign(64,sh_video->disp_w*sh_video->disp_h*bpp/8); // FIXME!!! 406 sh_video->our_out_buffer = (char*)memalign(64,sh_video->disp_w*sh_video->disp_h*bpp/8); // FIXME!!!
361 407
408 DS_SetAttr_DivX("Quality",divx_quality);
409
410 #ifdef NEW_DSHOW
411 DS_VideoDecoder_StartInternal(ds_vdec);
412 #else
362 DS_VideoDecoder_Start(); 413 DS_VideoDecoder_Start();
363 414 #endif
364 DS_SetAttr_DivX("Quality",divx_quality);
365 // printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) ); 415 // printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) );
366 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); 416 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) );
367 417
368 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n"); 418 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n");
369 break; 419 break;
604 break; 654 break;
605 } 655 }
606 #endif 656 #endif
607 #ifdef USE_DIRECTSHOW 657 #ifdef USE_DIRECTSHOW
608 case VFM_DSHOW: { // W32/DirectShow 658 case VFM_DSHOW: { // W32/DirectShow
609 if(drop_frame<2) DS_VideoDecoder_DecodeFrame(start, in_size, 0, !drop_frame); 659 if(drop_frame<2)
660 #ifdef NEW_DSHOW
661 DS_VideoDecoder_DecodeInternal(ds_vdec, start, in_size, 0, drop_frame ? 0 : sh_video->our_out_buffer);
662 #else
663 DS_VideoDecoder_DecodeFrame(start, in_size, 0, !drop_frame);
664 #endif
610 if(!drop_frame && sh_video->our_out_buffer) blit_frame=3; 665 if(!drop_frame && sh_video->our_out_buffer) blit_frame=3;
611 break; 666 break;
612 } 667 }
613 #endif 668 #endif
614 #ifdef USE_LIBAVCODEC 669 #ifdef USE_LIBAVCODEC