Cleanup: rename ImBuf anim & anim_index structs

Rename: anim -> ImBufAnim
Rename: anim_index -> ImBufAnimIndex

There were cases where removing redundant "struct" qualifier caused
a warning since the name of the struct member was also anim.

Use uppercase type name to conform with other types names.

Ref !117394
This commit is contained in:
Campbell Barton 2024-01-23 20:26:49 +11:00
parent 30a152216e
commit 6cc8ac7cb3
24 changed files with 183 additions and 170 deletions

View File

@ -19,6 +19,7 @@ extern "C" {
struct Depsgraph; struct Depsgraph;
struct ID; struct ID;
struct ImBuf; struct ImBuf;
struct ImBufAnim;
struct Image; struct Image;
struct ImageFormatData; struct ImageFormatData;
struct ImagePool; struct ImagePool;
@ -31,7 +32,6 @@ struct RenderResult;
struct ReportList; struct ReportList;
struct Scene; struct Scene;
struct StampData; struct StampData;
struct anim;
#define IMA_MAX_SPACE 64 #define IMA_MAX_SPACE 64
#define IMA_UDIM_MAX 2000 #define IMA_UDIM_MAX 2000
@ -108,11 +108,11 @@ int BKE_imbuf_write_as(struct ImBuf *ibuf,
/** /**
* Used by sequencer too. * Used by sequencer too.
*/ */
struct anim *openanim(const char *filepath, struct ImBufAnim *openanim(const char *filepath,
int flags, int flags,
int streamindex, int streamindex,
char colorspace[IMA_MAX_SPACE]); char colorspace[IMA_MAX_SPACE]);
struct anim *openanim_noload(const char *filepath, struct ImBufAnim *openanim_noload(const char *filepath,
int flags, int flags,
int streamindex, int streamindex,
char colorspace[IMA_MAX_SPACE]); char colorspace[IMA_MAX_SPACE]);

View File

@ -2626,20 +2626,23 @@ int BKE_imbuf_write_stamp(const Scene *scene,
return BKE_imbuf_write(ibuf, filepath, imf); return BKE_imbuf_write(ibuf, filepath, imf);
} }
anim *openanim_noload(const char *filepath, ImBufAnim *openanim_noload(const char *filepath,
int flags, int flags,
int streamindex, int streamindex,
char colorspace[IMA_MAX_SPACE]) char colorspace[IMA_MAX_SPACE])
{ {
anim *anim; ImBufAnim *anim;
anim = IMB_open_anim(filepath, flags, streamindex, colorspace); anim = IMB_open_anim(filepath, flags, streamindex, colorspace);
return anim; return anim;
} }
anim *openanim(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) ImBufAnim *openanim(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE])
{ {
anim *anim; ImBufAnim *anim;
ImBuf *ibuf; ImBuf *ibuf;
anim = IMB_open_anim(filepath, flags, streamindex, colorspace); anim = IMB_open_anim(filepath, flags, streamindex, colorspace);

View File

@ -10,7 +10,7 @@
struct MovieClip; struct MovieClip;
struct MovieClipCache; struct MovieClipCache;
struct anim; struct ImBufAnim;
namespace blender::deg { namespace blender::deg {
@ -26,7 +26,7 @@ class MovieClipBackup {
void init_from_movieclip(MovieClip *movieclip); void init_from_movieclip(MovieClip *movieclip);
void restore_to_movieclip(MovieClip *movieclip); void restore_to_movieclip(MovieClip *movieclip);
struct anim *anim; struct ImBufAnim *anim;
struct MovieClipCache *cache; struct MovieClipCache *cache;
}; };

View File

@ -1242,7 +1242,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
int duration = 0; int duration = 0;
if (ima->source == IMA_SRC_MOVIE && BKE_image_has_anim(ima)) { if (ima->source == IMA_SRC_MOVIE && BKE_image_has_anim(ima)) {
anim *anim = ((ImageAnim *)ima->anims.first)->anim; ImBufAnim *anim = ((ImageAnim *)ima->anims.first)->anim;
if (anim) { if (anim) {
duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN); duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
} }

View File

@ -1702,7 +1702,7 @@ static int image_match_len_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
anim *anim = ((ImageAnim *)ima->anims.first)->anim; ImBufAnim *anim = ((ImageAnim *)ima->anims.first)->anim;
if (!anim) { if (!anim) {
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }

View File

@ -537,7 +537,7 @@ static void prefetch_data_fn(void *custom_data, wmJobWorkerStatus * /*worker_sta
} }
char colorspace[64] = "\0"; /* 64 == MAX_COLORSPACE_NAME length. */ char colorspace[64] = "\0"; /* 64 == MAX_COLORSPACE_NAME length. */
anim *anim = openanim(job_data->path, IB_rect, 0, colorspace); ImBufAnim *anim = openanim(job_data->path, IB_rect, 0, colorspace);
if (anim != nullptr) { if (anim != nullptr) {
g_drop_coords.strip_len = IMB_anim_get_duration(anim, IMB_TC_NONE); g_drop_coords.strip_len = IMB_anim_get_duration(anim, IMB_TC_NONE);

View File

@ -52,7 +52,7 @@ struct ImBuf;
struct rctf; struct rctf;
struct rcti; struct rcti;
struct anim; struct ImBufAnim;
struct ColorManagedDisplay; struct ColorManagedDisplay;
@ -270,19 +270,19 @@ enum eIMBInterpolationFilterMode {
/** /**
* Defaults to BL_proxy within the directory of the animation. * Defaults to BL_proxy within the directory of the animation.
*/ */
void IMB_anim_set_index_dir(anim *anim, const char *dir); void IMB_anim_set_index_dir(ImBufAnim *anim, const char *dir);
void IMB_anim_get_filename(anim *anim, char *filename, int filename_maxncpy); void IMB_anim_get_filename(ImBufAnim *anim, char *filename, int filename_maxncpy);
int IMB_anim_index_get_frame_index(anim *anim, IMB_Timecode_Type tc, int position); int IMB_anim_index_get_frame_index(ImBufAnim *anim, IMB_Timecode_Type tc, int position);
int IMB_anim_proxy_get_existing(anim *anim); int IMB_anim_proxy_get_existing(ImBufAnim *anim);
struct IndexBuildContext; struct IndexBuildContext;
/** /**
* Prepare context for proxies/time-codes builder * Prepare context for proxies/time-codes builder
*/ */
IndexBuildContext *IMB_anim_index_rebuild_context(anim *anim, IndexBuildContext *IMB_anim_index_rebuild_context(ImBufAnim *anim,
IMB_Timecode_Type tcs_in_use, IMB_Timecode_Type tcs_in_use,
int proxy_sizes_in_use, int proxy_sizes_in_use,
int quality, int quality,
@ -306,34 +306,37 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, bool stop);
/** /**
* Return the length (in frames) of the given \a anim. * Return the length (in frames) of the given \a anim.
*/ */
int IMB_anim_get_duration(anim *anim, IMB_Timecode_Type tc); int IMB_anim_get_duration(ImBufAnim *anim, IMB_Timecode_Type tc);
/** /**
* Return the encoded start offset (in seconds) of the given \a anim. * Return the encoded start offset (in seconds) of the given \a anim.
*/ */
double IMD_anim_get_offset(anim *anim); double IMD_anim_get_offset(ImBufAnim *anim);
/** /**
* Return the fps contained in movie files (function rval is false, * Return the fps contained in movie files (function rval is false,
* and frs_sec and frs_sec_base untouched if none available!) * and frs_sec and frs_sec_base untouched if none available!)
*/ */
bool IMB_anim_get_fps(const anim *anim, bool no_av_base, short *r_frs_sec, float *r_frs_sec_base); bool IMB_anim_get_fps(const ImBufAnim *anim,
bool no_av_base,
short *r_frs_sec,
float *r_frs_sec_base);
anim *IMB_open_anim(const char *filepath, ImBufAnim *IMB_open_anim(const char *filepath,
int ib_flags, int ib_flags,
int streamindex, int streamindex,
char colorspace[IM_MAX_SPACE]); char colorspace[IM_MAX_SPACE]);
void IMB_suffix_anim(anim *anim, const char *suffix); void IMB_suffix_anim(ImBufAnim *anim, const char *suffix);
void IMB_close_anim(anim *anim); void IMB_close_anim(ImBufAnim *anim);
void IMB_close_anim_proxies(anim *anim); void IMB_close_anim_proxies(ImBufAnim *anim);
bool IMB_anim_can_produce_frames(const anim *anim); bool IMB_anim_can_produce_frames(const ImBufAnim *anim);
int ismovie(const char *filepath); int ismovie(const char *filepath);
int IMB_anim_get_image_width(anim *anim); int IMB_anim_get_image_width(ImBufAnim *anim);
int IMB_anim_get_image_height(anim *anim); int IMB_anim_get_image_height(ImBufAnim *anim);
bool IMB_get_gop_decode_time(anim *anim); bool IMB_get_gop_decode_time(ImBufAnim *anim);
ImBuf *IMB_anim_absolute(anim *anim, ImBuf *IMB_anim_absolute(ImBufAnim *anim,
int position, int position,
IMB_Timecode_Type tc /* = 1 = IMB_TC_RECORD_RUN */, IMB_Timecode_Type tc /* = 1 = IMB_TC_RECORD_RUN */,
IMB_Proxy_Size preview_size /* = 0 = IMB_PROXY_NONE */); IMB_Proxy_Size preview_size /* = 0 = IMB_PROXY_NONE */);
@ -341,9 +344,9 @@ ImBuf *IMB_anim_absolute(anim *anim,
/** /**
* fetches a define preview-frame, usually half way into the movie. * fetches a define preview-frame, usually half way into the movie.
*/ */
ImBuf *IMB_anim_previewframe(anim *anim); ImBuf *IMB_anim_previewframe(ImBufAnim *anim);
void IMB_free_anim(anim *anim); void IMB_free_anim(ImBufAnim *anim);
#define FILTER_MASK_NULL 0 #define FILTER_MASK_NULL 0
#define FILTER_MASK_MARGIN 1 #define FILTER_MASK_MARGIN 1

View File

@ -10,7 +10,7 @@
struct IDProperty; struct IDProperty;
struct ImBuf; struct ImBuf;
struct anim; struct ImBufAnim;
/** /**
* The metadata is a list of key/value pairs (both char *) that can me * The metadata is a list of key/value pairs (both char *) that can me
@ -55,7 +55,7 @@ bool IMB_metadata_get_field(IDProperty *metadata,
void IMB_metadata_set_field(IDProperty *metadata, const char *key, const char *value); void IMB_metadata_set_field(IDProperty *metadata, const char *key, const char *value);
void IMB_metadata_copy(ImBuf *dimb, ImBuf *simb); void IMB_metadata_copy(ImBuf *dimb, ImBuf *simb);
IDProperty *IMB_anim_load_metadata(anim *anim); IDProperty *IMB_anim_load_metadata(ImBufAnim *anim);
/* Invoke callback for every value stored in the metadata. */ /* Invoke callback for every value stored in the metadata. */
typedef void (*IMBMetadataForeachCb)(const char *field, const char *value, void *userdata); typedef void (*IMBMetadataForeachCb)(const char *field, const char *value, void *userdata);

View File

@ -56,7 +56,7 @@ extern "C" {
# define LITTLE_LONG ENDIAN_NOP # define LITTLE_LONG ENDIAN_NOP
#endif #endif
/* anim.curtype, runtime only */ /** #ImBufAnim::curtype, runtime only. */
#define ANIM_NONE 0 #define ANIM_NONE 0
#define ANIM_SEQUENCE (1 << 0) #define ANIM_SEQUENCE (1 << 0)
#define ANIM_MOVIE (1 << 4) #define ANIM_MOVIE (1 << 4)
@ -67,9 +67,9 @@ extern "C" {
struct IDProperty; struct IDProperty;
struct _AviMovie; struct _AviMovie;
struct anim_index; struct ImBufAnimIndex;
struct anim { struct ImBufAnim {
int ib_flags; int ib_flags;
int curtype; int curtype;
int cur_position; /* index 0 = 1e, 1 = 2e, enz. */ int cur_position; /* index 0 = 1e, 1 = 2e, enz. */
@ -132,8 +132,8 @@ struct anim {
int proxies_tried; int proxies_tried;
int indices_tried; int indices_tried;
struct anim *proxy_anim[IMB_PROXY_MAX_SLOT]; struct ImBufAnim *proxy_anim[IMB_PROXY_MAX_SLOT];
struct anim_index *curr_idx[IMB_TC_MAX_SLOT]; struct ImBufAnimIndex *curr_idx[IMB_TC_MAX_SLOT];
char colorspace[64]; char colorspace[64];
char suffix[64]; /* MAX_NAME - multiview */ char suffix[64]; /* MAX_NAME - multiview */

View File

@ -42,7 +42,7 @@ typedef struct anim_index_entry {
uint64_t pts; uint64_t pts;
} anim_index_entry; } anim_index_entry;
struct anim_index { struct ImBufAnimIndex {
char filepath[1024]; char filepath[1024];
int num_entries; int num_entries;
@ -84,23 +84,23 @@ void IMB_index_builder_proc_frame(anim_index_builder *fp,
void IMB_index_builder_finish(anim_index_builder *fp, int rollback); void IMB_index_builder_finish(anim_index_builder *fp, int rollback);
struct anim_index *IMB_indexer_open(const char *name); struct ImBufAnimIndex *IMB_indexer_open(const char *name);
uint64_t IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index); uint64_t IMB_indexer_get_seek_pos(struct ImBufAnimIndex *idx, int frame_index);
uint64_t IMB_indexer_get_seek_pos_pts(struct anim_index *idx, int frame_index); uint64_t IMB_indexer_get_seek_pos_pts(struct ImBufAnimIndex *idx, int frame_index);
uint64_t IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index); uint64_t IMB_indexer_get_seek_pos_dts(struct ImBufAnimIndex *idx, int frame_index);
int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno); int IMB_indexer_get_frame_index(struct ImBufAnimIndex *idx, int frameno);
uint64_t IMB_indexer_get_pts(struct anim_index *idx, int frame_index); uint64_t IMB_indexer_get_pts(struct ImBufAnimIndex *idx, int frame_index);
int IMB_indexer_get_duration(struct anim_index *idx); int IMB_indexer_get_duration(struct ImBufAnimIndex *idx);
int IMB_indexer_can_scan(struct anim_index *idx, int old_frame_index, int new_frame_index); int IMB_indexer_can_scan(struct ImBufAnimIndex *idx, int old_frame_index, int new_frame_index);
void IMB_indexer_close(struct anim_index *idx); void IMB_indexer_close(struct ImBufAnimIndex *idx);
void IMB_free_indices(struct anim *anim); void IMB_free_indices(struct ImBufAnim *anim);
struct anim *IMB_anim_open_proxy(struct anim *anim, IMB_Proxy_Size preview_size); struct ImBufAnim *IMB_anim_open_proxy(struct ImBufAnim *anim, IMB_Proxy_Size preview_size);
struct anim_index *IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc); struct ImBufAnimIndex *IMB_anim_open_index(struct ImBufAnim *anim, IMB_Timecode_Type tc);
int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size); int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size);
int IMB_timecode_to_array_index(IMB_Timecode_Type tc); int IMB_timecode_to_array_index(IMB_Timecode_Type tc);

View File

@ -83,21 +83,21 @@ int ismovie(const char * /*filepath*/)
} }
/* never called, just keep the linker happy */ /* never called, just keep the linker happy */
static int startmovie(anim * /*anim*/) static int startmovie(ImBufAnim * /*anim*/)
{ {
return 1; return 1;
} }
static ImBuf *movie_fetchibuf(anim * /*anim*/, int /*position*/) static ImBuf *movie_fetchibuf(ImBufAnim * /*anim*/, int /*position*/)
{ {
return nullptr; return nullptr;
} }
static void free_anim_movie(anim * /*anim*/) static void free_anim_movie(ImBufAnim * /*anim*/)
{ {
/* pass */ /* pass */
} }
#ifdef WITH_AVI #ifdef WITH_AVI
static void free_anim_avi(anim *anim) static void free_anim_avi(ImBufAnim *anim)
{ {
# if defined(_WIN32) # if defined(_WIN32)
int i; int i;
@ -138,10 +138,10 @@ static void free_anim_avi(anim *anim)
#endif /* WITH_AVI */ #endif /* WITH_AVI */
#ifdef WITH_FFMPEG #ifdef WITH_FFMPEG
static void free_anim_ffmpeg(anim *anim); static void free_anim_ffmpeg(ImBufAnim *anim);
#endif #endif
void IMB_free_anim(anim *anim) void IMB_free_anim(ImBufAnim *anim)
{ {
if (anim == nullptr) { if (anim == nullptr) {
printf("free anim, anim == nullptr\n"); printf("free anim, anim == nullptr\n");
@ -163,7 +163,7 @@ void IMB_free_anim(anim *anim)
MEM_freeN(anim); MEM_freeN(anim);
} }
void IMB_close_anim(anim *anim) void IMB_close_anim(ImBufAnim *anim)
{ {
if (anim == nullptr) { if (anim == nullptr) {
return; return;
@ -172,7 +172,7 @@ void IMB_close_anim(anim *anim)
IMB_free_anim(anim); IMB_free_anim(anim);
} }
void IMB_close_anim_proxies(anim *anim) void IMB_close_anim_proxies(ImBufAnim *anim)
{ {
if (anim == nullptr) { if (anim == nullptr) {
return; return;
@ -181,7 +181,7 @@ void IMB_close_anim_proxies(anim *anim)
IMB_free_indices(anim); IMB_free_indices(anim);
} }
IDProperty *IMB_anim_load_metadata(anim *anim) IDProperty *IMB_anim_load_metadata(ImBufAnim *anim)
{ {
switch (anim->curtype) { switch (anim->curtype) {
case ANIM_FFMPEG: { case ANIM_FFMPEG: {
@ -216,16 +216,16 @@ IDProperty *IMB_anim_load_metadata(anim *anim)
return anim->metadata; return anim->metadata;
} }
anim *IMB_open_anim(const char *filepath, ImBufAnim *IMB_open_anim(const char *filepath,
int ib_flags, int ib_flags,
int streamindex, int streamindex,
char colorspace[IM_MAX_SPACE]) char colorspace[IM_MAX_SPACE])
{ {
anim *anim; ImBufAnim *anim;
BLI_assert(!BLI_path_is_rel(filepath)); BLI_assert(!BLI_path_is_rel(filepath));
anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct"); anim = (ImBufAnim *)MEM_callocN(sizeof(ImBufAnim), "anim struct");
if (anim != nullptr) { if (anim != nullptr) {
if (colorspace) { if (colorspace) {
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@ -243,7 +243,7 @@ anim *IMB_open_anim(const char *filepath,
return anim; return anim;
} }
bool IMB_anim_can_produce_frames(const anim *anim) bool IMB_anim_can_produce_frames(const ImBufAnim *anim)
{ {
#if !(defined(WITH_AVI) || defined(WITH_FFMPEG)) #if !(defined(WITH_AVI) || defined(WITH_FFMPEG))
UNUSED_VARS(anim); UNUSED_VARS(anim);
@ -262,13 +262,13 @@ bool IMB_anim_can_produce_frames(const anim *anim)
return false; return false;
} }
void IMB_suffix_anim(anim *anim, const char *suffix) void IMB_suffix_anim(ImBufAnim *anim, const char *suffix)
{ {
STRNCPY(anim->suffix, suffix); STRNCPY(anim->suffix, suffix);
} }
#ifdef WITH_AVI #ifdef WITH_AVI
static int startavi(anim *anim) static int startavi(ImBufAnim *anim)
{ {
AviError avierror; AviError avierror;
@ -387,7 +387,7 @@ static int startavi(anim *anim)
#endif /* WITH_AVI */ #endif /* WITH_AVI */
#ifdef WITH_AVI #ifdef WITH_AVI
static ImBuf *avi_fetchibuf(anim *anim, int position) static ImBuf *avi_fetchibuf(ImBufAnim *anim, int position)
{ {
ImBuf *ibuf = nullptr; ImBuf *ibuf = nullptr;
int *tmp; int *tmp;
@ -442,7 +442,7 @@ static ImBuf *avi_fetchibuf(anim *anim, int position)
#ifdef WITH_FFMPEG #ifdef WITH_FFMPEG
static int startffmpeg(anim *anim) static int startffmpeg(ImBufAnim *anim)
{ {
int i, video_stream_index; int i, video_stream_index;
@ -747,7 +747,7 @@ static int startffmpeg(anim *anim)
return 0; return 0;
} }
static double ffmpeg_steps_per_frame_get(anim *anim) static double ffmpeg_steps_per_frame_get(ImBufAnim *anim)
{ {
AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream]; AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
AVRational time_base = v_st->time_base; AVRational time_base = v_st->time_base;
@ -760,7 +760,7 @@ static double ffmpeg_steps_per_frame_get(anim *anim)
* It is likely to overshoot and scanning stops. Having previous frame backed up, it is possible * It is likely to overshoot and scanning stops. Having previous frame backed up, it is possible
* to use it when overshoot happens. * to use it when overshoot happens.
*/ */
static void ffmpeg_double_buffer_backup_frame_store(anim *anim, int64_t pts_to_search) static void ffmpeg_double_buffer_backup_frame_store(ImBufAnim *anim, int64_t pts_to_search)
{ {
/* `anim->pFrame` is beyond `pts_to_search`. Don't store it. */ /* `anim->pFrame` is beyond `pts_to_search`. Don't store it. */
if (anim->pFrame_backup_complete && anim->cur_pts >= pts_to_search) { if (anim->pFrame_backup_complete && anim->cur_pts >= pts_to_search) {
@ -779,7 +779,7 @@ static void ffmpeg_double_buffer_backup_frame_store(anim *anim, int64_t pts_to_s
} }
/* Free stored backup frame. */ /* Free stored backup frame. */
static void ffmpeg_double_buffer_backup_frame_clear(anim *anim) static void ffmpeg_double_buffer_backup_frame_clear(ImBufAnim *anim)
{ {
if (anim->pFrame_backup_complete) { if (anim->pFrame_backup_complete) {
av_frame_unref(anim->pFrame_backup); av_frame_unref(anim->pFrame_backup);
@ -788,7 +788,7 @@ static void ffmpeg_double_buffer_backup_frame_clear(anim *anim)
} }
/* Return recently decoded frame. If it does not exist, return frame from backup buffer. */ /* Return recently decoded frame. If it does not exist, return frame from backup buffer. */
static AVFrame *ffmpeg_double_buffer_frame_fallback_get(anim *anim) static AVFrame *ffmpeg_double_buffer_frame_fallback_get(ImBufAnim *anim)
{ {
av_log(anim->pFormatCtx, AV_LOG_ERROR, "DECODE UNHAPPY: PTS not matched!\n"); av_log(anim->pFormatCtx, AV_LOG_ERROR, "DECODE UNHAPPY: PTS not matched!\n");
@ -806,7 +806,7 @@ static AVFrame *ffmpeg_double_buffer_frame_fallback_get(anim *anim)
* *
* \param ibuf: The frame just read by `ffmpeg_fetchibuf`, processed in-place. * \param ibuf: The frame just read by `ffmpeg_fetchibuf`, processed in-place.
*/ */
static void ffmpeg_postprocess(anim *anim, AVFrame *input, ImBuf *ibuf) static void ffmpeg_postprocess(ImBufAnim *anim, AVFrame *input, ImBuf *ibuf)
{ {
int filter_y = 0; int filter_y = 0;
@ -890,7 +890,7 @@ static void ffmpeg_postprocess(anim *anim, AVFrame *input, ImBuf *ibuf)
} }
} }
static void final_frame_log(anim *anim, static void final_frame_log(ImBufAnim *anim,
int64_t frame_pts_start, int64_t frame_pts_start,
int64_t frame_pts_end, int64_t frame_pts_end,
const char *str) const char *str)
@ -909,7 +909,7 @@ static bool ffmpeg_pts_isect(int64_t pts_start, int64_t pts_end, int64_t pts_to_
} }
/* Return frame that matches `pts_to_search`, nullptr if matching frame does not exist. */ /* Return frame that matches `pts_to_search`, nullptr if matching frame does not exist. */
static AVFrame *ffmpeg_frame_by_pts_get(anim *anim, int64_t pts_to_search) static AVFrame *ffmpeg_frame_by_pts_get(ImBufAnim *anim, int64_t pts_to_search)
{ {
/* NOTE: `frame->pts + frame->pkt_duration` does not always match pts of next frame. /* NOTE: `frame->pts + frame->pkt_duration` does not always match pts of next frame.
* See footage from #86361. Here it is OK to use, because PTS must match current or backup frame. * See footage from #86361. Here it is OK to use, because PTS must match current or backup frame.
@ -936,7 +936,7 @@ static AVFrame *ffmpeg_frame_by_pts_get(anim *anim, int64_t pts_to_search)
return best_frame; return best_frame;
} }
static void ffmpeg_decode_store_frame_pts(anim *anim) static void ffmpeg_decode_store_frame_pts(ImBufAnim *anim)
{ {
anim->cur_pts = av_get_pts_from_frame(anim->pFrame); anim->cur_pts = av_get_pts_from_frame(anim->pFrame);
@ -951,7 +951,7 @@ static void ffmpeg_decode_store_frame_pts(anim *anim)
int64_t(anim->cur_pts)); int64_t(anim->cur_pts));
} }
static int ffmpeg_read_video_frame(anim *anim, AVPacket *packet) static int ffmpeg_read_video_frame(ImBufAnim *anim, AVPacket *packet)
{ {
int ret = 0; int ret = 0;
while ((ret = av_read_frame(anim->pFormatCtx, packet)) >= 0) { while ((ret = av_read_frame(anim->pFormatCtx, packet)) >= 0) {
@ -966,7 +966,7 @@ static int ffmpeg_read_video_frame(anim *anim, AVPacket *packet)
} }
/* decode one video frame also considering the packet read into cur_packet */ /* decode one video frame also considering the packet read into cur_packet */
static int ffmpeg_decode_video_frame(anim *anim) static int ffmpeg_decode_video_frame(ImBufAnim *anim)
{ {
av_log(anim->pFormatCtx, AV_LOG_DEBUG, " DECODE VIDEO FRAME\n"); av_log(anim->pFormatCtx, AV_LOG_DEBUG, " DECODE VIDEO FRAME\n");
@ -1079,7 +1079,7 @@ static int ffmpeg_seek_by_byte(AVFormatContext *pFormatCtx)
return false; return false;
} }
static int64_t ffmpeg_get_seek_pts(anim *anim, int64_t pts_to_search) static int64_t ffmpeg_get_seek_pts(ImBufAnim *anim, int64_t pts_to_search)
{ {
/* FFMPEG seeks internally using DTS values instead of PTS. In some files DTS and PTS values are /* FFMPEG seeks internally using DTS values instead of PTS. In some files DTS and PTS values are
* offset and sometimes FFMPEG fails to take this into account when seeking. * offset and sometimes FFMPEG fails to take this into account when seeking.
@ -1099,7 +1099,7 @@ static int64_t ffmpeg_get_seek_pts(anim *anim, int64_t pts_to_search)
/* This gives us an estimate of which pts our requested frame will have. /* This gives us an estimate of which pts our requested frame will have.
* Note that this might be off a bit in certain video files, but it should still be close enough. * Note that this might be off a bit in certain video files, but it should still be close enough.
*/ */
static int64_t ffmpeg_get_pts_to_search(anim *anim, anim_index *tc_index, int position) static int64_t ffmpeg_get_pts_to_search(ImBufAnim *anim, ImBufAnimIndex *tc_index, int position)
{ {
int64_t pts_to_search; int64_t pts_to_search;
@ -1120,12 +1120,12 @@ static int64_t ffmpeg_get_pts_to_search(anim *anim, anim_index *tc_index, int po
return pts_to_search; return pts_to_search;
} }
static bool ffmpeg_is_first_frame_decode(anim *anim) static bool ffmpeg_is_first_frame_decode(ImBufAnim *anim)
{ {
return anim->pFrame_complete == false; return anim->pFrame_complete == false;
} }
static void ffmpeg_scan_log(anim *anim, int64_t pts_to_search) static void ffmpeg_scan_log(ImBufAnim *anim, int64_t pts_to_search)
{ {
int64_t frame_pts_start = av_get_pts_from_frame(anim->pFrame); int64_t frame_pts_start = av_get_pts_from_frame(anim->pFrame);
int64_t frame_pts_end = frame_pts_start + av_get_frame_duration_in_pts_units(anim->pFrame); int64_t frame_pts_end = frame_pts_start + av_get_frame_duration_in_pts_units(anim->pFrame);
@ -1138,7 +1138,7 @@ static void ffmpeg_scan_log(anim *anim, int64_t pts_to_search)
} }
/* Decode frames one by one until its PTS matches pts_to_search. */ /* Decode frames one by one until its PTS matches pts_to_search. */
static void ffmpeg_decode_video_frame_scan(anim *anim, int64_t pts_to_search) static void ffmpeg_decode_video_frame_scan(ImBufAnim *anim, int64_t pts_to_search)
{ {
const int64_t start_gop_frame = anim->cur_key_frame_pts; const int64_t start_gop_frame = anim->cur_key_frame_pts;
bool decode_error = false; bool decode_error = false;
@ -1162,7 +1162,7 @@ static void ffmpeg_decode_video_frame_scan(anim *anim, int64_t pts_to_search)
* read_seek2() functions defined. When seeking in these formats, rule to seek to last * read_seek2() functions defined. When seeking in these formats, rule to seek to last
* necessary I-frame is not honored. It is not even guaranteed that I-frame, that must be * necessary I-frame is not honored. It is not even guaranteed that I-frame, that must be
* decoded will be read. See https://trac.ffmpeg.org/ticket/1607 & #86944. */ * decoded will be read. See https://trac.ffmpeg.org/ticket/1607 & #86944. */
static int ffmpeg_generic_seek_workaround(anim *anim, static int ffmpeg_generic_seek_workaround(ImBufAnim *anim,
int64_t *requested_pts, int64_t *requested_pts,
int64_t pts_to_search) int64_t pts_to_search)
{ {
@ -1224,7 +1224,7 @@ static int ffmpeg_generic_seek_workaround(anim *anim,
/* Read packet until timestamp matches `anim->cur_packet`, thus recovering internal `anim` stream /* Read packet until timestamp matches `anim->cur_packet`, thus recovering internal `anim` stream
* position state. */ * position state. */
static void ffmpeg_seek_recover_stream_position(anim *anim) static void ffmpeg_seek_recover_stream_position(ImBufAnim *anim)
{ {
AVPacket *temp_packet = av_packet_alloc(); AVPacket *temp_packet = av_packet_alloc();
while (ffmpeg_read_video_frame(anim, temp_packet) >= 0) { while (ffmpeg_read_video_frame(anim, temp_packet) >= 0) {
@ -1240,7 +1240,7 @@ static void ffmpeg_seek_recover_stream_position(anim *anim)
} }
/* Check if seeking and mainly flushing codec buffers is needed. */ /* Check if seeking and mainly flushing codec buffers is needed. */
static bool ffmpeg_seek_buffers_need_flushing(anim *anim, int position, int64_t seek_pos) static bool ffmpeg_seek_buffers_need_flushing(ImBufAnim *anim, int position, int64_t seek_pos)
{ {
/* Get timestamp of packet read after seeking. */ /* Get timestamp of packet read after seeking. */
AVPacket *temp_packet = av_packet_alloc(); AVPacket *temp_packet = av_packet_alloc();
@ -1269,9 +1269,9 @@ static bool ffmpeg_seek_buffers_need_flushing(anim *anim, int position, int64_t
} }
/* Seek to last necessary key frame. */ /* Seek to last necessary key frame. */
static int ffmpeg_seek_to_key_frame(anim *anim, static int ffmpeg_seek_to_key_frame(ImBufAnim *anim,
int position, int position,
anim_index *tc_index, ImBufAnimIndex *tc_index,
int64_t pts_to_search) int64_t pts_to_search)
{ {
int64_t seek_pos; int64_t seek_pos;
@ -1361,14 +1361,14 @@ static int ffmpeg_seek_to_key_frame(anim *anim,
return ret; return ret;
} }
static bool ffmpeg_must_seek(anim *anim, int position) static bool ffmpeg_must_seek(ImBufAnim *anim, int position)
{ {
bool must_seek = position != anim->cur_position + 1 || ffmpeg_is_first_frame_decode(anim); bool must_seek = position != anim->cur_position + 1 || ffmpeg_is_first_frame_decode(anim);
anim->seek_before_decode = must_seek; anim->seek_before_decode = must_seek;
return must_seek; return must_seek;
} }
static ImBuf *ffmpeg_fetchibuf(anim *anim, int position, IMB_Timecode_Type tc) static ImBuf *ffmpeg_fetchibuf(ImBufAnim *anim, int position, IMB_Timecode_Type tc)
{ {
if (anim == nullptr) { if (anim == nullptr) {
return nullptr; return nullptr;
@ -1376,7 +1376,7 @@ static ImBuf *ffmpeg_fetchibuf(anim *anim, int position, IMB_Timecode_Type tc)
av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: seek_pos=%d\n", position); av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: seek_pos=%d\n", position);
anim_index *tc_index = IMB_anim_open_index(anim, tc); ImBufAnimIndex *tc_index = IMB_anim_open_index(anim, tc);
int64_t pts_to_search = ffmpeg_get_pts_to_search(anim, tc_index, position); int64_t pts_to_search = ffmpeg_get_pts_to_search(anim, tc_index, position);
AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream]; AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
double frame_rate = av_q2d(v_st->r_frame_rate); double frame_rate = av_q2d(v_st->r_frame_rate);
@ -1455,7 +1455,7 @@ static ImBuf *ffmpeg_fetchibuf(anim *anim, int position, IMB_Timecode_Type tc)
return cur_frame_final; return cur_frame_final;
} }
static void free_anim_ffmpeg(anim *anim) static void free_anim_ffmpeg(ImBufAnim *anim)
{ {
if (anim == nullptr) { if (anim == nullptr) {
return; return;
@ -1482,7 +1482,7 @@ static void free_anim_ffmpeg(anim *anim)
* Try to initialize the #anim struct. * Try to initialize the #anim struct.
* Returns true on success. * Returns true on success.
*/ */
static bool anim_getnew(anim *anim) static bool anim_getnew(ImBufAnim *anim)
{ {
BLI_assert(anim->curtype == ANIM_NONE); BLI_assert(anim->curtype == ANIM_NONE);
if (anim == nullptr) { if (anim == nullptr) {
@ -1539,7 +1539,7 @@ static bool anim_getnew(anim *anim)
return true; return true;
} }
ImBuf *IMB_anim_previewframe(anim *anim) ImBuf *IMB_anim_previewframe(ImBufAnim *anim)
{ {
ImBuf *ibuf = nullptr; ImBuf *ibuf = nullptr;
int position = 0; int position = 0;
@ -1577,7 +1577,7 @@ ImBuf *IMB_anim_previewframe(anim *anim)
return ibuf; return ibuf;
} }
ImBuf *IMB_anim_absolute(anim *anim, ImBuf *IMB_anim_absolute(ImBufAnim *anim,
int position, int position,
IMB_Timecode_Type tc, IMB_Timecode_Type tc,
IMB_Proxy_Size preview_size) IMB_Proxy_Size preview_size)
@ -1605,7 +1605,7 @@ ImBuf *IMB_anim_absolute(anim *anim,
} }
} }
else { else {
struct anim *proxy = IMB_anim_open_proxy(anim, preview_size); ImBufAnim *proxy = IMB_anim_open_proxy(anim, preview_size);
if (proxy) { if (proxy) {
position = IMB_anim_index_get_frame_index(anim, tc, position); position = IMB_anim_index_get_frame_index(anim, tc, position);
@ -1666,9 +1666,9 @@ ImBuf *IMB_anim_absolute(anim *anim,
/***/ /***/
int IMB_anim_get_duration(anim *anim, IMB_Timecode_Type tc) int IMB_anim_get_duration(ImBufAnim *anim, IMB_Timecode_Type tc)
{ {
anim_index *idx; ImBufAnimIndex *idx;
if (tc == IMB_TC_NONE) { if (tc == IMB_TC_NONE) {
return anim->duration_in_frames; return anim->duration_in_frames;
} }
@ -1681,12 +1681,15 @@ int IMB_anim_get_duration(anim *anim, IMB_Timecode_Type tc)
return IMB_indexer_get_duration(idx); return IMB_indexer_get_duration(idx);
} }
double IMD_anim_get_offset(anim *anim) double IMD_anim_get_offset(ImBufAnim *anim)
{ {
return anim->start_offset; return anim->start_offset;
} }
bool IMB_anim_get_fps(const anim *anim, bool no_av_base, short *r_frs_sec, float *r_frs_sec_base) bool IMB_anim_get_fps(const ImBufAnim *anim,
bool no_av_base,
short *r_frs_sec,
float *r_frs_sec_base)
{ {
double frs_sec_base_double; double frs_sec_base_double;
if (anim->frs_sec) { if (anim->frs_sec) {
@ -1719,12 +1722,12 @@ bool IMB_anim_get_fps(const anim *anim, bool no_av_base, short *r_frs_sec, float
return false; return false;
} }
int IMB_anim_get_image_width(anim *anim) int IMB_anim_get_image_width(ImBufAnim *anim)
{ {
return anim->x; return anim->x;
} }
int IMB_anim_get_image_height(anim *anim) int IMB_anim_get_image_height(ImBufAnim *anim)
{ {
return anim->y; return anim->y;
} }

View File

@ -154,10 +154,10 @@ void IMB_index_builder_finish(anim_index_builder *fp, int rollback)
MEM_freeN(fp); MEM_freeN(fp);
} }
anim_index *IMB_indexer_open(const char *filepath) ImBufAnimIndex *IMB_indexer_open(const char *filepath)
{ {
char header[13]; char header[13];
anim_index *idx; ImBufAnimIndex *idx;
FILE *fp = BLI_fopen(filepath, "rb"); FILE *fp = BLI_fopen(filepath, "rb");
int i; int i;
@ -185,7 +185,7 @@ anim_index *IMB_indexer_open(const char *filepath)
return nullptr; return nullptr;
} }
idx = MEM_cnew<anim_index>("anim_index"); idx = MEM_cnew<ImBufAnimIndex>("ImBufAnimIndex");
STRNCPY(idx->filepath, filepath); STRNCPY(idx->filepath, filepath);
@ -235,7 +235,7 @@ anim_index *IMB_indexer_open(const char *filepath)
return idx; return idx;
} }
uint64_t IMB_indexer_get_seek_pos(anim_index *idx, int frame_index) uint64_t IMB_indexer_get_seek_pos(ImBufAnimIndex *idx, int frame_index)
{ {
/* This is hard coded, because our current timecode files return non zero seek position for index /* This is hard coded, because our current timecode files return non zero seek position for index
* 0. Only when seeking to 0 it is guaranteed, that first packet will be read. */ * 0. Only when seeking to 0 it is guaranteed, that first packet will be read. */
@ -248,7 +248,7 @@ uint64_t IMB_indexer_get_seek_pos(anim_index *idx, int frame_index)
return idx->entries[frame_index].seek_pos; return idx->entries[frame_index].seek_pos;
} }
uint64_t IMB_indexer_get_seek_pos_pts(anim_index *idx, int frame_index) uint64_t IMB_indexer_get_seek_pos_pts(ImBufAnimIndex *idx, int frame_index)
{ {
if (frame_index < 0) { if (frame_index < 0) {
frame_index = 0; frame_index = 0;
@ -259,7 +259,7 @@ uint64_t IMB_indexer_get_seek_pos_pts(anim_index *idx, int frame_index)
return idx->entries[frame_index].seek_pos_pts; return idx->entries[frame_index].seek_pos_pts;
} }
uint64_t IMB_indexer_get_seek_pos_dts(anim_index *idx, int frame_index) uint64_t IMB_indexer_get_seek_pos_dts(ImBufAnimIndex *idx, int frame_index)
{ {
if (frame_index < 0) { if (frame_index < 0) {
frame_index = 0; frame_index = 0;
@ -270,7 +270,7 @@ uint64_t IMB_indexer_get_seek_pos_dts(anim_index *idx, int frame_index)
return idx->entries[frame_index].seek_pos_dts; return idx->entries[frame_index].seek_pos_dts;
} }
int IMB_indexer_get_frame_index(anim_index *idx, int frameno) int IMB_indexer_get_frame_index(ImBufAnimIndex *idx, int frameno)
{ {
int len = idx->num_entries; int len = idx->num_entries;
int half; int half;
@ -302,7 +302,7 @@ int IMB_indexer_get_frame_index(anim_index *idx, int frameno)
return first; return first;
} }
uint64_t IMB_indexer_get_pts(anim_index *idx, int frame_index) uint64_t IMB_indexer_get_pts(ImBufAnimIndex *idx, int frame_index)
{ {
if (frame_index < 0) { if (frame_index < 0) {
frame_index = 0; frame_index = 0;
@ -313,7 +313,7 @@ uint64_t IMB_indexer_get_pts(anim_index *idx, int frame_index)
return idx->entries[frame_index].pts; return idx->entries[frame_index].pts;
} }
int IMB_indexer_get_duration(anim_index *idx) int IMB_indexer_get_duration(ImBufAnimIndex *idx)
{ {
if (idx->num_entries == 0) { if (idx->num_entries == 0) {
return 0; return 0;
@ -321,7 +321,7 @@ int IMB_indexer_get_duration(anim_index *idx)
return idx->entries[idx->num_entries - 1].frameno + 1; return idx->entries[idx->num_entries - 1].frameno + 1;
} }
int IMB_indexer_can_scan(anim_index *idx, int old_frame_index, int new_frame_index) int IMB_indexer_can_scan(ImBufAnimIndex *idx, int old_frame_index, int new_frame_index)
{ {
/* makes only sense, if it is the same I-Frame and we are not /* makes only sense, if it is the same I-Frame and we are not
* trying to run backwards in time... */ * trying to run backwards in time... */
@ -330,7 +330,7 @@ int IMB_indexer_can_scan(anim_index *idx, int old_frame_index, int new_frame_ind
old_frame_index < new_frame_index); old_frame_index < new_frame_index);
} }
void IMB_indexer_close(anim_index *idx) void IMB_indexer_close(ImBufAnimIndex *idx)
{ {
MEM_freeN(idx->entries); MEM_freeN(idx->entries);
MEM_freeN(idx); MEM_freeN(idx);
@ -378,7 +378,7 @@ int IMB_timecode_to_array_index(IMB_Timecode_Type tc)
* - rebuild helper functions * - rebuild helper functions
* ---------------------------------------------------------------------- */ * ---------------------------------------------------------------------- */
static void get_index_dir(anim *anim, char *index_dir, size_t index_dir_maxncpy) static void get_index_dir(ImBufAnim *anim, char *index_dir, size_t index_dir_maxncpy)
{ {
if (!anim->index_dir[0]) { if (!anim->index_dir[0]) {
char filename[FILE_MAXFILE]; char filename[FILE_MAXFILE];
@ -391,12 +391,15 @@ static void get_index_dir(anim *anim, char *index_dir, size_t index_dir_maxncpy)
} }
} }
void IMB_anim_get_filename(anim *anim, char *filename, int filename_maxncpy) void IMB_anim_get_filename(ImBufAnim *anim, char *filename, int filename_maxncpy)
{ {
BLI_path_split_file_part(anim->filepath, filename, filename_maxncpy); BLI_path_split_file_part(anim->filepath, filename, filename_maxncpy);
} }
static bool get_proxy_filepath(anim *anim, IMB_Proxy_Size preview_size, char *filepath, bool temp) static bool get_proxy_filepath(ImBufAnim *anim,
IMB_Proxy_Size preview_size,
char *filepath,
bool temp)
{ {
char index_dir[FILE_MAXDIR]; char index_dir[FILE_MAXDIR];
int i = IMB_proxy_size_to_array_index(preview_size); int i = IMB_proxy_size_to_array_index(preview_size);
@ -425,7 +428,7 @@ static bool get_proxy_filepath(anim *anim, IMB_Proxy_Size preview_size, char *fi
return true; return true;
} }
static void get_tc_filepath(anim *anim, IMB_Timecode_Type tc, char *filepath) static void get_tc_filepath(ImBufAnim *anim, IMB_Timecode_Type tc, char *filepath)
{ {
char index_dir[FILE_MAXDIR]; char index_dir[FILE_MAXDIR];
int i = IMB_timecode_to_array_index(tc); int i = IMB_timecode_to_array_index(tc);
@ -479,11 +482,11 @@ struct proxy_output_ctx {
int cfra; int cfra;
IMB_Proxy_Size proxy_size; IMB_Proxy_Size proxy_size;
int orig_height; int orig_height;
struct anim *anim; ImBufAnim *anim;
}; };
static proxy_output_ctx *alloc_proxy_output_ffmpeg( static proxy_output_ctx *alloc_proxy_output_ffmpeg(
anim *anim, AVStream *st, IMB_Proxy_Size proxy_size, int width, int height, int quality) ImBufAnim *anim, AVStream *st, IMB_Proxy_Size proxy_size, int width, int height, int quality)
{ {
proxy_output_ctx *rv = MEM_cnew<proxy_output_ctx>("alloc_proxy_output"); proxy_output_ctx *rv = MEM_cnew<proxy_output_ctx>("alloc_proxy_output");
@ -821,7 +824,7 @@ struct FFmpegIndexBuilderContext {
bool building_cancelled; bool building_cancelled;
}; };
static IndexBuildContext *index_ffmpeg_create_context(anim *anim, static IndexBuildContext *index_ffmpeg_create_context(ImBufAnim *anim,
int tcs_in_use, int tcs_in_use,
int proxy_sizes_in_use, int proxy_sizes_in_use,
int quality, int quality,
@ -1245,12 +1248,12 @@ static bool indexer_need_to_build_proxy(FFmpegIndexBuilderContext *context)
struct FallbackIndexBuilderContext { struct FallbackIndexBuilderContext {
int anim_type; int anim_type;
struct anim *anim; ImBufAnim *anim;
AviMovie *proxy_ctx[IMB_PROXY_MAX_SLOT]; AviMovie *proxy_ctx[IMB_PROXY_MAX_SLOT];
int proxy_sizes_in_use; int proxy_sizes_in_use;
}; };
static AviMovie *alloc_proxy_output_avi( static AviMovie *alloc_proxy_output_avi(
anim *anim, const char *filepath, int width, int height, int quality) ImBufAnim *anim, const char *filepath, int width, int height, int quality)
{ {
int x, y; int x, y;
AviFormat format; AviFormat format;
@ -1287,7 +1290,7 @@ static AviMovie *alloc_proxy_output_avi(
return avi; return avi;
} }
static IndexBuildContext *index_fallback_create_context(anim *anim, static IndexBuildContext *index_fallback_create_context(ImBufAnim *anim,
int /*tcs_in_use*/, int /*tcs_in_use*/,
int proxy_sizes_in_use, int proxy_sizes_in_use,
int quality) int quality)
@ -1328,7 +1331,7 @@ static IndexBuildContext *index_fallback_create_context(anim *anim,
static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, const bool stop) static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, const bool stop)
{ {
anim *anim = context->anim; ImBufAnim *anim = context->anim;
char filepath[FILE_MAX]; char filepath[FILE_MAX];
char filepath_tmp[FILE_MAX]; char filepath_tmp[FILE_MAX];
int i; int i;
@ -1359,7 +1362,7 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
{ {
int count = IMB_anim_get_duration(context->anim, IMB_TC_NONE); int count = IMB_anim_get_duration(context->anim, IMB_TC_NONE);
int i, pos; int i, pos;
anim *anim = context->anim; ImBufAnim *anim = context->anim;
for (pos = 0; pos < count; pos++) { for (pos = 0; pos < count; pos++) {
ImBuf *ibuf = IMB_anim_absolute(anim, pos, IMB_TC_NONE, IMB_PROXY_NONE); ImBuf *ibuf = IMB_anim_absolute(anim, pos, IMB_TC_NONE, IMB_PROXY_NONE);
@ -1407,7 +1410,7 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
* - public API * - public API
* ---------------------------------------------------------------------- */ * ---------------------------------------------------------------------- */
IndexBuildContext *IMB_anim_index_rebuild_context(anim *anim, IndexBuildContext *IMB_anim_index_rebuild_context(ImBufAnim *anim,
IMB_Timecode_Type tcs_in_use, IMB_Timecode_Type tcs_in_use,
int proxy_sizes_in_use, int proxy_sizes_in_use,
int quality, int quality,
@ -1535,7 +1538,7 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, const bool stop)
UNUSED_VARS(stop, proxy_sizes); UNUSED_VARS(stop, proxy_sizes);
} }
void IMB_free_indices(anim *anim) void IMB_free_indices(ImBufAnim *anim)
{ {
int i; int i;
@ -1557,7 +1560,7 @@ void IMB_free_indices(anim *anim)
anim->indices_tried = 0; anim->indices_tried = 0;
} }
void IMB_anim_set_index_dir(anim *anim, const char *dir) void IMB_anim_set_index_dir(ImBufAnim *anim, const char *dir)
{ {
if (STREQ(anim->index_dir, dir)) { if (STREQ(anim->index_dir, dir)) {
return; return;
@ -1567,7 +1570,7 @@ void IMB_anim_set_index_dir(anim *anim, const char *dir)
IMB_free_indices(anim); IMB_free_indices(anim);
} }
anim *IMB_anim_open_proxy(anim *anim, IMB_Proxy_Size preview_size) ImBufAnim *IMB_anim_open_proxy(ImBufAnim *anim, IMB_Proxy_Size preview_size)
{ {
char filepath[FILE_MAX]; char filepath[FILE_MAX];
int i = IMB_proxy_size_to_array_index(preview_size); int i = IMB_proxy_size_to_array_index(preview_size);
@ -1594,7 +1597,7 @@ anim *IMB_anim_open_proxy(anim *anim, IMB_Proxy_Size preview_size)
return anim->proxy_anim[i]; return anim->proxy_anim[i];
} }
anim_index *IMB_anim_open_index(anim *anim, IMB_Timecode_Type tc) ImBufAnimIndex *IMB_anim_open_index(ImBufAnim *anim, IMB_Timecode_Type tc)
{ {
char filepath[FILE_MAX]; char filepath[FILE_MAX];
int i = IMB_timecode_to_array_index(tc); int i = IMB_timecode_to_array_index(tc);
@ -1620,9 +1623,9 @@ anim_index *IMB_anim_open_index(anim *anim, IMB_Timecode_Type tc)
return anim->curr_idx[i]; return anim->curr_idx[i];
} }
int IMB_anim_index_get_frame_index(anim *anim, IMB_Timecode_Type tc, int position) int IMB_anim_index_get_frame_index(ImBufAnim *anim, IMB_Timecode_Type tc, int position)
{ {
anim_index *idx = IMB_anim_open_index(anim, tc); ImBufAnimIndex *idx = IMB_anim_open_index(anim, tc);
if (!idx) { if (!idx) {
return position; return position;
@ -1631,7 +1634,7 @@ int IMB_anim_index_get_frame_index(anim *anim, IMB_Timecode_Type tc, int positio
return IMB_indexer_get_frame_index(idx, position); return IMB_indexer_get_frame_index(idx, position);
} }
int IMB_anim_proxy_get_existing(anim *anim) int IMB_anim_proxy_get_existing(ImBufAnim *anim)
{ {
const int num_proxy_sizes = IMB_PROXY_MAX_SLOT; const int num_proxy_sizes = IMB_PROXY_MAX_SLOT;
int existing = IMB_PROXY_NONE; int existing = IMB_PROXY_NONE;

View File

@ -391,7 +391,7 @@ static ImBuf *thumb_create_ex(const char *file_path,
} }
} }
else if (THB_SOURCE_MOVIE == source) { else if (THB_SOURCE_MOVIE == source) {
anim *anim = nullptr; ImBufAnim *anim = nullptr;
anim = IMB_open_anim(file_path, IB_rect | IB_metadata, 0, nullptr); anim = IMB_open_anim(file_path, IB_rect | IB_metadata, 0, nullptr);
if (anim != nullptr) { if (anim != nullptr) {
img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);

View File

@ -13,11 +13,11 @@
#include "DNA_defs.h" #include "DNA_defs.h"
struct GPUTexture; struct GPUTexture;
struct ImBufAnim;
struct MovieCache; struct MovieCache;
struct PackedFile; struct PackedFile;
struct RenderResult; struct RenderResult;
struct Scene; struct Scene;
struct anim;
/* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */ /* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */
/* should be used in conjunction with an ID * to Image. */ /* should be used in conjunction with an ID * to Image. */
@ -47,7 +47,7 @@ typedef struct ImageUser {
typedef struct ImageAnim { typedef struct ImageAnim {
struct ImageAnim *next, *prev; struct ImageAnim *next, *prev;
struct anim *anim; struct ImBufAnim *anim;
} ImageAnim; } ImageAnim;
typedef struct ImageView { typedef struct ImageView {

View File

@ -14,10 +14,10 @@
struct AnimData; struct AnimData;
struct ImBuf; struct ImBuf;
struct ImBufAnim;
struct MovieClipProxy; struct MovieClipProxy;
struct MovieTrackingMarker; struct MovieTrackingMarker;
struct MovieTrackingTrack; struct MovieTrackingTrack;
struct anim;
struct bGPdata; struct bGPdata;
typedef struct MovieClipUser { typedef struct MovieClipUser {
@ -75,7 +75,7 @@ typedef struct MovieClip {
float aspx, aspy; float aspx, aspy;
/** Movie source data. */ /** Movie source data. */
struct anim *anim; struct ImBufAnim *anim;
/** Cache for different stuff, not in file. */ /** Cache for different stuff, not in file. */
struct MovieClipCache *cache; struct MovieClipCache *cache;
/** Grease pencil data. */ /** Grease pencil data. */

View File

@ -36,7 +36,7 @@ struct bSound;
typedef struct StripAnim { typedef struct StripAnim {
struct StripAnim *next, *prev; struct StripAnim *next, *prev;
struct anim *anim; struct ImBufAnim *anim;
} StripAnim; } StripAnim;
typedef struct StripElem { typedef struct StripElem {
@ -84,7 +84,7 @@ typedef struct StripProxy {
char dirpath[768]; char dirpath[768];
/** Custom file. */ /** Custom file. */
char filename[256]; char filename[256];
struct anim *anim; /* custom proxy anim file */ struct ImBufAnim *anim; /* custom proxy anim file */
short tc; /* time code in use */ short tc; /* time code in use */

View File

@ -575,7 +575,7 @@ static int rna_Image_frame_duration_get(PointerRNA *ptr)
} }
if (BKE_image_has_anim(ima)) { if (BKE_image_has_anim(ima)) {
anim *anim = ((ImageAnim *)ima->anims.first)->anim; ImBufAnim *anim = ((ImageAnim *)ima->anims.first)->anim;
if (anim) { if (anim) {
duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN); duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
} }

View File

@ -63,7 +63,7 @@ static void node_geo_exec(GeoNodeExecParams params)
float fps = 0.0f; float fps = 0.0f;
if (ImageAnim *ianim = static_cast<ImageAnim *>(image->anims.first)) { if (ImageAnim *ianim = static_cast<ImageAnim *>(image->anims.first)) {
anim *anim = ianim->anim; ImBufAnim *anim = ianim->anim;
if (anim) { if (anim) {
frames = IMB_anim_get_duration(anim, IMB_TC_NONE); frames = IMB_anim_get_duration(anim, IMB_TC_NONE);

View File

@ -18,7 +18,7 @@
#include "multiview.hh" #include "multiview.hh"
void seq_anim_add_suffix(Scene *scene, anim *anim, const int view_id) void seq_anim_add_suffix(Scene *scene, ImBufAnim *anim, const int view_id)
{ {
const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id); const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id);
IMB_suffix_anim(anim, suffix); IMB_suffix_anim(anim, suffix);

View File

@ -17,7 +17,7 @@ struct Scene;
* ********************************************************************** * **********************************************************************
*/ */
void seq_anim_add_suffix(Scene *scene, anim *anim, int view_id); void seq_anim_add_suffix(Scene *scene, ImBufAnim *anim, int view_id);
void seq_multiview_name( void seq_multiview_name(
Scene *scene, int view_id, const char *prefix, const char *ext, char *r_path, size_t r_size); Scene *scene, int view_id, const char *prefix, const char *ext, char *r_path, size_t r_size);
/** /**

View File

@ -412,7 +412,7 @@ static int seq_proxy_context_count(Sequence *seq, Scene *scene)
return num_views; return num_views;
} }
static bool seq_proxy_need_rebuild(Sequence *seq, anim *anim) static bool seq_proxy_need_rebuild(Sequence *seq, ImBufAnim *anim)
{ {
if ((seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0) { if ((seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0) {
return true; return true;
@ -608,7 +608,7 @@ void SEQ_proxy_set(Sequence *seq, bool value)
} }
} }
void seq_proxy_index_dir_set(anim *anim, const char *base_dir) void seq_proxy_index_dir_set(ImBufAnim *anim, const char *base_dir)
{ {
char dirname[FILE_MAX]; char dirname[FILE_MAX];
char filename[FILE_MAXFILE]; char filename[FILE_MAXFILE];

View File

@ -17,4 +17,4 @@ struct anim;
ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame); ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame);
bool seq_proxy_get_custom_file_filepath(Sequence *seq, char *name, int view_id); bool seq_proxy_get_custom_file_filepath(Sequence *seq, char *name, int view_id);
void free_proxy_seq(Sequence *seq); void free_proxy_seq(Sequence *seq);
void seq_proxy_index_dir_set(anim *anim, const char *base_dir); void seq_proxy_index_dir_set(ImBufAnim *anim, const char *base_dir);

View File

@ -392,7 +392,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */ char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
bool is_multiview_loaded = false; bool is_multiview_loaded = false;
const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview); const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview);
anim **anim_arr = static_cast<anim **>(MEM_callocN(sizeof(anim *) * totfiles, "Video files")); ImBufAnim **anim_arr = static_cast<ImBufAnim **>(
MEM_callocN(sizeof(ImBufAnim *) * totfiles, "Video files"));
int i; int i;
int orig_width = 0; int orig_width = 0;
int orig_height = 0; int orig_height = 0;
@ -575,7 +576,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
if (prefix[0] != '\0') { if (prefix[0] != '\0') {
for (i = 0; i < totfiles; i++) { for (i = 0; i < totfiles; i++) {
anim *anim; ImBufAnim *anim;
char filepath_view[FILE_MAX]; char filepath_view[FILE_MAX];
seq_multiview_name(scene, i, prefix, ext, filepath_view, sizeof(filepath_view)); seq_multiview_name(scene, i, prefix, ext, filepath_view, sizeof(filepath_view));
@ -596,7 +597,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
} }
if (is_multiview_loaded == false) { if (is_multiview_loaded == false) {
anim *anim; ImBufAnim *anim;
anim = openanim(filepath, anim = openanim(filepath,
IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
seq->streamindex, seq->streamindex,

View File

@ -336,7 +336,7 @@ struct PlayAnimPict {
/** The allocated error message to show if the file cannot be loaded. */ /** The allocated error message to show if the file cannot be loaded. */
char *error_message; char *error_message;
ImBuf *ibuf; ImBuf *ibuf;
struct anim *anim; ImBufAnim *anim;
int frame; int frame;
int IB_flags; int IB_flags;
@ -844,7 +844,7 @@ static void build_pict_list_from_anim(ListBase *picsbase,
const int frame_offset) const int frame_offset)
{ {
/* OCIO_TODO: support different input color space. */ /* OCIO_TODO: support different input color space. */
anim *anim = IMB_open_anim(filepath_first, IB_rect, 0, nullptr); ImBufAnim *anim = IMB_open_anim(filepath_first, IB_rect, 0, nullptr);
if (anim == nullptr) { if (anim == nullptr) {
CLOG_WARN(&LOG, "couldn't open anim '%s'", filepath_first); CLOG_WARN(&LOG, "couldn't open anim '%s'", filepath_first);
return; return;
@ -1807,7 +1807,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_
if (IMB_isanim(filepath)) { if (IMB_isanim(filepath)) {
/* OCIO_TODO: support different input color spaces. */ /* OCIO_TODO: support different input color spaces. */
anim *anim = IMB_open_anim(filepath, IB_rect, 0, nullptr); ImBufAnim *anim = IMB_open_anim(filepath, IB_rect, 0, nullptr);
if (anim) { if (anim) {
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
IMB_close_anim(anim); IMB_close_anim(anim);
@ -1918,7 +1918,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_
#ifdef WITH_AUDASPACE #ifdef WITH_AUDASPACE
g_audaspace.source = AUD_Sound_file(filepath); g_audaspace.source = AUD_Sound_file(filepath);
if (!BLI_listbase_is_empty(&ps.picsbase)) { if (!BLI_listbase_is_empty(&ps.picsbase)) {
anim *anim_movie = static_cast<PlayAnimPict *>(ps.picsbase.first)->anim; ImBufAnim *anim_movie = static_cast<PlayAnimPict *>(ps.picsbase.first)->anim;
if (anim_movie) { if (anim_movie) {
short frs_sec = 25; short frs_sec = 25;
float frs_sec_base = 1.0; float frs_sec_base = 1.0;