Merging r50192 through r50223 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Sun, 26 Aug 2012 14:12:09 +0000 (14:12 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 26 Aug 2012 14:12:09 +0000 (14:12 +0000)
1  2 
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/sequencer.c
source/blender/editors/render/render_internal.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/imbuf/IMB_imbuf.h
source/blender/makesrna/intern/rna_scene.c
source/blenderplayer/bad_level_call_stubs/stubs.c

@@@ -1484,7 -1484,7 +1484,7 @@@ void nodeSocketSetType(bNodeSocket *soc
   * otherwise we may reference missing data.
   *
   * Currently its only used for ID's, but nodes may one day
-  * referene other pointers which need validation.
+  * reference other pointers which need validation.
   */
  typedef struct bNodeClipboardExtraInfo {
        struct bNodeClipboardExtraInfo *next, *prev;
@@@ -2265,7 -2265,6 +2265,7 @@@ static void registerShaderNodes(bNodeTr
        register_node_type_sh_tex_gradient(ttype);
        register_node_type_sh_tex_magic(ttype);
        register_node_type_sh_tex_checker(ttype);
 +      register_node_type_sh_tex_brick(ttype);
  }
  
  static void registerTextureNodes(bNodeTreeType *ttype)
@@@ -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"
@@@ -1713,7 -1712,7 +1713,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 -1838,8 +1839,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 -2350,11 +2352,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 -2460,8 +2459,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 -2653,6 +2651,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;
  }
  
@@@ -3001,27 -2992,46 +3001,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, 
@@@ -3617,8 -3627,8 +3617,8 @@@ int BKE_sequence_swap(Sequence *seq_a, 
        SWAP(float, seq_a->blend_opacity, seq_b->blend_opacity);
  
  
-       SWAP(void *, seq_a->prev, seq_b->prev);
-       SWAP(void *, seq_a->next, seq_b->next);
+       SWAP(Sequence *, seq_a->prev, seq_b->prev);
+       SWAP(Sequence *, seq_a->next, seq_b->next);
        SWAP(int, seq_a->start, seq_b->start);
        SWAP(int, seq_a->startofs, seq_b->startofs);
        SWAP(int, seq_a->endofs, seq_b->endofs);
@@@ -61,7 -61,6 +61,7 @@@
  #include "ED_object.h"
  
  #include "RE_pipeline.h"
 +#include "IMB_colormanagement.h"
  #include "IMB_imbuf.h"
  #include "IMB_imbuf_types.h"
  
@@@ -151,9 -150,6 +151,9 @@@ void image_buffer_rect_update(Scene *sc
        IMB_buffer_byte_from_float(rectc, rectf,
                                   4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
                                   xmax, ymax, ibuf->x, rr->rectx);
 +
 +      IMB_partial_display_buffer_update(ibuf, rectf, rr->rectx, rxmin, rymin,
 +                                        rxmin, rymin, rxmin + xmax, rymin + ymax);
  }
  
  /* ****************************** render invoking ***************** */
@@@ -592,7 -588,7 +592,7 @@@ static int screen_render_invoke(bContex
  
        /* store actual owner of job, so modal operator could check for it,
         * the reason of this is that active scene could change when rendering
-        * several layers from composistor [#31800]
+        * several layers from compositor [#31800]
         */
        op->customdata = scene;
  
  #include "GPU_draw.h"
  #include "GPU_extensions.h"
  
 +#include "IMB_colormanagement.h"
 +
  #include "paint_intern.h"
  
  /* Defines and Structs */
@@@ -390,7 -388,11 +390,11 @@@ typedef struct UndoImageTile 
        char idname[MAX_ID_NAME];  /* name instead of pointer*/
        char ibufname[IB_FILENAME_SIZE];
  
-       void *rect;
+       union {
+               float        *fp;
+               unsigned int *uint;
+               void         *pt;
+       } rect;
        int x, y;
  
        short source, use_float;
@@@ -408,10 -410,10 +412,10 @@@ static void undo_copy_tile(UndoImageTil
                    tile->y * IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE);
  
        if (ibuf->rect_float) {
-               SWAP(void *, tmpibuf->rect_float, tile->rect);
+               SWAP(float *, tmpibuf->rect_float, tile->rect.fp);
        }
        else {
-               SWAP(void *, tmpibuf->rect, tile->rect);
+               SWAP(unsigned int *, tmpibuf->rect, tile->rect.uint);
        }
        
        if (restore)
@@@ -430,7 -432,7 +434,7 @@@ static void *image_undo_push_tile(Imag
                if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source)
                        if (tile->use_float == use_float)
                                if (strcmp(tile->idname, ima->id.name) == 0 && strcmp(tile->ibufname, ibuf->name) == 0)
-                                       return tile->rect;
+                                       return tile->rect.pt;
        
        if (*tmpibuf == NULL)
                *tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect);
  
        allocsize = IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE * 4;
        allocsize *= (ibuf->rect_float) ? sizeof(float) : sizeof(char);
-       tile->rect = MEM_mapallocN(allocsize, "UndeImageTile.rect");
+       tile->rect.pt = MEM_mapallocN(allocsize, "UndeImageTile.rect");
  
        BLI_strncpy(tile->ibufname, ibuf->name, sizeof(tile->ibufname));
  
  
        BLI_addtail(lb, tile);
        
-       return tile->rect;
+       return tile->rect.pt;
  }
  
  static void image_undo_restore(bContext *C, ListBase *lb)
@@@ -519,7 -521,7 +523,7 @@@ static void image_undo_free(ListBase *l
        UndoImageTile *tile;
  
        for (tile = lb->first; tile; tile = tile->next)
-               MEM_freeN(tile->rect);
+               MEM_freeN(tile->rect.pt);
  }
  
  /* get active image for face depending on old/new shading system */
@@@ -4222,11 -4224,8 +4226,11 @@@ static void imapaint_dirty_region(Imag
  
  static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
  {
 -      if (ibuf->rect_float)
 -              ibuf->userflags |= IB_RECT_INVALID;  /* force recreate of char rect */
 +      if (ibuf->rect_float) {
 +              IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, ibuf->x, 0, 0,
 +                                                imapaintpartial.x1, imapaintpartial.y1,
 +                                                imapaintpartial.x2, imapaintpartial.y2);
 +      }
        
        if (ibuf->mipmap[0])
                ibuf->userflags |= IB_MIPMAP_INVALID;
@@@ -4550,15 -4549,15 +4554,15 @@@ static int imapaint_canvas_set(ImagePai
  
                /* temporarily add float rect for cloning */
                if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
-                       int profile = IB_PROFILE_NONE;
+                       short profile = IB_PROFILE_NONE;
                        
                        /* Don't want to color manage, but don't disturb existing profiles */
-                       SWAP(int, s->clonecanvas->profile, profile);
+                       SWAP(short, s->clonecanvas->profile, profile);
  
                        IMB_float_from_rect(s->clonecanvas);
                        s->clonefreefloat = 1;
                        
-                       SWAP(int, s->clonecanvas->profile, profile);
+                       SWAP(short, s->clonecanvas->profile, profile);
                }
                else if (!s->canvas->rect_float && !s->clonecanvas->rect)
                        IMB_rect_from_float(s->clonecanvas);
@@@ -392,15 -392,6 +392,15 @@@ void IMB_buffer_byte_from_byte(unsigne
        int width, int height, int stride_to, int stride_from);
  void IMB_buffer_float_clamp(float *buf, int width, int height);
  
 +/* converting pixel buffers using tonecurve */
 +
 +typedef void (*imb_tonecurveCb) (float rgbOut[3], const float rgbIn[3]);
 +
 +void IMB_buffer_byte_from_float_tonecurve(unsigned char *rect_to, const float *rect_from,
 +                                          int channels_from, float dither, int profile_to, int profile_from, int predivide,
 +                                          int width, int height, int stride_to, int stride_from,
 +                                          imb_tonecurveCb tonecurve_func);
 +
  /**
   * Change the ordering of the color bytes pointed to by rect from
   * rgba to abgr. size * 4 color bytes are reordered.
@@@ -515,5 -506,9 +515,9 @@@ void IMB_processor_apply_threaded(int b
                                                        void *customdata),
                                    void *(do_thread) (void *));
  
+ /* ffmpeg */
+ void IMB_ffmpeg_init(void);
+ const char *IMB_ffmpeg_last_error(void);
  #endif
  
@@@ -2958,17 -2958,6 +2958,17 @@@ static void rna_def_scene_image_format_
        RNA_def_property_range(prop, 0.0f, 10.0f);
        RNA_def_property_ui_text(prop, "G", "Log conversion gamma");
        RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 +
 +      /* color management */
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings applied on image before saving");
 +
 +      prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "display_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings");
 +      RNA_def_property_ui_text(prop, "Display Settings", "Settings of device saved image would be displayed on");
  }
  
  static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna)
                {CODEC_ID_FLV1, "FLASH", 0, "Flash Video", ""},
                {CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""},
                {CODEC_ID_QTRLE, "QTRLE", 0, "QTRLE", ""},
-               /* {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, */ /* disabled for after release */
+               {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""},
                {0, NULL, 0, NULL, NULL}
        };
  
@@@ -4583,17 -4572,6 +4583,17 @@@ void RNA_def_scene(BlenderRNA *brna
        RNA_def_property_ui_text(prop, "Active Movie Clip", "Active movie clip used for constraints and viewport drawing");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
  
 +      /* color management */
 +      prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
 +      RNA_def_property_ui_text(prop, "View Settings", "Color management settings applied on image before saving");
 +
 +      prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE);
 +      RNA_def_property_pointer_sdna(prop, NULL, "display_settings");
 +      RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings");
 +      RNA_def_property_ui_text(prop, "Display Settings", "Settings of device saved image would be displayed on");
 +
        /* Nestled Data  */
        rna_def_tool_settings(brna);
        rna_def_unified_paint_settings(brna);
@@@ -183,7 -183,7 +183,7 @@@ int RE_WriteEnvmapResult(struct ReportL
  /* rna */
  float *give_cursor(struct Scene *scene, struct View3D *v3d) {return (float *) NULL;}
  void WM_menutype_free(void) {}
- void WM_menutype_freelink(struct MenuTypemt) {}
+ void WM_menutype_freelink(struct MenuType *mt) {}
  int WM_menutype_add(struct MenuType *mt) {return 0;}
  int WM_operator_props_dialog_popup(struct bContext *C, struct wmOperator *op, int width, int height) {return 0;}
  int WM_operator_confirm(struct bContext *C, struct wmOperator *op, struct wmEvent *event) {return 0;}
@@@ -418,7 -418,7 +418,7 @@@ void uiTemplateColorWheel(struct uiLayo
  void uiTemplateHistogram(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand) {}
  void uiTemplateReportsBanner(struct uiLayout *layout, struct bContext *C, struct wmOperator *op) {}
  void uiTemplateWaveform(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand) {}
- void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, charproperty, int expand) {}
+ void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, char *property, int expand) {}
  void uiTemplateNodeLink(struct uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) {}
  void uiTemplateNodeView(struct uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input) {}
  void uiTemplateTextureUser(struct uiLayout *layout, struct bContext *C) {}
@@@ -428,8 -428,6 +428,8 @@@ void uiTemplateMovieClip(struct uiLayou
  void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) {}
  void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact) {}
  void uiTemplateImageSettings(struct uiLayout *layout, struct PointerRNA *imfptr) {}
 +void uiTemplateColorspaceSettings(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) {}
 +void uiTemplateColormanagedViewSettings(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int show_global_settings) {}
  
  /* rna render */
  struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h) {return (struct RenderResult *) NULL;}