4958
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
5003
|
3 #include <stdarg.h>
|
4958
|
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/dshow/DS_VideoDecoder.h"
|
|
14
|
|
15 static vd_info_t info = {
|
|
16 "DirectShow video codecs",
|
|
17 "dshow",
|
|
18 VFM_DSHOW,
|
|
19 "A'rpi",
|
|
20 "based on http://avifile.sf.net",
|
|
21 "win32 codecs"
|
|
22 };
|
|
23
|
|
24 LIBVD_EXTERN(dshow)
|
|
25
|
|
26 // to set/get/query special features/parameters
|
|
27 static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
28 switch(cmd){
|
|
29 case VDCTRL_QUERY_MAX_PP_LEVEL:
|
|
30 return 4;
|
|
31 case VDCTRL_SET_PP_LEVEL:
|
|
32 if(!sh->context) return CONTROL_ERROR;
|
|
33 DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg));
|
|
34 return CONTROL_OK;
|
|
35
|
5003
|
36 case VDCTRL_SET_EQUALIZER: {
|
|
37 va_list ap;
|
|
38 int value;
|
|
39 va_start(ap, arg);
|
|
40 value=va_arg(ap, int);
|
|
41 va_end(ap);
|
6802
|
42 if(DS_VideoDecoder_SetValue(sh->context,arg,50+value/2)==0)
|
5003
|
43 return CONTROL_OK;
|
|
44 return CONTROL_FALSE;
|
|
45 }
|
|
46
|
4958
|
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 }
|
5124
|
60 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
|
4958
|
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
|
6525
|
70 case IMGFMT_YVU9:
|
|
71 DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
|
4958
|
72 default:
|
|
73 DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
|
|
74 }
|
5003
|
75 DS_SetAttr_DivX("Quality",divx_quality);
|
4958
|
76 DS_VideoDecoder_StartInternal(sh->context);
|
|
77 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n");
|
|
78 return 1;
|
|
79 }
|
|
80
|
|
81 // uninit driver
|
|
82 static void uninit(sh_video_t *sh){
|
|
83 DS_VideoDecoder_Destroy(sh->context);
|
|
84 }
|
|
85
|
|
86 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
|
|
87
|
|
88 // decode a frame
|
|
89 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|
90 mp_image_t* mpi;
|
|
91 if(len<=0) return NULL; // skipped frame
|
|
92
|
|
93 if(flags&3){
|
|
94 // framedrop:
|
|
95 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
|
|
96 return NULL;
|
|
97 }
|
|
98
|
|
99 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
|
|
100 sh->disp_w, sh->disp_h);
|
|
101
|
|
102 if(!mpi){ // temporary!
|
|
103 printf("couldn't allocate image for cinepak codec\n");
|
|
104 return NULL;
|
|
105 }
|
|
106
|
|
107 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]);
|
|
108
|
|
109 return mpi;
|
|
110 }
|
|
111
|
|
112 #endif
|