Commit Graph

897 Commits

Author SHA1 Message Date
Bastien Montagne
1d76cbab64 Cleanup: sequencer: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135747
2025-03-10 17:16:43 +01:00
Richard Antalik
951adb19ab Fix lite build error
Missed renaming LoadData in ifdef'd parts of code.
2025-03-06 18:38:32 +01:00
Richard Antalik
68abed543b Refactor: Remove module prefix form symbols in sequnecer namespaces
Remove
SEQ_ prefix for blender::seq namespace and
ED_sequencer for blender::ed::vse namespace

Pull Request: https://projects.blender.org/blender/blender/pulls/135560
2025-03-06 13:04:39 +01:00
Richard Antalik
21bd7ec180 Fix windows build error and warnings
Pull Request: https://projects.blender.org/blender/blender/pulls/135567
2025-03-06 11:18:28 +01:00
Campbell Barton
7d8bccbbd4 Cleanup: suppress undefined function warning
SeqRenderData declared outside the blender::seq namespace
was treated as a different type, causing the function to be treated
as undeclared.
2025-03-06 16:50:21 +11:00
Richard Antalik
a08246a1a2 Refactor: Move VSE code to namespaces
This PR creates 2 namespaces for VSE code:
- `blender::seq` for sequencer core code
- `blender::ed::vse` for editor code

These names are chosen to not be in conflict with each other.
No namespace was used for RNA.

Finally, file `BKE_sequencer_offscreen.h` was moved from BKE to sequencer.

Pull Request: https://projects.blender.org/blender/blender/pulls/135500
2025-03-06 06:22:14 +01:00
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Aras Pranckevicius
148aa54398 ImBuf: unify color space transform threaded/non-threaded functions
There's no point in having non-threaded image color space conversion functions.
So merge the threaded and non-threaded functions and clarify names while at it:

- IMB_colormanagement_transform & IMB_colormanagement_transform_threaded
    -> IMB_colormanagement_transform_float
- IMB_colormanagement_transform_byte & IMB_colormanagement_transform_byte_threaded
    -> IMB_colormanagement_transform_byte
- IMB_colormanagement_transform_from_byte & IMB_colormanagement_transform_from_byte_threaded
    -> IMB_colormanagement_transform_byte_to_float

These places were doing single-threaded colorspace conversion previously, and
thus now are potentially faster:
- IMB_rect_from_float (used in many places)
- EXR image "save as render" saving (image_exr_from_scene_linear_to_output)
- Object baking (write_internal_bake_pixels, write_external_bake_pixels)
- General image saving, clipboard copy, movie preparation
  (IMB_colormanagement_imbuf_for_write)
- Linear conversion when reading HDR images/movies
  (colormanage_imbuf_make_linear)
- EXR multi-layer conversion (render_result_new_from_exr)

For one case I benchmarked, which is to render out a 2D stabilized 10 bit input
movie clip out of VSE, the total render time went from 49sec down to 44sec
(Ryzen 5950X), one of the single-threaded parts was the colorspace conversion
in the movieclip code.

Pull Request: https://projects.blender.org/blender/blender/pulls/135155
2025-02-26 12:11:47 +01:00
Harley Acheson
5f6c919553 Merge branch 'blender-v4.4-release' 2025-02-23 13:42:21 -08:00
Harley Acheson
89f61ee6cb Fix: Use Font Flag to Identify Default Fonts
with #133413 the intent was that VSE Text strips would not use the
fallback font stack if using a custom (non-default) font. However this
determination was done by comparing the font id. This was very weak as
the id can vary quite a bit within the first few fonts. This PR instead
adds a BLF function (BLF_is_builtin) that uses BLF_DEFAULT font flag
instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/135014
2025-02-23 22:41:08 +01:00
Harley Acheson
e2c1922c60 Merge branch 'blender-v4.4-release' 2025-02-18 10:06:39 -08:00
Harley Acheson
35d14d578c Fix #133413: Don't Use Fallback for Sequencer Text Using Custom Fonts
If a sequencer text strip is using a custom font (not the default one)
then don't use the fallback font. This adds a new font flag to disable
the use of fallback.

Pull Request: https://projects.blender.org/blender/blender/pulls/133510
2025-02-18 19:05:34 +01:00
Falk David
c47a4b1e13 Refactor: VSE: Remove scene dependency of SEQ_lookup_* functions
Instead of passing the `scene`, pass a pointer to the `Editing` struct.
This is the struct that owns the `StripLookup` in its `runtime`
so there isn't a good reason to use the `scene` pointer here
anyways.

Pull Request: https://projects.blender.org/blender/blender/pulls/134743
2025-02-18 15:16:20 +01:00
Bastien Montagne
24a2e0b9ec Cleanup: make format. 2025-02-18 14:47:08 +01:00
Falk David
54be463b99 Refactor: VSE: Remove scene parameter of some time functions
This removes the `scene` parameter of
`SEQ_time_get_rounded_sound_offset` and
`SEQ_time_media_playback_rate_factor_get`.
Instead, we now pass the `frames_per_second` directly.

This is an attempt at getting less of the code to be
scene dependent.

Pull Request: https://projects.blender.org/blender/blender/pulls/134741
2025-02-18 13:45:56 +01:00
Brecht Van Lommel
20138318cc Merge branch 'blender-v4.4-release' 2025-02-18 13:21:45 +01:00
Brecht Van Lommel
4e02acf2ba Fix #134607: Sequencer render animation preview not working
This main thread check was introduced in 4536a4c610. At the time OpenGL
only ever worked in the main thread, but that limitation was lifted in
Blender 2.80.

With this operator being converted to use the jobs system, it now needs
to work in non-main threads. Note that this code does not run in parallel
with main thread drawing anyway, because of WM_job_main_thread_lock_acquire
and draw manager locks. What changed is that we can now activate OpenGL
contexts on other threads.

Pull Request: https://projects.blender.org/blender/blender/pulls/134696
2025-02-18 13:21:02 +01:00
Richard Antalik
2a44bdfbd0 Refactor: Use C++ types for vectors strip image transform code
All 2D vectors related to image transform code were changed to float2.
Previously, it was decided, that 4x4 matrix should be used for 2D
affine transform, but this is changed to 3x3 now.

Texture painting code did rely on `IMB_transform` with 4x4 matrix.
To avoid large changes, I have added function
`BLI_rctf_transform_calc_m3_pivot_min`.

Main motivation is cleaner code - ease of use of c++ API, and avoiding
returning values by arguments.

Pull Request: https://projects.blender.org/blender/blender/pulls/133692
2025-02-17 11:23:00 +01:00
Richard Antalik
564feceffd Cleanup: Use float instead of double for VSE retiming step
After calculating precision error, it turns out, that float type is
capable of working with up to 100h of 60fps footage without problems.

Pull Request: https://projects.blender.org/blender/blender/pulls/134477
2025-02-15 09:53:58 +01:00
Bastien Montagne
70f77a5bf3 Merge branch 'blender-v4.4-release' 2025-02-14 18:41:43 +01:00
Bastien Montagne
69f7530f7a Fix (unreported) invalid C-style allocation of non-trivial C++ data. 2025-02-14 18:39:24 +01:00
Campbell Barton
640e70b6e8 Cleanup: various non-functional changes for C++ 2025-02-13 13:33:09 +11:00
Richard Antalik
84358c5a3e Merge branch 'blender-v4.4-release' 2025-02-13 03:18:51 +01:00
Richard Antalik
ee9e4ead8d Fix: VSE: Retiming key translation not working correctly
Translating keys when speed transitions are present with media not
matching scene FPS causes incorrect behavior.

This was caused by multiple issues - in some places media vs scene FPS
mismatch was not accounted for and multiple instances of presision loss
due to casting float values to integer.

Pull Request: https://projects.blender.org/blender/blender/pulls/131911
2025-02-13 03:16:29 +01:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Aras Pranckevicius
4f0fd32d6f VSE: Over Drop effect was not doing anything useful, map it to Alpha Over
Behavior of it was exactly the same as Alpha Over for the last 18 years (since
327d413eb3 in 2006 March), so just remap it to regular alpha over on file read.

Pull Request: https://projects.blender.org/blender/blender/pulls/134342
2025-02-10 16:10:01 +01:00
Richard Antalik
412353b198 Merge branch 'blender-v4.4-release' 2025-02-07 22:44:45 +01:00
Richard Antalik
b2660dbd2b Fix: Improve retiming speed get/set code precision
Use float for intermediate values when calculating speed or timeline
frames.

More details on precision improvement itself: In some cases, setting
strip speed to say 70% would result in actual speed being set to say
69.5%. With this change, the number would be closer or equal to 70%.

There few tangentially related changes:
- `SEQ_retiming_key_speed_get` was changed so both functions work in
  same time domain.
- `SEQ_retiming_key_speed_set` now expects speed as float factor
  instead of percentage. This is consistent with get function return
   value.
- Improve variable names, for better code readability.

Pull Request: https://projects.blender.org/blender/blender/pulls/131782
2025-02-07 22:41:18 +01:00
Bastien Montagne
87a4c0d3a8 Refactor: Make Library.runtime an allocated pointer.
Move `Library.runtime` to be a pointer, move the related
`LibraryRuntime` struct to `BKE_library.hh`. Similar to e.g.
Mesh.runtime, that pointer is expected to always be valid, and is
allocated at readtime or when creating a new Library ID.

Related smaller changes:
* Write code now uses standard ID writing codepath for Library IDs too.
  * Runtime pointer is reset to nullptr before writing.
* Looking up a library by its absolute path is now handled through a
  dedicated utils, `search_filepath_abs`, instead of using
  `BLI_findstring`.

Pull Request: https://projects.blender.org/blender/blender/pulls/134188
2025-02-07 17:47:16 +01:00
Brecht Van Lommel
112cd9cc20 Cleanup: Various clang-tidy warnings in sequencer
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:18 +01:00
Aras Pranckevicius
2b39897d18 Fix #133799: render of VSE 10/12bpp videos broken unless source strips are float
10/12bpp movie writing code assumes that input image is properly
floating point for these cases. That is always true for regular
rendering, however VSE can produce 8bpp images, if there
are no float/HDR strips in there. Make these convert into a float
image in the render pipeline when needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/133802
2025-01-30 14:55:41 +01:00
Richard Antalik
bf19960937 Refactor: VSE: Use C++ matrix BLI API
This PR explicitly declares integer type for `image_center_offs`, which
formalizes accidentally implemented correct behavior. Previously type
was float, all rhs types in expression were integers, so result was int
cast to float.

Comment is also added clarifying why integer must be used - float may
cause images to be interpolated, even when translation is set to 0.

There should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/133573
2025-01-28 02:01:07 +01:00
Falk David
b9f253564e VSE: Python API: Deprecate sequence properties and replace with new ones
This PR adds new RNA properties that deprecate and replace any `sequence` property.
The old prooperties are still there and fully functional, but the description is changed
to indicate that these will be removed in the future and that the new properties should
be used instead.

| Deprecated property | Replacement property |
| --------------------------------- | ----------------------------------- |
| `context.active_sequence_strip` | `context.active_strip` |
| `context.selected_editable_sequences` | `context.selected_editable_strips` |
| `context.selected_sequences` | `context.selected_strips` |
| `context.sequences` | `context.strips` |
| `SequenceEditor.sequences` | `SequenceEditor.strips` |
| `SequenceEditor.sequences_all` |  `SequenceEditor.strips_all` |
| `MetaStrip.sequences` | `MetaStrip.strips` |

Previously, rna paths for animation data on strips started with `sequence_editor.sequences`.
This PRadds versioning for the rna paths to make sure to use
the new naming scheme. This does mean that in previous versions of blender,
the animations don't show but the data is not lost (even if the file is saved in the older version).

Also do some cleanup of existing python scripts inside the source to use the
new properties.

Part of #132963.

Pull Request: https://projects.blender.org/blender/blender/pulls/133156
2025-01-21 11:30:20 +01:00
Campbell Barton
631495c0e4 Cleanup: sort CMake file lists 2025-01-14 15:45:19 +11:00
John Kiril Swenson
09a65ca669 Cleanup: VSE: Rename SeqConnection to StripConnection and seq_ref to strip_ref
Pull Request: https://projects.blender.org/blender/blender/pulls/132932
2025-01-13 18:16:48 +01:00
John Kiril Swenson
6ac58a5b8a VSE: Auto-include effect chain for copying and metastrip creation
Part of Code Quality Project outlined in #130975.

This patch eschews warning messages urging the user to "select all
related strips" when copying or creating new metastrips and instead
automatically includes those related strips in the operation.

- Attempting to copy or create a metastrip with no strips selected no
  longer delivers a warning.
- When copying strip(s), if there are related effect chains, they will
  be automatically selected and included in the copy if the operation
  succeeds.
  - The decision to select related strips was intentional, as it allows
    the user to easily see the entire effect chain and thus which strips
    were copied.
- When creating a new metastrip, if there are related effect chains,
  they will automatically be included in the resulting metastrip.
  - This is done using a new
    `SEQ_query_strip_connected_and_effect_chain()` iterator. This
    iterator is only used for metastrips, and not copying, since the
    user may wish to only copy single strips in a connection, but
    connected strips should always stay together in a metastrip/seqbase.

Pull Request: https://projects.blender.org/blender/blender/pulls/132930
2025-01-11 20:45:46 +01:00
Aras Pranckevicius
5ef08c2a96 Fix #112586: VSE can't use multi-layer EXR images
The rest of blender does handle multi-layer EXR images, using the
"combined" or RGBA/RGB layers when the visual result is needed. Make
VSE do the same.

While fixing this, I found several issues in other not well tested code
and had to fix them:

- IMB_buffer_float_from_float_threaded was wrongly using source channels
  as destination channels, producing garbage result.
- IMB_scale_into_new was not assigning channels to destination image.

Pull Request: https://projects.blender.org/blender/blender/pulls/132790
2025-01-08 10:45:24 +01:00
Falk David
a9c87a15fc Cleanup: VSE: Rename SequenceColorTag to StripColorTag and flags
Also rename the flags from `SEQUENCE_COLOR_*` to `STRIP_COLOR_*`.
2025-01-07 17:19:24 +01:00
Falk David
ff99dcdf0d Cleanup: VSE: Use explicit type of Span 2025-01-07 17:10:12 +01:00
Falk David
63d3573c2b Cleanup: VSE: Rename occurences of sequence in lookup code
Rename `sequence` -> `strip` for all the lookup code for strips.
2025-01-07 17:04:00 +01:00
Falk David
9421d4f623 Cleanup: VSE: Remove unused declaration in header 2025-01-07 17:04:00 +01:00
Falk David
32a1de9f78 Cleanup: VSE: Rename SEQ macros to STRIP
Rename `SEQ` macros (that refer to strips) to `STRIP`.
2025-01-07 17:04:00 +01:00
Falk David
c9772fee13 Fix: Build error after cleanup commit
Broken by ff91c27481.
2025-01-07 16:27:59 +01:00
Falk David
ff91c27481 Cleanup: VSE: Rename SequenceType to StripType as well as flags
Rename the flags from `SEQ_TYPE_*` to `STRIP_TYPE_*`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132753
2025-01-07 16:10:36 +01:00
Falk David
82cfa92233 Cleanup: VSE: Rename seq_ functions/variables to strip_
This should only rename functions and variables that are
referring to (operations on) a single `Strip`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132748
2025-01-07 16:03:11 +01:00
Falk David
8541296e9d Cleanup: VSE: Rename Strip *seq variables to strip
This only renames variables named `seq` and not other variants,
like `seq_*` or `seq1`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132736
2025-01-07 14:09:45 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Aras Pranckevicius
016167e8f3 Fix #132529: VSE strip scaled to 0.0 occludes strips below it
The "does a strip cover whole screen" logic did not handle the case
of completely zero size strip, and thus was wrongly deciding
that the strip is opaque.

Pull Request: https://projects.blender.org/blender/blender/pulls/132714
2025-01-07 10:01:11 +01:00
Aras Pranckevicius
ab1fc88f2e Fix #132646: VSE proxy strip incorrectly occludes strips below it
Depending on proxy size and scaling factor, the "does proxy cover
whole screen" code was producing wrong results, due to mismatched
resolutions it was working on: SeqRenderData at that point contains
proxy resolution (reduced), but SEQ_image_transform_final_quad_get
works at full resolution. The produced quad needs to be scaled down
to what the render context is operating at.
2025-01-07 10:01:10 +01:00