8295
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <stdarg.h>
|
|
4
|
|
5 #include "config.h"
|
|
6 #ifdef USE_DIRECTSHOW
|
|
7
|
|
8 #include "mp_msg.h"
|
|
9 #include "help_mp.h"
|
|
10
|
|
11 #include "vd_internal.h"
|
|
12
|
|
13 #include "loader/dmo/DMO_VideoDecoder.h"
|
|
14
|
|
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"
|
|
21 };
|
|
22
|
|
23 LIBVD_EXTERN(dmo)
|
|
24
|
|
25 // to set/get/query special features/parameters
|
|
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
27 return CONTROL_UNKNOWN;
|
|
28 }
|
|
29
|
|
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,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
|
|
36 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.zip !\n");
|
|
37 return 0;
|
|
38 }
|
|
39 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
|
|
40 out_fmt=sh->codec->outfmt[sh->outfmtidx];
|
|
41 switch(out_fmt){
|
|
42 case IMGFMT_YUY2:
|
|
43 case IMGFMT_UYVY:
|
|
44 DMO_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
|
|
45 case IMGFMT_YV12:
|
|
46 case IMGFMT_I420:
|
|
47 case IMGFMT_IYUV:
|
|
48 DMO_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
|
|
49 case IMGFMT_YVU9:
|
|
50 DMO_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
|
|
51 default:
|
|
52 DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
|
|
53 }
|
|
54 DMO_VideoDecoder_StartInternal(sh->context);
|
|
55 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMOhow video codec init OK!\n");
|
|
56 return 1;
|
|
57 }
|
|
58
|
|
59 // uninit driver
|
|
60 static void uninit(sh_video_t *sh){
|
|
61 DMO_VideoDecoder_Destroy(sh->context);
|
|
62 }
|
|
63
|
|
64 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
|
|
65
|
|
66 // decode a frame
|
|
67 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|
68 mp_image_t* mpi;
|
|
69 if(len<=0) return NULL; // skipped frame
|
|
70
|
|
71 if(flags&3){
|
|
72 // framedrop:
|
|
73 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
|
|
74 return NULL;
|
|
75 }
|
|
76
|
|
77 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
|
|
78 sh->disp_w, sh->disp_h);
|
|
79
|
|
80 if(!mpi){ // temporary!
|
|
81 printf("couldn't allocate image for cinepak codec\n");
|
|
82 return NULL;
|
|
83 }
|
|
84
|
|
85 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 1, mpi->planes[0]);
|
|
86
|
|
87 return mpi;
|
|
88 }
|
|
89
|
|
90 #endif
|