aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* swscale: add support for new 10/12 bit MSB formatsTimo Rothenpieler2025-07-111-0/+2
|
* swscale/utils: Fix potential race when initializing xyz tablesAndreas Rheinhardt2025-05-271-22/+31
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/utils: split off format code into new fileNiklas Haas2025-03-141-559/+0
| | | | | | | | | | utils.c is getting quite crowded, and I need a new place to dump a lot of format handling code for the ongoing rewrite. Rather than bloating this file even more, start splitting format handling helpers off into a new file. This also renames the existing utils.h header, which didn't really contain anything except the SwsFormat definition anyway (the prototypes for what should have been in utils.h are all still in the legacy swscale_internal.h).
* swscale/input: add support for UYYVYY411James Almer2025-03-131-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add support for YAF16 and YAF32James Almer2025-03-101-0/+4
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale: 16bit planar float input supportMichael Niedermayer2025-01-211-0/+8
| | | | | Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/cms,graph,lut3d: Use ff_-prefix, don't export internal functionsAndreas Rheinhardt2025-01-121-1/+1
| | | | | | | Symbols with the sws_* prefix are exported. Reviewed-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* swscale/utils: lazily allocate XYZ tables on CONFIG_SMALLNiklas Haas2024-12-261-5/+21
| | | | | | | This has the downside of requiring these tables to be recomputed on every init, but saves ~270 kB of static data. Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale/utils: add return code to fill_xyztables()Niklas Haas2024-12-261-7/+14
| | | | | | Needed for lazy allocation of XYZ tables. Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: use 16-bit intermediate precision for RGB/XYZ conversionNiklas Haas2024-12-261-7/+12
| | | | | | | | | | | | | | The current logic uses 12-bit linear light math, which is woefully insufficient and leads to nasty postarization artifacts. This patch simply switches the internal logic to 16-bit precision. This raises the memory requirement of these tables from 32 kB to 272 kB. All relevant FATE tests updated for improved accuracy. Fixes: #4829 Signed-off-by: Niklas Haas <git@haasn.dev> Sponsored-by: Sovereign Tech Fund
* swscale/utils: fix XYZ primaries taggingNiklas Haas2024-12-231-1/+1
| | | | | | | | | | | Swscale currently handles XYZ by embedding a forced conversion to BT.709 RGB with a hardcoded matrix. This is not ideal, but to preserve the status quo and avoid any unexpected changes in behavior, this patch merely fixes the inferred primaries tag to match the reality. In the future, I would like to handle XYZ properly, via direct conversion to the target colorspace (or possibly simply by using a more fitting RGB intermediate like SMPTE428), but for now just keep the status quo.
* swscale/utils: add helper function to infer colorspace metadataNiklas Haas2024-12-231-0/+66
| | | | | | | | | | | | | Logic is loosely on equivalent decisions in libplacebo. The basic idea is to try and be a bit conservative by treating AVCOL_*_UNSPECIFIED as a no-op, unless the other primaries set are non-standard / wide-gamut or HDR. This helps avoid unintended or unexpected colorspace conversions, while forcing it in cases where we are almost certain it is needed. The major departure from libplacebo semantics is that we no default to a 1000:1 contrast ration for SDR displays, instead modelling them as idealized devices with an infinite contrast ratio. In either case, setting SWS_STRICT overrides this behavior in favor of always requiring explicit colorspace metadata.
* swscale/utils: read dynamic HDR10+ metadata from AVFrameNiklas Haas2024-12-231-0/+50
| | | | | | | | Logic ported from libplacebo's AVFrame helpers. The basic idea is to use the provided MaxRGB/MaxSCL values to infer what the actual luminance would have been, which HDR10+ metadata does not provide directly. It's worth pointing out that this gives us an *upper* bound on the true maximum luminance, so any error in the estimation cannot result in clipping.
* swscale/utils: read HDR mastering metadata from AVFrameNiklas Haas2024-12-231-0/+25
|
* swscale/utils: set static/implied HDR metadataNiklas Haas2024-12-231-0/+17
| | | | Provide default values for the fields added in the previous commit.
* swscale/utils: add HDR metadata to SwsFormatNiklas Haas2024-12-231-12/+16
| | | | | | | | Only add the condensed values that we actually care about. Group them into a new struct to make it easier to discard or replace this metadata. Define a special comparison function that does not choke on undefined/unknown metadata.
* swscale/utils: check for supported color transfersNiklas Haas2024-12-231-2/+4
| | | | | We will use the av_csp_itu_eotf() functions to decode these internally, so check this function to see if it succeeds.
* swscale/utils: fix sws_getCachedContext checkNiklas Haas2024-12-181-8/+8
| | | | | | | | | This logic was inverted, but || was not replaced by &&. Fixes: ed5dd675624c83d9c69b406ce30e4e09f29970e3 Fixes: ticket #11353 Signed-off-by: Niklas Haas <git@haasn.dev> Sponsored-by: Sovereign Tech Fund
* swscale/utils: disable full_chr_h_input optimization for odd widthNiklas Haas2024-12-041-1/+1
| | | | | | | | | | | | | | | | | The basic problem here is that the rgb*ToUV_half_* functions hard-code a bilinear downsample from src[i] + src[i+1], with no bounds check on the i+1 access. Due to the signature of the function, we cannot easily plumb the "true" width into the function body to perform a bounds check. Similarly, we cannot easily pre-pad the input because it is typically reading from the (const) input frame, which would require a full memcpy to pad. Either of these solutions are more trouble than the feature is worth, so just disable it on odd input sizes. Fixes: use of uninitialized value Fixes: ticket #11265 Signed-off-by: Niklas Haas <git@haasn.dev> Sponsored-by: Sovereign Tech Fund
* swscale: introduce new, dynamic scaling APINiklas Haas2024-11-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | As part of a larger, ongoing effort to modernize and partially rewrite libswscale, it was decided and generally agreed upon to introduce a new public API for libswscale. This API is designed to be less stateful, more explicitly defined, and considerably easier to use than the existing one. Most of the API work has been already accomplished in the previous commits, this commit merely introduces the ability to use sws_scale_frame() dynamically, without prior sws_init_context() calls. Instead, the new API takes frame properties from the frames themselves, and the implementation is based on the new SwsGraph API, which we simply reinitialize as needed. This high-level wrapper also recreates the logic that used to live inside vf_scale for scaling interlaced frames, enabling it to be reused more easily by end users. Finally, this function is designed to simply copy refs directly when nothing needs to be done, substantially improving throughput of the noop fast path. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale/internal: expose sws_init_single_context() internallyNiklas Haas2024-11-251-4/+4
| | | | | | | Used by the graph API swscale wrapper, for now. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: eliminate redundant SwsInternal accessesNiklas Haas2024-11-251-119/+114
| | | | | | | | This is a purely cosmetic commit aimed at replacing accesses to SwsInternal.opts by direct access to SwsContext wherever convenient. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: expose SwsContext publiclyNiklas Haas2024-11-251-68/+55
| | | | | | | | | | Following in the footsteps of the work in the previous commit, it's now relatively straightforward to expose the options struct publicly as SwsContext. This is a step towards making this more user friendly, as well as following API conventions established elsewhere. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale/internal: group user-facing options togetherNiklas Haas2024-11-211-133/+142
| | | | | | | | This is a preliminary step to separating these into a new struct. This commit contains no functional changes, it is a pure search-and-replace. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale/internal: use static_assert for enforcing offsetsNiklas Haas2024-11-211-2/+0
| | | | | | | Instead of sprinkling av_assert0 into random init functions. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* fate/pixfmts: extend the high bit depth testJames Almer2024-11-061-1/+1
| | | | | | Also test 8bit formats, and try bitdepth conversion paths. Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/output: add full chroma interpolation support for x2rgb10James Almer2024-11-021-1/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/range_convert: call arch-specific init functions from main init functionRamiro Polla2024-10-271-9/+1
| | | | | This commit also fixes the issue that the call to ff_sws_init_range_convert() from sws_init_swscale() was not setting up the arch-specific optimizations.
* swscale/output: add XV48 output supportJames Almer2024-10-261-2/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add XV48 input supportJames Almer2024-10-261-0/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale: rename SwsContext to SwsInternalNiklas Haas2024-10-241-54/+63
| | | | | | | | | | | | | | | | | | | | | | | | And preserve the public SwsContext as separate name. The motivation here is that I want to turn SwsContext into a public struct, while keeping the internal implementation hidden. Additionally, I also want to be able to use multiple internal implementations, e.g. for GPU devices. This commit does not include any functional changes. For the most part, it is a simple rename. The only complications arise from the public facing API functions, which preserve their current type (and hence require an additional unwrapping step internally), and the checkasm test framework, which directly accesses SwsInternal. For consistency, the affected functions that need to maintain a distionction have generally been changed to refer to the SwsContext as *sws, and the SwsInternal as *c. In an upcoming commit, I will provide a backing definition for the public SwsContext, and update `sws_internal()` to dereference the internal struct instead of merely casting it. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: add sws_is_noop()Niklas Haas2024-10-231-0/+14
| | | | | | | Exactly what it says on the tin. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: add new frame testing APINiklas Haas2024-10-231-0/+68
| | | | | | | | | | | | Replacing the old sws_isSupported* API with a more consistent family of functions that follows the same signature and naming convention, including a placeholder for testing the color space parameters that we don't currently implement conversions for. These functions also perform some extra basic sanity checking. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale/utils: add SwsFormat abstraction and helpersNiklas Haas2024-10-231-0/+64
| | | | | | | | | | | | | | | | | | Groups together all relevant color metadata from an AVFrame. While we could use AVFrame directly, keeping it a separate struct has three advantages: 1. Functions accepting an SwsFormat will definitely not care about the data pointers. 2. It clearly separates sanitized and raw metadata, since the function to construct an SwsFormat from an AVFrame will also sanitize. 3. It's slightly more lightweight to pass around. Move these into a new header file "utils.h" to avoid crowding swscale_internal.h even more, and also to solve a circular dependency issue down the line. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: add sws_free_context()Niklas Haas2024-10-231-0/+10
| | | | | | | | Merely a convenience wrapper around sws_freeContext(). The name change is for parity with the other sws_* functions. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale: publicly typedef struct SwsContextNiklas Haas2024-10-231-7/+7
| | | | | | | | Slightly more convenient, especially for the upcoming refactor which will turn SwsContext into a public struct. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
* swscale/output: add Y216LE output supportJames Almer2024-10-231-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add Y216LE input supportJames Almer2024-10-231-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/output: add AYUV64BE output supportJames Almer2024-10-171-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add AYUV64BE input supportJames Almer2024-10-171-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/output: add X36VBE output supportJames Almer2024-10-171-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add X36VBE input supportJames Almer2024-10-171-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add input support for RGBF16Martin Schitter2024-10-141-0/+2
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/input: add input support for RGBF32Martin Schitter2024-10-141-0/+2
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* swscale/output: add V30X output supportJames Almer2024-10-121-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/output: add VYU444 output supportJames Almer2024-10-121-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/output: add UYVA output supportJames Almer2024-10-121-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/output: add AYUV output supportJames Almer2024-10-121-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add V30X input supportJames Almer2024-10-081-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* swscale/input: add VYU444 input supportJames Almer2024-10-081-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>