Mercurial > mplayer.hg
annotate libmpcodecs/vf_qp.c @ 23011:365eef1fc4f0
Disable caching of rotated glyphs.
The following commits will add perspective distortion to the glyphs rotated
with \frx and \fry. Somewhere along the way correct caching of such glyphs
will become impossible, but in the end everything will be fine.
author | eugeni |
---|---|
date | Fri, 20 Apr 2007 22:49:48 +0000 |
parents | e83548b7bd3b |
children | 918b0974e3a1 |
rev | line source |
---|---|
11921 | 1 /* |
2 Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
17367
401b440a6d76
Update licensing information: The FSF changed postal address.
diego
parents:
17012
diff
changeset
|
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
11921 | 17 */ |
18 | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <math.h> | |
23 #include <inttypes.h> | |
24 | |
17012 | 25 #include "config.h" |
11921 | 26 |
17012 | 27 #include "mp_msg.h" |
28 #include "cpudetect.h" | |
11921 | 29 |
30 #if 1 | |
31 double ff_eval(char *s, double *const_value, const char **const_name, | |
32 double (**func1)(void *, double), const char **func1_name, | |
33 double (**func2)(void *, double, double), char **func2_name, | |
34 void *opaque); | |
11923
e9ab21c4db24
#include dsputil.h as it contains the lrintf emu code
michael
parents:
11921
diff
changeset
|
35 #endif |
e9ab21c4db24
#include dsputil.h as it contains the lrintf emu code
michael
parents:
11921
diff
changeset
|
36 |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
37 // Needed to bring in lrintf. |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
38 #define HAVE_AV_CONFIG_H |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
39 |
17012 | 40 #include "libavcodec/avcodec.h" |
41 #include "libavcodec/dsputil.h" | |
42 #include "libavutil/common.h" | |
11921 | 43 |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
44 /* FIXME: common.h defines printf away when HAVE_AV_CONFIG |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
45 * is defined, but mp_image.h needs printf. |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
46 */ |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
47 #undef printf |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
48 |
11921 | 49 #ifdef HAVE_MALLOC_H |
50 #include <malloc.h> | |
51 #endif | |
52 | |
53 #include "img_format.h" | |
54 #include "mp_image.h" | |
55 #include "vf.h" | |
17012 | 56 #include "libvo/fastmemcpy.h" |
11921 | 57 |
58 | |
59 struct vf_priv_s { | |
60 char eq[200]; | |
61 int8_t *qp; | |
62 int8_t lut[257]; | |
63 int qp_stride; | |
64 }; | |
65 | |
66 static int config(struct vf_instance_s* vf, | |
67 int width, int height, int d_width, int d_height, | |
68 unsigned int flags, unsigned int outfmt){ | |
69 int h= (height+15)>>4; | |
70 int i; | |
71 | |
72 vf->priv->qp_stride= (width+15)>>4; | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
73 vf->priv->qp= av_malloc(vf->priv->qp_stride*h*sizeof(int8_t)); |
11921 | 74 |
75 for(i=-129; i<128; i++){ | |
76 double const_values[]={ | |
77 M_PI, | |
78 M_E, | |
79 i != -129, | |
80 i, | |
81 0 | |
82 }; | |
83 static const char *const_names[]={ | |
84 "PI", | |
85 "E", | |
86 "known", | |
87 "qp", | |
88 NULL | |
89 }; | |
90 | |
91 vf->priv->lut[i+129]= lrintf(ff_eval(vf->priv->eq, const_values, const_names, NULL, NULL, NULL, NULL, NULL)); | |
92 } | |
93 | |
94 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
95 } | |
96 | |
97 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
98 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
99 // ok, we can do pp in-place (or pp disabled): | |
100 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
101 mpi->type, mpi->flags, mpi->w, mpi->h); | |
102 mpi->planes[0]=vf->dmpi->planes[0]; | |
103 mpi->stride[0]=vf->dmpi->stride[0]; | |
104 mpi->width=vf->dmpi->width; | |
105 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
106 mpi->planes[1]=vf->dmpi->planes[1]; | |
107 mpi->planes[2]=vf->dmpi->planes[2]; | |
108 mpi->stride[1]=vf->dmpi->stride[1]; | |
109 mpi->stride[2]=vf->dmpi->stride[2]; | |
110 } | |
111 mpi->flags|=MP_IMGFLAG_DIRECT; | |
112 } | |
113 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
114 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
11921 | 115 mp_image_t *dmpi; |
116 int x,y; | |
117 | |
118 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
119 // no DR, so get a new image! hope we'll get DR buffer: | |
120 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
121 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, | |
122 mpi->w,mpi->h); | |
123 } | |
124 | |
125 dmpi= vf->dmpi; | |
126 | |
127 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
128 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); | |
129 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
130 memcpy_pic(dmpi->planes[1], mpi->planes[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[1], mpi->stride[1]); | |
131 memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[2], mpi->stride[2]); | |
132 } | |
133 } | |
134 vf_clone_mpi_attributes(dmpi, mpi); | |
135 | |
136 dmpi->qscale = vf->priv->qp; | |
137 dmpi->qstride= vf->priv->qp_stride; | |
138 if(mpi->qscale){ | |
139 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
140 for(x=0; x<vf->priv->qp_stride; x++){ | |
141 dmpi->qscale[x + dmpi->qstride*y]= | |
142 vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ]; | |
143 } | |
144 } | |
145 }else{ | |
146 int qp= vf->priv->lut[0]; | |
147 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
148 for(x=0; x<vf->priv->qp_stride; x++){ | |
149 dmpi->qscale[x + dmpi->qstride*y]= qp; | |
150 } | |
151 } | |
152 } | |
153 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
154 return vf_next_put_image(vf,dmpi, pts); |
11921 | 155 } |
156 | |
157 static void uninit(struct vf_instance_s* vf){ | |
158 if(!vf->priv) return; | |
159 | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
160 if(vf->priv->qp) av_free(vf->priv->qp); |
11921 | 161 vf->priv->qp= NULL; |
162 | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
163 av_free(vf->priv); |
11921 | 164 vf->priv=NULL; |
165 } | |
166 | |
167 //===========================================================================// | |
168 static int open(vf_instance_t *vf, char* args){ | |
169 vf->config=config; | |
170 vf->put_image=put_image; | |
171 vf->get_image=get_image; | |
172 vf->uninit=uninit; | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
173 vf->priv=av_malloc(sizeof(struct vf_priv_s)); |
11921 | 174 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
175 | |
176 // avcodec_init(); | |
177 | |
178 if (args) strncpy(vf->priv->eq, args, 199); | |
179 | |
180 return 1; | |
181 } | |
182 | |
183 vf_info_t vf_info_qp = { | |
184 "QP changer", | |
185 "qp", | |
186 "Michael Niedermayer", | |
187 "", | |
188 open, | |
189 NULL | |
190 }; |