Mercurial > mplayer.hg
annotate libmpcodecs/vf_spp.c @ 11324:9fceaedbd5a6
Missing <application> tags added, patch by Maciej Paszta <paszczi@go2.pl>.
zlib added to the recommended libraries list.
author | diego |
---|---|
date | Thu, 30 Oct 2003 00:21:31 +0000 |
parents | 0c8d12a58a29 |
children | 04ea7b95da68 |
rev | line source |
---|---|
11277 | 1 /* |
2 Copyright (C) 2003 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 /* | |
20 * This implementation is based on an algorithm described in | |
21 * "Aria Nosratinia Embedded Post-Processing for | |
22 * Enhancement of Compressed Images (1999)" | |
23 * (http://citeseer.nj.nec.com/nosratinia99embedded.html) | |
24 */ | |
25 | |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <string.h> | |
29 #include <inttypes.h> | |
30 #include <math.h> | |
31 | |
32 #include "../config.h" | |
33 #include "../mp_msg.h" | |
34 #include "../cpudetect.h" | |
35 #include "../libavcodec/avcodec.h" | |
36 #include "../libavcodec/dsputil.h" | |
37 | |
38 #ifdef HAVE_MALLOC_H | |
39 #include <malloc.h> | |
40 #endif | |
41 | |
42 #include "img_format.h" | |
43 #include "mp_image.h" | |
44 #include "vf.h" | |
45 #include "../libvo/fastmemcpy.h" | |
46 | |
47 #define XMIN(a,b) ((a) < (b) ? (a) : (b)) | |
48 | |
49 //===========================================================================// | |
50 const uint8_t __attribute__((aligned(8))) dither[8][8]={ | |
51 { 0, 48, 12, 60, 3, 51, 15, 63, }, | |
52 { 32, 16, 44, 28, 35, 19, 47, 31, }, | |
53 { 8, 56, 4, 52, 11, 59, 7, 55, }, | |
54 { 40, 24, 36, 20, 43, 27, 39, 23, }, | |
55 { 2, 50, 14, 62, 1, 49, 13, 61, }, | |
56 { 34, 18, 46, 30, 33, 17, 45, 29, }, | |
57 { 10, 58, 6, 54, 9, 57, 5, 53, }, | |
58 { 42, 26, 38, 22, 41, 25, 37, 21, }, | |
59 }; | |
60 | |
11298 | 61 const uint8_t offset[127][2]= { |
62 {0,0}, | |
63 {0,0}, {4,4}, | |
64 {0,0}, {2,2}, {6,4}, {4,6}, | |
65 {0,0}, {5,1}, {2,2}, {7,3}, {4,4}, {1,5}, {6,6}, {3,7}, | |
66 | |
67 {0,0}, {4,0}, {1,1}, {5,1}, {3,2}, {7,2}, {2,3}, {6,3}, | |
68 {0,4}, {4,4}, {1,5}, {5,5}, {3,6}, {7,6}, {2,7}, {6,7}, | |
69 | |
70 {0,0}, {0,2}, {0,4}, {0,6}, {1,1}, {1,3}, {1,5}, {1,7}, | |
71 {2,0}, {2,2}, {2,4}, {2,6}, {3,1}, {3,3}, {3,5}, {3,7}, | |
72 {4,0}, {4,2}, {4,4}, {4,6}, {5,1}, {5,3}, {5,5}, {5,7}, | |
73 {6,0}, {6,2}, {6,4}, {6,6}, {7,1}, {7,3}, {7,5}, {7,7}, | |
74 | |
11277 | 75 {0,0}, {4,4}, {0,4}, {4,0}, {2,2}, {6,6}, {2,6}, {6,2}, |
76 {0,2}, {4,6}, {0,6}, {4,2}, {2,0}, {6,4}, {2,4}, {6,0}, | |
77 {1,1}, {5,5}, {1,5}, {5,1}, {3,3}, {7,7}, {3,7}, {7,3}, | |
78 {1,3}, {5,7}, {1,7}, {5,3}, {3,1}, {7,5}, {3,5}, {7,1}, | |
79 {0,1}, {4,5}, {0,5}, {4,1}, {2,3}, {6,7}, {2,7}, {6,3}, | |
80 {0,3}, {4,7}, {0,7}, {4,3}, {2,1}, {6,5}, {2,5}, {6,1}, | |
81 {1,0}, {5,4}, {1,4}, {5,0}, {3,2}, {7,6}, {3,6}, {7,2}, | |
82 {1,2}, {5,6}, {1,6}, {5,2}, {3,0}, {7,4}, {3,4}, {7,0}, | |
83 }; | |
84 | |
85 struct vf_priv_s { | |
86 int log2_count; | |
87 int qp; | |
88 int mpeg2; | |
89 unsigned int outfmt; | |
90 int temp_stride; | |
91 uint8_t *src; | |
92 int16_t *temp; | |
93 AVCodecContext *avctx; | |
94 DSPContext dsp; | |
95 }; | |
96 | |
97 #define SHIFT 22 | |
98 | |
11301 | 99 static void requantize_c(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ |
11277 | 100 int i; |
101 int bias= 0; //FIXME | |
102 unsigned int threshold1, threshold2; | |
11296 | 103 |
11301 | 104 threshold1= qp*((1<<4) - bias) - 1; |
11277 | 105 threshold2= (threshold1<<1); |
106 | |
107 memset(dst, 0, 64*sizeof(DCTELEM)); | |
11296 | 108 dst[0]= (src[0] + 4)>>3; |
11277 | 109 |
11296 | 110 for(i=1; i<64; i++){ |
111 int level= src[i]; | |
11277 | 112 if(((unsigned)(level+threshold1))>threshold2){ |
113 const int j= permutation[i]; | |
11296 | 114 dst[j]= (level + 4)>>3; |
11277 | 115 } |
116 } | |
117 } | |
118 | |
11301 | 119 #ifdef HAVE_MMX |
120 static void requantize_mmx(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){ | |
121 int bias= 0; //FIXME | |
122 unsigned int threshold1; | |
123 | |
124 threshold1= qp*((1<<4) - bias) - 1; | |
125 | |
126 asm volatile( | |
127 #define REQUANT_CORE(dst0, dst1, dst2, dst3, src0, src1, src2, src3) \ | |
128 "movq " #src0 ", %%mm0 \n\t"\ | |
129 "movq " #src1 ", %%mm1 \n\t"\ | |
130 "movq " #src2 ", %%mm2 \n\t"\ | |
131 "movq " #src3 ", %%mm3 \n\t"\ | |
132 "psubw %%mm4, %%mm0 \n\t"\ | |
133 "psubw %%mm4, %%mm1 \n\t"\ | |
134 "psubw %%mm4, %%mm2 \n\t"\ | |
135 "psubw %%mm4, %%mm3 \n\t"\ | |
136 "paddusw %%mm5, %%mm0 \n\t"\ | |
137 "paddusw %%mm5, %%mm1 \n\t"\ | |
138 "paddusw %%mm5, %%mm2 \n\t"\ | |
139 "paddusw %%mm5, %%mm3 \n\t"\ | |
140 "paddw %%mm6, %%mm0 \n\t"\ | |
141 "paddw %%mm6, %%mm1 \n\t"\ | |
142 "paddw %%mm6, %%mm2 \n\t"\ | |
143 "paddw %%mm6, %%mm3 \n\t"\ | |
144 "psubusw %%mm6, %%mm0 \n\t"\ | |
145 "psubusw %%mm6, %%mm1 \n\t"\ | |
146 "psubusw %%mm6, %%mm2 \n\t"\ | |
147 "psubusw %%mm6, %%mm3 \n\t"\ | |
148 "psraw $3, %%mm0 \n\t"\ | |
149 "psraw $3, %%mm1 \n\t"\ | |
150 "psraw $3, %%mm2 \n\t"\ | |
151 "psraw $3, %%mm3 \n\t"\ | |
152 \ | |
153 "movq %%mm0, %%mm7 \n\t"\ | |
154 "punpcklwd %%mm2, %%mm0 \n\t" /*A*/\ | |
155 "punpckhwd %%mm2, %%mm7 \n\t" /*C*/\ | |
156 "movq %%mm1, %%mm2 \n\t"\ | |
157 "punpcklwd %%mm3, %%mm1 \n\t" /*B*/\ | |
158 "punpckhwd %%mm3, %%mm2 \n\t" /*D*/\ | |
159 "movq %%mm0, %%mm3 \n\t"\ | |
160 "punpcklwd %%mm1, %%mm0 \n\t" /*A*/\ | |
161 "punpckhwd %%mm7, %%mm3 \n\t" /*C*/\ | |
162 "punpcklwd %%mm1, %%mm7 \n\t" /*B*/\ | |
163 "punpckhwd %%mm2, %%mm1 \n\t" /*D*/\ | |
164 \ | |
165 "movq %%mm0, " #dst0 " \n\t"\ | |
166 "movq %%mm7, " #dst1 " \n\t"\ | |
167 "movq %%mm3, " #dst2 " \n\t"\ | |
168 "movq %%mm1, " #dst3 " \n\t" | |
169 | |
170 "movd %2, %%mm4 \n\t" | |
171 "movd %3, %%mm5 \n\t" | |
172 "movd %4, %%mm6 \n\t" | |
173 "packssdw %%mm4, %%mm4 \n\t" | |
174 "packssdw %%mm5, %%mm5 \n\t" | |
175 "packssdw %%mm6, %%mm6 \n\t" | |
176 "packssdw %%mm4, %%mm4 \n\t" | |
177 "packssdw %%mm5, %%mm5 \n\t" | |
178 "packssdw %%mm6, %%mm6 \n\t" | |
179 REQUANT_CORE( (%1), 8(%1), 16(%1), 24(%1), (%0), 8(%0), 64(%0), 72(%0)) | |
180 REQUANT_CORE(32(%1), 40(%1), 48(%1), 56(%1),16(%0),24(%0), 48(%0), 56(%0)) | |
181 REQUANT_CORE(64(%1), 72(%1), 80(%1), 88(%1),32(%0),40(%0), 96(%0),104(%0)) | |
182 REQUANT_CORE(96(%1),104(%1),112(%1),120(%1),80(%0),88(%0),112(%0),120(%0)) | |
183 : : "r" (src), "r" (dst), "g" (threshold1+1), "g" (threshold1+5), "g" (threshold1-4) //FIXME maybe more accurate then needed? | |
184 ); | |
185 dst[0]= (src[0] + 4)>>3; | |
186 } | |
187 #endif | |
188 | |
11277 | 189 static inline void add_block(int16_t *dst, int stride, DCTELEM block[64]){ |
11280 | 190 int y; |
11277 | 191 |
192 for(y=0; y<8; y++){ | |
11280 | 193 *(uint32_t*)&dst[0 + y*stride]+= *(uint32_t*)&block[0 + y*8]; |
194 *(uint32_t*)&dst[2 + y*stride]+= *(uint32_t*)&block[2 + y*8]; | |
195 *(uint32_t*)&dst[4 + y*stride]+= *(uint32_t*)&block[4 + y*8]; | |
196 *(uint32_t*)&dst[6 + y*stride]+= *(uint32_t*)&block[6 + y*8]; | |
11277 | 197 } |
198 } | |
199 | |
11305 | 200 static void store_slice_c(uint8_t *dst, int16_t *src, int dst_stride, int src_stride, int width, int height, int log2_scale){ |
11299 | 201 int y, x; |
202 | |
203 #define STORE(pos) \ | |
204 temp= ((src[x + y*src_stride + pos]<<log2_scale) + d[pos])>>6;\ | |
205 if(temp & 0x100) temp= ~(temp>>31);\ | |
206 dst[x + y*dst_stride + pos]= temp; | |
207 | |
11305 | 208 for(y=0; y<height; y++){ |
11299 | 209 uint8_t *d= dither[y]; |
210 for(x=0; x<width; x+=8){ | |
211 int temp; | |
212 STORE(0); | |
213 STORE(1); | |
214 STORE(2); | |
215 STORE(3); | |
216 STORE(4); | |
217 STORE(5); | |
218 STORE(6); | |
219 STORE(7); | |
220 } | |
221 } | |
222 } | |
223 | |
224 #ifdef HAVE_MMX | |
11305 | 225 static void store_slice_mmx(uint8_t *dst, int16_t *src, int dst_stride, int src_stride, int width, int height, int log2_scale){ |
11299 | 226 int y; |
227 | |
11305 | 228 for(y=0; y<height; y++){ |
11299 | 229 uint8_t *dst1= dst; |
230 int16_t *src1= src; | |
231 asm volatile( | |
232 "movq (%3), %%mm3 \n\t" | |
233 "movq (%3), %%mm4 \n\t" | |
234 "movd %4, %%mm2 \n\t" | |
235 "pxor %%mm0, %%mm0 \n\t" | |
236 "punpcklbw %%mm0, %%mm3 \n\t" | |
237 "punpckhbw %%mm0, %%mm4 \n\t" | |
238 "psraw %%mm2, %%mm3 \n\t" | |
239 "psraw %%mm2, %%mm4 \n\t" | |
240 "movd %5, %%mm2 \n\t" | |
241 "1: \n\t" | |
242 "movq (%0), %%mm0 \n\t" | |
243 "movq 8(%0), %%mm1 \n\t" | |
244 "paddw %%mm3, %%mm0 \n\t" | |
245 "paddw %%mm4, %%mm1 \n\t" | |
246 "psraw %%mm2, %%mm0 \n\t" | |
247 "psraw %%mm2, %%mm1 \n\t" | |
248 "packuswb %%mm1, %%mm0 \n\t" | |
249 "movq %%mm0, (%1) \n\t" | |
250 "addl $16, %0 \n\t" | |
251 "addl $8, %1 \n\t" | |
252 "cmpl %2, %1 \n\t" | |
253 " jb 1b \n\t" | |
254 : "+r" (src1), "+r"(dst1) | |
255 : "r"(dst + width), "r"(dither[y]), "g"(log2_scale), "g"(6-log2_scale) | |
256 ); | |
257 src += src_stride; | |
258 dst += dst_stride; | |
259 } | |
260 // if(width != mmxw) | |
261 // store_slice_c(dst + mmxw, src + mmxw, dst_stride, src_stride, width - mmxw, log2_scale); | |
262 } | |
263 #endif | |
264 | |
11305 | 265 static void (*store_slice)(uint8_t *dst, int16_t *src, int dst_stride, int src_stride, int width, int height, int log2_scale)= store_slice_c; |
11299 | 266 |
11301 | 267 static void (*requantize)(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation)= requantize_c; |
268 | |
11277 | 269 static void filter(struct vf_priv_s *p, uint8_t *dst, uint8_t *src, int dst_stride, int src_stride, int width, int height, uint8_t *qp_store, int qp_stride, int is_luma){ |
270 int x, y, i; | |
271 const int count= 1<<p->log2_count; | |
11307 | 272 const int stride= is_luma ? p->temp_stride : ((width+16+15)&(~15)); |
11277 | 273 uint64_t block_align[32]; |
274 DCTELEM *block = (DCTELEM *)block_align; | |
275 DCTELEM *block2= (DCTELEM *)(block_align+16); | |
11301 | 276 |
11277 | 277 for(y=0; y<height; y++){ |
11299 | 278 int index= 8 + 8*stride + y*stride; |
279 memcpy(p->src + index, src + y*src_stride, width); | |
11277 | 280 for(x=0; x<8; x++){ |
281 p->src[index - x - 1]= p->src[index + x ]; | |
282 p->src[index + width + x ]= p->src[index + width - x - 1]; | |
283 } | |
284 } | |
285 for(y=0; y<8; y++){ | |
286 memcpy(p->src + ( 7-y)*stride, p->src + ( y+8)*stride, stride); | |
11281 | 287 memcpy(p->src + (height+8+y)*stride, p->src + (height-y+7)*stride, stride); |
11277 | 288 } |
289 //FIXME (try edge emu) | |
290 | |
291 for(y=0; y<height+8; y+=8){ | |
11299 | 292 memset(p->temp + (8+y)*stride, 0, 8*stride*sizeof(int16_t)); |
11277 | 293 for(x=0; x<width+8; x+=8){ |
294 const int qps= 3 + is_luma; | |
295 int qp; | |
296 | |
297 if(p->qp) | |
298 qp= p->qp; | |
299 else{ | |
300 qp= qp_store[ (XMIN(x, width-1)>>qps) + (XMIN(y, height-1)>>qps) * qp_stride]; | |
301 if(p->mpeg2) qp>>=1; | |
302 } | |
303 for(i=0; i<count; i++){ | |
11298 | 304 const int x1= x + offset[i+count-1][0]; |
305 const int y1= y + offset[i+count-1][1]; | |
11277 | 306 const int index= x1 + y1*stride; |
307 p->dsp.get_pixels(block, p->src + index, stride); | |
308 p->dsp.fdct(block); | |
309 requantize(block2, block, qp, p->dsp.idct_permutation); | |
310 p->dsp.idct(block2); | |
311 add_block(p->temp + index, stride, block2); | |
312 } | |
313 } | |
11299 | 314 if(y) |
11305 | 315 store_slice(dst + (y-8)*dst_stride, p->temp + 8 + y*stride, dst_stride, stride, width, XMIN(8, height+8-y), 6-p->log2_count); |
11277 | 316 } |
11295 | 317 #if 0 |
318 for(y=0; y<height; y++){ | |
319 for(x=0; x<width; x++){ | |
320 if((((x>>6) ^ (y>>6)) & 1) == 0) | |
321 dst[x + y*dst_stride]= p->src[8 + 8*stride + x + y*stride]; | |
322 if((x&63) == 0 || (y&63)==0) | |
323 dst[x + y*dst_stride] += 128; | |
324 } | |
325 } | |
326 #endif | |
11277 | 327 //FIXME reorder for better caching |
328 } | |
329 | |
330 static int config(struct vf_instance_s* vf, | |
331 int width, int height, int d_width, int d_height, | |
332 unsigned int flags, unsigned int outfmt){ | |
11305 | 333 int h= (height+16+15)&(~15); |
11277 | 334 |
335 vf->priv->temp_stride= (width+16+15)&(~15); | |
11305 | 336 vf->priv->temp= malloc(vf->priv->temp_stride*h*sizeof(int16_t)); |
337 vf->priv->src = malloc(vf->priv->temp_stride*h*sizeof(uint8_t)); | |
11277 | 338 |
339 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
340 } | |
341 | |
342 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
343 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change | |
344 if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ | |
345 // ok, we can do pp in-place (or pp disabled): | |
346 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
347 mpi->type, mpi->flags, mpi->w, mpi->h); | |
348 mpi->planes[0]=vf->dmpi->planes[0]; | |
349 mpi->stride[0]=vf->dmpi->stride[0]; | |
350 mpi->width=vf->dmpi->width; | |
351 if(mpi->flags&MP_IMGFLAG_PLANAR){ | |
352 mpi->planes[1]=vf->dmpi->planes[1]; | |
353 mpi->planes[2]=vf->dmpi->planes[2]; | |
354 mpi->stride[1]=vf->dmpi->stride[1]; | |
355 mpi->stride[2]=vf->dmpi->stride[2]; | |
356 } | |
357 mpi->flags|=MP_IMGFLAG_DIRECT; | |
358 } | |
359 | |
360 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ | |
361 mp_image_t *dmpi; | |
362 | |
363 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | |
364 // no DR, so get a new image! hope we'll get DR buffer: | |
365 vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt, | |
11307 | 366 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, |
11277 | 367 mpi->w,mpi->h); |
368 } | |
369 | |
370 dmpi= vf->dmpi; | |
371 | |
372 vf->priv->mpeg2= mpi->qscale_type; | |
11307 | 373 if(vf->priv->log2_count || !(mpi->flags&MP_IMGFLAG_DIRECT)){ |
11308
0c8d12a58a29
skip filter if codec doesnt provide the QP array and user didnt force a QP (fixes diegos segfault)
michael
parents:
11307
diff
changeset
|
374 if(mpi->qscale || vf->priv->qp){ |
11307 | 375 filter(vf->priv, dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, mpi->qscale, mpi->qstride, 1); |
376 filter(vf->priv, dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, mpi->qscale, mpi->qstride, 0); | |
377 filter(vf->priv, dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, mpi->qscale, mpi->qstride, 0); | |
11308
0c8d12a58a29
skip filter if codec doesnt provide the QP array and user didnt force a QP (fixes diegos segfault)
michael
parents:
11307
diff
changeset
|
378 } |
11307 | 379 } |
11277 | 380 vf_clone_mpi_attributes(dmpi, mpi); |
381 | |
382 #ifdef HAVE_MMX | |
383 if(gCpuCaps.hasMMX) asm volatile ("emms\n\t"); | |
384 #endif | |
385 #ifdef HAVE_MMX2 | |
386 if(gCpuCaps.hasMMX2) asm volatile ("sfence\n\t"); | |
387 #endif | |
388 | |
389 return vf_next_put_image(vf,dmpi); | |
390 } | |
391 | |
392 static void uninit(struct vf_instance_s* vf){ | |
393 if(!vf->priv) return; | |
394 | |
395 if(vf->priv->temp) free(vf->priv->temp); | |
396 vf->priv->temp= NULL; | |
397 if(vf->priv->src) free(vf->priv->src); | |
398 vf->priv->src= NULL; | |
399 if(vf->priv->avctx) free(vf->priv->avctx); | |
400 vf->priv->avctx= NULL; | |
401 | |
402 free(vf->priv); | |
403 vf->priv=NULL; | |
404 } | |
405 | |
406 //===========================================================================// | |
407 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
11307 | 408 switch(fmt){ |
409 case IMGFMT_YVU9: | |
410 case IMGFMT_IF09: | |
11277 | 411 case IMGFMT_YV12: |
412 case IMGFMT_I420: | |
413 case IMGFMT_IYUV: | |
11307 | 414 case IMGFMT_CLPL: |
415 case IMGFMT_Y800: | |
416 case IMGFMT_Y8: | |
417 case IMGFMT_NV12: | |
418 case IMGFMT_444P: | |
419 case IMGFMT_422P: | |
420 case IMGFMT_411P: | |
421 return vf_next_query_format(vf,fmt); | |
422 } | |
423 return 0; | |
11277 | 424 } |
425 | |
426 static unsigned int fmt_list[]={ | |
11307 | 427 IMGFMT_YVU9, |
428 IMGFMT_IF09, | |
429 IMGFMT_YV12, | |
430 IMGFMT_I420, | |
431 IMGFMT_IYUV, | |
432 IMGFMT_CLPL, | |
433 IMGFMT_Y800, | |
434 IMGFMT_Y8, | |
435 IMGFMT_NV12, | |
436 IMGFMT_444P, | |
437 IMGFMT_422P, | |
438 IMGFMT_411P, | |
439 0 | |
11277 | 440 }; |
441 | |
11307 | 442 static int control(struct vf_instance_s* vf, int request, void* data){ |
443 switch(request){ | |
444 case VFCTRL_QUERY_MAX_PP_LEVEL: | |
445 return 6; | |
446 case VFCTRL_SET_PP_LEVEL: | |
447 vf->priv->log2_count= *((unsigned int*)data); | |
448 return CONTROL_TRUE; | |
449 } | |
450 return vf_next_control(vf,request,data); | |
451 } | |
452 | |
11277 | 453 static int open(vf_instance_t *vf, char* args){ |
454 vf->config=config; | |
455 vf->put_image=put_image; | |
456 vf->get_image=get_image; | |
457 vf->query_format=query_format; | |
458 vf->uninit=uninit; | |
11307 | 459 vf->control= control; |
11277 | 460 vf->priv=malloc(sizeof(struct vf_priv_s)); |
461 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | |
11280 | 462 |
463 avcodec_init(); | |
464 | |
11277 | 465 vf->priv->avctx= avcodec_alloc_context(); |
466 dsputil_init(&vf->priv->dsp, vf->priv->avctx); | |
11304 | 467 #ifdef HAVE_MMX |
11299 | 468 if(gCpuCaps.hasMMX){ |
469 store_slice= store_slice_mmx; | |
11301 | 470 requantize= requantize_mmx; |
11299 | 471 } |
11304 | 472 #endif |
11299 | 473 |
11307 | 474 vf->priv->log2_count= 3; |
11277 | 475 |
476 if (args) sscanf(args, "%d:%d", &vf->priv->log2_count, &vf->priv->qp); | |
477 | |
478 // check csp: | |
479 vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12); | |
480 if(!vf->priv->outfmt) | |
481 { | |
482 uninit(vf); | |
483 return 0; // no csp match :( | |
484 } | |
485 | |
486 return 1; | |
487 } | |
488 | |
489 vf_info_t vf_info_spp = { | |
490 "simple postprocess", | |
491 "spp", | |
492 "Michael Niedermayer", | |
493 "", | |
494 open, | |
495 NULL | |
496 }; | |
497 | |
498 //===========================================================================// |