Mercurial > mplayer.hg
annotate libmpcodecs/vd_divx4.c @ 9961:1a6057610a61
cygwin support by Sascha Sommer
author | alex |
---|---|
date | Mon, 21 Apr 2003 19:16:31 +0000 |
parents | 32be26de0d7c |
children | d275152390ee |
rev | line source |
---|---|
4968 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
5003 | 3 #include <stdarg.h> |
4968 | 4 #include <assert.h> |
5 | |
6 #include "config.h" | |
7 #include "mp_msg.h" | |
8 #include "help_mp.h" | |
9 | |
10 #ifdef USE_DIVX | |
11 #ifdef NEW_DECORE | |
12 | |
13 #include "vd_internal.h" | |
14 | |
15 static vd_info_t info = { | |
16 #ifdef DECORE_DIVX5 | |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
17 "DivX5Linux lib", |
4968 | 18 #else |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
19 #ifdef DECORE_XVID |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
20 "XviD lib (divx4 compat.)", |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
21 #else |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
22 "DivX4Linux lib", |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
23 #endif |
4968 | 24 #endif |
25 "divx4", | |
26 "A'rpi", | |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
27 #ifdef DECORE_XVID |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
28 "http://www.xvid.com", |
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
29 #else |
4968 | 30 "http://www.divx.com", |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
31 #endif |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
32 "native binary codec" |
4968 | 33 }; |
34 | |
35 LIBVD_EXTERN(divx4) | |
36 | |
9300
32be26de0d7c
cleanup detection of various divx4 versions/alternatives
arpi
parents:
7191
diff
changeset
|
37 #ifdef DECORE_XVID |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
38 #include <divx4.h> |
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
39 #else |
4968 | 40 #include <decore.h> |
6701
522713337297
Support for Xvid using their new api. If divx4 compatiblity is disabeled
albeu
parents:
5247
diff
changeset
|
41 #endif |
4968 | 42 |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
43 #define USE_DIVX_BUILTIN_PP |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
44 |
4968 | 45 // to set/get/query special features/parameters |
46 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
47 switch(cmd){ | |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
48 #ifdef USE_DIVX_BUILTIN_PP |
4968 | 49 case VDCTRL_QUERY_MAX_PP_LEVEL: |
50 return 9; // for divx4linux | |
51 case VDCTRL_SET_PP_LEVEL: { | |
52 DEC_SET dec_set; | |
53 int quality=*((int*)arg); | |
54 if(quality<0 || quality>9) quality=9; | |
55 dec_set.postproc_level=quality*10; | |
56 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
57 return CONTROL_OK; | |
58 } | |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
59 #endif |
5003 | 60 #ifdef DECORE_VERSION |
61 #if DECORE_VERSION >= 20011010 | |
62 case VDCTRL_SET_EQUALIZER: { | |
63 va_list ap; | |
64 int value; | |
65 int option; | |
66 va_start(ap, arg); | |
67 value=va_arg(ap, int); | |
68 va_end(ap); | |
69 | |
6803 | 70 if(!strcasecmp(arg,"Brightness")) option=DEC_GAMMA_BRIGHTNESS; |
71 else if(!strcasecmp(arg, "Contrast")) option=DEC_GAMMA_CONTRAST; | |
72 else if(!strcasecmp(arg,"Saturation")) option=DEC_GAMMA_SATURATION; | |
5003 | 73 else return CONTROL_FALSE; |
74 | |
6803 | 75 value = (value * 128) / 100; |
5003 | 76 decore(0x123, DEC_OPT_GAMMA, (void *)option, (void *) value); |
77 return CONTROL_OK; | |
78 } | |
79 #endif | |
80 #endif | |
4968 | 81 |
82 } | |
83 | |
84 return CONTROL_UNKNOWN; | |
85 } | |
86 | |
87 // init driver | |
88 static int init(sh_video_t *sh){ | |
89 DEC_PARAM dec_param; | |
5003 | 90 DEC_SET dec_set; |
4968 | 91 int bits=16; |
92 | |
5168 | 93 #ifndef NEW_DECORE |
94 if(sh->format==mmioFOURCC('D','I','V','3')){ | |
95 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n"); | |
96 return 0; // not supported | |
97 } | |
98 #endif | |
99 #ifndef DECORE_DIVX5 | |
100 if(sh->format==mmioFOURCC('D','X','5','0')){ | |
101 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n"); | |
102 return 0; // not supported | |
103 } | |
104 #endif | |
105 | |
5124 | 106 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; |
107 | |
108 memset(&dec_param,0,sizeof(dec_param)); | |
4968 | 109 |
110 switch(sh->codec->outfmt[sh->outfmtidx]){ | |
111 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break; | |
112 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break; | |
113 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break; | |
114 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break; | |
115 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break; | |
116 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break; | |
117 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break; | |
118 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break; | |
119 default: | |
120 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]); | |
121 return 0; | |
122 } | |
4997 | 123 #ifdef DECORE_DIVX5 |
5247 | 124 switch(sh->format) { |
125 case mmioFOURCC('D','I','V','3'): | |
126 dec_param.codec_version = 311; | |
127 break; | |
128 case mmioFOURCC('D','I','V','X'): | |
129 dec_param.codec_version = 400; | |
130 break; | |
131 case mmioFOURCC('D','X','5','0'): | |
132 default: // Fallback to DivX 5 behaviour | |
133 dec_param.codec_version = 500; | |
134 } | |
4997 | 135 dec_param.build_number = 0; |
136 #endif | |
4968 | 137 dec_param.x_dim = sh->disp_w; |
138 dec_param.y_dim = sh->disp_h; | |
139 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 140 |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
141 #ifdef USE_DIVX_BUILTIN_PP |
5003 | 142 dec_set.postproc_level = divx_quality; |
143 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
144 #endif |
4968 | 145 |
146 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: DivX4Linux video codec init OK!\n"); | |
147 | |
148 return 1; | |
149 } | |
150 | |
151 // uninit driver | |
152 static void uninit(sh_video_t *sh){ | |
153 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
154 } | |
155 | |
156 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
157 | |
158 // decode a frame | |
159 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
160 mp_image_t* mpi; | |
161 DEC_FRAME dec_frame; | |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
162 #ifndef USE_DIVX_BUILTIN_PP |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
163 DEC_FRAME_INFO frameinfo; |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
164 #endif |
4968 | 165 |
166 if(len<=0) return NULL; // skipped frame | |
167 | |
168 dec_frame.length = len; | |
169 dec_frame.bitstream = data; | |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
170 dec_frame.render_flag = (flags&VDFLAGS_DROPFRAME)?0:1; |
4968 | 171 |
172 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_PRESERVE | MP_IMGFLAG_ACCEPT_WIDTH, | |
173 sh->disp_w, sh->disp_h); | |
174 if(!mpi) return NULL; | |
175 | |
176 dec_frame.bmp=mpi->planes[0]; | |
177 dec_frame.stride=mpi->width; | |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
178 |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
179 decore(0x123, |
5037 | 180 #ifndef DEC_OPT_FRAME_311 |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
181 DEC_OPT_FRAME, |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
182 #else |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
183 (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
184 #endif |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
185 &dec_frame, |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
186 #ifndef USE_DIVX_BUILTIN_PP |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
187 &frameinfo |
4968 | 188 #else |
6708
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
189 NULL |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
190 #endif |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
191 ); |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
192 |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
193 #ifndef USE_DIVX_BUILTIN_PP |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
194 mpi->qscale = frameinfo.quant_store; |
8058078f1248
support for external pp by divx4. some fixes/cosmetics?
alex
parents:
6701
diff
changeset
|
195 mpi->qstride = frameinfo.quant_stride; |
4968 | 196 #endif |
197 | |
198 return mpi; | |
199 } | |
200 #endif | |
201 #endif |