typo fixes
[mplayer/greg.git] / libmpcodecs / vd_dshow.c
blob6f0923636f64c07f3dea12942499bbbfc4edbfff
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdarg.h>
5 #include "config.h"
6 #ifdef USE_DIRECTSHOW
8 #include "mp_msg.h"
9 #include "help_mp.h"
11 #include "vd_internal.h"
13 #include "loader/dshow/DS_VideoDecoder.h"
15 static vd_info_t info = {
16 "DirectShow video codecs",
17 "dshow",
18 "A'rpi",
19 "based on http://avifile.sf.net",
20 "win32 codecs"
23 LIBVD_EXTERN(dshow)
25 // to set/get/query special features/parameters
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
27 switch(cmd){
28 case VDCTRL_QUERY_MAX_PP_LEVEL:
29 return 4;
30 case VDCTRL_SET_PP_LEVEL:
31 if(!sh->context) return CONTROL_ERROR;
32 DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg));
33 return CONTROL_OK;
35 case VDCTRL_SET_EQUALIZER: {
36 va_list ap;
37 int value;
38 va_start(ap, arg);
39 value=va_arg(ap, int);
40 va_end(ap);
41 if(DS_VideoDecoder_SetValue(sh->context,arg,50+value/2)==0)
42 return CONTROL_OK;
43 return CONTROL_FALSE;
47 return CONTROL_UNKNOWN;
50 // init driver
51 static int init(sh_video_t *sh){
52 unsigned int out_fmt;
54 /* Hack for VSSH codec: new dll can't decode old files
55 * In my samples old files have no extradata, so use that info
56 * to decide what dll should be used (here and in vd_vfw).
58 if (!strcmp(sh->codec->dll, "vsshdsd.dll") && (sh->bih->biSize == 40))
59 return 0;
61 if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
62 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
63 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
64 return 0;
66 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
67 out_fmt=sh->codec->outfmt[sh->outfmtidx];
68 switch(out_fmt){
69 case IMGFMT_YUY2:
70 case IMGFMT_UYVY:
71 DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
72 case IMGFMT_YV12:
73 case IMGFMT_I420:
74 case IMGFMT_IYUV:
75 DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
76 case IMGFMT_YVU9:
77 DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
78 default:
79 DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
81 DS_SetAttr_DivX("Quality",divx_quality);
82 DS_VideoDecoder_StartInternal(sh->context);
83 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DShowInitOK);
84 return 1;
87 // uninit driver
88 static void uninit(sh_video_t *sh){
89 DS_VideoDecoder_Destroy(sh->context);
92 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
94 // decode a frame
95 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
96 mp_image_t* mpi;
97 if(len<=0) return NULL; // skipped frame
99 if(flags&3){
100 // framedrop:
101 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
102 return NULL;
105 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
106 sh->disp_w, sh->disp_h);
108 if(!mpi){ // temporary!
109 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
110 return NULL;
113 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]);
115 return mpi;
118 #endif