Mercurial > mplayer.hg
annotate libmpcodecs/vd_odivx.c @ 9612:a9273ae50f59
what's the opposite of backport? :)
some changes ported from 0_90
author | arpi |
---|---|
date | Mon, 17 Mar 2003 00:48:26 +0000 |
parents | 32be26de0d7c |
children | d275152390ee |
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 | |
56 //**************************************************************************// | |
57 // The OpenDivX stuff: | |
58 //**************************************************************************// | |
59 | |
60 #ifndef NEW_DECORE | |
61 | |
62 static unsigned char *opendivx_src[3]; | |
63 static int opendivx_stride[3]; | |
64 | |
65 // callback, the opendivx decoder calls this for each frame: | |
66 void convert_linux(unsigned char *puc_y, int stride_y, | |
67 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
68 unsigned char *bmp, int width_y, int height_y){ | |
69 | |
70 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
71 | |
72 opendivx_src[0]=puc_y; | |
73 opendivx_src[1]=puc_u; | |
74 opendivx_src[2]=puc_v; | |
75 | |
76 opendivx_stride[0]=stride_y; | |
77 opendivx_stride[1]=stride_uv; | |
78 opendivx_stride[2]=stride_uv; | |
79 } | |
80 #endif | |
81 | |
82 | |
83 // to set/get/query special features/parameters | |
84 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
85 switch(cmd){ | |
86 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
87 #ifdef NEW_DECORE | |
88 return 9; // for divx4linux | |
89 #else | |
8040 | 90 return PP_QUALITY_MAX; // for opendivx |
4968 | 91 #endif |
92 case VDCTRL_SET_PP_LEVEL: { | |
93 DEC_SET dec_set; | |
94 int quality=*((int*)arg); | |
95 #ifdef NEW_DECORE | |
96 if(quality<0 || quality>9) quality=9; | |
97 dec_set.postproc_level=quality*10; | |
98 #else | |
8040 | 99 if(quality<0 || quality>PP_QUALITY_MAX) quality=PP_QUALITY_MAX; |
4968 | 100 dec_set.postproc_level=getPpModeForQuality(quality); |
101 #endif | |
102 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
103 return CONTROL_OK; | |
104 } | |
105 | |
106 } | |
107 | |
108 return CONTROL_UNKNOWN; | |
109 } | |
110 | |
111 // init driver | |
112 static int init(sh_video_t *sh){ | |
113 DEC_PARAM dec_param; | |
5003 | 114 DEC_SET dec_set; |
5173 | 115 |
116 #ifndef NEW_DECORE | |
117 if(sh->format==mmioFOURCC('D','I','V','3')){ | |
118 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n"); | |
119 return 0; // not supported | |
120 } | |
121 #endif | |
122 #ifndef DECORE_DIVX5 | |
123 if(sh->format==mmioFOURCC('D','X','5','0')){ | |
124 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n"); | |
125 return 0; // not supported | |
126 } | |
127 #endif | |
128 | |
4968 | 129 memset(&dec_param,0,sizeof(dec_param)); |
130 #ifdef NEW_DECORE | |
131 dec_param.output_format=DEC_USER; | |
132 #else | |
133 dec_param.color_depth = 32; | |
134 #endif | |
4997 | 135 #ifdef DECORE_DIVX5 |
5247 | 136 switch(sh->format) { |
137 case mmioFOURCC('D','I','V','3'): | |
138 dec_param.codec_version = 311; | |
139 break; | |
140 case mmioFOURCC('D','I','V','X'): | |
141 dec_param.codec_version = 400; | |
142 break; | |
143 case mmioFOURCC('D','X','5','0'): | |
144 default: // Fallback to DivX 5 behaviour | |
145 dec_param.codec_version = 500; | |
146 } | |
4997 | 147 dec_param.build_number = 0; |
148 #endif | |
4968 | 149 dec_param.x_dim = sh->disp_w; |
150 dec_param.y_dim = sh->disp_h; | |
151 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 152 |
153 dec_set.postproc_level = divx_quality; | |
154 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
4968 | 155 |
156 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); | |
157 | |
5124 | 158 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); |
4968 | 159 } |
160 | |
161 // uninit driver | |
162 static void uninit(sh_video_t *sh){ | |
163 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
164 } | |
165 | |
166 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
167 | |
168 // decode a frame | |
169 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
170 mp_image_t* mpi; | |
171 DEC_FRAME dec_frame; | |
172 #ifdef NEW_DECORE | |
173 DEC_PICTURE dec_pic; | |
174 #endif | |
175 | |
176 if(len<=0) return NULL; // skipped frame | |
177 | |
178 dec_frame.length = len; | |
179 dec_frame.bitstream = data; | |
180 dec_frame.render_flag = (flags&3)?0:1; | |
181 | |
182 #ifdef NEW_DECORE | |
183 dec_frame.bmp=&dec_pic; | |
184 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
5037 | 185 #ifndef DEC_OPT_FRAME_311 |
4968 | 186 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); |
187 #else | |
188 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
189 #endif | |
190 #else | |
191 // opendivx: | |
192 opendivx_src[0]=NULL; | |
193 decore(0x123, 0, &dec_frame, NULL); | |
194 #endif | |
195 | |
196 if(flags&3) return NULL; // framedrop | |
197 | |
198 #ifdef NEW_DECORE | |
199 if(!dec_pic.y) return NULL; // bad frame | |
200 #else | |
201 if(!opendivx_src[0]) return NULL; // bad frame | |
202 #endif | |
203 | |
204 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, | |
205 sh->disp_w, sh->disp_h); | |
206 if(!mpi) return NULL; | |
207 | |
208 #ifdef NEW_DECORE | |
209 mpi->planes[0]=dec_pic.y; | |
210 mpi->planes[1]=dec_pic.u; | |
211 mpi->planes[2]=dec_pic.v; | |
212 mpi->stride[0]=dec_pic.stride_y; | |
213 mpi->stride[1]=mpi->stride[2]=dec_pic.stride_uv; | |
214 #else | |
215 mpi->planes[0]=opendivx_src[0]; | |
216 mpi->planes[1]=opendivx_src[1]; | |
217 mpi->planes[2]=opendivx_src[2]; | |
218 mpi->stride[0]=opendivx_stride[0]; | |
219 mpi->stride[1]=opendivx_stride[1]; | |
220 mpi->stride[2]=opendivx_stride[2]; | |
221 #endif | |
222 | |
223 return mpi; | |
224 } | |
225 | |
226 #endif | |
227 |