10 #include "vd_internal.h"
12 #include "loader/dshow/DS_VideoDecoder.h"
14 static vd_info_t info
= {
15 "DirectShow video codecs",
18 "based on http://avifile.sf.net",
24 // to set/get/query special features/parameters
25 static int control(sh_video_t
*sh
,int cmd
,void* arg
,...){
27 case VDCTRL_QUERY_MAX_PP_LEVEL
:
29 case VDCTRL_SET_PP_LEVEL
:
30 if(!sh
->context
) return CONTROL_ERROR
;
31 DS_VideoDecoder_SetValue(sh
->context
,"Quality",*((int*)arg
));
34 case VDCTRL_SET_EQUALIZER
: {
38 value
=va_arg(ap
, int);
40 if(DS_VideoDecoder_SetValue(sh
->context
,arg
,50+value
/2)==0)
46 return CONTROL_UNKNOWN
;
50 static int init(sh_video_t
*sh
){
53 /* Hack for VSSH codec: new dll can't decode old files
54 * In my samples old files have no extradata, so use that info
55 * to decide what dll should be used (here and in vd_vfw).
57 if (!strcmp(sh
->codec
->dll
, "vsshdsd.dll") && (sh
->bih
->biSize
== 40))
60 if(!(sh
->context
=DS_VideoDecoder_Open(sh
->codec
->dll
,&sh
->codec
->guid
, sh
->bih
, 0, 0))){
61 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_MissingDLLcodec
,sh
->codec
->dll
);
62 mp_msg(MSGT_DECVIDEO
,MSGL_HINT
,MSGTR_DownloadCodecPackage
);
65 if(!mpcodecs_config_vo(sh
,sh
->disp_w
,sh
->disp_h
,IMGFMT_YUY2
)) return 0;
66 out_fmt
=sh
->codec
->outfmt
[sh
->outfmtidx
];
70 DS_VideoDecoder_SetDestFmt(sh
->context
,16,out_fmt
);break; // packed YUV
74 DS_VideoDecoder_SetDestFmt(sh
->context
,12,out_fmt
);break; // planar YUV
76 DS_VideoDecoder_SetDestFmt(sh
->context
,9,out_fmt
);break;
78 DS_VideoDecoder_SetDestFmt(sh
->context
,out_fmt
&255,0); // RGB/BGR
80 DS_SetAttr_DivX("Quality",divx_quality
);
81 DS_VideoDecoder_StartInternal(sh
->context
);
82 mp_msg(MSGT_DECVIDEO
,MSGL_V
,MSGTR_DShowInitOK
);
87 static void uninit(sh_video_t
*sh
){
88 DS_VideoDecoder_Destroy(sh
->context
);
91 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
94 static mp_image_t
* decode(sh_video_t
*sh
,void* data
,int len
,int flags
){
96 if(len
<=0) return NULL
; // skipped frame
100 DS_VideoDecoder_DecodeInternal(sh
->context
, data
, len
, 0, 0);
104 mpi
=mpcodecs_get_image(sh
, MP_IMGTYPE_TEMP
, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
105 sh
->disp_w
, sh
->disp_h
);
107 if(!mpi
){ // temporary!
108 mp_msg(MSGT_DECVIDEO
,MSGL_WARN
,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec
);
112 DS_VideoDecoder_DecodeInternal(sh
->context
, data
, len
, 0, mpi
->planes
[0]);