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