2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
|
|
|
|
#include "COM_MemoryBuffer.h"
|
2014-04-15 16:06:12 +02:00
|
|
|
|
2024-01-18 22:50:23 +02:00
|
|
|
#include "IMB_colormanagement.hh"
|
|
|
|
|
#include "IMB_imbuf_types.hh"
|
2014-04-15 16:06:12 +02:00
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
#define ASSERT_BUFFER_CONTAINS_AREA(buf, area) \
|
|
|
|
|
BLI_assert(BLI_rcti_inside_rcti(&(buf)->get_rect(), &(area)))
|
|
|
|
|
|
|
|
|
|
#define ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(buf, area, x, y) \
|
|
|
|
|
BLI_assert((buf)->get_rect().xmin <= (x)); \
|
|
|
|
|
BLI_assert((buf)->get_rect().ymin <= (y)); \
|
|
|
|
|
BLI_assert((buf)->get_rect().xmax >= (x) + BLI_rcti_size_x(&(area))); \
|
|
|
|
|
BLI_assert((buf)->get_rect().ymax >= (y) + BLI_rcti_size_y(&(area)))
|
|
|
|
|
|
|
|
|
|
#define ASSERT_VALID_ELEM_SIZE(buf, channel_offset, elem_size) \
|
2021-09-18 19:04:47 +02:00
|
|
|
BLI_assert((buf)->get_num_channels() >= (channel_offset) + (elem_size))
|
2021-06-23 17:21:17 +02:00
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
static rcti create_rect(const int width, const int height)
|
|
|
|
|
{
|
|
|
|
|
rcti rect;
|
|
|
|
|
BLI_rcti_init(&rect, 0, width, 0, height);
|
|
|
|
|
return rect;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-21 17:35:19 +02:00
|
|
|
MemoryBuffer::MemoryBuffer(DataType data_type, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
BLI_rcti_init(&rect_, 0, width, 0, height);
|
|
|
|
|
is_a_single_elem_ = false;
|
|
|
|
|
num_channels_ = COM_data_type_num_channels(data_type);
|
|
|
|
|
buffer_ = (float *)MEM_mallocN_aligned(
|
|
|
|
|
sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
|
|
|
|
|
owns_data_ = true;
|
|
|
|
|
datatype_ = data_type;
|
|
|
|
|
|
|
|
|
|
set_strides();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
MemoryBuffer::MemoryBuffer(DataType data_type, const rcti &rect, bool is_a_single_elem)
|
2015-01-19 18:13:26 +01:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
rect_ = rect;
|
|
|
|
|
is_a_single_elem_ = is_a_single_elem;
|
2021-10-13 23:01:15 +02:00
|
|
|
num_channels_ = COM_data_type_num_channels(data_type);
|
2021-10-13 23:01:04 +02:00
|
|
|
buffer_ = (float *)MEM_mallocN_aligned(
|
|
|
|
|
sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
|
2021-06-23 17:21:17 +02:00
|
|
|
owns_data_ = true;
|
2021-10-13 23:01:15 +02:00
|
|
|
datatype_ = data_type;
|
2021-05-10 10:56:07 +02:00
|
|
|
|
|
|
|
|
set_strides();
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2021-03-19 16:07:32 +01:00
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
MemoryBuffer::MemoryBuffer(
|
|
|
|
|
float *buffer, int num_channels, int width, int height, bool is_a_single_elem)
|
|
|
|
|
: MemoryBuffer(buffer, num_channels, create_rect(width, height), is_a_single_elem)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MemoryBuffer::MemoryBuffer(float *buffer,
|
|
|
|
|
const int num_channels,
|
|
|
|
|
const rcti &rect,
|
|
|
|
|
const bool is_a_single_elem)
|
|
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
rect_ = rect;
|
|
|
|
|
is_a_single_elem_ = is_a_single_elem;
|
|
|
|
|
num_channels_ = num_channels;
|
|
|
|
|
datatype_ = COM_num_channels_data_type(num_channels);
|
|
|
|
|
buffer_ = buffer;
|
2021-06-23 17:21:17 +02:00
|
|
|
owns_data_ = false;
|
|
|
|
|
|
|
|
|
|
set_strides();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) : MemoryBuffer(src.datatype_, src.rect_, false)
|
2021-05-10 10:56:07 +02:00
|
|
|
{
|
|
|
|
|
/* src may be single elem buffer */
|
|
|
|
|
fill_from(src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::set_strides()
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
if (is_a_single_elem_) {
|
2021-05-10 10:56:07 +02:00
|
|
|
this->elem_stride = 0;
|
|
|
|
|
this->row_stride = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2021-10-13 23:01:04 +02:00
|
|
|
this->elem_stride = num_channels_;
|
2021-10-13 23:01:15 +02:00
|
|
|
this->row_stride = get_width() * num_channels_;
|
2021-05-10 10:56:07 +02:00
|
|
|
}
|
2021-10-13 23:01:04 +02:00
|
|
|
to_positive_x_stride_ = rect_.xmin < 0 ? -rect_.xmin + 1 : (rect_.xmin == 0 ? 1 : 0);
|
|
|
|
|
to_positive_y_stride_ = rect_.ymin < 0 ? -rect_.ymin + 1 : (rect_.ymin == 0 ? 1 : 0);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2021-03-19 16:07:32 +01:00
|
|
|
|
2012-05-17 22:55:28 +00:00
|
|
|
void MemoryBuffer::clear()
|
|
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
memset(buffer_, 0, buffer_len() * num_channels_ * sizeof(float));
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-19 17:55:46 +02:00
|
|
|
BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs)
|
|
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
return iterate_with(inputs, rect_);
|
2021-07-19 17:55:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, const rcti &area)
|
|
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
BuffersIteratorBuilder<float> builder(buffer_, rect_, area, elem_stride);
|
2021-07-19 17:55:46 +02:00
|
|
|
for (MemoryBuffer *input : inputs) {
|
2021-10-13 23:01:15 +02:00
|
|
|
builder.add_input(input->get_buffer(), input->get_rect(), input->elem_stride);
|
2021-07-19 17:55:46 +02:00
|
|
|
}
|
|
|
|
|
return builder.build();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-05 23:32:19 +02:00
|
|
|
MemoryBuffer *MemoryBuffer::inflate() const
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(is_a_single_elem());
|
2021-10-13 23:01:04 +02:00
|
|
|
MemoryBuffer *inflated = new MemoryBuffer(datatype_, rect_, false);
|
|
|
|
|
inflated->copy_from(this, rect_);
|
2021-07-05 23:32:19 +02:00
|
|
|
return inflated;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-19 16:45:29 +01:00
|
|
|
float MemoryBuffer::get_max_value() const
|
2012-07-25 10:46:19 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
float result = buffer_[0];
|
2022-09-25 17:04:52 +10:00
|
|
|
const uint size = this->buffer_len();
|
|
|
|
|
uint i;
|
2012-07-25 10:46:19 +00:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
const float *fp_src = buffer_;
|
2012-07-25 10:46:19 +00:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
for (i = 0; i < size; i++, fp_src += num_channels_) {
|
2012-07-25 10:46:19 +00:00
|
|
|
float value = *fp_src;
|
|
|
|
|
if (value > result) {
|
|
|
|
|
result = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-19 16:45:29 +01:00
|
|
|
float MemoryBuffer::get_max_value(const rcti &rect) const
|
2012-07-25 10:46:19 +00:00
|
|
|
{
|
2012-08-03 09:51:10 +00:00
|
|
|
rcti rect_clamp;
|
|
|
|
|
|
|
|
|
|
/* first clamp the rect by the bounds or we get un-initialized values */
|
2021-10-13 23:01:04 +02:00
|
|
|
BLI_rcti_isect(&rect, &rect_, &rect_clamp);
|
2012-08-03 09:51:10 +00:00
|
|
|
|
|
|
|
|
if (!BLI_rcti_is_empty(&rect_clamp)) {
|
2021-10-13 23:01:04 +02:00
|
|
|
MemoryBuffer temp_buffer(datatype_, rect_clamp);
|
2021-03-19 16:15:08 +01:00
|
|
|
temp_buffer.fill_from(*this);
|
2021-03-19 16:45:29 +01:00
|
|
|
return temp_buffer.get_max_value();
|
2012-08-03 09:51:10 +00:00
|
|
|
}
|
2020-08-07 12:32:45 +02:00
|
|
|
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
return 0.0f;
|
2012-07-25 10:46:19 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-17 22:55:28 +00:00
|
|
|
MemoryBuffer::~MemoryBuffer()
|
|
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
if (buffer_ && owns_data_) {
|
|
|
|
|
MEM_freeN(buffer_);
|
|
|
|
|
buffer_ = nullptr;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
void MemoryBuffer::copy_from(const MemoryBuffer *src, const rcti &area)
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-06-23 17:21:17 +02:00
|
|
|
copy_from(src, area, area.xmin, area.ymin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const MemoryBuffer *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int to_x,
|
|
|
|
|
const int to_y)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(this->get_num_channels() == src->get_num_channels());
|
|
|
|
|
copy_from(src, area, 0, src->get_num_channels(), to_x, to_y, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const MemoryBuffer *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int to_channel_offset)
|
|
|
|
|
{
|
|
|
|
|
copy_from(src, area, channel_offset, elem_size, area.xmin, area.ymin, to_channel_offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const MemoryBuffer *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int to_x,
|
|
|
|
|
const int to_y,
|
|
|
|
|
const int to_channel_offset)
|
|
|
|
|
{
|
|
|
|
|
if (this->is_a_single_elem()) {
|
|
|
|
|
copy_single_elem_from(src, channel_offset, elem_size, to_channel_offset);
|
|
|
|
|
}
|
|
|
|
|
else if (!src->is_a_single_elem() && elem_size == src->get_num_channels() &&
|
|
|
|
|
elem_size == this->get_num_channels())
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(to_channel_offset == 0);
|
|
|
|
|
BLI_assert(channel_offset == 0);
|
|
|
|
|
copy_rows_from(src, area, to_x, to_y);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
copy_elems_from(src, area, channel_offset, elem_size, to_x, to_y, to_channel_offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const uchar *src, const rcti &area)
|
|
|
|
|
{
|
2021-08-23 15:30:56 +02:00
|
|
|
const int elem_stride = this->get_num_channels();
|
2021-10-13 23:01:15 +02:00
|
|
|
const int row_stride = elem_stride * get_width();
|
2021-08-23 15:30:56 +02:00
|
|
|
copy_from(src, area, 0, this->get_num_channels(), elem_stride, row_stride, 0);
|
2021-06-23 17:21:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const uchar *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int elem_stride,
|
2021-08-23 15:30:56 +02:00
|
|
|
const int row_stride,
|
2021-06-23 17:21:17 +02:00
|
|
|
const int to_channel_offset)
|
|
|
|
|
{
|
2021-08-23 15:30:56 +02:00
|
|
|
copy_from(src,
|
|
|
|
|
area,
|
|
|
|
|
channel_offset,
|
|
|
|
|
elem_size,
|
|
|
|
|
elem_stride,
|
|
|
|
|
row_stride,
|
|
|
|
|
area.xmin,
|
|
|
|
|
area.ymin,
|
|
|
|
|
to_channel_offset);
|
2021-06-23 17:21:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const uchar *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int elem_stride,
|
2021-08-23 15:30:56 +02:00
|
|
|
const int row_stride,
|
2021-06-23 17:21:17 +02:00
|
|
|
const int to_x,
|
|
|
|
|
const int to_y,
|
|
|
|
|
const int to_channel_offset)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(this, area, to_x, to_y);
|
|
|
|
|
ASSERT_VALID_ELEM_SIZE(this, to_channel_offset, elem_size);
|
|
|
|
|
|
|
|
|
|
const int width = BLI_rcti_size_x(&area);
|
|
|
|
|
const int height = BLI_rcti_size_y(&area);
|
2021-08-23 15:30:56 +02:00
|
|
|
const uchar *const src_start = src + area.ymin * row_stride + channel_offset;
|
2021-06-23 17:21:17 +02:00
|
|
|
for (int y = 0; y < height; y++) {
|
2021-08-23 15:30:56 +02:00
|
|
|
const uchar *from_elem = src_start + y * row_stride + area.xmin * elem_stride;
|
2021-06-23 17:21:17 +02:00
|
|
|
float *to_elem = &this->get_value(to_x, to_y + y, to_channel_offset);
|
|
|
|
|
const float *row_end = to_elem + width * this->elem_stride;
|
|
|
|
|
while (to_elem < row_end) {
|
|
|
|
|
for (int i = 0; i < elem_size; i++) {
|
2022-09-25 18:33:28 +10:00
|
|
|
to_elem[i] = float(from_elem[i]) * (1.0f / 255.0f);
|
2021-06-23 17:21:17 +02:00
|
|
|
}
|
|
|
|
|
to_elem += this->elem_stride;
|
|
|
|
|
from_elem += elem_stride;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-10 08:57:53 +01:00
|
|
|
void MemoryBuffer::apply_processor(ColormanageProcessor &processor, const rcti area)
|
|
|
|
|
{
|
|
|
|
|
const int width = BLI_rcti_size_x(&area);
|
|
|
|
|
const int height = BLI_rcti_size_y(&area);
|
|
|
|
|
float *out = get_elem(area.xmin, area.ymin);
|
|
|
|
|
/* If area allows continuous memory do conversion in one step. Otherwise per row. */
|
|
|
|
|
if (get_width() == width) {
|
|
|
|
|
IMB_colormanagement_processor_apply(&processor, out, width, height, get_num_channels(), false);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
|
IMB_colormanagement_processor_apply(&processor, out, width, 1, get_num_channels(), false);
|
|
|
|
|
out += row_stride;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
static void colorspace_to_scene_linear(MemoryBuffer *buf, const rcti &area, ColorSpace *colorspace)
|
|
|
|
|
{
|
|
|
|
|
const int width = BLI_rcti_size_x(&area);
|
|
|
|
|
const int height = BLI_rcti_size_y(&area);
|
|
|
|
|
float *out = buf->get_elem(area.xmin, area.ymin);
|
|
|
|
|
/* If area allows continuous memory do conversion in one step. Otherwise per row. */
|
2021-10-13 23:01:15 +02:00
|
|
|
if (buf->get_width() == width) {
|
2021-06-23 17:21:17 +02:00
|
|
|
IMB_colormanagement_colorspace_to_scene_linear(
|
|
|
|
|
out, width, height, buf->get_num_channels(), colorspace, false);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
|
IMB_colormanagement_colorspace_to_scene_linear(
|
|
|
|
|
out, width, 1, buf->get_num_channels(), colorspace, false);
|
|
|
|
|
out += buf->row_stride;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-06 15:15:22 +01:00
|
|
|
static void premultiply_alpha(MemoryBuffer *buf, const rcti &area)
|
2021-06-23 17:21:17 +02:00
|
|
|
{
|
2023-11-06 15:15:22 +01:00
|
|
|
for (int y = area.ymin; y < area.ymax; y++) {
|
|
|
|
|
for (int x = area.xmin; x < area.xmax; x++) {
|
|
|
|
|
straight_to_premul_v4(buf->get_elem(x, y));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_from(const ImBuf *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const bool ensure_premultiplied,
|
|
|
|
|
const bool ensure_linear_space)
|
|
|
|
|
{
|
|
|
|
|
copy_from(src, area, 0, this->get_num_channels(), 0, ensure_premultiplied, ensure_linear_space);
|
2021-06-23 17:21:17 +02:00
|
|
|
}
|
2021-05-10 10:56:07 +02:00
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
void MemoryBuffer::copy_from(const ImBuf *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int to_channel_offset,
|
2023-11-06 15:15:22 +01:00
|
|
|
const bool ensure_premultiplied,
|
2021-06-23 17:21:17 +02:00
|
|
|
const bool ensure_linear_space)
|
|
|
|
|
{
|
|
|
|
|
copy_from(src,
|
|
|
|
|
area,
|
|
|
|
|
channel_offset,
|
|
|
|
|
elem_size,
|
|
|
|
|
area.xmin,
|
|
|
|
|
area.ymin,
|
|
|
|
|
to_channel_offset,
|
2023-11-06 15:15:22 +01:00
|
|
|
ensure_premultiplied,
|
2021-06-23 17:21:17 +02:00
|
|
|
ensure_linear_space);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
void MemoryBuffer::copy_from(const ImBuf *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int to_x,
|
|
|
|
|
const int to_y,
|
|
|
|
|
const int to_channel_offset,
|
2023-11-06 15:15:22 +01:00
|
|
|
const bool ensure_premultiplied,
|
2021-06-23 17:21:17 +02:00
|
|
|
const bool ensure_linear_space)
|
|
|
|
|
{
|
2023-05-18 10:19:01 +02:00
|
|
|
if (src->float_buffer.data) {
|
|
|
|
|
const MemoryBuffer mem_buf(src->float_buffer.data, src->channels, src->x, src->y, false);
|
2021-06-23 17:21:17 +02:00
|
|
|
copy_from(&mem_buf, area, channel_offset, elem_size, to_x, to_y, to_channel_offset);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2023-05-18 10:19:01 +02:00
|
|
|
else if (src->byte_buffer.data) {
|
|
|
|
|
const uchar *uc_buf = src->byte_buffer.data;
|
2021-06-23 17:21:17 +02:00
|
|
|
const int elem_stride = src->channels;
|
2021-08-23 15:30:56 +02:00
|
|
|
const int row_stride = elem_stride * src->x;
|
|
|
|
|
copy_from(uc_buf,
|
|
|
|
|
area,
|
|
|
|
|
channel_offset,
|
|
|
|
|
elem_size,
|
|
|
|
|
elem_stride,
|
|
|
|
|
row_stride,
|
|
|
|
|
to_x,
|
|
|
|
|
to_y,
|
|
|
|
|
to_channel_offset);
|
2021-06-23 17:21:17 +02:00
|
|
|
if (ensure_linear_space) {
|
2023-06-23 15:55:42 +02:00
|
|
|
colorspace_to_scene_linear(this, area, src->byte_buffer.colorspace);
|
2021-06-23 17:21:17 +02:00
|
|
|
}
|
2023-11-06 15:15:22 +01:00
|
|
|
if (ensure_premultiplied) {
|
|
|
|
|
premultiply_alpha(this, area);
|
|
|
|
|
}
|
2021-06-23 17:21:17 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Empty ImBuf source. Fill destination with empty values. */
|
|
|
|
|
const float *zero_elem = new float[elem_size]{0};
|
|
|
|
|
fill(area, to_channel_offset, zero_elem, elem_size);
|
|
|
|
|
delete[] zero_elem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::fill(const rcti &area, const float *value)
|
|
|
|
|
{
|
|
|
|
|
fill(area, 0, value, this->get_num_channels());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::fill(const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const float *value,
|
|
|
|
|
const int value_size)
|
|
|
|
|
{
|
|
|
|
|
const MemoryBuffer single_elem(const_cast<float *>(value), value_size, this->get_rect(), true);
|
|
|
|
|
copy_from(&single_elem, area, 0, value_size, area.xmin, area.ymin, channel_offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::fill_from(const MemoryBuffer &src)
|
|
|
|
|
{
|
|
|
|
|
rcti overlap;
|
2024-01-22 15:58:18 +01:00
|
|
|
overlap.xmin = std::max(rect_.xmin, src.rect_.xmin);
|
|
|
|
|
overlap.xmax = std::min(rect_.xmax, src.rect_.xmax);
|
2023-11-07 16:33:19 +11:00
|
|
|
overlap.ymin = std::max(rect_.ymin, src.rect_.ymin);
|
|
|
|
|
overlap.ymax = std::min(rect_.ymax, src.rect_.ymax);
|
2021-06-23 17:21:17 +02:00
|
|
|
copy_from(&src, overlap);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void MemoryBuffer::write_pixel(int x, int y, const float color[4])
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
|
2021-05-10 10:56:07 +02:00
|
|
|
const int offset = get_coords_offset(x, y);
|
2021-10-13 23:01:04 +02:00
|
|
|
memcpy(&buffer_[offset], color, sizeof(float) * num_channels_);
|
2016-01-18 20:10:18 +11:00
|
|
|
}
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void MemoryBuffer::add_pixel(int x, int y, const float color[4])
|
2012-06-14 03:11:36 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
|
2021-05-10 10:56:07 +02:00
|
|
|
const int offset = get_coords_offset(x, y);
|
2021-10-13 23:01:04 +02:00
|
|
|
float *dst = &buffer_[offset];
|
2015-02-11 18:38:41 +11:00
|
|
|
const float *src = color;
|
2021-10-13 23:01:04 +02:00
|
|
|
for (int i = 0; i < num_channels_; i++, dst++, src++) {
|
2015-02-11 18:38:41 +11:00
|
|
|
*dst += *src;
|
|
|
|
|
}
|
2012-06-14 03:11:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-29 12:30:16 +01:00
|
|
|
static void read_ewa_elem_checked(void *userdata, int x, int y, float result[4])
|
2021-08-23 15:29:34 +02:00
|
|
|
{
|
|
|
|
|
const MemoryBuffer *buffer = static_cast<const MemoryBuffer *>(userdata);
|
|
|
|
|
buffer->read_elem_checked(x, y, result);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-29 12:30:16 +01:00
|
|
|
static void read_ewa_elem_clamped(void *userdata, int x, int y, float result[4])
|
|
|
|
|
{
|
|
|
|
|
const MemoryBuffer *buffer = static_cast<const MemoryBuffer *>(userdata);
|
|
|
|
|
buffer->read_elem_clamped(x, y, result);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:29:34 +02:00
|
|
|
void MemoryBuffer::read_elem_filtered(
|
2024-02-29 12:30:16 +01:00
|
|
|
const float x, const float y, float dx[2], float dy[2], bool extend_boundary, float *out) const
|
2021-08-23 15:29:34 +02:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
BLI_assert(datatype_ == DataType::Color);
|
2021-08-23 15:29:34 +02:00
|
|
|
|
|
|
|
|
const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
|
|
|
|
|
|
2022-09-25 18:33:28 +10:00
|
|
|
float inv_width = 1.0f / float(this->get_width()), inv_height = 1.0f / float(this->get_height());
|
2021-08-23 15:29:34 +02:00
|
|
|
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
|
|
|
|
|
* but compositor uses pixel space. For now let's just divide the values and
|
|
|
|
|
* switch compositor to normalized space for EWA later.
|
|
|
|
|
*/
|
|
|
|
|
float uv_normal[2] = {get_relative_x(x) * inv_width, get_relative_y(y) * inv_height};
|
|
|
|
|
float du_normal[2] = {deriv[0][0] * inv_width, deriv[0][1] * inv_height};
|
|
|
|
|
float dv_normal[2] = {deriv[1][0] * inv_width, deriv[1][1] * inv_height};
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
BLI_ewa_filter(this->get_width(),
|
|
|
|
|
this->get_height(),
|
2021-08-23 15:29:34 +02:00
|
|
|
false,
|
|
|
|
|
true,
|
|
|
|
|
uv_normal,
|
|
|
|
|
du_normal,
|
|
|
|
|
dv_normal,
|
2024-02-29 12:30:16 +01:00
|
|
|
extend_boundary ? read_ewa_elem_clamped : read_ewa_elem_checked,
|
2021-08-23 15:29:34 +02:00
|
|
|
const_cast<MemoryBuffer *>(this),
|
|
|
|
|
out);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 17:21:17 +02:00
|
|
|
void MemoryBuffer::copy_single_elem_from(const MemoryBuffer *src,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int to_channel_offset)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_VALID_ELEM_SIZE(this, to_channel_offset, elem_size);
|
|
|
|
|
ASSERT_VALID_ELEM_SIZE(src, channel_offset, elem_size);
|
|
|
|
|
BLI_assert(this->is_a_single_elem());
|
|
|
|
|
|
|
|
|
|
float *to_elem = &this->get_value(
|
|
|
|
|
this->get_rect().xmin, this->get_rect().ymin, to_channel_offset);
|
|
|
|
|
const float *from_elem = &src->get_value(
|
|
|
|
|
src->get_rect().xmin, src->get_rect().ymin, channel_offset);
|
|
|
|
|
const int elem_bytes = elem_size * sizeof(float);
|
|
|
|
|
memcpy(to_elem, from_elem, elem_bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_rows_from(const MemoryBuffer *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int to_x,
|
|
|
|
|
const int to_y)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_BUFFER_CONTAINS_AREA(src, area);
|
|
|
|
|
ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(this, area, to_x, to_y);
|
|
|
|
|
BLI_assert(this->get_num_channels() == src->get_num_channels());
|
|
|
|
|
BLI_assert(!this->is_a_single_elem());
|
|
|
|
|
BLI_assert(!src->is_a_single_elem());
|
|
|
|
|
|
|
|
|
|
const int width = BLI_rcti_size_x(&area);
|
|
|
|
|
const int height = BLI_rcti_size_y(&area);
|
|
|
|
|
const int row_bytes = this->get_num_channels() * width * sizeof(float);
|
|
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
|
float *to_row = this->get_elem(to_x, to_y + y);
|
|
|
|
|
const float *from_row = src->get_elem(area.xmin, area.ymin + y);
|
|
|
|
|
memcpy(to_row, from_row, row_bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryBuffer::copy_elems_from(const MemoryBuffer *src,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
const int channel_offset,
|
|
|
|
|
const int elem_size,
|
|
|
|
|
const int to_x,
|
|
|
|
|
const int to_y,
|
|
|
|
|
const int to_channel_offset)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_BUFFER_CONTAINS_AREA(src, area);
|
|
|
|
|
ASSERT_BUFFER_CONTAINS_AREA_AT_COORDS(this, area, to_x, to_y);
|
|
|
|
|
ASSERT_VALID_ELEM_SIZE(this, to_channel_offset, elem_size);
|
|
|
|
|
ASSERT_VALID_ELEM_SIZE(src, channel_offset, elem_size);
|
|
|
|
|
|
|
|
|
|
const int width = BLI_rcti_size_x(&area);
|
|
|
|
|
const int height = BLI_rcti_size_y(&area);
|
|
|
|
|
const int elem_bytes = elem_size * sizeof(float);
|
|
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
|
float *to_elem = &this->get_value(to_x, to_y + y, to_channel_offset);
|
|
|
|
|
const float *from_elem = &src->get_value(area.xmin, area.ymin + y, channel_offset);
|
|
|
|
|
const float *row_end = to_elem + width * this->elem_stride;
|
|
|
|
|
while (to_elem < row_end) {
|
|
|
|
|
memcpy(to_elem, from_elem, elem_bytes);
|
|
|
|
|
to_elem += this->elem_stride;
|
|
|
|
|
from_elem += src->elem_stride;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
} // namespace blender::compositor
|