Cleanup: remove redundant float to byte conversion for stereo image saving

For non-stereo cases this is automatically handled by IMB_saveiff, no reason for
stereo to do this separately.

Ref D14899
This commit is contained in:
Brecht Van Lommel 2022-05-12 22:46:15 +02:00
parent c0df1cd1b3
commit 906b9f55af
Notes: blender-bot 2023-02-14 06:00:46 +01:00
Referenced by issue #98108, The alembic exporter does not export edges
5 changed files with 10 additions and 48 deletions

View File

@ -504,7 +504,6 @@ static bool image_save_single(ReportList *reports,
colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, true, imf);
BKE_image_format_to_imbuf(colormanaged_ibuf, imf);
IMB_prepare_write_ImBuf(IMB_isfloat(colormanaged_ibuf), colormanaged_ibuf);
/* duplicate buffer to prevent locker issue when using render result */
ibuf_stereo[i] = IMB_dupImBuf(colormanaged_ibuf);
@ -924,7 +923,6 @@ bool BKE_image_render_write(ReportList *reports,
int view_id = BLI_findstringindex(&rr->views, names[i], offsetof(RenderView, name));
ibuf_arr[i] = RE_render_result_rect_to_ibuf(rr, &image_format, dither, view_id);
IMB_colormanagement_imbuf_for_write(ibuf_arr[i], true, false, &image_format);
IMB_prepare_write_ImBuf(IMB_isfloat(ibuf_arr[i]), ibuf_arr[i]);
}
ibuf_arr[2] = IMB_stereo3d_ImBuf(&image_format, ibuf_arr[0], ibuf_arr[1]);

View File

@ -325,7 +325,6 @@ void OutputStereoOperation::deinit_execution()
/* do colormanagement in the individual views, so it doesn't need to do in the stereo */
IMB_colormanagement_imbuf_for_write(ibuf[i], true, false, &format_);
IMB_prepare_write_ImBuf(IMB_isfloat(ibuf[i]), ibuf[i]);
}
/* create stereo buffer */

View File

@ -530,7 +530,6 @@ void IMB_scaleImBuf_threaded(struct ImBuf *ibuf, unsigned int newx, unsigned int
* \attention Defined in writeimage.c
*/
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
bool IMB_prepare_write_ImBuf(bool isfloat, struct ImBuf *ibuf);
/**
*
@ -553,12 +552,6 @@ bool IMB_isanim(const char *filepath);
*/
int imb_get_anim_type(const char *filepath);
/**
*
* \attention Defined in util.c
*/
bool IMB_isfloat(const struct ImBuf *ibuf);
/**
* Test if color-space conversions of pixels in buffer need to take into account alpha.
*/

View File

@ -390,14 +390,3 @@ bool IMB_isanim(const char *filepath)
return (type && type != ANIM_SEQUENCE);
}
bool IMB_isfloat(const ImBuf *ibuf)
{
const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
if (type != NULL) {
if (type->flag & IM_FTYPE_FLOAT) {
return true;
}
}
return false;
}

View File

@ -19,11 +19,6 @@
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"
static bool prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf)
{
return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf);
}
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
{
errno = 0;
@ -36,34 +31,22 @@ bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
ibuf->flags = flags;
const ImFileType *type = IMB_file_type_from_ibuf(ibuf);
if (type != NULL) {
if (type->save != NULL) {
prepare_write_imbuf(type, ibuf);
return type->save(ibuf, filepath, flags);
}
if (type == NULL || type->save == NULL) {
fprintf(stderr, "Couldn't save picture.\n");
return false;
}
fprintf(stderr, "Couldn't save picture.\n");
return false;
}
bool IMB_prepare_write_ImBuf(const bool isfloat, ImBuf *ibuf)
{
bool changed = false;
if (isfloat) {
/* pass */
}
else {
/* If writing byte image from float buffer, create a byte buffer for writing.
*
* For color managed image writing, IMB_colormanagement_imbuf_for_write should
* have already created this byte buffer. This is a basic fallback for other
* cases where we do not have a specific desired output colorspace. */
if (!(type->flag & IM_FTYPE_FLOAT)) {
if (ibuf->rect == NULL && ibuf->rect_float) {
ibuf->rect_colorspace = colormanage_colorspace_get_roled(COLOR_ROLE_DEFAULT_BYTE);
IMB_rect_from_float(ibuf);
if (ibuf->rect != NULL) {
changed = true;
}
}
}
return changed;
return type->save(ibuf, filepath, flags);
}