Merging r50237 through r50240 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 27 Aug 2012 09:02:26 +0000 (09:02 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 27 Aug 2012 09:02:26 +0000 (09:02 +0000)
1  2 
source/blender/blenkernel/intern/sequencer.c

index 60b0b65ad0f55a633226ef94555ee80dfa550576,8aab622148b8620a9a99b48f99c7388e0c2dcdeb..84da45294a64a6db630926a86f91d7b29da74911
@@@ -72,7 -72,6 +72,7 @@@
  
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
 +#include "IMB_colormanagement.h"
  
  #include "BKE_context.h"
  #include "BKE_sound.h"
@@@ -208,8 -207,10 +208,10 @@@ void BKE_sequence_free(Scene *scene, Se
        /* free modifiers */
        BKE_sequence_modifier_clear(seq);
  
-       BKE_sequencer_cache_cleanup_sequence(seq);
-       BKE_sequencer_preprocessed_cache_cleanup_sequence(seq);
+       /* free cached data used by this strip,
+        * also invalidate cache for all dependent sequences
+        */
+       BKE_sequence_invalidate_cache(scene, seq);
  
        MEM_freeN(seq);
  }
@@@ -1713,7 -1714,7 +1715,7 @@@ int BKE_sequencer_input_have_to_preproc
        float mul;
  
        if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX |
 -                       SEQ_FLIPY | SEQ_USE_COLOR_BALANCE | SEQ_MAKE_PREMUL))
 +                       SEQ_FLIPY | SEQ_USE_COLOR_BALANCE | SEQ_MAKE_PREMUL | SEQ_MAKE_FLOAT))
        {
                return TRUE;
        }
@@@ -1839,9 -1840,8 +1841,9 @@@ static ImBuf *input_preprocess(SeqRende
        }
  
        if (seq->flag & SEQ_MAKE_FLOAT) {
 -              if (!ibuf->rect_float)
 -                      IMB_float_from_rect_simple(ibuf);
 +              if (!ibuf->rect_float) {
 +                      IMB_colormanagement_imbuf_to_sequencer_space(ibuf, TRUE);
 +              }
  
                if (ibuf->rect) {
                        imb_freerectImBuf(ibuf);
@@@ -2352,8 -2352,11 +2354,8 @@@ static ImBuf *seq_render_scene_strip(Se
                        }
  
                        /* float buffers in the sequencer are not linear */
 -                      if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
 -                              ibuf->profile = IB_PROFILE_LINEAR_RGB;
 -                      else
 -                              ibuf->profile = IB_PROFILE_NONE;
 -                      IMB_convert_profile(ibuf, IB_PROFILE_SRGB);                     
 +                      ibuf->profile = IB_PROFILE_LINEAR_RGB;
 +                      IMB_colormanagement_imbuf_to_sequencer_space(ibuf, FALSE);
                }
                else if (rres.rect32) {
                        ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect);
@@@ -2459,7 -2462,8 +2461,7 @@@ static ImBuf *do_render_strip_uncached(
                                        imb_freerectImBuf(ibuf);
  
                                /* all sequencer color is done in SRGB space, linear gives odd crossfades */
 -                              if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
 -                                      IMB_convert_profile(ibuf, IB_PROFILE_NONE);
 +                              IMB_colormanagement_imbuf_to_sequencer_space(ibuf, FALSE);
  
                                copy_to_ibuf_still(context, seq, nr, ibuf);
  
@@@ -2651,12 -2655,6 +2653,12 @@@ static ImBuf *seq_render_strip_stack(Se
        
        if (count == 1) {
                out = seq_render_strip(context, seq_arr[0], cfra);
 +
 +              if (out) {
 +                      /* put buffer back to linear space */
 +                      IMB_colormanagement_imbuf_from_sequencer_space(out);
 +              }
 +
                BKE_sequencer_cache_put(context, seq_arr[0], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
  
                return out;
                BKE_sequencer_cache_put(context, seq_arr[i], cfra, SEQ_STRIPELEM_IBUF_COMP, out);
        }
  
 +      if (out) {
 +              /* put buffer back to linear space */
 +              IMB_colormanagement_imbuf_from_sequencer_space(out);
 +      }
 +
        return out;
  }
  
@@@ -2945,6 -2938,9 +2947,9 @@@ static void free_anim_seq(Sequence *seq
  /* check whether sequence cur depends on seq */
  int BKE_sequence_check_depend(Sequence *seq, Sequence *cur)
  {
+       if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq)
+               return TRUE;
        /* sequences are not intersecting in time, assume no dependency exists between them */
        if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp)
                return FALSE;
@@@ -3001,27 -2997,46 +3006,27 @@@ void BKE_sequence_invalidate_cache_for_
        sequence_invalidate_cache(scene, seq, FALSE);
  }
  
 -void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, int check_mem_usage, int keep_file_handles)
 +void BKE_sequencer_free_imbuf(Scene *scene, ListBase *seqbase, int for_render)
  {
        Sequence *seq;
  
 -      if (check_mem_usage) {
 -              /* Let the cache limitor take care of this (schlaile) */
 -              /* While render let's keep all memory available for render 
 -               * (ton)
 -               * At least if free memory is tight...
 -               * This can make a big difference in encoding speed
 -               * (it is around 4 times(!) faster, if we do not waste time
 -               * on freeing _all_ buffers every time on long timelines...)
 -               * (schlaile)
 -               */
 -      
 -              uintptr_t mem_in_use;
 -              uintptr_t mmap_in_use;
 -              uintptr_t max;
 -      
 -              mem_in_use = MEM_get_memory_in_use();
 -              mmap_in_use = MEM_get_mapped_memory_in_use();
 -              max = MEM_CacheLimiter_get_maximum();
 -      
 -              if (max == 0 || mem_in_use + mmap_in_use <= max) {
 -                      return;
 -              }
 -      }
 -
        BKE_sequencer_cache_cleanup();
 -      
 +
        for (seq = seqbase->first; seq; seq = seq->next) {
 +              if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
 +                      continue;
 +              }
 +
                if (seq->strip) {
 -                      if (seq->type == SEQ_TYPE_MOVIE && !keep_file_handles)
 +                      if (seq->type == SEQ_TYPE_MOVIE) {
                                free_anim_seq(seq);
 +                      }
                        if (seq->type == SEQ_TYPE_SPEED) {
                                BKE_sequence_effect_speed_rebuild_map(scene, seq, 1);
                        }
                }
                if (seq->type == SEQ_TYPE_META) {
 -                      BKE_sequencer_free_imbuf(scene, &seq->seqbase, FALSE, keep_file_handles);
 +                      BKE_sequencer_free_imbuf(scene, &seq->seqbase, for_render);
                }
                if (seq->type == SEQ_TYPE_SCENE) {
                        /* FIXME: recurs downwards,