Mercurial > mplayer.hg
annotate libmpcodecs/vd_xvid4.c @ 13160:7dbbfba0a722
better -slang description inspired by a patch from Guillaume Poirier
author | diego |
---|---|
date | Fri, 27 Aug 2004 02:12:11 +0000 |
parents | 4f4b81257d19 |
children | 3427a9f4b6e3 |
rev | line source |
---|---|
11437 | 1 /***************************************************************************** |
2 * | |
3 * - XviD 1.0 decoder module for mplayer/mencoder - | |
4 * | |
5 * Copyright(C) 2003 Marco Belli <elcabesa@inwind.it> | |
6 * 2003 Edouard Gomez <ed.gomez@free.fr> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 *****************************************************************************/ | |
23 | |
24 /***************************************************************************** | |
25 * Includes | |
26 ****************************************************************************/ | |
27 | |
28 #include <stdio.h> | |
29 #include <stdlib.h> | |
30 | |
31 #include "config.h" | |
32 #include "mp_msg.h" | |
33 | |
34 #ifdef HAVE_XVID4 | |
35 | |
36 #include "vd_internal.h" | |
37 #include "m_option.h" | |
38 | |
39 #include <xvid.h> | |
40 | |
41 /***************************************************************************** | |
42 * Configuration options | |
43 ****************************************************************************/ | |
44 | |
45 static int do_dr2 = 1; | |
11967
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
46 static int filmeffect = 0; |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
47 static int lumadeblock = 0; |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
48 static int chromadeblock = 0; |
11437 | 49 |
50 m_option_t xvid_dec_opts[] = { | |
51 { "dr2", &do_dr2, CONF_TYPE_FLAG, 0, 0, 1, NULL}, | |
52 { "nodr2", &do_dr2, CONF_TYPE_FLAG, 0, 1, 0, NULL}, | |
11967
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
53 { "filmeffect", &filmeffect, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
54 { "deblock-luma", &lumadeblock, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
55 { "deblock-chroma", &chromadeblock, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
11437 | 56 {NULL, NULL, 0, 0, 0, 0, NULL} |
57 }; | |
58 | |
59 /***************************************************************************** | |
60 * Module private data | |
61 ****************************************************************************/ | |
62 | |
63 typedef struct { | |
64 int cs; | |
65 unsigned char img_type; | |
66 void* hdl; | |
67 mp_image_t* mpi; | |
68 } priv_t; | |
69 | |
70 /***************************************************************************** | |
71 * Video decoder API function definitions | |
72 ****************************************************************************/ | |
73 | |
74 /*============================================================================ | |
75 * control - to set/get/query special features/parameters | |
76 *==========================================================================*/ | |
77 | |
78 static int control(sh_video_t *sh,int cmd,void* arg,...) | |
79 { | |
80 return(CONTROL_UNKNOWN); | |
81 } | |
82 | |
83 /*============================================================================ | |
84 * init - initialize the codec | |
85 *==========================================================================*/ | |
86 | |
87 static int init(sh_video_t *sh) | |
88 { | |
89 xvid_gbl_init_t xvid_ini; | |
90 xvid_dec_create_t dec_p; | |
91 priv_t* p; | |
92 int cs; | |
93 | |
94 memset(&xvid_ini, 0, sizeof(xvid_gbl_init_t)); | |
95 xvid_ini.version = XVID_VERSION; | |
96 memset(&dec_p, 0, sizeof(xvid_dec_create_t)); | |
97 dec_p.version = XVID_VERSION; | |
98 | |
99 if(!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_YV12)) | |
100 return(0); | |
101 | |
102 switch(sh->codec->outfmt[sh->outfmtidx]){ | |
103 case IMGFMT_YV12: | |
104 /* We will use our own buffers, this speeds decoding avoiding | |
105 * frame memcpy's overhead */ | |
106 cs = (do_dr2)?XVID_CSP_INTERNAL:XVID_CSP_USER; | |
107 break; | |
108 case IMGFMT_YUY2: | |
109 cs = XVID_CSP_YUY2; | |
110 break; | |
111 case IMGFMT_UYVY: | |
112 cs = XVID_CSP_UYVY; | |
113 break; | |
114 case IMGFMT_I420: | |
115 case IMGFMT_IYUV: | |
116 /* We will use our own buffers, this speeds decoding avoiding | |
117 * frame memcpy's overhead */ | |
118 cs = (do_dr2)?XVID_CSP_INTERNAL:XVID_CSP_USER; | |
119 break; | |
120 case IMGFMT_BGR15: | |
121 cs = XVID_CSP_RGB555; | |
122 break; | |
123 case IMGFMT_BGR16: | |
124 cs = XVID_CSP_RGB565; | |
125 break; | |
126 case IMGFMT_BGR32: | |
127 cs = XVID_CSP_BGRA; | |
128 break; | |
129 case IMGFMT_YVYU: | |
130 cs = XVID_CSP_YVYU; | |
131 break; | |
132 default: | |
133 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Unsupported out_fmt: 0x%X\n", | |
134 sh->codec->outfmt[sh->outfmtidx]); | |
135 return(0); | |
136 } | |
137 | |
138 if(xvid_global(NULL, XVID_GBL_INIT, &xvid_ini, NULL)) | |
139 return(0); | |
140 | |
141 dec_p.width = sh->disp_w; | |
142 dec_p.height = sh->disp_h; | |
143 | |
144 if(xvid_decore(0, XVID_DEC_CREATE, &dec_p, NULL)<0) { | |
145 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "XviD init failed\n"); | |
146 return(0); | |
147 } | |
148 | |
149 p = (priv_t*)malloc(sizeof(priv_t)); | |
150 p->cs = cs; | |
151 p->hdl = dec_p.handle; | |
152 sh->context = p; | |
153 | |
154 switch(cs) { | |
155 case XVID_CSP_INTERNAL: | |
156 p->img_type = MP_IMGTYPE_EXPORT; | |
157 break; | |
158 case XVID_CSP_USER: | |
159 p->img_type = MP_IMGTYPE_STATIC; | |
160 break; | |
161 default: | |
162 p->img_type = MP_IMGTYPE_TEMP; | |
163 break; | |
164 } | |
165 | |
166 return(1); | |
167 } | |
168 | |
169 /*============================================================================ | |
170 * uninit - close the codec | |
171 *==========================================================================*/ | |
172 | |
173 static void uninit(sh_video_t *sh){ | |
174 priv_t* p = sh->context; | |
175 if(!p) | |
176 return; | |
177 xvid_decore(p->hdl,XVID_DEC_DESTROY, NULL, NULL); | |
178 free(p); | |
179 } | |
180 | |
181 /*============================================================================ | |
182 * decode - decode a frame from stream | |
183 *==========================================================================*/ | |
184 | |
185 static mp_image_t* decode(sh_video_t *sh, void* data, int len, int flags) | |
186 { | |
187 xvid_dec_frame_t dec; | |
188 priv_t* p = sh->context; | |
189 | |
190 mp_image_t* mpi = mpcodecs_get_image(sh, p->img_type, | |
191 MP_IMGFLAG_ACCEPT_STRIDE, | |
192 sh->disp_w,sh->disp_h); | |
193 | |
194 if(!data || !mpi || len <= 0) | |
195 return(NULL); | |
196 | |
197 memset(&dec,0,sizeof(xvid_dec_frame_t)); | |
198 dec.version = XVID_VERSION; | |
199 | |
200 dec.bitstream = data; | |
201 dec.length = len; | |
202 | |
11967
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
203 dec.general |= XVID_LOWDELAY |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
204 | (filmeffect ? XVID_FILMEFFECT : 0 ) |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
205 | (lumadeblock ? XVID_DEBLOCKY : 0 ) |
4f4b81257d19
Adds support for the film grain effect and deblocking filters in xvid
attila
parents:
11437
diff
changeset
|
206 | (chromadeblock ? XVID_DEBLOCKUV : 0 ); |
11437 | 207 |
208 dec.output.csp = p->cs; | |
209 | |
210 if(p->cs != XVID_CSP_INTERNAL) { | |
211 dec.output.plane[0] = mpi->planes[0]; | |
212 dec.output.plane[1] = mpi->planes[1]; | |
213 dec.output.plane[2] = mpi->planes[2]; | |
214 | |
215 dec.output.stride[0] = mpi->stride[0]; | |
216 dec.output.stride[1] = mpi->stride[1]; | |
217 dec.output.stride[2] = mpi->stride[2]; | |
218 } | |
219 | |
220 if(xvid_decore(p->hdl, XVID_DEC_DECODE, &dec, NULL) < 0) { | |
221 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Decoding error\n"); | |
222 return(NULL); | |
223 } | |
224 | |
225 if(p->cs == XVID_CSP_INTERNAL) { | |
226 mpi->planes[0] = dec.output.plane[0]; | |
227 mpi->planes[1] = dec.output.plane[1]; | |
228 mpi->planes[2] = dec.output.plane[2]; | |
229 | |
230 mpi->stride[0] = dec.output.stride[0]; | |
231 mpi->stride[1] = dec.output.stride[1]; | |
232 mpi->stride[2] = dec.output.stride[2]; | |
233 } | |
234 | |
235 return(mpi); | |
236 } | |
237 | |
238 /***************************************************************************** | |
239 * Module structure definition | |
240 ****************************************************************************/ | |
241 | |
242 static vd_info_t info = | |
243 { | |
244 "XviD 1.0 decoder", | |
245 "xvid", | |
246 "Marco Belli <elcabesa@inwind.it>, Edouard Gomez <ed.gomez@free.fr>", | |
247 "Marco Belli <elcabesa@inwind.it>, Edouard Gomez <ed.gomez@free.fr>", | |
248 "No Comment" | |
249 }; | |
250 | |
251 LIBVD_EXTERN(xvid) | |
252 | |
253 #endif /* HAVE_XVID4 */ | |
254 | |
255 /* Please do not change that tag comment. | |
256 * arch-tag: b7d654a5-76ea-4768-9713-2c791567fe7d mplayer xvid decoder module */ |