Mercurial > mplayer.hg
annotate libmpcodecs/vf_pp.c @ 8441:649ef4a6c8f9
Update to the QT documentation by Alex.
author | diego |
---|---|
date | Fri, 13 Dec 2002 20:07:31 +0000 |
parents | 9fc45fe0d444 |
children | e18f7b016a4a |
rev | line source |
---|---|
5512 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
7946 | 4 #include <inttypes.h> |
7963 | 5 #include <errno.h> |
5512 | 6 |
7 #include "../config.h" | |
8 #include "../mp_msg.h" | |
7972 | 9 #include "../cpudetect.h" |
5512 | 10 |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8040
diff
changeset
|
11 #ifdef HAVE_MALLOC_H |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8040
diff
changeset
|
12 #include <malloc.h> |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8040
diff
changeset
|
13 #endif |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8040
diff
changeset
|
14 |
5607 | 15 #include "img_format.h" |
16 #include "mp_image.h" | |
5512 | 17 #include "vf.h" |
18 | |
8038 | 19 #define EMU_OLD |
20 | |
5512 | 21 #include "../postproc/postprocess.h" |
22 | |
8038 | 23 #ifdef EMU_OLD |
24 #include "../postproc/postprocess_internal.h" | |
25 #endif | |
26 | |
5512 | 27 struct vf_priv_s { |
7946 | 28 int pp; |
8040 | 29 pp_mode_t *ppMode[PP_QUALITY_MAX+1]; |
7946 | 30 void *context; |
5512 | 31 mp_image_t *dmpi; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
32 unsigned int outfmt; |
5512 | 33 }; |
34 | |
35 //===========================================================================// | |
36 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
37 static int config(struct vf_instance_s* vf, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
38 int width, int height, int d_width, int d_height, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
39 unsigned int voflags, unsigned int outfmt){ |
7985 | 40 vf->priv->context= pp_get_context(width, height, |
41 (gCpuCaps.hasMMX ? PP_CPU_CAPS_MMX : 0) | |
42 | (gCpuCaps.hasMMX2 ? PP_CPU_CAPS_MMX2 : 0) | |
43 | (gCpuCaps.has3DNow ? PP_CPU_CAPS_3DNOW : 0) | |
44 ); | |
7946 | 45 |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
46 return vf_next_config(vf,width,height,d_width,d_height,voflags,vf->priv->outfmt); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
47 } |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
48 |
7949 | 49 static void uninit(struct vf_instance_s* vf){ |
8038 | 50 int i; |
8040 | 51 for(i=0; i<=PP_QUALITY_MAX; i++){ |
8038 | 52 if(vf->priv->ppMode[i]) |
53 pp_free_mode(vf->priv->ppMode[i]); | |
54 } | |
7961 | 55 if(vf->priv->context) pp_free_context(vf->priv->context); |
7949 | 56 } |
57 | |
5518 | 58 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
59 switch(fmt){ | |
60 case IMGFMT_YV12: | |
61 case IMGFMT_I420: | |
62 case IMGFMT_IYUV: | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
63 return vf_next_query_format(vf,vf->priv->outfmt); |
5518 | 64 } |
65 return 0; | |
66 } | |
67 | |
5519 | 68 static int control(struct vf_instance_s* vf, int request, void* data){ |
69 switch(request){ | |
70 case VFCTRL_QUERY_MAX_PP_LEVEL: | |
8040 | 71 return PP_QUALITY_MAX; |
5519 | 72 case VFCTRL_SET_PP_LEVEL: |
7946 | 73 vf->priv->pp= *((unsigned int*)data); |
5519 | 74 return CONTROL_TRUE; |
75 } | |
76 return vf_next_control(vf,request,data); | |
77 } | |
78 | |
5512 | 79 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
80 if(vf->priv->pp&0xFFFF) return; // non-local filters enabled | |
5513 | 81 if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) && |
82 mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
83 if(!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE) && mpi->imgfmt!=vf->priv->outfmt) |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
84 return; // colorspace differ |
5512 | 85 // ok, we can do pp in-place (or pp disabled): |
86 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
87 mpi->type, mpi->flags, mpi->w, mpi->h); | |
88 mpi->planes[0]=vf->priv->dmpi->planes[0]; | |
89 mpi->stride[0]=vf->priv->dmpi->stride[0]; | |
90 mpi->width=vf->priv->dmpi->width; | |
91 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
92 mpi->planes[1]=vf->priv->dmpi->planes[1]; | |
93 mpi->planes[2]=vf->priv->dmpi->planes[2]; | |
94 mpi->stride[1]=vf->priv->dmpi->stride[1]; | |
95 mpi->stride[2]=vf->priv->dmpi->stride[2]; | |
96 } | |
97 mpi->flags|=MP_IMGFLAG_DIRECT; | |
98 } | |
99 | |
7368 | 100 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
5512 | 101 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ |
102 // no DR, so get a new image! hope we'll get DR buffer: | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
103 vf->priv->dmpi=vf_get_image(vf->next,vf->priv->outfmt, |
6875 | 104 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, |
105 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
106 // mpi->w,mpi->h); | |
107 (mpi->w+7)&(~7),(mpi->h+7)&(~7)); | |
108 vf->priv->dmpi->w=mpi->w; vf->priv->dmpi->h=mpi->h; // display w;h | |
5512 | 109 } |
110 | |
111 if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
112 // do the postprocessing! (or copy if no DR) | |
7961 | 113 pp_postprocess(mpi->planes ,mpi->stride, |
7946 | 114 vf->priv->dmpi->planes,vf->priv->dmpi->stride, |
6875 | 115 (mpi->w+7)&(~7),mpi->h, |
5512 | 116 mpi->qscale, mpi->qstride, |
8038 | 117 vf->priv->ppMode[ vf->priv->pp ], vf->priv->context, |
7960 | 118 mpi->pict_type); |
5512 | 119 } |
7368 | 120 return vf_next_put_image(vf,vf->priv->dmpi); |
5512 | 121 } |
122 | |
123 //===========================================================================// | |
124 | |
125 extern int divx_quality; | |
126 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
127 static unsigned int fmt_list[]={ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
128 IMGFMT_YV12, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
129 IMGFMT_I420, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
130 IMGFMT_IYUV, |
7127 | 131 0 |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
132 }; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
133 |
5512 | 134 static int open(vf_instance_t *vf, char* args){ |
7946 | 135 char *endptr, *name; |
136 int i; | |
137 int hex_mode=0; | |
138 | |
5518 | 139 vf->query_format=query_format; |
5519 | 140 vf->control=control; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
141 vf->config=config; |
5512 | 142 vf->get_image=get_image; |
143 vf->put_image=put_image; | |
7949 | 144 vf->uninit=uninit; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
145 vf->default_caps=VFCAP_ACCEPT_STRIDE|VFCAP_POSTPROC; |
5512 | 146 vf->priv=malloc(sizeof(struct vf_priv_s)); |
7949 | 147 vf->priv->context=NULL; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
148 |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
149 // check csp: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
150 vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12); |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
151 if(!vf->priv->outfmt) return 0; // no csp match :( |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
152 |
5514 | 153 if(args){ |
7946 | 154 if(!strcmp("help", args)){ |
7961 | 155 printf("%s", pp_help); |
7946 | 156 exit(1); |
157 } | |
158 | |
159 hex_mode= strtol(args, &endptr, 0); | |
160 if(*endptr){ | |
161 name= args; | |
162 }else | |
163 name= NULL; | |
164 }else{ | |
165 name="de"; | |
5514 | 166 } |
7972 | 167 |
8038 | 168 #ifdef EMU_OLD |
7946 | 169 if(name){ |
8038 | 170 #endif |
8040 | 171 for(i=0; i<=PP_QUALITY_MAX; i++){ |
7961 | 172 vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(name, i); |
8038 | 173 if(vf->priv->ppMode[i]==NULL) return -1; |
7946 | 174 } |
8038 | 175 #ifdef EMU_OLD |
7946 | 176 }else{ |
177 /* hex mode for compatibility */ | |
8040 | 178 for(i=0; i<=PP_QUALITY_MAX; i++){ |
8038 | 179 PPMode *ppMode; |
180 | |
181 ppMode= (PPMode*)memalign(8, sizeof(PPMode)); | |
7946 | 182 |
8038 | 183 ppMode->lumMode= hex_mode; |
184 ppMode->chromMode= ((hex_mode&0xFF)>>4) | (hex_mode&0xFFFFFF00); | |
185 ppMode->maxTmpNoise[0]= 700; | |
186 ppMode->maxTmpNoise[1]= 1500; | |
187 ppMode->maxTmpNoise[2]= 3000; | |
188 ppMode->maxAllowedY= 234; | |
189 ppMode->minAllowedY= 16; | |
190 ppMode->baseDcDiff= 256/4; | |
191 ppMode->flatnessThreshold=40; | |
7946 | 192 |
193 vf->priv->ppMode[i]= ppMode; | |
194 } | |
195 } | |
8038 | 196 #endif |
7946 | 197 |
8040 | 198 vf->priv->pp=PP_QUALITY_MAX; //divx_quality; |
5512 | 199 return 1; |
200 } | |
201 | |
7963 | 202 int readPPOpt(void *conf, char *arg) |
203 { | |
204 int val; | |
205 | |
206 if(arg == NULL) | |
207 return -2; // ERR_MISSING_PARAM | |
208 errno = 0; | |
209 val = (int)strtol(arg,NULL,0); | |
210 if(errno != 0) | |
211 return -4; // What about include cfgparser.h and use ERR_* defines */ | |
212 if(val < 0) | |
213 return -3; // ERR_OUT_OF_RANGE | |
214 | |
215 divx_quality = val; | |
216 | |
217 return 1; | |
218 } | |
219 | |
220 void revertPPOpt(void *conf, char* opt) | |
221 { | |
222 divx_quality=0; | |
223 } | |
224 | |
5512 | 225 vf_info_t vf_info_pp = { |
226 "postprocessing", | |
227 "pp", | |
228 "A'rpi", | |
229 "", | |
230 open | |
231 }; | |
232 | |
233 //===========================================================================// |