Mercurial > mplayer.hg
annotate libmpcodecs/vf_qp.c @ 13508:d3a1e13e44a6
Removal of vo_md5 and vo_pgm of MAINTAINERS file.
author | ivo |
---|---|
date | Wed, 29 Sep 2004 01:51:51 +0000 |
parents | e9ab21c4db24 |
children | 044b85964c05 |
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 | |
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 */ | |
18 | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <math.h> | |
23 #include <inttypes.h> | |
24 | |
25 #include "../config.h" | |
26 | |
27 #ifdef USE_LIBAVCODEC | |
28 | |
29 #include "../mp_msg.h" | |
30 #include "../cpudetect.h" | |
31 | |
32 #if 1 | |
33 double ff_eval(char *s, double *const_value, const char **const_name, | |
34 double (**func1)(void *, double), const char **func1_name, | |
35 double (**func2)(void *, double, double), char **func2_name, | |
36 void *opaque); | |
11923
e9ab21c4db24
#include dsputil.h as it contains the lrintf emu code
michael
parents:
11921
diff
changeset
|
37 #endif |
e9ab21c4db24
#include dsputil.h as it contains the lrintf emu code
michael
parents:
11921
diff
changeset
|
38 |
11921 | 39 #ifdef USE_LIBAVCODEC_SO |
40 #include <ffmpeg/avcodec.h> | |
11923
e9ab21c4db24
#include dsputil.h as it contains the lrintf emu code
michael
parents:
11921
diff
changeset
|
41 #include <ffmpeg/dsputil.h> |
11921 | 42 #else |
43 #include "../libavcodec/avcodec.h" | |
11923
e9ab21c4db24
#include dsputil.h as it contains the lrintf emu code
michael
parents:
11921
diff
changeset
|
44 #include "../libavcodec/dsputil.h" |
11921 | 45 #endif |
46 | |
47 #ifdef HAVE_MALLOC_H | |
48 #include <malloc.h> | |
49 #endif | |
50 | |
51 #include "img_format.h" | |
52 #include "mp_image.h" | |
53 #include "vf.h" | |
54 #include "../libvo/fastmemcpy.h" | |
55 | |
56 | |
57 struct vf_priv_s { | |
58 char eq[200]; | |
59 int8_t *qp; | |
60 int8_t lut[257]; | |
61 int qp_stride; | |
62 }; | |
63 | |
64 static int config(struct vf_instance_s* vf, | |
65 int width, int height, int d_width, int d_height, | |
66 unsigned int flags, unsigned int outfmt){ | |
67 int h= (height+15)>>4; | |
68 int i; | |
69 | |
70 vf->priv->qp_stride= (width+15)>>4; | |
71 vf->priv->qp= malloc(vf->priv->qp_stride*h*sizeof(int8_t)); | |
72 | |
73 for(i=-129; i<128; i++){ | |
74 double const_values[]={ | |
75 M_PI, | |
76 M_E, | |
77 i != -129, | |
78 i, | |
79 0 | |
80 }; | |
81 static const char *const_names[]={ | |
82 "PI", | |
83 "E", | |
84 "known", | |
85 "qp", | |
86 NULL | |
87 }; | |
88 | |
89 vf->priv->lut[i+129]= lrintf(ff_eval(vf->priv->eq, const_values, const_names, NULL, NULL, NULL, NULL, NULL)); | |
90 } | |
91 | |
92 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
93 } | |
94 | |
95 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
96 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
97 // ok, we can do pp in-place (or pp disabled): | |
98 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
99 mpi->type, mpi->flags, mpi->w, mpi->h); | |
100 mpi->planes[0]=vf->dmpi->planes[0]; | |
101 mpi->stride[0]=vf->dmpi->stride[0]; | |
102 mpi->width=vf->dmpi->width; | |
103 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
104 mpi->planes[1]=vf->dmpi->planes[1]; | |
105 mpi->planes[2]=vf->dmpi->planes[2]; | |
106 mpi->stride[1]=vf->dmpi->stride[1]; | |
107 mpi->stride[2]=vf->dmpi->stride[2]; | |
108 } | |
109 mpi->flags|=MP_IMGFLAG_DIRECT; | |
110 } | |
111 | |
112 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
113 mp_image_t *dmpi; | |
114 int x,y; | |
115 | |
116 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
117 // no DR, so get a new image! hope we'll get DR buffer: | |
118 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
119 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, | |
120 mpi->w,mpi->h); | |
121 } | |
122 | |
123 dmpi= vf->dmpi; | |
124 | |
125 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
126 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); | |
127 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
128 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]); | |
129 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]); | |
130 } | |
131 } | |
132 vf_clone_mpi_attributes(dmpi, mpi); | |
133 | |
134 dmpi->qscale = vf->priv->qp; | |
135 dmpi->qstride= vf->priv->qp_stride; | |
136 if(mpi->qscale){ | |
137 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
138 for(x=0; x<vf->priv->qp_stride; x++){ | |
139 dmpi->qscale[x + dmpi->qstride*y]= | |
140 vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ]; | |
141 } | |
142 } | |
143 }else{ | |
144 int qp= vf->priv->lut[0]; | |
145 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
146 for(x=0; x<vf->priv->qp_stride; x++){ | |
147 dmpi->qscale[x + dmpi->qstride*y]= qp; | |
148 } | |
149 } | |
150 } | |
151 | |
152 return vf_next_put_image(vf,dmpi); | |
153 } | |
154 | |
155 static void uninit(struct vf_instance_s* vf){ | |
156 if(!vf->priv) return; | |
157 | |
158 if(vf->priv->qp) free(vf->priv->qp); | |
159 vf->priv->qp= NULL; | |
160 | |
161 free(vf->priv); | |
162 vf->priv=NULL; | |
163 } | |
164 | |
165 //===========================================================================// | |
166 static int open(vf_instance_t *vf, char* args){ | |
167 vf->config=config; | |
168 vf->put_image=put_image; | |
169 vf->get_image=get_image; | |
170 vf->uninit=uninit; | |
171 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
172 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | |
173 | |
174 // avcodec_init(); | |
175 | |
176 if (args) strncpy(vf->priv->eq, args, 199); | |
177 | |
178 return 1; | |
179 } | |
180 | |
181 vf_info_t vf_info_qp = { | |
182 "QP changer", | |
183 "qp", | |
184 "Michael Niedermayer", | |
185 "", | |
186 open, | |
187 NULL | |
188 }; | |
189 | |
190 #endif //USE_LIBAVCODEC |