Mercurial > mplayer.hg
annotate libmpcodecs/vf_pp.c @ 26066:7b7d321574d7
Remove old EMU_OLD cruft.
author | diego |
---|---|
date | Mon, 25 Feb 2008 09:42:26 +0000 |
parents | 00fff9a3b735 |
children | bfada3b4c366 |
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 |
17012 | 7 #include "config.h" |
8 #include "mp_msg.h" | |
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 | |
9426 | 19 |
17463 | 20 #ifdef USE_LIBPOSTPROC_SO |
21 #include <postproc/postprocess.h> | |
22 #elif defined(USE_LIBPOSTPROC) | |
18557
b7746166426c
libpostproc is not a subdirectory of libavcodec anymore.
diego
parents:
17906
diff
changeset
|
23 #include "libpostproc/postprocess.h" |
17463 | 24 #endif |
8038 | 25 |
5512 | 26 struct vf_priv_s { |
7946 | 27 int pp; |
8040 | 28 pp_mode_t *ppMode[PP_QUALITY_MAX+1]; |
7946 | 29 void *context; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
30 unsigned int outfmt; |
5512 | 31 }; |
32 | |
33 //===========================================================================// | |
34 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
35 static int config(struct vf_instance_s* vf, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
36 int width, int height, int d_width, int d_height, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
37 unsigned int voflags, unsigned int outfmt){ |
8805 | 38 int flags= |
7985 | 39 (gCpuCaps.hasMMX ? PP_CPU_CAPS_MMX : 0) |
40 | (gCpuCaps.hasMMX2 ? PP_CPU_CAPS_MMX2 : 0) | |
8805 | 41 | (gCpuCaps.has3DNow ? PP_CPU_CAPS_3DNOW : 0); |
42 | |
43 switch(outfmt){ | |
44 case IMGFMT_444P: flags|= PP_FORMAT_444; break; | |
45 case IMGFMT_422P: flags|= PP_FORMAT_422; break; | |
46 case IMGFMT_411P: flags|= PP_FORMAT_411; break; | |
47 default: flags|= PP_FORMAT_420; break; | |
48 } | |
49 | |
50 if(vf->priv->context) pp_free_context(vf->priv->context); | |
51 vf->priv->context= pp_get_context(width, height, flags); | |
7946 | 52 |
9528 | 53 return vf_next_config(vf,width,height,d_width,d_height,voflags,outfmt); |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
54 } |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
55 |
7949 | 56 static void uninit(struct vf_instance_s* vf){ |
8038 | 57 int i; |
8040 | 58 for(i=0; i<=PP_QUALITY_MAX; i++){ |
8038 | 59 if(vf->priv->ppMode[i]) |
60 pp_free_mode(vf->priv->ppMode[i]); | |
61 } | |
7961 | 62 if(vf->priv->context) pp_free_context(vf->priv->context); |
7949 | 63 } |
64 | |
5518 | 65 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
66 switch(fmt){ | |
67 case IMGFMT_YV12: | |
68 case IMGFMT_I420: | |
69 case IMGFMT_IYUV: | |
8805 | 70 case IMGFMT_444P: |
71 case IMGFMT_422P: | |
72 case IMGFMT_411P: | |
73 return vf_next_query_format(vf,fmt); | |
5518 | 74 } |
75 return 0; | |
76 } | |
77 | |
5519 | 78 static int control(struct vf_instance_s* vf, int request, void* data){ |
79 switch(request){ | |
80 case VFCTRL_QUERY_MAX_PP_LEVEL: | |
8040 | 81 return PP_QUALITY_MAX; |
5519 | 82 case VFCTRL_SET_PP_LEVEL: |
7946 | 83 vf->priv->pp= *((unsigned int*)data); |
5519 | 84 return CONTROL_TRUE; |
85 } | |
86 return vf_next_control(vf,request,data); | |
87 } | |
88 | |
5512 | 89 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
90 if(vf->priv->pp&0xFFFF) return; // non-local filters enabled | |
5513 | 91 if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) && |
92 mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
93 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
|
94 return; // colorspace differ |
5512 | 95 // ok, we can do pp in-place (or pp disabled): |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
96 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
16018
bdf1b4ecb906
use stored dimensions instead of visible one when (vf_)get_image is called
iive
parents:
15965
diff
changeset
|
97 mpi->type, mpi->flags | MP_IMGFLAG_READABLE, mpi->width, mpi->height); |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
98 mpi->planes[0]=vf->dmpi->planes[0]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
99 mpi->stride[0]=vf->dmpi->stride[0]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
100 mpi->width=vf->dmpi->width; |
5512 | 101 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
102 mpi->planes[1]=vf->dmpi->planes[1]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
103 mpi->planes[2]=vf->dmpi->planes[2]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
104 mpi->stride[1]=vf->dmpi->stride[1]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
105 mpi->stride[2]=vf->dmpi->stride[2]; |
5512 | 106 } |
107 mpi->flags|=MP_IMGFLAG_DIRECT; | |
108 } | |
109 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17463
diff
changeset
|
110 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
5512 | 111 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ |
112 // no DR, so get a new image! hope we'll get DR buffer: | |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
113 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, |
16471
9f516ed86916
pp_postprocess reads from target image, so request a readable one.
reimar
parents:
16018
diff
changeset
|
114 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | |
9f516ed86916
pp_postprocess reads from target image, so request a readable one.
reimar
parents:
16018
diff
changeset
|
115 MP_IMGFLAG_PREFER_ALIGNED_STRIDE | MP_IMGFLAG_READABLE, |
6875 | 116 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
117 // mpi->w,mpi->h); | |
16018
bdf1b4ecb906
use stored dimensions instead of visible one when (vf_)get_image is called
iive
parents:
15965
diff
changeset
|
118 (mpi->width+7)&(~7),(mpi->height+7)&(~7)); |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
119 vf->dmpi->w=mpi->w; vf->dmpi->h=mpi->h; // display w;h |
5512 | 120 } |
121 | |
122 if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
123 // do the postprocessing! (or copy if no DR) | |
7961 | 124 pp_postprocess(mpi->planes ,mpi->stride, |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9931
diff
changeset
|
125 vf->dmpi->planes,vf->dmpi->stride, |
6875 | 126 (mpi->w+7)&(~7),mpi->h, |
5512 | 127 mpi->qscale, mpi->qstride, |
8038 | 128 vf->priv->ppMode[ vf->priv->pp ], vf->priv->context, |
9931 | 129 #ifdef PP_PICT_TYPE_QP2 |
9925
420640a0f6d0
passing qscale_type around so the pp code can fix the mpeg2 <<1 thing
michael
parents:
9593
diff
changeset
|
130 mpi->pict_type | (mpi->qscale_type ? PP_PICT_TYPE_QP2 : 0)); |
9931 | 131 #else |
132 mpi->pict_type); | |
133 #endif | |
5512 | 134 } |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17463
diff
changeset
|
135 return vf_next_put_image(vf,vf->dmpi, pts); |
5512 | 136 } |
137 | |
138 //===========================================================================// | |
139 | |
140 extern int divx_quality; | |
141 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
142 static unsigned int fmt_list[]={ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
143 IMGFMT_YV12, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
144 IMGFMT_I420, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
145 IMGFMT_IYUV, |
8805 | 146 IMGFMT_444P, |
147 IMGFMT_422P, | |
148 IMGFMT_411P, | |
7127 | 149 0 |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
150 }; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
151 |
5512 | 152 static int open(vf_instance_t *vf, char* args){ |
7946 | 153 char *endptr, *name; |
154 int i; | |
155 int hex_mode=0; | |
156 | |
5518 | 157 vf->query_format=query_format; |
5519 | 158 vf->control=control; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
159 vf->config=config; |
5512 | 160 vf->get_image=get_image; |
161 vf->put_image=put_image; | |
7949 | 162 vf->uninit=uninit; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
163 vf->default_caps=VFCAP_ACCEPT_STRIDE|VFCAP_POSTPROC; |
5512 | 164 vf->priv=malloc(sizeof(struct vf_priv_s)); |
7949 | 165 vf->priv->context=NULL; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
166 |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
167 // check csp: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
168 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
|
169 if(!vf->priv->outfmt) return 0; // no csp match :( |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
170 |
5514 | 171 if(args){ |
7946 | 172 hex_mode= strtol(args, &endptr, 0); |
173 if(*endptr){ | |
174 name= args; | |
175 }else | |
176 name= NULL; | |
177 }else{ | |
178 name="de"; | |
5514 | 179 } |
7972 | 180 |
8038 | 181 #ifdef EMU_OLD |
7946 | 182 if(name){ |
8038 | 183 #endif |
8040 | 184 for(i=0; i<=PP_QUALITY_MAX; i++){ |
7961 | 185 vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(name, i); |
8038 | 186 if(vf->priv->ppMode[i]==NULL) return -1; |
7946 | 187 } |
8038 | 188 #ifdef EMU_OLD |
7946 | 189 }else{ |
190 /* hex mode for compatibility */ | |
8040 | 191 for(i=0; i<=PP_QUALITY_MAX; i++){ |
8038 | 192 PPMode *ppMode; |
193 | |
194 ppMode= (PPMode*)memalign(8, sizeof(PPMode)); | |
7946 | 195 |
8038 | 196 ppMode->lumMode= hex_mode; |
197 ppMode->chromMode= ((hex_mode&0xFF)>>4) | (hex_mode&0xFFFFFF00); | |
198 ppMode->maxTmpNoise[0]= 700; | |
199 ppMode->maxTmpNoise[1]= 1500; | |
200 ppMode->maxTmpNoise[2]= 3000; | |
201 ppMode->maxAllowedY= 234; | |
202 ppMode->minAllowedY= 16; | |
203 ppMode->baseDcDiff= 256/4; | |
204 ppMode->flatnessThreshold=40; | |
7946 | 205 |
206 vf->priv->ppMode[i]= ppMode; | |
207 } | |
208 } | |
8038 | 209 #endif |
7946 | 210 |
10756 | 211 vf->priv->pp=PP_QUALITY_MAX; |
5512 | 212 return 1; |
213 } | |
214 | |
25221 | 215 const vf_info_t vf_info_pp = { |
5512 | 216 "postprocessing", |
217 "pp", | |
218 "A'rpi", | |
219 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9528
diff
changeset
|
220 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9528
diff
changeset
|
221 NULL |
5512 | 222 }; |
223 | |
224 //===========================================================================// | |
9426 | 225 |