[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59734] trunk/blender/source/blender: Fix #36124: VSE - Input Color option does not work for video files

Sergey Sharybin sergey.vfx at gmail.com
Mon Sep 2 15:54:12 CEST 2013


Revision: 59734
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59734
Author:   nazgul
Date:     2013-09-02 13:54:12 +0000 (Mon, 02 Sep 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/sequencer.c
    trunk/blender/source/blender/imbuf/IMB_colormanagement.h
    trunk/blender/source/blender/imbuf/intern/colormanagement.c

Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c	2013-09-02 13:45:57 UTC (rev 59733)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c	2013-09-02 13:54:12 UTC (rev 59734)
@@ -417,33 +417,41 @@
 
 static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
 {
-	IMB_colormanagement_assign_float_colorspace(ibuf, scene->sequencer_colorspace_settings.name);
+	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) {
-			/* 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.
-			 *
-			 */
+		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.
+				 */
 
-			/*
-			 * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's
-			 */
+				/* 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.
+				 */
 
-			IMB_float_from_rect(ibuf);
+				/*
+				 * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's
+				 */
+
+				IMB_float_from_rect(ibuf);
+			}
+			else {
+				return;
+			}
 		}
 		else {
-			/* if there's only byte buffer in image it's already in compositor's working space,
-			 * nothing to do here
-			 */
-
 			return;
 		}
 	}
@@ -452,8 +460,10 @@
 		if (ibuf->rect)
 			imb_freerectImBuf(ibuf);
 
-		IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
-		                                       from_colorspace, to_colorspace, TRUE);
+		if (!STREQ(float_colorspace, to_colorspace)) {
+			IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
+			                                       from_colorspace, to_colorspace, TRUE);
+		}
 	}
 }
 
@@ -2668,6 +2678,8 @@
 				                         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);

Modified: trunk/blender/source/blender/imbuf/IMB_colormanagement.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_colormanagement.h	2013-09-02 13:45:57 UTC (rev 59733)
+++ trunk/blender/source/blender/imbuf/IMB_colormanagement.h	2013-09-02 13:54:12 UTC (rev 59734)
@@ -62,6 +62,9 @@
 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);

Modified: trunk/blender/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/colormanagement.c	2013-09-02 13:45:57 UTC (rev 59733)
+++ trunk/blender/source/blender/imbuf/intern/colormanagement.c	2013-09-02 13:54:12 UTC (rev 59734)
@@ -1134,6 +1134,21 @@
 		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 {




More information about the Bf-blender-cvs mailing list