18 #include <sys/types.h>
21 # include <sys/times.h>
22 # include <sys/wait.h>
65 # include <AUD_Device.h>
66 # include <AUD_Handle.h>
67 # include <AUD_Sound.h>
68 # include <AUD_Special.h>
70 static AUD_Sound *source =
NULL;
71 static AUD_Handle *playback_handle =
NULL;
72 static AUD_Handle *scrub_handle =
NULL;
73 static AUD_Device *audio_device =
NULL;
77 #define USE_FRAME_CACHE_LIMIT
78 #ifdef USE_FRAME_CACHE_LIMIT
79 # define PLAY_FRAME_CACHE_MAX 30
159 printf(
" direction=%d,\n", (
int)ps->
direction);
160 printf(
" once=%d,\n", ps->
once);
161 printf(
" pingpong=%d,\n", ps->
pingpong);
162 printf(
" noskip=%d,\n", ps->
noskip);
163 printf(
" sstep=%d,\n", ps->
sstep);
164 printf(
" wait2=%d,\n", ps->
wait2);
165 printf(
" stopped=%d,\n", ps->
stopped);
166 printf(
" go=%d,\n\n", ps->
go);
249 #ifdef USE_FRAME_CACHE_LIMIT
260 #ifdef WITH_AUDASPACE
261 static double fps_movie;
264 #ifdef USE_FRAME_CACHE_LIMIT
277 .pics_size_in_memory = 0,
333 if (pic->
ibuf && pic->
ibuf != ibuf_keep) {
348 else if (pic->
anim) {
366 while (step-- && playanim) {
367 playanim = playanim->
next;
371 while (step++ && playanim) {
372 playanim = playanim->
prev;
394 void **r_buffer_cache_handle)
396 void *display_buffer;
397 bool force_fallback =
false;
398 *r_glsl_used =
false;
400 force_fallback |= (ibuf->
dither != 0.0f);
407 if (force_fallback) {
408 *r_glsl_used =
false;
409 display_buffer =
NULL;
436 else if (ibuf->
rect) {
437 display_buffer = ibuf->
rect;
446 display_buffer =
NULL;
458 return display_buffer;
463 void *display_buffer;
469 bool glsl_used =
false;
475 void *buffer_cache_handle =
NULL;
528 if (buffer_cache_handle) {
537 printf(
"%s: no ibuf for picture '%s'\n", __func__, picture ? picture->
name :
"<NIL>");
544 float span_x = (ps->
zoom * ibuf->
x) / (
float)ps->
win_x;
545 float span_y = (ps->
zoom * ibuf->
y) / (
float)ps->
win_y;
548 float offs_x = 0.5f * (1.0f - span_x);
549 float offs_y = 0.5f * (1.0f - span_y);
551 CLAMP(offs_x, 0.0f, 1.0f);
552 CLAMP(offs_y, 0.0f, 1.0f);
564 (
const float[4]){0.15, 0.15, 0.15, 1.0},
565 (
const float[4]){0.20, 0.20, 0.20, 1.0},
577 float fsizex_inv, fsizey_inv;
582 fsizex_inv = 1.0f / sizex;
583 fsizey_inv = 1.0f / sizey;
587 BLF_aspect(fontid, fsizex_inv, fsizey_inv, 1.0f);
588 BLF_position(fontid, 10.0f * fsizex_inv, 10.0f * fsizey_inv, 0.0f);
596 fac = 2.0f * fac - 1.0f;
622 PlayState *ps,
const char *
first,
int totframes,
int fstep,
int fontid)
638 picture->
frame = pic;
645 printf(
"couldn't open anim %s\n", first);
651 #ifdef USE_FRAME_CACHE_LIMIT
652 bool fill_cache =
true;
654 bool fill_cache =
false;
662 unsigned short digits;
668 filepath, fp_decoded.head, fp_decoded.tail, &fp_decoded.digits);
684 while (
IMB_ispic(filepath) && totframes) {
696 if (picture ==
NULL) {
697 printf(
"Not enough memory for pict struct '%s'\n", filepath);
716 printf(
"Couldn't get memory\n");
723 printf(
"Error while reading %s\n", filepath);
743 const bool display_imbuf =
ptottime > 1.0;
745 if (display_imbuf || fill_cache) {
753 #ifdef USE_FRAME_CACHE_LIMIT
755 picture->
ibuf = ibuf;
775 filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
798 #ifdef WITH_AUDASPACE
799 if (playback_handle) {
801 double speed = 1.0 / (
swaptime * fps_movie);
803 AUD_Handle_setPitch(playback_handle, speed);
832 #ifdef WITH_AUDASPACE
834 AUD_Handle_stop(scrub_handle);
838 if (playback_handle) {
839 AUD_Status status = AUD_Handle_getStatus(playback_handle);
840 if (status != AUD_STATUS_PLAYING) {
841 AUD_Handle_stop(playback_handle);
842 playback_handle = AUD_Device_play(audio_device, source, 1);
843 if (playback_handle) {
844 AUD_Handle_setPosition(playback_handle, i / fps_movie);
845 scrub_handle = AUD_pauseAfter(playback_handle, 1 / fps_movie);
850 AUD_Handle_setPosition(playback_handle, i / fps_movie);
851 scrub_handle = AUD_pauseAfter(playback_handle, 1 / fps_movie);
855 playback_handle = AUD_Device_play(audio_device, source, 1);
856 if (playback_handle) {
857 AUD_Handle_setPosition(playback_handle, i / fps_movie);
858 scrub_handle = AUD_pauseAfter(playback_handle, 1 / fps_movie);
893 switch (key_data->
key) {
923 switch (key_data->
key) {
1069 printf(
" Name: %s | Speed: %.2f frames/s\n",
1098 #ifdef WITH_AUDASPACE
1104 while (picture && picture != ps->
picture) {
1106 picture = picture->
next;
1108 if (playback_handle) {
1109 AUD_Handle_stop(playback_handle);
1111 playback_handle = AUD_Device_play(audio_device, source, 1);
1112 if (playback_handle) {
1113 AUD_Handle_setPosition(playback_handle, i / fps_movie);
1122 #ifdef WITH_AUDASPACE
1123 if (playback_handle) {
1124 AUD_Handle_stop(playback_handle);
1125 playback_handle =
NULL;
1135 #ifdef WITH_AUDASPACE
1140 while (picture && picture != ps->
picture) {
1142 picture = picture->
next;
1144 if (playback_handle) {
1145 AUD_Handle_stop(playback_handle);
1147 playback_handle = AUD_Device_play(audio_device, source, 1);
1148 if (playback_handle) {
1149 AUD_Handle_setPosition(playback_handle, i / fps_movie);
1165 #ifdef WITH_AUDASPACE
1166 if (playback_handle) {
1167 AUD_Handle_stop(playback_handle);
1168 playback_handle =
NULL;
1200 if (swaptime < ps->fstep / 5.0) {
1218 int cx, cy, sizex, sizey, inside_window;
1223 inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey);
1227 if (inside_window) {
1238 if (inside_window) {
1248 if (inside_window) {
1272 if (cx != x_test || cy != y_test) {
1323 for (
a = 0;
a < stra->
count;
a++) {
1326 printf(
"drop file %s\n", stra->
strings[
a]);
1347 posy = (scr_h - posy - sizey);
1368 if (ps->
zoom + zoom_offset > 0.0f) {
1369 ps->
zoom += zoom_offset;
1394 int start_x = 0, start_y = 0;
1428 if (argv[1][0] ==
'-') {
1429 switch (argv[1][1]) {
1435 start_x = atoi(argv[2]);
1436 start_y = atoi(argv[3]);
1441 printf(
"too few arguments for -p (need 2): skipping\n");
1446 double fps = atof(argv[2]);
1447 double fps_base = atof(argv[3]);
1459 printf(
"too few arguments for -f (need 2): skipping\n");
1463 sfra = atoi(argv[2]);
1469 efra = atoi(argv[2]);
1475 ps.
fstep = atoi(argv[2]);
1482 #ifdef USE_FRAME_CACHE_LIMIT
1483 const int memory_in_mb =
max_ii(0, atoi(argv[2]));
1484 g_frame_cache.memory_limit = (size_t)memory_in_mb * (1024 * 1024);
1491 printf(
"unknown option '%c': skipping\n", argv[1][1]);
1506 printf(
"%s: no filepath argument given\n", __func__);
1521 printf(
"%s: '%s' not an image file\n", __func__, filepath);
1531 printf(
"%s: '%s' couldn't open\n", __func__, filepath);
1567 if (maxwinx % ibuf->
x) {
1568 maxwinx = ibuf->
x * (1 + (maxwinx / ibuf->
x));
1570 if (maxwiny % ibuf->
y) {
1571 maxwiny = ibuf->
y * (1 + (maxwiny / ibuf->
y));
1584 if (sfra == -1 || efra == -1) {
1592 #ifdef WITH_AUDASPACE
1593 source = AUD_Sound_file(filepath);
1598 float frs_sec_base = 1.0;
1602 fps_movie = (
double)frs_sec / (
double)frs_sec_base;
1609 for (i = 2; i < argc; i++) {
1621 #define USE_IMB_CACHE
1636 printf(
"couldn't find pictures\n");
1651 #ifdef WITH_AUDASPACE
1652 if (playback_handle) {
1653 AUD_Handle_stop(playback_handle);
1655 playback_handle = AUD_Device_play(audio_device, source, 1);
1661 #ifndef USE_IMB_CACHE
1670 #ifdef USE_IMB_CACHE
1674 #ifdef USE_FRAME_CACHE_LIMIT
1699 printf(
"error: can't play this image type\n");
1717 if (ps.
go ==
false) {
1760 if (ps.
go ==
false) {
1784 #ifndef USE_IMB_CACHE
1792 #ifdef USE_FRAME_CACHE_LIMIT
1798 #ifdef WITH_AUDASPACE
1799 if (playback_handle) {
1800 AUD_Handle_stop(playback_handle);
1801 playback_handle =
NULL;
1804 AUD_Handle_stop(scrub_handle);
1805 scrub_handle =
NULL;
1807 AUD_Sound_free(source);
1838 printf(
"Error Totblock: %d\n",
totblock);
1848 const char *argv_next[2];
1849 bool looping =
true;
1851 #ifdef WITH_AUDASPACE
1853 AUD_DeviceSpecs specs;
1855 specs.rate = AUD_RATE_48000;
1856 specs.format = AUD_FORMAT_FLOAT32;
1857 specs.channels = AUD_CHANNELS_STEREO;
1861 if (!(audio_device = AUD_init(
NULL, specs, 1024,
"Blender"))) {
1862 audio_device = AUD_init(
"None", specs, 0,
"Blender");
1871 argv_next[0] = argv[0];
1872 argv_next[1] = filepath;
1883 #ifdef WITH_AUDASPACE
1884 AUD_exit(audio_device);
typedef float(TangentPoint)[2]
int ED_draw_imbuf_method(struct ImBuf *ibuf)
void BLF_aspect(int fontid, float x, float y, float z)
int BLF_load_mono_default(bool unique)
void BLF_draw(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2)
void BLF_load_font_stack(void)
void BLF_enable(int fontid, int option)
void BLF_color4f(int fontid, float r, float g, float b, float a)
void BLF_size(int fontid, float size, int dpi)
void BLF_position(int fontid, float x, float y, float z)
File and directory operations.
size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
struct LinkData * BLI_genericNodeN(void *data)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
int BLI_path_sequence_decode(const char *string, char *head, char *tail, unsigned short *r_digits_len)
void BLI_path_sequence_encode(char *string, const char *head, const char *tail, unsigned short numlen, int pic)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define STRNCPY(dst, src)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLI_system_backtrace(FILE *fp)
#define SET_FLAG_FROM_TEST(value, test, flag)
typedef double(DMatrix)[4][4]
void DEG_free_node_types(void)
GHOST C-API function and type declarations.
int32_t GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
GHOST_TSuccess GHOST_GetCursorPosition(const GHOST_SystemHandle systemhandle, const GHOST_WindowHandle windowhandle, int32_t *x, int32_t *y)
GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle, uint32_t width, uint32_t height)
GHOST_SystemHandle GHOST_CreateSystem(void)
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent)
void GHOST_SetTitle(GHOST_WindowHandle windowhandle, const char *title)
void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle, int32_t inX, int32_t inY, int32_t *outX, int32_t *outY)
GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle)
void GHOST_SetBacktraceHandler(GHOST_TBacktraceFn backtrace_fn)
int32_t GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle, uint32_t *width, uint32_t *height)
GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle, GHOST_TModifierKey mask, bool *r_is_down)
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle parent_windowhandle, const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, bool is_dialog, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings)
GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr userdata)
GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
@ GHOST_kWindowStateNormal
void * GHOST_TUserDataPtr
@ GHOST_kEventWindowClose
@ GHOST_kEventDraggingDropDone
@ GHOST_kEventWindowActivate
@ GHOST_kEventWindowDeactivate
@ GHOST_kEventQuitRequest
@ GHOST_kDrawingContextTypeOpenGL
@ GHOST_kModifierKeyRightControl
@ GHOST_kModifierKeyLeftControl
@ GHOST_kModifierKeyRightAlt
@ GHOST_kModifierKeyRightShift
@ GHOST_kModifierKeyLeftAlt
@ GHOST_kModifierKeyLeftShift
void(* GHOST_TBacktraceFn)(void *file_handle)
@ GHOST_kDragnDropTypeFilenames
@ GHOST_kButtonMaskMiddle
struct GPUContext GPUContext
void GPU_context_discard(GPUContext *)
GPUContext * GPU_context_create(void *ghost_window)
void GPU_context_active_set(GPUContext *)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void GPU_matrix_pop(void)
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
void GPU_matrix_identity_projection_set(void)
void GPU_matrix_pop_projection(void)
void GPU_matrix_push(void)
void GPU_matrix_identity_set(void)
void GPU_matrix_push_projection(void)
@ GPU_SHADER_2D_UNIFORM_COLOR
@ GPU_SHADER_2D_IMAGE_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_scissor(int x, int y, int width, int height)
void GPU_viewport(int x, int y, int width, int height)
struct GPUTexture GPUTexture
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
void GPU_texture_free(GPUTexture *tex)
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
void GPU_texture_unbind(GPUTexture *tex)
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
void GPU_texture_bind(GPUTexture *tex, int unit)
@ COLOR_ROLE_DEFAULT_BYTE
void IMB_display_buffer_release(void *cache_handle)
bool IMB_colormanagement_setup_glsl_draw(const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, float dither, bool predivide)
void IMB_colormanagement_init_default_view_settings(struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings)
unsigned char * IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, void **cache_handle)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_colormanagement_finish_glsl_draw(void)
bool IMB_colormanagement_setup_glsl_draw_from_space(const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, struct ColorSpace *colorspace, float dither, bool predivide, bool do_overlay_merge)
bool IMB_anim_get_fps(struct anim *anim, short *frs_sec, float *frs_sec_base, bool no_av_base)
void IMB_close_anim(struct anim *anim)
size_t IMB_get_size_in_memory(struct ImBuf *ibuf)
struct anim * IMB_open_anim(const char *name, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE])
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
bool IMB_isanim(const char *filepath)
struct ImBuf * IMB_ibImageFromMemory(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
bool IMB_ispic(const char *filepath)
struct ImBuf * IMB_anim_absolute(struct anim *anim, int position, IMB_Timecode_Type tc, IMB_Proxy_Size preview_size)
int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
Platform independent time functions.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
void GPU_clear_color(float red, float green, float blue, float alpha)
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
void(* MEM_freeN)(void *vmemh)
unsigned int(* MEM_get_memory_blocks_in_use)(void)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void(* MEM_printmemlist)(void)
static unsigned int totblock
static const pxr::TfToken preview("preview", pxr::TfToken::Immortal)
GHOST_TDragnDropTypes dataType
struct ColorSpace * rect_colorspace
char name[IMB_FILENAME_SIZE]
struct ColorSpace * float_colorspace
struct PlayAnimPict * prev
LinkData * frame_cache_node
struct PlayAnimPict * next
ColorManagedViewSettings view_settings
struct PlayAnimPict * picture
char dropped_file[FILE_MAX]
ColorManagedDisplaySettings display_settings
GHOST_SystemHandle ghost_system
void PIL_sleep_ms(int ms)
double PIL_check_seconds_timer(void)
static void playanim_gl_matrix(void)
static char * wm_main_playanim_intern(int argc, const char **argv)
struct PlayAnimPict PlayAnimPict
void WM_main_playanim(int argc, const char **argv)
static void frame_cache_remove(PlayAnimPict *pic)
static struct WindowStateGlobal g_WS
static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey)
static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
static struct ListBase picsbase
static void frame_cache_touch(PlayAnimPict *pic)
static void build_pict_list_ex(PlayState *ps, const char *first, int totframes, int fstep, int fontid)
static int pupdate_time(void)
static void frame_cache_add(PlayAnimPict *pic)
static bool frame_cache_limit_exceeded(void)
static void playanim_window_get_size(int *r_width, int *r_height)
static void playanim_window_zoom(struct PlayState *ps, const float zoom_offset)
static ImBuf * ibuf_from_picture(PlayAnimPict *pic)
static PlayAnimPict * playanim_step(PlayAnimPict *playanim, int step)
static void change_frame(PlayState *ps)
static void frame_cache_limit_apply(ImBuf *ibuf_keep)
size_t pics_size_in_memory
static void update_sound_fps(void)
static struct @1199 g_frame_cache
struct PlayState PlayState
static void tag_change_frame(PlayState *ps, int cx)
static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
#define PLAY_FRAME_CACHE_MAX
static void draw_display_buffer(PlayState *ps, ImBuf *ibuf)
static void playanim_event_qual_update(void)
static void * ocio_transform_ibuf(PlayState *ps, ImBuf *ibuf, bool *r_glsl_used, eGPUTextureFormat *r_format, eGPUDataFormat *r_data, void **r_buffer_cache_handle)
static void build_pict_list(PlayState *ps, const char *first, int totframes, int fstep, int fontid)