Commit Graph

478 Commits

Author SHA1 Message Date
Campbell Barton
f8dea82aaa Cleanup: rename seq_cache_relink_keys to seq_cache_key_unlink
The term relink made some sense when when two links were passed in.
As this removes the link, use the term "unlink" (matching listbase API).
2023-07-13 13:25:40 +10:00
Richard Antalik
5f17e0c796 VSE: Optimize cache linking
Pass key that is being removed to `seq_cache_relink_keys()`. This allows
to remove checks before calling the function. Also makes it possible to
assert, that links are actually pointing where they should be.
2023-07-12 10:50:45 +02:00
Campbell Barton
d5c2c98314 Cleanup: remove redundant call to seq_cache_relink_keys
When all keys are removed there is no need to update links.
2023-07-12 12:41:33 +10:00
Richard Antalik
02c87b1740 Fix possible use after free in VSE cache
Use `BLI_ghash_insert` instead of `BLI_ghash_reinsert` to store images.

VSE links stored cache keys for each frame in style of linked list.
These links must be maintained when any image/key is removed from the
cache. Reinserting can free key without proper relinking, which would
lead to accessing this freed key when cache limiting frees images in
a frame.

This should not happen since reinserting is prevented in
`seq_cache_put()`, but it's safer to assert, that key is not stored in
hash instead.
2023-07-12 03:36:14 +02:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Sergey Sharybin
d579ac2b3f Refactor: Use ImBuf to store passes in RenderResult
Doing so avoids having duplicated logic for working with pixel
data which is being passed throughout the render pipeline.

Notable changes:

- ImBug can now store GPU texture.
  This is not very finished part of the API, which will be
  worked further to support tiling for very-high-res images.

- Implicit sharing is removed from the image buffer, as it is
  no longer needed.

There should be no functional changes on user level with this
change.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109788
2023-07-10 16:33:32 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Campbell Barton
7e24a0a2ec Fix invalid address-of operator (hidden by a cast)
While in practice this didn't cause problems,
it's misleading & unnecessary.
2023-07-10 12:37:44 +10:00
Campbell Barton
7271ceb057 Fix memory leak when there are unexpectedly more than MAXSEQ strips 2023-07-10 12:37:44 +10:00
Campbell Barton
0b5eb86e2c Cleanup: check the result of BLI_findindex against -1 instead of < 0
There is only one error value, prefer a specific check.
2023-07-10 12:37:44 +10:00
Ray Molenkamp
f0ee4c3ffe Cleanup: Cmake: use alias target for bf_intern_atomic
This introduces an alias target `bf::intern::atomic` for
`bf_intern_atomic`. This has the following benefits:

- Any target name with `::` in it will be recognized as an actual
target by cmake, rather than a library name it may not know about.
and will be validated by cmake to exist. Which means if you make
a typo in the LIB section, CMake will error out telling you it
doesn't know about this specific target rather than passing it on
to the build system, where you'll either get build or linker errors
because of said typo.

- Given there is quite a cleanup still to do in the build system,
it won't always be obvious which targets have been updated to
modern targets and which still need to be done. Having a namespaced
target name is a good indicator there.

Pull Request: https://projects.blender.org/blender/blender/pulls/109784
2023-07-07 15:37:02 +02:00
Campbell Barton
d7cfa51e49 Cleanup: declare const variables 2023-07-07 16:00:50 +10:00
Campbell Barton
1b84135fb5 Fix sequencer image cache holding references to freed keys
In some cases, freeing the image cache keys would not update
next/previous links - causing future updates to reference freed memory.

Also assert the `last_key` is never points to freed memory.
2023-07-05 16:49:56 +10:00
Campbell Barton
3195a4cef1 Fix use-after free while transforming sequence strips
Resolve use after free & potential double-free introduced in [0].

[0]: fd51d2f97c
2023-07-05 14:59:24 +10:00
Sergey Sharybin
e1b60fdb91 Remove Z Buffer from ImBuf
It was only used by OpenEXR and Iris images, and saving the Z Buffer
in those formats was disabled by default. This option comes from the
times prior to the addition of the Multilayer EXR.

It also worth noting that it was not possible to save Iris with Depth
pass from Blender as internally it is called IRIZ format and it was
not exposed. But even after exposing this format option something still
was missing as saving and loading ITIZ did not show up the Depth pass.

The reason of removal is to make it a more clear match of the ImBuf
with a render pass, and use it instead of a custom type in the render
result and render pass API. This will simplify the API and also avoid
stealing buffers and making shallow copies when showing the render
result.

For the cases when Depth is needed a Multilayer EXR is to be used,
as most likely more than just the Depth will be needed.

On a user level this change:

- Removes the "Z Buffer" option from the interface.

- It preserves existing sockets in compositor nodes, but it will
  output black image. Also changing the image data-block will
  remove the socket unless a Multilayer EXR with Depth pass image
  is selected.

- Removes "Depth" socket of the Viewer and Composite nodes.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109687
2023-07-04 17:03:02 +02:00
Ray molenkamp
2dac20e35f CMake/Cleanup: Use bf_intern_atomic target
Use the bf_intern_atomic target rather than adding a relative path
to it in the INC section.

Pull Request: https://projects.blender.org/blender/blender/pulls/109424
2023-06-28 19:12:55 +02:00
Campbell Barton
2f1230593c Cleanup: use nullptr, function style casts, use ELEM macro 2023-06-28 12:17:06 +10:00
Richard Antalik
91ff6457be Fix VSE ensuring handle adds duplicate handle.
This happened, because `SEQ_retiming_find_segment_start_handle()` does
not consider last handle as valid return value, so it was never checked
against.
2023-06-27 12:52:27 +02:00
Richard Antalik
438ff8fd04 VSE: Ensure retiming handle at strip right handle
When strip is split it is hard to add new retiming handle to it's end.
Ensuring this handle exists greatly improves workflow.
2023-06-26 18:26:58 +02:00
Sergey Sharybin
d8cc8fcf7f Refactor: Move color space information to ImBuf buffers
Before this change the ImBuf struct had dedicated fields for the
buffer data. Now the color space is stored inside of the struct
which wraps around the buffer information.

This only changes the field placement, without changing the way
it is handled. In the future one might imagine that operations
like stealing buffer data should null-ify the buffer colorspace
pointer. Such changes would need to have more accurate thinking
before implementation.

Should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109291
2023-06-23 15:55:42 +02:00
Richard Antalik
c1e7c02f14 Fix #109213: Retime tool value slider crash blender
Crash caused by reading beyond boundary of allocated memory.
2023-06-22 19:19:34 +02:00
Bastien Montagne
738264c7d6 Merge remote-tracking branch 'upstream/blender-v3.6-release'
Conflicts:
	source/blender/editors/uvedit/uvedit_select.cc
2023-06-21 16:47:05 +02:00
Damien Picard
386c653855 I18n: translate new sequence strip names
Newly added sequence strip names can be translated as user data. This
commit adds the appropriate `DATA_()` macros.

Pull Request: https://projects.blender.org/blender/blender/pulls/109058
2023-06-21 16:41:13 +02:00
Campbell Barton
65f99397ec License headers: use SPDX-FileCopyrightText in all sources 2023-06-15 13:35:34 +10:00
Guillermo Venegas
43a0f22be2 Cleanup: Move space sequencer files to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/108959
2023-06-14 18:36:17 +02:00
Richard Antalik
58d8a2ed67 Revert "Merge branch 'blender-v3.6-release'"
This reverts commit 01f0f8b86c, reversing
changes made to 26b5de6865.
2023-06-14 04:47:53 +02:00
Richard Antalik
01f0f8b86c Merge branch 'blender-v3.6-release' 2023-06-14 04:41:57 +02:00
Richard Antalik
b77e7480ef VSE: Remove retiming tool for 3.6 release
This reverts commits:
e1f6587f12
b4100ed377
6749593aec
a97cae3efc
559898709f
e4eb9e04e0
bb1c503bee
b21695a507
7bf56e5c75
4dc026ec8e
354ef89d20

Reason for reverting is to not introduce this feature with current UI.

Pull Request: https://projects.blender.org/blender/blender/pulls/108870
2023-06-14 04:25:52 +02:00
Richard Antalik
f4d6edd476 VSE: Add "Set Speed" gizmo to retiming tool
This gizmo is now responsible for drawing labels with speed of retimed
segments. By clicking on the value it is possible to type in new speed,
which is more convenient, than dragging handles by hand.

Note: Due to granularity of frames, the precise value may not be
respected.

Pull Request: https://projects.blender.org/blender/blender/pulls/108422
2023-06-12 02:30:41 +02:00
Campbell Barton
6704881708 Cleanup: spelling in comments 2023-06-07 21:47:45 +10:00
Campbell Barton
87ff8ee09a Cleanup: disambiguate the term 'path'
Use filepath or dirpath, unless the contents might be either,
in that case note that the contents could be both.
Use `rna_path*` in some cases too.
2023-06-05 10:57:34 +10:00
Campbell Barton
74dd0ed09e Cleanup: remove redundant struct qualifiers 2023-06-03 08:54:37 +10:00
Richard Antalik
6d215b87ce VSE: Freeze frame feature for retiming tool
Freeze frames can be added now using retiming tool with no need to hold
splitting strips or using hold offsets. To use this feature, add
retiming handle where you want to freeze the frame, hold ctrl key and
drag the handle. It is not possible to freeze frame of transition handle
and it is not possible to add transition to or from freeze frame.
Retiming system would handle these cases, but they are not useful in
practice.

When freeze frame is created, start handle of frozen segment is flagged
as `FREEZE_FRAME`. Most handling is similar to `SPEED_TRANSITION`
type handle. For evaluation, there is no special case for this type, as
it's just 2 handles with same `retiming_factor` value. It is possible to
recreate this behavior without using freeze frame feature by adding
handle between 2 consecutive content frames, but this would not be
recognized by UI or treated as freeze frame segment/handle.

Eventually this feature should replace hold offsets, leaving `Sequence`
struct with single offset type, see PR 105620 for reference.
2023-06-02 18:02:14 +02:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton
99acfea0c4 Cleanup: avoid term 'str' or 'string' for string variables
Use: path, filepath or label instead.
2023-05-30 10:34:10 +10:00
Campbell Barton
65cc4cd774 Merge branch 'blender-v3.6-release' 2023-05-30 10:19:26 +10:00
Campbell Barton
0a125fccf4 Fix sequencer multi-view context check
Own regression caused by [0] made to ensure the string was initialized,
without accounting for it being static & reused between calls.

Replace static variables with a struct that's passed to the function,
this explicitly shares state between calls as this static variable use
depended on BKE_scene_multiview_view_prefix_get always clearing prefix
variables with a zero view_id so future calls would also be cleared.

While this non-obvious behavior could be documented,
use more straightforward logic.

[0]: bdad2c0595
2023-05-30 10:11:46 +10:00
Richard Antalik
0542705218 Merge branch 'blender-v3.6-release' 2023-05-29 14:52:50 +02:00
Richard Antalik
97d9e078b3 Fix #108094: VSE relative paths do not work with linked scenes
Use `ID_BLEND_PATH_FROM_GLOBAL` instead of
`BKE_main_blendfile_path_from_global`.

Pull Request: https://projects.blender.org/blender/blender/pulls/108251
2023-05-29 14:50:50 +02:00
Campbell Barton
26e1d63b67 Cleanup: rename fname to filepath or failname depending on use 2023-05-27 15:38:15 +10:00
Campbell Barton
14a7c5afac Cleanup: remove outdated comments 2023-05-24 11:21:19 +10:00
Campbell Barton
13c815085b Cleanup: spelling in comments 2023-05-24 11:21:18 +10:00
Sergey Sharybin
a5677d225b Refactor Render Result to allow implicit buffer sharing
Allows to share buffer data between the render result and image buffers.

The storage of the passes and buffers in the render result have been
wrapped into utility structures, with functions to operate on them.

Currently only image buffers which are sharing buffers with the render
results are using the implicit sharing. This allows proper decoupling of
the image buffers from the lifetime of the underlying render result.

Fixes #107248: Compositor ACCESS VIOLATION when updating datablocks from handlers

Additionally, this lowers the memory usage of multi-layer EXR sequences
by avoiding having two copies of render passes in memory.

It is possible to use implicit sharing in more places, but needs
some API to ensure the render result is the only owner of data before
writing to its pixels.

Pull Request: https://projects.blender.org/blender/blender/pulls/108045
2023-05-23 09:19:37 +02:00
Campbell Barton
8ad2ee7f12 Cleanup: function style C++ casts, use printing & ELEM macros 2023-05-19 11:35:59 +10:00
Sergey Sharybin
406cfd214a Refactor ImBuf buffer access
The goal is to make it more explicit and centralized operation to
assign and steal buffer data, with proper ownership tracking.

The buffers and ownership flags are wrapped into their dedicated
structures now.

There should be no functional changes currently, it is a preparation
for allowing implicit sharing of the ImBuf buffers. Additionally, in
the future it is possible to more buffer-specific information (such
as color space) next to the buffer data itself. It is also possible
to clean up the allocation flags (IB_rect, ...) to give them more
clear naming and not have stored in the ImBuf->flags as they are only
needed for allocation.

The most dangerous part of this change is the change of byte buffer
data from `int*` to `uint8_t*`. In a lot of cases the byte buffer was
cast to `uchar*`, so those casts are now gone. But some code is
operating on `int*` so now there are casts in there. In practice this
should be fine, since we only support 64bit platforms, so allocations
are aligned. The real things to watch out for here is the fact that
allocation and offsetting from the byte buffer now need an explicit 4
channel multiplier.

Once everything is C++ it will be possible to simplify public
functions even further.

Pull Request: https://projects.blender.org/blender/blender/pulls/107609
2023-05-18 10:19:01 +02:00
Bastien Montagne
a9193a9ad2 Refactor ID liblinking on readfile to take ID pointer.
The usage of the lib pointer was cryptic to say the least, it was
essentialy used to allow or not local IDs results in the mapping
old_id_pointer -> new_id_pointer lookup result.

Now:
- Explicitely pass a boolean to allow or not local ID as result in
  lower-level code.
- Pass the 'self ID' pointer instead of its library to the whole
  liblinking code (that was already the case in a few places).

Note that naming of the 'self id' pointer is currently very inconsistent
throughout the readfile liblink code, this will have to be cleaned up in
a separate step later. For now, `self_id` has been chosen for new code
as it matches the terminology in lib_query code.

The later change can also allow finer handling of lookup on undo, based
on how it was re-read (or not), should the need for this arise.
2023-05-17 16:38:56 +02:00
Richard Antalik
4dc026ec8e VSE: Smooth transition for retiming tool
This feature implements smooth transition between 2 retimed segments.

A transition can be added by dragging retiming handle while holding
shift key. When any handle defining transition is removed, the
transition segment is removed and 2 linear segments are restored to
state before transition was created.

These transitions work with video and sound and changes are reflected
in waveforms with correct seeking, therefore it replaces usage of
`speed_factor` or earlier sound `pitch` property.

Smooth transition is achieved by evaluating Y value of circular arc,
that is tangent to lines of linear retimed segments. Because of this,
when transition length is changed both handles are moved symetrically.
This way it is possible to make transition without affecting content in
linear segments.
When linear segment after transition is further retimed, this shifts
content inside of a transition segment.

To support sound, `SEQ_retiming_sound_animation_data_set` and related
data structures has been updated to build speed table for each smooth
transition segment. Layering of retiming data via meta strips is still
fully supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/107197
2023-05-16 22:33:13 +02:00
Campbell Barton
4e85d17000 Cleanup: use native path separator 2023-05-13 17:38:46 +10:00