annotate libmpcodecs/vf_spp.c @ 29826:4eae69f3f4f4

Add support for 8 channel audio. Where 8 channel support is non-trivial (e.g. ao_dsound), at least ensure we fail gracefully.
author tack
date Tue, 10 Nov 2009 00:45:19 +0000
parents 0f1b5b68af32
children 915be5c7a30c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
1 /*
26727
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
2 * Copyright (C) 2003 Michael Niedermayer <michaelni@gmx.at>
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
3 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
4 * This file is part of MPlayer.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
5 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
7 * it under the terms of the GNU General Public License as published by
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
9 * (at your option) any later version.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
10 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
14 * GNU General Public License for more details.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
15 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
16 * You should have received a copy of the GNU General Public License along
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
19 */
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
20
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
21 /*
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
22 * This implementation is based on an algorithm described in
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
23 * "Aria Nosratinia Embedded Post-Processing for
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
24 * Enhancement of Compressed Images (1999)"
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
25 * (http://citeseer.nj.nec.com/nosratinia99embedded.html)
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
26 */
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
27
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
28
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
29 #include <stdio.h>
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
30 #include <stdlib.h>
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
31 #include <string.h>
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
32 #include <inttypes.h>
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
33 #include <math.h>
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
34
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16018
diff changeset
35 #include "config.h"
11335
michael
parents: 11334
diff changeset
36
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16018
diff changeset
37 #include "mp_msg.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16018
diff changeset
38 #include "cpudetect.h"
11568
cf76671b3d77 Fix compilation if lavc is compiled as a shared lib. Patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
alex
parents: 11477
diff changeset
39
28329
ed42e982e79f Fix compilation after DECLARE_ASM_CONST/DECLARE_ALIGNED moving within FFmpeg.
diego
parents: 28290
diff changeset
40 #include "libavutil/internal.h"
24977
1e25755bc0c4 Add missing header files, fixes the warnings:
diego
parents: 24865
diff changeset
41 #include "libavutil/intreadwrite.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16018
diff changeset
42 #include "libavcodec/avcodec.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16018
diff changeset
43 #include "libavcodec/dsputil.h"
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
44
28329
ed42e982e79f Fix compilation after DECLARE_ASM_CONST/DECLARE_ALIGNED moving within FFmpeg.
diego
parents: 28290
diff changeset
45 #undef fprintf
ed42e982e79f Fix compilation after DECLARE_ASM_CONST/DECLARE_ALIGNED moving within FFmpeg.
diego
parents: 28290
diff changeset
46 #undef free
ed42e982e79f Fix compilation after DECLARE_ASM_CONST/DECLARE_ALIGNED moving within FFmpeg.
diego
parents: 28290
diff changeset
47 #undef malloc
ed42e982e79f Fix compilation after DECLARE_ASM_CONST/DECLARE_ALIGNED moving within FFmpeg.
diego
parents: 28290
diff changeset
48
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
49 #include "img_format.h"
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
50 #include "mp_image.h"
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
51 #include "vf.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16018
diff changeset
52 #include "libvo/fastmemcpy.h"
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
53
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
54 #define XMIN(a,b) ((a) < (b) ? (a) : (b))
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
55
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
56 //===========================================================================//
11477
9785bff83777 memcpy pix instead of black screen if no DR and codec provides no qscale table
michael
parents: 11335
diff changeset
57 static const uint8_t __attribute__((aligned(8))) dither[8][8]={
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
58 { 0, 48, 12, 60, 3, 51, 15, 63, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
59 { 32, 16, 44, 28, 35, 19, 47, 31, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
60 { 8, 56, 4, 52, 11, 59, 7, 55, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
61 { 40, 24, 36, 20, 43, 27, 39, 23, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
62 { 2, 50, 14, 62, 1, 49, 13, 61, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
63 { 34, 18, 46, 30, 33, 17, 45, 29, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
64 { 10, 58, 6, 54, 9, 57, 5, 53, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
65 { 42, 26, 38, 22, 41, 25, 37, 21, },
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
66 };
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
67
11477
9785bff83777 memcpy pix instead of black screen if no DR and codec provides no qscale table
michael
parents: 11335
diff changeset
68 static const uint8_t offset[127][2]= {
11298
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
69 {0,0},
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
70 {0,0}, {4,4},
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
71 {0,0}, {2,2}, {6,4}, {4,6},
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
72 {0,0}, {5,1}, {2,2}, {7,3}, {4,4}, {1,5}, {6,6}, {3,7},
11298
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
73
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
74 {0,0}, {4,0}, {1,1}, {5,1}, {3,2}, {7,2}, {2,3}, {6,3},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
75 {0,4}, {4,4}, {1,5}, {5,5}, {3,6}, {7,6}, {2,7}, {6,7},
11298
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
76
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
77 {0,0}, {0,2}, {0,4}, {0,6}, {1,1}, {1,3}, {1,5}, {1,7},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
78 {2,0}, {2,2}, {2,4}, {2,6}, {3,1}, {3,3}, {3,5}, {3,7},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
79 {4,0}, {4,2}, {4,4}, {4,6}, {5,1}, {5,3}, {5,5}, {5,7},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
80 {6,0}, {6,2}, {6,4}, {6,6}, {7,1}, {7,3}, {7,5}, {7,7},
11298
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
81
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
82 {0,0}, {4,4}, {0,4}, {4,0}, {2,2}, {6,6}, {2,6}, {6,2},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
83 {0,2}, {4,6}, {0,6}, {4,2}, {2,0}, {6,4}, {2,4}, {6,0},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
84 {1,1}, {5,5}, {1,5}, {5,1}, {3,3}, {7,7}, {3,7}, {7,3},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
85 {1,3}, {5,7}, {1,7}, {5,3}, {3,1}, {7,5}, {3,5}, {7,1},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
86 {0,1}, {4,5}, {0,5}, {4,1}, {2,3}, {6,7}, {2,7}, {6,3},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
87 {0,3}, {4,7}, {0,7}, {4,3}, {2,1}, {6,5}, {2,5}, {6,1},
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
88 {1,0}, {5,4}, {1,4}, {5,0}, {3,2}, {7,6}, {3,6}, {7,2},
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
89 {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
90 };
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
91
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
92 struct vf_priv_s {
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
93 int log2_count;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
94 int qp;
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
95 int mode;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
96 int mpeg2;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
97 int temp_stride;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
98 uint8_t *src;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
99 int16_t *temp;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
100 AVCodecContext *avctx;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
101 DSPContext dsp;
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
102 char *non_b_qp;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
103 };
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
104
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
105 #define SHIFT 22
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
106
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
107 static void hardthresh_c(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
108 int i;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
109 int bias= 0; //FIXME
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
110 unsigned int threshold1, threshold2;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
111
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
112 threshold1= qp*((1<<4) - bias) - 1;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
113 threshold2= (threshold1<<1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
114
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
115 memset(dst, 0, 64*sizeof(DCTELEM));
11296
86916e46d445 different / faster / simpler "quantization"
michael
parents: 11295
diff changeset
116 dst[0]= (src[0] + 4)>>3;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
117
11296
86916e46d445 different / faster / simpler "quantization"
michael
parents: 11295
diff changeset
118 for(i=1; i<64; i++){
86916e46d445 different / faster / simpler "quantization"
michael
parents: 11295
diff changeset
119 int level= src[i];
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
120 if(((unsigned)(level+threshold1))>threshold2){
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
121 const int j= permutation[i];
11296
86916e46d445 different / faster / simpler "quantization"
michael
parents: 11295
diff changeset
122 dst[j]= (level + 4)>>3;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
123 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
124 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
125 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
126
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
127 static void softthresh_c(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
128 int i;
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
129 int bias= 0; //FIXME
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
130 unsigned int threshold1, threshold2;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
131
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
132 threshold1= qp*((1<<4) - bias) - 1;
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
133 threshold2= (threshold1<<1);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
134
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
135 memset(dst, 0, 64*sizeof(DCTELEM));
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
136 dst[0]= (src[0] + 4)>>3;
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
137
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
138 for(i=1; i<64; i++){
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
139 int level= src[i];
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
140 if(((unsigned)(level+threshold1))>threshold2){
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
141 const int j= permutation[i];
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
142 if(level>0)
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
143 dst[j]= (level - threshold1 + 4)>>3;
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
144 else
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
145 dst[j]= (level + threshold1 + 4)>>3;
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
146 }
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
147 }
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
148 }
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
149
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
150 #if HAVE_MMX
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
151 static void hardthresh_mmx(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
152 int bias= 0; //FIXME
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
153 unsigned int threshold1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
154
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
155 threshold1= qp*((1<<4) - bias) - 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
156
27754
08d18fe9da52 Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents: 26727
diff changeset
157 __asm__ volatile(
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
158 #define REQUANT_CORE(dst0, dst1, dst2, dst3, src0, src1, src2, src3) \
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
159 "movq " #src0 ", %%mm0 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
160 "movq " #src1 ", %%mm1 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
161 "movq " #src2 ", %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
162 "movq " #src3 ", %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
163 "psubw %%mm4, %%mm0 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
164 "psubw %%mm4, %%mm1 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
165 "psubw %%mm4, %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
166 "psubw %%mm4, %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
167 "paddusw %%mm5, %%mm0 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
168 "paddusw %%mm5, %%mm1 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
169 "paddusw %%mm5, %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
170 "paddusw %%mm5, %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
171 "paddw %%mm6, %%mm0 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
172 "paddw %%mm6, %%mm1 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
173 "paddw %%mm6, %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
174 "paddw %%mm6, %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
175 "psubusw %%mm6, %%mm0 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
176 "psubusw %%mm6, %%mm1 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
177 "psubusw %%mm6, %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
178 "psubusw %%mm6, %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
179 "psraw $3, %%mm0 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
180 "psraw $3, %%mm1 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
181 "psraw $3, %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
182 "psraw $3, %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
183 \
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
184 "movq %%mm0, %%mm7 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
185 "punpcklwd %%mm2, %%mm0 \n\t" /*A*/\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
186 "punpckhwd %%mm2, %%mm7 \n\t" /*C*/\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
187 "movq %%mm1, %%mm2 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
188 "punpcklwd %%mm3, %%mm1 \n\t" /*B*/\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
189 "punpckhwd %%mm3, %%mm2 \n\t" /*D*/\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
190 "movq %%mm0, %%mm3 \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
191 "punpcklwd %%mm1, %%mm0 \n\t" /*A*/\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
192 "punpckhwd %%mm7, %%mm3 \n\t" /*C*/\
13393
74fa728e6fc2 100l typo
michael
parents: 13149
diff changeset
193 "punpcklwd %%mm2, %%mm7 \n\t" /*B*/\
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
194 "punpckhwd %%mm2, %%mm1 \n\t" /*D*/\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
195 \
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
196 "movq %%mm0, " #dst0 " \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
197 "movq %%mm7, " #dst1 " \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
198 "movq %%mm3, " #dst2 " \n\t"\
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
199 "movq %%mm1, " #dst3 " \n\t"
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
200
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
201 "movd %2, %%mm4 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
202 "movd %3, %%mm5 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
203 "movd %4, %%mm6 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
204 "packssdw %%mm4, %%mm4 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
205 "packssdw %%mm5, %%mm5 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
206 "packssdw %%mm6, %%mm6 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
207 "packssdw %%mm4, %%mm4 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
208 "packssdw %%mm5, %%mm5 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
209 "packssdw %%mm6, %%mm6 \n\t"
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
210 REQUANT_CORE( (%1), 8(%1), 16(%1), 24(%1), (%0), 8(%0), 64(%0), 72(%0))
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
211 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
212 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
213 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
214 : : "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
215 );
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
216 dst[0]= (src[0] + 4)>>3;
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
217 }
11994
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
218
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
219 static void softthresh_mmx(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation){
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
220 int bias= 0; //FIXME
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
221 unsigned int threshold1;
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
222
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
223 threshold1= qp*((1<<4) - bias) - 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
224
27754
08d18fe9da52 Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents: 26727
diff changeset
225 __asm__ volatile(
11994
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
226 #undef REQUANT_CORE
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
227 #define REQUANT_CORE(dst0, dst1, dst2, dst3, src0, src1, src2, src3) \
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
228 "movq " #src0 ", %%mm0 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
229 "movq " #src1 ", %%mm1 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
230 "pxor %%mm6, %%mm6 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
231 "pxor %%mm7, %%mm7 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
232 "pcmpgtw %%mm0, %%mm6 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
233 "pcmpgtw %%mm1, %%mm7 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
234 "pxor %%mm6, %%mm0 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
235 "pxor %%mm7, %%mm1 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
236 "psubusw %%mm4, %%mm0 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
237 "psubusw %%mm4, %%mm1 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
238 "pxor %%mm6, %%mm0 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
239 "pxor %%mm7, %%mm1 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
240 "movq " #src2 ", %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
241 "movq " #src3 ", %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
242 "pxor %%mm6, %%mm6 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
243 "pxor %%mm7, %%mm7 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
244 "pcmpgtw %%mm2, %%mm6 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
245 "pcmpgtw %%mm3, %%mm7 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
246 "pxor %%mm6, %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
247 "pxor %%mm7, %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
248 "psubusw %%mm4, %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
249 "psubusw %%mm4, %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
250 "pxor %%mm6, %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
251 "pxor %%mm7, %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
252 \
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
253 "paddsw %%mm5, %%mm0 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
254 "paddsw %%mm5, %%mm1 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
255 "paddsw %%mm5, %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
256 "paddsw %%mm5, %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
257 "psraw $3, %%mm0 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
258 "psraw $3, %%mm1 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
259 "psraw $3, %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
260 "psraw $3, %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
261 \
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
262 "movq %%mm0, %%mm7 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
263 "punpcklwd %%mm2, %%mm0 \n\t" /*A*/\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
264 "punpckhwd %%mm2, %%mm7 \n\t" /*C*/\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
265 "movq %%mm1, %%mm2 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
266 "punpcklwd %%mm3, %%mm1 \n\t" /*B*/\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
267 "punpckhwd %%mm3, %%mm2 \n\t" /*D*/\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
268 "movq %%mm0, %%mm3 \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
269 "punpcklwd %%mm1, %%mm0 \n\t" /*A*/\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
270 "punpckhwd %%mm7, %%mm3 \n\t" /*C*/\
13393
74fa728e6fc2 100l typo
michael
parents: 13149
diff changeset
271 "punpcklwd %%mm2, %%mm7 \n\t" /*B*/\
11994
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
272 "punpckhwd %%mm2, %%mm1 \n\t" /*D*/\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
273 \
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
274 "movq %%mm0, " #dst0 " \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
275 "movq %%mm7, " #dst1 " \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
276 "movq %%mm3, " #dst2 " \n\t"\
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
277 "movq %%mm1, " #dst3 " \n\t"
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
278
11994
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
279 "movd %2, %%mm4 \n\t"
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
280 "movd %3, %%mm5 \n\t"
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
281 "packssdw %%mm4, %%mm4 \n\t"
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
282 "packssdw %%mm5, %%mm5 \n\t"
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
283 "packssdw %%mm4, %%mm4 \n\t"
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
284 "packssdw %%mm5, %%mm5 \n\t"
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
285 REQUANT_CORE( (%1), 8(%1), 16(%1), 24(%1), (%0), 8(%0), 64(%0), 72(%0))
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
286 REQUANT_CORE(32(%1), 40(%1), 48(%1), 56(%1),16(%0),24(%0), 48(%0), 56(%0))
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
287 REQUANT_CORE(64(%1), 72(%1), 80(%1), 88(%1),32(%0),40(%0), 96(%0),104(%0))
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
288 REQUANT_CORE(96(%1),104(%1),112(%1),120(%1),80(%0),88(%0),112(%0),120(%0))
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
289 : : "r" (src), "r" (dst), "g" (threshold1), "rm" (4) //FIXME maybe more accurate then needed?
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
290 );
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
291
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
292 dst[0]= (src[0] + 4)>>3;
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
293 }
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
294 #endif
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
295
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
296 static inline void add_block(int16_t *dst, int stride, DCTELEM block[64]){
11280
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
297 int y;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
298
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
299 for(y=0; y<8; y++){
11280
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
300 *(uint32_t*)&dst[0 + y*stride]+= *(uint32_t*)&block[0 + y*8];
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
301 *(uint32_t*)&dst[2 + y*stride]+= *(uint32_t*)&block[2 + y*8];
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
302 *(uint32_t*)&dst[4 + y*stride]+= *(uint32_t*)&block[4 + y*8];
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
303 *(uint32_t*)&dst[6 + y*stride]+= *(uint32_t*)&block[6 + y*8];
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
304 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
305 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
306
11305
michael
parents: 11304
diff changeset
307 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
308 int y, x;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
309
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
310 #define STORE(pos) \
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
311 temp= ((src[x + y*src_stride + pos]<<log2_scale) + d[pos])>>6;\
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
312 if(temp & 0x100) temp= ~(temp>>31);\
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
313 dst[x + y*dst_stride + pos]= temp;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
314
11305
michael
parents: 11304
diff changeset
315 for(y=0; y<height; y++){
12157
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
316 const uint8_t *d= dither[y];
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
317 for(x=0; x<width; x+=8){
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
318 int temp;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
319 STORE(0);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
320 STORE(1);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
321 STORE(2);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
322 STORE(3);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
323 STORE(4);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
324 STORE(5);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
325 STORE(6);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
326 STORE(7);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
327 }
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
328 }
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
329 }
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
330
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
331 #if HAVE_MMX
11305
michael
parents: 11304
diff changeset
332 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
333 int y;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
334
11305
michael
parents: 11304
diff changeset
335 for(y=0; y<height; y++){
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
336 uint8_t *dst1= dst;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
337 int16_t *src1= src;
27754
08d18fe9da52 Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents: 26727
diff changeset
338 __asm__ volatile(
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
339 "movq (%3), %%mm3 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
340 "movq (%3), %%mm4 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
341 "movd %4, %%mm2 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
342 "pxor %%mm0, %%mm0 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
343 "punpcklbw %%mm0, %%mm3 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
344 "punpckhbw %%mm0, %%mm4 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
345 "psraw %%mm2, %%mm3 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
346 "psraw %%mm2, %%mm4 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
347 "movd %5, %%mm2 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
348 "1: \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
349 "movq (%0), %%mm0 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
350 "movq 8(%0), %%mm1 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
351 "paddw %%mm3, %%mm0 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
352 "paddw %%mm4, %%mm1 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
353 "psraw %%mm2, %%mm0 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
354 "psraw %%mm2, %%mm1 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
355 "packuswb %%mm1, %%mm0 \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
356 "movq %%mm0, (%1) \n\t"
13720
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 13393
diff changeset
357 "add $16, %0 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 13393
diff changeset
358 "add $8, %1 \n\t"
821f464b4d90 adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents: 13393
diff changeset
359 "cmp %2, %1 \n\t"
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
360 " jb 1b \n\t"
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
361 : "+r" (src1), "+r"(dst1)
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
362 : "r"(dst + width), "r"(dither[y]), "g"(log2_scale), "g"(6-log2_scale)
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
363 );
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
364 src += src_stride;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
365 dst += dst_stride;
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
366 }
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
367 // if(width != mmxw)
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
368 // store_slice_c(dst + mmxw, src + mmxw, dst_stride, src_stride, width - mmxw, log2_scale);
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
369 }
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
370 #endif
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
371
11305
michael
parents: 11304
diff changeset
372 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
373
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
374 static void (*requantize)(DCTELEM dst[64], DCTELEM src[64], int qp, uint8_t *permutation)= hardthresh_c;
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
375
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
376 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
377 int x, y, i;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
378 const int count= 1<<p->log2_count;
11307
michael
parents: 11305
diff changeset
379 const int stride= is_luma ? p->temp_stride : ((width+16+15)&(~15));
17082
c6da587be0b2 attribute align
michael
parents: 17012
diff changeset
380 uint64_t __attribute__((aligned(16))) block_align[32];
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
381 DCTELEM *block = (DCTELEM *)block_align;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
382 DCTELEM *block2= (DCTELEM *)(block_align+16);
11301
a8dfeb7180ff optimize
michael
parents: 11299
diff changeset
383
13729
045dbaccaccc crash with Y8 colourspace fixed
reimar
parents: 13720
diff changeset
384 if (!src || !dst) return; // HACK avoid crash for Y8 colourspace
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
385 for(y=0; y<height; y++){
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
386 int index= 8 + 8*stride + y*stride;
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 20585
diff changeset
387 fast_memcpy(p->src + index, src + y*src_stride, width);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
388 for(x=0; x<8; x++){
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
389 p->src[index - x - 1]= p->src[index + x ];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
390 p->src[index + width + x ]= p->src[index + width - x - 1];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
391 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
392 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
393 for(y=0; y<8; y++){
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 20585
diff changeset
394 fast_memcpy(p->src + ( 7-y)*stride, p->src + ( y+8)*stride, stride);
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 20585
diff changeset
395 fast_memcpy(p->src + (height+8+y)*stride, p->src + (height-y+7)*stride, stride);
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
396 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
397 //FIXME (try edge emu)
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
398
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
399 for(y=0; y<height+8; y+=8){
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
400 memset(p->temp + (8+y)*stride, 0, 8*stride*sizeof(int16_t));
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
401 for(x=0; x<width+8; x+=8){
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
402 const int qps= 3 + is_luma;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
403 int qp;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
404
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
405 if(p->qp)
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
406 qp= p->qp;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
407 else{
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
408 qp= qp_store[ (XMIN(x, width-1)>>qps) + (XMIN(y, height-1)>>qps) * qp_stride];
24552
c9c2e550a449 MPEG-2 blocks at qp 1 get overfiltered by spp, apparently because "qp>>1" turns
diego
parents: 23457
diff changeset
409 if(p->mpeg2) qp = FFMAX(1, qp>>1);
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
410 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
411 for(i=0; i<count; i++){
11298
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
412 const int x1= x + offset[i+count-1][0];
14dbc88adaf0 change offsets (quality 2-4 looks better now)
michael
parents: 11296
diff changeset
413 const int y1= y + offset[i+count-1][1];
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
414 const int index= x1 + y1*stride;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
415 p->dsp.get_pixels(block, p->src + index, stride);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
416 p->dsp.fdct(block);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
417 requantize(block2, block, qp, p->dsp.idct_permutation);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
418 p->dsp.idct(block2);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
419 add_block(p->temp + index, stride, block2);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
420 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
421 }
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
422 if(y)
11305
michael
parents: 11304
diff changeset
423 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
424 }
11295
michael
parents: 11281
diff changeset
425 #if 0
michael
parents: 11281
diff changeset
426 for(y=0; y<height; y++){
michael
parents: 11281
diff changeset
427 for(x=0; x<width; x++){
michael
parents: 11281
diff changeset
428 if((((x>>6) ^ (y>>6)) & 1) == 0)
michael
parents: 11281
diff changeset
429 dst[x + y*dst_stride]= p->src[8 + 8*stride + x + y*stride];
michael
parents: 11281
diff changeset
430 if((x&63) == 0 || (y&63)==0)
michael
parents: 11281
diff changeset
431 dst[x + y*dst_stride] += 128;
michael
parents: 11281
diff changeset
432 }
michael
parents: 11281
diff changeset
433 }
michael
parents: 11281
diff changeset
434 #endif
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
435 //FIXME reorder for better caching
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
436 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
437
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
438 static int config(struct vf_instance_s* vf,
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
439 int width, int height, int d_width, int d_height,
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
440 unsigned int flags, unsigned int outfmt){
11305
michael
parents: 11304
diff changeset
441 int h= (height+16+15)&(~15);
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
442
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
443 vf->priv->temp_stride= (width+16+15)&(~15);
11305
michael
parents: 11304
diff changeset
444 vf->priv->temp= malloc(vf->priv->temp_stride*h*sizeof(int16_t));
michael
parents: 11304
diff changeset
445 vf->priv->src = malloc(vf->priv->temp_stride*h*sizeof(uint8_t));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
446
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
447 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
448 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
449
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
450 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
451 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
452 // ok, we can do pp in-place (or pp disabled):
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
453 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
16018
bdf1b4ecb906 use stored dimensions instead of visible one when (vf_)get_image is called
iive
parents: 15965
diff changeset
454 mpi->type, mpi->flags | MP_IMGFLAG_READABLE, mpi->width, mpi->height);
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
455 mpi->planes[0]=vf->dmpi->planes[0];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
456 mpi->stride[0]=vf->dmpi->stride[0];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
457 mpi->width=vf->dmpi->width;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
458 if(mpi->flags&MP_IMGFLAG_PLANAR){
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
459 mpi->planes[1]=vf->dmpi->planes[1];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
460 mpi->planes[2]=vf->dmpi->planes[2];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
461 mpi->stride[1]=vf->dmpi->stride[1];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
462 mpi->stride[2]=vf->dmpi->stride[2];
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
463 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
464 mpi->flags|=MP_IMGFLAG_DIRECT;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
465 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
466
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17523
diff changeset
467 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
468 mp_image_t *dmpi;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
469
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
470 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
471 // no DR, so get a new image! hope we'll get DR buffer:
14022
803be9a78854 removing strange csp matching code (was copy&pasted from vf_pp where it originated from arpi 2.5 years ago) -> fixes spp+scale+x11 crash
michael
parents: 13729
diff changeset
472 dmpi=vf_get_image(vf->next,mpi->imgfmt,
12631
6cbccc0c7d7b Fix memory corruption, noticable at reallocate image
iive
parents: 12163
diff changeset
473 MP_IMGTYPE_TEMP,
6cbccc0c7d7b Fix memory corruption, noticable at reallocate image
iive
parents: 12163
diff changeset
474 MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
16018
bdf1b4ecb906 use stored dimensions instead of visible one when (vf_)get_image is called
iive
parents: 15965
diff changeset
475 mpi->width,mpi->height);
12631
6cbccc0c7d7b Fix memory corruption, noticable at reallocate image
iive
parents: 12163
diff changeset
476 vf_clone_mpi_attributes(dmpi, mpi);
6cbccc0c7d7b Fix memory corruption, noticable at reallocate image
iive
parents: 12163
diff changeset
477 }else{
13149
michael
parents: 12631
diff changeset
478 dmpi=vf->dmpi;
12631
6cbccc0c7d7b Fix memory corruption, noticable at reallocate image
iive
parents: 12163
diff changeset
479 }
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
480
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
481 vf->priv->mpeg2= mpi->qscale_type;
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
482 if(mpi->pict_type != 3 && mpi->qscale && !vf->priv->qp){
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
483 if(!vf->priv->non_b_qp)
20585
68b55a823fd4 qp height should be in macroblocks, not pixels
henry
parents: 18131
diff changeset
484 vf->priv->non_b_qp= malloc(mpi->qstride * ((mpi->h + 15) >> 4));
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 20585
diff changeset
485 fast_memcpy(vf->priv->non_b_qp, mpi->qscale, mpi->qstride * ((mpi->h + 15) >> 4));
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
486 }
11307
michael
parents: 11305
diff changeset
487 if(vf->priv->log2_count || !(mpi->flags&MP_IMGFLAG_DIRECT)){
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
488 char *qp_tab= vf->priv->non_b_qp;
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
489 if((vf->priv->mode&4) || !qp_tab)
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
490 qp_tab= mpi->qscale;
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
491
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
492 if(qp_tab || vf->priv->qp){
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
493 filter(vf->priv, dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, qp_tab, mpi->qstride, 1);
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
494 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, qp_tab, mpi->qstride, 0);
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
495 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, qp_tab, mpi->qstride, 0);
11477
9785bff83777 memcpy pix instead of black screen if no DR and codec provides no qscale table
michael
parents: 11335
diff changeset
496 }else{
9785bff83777 memcpy pix instead of black screen if no DR and codec provides no qscale table
michael
parents: 11335
diff changeset
497 memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]);
9785bff83777 memcpy pix instead of black screen if no DR and codec provides no qscale table
michael
parents: 11335
diff changeset
498 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]);
9785bff83777 memcpy pix instead of black screen if no DR and codec provides no qscale table
michael
parents: 11335
diff changeset
499 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]);
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
500 }
11307
michael
parents: 11305
diff changeset
501 }
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
502
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
503 #if HAVE_MMX
27754
08d18fe9da52 Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents: 26727
diff changeset
504 if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t");
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
505 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
506 #if HAVE_MMX2
27754
08d18fe9da52 Change all occurrences of asm and __asm to __asm__, same as was done for FFmpeg.
diego
parents: 26727
diff changeset
507 if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t");
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
508 #endif
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
509
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17523
diff changeset
510 return vf_next_put_image(vf,dmpi, pts);
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
511 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
512
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
513 static void uninit(struct vf_instance_s* vf){
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
514 if(!vf->priv) return;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
515
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
516 if(vf->priv->temp) free(vf->priv->temp);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
517 vf->priv->temp= NULL;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
518 if(vf->priv->src) free(vf->priv->src);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
519 vf->priv->src= NULL;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
520 if(vf->priv->avctx) free(vf->priv->avctx);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
521 vf->priv->avctx= NULL;
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
522 if(vf->priv->non_b_qp) free(vf->priv->non_b_qp);
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
523 vf->priv->non_b_qp= NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
524
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
525 free(vf->priv);
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
526 vf->priv=NULL;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
527 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
528
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
529 //===========================================================================//
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
530 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
11307
michael
parents: 11305
diff changeset
531 switch(fmt){
michael
parents: 11305
diff changeset
532 case IMGFMT_YVU9:
michael
parents: 11305
diff changeset
533 case IMGFMT_IF09:
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
534 case IMGFMT_YV12:
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
535 case IMGFMT_I420:
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
536 case IMGFMT_IYUV:
11307
michael
parents: 11305
diff changeset
537 case IMGFMT_CLPL:
michael
parents: 11305
diff changeset
538 case IMGFMT_Y800:
michael
parents: 11305
diff changeset
539 case IMGFMT_Y8:
michael
parents: 11305
diff changeset
540 case IMGFMT_444P:
michael
parents: 11305
diff changeset
541 case IMGFMT_422P:
michael
parents: 11305
diff changeset
542 case IMGFMT_411P:
michael
parents: 11305
diff changeset
543 return vf_next_query_format(vf,fmt);
michael
parents: 11305
diff changeset
544 }
michael
parents: 11305
diff changeset
545 return 0;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
546 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
547
11307
michael
parents: 11305
diff changeset
548 static int control(struct vf_instance_s* vf, int request, void* data){
michael
parents: 11305
diff changeset
549 switch(request){
michael
parents: 11305
diff changeset
550 case VFCTRL_QUERY_MAX_PP_LEVEL:
michael
parents: 11305
diff changeset
551 return 6;
michael
parents: 11305
diff changeset
552 case VFCTRL_SET_PP_LEVEL:
michael
parents: 11305
diff changeset
553 vf->priv->log2_count= *((unsigned int*)data);
michael
parents: 11305
diff changeset
554 return CONTROL_TRUE;
michael
parents: 11305
diff changeset
555 }
michael
parents: 11305
diff changeset
556 return vf_next_control(vf,request,data);
michael
parents: 11305
diff changeset
557 }
michael
parents: 11305
diff changeset
558
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
559 static int open(vf_instance_t *vf, char* args){
12157
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
560
14022
803be9a78854 removing strange csp matching code (was copy&pasted from vf_pp where it originated from arpi 2.5 years ago) -> fixes spp+scale+x11 crash
michael
parents: 13729
diff changeset
561 int log2c=-1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
562
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
563 vf->config=config;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
564 vf->put_image=put_image;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
565 vf->get_image=get_image;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
566 vf->query_format=query_format;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
567 vf->uninit=uninit;
11307
michael
parents: 11305
diff changeset
568 vf->control= control;
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
569 vf->priv=malloc(sizeof(struct vf_priv_s));
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
570 memset(vf->priv, 0, sizeof(struct vf_priv_s));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
571
11280
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
572 avcodec_init();
b677102fa650 10l and minor optimization
michael
parents: 11277
diff changeset
573
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
574 vf->priv->avctx= avcodec_alloc_context();
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
575 dsputil_init(&vf->priv->dsp, vf->priv->avctx);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
576
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
577 vf->priv->log2_count= 3;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
578
12157
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
579 if (args) sscanf(args, "%d:%d:%d", &log2c, &vf->priv->qp, &vf->priv->mode);
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
580
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
581 if( log2c >=0 && log2c <=6 )
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
582 vf->priv->log2_count = log2c;
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
583
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
584 if(vf->priv->qp < 0)
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
585 vf->priv->qp = 0;
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
586
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
587 switch(vf->priv->mode&3){
12157
e26d5e388618 check for invalid user input
iive
parents: 11994
diff changeset
588 default:
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
589 case 0: requantize= hardthresh_c; break;
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
590 case 1: requantize= softthresh_c; break;
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
591 }
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
592
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27754
diff changeset
593 #if HAVE_MMX
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
594 if(gCpuCaps.hasMMX){
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
595 store_slice= store_slice_mmx;
17110
ba9bf9beb23f prevent flicker, to get old behaviour use spp=x:y:4 / x:y:5
michael
parents: 17082
diff changeset
596 switch(vf->priv->mode&3){
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
597 case 0: requantize= hardthresh_mmx; break;
11994
a7751694c177 spp softthresholding in mmx
michael
parents: 11993
diff changeset
598 case 1: requantize= softthresh_mmx; break;
11993
4e2d99dbef78 spp soft thresholding patch by (James Crowson <jbcrowso at ncsu dot edu>)
michael
parents: 11568
diff changeset
599 }
11299
66bdf2002aab optimizing
michael
parents: 11298
diff changeset
600 }
11304
f89e212dd5b9 another 10l ...
michael
parents: 11301
diff changeset
601 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
602
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
603 return 1;
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
604 }
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
605
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 24977
diff changeset
606 const vf_info_t vf_info_spp = {
11277
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
607 "simple postprocess",
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
608 "spp",
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
609 "Michael Niedermayer",
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
610 "",
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
611 open,
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
612 NULL
fffd200d81a7 simple alternative postprocessing filter
michael
parents:
diff changeset
613 };