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