annotate libmpcodecs/vf_spp.c @ 11305:d1585f7d5366

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