Commit Graph

2381 Commits

Author SHA1 Message Date
Campbell Barton
49bf7ebbdd Cleanup: use const args & variables, remove redundant checks
- Declare const variables & arguments.
- Remove redundant null checks.
- Remove break after return.
- Replace suspicious "&" with "&&".
2024-04-15 09:50:47 +10:00
Omar Emara
0c91ad9008 Fix #120175: File Output node has wrong BW output
The File Output node produces wrong output when the output is set to BW.
This is because the image saving logic assumes float buffers always have
4 channels and ignores the image buffer channels member. So for single
channel images, the code weighted sum neighbouring pixels and asigned
them as a single pixel, producing bleeding at best and crashes at worst.

To fix this, we skip Color to BW conversion if the image is already BW.
And, we fix the functions that assume 4 channels for float buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/120206
2024-04-04 08:51:57 +02:00
Campbell Barton
fdaaebce54 Cleanup: remove unnecessary checks & unused assignments 2024-04-04 10:55:13 +11:00
Philipp Oeser
8af4c72ddd Fix #120113: crash reading large jpeg
Caused by 406cfd214a

Above commit added a multiplication by 4 to the offset (rightfully so),
but this could overflow with very large image dimensions.

Pull Request: https://projects.blender.org/blender/blender/pulls/120214
2024-04-03 17:38:02 +02:00
Aras Pranckevicius
b3ea1e75dc Cleanup: comment why DDS DXT/S3TC needs power of two sizes, and clearer log message
It is not immediately clear why DDS compressed (DXT/S3TC) textures need
to be power of two in size (since nothing in DXT/S3TC intrinsically
requires that). It is only needed due to the "flip the texture upside
down" dance that we do for DDS at load time.

While at it, when logging DXT related messages, tell which texture
was it for, and dimensions. This changes logs like:
```
Unable to load non-power-of-two DXT image resolution, falling back to uncompressed.
Unable to load non-power-of-two DXT image resolution, falling back to uncompressed.
Unable to find a suitable DXT compression, falling back to uncompressed.
```
Into:
```
Unable to load non-power-of-two DXT image resolution, falling back to uncompressed (281splash-dxt1-mips.dds, 890x501).
Unable to load non-power-of-two DXT image resolution, falling back to uncompressed (281splash-dxt5-mips.dds, 890x501).
Unable to find a suitable DXT compression, falling back to uncompressed (281splash-rgba8-mips.dds, 890x501).
```

Pull Request: https://projects.blender.org/blender/blender/pulls/120210
2024-04-03 17:12:46 +02:00
Campbell Barton
b03332a055 Cleanup: use BLI_assert_msg instead of checking string literals 2024-04-03 14:27:54 +11:00
Campbell Barton
d5d1025e94 Cleanup: use const pointer arguments 2024-04-03 10:22:05 +11:00
Campbell Barton
04b6fe78e7 Fix integer truncation when calculating int64_t values
Large int64_t values were calculated and assigned int however the
calculation was performed on integer types which would truncate the
result before casting to an in64_t.
2024-04-01 22:19:36 +11:00
Campbell Barton
686605a6dd Cleanup: declare arrays as const where possible 2024-03-28 22:57:57 +11:00
Campbell Barton
b2e00d1285 Cleanup: use const pointer arguments 2024-03-28 20:57:50 +11:00
Campbell Barton
8f88487768 Cleanup: pass LogImageElement by reference or pointer instead of value 2024-03-28 13:01:38 +11:00
Campbell Barton
872c997c8f Cleanup: remove redundant break & return statements 2024-03-28 13:01:37 +11:00
Hans Goudey
0cdd429b44 Cleanup: Use newer API for creating IDProperties in most places
There are still a few places that are more complicated where the replacement
to `IDP_New` isn't obvious, but this commit replaces most uses of the ugly
`IDPropertyTemplate` usage.
2024-03-26 15:39:39 -04:00
Hans Goudey
efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Hans Goudey
fc0d8ba012 Cleanup: Remove C++ ifdef checks in C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119900
2024-03-26 04:56:03 +01:00
Omar Emara
4971b144a4 Compositor: Unify sRGB to Linear between CPU and GPU
This patch unifies the sRGB to Linear color space conversion between the
CPU and GPU compositors. This is because CPU uses an optimized path that
produces values that are very slightly off. To fix this, for the GPU, we
do the conversion CPU side instead of doing it in a shader. Since images
are cached, the performance implications are not significant.

Another added benefit is that we no longer get differences due to the
order of alpha pre-multiplication and sRGB conversion, demonstrated in
#114305. And we no longer require any preprocessing of the images.

This patch adds some new utilities to the Image Buffer module to assign
float, byte, and compressed buffers along with their color spaces. It
also adds an ownership flag to compressed data. Those were added as a
way to facilitate the implementation.

Pull Request: https://projects.blender.org/blender/blender/pulls/118624
2024-03-25 14:09:54 +01:00
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Campbell Barton
e4b7f4d884 Suppress noisy color-management prints when using --command 2024-03-22 16:08:25 +11:00
Omar Emara
2906ea9785 BLI: Add nearest interpolation with clamped boundary
This patch adds clamped boundaries variants of the nearest interpolation
functions in the BLI module. The naming convention used by the bilinear
functions were followed.

Needed by #119414.

Pull Request: https://projects.blender.org/blender/blender/pulls/119732
2024-03-21 13:22:10 +01:00
Campbell Barton
57dd9c21d3 Cleanup: spelling in comments 2024-03-21 10:02:53 +11:00
Sergey Sharybin
6dc1cffe33 Merge branch 'blender-v4.1-release' 2024-03-20 14:38:52 +01:00
Sergey Sharybin
03c7191286 Fix #119560: Wanderer Demo Crash in 4.1 and 4.2
Add a null pointer check around CPU processor, matching the rest of the
processor access.

This solves crash in cases when the OCIO configuration exists but is
invalid: i.e. by removing a lookup table. It could lead to an invalid
render result, but is better than a crash.

The original issue with running Blender from within .zip archive might
still need investigation, as there might be a way to make it work.

Pull Request: https://projects.blender.org/blender/blender/pulls/119693
2024-03-20 14:38:23 +01:00
Brecht Van Lommel
7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
2024-03-18 15:04:12 +01:00
Sergey Sharybin
74d948097f Merge branch 'blender-v4.1-release' 2024-03-14 17:11:45 +01:00
Sergey Sharybin
6aa21ed752 Fix: incorrect GPU ownership after IMB_dupImBuf
The IMB_dupImBuf() function does not copy the GPU texture as it might
not be possible if the GPU context is not active, but it also was not
clearing the pointer in the result ImBuf. This could potentially lead
to situation when the texture gets freed via IMB_freeImBuf of either
original or copied image buffer, leaving the other pointing to a freed
GPU texture.

It is not known whether it ever was an actual problem for artists,
but it is nice to avoid such possibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/119469
2024-03-14 17:09:33 +01:00
Brecht Van Lommel
f131709122 Merge branch 'blender-v4.1-release' 2024-03-14 14:12:05 +01:00
Brecht Van Lommel
e9ca817d5f Fix #119419: Crashes with incompatible OpenColorIO configs
* If required roles are not found, refuse to load the config
* Use "default" role as fallback for all roles, following the
  OpenColorIO docs.
* Use bundled config if loading environment config fails,
  instead using very limited fallback config.
* Fix OCIO_exit get called on failed config load, causing
  crash when trying to load the next config.

Pull Request: https://projects.blender.org/blender/blender/pulls/119435
2024-03-14 14:08:56 +01:00
Brecht Van Lommel
a887ec8f38 Cleanup: Move variable definitions closer to use, other style tweaks
Pull Request: https://projects.blender.org/blender/blender/pulls/119435
2024-03-14 14:08:12 +01:00
Campbell Barton
74d9fb60ba Cleanup: use 'const' where possible, remove redundant check 2024-03-09 16:38:25 +11:00
Hans Goudey
744f3b2823 Cleanup: Grammar in comments: Fix uses of "own"
"Own" (the adjective) cannot be used on its own. It should be combined
with something like "its own", "our own",  "her own", or "the object's own".
It also isn't used separately to mean something like "separate".

Also, "its own" is correct instead of "it's own" which is a misues of the verb.
2024-03-07 16:23:35 -05:00
Campbell Barton
6549019ae1 Cleanup: use STREQUAL instead of MATCHES for exact comparisons
MATCHES takes a REGEX and searches the input for a match,
this isn't necessary for CMAKE_SYSTEM_PROCESSOR & CMAKE_*_COMPILER_ID.
2024-03-07 17:56:41 +11:00
Anthony Roberts
445fd42c61 Windows: Add ARM64 support
* Only works on machines with a Qualcomm Snapdragon 8cx Gen3 or above.
  Older generation devices are not and will not be supported due to
  some driver issues
* Requires VS2022 for building.
* Uses new MSVC preprocessor for sse2neon compatibility.
* SIMD is not enabled, waiting on conversion of blenlib to C++.

Ref #119126

Pull Request: https://projects.blender.org/blender/blender/pulls/117036
2024-03-06 16:14:34 +01:00
Campbell Barton
76867ad4c2 Cleanup: redundant "void" in function declarations for C++ 2024-03-05 11:25:35 +11:00
Campbell Barton
d012a46605 Merge branch 'blender-v4.1-release' 2024-03-01 09:12:23 +11:00
Campbell Barton
fc6975e218 Unbreak build with WITH_IMAGE_OPENEXR disabled on macOS/ARM
[0] was meant to resolve this but the include is still needed event
when OPENEXR is disabled.

[0]: a39c16270c
2024-03-01 09:08:14 +11:00
Brecht Van Lommel
1355285c0e Merge branch 'blender-v4.1-release' 2024-02-29 13:52:19 +01:00
Brecht Van Lommel
a060e96103 Fix #101227: Crash and other issues with non-multiview multipart EXR
Some software stores passes or layers as parts. This case was not
supported by the OpenEXR reader yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/118867
2024-02-29 13:50:18 +01:00
Campbell Barton
7db790c4b7 Cleanup: spelling in comments 2024-02-28 12:13:20 +11:00
Campbell Barton
59abe4a757 Cleanup: use const for the source argument of IMB_metadata_copy
Also use more meaningful argument names.
2024-02-28 11:02:56 +11:00
Campbell Barton
da40fcdd15 Cleanup: quest unused argument warnings without FFMpeg 2024-02-22 22:36:11 +11:00
Aras Pranckevicius
b261654a93 VSE: Reduce playback stalls when new video clips start playing
When starting to play back a movie strip, there was a "oh, let's figure out if
this is a video file?" check, immediately followed by "let's initialize the
machinery to decode a video file". The first one is kinda redundant, since if
it will happen to not be a video file, the latter check will nicely fail.

Addressed that by removing (seemingly unused at all?) functionality from
`ImBufAnim`, now it is only used for video file playback. Details:

- It looks like `ImBufAnim` is only ever used to play back "video files", so
  remove all the other modes of operation from it ("image sequence").
- Which makes `ImBufAnim::curtype` be not needed, it only needs to store state
  of whether it's initialized already.
- Which means there's no need to call `imb_get_anim_type` (which does very
  costly `isffmpeg`) when starting to play ImBufAnim.
- Remove some other variables from `ImBufAnim` that were just flat out unused.

In Gold previs playback between 1:41-1:55, on Windows/Ryzen5950X:
- Slowest 3 frames went from 276, 195, 168ms -> 222, 174, 147ms (saves 20+ ms
  per frame). All of these frames are camera cuts where multiple new video
  clips start playing.
- In the whole playback, total amount of time taken by `imb_get_anim_type`:
  234ms -> zero! Since that is no longer used.
- There are still stalls when starting to play a movie clip, and that is
  actually initializing ffmpeg things. But now at least right before
  "initialize ffmpeg" there's no additional redundant work.

Pull Request: https://projects.blender.org/blender/blender/pulls/118503
2024-02-22 09:24:35 +01:00
Aras Pranckevicius
31869d6857 Cleanup: ImBuf: remove various unused functions
IMB_double_x, IMB_double_y, IMB_double_fast_x, IMB_double_fast_y,
imb_filterx are not used by anything. Looks like they all come
from "initial revision, 22 years ago" and probably unused for decades.
2024-02-21 13:47:50 +02:00
Campbell Barton
b6b00b61cb Cleanup: various non-functional changes for C++ 2024-02-21 10:33:56 +11:00
Aras Pranckevicius
f09c7dc4ba Video: Remove non-ffmpeg AVI support
Blender had a very limited (only uncompressed or MJPEG frames) .avi file
support, for both reading and writing. This is something that ffmpeg can
fully do.

This removes all of that. 3500 lines of code gone, primary motivations being:
- ffmpeg can read and write .avi files just fine, including ones with
  uncompressed or MJPEG frames.
- Blender's ffmpeg integration could also be taught to produce uncompressed or
  MJPEG .avi files, but TBH I don't see a particular reason to do that. Modern
  formats like H264 are better in every way, and already support "lossless"
  option if needed.
- The "Lite" blender build configuration was excluding both ffmpeg and avi
  anyway, so that config is something that can't read nor write any movies.

User visible changes:

- In scene image output type, under Video section now there's only Ffmpeg Video
  (AVI Raw and AVI JPEG are gone)
- Whenever loading an existing file, if output was one of AVI Raw / AVI JPEG,
  it is set to Ffmpeg Video.

Pull Request: https://projects.blender.org/blender/blender/pulls/118409
2024-02-20 13:15:50 +01:00
Brecht Van Lommel
0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564.
2024-02-19 15:59:59 +01:00
Aras Pranckevicius
b4c6c69632 ImBuf: do not clear newly allocated image pixels when not needed
In some/many cases, an `ImBuf` is allocated, and all the pixels are
immediately filled by some code. Doing the memory clear within allocation
is just memory traffic for no good reason.

Add a flag to skip initialization of ImBuf pixels (IB_uninitialized_pixels)
and use that in some parts of VSE effects/rendering/cache/scopes, as well
as image loading code.

Rendering out VSE movie, on Windows/VS2022/Ryzen5950X:
- Sprite Fright: 443sec -> 414sec (takes 93% of previous time)
- Gold previs: 367sec -> 325sec (takes 88% of prev time)

Pull Request: https://projects.blender.org/blender/blender/pulls/118321
2024-02-15 14:54:57 +01:00
Aras Pranckevicius
ffbc90874b ffmpeg: cache swscale contexts instead of re-creating them
ffmpeg's libswscale is used to do RGB<->YUV conversions on movie reading
and writing. The "context" for the scale operation was being created
and destroyed for each movie clip / animation. Now, maintain a cache
of the scale contexts instead.

E.g. in Gold edit, it only ever needs two contexts (one for reading
source movie clips since they are all exactly the same resolution
and format; and one for rendering the resulting movie).

During playback, on some of the "slow" frames (camera cuts) this
saves 10-20ms (Windows, Ryzen 5950X). Rendering whole movie goes
from 390sec to 376sec.

Pull Request: https://projects.blender.org/blender/blender/pulls/118130
2024-02-15 10:35:02 +01:00
Campbell Barton
5c87dfd269 Cleanup: use BLI_time_ prefix for time functions
Also use the term "now" instead of "check" for clarity.
2024-02-15 13:15:56 +11:00
Pratik Borhade
dda277e48c Merge branch 'blender-v4.1-release' 2024-02-14 16:22:28 +05:30
Pratik Borhade
f344823785 UI: Opus files not included in sound files filter
Include `.opus` extension in audio filter list

Fixes #118235

Pull Request: https://projects.blender.org/blender/blender/pulls/118238
2024-02-14 11:39:11 +01:00