This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/imbuf/intern/allocimbuf.c

493 lines
10 KiB
C
Raw Normal View History

2003-05-26 05:24:53 +00:00
/*
* ***** BEGIN GPL LICENSE BLOCK *****
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
* 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.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
2002-10-12 11:37:38 +00:00
*/
2011-02-27 20:23:21 +00:00
/** \file blender/imbuf/intern/allocimbuf.c
* \ingroup imbuf
*/
2002-10-12 11:37:38 +00:00
/* It's become a bit messy... Basically, only the IMB_ prefixed files
* should remain. */
#include <stddef.h>
2002-10-12 11:37:38 +00:00
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
2002-10-12 11:37:38 +00:00
#include "IMB_allocimbuf.h"
#include "IMB_filetype.h"
#include "IMB_metadata.h"
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
#include "IMB_colormanagement_intern.h"
2002-10-12 11:37:38 +00:00
#include "imbuf.h"
2002-10-12 11:37:38 +00:00
#include "MEM_guardedalloc.h"
#include "MEM_CacheLimiterC-Api.h"
2002-10-12 11:37:38 +00:00
#include "BLI_utildefines.h"
void imb_freemipmapImBuf(ImBuf *ibuf)
{
int a;
2012-05-13 22:05:51 +00:00
for (a = 1; a < ibuf->miptot; a++) {
if (ibuf->mipmap[a - 1])
IMB_freeImBuf(ibuf->mipmap[a - 1]);
ibuf->mipmap[a - 1] = NULL;
}
2012-05-13 22:05:51 +00:00
ibuf->miptot = 0;
}
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectfloatImBuf(ImBuf *ibuf)
{
2012-05-13 22:05:51 +00:00
if (ibuf == NULL) return;
if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) {
MEM_freeN(ibuf->rect_float);
2012-05-13 22:05:51 +00:00
ibuf->rect_float = NULL;
}
imb_freemipmapImBuf(ibuf);
2012-05-13 22:05:51 +00:00
ibuf->rect_float = NULL;
ibuf->mall &= ~IB_rectfloat;
}
2002-10-12 11:37:38 +00:00
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
2012-05-13 22:05:51 +00:00
if (ibuf == NULL) return;
if (ibuf->rect && (ibuf->mall & IB_rect))
MEM_freeN(ibuf->rect);
2012-05-13 22:05:51 +00:00
ibuf->rect = NULL;
imb_freemipmapImBuf(ibuf);
2002-10-12 11:37:38 +00:00
ibuf->mall &= ~IB_rect;
}
void imb_freetilesImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
int tx, ty;
2012-05-13 22:05:51 +00:00
if (ibuf == NULL) return;
if (ibuf->tiles && (ibuf->mall & IB_tiles)) {
2012-05-13 22:05:51 +00:00
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);
2012-05-13 22:05:51 +00:00
MEM_freeN(ibuf->tiles[ibuf->xtiles * ty + tx]);
}
}
}
MEM_freeN(ibuf->tiles);
2002-10-12 11:37:38 +00:00
}
2012-05-13 22:05:51 +00:00
ibuf->tiles = NULL;
ibuf->mall &= ~IB_tiles;
}
static void freeencodedbufferImBuf(ImBuf *ibuf)
{
2012-05-13 22:05:51 +00:00
if (ibuf == NULL) return;
if (ibuf->encodedbuffer && (ibuf->mall & IB_mem))
MEM_freeN(ibuf->encodedbuffer);
ibuf->encodedbuffer = NULL;
2002-10-12 11:37:38 +00:00
ibuf->encodedbuffersize = 0;
ibuf->encodedsize = 0;
ibuf->mall &= ~IB_mem;
}
void IMB_freezbufImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
2012-05-13 22:05:51 +00:00
if (ibuf == NULL) return;
if (ibuf->zbuf && (ibuf->mall & IB_zbuf))
MEM_freeN(ibuf->zbuf);
2012-05-13 22:05:51 +00:00
ibuf->zbuf = NULL;
2002-10-12 11:37:38 +00:00
ibuf->mall &= ~IB_zbuf;
}
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
{
2012-05-13 22:05:51 +00:00
if (ibuf == NULL) return;
if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat))
MEM_freeN(ibuf->zbuf_float);
2012-05-13 22:05:51 +00:00
ibuf->zbuf_float = NULL;
ibuf->mall &= ~IB_zbuffloat;
}
void IMB_freeImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
if (ibuf) {
if (ibuf->refcounter > 0) {
ibuf->refcounter--;
}
else {
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
imb_freetilesImBuf(ibuf);
IMB_freezbufImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
freeencodedbufferImBuf(ibuf);
IMB_metadata_free(ibuf);
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
colormanage_cache_free(ibuf);
if (ibuf->dds_data.data != NULL) {
free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
}
MEM_freeN(ibuf);
}
2002-10-12 11:37:38 +00:00
}
}
void IMB_refImBuf(ImBuf *ibuf)
{
ibuf->refcounter++;
}
2012-05-13 22:05:51 +00:00
ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
{
2012-05-13 22:05:51 +00:00
ImBuf *rval;
if (!ibuf || ibuf->refcounter == 0) { return ibuf; }
rval = IMB_dupImBuf(ibuf);
IMB_freeImBuf(ibuf);
return rval;
}
bool addzbufImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
size_t size;
if (ibuf == NULL) return false;
2002-10-12 11:37:38 +00:00
IMB_freezbufImBuf(ibuf);
size = (size_t)(ibuf->x * ibuf->y) * sizeof(unsigned int);
if ((ibuf->zbuf = MEM_mapallocN(size, __func__))) {
2002-10-12 11:37:38 +00:00
ibuf->mall |= IB_zbuf;
ibuf->flags |= IB_zbuf;
return true;
2002-10-12 11:37:38 +00:00
}
return false;
}
2002-10-12 11:37:38 +00:00
bool addzbuffloatImBuf(ImBuf *ibuf)
{
size_t size;
if (ibuf == NULL) return false;
IMB_freezbuffloatImBuf(ibuf);
size = (size_t)(ibuf->x * ibuf->y) * sizeof(float);
if ((ibuf->zbuf_float = MEM_mapallocN(size, __func__))) {
ibuf->mall |= IB_zbuffloat;
ibuf->flags |= IB_zbuffloat;
return true;
}
return false;
2002-10-12 11:37:38 +00:00
}
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
if (ibuf == NULL) return false;
2002-10-12 11:37:38 +00:00
freeencodedbufferImBuf(ibuf);
if (ibuf->encodedbuffersize == 0)
2002-10-12 11:37:38 +00:00
ibuf->encodedbuffersize = 10000;
ibuf->encodedsize = 0;
if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, __func__))) {
2002-10-12 11:37:38 +00:00
ibuf->mall |= IB_mem;
ibuf->flags |= IB_mem;
return true;
2002-10-12 11:37:38 +00:00
}
return false;
2002-10-12 11:37:38 +00:00
}
bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
unsigned int newsize, encodedsize;
void *newbuffer;
if (ibuf == NULL) return false;
2002-10-12 11:37:38 +00:00
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
printf("%s: error in parameters\n", __func__);
return false;
2002-10-12 11:37:38 +00:00
}
2012-05-13 22:05:51 +00:00
newsize = 2 * ibuf->encodedbuffersize;
if (newsize < 10000) newsize = 10000;
2002-10-12 11:37:38 +00:00
newbuffer = MEM_mallocN(newsize, __func__);
if (newbuffer == NULL) return false;
2002-10-12 11:37:38 +00:00
if (ibuf->encodedbuffer) {
2002-10-12 11:37:38 +00:00
memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize);
}
else {
2002-10-12 11:37:38 +00:00
ibuf->encodedsize = 0;
}
encodedsize = ibuf->encodedsize;
freeencodedbufferImBuf(ibuf);
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
return true;
2002-10-12 11:37:38 +00:00
}
bool imb_addrectfloatImBuf(ImBuf *ibuf)
{
size_t size;
if (ibuf == NULL) return false;
if (ibuf->rect_float)
2012-05-13 22:05:51 +00:00
imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
size = (size_t)(ibuf->x * ibuf->y) * sizeof(float[4]);
2012-05-13 22:05:51 +00:00
ibuf->channels = 4;
if ((ibuf->rect_float = MEM_mapallocN(size, __func__))) {
ibuf->mall |= IB_rectfloat;
ibuf->flags |= IB_rectfloat;
return true;
}
return false;
}
2002-10-12 11:37:38 +00:00
/* question; why also add zbuf? */
bool imb_addrectImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
size_t size;
2002-10-12 11:37:38 +00:00
if (ibuf == NULL) return false;
/* don't call imb_freerectImBuf, it frees mipmaps, this call is used only too give float buffers display */
if (ibuf->rect && (ibuf->mall & IB_rect))
MEM_freeN(ibuf->rect);
2012-05-13 22:05:51 +00:00
ibuf->rect = NULL;
size = (size_t)(ibuf->x * ibuf->y) * sizeof(unsigned int);
if ((ibuf->rect = MEM_mapallocN(size, __func__))) {
2002-10-12 11:37:38 +00:00
ibuf->mall |= IB_rect;
ibuf->flags |= IB_rect;
if (ibuf->planes > 32) {
return (addzbufImBuf(ibuf));
}
else {
return true;
}
2002-10-12 11:37:38 +00:00
}
return false;
2002-10-12 11:37:38 +00:00
}
bool imb_addtilesImBuf(ImBuf *ibuf)
2002-10-12 11:37:38 +00:00
{
if (ibuf == NULL) return false;
2002-10-12 11:37:38 +00:00
if (!ibuf->tiles)
2012-05-13 22:05:51 +00:00
if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles, "imb_tiles")))
ibuf->mall |= IB_tiles;
2002-10-12 11:37:38 +00:00
return (ibuf->tiles != NULL);
2002-10-12 11:37:38 +00:00
}
ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags)
2002-10-12 11:37:38 +00:00
{
ImBuf *ibuf;
2002-10-12 11:37:38 +00:00
ibuf = MEM_callocN(sizeof(ImBuf), "ImBuf_struct");
2002-10-12 11:37:38 +00:00
if (ibuf) {
2012-05-13 22:05:51 +00:00
ibuf->x = x;
ibuf->y = y;
ibuf->planes = planes;
ibuf->ftype = PNG | 15; /* the 15 means, set compression to low ratio but not time consuming */
2012-05-13 22:05:51 +00:00
ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */
ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254f; /* IMB_DPI_DEFAULT -> pixels-per-meter */
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
if (flags & IB_rect) {
if (imb_addrectImBuf(ibuf) == false) {
2002-10-12 11:37:38 +00:00
IMB_freeImBuf(ibuf);
return NULL;
}
}
if (flags & IB_rectfloat) {
if (imb_addrectfloatImBuf(ibuf) == false) {
IMB_freeImBuf(ibuf);
return NULL;
2002-10-12 11:37:38 +00:00
}
}
if (flags & IB_zbuf) {
if (addzbufImBuf(ibuf) == false) {
2002-10-12 11:37:38 +00:00
IMB_freeImBuf(ibuf);
return NULL;
2002-10-12 11:37:38 +00:00
}
}
if (flags & IB_zbuffloat) {
if (addzbuffloatImBuf(ibuf) == false) {
2002-10-12 11:37:38 +00:00
IMB_freeImBuf(ibuf);
return NULL;
2002-10-12 11:37:38 +00:00
}
}
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
/* assign default spaces */
colormanage_imbuf_set_default_spaces(ibuf);
2002-10-12 11:37:38 +00:00
}
return (ibuf);
}
/* does no zbuffers? */
ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
2002-10-12 11:37:38 +00:00
{
ImBuf *ibuf2, tbuf;
2002-10-12 11:37:38 +00:00
int flags = 0;
int a, x, y;
2002-10-12 11:37:38 +00:00
if (ibuf1 == NULL) return NULL;
2002-10-12 11:37:38 +00:00
if (ibuf1->rect) flags |= IB_rect;
if (ibuf1->rect_float) flags |= IB_rectfloat;
2002-10-12 11:37:38 +00:00
x = ibuf1->x;
y = ibuf1->y;
if (ibuf1->flags & IB_fields) y *= 2;
2002-10-12 11:37:38 +00:00
ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags);
if (ibuf2 == NULL) return NULL;
2002-10-12 11:37:38 +00:00
if (flags & IB_rect)
2012-05-13 22:05:51 +00:00
memcpy(ibuf2->rect, ibuf1->rect, x * y * sizeof(int));
if (flags & IB_rectfloat)
2012-05-13 22:05:51 +00:00
memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels * x * y * sizeof(float));
if (ibuf1->encodedbuffer) {
2002-10-12 11:37:38 +00:00
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
if (imb_addencodedbufferImBuf(ibuf2) == false) {
2002-10-12 11:37:38 +00:00
IMB_freeImBuf(ibuf2);
return NULL;
2002-10-12 11:37:38 +00:00
}
memcpy(ibuf2->encodedbuffer, ibuf1->encodedbuffer, ibuf1->encodedsize);
}
/* silly trick to copy the entire contents of ibuf1 struct over to ibuf */
2002-10-12 11:37:38 +00:00
tbuf = *ibuf1;
2012-07-07 22:51:57 +00:00
/* fix pointers */
2012-05-13 22:05:51 +00:00
tbuf.rect = ibuf2->rect;
tbuf.rect_float = ibuf2->rect_float;
2002-10-12 11:37:38 +00:00
tbuf.encodedbuffer = ibuf2->encodedbuffer;
2012-05-13 22:05:51 +00:00
tbuf.zbuf = NULL;
tbuf.zbuf_float = NULL;
for (a = 0; a < IB_MIPMAP_LEVELS; a++)
tbuf.mipmap[a] = NULL;
tbuf.dds_data.data = NULL;
2002-10-12 11:37:38 +00:00
2012-07-07 22:51:57 +00:00
/* set malloc flag */
2012-05-13 22:05:51 +00:00
tbuf.mall = ibuf2->mall;
tbuf.c_handle = NULL;
tbuf.refcounter = 0;
2012-07-07 22:51:57 +00:00
/* for now don't duplicate metadata */
tbuf.metadata = NULL;
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
tbuf.display_buffer_flags = NULL;
tbuf.colormanage_cache = NULL;
2002-10-12 11:37:38 +00:00
*ibuf2 = tbuf;
Color Management, Stage 2: Switch color pipeline to use OpenColorIO Replace old color pipeline which was supporting linear/sRGB color spaces only with OpenColorIO-based pipeline. This introduces two configurable color spaces: - Input color space for images and movie clips. This space is used to convert images/movies from color space in which file is saved to Blender's linear space (for float images, byte images are not internally converted, only input space is stored for such images and used later). This setting could be found in image/clip data block settings. - Display color space which defines space in which particular display is working. This settings could be found in scene's Color Management panel. When render result is being displayed on the screen, apart from converting image to display space, some additional conversions could happen. This conversions are: - View, which defines tone curve applying before display transformation. These are different ways to view the image on the same display device. For example it could be used to emulate film view on sRGB display. - Exposure affects on image exposure before tone map is applied. - Gamma is post-display gamma correction, could be used to match particular display gamma. - RGB curves are user-defined curves which are applying before display transformation, could be used for different purposes. All this settings by default are only applying on render result and does not affect on other images. If some particular image needs to be affected by this transformation, "View as Render" setting of image data block should be set to truth. Movie clips are always affected by all display transformations. This commit also introduces configurable color space in which sequencer is working. This setting could be found in scene's Color Management panel and it should be used if such stuff as grading needs to be done in color space different from sRGB (i.e. when Film view on sRGB display is use, using VD16 space as sequencer's internal space would make grading working in space which is close to the space using for display). Some technical notes: - Image buffer's float buffer is now always in linear space, even if it was created from 16bit byte images. - Space of byte buffer is stored in image buffer's rect_colorspace property. - Profile of image buffer was removed since it's not longer meaningful. - OpenGL and GLSL is supposed to always work in sRGB space. It is possible to support other spaces, but it's quite large project which isn't so much important. - Legacy Color Management option disabled is emulated by using None display. It could have some regressions, but there's no clear way to avoid them. - If OpenColorIO is disabled on build time, it should make blender behaving in the same way as previous release with color management enabled. More details could be found at this page (more details would be added soon): http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management -- Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO integration and to Brecht van Lommel for some further development and code/ usecase review!
2012-09-15 10:05:07 +00:00
2002-10-12 11:37:38 +00:00
return(ibuf2);
}
#if 0 /* remove? - campbell */
/* support for cache limiting */
static void imbuf_cache_destructor(void *data)
{
2012-05-13 22:05:51 +00:00
ImBuf *ibuf = (ImBuf *) data;
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbufImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
freeencodedbufferImBuf(ibuf);
ibuf->c_handle = NULL;
}
static MEM_CacheLimiterC **get_imbuf_cache_limiter(void)
{
static MEM_CacheLimiterC *c = NULL;
if (!c)
c = new_MEM_CacheLimiter(imbuf_cache_destructor, NULL);
return &c;
}
#endif