typo fixes
[mplayer/greg.git] / libmpcodecs / vd_dmo.c
blob737c0e23749aaa4db294bf74b1e88817303fafbc
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/dmo/DMO_VideoDecoder.h"
15 static vd_info_t info = {
16 "DMO video codecs",
17 "dmo",
18 "A'rpi",
19 "based on http://avifile.sf.net",
20 "win32 codecs"
23 LIBVD_EXTERN(dmo)
25 // to set/get/query special features/parameters
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
27 return CONTROL_UNKNOWN;
30 // init driver
31 static int init(sh_video_t *sh){
32 unsigned int out_fmt;
33 if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
34 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
35 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
36 return 0;
38 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
39 out_fmt=sh->codec->outfmt[sh->outfmtidx];
40 switch(out_fmt){
41 case IMGFMT_YUY2:
42 case IMGFMT_UYVY:
43 DMO_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
44 case IMGFMT_YV12:
45 case IMGFMT_I420:
46 case IMGFMT_IYUV:
47 DMO_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
48 case IMGFMT_YVU9:
49 DMO_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
50 default:
51 DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
53 DMO_VideoDecoder_StartInternal(sh->context);
54 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK);
55 return 1;
58 // uninit driver
59 static void uninit(sh_video_t *sh){
60 DMO_VideoDecoder_Destroy(sh->context);
63 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
65 // decode a frame
66 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
67 mp_image_t* mpi;
68 if(len<=0) return NULL; // skipped frame
70 if(flags&3){
71 // framedrop:
72 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
73 return NULL;
76 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
77 sh->disp_w, sh->disp_h);
79 if(!mpi){ // temporary!
80 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
81 return NULL;
84 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 1, mpi->planes[0]);
86 return mpi;
89 #endif