- saturation option for sequencer strips, runs before multiply and color balance.
[blender.git] / source / blender / blenkernel / intern / sequencer.c
index 1ab4e75ee06a89cd9b9f035480fc220c9bb0ca2d..69dd4b3a1b737783bb0c79058c49363287d1cdc1 100644 (file)
@@ -1769,12 +1769,31 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf
        if(seq->flag & SEQ_FLIPX) {
                IMB_flipx(se->ibuf);
        }
-       if(seq->flag & SEQ_FLIPY) {
-               IMB_flipy(se->ibuf);
-       }
 
-       if(seq->mul == 0.0) {
-               seq->mul = 1.0;
+       if(seq->sat != 1.0f) {
+               /* inline for now, could become an imbuf function */
+               int i;
+               char *rct= (char *)se->ibuf->rect;
+               float *rctf= se->ibuf->rect_float;
+               const float sat= seq->sat;
+               float hsv[3];
+
+               if(rct) {
+                       float rgb[3];
+                       for (i = se->ibuf->x * se->ibuf->y; i > 0; i--, rct+=4) {
+                               rgb_byte_to_float(rct, rgb);
+                               rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+                               hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb+1, rgb+2);
+                               rgb_float_to_byte(rgb, rct);
+                       }
+               }
+
+               if(rctf) {
+                       for (i = se->ibuf->x * se->ibuf->y; i > 0; i--, rctf+=4) {
+                               rgb_to_hsv(rctf[0], rctf[1], rctf[2], hsv, hsv+1, hsv+2);
+                               hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rctf, rctf+1, rctf+2);
+                       }
+               }
        }
 
        mul = seq->mul;