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