Mercurial > mplayer.hg
annotate libswscale/utils.c @ 32315:549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
sws_init_context() instead.
author | stefano |
---|---|
date | Tue, 28 Sep 2010 22:23:58 +0000 |
parents | ecb8e52d4add |
children | 6f41498718cd |
rev | line source |
---|---|
18861 | 1 /* |
20094
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
2 * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at> |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
3 * |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
4 * This file is part of FFmpeg. |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
5 * |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
20094
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
10 * |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
14 * Lesser General Public License for more details. |
20094
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
15 * |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
23702 | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20094
aca9e9783f67
Change license headers to say 'FFmpeg' instead of 'this program'.
diego
parents:
19987
diff
changeset
|
19 */ |
18861 | 20 |
27511 | 21 #define _SVID_SOURCE //needed for MAP_ANONYMOUS |
31694
e251996735b5
darwin: allow 64-bit darwin to allocate executable memory
ramiro
parents:
31234
diff
changeset
|
22 #define _DARWIN_C_SOURCE // needed for MAP_ANON |
18861 | 23 #include <inttypes.h> |
24 #include <string.h> | |
25 #include <math.h> | |
26 #include <stdio.h> | |
27 #include "config.h" | |
28 #include <assert.h> | |
28276 | 29 #if HAVE_SYS_MMAN_H |
18861 | 30 #include <sys/mman.h> |
31 #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) | |
32 #define MAP_ANONYMOUS MAP_ANON | |
33 #endif | |
34 #endif | |
28971
b8e356a9dbb1
Allocate executable memory with VirtualAlloc() in Windows.
ramiro
parents:
28970
diff
changeset
|
35 #if HAVE_VIRTUALALLOC |
b8e356a9dbb1
Allocate executable memory with VirtualAlloc() in Windows.
ramiro
parents:
28970
diff
changeset
|
36 #define WIN32_LEAN_AND_MEAN |
b8e356a9dbb1
Allocate executable memory with VirtualAlloc() in Windows.
ramiro
parents:
28970
diff
changeset
|
37 #include <windows.h> |
b8e356a9dbb1
Allocate executable memory with VirtualAlloc() in Windows.
ramiro
parents:
28970
diff
changeset
|
38 #endif |
18861 | 39 #include "swscale.h" |
40 #include "swscale_internal.h" | |
41 #include "rgb2rgb.h" | |
29475 | 42 #include "libavutil/intreadwrite.h" |
26670
e6774798e913
Use full path for #includes from another directory.
diego
parents:
26238
diff
changeset
|
43 #include "libavutil/x86_cpu.h" |
29542 | 44 #include "libavutil/avutil.h" |
26670
e6774798e913
Use full path for #includes from another directory.
diego
parents:
26238
diff
changeset
|
45 #include "libavutil/bswap.h" |
29926
916134a82d74
Make sws_format_name() use av_pix_fmt_descriptors.
stefano
parents:
29890
diff
changeset
|
46 #include "libavutil/pixdesc.h" |
18861 | 47 |
27460 | 48 unsigned swscale_version(void) |
49 { | |
50 return LIBSWSCALE_VERSION_INT; | |
51 } | |
52 | |
30138 | 53 const char *swscale_configuration(void) |
29890
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
54 { |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
55 return FFMPEG_CONFIGURATION; |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
56 } |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
57 |
30138 | 58 const char *swscale_license(void) |
29890
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
59 { |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
60 #define LICENSE_PREFIX "libswscale license: " |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
61 return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1; |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
62 } |
e8e1f8cc7c5b
Add functions to return library license and library configuration.
diego
parents:
29843
diff
changeset
|
63 |
28316 | 64 #define RET 0xC3 //near return opcode for x86 |
18861 | 65 |
23278 | 66 #define isSupportedIn(x) ( \ |
67 (x)==PIX_FMT_YUV420P \ | |
24581
a7fe1ee84511
add support for yuva420p colorspace (yuv420p + alpha)
aurel
parents:
24289
diff
changeset
|
68 || (x)==PIX_FMT_YUVA420P \ |
23278 | 69 || (x)==PIX_FMT_YUYV422 \ |
70 || (x)==PIX_FMT_UYVY422 \ | |
29299
24954ec81529
Partial (low bits ignored, no direct transcoding into other RGB formats) support
kostya
parents:
29278
diff
changeset
|
71 || (x)==PIX_FMT_RGB48BE \ |
24954ec81529
Partial (low bits ignored, no direct transcoding into other RGB formats) support
kostya
parents:
29278
diff
changeset
|
72 || (x)==PIX_FMT_RGB48LE \ |
23278 | 73 || (x)==PIX_FMT_RGB32 \ |
27490 | 74 || (x)==PIX_FMT_RGB32_1 \ |
23278 | 75 || (x)==PIX_FMT_BGR24 \ |
76 || (x)==PIX_FMT_BGR565 \ | |
77 || (x)==PIX_FMT_BGR555 \ | |
78 || (x)==PIX_FMT_BGR32 \ | |
27490 | 79 || (x)==PIX_FMT_BGR32_1 \ |
23278 | 80 || (x)==PIX_FMT_RGB24 \ |
81 || (x)==PIX_FMT_RGB565 \ | |
82 || (x)==PIX_FMT_RGB555 \ | |
83 || (x)==PIX_FMT_GRAY8 \ | |
32308
ecb8e52d4add
Y400A (gray alpha) input support in libswscale
bcoudurier
parents:
32307
diff
changeset
|
84 || (x)==PIX_FMT_Y400A \ |
23278 | 85 || (x)==PIX_FMT_YUV410P \ |
27557 | 86 || (x)==PIX_FMT_YUV440P \ |
29932 | 87 || (x)==PIX_FMT_NV12 \ |
88 || (x)==PIX_FMT_NV21 \ | |
23278 | 89 || (x)==PIX_FMT_GRAY16BE \ |
90 || (x)==PIX_FMT_GRAY16LE \ | |
91 || (x)==PIX_FMT_YUV444P \ | |
92 || (x)==PIX_FMT_YUV422P \ | |
93 || (x)==PIX_FMT_YUV411P \ | |
30432 | 94 || (x)==PIX_FMT_YUVJ420P \ |
95 || (x)==PIX_FMT_YUVJ422P \ | |
96 || (x)==PIX_FMT_YUVJ440P \ | |
97 || (x)==PIX_FMT_YUVJ444P \ | |
23278 | 98 || (x)==PIX_FMT_PAL8 \ |
99 || (x)==PIX_FMT_BGR8 \ | |
100 || (x)==PIX_FMT_RGB8 \ | |
101 || (x)==PIX_FMT_BGR4_BYTE \ | |
102 || (x)==PIX_FMT_RGB4_BYTE \ | |
23791 | 103 || (x)==PIX_FMT_YUV440P \ |
27555 | 104 || (x)==PIX_FMT_MONOWHITE \ |
105 || (x)==PIX_FMT_MONOBLACK \ | |
29608
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
106 || (x)==PIX_FMT_YUV420P16LE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
107 || (x)==PIX_FMT_YUV422P16LE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
108 || (x)==PIX_FMT_YUV444P16LE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
109 || (x)==PIX_FMT_YUV420P16BE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
110 || (x)==PIX_FMT_YUV422P16BE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
111 || (x)==PIX_FMT_YUV444P16BE \ |
23278 | 112 ) |
30194
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
113 |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
114 int sws_isSupportedInput(enum PixelFormat pix_fmt) |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
115 { |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
116 return isSupportedIn(pix_fmt); |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
117 } |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
118 |
23278 | 119 #define isSupportedOut(x) ( \ |
120 (x)==PIX_FMT_YUV420P \ | |
28977 | 121 || (x)==PIX_FMT_YUVA420P \ |
23278 | 122 || (x)==PIX_FMT_YUYV422 \ |
123 || (x)==PIX_FMT_UYVY422 \ | |
124 || (x)==PIX_FMT_YUV444P \ | |
125 || (x)==PIX_FMT_YUV422P \ | |
126 || (x)==PIX_FMT_YUV411P \ | |
30432 | 127 || (x)==PIX_FMT_YUVJ420P \ |
128 || (x)==PIX_FMT_YUVJ422P \ | |
129 || (x)==PIX_FMT_YUVJ440P \ | |
130 || (x)==PIX_FMT_YUVJ444P \ | |
30393 | 131 || isAnyRGB(x) \ |
23278 | 132 || (x)==PIX_FMT_NV12 \ |
133 || (x)==PIX_FMT_NV21 \ | |
134 || (x)==PIX_FMT_GRAY16BE \ | |
135 || (x)==PIX_FMT_GRAY16LE \ | |
136 || (x)==PIX_FMT_GRAY8 \ | |
137 || (x)==PIX_FMT_YUV410P \ | |
27557 | 138 || (x)==PIX_FMT_YUV440P \ |
29608
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
139 || (x)==PIX_FMT_YUV420P16LE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
140 || (x)==PIX_FMT_YUV422P16LE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
141 || (x)==PIX_FMT_YUV444P16LE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
142 || (x)==PIX_FMT_YUV420P16BE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
143 || (x)==PIX_FMT_YUV422P16BE \ |
ff34398b14b1
Make 16bit YUV formats compatible with NE avcodec_get_pix_fmt().
ramiro
parents:
29545
diff
changeset
|
144 || (x)==PIX_FMT_YUV444P16BE \ |
23278 | 145 ) |
30194
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
146 |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
147 int sws_isSupportedOutput(enum PixelFormat pix_fmt) |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
148 { |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
149 return isSupportedOut(pix_fmt); |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
150 } |
bd9db1814611
Implement sws_isSupportedInput() and sws_isSupportedOutput().
stefano
parents:
30142
diff
changeset
|
151 |
28460 | 152 extern const int32_t ff_yuv2rgb_coeffs[8][4]; |
18861 | 153 |
26151
5884743208b6
change sws_format_name to return const char*, supress many warnings
bcoudurier
parents:
26150
diff
changeset
|
154 const char *sws_format_name(enum PixelFormat format) |
19143
c4dac777b44c
Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents:
18861
diff
changeset
|
155 { |
29926
916134a82d74
Make sws_format_name() use av_pix_fmt_descriptors.
stefano
parents:
29890
diff
changeset
|
156 if ((unsigned)format < PIX_FMT_NB && av_pix_fmt_descriptors[format].name) |
916134a82d74
Make sws_format_name() use av_pix_fmt_descriptors.
stefano
parents:
29890
diff
changeset
|
157 return av_pix_fmt_descriptors[format].name; |
916134a82d74
Make sws_format_name() use av_pix_fmt_descriptors.
stefano
parents:
29890
diff
changeset
|
158 else |
29480 | 159 return "Unknown format"; |
19143
c4dac777b44c
Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents:
18861
diff
changeset
|
160 } |
c4dac777b44c
Use libavutil in libswscale, and allow it to be built out of the mplayer tree
lucabe
parents:
18861
diff
changeset
|
161 |
18861 | 162 static double getSplineCoeff(double a, double b, double c, double d, double dist) |
163 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
164 // printf("%f %f %f %f %f\n", a,b,c,d,dist); |
29480 | 165 if (dist<=1.0) return ((d*dist + c)*dist + b)*dist +a; |
166 else return getSplineCoeff( 0.0, | |
167 b+ 2.0*c + 3.0*d, | |
168 c + 3.0*d, | |
169 -b- 3.0*c - 6.0*d, | |
170 dist-1.0); | |
18861 | 171 } |
172 | |
30307 | 173 static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSize, int xInc, |
30308 | 174 int srcW, int dstW, int filterAlign, int one, int flags, |
175 SwsVector *srcFilter, SwsVector *dstFilter, double param[2]) | |
18861 | 176 { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
177 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
178 int filterSize; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
179 int filter2Size; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
180 int minFilterSize; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
181 int64_t *filter=NULL; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
182 int64_t *filter2=NULL; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
183 const int64_t fone= 1LL<<54; |
27300 | 184 int ret= -1; |
28276 | 185 #if ARCH_X86 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
186 if (flags & SWS_CPU_CAPS_MMX) |
27744 | 187 __asm__ volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions) |
18861 | 188 #endif |
189 | |
28316 | 190 // NOTE: the +1 is for the MMX scaler which reads over the end |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
191 FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW+1)*sizeof(int16_t), fail); |
18861 | 192 |
29481 | 193 if (FFABS(xInc - 0x10000) <10) { // unscaled |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
194 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
195 filterSize= 1; |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
196 FF_ALLOCZ_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail); |
18861 | 197 |
29481 | 198 for (i=0; i<dstW; i++) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
199 filter[i*filterSize]= fone; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
200 (*filterPos)[i]=i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
201 } |
18861 | 202 |
29481 | 203 } else if (flags&SWS_POINT) { // lame looking point sampling mode |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
204 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
205 int xDstInSrc; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
206 filterSize= 1; |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
207 FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail); |
23129 | 208 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
209 xDstInSrc= xInc/2 - 0x8000; |
29481 | 210 for (i=0; i<dstW; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
211 int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16; |
18861 | 212 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
213 (*filterPos)[i]= xx; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
214 filter[i]= fone; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
215 xDstInSrc+= xInc; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
216 } |
29481 | 217 } else if ((xInc <= (1<<16) && (flags&SWS_AREA)) || (flags&SWS_FAST_BILINEAR)) { // bilinear upscale |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
218 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
219 int xDstInSrc; |
29407 | 220 filterSize= 2; |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
221 FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail); |
18861 | 222 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
223 xDstInSrc= xInc/2 - 0x8000; |
29481 | 224 for (i=0; i<dstW; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
225 int xx= (xDstInSrc - ((filterSize-1)<<15) + (1<<15))>>16; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
226 int j; |
18861 | 227 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
228 (*filterPos)[i]= xx; |
29480 | 229 //bilinear upscale / linear interpolate / area averaging |
29481 | 230 for (j=0; j<filterSize; j++) { |
29480 | 231 int64_t coeff= fone - FFABS((xx<<16) - xDstInSrc)*(fone>>16); |
232 if (coeff<0) coeff=0; | |
233 filter[i*filterSize + j]= coeff; | |
234 xx++; | |
235 } | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
236 xDstInSrc+= xInc; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
237 } |
29481 | 238 } else { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
239 int xDstInSrc; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
240 int sizeFactor; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
241 |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
242 if (flags&SWS_BICUBIC) sizeFactor= 4; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
243 else if (flags&SWS_X) sizeFactor= 8; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
244 else if (flags&SWS_AREA) sizeFactor= 1; //downscale only, for upscale it is bilinear |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
245 else if (flags&SWS_GAUSS) sizeFactor= 8; // infinite ;) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
246 else if (flags&SWS_LANCZOS) sizeFactor= param[0] != SWS_PARAM_DEFAULT ? ceil(2*param[0]) : 6; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
247 else if (flags&SWS_SINC) sizeFactor= 20; // infinite ;) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
248 else if (flags&SWS_SPLINE) sizeFactor= 20; // infinite ;) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
249 else if (flags&SWS_BILINEAR) sizeFactor= 2; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
250 else { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
251 sizeFactor= 0; //GCC warning killer |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
252 assert(0); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
253 } |
23129 | 254 |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
255 if (xInc <= 1<<16) filterSize= 1 + sizeFactor; // upscale |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
256 else filterSize= 1 + (sizeFactor*srcW + dstW - 1)/ dstW; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
257 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
258 if (filterSize > srcW-2) filterSize=srcW-2; |
18861 | 259 |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
260 FF_ALLOC_OR_GOTO(NULL, filter, dstW*sizeof(*filter)*filterSize, fail); |
18861 | 261 |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
262 xDstInSrc= xInc - 0x10000; |
29481 | 263 for (i=0; i<dstW; i++) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
264 int xx= (xDstInSrc - ((filterSize-2)<<16)) / (1<<17); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
265 int j; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
266 (*filterPos)[i]= xx; |
29481 | 267 for (j=0; j<filterSize; j++) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
268 int64_t d= ((int64_t)FFABS((xx<<17) - xDstInSrc))<<13; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
269 double floatd; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
270 int64_t coeff; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
271 |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
272 if (xInc > 1<<16) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
273 d= d*dstW/srcW; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
274 floatd= d * (1.0/(1<<30)); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
275 |
29481 | 276 if (flags & SWS_BICUBIC) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
277 int64_t B= (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1<<24); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
278 int64_t C= (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1<<24); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
279 int64_t dd = ( d*d)>>30; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
280 int64_t ddd= (dd*d)>>30; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
281 |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
282 if (d < 1LL<<30) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
283 coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
284 else if (d < 1LL<<31) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
285 coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
286 else |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
287 coeff=0.0; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
288 coeff *= fone>>(30+24); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
289 } |
29481 | 290 /* else if (flags & SWS_X) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
291 double p= param ? param*0.01 : 0.3; |
31128 | 292 coeff = d ? sin(d*M_PI)/(d*M_PI) : 1.0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
293 coeff*= pow(2.0, - p*d*d); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
294 }*/ |
29481 | 295 else if (flags & SWS_X) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
296 double A= param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
297 double c; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
298 |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
299 if (floatd<1.0) |
30370
a8c94e9dc653
Don't redefine M_PI. It is already defined from libavutil/mathematics.h.
ramiro
parents:
30369
diff
changeset
|
300 c = cos(floatd*M_PI); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
301 else |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
302 c=-1.0; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
303 if (c<0.0) c= -pow(-c, A); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
304 else c= pow( c, A); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
305 coeff= (c*0.5 + 0.5)*fone; |
29481 | 306 } else if (flags & SWS_AREA) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
307 int64_t d2= d - (1<<29); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
308 if (d2*xInc < -(1LL<<(29+16))) coeff= 1.0 * (1LL<<(30+16)); |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
309 else if (d2*xInc < (1LL<<(29+16))) coeff= -d2*xInc + (1LL<<(29+16)); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
310 else coeff=0.0; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
311 coeff *= fone>>(30+16); |
29481 | 312 } else if (flags & SWS_GAUSS) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
313 double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
314 coeff = (pow(2.0, - p*floatd*floatd))*fone; |
29481 | 315 } else if (flags & SWS_SINC) { |
30370
a8c94e9dc653
Don't redefine M_PI. It is already defined from libavutil/mathematics.h.
ramiro
parents:
30369
diff
changeset
|
316 coeff = (d ? sin(floatd*M_PI)/(floatd*M_PI) : 1.0)*fone; |
29481 | 317 } else if (flags & SWS_LANCZOS) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
318 double p= param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0; |
30370
a8c94e9dc653
Don't redefine M_PI. It is already defined from libavutil/mathematics.h.
ramiro
parents:
30369
diff
changeset
|
319 coeff = (d ? sin(floatd*M_PI)*sin(floatd*M_PI/p)/(floatd*floatd*M_PI*M_PI/p) : 1.0)*fone; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
320 if (floatd>p) coeff=0; |
29481 | 321 } else if (flags & SWS_BILINEAR) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
322 coeff= (1<<30) - d; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
323 if (coeff<0) coeff=0; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
324 coeff *= fone >> 30; |
29481 | 325 } else if (flags & SWS_SPLINE) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
326 double p=-2.196152422706632; |
27637
5abf906c09c8
Fix infinite loop with spline, bug was introduced in r27612 by me.
michael
parents:
27596
diff
changeset
|
327 coeff = getSplineCoeff(1.0, 0.0, p, -p-1.0, floatd) * fone; |
29481 | 328 } else { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
329 coeff= 0.0; //GCC warning killer |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
330 assert(0); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
331 } |
18861 | 332 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
333 filter[i*filterSize + j]= coeff; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
334 xx++; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
335 } |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
336 xDstInSrc+= 2*xInc; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
337 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
338 } |
18861 | 339 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
340 /* apply src & dst Filter to filter -> filter2 |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
341 av_free(filter); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
342 */ |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
343 assert(filterSize>0); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
344 filter2Size= filterSize; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
345 if (srcFilter) filter2Size+= srcFilter->length - 1; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
346 if (dstFilter) filter2Size+= dstFilter->length - 1; |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
347 assert(filter2Size>0); |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
348 FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size*dstW*sizeof(*filter2), fail); |
18861 | 349 |
29481 | 350 for (i=0; i<dstW; i++) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
351 int j, k; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
352 |
29481 | 353 if(srcFilter) { |
354 for (k=0; k<srcFilter->length; k++) { | |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
355 for (j=0; j<filterSize; j++) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
356 filter2[i*filter2Size + k + j] += srcFilter->coeff[k]*filter[i*filterSize + j]; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
357 } |
29481 | 358 } else { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
359 for (j=0; j<filterSize; j++) |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
360 filter2[i*filter2Size + j]= filter[i*filterSize + j]; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
361 } |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
362 //FIXME dstFilter |
18861 | 363 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
364 (*filterPos)[i]+= (filterSize-1)/2 - (filter2Size-1)/2; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
365 } |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
366 av_freep(&filter); |
18861 | 367 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
368 /* try to reduce the filter-size (step1 find size and shift left) */ |
23536 | 369 // Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not). |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
370 minFilterSize= 0; |
29481 | 371 for (i=dstW-1; i>=0; i--) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
372 int min= filter2Size; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
373 int j; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
374 int64_t cutOff=0.0; |
18861 | 375 |
30296 | 376 /* get rid of near zero elements on the left by shifting left */ |
29481 | 377 for (j=0; j<filter2Size; j++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
378 int k; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
379 cutOff += FFABS(filter2[i*filter2Size]); |
18861 | 380 |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
381 if (cutOff > SWS_MAX_REDUCE_CUTOFF*fone) break; |
18861 | 382 |
23536 | 383 /* preserve monotonicity because the core can't handle the filter otherwise */ |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
384 if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break; |
18861 | 385 |
28316 | 386 // move filter coefficients left |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
387 for (k=1; k<filter2Size; k++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
388 filter2[i*filter2Size + k - 1]= filter2[i*filter2Size + k]; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
389 filter2[i*filter2Size + k - 1]= 0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
390 (*filterPos)[i]++; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
391 } |
18861 | 392 |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
393 cutOff=0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
394 /* count near zeros on the right */ |
29481 | 395 for (j=filter2Size-1; j>0; j--) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
396 cutOff += FFABS(filter2[i*filter2Size + j]); |
18861 | 397 |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
398 if (cutOff > SWS_MAX_REDUCE_CUTOFF*fone) break; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
399 min--; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
400 } |
18861 | 401 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
402 if (min>minFilterSize) minFilterSize= min; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
403 } |
18861 | 404 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
405 if (flags & SWS_CPU_CAPS_ALTIVEC) { |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
406 // we can handle the special case 4, |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
407 // so we don't want to go to the full 8 |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
408 if (minFilterSize < 5) |
18861 | 409 filterAlign = 4; |
410 | |
28316 | 411 // We really don't want to waste our time |
412 // doing useless computation, so fall back on | |
413 // the scalar C code for very small filters. | |
414 // Vectorizing is worth it only if you have a | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
415 // decent-sized vector. |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
416 if (minFilterSize < 3) |
18861 | 417 filterAlign = 1; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
418 } |
18861 | 419 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
420 if (flags & SWS_CPU_CAPS_MMX) { |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
421 // special case for unscaled vertical filtering |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
422 if (minFilterSize == 1 && filterAlign == 2) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
423 filterAlign= 1; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
424 } |
19172
bae6c99a99cc
vertical scaler with accurate rounding, some people on doom9 can see +-1 errors
michael
parents:
19169
diff
changeset
|
425 |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
426 assert(minFilterSize > 0); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
427 filterSize= (minFilterSize +(filterAlign-1)) & (~(filterAlign-1)); |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
428 assert(filterSize > 0); |
27579 | 429 filter= av_malloc(filterSize*dstW*sizeof(*filter)); |
27513 | 430 if (filterSize >= MAX_FILTER_SIZE*16/((flags&SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter) |
29542 | 431 goto fail; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
432 *outFilterSize= filterSize; |
18861 | 433 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
434 if (flags&SWS_PRINT_INFO) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
435 av_log(NULL, AV_LOG_VERBOSE, "SwScaler: reducing / aligning filtersize %d -> %d\n", filter2Size, filterSize); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
436 /* try to reduce the filter-size (step2 reduce it) */ |
29481 | 437 for (i=0; i<dstW; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
438 int j; |
18861 | 439 |
29481 | 440 for (j=0; j<filterSize; j++) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
441 if (j>=filter2Size) filter[i*filterSize + j]= 0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
442 else filter[i*filterSize + j]= filter2[i*filter2Size + j]; |
27563
39c8d234b98e
Ensure that additional filter coeffs that exist due to alignment
michael
parents:
27562
diff
changeset
|
443 if((flags & SWS_BITEXACT) && j>=minFilterSize) |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
444 filter[i*filterSize + j]= 0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
445 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
446 } |
23129 | 447 |
28316 | 448 //FIXME try to align filterPos if possible |
18861 | 449 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
450 //fix borders |
29481 | 451 for (i=0; i<dstW; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
452 int j; |
29481 | 453 if ((*filterPos)[i] < 0) { |
28316 | 454 // move filter coefficients left to compensate for filterPos |
29481 | 455 for (j=1; j<filterSize; j++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
456 int left= FFMAX(j + (*filterPos)[i], 0); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
457 filter[i*filterSize + left] += filter[i*filterSize + j]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
458 filter[i*filterSize + j]=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
459 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
460 (*filterPos)[i]= 0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
461 } |
18861 | 462 |
29481 | 463 if ((*filterPos)[i] + filterSize > srcW) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
464 int shift= (*filterPos)[i] + filterSize - srcW; |
28316 | 465 // move filter coefficients right to compensate for filterPos |
29481 | 466 for (j=filterSize-2; j>=0; j--) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
467 int right= FFMIN(j + shift, filterSize-1); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
468 filter[i*filterSize +right] += filter[i*filterSize +j]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
469 filter[i*filterSize +j]=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
470 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
471 (*filterPos)[i]= srcW - filterSize; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
472 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
473 } |
18861 | 474 |
28316 | 475 // Note the +1 is for the MMX scaler which reads over the end |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
476 /* align at 16 for AltiVec (needed by hScale_altivec_real) */ |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
477 FF_ALLOCZ_OR_GOTO(NULL, *outFilter, *outFilterSize*(dstW+1)*sizeof(int16_t), fail); |
18861 | 478 |
28316 | 479 /* normalize & store in outFilter */ |
29481 | 480 for (i=0; i<dstW; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
481 int j; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
482 int64_t error=0; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
483 int64_t sum=0; |
18861 | 484 |
29481 | 485 for (j=0; j<filterSize; j++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
486 sum+= filter[i*filterSize + j]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
487 } |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
488 sum= (sum + one/2)/ one; |
29481 | 489 for (j=0; j<*outFilterSize; j++) { |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
490 int64_t v= filter[i*filterSize + j] + error; |
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
491 int intV= ROUNDED_DIV(v, sum); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
492 (*outFilter)[i*(*outFilterSize) + j]= intV; |
27580
9ff7a64a51fa
Avoid using floating point for calculating filter coefficients.
michael
parents:
27579
diff
changeset
|
493 error= v - intV*sum; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
494 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
495 } |
23129 | 496 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
497 (*filterPos)[dstW]= (*filterPos)[dstW-1]; // the MMX scaler will read over the end |
29481 | 498 for (i=0; i<*outFilterSize; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
499 int j= dstW*(*outFilterSize); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
500 (*outFilter)[j + i]= (*outFilter)[j + i - (*outFilterSize)]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
501 } |
18861 | 502 |
27300 | 503 ret=0; |
29542 | 504 fail: |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
505 av_free(filter); |
27300 | 506 av_free(filter2); |
507 return ret; | |
18861 | 508 } |
509 | |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
510 #if ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
511 static int initMMX2HScaler(int dstW, int xInc, uint8_t *filterCode, int16_t *filter, int32_t *filterPos, int numSplits) |
18861 | 512 { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
513 uint8_t *fragmentA; |
28957 | 514 x86_reg imm8OfPShufW1A; |
515 x86_reg imm8OfPShufW2A; | |
516 x86_reg fragmentLengthA; | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
517 uint8_t *fragmentB; |
28957 | 518 x86_reg imm8OfPShufW1B; |
519 x86_reg imm8OfPShufW2B; | |
520 x86_reg fragmentLengthB; | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
521 int fragmentPos; |
18861 | 522 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
523 int xpos, i; |
18861 | 524 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
525 // create an optimized horizontal scaling routine |
29936
f43f03c00402
Document the differences between the two asm fragments in initMMX2HScaler().
ramiro
parents:
29932
diff
changeset
|
526 /* This scaler is made of runtime-generated MMX2 code using specially |
f43f03c00402
Document the differences between the two asm fragments in initMMX2HScaler().
ramiro
parents:
29932
diff
changeset
|
527 * tuned pshufw instructions. For every four output pixels, if four |
f43f03c00402
Document the differences between the two asm fragments in initMMX2HScaler().
ramiro
parents:
29932
diff
changeset
|
528 * input pixels are enough for the fast bilinear scaling, then a chunk |
f43f03c00402
Document the differences between the two asm fragments in initMMX2HScaler().
ramiro
parents:
29932
diff
changeset
|
529 * of fragmentB is used. If five input pixels are needed, then a chunk |
f43f03c00402
Document the differences between the two asm fragments in initMMX2HScaler().
ramiro
parents:
29932
diff
changeset
|
530 * of fragmentA is used. |
f43f03c00402
Document the differences between the two asm fragments in initMMX2HScaler().
ramiro
parents:
29932
diff
changeset
|
531 */ |
18861 | 532 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
533 //code fragment |
18861 | 534 |
27744 | 535 __asm__ volatile( |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
536 "jmp 9f \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
537 // Begin |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
538 "0: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
539 "movq (%%"REG_d", %%"REG_a"), %%mm3 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
540 "movd (%%"REG_c", %%"REG_S"), %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
541 "movd 1(%%"REG_c", %%"REG_S"), %%mm1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
542 "punpcklbw %%mm7, %%mm1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
543 "punpcklbw %%mm7, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
544 "pshufw $0xFF, %%mm1, %%mm1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
545 "1: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
546 "pshufw $0xFF, %%mm0, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
547 "2: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
548 "psubw %%mm1, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
549 "movl 8(%%"REG_b", %%"REG_a"), %%esi \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
550 "pmullw %%mm3, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
551 "psllw $7, %%mm1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
552 "paddw %%mm1, %%mm0 \n\t" |
18861 | 553 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
554 "movq %%mm0, (%%"REG_D", %%"REG_a") \n\t" |
18861 | 555 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
556 "add $8, %%"REG_a" \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
557 // End |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
558 "9: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
559 // "int $3 \n\t" |
26238
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
560 "lea " LOCAL_MANGLE(0b) ", %0 \n\t" |
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
561 "lea " LOCAL_MANGLE(1b) ", %1 \n\t" |
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
562 "lea " LOCAL_MANGLE(2b) ", %2 \n\t" |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
563 "dec %1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
564 "dec %2 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
565 "sub %0, %1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
566 "sub %0, %2 \n\t" |
26238
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
567 "lea " LOCAL_MANGLE(9b) ", %3 \n\t" |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
568 "sub %0, %3 \n\t" |
18861 | 569 |
570 | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
571 :"=r" (fragmentA), "=r" (imm8OfPShufW1A), "=r" (imm8OfPShufW2A), |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
572 "=r" (fragmentLengthA) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
573 ); |
18861 | 574 |
27744 | 575 __asm__ volatile( |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
576 "jmp 9f \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
577 // Begin |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
578 "0: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
579 "movq (%%"REG_d", %%"REG_a"), %%mm3 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
580 "movd (%%"REG_c", %%"REG_S"), %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
581 "punpcklbw %%mm7, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
582 "pshufw $0xFF, %%mm0, %%mm1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
583 "1: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
584 "pshufw $0xFF, %%mm0, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
585 "2: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
586 "psubw %%mm1, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
587 "movl 8(%%"REG_b", %%"REG_a"), %%esi \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
588 "pmullw %%mm3, %%mm0 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
589 "psllw $7, %%mm1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
590 "paddw %%mm1, %%mm0 \n\t" |
18861 | 591 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
592 "movq %%mm0, (%%"REG_D", %%"REG_a") \n\t" |
18861 | 593 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
594 "add $8, %%"REG_a" \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
595 // End |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
596 "9: \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
597 // "int $3 \n\t" |
26238
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
598 "lea " LOCAL_MANGLE(0b) ", %0 \n\t" |
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
599 "lea " LOCAL_MANGLE(1b) ", %1 \n\t" |
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
600 "lea " LOCAL_MANGLE(2b) ", %2 \n\t" |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
601 "dec %1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
602 "dec %2 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
603 "sub %0, %1 \n\t" |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
604 "sub %0, %2 \n\t" |
26238
726b915c2b45
Fix 64 bit shared library compilation with MMX2 by properly using PIC mangling.
diego
parents:
26232
diff
changeset
|
605 "lea " LOCAL_MANGLE(9b) ", %3 \n\t" |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
606 "sub %0, %3 \n\t" |
18861 | 607 |
608 | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
609 :"=r" (fragmentB), "=r" (imm8OfPShufW1B), "=r" (imm8OfPShufW2B), |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
610 "=r" (fragmentLengthB) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
611 ); |
18861 | 612 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
613 xpos= 0; //lumXInc/2 - 0x8000; // difference between pixel centers |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
614 fragmentPos=0; |
23129 | 615 |
29481 | 616 for (i=0; i<dstW/numSplits; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
617 int xx=xpos>>16; |
18861 | 618 |
29481 | 619 if ((i&3) == 0) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
620 int a=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
621 int b=((xpos+xInc)>>16) - xx; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
622 int c=((xpos+xInc*2)>>16) - xx; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
623 int d=((xpos+xInc*3)>>16) - xx; |
29410
fd9b0bd6c908
MMX2 scaler: add variable to ease factorization of initMMX2Scaler().
ramiro
parents:
29407
diff
changeset
|
624 int inc = (d+1<4); |
29411 | 625 uint8_t *fragment = (d+1<4) ? fragmentB : fragmentA; |
626 x86_reg imm8OfPShufW1 = (d+1<4) ? imm8OfPShufW1B : imm8OfPShufW1A; | |
627 x86_reg imm8OfPShufW2 = (d+1<4) ? imm8OfPShufW2B : imm8OfPShufW2A; | |
628 x86_reg fragmentLength = (d+1<4) ? fragmentLengthB : fragmentLengthA; | |
29412
139af822b6ce
MMX2 scaler: Remove {} block leftover from factorization in initMMX2Scaler().
ramiro
parents:
29411
diff
changeset
|
629 int maxShift= 3-(d+inc); |
139af822b6ce
MMX2 scaler: Remove {} block leftover from factorization in initMMX2Scaler().
ramiro
parents:
29411
diff
changeset
|
630 int shift=0; |
18861 | 631 |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
632 if (filterCode) { |
29470 | 633 filter[i ] = (( xpos & 0xFFFF) ^ 0xFFFF)>>9; |
634 filter[i+1] = (((xpos+xInc ) & 0xFFFF) ^ 0xFFFF)>>9; | |
635 filter[i+2] = (((xpos+xInc*2) & 0xFFFF) ^ 0xFFFF)>>9; | |
636 filter[i+3] = (((xpos+xInc*3) & 0xFFFF) ^ 0xFFFF)>>9; | |
637 filterPos[i/2]= xx; | |
638 | |
639 memcpy(filterCode + fragmentPos, fragment, fragmentLength); | |
640 | |
641 filterCode[fragmentPos + imm8OfPShufW1]= | |
642 (a+inc) | ((b+inc)<<2) | ((c+inc)<<4) | ((d+inc)<<6); | |
643 filterCode[fragmentPos + imm8OfPShufW2]= | |
644 a | (b<<2) | (c<<4) | (d<<6); | |
645 | |
646 if (i+4-inc>=dstW) shift=maxShift; //avoid overread | |
647 else if ((filterPos[i/2]&3) <= maxShift) shift=filterPos[i/2]&3; //Align | |
648 | |
29481 | 649 if (shift && i>=shift) { |
29470 | 650 filterCode[fragmentPos + imm8OfPShufW1]+= 0x55*shift; |
651 filterCode[fragmentPos + imm8OfPShufW2]+= 0x55*shift; | |
652 filterPos[i/2]-=shift; | |
653 } | |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
654 } |
18861 | 655 |
29412
139af822b6ce
MMX2 scaler: Remove {} block leftover from factorization in initMMX2Scaler().
ramiro
parents:
29411
diff
changeset
|
656 fragmentPos+= fragmentLength; |
139af822b6ce
MMX2 scaler: Remove {} block leftover from factorization in initMMX2Scaler().
ramiro
parents:
29411
diff
changeset
|
657 |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
658 if (filterCode) |
29470 | 659 filterCode[fragmentPos]= RET; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
660 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
661 xpos+=xInc; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
662 } |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
663 if (filterCode) |
29470 | 664 filterPos[((i/2)+1)&(~1)]= xpos>>16; // needed to jump to the next part |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
665 |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
666 return fragmentPos + 1; |
18861 | 667 } |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
668 #endif /* ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) */ |
18861 | 669 |
30142
bd5ab02f84f8
Prefer enum PixelFormat over int for the type of the format parameter
stefano
parents:
30138
diff
changeset
|
670 static void getSubSampleFactors(int *h, int *v, enum PixelFormat format) |
29481 | 671 { |
30129
a8283bcc8d2e
Simplify getSubSampleFactors(), make it use the values provided by
stefano
parents:
30045
diff
changeset
|
672 *h = av_pix_fmt_descriptors[format].log2_chroma_w; |
a8283bcc8d2e
Simplify getSubSampleFactors(), make it use the values provided by
stefano
parents:
30045
diff
changeset
|
673 *v = av_pix_fmt_descriptors[format].log2_chroma_h; |
18861 | 674 } |
675 | |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
676 static int update_flags_cpu(int flags); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
677 |
29481 | 678 int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation) |
679 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
680 memcpy(c->srcColorspaceTable, inv_table, sizeof(int)*4); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
681 memcpy(c->dstColorspaceTable, table, sizeof(int)*4); |
18861 | 682 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
683 c->brightness= brightness; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
684 c->contrast = contrast; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
685 c->saturation= saturation; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
686 c->srcRange = srcRange; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
687 c->dstRange = dstRange; |
29146
d6d87abb137f
Make sws_setColorspaceDetails() return -1 if the destination format is
stefano
parents:
29145
diff
changeset
|
688 if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1; |
18861 | 689 |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
690 c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->dstFormat]); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
691 c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->srcFormat]); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
692 c->flags = update_flags_cpu(c->flags); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
693 |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28951
diff
changeset
|
694 ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
695 //FIXME factorize |
18861 | 696 |
30912
f91ad62a2281
AltiVec implies a PPC CPU, so there is no need to check for both.
diego
parents:
30910
diff
changeset
|
697 #if HAVE_ALTIVEC |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
698 if (c->flags & SWS_CPU_CAPS_ALTIVEC) |
28953
1e56ea9937ce
Consistently use ff_ prefixes for internal symbols.
diego
parents:
28951
diff
changeset
|
699 ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness, contrast, saturation); |
23129 | 700 #endif |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
701 return 0; |
18861 | 702 } |
703 | |
29481 | 704 int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation) |
705 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
706 if (isYUV(c->dstFormat) || isGray(c->dstFormat)) return -1; |
18861 | 707 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
708 *inv_table = c->srcColorspaceTable; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
709 *table = c->dstColorspaceTable; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
710 *srcRange = c->srcRange; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
711 *dstRange = c->dstRange; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
712 *brightness= c->brightness; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
713 *contrast = c->contrast; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
714 *saturation= c->saturation; |
23129 | 715 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
716 return 0; |
18861 | 717 } |
718 | |
27696
0c2dc440984b
Change one more variable type from int to enum PixelFormat.
aurel
parents:
27695
diff
changeset
|
719 static int handle_jpeg(enum PixelFormat *format) |
19987 | 720 { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
721 switch (*format) { |
31129
8639a950e856
Cosmetics: make more compact the code for handle_jpeg(), this also allows
stefano
parents:
31128
diff
changeset
|
722 case PIX_FMT_YUVJ420P: *format = PIX_FMT_YUV420P; return 1; |
8639a950e856
Cosmetics: make more compact the code for handle_jpeg(), this also allows
stefano
parents:
31128
diff
changeset
|
723 case PIX_FMT_YUVJ422P: *format = PIX_FMT_YUV422P; return 1; |
8639a950e856
Cosmetics: make more compact the code for handle_jpeg(), this also allows
stefano
parents:
31128
diff
changeset
|
724 case PIX_FMT_YUVJ444P: *format = PIX_FMT_YUV444P; return 1; |
8639a950e856
Cosmetics: make more compact the code for handle_jpeg(), this also allows
stefano
parents:
31128
diff
changeset
|
725 case PIX_FMT_YUVJ440P: *format = PIX_FMT_YUV440P; return 1; |
8639a950e856
Cosmetics: make more compact the code for handle_jpeg(), this also allows
stefano
parents:
31128
diff
changeset
|
726 default: return 0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
727 } |
19987 | 728 } |
729 | |
31968
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
730 static int update_flags_cpu(int flags) |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
731 { |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
732 #if !CONFIG_RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off |
32306 | 733 flags &= ~( SWS_CPU_CAPS_MMX |
734 |SWS_CPU_CAPS_MMX2 | |
735 |SWS_CPU_CAPS_3DNOW | |
32307
7ba2369d71f7
swscale: clear SWS_CPU_CAPS_SSE2 in update_flags_cpu() missed in r32068
janne
parents:
32306
diff
changeset
|
736 |SWS_CPU_CAPS_SSE2 |
32306 | 737 |SWS_CPU_CAPS_ALTIVEC |
738 |SWS_CPU_CAPS_BFIN); | |
31968
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
739 flags |= ff_hardcodedcpuflags(); |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
740 #endif /* CONFIG_RUNTIME_CPUDETECT */ |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
741 return flags; |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
742 } |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
743 |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
744 SwsContext *sws_alloc_context(void){ |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
745 SwsContext *c= av_mallocz(sizeof(SwsContext)); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
746 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
747 c->av_class = &sws_context_class; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
748 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
749 return c; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
750 } |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
751 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
752 int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter){ |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
753 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
754 int usesVFilter, usesHFilter; |
30369
8c479cb29c7a
Split swscale.c into scaler code (swscale.c) and utility code (utils.c).
ramiro
parents:
30343
diff
changeset
|
755 int unscaled; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
756 SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
757 int srcW= c->srcW; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
758 int srcH= c->srcH; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
759 int dstW= c->dstW; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
760 int dstH= c->dstH; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
761 int flags; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
762 enum PixelFormat srcFormat= c->srcFormat; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
763 enum PixelFormat dstFormat= c->dstFormat; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
764 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
765 flags= c->flags = update_flags_cpu(c->flags); |
28276 | 766 #if ARCH_X86 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
767 if (flags & SWS_CPU_CAPS_MMX) |
27744 | 768 __asm__ volatile("emms\n\t"::: "memory"); |
18861 | 769 #endif |
25752
559b0e9d47fb
Change (a == NULL) condition to (!a) and (a != NULL) condition to (a).
benoit
parents:
25750
diff
changeset
|
770 if (!rgb15to16) sws_rgb2rgb_init(flags); |
18861 | 771 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
772 unscaled = (srcW == dstW && srcH == dstH); |
18861 | 773 |
29481 | 774 if (!isSupportedIn(srcFormat)) { |
25967
87331ea89425
More explicit unsupported pixel format error messages.
benoit
parents:
25935
diff
changeset
|
775 av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as input pixel format\n", sws_format_name(srcFormat)); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
776 return AVERROR(EINVAL); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
777 } |
29481 | 778 if (!isSupportedOut(dstFormat)) { |
25967
87331ea89425
More explicit unsupported pixel format error messages.
benoit
parents:
25935
diff
changeset
|
779 av_log(NULL, AV_LOG_ERROR, "swScaler: %s is not supported as output pixel format\n", sws_format_name(dstFormat)); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
780 return AVERROR(EINVAL); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
781 } |
18861 | 782 |
27285 | 783 i= flags & ( SWS_POINT |
784 |SWS_AREA | |
27286 | 785 |SWS_BILINEAR |
27285 | 786 |SWS_FAST_BILINEAR |
787 |SWS_BICUBIC | |
788 |SWS_X | |
789 |SWS_GAUSS | |
790 |SWS_LANCZOS | |
791 |SWS_SINC | |
792 |SWS_SPLINE | |
793 |SWS_BICUBLIN); | |
29481 | 794 if(!i || (i & (i-1))) { |
28316 | 795 av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be chosen\n"); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
796 return AVERROR(EINVAL); |
27285 | 797 } |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
798 /* sanity check */ |
29481 | 799 if (srcW<4 || srcH<1 || dstW<8 || dstH<1) { //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
800 av_log(NULL, AV_LOG_ERROR, "swScaler: %dx%d -> %dx%d is invalid scaling dimension\n", |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
801 srcW, srcH, dstW, dstH); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
802 return AVERROR(EINVAL); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
803 } |
29481 | 804 if(srcW > VOFW || dstW > VOFW) { |
28316 | 805 av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n"); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
806 return AVERROR(EINVAL); |
26133
94cc4bac8cd0
Turn ancient V offset numerical constants into named ones.
michael
parents:
26028
diff
changeset
|
807 } |
18861 | 808 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
809 if (!dstFilter) dstFilter= &dummyFilter; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
810 if (!srcFilter) srcFilter= &dummyFilter; |
18861 | 811 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
812 c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
813 c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; |
30377
2eea1f09e2c5
Use av_get_bits_per_pixel() for computing the bits per pixel of the
stefano
parents:
30370
diff
changeset
|
814 c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[dstFormat]); |
2eea1f09e2c5
Use av_get_bits_per_pixel() for computing the bits per pixel of the
stefano
parents:
30370
diff
changeset
|
815 c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[srcFormat]); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
816 c->vRounder= 4* 0x0001000100010001ULL; |
18861 | 817 |
30478
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
818 usesVFilter = (srcFilter->lumV && srcFilter->lumV->length>1) || |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
819 (srcFilter->chrV && srcFilter->chrV->length>1) || |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
820 (dstFilter->lumV && dstFilter->lumV->length>1) || |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
821 (dstFilter->chrV && dstFilter->chrV->length>1); |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
822 usesHFilter = (srcFilter->lumH && srcFilter->lumH->length>1) || |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
823 (srcFilter->chrH && srcFilter->chrH->length>1) || |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
824 (dstFilter->lumH && dstFilter->lumH->length>1) || |
838bbf6bc6ff
Simplify how usesVFilter and usesHFilter are set.
stefano
parents:
30432
diff
changeset
|
825 (dstFilter->chrH && dstFilter->chrH->length>1); |
18861 | 826 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
827 getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
828 getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); |
18861 | 829 |
28316 | 830 // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpolation |
30393 | 831 if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1; |
18861 | 832 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
833 // drop some chroma lines if the user wants it |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
834 c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
835 c->chrSrcVSubSample+= c->vChrDrop; |
18861 | 836 |
28316 | 837 // drop every other pixel for chroma calculation unless user wants full chroma |
30393 | 838 if (isAnyRGB(srcFormat) && !(flags&SWS_FULL_CHR_H_INP) |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
839 && srcFormat!=PIX_FMT_RGB8 && srcFormat!=PIX_FMT_BGR8 |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
840 && srcFormat!=PIX_FMT_RGB4 && srcFormat!=PIX_FMT_BGR4 |
27529
ffb573fae5e8
Rewrite bgr24->yuv mmx code, the new code is cleaner, more accurate,
michael
parents:
27526
diff
changeset
|
841 && srcFormat!=PIX_FMT_RGB4_BYTE && srcFormat!=PIX_FMT_BGR4_BYTE |
32274 | 842 && ((dstW>>c->chrDstHSubSample) <= (srcW>>1) || (flags&SWS_FAST_BILINEAR))) |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
843 c->chrSrcHSubSample=1; |
18861 | 844 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
845 // Note the -((-x)>>y) is so that we always round toward +inf. |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
846 c->chrSrcW= -((-srcW) >> c->chrSrcHSubSample); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
847 c->chrSrcH= -((-srcH) >> c->chrSrcVSubSample); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
848 c->chrDstW= -((-dstW) >> c->chrDstHSubSample); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
849 c->chrDstH= -((-dstH) >> c->chrDstVSubSample); |
18861 | 850 |
28316 | 851 /* unscaled special cases */ |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
852 if (unscaled && !usesHFilter && !usesVFilter && (c->srcRange == c->dstRange || isAnyRGB(dstFormat))) { |
30369
8c479cb29c7a
Split swscale.c into scaler code (swscale.c) and utility code (utils.c).
ramiro
parents:
30343
diff
changeset
|
853 ff_get_unscaled_swscale(c); |
23585
d3ae6979d3df
integrating ff_bfin_get_unscaled_swscale into the system
mhoffman
parents:
23536
diff
changeset
|
854 |
29481 | 855 if (c->swScale) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
856 if (flags&SWS_PRINT_INFO) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
857 av_log(c, AV_LOG_INFO, "using unscaled %s -> %s special converter\n", |
29480 | 858 sws_format_name(srcFormat), sws_format_name(dstFormat)); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
859 return 0; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
860 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
861 } |
18861 | 862 |
29481 | 863 if (flags & SWS_CPU_CAPS_MMX2) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
864 c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; |
29481 | 865 if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
866 if (flags&SWS_PRINT_INFO) |
28316 | 867 av_log(c, AV_LOG_INFO, "output width is not a multiple of 32 -> no MMX2 scaler\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
868 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
869 if (usesHFilter) c->canMMX2BeUsed=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
870 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
871 else |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
872 c->canMMX2BeUsed=0; |
18861 | 873 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
874 c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
875 c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH; |
18861 | 876 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
877 // match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
878 // but only for the FAST_BILINEAR mode otherwise do correct scaling |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
879 // n-2 is the last chrominance sample available |
23536 | 880 // this is not perfect, but no one should notice the difference, the more correct variant |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
881 // would be like the vertical one, but that would require some special code for the |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
882 // first and last pixel |
29481 | 883 if (flags&SWS_FAST_BILINEAR) { |
884 if (c->canMMX2BeUsed) { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
885 c->lumXInc+= 20; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
886 c->chrXInc+= 20; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
887 } |
28316 | 888 //we don't use the x86 asm scaler if MMX is available |
29481 | 889 else if (flags & SWS_CPU_CAPS_MMX) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
890 c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
891 c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
892 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
893 } |
18861 | 894 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
895 /* precalculate horizontal scaler filter coefficients */ |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
896 { |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
897 #if ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) |
18861 | 898 // can't downscale !!! |
29481 | 899 if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) { |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
900 c->lumMmx2FilterCodeSize = initMMX2HScaler( dstW, c->lumXInc, NULL, NULL, NULL, 8); |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
901 c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4); |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
902 |
18861 | 903 #ifdef MAP_ANONYMOUS |
31903 | 904 c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
905 c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | |
28971
b8e356a9dbb1
Allocate executable memory with VirtualAlloc() in Windows.
ramiro
parents:
28970
diff
changeset
|
906 #elif HAVE_VIRTUALALLOC |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
907 c->lumMmx2FilterCode = VirtualAlloc(NULL, c->lumMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
908 c->chrMmx2FilterCode = VirtualAlloc(NULL, c->chrMmx2FilterCodeSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); |
18861 | 909 #else |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
910 c->lumMmx2FilterCode = av_malloc(c->lumMmx2FilterCodeSize); |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
911 c->chrMmx2FilterCode = av_malloc(c->chrMmx2FilterCodeSize); |
18861 | 912 #endif |
913 | |
30822
ed3b3682cdde
Check for allocation failure for c->lumMmx2FilterCode and c->chrMmx2FilterCode.
reimar
parents:
30821
diff
changeset
|
914 if (!c->lumMmx2FilterCode || !c->chrMmx2FilterCode) |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
915 return AVERROR(ENOMEM); |
30285
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
916 FF_ALLOCZ_OR_GOTO(c, c->hLumFilter , (dstW /8+8)*sizeof(int16_t), fail); |
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
917 FF_ALLOCZ_OR_GOTO(c, c->hChrFilter , (c->chrDstW /4+8)*sizeof(int16_t), fail); |
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
918 FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW /2/8+8)*sizeof(int32_t), fail); |
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
919 FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW/2/4+8)*sizeof(int32_t), fail); |
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
920 |
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
921 initMMX2HScaler( dstW, c->lumXInc, c->lumMmx2FilterCode, c->hLumFilter, c->hLumFilterPos, 8); |
042ec58ab0e2
Reuse h{lum,chr}Filter{,Pos} variables for MMX2 fast_bilinear horizontal scaler.
ramiro
parents:
30284
diff
changeset
|
922 initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4); |
29467
1acbe8b170ed
Protect mmx2 filter code buffers so they are not executable and writeable at
ramiro
parents:
29465
diff
changeset
|
923 |
1acbe8b170ed
Protect mmx2 filter code buffers so they are not executable and writeable at
ramiro
parents:
29465
diff
changeset
|
924 #ifdef MAP_ANONYMOUS |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
925 mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ); |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
926 mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ); |
29467
1acbe8b170ed
Protect mmx2 filter code buffers so they are not executable and writeable at
ramiro
parents:
29465
diff
changeset
|
927 #endif |
30271
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
928 } else |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
929 #endif /* ARCH_X86 && (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) */ |
30271
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
930 { |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
931 const int filterAlign= |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
932 (flags & SWS_CPU_CAPS_MMX) ? 4 : |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
933 (flags & SWS_CPU_CAPS_ALTIVEC) ? 8 : |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
934 1; |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
935 |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
936 if (initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc, |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
937 srcW , dstW, filterAlign, 1<<14, |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
938 (flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags, |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
939 srcFilter->lumH, dstFilter->lumH, c->param) < 0) |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
940 goto fail; |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
941 if (initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc, |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
942 c->chrSrcW, c->chrDstW, filterAlign, 1<<14, |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
943 (flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags, |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
944 srcFilter->chrH, dstFilter->chrH, c->param) < 0) |
2fad32dd128c
Don't initialize normal horizontal filter if MMX2 filter is used.
ramiro
parents:
30264
diff
changeset
|
945 goto fail; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
946 } |
28316 | 947 } // initialize horizontal stuff |
18861 | 948 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
949 /* precalculate vertical scaler filter coefficients */ |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
950 { |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
951 const int filterAlign= |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
952 (flags & SWS_CPU_CAPS_MMX) && (flags & SWS_ACCURATE_RND) ? 2 : |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
953 (flags & SWS_CPU_CAPS_ALTIVEC) ? 8 : |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
954 1; |
18861 | 955 |
29544 | 956 if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc, |
30045 | 957 srcH , dstH, filterAlign, (1<<12), |
958 (flags&SWS_BICUBLIN) ? (flags|SWS_BICUBIC) : flags, | |
959 srcFilter->lumV, dstFilter->lumV, c->param) < 0) | |
29544 | 960 goto fail; |
961 if (initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc, | |
30045 | 962 c->chrSrcH, c->chrDstH, filterAlign, (1<<12), |
963 (flags&SWS_BICUBLIN) ? (flags|SWS_BILINEAR) : flags, | |
964 srcFilter->chrV, dstFilter->chrV, c->param) < 0) | |
29544 | 965 goto fail; |
18861 | 966 |
30912
f91ad62a2281
AltiVec implies a PPC CPU, so there is no need to check for both.
diego
parents:
30910
diff
changeset
|
967 #if HAVE_ALTIVEC |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
968 FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof (vector signed short)*c->vLumFilterSize*c->dstH, fail); |
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
969 FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof (vector signed short)*c->vChrFilterSize*c->chrDstH, fail); |
18861 | 970 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
971 for (i=0;i<c->vLumFilterSize*c->dstH;i++) { |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
972 int j; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
973 short *p = (short *)&c->vYCoeffsBank[i]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
974 for (j=0;j<8;j++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
975 p[j] = c->vLumFilter[i]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
976 } |
18861 | 977 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
978 for (i=0;i<c->vChrFilterSize*c->chrDstH;i++) { |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
979 int j; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
980 short *p = (short *)&c->vCCoeffsBank[i]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
981 for (j=0;j<8;j++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
982 p[j] = c->vChrFilter[i]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
983 } |
18861 | 984 #endif |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
985 } |
18861 | 986 |
28316 | 987 // calculate buffer sizes so that they won't run out while handling these damn slices |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
988 c->vLumBufSize= c->vLumFilterSize; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
989 c->vChrBufSize= c->vChrFilterSize; |
29481 | 990 for (i=0; i<dstH; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
991 int chrI= i*c->chrDstH / dstH; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
992 int nextSlice= FFMAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1, |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
993 ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<c->chrSrcVSubSample)); |
18861 | 994 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
995 nextSlice>>= c->chrSrcVSubSample; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
996 nextSlice<<= c->chrSrcVSubSample; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
997 if (c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice) |
25749 | 998 c->vLumBufSize= nextSlice - c->vLumFilterPos[i]; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
999 if (c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>c->chrSrcVSubSample)) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1000 c->vChrBufSize= (nextSlice>>c->chrSrcVSubSample) - c->vChrFilterPos[chrI]; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1001 } |
18861 | 1002 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1003 // allocate pixbufs (we use dynamic allocation because otherwise we would need to |
29540 | 1004 // allocate several megabytes to handle all possible cases) |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
1005 FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail); |
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
1006 FF_ALLOC_OR_GOTO(c, c->chrPixBuf, c->vChrBufSize*2*sizeof(int16_t*), fail); |
28976 | 1007 if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
1008 FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize*2*sizeof(int16_t*), fail); |
28316 | 1009 //Note we need at least one pixel more at the end because of the MMX code (just in case someone wanna replace the 4000/8000) |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1010 /* align at 16 bytes for AltiVec */ |
29545 | 1011 for (i=0; i<c->vLumBufSize; i++) { |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
1012 FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i+c->vLumBufSize], VOF+1, fail); |
29542 | 1013 c->lumPixBuf[i] = c->lumPixBuf[i+c->vLumBufSize]; |
1014 } | |
29545 | 1015 for (i=0; i<c->vChrBufSize; i++) { |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
1016 FF_ALLOC_OR_GOTO(c, c->chrPixBuf[i+c->vChrBufSize], (VOF+1)*2, fail); |
29542 | 1017 c->chrPixBuf[i] = c->chrPixBuf[i+c->vChrBufSize]; |
1018 } | |
28976 | 1019 if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) |
29545 | 1020 for (i=0; i<c->vLumBufSize; i++) { |
29610
c35359578f8d
Rename CHECKED_ALLOC(Z) to FF_ALLOC(Z)_OR_GOTO and add context and label
ramiro
parents:
29609
diff
changeset
|
1021 FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i+c->vLumBufSize], VOF+1, fail); |
29542 | 1022 c->alpPixBuf[i] = c->alpPixBuf[i+c->vLumBufSize]; |
1023 } | |
18861 | 1024 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1025 //try to avoid drawing green stuff between the right end and the stride end |
26133
94cc4bac8cd0
Turn ancient V offset numerical constants into named ones.
michael
parents:
26028
diff
changeset
|
1026 for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, (VOF+1)*2); |
94cc4bac8cd0
Turn ancient V offset numerical constants into named ones.
michael
parents:
26028
diff
changeset
|
1027 |
26225 | 1028 assert(2*VOFW == VOF); |
18861 | 1029 |
27182
f7b6d1014b6b
Remove ASSERT() macro. SoC Patch from Keiji Costantini
lu_zero
parents:
27181
diff
changeset
|
1030 assert(c->chrDstH <= dstH); |
18861 | 1031 |
29481 | 1032 if (flags&SWS_PRINT_INFO) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1033 if (flags&SWS_FAST_BILINEAR) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1034 av_log(c, AV_LOG_INFO, "FAST_BILINEAR scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1035 else if (flags&SWS_BILINEAR) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1036 av_log(c, AV_LOG_INFO, "BILINEAR scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1037 else if (flags&SWS_BICUBIC) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1038 av_log(c, AV_LOG_INFO, "BICUBIC scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1039 else if (flags&SWS_X) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1040 av_log(c, AV_LOG_INFO, "Experimental scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1041 else if (flags&SWS_POINT) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1042 av_log(c, AV_LOG_INFO, "Nearest Neighbor / POINT scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1043 else if (flags&SWS_AREA) |
30262 | 1044 av_log(c, AV_LOG_INFO, "Area Averaging scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1045 else if (flags&SWS_BICUBLIN) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1046 av_log(c, AV_LOG_INFO, "luma BICUBIC / chroma BILINEAR scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1047 else if (flags&SWS_GAUSS) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1048 av_log(c, AV_LOG_INFO, "Gaussian scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1049 else if (flags&SWS_SINC) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1050 av_log(c, AV_LOG_INFO, "Sinc scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1051 else if (flags&SWS_LANCZOS) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1052 av_log(c, AV_LOG_INFO, "Lanczos scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1053 else if (flags&SWS_SPLINE) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1054 av_log(c, AV_LOG_INFO, "Bicubic spline scaler, "); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1055 else |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1056 av_log(c, AV_LOG_INFO, "ehh flags invalid?! "); |
18861 | 1057 |
30288
4ee0cedb32f2
Prefer "to %s%s" over "to%s %s", slightly more readable.
stefano
parents:
30287
diff
changeset
|
1058 av_log(c, AV_LOG_INFO, "from %s to %s%s ", |
30284
03f99130b7c3
Factorize code which logs the source and destination formats in
stefano
parents:
30275
diff
changeset
|
1059 sws_format_name(srcFormat), |
30287
67cace3e3df7
Simplify code in sws_getContext() which logs if the destination format
stefano
parents:
30285
diff
changeset
|
1060 #ifdef DITHER1XBPP |
30892
e052716dcb5b
Extend the generic path of the yuv2rgb converter with support for rgb444
cehoyos
parents:
30822
diff
changeset
|
1061 dstFormat == PIX_FMT_BGR555 || dstFormat == PIX_FMT_BGR565 || |
e052716dcb5b
Extend the generic path of the yuv2rgb converter with support for rgb444
cehoyos
parents:
30822
diff
changeset
|
1062 dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE || |
e052716dcb5b
Extend the generic path of the yuv2rgb converter with support for rgb444
cehoyos
parents:
30822
diff
changeset
|
1063 dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE ? "dithered " : "", |
30287
67cace3e3df7
Simplify code in sws_getContext() which logs if the destination format
stefano
parents:
30285
diff
changeset
|
1064 #else |
67cace3e3df7
Simplify code in sws_getContext() which logs if the destination format
stefano
parents:
30285
diff
changeset
|
1065 "", |
67cace3e3df7
Simplify code in sws_getContext() which logs if the destination format
stefano
parents:
30285
diff
changeset
|
1066 #endif |
30284
03f99130b7c3
Factorize code which logs the source and destination formats in
stefano
parents:
30275
diff
changeset
|
1067 sws_format_name(dstFormat)); |
18861 | 1068 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1069 if (flags & SWS_CPU_CAPS_MMX2) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1070 av_log(c, AV_LOG_INFO, "using MMX2\n"); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1071 else if (flags & SWS_CPU_CAPS_3DNOW) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1072 av_log(c, AV_LOG_INFO, "using 3DNOW\n"); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1073 else if (flags & SWS_CPU_CAPS_MMX) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1074 av_log(c, AV_LOG_INFO, "using MMX\n"); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1075 else if (flags & SWS_CPU_CAPS_ALTIVEC) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1076 av_log(c, AV_LOG_INFO, "using AltiVec\n"); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1077 else |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1078 av_log(c, AV_LOG_INFO, "using C\n"); |
18861 | 1079 |
29481 | 1080 if (flags & SWS_CPU_CAPS_MMX) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1081 if (c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1082 av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR MMX2 scaler for horizontal scaling\n"); |
29481 | 1083 else { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1084 if (c->hLumFilterSize==4) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1085 av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal luminance scaling\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1086 else if (c->hLumFilterSize==8) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1087 av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal luminance scaling\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1088 else |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1089 av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal luminance scaling\n"); |
18861 | 1090 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1091 if (c->hChrFilterSize==4) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1092 av_log(c, AV_LOG_VERBOSE, "using 4-tap MMX scaler for horizontal chrominance scaling\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1093 else if (c->hChrFilterSize==8) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1094 av_log(c, AV_LOG_VERBOSE, "using 8-tap MMX scaler for horizontal chrominance scaling\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1095 else |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1096 av_log(c, AV_LOG_VERBOSE, "using n-tap MMX scaler for horizontal chrominance scaling\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1097 } |
29481 | 1098 } else { |
28276 | 1099 #if ARCH_X86 |
28316 | 1100 av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n"); |
18861 | 1101 #else |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1102 if (flags & SWS_FAST_BILINEAR) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1103 av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR C scaler for horizontal scaling\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1104 else |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1105 av_log(c, AV_LOG_VERBOSE, "using C scaler for horizontal scaling\n"); |
18861 | 1106 #endif |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1107 } |
29481 | 1108 if (isPlanarYUV(dstFormat)) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1109 if (c->vLumFilterSize==1) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1110 av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1111 else |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1112 av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (YV12 like)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
29481 | 1113 } else { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1114 if (c->vLumFilterSize==1 && c->vChrFilterSize==2) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1115 av_log(c, AV_LOG_VERBOSE, "using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n" |
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1116 " 2-tap scaler for vertical chrominance scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1117 else if (c->vLumFilterSize==2 && c->vChrFilterSize==2) |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1118 av_log(c, AV_LOG_VERBOSE, "using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1119 else |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1120 av_log(c, AV_LOG_VERBOSE, "using n-tap %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1121 } |
18861 | 1122 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1123 if (dstFormat==PIX_FMT_BGR24) |
28316 | 1124 av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR24 converter\n", |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1125 (flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C")); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1126 else if (dstFormat==PIX_FMT_RGB32) |
28316 | 1127 av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR32 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1128 else if (dstFormat==PIX_FMT_BGR565) |
28316 | 1129 av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR16 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1130 else if (dstFormat==PIX_FMT_BGR555) |
28316 | 1131 av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
30892
e052716dcb5b
Extend the generic path of the yuv2rgb converter with support for rgb444
cehoyos
parents:
30822
diff
changeset
|
1132 else if (dstFormat == PIX_FMT_RGB444BE || dstFormat == PIX_FMT_RGB444LE || |
e052716dcb5b
Extend the generic path of the yuv2rgb converter with support for rgb444
cehoyos
parents:
30822
diff
changeset
|
1133 dstFormat == PIX_FMT_BGR444BE || dstFormat == PIX_FMT_BGR444LE) |
e052716dcb5b
Extend the generic path of the yuv2rgb converter with support for rgb444
cehoyos
parents:
30822
diff
changeset
|
1134 av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR12 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); |
26150
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1135 |
1df4a811aa9c
remove redundant SwScaler text since av_log uses AVClass context
bcoudurier
parents:
26134
diff
changeset
|
1136 av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); |
28316 | 1137 av_log(c, AV_LOG_DEBUG, "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1138 c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc); |
28316 | 1139 av_log(c, AV_LOG_DEBUG, "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1140 c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1141 } |
18861 | 1142 |
30369
8c479cb29c7a
Split swscale.c into scaler code (swscale.c) and utility code (utils.c).
ramiro
parents:
30343
diff
changeset
|
1143 c->swScale= ff_getSwsFunc(c); |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1144 return 0; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1145 fail: //FIXME replace things by appropriate error codes |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1146 return -1; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1147 } |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1148 |
32315
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1149 #if FF_API_SWS_GETCONTEXT |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1150 SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1151 int dstW, int dstH, enum PixelFormat dstFormat, int flags, |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1152 SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param) |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1153 { |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1154 SwsContext *c; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1155 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1156 if(!(c=sws_alloc_context())) |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1157 return NULL; |
29542 | 1158 |
32282
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1159 c->flags= flags; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1160 c->srcW= srcW; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1161 c->srcH= srcH; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1162 c->dstW= dstW; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1163 c->dstH= dstH; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1164 c->srcRange = handle_jpeg(&srcFormat); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1165 c->dstRange = handle_jpeg(&dstFormat); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1166 c->srcFormat= srcFormat; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1167 c->dstFormat= dstFormat; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1168 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1169 if (param) { |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1170 c->param[0] = param[0]; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1171 c->param[1] = param[1]; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1172 } else { |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1173 c->param[0] = |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1174 c->param[1] = SWS_PARAM_DEFAULT; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1175 } |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1176 sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->srcRange, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/, c->dstRange, 0, 1<<16, 1<<16); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1177 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1178 if(sws_init_context(c, srcFilter, dstFilter) < 0){ |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1179 sws_freeContext(c); |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1180 return NULL; |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1181 } |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1182 |
606e4157cd4c
Split alloc and init of context so that parameters can be set in the context
michael
parents:
32274
diff
changeset
|
1183 return c; |
18861 | 1184 } |
32315
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1185 #endif |
18861 | 1186 |
23129 | 1187 SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur, |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1188 float lumaSharpen, float chromaSharpen, |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1189 float chromaHShift, float chromaVShift, |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1190 int verbose) |
18861 | 1191 { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1192 SwsFilter *filter= av_malloc(sizeof(SwsFilter)); |
29542 | 1193 if (!filter) |
1194 return NULL; | |
18861 | 1195 |
29481 | 1196 if (lumaGBlur!=0.0) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1197 filter->lumH= sws_getGaussianVec(lumaGBlur, 3.0); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1198 filter->lumV= sws_getGaussianVec(lumaGBlur, 3.0); |
29481 | 1199 } else { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1200 filter->lumH= sws_getIdentityVec(); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1201 filter->lumV= sws_getIdentityVec(); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1202 } |
18861 | 1203 |
29481 | 1204 if (chromaGBlur!=0.0) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1205 filter->chrH= sws_getGaussianVec(chromaGBlur, 3.0); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1206 filter->chrV= sws_getGaussianVec(chromaGBlur, 3.0); |
29481 | 1207 } else { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1208 filter->chrH= sws_getIdentityVec(); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1209 filter->chrV= sws_getIdentityVec(); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1210 } |
18861 | 1211 |
29481 | 1212 if (chromaSharpen!=0.0) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1213 SwsVector *id= sws_getIdentityVec(); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1214 sws_scaleVec(filter->chrH, -chromaSharpen); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1215 sws_scaleVec(filter->chrV, -chromaSharpen); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1216 sws_addVec(filter->chrH, id); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1217 sws_addVec(filter->chrV, id); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1218 sws_freeVec(id); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1219 } |
18861 | 1220 |
29481 | 1221 if (lumaSharpen!=0.0) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1222 SwsVector *id= sws_getIdentityVec(); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1223 sws_scaleVec(filter->lumH, -lumaSharpen); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1224 sws_scaleVec(filter->lumV, -lumaSharpen); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1225 sws_addVec(filter->lumH, id); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1226 sws_addVec(filter->lumV, id); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1227 sws_freeVec(id); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1228 } |
18861 | 1229 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1230 if (chromaHShift != 0.0) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1231 sws_shiftVec(filter->chrH, (int)(chromaHShift+0.5)); |
18861 | 1232 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1233 if (chromaVShift != 0.0) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1234 sws_shiftVec(filter->chrV, (int)(chromaVShift+0.5)); |
18861 | 1235 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1236 sws_normalizeVec(filter->chrH, 1.0); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1237 sws_normalizeVec(filter->chrV, 1.0); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1238 sws_normalizeVec(filter->lumH, 1.0); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1239 sws_normalizeVec(filter->lumV, 1.0); |
18861 | 1240 |
28532
e5a0c2f38f96
Use sws_printVec2() instead of the deprecated sws_printVec().
stefano
parents:
28531
diff
changeset
|
1241 if (verbose) sws_printVec2(filter->chrH, NULL, AV_LOG_DEBUG); |
e5a0c2f38f96
Use sws_printVec2() instead of the deprecated sws_printVec().
stefano
parents:
28531
diff
changeset
|
1242 if (verbose) sws_printVec2(filter->lumH, NULL, AV_LOG_DEBUG); |
18861 | 1243 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1244 return filter; |
18861 | 1245 } |
1246 | |
29494 | 1247 SwsVector *sws_allocVec(int length) |
1248 { | |
1249 SwsVector *vec = av_malloc(sizeof(SwsVector)); | |
1250 if (!vec) | |
1251 return NULL; | |
1252 vec->length = length; | |
1253 vec->coeff = av_malloc(sizeof(double) * length); | |
1254 if (!vec->coeff) | |
1255 av_freep(&vec); | |
1256 return vec; | |
1257 } | |
1258 | |
29481 | 1259 SwsVector *sws_getGaussianVec(double variance, double quality) |
1260 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1261 const int length= (int)(variance*quality + 0.5) | 1; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1262 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1263 double middle= (length-1)*0.5; |
29494 | 1264 SwsVector *vec= sws_allocVec(length); |
18861 | 1265 |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1266 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1267 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1268 |
29481 | 1269 for (i=0; i<length; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1270 double dist= i-middle; |
30370
a8c94e9dc653
Don't redefine M_PI. It is already defined from libavutil/mathematics.h.
ramiro
parents:
30369
diff
changeset
|
1271 vec->coeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*M_PI); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1272 } |
18861 | 1273 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1274 sws_normalizeVec(vec, 1.0); |
18861 | 1275 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1276 return vec; |
18861 | 1277 } |
1278 | |
29481 | 1279 SwsVector *sws_getConstVec(double c, int length) |
1280 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1281 int i; |
29494 | 1282 SwsVector *vec= sws_allocVec(length); |
18861 | 1283 |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1284 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1285 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1286 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1287 for (i=0; i<length; i++) |
29494 | 1288 vec->coeff[i]= c; |
18861 | 1289 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1290 return vec; |
18861 | 1291 } |
1292 | |
29481 | 1293 SwsVector *sws_getIdentityVec(void) |
1294 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1295 return sws_getConstVec(1.0, 1); |
18861 | 1296 } |
1297 | |
30745
c5a49657b3e4
Make sws_dcVec static: It is only used inside libswscale/utils.c.
cehoyos
parents:
30688
diff
changeset
|
1298 static double sws_dcVec(SwsVector *a) |
29481 | 1299 { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1300 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1301 double sum=0; |
18861 | 1302 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1303 for (i=0; i<a->length; i++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1304 sum+= a->coeff[i]; |
18861 | 1305 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1306 return sum; |
18861 | 1307 } |
1308 | |
29481 | 1309 void sws_scaleVec(SwsVector *a, double scalar) |
1310 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1311 int i; |
18861 | 1312 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1313 for (i=0; i<a->length; i++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1314 a->coeff[i]*= scalar; |
18861 | 1315 } |
1316 | |
29481 | 1317 void sws_normalizeVec(SwsVector *a, double height) |
1318 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1319 sws_scaleVec(a, height/sws_dcVec(a)); |
18861 | 1320 } |
1321 | |
29481 | 1322 static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b) |
1323 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1324 int length= a->length + b->length - 1; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1325 int i, j; |
29493 | 1326 SwsVector *vec= sws_getConstVec(0.0, length); |
18861 | 1327 |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1328 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1329 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1330 |
29481 | 1331 for (i=0; i<a->length; i++) { |
1332 for (j=0; j<b->length; j++) { | |
29493 | 1333 vec->coeff[i+j]+= a->coeff[i]*b->coeff[j]; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1334 } |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1335 } |
18861 | 1336 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1337 return vec; |
18861 | 1338 } |
1339 | |
29481 | 1340 static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b) |
1341 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1342 int length= FFMAX(a->length, b->length); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1343 int i; |
29493 | 1344 SwsVector *vec= sws_getConstVec(0.0, length); |
1345 | |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1346 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1347 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1348 |
29493 | 1349 for (i=0; i<a->length; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; |
1350 for (i=0; i<b->length; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; | |
18861 | 1351 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1352 return vec; |
18861 | 1353 } |
1354 | |
29481 | 1355 static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b) |
1356 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1357 int length= FFMAX(a->length, b->length); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1358 int i; |
29493 | 1359 SwsVector *vec= sws_getConstVec(0.0, length); |
1360 | |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1361 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1362 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1363 |
29493 | 1364 for (i=0; i<a->length; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; |
1365 for (i=0; i<b->length; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; | |
18861 | 1366 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1367 return vec; |
18861 | 1368 } |
1369 | |
1370 /* shift left / or right if "shift" is negative */ | |
29481 | 1371 static SwsVector *sws_getShiftedVec(SwsVector *a, int shift) |
1372 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1373 int length= a->length + FFABS(shift)*2; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1374 int i; |
29493 | 1375 SwsVector *vec= sws_getConstVec(0.0, length); |
18861 | 1376 |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1377 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1378 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1379 |
29481 | 1380 for (i=0; i<a->length; i++) { |
29493 | 1381 vec->coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1382 } |
18861 | 1383 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1384 return vec; |
18861 | 1385 } |
1386 | |
29481 | 1387 void sws_shiftVec(SwsVector *a, int shift) |
1388 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1389 SwsVector *shifted= sws_getShiftedVec(a, shift); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1390 av_free(a->coeff); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1391 a->coeff= shifted->coeff; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1392 a->length= shifted->length; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1393 av_free(shifted); |
18861 | 1394 } |
1395 | |
29481 | 1396 void sws_addVec(SwsVector *a, SwsVector *b) |
1397 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1398 SwsVector *sum= sws_sumVec(a, b); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1399 av_free(a->coeff); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1400 a->coeff= sum->coeff; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1401 a->length= sum->length; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1402 av_free(sum); |
18861 | 1403 } |
1404 | |
29481 | 1405 void sws_subVec(SwsVector *a, SwsVector *b) |
1406 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1407 SwsVector *diff= sws_diffVec(a, b); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1408 av_free(a->coeff); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1409 a->coeff= diff->coeff; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1410 a->length= diff->length; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1411 av_free(diff); |
18861 | 1412 } |
1413 | |
29481 | 1414 void sws_convVec(SwsVector *a, SwsVector *b) |
1415 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1416 SwsVector *conv= sws_getConvVec(a, b); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1417 av_free(a->coeff); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1418 a->coeff= conv->coeff; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1419 a->length= conv->length; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1420 av_free(conv); |
18861 | 1421 } |
1422 | |
29481 | 1423 SwsVector *sws_cloneVec(SwsVector *a) |
1424 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1425 int i; |
29494 | 1426 SwsVector *vec= sws_allocVec(a->length); |
1427 | |
29501
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1428 if (!vec) |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1429 return NULL; |
a0ba51e33912
Check return values of sws_allocVec() and sws_getConstVec().
ramiro
parents:
29494
diff
changeset
|
1430 |
29494 | 1431 for (i=0; i<a->length; i++) vec->coeff[i]= a->coeff[i]; |
18861 | 1432 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1433 return vec; |
18861 | 1434 } |
1435 | |
29481 | 1436 void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level) |
1437 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1438 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1439 double max=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1440 double min=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1441 double range; |
18861 | 1442 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1443 for (i=0; i<a->length; i++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1444 if (a->coeff[i]>max) max= a->coeff[i]; |
18861 | 1445 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1446 for (i=0; i<a->length; i++) |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1447 if (a->coeff[i]<min) min= a->coeff[i]; |
18861 | 1448 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1449 range= max - min; |
18861 | 1450 |
29481 | 1451 for (i=0; i<a->length; i++) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1452 int x= (int)((a->coeff[i]-min)*60.0/range +0.5); |
28531
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1453 av_log(log_ctx, log_level, "%1.3f ", a->coeff[i]); |
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1454 for (;x>0; x--) av_log(log_ctx, log_level, " "); |
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1455 av_log(log_ctx, log_level, "|\n"); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1456 } |
18861 | 1457 } |
1458 | |
28531
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1459 #if LIBSWSCALE_VERSION_MAJOR < 1 |
29481 | 1460 void sws_printVec(SwsVector *a) |
1461 { | |
28531
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1462 sws_printVec2(a, NULL, AV_LOG_DEBUG); |
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1463 } |
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1464 #endif |
a14b65e14dc9
Implement sws_printVec2() and deprecate sws_printVec().
stefano
parents:
28520
diff
changeset
|
1465 |
29481 | 1466 void sws_freeVec(SwsVector *a) |
1467 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1468 if (!a) return; |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1469 av_freep(&a->coeff); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1470 a->length=0; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1471 av_free(a); |
18861 | 1472 } |
1473 | |
29481 | 1474 void sws_freeFilter(SwsFilter *filter) |
1475 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1476 if (!filter) return; |
18861 | 1477 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1478 if (filter->lumH) sws_freeVec(filter->lumH); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1479 if (filter->lumV) sws_freeVec(filter->lumV); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1480 if (filter->chrH) sws_freeVec(filter->chrH); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1481 if (filter->chrV) sws_freeVec(filter->chrV); |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1482 av_free(filter); |
18861 | 1483 } |
1484 | |
29481 | 1485 void sws_freeContext(SwsContext *c) |
1486 { | |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1487 int i; |
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1488 if (!c) return; |
18861 | 1489 |
29481 | 1490 if (c->lumPixBuf) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1491 for (i=0; i<c->vLumBufSize; i++) |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1492 av_freep(&c->lumPixBuf[i]); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1493 av_freep(&c->lumPixBuf); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1494 } |
18861 | 1495 |
29481 | 1496 if (c->chrPixBuf) { |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1497 for (i=0; i<c->vChrBufSize; i++) |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1498 av_freep(&c->chrPixBuf[i]); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1499 av_freep(&c->chrPixBuf); |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1500 } |
18861 | 1501 |
29481 | 1502 if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { |
28976 | 1503 for (i=0; i<c->vLumBufSize; i++) |
1504 av_freep(&c->alpPixBuf[i]); | |
1505 av_freep(&c->alpPixBuf); | |
1506 } | |
1507 | |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1508 av_freep(&c->vLumFilter); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1509 av_freep(&c->vChrFilter); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1510 av_freep(&c->hLumFilter); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1511 av_freep(&c->hChrFilter); |
30912
f91ad62a2281
AltiVec implies a PPC CPU, so there is no need to check for both.
diego
parents:
30910
diff
changeset
|
1512 #if HAVE_ALTIVEC |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1513 av_freep(&c->vYCoeffsBank); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1514 av_freep(&c->vCCoeffsBank); |
18861 | 1515 #endif |
1516 | |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1517 av_freep(&c->vLumFilterPos); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1518 av_freep(&c->vChrFilterPos); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1519 av_freep(&c->hLumFilterPos); |
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1520 av_freep(&c->hChrFilterPos); |
18861 | 1521 |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
1522 #if ARCH_X86 |
18861 | 1523 #ifdef MAP_ANONYMOUS |
29468
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
1524 if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize); |
947a942221c4
MMX2 horizontal scaler: Determine code size at runtime.
ramiro
parents:
29467
diff
changeset
|
1525 if (c->chrMmx2FilterCode) munmap(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize); |
28971
b8e356a9dbb1
Allocate executable memory with VirtualAlloc() in Windows.
ramiro
parents:
28970
diff
changeset
|
1526 #elif HAVE_VIRTUALALLOC |
30821
d59dfdf82fca
Fix memleak due to incorrect VirtualFree arguments: size must be 0 for MEM_RELEASE.
reimar
parents:
30814
diff
changeset
|
1527 if (c->lumMmx2FilterCode) VirtualFree(c->lumMmx2FilterCode, 0, MEM_RELEASE); |
d59dfdf82fca
Fix memleak due to incorrect VirtualFree arguments: size must be 0 for MEM_RELEASE.
reimar
parents:
30814
diff
changeset
|
1528 if (c->chrMmx2FilterCode) VirtualFree(c->chrMmx2FilterCode, 0, MEM_RELEASE); |
18861 | 1529 #else |
29465 | 1530 av_free(c->lumMmx2FilterCode); |
1531 av_free(c->chrMmx2FilterCode); | |
18861 | 1532 #endif |
29465 | 1533 c->lumMmx2FilterCode=NULL; |
1534 c->chrMmx2FilterCode=NULL; | |
30923
0be6ed163321
libswscale: Relicense almost all x86 assembler optimizations as LGPL.
diego
parents:
30912
diff
changeset
|
1535 #endif /* ARCH_X86 */ |
18861 | 1536 |
27299
4e57d47ee5db
Cleanup, use av_freep() instead of av_free(x); x=NULL
michael
parents:
27286
diff
changeset
|
1537 av_freep(&c->yuvTable); |
18861 | 1538 |
23155
1befc8d767cd
cosmetics attack, part II: Remove all tabs and prettyprint/reindent the code.
diego
parents:
23129
diff
changeset
|
1539 av_free(c); |
18861 | 1540 } |
1541 | |
19661
7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
gpoirier
parents:
19594
diff
changeset
|
1542 struct SwsContext *sws_getCachedContext(struct SwsContext *context, |
27695
9cf6c7c5c7cd
Change variable types from int to enum PixelFormat.
cehoyos
parents:
27686
diff
changeset
|
1543 int srcW, int srcH, enum PixelFormat srcFormat, |
9cf6c7c5c7cd
Change variable types from int to enum PixelFormat.
cehoyos
parents:
27686
diff
changeset
|
1544 int dstW, int dstH, enum PixelFormat dstFormat, int flags, |
29246
8861e08033eb
Add const qualifier to param argument of sws_getContext() and
diego
parents:
29245
diff
changeset
|
1545 SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param) |
19661
7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
gpoirier
parents:
19594
diff
changeset
|
1546 { |
25747 | 1547 static const double default_param[2] = {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT}; |
1548 | |
1549 if (!param) | |
1550 param = default_param; | |
1551 | |
31968
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
1552 flags = update_flags_cpu(flags); |
5c9310a4d2e9
swscale: also update flags on sws_getCachedContext()
ramiro
parents:
31903
diff
changeset
|
1553 |
30599
7c1fea45bfc8
Merge two if conditions, allow to decrese the level of indentation of
stefano
parents:
30478
diff
changeset
|
1554 if (context && |
30600
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1555 (context->srcW != srcW || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1556 context->srcH != srcH || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1557 context->srcFormat != srcFormat || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1558 context->dstW != dstW || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1559 context->dstH != dstH || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1560 context->dstFormat != dstFormat || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1561 context->flags != flags || |
e2935c75f1aa
Vertically align a list of comparisons in sws_getCachedContext().
stefano
parents:
30599
diff
changeset
|
1562 context->param[0] != param[0] || |
30601 | 1563 context->param[1] != param[1])) { |
1564 sws_freeContext(context); | |
1565 context = NULL; | |
1566 } | |
30599
7c1fea45bfc8
Merge two if conditions, allow to decrese the level of indentation of
stefano
parents:
30478
diff
changeset
|
1567 |
25752
559b0e9d47fb
Change (a == NULL) condition to (!a) and (a != NULL) condition to (a).
benoit
parents:
25750
diff
changeset
|
1568 if (!context) { |
32315
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1569 if (!(context = sws_alloc_context())) |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1570 return NULL; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1571 context->srcW = srcW; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1572 context->srcH = srcH; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1573 context->srcFormat = srcFormat; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1574 context->dstFormat = dstFormat; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1575 context->flags = flags; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1576 context->param[0] = param[0]; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1577 context->param[1] = param[1]; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1578 if (sws_init_context(context, srcFilter, dstFilter) < 0) { |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1579 sws_freeContext(context); |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1580 return NULL; |
549b1ad3f777
Deprecate sws_getContext(), use sws_alloc_context() and
stefano
parents:
32308
diff
changeset
|
1581 } |
19661
7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
gpoirier
parents:
19594
diff
changeset
|
1582 } |
7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
gpoirier
parents:
19594
diff
changeset
|
1583 return context; |
7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
gpoirier
parents:
19594
diff
changeset
|
1584 } |
7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
gpoirier
parents:
19594
diff
changeset
|
1585 |