Mercurial > mplayer.hg
comparison libmpcodecs/vd_dshow.c @ 4958:ca6f6b35baf4
vd_dshow added
author | arpi |
---|---|
date | Wed, 06 Mar 2002 22:03:46 +0000 |
parents | |
children | eb57973314ae |
comparison
equal
deleted
inserted
replaced
4957:2826b2e5cbd3 | 4958:ca6f6b35baf4 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 | |
4 #include "config.h" | |
5 #ifdef USE_DIRECTSHOW | |
6 | |
7 #include "mp_msg.h" | |
8 #include "help_mp.h" | |
9 | |
10 | |
11 #include "codec-cfg.h" | |
12 #include "../libvo/img_format.h" | |
13 | |
14 #include "stream.h" | |
15 #include "demuxer.h" | |
16 #include "stheader.h" | |
17 | |
18 #include "vd.h" | |
19 #include "vd_internal.h" | |
20 | |
21 #include "loader/dshow/DS_VideoDecoder.h" | |
22 | |
23 static vd_info_t info = { | |
24 "DirectShow video codecs", | |
25 "dshow", | |
26 VFM_DSHOW, | |
27 "A'rpi", | |
28 "based on http://avifile.sf.net", | |
29 "win32 codecs" | |
30 }; | |
31 | |
32 LIBVD_EXTERN(dshow) | |
33 | |
34 // to set/get/query special features/parameters | |
35 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
36 switch(cmd){ | |
37 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
38 return 4; | |
39 case VDCTRL_SET_PP_LEVEL: | |
40 if(!sh->context) return CONTROL_ERROR; | |
41 DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg)); | |
42 return CONTROL_OK; | |
43 | |
44 // TODO: query/set video options (brightness contrast etc) | |
45 // DS_VideoDecoder_SetValue(ds_vdec,item,value); | |
46 | |
47 } | |
48 return CONTROL_UNKNOWN; | |
49 } | |
50 | |
51 // init driver | |
52 static int init(sh_video_t *sh){ | |
53 unsigned int out_fmt; | |
54 if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){ | |
55 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll); | |
56 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); | |
57 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n"); | |
58 return 0; | |
59 } | |
60 mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2); | |
61 out_fmt=sh->codec->outfmt[sh->outfmtidx]; | |
62 switch(out_fmt){ | |
63 case IMGFMT_YUY2: | |
64 case IMGFMT_UYVY: | |
65 DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV | |
66 case IMGFMT_YV12: | |
67 case IMGFMT_I420: | |
68 case IMGFMT_IYUV: | |
69 DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV | |
70 default: | |
71 DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR | |
72 } | |
73 DS_VideoDecoder_StartInternal(sh->context); | |
74 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n"); | |
75 return 1; | |
76 } | |
77 | |
78 // uninit driver | |
79 static void uninit(sh_video_t *sh){ | |
80 DS_VideoDecoder_Destroy(sh->context); | |
81 } | |
82 | |
83 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
84 | |
85 // decode a frame | |
86 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
87 mp_image_t* mpi; | |
88 if(len<=0) return NULL; // skipped frame | |
89 | |
90 if(flags&3){ | |
91 // framedrop: | |
92 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0); | |
93 return NULL; | |
94 } | |
95 | |
96 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/, | |
97 sh->disp_w, sh->disp_h); | |
98 | |
99 if(!mpi){ // temporary! | |
100 printf("couldn't allocate image for cinepak codec\n"); | |
101 return NULL; | |
102 } | |
103 | |
104 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]); | |
105 | |
106 return mpi; | |
107 } | |
108 | |
109 #endif |