Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/render.c
| Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | void SEQ_render_new_render_data(Main *bmain, | ||||
| r_context->is_prefetch_render = false; | r_context->is_prefetch_render = false; | ||||
| } | } | ||||
| void seq_render_state_init(SeqRenderState *state) | void seq_render_state_init(SeqRenderState *state) | ||||
| { | { | ||||
| state->scene_parents = NULL; | state->scene_parents = NULL; | ||||
| } | } | ||||
| float seq_preview_scale_factor_from_context(const SeqRenderData *context) | |||||
| { | |||||
| switch (context->preview_render_size) { | |||||
| case SEQ_RENDER_SIZE_SCENE: | |||||
| return (float)context->scene->r.size / 100; | |||||
| case SEQ_RENDER_SIZE_AUTOMATIC: | |||||
| return 1.0f / context->downscale_factor; | |||||
| default: | |||||
| return SEQ_rendersize_to_scale_factor(context->preview_render_size); | |||||
| } | |||||
| } | |||||
| StripElem *SEQ_render_give_stripelem(Sequence *seq, int timeline_frame) | StripElem *SEQ_render_give_stripelem(Sequence *seq, int timeline_frame) | ||||
| { | { | ||||
| StripElem *se = seq->strip->stripdata; | StripElem *se = seq->strip->stripdata; | ||||
| if (seq->type == SEQ_TYPE_IMAGE) { | if (seq->type == SEQ_TYPE_IMAGE) { | ||||
| /* only IMAGE strips use the whole array, MOVIE strips use only the first element, | /* only IMAGE strips use the whole array, MOVIE strips use only the first element, | ||||
| * all other strips don't use this... | * all other strips don't use this... | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | if ((seq->flag & SEQ_FILTERY) && !ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) { | ||||
| /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */ | /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */ | ||||
| preprocessed_ibuf = IMB_makeSingleUser(ibuf); | preprocessed_ibuf = IMB_makeSingleUser(ibuf); | ||||
| ibuf = preprocessed_ibuf; | ibuf = preprocessed_ibuf; | ||||
| IMB_filtery(preprocessed_ibuf); | IMB_filtery(preprocessed_ibuf); | ||||
| } | } | ||||
| /* Get scale factor if preview resolution doesn't match project resolution. */ | /* Get scale factor if preview resolution doesn't match project resolution. */ | ||||
| float preview_scale_factor; | float preview_scale_factor = seq_preview_scale_factor_from_context(context); | ||||
| if (context->preview_render_size == SEQ_RENDER_SIZE_SCENE) { | |||||
| preview_scale_factor = (float)scene->r.size / 100; | |||||
| } | |||||
| else { | |||||
| preview_scale_factor = SEQ_rendersize_to_scale_factor(context->preview_render_size); | |||||
| } | |||||
| if (sequencer_use_crop(seq)) { | if (sequencer_use_crop(seq)) { | ||||
| /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */ | /* Change original image pointer to avoid another duplication in SEQ_USE_TRANSFORM. */ | ||||
| preprocessed_ibuf = IMB_makeSingleUser(ibuf); | preprocessed_ibuf = IMB_makeSingleUser(ibuf); | ||||
| ibuf = preprocessed_ibuf; | ibuf = preprocessed_ibuf; | ||||
| const int width = ibuf->x; | const int width = ibuf->x; | ||||
| const int height = ibuf->y; | const int height = ibuf->y; | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context, | ||||
| bool use_preprocess, | bool use_preprocess, | ||||
| const bool is_proxy_image) | const bool is_proxy_image) | ||||
| { | { | ||||
| if (context->is_proxy_render == false && | if (context->is_proxy_render == false && | ||||
| (ibuf->x != context->rectx || ibuf->y != context->recty)) { | (ibuf->x != context->rectx || ibuf->y != context->recty)) { | ||||
| use_preprocess = true; | use_preprocess = true; | ||||
| } | } | ||||
| if (use_preprocess) { | |||||
| float cost = seq_estimate_render_cost_end(context->scene, begin); | float cost = seq_estimate_render_cost_end(context->scene, begin); | ||||
| /* Proxies are not stored in cache. */ | /* Proxies are not stored in cache. */ | ||||
| if (!is_proxy_image) { | if (!is_proxy_image) { | ||||
| BKE_sequencer_cache_put( | BKE_sequencer_cache_put(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibuf, cost, false); | ||||
| context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibuf, cost, false); | |||||
| } | } | ||||
| if (use_preprocess) { | |||||
| /* Reset timer so we can get partial render time. */ | /* Reset timer so we can get partial render time. */ | ||||
| begin = seq_estimate_render_cost_begin(); | begin = seq_estimate_render_cost_begin(); | ||||
| ibuf = input_preprocess(context, seq, timeline_frame, ibuf); | ibuf = input_preprocess(context, seq, timeline_frame, ibuf); | ||||
| } | } | ||||
| float cost = seq_estimate_render_cost_end(context->scene, begin); | cost = seq_estimate_render_cost_end(context->scene, begin); | ||||
| BKE_sequencer_cache_put( | BKE_sequencer_cache_put( | ||||
| context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost, false); | context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost, false); | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| typedef struct RenderEffectInitData { | typedef struct RenderEffectInitData { | ||||
| struct SeqEffectHandle *sh; | struct SeqEffectHandle *sh; | ||||
| const SeqRenderData *context; | const SeqRenderData *context; | ||||
| ▲ Show 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | if (seq_proxy_get_custom_file_fname(seq, name, context->view_id)) { | ||||
| proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name); | proxy->anim = openanim(name, IB_rect, 0, seq->strip->colorspace_settings.name); | ||||
| } | } | ||||
| if (proxy->anim == NULL) { | if (proxy->anim == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| int frameno = (int)seq_give_frame_index(seq, timeline_frame) + seq->anim_startofs; | int frameno = (int)seq_give_frame_index(seq, timeline_frame) + seq->anim_startofs; | ||||
| return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE); | return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE, IMB_DOWNSCALE_NONE); | ||||
| } | |||||
| static IMB_Downscale get_downscale_index(const SeqRenderData *context, struct anim *anim) | |||||
| { | |||||
| /* Downscale factor based on project settings. */ | |||||
| const float downscale_factor_width = (float)IMB_anim_get_image_width(anim) / | |||||
| (float)context->rectx; | |||||
| const float downscale_factor_height = (float)IMB_anim_get_image_height(anim) / | |||||
| (float)context->recty; | |||||
| const float downscale_factor = MAX2(downscale_factor_width, downscale_factor_height); | |||||
| return downscale_factor_to_downscale_index(downscale_factor); | |||||
| } | } | ||||
| /** | /** | ||||
| * Render individual view for multi-view or single (default view) for mono-view. | * Render individual view for multi-view or single (default view) for mono-view. | ||||
| */ | */ | ||||
| static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context, | static ImBuf *seq_render_movie_strip_view(const SeqRenderData *context, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| float frame_index, | float frame_index, | ||||
| Show All 12 Lines | if (SEQ_can_use_proxy(seq, psize)) { | ||||
| if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE && | if (context->scene->ed->proxy_storage != SEQ_EDIT_PROXY_DIR_STORAGE && | ||||
| seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) { | seq->strip->proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) { | ||||
| ibuf = seq_render_movie_strip_custom_file_proxy(context, seq, timeline_frame); | ibuf = seq_render_movie_strip_custom_file_proxy(context, seq, timeline_frame); | ||||
| } | } | ||||
| else { | else { | ||||
| ibuf = IMB_anim_absolute(sanim->anim, | ibuf = IMB_anim_absolute(sanim->anim, | ||||
| frame_index + seq->anim_startofs, | frame_index + seq->anim_startofs, | ||||
| seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, | seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, | ||||
| psize); | psize, | ||||
| IMB_DOWNSCALE_NONE); | |||||
| } | } | ||||
| if (ibuf != NULL) { | if (ibuf != NULL) { | ||||
| *r_is_proxy_image = true; | *r_is_proxy_image = true; | ||||
| } | } | ||||
| } | } | ||||
| /* Fetching for requested proxy size failed, try fetching the original instead. */ | /* Fetching for requested proxy size failed, try fetching the original instead. */ | ||||
| if (ibuf == NULL) { | if (ibuf == NULL) { | ||||
| ibuf = IMB_anim_absolute(sanim->anim, | ibuf = IMB_anim_absolute(sanim->anim, | ||||
| frame_index + seq->anim_startofs, | frame_index + seq->anim_startofs, | ||||
| seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, | seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN, | ||||
| IMB_PROXY_NONE); | IMB_PROXY_NONE, | ||||
| get_downscale_index(context, sanim->anim)); | |||||
| } | } | ||||
| if (ibuf == NULL) { | if (ibuf == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| seq_imbuf_to_sequencer_space(context->scene, ibuf, false); | seq_imbuf_to_sequencer_space(context->scene, ibuf, false); | ||||
| /* We don't need both (speed reasons)! */ | /* We don't need both (speed reasons)! */ | ||||
| ▲ Show 20 Lines • Show All 916 Lines • Show Last 20 Lines | |||||