Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/render.c
| Show First 20 Lines • Show All 1,993 Lines • ▼ Show 20 Lines | |||||
| /* Render the series of thumbnails and store in cache. */ | /* Render the series of thumbnails and store in cache. */ | ||||
| void SEQ_render_thumbnails(const SeqRenderData *context, | void SEQ_render_thumbnails(const SeqRenderData *context, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| Sequence *seq_orig, | Sequence *seq_orig, | ||||
| float start_frame, | float start_frame, | ||||
| float frame_step, | float frame_step, | ||||
| rctf *view_area, | rctf *view_area, | ||||
| bool update_start_end, | |||||
| const short *stop) | const short *stop) | ||||
| { | { | ||||
| SeqRenderState state; | SeqRenderState state; | ||||
| seq_render_state_init(&state); | seq_render_state_init(&state); | ||||
| /* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not | /* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not | ||||
| * affected, but frame loaded affected. */ | * affected, but frame loaded affected. */ | ||||
| start_frame = start_frame - frame_step; | |||||
| float upper_thumb_bound = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; | float upper_thumb_bound = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; | ||||
| upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step : | upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step : | ||||
| upper_thumb_bound; | upper_thumb_bound; | ||||
| printf("job start: %f, update_start_end: %d\n", start_frame, update_start_end); | |||||
| while ((start_frame < upper_thumb_bound) & !*stop) { | while ((start_frame < upper_thumb_bound) & !*stop) { | ||||
| /* Only render first frame. */ | |||||
| if (update_start_end && start_frame != seq->startdisp) { | |||||
| return; | |||||
| } | |||||
| ImBuf *ibuf = seq_cache_get( | ImBuf *ibuf = seq_cache_get( | ||||
| context, seq_orig, round_fl_to_int(start_frame), SEQ_CACHE_STORE_THUMBNAIL); | context, seq_orig, round_fl_to_int(start_frame), SEQ_CACHE_STORE_THUMBNAIL); | ||||
| if (ibuf) { | if (ibuf) { | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| start_frame += frame_step; | start_frame += frame_step; | ||||
| continue; | continue; | ||||
| } | } | ||||
| ibuf = seq_get_uncached_thumbnail(context, &state, seq, round_fl_to_int(start_frame)); | ibuf = seq_get_uncached_thumbnail(context, &state, seq, round_fl_to_int(start_frame)); | ||||
| printf("job render: %f\n", start_frame); | |||||
| if (ibuf) { | if (ibuf) { | ||||
| seq_cache_thumbnail_put(context, seq_orig, round_fl_to_int(start_frame), ibuf, view_area); | seq_cache_thumbnail_put(context, seq_orig, round_fl_to_int(start_frame), ibuf, view_area); | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| seq_orig->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS; | seq_orig->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Can not open source file. */ | /* Can not open source file. */ | ||||
| seq_orig->flag |= SEQ_FLAG_SKIP_THUMBNAILS; | seq_orig->flag |= SEQ_FLAG_SKIP_THUMBNAILS; | ||||
| return; | return; | ||||
| } | } | ||||
| start_frame += frame_step; | start_frame += frame_step; | ||||
| } | } | ||||
| } | } | ||||
| /* Get frame step for equally spaced thumbnails. These thumbnails should always be present in | /* Get frame step for equally spaced thumbnails. These thumbnails should always be present in | ||||
| * memory, so they can be used when zooming.*/ | * memory, so they can be used when zooming.*/ | ||||
| int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Sequence *seq) | int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Sequence *seq) | ||||
| { | { | ||||
| const int content_len = (seq->enddisp - seq->startdisp - seq->startstill - seq->endstill); | const int content_len = seq->len; | ||||
| /* Arbitrary, but due to performance reasons should be as low as possible. */ | /* Arbitrary, but due to performance reasons should be as low as possible. */ | ||||
| const int thumbnails_base_set_count = min_ii(content_len / 100, 30); | const int thumbnails_base_set_count = min_ii(content_len / 100, 30); | ||||
| if (thumbnails_base_set_count <= 0) { | if (thumbnails_base_set_count <= 0) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| return content_len / thumbnails_base_set_count; | return content_len / thumbnails_base_set_count; | ||||
| } | } | ||||
| /* Render set of evenly spaced thumbnails that are drawn when zooming. */ | /* Render set of evenly spaced thumbnails that are drawn when zooming. */ | ||||
| void SEQ_render_thumbnails_base_set(const SeqRenderData *context, | void SEQ_render_thumbnails_base_set(const SeqRenderData *context, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| Sequence *seq_orig, | Sequence *seq_orig, | ||||
| rctf *view_area, | rctf *view_area, | ||||
| const short *stop) | const short *stop) | ||||
| { | { | ||||
| SeqRenderState state; | SeqRenderState state; | ||||
| seq_render_state_init(&state); | seq_render_state_init(&state); | ||||
| int timeline_frame = seq->startdisp; | int timeline_frame = seq->start; | ||||
| const int frame_step = SEQ_render_thumbnails_guaranteed_set_frame_step_get(seq); | const int frame_step = SEQ_render_thumbnails_guaranteed_set_frame_step_get(seq); | ||||
| while (timeline_frame < seq->enddisp && !*stop) { | while (timeline_frame < seq->start + seq->len && !*stop) { | ||||
| ImBuf *ibuf = seq_cache_get( | ImBuf *ibuf = seq_cache_get( | ||||
| context, seq_orig, roundf(timeline_frame), SEQ_CACHE_STORE_THUMBNAIL); | context, seq_orig, roundf(timeline_frame), SEQ_CACHE_STORE_THUMBNAIL); | ||||
| if (ibuf) { | if (ibuf) { | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| if (frame_step == 0) { | if (frame_step == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 21 Lines | |||||