Commit Graph

614 Commits

Author SHA1 Message Date
Campbell Barton 52ce8d408f Cleanup: use const arguments & variables 2024-04-04 10:55:10 +11: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 7ce68904eb Cleanup: replace suspicious use of "&" with "&&" 2024-04-01 22:20:09 +11:00
Campbell Barton 7e5a712e58 Cleanup: remove redundant null pointer checks
Based on the surrounding context these checks aren't needed.
2024-04-01 22:20:09 +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 b2e00d1285 Cleanup: use const pointer arguments 2024-03-28 20:57:50 +11:00
Campbell Barton 5685481fcb Cleanup: rename "name" to "filepath" for full paths 2024-03-28 20:57:50 +11:00
Campbell Barton 0ef033750f Cleanup: pass arguments by const reference 2024-03-28 17:16:33 +11:00
Harley Acheson 27c95da888 Refactor: Remove BLF _ex functions using default arguments
Remove all BLF "_ex" versions of functions by using default arguments.
These functions only differ by having an optional argument that can
return extra details about the result of the operation. This PR just
make these part of the main function as optional arguments with default
values - all nullptr.

Pull Request: https://projects.blender.org/blender/blender/pulls/119994
2024-03-28 04:02:13 +01:00
Campbell Barton 0d3ea69daa Fix sizeof(sizeof(...)) passed to BLI_path_slash_ensure
Regression in [0] which would cause ensuring the slash to do nothing
in most cases. Note that the slash may not be needed, but that should
be handled separately.

[0]: d66f24cfe3
2024-03-28 11:40:21 +11:00
Hans Goudey efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Campbell Barton 155dae94d7 Cleanup: code-comments, use doxygen formatting & spelling corrections
Also move some function doc-strings from the implementation
to their declarations.
2024-03-26 17:55:20 +11:00
JonasDichelle 8812be59a4 Compositor: Make Hue Correct node wrap
Compositor: Make Hue Correct node wrap

This patch makes the Hue Correct node as well as the Hue Correct VSE
modifiers to wrap, such that no discontinuities occur for the red hue.
Since it now wraps, the default curve preset now exempts the last point
of the curve.

A new CUMA_USE_WRAPPING flag was added to specify wrapping for curve
maps. The implementation works by adding two virtual points before and
after the terminal points in the curve map, such that their handles
match, and would then produce a continues curve.

This is a breaking change, since existing curves were also adjusted
using versioning. However, the change will not be significant, since in
most realistic cases, the terminal points will be close to each other,
and even with wrapping, the connection will be very sharp, almost
matching the old behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/117114
2024-03-21 15:35:02 +01: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 fbe16bc1eb BLI_delete: assert that dir is true when recursive is true
While this isn't an error avoid ambiguity for recursive deletion
as it's not meaningful to delete a file.
2024-03-21 09:43:40 +11:00
Aras Pranckevicius 6826efdb02 Fix #119456, #119493: VSE adjustment/text strips do not update in some cases
As part of PR #118396 the "generator" effect strips (color, text,
adjustment) also started to put their "raw" images into the cache.
However, seq_cache_timeline_frame_to_frame_index that has optimization
that tries to use only one cache entry based on how many frames are
present in the strip was not expecting to see effect strips, ever.

As a result, something like adjustment layer would effectively just
cache a single frame, since it has no "source frames" to speak of.

Fixed that by only doing this optimization for non-effect strips.
2024-03-15 10:37:30 +02:00
Falk David a11335d19a Cleanup: Move BKE_fcurve.h to C++
No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119094
2024-03-05 18:39:08 +01:00
Richard Antalik fc32b9c5dd Fix: Crash when multiview movie right view is missing.
Ultimately this was due to missing nullptr check before trying to
process the image, but this should have been caught when loading
ImBufAnims. If any is missing, cancel multiview loading and load
movie as if it was single view only.
2024-03-02 18:12:47 +01:00
Bastien Montagne de5451b112 Cleanup: Move `BKE_anim_data` header to be fully C++. 2024-02-28 11:51:03 +01:00
Hans Goudey d338261c55 Cleanup: Pass Span by value
Also pass Span instead of `const Array &`
and use parantheses for BLI includes.
2024-02-27 23:09:54 -05:00
Richard Antalik d4925b9775 Cleanup: Refactor VSE movie loading
Original code was very confusing, with seemingly indecisive logic.
I hope, that it is less confusing now, however there is still some
indecisiveness present. This is because multiview configuration may not
be correct, so there must be fallback and only some multiview settings
require loading of multiple files. Perhaps be better wording could be
used for `open_anim_file_multiview()`.
Fortunately this is now expressed within 5 lines of code instead of 100.

Further this can be improved by checking if the file exists, since now
VSE crashes when right eye image is missing, because loading code
does not try to actually open the file.

Pull Request: https://projects.blender.org/blender/blender/pulls/118580
2024-02-22 17:48:40 +01:00
Aras Pranckevicius f4f708a54f VSE: Skip rendering lower strips that are behind opaque strips above them
Often in previs setups, you have several "variations" of image/movie strips
for review, where the topmost one completely covers the others under it. VSE
rendering already had an optimization where if there's a fully opaque strip
that covers the whole screen, then the lower strips are skipped from
processing/rendering. However, it was not handling the case of non-fullscreen
strips (e.g. you'd have a Color strip near top & bottom for letterboxing, and
an opaque strip "in the middle").

This adds a simple "occluder tracking", and skips strips that are completely
covered by any single opaque strip that is above it (like outlined in #117790
task).

Playback of Gold previs between 1:42 and 1:55, on Windows/Ryzen5950X:
- Average frame time 28.5ms -> 23.8ms
- Median frame time 24.1ms -> 21.5ms
- Two slowest frames: 263->189ms, 194->178ms

Rendering the Gold previs movie: 325s -> 304s (93% of previous time)

Pull Request: https://projects.blender.org/blender/blender/pulls/118396
2024-02-21 20:16:44 +01:00
Hans Goudey 81a63153d0 Despgraph: Rename "copy-on-write" to "copy-on-evaluation"
The depsgraph CoW mechanism is a bit of a misnomer. It creates an
evaluated copy for data-blocks regardless of whether the copy will
actually be written to. The point is to have physical separation between
original and evaluated data. This is in contrast to the commonly used
performance improvement of keeping a user count and copying data
implicitly when it needs to be changed. In Blender code we call this
"implicit sharing" instead. Importantly, the dependency graph has no
idea about the _actual_ CoW behavior in Blender.

Renaming this functionality in the despgraph removes some of the
confusion that comes up when talking about this, and will hopefully
make the depsgraph less confusing to understand initially too. Wording
like "the evaluated copy" (as opposed to the original data-block) has
also become common anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/118338
2024-02-19 15:54:08 +01:00
Aras Pranckevicius 69b9735ce2 Merge branch 'blender-v4.1-release' 2024-02-16 20:56:56 +02:00
Aras Pranckevicius 6508ed8a3f Fix #118213: Applying effects to VSE Color/Text strips makes both the effect and source strip visible
This is different from applying effects to regular "source media" strips
like images or movies; an effect "hides" the input strip when it is
below itself in the channel.

Apply the same treatment to Color & Text strips. Fixes #118213.

If someone wants previous behavior for some reason, they can drag
the effect applied on Color/Text to be below the input strip.

Pull Request: https://projects.blender.org/blender/blender/pulls/118269
2024-02-16 20:56:06 +02: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
Campbell Barton fee47f6da8 Cleanup: unused includes in source/blender/sequencer
Remove 95 includes.
2024-02-13 13:37:56 +11:00
ok_what 751d9c5999 Fix: VSE transition strip factor is not clamped
Previewing strip outside of it's boundary caused overflow.
Clamp the factor to prevent overflow.

Pull Request: https://projects.blender.org/blender/blender/pulls/118086
2024-02-12 21:21:19 +01:00
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 29fe777445 Cleanup: Make `BKE_report.h` a full Cpp header. 2024-02-10 18:34:29 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Bastien Montagne 45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Richard Antalik a17e3a6fbb Fix: VSE prefetching doesn't work
Caused by error in 3fccfe0bc6. Commit reversed logic for getting scene strips.
2024-02-06 17:32:49 +01:00
Aras Pranckevicius e1f8775807 VSE: default to new "Auto" image filter for strips
Part of "improve filtering situation" (#116980), now strip scaling filter defaults to "Auto" which has logic like:

- No scale, no rotation, integer positions: Nearest (fastest)
- Scaling up by more than 2x: Cubic Mitchell, so you get nicer blending between pixels than with bilinear,
- Scaling down by more than 2x: Box, so that many pixels are averaged properly without too much aliasing,
- Otherwise: Bilinear

Existing strips that use Bilinear (which is default) get switched to Auto when loading older files.

All of this has an advantage that unless you have some special needs for your look, you can leave it at default and it will look decently good at either large up-scaling or large down-scaling, but not waste performance if you don't use any scaling at all. Previously none of the choices were good in "all cases": box (née subsampled3x3) only looks good when scaling down, cubic only looks good when scaling up, default bilinear leaves performance on the table when you don't use any scale/rotation, etc.

On something like Gold movie current edit, most of the strips effectively use Nearest now, except some that are translated into non-integer pixel positions; those stay effectively Bilinear.

Pull Request: https://projects.blender.org/blender/blender/pulls/117853
2024-02-05 20:09:29 +01:00
Damien Picard fa77e9142d UI: fix and improve a few messages
- "can not" -> "cannot" in many places (ambiguous, also see
  Writing Style guide).
- "Bezier" -> "Bézier": proper spelling of the eponym.
- Tool keymaps: make "Uv" all caps.
- "FFMPEG" -> "FFmpeg" (official spelling)
- Use MULTIPLICATION SIGN U+00D7 instead of MULTIPLICATION X U+2715.
- "LClick" -> "LMB", "RClick" -> "RMB": this convention is used
  everywhere else.
- "Save rendered the image..." -> "Save the rendered image...": typo.
- "Preserve Current retiming": title case for property.
- Bend status message: punctuation.
- "... class used to define the panel" -> "header": copy-paste error.
- "... class used to define the menu" -> "asset": copy-paste error.
- "Lights user to display objects..." -> "Lights used...": typo.
- "-setaudio require one argument" -> "requires": typo.

Some issues reported by Joan Pujolar and Tamar Mebonia.

Pull Request: https://projects.blender.org/blender/blender/pulls/117856
2024-02-05 17:08:17 +01:00
Aras Pranckevicius 4cf2d95bb5 Cleanup: more C++ constructs in VSE render.hh and friends
- enum class StripEarlyOut instead of raw integer defines
- SeqRenderState default initializer instead of seq_render_state_init
- Vector<Sequence*> instead of manually sized arrays of pointers
- some const to several function arguments

Pull Request: https://projects.blender.org/blender/blender/pulls/117829
2024-02-05 11:10:43 +01:00
Aras Pranckevicius 0bfffdaf82 VSE: bilinear upscaling no longer adds transparent border around the image
Part of overall "improve image filtering situation" (#116980), this PR addresses
two issues:
- Bilinear (default) image filtering makes half a source pixel wide transparent
  border around the image. This is very noticeable when scaling images/movies up
  in VSE. However, when there is no scaling up but you have slightly rotated
  image, this creates a "somewhat nice" anti-aliasing around the edge.
- The other filtering kinds (e.g. cubic) do not have this behavior. So they do
  not create unexpected transparency when scaling up (yay), however for slightly
  rotated images the edge is "jagged" (oh no).

More detail and images in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/117717
2024-02-02 16:28:51 +01:00
Hans Goudey c87e51790d Cleanup: Make format 2024-01-31 22:01:30 -05:00
Hans Goudey fac27b1b6b Cleanup: Replace most used of SWAP macro with std::swap
Also remove / replace use of the math vector double swapping functions.
2024-01-31 21:12:16 -05:00
Hans Goudey 7fa5fc02b7 Cleanup: Move BLF headers to C++ 2024-01-31 14:04:56 -05:00
Richard Antalik 8a96f0fb06 Fix #116411: Sound animation not working correctly
This was caused by global variable `sound_cfra` not being updated when
rendering sequencer data. This global variable could cause problems in
other cases though, so it is removed. Functions that are used to set
anomation buffers now accept frame as argument.

Pull Request: https://projects.blender.org/blender/blender/pulls/117345
2024-01-31 18:57:06 +01:00
Aras Pranckevicius 5bd1e0bb22 VSE: replace Subsampled3x3 filter by a general Box filter
Part of overall "improve filtering situation" (#116980): replace Subsampled3x3
(added for blender 3.5 in f210842a72 et al.) strip scaling filter with a
general Box filter.

Subsampled3x3 is really a Box filter ("average pixel values over NxM region"),
hardcoded to 3x3 size. As such, it works pretty well when downscaling images by
3x on each axis. But starts to break down and introduce aliasing at other
scaling factors. Also when scaling up or scaling down by less than 3x, using
total of 9 samples is a bit of overkill and hurts performance.

So instead, calculate the amount of NxM samples needed by looking at scaling
factors on X/Y axes. Note: use at least 2 samples on each axis, so that when
rotation is present, the result edges will get some anti-aliasing, just like it
was happening in previous filter implementation.

Images in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/117584
2024-01-29 18:41:31 +01:00
Aras Pranckevicius b7cf71d567 VSE: add Cubic Mitchell filtering, rename previous cubic to Cubic BSpline
Part of overall "improve filtering situation" (#116980) task:

Add "Cubic Mitchell" filtering option to VSE strips. This is a cubic (4x4)
filter that generally looks better than bilinear, while not blurring the image
as much as the Cubic BSpline filter that exists elsewhere within Blender. It is
also default in many other apps.

Rename the (very recently added) VSE Bicubic filter option to Cubic BSpline.

Images in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/117517
2024-01-26 11:57:19 +01:00
Aras Pranckevicius 5ed2eea0f6 ImBuf: Refactor pixel interpolation functions
There exist a bunch of "give me a (filtered) image pixel at this location"
functions, some with duplicated functionality, some with almost the same but
not quite, some that look similar but behave slightly differently, etc.
Some of them were in BLI, some were in ImBuf.

This commit tries to improve the situation by:
* Adding low level interpolation functions to `BLI_math_interp.hh`
  - With documentation on their behavior,
  - And with more unit tests.
* At `ImBuf` level, there are only convenience inline wrappers to the above BLI
  functions (split off into a separate header `IMB_interp.hh`). However, since
  these wrappers are inline,   some things get a tiny bit faster as a side
  effect. E.g. VSE image strip, scaling to 4K resolution (Windows/Ryzen5950X):
  - Nearest filter: 2.33 -> 1.94ms
  - Bilinear filter: 5.83 -> 5.69ms
  - Subsampled3x3 filter: 28.6 -> 22.4ms

Details on the functions:
- All of them have `_byte` and `_fl` suffixes.
- They exist in 4-channel byte (uchar4) and float (float4), as well as
  explicitly passed amount of channels for other float images.
- New functions in BLI `blender::math` namespace:
  - `interpolate_nearest`
  - `interpolate_bilinear`
  - `interpolate_bilinear_wrap`. Note that unlike previous "wrap" function,
    this one no longer requires the caller to do their own wrapping.
  - `interpolate_cubic_bspline`. Previous similar function was called just
    "bicubic" which could mean many different things.
- Same functions exist in `IMB_interp.hh`, they are just convenience that takes
  ImBuf and uses data pointer, width, height from that.

Other bits:
- Renamed `mod_f_positive` to `floored_fmod` (better matches `safe_floored_modf`
  and `floored_modulo` that exist elsewhere), made it branchless and added more
  unit tests.
- `interpolate_bilinear_wrap_fl` no longer clamps result to 0..1 range. Instead,
  moved the clamp to be outside of the call in `paint_image_proj.cc` and
  `paint_utils.cc`. Though the need for clamping in there is also questionable.

Pull Request: https://projects.blender.org/blender/blender/pulls/117387
2024-01-25 11:45:24 +01:00
Hans Goudey 02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05:00
Campbell Barton 6cc8ac7cb3 Cleanup: rename ImBuf anim & anim_index structs
Rename: anim -> ImBufAnim
Rename: anim_index -> ImBufAnimIndex

There were cases where removing redundant "struct" qualifier caused
a warning since the name of the struct member was also anim.

Use uppercase type name to conform with other types names.

Ref !117394
2024-01-23 20:26:55 +11:00
Hans Goudey 0618de49ad Cleanup: Replace MIN/MAX macros with C++ functions
Use `std::min` and `std::max` instead. Though keep MIN2 and MAX2
just for C code that hasn't been moved to C++ yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/117384
2024-01-22 15:58:18 +01:00
Jacques Lucke 311ca3e6af Core: rename Session UUID to Session UID
`UUID` generally stands for "universally unique identifier". The session identifier that
we use is neither universally unique, nor does it follow the standard. Therefor, the term
"session uuid" is confusing and should be replaced.

In #116888 we briefly talked about a better name and ended up with "session uid".
The reason for "uid" instead of "id" is that the latter is a very overloaded term in Blender
already.

This patch changes all uses of "uuid" to "uid" where it's used in the context of a
"session uid". It's not always trivial to see whether a specific mention of "uuid" refers
to an actual uuid or something else. Therefore, I might have missed some renames.
I can't think of an automated way to differentiate the case.

BMesh also uses the term "uuid" sometimes in a the wrong context (e.g. `UUIDFaceStepItem`)
but there it also does not mean "session uid", so it's *not* changed by this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/117350
2024-01-22 13:47:13 +01:00
Aras Pranckevicius a705259b4b Cleanup: move imbuf .h files to .hh 2024-01-19 20:29:38 +01:00