Mercurial > mplayer.hg
annotate libmpcodecs/vf_qp.c @ 29370:059ff1f4e280
The AltiVec code in libswscale no longer is under GPL.
Remove one erroneous preprocessor check for CONFIG_GPL in the AltiVec code.
author | diego |
---|---|
date | Sun, 05 Jul 2009 20:10:59 +0000 |
parents | 0f1b5b68af32 |
children | a7b908875c14 |
rev | line source |
---|---|
11921 | 1 /* |
26727 | 2 * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
11921 | 20 |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <math.h> | |
25 #include <inttypes.h> | |
26 | |
17012 | 27 #include "mp_msg.h" |
28 #include "cpudetect.h" | |
24974
6f05850b5fd1
Rearrange headers to get rid of an #undef and remove unnecessary headers.
diego
parents:
24972
diff
changeset
|
29 #include "img_format.h" |
6f05850b5fd1
Rearrange headers to get rid of an #undef and remove unnecessary headers.
diego
parents:
24972
diff
changeset
|
30 #include "mp_image.h" |
6f05850b5fd1
Rearrange headers to get rid of an #undef and remove unnecessary headers.
diego
parents:
24972
diff
changeset
|
31 #include "vf.h" |
6f05850b5fd1
Rearrange headers to get rid of an #undef and remove unnecessary headers.
diego
parents:
24972
diff
changeset
|
32 #include "libvo/fastmemcpy.h" |
11921 | 33 |
17012 | 34 #include "libavcodec/avcodec.h" |
24972
60e8bf1f23e9
#include libavcodec/eval.h instead of manually declaring ff_eval.
diego
parents:
24020
diff
changeset
|
35 #include "libavcodec/eval.h" |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
36 |
11921 | 37 |
38 struct vf_priv_s { | |
39 char eq[200]; | |
40 int8_t *qp; | |
41 int8_t lut[257]; | |
42 int qp_stride; | |
43 }; | |
44 | |
45 static int config(struct vf_instance_s* vf, | |
46 int width, int height, int d_width, int d_height, | |
47 unsigned int flags, unsigned int outfmt){ | |
48 int h= (height+15)>>4; | |
49 int i; | |
50 | |
51 vf->priv->qp_stride= (width+15)>>4; | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
52 vf->priv->qp= av_malloc(vf->priv->qp_stride*h*sizeof(int8_t)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
53 |
11921 | 54 for(i=-129; i<128; i++){ |
55 double const_values[]={ | |
56 M_PI, | |
57 M_E, | |
58 i != -129, | |
59 i, | |
60 0 | |
61 }; | |
62 static const char *const_names[]={ | |
63 "PI", | |
64 "E", | |
65 "known", | |
66 "qp", | |
67 NULL | |
68 }; | |
69 | |
27516
3364aef9a988
Fix compilation after libavcodec major version 52 changes
uau
parents:
26727
diff
changeset
|
70 const char *error = NULL; |
3364aef9a988
Fix compilation after libavcodec major version 52 changes
uau
parents:
26727
diff
changeset
|
71 vf->priv->lut[i+129]= lrintf(ff_eval2(vf->priv->eq, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error)); |
3364aef9a988
Fix compilation after libavcodec major version 52 changes
uau
parents:
26727
diff
changeset
|
72 if (error) |
3364aef9a988
Fix compilation after libavcodec major version 52 changes
uau
parents:
26727
diff
changeset
|
73 mp_msg(MSGT_VFILTER, MSGL_ERR, "qp: Error evaluating \"%s\": %s\n", vf->priv->eq, error); |
11921 | 74 } |
75 | |
76 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
77 } | |
78 | |
79 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
80 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
81 // ok, we can do pp in-place (or pp disabled): | |
82 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
83 mpi->type, mpi->flags, mpi->w, mpi->h); | |
84 mpi->planes[0]=vf->dmpi->planes[0]; | |
85 mpi->stride[0]=vf->dmpi->stride[0]; | |
86 mpi->width=vf->dmpi->width; | |
87 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
88 mpi->planes[1]=vf->dmpi->planes[1]; | |
89 mpi->planes[2]=vf->dmpi->planes[2]; | |
90 mpi->stride[1]=vf->dmpi->stride[1]; | |
91 mpi->stride[2]=vf->dmpi->stride[2]; | |
92 } | |
93 mpi->flags|=MP_IMGFLAG_DIRECT; | |
94 } | |
95 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
96 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
11921 | 97 mp_image_t *dmpi; |
98 int x,y; | |
99 | |
100 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
101 // no DR, so get a new image! hope we'll get DR buffer: | |
102 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
103 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, | |
104 mpi->w,mpi->h); | |
105 } | |
106 | |
107 dmpi= vf->dmpi; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
108 |
11921 | 109 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ |
110 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); | |
111 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
112 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]); | |
113 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]); | |
114 } | |
115 } | |
116 vf_clone_mpi_attributes(dmpi, mpi); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
117 |
11921 | 118 dmpi->qscale = vf->priv->qp; |
119 dmpi->qstride= vf->priv->qp_stride; | |
120 if(mpi->qscale){ | |
121 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
122 for(x=0; x<vf->priv->qp_stride; x++){ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
123 dmpi->qscale[x + dmpi->qstride*y]= |
11921 | 124 vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ]; |
125 } | |
126 } | |
127 }else{ | |
128 int qp= vf->priv->lut[0]; | |
129 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
130 for(x=0; x<vf->priv->qp_stride; x++){ | |
131 dmpi->qscale[x + dmpi->qstride*y]= qp; | |
132 } | |
133 } | |
134 } | |
135 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
136 return vf_next_put_image(vf,dmpi, pts); |
11921 | 137 } |
138 | |
139 static void uninit(struct vf_instance_s* vf){ | |
140 if(!vf->priv) return; | |
141 | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
142 if(vf->priv->qp) av_free(vf->priv->qp); |
11921 | 143 vf->priv->qp= NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
144 |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
145 av_free(vf->priv); |
11921 | 146 vf->priv=NULL; |
147 } | |
148 | |
149 //===========================================================================// | |
150 static int open(vf_instance_t *vf, char* args){ | |
151 vf->config=config; | |
152 vf->put_image=put_image; | |
153 vf->get_image=get_image; | |
154 vf->uninit=uninit; | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
155 vf->priv=av_malloc(sizeof(struct vf_priv_s)); |
11921 | 156 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
157 |
11921 | 158 // avcodec_init(); |
159 | |
160 if (args) strncpy(vf->priv->eq, args, 199); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
161 |
11921 | 162 return 1; |
163 } | |
164 | |
25221 | 165 const vf_info_t vf_info_qp = { |
11921 | 166 "QP changer", |
167 "qp", | |
168 "Michael Niedermayer", | |
169 "", | |
170 open, | |
171 NULL | |
172 }; |