Mercurial > mplayer.hg
annotate libmpcodecs/vf_pp.c @ 6395:9b218a01b74b
use default.css
author | diego |
---|---|
date | Wed, 12 Jun 2002 11:05:55 +0000 |
parents | 1972c3475d93 |
children | 255b150a75a5 |
rev | line source |
---|---|
5512 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 | |
5 #include "../config.h" | |
6 #include "../mp_msg.h" | |
7 | |
5607 | 8 #include "img_format.h" |
9 #include "mp_image.h" | |
5512 | 10 #include "vf.h" |
11 | |
12 #include "../postproc/postprocess.h" | |
13 | |
14 struct vf_priv_s { | |
15 unsigned int pp; | |
16 mp_image_t *dmpi; | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
17 unsigned int outfmt; |
5512 | 18 }; |
19 | |
20 //===========================================================================// | |
21 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
22 static int config(struct vf_instance_s* vf, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
23 int width, int height, int d_width, int d_height, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
24 unsigned int voflags, unsigned int outfmt){ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
25 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
|
26 } |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
27 |
5518 | 28 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
29 switch(fmt){ | |
30 case IMGFMT_YV12: | |
31 case IMGFMT_I420: | |
32 case IMGFMT_IYUV: | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
33 return vf_next_query_format(vf,vf->priv->outfmt); |
5518 | 34 } |
35 return 0; | |
36 } | |
37 | |
5519 | 38 static int control(struct vf_instance_s* vf, int request, void* data){ |
39 switch(request){ | |
40 case VFCTRL_QUERY_MAX_PP_LEVEL: | |
41 return GET_PP_QUALITY_MAX; | |
42 case VFCTRL_SET_PP_LEVEL: | |
43 vf->priv->pp=getPpModeForQuality(*((unsigned int*)data)); | |
44 return CONTROL_TRUE; | |
45 } | |
46 return vf_next_control(vf,request,data); | |
47 } | |
48 | |
5512 | 49 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
50 if(vf->priv->pp&0xFFFF) return; // non-local filters enabled | |
5513 | 51 if((mpi->type==MP_IMGTYPE_IPB || vf->priv->pp) && |
52 mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
53 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
|
54 return; // colorspace differ |
5512 | 55 // ok, we can do pp in-place (or pp disabled): |
56 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
57 mpi->type, mpi->flags, mpi->w, mpi->h); | |
58 mpi->planes[0]=vf->priv->dmpi->planes[0]; | |
59 mpi->stride[0]=vf->priv->dmpi->stride[0]; | |
60 mpi->width=vf->priv->dmpi->width; | |
61 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
62 mpi->planes[1]=vf->priv->dmpi->planes[1]; | |
63 mpi->planes[2]=vf->priv->dmpi->planes[2]; | |
64 mpi->stride[1]=vf->priv->dmpi->stride[1]; | |
65 mpi->stride[2]=vf->priv->dmpi->stride[2]; | |
66 } | |
67 mpi->flags|=MP_IMGFLAG_DIRECT; | |
68 } | |
69 | |
70 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
71 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
72 // 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
|
73 vf->priv->dmpi=vf_get_image(vf->next,vf->priv->outfmt, |
5512 | 74 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ALIGNED_STRIDE, |
75 mpi->w,mpi->h); | |
76 } | |
77 | |
78 if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
79 // do the postprocessing! (or copy if no DR) | |
80 postprocess(mpi->planes,mpi->stride[0], | |
81 vf->priv->dmpi->planes,vf->priv->dmpi->stride[0], | |
82 mpi->w,mpi->h, | |
83 mpi->qscale, mpi->qstride, | |
84 vf->priv->pp); | |
85 } | |
86 | |
87 vf_next_put_image(vf,vf->priv->dmpi); | |
88 } | |
89 | |
90 //===========================================================================// | |
91 | |
92 extern int divx_quality; | |
93 | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
94 static unsigned int fmt_list[]={ |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
95 IMGFMT_YV12, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
96 IMGFMT_I420, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
97 IMGFMT_IYUV, |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
98 NULL |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
99 }; |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
100 |
5512 | 101 static int open(vf_instance_t *vf, char* args){ |
5514 | 102 char *endptr; |
5518 | 103 vf->query_format=query_format; |
5519 | 104 vf->control=control; |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
105 vf->config=config; |
5512 | 106 vf->get_image=get_image; |
107 vf->put_image=put_image; | |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
108 vf->default_caps=VFCAP_ACCEPT_STRIDE|VFCAP_POSTPROC; |
5512 | 109 vf->priv=malloc(sizeof(struct vf_priv_s)); |
5565
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
110 |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
111 // check csp: |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
112 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
|
113 if(!vf->priv->outfmt) return 0; // no csp match :( |
0b301fec999a
capabilities support -> automatic insertion of scale, expand, pp
arpi
parents:
5519
diff
changeset
|
114 |
5514 | 115 if(args){ |
116 vf->priv->pp=strtol(args, &endptr, 0); | |
117 if(!(*endptr)) return 1; | |
118 } | |
5512 | 119 vf->priv->pp=divx_quality; |
120 return 1; | |
121 } | |
122 | |
123 vf_info_t vf_info_pp = { | |
124 "postprocessing", | |
125 "pp", | |
126 "A'rpi", | |
127 "", | |
128 open | |
129 }; | |
130 | |
131 //===========================================================================// |