Fix #36124: VSE - Input Color option does not work for video files

Byte images and movies will now fully follow input color space.
Before this non-sRGB input colorspace for byte images and movies
behave really doggy (results in preview and final render were
totally different).

To prevent data loss, if byte image is set not stored in sequencer's
space it'll be internally converted to float buffer.

In theory some setups might be rendering a bit different now, but
new behavior is totally expected and someone used non-sRGB input
space for byte images/movies had Convert Float enabled anyway.
This commit is contained in:
Sergey Sharybin 2013-09-02 13:54:12 +00:00
parent 79759d8368
commit 529c6d0eeb
3 changed files with 47 additions and 17 deletions

@ -417,20 +417,28 @@ void BKE_sequencer_editing_free(Scene *scene)
static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
{
if (ibuf->rect_float) {
IMB_colormanagement_assign_float_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
}
}
void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_float)
{
const char *from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
const char *to_colorspace = scene->sequencer_colorspace_settings.name;
const char *float_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
if (!ibuf->rect_float) {
if (make_float && ibuf->rect) {
if (ibuf->rect) {
const char *byte_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
if (make_float || !STREQ(to_colorspace, byte_colorspace)) {
/* If byte space is not in sequencer's working space, we deliver float color space,
* this is to to prevent data loss.
*/
/* when converting byte buffer to float in sequencer we need to make float
* buffer be in sequencer's working space, which is currently only doable
* from linear space.
*
*/
/*
@ -440,10 +448,10 @@ void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_
IMB_float_from_rect(ibuf);
}
else {
/* if there's only byte buffer in image it's already in compositor's working space,
* nothing to do here
*/
return;
}
}
else {
return;
}
}
@ -452,10 +460,12 @@ void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_
if (ibuf->rect)
imb_freerectImBuf(ibuf);
if (!STREQ(float_colorspace, to_colorspace)) {
IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
from_colorspace, to_colorspace, TRUE);
}
}
}
void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
{
@ -2668,6 +2678,8 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo
seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
seq_rendersize_to_proxysize(context.preview_render_size));
BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE);
/* we don't need both (speed reasons)! */
if (ibuf && ibuf->rect_float && ibuf->rect)
imb_freerectImBuf(ibuf);

@ -62,6 +62,9 @@ void IMB_colormanagement_check_is_data(struct ImBuf *ibuf, const char *name);
void IMB_colormanagement_assign_float_colorspace(struct ImBuf *ibuf, const char *name);
void IMB_colormanagement_assign_rect_colorspace(struct ImBuf *ibuf, const char *name);
const char *IMB_colormanagement_get_float_colorspace(struct ImBuf *ibuf);
const char *IMB_colormanagement_get_rect_colorspace(struct ImBuf *ibuf);
/* ** Color space transformation functions ** */
void IMB_colormanagement_transform(float *buffer, int width, int height, int channels,
const char *from_colorspace, const char *to_colorspace, int predivide);

@ -1134,6 +1134,21 @@ void IMB_colormanagement_assign_rect_colorspace(ImBuf *ibuf, const char *name)
ibuf->colormanage_flag &= ~IMB_COLORMANAGE_IS_DATA;
}
const char *IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
{
if (ibuf->float_colorspace) {
return ibuf->float_colorspace->name;
}
else {
return IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
}
}
const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
{
return ibuf->rect_colorspace->name;
}
/*********************** Threaded display buffer transform routines *************************/
typedef struct DisplayBufferThread {