Implementing part of design outlined in #126087. - VSE thumbnail cache has a new implementation, hopefully simpler and easier to understand. - Instead of cache key being a VSE strip, frame index, plus complicated logic for cache items linking etc., - The cache is keyed by media file path (if multiple strips use the same input file, they will share cache entries), frame index within media file, and any extra data (e.g. steam index for multi-steam videos) - Much reduced cache flickering and strange/weird thumbnail choices. - Likewise, thumbnails no longer disappear-and-reload on operations like Undo, dragging new video strip into timeline, or F12 render. - Thumbnails now load faster. - Images use dedicated/faster thumbnail loading routines when a format can do that (e.g. JPG and EXR can). - Movies reuse ffmpeg decoding context for neighboring strips that use the same file (as often happens when cutting footage) - Thumbnail requests are processed on several threads now too. Images and more detail in PR. Pull Request: https://projects.blender.org/blender/blender/pulls/126405
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup sequencer
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
struct bContext;
|
|
struct ImBuf;
|
|
struct rctf;
|
|
struct Sequence;
|
|
struct Scene;
|
|
|
|
#include "BLI_function_ref.hh"
|
|
|
|
#include <string>
|
|
|
|
namespace blender::seq {
|
|
|
|
static constexpr int SEQ_THUMB_SIZE = 256;
|
|
|
|
/**
|
|
* Get a thumbnail image for given strip `seq` at `timeline_frame`.
|
|
*
|
|
* The function can return null if a strip type does not have a thumbnail, a source media file is
|
|
* not found, or the thumbnail has not been loaded yet.
|
|
*
|
|
* A "closest" thumbnail if there is no exact match can also be returned, e.g. for a movie strip
|
|
* the closest frame that has a thumbnail already.
|
|
*
|
|
* When there is no exact match, a request to load a thumbnail will be internally added and
|
|
* processed in the background. */
|
|
ImBuf *thumbnail_cache_get(const bContext *C,
|
|
Scene *scene,
|
|
const Sequence *seq,
|
|
float timeline_frame);
|
|
|
|
/**
|
|
* If total amount of resident thumbnails is too large, try to remove oldest-used ones to
|
|
* keep the cache size in check.
|
|
*/
|
|
void thumbnail_cache_maintain_capacity(Scene *scene);
|
|
|
|
void thumbnail_cache_invalidate_strip(Scene *scene, const Sequence *seq);
|
|
|
|
/**
|
|
* Discard in-flight thumbnail loading requests that are outside of the given view (X coordinate:
|
|
* timeline frames, Y coordinate: channels).
|
|
*/
|
|
void thumbnail_cache_discard_requests_outside(Scene *scene, const rctf &rect);
|
|
|
|
void thumbnail_cache_clear(Scene *scene);
|
|
void thumbnail_cache_destroy(Scene *scene);
|
|
|
|
} // namespace blender::seq
|