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 333 Lines • ▼ Show 20 Lines | while (a--) { | ||||
| rt_float += 4; | rt_float += 4; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static ImBuf *input_preprocess(const SeqRenderData *context, | static ImBuf *input_preprocess(const SeqRenderData *context, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| float timeline_frame, | float timeline_frame, | ||||
| ImBuf *ibuf) | ImBuf *ibuf, | ||||
| IMB_Downscale downscale_index) | |||||
| { | { | ||||
| Scene *scene = context->scene; | Scene *scene = context->scene; | ||||
| ImBuf *preprocessed_ibuf = NULL; | ImBuf *preprocessed_ibuf = NULL; | ||||
| /* Deinterlace. */ | /* Deinterlace. */ | ||||
| if ((seq->flag & SEQ_FILTERY) && !ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP)) { | 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 *= downscale_index_to_downscale_factor(downscale_index); | ||||
| 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 All 10 Lines | if (sequencer_use_crop(seq)) { | ||||
| /* Bottom. */ | /* Bottom. */ | ||||
| IMB_rectfill_area_replace(preprocessed_ibuf, col, left, 0, width, bottom); | IMB_rectfill_area_replace(preprocessed_ibuf, col, left, 0, width, bottom); | ||||
| /* Right. */ | /* Right. */ | ||||
| IMB_rectfill_area_replace(preprocessed_ibuf, col, width - right, bottom, width, height); | IMB_rectfill_area_replace(preprocessed_ibuf, col, width - right, bottom, width, height); | ||||
| /* Top. */ | /* Top. */ | ||||
| IMB_rectfill_area_replace(preprocessed_ibuf, col, left, height - top, width - right, height); | IMB_rectfill_area_replace(preprocessed_ibuf, col, left, height - top, width - right, height); | ||||
| } | } | ||||
| if (sequencer_use_transform(seq) || context->rectx != ibuf->x || context->recty != ibuf->y) { | if (sequencer_use_transform(seq) || context->rectx != ibuf->x || context->recty != ibuf->y || | ||||
| preview_scale_factor != 1.0f) { | |||||
| const int x = context->rectx; | const int x = context->rectx; | ||||
| const int y = context->recty; | const int y = context->recty; | ||||
| preprocessed_ibuf = IMB_allocImBuf(x, y, 32, ibuf->rect_float ? IB_rectfloat : IB_rect); | preprocessed_ibuf = IMB_allocImBuf(x, y, 32, ibuf->rect_float ? IB_rectfloat : IB_rect); | ||||
| ImageTransformThreadInitData init_data = {NULL}; | ImageTransformThreadInitData init_data = {NULL}; | ||||
| init_data.ibuf_source = ibuf; | init_data.ibuf_source = ibuf; | ||||
| init_data.ibuf_out = preprocessed_ibuf; | init_data.ibuf_out = preprocessed_ibuf; | ||||
| init_data.transform = seq->strip->transform; | init_data.transform = seq->strip->transform; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context, | static ImBuf *seq_render_preprocess_ibuf(const SeqRenderData *context, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| ImBuf *ibuf, | ImBuf *ibuf, | ||||
| float timeline_frame, | float timeline_frame, | ||||
| clock_t begin, | clock_t begin, | ||||
| bool use_preprocess, | bool use_preprocess, | ||||
| const bool is_proxy_image) | const bool is_proxy_image, | ||||
| IMB_Downscale downscale_index) | |||||
| { | { | ||||
| 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 || | ||||
| downscale_index != IMB_DOWNSCALE_NONE)) { | |||||
| 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, downscale_index, 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, downscale_index); | ||||
| } | } | ||||
| 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, | ||||
| context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, ibuf, cost, false); | seq, | ||||
| timeline_frame, | |||||
| SEQ_CACHE_STORE_PREPROCESSED, | |||||
| ibuf, | |||||
| cost, | |||||
| IMB_DOWNSCALE_NONE, | |||||
| false); | |||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| typedef struct RenderEffectInitData { | typedef struct RenderEffectInitData { | ||||
| struct SeqEffectHandle *sh; | struct SeqEffectHandle *sh; | ||||
| const SeqRenderData *context; | const SeqRenderData *context; | ||||
| Sequence *seq; | Sequence *seq; | ||||
| float timeline_frame, facf0, facf1; | float timeline_frame, facf0, facf1; | ||||
| ▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | if (seq->views_format == R_IMF_VIEWS_STEREO_3D) { | ||||
| IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]); | IMB_ImBufFromStereo3d(seq->stereo3d_format, ibufs_arr[0], &ibufs_arr[0], &ibufs_arr[1]); | ||||
| } | } | ||||
| for (int view_id = 0; view_id < totviews; view_id++) { | for (int view_id = 0; view_id < totviews; view_id++) { | ||||
| SeqRenderData localcontext = *context; | SeqRenderData localcontext = *context; | ||||
| localcontext.view_id = view_id; | localcontext.view_id = view_id; | ||||
| if (view_id != context->view_id) { | if (view_id != context->view_id) { | ||||
| ibufs_arr[view_id] = seq_render_preprocess_ibuf( | ibufs_arr[view_id] = seq_render_preprocess_ibuf(&localcontext, | ||||
| &localcontext, seq, ibufs_arr[view_id], timeline_frame, clock(), true, false); | seq, | ||||
| ibufs_arr[view_id], | |||||
| timeline_frame, | |||||
| clock(), | |||||
| true, | |||||
| false, | |||||
| IMB_DOWNSCALE_NONE); | |||||
| } | } | ||||
| } | } | ||||
| /* Return the original requested ImBuf. */ | /* Return the original requested ImBuf. */ | ||||
| ibuf = ibufs_arr[context->view_id]; | ibuf = ibufs_arr[context->view_id]; | ||||
| /* Remove the others (decrease their refcount). */ | /* Remove the others (decrease their refcount). */ | ||||
| for (int view_id = 0; view_id < totviews; view_id++) { | for (int view_id = 0; view_id < totviews; view_id++) { | ||||
| Show All 30 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) | |||||
| { | |||||
| if (context->preview_render_size != SEQ_RENDER_SIZE_AUTOMATIC) { | |||||
| return IMB_DOWNSCALE_NONE; | |||||
| } | |||||
| /* 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, | ||||
| float timeline_frame, | float timeline_frame, | ||||
| StripAnim *sanim, | StripAnim *sanim, | ||||
| bool *r_is_proxy_image) | bool *r_is_proxy_image, | ||||
| IMB_Downscale *r_downscale_index) | |||||
| { | { | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size); | IMB_Proxy_Size psize = SEQ_rendersize_to_proxysize(context->preview_render_size); | ||||
| IMB_anim_set_preseek(sanim->anim, seq->anim_preseek); | IMB_anim_set_preseek(sanim->anim, seq->anim_preseek); | ||||
| if (SEQ_can_use_proxy(seq, psize)) { | if (SEQ_can_use_proxy(seq, psize)) { | ||||
| /* Try to get a proxy image. | /* Try to get a proxy image. | ||||
| * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */ | * Movie proxies are handled by ImBuf module with exception of `custom file` setting. */ | ||||
| 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) { | ||||
| *r_downscale_index = get_downscale_index(context, sanim->anim); | |||||
| 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, | ||||
| *r_downscale_index); | |||||
| } | } | ||||
| 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)! */ | ||||
| if (ibuf->rect_float != NULL && ibuf->rect != NULL) { | if (ibuf->rect_float != NULL && ibuf->rect != NULL) { | ||||
| imb_freerectImBuf(ibuf); | imb_freerectImBuf(ibuf); | ||||
| } | } | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| static ImBuf *seq_render_movie_strip(const SeqRenderData *context, | static ImBuf *seq_render_movie_strip(const SeqRenderData *context, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| float frame_index, | float frame_index, | ||||
| float timeline_frame, | float timeline_frame, | ||||
| bool *r_is_proxy_image) | bool *r_is_proxy_image, | ||||
| IMB_Downscale *r_downscale_index) | |||||
| { | { | ||||
| /* Load all the videos. */ | /* Load all the videos. */ | ||||
| seq_open_anim_file(context->scene, seq, false); | seq_open_anim_file(context->scene, seq, false); | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| StripAnim *sanim = seq->anims.first; | StripAnim *sanim = seq->anims.first; | ||||
| const int totfiles = seq_num_files(context->scene, seq->views_format, true); | const int totfiles = seq_num_files(context->scene, seq->views_format, true); | ||||
| bool is_multiview_render = (seq->flag & SEQ_USE_VIEWS) != 0 && | bool is_multiview_render = (seq->flag & SEQ_USE_VIEWS) != 0 && | ||||
| (context->scene->r.scemode & R_MULTIVIEW) != 0 && | (context->scene->r.scemode & R_MULTIVIEW) != 0 && | ||||
| BLI_listbase_count_at_most(&seq->anims, totfiles + 1) == totfiles; | BLI_listbase_count_at_most(&seq->anims, totfiles + 1) == totfiles; | ||||
| if (is_multiview_render) { | if (is_multiview_render) { | ||||
| ImBuf **ibuf_arr; | ImBuf **ibuf_arr; | ||||
| int totviews = BKE_scene_multiview_num_views_get(&context->scene->r); | int totviews = BKE_scene_multiview_num_views_get(&context->scene->r); | ||||
| ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs"); | ibuf_arr = MEM_callocN(sizeof(ImBuf *) * totviews, "Sequence Image Views Imbufs"); | ||||
| int ibuf_view_id; | int ibuf_view_id; | ||||
| for (ibuf_view_id = 0, sanim = seq->anims.first; sanim; sanim = sanim->next, ibuf_view_id++) { | for (ibuf_view_id = 0, sanim = seq->anims.first; sanim; sanim = sanim->next, ibuf_view_id++) { | ||||
| if (sanim->anim) { | if (sanim->anim) { | ||||
| ibuf_arr[ibuf_view_id] = seq_render_movie_strip_view( | ibuf_arr[ibuf_view_id] = seq_render_movie_strip_view( | ||||
| context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image); | context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image, r_downscale_index); | ||||
| } | } | ||||
| } | } | ||||
| if (seq->views_format == R_IMF_VIEWS_STEREO_3D) { | if (seq->views_format == R_IMF_VIEWS_STEREO_3D) { | ||||
| if (ibuf_arr[0] == NULL) { | if (ibuf_arr[0] == NULL) { | ||||
| /* Probably proxy hasn't been created yet. */ | /* Probably proxy hasn't been created yet. */ | ||||
| MEM_freeN(ibuf_arr); | MEM_freeN(ibuf_arr); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| IMB_ImBufFromStereo3d(seq->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]); | IMB_ImBufFromStereo3d(seq->stereo3d_format, ibuf_arr[0], &ibuf_arr[0], &ibuf_arr[1]); | ||||
| } | } | ||||
| for (int view_id = 0; view_id < totviews; view_id++) { | for (int view_id = 0; view_id < totviews; view_id++) { | ||||
| SeqRenderData localcontext = *context; | SeqRenderData localcontext = *context; | ||||
| localcontext.view_id = view_id; | localcontext.view_id = view_id; | ||||
| if (view_id != context->view_id) { | if (view_id != context->view_id) { | ||||
| ibuf_arr[view_id] = seq_render_preprocess_ibuf( | ibuf_arr[view_id] = seq_render_preprocess_ibuf(&localcontext, | ||||
| &localcontext, seq, ibuf_arr[view_id], timeline_frame, clock(), true, false); | seq, | ||||
| ibuf_arr[view_id], | |||||
| timeline_frame, | |||||
| clock(), | |||||
| true, | |||||
| false, | |||||
| IMB_DOWNSCALE_NONE); | |||||
| } | } | ||||
| } | } | ||||
| /* Return the original requested ImBuf. */ | /* Return the original requested ImBuf. */ | ||||
| ibuf = ibuf_arr[context->view_id]; | ibuf = ibuf_arr[context->view_id]; | ||||
| /* Remove the others (decrease their refcount). */ | /* Remove the others (decrease their refcount). */ | ||||
| for (int view_id = 0; view_id < totviews; view_id++) { | for (int view_id = 0; view_id < totviews; view_id++) { | ||||
| if (ibuf_arr[view_id] != ibuf) { | if (ibuf_arr[view_id] != ibuf) { | ||||
| IMB_freeImBuf(ibuf_arr[view_id]); | IMB_freeImBuf(ibuf_arr[view_id]); | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(ibuf_arr); | MEM_freeN(ibuf_arr); | ||||
| } | } | ||||
| else { | else { | ||||
| ibuf = seq_render_movie_strip_view( | ibuf = seq_render_movie_strip_view( | ||||
| context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image); | context, seq, frame_index, timeline_frame, sanim, r_is_proxy_image, r_downscale_index); | ||||
| } | } | ||||
| if (ibuf == NULL) { | if (ibuf == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| seq->strip->stripdata->orig_width = ibuf->x; | seq->strip->stripdata->orig_width = ibuf->x; | ||||
| seq->strip->stripdata->orig_height = ibuf->y; | seq->strip->stripdata->orig_height = ibuf->y; | ||||
| ▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | for (int view_id = 0; view_id < totviews; view_id++) { | ||||
| seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false); | seq_imbuf_to_sequencer_space(context->scene, ibufs_arr[view_id], false); | ||||
| } | } | ||||
| else if (rres.rect32) { | else if (rres.rect32) { | ||||
| ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect); | ibufs_arr[view_id] = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect); | ||||
| memcpy(ibufs_arr[view_id]->rect, rres.rect32, 4 * rres.rectx * rres.recty); | memcpy(ibufs_arr[view_id]->rect, rres.rect32, 4 * rres.rectx * rres.recty); | ||||
| } | } | ||||
| if (view_id != context->view_id) { | if (view_id != context->view_id) { | ||||
| BKE_sequencer_cache_put( | BKE_sequencer_cache_put(&localcontext, | ||||
| &localcontext, seq, timeline_frame, SEQ_CACHE_STORE_RAW, ibufs_arr[view_id], 0, false); | seq, | ||||
| timeline_frame, | |||||
| SEQ_CACHE_STORE_RAW, | |||||
| ibufs_arr[view_id], | |||||
| 0, | |||||
| IMB_DOWNSCALE_NONE, | |||||
| false); | |||||
| } | } | ||||
| RE_ReleaseResultImage(re); | RE_ReleaseResultImage(re); | ||||
| } | } | ||||
| /* return the original requested ImBuf */ | /* return the original requested ImBuf */ | ||||
| ibuf = ibufs_arr[context->view_id]; | ibuf = ibufs_arr[context->view_id]; | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Strip stack rendering functions | /** \name Strip stack rendering functions | ||||
| * \{ */ | * \{ */ | ||||
| static ImBuf *do_render_strip_uncached(const SeqRenderData *context, | static ImBuf *do_render_strip_uncached(const SeqRenderData *context, | ||||
| SeqRenderState *state, | SeqRenderState *state, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| float timeline_frame, | float timeline_frame, | ||||
| bool *r_is_proxy_image) | bool *r_is_proxy_image, | ||||
| IMB_Downscale *r_downscale_index) | |||||
| { | { | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| float frame_index = seq_give_frame_index(seq, timeline_frame); | float frame_index = seq_give_frame_index(seq, timeline_frame); | ||||
| int type = (seq->type & SEQ_TYPE_EFFECT) ? SEQ_TYPE_EFFECT : seq->type; | int type = (seq->type & SEQ_TYPE_EFFECT) ? SEQ_TYPE_EFFECT : seq->type; | ||||
| switch (type) { | switch (type) { | ||||
| case SEQ_TYPE_META: { | case SEQ_TYPE_META: { | ||||
| ibuf = do_render_strip_seqbase(context, state, seq, frame_index); | ibuf = do_render_strip_seqbase(context, state, seq, frame_index); | ||||
| break; | break; | ||||
| Show All 39 Lines | switch (type) { | ||||
| } | } | ||||
| case SEQ_TYPE_IMAGE: { | case SEQ_TYPE_IMAGE: { | ||||
| ibuf = seq_render_image_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image); | ibuf = seq_render_image_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image); | ||||
| break; | break; | ||||
| } | } | ||||
| case SEQ_TYPE_MOVIE: { | case SEQ_TYPE_MOVIE: { | ||||
| ibuf = seq_render_movie_strip(context, seq, frame_index, timeline_frame, r_is_proxy_image); | ibuf = seq_render_movie_strip( | ||||
| context, seq, frame_index, timeline_frame, r_is_proxy_image, r_downscale_index); | |||||
| break; | break; | ||||
| } | } | ||||
| case SEQ_TYPE_MOVIECLIP: { | case SEQ_TYPE_MOVIECLIP: { | ||||
| ibuf = seq_render_movieclip_strip(context, seq, frame_index, r_is_proxy_image); | ibuf = seq_render_movieclip_strip(context, seq, frame_index, r_is_proxy_image); | ||||
| if (ibuf) { | if (ibuf) { | ||||
| /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */ | /* duplicate frame so movie cache wouldn't be confused by sequencer's stuff */ | ||||
| Show All 26 Lines | |||||
| ImBuf *seq_render_strip(const SeqRenderData *context, | ImBuf *seq_render_strip(const SeqRenderData *context, | ||||
| SeqRenderState *state, | SeqRenderState *state, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| float timeline_frame) | float timeline_frame) | ||||
| { | { | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| bool use_preprocess = false; | bool use_preprocess = false; | ||||
| bool is_proxy_image = false; | bool is_proxy_image = false; | ||||
| IMB_Downscale downscale_index = IMB_DOWNSCALE_NONE; | |||||
| clock_t begin = seq_estimate_render_cost_begin(); | clock_t begin = seq_estimate_render_cost_begin(); | ||||
| ibuf = BKE_sequencer_cache_get( | ibuf = BKE_sequencer_cache_get( | ||||
| context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, false); | context, seq, timeline_frame, SEQ_CACHE_STORE_PREPROCESSED, NULL, false); | ||||
| if (ibuf != NULL) { | if (ibuf != NULL) { | ||||
| return ibuf; | return ibuf; | ||||
| } | } | ||||
| /* Proxies are not stored in cache. */ | /* Proxies are not stored in cache. */ | ||||
| if (!SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) { | if (!SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(context->preview_render_size))) { | ||||
| ibuf = BKE_sequencer_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, false); | ibuf = BKE_sequencer_cache_get( | ||||
| context, seq, timeline_frame, SEQ_CACHE_STORE_RAW, &downscale_index, false); | |||||
| } | } | ||||
| if (ibuf == NULL) { | if (ibuf == NULL) { | ||||
| ibuf = do_render_strip_uncached(context, state, seq, timeline_frame, &is_proxy_image); | ibuf = do_render_strip_uncached( | ||||
| context, state, seq, timeline_frame, &is_proxy_image, &downscale_index); | |||||
| } | } | ||||
| if (ibuf) { | if (ibuf) { | ||||
| use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, timeline_frame); | use_preprocess = BKE_sequencer_input_have_to_preprocess(context, seq, timeline_frame); | ||||
| ibuf = seq_render_preprocess_ibuf( | ibuf = seq_render_preprocess_ibuf(context, | ||||
| context, seq, ibuf, timeline_frame, begin, use_preprocess, is_proxy_image); | seq, | ||||
| ibuf, | |||||
| timeline_frame, | |||||
| begin, | |||||
| use_preprocess, | |||||
| is_proxy_image, | |||||
| downscale_index); | |||||
| } | } | ||||
| if (ibuf == NULL) { | if (ibuf == NULL) { | ||||
| ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect); | ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect); | ||||
| seq_imbuf_assign_spaces(context->scene, ibuf); | seq_imbuf_assign_spaces(context->scene, ibuf); | ||||
| } | } | ||||
| return ibuf; | return ibuf; | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | static ImBuf *seq_render_strip_stack(const SeqRenderData *context, | ||||
| if (count == 0) { | if (count == 0) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| for (i = count - 1; i >= 0; i--) { | for (i = count - 1; i >= 0; i--) { | ||||
| int early_out; | int early_out; | ||||
| Sequence *seq = seq_arr[i]; | Sequence *seq = seq_arr[i]; | ||||
| out = BKE_sequencer_cache_get(context, seq, timeline_frame, SEQ_CACHE_STORE_COMPOSITE, false); | out = BKE_sequencer_cache_get( | ||||
| context, seq, timeline_frame, SEQ_CACHE_STORE_COMPOSITE, NULL, false); | |||||
| if (out) { | if (out) { | ||||
| break; | break; | ||||
| } | } | ||||
| if (seq->blend_mode == SEQ_BLEND_REPLACE) { | if (seq->blend_mode == SEQ_BLEND_REPLACE) { | ||||
| out = seq_render_strip(context, state, seq, timeline_frame); | out = seq_render_strip(context, state, seq, timeline_frame); | ||||
| break; | break; | ||||
| } | } | ||||
| Show All 15 Lines | switch (early_out) { | ||||
| begin = seq_estimate_render_cost_begin(); | begin = seq_estimate_render_cost_begin(); | ||||
| ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect); | ImBuf *ibuf1 = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect); | ||||
| ImBuf *ibuf2 = seq_render_strip(context, state, seq, timeline_frame); | ImBuf *ibuf2 = seq_render_strip(context, state, seq, timeline_frame); | ||||
| out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2); | out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2); | ||||
| float cost = seq_estimate_render_cost_end(context->scene, begin); | float cost = seq_estimate_render_cost_end(context->scene, begin); | ||||
| BKE_sequencer_cache_put( | BKE_sequencer_cache_put(context, | ||||
| context, seq_arr[i], timeline_frame, SEQ_CACHE_STORE_COMPOSITE, out, cost, false); | seq_arr[i], | ||||
| timeline_frame, | |||||
| SEQ_CACHE_STORE_COMPOSITE, | |||||
| out, | |||||
| cost, | |||||
| IMB_DOWNSCALE_NONE, | |||||
| false); | |||||
| IMB_freeImBuf(ibuf1); | IMB_freeImBuf(ibuf1); | ||||
| IMB_freeImBuf(ibuf2); | IMB_freeImBuf(ibuf2); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| if (out) { | if (out) { | ||||
| break; | break; | ||||
| Show All 11 Lines | if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) { | ||||
| out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2); | out = seq_render_strip_stack_apply_effect(context, seq, timeline_frame, ibuf1, ibuf2); | ||||
| IMB_freeImBuf(ibuf1); | IMB_freeImBuf(ibuf1); | ||||
| IMB_freeImBuf(ibuf2); | IMB_freeImBuf(ibuf2); | ||||
| } | } | ||||
| float cost = seq_estimate_render_cost_end(context->scene, begin); | float cost = seq_estimate_render_cost_end(context->scene, begin); | ||||
| BKE_sequencer_cache_put( | BKE_sequencer_cache_put(context, | ||||
| context, seq_arr[i], timeline_frame, SEQ_CACHE_STORE_COMPOSITE, out, cost, false); | seq_arr[i], | ||||
| timeline_frame, | |||||
| SEQ_CACHE_STORE_COMPOSITE, | |||||
| out, | |||||
| cost, | |||||
| IMB_DOWNSCALE_NONE, | |||||
| false); | |||||
| } | } | ||||
| return out; | return out; | ||||
| } | } | ||||
| /** | /** | ||||
| * \return The image buffer or NULL. | * \return The image buffer or NULL. | ||||
| * | * | ||||
| Show All 23 Lines | ImBuf *SEQ_render_give_ibuf(const SeqRenderData *context, float timeline_frame, int chanshown) | ||||
| ImBuf *out = NULL; | ImBuf *out = NULL; | ||||
| Sequence *seq_arr[MAXSEQ + 1]; | Sequence *seq_arr[MAXSEQ + 1]; | ||||
| int count; | int count; | ||||
| count = seq_get_shown_sequences(seqbasep, timeline_frame, chanshown, seq_arr); | count = seq_get_shown_sequences(seqbasep, timeline_frame, chanshown, seq_arr); | ||||
| if (count) { | if (count) { | ||||
| out = BKE_sequencer_cache_get( | out = BKE_sequencer_cache_get( | ||||
| context, seq_arr[count - 1], timeline_frame, SEQ_CACHE_STORE_FINAL_OUT, false); | context, seq_arr[count - 1], timeline_frame, SEQ_CACHE_STORE_FINAL_OUT, NULL, false); | ||||
| } | } | ||||
| BKE_sequencer_cache_free_temp_cache(context->scene, context->task_id, timeline_frame); | BKE_sequencer_cache_free_temp_cache(context->scene, context->task_id, timeline_frame); | ||||
| clock_t begin = seq_estimate_render_cost_begin(); | clock_t begin = seq_estimate_render_cost_begin(); | ||||
| float cost = 0; | float cost = 0; | ||||
| if (count && !out) { | if (count && !out) { | ||||
| BLI_mutex_lock(&seq_render_mutex); | BLI_mutex_lock(&seq_render_mutex); | ||||
| out = seq_render_strip_stack(context, &state, seqbasep, timeline_frame, chanshown); | out = seq_render_strip_stack(context, &state, seqbasep, timeline_frame, chanshown); | ||||
| cost = seq_estimate_render_cost_end(context->scene, begin); | cost = seq_estimate_render_cost_end(context->scene, begin); | ||||
| if (context->is_prefetch_render) { | if (context->is_prefetch_render) { | ||||
| BKE_sequencer_cache_put(context, | BKE_sequencer_cache_put(context, | ||||
| seq_arr[count - 1], | seq_arr[count - 1], | ||||
| timeline_frame, | timeline_frame, | ||||
| SEQ_CACHE_STORE_FINAL_OUT, | SEQ_CACHE_STORE_FINAL_OUT, | ||||
| out, | out, | ||||
| cost, | cost, | ||||
| IMB_DOWNSCALE_NONE, | |||||
| false); | false); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_sequencer_cache_put_if_possible(context, | BKE_sequencer_cache_put_if_possible(context, | ||||
| seq_arr[count - 1], | seq_arr[count - 1], | ||||
| timeline_frame, | timeline_frame, | ||||
| SEQ_CACHE_STORE_FINAL_OUT, | SEQ_CACHE_STORE_FINAL_OUT, | ||||
| out, | out, | ||||
| Show All 34 Lines | |||||