Mercurial > mplayer.hg
annotate libmpcodecs/vd_odivx.c @ 12310:da00c08d8279
DVB now supports multiple cards, patch by Nico Sabbi.
author | diego |
---|---|
date | Tue, 27 Apr 2004 01:34:54 +0000 |
parents | d275152390ee |
children | a1807995e2ab |
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 | |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
16 "DivX5Linux lib (odivx compat.)", |
4968 | 17 #else |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
18 #ifdef DECORE_XVID |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
19 "XviD lib (odivx compat.)", |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
20 #else |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
21 "DivX4Linux lib (odivx compat.)", |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
22 #endif |
4968 | 23 #endif |
24 #else | |
25 "Opendivx 0.48 codec", | |
26 #endif | |
27 "odivx", | |
28 "A'rpi", | |
29 #ifdef NEW_DECORE | |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
30 #ifdef DECORE_XVID |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
31 "http://www.xvid.com", |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
32 #else |
4968 | 33 "http://www.divx.com", |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
34 #endif |
4968 | 35 #else |
36 "http://www.projectmayo.org", | |
37 #endif | |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
38 #ifdef NEW_DECORE |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
39 "native binary codec" |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
40 #else |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
41 "native codec" |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
42 #endif |
4968 | 43 }; |
44 | |
45 LIBVD_EXTERN(odivx) | |
46 | |
47 #ifndef NEW_DECORE | |
48 #include "opendivx/decore.h" | |
5011
d53725339d5d
postprocess.h requires for GET_PP_QUALITY_MAX - patch by Fredrik Kuivinen
arpi
parents:
5003
diff
changeset
|
49 #include "postproc/postprocess.h" |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
8040
diff
changeset
|
50 #elif DECORE_XVID |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
51 #include <divx4.h> |
4968 | 52 #else |
53 #include <decore.h> | |
54 #endif | |
55 | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
56 #ifndef DECORE_VERSION |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
57 #define DECORE_VERSION 0 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
58 #endif |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
59 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
60 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
61 static void* dec_handle = NULL; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
62 #endif |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
63 |
4968 | 64 //**************************************************************************// |
65 // The OpenDivX stuff: | |
66 //**************************************************************************// | |
67 | |
68 #ifndef NEW_DECORE | |
69 | |
70 static unsigned char *opendivx_src[3]; | |
71 static int opendivx_stride[3]; | |
72 | |
73 // callback, the opendivx decoder calls this for each frame: | |
74 void convert_linux(unsigned char *puc_y, int stride_y, | |
75 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
76 unsigned char *bmp, int width_y, int height_y){ | |
77 | |
78 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
79 | |
80 opendivx_src[0]=puc_y; | |
81 opendivx_src[1]=puc_u; | |
82 opendivx_src[2]=puc_v; | |
83 | |
84 opendivx_stride[0]=stride_y; | |
85 opendivx_stride[1]=stride_uv; | |
86 opendivx_stride[2]=stride_uv; | |
87 } | |
88 #endif | |
89 | |
90 | |
91 // to set/get/query special features/parameters | |
92 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
93 switch(cmd){ | |
94 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
95 #ifdef NEW_DECORE | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
96 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
97 return 6; // divx4linux >= 5.0.5 -> 0..60 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
98 #else |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
99 return 10; // divx4linux < 5.0.5 -> 0..100 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
100 #endif |
4968 | 101 #else |
8040 | 102 return PP_QUALITY_MAX; // for opendivx |
4968 | 103 #endif |
104 case VDCTRL_SET_PP_LEVEL: { | |
105 int quality=*((int*)arg); | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
106 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
107 int32_t iInstruction, iPostproc; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
108 if(quality<0 || quality>6) quality=6; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
109 iInstruction = DEC_ADJ_POSTPROCESSING | DEC_ADJ_SET; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
110 iPostproc = quality*10; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
111 decore(dec_handle, DEC_OPT_ADJUST, &iInstruction, &iPostproc); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
112 #else |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
113 DEC_SET dec_set; |
4968 | 114 #ifdef NEW_DECORE |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
115 if(quality<0 || quality>10) quality=10; |
4968 | 116 dec_set.postproc_level=quality*10; |
117 #else | |
8040 | 118 if(quality<0 || quality>PP_QUALITY_MAX) quality=PP_QUALITY_MAX; |
4968 | 119 dec_set.postproc_level=getPpModeForQuality(quality); |
120 #endif | |
121 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
122 #endif |
4968 | 123 return CONTROL_OK; |
124 } | |
125 | |
126 } | |
127 | |
128 return CONTROL_UNKNOWN; | |
129 } | |
130 | |
131 // init driver | |
132 static int init(sh_video_t *sh){ | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
133 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
134 DEC_INIT dec_init; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
135 int iSize=sizeof(DivXBitmapInfoHeader); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
136 DivXBitmapInfoHeader* pbi=malloc(iSize); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
137 int32_t iInstruction; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
138 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
139 memset(&dec_init, 0, sizeof(dec_init)); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
140 memset(pbi, 0, iSize); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
141 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
142 switch(sh->format) { |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
143 case mmioFOURCC('D','I','V','3'): |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
144 dec_init.codec_version = 311; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
145 break; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
146 case mmioFOURCC('D','I','V','X'): |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
147 dec_init.codec_version = 412; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
148 break; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
149 case mmioFOURCC('D','X','5','0'): |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
150 default: // Fallback to DivX 5 behaviour |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
151 dec_init.codec_version = 500; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
152 } |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
153 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
154 // no smoothing of the CPU load |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
155 dec_init.smooth_playback = 0; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
156 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
157 pbi->biSize=iSize; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
158 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
159 pbi->biCompression=mmioFOURCC('U','S','E','R'); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
160 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
161 pbi->biWidth = sh->disp_w; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
162 pbi->biHeight = sh->disp_h; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
163 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
164 decore(&dec_handle, DEC_OPT_INIT, &dec_init, NULL); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
165 decore(dec_handle, DEC_OPT_SETOUT, pbi, NULL); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
166 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
167 iInstruction = DEC_ADJ_POSTPROCESSING | DEC_ADJ_SET; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
168 decore(dec_handle, DEC_OPT_ADJUST, &iInstruction, &divx_quality); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
169 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
170 free(pbi); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
171 #else // DECORE_VERSION < 20021112 |
4968 | 172 DEC_PARAM dec_param; |
5003 | 173 DEC_SET dec_set; |
5173 | 174 |
175 #ifndef NEW_DECORE | |
176 if(sh->format==mmioFOURCC('D','I','V','3')){ | |
177 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n"); | |
178 return 0; // not supported | |
179 } | |
180 #endif | |
181 #ifndef DECORE_DIVX5 | |
182 if(sh->format==mmioFOURCC('D','X','5','0')){ | |
183 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n"); | |
184 return 0; // not supported | |
185 } | |
186 #endif | |
187 | |
4968 | 188 memset(&dec_param,0,sizeof(dec_param)); |
189 #ifdef NEW_DECORE | |
190 dec_param.output_format=DEC_USER; | |
191 #else | |
192 dec_param.color_depth = 32; | |
193 #endif | |
4997 | 194 #ifdef DECORE_DIVX5 |
5247 | 195 switch(sh->format) { |
196 case mmioFOURCC('D','I','V','3'): | |
197 dec_param.codec_version = 311; | |
198 break; | |
199 case mmioFOURCC('D','I','V','X'): | |
200 dec_param.codec_version = 400; | |
201 break; | |
202 case mmioFOURCC('D','X','5','0'): | |
203 default: // Fallback to DivX 5 behaviour | |
204 dec_param.codec_version = 500; | |
205 } | |
4997 | 206 dec_param.build_number = 0; |
207 #endif | |
4968 | 208 dec_param.x_dim = sh->disp_w; |
209 dec_param.y_dim = sh->disp_h; | |
210 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 211 |
212 dec_set.postproc_level = divx_quality; | |
213 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
214 #endif // DECORE_VERSION |
4968 | 215 |
216 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); | |
217 | |
5124 | 218 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); |
4968 | 219 } |
220 | |
221 // uninit driver | |
222 static void uninit(sh_video_t *sh){ | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
223 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
224 decore(dec_handle, DEC_OPT_RELEASE, NULL, NULL); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
225 dec_handle = NULL; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
226 #else |
4968 | 227 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
228 #endif |
4968 | 229 } |
230 | |
231 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
232 | |
233 // decode a frame | |
234 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
235 mp_image_t* mpi; | |
236 DEC_FRAME dec_frame; | |
237 #ifdef NEW_DECORE | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
238 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
239 DEC_FRAME_INFO dec_pic; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
240 #else |
4968 | 241 DEC_PICTURE dec_pic; |
242 #endif | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
243 #endif |
4968 | 244 |
245 if(len<=0) return NULL; // skipped frame | |
246 | |
247 dec_frame.length = len; | |
248 dec_frame.bitstream = data; | |
249 dec_frame.render_flag = (flags&3)?0:1; | |
250 | |
251 #ifdef NEW_DECORE | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
252 #if DECORE_VERSION >= 20021112 |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
253 dec_frame.stride=sh->disp_w; |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
254 decore(dec_handle, DEC_OPT_FRAME, &dec_frame, &dec_pic); |
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
255 #else |
4968 | 256 dec_frame.bmp=&dec_pic; |
257 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
5037 | 258 #ifndef DEC_OPT_FRAME_311 |
4968 | 259 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); |
260 #else | |
261 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
262 #endif | |
10252
d275152390ee
I've found some time to implement the encoding support for the new
arpi
parents:
9300
diff
changeset
|
263 #endif |
4968 | 264 #else |
265 // opendivx: | |
266 opendivx_src[0]=NULL; | |
267 decore(0x123, 0, &dec_frame, NULL); | |
268 #endif | |
269 | |
270 if(flags&3) return NULL; // framedrop | |
271 | |
272 #ifdef NEW_DECORE | |
273 if(!dec_pic.y) return NULL; // bad frame | |
274 #else | |
275 if(!opendivx_src[0]) return NULL; // bad frame | |
276 #endif | |
277 | |
278 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, | |
279 sh->disp_w, sh->disp_h); | |
280 if(!mpi) return NULL; | |
281 | |
282 #ifdef NEW_DECORE | |
283 mpi->planes[0]=dec_pic.y; | |
284 mpi->planes[1]=dec_pic.u; | |
285 mpi->planes[2]=dec_pic.v; | |
286 mpi->stride[0]=dec_pic.stride_y; | |
287 mpi->stride[1]=mpi->stride[2]=dec_pic.stride_uv; | |
288 #else | |
289 mpi->planes[0]=opendivx_src[0]; | |
290 mpi->planes[1]=opendivx_src[1]; | |
291 mpi->planes[2]=opendivx_src[2]; | |
292 mpi->stride[0]=opendivx_stride[0]; | |
293 mpi->stride[1]=opendivx_stride[1]; | |
294 mpi->stride[2]=opendivx_stride[2]; | |
295 #endif | |
296 | |
297 return mpi; | |
298 } | |
299 | |
300 #endif | |
301 |