Commit Graph

1032 Commits

Author SHA1 Message Date
Ronald S. Bultje 8283f90a52 swscale: handle unaligned buffers in yuv2plane1
The issue had been introduced in
c435653627

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2011-11-13 08:27:20 +01:00
Sean McGovern 124e56454d swscale: add padding to conversion buffer.
Altivec does unaligned reads from this buffer in
hscale_altivec_real(), and can thus read up to 16 bytes beyond
the end of the buffer. Therefore, add an extra 16 bytes of
padding at the end of the conversion buffer.

This fixes fate-lavfi-pixfmts_scale on AltiVec-enabled builds
under valgrind.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-11-11 07:44:35 -08:00
Ronald S. Bultje c435653627 swscale: write yuv2plane1 MMX/SSE2/SSE4/AVX functions. 2011-11-05 20:48:14 -07:00
Ronald S. Bultje 1deb08fcb6 swscale: align vertical filtersize by 2 on x86.
The vertical scaler handles 2 rows at a time and thus requires
alignment by 2, or else it'll read invalid memory and result in
corrupt output.
2011-11-05 07:06:38 -07:00
Ronald S. Bultje 9e66b892e8 swscale: add missing colons to x86 assembly yuv2planeX.
This fixes assembling using "nasm".
2011-10-23 09:44:03 -07:00
Ronald S. Bultje f48b12e0a6 swscale: update altivec yuv2planeX asm to new per-plane API. 2011-10-22 10:35:14 -07:00
Ronald S. Bultje 6cacecdca3 swscale: make yuv2yuvX_10_sse2/avx 8/9/16-bits aware.
Also implement MMX/MMX2 versions and SSE4 versions.
2011-10-22 10:35:14 -07:00
Kieran Kunhya 7fbbf95293 yuv2planeX10 SIMD
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-10-22 10:35:14 -07:00
Ronald S. Bultje 109f62e8f8 swscale: decide whether to use yuv2plane1/X on a per-plane basis. 2011-10-22 10:35:14 -07:00
Ronald S. Bultje f99654d470 swscale: reintroduce full precision in 16-bit output. 2011-10-22 10:35:14 -07:00
Kieran Kunhya ff7913aef1 Split up yuv2yuvX functions
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-10-22 10:35:13 -07:00
Kieran Kunhya 34e8d147b3 Split out yuv2yuv1 luma and chroma in order to make them generic DSP functions
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-10-22 10:35:13 -07:00
Mans Rullgard 41ac093f7e swscale: fix signed shift overflows in ff_yuv2rgb_c_init_tables()
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-10-21 20:56:59 +01:00
Ronald S. Bultje dc49bf1270 sws/pixfmt/pixdesc: add support for yuv420p9le/be. 2011-10-21 00:58:01 -07:00
Ronald S. Bultje 8305041e13 swscale: prevent overflow in coefficient calculation. 2011-10-21 00:14:11 -07:00
Ronald Bultje d1d421cbc0 swscale: prevent overflow during initialization
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
2011-10-18 10:29:49 +02:00
Anton Khirnov 145f741e11 AVOptions: rename FF_OPT_TYPE_* => AV_OPT_TYPE_* 2011-10-12 16:51:16 +02:00
Anton Khirnov 04de1569cd sws: support yuv444p9/10 output. 2011-10-12 08:27:30 +02:00
Ronald S. Bultje 6aa3cac6bf swscale: use aligned move for storage into temporary buffer.
The intermediate buffer is always aligned.
2011-10-11 07:50:48 -07:00
Mans Rullgard d853e571ad ppc: fix some pointer to integer casts
Use uintptr_t instead of plain int.  Without this change, the
comparisons will come out wrong for pointers in certain ranges.
Fixes random failures on ppc64.  Also fixes some compiler warnings.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-09-25 18:33:38 +01:00
Kieran Kunhya 4d4d0e8176 Fix unnecessary shift with 9/10bit vertical scaling
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-09-23 02:13:30 +02:00
Ronald S. Bultje ea540401d6 swscale: fix byte overreads in SSE-optimized hscale().
SSE-optimized hScale() scales up to 4 pixels at once, so we need to
allocate up to 3 padding pixels to prevent overreads. This fixes
valgrind errors in various swscale-tests on fate.
2011-09-15 07:30:46 -07:00
Ronald S. Bultje e0c3e07387 sws: implement MMX/SSE2/SSSE3/SSE4 versions for horizontal scaling.
Speed: from 3.9x to 9.6x speed improvement over C, and some small
(up to 15%) speed improvements over existing MMX code (particularly
for bigger filters).
2011-09-13 09:53:42 -07:00
Anton Khirnov fb4ca26bdb lavf,lavc,sws: add {avcodec,avformat,sws}_get_class() functions. 2011-09-03 20:53:35 +02:00
Ronald S. Bultje 3f04ab4fcd swscale: split hScale() function pointer into h[cy]Scale().
This allows using more specific implementations for chroma/luma, e.g.
we can make assumptions on filterSize being constant, thus avoiding
that test at runtime.
2011-08-17 20:56:06 -07:00
Luca Barbato 3304a1e69a swscale: add dithering to yuv2yuvX_altivec_real
It just does that part in scalar form, I doubt using a vector store
over 2 array would speed it up particularly.

The function should be written to not use a scratch buffer.
2011-08-13 00:06:04 +02:00
Ronald S. Bultje 28c1115a91 swscale: use 15-bit intermediates for 9/10-bit scaling. 2011-08-12 11:54:25 -07:00
Stefano Sabatini 6a92551234 lsws: remove optimization debug logs in sws_init_context()
The logged information is possibly false, and it tends to be outdated
after each change since the logging code needs to be manually updated.

Simplify and prevent confusing wrong debug messages.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2011-08-05 00:45:06 +02:00
Stefano Sabatini 347167ecf5 lsws: use array for storing the supported in/out information
Also remove the unnecessary isSupportedIn/Out macros.

Make the code more compact/readable, and simplify the access to
lsws-specific pixel format information.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2011-08-05 00:44:11 +02:00
Ronald S. Bultje 62ee0e6a97 Revert "swscale: use 15-bit intermediates for 9/10-bit scaling."
This reverts commit ac0fb59348. It
causes valgrind errors which I'll want to investigate before
resubmitting this.
2011-08-02 12:27:43 -07:00
Ronald S. Bultje ac0fb59348 swscale: use 15-bit intermediates for 9/10-bit scaling. 2011-08-02 10:34:02 -07:00
Kostya Shishkov 42ba12888b Do not convert RGB buffer at once when stride does not fit exact samples.
When converting RGB format to RGB format with the same bits per sample,
unscaled path performs conversion on the whole buffer at once. For
non-multiple-of-16 BGR24 to RGB24 conversion it means that padding at the
end of line will be converted too. Since it may be of arbitrary length
(e.g. 8 bytes), operating on the whole buffer produces obviously wrong
results.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-07-30 09:51:23 -07:00
Joseph Artsimovich eedb1f2034 swscale: mark YUV422P10(LE,BE) as supported for output
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-21 02:10:31 +01:00
Ronald S. Bultje baba2eedac swscale: extend mmx padding.
Fixes a crash when forcing libc to strictly adhere to malloc sizes.
2011-07-14 13:27:06 -07:00
Ronald S. Bultje 55eda370cb swscale: clip unscaled colorspace conversion path.
Prevents overflows on very bright scenes when adding dither,
which may lead to black dots.
2011-07-14 13:27:06 -07:00
Diego Biurrun 96c1e6d40d doxygen: Make sure parameter names match between .c and .h files. 2011-07-14 04:09:49 +02:00
Anton Mitrofanov 142e76f105 swscale: fix crash with dithering due incorrect offset calculation.
ptrdiff_t can be 4 bytes, which leads to the next element being 4-byte
aligned and thus at a different offset than intended. Forcing 8-byte
alignment forces equal offset of dither16/32 on x86-32 and x86-64.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-07-10 14:52:21 -07:00
Ronald S. Bultje 5c391a161a swscale: rename uv_off/uv_off2 to uv_off_px/byte. 2011-07-08 15:15:31 -07:00
Ronald S. Bultje 1ce724ee39 swscale: implement error dithering in planarCopyWrapper.
Based on a somewhat similar idea in FFmpeg's swscale.
2011-07-08 15:15:31 -07:00
Ronald S. Bultje 4e3e333a79 swscale: error dithering for 16/9/10-bit to 8-bit.
Based on a somewhat similar idea in FFmpeg's swscale copy.
2011-07-08 15:15:30 -07:00
Ronald S. Bultje 7d7bacf0f1 swscale: fix overflow in 16-bit vertical scaling.
We operated on 31-bits, but with e.g. lanczos scaling, values can
add up to beyond 0x80000000, thus leading to output of zeroes. Drop
one bit of precision fixes this.
2011-07-08 15:15:30 -07:00
Ronald S. Bultje bf2cba4532 swscale: fix crash in 8-bpc bilinear output without alpha.
We accessed the alpha array even it wasn't used and didn't
exist, hence leading to a NULL pointer segfault.
2011-07-08 15:15:30 -07:00
Ronald S. Bultje f44d50a94c swscale: fix 16-bit horizontal scaling underflow.
When using e.g. lanczos scaling, values can drop below 0, so they
should never be unsigned.
2011-07-08 15:15:30 -07:00
Ronald S. Bultje 42d622fab3 swscale: fix 16-bit scaling when output is 8-bits.
We would use the second half of the U plane buffer, rather than the
V plane buffer, to output the V plane pixels.
2011-07-08 15:15:30 -07:00
Ronald S. Bultje f28aaae1c5 swscale: amend documentation to mention use of native depth for scaling.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-07-06 03:33:36 +02:00
Diego Biurrun e589e4b82d Remove unused static tables and static inline functions. 2011-07-04 14:59:35 +02:00
Mans Rullgard abc78a5a7c Do not include log.h in avutil.h
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-03 21:42:07 +01:00
Mans Rullgard d49ea4afb4 Do not include pixfmt.h in avutil.h
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-03 21:42:07 +01:00
Diego Biurrun 01c17c88ed doxygen: Remove spurious documentation for non-existing function parameters. 2011-07-03 18:30:02 +02:00
Ronald S. Bultje 8f440223f6 swscale: disable full_chroma_int when converting to non-24/32bpp RGB.
This functionality is only implemented for RGB24/32 and causes crashes
otherwise.
2011-07-02 08:33:52 -07:00
Ronald S. Bultje 8a8d0ce208 swscale: for >8bit scaling, read in native bit-depth.
For 9/10bit, it means we don't have to upscale to 16bit before
actual scaling or pixel format conversion, and thus a performance
gain.
2011-07-01 09:08:26 -07:00
Ronald S. Bultje 81cc7d0bd1 swscale: fix another yuv range conversion overflow in 16bit scaling. 2011-06-30 07:05:52 -07:00
Mohamed Naufal 705b21a06e swscale: Unbreak build with --enable-small
This fixes building with --enable-small, by using the correct
variable name.

Signed-off-by: Martin Storsjö <martin@martin.st>
2011-06-30 11:58:38 +03:00
Ronald S. Bultje e0b8fff6c7 swscale: fix yuv range correction when using 16-bit scaling. 2011-06-29 21:04:45 -07:00
Ronald S. Bultje ef1ee362b3 swscale: implement >8bit scaling support.
This means that precision is retained when scaling between sample
formats with >8 bits per component (48bit RGB, 16bit grayscale,
9/10/16bit YUV).
2011-06-29 09:45:52 -07:00
Ronald S. Bultje 4578435f35 swscale: Add Doxygen for hyscale_fast/hScale. 2011-06-29 01:20:34 +02:00
Mans Rullgard 635930d466 PPC: swscale: disable altivec functions for unsupported formats
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-06-28 23:22:31 +01:00
Ronald S. Bultje d6cc6ac6b8 swscale: Add Doxygen for yuv2planar*/yuv2packed* functions. 2011-06-28 20:18:58 +02:00
Mans Rullgard 57b4a3dd2b build: include sub-makefiles using full path instead of symlinks
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-06-28 18:15:19 +01:00
Ronald S. Bultje 13a099799e swscale: change prototypes of scaled YUV output functions.
Remove unused variables "flags" and "dstFormat" in yuv2packed1,
merge source rows per plane for yuv2packed[12], and make every
source argument int16_t (some where invalidly set to uint16_t).
This prevents stack pollution and is part of the Great Evil Plan
to simplify swscale.
2011-06-27 21:24:44 -07:00
Ronald S. Bultje dff5a83532 swscale: re-add support for non-native endianness.
This works through some non-obvious hacks in utils.c.
2011-06-27 18:10:41 -07:00
Ronald S. Bultje 3d3c814937 swscale: disentangle yuv2rgbX_c_full() into small functions.
This is part of the Great Evil Plan to simplify swscale.
2011-06-27 18:10:24 -07:00
Ronald Bultje 6fba14eecb swscale: split yuv2packed[12X]_c() remainders into small functions.
This is part of the Great Evil Plan to simplify swscale.
2011-06-27 18:10:03 -07:00
Ronald S. Bultje dc179ec819 swscale: split yuv2packedX_altivec in smaller functions.
This will likely lead to a considerable performance boost,
since it removes a branch from the inner loop. Part of the
Great Evil Plan to simplify swscale.
2011-06-27 18:05:16 -07:00
Ronald S. Bultje 0d994b2f45 swscale: don't use planar output functions to write to NV12/21.
This prevents a crash when converting to NV12/21 without the bitexact
flags enabled.
2011-06-27 17:15:41 -07:00
Ronald S. Bultje 97535ffb97 swscale: remove unused xInc/srcW arguments from hScale(). 2011-06-26 14:41:44 -07:00
Diego Biurrun a6213f3dce build: Remove redundant config.mak includes from subdirectory Makefiles.
Calling Make from subdirectories is not supported and config.mak has
multiple inclusion guards anyway, so the top-level include is enough.
2011-06-25 13:02:51 +02:00
Diego Biurrun 087d93f568 swscale: Remove unused variable from ff_bfin_get_unscaled_swscale(). 2011-06-21 20:53:52 +02:00
Reinhard Tartler 0793531859 Bump major version for b8e893399f
On architectures such as x86 (both 32 bit and 64bit), the stack element
size is fixed, which maintains alignment.  Here, this change does not
break anything. However, we also support also other architectures where
this property is not maintained and therefore, applications will crash
horribly.

This change effectively forces all applications to be recompiled against
libswscale.
2011-06-20 18:01:39 +02:00
Janne Grunau 3636e791ec swscale: use SwsContext for av_log when available
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2011-06-15 13:20:20 +02:00
Diego Biurrun a60466dbc3 swscale: Remove HAVE_MMX from files that are only compiled with MMX enabled. 2011-06-15 01:18:10 +02:00
Diego Biurrun 97e057ff81 swscale: Fix compilation with --disable-mmx2.
Some MMX2 functions were being referenced without proper #ifdefs.
2011-06-15 01:17:59 +02:00
Ronald S. Bultje 4e05830205 swscale: remove misplaced comment.
The comment should have been placed only in
yuv2rgb48_X_c_template, not yuv2rgb48_1_c_template.
2011-06-14 16:55:24 -04:00
Ronald S. Bultje 9f63211175 swscale: split out RGB48 output functions from yuv2packed[12X]_c().
This is part of the Great Evil Plan to simplify swscale. Note that
you'll see some code duplication between the output functions for
different RGB variants, and even between packed-YUV and RGB
variants. This is intentional because it improves readability.
2011-06-14 15:59:14 -04:00
Michael Niedermayer 0af8a71d66 swscale: fix JPEG-range YUV scaling artifacts.
YUV planes were marked as uint16_t, but they contained signed data.
Fixes issue 1108 and 675.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-06-14 09:46:49 -04:00
Ronald S. Bultje 103278f7b0 libavutil/swscale: YUV444P10/YUV444P9 support.
Also add missing glue code for recently added YUV422P10 formats
to swscale.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-06-10 15:12:24 -04:00
Ronald S. Bultje af2faf2076 swscale: split YUYV output out of yuv2packed[12X]_c().
This is part of the Great Evil Plan to simplify swscale.
2011-06-09 20:52:38 -04:00
Ronald S. Bultje 6b105e3ee6 swscale: extract monowhite/black output from yuv2packed[12X]_c().
This is part of the Great Evil Plan to simplify swscale.
2011-06-09 16:47:45 -04:00
Ronald S. Bultje 6d4d483eee swscale: de-macro'ify RGB15/16/32 input functions.
Inline functions are easier to read, maintain, modify and test,
which justifies the slightly increased source size. This patch
also adds support for non-native endianness RGB15/16 and fixes
isSupportedOutput() to no longer claim that we support writing
non-native RGB565/555/444.
2011-06-09 16:47:45 -04:00
Ronald S. Bultje e2babb9b47 swscale: rearrange code.
This way the code in the file is less cluttered all-over-the-
place.
2011-06-09 16:47:45 -04:00
Ronald S. Bultje dbd3183935 swscale: change 48bit RGB input macros to inline functions.
Inline functions are slightly larger in source code, but
are easier to handle in source code editors. The binary code
generated is the same.
2011-06-09 09:29:20 -04:00
Ronald S. Bultje f30ee65700 swscale: change 9/10bit YUV input macros to inline functions.
Inline functions are slightly larger in source code, but
are easier to handle in source code editors. The binary code
generated is the same.
2011-06-09 09:29:03 -04:00
Ronald S. Bultje aa39f5f6d6 swscale: extract gray16 output functions from yuv2packed[12X]().
This is part of the Great Evil Plan to simplify swscale.
2011-06-09 09:29:02 -04:00
Ronald S. Bultje f1e0b90c64 swscale: use standard clipping functions.
This generates better code on some non-x86 architectures.
2011-06-09 09:27:51 -04:00
Ronald S. Bultje e458b53605 swscale: merge macros that are used only once.
This reduces source code size without affecting the binary.
2011-06-09 09:26:00 -04:00
Ronald S. Bultje 6e5a8d3c9a swscale: fix function declarations in swscale.c.
Remove inline keyword from functions that are never inlined.
Use av_always_inline for functions that should be force-inlined
for performance reasons. Use av_cold for init functions.
2011-06-09 09:25:59 -04:00
Ronald S. Bultje a27db4c349 swscale: fix function declaration keywords in x86/swscale_template.c.
Remove inline keyword for functions that are only called through
their function pointers (and thus cannot be inlined); add av_cold
keyword to init function, and use av_always_inline instead of
inline for functions that must be inlined for performance reasons.
2011-06-09 09:25:59 -04:00
Ronald S. Bultje 9bcbb250e2 swscale: fix types of assembly arguments.
This prevents the following compiler warnings: "warning:
initialization from incompatible pointer type". Since the
variables are only ever used in inline assembly, their type
is actually irrelevant (so the part where it was wrong did
not invoke any buggy behaviour).
2011-06-08 11:39:26 -04:00
Ronald S. Bultje 496d95c34c swscale: move two macros that are only used once into caller.
This way, they look like regular code, which is easier to
understand.
2011-06-08 11:33:46 -04:00
Ronald S. Bultje 9d84dfce93 swscale: remove unused function.
Use of this wrapper was removed in a previous patch, but I
forgot to actually remove the function itself.
2011-06-08 11:08:20 -04:00
Ronald S. Bultje edeb56fa31 swscale: remove duplicate conversion routine in swScale(). 2011-06-07 10:05:55 -04:00
Ronald S. Bultje b73fe70025 swscale: add yuv2planar/packed function typedefs. 2011-06-07 10:05:55 -04:00
Ronald S. Bultje df91d09174 swscale: integrate yuv2nv12X_C into yuv2yuvX() function pointers. 2011-06-07 10:05:54 -04:00
Ronald S. Bultje 0fb5193156 swscale: reindent x86 init code. 2011-06-07 10:05:50 -04:00
Ronald S. Bultje ca364a5b43 swscale: extract SWS_FULL_CHR_H_INT conditional into init code. 2011-06-07 10:03:47 -04:00
Ronald S. Bultje b3b28b080f swscale: cosmetics. 2011-06-07 10:03:46 -04:00
Ronald S. Bultje ea28175312 swscale: remove alp/chr/lumSrcOffset.
They are hacks added to reuse the same scaling function for
different formats and they may cause problems when SIMD
implementation of the same functions are used along with pure
C functions.
2011-06-07 10:03:18 -04:00
Ronald S. Bultje bda9b20fa4 swscale: un-special-case yuv2yuvX16_c().
Make yuv2yuvX16_c a function pointer for yuv2yuvX(), so that the
function pointer becomes bitdepth-independent.
2011-06-07 10:03:12 -04:00
Ronald S. Bultje 6af2801088 swscale: split swscale.c in unscaled and generic conversion routines.
This duplicates the function fillPlane().
2011-06-03 09:52:09 -07:00
Ronald S. Bultje 2762ee3034 swscale: cosmetics.
Remove duplicate "inC" and "_c" functions that do the same thing;
give each function that handles data and acts as a function pointer
a "_c" suffix; remove "_c" suffix from functions that are inherently
not optimizable. Remove inline keyword from functions that are only
used through function pointers.
2011-06-03 09:52:09 -07:00