2003-05-26 05:24:53 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup imbuf
|
2011-02-27 20:23:21 +00:00
|
|
|
*/
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* It's become a bit messy... Basically, only the IMB_ prefixed files
|
|
|
|
|
* should remain. */
|
|
|
|
|
|
2010-09-15 06:43:36 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "IMB_imbuf.h"
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "IMB_allocimbuf.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_colormanagement_intern.h"
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
#include "IMB_filetype.h"
|
|
|
|
|
#include "IMB_metadata.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
#include "imbuf.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-08-16 05:46:10 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-04-01 13:14:37 +06:00
|
|
|
#include "BLI_threads.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2014-04-01 13:14:37 +06:00
|
|
|
|
|
|
|
|
static SpinLock refcounter_spin;
|
|
|
|
|
|
|
|
|
|
void imb_refcounter_lock_init(void)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_init(&refcounter_spin);
|
2014-04-01 13:14:37 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void imb_refcounter_lock_exit(void)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_end(&refcounter_spin);
|
2014-04-01 13:14:37 +06:00
|
|
|
}
|
2013-09-10 05:57:54 +00:00
|
|
|
|
2015-09-29 19:54:25 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
|
static SpinLock mmap_spin;
|
|
|
|
|
|
|
|
|
|
void imb_mmap_lock_init(void)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_init(&mmap_spin);
|
2015-09-29 19:54:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void imb_mmap_lock_exit(void)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_end(&mmap_spin);
|
2015-09-29 19:54:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void imb_mmap_lock(void)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_lock(&mmap_spin);
|
2015-09-29 19:54:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void imb_mmap_unlock(void)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_unlock(&mmap_spin);
|
2015-09-29 19:54:25 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void imb_freemipmapImBuf(ImBuf *ibuf)
|
2006-12-20 17:57:56 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* Do not trust ibuf->miptot, in some cases IMB_remakemipmap can leave unfreed unused levels,
|
|
|
|
|
* leading to memory leaks... */
|
|
|
|
|
for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
|
|
|
|
|
if (ibuf->mipmap[a] != NULL) {
|
|
|
|
|
IMB_freeImBuf(ibuf->mipmap[a]);
|
|
|
|
|
ibuf->mipmap[a] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ibuf->miptot = 0;
|
2006-12-20 17:57:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* any free rect frees mipmaps to be sure, creation is in render on first request */
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void imb_freerectfloatImBuf(ImBuf *ibuf)
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) {
|
|
|
|
|
MEM_freeN(ibuf->rect_float);
|
|
|
|
|
ibuf->rect_float = NULL;
|
|
|
|
|
}
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
imb_freemipmapImBuf(ibuf);
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->rect_float = NULL;
|
|
|
|
|
ibuf->mall &= ~IB_rectfloat;
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* any free rect frees mipmaps to be sure, creation is in render on first request */
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void imb_freerectImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2011-05-13 04:53:20 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->rect && (ibuf->mall & IB_rect)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(ibuf->rect);
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->rect = NULL;
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
imb_freemipmapImBuf(ibuf);
|
2011-05-13 04:53:20 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->mall &= ~IB_rect;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void imb_freetilesImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int tx, ty;
|
|
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (ibuf->tiles && (ibuf->mall & IB_tiles)) {
|
|
|
|
|
for (ty = 0; ty < ibuf->ytiles; ty++) {
|
|
|
|
|
for (tx = 0; tx < ibuf->xtiles; tx++) {
|
|
|
|
|
if (ibuf->tiles[ibuf->xtiles * ty + tx]) {
|
|
|
|
|
imb_tile_cache_tile_free(ibuf, tx, ty);
|
|
|
|
|
MEM_freeN(ibuf->tiles[ibuf->xtiles * ty + tx]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(ibuf->tiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ibuf->tiles = NULL;
|
|
|
|
|
ibuf->mall &= ~IB_tiles;
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void freeencodedbufferImBuf(ImBuf *ibuf)
|
|
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->encodedbuffer && (ibuf->mall & IB_mem)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(ibuf->encodedbuffer);
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->encodedbuffer = NULL;
|
|
|
|
|
ibuf->encodedbuffersize = 0;
|
|
|
|
|
ibuf->encodedsize = 0;
|
|
|
|
|
ibuf->mall &= ~IB_mem;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void IMB_freezbufImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->zbuf && (ibuf->mall & IB_zbuf)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(ibuf->zbuf);
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->zbuf = NULL;
|
|
|
|
|
ibuf->mall &= ~IB_zbuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
|
2006-01-11 22:36:31 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(ibuf->zbuf_float);
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->zbuf_float = NULL;
|
|
|
|
|
ibuf->mall &= ~IB_zbuffloat;
|
2006-01-11 22:36:31 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-15 11:47:11 +11:00
|
|
|
/** Free all pixel data (assosiated with image size). */
|
|
|
|
|
void imb_freerectImbuf_all(ImBuf *ibuf)
|
|
|
|
|
{
|
|
|
|
|
imb_freerectImBuf(ibuf);
|
|
|
|
|
imb_freerectfloatImBuf(ibuf);
|
|
|
|
|
imb_freetilesImBuf(ibuf);
|
|
|
|
|
IMB_freezbufImBuf(ibuf);
|
|
|
|
|
IMB_freezbuffloatImBuf(ibuf);
|
|
|
|
|
freeencodedbufferImBuf(ibuf);
|
|
|
|
|
}
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void IMB_freeImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
|
bool needs_free = false;
|
|
|
|
|
|
|
|
|
|
BLI_spin_lock(&refcounter_spin);
|
|
|
|
|
if (ibuf->refcounter > 0) {
|
|
|
|
|
ibuf->refcounter--;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
needs_free = true;
|
|
|
|
|
}
|
|
|
|
|
BLI_spin_unlock(&refcounter_spin);
|
|
|
|
|
|
|
|
|
|
if (needs_free) {
|
2019-10-15 11:47:11 +11:00
|
|
|
imb_freerectImbuf_all(ibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_metadata_free(ibuf->metadata);
|
|
|
|
|
colormanage_cache_free(ibuf);
|
|
|
|
|
|
|
|
|
|
if (ibuf->dds_data.data != NULL) {
|
2019-04-22 01:18:55 +10:00
|
|
|
/* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
|
|
|
|
|
free(ibuf->dds_data.data);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
MEM_freeN(ibuf);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
void IMB_refImBuf(ImBuf *ibuf)
|
2006-02-05 19:23:34 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_spin_lock(&refcounter_spin);
|
|
|
|
|
ibuf->refcounter++;
|
|
|
|
|
BLI_spin_unlock(&refcounter_spin);
|
2006-02-05 19:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-13 22:05:51 +00:00
|
|
|
ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *rval;
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
|
bool is_single;
|
|
|
|
|
BLI_spin_lock(&refcounter_spin);
|
|
|
|
|
is_single = (ibuf->refcounter == 0);
|
|
|
|
|
BLI_spin_unlock(&refcounter_spin);
|
|
|
|
|
if (is_single) {
|
|
|
|
|
return ibuf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
rval = IMB_dupImBuf(ibuf);
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_metadata_copy(rval, ibuf);
|
2015-05-04 12:52:58 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_freeImBuf(ibuf);
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return rval;
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 01:00:03 +00:00
|
|
|
bool addzbufImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_freezbufImBuf(ibuf);
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((ibuf->zbuf = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(unsigned int), __func__))) {
|
|
|
|
|
ibuf->mall |= IB_zbuf;
|
|
|
|
|
ibuf->flags |= IB_zbuf;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2006-01-11 22:36:31 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-09-10 01:00:03 +00:00
|
|
|
bool addzbuffloatImBuf(ImBuf *ibuf)
|
2006-01-11 22:36:31 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
IMB_freezbuffloatImBuf(ibuf);
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((ibuf->zbuf_float = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(float), __func__))) {
|
|
|
|
|
ibuf->mall |= IB_zbuffloat;
|
|
|
|
|
ibuf->flags |= IB_zbuffloat;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 01:00:03 +00:00
|
|
|
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
freeencodedbufferImBuf(ibuf);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->encodedbuffersize == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->encodedbuffersize = 10000;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->encodedsize = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, __func__))) {
|
|
|
|
|
ibuf->mall |= IB_mem;
|
|
|
|
|
ibuf->flags |= IB_mem;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 01:00:03 +00:00
|
|
|
bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
unsigned int newsize, encodedsize;
|
|
|
|
|
void *newbuffer;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
|
|
|
|
|
printf("%s: error in parameters\n", __func__);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
newsize = 2 * ibuf->encodedbuffersize;
|
2019-04-22 12:20:14 +10:00
|
|
|
if (newsize < 10000) {
|
2019-04-17 06:17:24 +02:00
|
|
|
newsize = 10000;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
newbuffer = MEM_mallocN(newsize, __func__);
|
2019-04-22 12:20:14 +10:00
|
|
|
if (newbuffer == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf->encodedbuffer) {
|
|
|
|
|
memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ibuf->encodedsize = 0;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
encodedsize = ibuf->encodedsize;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
freeencodedbufferImBuf(ibuf);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->encodedbuffersize = newsize;
|
|
|
|
|
ibuf->encodedsize = encodedsize;
|
|
|
|
|
ibuf->encodedbuffer = newbuffer;
|
|
|
|
|
ibuf->mall |= IB_mem;
|
|
|
|
|
ibuf->flags |= IB_mem;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void *imb_alloc_pixels(
|
|
|
|
|
unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name)
|
2018-01-14 14:19:57 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Protect against buffer overflow vulnerabilities from files specifying
|
|
|
|
|
* a width and height that overflow and alloc too little memory. */
|
|
|
|
|
if (!((uint64_t)x * (uint64_t)y < (SIZE_MAX / (channels * typesize)))) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t size = (size_t)x * (size_t)y * (size_t)channels * typesize;
|
2020-05-20 00:24:26 +02:00
|
|
|
return MEM_callocN(size, name);
|
2018-01-14 14:19:57 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 01:00:03 +00:00
|
|
|
bool imb_addrectfloatImBuf(ImBuf *ibuf)
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->rect_float) {
|
2019-04-17 06:17:24 +02:00
|
|
|
imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->channels = 4;
|
|
|
|
|
if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(float), __func__))) {
|
|
|
|
|
ibuf->mall |= IB_rectfloat;
|
|
|
|
|
ibuf->flags |= IB_rectfloat;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-06-17 17:04:54 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Orange branch: OpenEXR finally in Blender!
Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.
At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/
Several changes/additions/fixes were added:
- EXR code only supported 'half' format (16 bits per channel). I've added
float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong
Imbuf:
- added proper imbuf->flags and imbuf->mall support for float buffers, it
was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
rect exists (for saving for example)
TODO:
- support internal float images for textures, backbuf, AO probes, and
display in Image window
Hope this commit won't screwup syncing with bf-blender... :/
2006-01-09 00:40:35 +00:00
|
|
|
/* question; why also add zbuf? */
|
2013-09-10 01:00:03 +00:00
|
|
|
bool imb_addrectImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 01:18:55 +10:00
|
|
|
/* Don't call imb_freerectImBuf, it frees mipmaps,
|
|
|
|
|
* this call is used only too give float buffers display. */
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf->rect && (ibuf->mall & IB_rect)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_freeN(ibuf->rect);
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->rect = NULL;
|
|
|
|
|
|
|
|
|
|
if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(unsigned char), __func__))) {
|
|
|
|
|
ibuf->mall |= IB_rect;
|
|
|
|
|
ibuf->flags |= IB_rect;
|
|
|
|
|
if (ibuf->planes > 32) {
|
|
|
|
|
return (addzbufImBuf(ibuf));
|
|
|
|
|
}
|
2020-08-07 12:39:50 +02:00
|
|
|
|
|
|
|
|
return true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
|
|
|
|
|
const float *rectf,
|
|
|
|
|
unsigned int w,
|
2019-08-27 08:42:50 +02:00
|
|
|
unsigned int h,
|
|
|
|
|
unsigned int channels)
|
2015-02-23 17:19:06 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf = NULL;
|
2015-02-23 17:19:06 +01:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (!(rect || rectf)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2015-02-23 17:19:06 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = IMB_allocImBuf(w, h, 32, 0);
|
2015-02-23 17:19:06 +01:00
|
|
|
|
2019-08-27 08:42:50 +02:00
|
|
|
ibuf->channels = channels;
|
2019-04-17 06:17:24 +02:00
|
|
|
if (rectf) {
|
|
|
|
|
ibuf->rect_float = MEM_dupallocN(rectf);
|
|
|
|
|
ibuf->flags |= IB_rectfloat;
|
|
|
|
|
ibuf->mall |= IB_rectfloat;
|
|
|
|
|
}
|
|
|
|
|
if (rect) {
|
|
|
|
|
ibuf->rect = MEM_dupallocN(rect);
|
|
|
|
|
ibuf->flags |= IB_rect;
|
|
|
|
|
ibuf->mall |= IB_rect;
|
|
|
|
|
}
|
2015-02-23 17:19:06 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return ibuf;
|
2015-02-23 17:19:06 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 01:00:03 +00:00
|
|
|
bool imb_addtilesImBuf(ImBuf *ibuf)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (!ibuf->tiles) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles,
|
2019-04-22 12:20:14 +10:00
|
|
|
"imb_tiles"))) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->mall |= IB_tiles;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (ibuf->tiles != NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-21 20:47:19 +00:00
|
|
|
ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf = MEM_mallocN(sizeof(ImBuf), "ImBuf_struct");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ibuf) {
|
|
|
|
|
if (!IMB_initImBuf(ibuf, x, y, planes, flags)) {
|
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-06 11:48:07 +02:00
|
|
|
|
2020-08-08 11:02:11 +10:00
|
|
|
return ibuf;
|
2016-05-06 11:48:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
bool IMB_initImBuf(
|
|
|
|
|
struct ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
|
2016-05-06 11:48:07 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
memset(ibuf, 0, sizeof(ImBuf));
|
|
|
|
|
|
|
|
|
|
ibuf->x = x;
|
|
|
|
|
ibuf->y = y;
|
|
|
|
|
ibuf->planes = planes;
|
|
|
|
|
ibuf->ftype = IMB_FTYPE_PNG;
|
2019-07-02 22:17:22 +10:00
|
|
|
/* The '15' means, set compression to low ratio but not time consuming. */
|
|
|
|
|
ibuf->foptions.quality = 15;
|
|
|
|
|
/* float option, is set to other values when buffers get assigned. */
|
|
|
|
|
ibuf->channels = 4;
|
|
|
|
|
/* IMB_DPI_DEFAULT -> pixels-per-meter. */
|
|
|
|
|
ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (flags & IB_rect) {
|
|
|
|
|
if (imb_addrectImBuf(ibuf) == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & IB_rectfloat) {
|
|
|
|
|
if (imb_addrectfloatImBuf(ibuf) == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & IB_zbuf) {
|
|
|
|
|
if (addzbufImBuf(ibuf) == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & IB_zbuffloat) {
|
|
|
|
|
if (addzbuffloatImBuf(ibuf) == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* assign default spaces */
|
|
|
|
|
colormanage_imbuf_set_default_spaces(ibuf);
|
|
|
|
|
|
|
|
|
|
return true;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 22:36:31 +00:00
|
|
|
/* does no zbuffers? */
|
2017-06-14 22:36:30 +02:00
|
|
|
ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImBuf *ibuf2, tbuf;
|
|
|
|
|
int flags = 0;
|
|
|
|
|
int a, x, y;
|
|
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf1 == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf1->rect) {
|
2019-04-17 06:17:24 +02:00
|
|
|
flags |= IB_rect;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
|
|
|
|
if (ibuf1->rect_float) {
|
2019-04-17 06:17:24 +02:00
|
|
|
flags |= IB_rectfloat;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
|
|
|
|
if (ibuf1->zbuf) {
|
2019-04-17 06:17:24 +02:00
|
|
|
flags |= IB_zbuf;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
|
|
|
|
if (ibuf1->zbuf_float) {
|
2019-04-17 06:17:24 +02:00
|
|
|
flags |= IB_zbuffloat;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
x = ibuf1->x;
|
|
|
|
|
y = ibuf1->y;
|
|
|
|
|
|
|
|
|
|
ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags);
|
2019-04-22 12:20:14 +10:00
|
|
|
if (ibuf2 == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (flags & IB_rect) {
|
2019-04-17 06:17:24 +02:00
|
|
|
memcpy(ibuf2->rect, ibuf1->rect, ((size_t)x) * y * sizeof(int));
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (flags & IB_rectfloat) {
|
2019-04-17 06:17:24 +02:00
|
|
|
memcpy(
|
|
|
|
|
ibuf2->rect_float, ibuf1->rect_float, ((size_t)ibuf1->channels) * x * y * sizeof(float));
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (flags & IB_zbuf) {
|
2019-04-17 06:17:24 +02:00
|
|
|
memcpy(ibuf2->zbuf, ibuf1->zbuf, ((size_t)x) * y * sizeof(int));
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (flags & IB_zbuffloat) {
|
2019-04-17 06:17:24 +02:00
|
|
|
memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, ((size_t)x) * y * sizeof(float));
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (ibuf1->encodedbuffer) {
|
|
|
|
|
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
|
|
|
|
|
if (imb_addencodedbufferImBuf(ibuf2) == false) {
|
|
|
|
|
IMB_freeImBuf(ibuf2);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy(ibuf2->encodedbuffer, ibuf1->encodedbuffer, ibuf1->encodedsize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* silly trick to copy the entire contents of ibuf1 struct over to ibuf */
|
|
|
|
|
tbuf = *ibuf1;
|
|
|
|
|
|
|
|
|
|
/* fix pointers */
|
|
|
|
|
tbuf.rect = ibuf2->rect;
|
|
|
|
|
tbuf.rect_float = ibuf2->rect_float;
|
|
|
|
|
tbuf.encodedbuffer = ibuf2->encodedbuffer;
|
|
|
|
|
tbuf.zbuf = ibuf2->zbuf;
|
|
|
|
|
tbuf.zbuf_float = ibuf2->zbuf_float;
|
2019-04-23 11:01:30 +10:00
|
|
|
for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
|
2019-04-17 06:17:24 +02:00
|
|
|
tbuf.mipmap[a] = NULL;
|
2019-04-23 11:01:30 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
tbuf.dds_data.data = NULL;
|
|
|
|
|
|
|
|
|
|
/* set malloc flag */
|
|
|
|
|
tbuf.mall = ibuf2->mall;
|
|
|
|
|
tbuf.c_handle = NULL;
|
|
|
|
|
tbuf.refcounter = 0;
|
|
|
|
|
|
|
|
|
|
/* for now don't duplicate metadata */
|
|
|
|
|
tbuf.metadata = NULL;
|
|
|
|
|
|
|
|
|
|
tbuf.display_buffer_flags = NULL;
|
|
|
|
|
tbuf.colormanage_cache = NULL;
|
|
|
|
|
|
|
|
|
|
*ibuf2 = tbuf;
|
|
|
|
|
|
2020-08-08 11:02:11 +10:00
|
|
|
return ibuf2;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2019-04-28 14:13:41 -07:00
|
|
|
size_t IMB_get_size_in_memory(ImBuf *ibuf)
|
|
|
|
|
{
|
|
|
|
|
int a;
|
|
|
|
|
size_t size = 0, channel_size = 0;
|
|
|
|
|
|
|
|
|
|
size += sizeof(ImBuf);
|
|
|
|
|
|
2019-05-31 22:51:19 +10:00
|
|
|
if (ibuf->rect) {
|
2019-04-28 14:13:41 -07:00
|
|
|
channel_size += sizeof(char);
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2019-04-28 14:13:41 -07:00
|
|
|
|
2019-05-31 22:51:19 +10:00
|
|
|
if (ibuf->rect_float) {
|
2019-04-28 14:13:41 -07:00
|
|
|
channel_size += sizeof(float);
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2019-04-28 14:13:41 -07:00
|
|
|
|
|
|
|
|
size += channel_size * ibuf->x * ibuf->y * ibuf->channels;
|
|
|
|
|
|
|
|
|
|
if (ibuf->miptot) {
|
|
|
|
|
for (a = 0; a < ibuf->miptot; a++) {
|
2019-05-31 22:51:19 +10:00
|
|
|
if (ibuf->mipmap[a]) {
|
2019-04-28 14:13:41 -07:00
|
|
|
size += IMB_get_size_in_memory(ibuf->mipmap[a]);
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2019-04-28 14:13:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ibuf->tiles) {
|
|
|
|
|
size += sizeof(unsigned int) * ibuf->ytiles * ibuf->xtiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-27 04:24:34 +00:00
|
|
|
#if 0 /* remove? - campbell */
|
2006-02-05 19:23:34 +00:00
|
|
|
/* support for cache limiting */
|
|
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
static void imbuf_cache_destructor(void *data)
|
2006-02-05 19:23:34 +00:00
|
|
|
{
|
2019-04-17 08:24:14 +02:00
|
|
|
ImBuf *ibuf = (ImBuf *)data;
|
2006-02-05 19:23:34 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
imb_freerectImBuf(ibuf);
|
|
|
|
|
imb_freerectfloatImBuf(ibuf);
|
|
|
|
|
IMB_freezbufImBuf(ibuf);
|
|
|
|
|
IMB_freezbuffloatImBuf(ibuf);
|
|
|
|
|
freeencodedbufferImBuf(ibuf);
|
2006-02-28 13:07:02 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ibuf->c_handle = NULL;
|
2006-02-05 19:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
static MEM_CacheLimiterC **get_imbuf_cache_limiter(void)
|
2006-02-05 19:23:34 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
static MEM_CacheLimiterC *c = NULL;
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-22 12:20:14 +10:00
|
|
|
if (!c) {
|
2019-04-17 06:17:24 +02:00
|
|
|
c = new_MEM_CacheLimiter(imbuf_cache_destructor, NULL);
|
2019-04-22 12:20:14 +10:00
|
|
|
}
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return &c;
|
2006-02-05 19:23:34 +00:00
|
|
|
}
|
2011-10-27 04:24:34 +00:00
|
|
|
#endif
|