diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2016-09-23 02:40:19 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2016-09-23 02:40:19 +0300 |
commit | 1dfb89d229304c302b8849756aa0ddd7e8d96488 (patch) | |
tree | db7a2ed403101788b2cb308538d73a99c95621d6 /source/blender/blenkernel | |
parent | 4a1feaa5558ed60388fd3be41db74fbc54f2ab08 (diff) | |
parent | 1b2b7cfa2007172e07d78324bb941d0160b59c42 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
intern/ghost/intern/GHOST_ContextCGL.mm
intern/ghost/intern/GHOST_WindowCocoa.mm
source/blender/makesrna/intern/rna_main.c
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_blender_version.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_cachefile.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_freestyle.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_linestyle.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cachefile.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/freestyle.c | 22 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_query.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_remap.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/linestyle.c | 32 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 76 |
12 files changed, 103 insertions, 74 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 3ae01d8148a..55142510f9e 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -28,7 +28,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 278 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 /* Several breakages with 270, e.g. constraint deg vs rad */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 6 diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h index 7a9744ef9d6..b30143cbaec 100644 --- a/source/blender/blenkernel/BKE_cachefile.h +++ b/source/blender/blenkernel/BKE_cachefile.h @@ -39,6 +39,7 @@ struct Main; struct Scene; void BKE_cachefiles_init(void); +void BKE_cachefiles_exit(void); void *BKE_cachefile_add(struct Main *bmain, const char *name); diff --git a/source/blender/blenkernel/BKE_freestyle.h b/source/blender/blenkernel/BKE_freestyle.h index e10594634f0..50407f3bdfc 100644 --- a/source/blender/blenkernel/BKE_freestyle.h +++ b/source/blender/blenkernel/BKE_freestyle.h @@ -55,8 +55,7 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *con /* FreestyleConfig.modules */ FreestyleModuleConfig *BKE_freestyle_module_add(FreestyleConfig *config); bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf); -bool BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf); -bool BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf); +bool BKE_freestyle_module_move(FreestyleConfig *config, FreestyleModuleConfig *module_conf, int direction); /* FreestyleConfig.linesets */ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain, FreestyleConfig *config, const char *name); diff --git a/source/blender/blenkernel/BKE_linestyle.h b/source/blender/blenkernel/BKE_linestyle.h index e96ef4e7be3..af9bf58ce77 100644 --- a/source/blender/blenkernel/BKE_linestyle.h +++ b/source/blender/blenkernel/BKE_linestyle.h @@ -73,10 +73,10 @@ int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyle int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier); int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier); -void BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); -void BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); -void BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); -void BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); +bool BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); +bool BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); +bool BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); +bool BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction); void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase); char *BKE_linestyle_path_to_color_ramp(FreestyleLineStyle *linestyle, struct ColorBand *color_ramp); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 0805335da66..a8670395fc4 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -49,6 +49,7 @@ #include "BKE_blender_version.h" /* own include */ #include "BKE_blendfile.h" #include "BKE_brush.h" +#include "BKE_cachefile.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -84,6 +85,7 @@ void BKE_blender_free(void) BKE_spacetypes_free(); /* after free main, it uses space callbacks */ IMB_exit(); + BKE_cachefiles_exit(); BKE_images_exit(); DAG_exit(); diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index 502f1d53ab2..e62e652b4a6 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -56,6 +56,11 @@ void BKE_cachefiles_init(void) BLI_spin_init(&spin); } +void BKE_cachefiles_exit(void) +{ + BLI_spin_end(&spin); +} + void *BKE_cachefile_add(Main *bmain, const char *name) { CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name); diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c index 3a15be5a09d..21fc1674dc5 100644 --- a/source/blender/blenkernel/intern/freestyle.c +++ b/source/blender/blenkernel/intern/freestyle.c @@ -151,22 +151,14 @@ bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig return true; } -bool BKE_freestyle_module_move_up(FreestyleConfig *config, FreestyleModuleConfig *module_conf) -{ - if (BLI_findindex(&config->modules, module_conf) == -1) - return false; - BLI_remlink(&config->modules, module_conf); - BLI_insertlinkbefore(&config->modules, module_conf->prev, module_conf); - return true; -} - -bool BKE_freestyle_module_move_down(FreestyleConfig *config, FreestyleModuleConfig *module_conf) +/** + * Reinsert \a module_conf offset by \a direction from current position. + * \return if position of \a module_conf changed. + */ +bool BKE_freestyle_module_move(FreestyleConfig *config, FreestyleModuleConfig *module_conf, int direction) { - if (BLI_findindex(&config->modules, module_conf) == -1) - return false; - BLI_remlink(&config->modules, module_conf); - BLI_insertlinkafter(&config->modules, module_conf->next, module_conf); - return true; + return ((BLI_findindex(&config->modules, module_conf) > -1) && + (BLI_listbase_link_move(&config->modules, module_conf, direction) == true)); } void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet *lineset) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8a9cb73c8c9..a4eef2f9230 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1325,7 +1325,7 @@ char BKE_imtype_from_arg(const char *imtype_arg) else if (STREQ(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR; else if (STREQ(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER; #endif - else if (STREQ(imtype_arg, "MPEG")) return R_IMF_IMTYPE_FFMPEG; + else if (STREQ(imtype_arg, "FFMPEG")) return R_IMF_IMTYPE_FFMPEG; else if (STREQ(imtype_arg, "FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER; #ifdef WITH_CINEON else if (STREQ(imtype_arg, "CINEON")) return R_IMF_IMTYPE_CINEON; diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index b538c556415..772ba2d9c80 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -831,10 +831,12 @@ void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cd_flag) * This is a 'simplified' abstract version of #BKE_library_foreach_ID_link() above, quite useful to reduce * useless iterations in some cases. */ +/* XXX This has to be fully rethink, basing check on ID type is not really working anymore (and even worth once + * IDProps will support ID pointers), we'll have to do some quick checks on IDs themselves... */ bool BKE_library_idtype_can_use_idtype(const short id_type_owner, const short id_type_used) { - if (id_type_used == ID_AC) { - return id_type_can_have_animdata(id_type_owner); + if (id_type_can_have_animdata(id_type_owner)) { + return true; /* AnimationData can use virtually any kind of datablocks, through drivers especially. */ } switch ((ID_Type)id_type_owner) { @@ -931,10 +933,10 @@ static int foreach_libblock_id_users_callback(void *user_data, ID *self_id, ID * IDUsersIter *iter = user_data; /* XXX This is actually some kind of hack... - * Issue is, only ID pointer from shapekeys is the 'from' one, which is not actually ID usage. + * Issue is, shapekeys' 'from' ID pointer is not actually ID usage. * Maybe we should even nuke it from BKE_library_foreach_ID_link, not 100% sure yet... */ - if (GS(self_id->name) == ID_KE) { + if ((GS(self_id->name) == ID_KE) && (((Key *)self_id)->from == *id_p)) { return IDWALK_RET_NOP; } diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index bdfe951a501..69b52c92c3f 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -132,6 +132,7 @@ void BKE_library_callback_remap_editor_id_reference_set(BKE_library_remap_editor } typedef struct IDRemap { + Main *bmain; /* Only used to trigger depsgraph updates in the right bmain. */ ID *old_id; ID *new_id; ID *id; /* The ID in which we are replacing old_id by new_id usages. */ @@ -211,7 +212,7 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id else { if (!is_never_null) { *id_p = new_id; - DAG_id_tag_update(id_self, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DAG_id_tag_update_ex(id_remap_data->bmain, id_self, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } if (cb_flag & IDWALK_USER) { id_us_min(old_id); @@ -385,15 +386,15 @@ static void libblock_remap_data_postprocess_obdata_relink(Main *UNUSED(bmain), O * - \a id is non-NULL: * + If \a old_id is NULL, \a new_id must also be NULL, and all ID pointers from \a id are cleared (i.e. \a id * does not references any other datablock anymore). - * + If \a old_id is non-NULL, behavior is as with a NULL \a id, but only for given \a id. + * + If \a old_id is non-NULL, behavior is as with a NULL \a id, but only within given \a id. * - * \param bmain: the Main data storage to operate on (can be NULL if \a id is non-NULL). - * \param id: the datablock to operate on (can be NULL if \a bmain is non-NULL). + * \param bmain: the Main data storage to operate on (must never be NULL). + * \param id: the datablock to operate on (can be NULL, in which case we operate over all IDs from given bmain). * \param old_id: the datablock to dereference (may be NULL if \a id is non-NULL). * \param new_id: the new datablock to replace \a old_id references with (may be NULL). * \param r_id_remap_data: if non-NULL, the IDRemap struct to use (uselful to retrieve info about remapping process). */ -static void libblock_remap_data( +ATTR_NONNULL(1) static void libblock_remap_data( Main *bmain, ID *id, ID *old_id, ID *new_id, const short remap_flags, IDRemap *r_id_remap_data) { IDRemap id_remap_data; @@ -403,6 +404,7 @@ static void libblock_remap_data( if (r_id_remap_data == NULL) { r_id_remap_data = &id_remap_data; } + r_id_remap_data->bmain = bmain; r_id_remap_data->old_id = old_id; r_id_remap_data->new_id = new_id; r_id_remap_data->id = NULL; @@ -610,7 +612,7 @@ void BKE_libblock_relink_ex( BLI_assert(new_id == NULL); } - libblock_remap_data(NULL, id, old_id, new_id, remap_flags, NULL); + libblock_remap_data(bmain, id, old_id, new_id, remap_flags, NULL); /* Some after-process updates. * This is a bit ugly, but cannot see a way to avoid it. Maybe we should do a per-ID callback for this instead? diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 430935a5fad..bd21215f91e 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -1343,33 +1343,25 @@ int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineSt return 0; } -static void move_modifier(ListBase *lb, LineStyleModifier *modifier, int direction) +/** + * Reinsert \a modifier in modifier list with an offset of \a direction. + * \return if position of \a modifier has changed. + */ +bool BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) { - BLI_remlink(lb, modifier); - if (direction > 0) - BLI_insertlinkbefore(lb, modifier->prev, modifier); - else - BLI_insertlinkafter(lb, modifier->next, modifier); + return BLI_listbase_link_move(&linestyle->color_modifiers, modifier, direction); } - -void BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) +bool BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) { - move_modifier(&linestyle->color_modifiers, modifier, direction); + return BLI_listbase_link_move(&linestyle->alpha_modifiers, modifier, direction); } - -void BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) +bool BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) { - move_modifier(&linestyle->alpha_modifiers, modifier, direction); + return BLI_listbase_link_move(&linestyle->thickness_modifiers, modifier, direction); } - -void BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) -{ - move_modifier(&linestyle->thickness_modifiers, modifier, direction); -} - -void BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) +bool BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction) { - move_modifier(&linestyle->geometry_modifiers, modifier, direction); + return BLI_listbase_link_move(&linestyle->geometry_modifiers, modifier, direction); } void BKE_linestyle_modifier_list_color_ramps(FreestyleLineStyle *linestyle, ListBase *listbase) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index de55a1977bf..b0ab6f707fa 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -69,10 +69,14 @@ typedef struct FFMpegContext { int ffmpeg_video_bitrate; int ffmpeg_audio_bitrate; int ffmpeg_gop_size; + int ffmpeg_max_b_frames; int ffmpeg_autosplit; int ffmpeg_autosplit_count; bool ffmpeg_preview; + int ffmpeg_crf; /* set to 0 to not use CRF mode; we have another flag for lossless anyway. */ + int ffmpeg_preset; /* see FFMpegPreset */ + AVFormatContext *outfile; AVStream *video_stream; AVStream *audio_stream; @@ -560,10 +564,37 @@ static AVStream *alloc_video_stream(FFMpegContext *context, RenderData *rd, int } c->gop_size = context->ffmpeg_gop_size; - c->bit_rate = context->ffmpeg_video_bitrate * 1000; - c->rc_max_rate = rd->ffcodecdata.rc_max_rate * 1000; - c->rc_min_rate = rd->ffcodecdata.rc_min_rate * 1000; - c->rc_buffer_size = rd->ffcodecdata.rc_buffer_size * 1024; + c->max_b_frames = context->ffmpeg_max_b_frames; + + if (context->ffmpeg_crf >= 0) { + ffmpeg_dict_set_int(&opts, "crf", context->ffmpeg_crf); + } else { + c->bit_rate = context->ffmpeg_video_bitrate * 1000; + c->rc_max_rate = rd->ffcodecdata.rc_max_rate * 1000; + c->rc_min_rate = rd->ffcodecdata.rc_min_rate * 1000; + c->rc_buffer_size = rd->ffcodecdata.rc_buffer_size * 1024; + } + + if (context->ffmpeg_preset) { + char const * preset_name; + switch(context->ffmpeg_preset) { + case FFM_PRESET_ULTRAFAST: preset_name = "ultrafast"; break; + case FFM_PRESET_SUPERFAST: preset_name = "superfast"; break; + case FFM_PRESET_VERYFAST: preset_name = "veryfast"; break; + case FFM_PRESET_FASTER: preset_name = "faster"; break; + case FFM_PRESET_FAST: preset_name = "fast"; break; + case FFM_PRESET_MEDIUM: preset_name = "medium"; break; + case FFM_PRESET_SLOW: preset_name = "slow"; break; + case FFM_PRESET_SLOWER: preset_name = "slower"; break; + case FFM_PRESET_VERYSLOW: preset_name = "veryslow"; break; + default: + printf("Unknown preset number %i, ignoring.\n", context->ffmpeg_preset); + preset_name = NULL; + } + if (preset_name != NULL) { + av_dict_set(&opts, "preset", preset_name, 0); + } + } #if 0 /* this options are not set in ffmpeg.c and leads to artifacts with MPEG-4 @@ -819,6 +850,12 @@ static int start_ffmpeg_impl(FFMpegContext *context, struct RenderData *rd, int context->ffmpeg_audio_bitrate = rd->ffcodecdata.audio_bitrate; context->ffmpeg_gop_size = rd->ffcodecdata.gop_size; context->ffmpeg_autosplit = rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT; + context->ffmpeg_crf = rd->ffcodecdata.constant_rate_factor; + context->ffmpeg_preset = rd->ffcodecdata.ffmpeg_preset; + + if ((rd->ffcodecdata.flags & FFMPEG_USE_MAX_B_FRAMES) != 0) { + context->ffmpeg_max_b_frames = rd->ffcodecdata.max_b_frames; + } /* Determine the correct filename */ ffmpeg_filepath_get(context, name, rd, context->ffmpeg_preview, suffix); @@ -852,12 +889,16 @@ static int start_ffmpeg_impl(FFMpegContext *context, struct RenderData *rd, int /* Returns after this must 'goto fail;' */ of->oformat = fmt; - of->packet_size = rd->ffcodecdata.mux_packet_size; - if (context->ffmpeg_audio_codec != AV_CODEC_ID_NONE) { - ffmpeg_dict_set_int(&opts, "muxrate", rd->ffcodecdata.mux_rate); - } - else { - av_dict_set(&opts, "muxrate", "0", 0); + + /* Only bother with setting packet size & mux rate when CRF is not used. */ + if (context->ffmpeg_crf == 0) { + of->packet_size = rd->ffcodecdata.mux_packet_size; + if (context->ffmpeg_audio_codec != AV_CODEC_ID_NONE) { + ffmpeg_dict_set_int(&opts, "muxrate", rd->ffcodecdata.mux_rate); + } + else { + av_dict_set(&opts, "muxrate", "0", 0); + } } ffmpeg_dict_set_int(&opts, "preload", (int)(0.5 * AV_TIME_BASE)); @@ -1503,14 +1544,6 @@ static void ffmpeg_set_expert_options(RenderData *rd) BKE_ffmpeg_property_add_string(rd, "video", "fast-pskip:1"); BKE_ffmpeg_property_add_string(rd, "video", "wpredp:2"); #endif - - if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) { -#ifdef FFMPEG_HAVE_DEPRECATED_FLAGS2 - BKE_ffmpeg_property_add_string(rd, "video", "cqp:0"); -#else - BKE_ffmpeg_property_add_string(rd, "video", "qp:0"); -#endif - } } else if (codec_id == AV_CODEC_ID_DNXHD) { if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) @@ -1622,9 +1655,10 @@ void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf) rd->ffcodecdata.audio_codec <= 0 || rd->ffcodecdata.video_bitrate <= 1) { - rd->ffcodecdata.codec = AV_CODEC_ID_MPEG2VIDEO; - - BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_DVD); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264); + rd->ffcodecdata.constant_rate_factor = FFM_CRF_MEDIUM; + rd->ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM; + rd->ffcodecdata.type = FFMPEG_MKV; } if (rd->ffcodecdata.type == FFMPEG_OGG) { rd->ffcodecdata.type = FFMPEG_MPEG2; |