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