[Bf-blender-cvs] [59b7aec9a2d] master: VSE: Add missing NULL check in poll

2023-01-31 Thread Sebastian Parborg
Commit: 59b7aec9a2d785f0db8b6d98d990990b93e45409
Author: Sebastian Parborg
Date:   Tue Jan 31 14:43:17 2023 +0100
Branches: master
https://developer.blender.org/rB59b7aec9a2d785f0db8b6d98d990990b93e45409

VSE: Add missing NULL check in poll

Commit 90e940686692 forgot to add a NULL check for `ed`

===

M   source/blender/editors/space_sequencer/sequencer_edit.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c 
b/source/blender/editors/space_sequencer/sequencer_edit.c
index be4bbc50aa9..c74997def2a 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3594,7 +3594,7 @@ static int 
sequencer_scene_frame_range_update_exec(bContext *C, wmOperator *UNUS
 static bool sequencer_scene_frame_range_update_poll(bContext *C)
 {
   Editing *ed = SEQ_editing_get(CTX_data_scene(C));
-  return (ed->act_seq != NULL && (ed->act_seq->type & SEQ_TYPE_SCENE) != 0);
+  return (ed != NULL && ed->act_seq != NULL && (ed->act_seq->type & 
SEQ_TYPE_SCENE) != 0);
 }
 
 void SEQUENCER_OT_scene_frame_range_update(wmOperatorType *ot)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [79837c5ed4b] master: Fix building with boost >= 1.81

2023-01-04 Thread Sebastian Parborg
Commit: 79837c5ed4b57925bf6c6bb9e7c2248f6f52bbb0
Author: Sebastian Parborg
Date:   Wed Jan 4 15:23:26 2023 +0100
Branches: master
https://developer.blender.org/rB79837c5ed4b57925bf6c6bb9e7c2248f6f52bbb0

Fix building with boost >= 1.81

In boost 1.81 they no longer implicitly include  anymore.

===

M   intern/locale/boost_locale_wrapper.cpp

===

diff --git a/intern/locale/boost_locale_wrapper.cpp 
b/intern/locale/boost_locale_wrapper.cpp
index fb0e194352a..80e8d89799a 100644
--- a/intern/locale/boost_locale_wrapper.cpp
+++ b/intern/locale/boost_locale_wrapper.cpp
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include "boost_locale_wrapper.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [98fc2aa93f1] temp-asset-representation: Fix support for building with ffmpeg < 5.0

2022-11-08 Thread Sebastian Parborg
Commit: 98fc2aa93f1f699744ce7caca5c4032de2786fb5
Author: Sebastian Parborg
Date:   Mon Nov 7 17:44:14 2022 +0100
Branches: temp-asset-representation
https://developer.blender.org/rB98fc2aa93f1f699744ce7caca5c4032de2786fb5

Fix support for building with ffmpeg < 5.0

Seems like the new audio channel api was not as backwards compatible as we 
thought.
Therefore we need to reintroduce the usage of the old api to make older ffmpeg 
version be able to compile Blender.

This change is only intended to stick around for two releases or so. After that 
we hope that most Linux distros ship
ffmpeg >=5.0 so we can switch to it.

Reviewed By: Sergey

Differential Revision: http://developer.blender.org/D16408

===

M   intern/ffmpeg/CMakeLists.txt
M   intern/ffmpeg/ffmpeg_compat.h
M   intern/ffmpeg/tests/ffmpeg_codecs.cc
M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/intern/ffmpeg/CMakeLists.txt b/intern/ffmpeg/CMakeLists.txt
index 0de8496f3f3..4fb5df9d4cd 100644
--- a/intern/ffmpeg/CMakeLists.txt
+++ b/intern/ffmpeg/CMakeLists.txt
@@ -6,6 +6,7 @@ if(WITH_GTESTS)
 tests/ffmpeg_codecs.cc
   )
   set(TEST_INC
+.
   )
   set(TEST_INC_SYS
 ${FFMPEG_INCLUDE_DIRS}
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index f311e04d8e0..f7d87af8bca 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -36,6 +36,14 @@
 #  define FFMPEG_INLINE static inline
 #endif
 
+#if (LIBAVFORMAT_VERSION_MAJOR < 59)
+/* For versions older than ffmpeg 5.0, use the old channel layout variables.
+ * We intend to only keep this  workaround for around two releases (3.5, 3.6).
+ * If it sticks around any longer, then we should consider refactoring this.
+ */
+#  define FFMPEG_USE_OLD_CHANNEL_VARS
+#endif
+
 #if (LIBAVFORMAT_VERSION_MAJOR < 58) || \
 ((LIBAVFORMAT_VERSION_MAJOR == 58) && (LIBAVFORMAT_VERSION_MINOR < 76))
 #  define FFMPEG_USE_DURATION_WORKAROUND 1
diff --git a/intern/ffmpeg/tests/ffmpeg_codecs.cc 
b/intern/ffmpeg/tests/ffmpeg_codecs.cc
index 10cbe4b938b..cd06917f59b 100644
--- a/intern/ffmpeg/tests/ffmpeg_codecs.cc
+++ b/intern/ffmpeg/tests/ffmpeg_codecs.cc
@@ -3,6 +3,8 @@
 #include "testing/testing.h"
 
 extern "C" {
+#include "ffmpeg_compat.h"
+
 #include 
 #include 
 #include 
@@ -40,7 +42,11 @@ bool test_acodec(const AVCodec *codec, AVSampleFormat fmt)
 if (ctx) {
   ctx->sample_fmt = fmt;
   ctx->sample_rate = 48000;
+#ifdef FFMPEG_USE_OLD_CHANNEL_VARS
+  ctx->channel_layout = AV_CH_LAYOUT_MONO;
+#else
   av_channel_layout_from_mask(&ctx->ch_layout, AV_CH_LAYOUT_MONO);
+#endif
   ctx->bit_rate = 128000;
   int open = avcodec_open2(ctx, codec, NULL);
   if (open >= 0) {
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index d71db8f71a5..4c11a2896a8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -141,18 +141,25 @@ static int write_audio_frame(FFMpegContext *context)
   frame->pts = context->audio_time / av_q2d(c->time_base);
   frame->nb_samples = context->audio_input_samples;
   frame->format = c->sample_fmt;
+#ifdef FFMPEG_USE_OLD_CHANNEL_VARS
+  frame->channels = c->channels;
+  frame->channel_layout = c->channel_layout;
+  const int num_channels = c->channels;
+#else
   av_channel_layout_copy(&frame->ch_layout, &c->ch_layout);
+  const int num_channels = c->ch_layout.nb_channels;
+#endif
 
   if (context->audio_deinterleave) {
 int channel, i;
 uint8_t *temp;
 
-for (channel = 0; channel < c->ch_layout.nb_channels; channel++) {
+for (channel = 0; channel < num_channels; channel++) {
   for (i = 0; i < frame->nb_samples; i++) {
 memcpy(context->audio_deinterleave_buffer +
(i + channel * frame->nb_samples) * 
context->audio_sample_size,
context->audio_input_buffer +
-   (c->ch_layout.nb_channels * i + channel) * 
context->audio_sample_size,
+   (num_channels * i + channel) * context->audio_sample_size,
context->audio_sample_size);
   }
 }
@@ -163,10 +170,10 @@ static int write_audio_frame(FFMpegContext *context)
   }
 
   avcodec_fill_audio_frame(frame,
-   c->ch_layout.nb_channels,
+   num_channels,
c->sample_fmt,
context->audio_input_buffer,
-   context->audio_input_samples * 
c->ch_layout.nb_channels *
+   context->audio_input_samples * num_channels *
   

[Bf-blender-cvs] [3e71220efcc] master: Fix support for building with ffmpeg < 5.0

2022-11-07 Thread Sebastian Parborg
Commit: 3e71220efcc11afaedb33a1cb2c9d3cd2cb50228
Author: Sebastian Parborg
Date:   Mon Nov 7 17:44:14 2022 +0100
Branches: master
https://developer.blender.org/rB3e71220efcc11afaedb33a1cb2c9d3cd2cb50228

Fix support for building with ffmpeg < 5.0

Seems like the new audio channel api was not as backwards compatible as we 
thought.
Therefore we need to reintroduce the usage of the old api to make older ffmpeg 
version be able to compile Blender.

This change is only intended to stick around for two releases or so. After that 
we hope that most Linux distros ship
ffmpeg >=5.0 so we can switch to it.

Reviewed By: Sergey

Differential Revision: http://developer.blender.org/D16408

===

M   intern/ffmpeg/CMakeLists.txt
M   intern/ffmpeg/ffmpeg_compat.h
M   intern/ffmpeg/tests/ffmpeg_codecs.cc
M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/intern/ffmpeg/CMakeLists.txt b/intern/ffmpeg/CMakeLists.txt
index 0de8496f3f3..4fb5df9d4cd 100644
--- a/intern/ffmpeg/CMakeLists.txt
+++ b/intern/ffmpeg/CMakeLists.txt
@@ -6,6 +6,7 @@ if(WITH_GTESTS)
 tests/ffmpeg_codecs.cc
   )
   set(TEST_INC
+.
   )
   set(TEST_INC_SYS
 ${FFMPEG_INCLUDE_DIRS}
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
index f311e04d8e0..f7d87af8bca 100644
--- a/intern/ffmpeg/ffmpeg_compat.h
+++ b/intern/ffmpeg/ffmpeg_compat.h
@@ -36,6 +36,14 @@
 #  define FFMPEG_INLINE static inline
 #endif
 
+#if (LIBAVFORMAT_VERSION_MAJOR < 59)
+/* For versions older than ffmpeg 5.0, use the old channel layout variables.
+ * We intend to only keep this  workaround for around two releases (3.5, 3.6).
+ * If it sticks around any longer, then we should consider refactoring this.
+ */
+#  define FFMPEG_USE_OLD_CHANNEL_VARS
+#endif
+
 #if (LIBAVFORMAT_VERSION_MAJOR < 58) || \
 ((LIBAVFORMAT_VERSION_MAJOR == 58) && (LIBAVFORMAT_VERSION_MINOR < 76))
 #  define FFMPEG_USE_DURATION_WORKAROUND 1
diff --git a/intern/ffmpeg/tests/ffmpeg_codecs.cc 
b/intern/ffmpeg/tests/ffmpeg_codecs.cc
index 10cbe4b938b..cd06917f59b 100644
--- a/intern/ffmpeg/tests/ffmpeg_codecs.cc
+++ b/intern/ffmpeg/tests/ffmpeg_codecs.cc
@@ -3,6 +3,8 @@
 #include "testing/testing.h"
 
 extern "C" {
+#include "ffmpeg_compat.h"
+
 #include 
 #include 
 #include 
@@ -40,7 +42,11 @@ bool test_acodec(const AVCodec *codec, AVSampleFormat fmt)
 if (ctx) {
   ctx->sample_fmt = fmt;
   ctx->sample_rate = 48000;
+#ifdef FFMPEG_USE_OLD_CHANNEL_VARS
+  ctx->channel_layout = AV_CH_LAYOUT_MONO;
+#else
   av_channel_layout_from_mask(&ctx->ch_layout, AV_CH_LAYOUT_MONO);
+#endif
   ctx->bit_rate = 128000;
   int open = avcodec_open2(ctx, codec, NULL);
   if (open >= 0) {
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index d71db8f71a5..4c11a2896a8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -141,18 +141,25 @@ static int write_audio_frame(FFMpegContext *context)
   frame->pts = context->audio_time / av_q2d(c->time_base);
   frame->nb_samples = context->audio_input_samples;
   frame->format = c->sample_fmt;
+#ifdef FFMPEG_USE_OLD_CHANNEL_VARS
+  frame->channels = c->channels;
+  frame->channel_layout = c->channel_layout;
+  const int num_channels = c->channels;
+#else
   av_channel_layout_copy(&frame->ch_layout, &c->ch_layout);
+  const int num_channels = c->ch_layout.nb_channels;
+#endif
 
   if (context->audio_deinterleave) {
 int channel, i;
 uint8_t *temp;
 
-for (channel = 0; channel < c->ch_layout.nb_channels; channel++) {
+for (channel = 0; channel < num_channels; channel++) {
   for (i = 0; i < frame->nb_samples; i++) {
 memcpy(context->audio_deinterleave_buffer +
(i + channel * frame->nb_samples) * 
context->audio_sample_size,
context->audio_input_buffer +
-   (c->ch_layout.nb_channels * i + channel) * 
context->audio_sample_size,
+   (num_channels * i + channel) * context->audio_sample_size,
context->audio_sample_size);
   }
 }
@@ -163,10 +170,10 @@ static int write_audio_frame(FFMpegContext *context)
   }
 
   avcodec_fill_audio_frame(frame,
-   c->ch_layout.nb_channels,
+   num_channels,
c->sample_fmt,
context->audio_input_buffer,
-   context->audio_input_samples * 
c->ch_layout.nb_channels *
+   context->audio_input_samples * num_channels *
contex

[Bf-blender-cvs] [c4255992163] master: Fix linker order of X11 and Wayland libs

2022-10-11 Thread Sebastian Parborg
Commit: c4255992163da64e3fab7b8fe196cb119dffccc2
Author: Sebastian Parborg
Date:   Tue Oct 11 14:52:35 2022 +0200
Branches: master
https://developer.blender.org/rBc4255992163da64e3fab7b8fe196cb119dffccc2

Fix linker order of X11 and Wayland libs

For some compiler and linker configurations, linking would fail as the
wayland libs were linked at a high level and not at the actual code
where they were needed.

After talking to Campbell, we decided to clean up this part and now
only link both the X11 and Wayland libs where they are used.

===

M   build_files/cmake/platform/platform_unix.cmake
M   intern/ghost/CMakeLists.txt

===

diff --git a/build_files/cmake/platform/platform_unix.cmake 
b/build_files/cmake/platform/platform_unix.cmake
index 0b137ae93d6..7b7937959bf 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -778,31 +778,11 @@ if(WITH_GHOST_WAYLAND)
   endif()
 endif()
 
-list(APPEND PLATFORM_LINKLIBS
-  ${xkbcommon_LINK_LIBRARIES}
-)
-
-if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
-  list(APPEND PLATFORM_LINKLIBS
-${wayland-client_LINK_LIBRARIES}
-${wayland-egl_LINK_LIBRARIES}
-${wayland-cursor_LINK_LIBRARIES}
-  )
-endif()
-
 if(WITH_GHOST_WAYLAND_DBUS)
-  list(APPEND PLATFORM_LINKLIBS
-${dbus_LINK_LIBRARIES}
-  )
   add_definitions(-DWITH_GHOST_WAYLAND_DBUS)
 endif()
 
 if(WITH_GHOST_WAYLAND_LIBDECOR)
-  if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
-list(APPEND PLATFORM_LINKLIBS
-  ${libdecor_LIBRARIES}
-)
-  endif()
   add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
 endif()
 
@@ -855,12 +835,8 @@ if(WITH_GHOST_X11)
   find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h 
${X11_INC_SEARCH_PATH})
   mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
 
-  list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
-
   if(WITH_X11_XINPUT)
-if(X11_Xinput_LIB)
-  list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
-else()
+if(NOT X11_Xinput_LIB)
   message(FATAL_ERROR "LibXi not found. Disable WITH_X11_XINPUT if you
   want to build without tablet support")
 endif()
@@ -870,18 +846,14 @@ if(WITH_GHOST_X11)
 # XXX, why doesn't cmake make this available?
 find_library(X11_Xxf86vmode_LIB Xxf86vm   ${X11_LIB_SEARCH_PATH})
 mark_as_advanced(X11_Xxf86vmode_LIB)
-if(X11_Xxf86vmode_LIB)
-  list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
-else()
+if(NOT X11_Xxf86vmode_LIB)
   message(FATAL_ERROR "libXxf86vm not found. Disable WITH_X11_XF86VMODE if 
you
   want to build without")
 endif()
   endif()
 
   if(WITH_X11_XFIXES)
-if(X11_Xfixes_LIB)
-  list(APPEND PLATFORM_LINKLIBS ${X11_Xfixes_LIB})
-else()
+if(NOT X11_Xfixes_LIB)
   message(FATAL_ERROR "libXfixes not found. Disable WITH_X11_XFIXES if you
   want to build without")
 endif()
@@ -890,9 +862,7 @@ if(WITH_GHOST_X11)
   if(WITH_X11_ALPHA)
 find_library(X11_Xrender_LIB Xrender  ${X11_LIB_SEARCH_PATH})
 mark_as_advanced(X11_Xrender_LIB)
-if(X11_Xrender_LIB)
-  list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
-else()
+if(NOT X11_Xrender_LIB)
   message(FATAL_ERROR "libXrender not found. Disable WITH_X11_ALPHA if you
   want to build without")
 endif()
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index aa23618ca39..9e3a15dd543 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -262,6 +262,9 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
   ${xkbcommon_INCLUDE_DIRS}
   ${wayland-cursor_INCLUDE_DIRS}
 )
+list(APPEND LIB
+  ${xkbcommon_LINK_LIBRARIES}
+)
 
 if(WITH_GHOST_WAYLAND_DYNLOAD)
   list(APPEND INC_SYS
@@ -271,18 +274,32 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
 bf_intern_wayland_dynload
   )
   add_definitions(-DWITH_GHOST_WAYLAND_DYNLOAD)
+else()
+  list(APPEND LIB
+${wayland-client_LINK_LIBRARIES}
+${wayland-egl_LINK_LIBRARIES}
+${wayland-cursor_LINK_LIBRARIES}
+  )
 endif()
 
 if(WITH_GHOST_WAYLAND_DBUS)
   list(APPEND INC_SYS
 ${dbus_INCLUDE_DIRS}
   )
+  list(APPEND LIB
+${dbus_LINK_LIBRARIES}
+  )
 endif()
 
 if(WITH_GHOST_WAYLAND_LIBDECOR)
   list(APPEND INC_SYS
 ${libdecor_INCLUDE_DIRS}
   )
+  if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
+list(APPEND LIB
+  ${libdecor_LIBRARIES}
+)
+  endif()
 endif()
 
 include(CheckSymbolExists)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [03fd2f7a5a4] master: Fix building WITH_HEADLESS

2022-10-10 Thread Sebastian Parborg
Commit: 03fd2f7a5a4fdb8cf6bdd19e055beffd099648c0
Author: Sebastian Parborg
Date:   Mon Oct 10 18:14:56 2022 +0200
Branches: master
https://developer.blender.org/rB03fd2f7a5a4fdb8cf6bdd19e055beffd099648c0

Fix building WITH_HEADLESS

An earlier commit removed the '#ifdef' check for the function call but not for
the function declaration.

===

M   source/creator/creator_signals.c

===

diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index c016372e6b0..f67c4dde41d 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -66,7 +66,6 @@ static void sig_handle_fpe(int UNUSED(sig))
 #  endif
 
 /* Handling `Ctrl-C` event in the console. */
-#  if !defined(WITH_HEADLESS)
 static void sig_handle_blender_esc(int sig)
 {
   G.is_break = true; /* forces render loop to read queue, not sure if its 
needed */
@@ -81,7 +80,6 @@ static void sig_handle_blender_esc(int sig)
 count++;
   }
 }
-#  endif
 
 static void sig_handle_crash_backtrace(FILE *fp)
 {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7163a834506] master: Fix addons submodule ref

2022-10-06 Thread Sebastian Parborg
Commit: 7163a83450655316900a91c6a24c8abf155c3e71
Author: Sebastian Parborg
Date:   Thu Oct 6 12:51:34 2022 +0200
Branches: master
https://developer.blender.org/rB7163a83450655316900a91c6a24c8abf155c3e71

Fix addons submodule ref

Was downgraded to a version from 2019 by mistake

===

M   release/scripts/addons

===

diff --git a/release/scripts/addons b/release/scripts/addons
index 67f1fbca148..eb09be71a96 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
+Subproject commit eb09be71a96c4fe910fdc43373be5ec08b419d2c

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [050b6498d30] master: Bump submodule versions

2022-09-28 Thread Sebastian Parborg
Commit: 050b6498d308f1d01096888e80b8aa5f99f1fee7
Author: Sebastian Parborg
Date:   Wed Sep 28 13:45:22 2022 +0200
Branches: master
https://developer.blender.org/rB050b6498d308f1d01096888e80b8aa5f99f1fee7

Bump submodule versions

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 1b891478f44..7be7aff5a18 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 1b891478f44dd047c3a92fda3ebd17fae1c3acd3
+Subproject commit 7be7aff5a18c550465b3f7634539ed4168af7c51
diff --git a/release/scripts/addons b/release/scripts/addons
index 67f1fbca148..726d08c9036 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
+Subproject commit 726d08c9036b939f46b59bceb72a61e3102600cc
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 95107484d07..c43c0b2bcf0 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 95107484d076bc965239942e857c83433bfa86d7
+Subproject commit c43c0b2bcf08c34d933c3b56f096c9a23c8eff68
diff --git a/source/tools b/source/tools
index 2a541f164a2..2ab59df2c98 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 2a541f164a222ef7bcd036d37687738acee8d946
+Subproject commit 2ab59df2c987d383a7ed9dbcd4f3897bbba7c12b

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7a239812ca5] master: Fix misleading operator name in the dope-sheet and action editor

2022-09-20 Thread Sebastian Parborg
Commit: 7a239812ca55153fc9751b6a87bc5c4deb76456b
Author: Sebastian Parborg
Date:   Tue Sep 20 10:50:38 2022 +0200
Branches: master
https://developer.blender.org/rB7a239812ca55153fc9751b6a87bc5c4deb76456b

Fix misleading operator name in the dope-sheet and action editor

The operator did not set the any extrapolation mode of the individual
keyframes, it sets it for the whole f-curve. Change the operator name to
reflect that.

===

M   source/blender/editors/space_action/action_edit.c
M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/editors/space_action/action_edit.c 
b/source/blender/editors/space_action/action_edit.c
index 6d880f338f6..0803c5dc575 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1326,7 +1326,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
 void ACTION_OT_extrapolation_type(wmOperatorType *ot)
 {
   /* identifiers */
-  ot->name = "Set Keyframe Extrapolation";
+  ot->name = "Set F-Curve Extrapolation";
   ot->idname = "ACTION_OT_extrapolation_type";
   ot->description = "Set extrapolation mode for selected F-Curves";
 
diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index 39be05618d5..cab491fb8d2 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1448,7 +1448,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator 
*op)
 void GRAPH_OT_extrapolation_type(wmOperatorType *ot)
 {
   /* Identifiers */
-  ot->name = "Set Keyframe Extrapolation";
+  ot->name = "Set F-Curve Extrapolation";
   ot->idname = "GRAPH_OT_extrapolation_type";
   ot->description = "Set extrapolation mode for selected F-Curves";

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1c63e4233d3] master: Cleanup: Fix "unused m_system" warnings

2022-08-17 Thread Sebastian Parborg
Commit: 1c63e4233d3c30cab6d3b627dbdb56c329396c03
Author: Sebastian Parborg
Date:   Wed Aug 17 12:53:32 2022 +0200
Branches: master
https://developer.blender.org/rB1c63e4233d3c30cab6d3b627dbdb56c329396c03

Cleanup: Fix "unused m_system" warnings

The dummy `m_system` variable is not needed in the GHOST_NULL classes

===

M   intern/ghost/intern/GHOST_DisplayManagerNULL.h
M   intern/ghost/intern/GHOST_SystemHeadless.h
M   intern/ghost/intern/GHOST_WindowNULL.h

===

diff --git a/intern/ghost/intern/GHOST_DisplayManagerNULL.h 
b/intern/ghost/intern/GHOST_DisplayManagerNULL.h
index 9adbe17c532..dbef4fafd8f 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerNULL.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerNULL.h
@@ -14,7 +14,7 @@ class GHOST_SystemHeadless;
 
 class GHOST_DisplayManagerNULL : public GHOST_DisplayManager {
  public:
-  GHOST_DisplayManagerNULL(GHOST_SystemHeadless *system) : 
GHOST_DisplayManager(), m_system(system)
+  GHOST_DisplayManagerNULL() : GHOST_DisplayManager()
   { /* nop */
   }
   GHOST_TSuccess getNumDisplays(uint8_t & /*numDisplays*/) const override
@@ -42,7 +42,4 @@ class GHOST_DisplayManagerNULL : public GHOST_DisplayManager {
   {
 return GHOST_kSuccess;
   }
-
- private:
-  GHOST_SystemHeadless *m_system;
 };
diff --git a/intern/ghost/intern/GHOST_SystemHeadless.h 
b/intern/ghost/intern/GHOST_SystemHeadless.h
index 5c5382d6a23..dcf445420a4 100644
--- a/intern/ghost/intern/GHOST_SystemHeadless.h
+++ b/intern/ghost/intern/GHOST_SystemHeadless.h
@@ -126,7 +126,7 @@ class GHOST_SystemHeadless : public GHOST_System {
 GHOST_TSuccess success = GHOST_System::init();
 
 if (success) {
-  m_displayManager = new GHOST_DisplayManagerNULL(this);
+  m_displayManager = new GHOST_DisplayManagerNULL();
 
   if (m_displayManager) {
 return GHOST_kSuccess;
@@ -148,8 +148,7 @@ class GHOST_SystemHeadless : public GHOST_System {
   const bool /*is_dialog*/,
   const GHOST_IWindow *parentWindow) override
   {
-return new GHOST_WindowNULL(this,
-title,
+return new GHOST_WindowNULL(title,
 left,
 top,
 width,
diff --git a/intern/ghost/intern/GHOST_WindowNULL.h 
b/intern/ghost/intern/GHOST_WindowNULL.h
index cfc73d4e783..f9c0a593d5f 100644
--- a/intern/ghost/intern/GHOST_WindowNULL.h
+++ b/intern/ghost/intern/GHOST_WindowNULL.h
@@ -20,8 +20,7 @@ class GHOST_WindowNULL : public GHOST_Window {
 return GHOST_kSuccess;
   }
 
-  GHOST_WindowNULL(GHOST_SystemHeadless *system,
-   const char *title,
+  GHOST_WindowNULL(const char *title,
int32_t /*left*/,
int32_t /*top*/,
uint32_t width,
@@ -30,7 +29,7 @@ class GHOST_WindowNULL : public GHOST_Window {
const GHOST_IWindow * /*parentWindow*/,
GHOST_TDrawingContextType /*type*/,
const bool stereoVisual)
-  : GHOST_Window(width, height, state, stereoVisual, false), 
m_system(system)
+  : GHOST_Window(width, height, state, stereoVisual, false)
   {
 setTitle(title);
   }
@@ -144,8 +143,6 @@ class GHOST_WindowNULL : public GHOST_Window {
   }
 
  private:
-  GHOST_SystemHeadless *m_system;
-
   /**
* \param type: The type of rendering context create.
* \return Indication of success.

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3195a381200] master: Introduce headless OpenGL rendering on Linux

2022-08-15 Thread Sebastian Parborg
Commit: 3195a381200eb98e6add8b0504f701318186946d
Author: Sebastian Parborg
Date:   Mon Aug 15 16:54:29 2022 +0200
Branches: master
https://developer.blender.org/rB3195a381200eb98e6add8b0504f701318186946d

Introduce headless OpenGL rendering on Linux

With this patch true headless OpenGL rendering is now possible on Linux.
It changes the logic of the WITH_HEADLESS build flag.

The headless backend is now always available with regular builds and
Blender will try to fall back to it if it fails to initialize other
backends while in background mode.

The headless backend only works on Linux as EGL is not used on Mac or Windows.
libepoxy does support windows and mac, so this can perhaps be remedied in the 
future.

Reviewed By: Brecht, Jeroen, Campbell

Differential Revision: http://developer.blender.org/D1

===

M   CMakeLists.txt
M   intern/ghost/CMakeLists.txt
M   intern/ghost/GHOST_C-api.h
M   intern/ghost/GHOST_ISystem.h
M   intern/ghost/intern/GHOST_C-api.cpp
M   intern/ghost/intern/GHOST_ContextEGL.cpp
M   intern/ghost/intern/GHOST_DisplayManagerNULL.h
M   intern/ghost/intern/GHOST_ISystem.cpp
A   intern/ghost/intern/GHOST_SystemHeadless.h
D   intern/ghost/intern/GHOST_SystemNULL.h
M   intern/ghost/intern/GHOST_SystemSDL.cpp
M   intern/ghost/intern/GHOST_SystemX11.cpp
M   intern/ghost/intern/GHOST_WindowNULL.h
M   source/blender/windowmanager/intern/wm_init_exit.c
M   source/blender/windowmanager/intern/wm_window.c
M   source/blender/windowmanager/wm_window.h

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f72521266aa..f59a849cbf8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -536,10 +536,6 @@ mark_as_advanced(
   WITH_GPU_BUILDTIME_SHADER_BUILDER
 )
 
-if(WITH_HEADLESS)
-  set(WITH_OPENGL OFF)
-endif()
-
 # Metal
 
 if(APPLE)
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 84b68014e91..099785bafa8 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -103,42 +103,39 @@ if(WITH_INPUT_NDOF)
   )
 endif()
 
-if(WITH_HEADLESS OR WITH_GHOST_SDL)
-  if(WITH_HEADLESS)
-list(APPEND SRC
-  intern/GHOST_DisplayManagerNULL.h
-  intern/GHOST_SystemNULL.h
-  intern/GHOST_WindowNULL.h
+list(APPEND SRC
+  intern/GHOST_DisplayManagerNULL.h
+  intern/GHOST_SystemHeadless.h
+  intern/GHOST_WindowNULL.h
+)
+
+if(WITH_HEADLESS)
+  add_definitions(-DWITH_HEADLESS)
+elseif (WITH_GHOST_SDL)
+  list(APPEND SRC
+intern/GHOST_ContextSDL.cpp
+intern/GHOST_DisplayManagerSDL.cpp
+intern/GHOST_SystemSDL.cpp
+intern/GHOST_WindowSDL.cpp
+
+intern/GHOST_ContextSDL.h
+intern/GHOST_DisplayManagerSDL.h
+intern/GHOST_SystemSDL.h
+intern/GHOST_WindowSDL.h
+  )
+  add_definitions(-DWITH_GHOST_SDL)
+
+  list(APPEND INC_SYS
+${SDL_INCLUDE_DIR}
+  )
+  if(WITH_SDL_DYNLOAD)
+list(APPEND LIB
+  extern_sdlew
 )
-add_definitions(-DWITH_HEADLESS)
   else()
-list(APPEND SRC
-  intern/GHOST_ContextSDL.cpp
-  intern/GHOST_DisplayManagerSDL.cpp
-  intern/GHOST_SystemSDL.cpp
-  intern/GHOST_WindowSDL.cpp
-
-  intern/GHOST_ContextSDL.h
-  intern/GHOST_DisplayManagerSDL.h
-  intern/GHOST_SystemSDL.h
-  intern/GHOST_WindowSDL.h
-)
-add_definitions(-DWITH_GHOST_SDL)
-  endif()
-
-  if(NOT WITH_HEADLESS)
-list(APPEND INC_SYS
-  ${SDL_INCLUDE_DIR}
+list(APPEND LIB
+  ${SDL_LIBRARY}
 )
-if(WITH_SDL_DYNLOAD)
-  list(APPEND LIB
-extern_sdlew
-  )
-else()
-  list(APPEND LIB
-${SDL_LIBRARY}
-  )
-endif()
   endif()
 
 elseif(APPLE AND NOT WITH_GHOST_X11)
@@ -449,7 +446,7 @@ elseif(WIN32)
   endif()
 endif()
 
-if(NOT (WITH_HEADLESS OR WITH_GHOST_SDL))
+if(UNIX AND NOT APPLE)
   list(APPEND SRC
 intern/GHOST_ContextEGL.cpp
 
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 4cbc0d65b11..f01f439718f 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -27,6 +27,7 @@ typedef bool (*GHOST_EventCallbackProcPtr)(GHOST_EventHandle 
event, GHOST_TUserD
  * \return a handle to the system.
  */
 extern GHOST_SystemHandle GHOST_CreateSystem(void);
+extern GHOST_SystemHandle GHOST_CreateSystemBackground(void);
 
 /**
  * Specifies whether debug messages are to be enabled for the specific system 
handle.
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 89878a6d6a1..0dd855bb513 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -120,6 +120,7 @@ class GHOST_ISystem {
* \return An indication of success.
*/
   static GHOST_TSuccess createSystem();
+  static GHOST_TSuccess createSystemBackground();
 
   /**
* Disposes the one and only system.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp 
b/intern/ghost/intern/GHOST_C-api.cpp

[Bf-blender-cvs] [8ffc11dbcb2] master: Cleanup OpenGL linking and related code after libepoxy merge

2022-08-15 Thread Sebastian Parborg
Commit: 8ffc11dbcb21e81634e8f22cd65fdc921c7320d1
Author: Sebastian Parborg
Date:   Mon Aug 15 16:44:24 2022 +0200
Branches: master
https://developer.blender.org/rB8ffc11dbcb21e81634e8f22cd65fdc921c7320d1

Cleanup OpenGL linking and related code after libepoxy merge

This cleans up the OpenGL build flags and linking.
It additionally also removes some dead code.

One of these dead code paths is WITH_X11_ALPHA which actually never was
active even with the build flag on. The call to use this was never
called because the default initializer for GHOST was set to have it off
per default. Nothing called this function with a boolean value to enable it.

These cleanups are needed to support true headless OpenGL rendering.
Without these cleanups libepoxy will fail to load the correct OpenGL
Libraries as we have already linked them to the blender binary.

Reviewed By: Brecht, Campbell, Jeroen

Differential Revision: http://developer.blender.org/D15554

===

M   CMakeLists.txt
D   build_files/cmake/Modules/FindOpenGLES.cmake
M   intern/cycles/app/CMakeLists.txt
M   intern/cycles/blender/CMakeLists.txt
M   intern/cycles/cmake/external_libs.cmake
M   intern/cycles/device/CMakeLists.txt
M   intern/cycles/hydra/CMakeLists.txt
M   intern/cycles/scene/CMakeLists.txt
M   intern/cycles/session/CMakeLists.txt
M   intern/cycles/util/CMakeLists.txt
M   intern/ghost/CMakeLists.txt
M   intern/ghost/GHOST_ISystem.h
M   intern/ghost/GHOST_Types.h
M   intern/ghost/intern/GHOST_ContextCGL.h
M   intern/ghost/intern/GHOST_ContextCGL.mm
M   intern/ghost/intern/GHOST_ContextEGL.cpp
M   intern/ghost/intern/GHOST_ContextEGL.h
M   intern/ghost/intern/GHOST_IXrGraphicsBinding.h
M   intern/ghost/intern/GHOST_System.cpp
M   intern/ghost/intern/GHOST_System.h
M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   intern/ghost/intern/GHOST_SystemWin32.cpp
M   intern/ghost/intern/GHOST_SystemX11.cpp
M   intern/ghost/intern/GHOST_WindowWin32.cpp
M   intern/ghost/intern/GHOST_WindowX11.cpp
M   intern/ghost/intern/GHOST_WindowX11.h
M   intern/ghost/intern/GHOST_XrContext.cpp
M   intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
M   intern/ghost/intern/GHOST_Xr_openxr_includes.h
M   intern/ghost/test/CMakeLists.txt
M   intern/opencolorio/CMakeLists.txt
M   intern/opensubdiv/CMakeLists.txt
M   source/blender/gpencil_modifiers/CMakeLists.txt
M   source/blender/gpu/CMakeLists.txt
M   source/blender/makesrna/intern/CMakeLists.txt
M   source/blender/python/generic/CMakeLists.txt
M   source/blender/python/gpu/CMakeLists.txt
M   source/creator/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd14feaeb25..f72521266aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,13 +25,6 @@ endif()
 
 cmake_minimum_required(VERSION 3.10)
 
-# Prefer LEGACY OpenGL to be compatible with all the existing releases and
-# platforms which don't have GLVND yet. Only do it if preference was not set
-# externally.
-if(NOT DEFINED OpenGL_GL_PREFERENCE)
-  set(OpenGL_GL_PREFERENCE "LEGACY")
-endif()
-
 if(NOT EXECUTABLE_OUTPUT_PATH)
   set(FIRST_RUN TRUE)
 else()
@@ -262,7 +255,6 @@ if(WITH_GHOST_X11)
   option(WITH_X11_XINPUT"Enable X11 Xinput (tablet support and unicode 
input)"  ON)
   option(WITH_X11_XF86VMODE "Enable X11 video mode switching"  
 ON)
   option(WITH_X11_XFIXES"Enable X11 XWayland cursor warping workaround"
 ON)
-  option(WITH_X11_ALPHA "Enable X11 transparent background"
 ON)
 endif()
 
 if(UNIX AND NOT APPLE)
@@ -536,29 +528,11 @@ endif()
 
 # OpenGL
 
-# Experimental EGL option.
-option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform 
specific OpenGL system library (CGL, GLX or WGL)" OFF)
-mark_as_advanced(WITH_GL_EGL)
-
-if(WITH_GHOST_WAYLAND)
-  # Wayland can only use EGL to create OpenGL contexts, not GLX.
-  set(WITH_GL_EGL ON)
-endif()
-
-if(UNIX AND NOT APPLE)
-  option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating 
system" ON)
-else()
-  # System GLES not an option on other platforms.
-  set(WITH_SYSTEM_GLES OFF)
-endif()
-
 option(WITH_OPENGL  "When off limits visibility of the opengl 
headers to just bf_gpu and gawain (temporary option for development purposes)" 
ON)
-option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either 
EGL or the AGL/WGL/XGL 'es20' profile)"   OFF)
 option(WITH_GPU_BUILDTIME_SHADER_BUILDER  "Shader builder is a developer 
option enabling linting on GLSL during compilation" 
 OFF)
 
 mark_as_advanced(
   WITH_OPENGL
-

[Bf-blender-cvs] [3551b0a6721] blender-v3.3-release: Fix T99255: Strips inserting incorrectly

2022-08-15 Thread Sebastian Parborg
Commit: 3551b0a67213c3f35446a9cd673da4aa3b39ff1e
Author: Sebastian Parborg
Date:   Tue Aug 2 19:36:42 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB3551b0a67213c3f35446a9cd673da4aa3b39ff1e

Fix T99255: Strips inserting incorrectly

When dropping file to sequencer timeline, coordinates for strip position
and overlap handling are used even if not set.

Reset internal state in on_drag_start callback and set is_modal
variable only if coordinates are updated. This way when dragging file
from external file browser, strip is added at current frame as before
modal operator was implemented.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D15333

===

M   source/blender/editors/space_sequencer/sequencer_drag_drop.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c 
b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
index f6561cf07b9..4796d80b3a0 100644
--- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c
+++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
@@ -51,7 +51,9 @@
 typedef struct SeqDropCoords {
   float start_frame, channel;
   int strip_len, channel_len;
+  float playback_rate;
   bool in_use;
+  bool has_read_mouse_pos;
   bool is_intersecting;
   bool use_snapping;
   float snap_point_x;
@@ -63,7 +65,7 @@ typedef struct SeqDropCoords {
  * preloading data on drag start.
  * Therefore we will for now use a global variable for this.
  */
-static SeqDropCoords g_drop_coords = {.in_use = false};
+static SeqDropCoords g_drop_coords = {.in_use = false, .has_read_mouse_pos = 
false};
 
 static void generic_poll_operations(const wmEvent *event, uint8_t type)
 {
@@ -82,31 +84,134 @@ static bool image_drop_poll(bContext *UNUSED(C), wmDrag 
*drag, const wmEvent *ev
 }
   }
 
-  return WM_drag_is_ID_type(drag, ID_IM);
+  if (WM_drag_is_ID_type(drag, ID_IM)) {
+generic_poll_operations(event, TH_SEQ_IMAGE);
+return true;
+  }
+
+  return false;
 }
 
-static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+static bool is_movie(wmDrag *drag)
 {
   if (drag->type == WM_DRAG_PATH) {
-if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might 
not work? */
-  generic_poll_operations(event, TH_SEQ_MOVIE);
+if (ELEM(drag->icon, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might 
not work? */
   return true;
 }
   }
+  if (WM_drag_is_ID_type(drag, ID_MC)) {
+return true;
+  }
+  return false;
+}
+
+static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+{
+  if (is_movie(drag)) {
+generic_poll_operations(event, TH_SEQ_MOVIE);
+return true;
+  }
 
-  return WM_drag_is_ID_type(drag, ID_MC);
+  return false;
 }
 
-static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+static bool is_sound(wmDrag *drag)
 {
   if (drag->type == WM_DRAG_PATH) {
 if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might 
not work? */
-  generic_poll_operations(event, TH_SEQ_AUDIO);
   return true;
 }
   }
+  if (WM_drag_is_ID_type(drag, ID_SO)) {
+return true;
+  }
+  return false;
+}
 
-  return WM_drag_is_ID_type(drag, ID_SO);
+static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+{
+  if (is_sound(drag)) {
+generic_poll_operations(event, TH_SEQ_AUDIO);
+return true;
+  }
+
+  return false;
+}
+
+static float update_overlay_strip_position_data(bContext *C, const int mval[2])
+{
+  SeqDropCoords *coords = &g_drop_coords;
+  ARegion *region = CTX_wm_region(C);
+  Scene *scene = CTX_data_scene(C);
+  int hand;
+  View2D *v2d = ®ion->v2d;
+
+  /* Update the position were we would place the strip if we complete the drag 
and drop action.
+   */
+  UI_view2d_region_to_view(v2d, mval[0], mval[1], &coords->start_frame, 
&coords->channel);
+  coords->start_frame = roundf(coords->start_frame);
+  if (coords->channel < 1.0f) {
+coords->channel = 1;
+  }
+
+  float start_frame = coords->start_frame;
+  float end_frame;
+  float strip_len;
+
+  if (coords->playback_rate != 0.0f) {
+float scene_playback_rate = (float)scene->r.frs_sec / 
scene->r.frs_sec_base;
+strip_len = coords->strip_len / (coords->playback_rate / 
scene_playback_rate);
+  }
+  else {
+strip_len = coords->strip_len;
+  }
+
+  end_frame = coords->start_frame + strip_len;
+
+  if (coords->use_snapping) {
+/* Do snapping via the existing transform code. */
+int snap_delta;
+float snap_frame;
+bool valid_snap;
+
+valid_snap = ED_transform_snap_sequencer_to_closest_strip_calc(
+scene, region, start_frame, end_frame, &snap_delta, &snap_frame);
+
+if (valid_snap) {
+  /* We s

[Bf-blender-cvs] [3de18e16ddf] master: Merge branch 'blender-v3.3-release'

2022-08-12 Thread Sebastian Parborg
Commit: 3de18e16ddf4999724c77a0a33004283b7fb7a70
Author: Sebastian Parborg
Date:   Fri Aug 12 17:57:10 2022 +0200
Branches: master
https://developer.blender.org/rB3de18e16ddf4999724c77a0a33004283b7fb7a70

Merge branch 'blender-v3.3-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c1c0473a7ef] blender-v3.3-release: Fix out of bounds read in LineArt if there are only interestion edges

2022-08-12 Thread Sebastian Parborg
Commit: c1c0473a7efb5dc6455401799e3f3e8282aa31df
Author: Sebastian Parborg
Date:   Fri Aug 12 17:52:15 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBc1c0473a7efb5dc6455401799e3f3e8282aa31df

Fix out of bounds read in LineArt if there are only interestion edges

In this case the array allocation would allocate an array of size zero.
This would then later lead to out of bounds memory reads.

Now the code will skip zero length allocations.

===

M   source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c

===

diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c 
b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 9970e4d5ac1..a6b9f1420f1 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1799,7 +1799,7 @@ static void 
lineart_add_edge_to_array_thread(LineartObjectInfo *obi, LineartEdge
  * #pe.  */
 void lineart_finalize_object_edge_array_reserve(LineartPendingEdges *pe, int 
count)
 {
-  if (pe->max || pe->array) {
+  if (pe->max || pe->array || count == 0) {
 return;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [144027d70ff] master: Fix sequencer viewport render not respecting the "use_stamp" option

2022-08-03 Thread Sebastian Parborg
Commit: 144027d70ffc400040916ca15c7eed91e78e9c57
Author: Sebastian Parborg
Date:   Wed Aug 3 17:12:50 2022 +0200
Branches: master
https://developer.blender.org/rB144027d70ffc400040916ca15c7eed91e78e9c57

Fix sequencer viewport render not respecting the "use_stamp" option

The sequencer OpenGL viewport renders would not render the metadata into
the image even if the option was on.

Did minor cleanups in the render function as well.

===

M   source/blender/editors/render/render_opengl.cc

===

diff --git a/source/blender/editors/render/render_opengl.cc 
b/source/blender/editors/render/render_opengl.cc
index 77ad23f1e3f..e91bffce2c2 100644
--- a/source/blender/editors/render/render_opengl.cc
+++ b/source/blender/editors/render/render_opengl.cc
@@ -278,19 +278,10 @@ static void screen_opengl_views_setup(OGLRender 
*oglrender)
 
 static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, 
RenderResult *rr)
 {
-  Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
   Scene *scene = oglrender->scene;
-  ARegion *region = oglrender->region;
-  View3D *v3d = oglrender->v3d;
-  RegionView3D *rv3d = oglrender->rv3d;
   Object *camera = nullptr;
   int sizex = oglrender->sizex;
   int sizey = oglrender->sizey;
-  const short view_context = (v3d != nullptr);
-  bool draw_sky = (scene->r.alphamode == R_ADDSKY);
-  float *rectf = nullptr;
-  uchar *rect = nullptr;
-  const char *viewname = RE_GetActiveRenderView(oglrender->re);
   ImBuf *ibuf_result = nullptr;
 
   if (oglrender->is_sequencer) {
@@ -301,7 +292,7 @@ static void screen_opengl_render_doit(const bContext *C, 
OGLRender *oglrender, R
 ImBuf *ibuf = oglrender->seq_data.ibufs_arr[oglrender->view_id];
 
 if (ibuf) {
-  ImBuf *out = IMB_dupImBuf(ibuf);
+  ibuf_result = IMB_dupImBuf(ibuf);
   IMB_freeImBuf(ibuf);
   /* OpenGL render is considered to be preview and should be
* as fast as possible. So currently we're making sure sequencer
@@ -310,25 +301,21 @@ static void screen_opengl_render_doit(const bContext *C, 
OGLRender *oglrender, R
* TODO(sergey): In the case of output to float container (EXR)
* it actually makes sense to keep float buffer instead.
*/
-  if (out->rect_float != nullptr) {
-IMB_rect_from_float(out);
-imb_freerectfloatImBuf(out);
+  if (ibuf_result->rect_float != nullptr) {
+IMB_rect_from_float(ibuf_result);
+imb_freerectfloatImBuf(ibuf_result);
   }
-  BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == 
ibuf->y));
-  RE_render_result_rect_from_ibuf(rr, out, oglrender->view_id);
-  IMB_freeImBuf(out);
+  BLI_assert((sizex == ibuf->x) && (sizey == ibuf->y));
 }
 else if (gpd) {
   /* If there are no strips, Grease Pencil still needs a buffer to draw on 
*/
-  ImBuf *out = IMB_allocImBuf(oglrender->sizex, oglrender->sizey, 32, 
IB_rect);
-  RE_render_result_rect_from_ibuf(rr, out, oglrender->view_id);
-  IMB_freeImBuf(out);
+  ibuf_result = IMB_allocImBuf(sizex, sizey, 32, IB_rect);
 }
 
 if (gpd) {
   int i;
   uchar *gp_rect;
-  uchar *render_rect = (uchar *)RE_RenderViewGetById(rr, 
oglrender->view_id)->rect32;
+  uchar *render_rect = (uchar *)ibuf_result->rect;
 
   DRW_opengl_context_enable();
   GPU_offscreen_bind(oglrender->ofs, true);
@@ -359,10 +346,16 @@ static void screen_opengl_render_doit(const bContext *C, 
OGLRender *oglrender, R
   }
   else {
 /* shouldn't suddenly give errors mid-render but possible */
+Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
 char err_out[256] = "unknown";
 ImBuf *ibuf_view;
+bool draw_sky = (scene->r.alphamode == R_ADDSKY);
 const int alpha_mode = (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL;
-if (view_context) {
+const char *viewname = RE_GetActiveRenderView(oglrender->re);
+View3D *v3d = oglrender->v3d;
+
+if (v3d != nullptr) {
+  ARegion *region = oglrender->region;
   ibuf_view = ED_view3d_draw_offscreen_imbuf(depsgraph,
  scene,
  
static_cast(v3d->shading.type),
@@ -378,7 +371,7 @@ static void screen_opengl_render_doit(const bContext *C, 
OGLRender *oglrender, R
  err_out);
 
   /* for stamp only */
-  if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
+  if (oglrender->rv3d->persp == RV3D_CAMOB && v3d->camera) {
 camera = BKE_camera_multiview_render(oglrender->scene, v3d->camera, 
viewname);
   

[Bf-blender-cvs] [b010985e4ac] master: Fix T99255: Strips inserting incorrectly

2022-08-02 Thread Sebastian Parborg
Commit: b010985e4ac49a98e12802567efdf6b38f7b5bf2
Author: Sebastian Parborg
Date:   Tue Aug 2 19:36:42 2022 +0200
Branches: master
https://developer.blender.org/rBb010985e4ac49a98e12802567efdf6b38f7b5bf2

Fix T99255: Strips inserting incorrectly

When dropping file to sequencer timeline, coordinates for strip position
and overlap handling are used even if not set.

Reset internal state in on_drag_start callback and set is_modal
variable only if coordinates are updated. This way when dragging file
from external file browser, strip is added at current frame as before
modal operator was implemented.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D15333

===

M   source/blender/editors/space_sequencer/sequencer_drag_drop.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c 
b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
index f6561cf07b9..4796d80b3a0 100644
--- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c
+++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
@@ -51,7 +51,9 @@
 typedef struct SeqDropCoords {
   float start_frame, channel;
   int strip_len, channel_len;
+  float playback_rate;
   bool in_use;
+  bool has_read_mouse_pos;
   bool is_intersecting;
   bool use_snapping;
   float snap_point_x;
@@ -63,7 +65,7 @@ typedef struct SeqDropCoords {
  * preloading data on drag start.
  * Therefore we will for now use a global variable for this.
  */
-static SeqDropCoords g_drop_coords = {.in_use = false};
+static SeqDropCoords g_drop_coords = {.in_use = false, .has_read_mouse_pos = 
false};
 
 static void generic_poll_operations(const wmEvent *event, uint8_t type)
 {
@@ -82,31 +84,134 @@ static bool image_drop_poll(bContext *UNUSED(C), wmDrag 
*drag, const wmEvent *ev
 }
   }
 
-  return WM_drag_is_ID_type(drag, ID_IM);
+  if (WM_drag_is_ID_type(drag, ID_IM)) {
+generic_poll_operations(event, TH_SEQ_IMAGE);
+return true;
+  }
+
+  return false;
 }
 
-static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+static bool is_movie(wmDrag *drag)
 {
   if (drag->type == WM_DRAG_PATH) {
-if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might 
not work? */
-  generic_poll_operations(event, TH_SEQ_MOVIE);
+if (ELEM(drag->icon, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might 
not work? */
   return true;
 }
   }
+  if (WM_drag_is_ID_type(drag, ID_MC)) {
+return true;
+  }
+  return false;
+}
+
+static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+{
+  if (is_movie(drag)) {
+generic_poll_operations(event, TH_SEQ_MOVIE);
+return true;
+  }
 
-  return WM_drag_is_ID_type(drag, ID_MC);
+  return false;
 }
 
-static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+static bool is_sound(wmDrag *drag)
 {
   if (drag->type == WM_DRAG_PATH) {
 if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might 
not work? */
-  generic_poll_operations(event, TH_SEQ_AUDIO);
   return true;
 }
   }
+  if (WM_drag_is_ID_type(drag, ID_SO)) {
+return true;
+  }
+  return false;
+}
 
-  return WM_drag_is_ID_type(drag, ID_SO);
+static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+{
+  if (is_sound(drag)) {
+generic_poll_operations(event, TH_SEQ_AUDIO);
+return true;
+  }
+
+  return false;
+}
+
+static float update_overlay_strip_position_data(bContext *C, const int mval[2])
+{
+  SeqDropCoords *coords = &g_drop_coords;
+  ARegion *region = CTX_wm_region(C);
+  Scene *scene = CTX_data_scene(C);
+  int hand;
+  View2D *v2d = ®ion->v2d;
+
+  /* Update the position were we would place the strip if we complete the drag 
and drop action.
+   */
+  UI_view2d_region_to_view(v2d, mval[0], mval[1], &coords->start_frame, 
&coords->channel);
+  coords->start_frame = roundf(coords->start_frame);
+  if (coords->channel < 1.0f) {
+coords->channel = 1;
+  }
+
+  float start_frame = coords->start_frame;
+  float end_frame;
+  float strip_len;
+
+  if (coords->playback_rate != 0.0f) {
+float scene_playback_rate = (float)scene->r.frs_sec / 
scene->r.frs_sec_base;
+strip_len = coords->strip_len / (coords->playback_rate / 
scene_playback_rate);
+  }
+  else {
+strip_len = coords->strip_len;
+  }
+
+  end_frame = coords->start_frame + strip_len;
+
+  if (coords->use_snapping) {
+/* Do snapping via the existing transform code. */
+int snap_delta;
+float snap_frame;
+bool valid_snap;
+
+valid_snap = ED_transform_snap_sequencer_to_closest_strip_calc(
+scene, region, start_frame, end_frame, &snap_delta, &snap_frame);
+
+if (valid_snap) {
+  /* We snapped onto so

[Bf-blender-cvs] [0830320a7ce] master: CMake: Check if freetype is compiled with brotli support

2022-08-02 Thread Sebastian Parborg
Commit: 0830320a7ce8da31dec7c1efd97a7481784b6445
Author: Sebastian Parborg
Date:   Tue Aug 2 14:48:05 2022 +0200
Branches: master
https://developer.blender.org/rB0830320a7ce8da31dec7c1efd97a7481784b6445

CMake: Check if freetype is compiled with brotli support

Because of the recent changes to our core fonts,
Freetype has to support Woff2 fonts or Blender will segfault on startup.

This adds an explicit check for this to inform people compiling Blender
about this requirement.

===

M   build_files/cmake/platform/platform_unix.cmake

===

diff --git a/build_files/cmake/platform/platform_unix.cmake 
b/build_files/cmake/platform/platform_unix.cmake
index f6e233a0c86..406748b7ff0 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -96,6 +96,18 @@ find_package_wrapper(PNG REQUIRED)
 find_package_wrapper(ZLIB REQUIRED)
 find_package_wrapper(Zstd REQUIRED)
 
+function(check_freetype_for_brotli)
+  include(CheckSymbolExists)
+  set(CMAKE_REQUIRED_INCLUDES ${FREETYPE_INCLUDE_DIRS})
+  check_symbol_exists(FT_CONFIG_OPTION_USE_BROTLI
+  "freetype/config/ftconfig.h" HAVE_BROTLI)
+  if(NOT HAVE_BROTLI)
+unset(HAVE_BROTLI CACHE)
+message(FATAL_ERROR "Freetype needs to be compiled with brotli support!")
+  endif()
+  unset(HAVE_BROTLI CACHE)
+endfunction()
+
 if(NOT WITH_SYSTEM_FREETYPE)
   # FreeType compiled with Brotli compression for woff2.
   find_package_wrapper(Freetype REQUIRED)
@@ -110,6 +122,7 @@ if(NOT WITH_SYSTEM_FREETYPE)
 #   ${BROTLI_LIBRARIES}
 # )
   endif()
+  check_freetype_for_brotli()
 endif()
 
 if(WITH_PYTHON)
@@ -587,6 +600,7 @@ if(WITH_SYSTEM_FREETYPE)
   if(NOT FREETYPE_FOUND)
 message(FATAL_ERROR "Failed finding system FreeType version!")
   endif()
+  check_freetype_for_brotli()
 endif()
 
 if(WITH_LZO AND WITH_SYSTEM_LZO)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b7676281734] master: Fix: Memory leaks in indexer code

2022-07-12 Thread Sebastian Parborg
Commit: b767628173446433f12b321d9209f9be11aee58c
Author: Sebastian Parborg
Date:   Tue Jul 12 16:58:04 2022 +0200
Branches: master
https://developer.blender.org/rBb767628173446433f12b321d9209f9be11aee58c

Fix: Memory leaks in indexer code

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D15376

===

M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/indexer.c 
b/source/blender/imbuf/intern/indexer.c
index cbc5d984755..00396c01d99 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1098,6 +1098,7 @@ static int 
indexer_performance_get_decode_rate(FFmpegIndexBuilderContext *contex
 
   while (av_read_frame(context->iFormatCtx, packet) >= 0) {
 if (packet->stream_index != context->videoStream) {
+  av_packet_unref(packet);
   continue;
 }
 
@@ -1121,6 +1122,7 @@ static int 
indexer_performance_get_decode_rate(FFmpegIndexBuilderContext *contex
 if (end > start + time_period) {
   break;
 }
+av_packet_unref(packet);
   }
 
   av_packet_free(&packet);
@@ -1145,6 +1147,7 @@ static int 
indexer_performance_get_max_gop_size(FFmpegIndexBuilderContext *conte
 
   while (av_read_frame(context->iFormatCtx, packet) >= 0) {
 if (packet->stream_index != context->videoStream) {
+  av_packet_unref(packet);
   continue;
 }
 packet_index++;
@@ -1158,6 +1161,7 @@ static int 
indexer_performance_get_max_gop_size(FFmpegIndexBuilderContext *conte
 if (packet_index > packets_max) {
   break;
 }
+av_packet_unref(packet);
   }
 
   av_packet_free(&packet);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [883d8ea16c3] master: Fix: Memleak in sequencer drag and drop code

2022-07-05 Thread Sebastian Parborg
Commit: 883d8ea16c36a0e1d56826e3bc4f072d6aa58618
Author: Sebastian Parborg
Date:   Tue Jul 5 16:31:13 2022 +0200
Branches: master
https://developer.blender.org/rB883d8ea16c36a0e1d56826e3bc4f072d6aa58618

Fix: Memleak in sequencer drag and drop code

===

M   source/blender/editors/space_sequencer/sequencer_drag_drop.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c 
b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
index 94427009939..f6561cf07b9 100644
--- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c
+++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
@@ -179,6 +179,7 @@ static void sequencer_drop_copy(bContext *C, wmDrag *drag, 
wmDropBox *drop)
   if (max_channel != -1) {
 RNA_int_set(drop->ptr, "channel", max_channel);
   }
+  SEQ_collection_free(strips);
 }
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b8302631865] master: Fix T98871: Drivers not updated when joining an armature

2022-06-23 Thread Sebastian Parborg
Commit: b8302631865538eb967896455ea59b62f0f8711c
Author: Sebastian Parborg
Date:   Thu Jun 23 11:44:29 2022 +0200
Branches: master
https://developer.blender.org/rBb8302631865538eb967896455ea59b62f0f8711c

Fix T98871: Drivers not updated when joining an armature

If the some driver had been flagged as "invalid", the flag would not be
cleared when joining armatures which could lead to now valid drivers
still being flagged as invalid.

Now we clear this invalid flag on all drivers to force a recheck after
joining the armatures.

===

M   source/blender/editors/armature/armature_relations.c

===

diff --git a/source/blender/editors/armature/armature_relations.c 
b/source/blender/editors/armature/armature_relations.c
index 950178e865d..0825d6968c6 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -159,6 +159,11 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve 
*fcu, void *user_data
 ChannelDriver *driver = fcu->driver;
 DriverVar *dvar;
 
+/* Ensure that invalid drivers gets re-evaluated in case they become valid 
once the join
+ * operation is finished. */
+fcu->flag &= ~FCURVE_DISABLED;
+driver->flag &= ~DRIVER_FLAG_INVALID;
+
 /* Fix driver references to invalid ID's */
 for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
   /* only change the used targets, since the others will need fixing 
manually anyway */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [82060c16977] master: Remove unused compile flag on linux x86 GCC platforms

2022-05-09 Thread Sebastian Parborg
Commit: 82060c16977ee32abac72129f2340e0a4a550942
Author: Sebastian Parborg
Date:   Mon May 9 14:26:56 2022 +0200
Branches: master
https://developer.blender.org/rB82060c16977ee32abac72129f2340e0a4a550942

Remove unused compile flag on linux x86 GCC platforms

The "cast-align" warning is only triggered on Arm CPUs when using GCC.
Currently the only officialy supported ARM platform is the Mac platform
where we use Clang. So this warning never triggers.

===

M   CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5660b3653b..f48334a298b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1539,7 +1539,6 @@ endif()
 if(CMAKE_COMPILER_IS_GNUCC)
 
   ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
-  ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
   ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS 
C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION 
-Werror=implicit-function-declaration)
   ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  
-Werror=return-type)
   ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_VLA -Werror=vla)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dd2df5ceb0b] master: Fix: Comments in clang-tidy checks list is not allowed

2022-05-06 Thread Sebastian Parborg
Commit: dd2df5ceb0bfe5db7d6ee2c4865310672d7d9c9c
Author: Sebastian Parborg
Date:   Fri May 6 14:41:58 2022 +0200
Branches: master
https://developer.blender.org/rBdd2df5ceb0bfe5db7d6ee2c4865310672d7d9c9c

Fix: Comments in clang-tidy checks list is not allowed

Clang-tidy will not parse any options after the comment.

===

M   .clang-tidy

===

diff --git a/.clang-tidy b/.clang-tidy
index 1cc0e6e7f4a..bbd51291918 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,6 +1,8 @@
 # The warnings below are disabled because they are too pedantic and not worth 
fixing.
 # Some of them will be enabled as part of the Clang-Tidy task, see T78535.
 
+# NOTE: No comments in the list below is allowed. Clang-tidy will ignore items 
after comments in the lists flag list.
+# This is because the comment is not a valid list item and it will stop 
parsing flags if a list item is a comment.
 Checks:  >
   -*,
   readability-*,
@@ -42,8 +44,6 @@ Checks:  >
   -modernize-use-nodiscard,
   -modernize-loop-convert,
   -modernize-pass-by-value,
-  # Cannot be enabled yet, because using raw string literals in tests breaks
-  # the windows compiler currently.
   -modernize-raw-string-literal,
   -modernize-return-braced-init-list

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f23f831e914] master: Clang-tidy: Don't warn about unrecognized compiler flags

2022-05-06 Thread Sebastian Parborg
Commit: f23f831e91424afe564573ef00b31984bcde6ec3
Author: Sebastian Parborg
Date:   Fri May 6 15:21:54 2022 +0200
Branches: master
https://developer.blender.org/rBf23f831e91424afe564573ef00b31984bcde6ec3

Clang-tidy: Don't warn about unrecognized compiler flags

When using GCC, clang-tidy will still use clang under the hood but GCC
flags will still be passed. Therefore we will ignore any warnings about
unrecognized flags as we don't care about this when running clang-tidy.

===

M   source/CMakeLists.txt

===

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index ffc4d37f622..d0592e9a405 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -15,8 +15,9 @@ if(WITH_CLANG_TIDY AND NOT MSVC)
   endif()
 
   find_package(ClangTidy REQUIRED)
-  set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE})
-  set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE})
+  set(CMAKE_C_CLANG_TIDY
+${CLANG_TIDY_EXECUTABLE};--extra-arg=-Wno-error=unknown-warning-option)
+  set(CMAKE_CXX_CLANG_TIDY 
${CLANG_TIDY_EXECUTABLE};--extra-arg=-Wno-error=unknown-warning-option)
 endif()
 
 add_subdirectory(blender)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [763b8f14237] master: Clang-tidy: Ignore variable name length and .c/.cc include warnings

2022-05-06 Thread Sebastian Parborg
Commit: 763b8f14237fd534fc9ebd3a8ed82c57ca8b5463
Author: Sebastian Parborg
Date:   Fri May 6 14:47:45 2022 +0200
Branches: master
https://developer.blender.org/rB763b8f14237fd534fc9ebd3a8ed82c57ca8b5463

Clang-tidy: Ignore variable name length and .c/.cc include warnings

After some internal discussion it was decided that we should ignore name
variable length tidy warnings. Otherwise we would have warnings for
every variable that is under three characters long.

Additionally we will also ignore any warnings when including non header
files as the Unity library in our build system uses this excessively

===

M   .clang-tidy

===

diff --git a/.clang-tidy b/.clang-tidy
index bbd51291918..42ce52d58ca 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -16,10 +16,9 @@ Checks:  >
   -readability-make-member-function-const,
   -readability-suspicious-call-argument,
   -readability-redundant-member-init,
-
   -readability-misleading-indentation,
-
   -readability-use-anyofallof,
+  -readability-identifier-length,
 
   -readability-function-cognitive-complexity,
 
@@ -37,6 +36,8 @@ Checks:  >
 
   -bugprone-redundant-branch-condition,
 
+  -bugprone-suspicious-include,
+
   modernize-*,
   -modernize-use-auto,
   -modernize-use-trailing-return-type,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [074a8558b7b] master: Fix rendering of wire curves when used as custom bone objects

2022-04-29 Thread Sebastian Parborg
Commit: 074a8558b7b320d7be78d436ab5473fd5b53ff56
Author: Sebastian Parborg
Date:   Fri Apr 29 18:20:54 2022 +0200
Branches: master
https://developer.blender.org/rB074a8558b7b320d7be78d436ab5473fd5b53ff56

Fix rendering of wire curves when used as custom bone objects

In the current code we do not render any curves if they have not been
converted to meshes. This change makes the custom bone drawing try to
render mesh objects first and then falls back to curve objects if there
is no mesh data available.

Reviewed By: Clement

Differential Revision: http://developer.blender.org/D14804

===

M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/draw/intern/draw_cache.c
M   source/blender/draw/intern/draw_manager.c
M   source/blender/draw/intern/draw_manager.h

===

diff --git a/source/blender/draw/engines/overlay/overlay_armature.c 
b/source/blender/draw/engines/overlay/overlay_armature.c
index 741259a95b2..ea0c2f287a6 100644
--- a/source/blender/draw/engines/overlay/overlay_armature.c
+++ b/source/blender/draw/engines/overlay/overlay_armature.c
@@ -628,22 +628,14 @@ BLI_INLINE DRWCallBuffer 
*custom_bone_instance_shgroup(ArmatureDrawContext *ctx,
   return buf;
 }
 
-static void drw_shgroup_bone_custom_solid(ArmatureDrawContext *ctx,
-  const float (*bone_mat)[4],
-  const float bone_color[4],
-  const float hint_color[4],
-  const float outline_color[4],
-  Object *custom)
+static void drw_shgroup_bone_custom_solid_mesh(ArmatureDrawContext *ctx,
+   Mesh *mesh,
+   const float (*bone_mat)[4],
+   const float bone_color[4],
+   const float hint_color[4],
+   const float outline_color[4],
+   Object *custom)
 {
-  /* The custom object is not an evaluated object, so its object->data field 
hasn't been replaced
-   * by #data_eval. This is bad since it gives preference to an object's 
evaluated mesh over any
-   * other data type, but supporting all evaluated geometry components would 
require a much larger
-   * refactor of this area. */
-  Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom);
-  if (mesh == NULL) {
-return;
-  }
-
   /* TODO(fclem): arg... less than ideal but we never iter on this object
* to assure batch cache is valid. */
   DRW_mesh_batch_cache_validate(custom, mesh);
@@ -682,16 +674,12 @@ static void 
drw_shgroup_bone_custom_solid(ArmatureDrawContext *ctx,
   drw_batch_cache_generate_requested_delayed(custom);
 }
 
-static void drw_shgroup_bone_custom_wire(ArmatureDrawContext *ctx,
- const float (*bone_mat)[4],
- const float color[4],
- Object *custom)
+static void drw_shgroup_bone_custom_mesh_wire(ArmatureDrawContext *ctx,
+  Mesh *mesh,
+  const float (*bone_mat)[4],
+  const float color[4],
+  Object *custom)
 {
-  /* See comments in #drw_shgroup_bone_custom_solid. */
-  Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom);
-  if (mesh == NULL) {
-return;
-  }
   /* TODO(fclem): arg... less than ideal but we never iter on this object
* to assure batch cache is valid. */
   DRW_mesh_batch_cache_validate(custom, mesh);
@@ -710,6 +698,80 @@ static void 
drw_shgroup_bone_custom_wire(ArmatureDrawContext *ctx,
   drw_batch_cache_generate_requested_delayed(custom);
 }
 
+static void drw_shgroup_custom_bone_curve(ArmatureDrawContext *ctx,
+  Curve *curve,
+  const float (*bone_mat)[4],
+  const float outline_color[4],
+  Object *custom)
+{
+  /* TODO(fclem): arg... less than ideal but we never iter on this object
+   * to assure batch cache is valid. */
+  DRW_curve_batch_cache_validate(curve);
+
+  /* This only handles curves without any surface. The other curve types 
should have been converted
+   * to meshes and rendered in the mesh drawing function. */
+  struct GPUBatch *ledges = NULL;
+  if (custom->type == OB_FONT) {
+ledges = DRW_cache_text_edge_wire_get(custom);
+  }
+  else {
+ledges = DRW_cache_curve_edge_wire_get(custom);
+  }
+
+  if (ledges) {
+

[Bf-blender-cvs] [77794b1a7b9] master: VSE: Add precise drag and drop and strip previews

2022-04-28 Thread Sebastian Parborg
Commit: 77794b1a7b99bd689d1d9872c61d7990fbad2ce4
Author: Sebastian Parborg
Date:   Thu Apr 28 12:50:22 2022 +0200
Branches: master
https://developer.blender.org/rB77794b1a7b99bd689d1d9872c61d7990fbad2ce4

VSE: Add precise drag and drop and strip previews

This patch adds the drag and drop strip previews in the VSE.
It also adds two new functions to the drag and drop API.

1. "draw_in_view" for callbacks that wants to draw elements in local viewport 
coordinates
2. "on_drag_start" that can be used for prefetching data only once at the start 
of the drag.

Reviewed By: Julian, Campbell

Differential Revision: http://developer.blender.org/D14560

===

M   source/blender/editors/include/ED_transform.h
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/interface_dropboxes.cc
M   source/blender/editors/interface/interface_ops.c
M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_clip/space_clip.c
M   source/blender/editors/space_console/space_console.c
M   source/blender/editors/space_file/space_file.c
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/space_node/space_node.cc
M   source/blender/editors/space_sequencer/CMakeLists.txt
M   source/blender/editors/space_sequencer/sequencer_add.c
A   source/blender/editors/space_sequencer/sequencer_drag_drop.c
M   source/blender/editors/space_sequencer/sequencer_intern.h
M   source/blender/editors/space_sequencer/space_sequencer.c
M   source/blender/editors/space_text/space_text.c
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_convert.h
M   source/blender/editors/transform/transform_convert_sequencer.c
M   source/blender/editors/transform/transform_orientations.h
M   source/blender/editors/transform/transform_snap_sequencer.c
M   source/blender/sequencer/SEQ_transform.h
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_dragdrop.c
M   source/blender/windowmanager/intern/wm_draw.c

===

diff --git a/source/blender/editors/include/ED_transform.h 
b/source/blender/editors/include/ED_transform.h
index 66c17ff8115..82cc518f029 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -202,6 +202,21 @@ int ED_transform_calc_gizmo_stats(const struct bContext *C,
   const struct TransformCalcParams *params,
   struct TransformBounds *tbounds);
 
+/**
+ * Iterates over all the strips and finds the closest snapping candidate of 
either \a frame_1 or \a
+ * frame_2. The closest snapping candidate will be the closest start or end 
frame of an existing
+ * strip.
+ * \returns True if there was anything to snap to.
+ */
+bool ED_transform_snap_sequencer_to_closest_strip_calc(struct Scene *scene,
+   struct ARegion *region,
+   int frame_1,
+   int frame_2,
+   int *r_snap_distance,
+   float *r_snap_frame);
+
+void ED_draw_sequencer_snap_point(struct bContext *C, float snap_point);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 1b817d06564..9f4d6815287 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2925,7 +2925,7 @@ void ED_keymap_ui(struct wmKeyConfig *keyconf);
 void ED_dropboxes_ui(void);
 void ED_uilisttypes_ui(void);
 
-void UI_drop_color_copy(struct wmDrag *drag, struct wmDropBox *drop);
+void UI_drop_color_copy(struct bContext *C, struct wmDrag *drag, struct 
wmDropBox *drop);
 bool UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct 
wmEvent *event);
 
 bool UI_context_copy_to_selected_list(struct bContext *C,
diff --git a/source/blender/editors/interface/interface_dropboxes.cc 
b/source/blender/editors/interface/interface_dropboxes.cc
index 2e8708827e7..9d3c1372b15 100644
--- a/source/blender/editors/interface/interface_dropboxes.cc
+++ b/source/blender/editors/interface/interface_dropboxes.cc
@@ -67,7 +67,7 @@ static bool ui_drop_name_poll(struct bContext *C, wmDrag 
*drag, const wmEvent *U
   return UI_but_active_drop_name(C) && (drag->type == WM_DRAG_ID);
 }
 
-static void ui_drop_name_copy(wmDrag *drag, wmDropBox *drop)
+static void ui_drop_name_copy(bContext *UNUSED(C),

[Bf-blender-cvs] [5a0b4e97e67] master: Fix memleak in VSE proxy creation.

2022-04-04 Thread Sebastian Parborg
Commit: 5a0b4e97e67446ef3a180acb0ad03b4cbf91b356
Author: Sebastian Parborg
Date:   Mon Apr 4 12:42:59 2022 +0200
Branches: master
https://developer.blender.org/rB5a0b4e97e67446ef3a180acb0ad03b4cbf91b356

Fix memleak in VSE proxy creation.

We didn't properly free allocated ffmpeg data structures.

===

M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/indexer.c 
b/source/blender/imbuf/intern/indexer.c
index 84bed479577..357b250d0fe 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1123,6 +1123,9 @@ static int 
indexer_performance_get_decode_rate(FFmpegIndexBuilderContext *contex
 }
   }
 
+  av_packet_free(&packet);
+  av_frame_free(&in_frame);
+
   avcodec_flush_buffers(context->iCodecCtx);
   av_seek_frame(context->iFormatCtx, -1, 0, AVSEEK_FLAG_BACKWARD);
   return frames_decoded;
@@ -1157,6 +1160,8 @@ static int 
indexer_performance_get_max_gop_size(FFmpegIndexBuilderContext *conte
 }
   }
 
+  av_packet_free(&packet);
+
   av_seek_frame(context->iFormatCtx, -1, 0, AVSEEK_FLAG_BACKWARD);
   return max_gop;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0597902bde1] master: Fix memory leak when reading ffmpeg video frames.

2022-03-07 Thread Sebastian Parborg
Commit: 0597902bde1f6d9a77bf04144ad7fd5f7be9d651
Author: Sebastian Parborg
Date:   Mon Mar 7 19:02:34 2022 +0100
Branches: master
https://developer.blender.org/rB0597902bde1f6d9a77bf04144ad7fd5f7be9d651

Fix memory leak when reading ffmpeg video frames.

We had forgotten to unref packets after reading them.
This lead to a memory leak inside of ffmpeg.

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 7cde49f44b7..096089d4c41 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -874,6 +874,8 @@ static int ffmpeg_read_video_frame(struct anim *anim, 
AVPacket *packet)
 if (packet->stream_index == anim->videoStream) {
   break;
 }
+av_packet_unref(packet);
+packet->stream_index = -1;
   }
 
   return ret;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8ae77efe4e0] master: Merge branch 'blender-v3.1-release'

2022-02-22 Thread Sebastian Parborg
Commit: 8ae77efe4e075cbade646f8fe608e54d7d1ace08
Author: Sebastian Parborg
Date:   Tue Feb 22 17:34:07 2022 +0100
Branches: master
https://developer.blender.org/rB8ae77efe4e075cbade646f8fe608e54d7d1ace08

Merge branch 'blender-v3.1-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [283a4cd40e6] blender-v3.1-release: Fix ffmpeg tests when using ffmpeg 5.0

2022-02-22 Thread Sebastian Parborg
Commit: 283a4cd40e6d07a55027298d693d9fba9a8a6f30
Author: Sebastian Parborg
Date:   Tue Feb 22 17:30:52 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB283a4cd40e6d07a55027298d693d9fba9a8a6f30

Fix ffmpeg tests when using ffmpeg 5.0

===

M   intern/ffmpeg/tests/ffmpeg_codecs.cc

===

diff --git a/intern/ffmpeg/tests/ffmpeg_codecs.cc 
b/intern/ffmpeg/tests/ffmpeg_codecs.cc
index 9538bac84d2..157731bf1f2 100644
--- a/intern/ffmpeg/tests/ffmpeg_codecs.cc
+++ b/intern/ffmpeg/tests/ffmpeg_codecs.cc
@@ -2,12 +2,13 @@
 
 extern "C" {
 #include 
+#include 
 #include 
 }
 
 namespace {
 
-bool test_vcodec(AVCodec *codec, AVPixelFormat pixelformat)
+bool test_vcodec(const AVCodec *codec, AVPixelFormat pixelformat)
 {
   av_log_set_level(AV_LOG_QUIET);
   bool result = false;
@@ -28,7 +29,7 @@ bool test_vcodec(AVCodec *codec, AVPixelFormat pixelformat)
   }
   return result;
 }
-bool test_acodec(AVCodec *codec, AVSampleFormat fmt)
+bool test_acodec(const AVCodec *codec, AVSampleFormat fmt)
 {
   av_log_set_level(AV_LOG_QUIET);
   bool result = false;
@@ -52,7 +53,7 @@ bool test_acodec(AVCodec *codec, AVSampleFormat fmt)
 bool test_codec_video_by_codecid(AVCodecID codec_id, AVPixelFormat pixelformat)
 {
   bool result = false;
-  AVCodec *codec = avcodec_find_encoder(codec_id);
+  const AVCodec *codec = avcodec_find_encoder(codec_id);
   if (codec)
 result = test_vcodec(codec, pixelformat);
   return result;
@@ -61,7 +62,7 @@ bool test_codec_video_by_codecid(AVCodecID codec_id, 
AVPixelFormat pixelformat)
 bool test_codec_video_by_name(const char *codecname, AVPixelFormat pixelformat)
 {
   bool result = false;
-  AVCodec *codec = avcodec_find_encoder_by_name(codecname);
+  const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
   if (codec)
 result = test_vcodec(codec, pixelformat);
   return result;
@@ -70,7 +71,7 @@ bool test_codec_video_by_name(const char *codecname, 
AVPixelFormat pixelformat)
 bool test_codec_audio_by_codecid(AVCodecID codec_id, AVSampleFormat fmt)
 {
   bool result = false;
-  AVCodec *codec = avcodec_find_encoder(codec_id);
+  const AVCodec *codec = avcodec_find_encoder(codec_id);
   if (codec)
 result = test_acodec(codec, fmt);
   return result;
@@ -79,7 +80,7 @@ bool test_codec_audio_by_codecid(AVCodecID codec_id, 
AVSampleFormat fmt)
 bool test_codec_audio_by_name(const char *codecname, AVSampleFormat fmt)
 {
   bool result = false;
-  AVCodec *codec = avcodec_find_encoder_by_name(codecname);
+  const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
   if (codec)
 result = test_acodec(codec, fmt);
   return result;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c2016feadc8] master: Merge branch 'blender-v3.1-release'

2022-02-18 Thread Sebastian Parborg
Commit: c2016feadc8fe83565ea1e405e36221d05163e5b
Author: Sebastian Parborg
Date:   Fri Feb 18 18:25:31 2022 +0100
Branches: master
https://developer.blender.org/rBc2016feadc8fe83565ea1e405e36221d05163e5b

Merge branch 'blender-v3.1-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [af6a1b08e3f] blender-v3.1-release: VSE: Refactor our code to be compatible with ffmpeg 5.0

2022-02-18 Thread Sebastian Parborg
Commit: af6a1b08e3f0d0070ac9423868d2d3f81057717a
Author: Sebastian Parborg
Date:   Fri Feb 18 18:20:06 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBaf6a1b08e3f0d0070ac9423868d2d3f81057717a

VSE: Refactor our code to be compatible with ffmpeg 5.0

In ffmpeg 5.0, several variables were made const to try to prevent bad API 
usage.
Removed some dead code that wasn't used anymore as well.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D14063

===

M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
M   source/blender/blenkernel/BKE_writeffmpeg.h
M   source/blender/blenkernel/intern/scene.c
M   source/blender/blenkernel/intern/writeffmpeg.c
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c
M   source/blender/imbuf/intern/util.c
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_scene.c

===

diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp 
b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
index de3ca099696..69bb45119a6 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
@@ -177,7 +177,7 @@ void FFMPEGReader::init(int stream)
 
// get a decoder and open it
 #ifndef FFMPEG_OLD_CODE
-   AVCodec* aCodec = 
avcodec_find_decoder(m_formatCtx->streams[m_stream]->codecpar->codec_id);
+   const AVCodec* aCodec = 
avcodec_find_decoder(m_formatCtx->streams[m_stream]->codecpar->codec_id);
 
if(!aCodec)
AUD_THROW(FileException, "File couldn't be read, no decoder 
found with ffmpeg.");
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp 
b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
index 10517d1d596..32eb2330594 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
@@ -23,6 +23,7 @@
 extern "C" {
 #include 
 #include 
+#include 
 }
 
 AUD_NAMESPACE_BEGIN
@@ -171,66 +172,66 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, 
DeviceSpecs specs, Container fo
if(avformat_alloc_output_context2(&m_formatCtx, nullptr, 
formats[format], filename.c_str()) < 0)
AUD_THROW(FileException, "File couldn't be written, format 
couldn't be found with ffmpeg.");
 
-   AVOutputFormat* outputFmt = m_formatCtx->oformat;
+   const AVOutputFormat* outputFmt = m_formatCtx->oformat;
 
if(!outputFmt) {
avformat_free_context(m_formatCtx);
AUD_THROW(FileException, "File couldn't be written, output 
format couldn't be found with ffmpeg.");
}
 
-   outputFmt->audio_codec = AV_CODEC_ID_NONE;
+   AVCodecID audio_codec = AV_CODEC_ID_NONE;
 
switch(codec)
{
case CODEC_AAC:
-   outputFmt->audio_codec = AV_CODEC_ID_AAC;
+   audio_codec = AV_CODEC_ID_AAC;
break;
case CODEC_AC3:
-   outputFmt->audio_codec = AV_CODEC_ID_AC3;
+   audio_codec = AV_CODEC_ID_AC3;
break;
case CODEC_FLAC:
-   outputFmt->audio_codec = AV_CODEC_ID_FLAC;
+   audio_codec = AV_CODEC_ID_FLAC;
break;
case CODEC_MP2:
-   outputFmt->audio_codec = AV_CODEC_ID_MP2;
+   audio_codec = AV_CODEC_ID_MP2;
break;
case CODEC_MP3:
-   outputFmt->audio_codec = AV_CODEC_ID_MP3;
+   audio_codec = AV_CODEC_ID_MP3;
break;
case CODEC_OPUS:
-   outputFmt->audio_codec = AV_CODEC_ID_OPUS;
+   audio_codec = AV_CODEC_ID_OPUS;
break;
case CODEC_PCM:
switch(specs.format)
{
case FORMAT_U8:
-   outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
+   audio_codec = AV_CODEC_ID_PCM_U8;
break;
case FORMAT_S16:
-   outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
+   audio_codec = AV_CODEC_ID_PCM_S16LE;
break;
case FORMAT_S24:
-   outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
+   audio_codec = AV_CODEC_ID_PCM_S24LE;
break;
case FORMAT_S32:
-   outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
+   audio_codec = AV_CODEC_ID_PCM_S32LE;
break;
  

[Bf-blender-cvs] [b6fe1b0c658] master: Merge branch 'blender-v3.1-release'

2022-02-17 Thread Sebastian Parborg
Commit: b6fe1b0c658f5068154f9e4a726de789f5ebb68a
Author: Sebastian Parborg
Date:   Thu Feb 17 18:44:18 2022 +0100
Branches: master
https://developer.blender.org/rBb6fe1b0c658f5068154f9e4a726de789f5ebb68a

Merge branch 'blender-v3.1-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a04300c436d] blender-v3.1-release: Cleanup: Move more cmake library variables to be advanced

2022-02-17 Thread Sebastian Parborg
Commit: a04300c436d77bf47b94d033c1d832d86425945c
Author: Sebastian Parborg
Date:   Thu Feb 17 18:42:06 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBa04300c436d77bf47b94d033c1d832d86425945c

Cleanup: Move more cmake library variables to be advanced

I noticed that there were a few variables that should not be visible per 
default.
It seems to me to simply be an oversight, so I went ahead and cleaned them up.

Reviewed By: Sybren, Ray molenkamp

Differential Revision: http://developer.blender.org/D14132

===

M   build_files/cmake/Modules/FindFFmpeg.cmake
M   build_files/cmake/Modules/FindOSL.cmake
M   build_files/cmake/Modules/FindOpenColorIO.cmake
M   build_files/cmake/Modules/FindOpenImageDenoise.cmake
M   build_files/cmake/platform/platform_unix.cmake
M   source/blender/io/collada/CMakeLists.txt

===

diff --git a/build_files/cmake/Modules/FindFFmpeg.cmake 
b/build_files/cmake/Modules/FindFFmpeg.cmake
index 5f506a33e13..8d939f3ad85 100644
--- a/build_files/cmake/Modules/FindFFmpeg.cmake
+++ b/build_files/cmake/Modules/FindFFmpeg.cmake
@@ -82,4 +82,6 @@ mark_as_advanced(
 
 unset(_ffmpeg_SEARCH_DIRS)
 unset(_ffmpeg_LIBRARIES)
-unset(_ffmpeg_INCLUDE_DIR)
+# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
+# find_path so we don't need to clear it from the cache here.
+unset(_ffmpeg_INCLUDE_DIR CACHE)
diff --git a/build_files/cmake/Modules/FindOSL.cmake 
b/build_files/cmake/Modules/FindOSL.cmake
index b21c7ad50a3..b67ce515ff5 100644
--- a/build_files/cmake/Modules/FindOSL.cmake
+++ b/build_files/cmake/Modules/FindOSL.cmake
@@ -76,6 +76,7 @@ FIND_PATH(OSL_SHADER_DIR
 /usr/include/OSL/
   PATH_SUFFIXES
 share/OSL/shaders
+shaders
 )
 
 # handle the QUIETLY and REQUIRED arguments and set OSL_FOUND to TRUE if
@@ -99,6 +100,7 @@ ENDIF()
 
 MARK_AS_ADVANCED(
   OSL_INCLUDE_DIR
+  OSL_SHADER_DIR
 )
 FOREACH(COMPONENT ${_osl_FIND_COMPONENTS})
   STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
diff --git a/build_files/cmake/Modules/FindOpenColorIO.cmake 
b/build_files/cmake/Modules/FindOpenColorIO.cmake
index 21118533ebe..8aa7795b611 100644
--- a/build_files/cmake/Modules/FindOpenColorIO.cmake
+++ b/build_files/cmake/Modules/FindOpenColorIO.cmake
@@ -87,12 +87,14 @@ ENDIF()
 MARK_AS_ADVANCED(
   OPENCOLORIO_INCLUDE_DIR
   OPENCOLORIO_LIBRARY
-  OPENCOLORIO_OPENCOLORIO_LIBRARY
-  OPENCOLORIO_TINYXML_LIBRARY
-  OPENCOLORIO_YAML-CPP_LIBRARY
   OPENCOLORIO_VERSION
 )
 
+FOREACH(COMPONENT ${_opencolorio_FIND_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+  MARK_AS_ADVANCED(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY)
+ENDFOREACH()
+
 UNSET(COMPONENT)
 UNSET(UPPERCOMPONENT)
 UNSET(_opencolorio_FIND_COMPONENTS)
diff --git a/build_files/cmake/Modules/FindOpenImageDenoise.cmake 
b/build_files/cmake/Modules/FindOpenImageDenoise.cmake
index 3facadbb9be..6ad45c8cf61 100644
--- a/build_files/cmake/Modules/FindOpenImageDenoise.cmake
+++ b/build_files/cmake/Modules/FindOpenImageDenoise.cmake
@@ -110,6 +110,7 @@ ENDIF()
 
 MARK_AS_ADVANCED(
   OPENIMAGEDENOISE_INCLUDE_DIR
+  OPENIMAGEDENOISE_LIBRARY
 )
 
 FOREACH(COMPONENT ${_openimagedenoise_FIND_COMPONENTS})
diff --git a/build_files/cmake/platform/platform_unix.cmake 
b/build_files/cmake/platform/platform_unix.cmake
index 6a896709cc2..95d0e4de380 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -362,6 +362,7 @@ if(WITH_BOOST)
   find_package(IcuLinux)
 endif()
 mark_as_advanced(Boost_DIR)  # why doesn't boost do this?
+mark_as_advanced(Boost_INCLUDE_DIR)  # why doesn't boost do this?
   endif()
 
   set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
diff --git a/source/blender/io/collada/CMakeLists.txt 
b/source/blender/io/collada/CMakeLists.txt
index e1645083116..25c20accaa2 100644
--- a/source/blender/io/collada/CMakeLists.txt
+++ b/source/blender/io/collada/CMakeLists.txt
@@ -31,6 +31,10 @@ if(OPENCOLLADA_ANIMATION_CLIP)
   add_definitions(-DWITH_OPENCOLLADA_ANIMATION_CLIP)
 endif()
 
+# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
+# find_file so we don't need to clear it from the cache here.
+unset(OPENCOLLADA_ANIMATION_CLIP CACHE)
+
 set(INC
   .
   ../../blenkernel

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cd7550cfe71] blender-v3.1-release: Images: update code to support OpenEXR 3

2022-02-17 Thread Sebastian Parborg
Commit: cd7550cfe712598727b548d1c90565ac98a274c2
Author: Sebastian Parborg
Date:   Wed Feb 16 17:36:47 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBcd7550cfe712598727b548d1c90565ac98a274c2

Images: update code to support OpenEXR 3

Compatibility with OpenEXR 2 is preserved, since Blender releases and Linux
distribution packages can be on different versions.

Ref D14128

===

M   source/blender/imbuf/intern/openexr/openexr_api.cpp

===

diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp 
b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index ec8cf36dd49..46abb986259 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -32,30 +32,46 @@
 #include 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+/* The OpenEXR version can reliably be found in this header file from OpenEXR,
+ * for both 2.x and 3.x:
+ */
+#include 
+#define COMBINED_OPENEXR_VERSION \
+  ((1 * OPENEXR_VERSION_MAJOR) + (100 * OPENEXR_VERSION_MINOR) + 
OPENEXR_VERSION_PATCH)
+
+#if COMBINED_OPENEXR_VERSION >= 20599
+/* >=2.5.99 -> OpenEXR >=3.0 */
+#  include 
+#  include 
+#  define exr_file_offset_t uint64_t
+#else
+/* OpenEXR 2.x, use the old locations. */
+#  include 
+#  define exr_file_offset_t Int64
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 /* multiview/multipart */
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include "DNA_scene_types.h" /* For OpenEXR compression constants */
 
@@ -131,12 +147,12 @@ class IMemStream : public Imf::IStream {
 return false;
   }
 
-  Int64 tellg() override
+  exr_file_offset_t tellg() override
   {
 return _exrpos;
   }
 
-  void seekg(Int64 pos) override
+  void seekg(exr_file_offset_t pos) override
   {
 _exrpos = pos;
   }
@@ -146,8 +162,8 @@ class IMemStream : public Imf::IStream {
   }
 
  private:
-  Int64 _exrpos;
-  Int64 _exrsize;
+  exr_file_offset_t _exrpos;
+  exr_file_offset_t _exrsize;
   unsigned char *_exrbuf;
 };
 
@@ -182,12 +198,12 @@ class IFileStream : public Imf::IStream {
 return check_error();
   }
 
-  Int64 tellg() override
+  exr_file_offset_t tellg() override
   {
 return std::streamoff(ifs.tellg());
   }
 
-  void seekg(Int64 pos) override
+  void seekg(exr_file_offset_t pos) override
   {
 ifs.seekg(pos);
 check_error();
@@ -231,19 +247,19 @@ class OMemStream : public OStream {
 ibuf->encodedsize += n;
   }
 
-  Int64 tellp() override
+  exr_file_offset_t tellp() override
   {
 return offset;
   }
 
-  void seekp(Int64 pos) override
+  void seekp(exr_file_offset_t pos) override
   {
 offset = pos;
 ensure_size(offset);
   }
 
  private:
-  void ensure_size(Int64 size)
+  void ensure_size(exr_file_offset_t size)
   {
 /* if buffer is too small increase it. */
 while (size > ibuf->encodedbuffersize) {
@@ -254,7 +270,7 @@ class OMemStream : public OStream {
   }
 
   ImBuf *ibuf;
-  Int64 offset;
+  exr_file_offset_t offset;
 };
 
 /* File Output Stream */
@@ -284,12 +300,12 @@ class OFileStream : public OStream {
 check_error();
   }
 
-  Int64 tellp() override
+  exr_file_offset_t tellp() override
   {
 return std::streamoff(ofs.tellp());
   }
 
-  void seekp(Int64 pos) override
+  void seekp(exr_file_offset_t pos) override
   {
 ofs.seekp(pos);
 check_error();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [57013e2a44e] master: Merge branch 'blender-v3.1-release'

2022-02-16 Thread Sebastian Parborg
Commit: 57013e2a44e974d307f08f41793d810a49537f96
Author: Sebastian Parborg
Date:   Wed Feb 16 19:51:58 2022 +0100
Branches: master
https://developer.blender.org/rB57013e2a44e974d307f08f41793d810a49537f96

Merge branch 'blender-v3.1-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [05697470ab0] blender-v3.1-release: Cleanup: Remove deprecated StringGrid from our openvdb code

2022-02-16 Thread Sebastian Parborg
Commit: 05697470ab0dde6646be939ae57a95c9d4099e0b
Author: Sebastian Parborg
Date:   Wed Feb 16 19:49:58 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB05697470ab0dde6646be939ae57a95c9d4099e0b

Cleanup: Remove deprecated StringGrid from our openvdb code

StringGrid has been deprecated in openvdb 9.0.0 and will be removed soon

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D14133

===

M   source/blender/blenkernel/BKE_volume.h
M   source/blender/blenkernel/intern/volume.cc
M   source/blender/blenkernel/intern/volume_render.cc
M   source/blender/makesrna/intern/rna_volume.c
M   source/blender/modifiers/intern/MOD_volume_displace.cc

===

diff --git a/source/blender/blenkernel/BKE_volume.h 
b/source/blender/blenkernel/BKE_volume.h
index 8b42de7303d..068cdf87d16 100644
--- a/source/blender/blenkernel/BKE_volume.h
+++ b/source/blender/blenkernel/BKE_volume.h
@@ -104,7 +104,6 @@ typedef enum VolumeGridType {
   VOLUME_GRID_INT,
   VOLUME_GRID_INT64,
   VOLUME_GRID_MASK,
-  VOLUME_GRID_STRING,
   VOLUME_GRID_VECTOR_FLOAT,
   VOLUME_GRID_VECTOR_DOUBLE,
   VOLUME_GRID_VECTOR_INT,
@@ -218,8 +217,6 @@ auto BKE_volume_grid_type_operation(const VolumeGridType 
grid_type, OpType &&op)
   return op.template operator()();
 case VOLUME_GRID_VECTOR_DOUBLE:
   return op.template operator()();
-case VOLUME_GRID_STRING:
-  return op.template operator()();
 case VOLUME_GRID_MASK:
   return op.template operator()();
 case VOLUME_GRID_POINTS:
diff --git a/source/blender/blenkernel/intern/volume.cc 
b/source/blender/blenkernel/intern/volume.cc
index 39a7725bfa3..a0e2d1a83cd 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -1345,9 +1345,6 @@ VolumeGridType BKE_volume_grid_type_openvdb(const 
openvdb::GridBase &grid)
   if (grid.isType()) {
 return VOLUME_GRID_VECTOR_DOUBLE;
   }
-  if (grid.isType()) {
-return VOLUME_GRID_STRING;
-  }
   if (grid.isType()) {
 return VOLUME_GRID_MASK;
   }
@@ -1383,7 +1380,6 @@ int BKE_volume_grid_channels(const VolumeGrid *grid)
 case VOLUME_GRID_VECTOR_DOUBLE:
 case VOLUME_GRID_VECTOR_INT:
   return 3;
-case VOLUME_GRID_STRING:
 case VOLUME_GRID_POINTS:
 case VOLUME_GRID_UNKNOWN:
   return 0;
@@ -1624,13 +1620,8 @@ struct CreateGridWithChangedResolutionOp {
 
   template typename openvdb::GridBase::Ptr operator()()
   {
-if constexpr (std::is_same_v) {
-  return {};
-}
-else {
-  return create_grid_with_changed_resolution(static_cast(grid),
- resolution_factor);
-}
+return create_grid_with_changed_resolution(static_cast(grid),
+   resolution_factor);
   }
 };
 
diff --git a/source/blender/blenkernel/intern/volume_render.cc 
b/source/blender/blenkernel/intern/volume_render.cc
index c0a205b5673..7ccf04df941 100644
--- a/source/blender/blenkernel/intern/volume_render.cc
+++ b/source/blender/blenkernel/intern/volume_render.cc
@@ -77,7 +77,6 @@ static void extract_dense_float_voxels(const VolumeGridType 
grid_type,
 case VOLUME_GRID_VECTOR_INT:
   return extract_dense_voxels(
   grid, bbox, reinterpret_cast(r_voxels));
-case VOLUME_GRID_STRING:
 case VOLUME_GRID_POINTS:
 case VOLUME_GRID_UNKNOWN:
   /* Zero channels to copy. */
diff --git a/source/blender/makesrna/intern/rna_volume.c 
b/source/blender/makesrna/intern/rna_volume.c
index 3100c1195f4..2854f02a4d4 100644
--- a/source/blender/makesrna/intern/rna_volume.c
+++ b/source/blender/makesrna/intern/rna_volume.c
@@ -40,7 +40,6 @@ const EnumPropertyItem rna_enum_volume_grid_data_type_items[] 
= {
 {VOLUME_GRID_INT, "INT", 0, "Integer", "32-bit integer"},
 {VOLUME_GRID_INT64, "INT64", 0, "Integer 64-bit", "64-bit integer"},
 {VOLUME_GRID_MASK, "MASK", 0, "Mask", "No data, boolean mask of active 
voxels"},
-{VOLUME_GRID_STRING, "STRING", 0, "String", "Text string"},
 {VOLUME_GRID_VECTOR_FLOAT, "VECTOR_FLOAT", 0, "Float Vector", "3D float 
vector"},
 {VOLUME_GRID_VECTOR_DOUBLE, "VECTOR_DOUBLE", 0, "Double Vector", "3D 
double vector"},
 {VOLUME_GRID_VECTOR_INT, "VECTOR_INT", 0, "Integer Vector", "3D integer 
vector"},
diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc 
b/source/blender/modifiers/intern/MOD_volume_displace.cc
index af3a502162d..e2d7f445731 100644
--- a/source/blender/modifiers/intern/MOD_volume_displace.cc
+++ b/source/blender/modifiers/intern/MOD_volume_displace.cc
@@ -203,10 +203,8 @@ struct Disp

[Bf-blender-cvs] [623ff64a278] master: Fix T81541: Symmetrize Transform Constraint, Y rotational axis unexpected results

2022-02-04 Thread Sebastian Parborg
Commit: 623ff64a278924af57d7e1ec7e7bdb8792a560f8
Author: Sebastian Parborg
Date:   Fri Feb 4 14:19:44 2022 +0100
Branches: master
https://developer.blender.org/rB623ff64a278924af57d7e1ec7e7bdb8792a560f8

Fix T81541: Symmetrize Transform Constraint, Y rotational axis unexpected 
results

The case where Y rotation is mapped to Y rotation was not handled.
This is now fixed.

Also added an automated test to make sure that the symmetrize operator
functions as intended.

Reviewed By: Sybren

Differential Revision: http://developer.blender.org/D9214

===

M   source/blender/editors/armature/armature_add.c
M   tests/python/CMakeLists.txt
A   tests/python/bl_rigging_symmetrize.py

===

diff --git a/source/blender/editors/armature/armature_add.c 
b/source/blender/editors/armature/armature_add.c
index 02ecfdb4ea6..4a327904ddd 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -581,8 +581,6 @@ static void updateDuplicateLocRotConstraintSettings(Object 
*ob,
 {
   /* This code assumes that bRotLimitConstraint and bLocLimitConstraint have 
the same fields in
* the same memory locations. */
-  BLI_assert(sizeof(bLocLimitConstraint) == sizeof(bRotLimitConstraint));
-
   bRotLimitConstraint *limit = (bRotLimitConstraint *)curcon->data;
   float local_mat[4][4], imat[4][4];
 
@@ -798,6 +796,13 @@ static void 
updateDuplicateTransformConstraintSettings(Object *ob,
   trans->to_min_rot[i] = temp_vec[i];
 }
   }
+
+  if (trans->from == TRANS_ROTATION && trans->map[1] == Y) {
+/* Y Rot to Y Rot: Flip and invert */
+trans->to_max_rot[1] = -trans->to_min_rot[1];
+trans->to_min_rot[1] = -temp_vec[1];
+  }
+
   break;
   }
   /* convert back to the settings space */
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index 63dcdc0f925..04fdb380da2 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -293,6 +293,13 @@ add_blender_test(
   --testdir "${TEST_SRC_DIR}/animation"
 )
 
+add_blender_test(
+  bl_rigging_symmetrize
+  --python ${CMAKE_CURRENT_LIST_DIR}/bl_rigging_symmetrize.py
+  --
+  --testdir "${TEST_SRC_DIR}/animation"
+)
+
 # 
--
 # IO TESTS
 
diff --git a/tests/python/bl_rigging_symmetrize.py 
b/tests/python/bl_rigging_symmetrize.py
new file mode 100644
index 000..b47ace7f3f1
--- /dev/null
+++ b/tests/python/bl_rigging_symmetrize.py
@@ -0,0 +1,244 @@
+# # BEGIN GPL LICENSE BLOCK #
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# # END GPL LICENSE BLOCK #
+
+# 
+
+"""
+blender -b -noaudio --factory-startup --python 
tests/python/bl_rigging_symmetrize.py -- --testdir /path/to/lib/tests/animation
+"""
+
+import pathlib
+import sys
+import unittest
+
+import bpy
+
+
+def check_loc_rot_scale(self, bone, exp_bone):
+# Check if posistions are the same
+self.assertEqualVector(
+bone.head, exp_bone.head, "Head position", bone.name)
+self.assertEqualVector(
+bone.tail, exp_bone.tail, "Tail position", bone.name)
+
+# Scale
+self.assertEqualVector(
+bone.scale, exp_bone.scale, "Scale", bone.name)
+
+# Rotation
+rot_mode = exp_bone.rotation_mode
+self.assertEqual(bone.rotation_mode, rot_mode, "Rotations mode does not 
match on bone %s" % (bone.name))
+
+if rot_mode == 'QUATERNION':
+self.assertEqualVector(
+bone.rotation_quaternion, exp_bone.rotation_quaternion, 
"Quaternion rotation", bone.name)
+elif rot_mode == 'AXIS_ANGLE':
+self.assertEqualVector(
+bone.axis_angle, exp_bone.axis_angle, "Axis Angle rotation", 
bone.name)
+else:
+# Euler rotation
+self.assertEqualVector(
+bone.rotation_euler, exp_bone.rotation_euler, "Euler rotation", 
bone.name)
+
+
+def check_parent(self, bone, exp_bone):
+self.assertEqual(type(bone.parent)

[Bf-blender-cvs] [25fa5792e6e] master: Cleanup: Move the "toggle smooth brush" functionality to functions

2022-01-24 Thread Sebastian Parborg
Commit: 25fa5792e6edc339c77e75b59235a273b4e598f4
Author: Sebastian Parborg
Date:   Mon Jan 24 15:57:15 2022 +0100
Branches: master
https://developer.blender.org/rB25fa5792e6edc339c77e75b59235a273b4e598f4

Cleanup: Move the "toggle smooth brush" functionality to functions

This is so it will be easier to keep the logic to toggle on/off in sync
because they are declared close to eachother.

===

M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 5ac13ebdd93..91e44a0b062 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4028,13 +4028,71 @@ static void sculpt_init_mirror_clipping(Object *ob, 
SculptSession *ss)
   }
 }
 
+static void smooth_brush_toggle_on(const bContext *C, Paint *paint, 
StrokeCache *cache)
+{
+  Scene *scene = CTX_data_scene(C);
+  Brush *brush = paint->brush;
+
+  if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
+cache->saved_mask_brush_tool = brush->mask_tool;
+brush->mask_tool = BRUSH_MASK_SMOOTH;
+  }
+  else if (ELEM(brush->sculpt_tool,
+SCULPT_TOOL_SLIDE_RELAX,
+SCULPT_TOOL_DRAW_FACE_SETS,
+SCULPT_TOOL_PAINT,
+SCULPT_TOOL_SMEAR)) {
+/* Do nothing, this tool has its own smooth mode. */
+  }
+  else {
+int cur_brush_size = BKE_brush_size_get(scene, brush);
+
+BLI_strncpy(cache->saved_active_brush_name,
+brush->id.name + 2,
+sizeof(cache->saved_active_brush_name));
+
+/* Switch to the smooth brush. */
+brush = BKE_paint_toolslots_brush_get(paint, SCULPT_TOOL_SMOOTH);
+if (brush) {
+  BKE_paint_brush_set(paint, brush);
+  cache->saved_smooth_size = BKE_brush_size_get(scene, brush);
+  BKE_brush_size_set(scene, brush, cur_brush_size);
+  BKE_curvemapping_init(brush->curve);
+}
+  }
+}
+
+static void smooth_brush_toggle_off(const bContext *C, Paint *paint, 
StrokeCache *cache)
+{
+  Main *bmain = CTX_data_main(C);
+  Scene *scene = CTX_data_scene(C);
+  Brush *brush = BKE_paint_brush(paint);
+
+  if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
+brush->mask_tool = cache->saved_mask_brush_tool;
+  }
+  else if (ELEM(brush->sculpt_tool,
+SCULPT_TOOL_SLIDE_RELAX,
+SCULPT_TOOL_DRAW_FACE_SETS,
+SCULPT_TOOL_PAINT,
+SCULPT_TOOL_SMEAR)) {
+/* Do nothing. */
+  }
+  else {
+/* Try to switch back to the saved/previous brush. */
+BKE_brush_size_set(scene, brush, cache->saved_smooth_size);
+brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, 
cache->saved_active_brush_name);
+if (brush) {
+  BKE_paint_brush_set(paint, brush);
+}
+  }
+}
+
 /* Initialize the stroke cache invariants from operator properties. */
 static void sculpt_update_cache_invariants(
 bContext *C, Sculpt *sd, SculptSession *ss, wmOperator *op, const float 
mouse[2])
 {
   StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
-  Main *bmain = CTX_data_main(C);
-  Scene *scene = CTX_data_scene(C);
   UnifiedPaintSettings *ups = 
&CTX_data_tool_settings(C)->unified_paint_settings;
   Brush *brush = BKE_paint_brush(&sd->paint);
   ViewContext *vc = paint_stroke_view_context(op->customdata);
@@ -4099,35 +4157,9 @@ static void sculpt_update_cache_invariants(
 
   /* Alt-Smooth. */
   if (cache->alt_smooth) {
-if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
-  cache->saved_mask_brush_tool = brush->mask_tool;
-  brush->mask_tool = BRUSH_MASK_SMOOTH;
-}
-else if (ELEM(brush->sculpt_tool,
-  SCULPT_TOOL_SLIDE_RELAX,
-  SCULPT_TOOL_DRAW_FACE_SETS,
-  SCULPT_TOOL_PAINT,
-  SCULPT_TOOL_SMEAR)) {
-  /* Do nothing, this tool has its own smooth mode. */
-}
-else {
-  Paint *p = &sd->paint;
-  Brush *br;
-  int size = BKE_brush_size_get(scene, brush);
-
-  BLI_strncpy(cache->saved_active_brush_name,
-  brush->id.name + 2,
-  sizeof(cache->saved_active_brush_name));
-
-  br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smooth");
-  if (br) {
-BKE_paint_brush_set(p, br);
-brush = br;
-cache->saved_smooth_size = BKE_brush_size_get(scene, brush);
-BKE_brush_size_set(scene, brush, size);
-BKE_curvemapping_init(brush->curve);
-  }
-}
+smooth_brush_toggle_on(C, &sd->paint, cache);
+/* Refresh the brush pointer in case we switched brush in the toggle 
function. */
+brush = BKE_paint_brush(&sd->paint);
   }
 
   copy_v2_v2(c

[Bf-blender-cvs] [a215d7e230d] master: Hook up invert and smooth mode to weight and vertex paint

2022-01-24 Thread Sebastian Parborg
Commit: a215d7e230d3286abbed0108a46359ce57104bc1
Author: Sebastian Parborg
Date:   Mon Jan 24 15:10:25 2022 +0100
Branches: master
https://developer.blender.org/rBa215d7e230d3286abbed0108a46359ce57104bc1

Hook up invert and smooth mode to weight and vertex paint

Previously weight paint wasn't hooked up to the "Smooth" and "Invert" modes.
With this patch it is not possible to use the "Smooth" and "Invert"
modifiers for the draw keybindings.

Reviewed By: Campbell Barton

Differential Revision: http://developer.blender.org/D13857

===

M   source/blender/editors/sculpt_paint/paint_vertex.c
M   source/blender/makesdna/DNA_brush_enums.h

===

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index df323baa2a9..75d4237d157 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -32,6 +32,7 @@
 #include "BLI_listbase.h"
 #include "BLI_math.h"
 #include "BLI_rect.h"
+#include "BLI_string.h"
 #include "BLI_task.h"
 
 #include "DNA_brush_types.h"
@@ -43,9 +44,11 @@
 #include "RNA_access.h"
 
 #include "BKE_brush.h"
+#include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_deform.h"
 #include "BKE_layer.h"
+#include "BKE_lib_id.h"
 #include "BKE_main.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_mapping.h"
@@ -1470,14 +1473,48 @@ struct WPaintData {
   bool precomputed_weight_ready;
 };
 
+static void smooth_brush_toggle_on(const bContext *C, Paint *paint, 
StrokeCache *cache)
+{
+  Scene *scene = CTX_data_scene(C);
+  Brush *brush = paint->brush;
+  int cur_brush_size = BKE_brush_size_get(scene, brush);
+
+  BLI_strncpy(
+  cache->saved_active_brush_name, brush->id.name + 2, 
sizeof(cache->saved_active_brush_name));
+
+  /* Switch to the blur (smooth) brush. */
+  brush = BKE_paint_toolslots_brush_get(paint, WPAINT_TOOL_BLUR);
+  if (brush) {
+BKE_paint_brush_set(paint, brush);
+cache->saved_smooth_size = BKE_brush_size_get(scene, brush);
+BKE_brush_size_set(scene, brush, cur_brush_size);
+BKE_curvemapping_init(brush->curve);
+  }
+}
+
+static void smooth_brush_toggle_off(const bContext *C, Paint *paint, 
StrokeCache *cache)
+{
+  Main *bmain = CTX_data_main(C);
+  Scene *scene = CTX_data_scene(C);
+  Brush *brush = BKE_paint_brush(paint);
+  /* The current brush should match with what we have stored in the cache. */
+  BLI_assert(brush == cache->brush);
+
+  /* Try to switch back to the saved/previous brush. */
+  BKE_brush_size_set(scene, brush, cache->saved_smooth_size);
+  brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, 
cache->saved_active_brush_name);
+  if (brush) {
+BKE_paint_brush_set(paint, brush);
+  }
+}
+
 /* Initialize the stroke cache invariants from operator properties */
 static void vwpaint_update_cache_invariants(
-bContext *C, const VPaint *vp, SculptSession *ss, wmOperator *op, const 
float mouse[2])
+bContext *C, VPaint *vp, SculptSession *ss, wmOperator *op, const float 
mouse[2])
 {
   StrokeCache *cache;
   Scene *scene = CTX_data_scene(C);
   UnifiedPaintSettings *ups = 
&CTX_data_tool_settings(C)->unified_paint_settings;
-  const Brush *brush = vp->paint.brush;
   ViewContext *vc = paint_stroke_view_context(op->customdata);
   Object *ob = CTX_data_active_object(C);
   float mat[3][3];
@@ -1513,7 +1550,12 @@ static void vwpaint_update_cache_invariants(
 ups->draw_inverted = false;
   }
 
+  if (cache->alt_smooth) {
+smooth_brush_toggle_on(C, &vp->paint, cache);
+  }
+
   copy_v2_v2(cache->mouse, cache->initial_mouse);
+  Brush *brush = vp->paint.brush;
   /* Truly temporary data that isn't stored in properties */
   cache->vc = vc;
   cache->brush = brush;
@@ -1715,15 +1757,15 @@ static bool wpaint_stroke_test_start(bContext *C, 
wmOperator *op, const float mo
 wpd->mirror.lock = tmpflags;
   }
 
-  if (ELEM(vp->paint.brush->weightpaint_tool, WPAINT_TOOL_SMEAR, 
WPAINT_TOOL_BLUR)) {
-wpd->precomputed_weight = MEM_mallocN(sizeof(float) * me->totvert, 
__func__);
-  }
-
   /* If not previously created, create vertex/weight paint mode session data */
   vertex_paint_init_stroke(depsgraph, ob);
   vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
   vertex_paint_init_session_data(ts, ob);
 
+  if (ELEM(vp->paint.brush->weightpaint_tool, WPAINT_TOOL_SMEAR, 
WPAINT_TOOL_BLUR)) {
+wpd->precomputed_weight = MEM_mallocN(sizeof(float) * me->totvert, 
__func__);
+  }
+
   if (ob->sculpt->mode.wpaint.dvert_prev != NULL) {
 MDeformVert *dv 

[Bf-blender-cvs] [a25cfc5db26] master: Texture/Vertex Paint: Add secondary color to the tool header

2022-01-17 Thread Sebastian Parborg
Commit: a25cfc5db2625d147c4f2d89584e6d87748a47bb
Author: Sebastian Parborg
Date:   Mon Jan 17 16:48:18 2022 +0100
Branches: master
https://developer.blender.org/rBa25cfc5db2625d147c4f2d89584e6d87748a47bb

Texture/Vertex Paint: Add secondary color to the tool header

Before we would only display the secondary color in the N-panel.
Now we also display it in the tool header.

===

M   release/scripts/startup/bl_ui/properties_paint_common.py

===

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index 49effabc5cf..347f771d1f6 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -1107,7 +1107,11 @@ def brush_basic_texpaint_settings(layout, context, 
brush, *, compact=False):
 capabilities = brush.image_paint_capabilities
 
 if capabilities.has_color:
-UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", 
text="")
+row = layout.row(align=True)
+row.ui_units_x = 4
+UnifiedPaintPanel.prop_unified_color(row, context, brush, "color", 
text="")
+UnifiedPaintPanel.prop_unified_color(row, context, brush, 
"secondary_color", text="")
+row.separator()
 layout.prop(brush, "blend", text="" if compact else "Blend")
 
 UnifiedPaintPanel.prop_unified(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5703efab886] master: Fix T94784: Crop node gizmo doesn't work

2022-01-14 Thread Sebastian Parborg
Commit: 5703efab886dd612e6a52f9ac81e157db754b14f
Author: Sebastian Parborg
Date:   Fri Jan 14 17:42:28 2022 +0100
Branches: master
https://developer.blender.org/rB5703efab886dd612e6a52f9ac81e157db754b14f

Fix T94784: Crop node gizmo doesn't work

Fix refactoring mistake in rBcbca71a7cff3
Not the min and max values are initialized properly.

===

M   source/blender/editors/space_node/node_gizmo.cc

===

diff --git a/source/blender/editors/space_node/node_gizmo.cc 
b/source/blender/editors/space_node/node_gizmo.cc
index 41d13976209..4e5c5694aff 100644
--- a/source/blender/editors/space_node/node_gizmo.cc
+++ b/source/blender/editors/space_node/node_gizmo.cc
@@ -292,7 +292,11 @@ static void gizmo_node_crop_prop_matrix_set(const wmGizmo 
*gz,
   const bool ny = rct.ymin > rct.ymax;
   BLI_rctf_resize(&rct, fabsf(matrix[0][0]), fabsf(matrix[1][1]));
   BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / 
dims[1]) + 0.5f);
-  const rctf rct_isect{0, 0, 1, 1};
+  rctf rct_isect{};
+  rct_isect.xmin = 0;
+  rct_isect.xmax = 1;
+  rct_isect.ymin = 0;
+  rct_isect.ymax = 1;
   BLI_rctf_isect(&rct_isect, &rct, &rct);
   if (nx) {
 SWAP(float, rct.xmin, rct.xmax);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [654967b0e0c] blender-v2.93-release: Fix T89564: Spline IK breaks when it is far away from the world origin

2021-12-07 Thread Sebastian Parborg
Commit: 654967b0e0ce27ff12cff815dde98b2e566abe89
Author: Sebastian Parborg
Date:   Fri Nov 26 18:20:40 2021 +0100
Branches: blender-v2.93-release
https://developer.blender.org/rB654967b0e0ce27ff12cff815dde98b2e566abe89

Fix T89564: Spline IK breaks when it is far away from the world origin

The isect_line_sphere algorithm became very imprecise when the line and
the sphere were reasonably far away from the world origin.

This would lead to no intersections being reported even if there was a
guaranteed intersection (line crossing from inside the sphere to the
outside).

To fix this we now use the secant root finding method to get an
intersection point. This is much more stable and robust it seems.

===

M   source/blender/blenkernel/intern/armature_update.c

===

diff --git a/source/blender/blenkernel/intern/armature_update.c 
b/source/blender/blenkernel/intern/armature_update.c
index 4504f10967c..178940d78e6 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -277,46 +277,59 @@ static void apply_curve_transform(
   *r_radius = (radius + *r_radius) / 2;
 }
 
+static float dist_to_sphere_shell(const float sphere_origin[3],
+  const float sphere_radius,
+  const float point[3])
+{
+  float vec[3];
+  sub_v3_v3v3(vec, sphere_origin, point);
+  return sphere_radius - len_v3(vec);
+}
+
 /* This function positions the tail of the bone so that it preserves the 
length of it.
  * The length of the bone can be seen as a sphere radius.
  */
 static int position_tail_on_spline(bSplineIKConstraint *ik_data,
const float head_pos[3],
const float sphere_radius,
-   const int prev_seg_idx,
+   int prev_seg_idx,
float r_tail_pos[3],
float *r_new_curve_pos,
float *r_radius)
 {
   /* This is using the tessellated curve data.
* So we are working with piece-wise linear curve segments.
-   * The same method is use in #BKE_where_on_path to get curve location data. 
*/
+   * The same method is used in #BKE_where_on_path to get curve location data. 
*/
   const CurveCache *cache = ik_data->tar->runtime.curve_cache;
-  const BevList *bl = cache->bev.first;
-  BevPoint *bp = bl->bevpoints;
-  const float spline_len = BKE_anim_path_get_length(cache);
   const float *seg_accum_len = cache->anim_path_accum_length;
 
   int max_seg_idx = BKE_anim_path_get_array_size(cache) - 1;
 
-  /* Convert our initial intersection point guess to a point index.
-   * If the curve was a straight line, then pointEnd would be the correct 
location.
+  /* Make an initial guess of where our intersection point will be.
+   * If the curve was a straight line, then the faction passed in 
r_new_curve_pos
+   * would be the correct location.
* So make it our first initial guess.
*/
+  const float spline_len = BKE_anim_path_get_length(cache);
   const float guessed_len = *r_new_curve_pos * spline_len;
 
   BLI_assert(prev_seg_idx >= 0);
-
   int cur_seg_idx = prev_seg_idx;
   while (cur_seg_idx < max_seg_idx && guessed_len > 
seg_accum_len[cur_seg_idx]) {
 cur_seg_idx++;
   }
 
+  /* Convert the segment to bev points.
+   * For example, the segment with index 0 will have bev points 0 and 1.
+   */
   int bp_idx = cur_seg_idx + 1;
 
-  bp = bp + bp_idx;
+  const BevList *bl = cache->bev.first;
   bool is_cyclic = bl->poly >= 0;
-  BevPoint *prev_bp = bp - 1;
+  BevPoint *bp = bl->bevpoints;
+  BevPoint *prev_bp;
+  bp = bp + bp_idx;
+  prev_bp = bp - 1;
 
   /* Go to the next tessellated curve point until we cross to outside of the 
sphere. */
   while (len_v3v3(head_pos, bp->vec) < sphere_radius) {
@@ -337,35 +350,53 @@ static int position_tail_on_spline(bSplineIKConstraint 
*ik_data,
 bp_idx++;
   }
 
-  float isect_1[3], isect_2[3];
-
-  /* Calculate the intersection point. */
-  int ret = isect_line_sphere_v3(prev_bp->vec, bp->vec, head_pos, 
sphere_radius, isect_1, isect_2);
+  /* Calculate the intersection point using the secant root finding method */
+  float x0 = 0.0f, x1 = 1.0f, x2 = 0.5f;
+  float x0_point[3], x1_point[3], start_p[3];
+  float epsilon = max_fff(1.0f, len_v3(head_pos), len_v3(bp->vec)) * 
FLT_EPSILON;
 
-  if (ret > 0) {
-/* Because of how `isect_line_sphere_v3` works, we know that `isect_1` 
contains the
- * intersection point we want. And it will always intersect as we go from 
inside to outside
- * of the sphere.
+  if (prev_seg_idx == bp_idx - 1) {
+/* The intersection lies inside the same segment as the last point.
+ * Set the las

[Bf-blender-cvs] [a0bb6bb4d69] master: Fix T89564: Spline IK breaks when it is far away from the world origin

2021-11-26 Thread Sebastian Parborg
Commit: a0bb6bb4d69d4494c1bc75f0aa2be20a12aa5718
Author: Sebastian Parborg
Date:   Fri Nov 26 18:20:40 2021 +0100
Branches: master
https://developer.blender.org/rBa0bb6bb4d69d4494c1bc75f0aa2be20a12aa5718

Fix T89564: Spline IK breaks when it is far away from the world origin

The isect_line_sphere algorithm became very imprecise when the line and
the sphere were reasonably far away from the world origin.

This would lead to no intersections being reported even if there was a
guaranteed intersection (line crossing from inside the sphere to the
outside).

To fix this we now use the secant root finding method to get an
intersection point. This is much more stable and robust it seems.

===

M   source/blender/blenkernel/intern/armature_update.c

===

diff --git a/source/blender/blenkernel/intern/armature_update.c 
b/source/blender/blenkernel/intern/armature_update.c
index 35ae2d2dbef..05c318663e9 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -277,46 +277,59 @@ static void apply_curve_transform(
   *r_radius = (radius + *r_radius) / 2;
 }
 
+static float dist_to_sphere_shell(const float sphere_origin[3],
+  const float sphere_radius,
+  const float point[3])
+{
+  float vec[3];
+  sub_v3_v3v3(vec, sphere_origin, point);
+  return sphere_radius - len_v3(vec);
+}
+
 /* This function positions the tail of the bone so that it preserves the 
length of it.
  * The length of the bone can be seen as a sphere radius.
  */
 static int position_tail_on_spline(bSplineIKConstraint *ik_data,
const float head_pos[3],
const float sphere_radius,
-   const int prev_seg_idx,
+   int prev_seg_idx,
float r_tail_pos[3],
float *r_new_curve_pos,
float *r_radius)
 {
   /* This is using the tessellated curve data.
* So we are working with piece-wise linear curve segments.
-   * The same method is use in #BKE_where_on_path to get curve location data. 
*/
+   * The same method is used in #BKE_where_on_path to get curve location data. 
*/
   const CurveCache *cache = ik_data->tar->runtime.curve_cache;
-  const BevList *bl = cache->bev.first;
-  BevPoint *bp = bl->bevpoints;
-  const float spline_len = BKE_anim_path_get_length(cache);
   const float *seg_accum_len = cache->anim_path_accum_length;
 
   int max_seg_idx = BKE_anim_path_get_array_size(cache) - 1;
 
-  /* Convert our initial intersection point guess to a point index.
-   * If the curve was a straight line, then pointEnd would be the correct 
location.
+  /* Make an initial guess of where our intersection point will be.
+   * If the curve was a straight line, then the faction passed in 
r_new_curve_pos
+   * would be the correct location.
* So make it our first initial guess.
*/
+  const float spline_len = BKE_anim_path_get_length(cache);
   const float guessed_len = *r_new_curve_pos * spline_len;
 
   BLI_assert(prev_seg_idx >= 0);
-
   int cur_seg_idx = prev_seg_idx;
   while (cur_seg_idx < max_seg_idx && guessed_len > 
seg_accum_len[cur_seg_idx]) {
 cur_seg_idx++;
   }
 
+  /* Convert the segment to bev points.
+   * For example, the segment with index 0 will have bev points 0 and 1.
+   */
   int bp_idx = cur_seg_idx + 1;
 
-  bp = bp + bp_idx;
+  const BevList *bl = cache->bev.first;
   bool is_cyclic = bl->poly >= 0;
-  BevPoint *prev_bp = bp - 1;
+  BevPoint *bp = bl->bevpoints;
+  BevPoint *prev_bp;
+  bp = bp + bp_idx;
+  prev_bp = bp - 1;
 
   /* Go to the next tessellated curve point until we cross to outside of the 
sphere. */
   while (len_v3v3(head_pos, bp->vec) < sphere_radius) {
@@ -337,35 +350,53 @@ static int position_tail_on_spline(bSplineIKConstraint 
*ik_data,
 bp_idx++;
   }
 
-  float isect_1[3], isect_2[3];
-
-  /* Calculate the intersection point. */
-  int ret = isect_line_sphere_v3(prev_bp->vec, bp->vec, head_pos, 
sphere_radius, isect_1, isect_2);
+  /* Calculate the intersection point using the secant root finding method */
+  float x0 = 0.0f, x1 = 1.0f, x2 = 0.5f;
+  float x0_point[3], x1_point[3], start_p[3];
+  float epsilon = max_fff(1.0f, len_v3(head_pos), len_v3(bp->vec)) * 
FLT_EPSILON;
 
-  if (ret > 0) {
-/* Because of how `isect_line_sphere_v3` works, we know that `isect_1` 
contains the
- * intersection point we want. And it will always intersect as we go from 
inside to outside
- * of the sphere.
+  if (prev_seg_idx == bp_idx - 1) {
+/* The intersection lies inside the same segment as the last point.
+ * Set the last point t

[Bf-blender-cvs] [c0a2b217441] master: Merge branch 'blender-v3.0-release'

2021-11-23 Thread Sebastian Parborg
Commit: c0a2b2174415af228ecc27659d7cfb5148143a7f
Author: Sebastian Parborg
Date:   Tue Nov 23 18:04:28 2021 +0100
Branches: master
https://developer.blender.org/rBc0a2b2174415af228ecc27659d7cfb5148143a7f

Merge branch 'blender-v3.0-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fb4851fbbc3] blender-v3.0-release: Fix: The bounding box gizmo breaks if transform pivot is set to cursor

2021-11-23 Thread Sebastian Parborg
Commit: fb4851fbbc37eaea8b46fb8d237674555f9337a0
Author: Sebastian Parborg
Date:   Tue Nov 23 18:00:27 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rBfb4851fbbc37eaea8b46fb8d237674555f9337a0

Fix: The bounding box gizmo breaks if transform pivot is set to cursor

The bounding box transform code assumed that the pivot would always be
the sequence object transform center.

Rework the code so that this assumption is true even if the general
transform pivot is set to be the 2D cursor.

===

M   source/blender/editors/transform/transform_gizmo_2d.c

===

diff --git a/source/blender/editors/transform/transform_gizmo_2d.c 
b/source/blender/editors/transform/transform_gizmo_2d.c
index 7a23a4a92ce..c3a0e4b1163 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -286,7 +286,14 @@ static bool gizmo2d_calc_bounds(const bContext *C, float 
*r_center, float *r_min
* In addition to this, the rotation of the bounding box can not 
currently be hooked up
* properly to read the result from the transform system (when 
transforming multiple strips).
*/
-  mid_v2_v2v2(r_center, r_min, r_max);
+  const int pivot_point = 
scene->toolsettings->sequencer_tool_settings->pivot_point;
+  if (pivot_point == V3D_AROUND_CURSOR) {
+SpaceSeq *sseq = area->spacedata.first;
+SEQ_image_preview_unit_to_px(scene, sseq->cursor, r_center);
+  }
+  else {
+mid_v2_v2v2(r_center, r_min, r_max);
+  }
   zero_v2(r_min);
   zero_v2(r_max);
   return has_select;
@@ -353,39 +360,59 @@ static float gizmo2d_calc_rotation(const bContext *C)
   return 0.0f;
 }
 
-static bool gizmo2d_calc_center(const bContext *C, float r_center[2])
+static bool seq_get_strip_pivot_median(const Scene *scene, float r_pivot[2])
+{
+  zero_v2(r_pivot);
+
+  ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene));
+  SeqCollection *strips = SEQ_query_rendered_strips(seqbase, scene->r.cfra, 0);
+  SEQ_filter_selected_strips(strips);
+  bool has_select = SEQ_collection_len(strips) != 0;
+
+  if (has_select) {
+Sequence *seq;
+SEQ_ITERATOR_FOREACH (seq, strips) {
+  float origin[2];
+  SEQ_image_transform_origin_offset_pixelspace_get(scene, seq, origin);
+  add_v2_v2(r_pivot, origin);
+}
+mul_v2_fl(r_pivot, 1.0f / SEQ_collection_len(strips));
+  }
+
+  SEQ_collection_free(strips);
+  return has_select;
+}
+
+static bool gizmo2d_calc_transform_pivot(const bContext *C, float r_pivot[2])
 {
   ScrArea *area = CTX_wm_area(C);
   Scene *scene = CTX_data_scene(C);
   bool has_select = false;
-  zero_v2(r_center);
+
   if (area->spacetype == SPACE_IMAGE) {
 SpaceImage *sima = area->spacedata.first;
 ViewLayer *view_layer = CTX_data_view_layer(C);
-ED_uvedit_center_from_pivot_ex(sima, scene, view_layer, r_center, 
sima->around, &has_select);
+ED_uvedit_center_from_pivot_ex(sima, scene, view_layer, r_pivot, 
sima->around, &has_select);
   }
   else if (area->spacetype == SPACE_SEQ) {
 SpaceSeq *sseq = area->spacedata.first;
 const int pivot_point = 
scene->toolsettings->sequencer_tool_settings->pivot_point;
-ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene));
-SeqCollection *strips = SEQ_query_rendered_strips(seqbase, scene->r.cfra, 
0);
-SEQ_filter_selected_strips(strips);
-has_select = SEQ_collection_len(strips) != 0;
 
 if (pivot_point == V3D_AROUND_CURSOR) {
-  SEQ_image_preview_unit_to_px(scene, sseq->cursor, r_center);
+  SEQ_image_preview_unit_to_px(scene, sseq->cursor, r_pivot);
+
+  ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene));
+  SeqCollection *strips = SEQ_query_rendered_strips(seqbase, 
scene->r.cfra, 0);
+  SEQ_filter_selected_strips(strips);
+  has_select = SEQ_collection_len(strips) != 0;
+  SEQ_collection_free(strips);
 }
-else if (has_select) {
-  Sequence *seq;
-  SEQ_ITERATOR_FOREACH (seq, strips) {
-float origin[2];
-SEQ_image_transform_origin_offset_pixelspace_get(scene, seq, origin);
-add_v2_v2(r_center, origin);
-  }
-  mul_v2_fl(r_center, 1.0f / SEQ_collection_len(strips));
+else {
+  has_select = seq_get_strip_pivot_median(scene, r_pivot);
 }
-
-SEQ_collection_free(strips);
+  }
+  else {
+BLI_assert_msg(0, "Unhandled space type!");
   }
   return has_select;
 }
@@ -409,7 +436,7 @@ static int gizmo2d_modal(bContext *C,
   ARegion *region = CTX_wm_region(C);
   float origin[3];
 
-  gizmo2d_calc_center(C, origin);
+  gizmo2d_calc_transform_pivot(C, origin);
   gizmo2d_origin_to_region(region, origin);
   WM_gizmo_set_matrix_location(widget, origin);
 
@@ -541,7 +

[Bf-blender-cvs] [77104bf3189] blender-v2.93-release: Fix T92355: Quadriflow crashes with zero length edges

2021-11-02 Thread Sebastian Parborg
Commit: 77104bf31891229e7d18ab56506ce6f456491eb0
Author: Sebastian Parborg
Date:   Thu Oct 21 15:13:55 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB77104bf31891229e7d18ab56506ce6f456491eb0

Fix T92355: Quadriflow crashes with zero length edges

Add a check for zero length edges to the manifold check as quadriflow
doesn't handle meshes with these.

===

M   source/blender/editors/object/object_remesh.c

===

diff --git a/source/blender/editors/object/object_remesh.c 
b/source/blender/editors/object/object_remesh.c
index 9ef2cce875f..24de6b6052e 100644
--- a/source/blender/editors/object/object_remesh.c
+++ b/source/blender/editors/object/object_remesh.c
@@ -699,12 +699,19 @@ static bool mesh_is_manifold_consistent(Mesh *mesh)
   }
 
   if (is_manifold_consistent) {
-/* check for wire edges */
 for (uint i = 0; i < mesh->totedge; i++) {
+  /* Check for wire edges. */
   if (edge_faces[i] == 0) {
 is_manifold_consistent = false;
 break;
   }
+  /* Check for zero length edges */
+  MVert *v1 = &mesh->mvert[mesh->medge[i].v1];
+  MVert *v2 = &mesh->mvert[mesh->medge[i].v2];
+  if (compare_v3v3(v1->co, v2->co, 1e-4f)) {
+is_manifold_consistent = false;
+break;
+  }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a6af0e570d0] master: Merge branch 'blender-v3.0-release'

2021-10-28 Thread Sebastian Parborg
Commit: a6af0e570d0e134c6ebb016801309bfce2c32f67
Author: Sebastian Parborg
Date:   Thu Oct 28 21:20:25 2021 +0200
Branches: master
https://developer.blender.org/rBa6af0e570d0e134c6ebb016801309bfce2c32f67

Merge branch 'blender-v3.0-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [690300eb4ac] blender-v3.0-release: Fix install paths for blender thumbnailer when not building a portable install

2021-10-28 Thread Sebastian Parborg
Commit: 690300eb4acd01ecada000c5ce6162c2437f9f6b
Author: Sebastian Parborg
Date:   Thu Oct 28 21:03:47 2021 +0200
Branches: blender-v3.0-release
https://developer.blender.org/rB690300eb4acd01ecada000c5ce6162c2437f9f6b

Fix install paths for blender thumbnailer when not building a portable install

When doing a non portable build of blender, the executable
blender-thumbnailer would be installed in two locations:
/usr/bin/
/usr/

While cleaning up, also make the blender thumbnailer dll optional on
windows to bring the logic in line with what it is on linux and mac.

Reviewed By: Campbell Barton, Ray molenkamp

Differential Revision: http://developer.blender.org/D13014

===

M   CMakeLists.txt
M   source/blender/blendthumb/CMakeLists.txt
M   source/blender/blenlib/CMakeLists.txt
M   source/blender/blenlib/intern/winstuff.c
M   source/creator/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e975c18aaf..62e7d9b2941 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -160,8 +160,7 @@ if(APPLE)
   # Currently this causes a build error linking, disable.
   set(WITH_BLENDER_THUMBNAILER OFF)
 elseif(WIN32)
-  # Building the thumbnail extraction DLL could be made optional.
-  set(WITH_BLENDER_THUMBNAILER ON)
+  option(WITH_BLENDER_THUMBNAILER "Build \"BlendThumb.dll\" helper for Windows 
explorer integration" ON)
 else()
   option(WITH_BLENDER_THUMBNAILER "Build \"blender-thumbnailer\" thumbnail 
extraction utility" ON)
 endif()
diff --git a/source/blender/blendthumb/CMakeLists.txt 
b/source/blender/blendthumb/CMakeLists.txt
index 4bcd27082c0..4c2e72418a0 100644
--- a/source/blender/blendthumb/CMakeLists.txt
+++ b/source/blender/blendthumb/CMakeLists.txt
@@ -56,11 +56,6 @@ if(WIN32)
   target_link_libraries(BlendThumb bf_blenlib dbghelp.lib Version.lib)
   set_target_properties(BlendThumb PROPERTIES LINK_FLAGS_DEBUG 
"/NODEFAULTLIB:msvcrt")
 
-  install(
-FILES $
-COMPONENT Blender
-DESTINATION "."
-  )
 else()
   # 
-
   # Build `blender-thumbnailer` executable
@@ -68,10 +63,4 @@ else()
   add_executable(blender-thumbnailer ${SRC} src/blender_thumbnailer.cc)
   target_link_libraries(blender-thumbnailer bf_blenlib)
   target_link_libraries(blender-thumbnailer ${PTHREADS_LIBRARIES})
-
-  install(
-FILES $
-COMPONENT Blender
-DESTINATION "."
-  )
 endif()
diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index 72087a12767..7db984aef5c 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -367,6 +367,10 @@ if(WITH_GMP)
 endif()
 
 if(WIN32)
+  if (WITH_BLENDER_THUMBNAILER)
+# Needed for querying the thumbnailer .dll in winstuff.c
+add_definitions(-DWITH_BLENDER_THUMBNAILER)
+  endif()
   list(APPEND INC
 ../../../intern/utfconv
   )
diff --git a/source/blender/blenlib/intern/winstuff.c 
b/source/blender/blenlib/intern/winstuff.c
index d5c9c5cd5e6..3001b25bc1e 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -172,12 +172,14 @@ bool BLI_windows_register_blend_extension(const bool 
background)
 return false;
   }
 
+#  ifdef WITH_BLENDER_THUMBNAILER
   BLI_windows_get_executable_dir(InstallDir);
   GetSystemDirectory(SysDir, FILE_MAXDIR);
   ThumbHandlerDLL = "BlendThumb.dll";
   snprintf(
   RegCmd, MAX_PATH * 2, "%s\\regsvr32 /s \"%s\\%s\"", SysDir, InstallDir, 
ThumbHandlerDLL);
   system(RegCmd);
+#  endif
 
   RegCloseKey(root);
   printf("success (%s)\n", usr_mode ? "user" : "system");
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index de560e39606..816d3a60fc3 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -990,6 +990,13 @@ elseif(WIN32)
 DESTINATION "."
   )
 
+  if(WITH_BLENDER_THUMBNAILER)
+install(
+  TARGETS BlendThumb
+  DESTINATION "."
+)
+  endif()
+
   if(WITH_DRACO)
 install(
   PROGRAMS $

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [10fb5cc58d2] master: Fix T92355: Quadriflow crashes with zero length edges

2021-10-21 Thread Sebastian Parborg
Commit: 10fb5cc58d210592ef0ae410e305be906ad5ce51
Author: Sebastian Parborg
Date:   Thu Oct 21 15:13:55 2021 +0200
Branches: master
https://developer.blender.org/rB10fb5cc58d210592ef0ae410e305be906ad5ce51

Fix T92355: Quadriflow crashes with zero length edges

Add a check for zero length edges to the manifold check as quadriflow
doesn't handle meshes with these.

===

M   source/blender/editors/object/object_remesh.cc

===

diff --git a/source/blender/editors/object/object_remesh.cc 
b/source/blender/editors/object/object_remesh.cc
index d56cb3c7548..3bdf7e0d34d 100644
--- a/source/blender/editors/object/object_remesh.cc
+++ b/source/blender/editors/object/object_remesh.cc
@@ -708,12 +708,19 @@ static bool mesh_is_manifold_consistent(Mesh *mesh)
   }
 
   if (is_manifold_consistent) {
-/* check for wire edges */
 for (uint i = 0; i < mesh->totedge; i++) {
+  /* Check for wire edges. */
   if (edge_faces[i] == 0) {
 is_manifold_consistent = false;
 break;
   }
+  /* Check for zero length edges */
+  MVert *v1 = &mesh->mvert[mesh->medge[i].v1];
+  MVert *v2 = &mesh->mvert[mesh->medge[i].v2];
+  if (compare_v3v3(v1->co, v2->co, 1e-4f)) {
+is_manifold_consistent = false;
+break;
+  }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [482806c8167] master: VSE: Implement the bounding box (xform) tool in the seq preview window

2021-10-08 Thread Sebastian Parborg
Commit: 482806c81678e351ff171c68a757386a5b2d4676
Author: Sebastian Parborg
Date:   Fri Oct 8 12:09:27 2021 +0200
Branches: master
https://developer.blender.org/rB482806c81678e351ff171c68a757386a5b2d4676

VSE: Implement the bounding box (xform) tool in the seq preview window

Make the "xform" tool/gizmo available for strip transformations in the
sequencer preview window.

Because of the amount of hacks needed to make the gizmo work nicely with
multiple strips at the same time, it was decided to only show the
translate gizmo when multiple strips are selected.

This is because the transforms with multiple strips would appear buggy
because of our lack of shearing support in the transform system.
There is also currently no way to properly sync the gizmo drawing with
the transform when using multiple strips.

Reviewed By: Richard Antalik, Campbell Barton

Differential Revision: http://developer.blender.org/D12729

===

M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform_constraints.c
M   source/blender/editors/transform/transform_convert_sequencer_image.c
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_gizmo_2d.c
M   source/blender/editors/transform/transform_mode.c
M   source/blender/editors/transform/transform_mode.h
M   source/blender/editors/transform/transform_mode_resize.c
M   source/blender/editors/transform/transform_mode_shrink_fatten.c
M   source/blender/editors/transform/transform_ops.c
M   source/blender/editors/transform/transform_orientations.c
M   source/blender/sequencer/SEQ_transform.h
M   source/blender/sequencer/intern/strip_transform.c

===

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 008129cd389..9b1b401bc5b 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2515,6 +2515,18 @@ class _defs_sequencer_generic:
 keymap="Sequencer Tool: Scale",
 )
 
+@ToolDef.from_fn
+def transform():
+return dict(
+idname="builtin.transform",
+label="Transform",
+description=(
+"Supports any combination of grab, rotate, and scale at once"
+),
+icon="ops.transform.transform",
+widget="SEQUENCER_GGT_gizmo2d",
+# No keymap default action, only for gizmo!
+   )
 
 class _defs_sequencer_select:
 @ToolDef.from_fn
@@ -3112,6 +3124,8 @@ class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, 
Panel):
 _defs_sequencer_generic.translate,
 _defs_sequencer_generic.rotate,
 _defs_sequencer_generic.scale,
+_defs_sequencer_generic.transform,
+None,
 _defs_sequencer_generic.sample,
 *_tools_annotate,
 ],
@@ -3126,9 +3140,12 @@ class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, 
Panel):
 _defs_sequencer_generic.translate,
 _defs_sequencer_generic.rotate,
 _defs_sequencer_generic.scale,
-_defs_sequencer_generic.blade,
+_defs_sequencer_generic.transform,
+None,
 _defs_sequencer_generic.sample,
 *_tools_annotate,
+None,
+_defs_sequencer_generic.blade,
 ],
 }
 
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 6fd06b47656..08dbdd021d3 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -98,64 +98,12 @@ static bool gizmo_calc_rect_view_margin(const wmGizmo *gz, 
const float dims[2],
 zero_v2(margin);
 return false;
   }
+
   margin[0] = ((handle_size * scale_xy[0]));
   margin[1] = ((handle_size * scale_xy[1]));
   return true;
 }
 
-/*  */
-
-static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[2], bool 
r_constrain_axis[2])
-{
-  bool x = true, y = true;
-  switch (part) {
-case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: {
-  ARRAY_SET_ITEMS(r_pt, 0.5, 0.0);
-  x = false;
-  break;
-}
-case ED_GIZMO_CAGE2D_PART_SCALE_MAX_X: {
-  ARRAY_SET_ITEMS(r_pt, -0.5, 0.0);
-  x = false;
-  break;
-}
-case ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y: {

[Bf-blender-cvs] [ebb81050c58] studio-sprite-fright: VSE: Free animation strip data if they are not visible

2021-10-05 Thread Sebastian Parborg
Commit: ebb81050c588bb39a3adf8664bc04f04382a02cb
Author: Sebastian Parborg
Date:   Tue Oct 5 18:49:45 2021 +0200
Branches: studio-sprite-fright
https://developer.blender.org/rBebb81050c588bb39a3adf8664bc04f04382a02cb

VSE: Free animation strip data if they are not visible

Previously we would only free animation strip data when doing final
renders. If not doing a final render or simply just playing back videos
in the VSE, we would not free decoders or non VSE cache data from the
strips.

This would lead to memory usage exploding in complex VSE scenes.

Now we instead use the dumb apporach of freeing everything that is not
currently visible.

===

M   source/blender/render/intern/pipeline.c
M   source/blender/sequencer/intern/render.c
M   source/blender/sequencer/intern/strip_relations.c

===

diff --git a/source/blender/render/intern/pipeline.c 
b/source/blender/render/intern/pipeline.c
index 6c5f9a4ed4c..1685fab744a 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -1466,7 +1466,7 @@ static void do_render_full_pipeline(Render *re)
 
   /* ensure no images are in memory from previous animated sequences */
   BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
-  SEQ_relations_free_all_anim_ibufs(re->scene, re->r.cfra);
+  SEQ_cache_cleanup(re->scene);
 
   if (RE_engine_render(re, true)) {
 /* in this case external render overrides all */
diff --git a/source/blender/sequencer/intern/render.c 
b/source/blender/sequencer/intern/render.c
index 6c4502a3608..41fb640a407 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -69,6 +69,7 @@
 #include "SEQ_iterator.h"
 #include "SEQ_modifier.h"
 #include "SEQ_proxy.h"
+#include "SEQ_relations.h"
 #include "SEQ_render.h"
 #include "SEQ_sequencer.h"
 #include "SEQ_time.h"
@@ -1950,6 +1951,8 @@ ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context, 
float timeline_frame,
   }
 
   seq_cache_free_temp_cache(context->scene, context->task_id, timeline_frame);
+  /* Make sure we only keep the `anim` data for strips that are in view. */
+  SEQ_relations_free_all_anim_ibufs(context->scene, timeline_frame);
 
   if (count && !out) {
 BLI_mutex_lock(&seq_render_mutex);
diff --git a/source/blender/sequencer/intern/strip_relations.c 
b/source/blender/sequencer/intern/strip_relations.c
index 46fdd2c3d14..6b0452b69d5 100644
--- a/source/blender/sequencer/intern/strip_relations.c
+++ b/source/blender/sequencer/intern/strip_relations.c
@@ -354,7 +354,6 @@ void SEQ_relations_update_changed_seq_and_deps(Scene *scene,
   }
 }
 
-/* Unused */
 static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int 
timeline_frame)
 {
   for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
@@ -367,7 +366,6 @@ static void sequencer_all_free_anim_ibufs(ListBase 
*seqbase, int timeline_frame)
   }
 }
 
-/* Unused */
 void SEQ_relations_free_all_anim_ibufs(Scene *scene, int timeline_frame)
 {
   Editing *ed = SEQ_editing_get(scene);
@@ -375,7 +373,6 @@ void SEQ_relations_free_all_anim_ibufs(Scene *scene, int 
timeline_frame)
 return;
   }
   sequencer_all_free_anim_ibufs(&ed->seqbase, timeline_frame);
-  SEQ_cache_cleanup(scene);
 }
 
 static Sequence *sequencer_check_scene_recursion(Scene *scene, ListBase 
*seqbase)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0a1a173e57d] master: Cleanup: Make anim_getnew in the VSE less confusing

2021-10-05 Thread Sebastian Parborg
Commit: 0a1a173e57d0f9e797dbb4972adda2993fccd6d7
Author: Sebastian Parborg
Date:   Tue Oct 5 18:45:47 2021 +0200
Branches: master
https://developer.blender.org/rB0a1a173e57d0f9e797dbb4972adda2993fccd6d7

Cleanup: Make anim_getnew in the VSE less confusing

It was using dummy image buffers to indicate if an animation container
could be initialized or not.

Use booleans instead.

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 13f9356751e..4eb078113dd 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1496,16 +1496,15 @@ static void free_anim_ffmpeg(struct anim *anim)
 
 #endif
 
-/* Try next picture to read */
-/* No picture, try to open next animation */
-/* Succeed, remove first image from animation */
+/* Try to init the anim struct.
+ * Returns true on success.*/
 
-static ImBuf *anim_getnew(struct anim *anim)
+static bool anim_getnew(struct anim *anim)
 {
-  struct ImBuf *ibuf = NULL;
-
+  BLI_assert(anim->curtype == ANIM_NONE);
   if (anim == NULL) {
-return NULL;
+/* Nothing to init. */
+return false;
   }
 
   free_anim_movie(anim);
@@ -1518,44 +1517,43 @@ static ImBuf *anim_getnew(struct anim *anim)
   free_anim_ffmpeg(anim);
 #endif
 
-  if (anim->curtype != 0) {
-return NULL;
-  }
   anim->curtype = imb_get_anim_type(anim->name);
 
   switch (anim->curtype) {
-case ANIM_SEQUENCE:
-  ibuf = IMB_loadiffname(anim->name, anim->ib_flags, anim->colorspace);
+case ANIM_SEQUENCE: {
+  ImBuf *ibuf = IMB_loadiffname(anim->name, anim->ib_flags, 
anim->colorspace);
   if (ibuf) {
 BLI_strncpy(anim->first, anim->name, sizeof(anim->first));
 anim->duration_in_frames = 1;
+IMB_freeImBuf(ibuf);
+  }
+  else {
+return false;
   }
   break;
+}
 case ANIM_MOVIE:
   if (startmovie(anim)) {
-return NULL;
+return false;
   }
-  ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */
   break;
 #ifdef WITH_AVI
 case ANIM_AVI:
   if (startavi(anim)) {
 printf("couldn't start avi\n");
-return NULL;
+return false;
   }
-  ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
   break;
 #endif
 #ifdef WITH_FFMPEG
 case ANIM_FFMPEG:
   if (startffmpeg(anim)) {
-return 0;
+return false;
   }
-  ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0);
   break;
 #endif
   }
-  return ibuf;
+  return true;
 }
 
 struct ImBuf *IMB_anim_previewframe(struct anim *anim)
@@ -1589,14 +1587,10 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim,
   filter_y = (anim->ib_flags & IB_animdeinterlace);
 
   if (preview_size == IMB_PROXY_NONE) {
-if (anim->curtype == 0) {
-  ibuf = anim_getnew(anim);
-  if (ibuf == NULL) {
+if (anim->curtype == ANIM_NONE) {
+  if (!anim_getnew(anim)) {
 return NULL;
   }
-
-  IMB_freeImBuf(ibuf); /*  */
-  ibuf = NULL;
 }
 
 if (position < 0) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [88c02bf826d] master: VSE: Free animation strip data if they are not visible

2021-10-05 Thread Sebastian Parborg
Commit: 88c02bf826df371be89af326515a3216fb449673
Author: Sebastian Parborg
Date:   Tue Oct 5 18:49:45 2021 +0200
Branches: master
https://developer.blender.org/rB88c02bf826df371be89af326515a3216fb449673

VSE: Free animation strip data if they are not visible

Previously we would only free animation strip data when doing final
renders. If not doing a final render or simply just playing back videos
in the VSE, we would not free decoders or non VSE cache data from the
strips.

This would lead to memory usage exploding in complex VSE scenes.

Now we instead use the dumb apporach of freeing everything that is not
currently visible.

===

M   source/blender/render/intern/pipeline.c
M   source/blender/sequencer/intern/render.c
M   source/blender/sequencer/intern/strip_relations.c

===

diff --git a/source/blender/render/intern/pipeline.c 
b/source/blender/render/intern/pipeline.c
index 7c5259a1c5c..1bf0dfe079c 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -1440,7 +1440,7 @@ static void do_render_full_pipeline(Render *re)
 
   /* ensure no images are in memory from previous animated sequences */
   BKE_image_all_free_anim_ibufs(re->main, re->r.cfra);
-  SEQ_relations_free_all_anim_ibufs(re->scene, re->r.cfra);
+  SEQ_cache_cleanup(re->scene);
 
   if (RE_engine_render(re, true)) {
 /* in this case external render overrides all */
diff --git a/source/blender/sequencer/intern/render.c 
b/source/blender/sequencer/intern/render.c
index cf3f9d5cba5..6b233cd20fb 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -69,6 +69,7 @@
 #include "SEQ_iterator.h"
 #include "SEQ_modifier.h"
 #include "SEQ_proxy.h"
+#include "SEQ_relations.h"
 #include "SEQ_render.h"
 #include "SEQ_sequencer.h"
 #include "SEQ_time.h"
@@ -1882,6 +1883,8 @@ ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context, 
float timeline_frame,
   }
 
   seq_cache_free_temp_cache(context->scene, context->task_id, timeline_frame);
+  /* Make sure we only keep the `anim` data for strips that are in view. */
+  SEQ_relations_free_all_anim_ibufs(context->scene, timeline_frame);
 
   if (count && !out) {
 BLI_mutex_lock(&seq_render_mutex);
diff --git a/source/blender/sequencer/intern/strip_relations.c 
b/source/blender/sequencer/intern/strip_relations.c
index 9822bfe38f9..444d3581b3d 100644
--- a/source/blender/sequencer/intern/strip_relations.c
+++ b/source/blender/sequencer/intern/strip_relations.c
@@ -354,7 +354,6 @@ void SEQ_relations_update_changed_seq_and_deps(Scene *scene,
   }
 }
 
-/* Unused */
 static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int 
timeline_frame)
 {
   for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
@@ -367,7 +366,6 @@ static void sequencer_all_free_anim_ibufs(ListBase 
*seqbase, int timeline_frame)
   }
 }
 
-/* Unused */
 void SEQ_relations_free_all_anim_ibufs(Scene *scene, int timeline_frame)
 {
   Editing *ed = SEQ_editing_get(scene);
@@ -375,7 +373,6 @@ void SEQ_relations_free_all_anim_ibufs(Scene *scene, int 
timeline_frame)
 return;
   }
   sequencer_all_free_anim_ibufs(&ed->seqbase, timeline_frame);
-  SEQ_cache_cleanup(scene);
 }
 
 static Sequence *sequencer_check_scene_recursion(Scene *scene, ListBase 
*seqbase)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f2b86471eaa] master: Fix session uuid ghash comparison return value

2021-10-04 Thread Sebastian Parborg
Commit: f2b86471eaa48f09f534195c7b1095f85e2b7ff8
Author: Sebastian Parborg
Date:   Mon Oct 4 11:53:12 2021 +0200
Branches: master
https://developer.blender.org/rBf2b86471eaa48f09f534195c7b1095f85e2b7ff8

Fix session uuid ghash comparison return value

Because of legacy reasons (C string compare function returning 0 when
strings are equal), the ghash compare function is expected to return
false when hashes are equal.

===

M   source/blender/blenlib/intern/session_uuid.c

===

diff --git a/source/blender/blenlib/intern/session_uuid.c 
b/source/blender/blenlib/intern/session_uuid.c
index 8ed96f02149..ac15a400a92 100644
--- a/source/blender/blenlib/intern/session_uuid.c
+++ b/source/blender/blenlib/intern/session_uuid.c
@@ -74,5 +74,5 @@ bool BLI_session_uuid_ghash_compare(const void *lhs_v, const 
void *rhs_v)
 {
   const SessionUUID *lhs = (const SessionUUID *)lhs_v;
   const SessionUUID *rhs = (const SessionUUID *)rhs_v;
-  return BLI_session_uuid_is_equal(lhs, rhs);
+  return !BLI_session_uuid_is_equal(lhs, rhs);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [eacdc0ab4a9] master: VSE: Draw active strips with a different color in the preview window

2021-10-01 Thread Sebastian Parborg
Commit: eacdc0ab4a936c930ba5ae65931acf625f6254ba
Author: Sebastian Parborg
Date:   Fri Oct 1 18:03:18 2021 +0200
Branches: master
https://developer.blender.org/rBeacdc0ab4a936c930ba5ae65931acf625f6254ba

VSE: Draw active strips with a different color in the preview window

===

M   source/blender/editors/space_sequencer/sequencer_draw.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index ae392980069..dc5e11b6998 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -108,9 +108,9 @@
 static Sequence *special_seq_update = NULL;
 
 void color3ubv_from_seq(const Scene *curscene,
-const Sequence *seq,
-const bool show_strip_color_tag,
-uchar r_col[3])
+const Sequence *seq,
+const bool show_strip_color_tag,
+uchar r_col[3])
 {
   if (show_strip_color_tag && (uint)seq->color_tag < SEQUENCE_COLOR_TOT &&
   seq->color_tag != SEQUENCE_COLOR_NONE) {
@@ -2616,7 +2616,7 @@ static int 
sequencer_draw_get_transform_preview_frame(Scene *scene)
   return preview_frame;
 }
 
-static void seq_draw_image_origin_and_outline(const bContext *C, Sequence *seq)
+static void seq_draw_image_origin_and_outline(const bContext *C, Sequence 
*seq, bool is_active_seq)
 {
   SpaceSeq *sseq = CTX_wm_space_seq(C);
   if ((seq->flag & SELECT) == 0) {
@@ -2659,7 +2659,12 @@ static void seq_draw_image_origin_and_outline(const 
bContext *C, Sequence *seq)
   immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
   float col[3];
-  UI_GetThemeColor3fv(TH_SEQ_SELECTED, col);
+  if (is_active_seq) {
+UI_GetThemeColor3fv(TH_SEQ_ACTIVE, col);
+  }
+  else {
+UI_GetThemeColor3fv(TH_SEQ_SELECTED, col);
+  }
   immUniformColor3fv(col);
   immUniform1f("lineWidth", U.pixelsize);
   immBegin(GPU_PRIM_LINE_LOOP, 4);
@@ -2753,8 +2758,9 @@ void sequencer_draw_preview(const bContext *C,
   if (!draw_backdrop && scene->ed != NULL) {
 SeqCollection *collection = SEQ_query_rendered_strips(&scene->ed->seqbase, 
timeline_frame, 0);
 Sequence *seq;
+Sequence *active_seq = SEQ_select_active_get(scene);
 SEQ_ITERATOR_FOREACH (seq, collection) {
-  seq_draw_image_origin_and_outline(C, seq);
+  seq_draw_image_origin_and_outline(C, seq, seq == active_seq);
 }
 SEQ_collection_free(collection);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f49d438ced7] master: Cleanup and remove SEQ_ALL_BEGIN macro

2021-08-25 Thread Sebastian Parborg
Commit: f49d438ced7c5874dbf43976d9901a462176f541
Author: Sebastian Parborg
Date:   Fri Aug 20 16:30:34 2021 +0200
Branches: master
https://developer.blender.org/rBf49d438ced7c5874dbf43976d9901a462176f541

Cleanup and remove SEQ_ALL_BEGIN macro

We now use a for_each function with callback to iterate through all sequences 
in the scene.

This has the benefit that we now only loop over the sequences in the scene once.
Before we would loop over them twice and allocate memory to store temporary 
data.

The allocation of temporary data lead to unintentional memory leaks if the code 
used returns to exit out of the iteration loop.
The new for_each callback method doesn't allocate any temporary data and only 
iterates though all sequences once.

Reviewed By: Richard Antalik, Bastien Montagne

Differential Revision: http://developer.blender.org/D12278

===

M   source/blender/blenkernel/BKE_scene.h
M   source/blender/blenkernel/intern/bpath.c
M   source/blender/blenkernel/intern/ipo.c
M   source/blender/blenkernel/intern/scene.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/versioning_250.c
M   source/blender/blenloader/intern/versioning_260.c
M   source/blender/blenloader/intern/versioning_270.c
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/blenloader/intern/versioning_legacy.c
M   source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   
source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc
M   source/blender/editors/sound/sound_ops.c
M   source/blender/editors/space_sequencer/sequencer_edit.c
M   source/blender/imbuf/intern/colormanagement.c
M   source/blender/makesrna/intern/rna_color.c
M   source/blender/makesrna/intern/rna_sequencer.c
M   source/blender/sequencer/SEQ_iterator.h
M   source/blender/sequencer/SEQ_sequencer.h
M   source/blender/sequencer/SEQ_utils.h
M   source/blender/sequencer/intern/clipboard.c
M   source/blender/sequencer/intern/iterator.c
M   source/blender/sequencer/intern/proxy.c
M   source/blender/sequencer/intern/sequencer.c
M   source/blender/sequencer/intern/sequencer.h
M   source/blender/sequencer/intern/strip_relations.c
M   source/blender/sequencer/intern/utils.c

===

diff --git a/source/blender/blenkernel/BKE_scene.h 
b/source/blender/blenkernel/BKE_scene.h
index 83ce5e72794..f3edf8e9f64 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -264,14 +264,6 @@ void BKE_scene_cursor_from_mat4(struct View3DCursor 
*cursor,
 const float mat[4][4],
 bool use_compat);
 
-/* Dependency graph evaluation. */
-
-/* Evaluate parts of sequences which needs to be done as a part of a 
dependency graph evaluation.
- * This does NOT include actual rendering of the strips, but rather makes them 
up-to-date for
- * animation playback and makes them ready for the sequencer's rendering 
pipeline to render them.
- */
-void BKE_scene_eval_sequencer_sequences(struct Depsgraph *depsgraph, struct 
Scene *scene);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/bpath.c 
b/source/blender/blenkernel/intern/bpath.c
index 70274de8bff..1684e22dece 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -534,6 +534,46 @@ static bool rewrite_path_alloc(char **path,
   return false;
 }
 
+typedef struct Seq_callback_data {
+  const char *absbase;
+  void *bpath_user_data;
+  BPathVisitor visit_cb;
+  const int flag;
+} Seq_callback_data;
+
+static bool seq_rewrite_path_callback(Sequence *seq, void *user_data)
+{
+  if (SEQ_HAS_PATH(seq)) {
+StripElem *se = seq->strip->stripdata;
+Seq_callback_data *cd = (Seq_callback_data *)user_data;
+
+if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM) && se) {
+  rewrite_path_fixed_dirfile(
+  seq->strip->dir, se->name, cd->visit_cb, cd->absbase, 
cd->bpath_user_data);
+}
+else if ((seq->type == SEQ_TYPE_IMAGE) && se) {
+  /* might want an option not to loop over all strips */
+  unsigned int len = (unsigned int)MEM_allocN_len(se) / (unsigned 
int)sizeof(*se);
+  unsigned int i;
+
+  if (cd->flag & BKE_BPATH_TRAVERSE_SKIP_MULTIFILE) {
+/* only operate on one path */
+len = MIN2(1u, len);
+  }
+
+  for (i = 0; i < len; i++, se++) {
+rewrite_path_fixed_dirfile(
+seq->strip->dir, se->name, cd->visit_cb, cd->absbase, 
cd->bpath_user_data);
+  }
+}
+else {
+  /* simple case */
+  rewrite_path_fixed(seq->s

[Bf-blender-cvs] [85c08c9717b] blender-v2.93-release: VSE: Flush audio encode after finishing video export

2021-08-25 Thread Sebastian Parborg
Commit: 85c08c9717b104e1b537476604b6a0fa8e58e477
Author: Sebastian Parborg
Date:   Mon Jul 5 14:16:02 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB85c08c9717b104e1b537476604b6a0fa8e58e477

VSE: Flush audio encode after finishing video export

We didn't flush audio after encoding finished which lead to audio
packets being lost.

In addition to this the audio timestamps were wrong because we
incremented the current audio time before using it.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11916

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 5ab9bdcbee6..2474c43c3e8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -148,7 +148,6 @@ static int write_audio_frame(FFMpegContext *context)
 
   AUD_Device_read(
   context->audio_mixdown_device, context->audio_input_buffer, 
context->audio_input_samples);
-  context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
 
   frame = av_frame_alloc();
   frame->pts = context->audio_time / av_q2d(c->time_base);
@@ -183,7 +182,7 @@ static int write_audio_frame(FFMpegContext *context)
context->audio_input_samples * c->channels * 
context->audio_sample_size,
1);
 
-  int success = 0;
+  int success = 1;
 
   int ret = avcodec_send_frame(c, frame);
   if (ret < 0) {
@@ -368,7 +367,7 @@ static int write_video_frame(FFMpegContext *context, int 
cfra, AVFrame *frame, R
   return success;
 }
 
-/* read and encode a frame of audio from the buffer */
+/* read and encode a frame of video from the buffer */
 static AVFrame *generate_video_frame(FFMpegContext *context, const uint8_t 
*pixels)
 {
   AVCodecParameters *codec = context->video_stream->codecpar;
@@ -1220,9 +1219,8 @@ fail:
  * parameter.
  * 
  */
-static void flush_ffmpeg(FFMpegContext *context)
+static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext 
*outfile)
 {
-  AVCodecContext *c = context->video_codec;
   AVPacket *packet = av_packet_alloc();
 
   avcodec_send_frame(c, NULL);
@@ -1241,13 +1239,13 @@ static void flush_ffmpeg(FFMpegContext *context)
   break;
 }
 
-packet->stream_index = context->video_stream->index;
-av_packet_rescale_ts(packet, c->time_base, 
context->video_stream->time_base);
+packet->stream_index = stream->index;
+av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, context->video_stream, packet);
+my_guess_pkt_duration(context->outfile, stream, packet);
 #  endif
 
-int write_ret = av_interleaved_write_frame(context->outfile, packet);
+int write_ret = av_interleaved_write_frame(outfile, packet);
 if (write_ret != 0) {
   fprintf(stderr, "Error writing delayed frame: %s\n", 
av_err2str(write_ret));
   break;
@@ -1390,12 +1388,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit);
 #  ifdef WITH_AUDASPACE
 static void write_audio_frames(FFMpegContext *context, double to_pts)
 {
-  int finished = 0;
+  AVCodecContext *c = context->audio_codec;
 
-  while (context->audio_stream && !finished) {
-if ((context->audio_time >= to_pts) || (write_audio_frame(context))) {
-  finished = 1;
+  while (context->audio_stream) {
+if ((context->audio_time >= to_pts) || !write_audio_frame(context)) {
+  break;
 }
+context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
   }
 }
 #  endif
@@ -1416,9 +1415,6 @@ int BKE_ffmpeg_append(void *context_v,
 
   PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, 
recty);
 
-  /* why is this done before writing the video frame and again at end_ffmpeg? 
*/
-  //  write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
-
   if (context->video_stream) {
 avframe = generate_video_frame(context, (unsigned char *)pixels);
 success = (avframe && write_video_frame(context, frame - start_frame, 
avframe, reports));
@@ -1454,8 +1450,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit)
 #  endif
 
   if (context->video_stream) {
-PRINT("Flushing delayed frames...\n");
-flush_ffmpeg(context);
+PRINT("Flushing delayed video frames...\n");
+flush_ffmpeg(context->video_codec, context->video_stream, 
context->outfile);
+  }
+
+  if (context->audio_stream) {
+PRINT("Flushing

[Bf-blender-cvs] [7ec351c0d53] blender-v2.93-release: FFMPEG: Fix building with older versions that need FFMPEG_USE_DURATION_WORKAROUND

2021-08-25 Thread Sebastian Parborg
Commit: 7ec351c0d531a801d07263c6c95c8cffc1fb5e9b
Author: Sebastian Parborg
Date:   Tue Aug 24 15:15:21 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB7ec351c0d531a801d07263c6c95c8cffc1fb5e9b

FFMPEG: Fix building with older versions that need 
FFMPEG_USE_DURATION_WORKAROUND

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 2474c43c3e8..ba1bf88f89f 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1242,7 +1242,7 @@ static void flush_ffmpeg(AVCodecContext *c, AVStream 
*stream, AVFormatContext *o
 packet->stream_index = stream->index;
 av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, stream, packet);
+my_guess_pkt_duration(outfile, stream, packet);
 #  endif
 
 int write_ret = av_interleaved_write_frame(outfile, packet);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7aff40f410f] master: FFMPEG: Fix building with older versions that need FFMPEG_USE_DURATION_WORKAROUND

2021-08-24 Thread Sebastian Parborg
Commit: 7aff40f410f4bb869c8045a67cda6a6ab6810a13
Author: Sebastian Parborg
Date:   Tue Aug 24 15:15:21 2021 +0200
Branches: master
https://developer.blender.org/rB7aff40f410f4bb869c8045a67cda6a6ab6810a13

FFMPEG: Fix building with older versions that need 
FFMPEG_USE_DURATION_WORKAROUND

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 323da7473b5..a20c918c517 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1248,7 +1248,7 @@ static void flush_ffmpeg(AVCodecContext *c, AVStream 
*stream, AVFormatContext *o
 packet->stream_index = stream->index;
 av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, stream, packet);
+my_guess_pkt_duration(outfile, stream, packet);
 #  endif
 
 int write_ret = av_interleaved_write_frame(outfile, packet);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c634d859b21] blender-v2.93-release: VSE: Use lines to draw waveform

2021-08-23 Thread Sebastian Parborg
Commit: c634d859b216602d3d479966a5e48a433777ddce
Author: Sebastian Parborg
Date:   Thu Jul 1 18:51:26 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBc634d859b216602d3d479966a5e48a433777ddce

VSE: Use lines to draw waveform

Refactor and improve waveform drawing.

Drawing now can use line strips to draw waveforms instead of only
triangle strips. This makes us able to properly visualize thin waveforms
as they would not be visible before. We now also draw the RMS value of
the waveform.

The waveform drawing is now also properly aligned to the screen pixels
to avoid flickering when transforming the strip.

Reviewed By: Richard Antalik

Differential Revision: https://developer.blender.org/D11184

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   source/blender/editors/space_sequencer/sequencer_draw.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index 97e5f5540de..5cc33525d1d 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -247,7 +247,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, 
int length, int sampl
 
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
-   buffer[i * 3 + 2] = sqrt(power) / len;
+   buffer[i * 3 + 2] = sqrt(power / len); // RMS
 
if(overallmax < max)
overallmax = max;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index d63d62f54f1..52f162b5e87 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -232,9 +232,93 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, 
uchar col[3])
   }
 }
 
+typedef struct WaveVizData {
+  float pos[2];
+  float rms_pos;
+  bool clip;
+  bool end;
+} WaveVizData;
+
+static int get_section_len(WaveVizData *start, WaveVizData *end)
+{
+  int len = 0;
+  while (start != end) {
+len++;
+if (start->end) {
+  return len;
+}
+start++;
+  }
+  return len;
+}
+
+static void draw_waveform(WaveVizData *iter, WaveVizData *end, GPUPrimType 
prim_type, bool use_rms)
+{
+  int strip_len = get_section_len(iter, end);
+  if (strip_len > 1) {
+GPU_blend(GPU_BLEND_ALPHA);
+GPUVertFormat *format = immVertexFormat();
+uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, 
GPU_FETCH_FLOAT);
+uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, 
GPU_FETCH_FLOAT);
+
+immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+immBegin(prim_type, strip_len);
+
+while (iter != end) {
+  if (iter->clip) {
+immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+  }
+  else if (use_rms) {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.8f);
+  }
+  else {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+  }
+
+  if (use_rms) {
+immVertex2f(pos, iter->pos[0], iter->rms_pos);
+  }
+  else {
+immVertex2f(pos, iter->pos[0], iter->pos[1]);
+  }
+
+  if (iter->end) {
+/* End of line. */
+iter++;
+strip_len = get_section_len(iter, end);
+if (strip_len != 0) {
+  immEnd();
+  immUnbindProgram();
+  immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+  immBegin(prim_type, strip_len);
+}
+  }
+  else {
+iter++;
+  }
+}
+immEnd();
+immUnbindProgram();
+
+GPU_blend(GPU_BLEND_NONE);
+  }
+}
+
+static float clamp_frame_coord_to_pixel(float frame_coord,
+float pixel_frac,
+float frames_per_pixel)
+{
+  float cur_pixel = (frame_coord / frames_per_pixel);
+  float new_pixel = (int)(frame_coord / frames_per_pixel) + pixel_frac;
+  if (cur_pixel > new_pixel) {
+new_pixel += 1.0f;
+  }
+  return new_pixel * frames_per_pixel;
+}
+
 /**
  * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same 
for y1 and y2.
- * \param stepsize: The width of a pixel.
+ * \param frames_per_pixel: The amount of pixels a whole frame takes up 
(x-axis direction).
  */
 static void draw_seq_waveform_overlay(View2D *v2d,
   const bContext *C,
@@ -245,29 +329,34 @@ static void draw_seq_waveform_overlay(View2D *v2d,
   float y1,
   float x2,
   float y2,
-  float stepsize)
+  float frames_per_pixel)
 {
-  /* Offset x1 and x2 values, to match view min/max, if strip is out of 
bounds. */
- 

[Bf-blender-cvs] [489df7ac88c] blender-v2.93-release: VSE: Fix audaspace not reading ffmpeg files with start offset correctly

2021-08-23 Thread Sebastian Parborg
Commit: 489df7ac88ce06a1b6efcecf5cd27dcfb8c4efbd
Author: Sebastian Parborg
Date:   Tue Jul 6 19:48:06 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB489df7ac88ce06a1b6efcecf5cd27dcfb8c4efbd

VSE: Fix audaspace not reading ffmpeg files with start offset correctly

The duration and start time for audio strips were not correctly read in
audaspace.

Some video files have a "lead in" section of audio that plays before the
video starts playing back. Before this patch, we would play this lead in
audio at the same time as the video started and thus the audio would not
be in sync anymore.

Now the lead in audio is cut off and the duration should be correctly
calculated with this in mind.

If the audio starts after the video, the audio strip is shifted to
account for this, but it will also lead to cut off audio which might not
be wanted. However we don't have a simple way to solve this at this
point.

Differential Revision: http://developer.blender.org/D11917

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Types.h
M   extern/audaspace/include/IReader.h
M   extern/audaspace/include/fx/VolumeReader.h
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
M   extern/audaspace/src/fx/VolumeReader.cpp
M   source/blender/blenkernel/BKE_sound.h
M   source/blender/blenkernel/intern/sound.c
M   source/blender/editors/space_sequencer/sequencer_add.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_sequencer_api.c
M   source/blender/sequencer/SEQ_add.h
M   source/blender/sequencer/intern/sound.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/sequencer/intern/strip_time.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index ac876a01eb3..97e5f5540de 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
+   info.start_offset = 0.0f;
 
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) 
info.specs.rate;
+   info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
diff --git a/extern/audaspace/bindings/C/AUD_Types.h 
b/extern/audaspace/bindings/C/AUD_Types.h
index 75e4ffae18c..c6a96d30d3f 100644
--- a/extern/audaspace/bindings/C/AUD_Types.h
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -176,4 +176,5 @@ typedef struct
 {
AUD_Specs specs;
float length;
+   double start_offset;
 } AUD_SoundInfo;
diff --git a/extern/audaspace/include/IReader.h 
b/extern/audaspace/include/IReader.h
index c29900ca579..f6070b0f23b 100644
--- a/extern/audaspace/include/IReader.h
+++ b/extern/audaspace/include/IReader.h
@@ -70,6 +70,12 @@ public:
 */
virtual int getPosition() const=0;
 
+   /**
+* Returns the start offset the sound should have to line up with 
related sources.
+* \return The required start offset in seconds.
+*/
+   virtual double getStartOffset() const { return 0.0;}
+
/**
 * Returns the specification of the reader.
 * \return The Specs structure.
diff --git a/extern/audaspace/include/fx/VolumeReader.h 
b/extern/audaspace/include/fx/VolumeReader.h
index 13b6845e931..f7169f4c78b 100644
--- a/extern/audaspace/include/fx/VolumeReader.h
+++ b/extern/audaspace/include/fx/VolumeReader.h
@@ -67,4 +67,4 @@ public:
virtual void read(int& length, bool& eos, sample_t* buffer);
 };
 
-AUD_NAMESPACE_END
\ No newline at end of file
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp 
b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
index b46f65eddbf..afdc7fcfcc6 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
@@ -68,7 +68,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
for(int i = 0; i < m_frame->nb_samples; 
i++)
{

std::memcpy(((data_t*)buff

[Bf-blender-cvs] [1a4122d4415] blender-v2.93-release: Add sanity NULL checks when loading sound sequences

2021-08-23 Thread Sebastian Parborg
Commit: 1a4122d4415b05e3a106d93cda36e8e9c74c02f5
Author: Sebastian Parborg
Date:   Mon Aug 16 16:50:54 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB1a4122d4415b05e3a106d93cda36e8e9c74c02f5

Add sanity NULL checks when loading sound sequences

Would cause crashes in files that had lingering invalid sound sequences around.
For example our tests/render/volume/fire.blend test file.

===

M   source/blender/blenkernel/intern/sound.c

===

diff --git a/source/blender/blenkernel/intern/sound.c 
b/source/blender/blenkernel/intern/sound.c
index 284c5db10b3..b4a199382c1 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -703,7 +703,7 @@ void *BKE_sound_scene_add_scene_sound(
 Scene *scene, Sequence *sequence, int startframe, int endframe, int 
frameskip)
 {
   sound_verify_evaluated_id(&scene->id);
-  if (sequence->scene && scene != sequence->scene) {
+  if (sequence->scene && scene != sequence->scene && sequence->sound) {
 const double fps = FPS;
 return AUD_Sequence_add(scene->sound_scene,
 sequence->scene->sound_scene,
@@ -775,7 +775,7 @@ void BKE_sound_move_scene_sound(
 void BKE_sound_move_scene_sound_defaults(Scene *scene, Sequence *sequence)
 {
   sound_verify_evaluated_id(&scene->id);
-  if (sequence->scene_sound) {
+  if (sequence->scene_sound && sequence->sound) {
 BKE_sound_move_scene_sound(scene,
sequence->scene_sound,
sequence->startdisp,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [00dd68405d8] blender-v2.93-release: VSE: Fix seeking issues.

2021-08-23 Thread Sebastian Parborg
Commit: 00dd68405d886a1de94e265af077d0f001f01a04
Author: Sebastian Parborg
Date:   Mon Jul 12 19:13:15 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB00dd68405d886a1de94e265af077d0f001f01a04

VSE: Fix seeking issues.

The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11921

===

M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index e795445ceed..6562bd7be5f 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1059,33 +1059,21 @@ static int ffmpeg_seek_by_byte(AVFormatContext 
*pFormatCtx)
   return false;
 }
 
-static int64_t ffmpeg_get_seek_pos(struct anim *anim, int position)
+static int64_t ffmpeg_get_seek_pts(struct anim *anim, int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t st_time = anim->pFormatCtx->start_time;
-  int64_t pos = (int64_t)(position)*AV_TIME_BASE;
-  /* Step back half a time base position to make sure that we get the requested
-   * frame and not the one after it.
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+  /* Step back half a frame position to make sure that we get the requested
+   * frame and not the one after it. This is a workaround as ffmpeg will
+   * sometimes not seek to a frame after the requested pts even if
+   * AVSEEK_FLAG_BACKWARD is specified.
*/
-  pos -= (AV_TIME_BASE / 2);
-  pos /= frame_rate;
+  int64_t pts = pts_to_search - (steps_per_frame / 2);
 
-  av_log(anim->pFormatCtx,
- AV_LOG_DEBUG,
- "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n",
- pos,
- (st_time != AV_NOPTS_VALUE) ? st_time : 0);
-
-  if (pos < 0) {
-pos = 0;
-  }
-
-  if (st_time != AV_NOPTS_VALUE) {
-pos += st_time;
-  }
-
-  return pos;
+  return pts;
 }
 
 /* This gives us an estimate of which pts our requested frame will have.
@@ -1102,17 +1090,18 @@ static int64_t ffmpeg_get_pts_to_search(struct anim 
*anim,
 pts_to_search = IMB_indexer_get_pts(tc_index, new_frame_index);
   }
   else {
-int64_t st_time = anim->pFormatCtx->start_time;
 AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL);
+int64_t start_pts = v_st->start_time;
+AVRational frame_rate = v_st->r_frame_rate;
 AVRational time_base = v_st->time_base;
 
-int64_t steps_per_frame = (frame_rate.den * time_base.den) / 
(frame_rate.num * time_base.num);
-pts_to_search = position * steps_per_frame;
+double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+ (double)(frame_rate.num * time_base.num);
+
+pts_to_search = round(position * steps_per_frame);
 
-if (st_time != AV_NOPTS_VALUE && st_time != 0) {
-  int64_t start_frame = (double)st_time / AV_TIME_BASE * 
av_q2d(frame_rate);
-  pts_to_search += start_frame * steps_per_frame;
+if (start_pts != AV_NOPTS_VALUE) {
+  pts_to_search += start_pts;
 }
   }
   return pts_to_search;
@@ -1196,23 +1185,29 @@ static void ffmpeg_decode_video_frame_scan(struct anim 
*anim, int64_t pts_to_sea
  * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 and
  * https://developer.blender.org/T86944. */
 static int ffmpeg_generic_seek_workaround(struct anim *anim,
-  int64_t *requested_pos,
+  int64_t *requested_pts,
   int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t current_pos = *requested_pos;
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+
+  int64_t current_pts = *requested_pts;
   int64_t offset = 0;
 
   int64_t cur_pts, prev_pts = -1;
 
   /* Step backward frame by frame until we find the key frame we are looking 
for. */
-  while (current_pos != 0) {
-current_pos = *requested_pos -

[Bf-blender-cvs] [d486d248687] blender-v2.93-release: VSE: Fix video strip duration calculation

2021-08-23 Thread Sebastian Parborg
Commit: d486d2486879dcef87e13010cabc2f0adb5707e3
Author: Sebastian Parborg
Date:   Mon Jul 12 16:00:43 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBd486d2486879dcef87e13010cabc2f0adb5707e3

VSE: Fix video strip duration calculation

The video duration was not read correctly from the video file.

It would use the global duration of the file which does in some cases
not line up with the actual duration of the video stream.
Now we take the video stream duration and start time into account when
calculating the strip duration.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11920

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 21d9d739d4e..e795445ceed 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -616,10 +616,50 @@ static int startffmpeg(struct anim *anim)
   }
 }
   }
-  /* Fall back to the container. */
+  /* Fall back to manually estimating the video stream duration.
+   * This is because the video stream duration can be shorter than the 
pFormatCtx->duration.
+   */
   if (anim->duration_in_frames == 0) {
-anim->duration_in_frames = (int)(pFormatCtx->duration * av_q2d(frame_rate) 
/ AV_TIME_BASE +
- 0.5f);
+double pts_time_base = av_q2d(video_stream->time_base);
+double stream_dur;
+
+if (video_stream->duration != AV_NOPTS_VALUE) {
+  stream_dur = video_stream->duration * pts_time_base;
+}
+else {
+  double video_start = 0;
+  double audio_start = 0;
+
+  if (video_stream->start_time != AV_NOPTS_VALUE) {
+video_start = video_stream->start_time * pts_time_base;
+  }
+
+  /* Find audio stream to guess the duration of the video.
+   * Sometimes the audio AND the video stream have a start offset.
+   * The difference between these is the offset we want to use to
+   * calculate the video duration.
+   */
+  for (i = 0; i < pFormatCtx->nb_streams; i++) {
+if (pFormatCtx->streams[i]->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) {
+  AVStream *audio_stream = pFormatCtx->streams[i];
+  if (audio_stream->start_time != AV_NOPTS_VALUE) {
+audio_start = audio_stream->start_time * 
av_q2d(audio_stream->time_base);
+  }
+  break;
+}
+  }
+
+  if (video_start > audio_start) {
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE - 
(video_start - audio_start);
+  }
+  else {
+/* The video stream starts before or at the same time as the audio 
stream!
+ * We have to assume that the video stream is as long as the full 
pFormatCtx->duration.
+ */
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE;
+  }
+}
+anim->duration_in_frames = (int)(stream_dur * av_q2d(frame_rate) + 0.5f);
   }
 
   frs_num = frame_rate.num;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [54a821e8fd7] blender-v2.93-release: VSE: Fix memory leak when adding bad image/movie strips

2021-08-23 Thread Sebastian Parborg
Commit: 54a821e8fd7931765af69c761e20893148cba1ec
Author: Sebastian Parborg
Date:   Mon Jul 12 15:38:25 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB54a821e8fd7931765af69c761e20893148cba1ec

VSE: Fix memory leak when adding bad image/movie strips

If the add strip operator errored out, we wouldn't free custom data allocated

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11919

===

M   source/blender/editors/space_sequencer/sequencer_add.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_add.c 
b/source/blender/editors/space_sequencer/sequencer_add.c
index 68c0f4f4bdb..7db85405fcf 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -710,13 +710,13 @@ static int sequencer_add_movie_strip_exec(bContext *C, 
wmOperator *op)
   }
   else {
 if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
+  sequencer_add_cancel(C, op);
   return OPERATOR_CANCELLED;
 }
   }
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   DEG_relations_tag_update(bmain);
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@@ -1045,6 +1045,7 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   load_data.image.len = sequencer_add_image_strip_calculate_length(
   op, load_data.start_frame, &minframe, &numdigits);
   if (load_data.image.len == 0) {
+sequencer_add_cancel(C, op);
 return OPERATOR_CANCELLED;
   }
 
@@ -1067,9 +1068,8 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
   WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   return OPERATOR_FINISHED;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9511009438d] blender-v2.93-release: VSE: Fix "off by one" error when encoding audio

2021-08-23 Thread Sebastian Parborg
Commit: 9511009438deba9b5ca453f3a14b9cd67b6852a5
Author: Sebastian Parborg
Date:   Fri Jul 9 15:06:06 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB9511009438deba9b5ca453f3a14b9cd67b6852a5

VSE: Fix "off by one" error when encoding audio

Before we didn't encode the audio up until the current frame.
This lead to us not encoding the last video frame of audio.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11918

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index be90660983b..5ab9bdcbee6 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1433,8 +1433,9 @@ int BKE_ffmpeg_append(void *context_v,
   }
 
 #  ifdef WITH_AUDASPACE
-  write_audio_frames(context,
- (frame - start_frame) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
+  /* Add +1 frame because we want to encode audio up until the next video 
frame. */
+  write_audio_frames(
+  context, (frame - start_frame + 1) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
 #  endif
   return success;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [035d4c28aba] master: Add sanity NULL checks when loading sound sequences

2021-08-16 Thread Sebastian Parborg
Commit: 035d4c28abaf351b36ff5bb6057f865888790331
Author: Sebastian Parborg
Date:   Mon Aug 16 16:50:54 2021 +0200
Branches: master
https://developer.blender.org/rB035d4c28abaf351b36ff5bb6057f865888790331

Add sanity NULL checks when loading sound sequences

Would cause crashes in files that had lingering invalid sound sequences around.
For example our tests/render/volume/fire.blend test file.

===

M   source/blender/blenkernel/intern/sound.c

===

diff --git a/source/blender/blenkernel/intern/sound.c 
b/source/blender/blenkernel/intern/sound.c
index bd0fbd840ff..8730d2758e6 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -703,7 +703,7 @@ void *BKE_sound_scene_add_scene_sound(
 Scene *scene, Sequence *sequence, int startframe, int endframe, int 
frameskip)
 {
   sound_verify_evaluated_id(&scene->id);
-  if (sequence->scene && scene != sequence->scene) {
+  if (sequence->scene && scene != sequence->scene && sequence->sound) {
 const double fps = FPS;
 return AUD_Sequence_add(scene->sound_scene,
 sequence->scene->sound_scene,
@@ -775,7 +775,7 @@ void BKE_sound_move_scene_sound(
 void BKE_sound_move_scene_sound_defaults(Scene *scene, Sequence *sequence)
 {
   sound_verify_evaluated_id(&scene->id);
-  if (sequence->scene_sound) {
+  if (sequence->scene_sound && sequence->sound) {
 BKE_sound_move_scene_sound(scene,
sequence->scene_sound,
sequence->startdisp,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ded68fb1027] master: VSE: Fix audaspace not reading ffmpeg files with start offset correctly

2021-08-16 Thread Sebastian Parborg
Commit: ded68fb10275c9f9a66e7019171b83cab0e9485d
Author: Sebastian Parborg
Date:   Tue Jul 6 19:48:06 2021 +0200
Branches: master
https://developer.blender.org/rBded68fb10275c9f9a66e7019171b83cab0e9485d

VSE: Fix audaspace not reading ffmpeg files with start offset correctly

The duration and start time for audio strips were not correctly read in
audaspace.

Some video files have a "lead in" section of audio that plays before the
video starts playing back. Before this patch, we would play this lead in
audio at the same time as the video started and thus the audio would not
be in sync anymore.

Now the lead in audio is cut off and the duration should be correctly
calculated with this in mind.

If the audio starts after the video, the audio strip is shifted to
account for this, but it will also lead to cut off audio which might not
be wanted. However we don't have a simple way to solve this at this
point.

Differential Revision: http://developer.blender.org/D11917

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Types.h
M   extern/audaspace/include/IReader.h
M   extern/audaspace/include/fx/VolumeReader.h
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
M   extern/audaspace/src/fx/VolumeReader.cpp
M   source/blender/blenkernel/BKE_sound.h
M   source/blender/blenkernel/intern/sound.c
M   source/blender/editors/space_sequencer/sequencer_add.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_sequencer_api.c
M   source/blender/sequencer/SEQ_add.h
M   source/blender/sequencer/intern/sound.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/sequencer/intern/strip_time.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index ac876a01eb3..97e5f5540de 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
+   info.start_offset = 0.0f;
 
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) 
info.specs.rate;
+   info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
diff --git a/extern/audaspace/bindings/C/AUD_Types.h 
b/extern/audaspace/bindings/C/AUD_Types.h
index 75e4ffae18c..c6a96d30d3f 100644
--- a/extern/audaspace/bindings/C/AUD_Types.h
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -176,4 +176,5 @@ typedef struct
 {
AUD_Specs specs;
float length;
+   double start_offset;
 } AUD_SoundInfo;
diff --git a/extern/audaspace/include/IReader.h 
b/extern/audaspace/include/IReader.h
index c29900ca579..f6070b0f23b 100644
--- a/extern/audaspace/include/IReader.h
+++ b/extern/audaspace/include/IReader.h
@@ -70,6 +70,12 @@ public:
 */
virtual int getPosition() const=0;
 
+   /**
+* Returns the start offset the sound should have to line up with 
related sources.
+* \return The required start offset in seconds.
+*/
+   virtual double getStartOffset() const { return 0.0;}
+
/**
 * Returns the specification of the reader.
 * \return The Specs structure.
diff --git a/extern/audaspace/include/fx/VolumeReader.h 
b/extern/audaspace/include/fx/VolumeReader.h
index 13b6845e931..f7169f4c78b 100644
--- a/extern/audaspace/include/fx/VolumeReader.h
+++ b/extern/audaspace/include/fx/VolumeReader.h
@@ -67,4 +67,4 @@ public:
virtual void read(int& length, bool& eos, sample_t* buffer);
 };
 
-AUD_NAMESPACE_END
\ No newline at end of file
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp 
b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
index b46f65eddbf..afdc7fcfcc6 100644
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
@@ -68,7 +68,7 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
for(int i = 0; i < m_frame->nb_samples; 
i++)
{

std::memcpy(((data_t*)buffer.ge

[Bf-blender-cvs] [2946f72a2a1] master: VSE: Use lines to draw waveform

2021-08-16 Thread Sebastian Parborg
Commit: 2946f72a2a1f4afc4967ceda28df4294de304b81
Author: Sebastian Parborg
Date:   Thu Jul 1 18:51:26 2021 +0200
Branches: master
https://developer.blender.org/rB2946f72a2a1f4afc4967ceda28df4294de304b81

VSE: Use lines to draw waveform

Refactor and improve waveform drawing.

Drawing now can use line strips to draw waveforms instead of only
triangle strips. This makes us able to properly visualize thin waveforms
as they would not be visible before. We now also draw the RMS value of
the waveform.

The waveform drawing is now also properly aligned to the screen pixels
to avoid flickering when transforming the strip.

Reviewed By: Richard Antalik

Differential Revision: https://developer.blender.org/D11184

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   source/blender/editors/space_sequencer/sequencer_draw.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index 97e5f5540de..5cc33525d1d 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -247,7 +247,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, 
int length, int sampl
 
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
-   buffer[i * 3 + 2] = sqrt(power) / len;
+   buffer[i * 3 + 2] = sqrt(power / len); // RMS
 
if(overallmax < max)
overallmax = max;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index e49a88c88d2..888e232ce45 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -228,9 +228,93 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, 
uchar col[3])
   }
 }
 
+typedef struct WaveVizData {
+  float pos[2];
+  float rms_pos;
+  bool clip;
+  bool end;
+} WaveVizData;
+
+static int get_section_len(WaveVizData *start, WaveVizData *end)
+{
+  int len = 0;
+  while (start != end) {
+len++;
+if (start->end) {
+  return len;
+}
+start++;
+  }
+  return len;
+}
+
+static void draw_waveform(WaveVizData *iter, WaveVizData *end, GPUPrimType 
prim_type, bool use_rms)
+{
+  int strip_len = get_section_len(iter, end);
+  if (strip_len > 1) {
+GPU_blend(GPU_BLEND_ALPHA);
+GPUVertFormat *format = immVertexFormat();
+uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, 
GPU_FETCH_FLOAT);
+uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, 
GPU_FETCH_FLOAT);
+
+immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+immBegin(prim_type, strip_len);
+
+while (iter != end) {
+  if (iter->clip) {
+immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+  }
+  else if (use_rms) {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.8f);
+  }
+  else {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+  }
+
+  if (use_rms) {
+immVertex2f(pos, iter->pos[0], iter->rms_pos);
+  }
+  else {
+immVertex2f(pos, iter->pos[0], iter->pos[1]);
+  }
+
+  if (iter->end) {
+/* End of line. */
+iter++;
+strip_len = get_section_len(iter, end);
+if (strip_len != 0) {
+  immEnd();
+  immUnbindProgram();
+  immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+  immBegin(prim_type, strip_len);
+}
+  }
+  else {
+iter++;
+  }
+}
+immEnd();
+immUnbindProgram();
+
+GPU_blend(GPU_BLEND_NONE);
+  }
+}
+
+static float clamp_frame_coord_to_pixel(float frame_coord,
+float pixel_frac,
+float frames_per_pixel)
+{
+  float cur_pixel = (frame_coord / frames_per_pixel);
+  float new_pixel = (int)(frame_coord / frames_per_pixel) + pixel_frac;
+  if (cur_pixel > new_pixel) {
+new_pixel += 1.0f;
+  }
+  return new_pixel * frames_per_pixel;
+}
+
 /**
  * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same 
for y1 and y2.
- * \param stepsize: The width of a pixel.
+ * \param frames_per_pixel: The amount of pixels a whole frame takes up 
(x-axis direction).
  */
 static void draw_seq_waveform_overlay(View2D *v2d,
   const bContext *C,
@@ -241,29 +325,34 @@ static void draw_seq_waveform_overlay(View2D *v2d,
   float y1,
   float x2,
   float y2,
-  float stepsize)
+  float frames_per_pixel)
 {
-  /* Offset x1 and x2 values, to match view min/max, if strip is out of 
bounds. */
-  int x1_of

[Bf-blender-cvs] [6df81ddb84c] master: VSE: Fix seeking issues.

2021-08-16 Thread Sebastian Parborg
Commit: 6df81ddb84c60876ac3ebd87d1d134109f34eabd
Author: Sebastian Parborg
Date:   Mon Jul 12 19:13:15 2021 +0200
Branches: master
https://developer.blender.org/rB6df81ddb84c60876ac3ebd87d1d134109f34eabd

VSE: Fix seeking issues.

The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11921

===

M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index c08df2889de..fd96110b59e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1059,33 +1059,21 @@ static int ffmpeg_seek_by_byte(AVFormatContext 
*pFormatCtx)
   return false;
 }
 
-static int64_t ffmpeg_get_seek_pos(struct anim *anim, int position)
+static int64_t ffmpeg_get_seek_pts(struct anim *anim, int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t st_time = anim->pFormatCtx->start_time;
-  int64_t pos = (int64_t)(position)*AV_TIME_BASE;
-  /* Step back half a time base position to make sure that we get the requested
-   * frame and not the one after it.
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+  /* Step back half a frame position to make sure that we get the requested
+   * frame and not the one after it. This is a workaround as ffmpeg will
+   * sometimes not seek to a frame after the requested pts even if
+   * AVSEEK_FLAG_BACKWARD is specified.
*/
-  pos -= (AV_TIME_BASE / 2);
-  pos /= frame_rate;
+  int64_t pts = pts_to_search - (steps_per_frame / 2);
 
-  av_log(anim->pFormatCtx,
- AV_LOG_DEBUG,
- "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n",
- pos,
- (st_time != AV_NOPTS_VALUE) ? st_time : 0);
-
-  if (pos < 0) {
-pos = 0;
-  }
-
-  if (st_time != AV_NOPTS_VALUE) {
-pos += st_time;
-  }
-
-  return pos;
+  return pts;
 }
 
 /* This gives us an estimate of which pts our requested frame will have.
@@ -1102,17 +1090,18 @@ static int64_t ffmpeg_get_pts_to_search(struct anim 
*anim,
 pts_to_search = IMB_indexer_get_pts(tc_index, new_frame_index);
   }
   else {
-int64_t st_time = anim->pFormatCtx->start_time;
 AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL);
+int64_t start_pts = v_st->start_time;
+AVRational frame_rate = v_st->r_frame_rate;
 AVRational time_base = v_st->time_base;
 
-int64_t steps_per_frame = (frame_rate.den * time_base.den) / 
(frame_rate.num * time_base.num);
-pts_to_search = position * steps_per_frame;
+double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+ (double)(frame_rate.num * time_base.num);
+
+pts_to_search = round(position * steps_per_frame);
 
-if (st_time != AV_NOPTS_VALUE && st_time != 0) {
-  int64_t start_frame = (double)st_time / AV_TIME_BASE * 
av_q2d(frame_rate);
-  pts_to_search += start_frame * steps_per_frame;
+if (start_pts != AV_NOPTS_VALUE) {
+  pts_to_search += start_pts;
 }
   }
   return pts_to_search;
@@ -1196,23 +1185,29 @@ static void ffmpeg_decode_video_frame_scan(struct anim 
*anim, int64_t pts_to_sea
  * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 and
  * https://developer.blender.org/T86944. */
 static int ffmpeg_generic_seek_workaround(struct anim *anim,
-  int64_t *requested_pos,
+  int64_t *requested_pts,
   int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t current_pos = *requested_pos;
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+
+  int64_t current_pts = *requested_pts;
   int64_t offset = 0;
 
   int64_t cur_pts, prev_pts = -1;
 
   /* Step backward frame by frame until we find the key frame we are looking 
for. */
-  while (current_pos != 0) {
-current_pos = *requested_pos - ((in

[Bf-blender-cvs] [a01cf90fd8a] master: VSE: Fix video strip duration calculation

2021-08-16 Thread Sebastian Parborg
Commit: a01cf90fd8ad978d8b6c7fd2ece64872c940f3a1
Author: Sebastian Parborg
Date:   Mon Jul 12 16:00:43 2021 +0200
Branches: master
https://developer.blender.org/rBa01cf90fd8ad978d8b6c7fd2ece64872c940f3a1

VSE: Fix video strip duration calculation

The video duration was not read correctly from the video file.

It would use the global duration of the file which does in some cases
not line up with the actual duration of the video stream.
Now we take the video stream duration and start time into account when
calculating the strip duration.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11920

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 47514308ae4..c08df2889de 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -616,10 +616,50 @@ static int startffmpeg(struct anim *anim)
   }
 }
   }
-  /* Fall back to the container. */
+  /* Fall back to manually estimating the video stream duration.
+   * This is because the video stream duration can be shorter than the 
pFormatCtx->duration.
+   */
   if (anim->duration_in_frames == 0) {
-anim->duration_in_frames = (int)(pFormatCtx->duration * av_q2d(frame_rate) 
/ AV_TIME_BASE +
- 0.5f);
+double pts_time_base = av_q2d(video_stream->time_base);
+double stream_dur;
+
+if (video_stream->duration != AV_NOPTS_VALUE) {
+  stream_dur = video_stream->duration * pts_time_base;
+}
+else {
+  double video_start = 0;
+  double audio_start = 0;
+
+  if (video_stream->start_time != AV_NOPTS_VALUE) {
+video_start = video_stream->start_time * pts_time_base;
+  }
+
+  /* Find audio stream to guess the duration of the video.
+   * Sometimes the audio AND the video stream have a start offset.
+   * The difference between these is the offset we want to use to
+   * calculate the video duration.
+   */
+  for (i = 0; i < pFormatCtx->nb_streams; i++) {
+if (pFormatCtx->streams[i]->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) {
+  AVStream *audio_stream = pFormatCtx->streams[i];
+  if (audio_stream->start_time != AV_NOPTS_VALUE) {
+audio_start = audio_stream->start_time * 
av_q2d(audio_stream->time_base);
+  }
+  break;
+}
+  }
+
+  if (video_start > audio_start) {
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE - 
(video_start - audio_start);
+  }
+  else {
+/* The video stream starts before or at the same time as the audio 
stream!
+ * We have to assume that the video stream is as long as the full 
pFormatCtx->duration.
+ */
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE;
+  }
+}
+anim->duration_in_frames = (int)(stream_dur * av_q2d(frame_rate) + 0.5f);
   }
 
   frs_num = frame_rate.num;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [43ad345caa0] master: VSE: Fix memory leak when adding bad image/movie strips

2021-08-16 Thread Sebastian Parborg
Commit: 43ad345caa0ac156f585eab55e335dfca2465ce4
Author: Sebastian Parborg
Date:   Mon Jul 12 15:38:25 2021 +0200
Branches: master
https://developer.blender.org/rB43ad345caa0ac156f585eab55e335dfca2465ce4

VSE: Fix memory leak when adding bad image/movie strips

If the add strip operator errored out, we wouldn't free custom data allocated

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11919

===

M   source/blender/editors/space_sequencer/sequencer_add.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_add.c 
b/source/blender/editors/space_sequencer/sequencer_add.c
index 265a52ed1a6..47495eaa57a 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -707,13 +707,13 @@ static int sequencer_add_movie_strip_exec(bContext *C, 
wmOperator *op)
   }
   else {
 if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
+  sequencer_add_cancel(C, op);
   return OPERATOR_CANCELLED;
 }
   }
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   DEG_relations_tag_update(bmain);
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@@ -1040,6 +1040,7 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   load_data.image.len = sequencer_add_image_strip_calculate_length(
   op, load_data.start_frame, &minframe, &numdigits);
   if (load_data.image.len == 0) {
+sequencer_add_cancel(C, op);
 return OPERATOR_CANCELLED;
   }
 
@@ -1062,9 +1063,8 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
   WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   return OPERATOR_FINISHED;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [08af3e6e926] master: VSE: Flush audio encode after finishing video export

2021-08-16 Thread Sebastian Parborg
Commit: 08af3e6e926bf1d448bfdae8ffa2593d0850e016
Author: Sebastian Parborg
Date:   Mon Jul 5 14:16:02 2021 +0200
Branches: master
https://developer.blender.org/rB08af3e6e926bf1d448bfdae8ffa2593d0850e016

VSE: Flush audio encode after finishing video export

We didn't flush audio after encoding finished which lead to audio
packets being lost.

In addition to this the audio timestamps were wrong because we
incremented the current audio time before using it.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11916

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 32057709c38..9f3f50febe8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -149,7 +149,6 @@ static int write_audio_frame(FFMpegContext *context)
 
   AUD_Device_read(
   context->audio_mixdown_device, context->audio_input_buffer, 
context->audio_input_samples);
-  context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
 
   frame = av_frame_alloc();
   frame->pts = context->audio_time / av_q2d(c->time_base);
@@ -184,7 +183,7 @@ static int write_audio_frame(FFMpegContext *context)
context->audio_input_samples * c->channels * 
context->audio_sample_size,
1);
 
-  int success = 0;
+  int success = 1;
 
   int ret = avcodec_send_frame(c, frame);
   if (ret < 0) {
@@ -369,7 +368,7 @@ static int write_video_frame(FFMpegContext *context, int 
cfra, AVFrame *frame, R
   return success;
 }
 
-/* read and encode a frame of audio from the buffer */
+/* read and encode a frame of video from the buffer */
 static AVFrame *generate_video_frame(FFMpegContext *context, const uint8_t 
*pixels)
 {
   AVCodecParameters *codec = context->video_stream->codecpar;
@@ -1226,9 +1225,8 @@ fail:
  * parameter.
  * 
  */
-static void flush_ffmpeg(FFMpegContext *context)
+static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext 
*outfile)
 {
-  AVCodecContext *c = context->video_codec;
   AVPacket *packet = av_packet_alloc();
 
   avcodec_send_frame(c, NULL);
@@ -1247,13 +1245,13 @@ static void flush_ffmpeg(FFMpegContext *context)
   break;
 }
 
-packet->stream_index = context->video_stream->index;
-av_packet_rescale_ts(packet, c->time_base, 
context->video_stream->time_base);
+packet->stream_index = stream->index;
+av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, context->video_stream, packet);
+my_guess_pkt_duration(context->outfile, stream, packet);
 #  endif
 
-int write_ret = av_interleaved_write_frame(context->outfile, packet);
+int write_ret = av_interleaved_write_frame(outfile, packet);
 if (write_ret != 0) {
   fprintf(stderr, "Error writing delayed frame: %s\n", 
av_err2str(write_ret));
   break;
@@ -1396,12 +1394,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit);
 #  ifdef WITH_AUDASPACE
 static void write_audio_frames(FFMpegContext *context, double to_pts)
 {
-  int finished = 0;
+  AVCodecContext *c = context->audio_codec;
 
-  while (context->audio_stream && !finished) {
-if ((context->audio_time >= to_pts) || (write_audio_frame(context))) {
-  finished = 1;
+  while (context->audio_stream) {
+if ((context->audio_time >= to_pts) || !write_audio_frame(context)) {
+  break;
 }
+context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
   }
 }
 #  endif
@@ -1422,9 +1421,6 @@ int BKE_ffmpeg_append(void *context_v,
 
   PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, 
recty);
 
-  /* why is this done before writing the video frame and again at end_ffmpeg? 
*/
-  //  write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
-
   if (context->video_stream) {
 avframe = generate_video_frame(context, (unsigned char *)pixels);
 success = (avframe && write_video_frame(context, frame - start_frame, 
avframe, reports));
@@ -1461,8 +1457,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit)
 #  endif
 
   if (context->video_stream) {
-PRINT("Flushing delayed frames...\n");
-flush_ffmpeg(context);
+PRINT("Flushing delayed video frames...\n");
+flush_ffmpeg(context->video_codec, context->video_stream, 
context->outfile);
+  }
+
+  if (context->audio_stream) {
+PRINT("Flushing delayed audio f

[Bf-blender-cvs] [e314260fa77] master: VSE: Fix "off by one" error when encoding audio

2021-08-16 Thread Sebastian Parborg
Commit: e314260fa778b5d0874cadab1f70f91bddd18434
Author: Sebastian Parborg
Date:   Fri Jul 9 15:06:06 2021 +0200
Branches: master
https://developer.blender.org/rBe314260fa778b5d0874cadab1f70f91bddd18434

VSE: Fix "off by one" error when encoding audio

Before we didn't encode the audio up until the current frame.
This lead to us not encoding the last video frame of audio.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11918

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 9f3f50febe8..323da7473b5 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1435,8 +1435,9 @@ int BKE_ffmpeg_append(void *context_v,
   }
 
 #  ifdef WITH_AUDASPACE
-  write_audio_frames(context,
- (frame - start_frame) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
+  /* Add +1 frame because we want to encode audio up until the next video 
frame. */
+  write_audio_frames(
+  context, (frame - start_frame + 1) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
 #  endif
   return success;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [40f8615598b] temp-VSE-fixes: VSE: Fix audaspace not reading ffmpeg files with start offset correctly

2021-08-13 Thread Sebastian Parborg
Commit: 40f8615598bcc9ab70d8edbd9eb07651af31e9e5
Author: Sebastian Parborg
Date:   Tue Jul 6 19:48:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB40f8615598bcc9ab70d8edbd9eb07651af31e9e5

VSE: Fix audaspace not reading ffmpeg files with start offset correctly

The duration and start time for audio strips were not correctly read in
audaspace.

Some video files have a "lead in" section of audio that plays before the
video starts playing back. Before this patch, we would play this lead in
audio at the same time as the video started and thus the audio would not
be in sync anymore.

Now the lead in audio is cut off and the duration should be correctly
calculated with this in mind.

If the audio starts after the video, the audio strip is shifted to
account for this, but it will also lead to cut off audio which might not
be wanted. However we don't have a simple way to solve this at this
point.

Differential Revision: http://developer.blender.org/D11917

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Types.h
M   extern/audaspace/include/IReader.h
M   extern/audaspace/include/fx/EffectReader.h
M   extern/audaspace/include/fx/ModulatorReader.h
M   extern/audaspace/include/fx/MutableReader.h
M   extern/audaspace/include/fx/VolumeReader.h
M   extern/audaspace/include/generator/SawtoothReader.h
M   extern/audaspace/include/generator/SilenceReader.h
M   extern/audaspace/include/generator/SineReader.h
M   extern/audaspace/include/generator/SquareReader.h
M   extern/audaspace/include/generator/TriangleReader.h
M   extern/audaspace/include/sequence/DoubleReader.h
M   extern/audaspace/include/sequence/SequenceReader.h
M   extern/audaspace/include/sequence/SuperposeReader.h
M   extern/audaspace/include/util/BufferReader.h
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
M   extern/audaspace/plugins/libsndfile/SndFileReader.cpp
M   extern/audaspace/plugins/libsndfile/SndFileReader.h
M   extern/audaspace/src/fx/EffectReader.cpp
M   extern/audaspace/src/fx/ModulatorReader.cpp
M   extern/audaspace/src/fx/MutableReader.cpp
M   extern/audaspace/src/fx/VolumeReader.cpp
M   extern/audaspace/src/generator/SawtoothReader.cpp
M   extern/audaspace/src/generator/SilenceReader.cpp
M   extern/audaspace/src/generator/SineReader.cpp
M   extern/audaspace/src/generator/SquareReader.cpp
M   extern/audaspace/src/generator/TriangleReader.cpp
M   extern/audaspace/src/sequence/DoubleReader.cpp
M   extern/audaspace/src/sequence/SequenceReader.cpp
M   extern/audaspace/src/sequence/SuperposeReader.cpp
M   extern/audaspace/src/util/BufferReader.cpp
M   source/blender/blenkernel/BKE_sound.h
M   source/blender/blenkernel/intern/sound.c
M   source/blender/editors/space_sequencer/sequencer_add.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_sequencer_api.c
M   source/blender/sequencer/SEQ_add.h
M   source/blender/sequencer/intern/sound.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/sequencer/intern/strip_time.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index ac876a01eb3..97e5f5540de 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
+   info.start_offset = 0.0f;
 
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) 
info.specs.rate;
+   info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
diff --git a/extern/audaspace/bindings/C/AUD_Types.h 
b/extern/audaspace/bindings/C/AUD_Types.h
index 75e4ffae18c..c6a96d30d3f 100644
--- a/extern/audaspace/bindings/C/AUD_Types.h
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -176,4 +176,5 @@ typedef struct
 {
AUD_Specs specs;
float length;
+   double start_offset;
 } AUD_SoundInfo;
diff --git a/extern/audaspace/include/IReader.h 
b/extern/audaspace/include/IReader.h
index c29900ca579..7de9a5c6d81 100644
--- a/extern/audaspace/in

[Bf-blender-cvs] [81ba6f2f493] temp-VSE-fixes: VSE: Fix seeking issues.

2021-08-13 Thread Sebastian Parborg
Commit: 81ba6f2f493e98ec87cb7cf65656c43f8aa4bf34
Author: Sebastian Parborg
Date:   Mon Jul 12 19:13:15 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB81ba6f2f493e98ec87cb7cf65656c43f8aa4bf34

VSE: Fix seeking issues.

The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11921

===

M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index c08df2889de..fd96110b59e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1059,33 +1059,21 @@ static int ffmpeg_seek_by_byte(AVFormatContext 
*pFormatCtx)
   return false;
 }
 
-static int64_t ffmpeg_get_seek_pos(struct anim *anim, int position)
+static int64_t ffmpeg_get_seek_pts(struct anim *anim, int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t st_time = anim->pFormatCtx->start_time;
-  int64_t pos = (int64_t)(position)*AV_TIME_BASE;
-  /* Step back half a time base position to make sure that we get the requested
-   * frame and not the one after it.
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+  /* Step back half a frame position to make sure that we get the requested
+   * frame and not the one after it. This is a workaround as ffmpeg will
+   * sometimes not seek to a frame after the requested pts even if
+   * AVSEEK_FLAG_BACKWARD is specified.
*/
-  pos -= (AV_TIME_BASE / 2);
-  pos /= frame_rate;
+  int64_t pts = pts_to_search - (steps_per_frame / 2);
 
-  av_log(anim->pFormatCtx,
- AV_LOG_DEBUG,
- "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n",
- pos,
- (st_time != AV_NOPTS_VALUE) ? st_time : 0);
-
-  if (pos < 0) {
-pos = 0;
-  }
-
-  if (st_time != AV_NOPTS_VALUE) {
-pos += st_time;
-  }
-
-  return pos;
+  return pts;
 }
 
 /* This gives us an estimate of which pts our requested frame will have.
@@ -1102,17 +1090,18 @@ static int64_t ffmpeg_get_pts_to_search(struct anim 
*anim,
 pts_to_search = IMB_indexer_get_pts(tc_index, new_frame_index);
   }
   else {
-int64_t st_time = anim->pFormatCtx->start_time;
 AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL);
+int64_t start_pts = v_st->start_time;
+AVRational frame_rate = v_st->r_frame_rate;
 AVRational time_base = v_st->time_base;
 
-int64_t steps_per_frame = (frame_rate.den * time_base.den) / 
(frame_rate.num * time_base.num);
-pts_to_search = position * steps_per_frame;
+double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+ (double)(frame_rate.num * time_base.num);
+
+pts_to_search = round(position * steps_per_frame);
 
-if (st_time != AV_NOPTS_VALUE && st_time != 0) {
-  int64_t start_frame = (double)st_time / AV_TIME_BASE * 
av_q2d(frame_rate);
-  pts_to_search += start_frame * steps_per_frame;
+if (start_pts != AV_NOPTS_VALUE) {
+  pts_to_search += start_pts;
 }
   }
   return pts_to_search;
@@ -1196,23 +1185,29 @@ static void ffmpeg_decode_video_frame_scan(struct anim 
*anim, int64_t pts_to_sea
  * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 and
  * https://developer.blender.org/T86944. */
 static int ffmpeg_generic_seek_workaround(struct anim *anim,
-  int64_t *requested_pos,
+  int64_t *requested_pts,
   int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t current_pos = *requested_pos;
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+
+  int64_t current_pts = *requested_pts;
   int64_t offset = 0;
 
   int64_t cur_pts, prev_pts = -1;
 
   /* Step backward frame by frame until we find the key frame we are looking 
for. */
-  while (current_pos != 0) {
-current_pos = *requested_pos - ((in

[Bf-blender-cvs] [525e8f02f79] temp-VSE-fixes: VSE: Use lines to draw waveform

2021-08-13 Thread Sebastian Parborg
Commit: 525e8f02f7957795eaf16ffc842445396d87b1ea
Author: Sebastian Parborg
Date:   Thu Jul 1 18:51:26 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB525e8f02f7957795eaf16ffc842445396d87b1ea

VSE: Use lines to draw waveform

Refactor and improve waveform drawing.

Drawing now can use line strips to draw waveforms instead of only
triangle strips. This makes us able to properly visualize thin waveforms
as they would not be visible before. We now also draw the RMS value of
the waveform.

The waveform drawing is now also properly aligned to the screen pixels
to avoid flickering when transforming the strip.

Reviewed By: Richard Antalik

Differential Revision: https://developer.blender.org/D11184

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   source/blender/editors/space_sequencer/sequencer_draw.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index 97e5f5540de..5cc33525d1d 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -247,7 +247,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, 
int length, int sampl
 
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
-   buffer[i * 3 + 2] = sqrt(power) / len;
+   buffer[i * 3 + 2] = sqrt(power / len); // RMS
 
if(overallmax < max)
overallmax = max;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index e49a88c88d2..888e232ce45 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -228,9 +228,93 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, 
uchar col[3])
   }
 }
 
+typedef struct WaveVizData {
+  float pos[2];
+  float rms_pos;
+  bool clip;
+  bool end;
+} WaveVizData;
+
+static int get_section_len(WaveVizData *start, WaveVizData *end)
+{
+  int len = 0;
+  while (start != end) {
+len++;
+if (start->end) {
+  return len;
+}
+start++;
+  }
+  return len;
+}
+
+static void draw_waveform(WaveVizData *iter, WaveVizData *end, GPUPrimType 
prim_type, bool use_rms)
+{
+  int strip_len = get_section_len(iter, end);
+  if (strip_len > 1) {
+GPU_blend(GPU_BLEND_ALPHA);
+GPUVertFormat *format = immVertexFormat();
+uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, 
GPU_FETCH_FLOAT);
+uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, 
GPU_FETCH_FLOAT);
+
+immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+immBegin(prim_type, strip_len);
+
+while (iter != end) {
+  if (iter->clip) {
+immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+  }
+  else if (use_rms) {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.8f);
+  }
+  else {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+  }
+
+  if (use_rms) {
+immVertex2f(pos, iter->pos[0], iter->rms_pos);
+  }
+  else {
+immVertex2f(pos, iter->pos[0], iter->pos[1]);
+  }
+
+  if (iter->end) {
+/* End of line. */
+iter++;
+strip_len = get_section_len(iter, end);
+if (strip_len != 0) {
+  immEnd();
+  immUnbindProgram();
+  immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+  immBegin(prim_type, strip_len);
+}
+  }
+  else {
+iter++;
+  }
+}
+immEnd();
+immUnbindProgram();
+
+GPU_blend(GPU_BLEND_NONE);
+  }
+}
+
+static float clamp_frame_coord_to_pixel(float frame_coord,
+float pixel_frac,
+float frames_per_pixel)
+{
+  float cur_pixel = (frame_coord / frames_per_pixel);
+  float new_pixel = (int)(frame_coord / frames_per_pixel) + pixel_frac;
+  if (cur_pixel > new_pixel) {
+new_pixel += 1.0f;
+  }
+  return new_pixel * frames_per_pixel;
+}
+
 /**
  * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same 
for y1 and y2.
- * \param stepsize: The width of a pixel.
+ * \param frames_per_pixel: The amount of pixels a whole frame takes up 
(x-axis direction).
  */
 static void draw_seq_waveform_overlay(View2D *v2d,
   const bContext *C,
@@ -241,29 +325,34 @@ static void draw_seq_waveform_overlay(View2D *v2d,
   float y1,
   float x2,
   float y2,
-  float stepsize)
+  float frames_per_pixel)
 {
-  /* Offset x1 and x2 values, to match view min/max, if strip is out of 
bounds. */
- 

[Bf-blender-cvs] [ec173298a05] temp-VSE-fixes: VSE: Fix video strip duration calculation

2021-08-13 Thread Sebastian Parborg
Commit: ec173298a05496d64c9d74c442a8fbb846c6b9bd
Author: Sebastian Parborg
Date:   Mon Jul 12 16:00:43 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBec173298a05496d64c9d74c442a8fbb846c6b9bd

VSE: Fix video strip duration calculation

The video duration was not read correctly from the video file.

It would use the global duration of the file which does in some cases
not line up with the actual duration of the video stream.
Now we take the video stream duration and start time into account when
calculating the strip duration.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11920

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 47514308ae4..c08df2889de 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -616,10 +616,50 @@ static int startffmpeg(struct anim *anim)
   }
 }
   }
-  /* Fall back to the container. */
+  /* Fall back to manually estimating the video stream duration.
+   * This is because the video stream duration can be shorter than the 
pFormatCtx->duration.
+   */
   if (anim->duration_in_frames == 0) {
-anim->duration_in_frames = (int)(pFormatCtx->duration * av_q2d(frame_rate) 
/ AV_TIME_BASE +
- 0.5f);
+double pts_time_base = av_q2d(video_stream->time_base);
+double stream_dur;
+
+if (video_stream->duration != AV_NOPTS_VALUE) {
+  stream_dur = video_stream->duration * pts_time_base;
+}
+else {
+  double video_start = 0;
+  double audio_start = 0;
+
+  if (video_stream->start_time != AV_NOPTS_VALUE) {
+video_start = video_stream->start_time * pts_time_base;
+  }
+
+  /* Find audio stream to guess the duration of the video.
+   * Sometimes the audio AND the video stream have a start offset.
+   * The difference between these is the offset we want to use to
+   * calculate the video duration.
+   */
+  for (i = 0; i < pFormatCtx->nb_streams; i++) {
+if (pFormatCtx->streams[i]->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) {
+  AVStream *audio_stream = pFormatCtx->streams[i];
+  if (audio_stream->start_time != AV_NOPTS_VALUE) {
+audio_start = audio_stream->start_time * 
av_q2d(audio_stream->time_base);
+  }
+  break;
+}
+  }
+
+  if (video_start > audio_start) {
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE - 
(video_start - audio_start);
+  }
+  else {
+/* The video stream starts before or at the same time as the audio 
stream!
+ * We have to assume that the video stream is as long as the full 
pFormatCtx->duration.
+ */
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE;
+  }
+}
+anim->duration_in_frames = (int)(stream_dur * av_q2d(frame_rate) + 0.5f);
   }
 
   frs_num = frame_rate.num;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8631391baf4] temp-VSE-fixes: VSE: Fix "off by one" error when encoding audio

2021-08-13 Thread Sebastian Parborg
Commit: 8631391baf49de54c5f3567f8078ec84e737a280
Author: Sebastian Parborg
Date:   Fri Jul 9 15:06:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB8631391baf49de54c5f3567f8078ec84e737a280

VSE: Fix "off by one" error when encoding audio

Before we didn't encode the audio up until the current frame.
This lead to us not encoding the last video frame of audio.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11918

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 9f3f50febe8..323da7473b5 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1435,8 +1435,9 @@ int BKE_ffmpeg_append(void *context_v,
   }
 
 #  ifdef WITH_AUDASPACE
-  write_audio_frames(context,
- (frame - start_frame) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
+  /* Add +1 frame because we want to encode audio up until the next video 
frame. */
+  write_audio_frames(
+  context, (frame - start_frame + 1) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
 #  endif
   return success;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cb4e2421071] temp-VSE-fixes: VSE: Fix memory leak when adding bad image/movie strips

2021-08-13 Thread Sebastian Parborg
Commit: cb4e2421071a6b721e5e0a06dec15bfcf9cddfcc
Author: Sebastian Parborg
Date:   Mon Jul 12 15:38:25 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBcb4e2421071a6b721e5e0a06dec15bfcf9cddfcc

VSE: Fix memory leak when adding bad image/movie strips

If the add strip operator errored out, we wouldn't free custom data allocated

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11919

===

M   source/blender/editors/space_sequencer/sequencer_add.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_add.c 
b/source/blender/editors/space_sequencer/sequencer_add.c
index 265a52ed1a6..47495eaa57a 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -707,13 +707,13 @@ static int sequencer_add_movie_strip_exec(bContext *C, 
wmOperator *op)
   }
   else {
 if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
+  sequencer_add_cancel(C, op);
   return OPERATOR_CANCELLED;
 }
   }
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   DEG_relations_tag_update(bmain);
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@@ -1040,6 +1040,7 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   load_data.image.len = sequencer_add_image_strip_calculate_length(
   op, load_data.start_frame, &minframe, &numdigits);
   if (load_data.image.len == 0) {
+sequencer_add_cancel(C, op);
 return OPERATOR_CANCELLED;
   }
 
@@ -1062,9 +1063,8 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
   WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   return OPERATOR_FINISHED;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [57675c1f3cd] temp-VSE-fixes: VSE: Flush audio encode after finishing video export

2021-08-13 Thread Sebastian Parborg
Commit: 57675c1f3cdc6c3e2a8873cb4037e74932dcc936
Author: Sebastian Parborg
Date:   Mon Jul 5 14:16:02 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB57675c1f3cdc6c3e2a8873cb4037e74932dcc936

VSE: Flush audio encode after finishing video export

We didn't flush audio after encoding finished which lead to audio
packets being lost.

In addition to this the audio timestamps were wrong because we
incremented the current audio time before using it.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11916

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 32057709c38..9f3f50febe8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -149,7 +149,6 @@ static int write_audio_frame(FFMpegContext *context)
 
   AUD_Device_read(
   context->audio_mixdown_device, context->audio_input_buffer, 
context->audio_input_samples);
-  context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
 
   frame = av_frame_alloc();
   frame->pts = context->audio_time / av_q2d(c->time_base);
@@ -184,7 +183,7 @@ static int write_audio_frame(FFMpegContext *context)
context->audio_input_samples * c->channels * 
context->audio_sample_size,
1);
 
-  int success = 0;
+  int success = 1;
 
   int ret = avcodec_send_frame(c, frame);
   if (ret < 0) {
@@ -369,7 +368,7 @@ static int write_video_frame(FFMpegContext *context, int 
cfra, AVFrame *frame, R
   return success;
 }
 
-/* read and encode a frame of audio from the buffer */
+/* read and encode a frame of video from the buffer */
 static AVFrame *generate_video_frame(FFMpegContext *context, const uint8_t 
*pixels)
 {
   AVCodecParameters *codec = context->video_stream->codecpar;
@@ -1226,9 +1225,8 @@ fail:
  * parameter.
  * 
  */
-static void flush_ffmpeg(FFMpegContext *context)
+static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext 
*outfile)
 {
-  AVCodecContext *c = context->video_codec;
   AVPacket *packet = av_packet_alloc();
 
   avcodec_send_frame(c, NULL);
@@ -1247,13 +1245,13 @@ static void flush_ffmpeg(FFMpegContext *context)
   break;
 }
 
-packet->stream_index = context->video_stream->index;
-av_packet_rescale_ts(packet, c->time_base, 
context->video_stream->time_base);
+packet->stream_index = stream->index;
+av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, context->video_stream, packet);
+my_guess_pkt_duration(context->outfile, stream, packet);
 #  endif
 
-int write_ret = av_interleaved_write_frame(context->outfile, packet);
+int write_ret = av_interleaved_write_frame(outfile, packet);
 if (write_ret != 0) {
   fprintf(stderr, "Error writing delayed frame: %s\n", 
av_err2str(write_ret));
   break;
@@ -1396,12 +1394,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit);
 #  ifdef WITH_AUDASPACE
 static void write_audio_frames(FFMpegContext *context, double to_pts)
 {
-  int finished = 0;
+  AVCodecContext *c = context->audio_codec;
 
-  while (context->audio_stream && !finished) {
-if ((context->audio_time >= to_pts) || (write_audio_frame(context))) {
-  finished = 1;
+  while (context->audio_stream) {
+if ((context->audio_time >= to_pts) || !write_audio_frame(context)) {
+  break;
 }
+context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
   }
 }
 #  endif
@@ -1422,9 +1421,6 @@ int BKE_ffmpeg_append(void *context_v,
 
   PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, 
recty);
 
-  /* why is this done before writing the video frame and again at end_ffmpeg? 
*/
-  //  write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
-
   if (context->video_stream) {
 avframe = generate_video_frame(context, (unsigned char *)pixels);
 success = (avframe && write_video_frame(context, frame - start_frame, 
avframe, reports));
@@ -1461,8 +1457,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit)
 #  endif
 
   if (context->video_stream) {
-PRINT("Flushing delayed frames...\n");
-flush_ffmpeg(context);
+PRINT("Flushing delayed video frames...\n");
+flush_ffmpeg(context->video_codec, context->video_stream, 
context->outfile);
+  }
+
+  if (context->audio_stream) {
+PRINT("Flushing delayed

[Bf-blender-cvs] [8a63d9a0a14] temp-VSE-fixes: Fix audaspace not reading ffmpeg files with start offset correctly

2021-08-13 Thread Sebastian Parborg
Commit: 8a63d9a0a144fc8d67d098f497a1dd72fafb02d7
Author: Sebastian Parborg
Date:   Tue Jul 6 19:48:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB8a63d9a0a144fc8d67d098f497a1dd72fafb02d7

Fix audaspace not reading ffmpeg files with start offset correctly

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Types.h
M   extern/audaspace/include/IReader.h
M   extern/audaspace/include/fx/EffectReader.h
M   extern/audaspace/include/fx/ModulatorReader.h
M   extern/audaspace/include/fx/MutableReader.h
M   extern/audaspace/include/fx/VolumeReader.h
M   extern/audaspace/include/generator/SawtoothReader.h
M   extern/audaspace/include/generator/SilenceReader.h
M   extern/audaspace/include/generator/SineReader.h
M   extern/audaspace/include/generator/SquareReader.h
M   extern/audaspace/include/generator/TriangleReader.h
M   extern/audaspace/include/sequence/DoubleReader.h
M   extern/audaspace/include/sequence/SequenceReader.h
M   extern/audaspace/include/sequence/SuperposeReader.h
M   extern/audaspace/include/util/BufferReader.h
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
M   extern/audaspace/plugins/libsndfile/SndFileReader.cpp
M   extern/audaspace/plugins/libsndfile/SndFileReader.h
M   extern/audaspace/src/fx/EffectReader.cpp
M   extern/audaspace/src/fx/ModulatorReader.cpp
M   extern/audaspace/src/fx/MutableReader.cpp
M   extern/audaspace/src/fx/VolumeReader.cpp
M   extern/audaspace/src/generator/SawtoothReader.cpp
M   extern/audaspace/src/generator/SilenceReader.cpp
M   extern/audaspace/src/generator/SineReader.cpp
M   extern/audaspace/src/generator/SquareReader.cpp
M   extern/audaspace/src/generator/TriangleReader.cpp
M   extern/audaspace/src/sequence/DoubleReader.cpp
M   extern/audaspace/src/sequence/SequenceReader.cpp
M   extern/audaspace/src/sequence/SuperposeReader.cpp
M   extern/audaspace/src/util/BufferReader.cpp
M   source/blender/blenkernel/BKE_sound.h
M   source/blender/blenkernel/intern/sound.c
M   source/blender/editors/space_sequencer/sequencer_add.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_sequencer_api.c
M   source/blender/sequencer/SEQ_add.h
M   source/blender/sequencer/intern/sound.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/sequencer/intern/strip_time.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index ac876a01eb3..97e5f5540de 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
+   info.start_offset = 0.0f;
 
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) 
info.specs.rate;
+   info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
diff --git a/extern/audaspace/bindings/C/AUD_Types.h 
b/extern/audaspace/bindings/C/AUD_Types.h
index 75e4ffae18c..c6a96d30d3f 100644
--- a/extern/audaspace/bindings/C/AUD_Types.h
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -176,4 +176,5 @@ typedef struct
 {
AUD_Specs specs;
float length;
+   double start_offset;
 } AUD_SoundInfo;
diff --git a/extern/audaspace/include/IReader.h 
b/extern/audaspace/include/IReader.h
index c29900ca579..7de9a5c6d81 100644
--- a/extern/audaspace/include/IReader.h
+++ b/extern/audaspace/include/IReader.h
@@ -70,6 +70,12 @@ public:
 */
virtual int getPosition() const=0;
 
+   /**
+* Returns the start offset the sound should have to line up with 
related sources.
+* \return The required start offset in seconds.
+*/
+   virtual double getStartOffset() const=0;
+
/**
 * Returns the specification of the reader.
 * \return The Specs structure.
diff --git a/extern/audaspace/include/fx/EffectReader.h 
b/extern/audaspace/include/fx/EffectReader.h
index 85eff6a8ab9..f21001c1f86 100644
--- a/extern/audaspace/include/fx/EffectReader.h
+++ b/extern/audaspace/include/fx/EffectReader.h
@@ -61,6 +6

[Bf-blender-cvs] [fa6294b68f4] temp-VSE-fixes: Draw seq waveforms better

2021-08-13 Thread Sebastian Parborg
Commit: fa6294b68f44faf7b4d9eab4a5845e1681cf5aa1
Author: Sebastian Parborg
Date:   Thu Jul 1 18:51:26 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBfa6294b68f44faf7b4d9eab4a5845e1681cf5aa1

Draw seq waveforms better

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   source/blender/editors/space_sequencer/sequencer_draw.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index 97e5f5540de..5cc33525d1d 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -247,7 +247,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, 
int length, int sampl
 
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
-   buffer[i * 3 + 2] = sqrt(power) / len;
+   buffer[i * 3 + 2] = sqrt(power / len); // RMS
 
if(overallmax < max)
overallmax = max;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index e49a88c88d2..9cf4fd94c68 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -228,9 +228,81 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, 
uchar col[3])
   }
 }
 
+typedef struct WaveVizData {
+  float pos[2];
+  float rms_pos;
+  bool clip;
+  bool end;
+} WaveVizData;
+
+static int get_section_len(WaveVizData *start, WaveVizData *end)
+{
+  int len = 0;
+  while (start != end) {
+len++;
+if (start->end) {
+  return len;
+}
+start++;
+  }
+  return len;
+}
+
+static void draw_waveform(WaveVizData *iter, WaveVizData *end, GPUPrimType 
prim_type, bool use_rms)
+{
+  int strip_len = get_section_len(iter, end);
+  if (strip_len != 0) {
+GPU_blend(GPU_BLEND_ALPHA);
+GPUVertFormat *format = immVertexFormat();
+uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, 
GPU_FETCH_FLOAT);
+uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, 
GPU_FETCH_FLOAT);
+
+immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+immBegin(prim_type, strip_len);
+
+while (iter != end) {
+  if (iter->clip) {
+immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+  }
+  else if (use_rms) {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.8f);
+  }
+  else {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+  }
+
+  if (use_rms) {
+immVertex2f(pos, iter->pos[0], iter->rms_pos);
+  }
+  else {
+immVertex2f(pos, iter->pos[0], iter->pos[1]);
+  }
+
+  if (iter->end) {
+/* End of line. */
+iter++;
+strip_len = get_section_len(iter, end);
+if (strip_len != 0) {
+  immEnd();
+  immUnbindProgram();
+  immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+  immBegin(prim_type, strip_len);
+}
+  }
+  else {
+iter++;
+  }
+}
+immEnd();
+immUnbindProgram();
+
+GPU_blend(GPU_BLEND_NONE);
+  }
+}
+
 /**
  * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same 
for y1 and y2.
- * \param stepsize: The width of a pixel.
+ * \param pixels_per_frame: The amount of pixels a whole frame takes up 
(x-axis direction).
  */
 static void draw_seq_waveform_overlay(View2D *v2d,
   const bContext *C,
@@ -241,29 +313,25 @@ static void draw_seq_waveform_overlay(View2D *v2d,
   float y1,
   float x2,
   float y2,
-  float stepsize)
+  float pixels_per_frame)
 {
   /* Offset x1 and x2 values, to match view min/max, if strip is out of 
bounds. */
-  int x1_offset = max_ff(v2d->cur.xmin, x1);
-  int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
+  float x1_offset = max_ff(v2d->cur.xmin, x1);
+  float x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
 
   if (seq->sound && ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & 
SEQ_AUDIO_DRAW_WAVEFORM))) {
-int length = floor((x2_offset - x1_offset) / stepsize) + 1;
-float ymid = (y1 + y2) / 2.0f;
-float yscale = (y2 - y1) / 2.0f;
-float samplestep;
-float startsample, endsample;
-float volume = seq->volume;
-float value1, value2;
-bSound *sound = seq->sound;
-SoundWaveform *waveform;
+/* Calculate how long the strip that is in view is in pixels. */
+int pix_strip_len = floor((x2_offset - x1_offset) * pixels_per_frame);
 
-if (length < 2) {
+if (pix_strip_len < 2) {
   return;
 }
 
+   

[Bf-blender-cvs] [a69ca9b8f48] temp-VSE-fixes: Fix memory leak when adding bad VSE image/movie strips

2021-08-13 Thread Sebastian Parborg
Commit: a69ca9b8f48bc64331bd678c4475e633e9c2d6a8
Author: Sebastian Parborg
Date:   Mon Jul 12 15:38:25 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBa69ca9b8f48bc64331bd678c4475e633e9c2d6a8

Fix memory leak when adding bad VSE image/movie strips

===

M   source/blender/editors/space_sequencer/sequencer_add.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_add.c 
b/source/blender/editors/space_sequencer/sequencer_add.c
index 265a52ed1a6..47495eaa57a 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -707,13 +707,13 @@ static int sequencer_add_movie_strip_exec(bContext *C, 
wmOperator *op)
   }
   else {
 if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
+  sequencer_add_cancel(C, op);
   return OPERATOR_CANCELLED;
 }
   }
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   DEG_relations_tag_update(bmain);
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@@ -1040,6 +1040,7 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   load_data.image.len = sequencer_add_image_strip_calculate_length(
   op, load_data.start_frame, &minframe, &numdigits);
   if (load_data.image.len == 0) {
+sequencer_add_cancel(C, op);
 return OPERATOR_CANCELLED;
   }
 
@@ -1062,9 +1063,8 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
   WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   return OPERATOR_FINISHED;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [79fa4f6623b] temp-VSE-fixes: Fix VSE seeking issues.

2021-08-13 Thread Sebastian Parborg
Commit: 79fa4f6623b0912f71561256a2cf64c9c4e10d4d
Author: Sebastian Parborg
Date:   Mon Jul 12 19:13:15 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB79fa4f6623b0912f71561256a2cf64c9c4e10d4d

Fix VSE seeking issues.

The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

===

M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index c08df2889de..fd96110b59e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1059,33 +1059,21 @@ static int ffmpeg_seek_by_byte(AVFormatContext 
*pFormatCtx)
   return false;
 }
 
-static int64_t ffmpeg_get_seek_pos(struct anim *anim, int position)
+static int64_t ffmpeg_get_seek_pts(struct anim *anim, int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t st_time = anim->pFormatCtx->start_time;
-  int64_t pos = (int64_t)(position)*AV_TIME_BASE;
-  /* Step back half a time base position to make sure that we get the requested
-   * frame and not the one after it.
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+  /* Step back half a frame position to make sure that we get the requested
+   * frame and not the one after it. This is a workaround as ffmpeg will
+   * sometimes not seek to a frame after the requested pts even if
+   * AVSEEK_FLAG_BACKWARD is specified.
*/
-  pos -= (AV_TIME_BASE / 2);
-  pos /= frame_rate;
+  int64_t pts = pts_to_search - (steps_per_frame / 2);
 
-  av_log(anim->pFormatCtx,
- AV_LOG_DEBUG,
- "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n",
- pos,
- (st_time != AV_NOPTS_VALUE) ? st_time : 0);
-
-  if (pos < 0) {
-pos = 0;
-  }
-
-  if (st_time != AV_NOPTS_VALUE) {
-pos += st_time;
-  }
-
-  return pos;
+  return pts;
 }
 
 /* This gives us an estimate of which pts our requested frame will have.
@@ -1102,17 +1090,18 @@ static int64_t ffmpeg_get_pts_to_search(struct anim 
*anim,
 pts_to_search = IMB_indexer_get_pts(tc_index, new_frame_index);
   }
   else {
-int64_t st_time = anim->pFormatCtx->start_time;
 AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL);
+int64_t start_pts = v_st->start_time;
+AVRational frame_rate = v_st->r_frame_rate;
 AVRational time_base = v_st->time_base;
 
-int64_t steps_per_frame = (frame_rate.den * time_base.den) / 
(frame_rate.num * time_base.num);
-pts_to_search = position * steps_per_frame;
+double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+ (double)(frame_rate.num * time_base.num);
+
+pts_to_search = round(position * steps_per_frame);
 
-if (st_time != AV_NOPTS_VALUE && st_time != 0) {
-  int64_t start_frame = (double)st_time / AV_TIME_BASE * 
av_q2d(frame_rate);
-  pts_to_search += start_frame * steps_per_frame;
+if (start_pts != AV_NOPTS_VALUE) {
+  pts_to_search += start_pts;
 }
   }
   return pts_to_search;
@@ -1196,23 +1185,29 @@ static void ffmpeg_decode_video_frame_scan(struct anim 
*anim, int64_t pts_to_sea
  * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 and
  * https://developer.blender.org/T86944. */
 static int ffmpeg_generic_seek_workaround(struct anim *anim,
-  int64_t *requested_pos,
+  int64_t *requested_pts,
   int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t current_pos = *requested_pos;
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+
+  int64_t current_pts = *requested_pts;
   int64_t offset = 0;
 
   int64_t cur_pts, prev_pts = -1;
 
   /* Step backward frame by frame until we find the key frame we are looking 
for. */
-  while (current_pos != 0) {
-current_pos = *requested_pos - ((int64_t)(offset)*AV_TIME_BASE / 
frame_rate);
-current_pos = max_ii(current_p

[Bf-blender-cvs] [c83d38307b3] temp-VSE-fixes: Fix VSE video strip duration calculation

2021-08-13 Thread Sebastian Parborg
Commit: c83d38307b3f11da060a2d082b10c15298d26532
Author: Sebastian Parborg
Date:   Mon Jul 12 16:00:43 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBc83d38307b3f11da060a2d082b10c15298d26532

Fix VSE video strip duration calculation

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 47514308ae4..c08df2889de 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -616,10 +616,50 @@ static int startffmpeg(struct anim *anim)
   }
 }
   }
-  /* Fall back to the container. */
+  /* Fall back to manually estimating the video stream duration.
+   * This is because the video stream duration can be shorter than the 
pFormatCtx->duration.
+   */
   if (anim->duration_in_frames == 0) {
-anim->duration_in_frames = (int)(pFormatCtx->duration * av_q2d(frame_rate) 
/ AV_TIME_BASE +
- 0.5f);
+double pts_time_base = av_q2d(video_stream->time_base);
+double stream_dur;
+
+if (video_stream->duration != AV_NOPTS_VALUE) {
+  stream_dur = video_stream->duration * pts_time_base;
+}
+else {
+  double video_start = 0;
+  double audio_start = 0;
+
+  if (video_stream->start_time != AV_NOPTS_VALUE) {
+video_start = video_stream->start_time * pts_time_base;
+  }
+
+  /* Find audio stream to guess the duration of the video.
+   * Sometimes the audio AND the video stream have a start offset.
+   * The difference between these is the offset we want to use to
+   * calculate the video duration.
+   */
+  for (i = 0; i < pFormatCtx->nb_streams; i++) {
+if (pFormatCtx->streams[i]->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) {
+  AVStream *audio_stream = pFormatCtx->streams[i];
+  if (audio_stream->start_time != AV_NOPTS_VALUE) {
+audio_start = audio_stream->start_time * 
av_q2d(audio_stream->time_base);
+  }
+  break;
+}
+  }
+
+  if (video_start > audio_start) {
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE - 
(video_start - audio_start);
+  }
+  else {
+/* The video stream starts before or at the same time as the audio 
stream!
+ * We have to assume that the video stream is as long as the full 
pFormatCtx->duration.
+ */
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE;
+  }
+}
+anim->duration_in_frames = (int)(stream_dur * av_q2d(frame_rate) + 0.5f);
   }
 
   frs_num = frame_rate.num;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3f271cb5b62] temp-VSE-fixes: Fix "off by one" error when encoding audio

2021-08-13 Thread Sebastian Parborg
Commit: 3f271cb5b6224c27afdc760068dfb0103a94c639
Author: Sebastian Parborg
Date:   Fri Jul 9 15:06:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB3f271cb5b6224c27afdc760068dfb0103a94c639

Fix "off by one" error when encoding audio

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 9f3f50febe8..323da7473b5 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1435,8 +1435,9 @@ int BKE_ffmpeg_append(void *context_v,
   }
 
 #  ifdef WITH_AUDASPACE
-  write_audio_frames(context,
- (frame - start_frame) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
+  /* Add +1 frame because we want to encode audio up until the next video 
frame. */
+  write_audio_frames(
+  context, (frame - start_frame + 1) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
 #  endif
   return success;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [eb69f66fa8c] temp-VSE-fixes: Flush audio encode after finishing video export

2021-08-13 Thread Sebastian Parborg
Commit: eb69f66fa8c39467ab8b38f3d1bffccef31cda4b
Author: Sebastian Parborg
Date:   Mon Jul 5 14:16:02 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBeb69f66fa8c39467ab8b38f3d1bffccef31cda4b

Flush audio encode after finishing video export

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 32057709c38..9f3f50febe8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -149,7 +149,6 @@ static int write_audio_frame(FFMpegContext *context)
 
   AUD_Device_read(
   context->audio_mixdown_device, context->audio_input_buffer, 
context->audio_input_samples);
-  context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
 
   frame = av_frame_alloc();
   frame->pts = context->audio_time / av_q2d(c->time_base);
@@ -184,7 +183,7 @@ static int write_audio_frame(FFMpegContext *context)
context->audio_input_samples * c->channels * 
context->audio_sample_size,
1);
 
-  int success = 0;
+  int success = 1;
 
   int ret = avcodec_send_frame(c, frame);
   if (ret < 0) {
@@ -369,7 +368,7 @@ static int write_video_frame(FFMpegContext *context, int 
cfra, AVFrame *frame, R
   return success;
 }
 
-/* read and encode a frame of audio from the buffer */
+/* read and encode a frame of video from the buffer */
 static AVFrame *generate_video_frame(FFMpegContext *context, const uint8_t 
*pixels)
 {
   AVCodecParameters *codec = context->video_stream->codecpar;
@@ -1226,9 +1225,8 @@ fail:
  * parameter.
  * 
  */
-static void flush_ffmpeg(FFMpegContext *context)
+static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext 
*outfile)
 {
-  AVCodecContext *c = context->video_codec;
   AVPacket *packet = av_packet_alloc();
 
   avcodec_send_frame(c, NULL);
@@ -1247,13 +1245,13 @@ static void flush_ffmpeg(FFMpegContext *context)
   break;
 }
 
-packet->stream_index = context->video_stream->index;
-av_packet_rescale_ts(packet, c->time_base, 
context->video_stream->time_base);
+packet->stream_index = stream->index;
+av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, context->video_stream, packet);
+my_guess_pkt_duration(context->outfile, stream, packet);
 #  endif
 
-int write_ret = av_interleaved_write_frame(context->outfile, packet);
+int write_ret = av_interleaved_write_frame(outfile, packet);
 if (write_ret != 0) {
   fprintf(stderr, "Error writing delayed frame: %s\n", 
av_err2str(write_ret));
   break;
@@ -1396,12 +1394,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit);
 #  ifdef WITH_AUDASPACE
 static void write_audio_frames(FFMpegContext *context, double to_pts)
 {
-  int finished = 0;
+  AVCodecContext *c = context->audio_codec;
 
-  while (context->audio_stream && !finished) {
-if ((context->audio_time >= to_pts) || (write_audio_frame(context))) {
-  finished = 1;
+  while (context->audio_stream) {
+if ((context->audio_time >= to_pts) || !write_audio_frame(context)) {
+  break;
 }
+context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
   }
 }
 #  endif
@@ -1422,9 +1421,6 @@ int BKE_ffmpeg_append(void *context_v,
 
   PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, 
recty);
 
-  /* why is this done before writing the video frame and again at end_ffmpeg? 
*/
-  //  write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
-
   if (context->video_stream) {
 avframe = generate_video_frame(context, (unsigned char *)pixels);
 success = (avframe && write_video_frame(context, frame - start_frame, 
avframe, reports));
@@ -1461,8 +1457,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit)
 #  endif
 
   if (context->video_stream) {
-PRINT("Flushing delayed frames...\n");
-flush_ffmpeg(context);
+PRINT("Flushing delayed video frames...\n");
+flush_ffmpeg(context->video_codec, context->video_stream, 
context->outfile);
+  }
+
+  if (context->audio_stream) {
+PRINT("Flushing delayed audio frames...\n");
+flush_ffmpeg(context->audio_codec, context->audio_stream, 
context->outfile);
   }
 
   if (context->outfile) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [79fa4f6623b] temp-VSE-fixes: Fix VSE seeking issues.

2021-08-11 Thread Sebastian Parborg
Commit: 79fa4f6623b0912f71561256a2cf64c9c4e10d4d
Author: Sebastian Parborg
Date:   Mon Jul 12 19:13:15 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB79fa4f6623b0912f71561256a2cf64c9c4e10d4d

Fix VSE seeking issues.

The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

===

M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index c08df2889de..fd96110b59e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1059,33 +1059,21 @@ static int ffmpeg_seek_by_byte(AVFormatContext 
*pFormatCtx)
   return false;
 }
 
-static int64_t ffmpeg_get_seek_pos(struct anim *anim, int position)
+static int64_t ffmpeg_get_seek_pts(struct anim *anim, int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t st_time = anim->pFormatCtx->start_time;
-  int64_t pos = (int64_t)(position)*AV_TIME_BASE;
-  /* Step back half a time base position to make sure that we get the requested
-   * frame and not the one after it.
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+  /* Step back half a frame position to make sure that we get the requested
+   * frame and not the one after it. This is a workaround as ffmpeg will
+   * sometimes not seek to a frame after the requested pts even if
+   * AVSEEK_FLAG_BACKWARD is specified.
*/
-  pos -= (AV_TIME_BASE / 2);
-  pos /= frame_rate;
+  int64_t pts = pts_to_search - (steps_per_frame / 2);
 
-  av_log(anim->pFormatCtx,
- AV_LOG_DEBUG,
- "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n",
- pos,
- (st_time != AV_NOPTS_VALUE) ? st_time : 0);
-
-  if (pos < 0) {
-pos = 0;
-  }
-
-  if (st_time != AV_NOPTS_VALUE) {
-pos += st_time;
-  }
-
-  return pos;
+  return pts;
 }
 
 /* This gives us an estimate of which pts our requested frame will have.
@@ -1102,17 +1090,18 @@ static int64_t ffmpeg_get_pts_to_search(struct anim 
*anim,
 pts_to_search = IMB_indexer_get_pts(tc_index, new_frame_index);
   }
   else {
-int64_t st_time = anim->pFormatCtx->start_time;
 AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL);
+int64_t start_pts = v_st->start_time;
+AVRational frame_rate = v_st->r_frame_rate;
 AVRational time_base = v_st->time_base;
 
-int64_t steps_per_frame = (frame_rate.den * time_base.den) / 
(frame_rate.num * time_base.num);
-pts_to_search = position * steps_per_frame;
+double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+ (double)(frame_rate.num * time_base.num);
+
+pts_to_search = round(position * steps_per_frame);
 
-if (st_time != AV_NOPTS_VALUE && st_time != 0) {
-  int64_t start_frame = (double)st_time / AV_TIME_BASE * 
av_q2d(frame_rate);
-  pts_to_search += start_frame * steps_per_frame;
+if (start_pts != AV_NOPTS_VALUE) {
+  pts_to_search += start_pts;
 }
   }
   return pts_to_search;
@@ -1196,23 +1185,29 @@ static void ffmpeg_decode_video_frame_scan(struct anim 
*anim, int64_t pts_to_sea
  * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 and
  * https://developer.blender.org/T86944. */
 static int ffmpeg_generic_seek_workaround(struct anim *anim,
-  int64_t *requested_pos,
+  int64_t *requested_pts,
   int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t current_pos = *requested_pos;
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+
+  int64_t current_pts = *requested_pts;
   int64_t offset = 0;
 
   int64_t cur_pts, prev_pts = -1;
 
   /* Step backward frame by frame until we find the key frame we are looking 
for. */
-  while (current_pos != 0) {
-current_pos = *requested_pos - ((int64_t)(offset)*AV_TIME_BASE / 
frame_rate);
-current_pos = max_ii(current_p

[Bf-blender-cvs] [4ae1d1f1e8a] temp-VSE-fixes: Draw seq waveforms better

2021-08-11 Thread Sebastian Parborg
Commit: 4ae1d1f1e8a18bea2252a24c85728466c3b14f45
Author: Sebastian Parborg
Date:   Thu Jul 1 18:51:26 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB4ae1d1f1e8a18bea2252a24c85728466c3b14f45

Draw seq waveforms better

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   source/blender/editors/space_sequencer/sequencer_draw.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index 97e5f5540de..5cc33525d1d 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -247,7 +247,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, 
int length, int sampl
 
buffer[i * 3] = min;
buffer[i * 3 + 1] = max;
-   buffer[i * 3 + 2] = sqrt(power) / len;
+   buffer[i * 3 + 2] = sqrt(power / len); // RMS
 
if(overallmax < max)
overallmax = max;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index e49a88c88d2..9cf4fd94c68 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -228,9 +228,81 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, 
uchar col[3])
   }
 }
 
+typedef struct WaveVizData {
+  float pos[2];
+  float rms_pos;
+  bool clip;
+  bool end;
+} WaveVizData;
+
+static int get_section_len(WaveVizData *start, WaveVizData *end)
+{
+  int len = 0;
+  while (start != end) {
+len++;
+if (start->end) {
+  return len;
+}
+start++;
+  }
+  return len;
+}
+
+static void draw_waveform(WaveVizData *iter, WaveVizData *end, GPUPrimType 
prim_type, bool use_rms)
+{
+  int strip_len = get_section_len(iter, end);
+  if (strip_len != 0) {
+GPU_blend(GPU_BLEND_ALPHA);
+GPUVertFormat *format = immVertexFormat();
+uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, 
GPU_FETCH_FLOAT);
+uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, 
GPU_FETCH_FLOAT);
+
+immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+immBegin(prim_type, strip_len);
+
+while (iter != end) {
+  if (iter->clip) {
+immAttr4f(col, 1.0f, 0.0f, 0.0f, 0.5f);
+  }
+  else if (use_rms) {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.8f);
+  }
+  else {
+immAttr4f(col, 1.0f, 1.0f, 1.0f, 0.5f);
+  }
+
+  if (use_rms) {
+immVertex2f(pos, iter->pos[0], iter->rms_pos);
+  }
+  else {
+immVertex2f(pos, iter->pos[0], iter->pos[1]);
+  }
+
+  if (iter->end) {
+/* End of line. */
+iter++;
+strip_len = get_section_len(iter, end);
+if (strip_len != 0) {
+  immEnd();
+  immUnbindProgram();
+  immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+  immBegin(prim_type, strip_len);
+}
+  }
+  else {
+iter++;
+  }
+}
+immEnd();
+immUnbindProgram();
+
+GPU_blend(GPU_BLEND_NONE);
+  }
+}
+
 /**
  * \param x1, x2, y1, y2: The starting and end X value to draw the wave, same 
for y1 and y2.
- * \param stepsize: The width of a pixel.
+ * \param pixels_per_frame: The amount of pixels a whole frame takes up 
(x-axis direction).
  */
 static void draw_seq_waveform_overlay(View2D *v2d,
   const bContext *C,
@@ -241,29 +313,25 @@ static void draw_seq_waveform_overlay(View2D *v2d,
   float y1,
   float x2,
   float y2,
-  float stepsize)
+  float pixels_per_frame)
 {
   /* Offset x1 and x2 values, to match view min/max, if strip is out of 
bounds. */
-  int x1_offset = max_ff(v2d->cur.xmin, x1);
-  int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
+  float x1_offset = max_ff(v2d->cur.xmin, x1);
+  float x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2);
 
   if (seq->sound && ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & 
SEQ_AUDIO_DRAW_WAVEFORM))) {
-int length = floor((x2_offset - x1_offset) / stepsize) + 1;
-float ymid = (y1 + y2) / 2.0f;
-float yscale = (y2 - y1) / 2.0f;
-float samplestep;
-float startsample, endsample;
-float volume = seq->volume;
-float value1, value2;
-bSound *sound = seq->sound;
-SoundWaveform *waveform;
+/* Calculate how long the strip that is in view is in pixels. */
+int pix_strip_len = floor((x2_offset - x1_offset) * pixels_per_frame);
 
-if (length < 2) {
+if (pix_strip_len < 2) {
   return;
 }
 
+   

[Bf-blender-cvs] [8a63d9a0a14] temp-VSE-fixes: Fix audaspace not reading ffmpeg files with start offset correctly

2021-08-11 Thread Sebastian Parborg
Commit: 8a63d9a0a144fc8d67d098f497a1dd72fafb02d7
Author: Sebastian Parborg
Date:   Tue Jul 6 19:48:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB8a63d9a0a144fc8d67d098f497a1dd72fafb02d7

Fix audaspace not reading ffmpeg files with start offset correctly

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Types.h
M   extern/audaspace/include/IReader.h
M   extern/audaspace/include/fx/EffectReader.h
M   extern/audaspace/include/fx/ModulatorReader.h
M   extern/audaspace/include/fx/MutableReader.h
M   extern/audaspace/include/fx/VolumeReader.h
M   extern/audaspace/include/generator/SawtoothReader.h
M   extern/audaspace/include/generator/SilenceReader.h
M   extern/audaspace/include/generator/SineReader.h
M   extern/audaspace/include/generator/SquareReader.h
M   extern/audaspace/include/generator/TriangleReader.h
M   extern/audaspace/include/sequence/DoubleReader.h
M   extern/audaspace/include/sequence/SequenceReader.h
M   extern/audaspace/include/sequence/SuperposeReader.h
M   extern/audaspace/include/util/BufferReader.h
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
M   extern/audaspace/plugins/libsndfile/SndFileReader.cpp
M   extern/audaspace/plugins/libsndfile/SndFileReader.h
M   extern/audaspace/src/fx/EffectReader.cpp
M   extern/audaspace/src/fx/ModulatorReader.cpp
M   extern/audaspace/src/fx/MutableReader.cpp
M   extern/audaspace/src/fx/VolumeReader.cpp
M   extern/audaspace/src/generator/SawtoothReader.cpp
M   extern/audaspace/src/generator/SilenceReader.cpp
M   extern/audaspace/src/generator/SineReader.cpp
M   extern/audaspace/src/generator/SquareReader.cpp
M   extern/audaspace/src/generator/TriangleReader.cpp
M   extern/audaspace/src/sequence/DoubleReader.cpp
M   extern/audaspace/src/sequence/SequenceReader.cpp
M   extern/audaspace/src/sequence/SuperposeReader.cpp
M   extern/audaspace/src/util/BufferReader.cpp
M   source/blender/blenkernel/BKE_sound.h
M   source/blender/blenkernel/intern/sound.c
M   source/blender/editors/space_sequencer/sequencer_add.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_sequencer_api.c
M   source/blender/sequencer/SEQ_add.h
M   source/blender/sequencer/intern/sound.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/sequencer/intern/strip_time.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index ac876a01eb3..97e5f5540de 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
+   info.start_offset = 0.0f;
 
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) 
info.specs.rate;
+   info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
diff --git a/extern/audaspace/bindings/C/AUD_Types.h 
b/extern/audaspace/bindings/C/AUD_Types.h
index 75e4ffae18c..c6a96d30d3f 100644
--- a/extern/audaspace/bindings/C/AUD_Types.h
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -176,4 +176,5 @@ typedef struct
 {
AUD_Specs specs;
float length;
+   double start_offset;
 } AUD_SoundInfo;
diff --git a/extern/audaspace/include/IReader.h 
b/extern/audaspace/include/IReader.h
index c29900ca579..7de9a5c6d81 100644
--- a/extern/audaspace/include/IReader.h
+++ b/extern/audaspace/include/IReader.h
@@ -70,6 +70,12 @@ public:
 */
virtual int getPosition() const=0;
 
+   /**
+* Returns the start offset the sound should have to line up with 
related sources.
+* \return The required start offset in seconds.
+*/
+   virtual double getStartOffset() const=0;
+
/**
 * Returns the specification of the reader.
 * \return The Specs structure.
diff --git a/extern/audaspace/include/fx/EffectReader.h 
b/extern/audaspace/include/fx/EffectReader.h
index 85eff6a8ab9..f21001c1f86 100644
--- a/extern/audaspace/include/fx/EffectReader.h
+++ b/extern/audaspace/include/fx/EffectReader.h
@@ -61,6 +6

[Bf-blender-cvs] [c83d38307b3] temp-VSE-fixes: Fix VSE video strip duration calculation

2021-08-11 Thread Sebastian Parborg
Commit: c83d38307b3f11da060a2d082b10c15298d26532
Author: Sebastian Parborg
Date:   Mon Jul 12 16:00:43 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBc83d38307b3f11da060a2d082b10c15298d26532

Fix VSE video strip duration calculation

===

M   source/blender/imbuf/intern/anim_movie.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 47514308ae4..c08df2889de 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -616,10 +616,50 @@ static int startffmpeg(struct anim *anim)
   }
 }
   }
-  /* Fall back to the container. */
+  /* Fall back to manually estimating the video stream duration.
+   * This is because the video stream duration can be shorter than the 
pFormatCtx->duration.
+   */
   if (anim->duration_in_frames == 0) {
-anim->duration_in_frames = (int)(pFormatCtx->duration * av_q2d(frame_rate) 
/ AV_TIME_BASE +
- 0.5f);
+double pts_time_base = av_q2d(video_stream->time_base);
+double stream_dur;
+
+if (video_stream->duration != AV_NOPTS_VALUE) {
+  stream_dur = video_stream->duration * pts_time_base;
+}
+else {
+  double video_start = 0;
+  double audio_start = 0;
+
+  if (video_stream->start_time != AV_NOPTS_VALUE) {
+video_start = video_stream->start_time * pts_time_base;
+  }
+
+  /* Find audio stream to guess the duration of the video.
+   * Sometimes the audio AND the video stream have a start offset.
+   * The difference between these is the offset we want to use to
+   * calculate the video duration.
+   */
+  for (i = 0; i < pFormatCtx->nb_streams; i++) {
+if (pFormatCtx->streams[i]->codecpar->codec_type == 
AVMEDIA_TYPE_AUDIO) {
+  AVStream *audio_stream = pFormatCtx->streams[i];
+  if (audio_stream->start_time != AV_NOPTS_VALUE) {
+audio_start = audio_stream->start_time * 
av_q2d(audio_stream->time_base);
+  }
+  break;
+}
+  }
+
+  if (video_start > audio_start) {
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE - 
(video_start - audio_start);
+  }
+  else {
+/* The video stream starts before or at the same time as the audio 
stream!
+ * We have to assume that the video stream is as long as the full 
pFormatCtx->duration.
+ */
+stream_dur = (double)pFormatCtx->duration / AV_TIME_BASE;
+  }
+}
+anim->duration_in_frames = (int)(stream_dur * av_q2d(frame_rate) + 0.5f);
   }
 
   frs_num = frame_rate.num;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a69ca9b8f48] temp-VSE-fixes: Fix memory leak when adding bad VSE image/movie strips

2021-08-11 Thread Sebastian Parborg
Commit: a69ca9b8f48bc64331bd678c4475e633e9c2d6a8
Author: Sebastian Parborg
Date:   Mon Jul 12 15:38:25 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBa69ca9b8f48bc64331bd678c4475e633e9c2d6a8

Fix memory leak when adding bad VSE image/movie strips

===

M   source/blender/editors/space_sequencer/sequencer_add.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_add.c 
b/source/blender/editors/space_sequencer/sequencer_add.c
index 265a52ed1a6..47495eaa57a 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -707,13 +707,13 @@ static int sequencer_add_movie_strip_exec(bContext *C, 
wmOperator *op)
   }
   else {
 if (!sequencer_add_movie_single_strip(C, op, &load_data)) {
+  sequencer_add_cancel(C, op);
   return OPERATOR_CANCELLED;
 }
   }
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   DEG_relations_tag_update(bmain);
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@@ -1040,6 +1040,7 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   load_data.image.len = sequencer_add_image_strip_calculate_length(
   op, load_data.start_frame, &minframe, &numdigits);
   if (load_data.image.len == 0) {
+sequencer_add_cancel(C, op);
 return OPERATOR_CANCELLED;
   }
 
@@ -1062,9 +1063,8 @@ static int sequencer_add_image_strip_exec(bContext *C, 
wmOperator *op)
   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
   WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
-  if (op->customdata) {
-MEM_freeN(op->customdata);
-  }
+  /* Free custom data. */
+  sequencer_add_cancel(C, op);
 
   return OPERATOR_FINISHED;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [eb69f66fa8c] temp-VSE-fixes: Flush audio encode after finishing video export

2021-08-11 Thread Sebastian Parborg
Commit: eb69f66fa8c39467ab8b38f3d1bffccef31cda4b
Author: Sebastian Parborg
Date:   Mon Jul 5 14:16:02 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBeb69f66fa8c39467ab8b38f3d1bffccef31cda4b

Flush audio encode after finishing video export

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 32057709c38..9f3f50febe8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -149,7 +149,6 @@ static int write_audio_frame(FFMpegContext *context)
 
   AUD_Device_read(
   context->audio_mixdown_device, context->audio_input_buffer, 
context->audio_input_samples);
-  context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
 
   frame = av_frame_alloc();
   frame->pts = context->audio_time / av_q2d(c->time_base);
@@ -184,7 +183,7 @@ static int write_audio_frame(FFMpegContext *context)
context->audio_input_samples * c->channels * 
context->audio_sample_size,
1);
 
-  int success = 0;
+  int success = 1;
 
   int ret = avcodec_send_frame(c, frame);
   if (ret < 0) {
@@ -369,7 +368,7 @@ static int write_video_frame(FFMpegContext *context, int 
cfra, AVFrame *frame, R
   return success;
 }
 
-/* read and encode a frame of audio from the buffer */
+/* read and encode a frame of video from the buffer */
 static AVFrame *generate_video_frame(FFMpegContext *context, const uint8_t 
*pixels)
 {
   AVCodecParameters *codec = context->video_stream->codecpar;
@@ -1226,9 +1225,8 @@ fail:
  * parameter.
  * 
  */
-static void flush_ffmpeg(FFMpegContext *context)
+static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext 
*outfile)
 {
-  AVCodecContext *c = context->video_codec;
   AVPacket *packet = av_packet_alloc();
 
   avcodec_send_frame(c, NULL);
@@ -1247,13 +1245,13 @@ static void flush_ffmpeg(FFMpegContext *context)
   break;
 }
 
-packet->stream_index = context->video_stream->index;
-av_packet_rescale_ts(packet, c->time_base, 
context->video_stream->time_base);
+packet->stream_index = stream->index;
+av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, context->video_stream, packet);
+my_guess_pkt_duration(context->outfile, stream, packet);
 #  endif
 
-int write_ret = av_interleaved_write_frame(context->outfile, packet);
+int write_ret = av_interleaved_write_frame(outfile, packet);
 if (write_ret != 0) {
   fprintf(stderr, "Error writing delayed frame: %s\n", 
av_err2str(write_ret));
   break;
@@ -1396,12 +1394,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit);
 #  ifdef WITH_AUDASPACE
 static void write_audio_frames(FFMpegContext *context, double to_pts)
 {
-  int finished = 0;
+  AVCodecContext *c = context->audio_codec;
 
-  while (context->audio_stream && !finished) {
-if ((context->audio_time >= to_pts) || (write_audio_frame(context))) {
-  finished = 1;
+  while (context->audio_stream) {
+if ((context->audio_time >= to_pts) || !write_audio_frame(context)) {
+  break;
 }
+context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
   }
 }
 #  endif
@@ -1422,9 +1421,6 @@ int BKE_ffmpeg_append(void *context_v,
 
   PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, 
recty);
 
-  /* why is this done before writing the video frame and again at end_ffmpeg? 
*/
-  //  write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
-
   if (context->video_stream) {
 avframe = generate_video_frame(context, (unsigned char *)pixels);
 success = (avframe && write_video_frame(context, frame - start_frame, 
avframe, reports));
@@ -1461,8 +1457,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit)
 #  endif
 
   if (context->video_stream) {
-PRINT("Flushing delayed frames...\n");
-flush_ffmpeg(context);
+PRINT("Flushing delayed video frames...\n");
+flush_ffmpeg(context->video_codec, context->video_stream, 
context->outfile);
+  }
+
+  if (context->audio_stream) {
+PRINT("Flushing delayed audio frames...\n");
+flush_ffmpeg(context->audio_codec, context->audio_stream, 
context->outfile);
   }
 
   if (context->outfile) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3f271cb5b62] temp-VSE-fixes: Fix "off by one" error when encoding audio

2021-08-11 Thread Sebastian Parborg
Commit: 3f271cb5b6224c27afdc760068dfb0103a94c639
Author: Sebastian Parborg
Date:   Fri Jul 9 15:06:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB3f271cb5b6224c27afdc760068dfb0103a94c639

Fix "off by one" error when encoding audio

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 9f3f50febe8..323da7473b5 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1435,8 +1435,9 @@ int BKE_ffmpeg_append(void *context_v,
   }
 
 #  ifdef WITH_AUDASPACE
-  write_audio_frames(context,
- (frame - start_frame) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
+  /* Add +1 frame because we want to encode audio up until the next video 
frame. */
+  write_audio_frames(
+  context, (frame - start_frame + 1) / (((double)rd->frs_sec) / 
(double)rd->frs_sec_base));
 #  endif
   return success;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3c9a68fb0ec] temp-VSE-fixes: Fix audaspace not reading ffmpeg files with start offset correctly

2021-08-10 Thread Sebastian Parborg
Commit: 3c9a68fb0ec73f30adb03bd6ef8a3f49b6075387
Author: Sebastian Parborg
Date:   Tue Jul 6 19:48:06 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB3c9a68fb0ec73f30adb03bd6ef8a3f49b6075387

Fix audaspace not reading ffmpeg files with start offset correctly

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Types.h
M   extern/audaspace/include/IReader.h
M   extern/audaspace/include/fx/EffectReader.h
M   extern/audaspace/include/fx/ModulatorReader.h
M   extern/audaspace/include/fx/MutableReader.h
M   extern/audaspace/include/fx/VolumeReader.h
M   extern/audaspace/include/generator/SawtoothReader.h
M   extern/audaspace/include/generator/SilenceReader.h
M   extern/audaspace/include/generator/SineReader.h
M   extern/audaspace/include/generator/SquareReader.h
M   extern/audaspace/include/generator/TriangleReader.h
M   extern/audaspace/include/sequence/DoubleReader.h
M   extern/audaspace/include/sequence/SequenceReader.h
M   extern/audaspace/include/sequence/SuperposeReader.h
M   extern/audaspace/include/util/BufferReader.h
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
M   extern/audaspace/plugins/ffmpeg/FFMPEGReader.h
M   extern/audaspace/plugins/libsndfile/SndFileReader.cpp
M   extern/audaspace/plugins/libsndfile/SndFileReader.h
M   extern/audaspace/src/fx/EffectReader.cpp
M   extern/audaspace/src/fx/ModulatorReader.cpp
M   extern/audaspace/src/fx/MutableReader.cpp
M   extern/audaspace/src/fx/VolumeReader.cpp
M   extern/audaspace/src/generator/SawtoothReader.cpp
M   extern/audaspace/src/generator/SilenceReader.cpp
M   extern/audaspace/src/generator/SineReader.cpp
M   extern/audaspace/src/generator/SquareReader.cpp
M   extern/audaspace/src/generator/TriangleReader.cpp
M   extern/audaspace/src/sequence/DoubleReader.cpp
M   extern/audaspace/src/sequence/SequenceReader.cpp
M   extern/audaspace/src/sequence/SuperposeReader.cpp
M   extern/audaspace/src/util/BufferReader.cpp
M   source/blender/blenkernel/BKE_sound.h
M   source/blender/blenkernel/intern/sound.c
M   source/blender/editors/space_sequencer/sequencer_add.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/IMB_anim.h
M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/makesdna/DNA_sound_types.h
M   source/blender/makesrna/intern/rna_sequencer_api.c
M   source/blender/sequencer/SEQ_add.h
M   source/blender/sequencer/intern/sound.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/sequencer/intern/strip_time.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index f2398bf0efb..5cc33525d1d 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -86,6 +86,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
info.specs.channels = AUD_CHANNELS_INVALID;
info.specs.rate = AUD_RATE_INVALID;
info.length = 0.0f;
+   info.start_offset = 0.0f;
 
try
{
@@ -95,6 +96,7 @@ AUD_API AUD_SoundInfo AUD_getInfo(AUD_Sound* sound)
{
info.specs = convSpecToC(reader->getSpecs());
info.length = reader->getLength() / (float) 
info.specs.rate;
+   info.start_offset = reader->getStartOffset();
}
}
catch(Exception&)
diff --git a/extern/audaspace/bindings/C/AUD_Types.h 
b/extern/audaspace/bindings/C/AUD_Types.h
index 75e4ffae18c..c6a96d30d3f 100644
--- a/extern/audaspace/bindings/C/AUD_Types.h
+++ b/extern/audaspace/bindings/C/AUD_Types.h
@@ -176,4 +176,5 @@ typedef struct
 {
AUD_Specs specs;
float length;
+   double start_offset;
 } AUD_SoundInfo;
diff --git a/extern/audaspace/include/IReader.h 
b/extern/audaspace/include/IReader.h
index c29900ca579..7de9a5c6d81 100644
--- a/extern/audaspace/include/IReader.h
+++ b/extern/audaspace/include/IReader.h
@@ -70,6 +70,12 @@ public:
 */
virtual int getPosition() const=0;
 
+   /**
+* Returns the start offset the sound should have to line up with 
related sources.
+* \return The required start offset in seconds.
+*/
+   virtual double getStartOffset() const=0;
+
/**
 * Returns the specification of the reader.
 * \return The Specs structure.
diff --git a/extern/audaspace/include/fx/EffectReader.h 
b/extern/audaspace/include/fx/EffectReader.h
index 85eff6a8ab9..f21001c1f86 100644
--- a/extern/audaspace/include/fx/EffectReader.h
+++ b/extern/audaspace/include/fx/EffectReader.h
@@ -61,6 +6

[Bf-blender-cvs] [16ffeb05afc] temp-VSE-fixes: Fix VSE seeking issues.

2021-08-10 Thread Sebastian Parborg
Commit: 16ffeb05afce916c65eab18f98ae8b933e3dc7f4
Author: Sebastian Parborg
Date:   Mon Jul 12 19:13:15 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rB16ffeb05afce916c65eab18f98ae8b933e3dc7f4

Fix VSE seeking issues.

The seek pts was not correctly calculated.
In addition to that we were not seeking in the video pts time base.

===

M   source/blender/imbuf/intern/anim_movie.c
M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index c08df2889de..fd96110b59e 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1059,33 +1059,21 @@ static int ffmpeg_seek_by_byte(AVFormatContext 
*pFormatCtx)
   return false;
 }
 
-static int64_t ffmpeg_get_seek_pos(struct anim *anim, int position)
+static int64_t ffmpeg_get_seek_pts(struct anim *anim, int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t st_time = anim->pFormatCtx->start_time;
-  int64_t pos = (int64_t)(position)*AV_TIME_BASE;
-  /* Step back half a time base position to make sure that we get the requested
-   * frame and not the one after it.
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+  /* Step back half a frame position to make sure that we get the requested
+   * frame and not the one after it. This is a workaround as ffmpeg will
+   * sometimes not seek to a frame after the requested pts even if
+   * AVSEEK_FLAG_BACKWARD is specified.
*/
-  pos -= (AV_TIME_BASE / 2);
-  pos /= frame_rate;
+  int64_t pts = pts_to_search - (steps_per_frame / 2);
 
-  av_log(anim->pFormatCtx,
- AV_LOG_DEBUG,
- "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n",
- pos,
- (st_time != AV_NOPTS_VALUE) ? st_time : 0);
-
-  if (pos < 0) {
-pos = 0;
-  }
-
-  if (st_time != AV_NOPTS_VALUE) {
-pos += st_time;
-  }
-
-  return pos;
+  return pts;
 }
 
 /* This gives us an estimate of which pts our requested frame will have.
@@ -1102,17 +1090,18 @@ static int64_t ffmpeg_get_pts_to_search(struct anim 
*anim,
 pts_to_search = IMB_indexer_get_pts(tc_index, new_frame_index);
   }
   else {
-int64_t st_time = anim->pFormatCtx->start_time;
 AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-AVRational frame_rate = av_guess_frame_rate(anim->pFormatCtx, v_st, NULL);
+int64_t start_pts = v_st->start_time;
+AVRational frame_rate = v_st->r_frame_rate;
 AVRational time_base = v_st->time_base;
 
-int64_t steps_per_frame = (frame_rate.den * time_base.den) / 
(frame_rate.num * time_base.num);
-pts_to_search = position * steps_per_frame;
+double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+ (double)(frame_rate.num * time_base.num);
+
+pts_to_search = round(position * steps_per_frame);
 
-if (st_time != AV_NOPTS_VALUE && st_time != 0) {
-  int64_t start_frame = (double)st_time / AV_TIME_BASE * 
av_q2d(frame_rate);
-  pts_to_search += start_frame * steps_per_frame;
+if (start_pts != AV_NOPTS_VALUE) {
+  pts_to_search += start_pts;
 }
   }
   return pts_to_search;
@@ -1196,23 +1185,29 @@ static void ffmpeg_decode_video_frame_scan(struct anim 
*anim, int64_t pts_to_sea
  * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 and
  * https://developer.blender.org/T86944. */
 static int ffmpeg_generic_seek_workaround(struct anim *anim,
-  int64_t *requested_pos,
+  int64_t *requested_pts,
   int64_t pts_to_search)
 {
   AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
-  double frame_rate = av_q2d(av_guess_frame_rate(anim->pFormatCtx, v_st, 
NULL));
-  int64_t current_pos = *requested_pos;
+  AVRational frame_rate = v_st->r_frame_rate;
+  AVRational time_base = v_st->time_base;
+
+  double steps_per_frame = (double)(frame_rate.den * time_base.den) /
+   (double)(frame_rate.num * time_base.num);
+
+  int64_t current_pts = *requested_pts;
   int64_t offset = 0;
 
   int64_t cur_pts, prev_pts = -1;
 
   /* Step backward frame by frame until we find the key frame we are looking 
for. */
-  while (current_pos != 0) {
-current_pos = *requested_pos - ((int64_t)(offset)*AV_TIME_BASE / 
frame_rate);
-current_pos = max_ii(current_p

[Bf-blender-cvs] [dd1bc812203] temp-VSE-fixes: Flush audio encode after finishing video export

2021-08-10 Thread Sebastian Parborg
Commit: dd1bc8122033aff56137b9a1c316acff06672070
Author: Sebastian Parborg
Date:   Mon Jul 5 14:16:02 2021 +0200
Branches: temp-VSE-fixes
https://developer.blender.org/rBdd1bc8122033aff56137b9a1c316acff06672070

Flush audio encode after finishing video export

===

M   source/blender/blenkernel/intern/writeffmpeg.c

===

diff --git a/source/blender/blenkernel/intern/writeffmpeg.c 
b/source/blender/blenkernel/intern/writeffmpeg.c
index 32057709c38..9f3f50febe8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -149,7 +149,6 @@ static int write_audio_frame(FFMpegContext *context)
 
   AUD_Device_read(
   context->audio_mixdown_device, context->audio_input_buffer, 
context->audio_input_samples);
-  context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
 
   frame = av_frame_alloc();
   frame->pts = context->audio_time / av_q2d(c->time_base);
@@ -184,7 +183,7 @@ static int write_audio_frame(FFMpegContext *context)
context->audio_input_samples * c->channels * 
context->audio_sample_size,
1);
 
-  int success = 0;
+  int success = 1;
 
   int ret = avcodec_send_frame(c, frame);
   if (ret < 0) {
@@ -369,7 +368,7 @@ static int write_video_frame(FFMpegContext *context, int 
cfra, AVFrame *frame, R
   return success;
 }
 
-/* read and encode a frame of audio from the buffer */
+/* read and encode a frame of video from the buffer */
 static AVFrame *generate_video_frame(FFMpegContext *context, const uint8_t 
*pixels)
 {
   AVCodecParameters *codec = context->video_stream->codecpar;
@@ -1226,9 +1225,8 @@ fail:
  * parameter.
  * 
  */
-static void flush_ffmpeg(FFMpegContext *context)
+static void flush_ffmpeg(AVCodecContext *c, AVStream *stream, AVFormatContext 
*outfile)
 {
-  AVCodecContext *c = context->video_codec;
   AVPacket *packet = av_packet_alloc();
 
   avcodec_send_frame(c, NULL);
@@ -1247,13 +1245,13 @@ static void flush_ffmpeg(FFMpegContext *context)
   break;
 }
 
-packet->stream_index = context->video_stream->index;
-av_packet_rescale_ts(packet, c->time_base, 
context->video_stream->time_base);
+packet->stream_index = stream->index;
+av_packet_rescale_ts(packet, c->time_base, stream->time_base);
 #  ifdef FFMPEG_USE_DURATION_WORKAROUND
-my_guess_pkt_duration(context->outfile, context->video_stream, packet);
+my_guess_pkt_duration(context->outfile, stream, packet);
 #  endif
 
-int write_ret = av_interleaved_write_frame(context->outfile, packet);
+int write_ret = av_interleaved_write_frame(outfile, packet);
 if (write_ret != 0) {
   fprintf(stderr, "Error writing delayed frame: %s\n", 
av_err2str(write_ret));
   break;
@@ -1396,12 +1394,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit);
 #  ifdef WITH_AUDASPACE
 static void write_audio_frames(FFMpegContext *context, double to_pts)
 {
-  int finished = 0;
+  AVCodecContext *c = context->audio_codec;
 
-  while (context->audio_stream && !finished) {
-if ((context->audio_time >= to_pts) || (write_audio_frame(context))) {
-  finished = 1;
+  while (context->audio_stream) {
+if ((context->audio_time >= to_pts) || !write_audio_frame(context)) {
+  break;
 }
+context->audio_time += (double)context->audio_input_samples / 
(double)c->sample_rate;
   }
 }
 #  endif
@@ -1422,9 +1421,6 @@ int BKE_ffmpeg_append(void *context_v,
 
   PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, 
recty);
 
-  /* why is this done before writing the video frame and again at end_ffmpeg? 
*/
-  //  write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
-
   if (context->video_stream) {
 avframe = generate_video_frame(context, (unsigned char *)pixels);
 success = (avframe && write_video_frame(context, frame - start_frame, 
avframe, reports));
@@ -1461,8 +1457,13 @@ static void end_ffmpeg_impl(FFMpegContext *context, int 
is_autosplit)
 #  endif
 
   if (context->video_stream) {
-PRINT("Flushing delayed frames...\n");
-flush_ffmpeg(context);
+PRINT("Flushing delayed video frames...\n");
+flush_ffmpeg(context->video_codec, context->video_stream, 
context->outfile);
+  }
+
+  if (context->audio_stream) {
+PRINT("Flushing delayed audio frames...\n");
+flush_ffmpeg(context->audio_codec, context->audio_stream, 
context->outfile);
   }
 
   if (context->outfile) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


  1   2   3   4   5   6   >