Mercurial > mplayer.hg
annotate libmpcodecs/vd_odivx.c @ 5056:8d793d9980c1
fix dga key handling
author | atmos4 |
---|---|
date | Tue, 12 Mar 2002 22:11:35 +0000 |
parents | 0ef48d850bc9 |
children | 3dcbf67c0de0 |
rev | line source |
---|---|
4968 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <assert.h> | |
4 | |
5 #include "config.h" | |
6 #include "mp_msg.h" | |
7 #include "help_mp.h" | |
8 | |
9 #ifdef USE_DIVX | |
10 | |
11 #include "vd_internal.h" | |
12 | |
13 static vd_info_t info = { | |
14 #ifdef NEW_DECORE | |
15 #ifdef DECORE_DIVX5 | |
16 "DivX5Linux lib (odivx mode)", | |
17 #else | |
18 "DivX4Linux lib (odivx mode)", | |
19 #endif | |
20 #else | |
21 "Opendivx 0.48 codec", | |
22 #endif | |
23 "odivx", | |
24 VFM_ODIVX, | |
25 "A'rpi", | |
26 #ifdef NEW_DECORE | |
27 "http://www.divx.com", | |
28 #else | |
29 "http://www.projectmayo.org", | |
30 #endif | |
31 "native codecs" | |
32 }; | |
33 | |
34 LIBVD_EXTERN(odivx) | |
35 | |
36 #ifndef NEW_DECORE | |
37 #include "opendivx/decore.h" | |
5011
d53725339d5d
postprocess.h requires for GET_PP_QUALITY_MAX - patch by Fredrik Kuivinen
arpi
parents:
5003
diff
changeset
|
38 #include "postproc/postprocess.h" |
4968 | 39 #else |
40 #include <decore.h> | |
41 #endif | |
42 | |
43 //**************************************************************************// | |
44 // The OpenDivX stuff: | |
45 //**************************************************************************// | |
46 | |
47 #ifndef NEW_DECORE | |
48 | |
49 static unsigned char *opendivx_src[3]; | |
50 static int opendivx_stride[3]; | |
51 | |
52 // callback, the opendivx decoder calls this for each frame: | |
53 void convert_linux(unsigned char *puc_y, int stride_y, | |
54 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
55 unsigned char *bmp, int width_y, int height_y){ | |
56 | |
57 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
58 | |
59 opendivx_src[0]=puc_y; | |
60 opendivx_src[1]=puc_u; | |
61 opendivx_src[2]=puc_v; | |
62 | |
63 opendivx_stride[0]=stride_y; | |
64 opendivx_stride[1]=stride_uv; | |
65 opendivx_stride[2]=stride_uv; | |
66 } | |
67 #endif | |
68 | |
69 | |
70 // to set/get/query special features/parameters | |
71 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
72 switch(cmd){ | |
73 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
74 #ifdef NEW_DECORE | |
75 return 9; // for divx4linux | |
76 #else | |
77 return GET_PP_QUALITY_MAX; // for opendivx | |
78 #endif | |
79 case VDCTRL_SET_PP_LEVEL: { | |
80 DEC_SET dec_set; | |
81 int quality=*((int*)arg); | |
82 #ifdef NEW_DECORE | |
83 if(quality<0 || quality>9) quality=9; | |
84 dec_set.postproc_level=quality*10; | |
85 #else | |
86 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX; | |
87 dec_set.postproc_level=getPpModeForQuality(quality); | |
88 #endif | |
89 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
90 return CONTROL_OK; | |
91 } | |
92 | |
93 } | |
94 | |
95 return CONTROL_UNKNOWN; | |
96 } | |
97 | |
98 // init driver | |
99 static int init(sh_video_t *sh){ | |
100 DEC_PARAM dec_param; | |
5003 | 101 DEC_SET dec_set; |
4968 | 102 memset(&dec_param,0,sizeof(dec_param)); |
103 #ifdef NEW_DECORE | |
104 dec_param.output_format=DEC_USER; | |
105 #else | |
106 dec_param.color_depth = 32; | |
107 #endif | |
4997 | 108 #ifdef DECORE_DIVX5 |
109 dec_param.codec_version = (sh->format==mmioFOURCC('D','I','V','3'))?311:500; | |
110 dec_param.build_number = 0; | |
111 #endif | |
4968 | 112 dec_param.x_dim = sh->disp_w; |
113 dec_param.y_dim = sh->disp_h; | |
114 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 115 |
116 dec_set.postproc_level = divx_quality; | |
117 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
4968 | 118 |
119 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); | |
120 | |
121 mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); | |
122 return 1; | |
123 } | |
124 | |
125 // uninit driver | |
126 static void uninit(sh_video_t *sh){ | |
127 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
128 } | |
129 | |
130 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
131 | |
132 // decode a frame | |
133 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
134 mp_image_t* mpi; | |
135 DEC_FRAME dec_frame; | |
136 #ifdef NEW_DECORE | |
137 DEC_PICTURE dec_pic; | |
138 #endif | |
139 | |
140 if(len<=0) return NULL; // skipped frame | |
141 | |
142 dec_frame.length = len; | |
143 dec_frame.bitstream = data; | |
144 dec_frame.render_flag = (flags&3)?0:1; | |
145 | |
146 #ifdef NEW_DECORE | |
147 dec_frame.bmp=&dec_pic; | |
148 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
5037 | 149 #ifndef DEC_OPT_FRAME_311 |
4968 | 150 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); |
151 #else | |
152 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
153 #endif | |
154 #else | |
155 // opendivx: | |
156 opendivx_src[0]=NULL; | |
157 decore(0x123, 0, &dec_frame, NULL); | |
158 #endif | |
159 | |
160 if(flags&3) return NULL; // framedrop | |
161 | |
162 #ifdef NEW_DECORE | |
163 if(!dec_pic.y) return NULL; // bad frame | |
164 #else | |
165 if(!opendivx_src[0]) return NULL; // bad frame | |
166 #endif | |
167 | |
168 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, | |
169 sh->disp_w, sh->disp_h); | |
170 if(!mpi) return NULL; | |
171 | |
172 #ifdef NEW_DECORE | |
173 mpi->planes[0]=dec_pic.y; | |
174 mpi->planes[1]=dec_pic.u; | |
175 mpi->planes[2]=dec_pic.v; | |
176 mpi->stride[0]=dec_pic.stride_y; | |
177 mpi->stride[1]=mpi->stride[2]=dec_pic.stride_uv; | |
178 #else | |
179 mpi->planes[0]=opendivx_src[0]; | |
180 mpi->planes[1]=opendivx_src[1]; | |
181 mpi->planes[2]=opendivx_src[2]; | |
182 mpi->stride[0]=opendivx_stride[0]; | |
183 mpi->stride[1]=opendivx_stride[1]; | |
184 mpi->stride[2]=opendivx_stride[2]; | |
185 #endif | |
186 | |
187 return mpi; | |
188 } | |
189 | |
190 #endif | |
191 |