Mercurial > mplayer.hg
annotate libmpcodecs/vf_qp.c @ 25836:bc425ba00960
added code to check and handle the presence of LATM streams in the init() and decode() functions
author | nicodvb |
---|---|
date | Sat, 26 Jan 2008 18:45:11 +0000 |
parents | 00fff9a3b735 |
children | 82601a38e2a7 |
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" | |
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 |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
34 // Needed to bring in lrintf. |
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
35 #define HAVE_AV_CONFIG_H |
17012 | 36 #include "libavcodec/avcodec.h" |
24972
60e8bf1f23e9
#include libavcodec/eval.h instead of manually declaring ff_eval.
diego
parents:
24020
diff
changeset
|
37 #include "libavcodec/eval.h" |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
38 |
11921 | 39 #ifdef HAVE_MALLOC_H |
40 #include <malloc.h> | |
41 #endif | |
42 | |
43 | |
44 struct vf_priv_s { | |
45 char eq[200]; | |
46 int8_t *qp; | |
47 int8_t lut[257]; | |
48 int qp_stride; | |
49 }; | |
50 | |
51 static int config(struct vf_instance_s* vf, | |
52 int width, int height, int d_width, int d_height, | |
53 unsigned int flags, unsigned int outfmt){ | |
54 int h= (height+15)>>4; | |
55 int i; | |
56 | |
57 vf->priv->qp_stride= (width+15)>>4; | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
58 vf->priv->qp= av_malloc(vf->priv->qp_stride*h*sizeof(int8_t)); |
11921 | 59 |
60 for(i=-129; i<128; i++){ | |
61 double const_values[]={ | |
62 M_PI, | |
63 M_E, | |
64 i != -129, | |
65 i, | |
66 0 | |
67 }; | |
68 static const char *const_names[]={ | |
69 "PI", | |
70 "E", | |
71 "known", | |
72 "qp", | |
73 NULL | |
74 }; | |
75 | |
76 vf->priv->lut[i+129]= lrintf(ff_eval(vf->priv->eq, const_values, const_names, NULL, NULL, NULL, NULL, NULL)); | |
77 } | |
78 | |
79 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
80 } | |
81 | |
82 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
83 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
84 // ok, we can do pp in-place (or pp disabled): | |
85 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
86 mpi->type, mpi->flags, mpi->w, mpi->h); | |
87 mpi->planes[0]=vf->dmpi->planes[0]; | |
88 mpi->stride[0]=vf->dmpi->stride[0]; | |
89 mpi->width=vf->dmpi->width; | |
90 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
91 mpi->planes[1]=vf->dmpi->planes[1]; | |
92 mpi->planes[2]=vf->dmpi->planes[2]; | |
93 mpi->stride[1]=vf->dmpi->stride[1]; | |
94 mpi->stride[2]=vf->dmpi->stride[2]; | |
95 } | |
96 mpi->flags|=MP_IMGFLAG_DIRECT; | |
97 } | |
98 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
99 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
11921 | 100 mp_image_t *dmpi; |
101 int x,y; | |
102 | |
103 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
104 // no DR, so get a new image! hope we'll get DR buffer: | |
105 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
106 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, | |
107 mpi->w,mpi->h); | |
108 } | |
109 | |
110 dmpi= vf->dmpi; | |
111 | |
112 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
113 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]); | |
114 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
115 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]); | |
116 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]); | |
117 } | |
118 } | |
119 vf_clone_mpi_attributes(dmpi, mpi); | |
120 | |
121 dmpi->qscale = vf->priv->qp; | |
122 dmpi->qstride= vf->priv->qp_stride; | |
123 if(mpi->qscale){ | |
124 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
125 for(x=0; x<vf->priv->qp_stride; x++){ | |
126 dmpi->qscale[x + dmpi->qstride*y]= | |
127 vf->priv->lut[ 129 + ((int8_t)mpi->qscale[x + mpi->qstride*y]) ]; | |
128 } | |
129 } | |
130 }else{ | |
131 int qp= vf->priv->lut[0]; | |
132 for(y=0; y<((dmpi->h+15)>>4); y++){ | |
133 for(x=0; x<vf->priv->qp_stride; x++){ | |
134 dmpi->qscale[x + dmpi->qstride*y]= qp; | |
135 } | |
136 } | |
137 } | |
138 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17523
diff
changeset
|
139 return vf_next_put_image(vf,dmpi, pts); |
11921 | 140 } |
141 | |
142 static void uninit(struct vf_instance_s* vf){ | |
143 if(!vf->priv) return; | |
144 | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
145 if(vf->priv->qp) av_free(vf->priv->qp); |
11921 | 146 vf->priv->qp= NULL; |
147 | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
148 av_free(vf->priv); |
11921 | 149 vf->priv=NULL; |
150 } | |
151 | |
152 //===========================================================================// | |
153 static int open(vf_instance_t *vf, char* args){ | |
154 vf->config=config; | |
155 vf->put_image=put_image; | |
156 vf->get_image=get_image; | |
157 vf->uninit=uninit; | |
16677
044b85964c05
Compilation fix for systems lacking lrintf like e.g. NetBSD.
diego
parents:
11923
diff
changeset
|
158 vf->priv=av_malloc(sizeof(struct vf_priv_s)); |
11921 | 159 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
160 | |
161 // avcodec_init(); | |
162 | |
163 if (args) strncpy(vf->priv->eq, args, 199); | |
164 | |
165 return 1; | |
166 } | |
167 | |
25221 | 168 const vf_info_t vf_info_qp = { |
11921 | 169 "QP changer", |
170 "qp", | |
171 "Michael Niedermayer", | |
172 "", | |
173 open, | |
174 NULL | |
175 }; |