Mercurial > mplayer.hg
annotate libmpcodecs/vd_divx4.c @ 6703:feeaffcce1fa
adapting to the 'adding fff prefix to avoid global name conflicts' changes in libavcodec
author | rik |
---|---|
date | Thu, 11 Jul 2002 13:05:53 +0000 |
parents | 522713337297 |
children | 8058078f1248 |
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 |
36 // to set/get/query special features/parameters | |
37 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
38 switch(cmd){ | |
39 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
40 return 9; // for divx4linux | |
41 case VDCTRL_SET_PP_LEVEL: { | |
42 DEC_SET dec_set; | |
43 int quality=*((int*)arg); | |
44 if(quality<0 || quality>9) quality=9; | |
45 dec_set.postproc_level=quality*10; | |
46 decore(0x123,DEC_OPT_SETPP,&dec_set,NULL); | |
47 return CONTROL_OK; | |
48 } | |
5003 | 49 #ifdef DECORE_VERSION |
50 #if DECORE_VERSION >= 20011010 | |
51 case VDCTRL_SET_EQUALIZER: { | |
52 va_list ap; | |
53 int value; | |
54 int option; | |
55 va_start(ap, arg); | |
56 value=va_arg(ap, int); | |
57 va_end(ap); | |
58 | |
59 if(!strcmp(arg,"Brightness")) option=DEC_GAMMA_BRIGHTNESS; | |
60 else if(!strcmp(arg, "Contrast")) option=DEC_GAMMA_CONTRAST; | |
61 else if(!strcmp(arg,"Saturation")) option=DEC_GAMMA_SATURATION; | |
62 else return CONTROL_FALSE; | |
63 | |
64 value = (value * 256) / 100 - 128; | |
65 decore(0x123, DEC_OPT_GAMMA, (void *)option, (void *) value); | |
66 return CONTROL_OK; | |
67 } | |
68 #endif | |
69 #endif | |
4968 | 70 |
71 } | |
72 | |
73 return CONTROL_UNKNOWN; | |
74 } | |
75 | |
76 // init driver | |
77 static int init(sh_video_t *sh){ | |
78 DEC_PARAM dec_param; | |
5003 | 79 DEC_SET dec_set; |
4968 | 80 int bits=16; |
81 | |
5168 | 82 #ifndef NEW_DECORE |
83 if(sh->format==mmioFOURCC('D','I','V','3')){ | |
84 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 3.x not supported by opendivx decore - it requires divx4linux\n"); | |
85 return 0; // not supported | |
86 } | |
87 #endif | |
88 #ifndef DECORE_DIVX5 | |
89 if(sh->format==mmioFOURCC('D','X','5','0')){ | |
90 mp_msg(MSGT_DECVIDEO,MSGL_INFO,"DivX 5.00 not supported by divx4linux decore - it requires divx5linux\n"); | |
91 return 0; // not supported | |
92 } | |
93 #endif | |
94 | |
5124 | 95 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; |
96 | |
97 memset(&dec_param,0,sizeof(dec_param)); | |
4968 | 98 |
99 switch(sh->codec->outfmt[sh->outfmtidx]){ | |
100 case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break; | |
101 case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break; | |
102 case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break; | |
103 case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break; | |
104 case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break; | |
105 case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break; | |
106 case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break; | |
107 case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break; | |
108 default: | |
109 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",sh->codec->outfmt[sh->outfmtidx]); | |
110 return 0; | |
111 } | |
4997 | 112 #ifdef DECORE_DIVX5 |
5247 | 113 switch(sh->format) { |
114 case mmioFOURCC('D','I','V','3'): | |
115 dec_param.codec_version = 311; | |
116 break; | |
117 case mmioFOURCC('D','I','V','X'): | |
118 dec_param.codec_version = 400; | |
119 break; | |
120 case mmioFOURCC('D','X','5','0'): | |
121 default: // Fallback to DivX 5 behaviour | |
122 dec_param.codec_version = 500; | |
123 } | |
4997 | 124 dec_param.build_number = 0; |
125 #endif | |
4968 | 126 dec_param.x_dim = sh->disp_w; |
127 dec_param.y_dim = sh->disp_h; | |
128 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | |
5003 | 129 |
130 dec_set.postproc_level = divx_quality; | |
131 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
4968 | 132 |
133 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: DivX4Linux video codec init OK!\n"); | |
134 | |
135 return 1; | |
136 } | |
137 | |
138 // uninit driver | |
139 static void uninit(sh_video_t *sh){ | |
140 decore(0x123,DEC_OPT_RELEASE,NULL,NULL); | |
141 } | |
142 | |
143 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
144 | |
145 // decode a frame | |
146 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
147 mp_image_t* mpi; | |
148 DEC_FRAME dec_frame; | |
149 | |
150 if(len<=0) return NULL; // skipped frame | |
151 | |
152 dec_frame.length = len; | |
153 dec_frame.bitstream = data; | |
154 dec_frame.render_flag = (flags&3)?0:1; | |
155 | |
156 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_PRESERVE | MP_IMGFLAG_ACCEPT_WIDTH, | |
157 sh->disp_w, sh->disp_h); | |
158 if(!mpi) return NULL; | |
159 | |
160 dec_frame.bmp=mpi->planes[0]; | |
161 dec_frame.stride=mpi->width; | |
162 | |
5037 | 163 #ifndef DEC_OPT_FRAME_311 |
4968 | 164 decore(0x123, DEC_OPT_FRAME, &dec_frame, NULL); |
165 #else | |
166 decore(0x123, (sh->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL); | |
167 #endif | |
168 | |
169 return mpi; | |
170 } | |
171 | |
172 #endif | |
173 #endif | |
174 |