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