Mercurial > mplayer.hg
annotate libmpcodecs/vd_odivx.c @ 7099:0b70f3dc34eb
Applied patch by Andras Mohari <mayday@varoshaza.nagyatad.hu>, with some
small additions.
* Replaced <UL> with <OL> where it made sense (to me :-)).
* Moved "Developer Cries" into the appendix (as Appendix F)
with s/Flame Wars/Developer Cries/ and
s/In medias res/Developer Cries/.
* Renamed "Appendix X" to "Appendix E".
* Put a "Hint" inside <BLOCKQUOTE>.
* Converted 3-pass encoding and mga_vid installation
instructions to lists.
* Converted options tables (video eq, SDL, fbdev, VESA, DXR3, TV input,
DivX4Linux, AAlib) to <DL> lists.
* The "sections" for MPsub and INSTALLING OSD are numbered and displayed
in the TOC now.
* Changed the text inside some <H4> tags.
author | diego |
---|---|
date | Tue, 27 Aug 2002 18:06:07 +0000 |
parents | 522713337297 |
children | 28677d779205 |
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" |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
39 #elif HAVE_DIVX4_H |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
40 #include <divx4.h> |
4968 | 41 #else |
42 #include <decore.h> | |
43 #endif | |
44 | |
45 //**************************************************************************// | |
46 // The OpenDivX stuff: | |
47 //**************************************************************************// | |
48 | |
49 #ifndef NEW_DECORE | |
50 | |
51 static unsigned char *opendivx_src[3]; | |
52 static int opendivx_stride[3]; | |
53 | |
54 // callback, the opendivx decoder calls this for each frame: | |
55 void convert_linux(unsigned char *puc_y, int stride_y, | |
56 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, | |
57 unsigned char *bmp, int width_y, int height_y){ | |
58 | |
59 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
60 | |
61 opendivx_src[0]=puc_y; | |
62 opendivx_src[1]=puc_u; | |
63 opendivx_src[2]=puc_v; | |
64 | |
65 opendivx_stride[0]=stride_y; | |
66 opendivx_stride[1]=stride_uv; | |
67 opendivx_stride[2]=stride_uv; | |
68 } | |
69 #endif | |
70 | |
71 | |
72 // to set/get/query special features/parameters | |
73 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
74 switch(cmd){ | |
75 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
76 #ifdef NEW_DECORE | |
77 return 9; // for divx4linux | |
78 #else | |
79 return GET_PP_QUALITY_MAX; // for opendivx | |
80 #endif | |
81 case VDCTRL_SET_PP_LEVEL: { | |
82 DEC_SET dec_set; | |
83 int quality=*((int*)arg); | |
84 #ifdef NEW_DECORE | |
85 if(quality<0 || quality>9) quality=9; | |
86 dec_set.postproc_level=quality*10; | |
87 #else | |
88 if(quality<0 || quality>GET_PP_QUALITY_MAX) quality=GET_PP_QUALITY_MAX; | |
89 dec_set.postproc_level=getPpModeForQuality(quality); | |
90 #endif | |
91 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
92 return CONTROL_OK; | |
93 } | |
94 | |
95 } | |
96 | |
97 return CONTROL_UNKNOWN; | |
98 } | |
99 | |
100 // init driver | |
101 static int init(sh_video_t *sh){ | |
102 DEC_PARAM dec_param; | |
5003 | 103 DEC_SET dec_set; |
5173 | 104 |
105 #ifndef NEW_DECORE | |
106 if(sh->format==mmioFOURCC('D','I','V','3')){ | |
107 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n"); | |
108 return 0; // not supported | |
109 } | |
110 #endif | |
111 #ifndef DECORE_DIVX5 | |
112 if(sh->format==mmioFOURCC('D','X','5','0')){ | |
113 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n"); | |
114 return 0; // not supported | |
115 } | |
116 #endif | |
117 | |
4968 | 118 memset(&dec_param,0,sizeof(dec_param)); |
119 #ifdef NEW_DECORE | |
120 dec_param.output_format=DEC_USER; | |
121 #else | |
122 dec_param.color_depth = 32; | |
123 #endif | |
4997 | 124 #ifdef DECORE_DIVX5 |
5247 | 125 switch(sh->format) { |
126 case mmioFOURCC('D','I','V','3'): | |
127 dec_param.codec_version = 311; | |
128 break; | |
129 case mmioFOURCC('D','I','V','X'): | |
130 dec_param.codec_version = 400; | |
131 break; | |
132 case mmioFOURCC('D','X','5','0'): | |
133 default: // Fallback to DivX 5 behaviour | |
134 dec_param.codec_version = 500; | |
135 } | |
4997 | 136 dec_param.build_number = 0; |
137 #endif | |
4968 | 138 dec_param.x_dim = sh->disp_w; |
139 dec_param.y_dim = sh->disp_h; | |
140 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 141 |
142 dec_set.postproc_level = divx_quality; | |
143 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
4968 | 144 |
145 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: OpenDivX video codec init OK!\n"); | |
146 | |
5124 | 147 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12); |
4968 | 148 } |
149 | |
150 // uninit driver | |
151 static void uninit(sh_video_t *sh){ | |
152 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
153 } | |
154 | |
155 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
156 | |
157 // decode a frame | |
158 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
159 mp_image_t* mpi; | |
160 DEC_FRAME dec_frame; | |
161 #ifdef NEW_DECORE | |
162 DEC_PICTURE dec_pic; | |
163 #endif | |
164 | |
165 if(len<=0) return NULL; // skipped frame | |
166 | |
167 dec_frame.length = len; | |
168 dec_frame.bitstream = data; | |
169 dec_frame.render_flag = (flags&3)?0:1; | |
170 | |
171 #ifdef NEW_DECORE | |
172 dec_frame.bmp=&dec_pic; | |
173 dec_pic.y=dec_pic.u=dec_pic.v=NULL; | |
5037 | 174 #ifndef DEC_OPT_FRAME_311 |
4968 | 175 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); |
176 #else | |
177 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
178 #endif | |
179 #else | |
180 // opendivx: | |
181 opendivx_src[0]=NULL; | |
182 decore(0x123, 0, &dec_frame, NULL); | |
183 #endif | |
184 | |
185 if(flags&3) return NULL; // framedrop | |
186 | |
187 #ifdef NEW_DECORE | |
188 if(!dec_pic.y) return NULL; // bad frame | |
189 #else | |
190 if(!opendivx_src[0]) return NULL; // bad frame | |
191 #endif | |
192 | |
193 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, MP_IMGFLAG_PRESERVE, | |
194 sh->disp_w, sh->disp_h); | |
195 if(!mpi) return NULL; | |
196 | |
197 #ifdef NEW_DECORE | |
198 mpi->planes[0]=dec_pic.y; | |
199 mpi->planes[1]=dec_pic.u; | |
200 mpi->planes[2]=dec_pic.v; | |
201 mpi->stride[0]=dec_pic.stride_y; | |
202 mpi->stride[1]=mpi->stride[2]=dec_pic.stride_uv; | |
203 #else | |
204 mpi->planes[0]=opendivx_src[0]; | |
205 mpi->planes[1]=opendivx_src[1]; | |
206 mpi->planes[2]=opendivx_src[2]; | |
207 mpi->stride[0]=opendivx_stride[0]; | |
208 mpi->stride[1]=opendivx_stride[1]; | |
209 mpi->stride[2]=opendivx_stride[2]; | |
210 #endif | |
211 | |
212 return mpi; | |
213 } | |
214 | |
215 #endif | |
216 |