Mercurial > mplayer.hg
annotate libmpcodecs/vd_odivx.c @ 8420:a986112926f4
small html fixes
author | gabucino |
---|---|
date | Tue, 10 Dec 2002 21:38:37 +0000 |
parents | 5241f95b5ec4 |
children | 32be26de0d7c |
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 "A'rpi", | |
25 #ifdef NEW_DECORE | |
26 "http://www.divx.com", | |
27 #else | |
28 "http://www.projectmayo.org", | |
29 #endif | |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
30 #ifdef NEW_DECORE |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
31 "native binary codec" |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
32 #else |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
33 "native codec" |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
34 #endif |
4968 | 35 }; |
36 | |
37 LIBVD_EXTERN(odivx) | |
38 | |
39 #ifndef NEW_DECORE | |
40 #include "opendivx/decore.h" | |
5011
d53725339d5d
postprocess.h requires for GET_PP_QUALITY_MAX - patch by Fredrik Kuivinen
arpi
parents:
5003
diff
changeset
|
41 #include "postproc/postprocess.h" |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
42 #elif HAVE_DIVX4_H |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
43 #include <divx4.h> |
4968 | 44 #else |
45 #include <decore.h> | |
46 #endif | |
47 | |
48 //**************************************************************************// | |
49 // The OpenDivX stuff: | |
50 //**************************************************************************// | |
51 | |
52 #ifndef NEW_DECORE | |
53 | |
54 static unsigned char *opendivx_src[3]; | |
55 static int opendivx_stride[3]; | |
56 | |
57 // callback, the opendivx decoder calls this for each frame: | |
58 void convert_linux(unsigned char *puc_y, int stride_y, | |
59 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
60 unsigned char *bmp, int width_y, int height_y){ | |
61 | |
62 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
63 | |
64 opendivx_src[0]=puc_y; | |
65 opendivx_src[1]=puc_u; | |
66 opendivx_src[2]=puc_v; | |
67 | |
68 opendivx_stride[0]=stride_y; | |
69 opendivx_stride[1]=stride_uv; | |
70 opendivx_stride[2]=stride_uv; | |
71 } | |
72 #endif | |
73 | |
74 | |
75 // to set/get/query special features/parameters | |
76 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
77 switch(cmd){ | |
78 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
79 #ifdef NEW_DECORE | |
80 return 9; // for divx4linux | |
81 #else | |
8040 | 82 return PP_QUALITY_MAX; // for opendivx |
4968 | 83 #endif |
84 case VDCTRL_SET_PP_LEVEL: { | |
85 DEC_SET dec_set; | |
86 int quality=*((int*)arg); | |
87 #ifdef NEW_DECORE | |
88 if(quality<0 || quality>9) quality=9; | |
89 dec_set.postproc_level=quality*10; | |
90 #else | |
8040 | 91 if(quality<0 || quality>PP_QUALITY_MAX) quality=PP_QUALITY_MAX; |
4968 | 92 dec_set.postproc_level=getPpModeForQuality(quality); |
93 #endif | |
94 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
95 return CONTROL_OK; | |
96 } | |
97 | |
98 } | |
99 | |
100 return CONTROL_UNKNOWN; | |
101 } | |
102 | |
103 // init driver | |
104 static int init(sh_video_t *sh){ | |
105 DEC_PARAM dec_param; | |
5003 | 106 DEC_SET dec_set; |
5173 | 107 |
108 #ifndef NEW_DECORE | |
109 if(sh->format==mmioFOURCC('D','I','V','3')){ | |
110 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n"); | |
111 return 0; // not supported | |
112 } | |
113 #endif | |
114 #ifndef DECORE_DIVX5 | |
115 if(sh->format==mmioFOURCC('D','X','5','0')){ | |
116 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n"); | |
117 return 0; // not supported | |
118 } | |
119 #endif | |
120 | |
4968 | 121 memset(&dec_param,0,sizeof(dec_param)); |
122 #ifdef NEW_DECORE | |
123 dec_param.output_format=DEC_USER; | |
124 #else | |
125 dec_param.color_depth = 32; | |
126 #endif | |
4997 | 127 #ifdef DECORE_DIVX5 |
5247 | 128 switch(sh->format) { |
129 case mmioFOURCC('D','I','V','3'): | |
130 dec_param.codec_version = 311; | |
131 break; | |
132 case mmioFOURCC('D','I','V','X'): | |
133 dec_param.codec_version = 400; | |
134 break; | |
135 case mmioFOURCC('D','X','5','0'): | |
136 default: // Fallback to DivX 5 behaviour | |
137 dec_param.codec_version = 500; | |
138 } | |
4997 | 139 dec_param.build_number = 0; |
140 #endif | |
4968 | 141 dec_param.x_dim = sh->disp_w; |
142 dec_param.y_dim = sh->disp_h; | |
143 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 144 |
145 dec_set.postproc_level = divx_quality; | |
146 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
4968 | 147 |
148 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); | |
149 | |
5124 | 150 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); |
4968 | 151 } |
152 | |
153 // uninit driver | |
154 static void uninit(sh_video_t *sh){ | |
155 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
156 } | |
157 | |
158 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
159 | |
160 // decode a frame | |
161 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
162 mp_image_t* mpi; | |
163 DEC_FRAME dec_frame; | |
164 #ifdef NEW_DECORE | |
165 DEC_PICTURE dec_pic; | |
166 #endif | |
167 | |
168 if(len<=0) return NULL; // skipped frame | |
169 | |
170 dec_frame.length = len; | |
171 dec_frame.bitstream = data; | |
172 dec_frame.render_flag = (flags&3)?0:1; | |
173 | |
174 #ifdef NEW_DECORE | |
175 dec_frame.bmp=&dec_pic; | |
176 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
5037 | 177 #ifndef DEC_OPT_FRAME_311 |
4968 | 178 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); |
179 #else | |
180 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
181 #endif | |
182 #else | |
183 // opendivx: | |
184 opendivx_src[0]=NULL; | |
185 decore(0x123, 0, &dec_frame, NULL); | |
186 #endif | |
187 | |
188 if(flags&3) return NULL; // framedrop | |
189 | |
190 #ifdef NEW_DECORE | |
191 if(!dec_pic.y) return NULL; // bad frame | |
192 #else | |
193 if(!opendivx_src[0]) return NULL; // bad frame | |
194 #endif | |
195 | |
196 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, | |
197 sh->disp_w, sh->disp_h); | |
198 if(!mpi) return NULL; | |
199 | |
200 #ifdef NEW_DECORE | |
201 mpi->planes[0]=dec_pic.y; | |
202 mpi->planes[1]=dec_pic.u; | |
203 mpi->planes[2]=dec_pic.v; | |
204 mpi->stride[0]=dec_pic.stride_y; | |
205 mpi->stride[1]=mpi->stride[2]=dec_pic.stride_uv; | |
206 #else | |
207 mpi->planes[0]=opendivx_src[0]; | |
208 mpi->planes[1]=opendivx_src[1]; | |
209 mpi->planes[2]=opendivx_src[2]; | |
210 mpi->stride[0]=opendivx_stride[0]; | |
211 mpi->stride[1]=opendivx_stride[1]; | |
212 mpi->stride[2]=opendivx_stride[2]; | |
213 #endif | |
214 | |
215 return mpi; | |
216 } | |
217 | |
218 #endif | |
219 |