Blender V5.0
movie_read.cc File Reference
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sys/types.h>
#include "BLI_path_utils.hh"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_task.hh"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "IMB_colormanagement.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
#include "CLG_log.h"
#include "MOV_read.hh"
#include "IMB_metadata.hh"
#include "movie_proxy_indexer.hh"
#include "movie_read.hh"

Go to the source code of this file.

Functions

static bool anim_getnew (MovieReader *anim)
void MOV_close (MovieReader *anim)
void MOV_get_filename (const MovieReader *anim, char *filename, int filename_maxncpy)
IDPropertyMOV_load_metadata (MovieReader *anim)
static void probe_video_colorspace (MovieReader *anim, char r_colorspace_name[IM_MAX_SPACE])
MovieReaderMOV_open_file (const char *filepath, const int ib_flags, const int streamindex, const bool keep_original_colorspace, char colorspace[IM_MAX_SPACE])
bool MOV_is_initialized_and_valid (const MovieReader *anim)
void MOV_set_multiview_suffix (MovieReader *anim, const char *suffix)
ImBufMOV_decode_preview_frame (MovieReader *anim)
ImBufMOV_decode_frame (MovieReader *anim, int position, IMB_Timecode_Type tc, IMB_Proxy_Size preview_size)
int MOV_get_duration_frames (MovieReader *anim, IMB_Timecode_Type tc)
double MOV_get_start_offset_seconds (const MovieReader *anim)
float MOV_get_fps (const MovieReader *anim)
bool MOV_get_fps_num_denom (const MovieReader *anim, short &r_fps_num, float &r_fps_denom)
int MOV_get_image_width (const MovieReader *anim)
int MOV_get_image_height (const MovieReader *anim)

Function Documentation

◆ anim_getnew()

bool anim_getnew ( MovieReader * anim)
static

Try to initialize the #anim struct. Returns true on success.

Definition at line 1379 of file movie_read.cc.

References BLI_assert, MovieReader::Failed, MovieReader::state, MovieReader::Uninitialized, and MovieReader::Valid.

Referenced by MOV_decode_frame(), and probe_video_colorspace().

◆ MOV_close()

◆ MOV_decode_frame()

ImBuf * MOV_decode_frame ( MovieReader * anim,
int position,
IMB_Timecode_Type tc,
IMB_Proxy_Size preview_size )

Fetches a frame from a movie at given frame position.

Internally this will seek within the movie as/if needed. For most movie files, decoding frames sequentially is much more efficient than decoding random frames.

If proxy_size is not IMB_PROXY_NONE, a proxy file of given size will be attempted. If it exists, the frame will be decoded from it. If the proxy does not exist, original file will be used.

Movies that are <= 8 bits/color channel are returned as byte images; higher bit depth movies are returned as float images. Note that the color space is returned as-is, i.e. a float image might not be in linear space.

Returned image can be null if movie file does not exist, is not supported or failed decoding.

Definition at line 1437 of file movie_read.cc.

References anim_getnew(), MovieReader::cur_position, MovieReader::duration_in_frames, ImBuf::fileframe, ImBuf::filepath, MovieReader::filepath, IMB_PROXY_NONE, IMB_TC_NONE, MOV_calc_frame_index_with_timecode(), MOV_decode_frame(), movie_open_proxy(), MovieReader::state, STRNCPY(), MovieReader::Uninitialized, and MovieReader::Valid.

Referenced by build_pict_list_from_anim(), ibuf_from_picture(), load_movie_single(), MOV_decode_frame(), MOV_decode_preview_frame(), movieclip_load_movie_file(), openanim(), blender::seq::seq_proxy_fetch(), blender::seq::seq_render_movie_strip_custom_file_proxy(), blender::seq::seq_render_movie_strip_view(), thumb_create_ex(), and wm_main_playanim_intern().

◆ MOV_decode_preview_frame()

ImBuf * MOV_decode_preview_frame ( MovieReader * anim)

Fetches a frame from a movie used for preview/thumbnails. The frame will be halfway into the file duration. Thumbnail related metadata ("Thumb::Video::*") will be set on the returned image.

Definition at line 1399 of file movie_read.cc.

References MovieReader::duration_in_frames, IMB_freeImBuf(), IMB_metadata_ensure(), IMB_metadata_set_field(), IMB_PROXY_NONE, IMB_TC_NONE, ImBuf::metadata, MOV_decode_frame(), SNPRINTF_UTF8, MovieReader::x, and MovieReader::y.

Referenced by thumb_create_ex(), and ui_tooltip_from_clip().

◆ MOV_get_duration_frames()

◆ MOV_get_filename()

void MOV_get_filename ( const MovieReader * anim,
char * filename,
int filename_maxncpy )

Gets filename (without the folder) part of the movie.

Definition at line 81 of file movie_read.cc.

References BLI_path_split_file_part(), and MovieReader::filepath.

Referenced by blender::seq::seq_proxy_index_dir_set().

◆ MOV_get_fps()

float MOV_get_fps ( const MovieReader * anim)

◆ MOV_get_fps_num_denom()

bool MOV_get_fps_num_denom ( const MovieReader * anim,
short & r_fps_num,
float & r_fps_denom )

Returns the frames per second of the movie as numerator and denominator. False will be returned if the information is not available.

Definition at line 1514 of file movie_read.cc.

References float, MovieReader::frs_sec, and MovieReader::frs_sec_base.

Referenced by blender::seq::add_movie_strip().

◆ MOV_get_image_height()

int MOV_get_image_height ( const MovieReader * anim)

Get movie image height in pixels.

Definition at line 1536 of file movie_read.cc.

References ELEM, MovieReader::video_rotation, MovieReader::x, and MovieReader::y.

Referenced by blender::seq::add_movie_strip(), and ui_tooltip_from_clip().

◆ MOV_get_image_width()

int MOV_get_image_width ( const MovieReader * anim)

Get movie image width in pixels.

Definition at line 1531 of file movie_read.cc.

References ELEM, MovieReader::video_rotation, MovieReader::x, and MovieReader::y.

Referenced by blender::seq::add_movie_strip(), and ui_tooltip_from_clip().

◆ MOV_get_start_offset_seconds()

double MOV_get_start_offset_seconds ( const MovieReader * anim)

Return the encoded start offset (in seconds) of the movie.

Definition at line 1501 of file movie_read.cc.

References MovieReader::start_offset.

Referenced by blender::seq::add_movie_strip().

◆ MOV_is_initialized_and_valid()

bool MOV_is_initialized_and_valid ( const MovieReader * anim)

Returns true if movie playback has been fully initialized and is supported. Note that immediately after MOV_open_file the playback is not initialized yet.

Definition at line 178 of file movie_read.cc.

References UNUSED_VARS.

Referenced by blender::seq::add_movie_reload_if_needed().

◆ MOV_load_metadata()

IDProperty * MOV_load_metadata ( MovieReader * anim)

Loads metadata of the movie. Metadata is only loaded for already initialized movies.

Definition at line 86 of file movie_read.cc.

References BLI_assert, IMB_metadata_ensure(), IMB_metadata_set_field(), MovieReader::metadata, MovieReader::state, and MovieReader::Valid.

Referenced by blender::seq::add_movie_strip(), and blender::seq::add_reload_new_file().

◆ MOV_open_file()

MovieReader * MOV_open_file ( const char * filepath,
int ib_flags,
int streamindex,
bool keep_original_colorspace,
char colorspace[IM_MAX_SPACE] )

Opens a movie file for reading / playback. ib_flags are IB_ ImBuf bitmask (only IB_animdeinterlace is taken into account). streamindex is for multi-track movie files.

Returned MovieReader object can be used in other playback related functions. Note that a valid object will be returned even if file does not exist or is not a video file. The actual initialization is delayed until MOV_decode_frame is called.

When done with playback, use MOV_close to delete it.

Definition at line 141 of file movie_read.cc.

References BLI_assert, BLI_path_is_rel(), BLI_strncpy_utf8(), MovieReader::colorspace, MovieReader::filepath, MovieReader::ib_flags, IM_MAX_SPACE, MovieReader::keep_original_colorspace, probe_video_colorspace(), MovieReader::streamindex, STRNCPY(), and STRNCPY_UTF8.

Referenced by build_pict_list_from_anim(), movie_open_proxy(), openanim(), openanim_noload(), thumb_create_ex(), and wm_main_playanim_intern().

◆ MOV_set_multiview_suffix()

void MOV_set_multiview_suffix ( MovieReader * anim,
const char * suffix )

Sets multi-view suffix to be used when building proxies for this movie.

Definition at line 192 of file movie_read.cc.

References STRNCPY(), and MovieReader::suffix.

Referenced by blender::seq::open_anim_file_multiview(), and blender::seq::seq_anim_add_suffix().

◆ probe_video_colorspace()