34 #include <sys/types.h>
37 # include <sys/times.h>
38 # include <sys/wait.h>
80 # include <AUD_Device.h>
81 # include <AUD_Handle.h>
82 # include <AUD_Sound.h>
83 # include <AUD_Special.h>
85 static AUD_Sound *source =
NULL;
86 static AUD_Handle *playback_handle =
NULL;
87 static AUD_Handle *scrub_handle =
NULL;
88 static AUD_Device *audio_device =
NULL;
92 #define USE_FRAME_CACHE_LIMIT
93 #ifdef USE_FRAME_CACHE_LIMIT
94 # define PLAY_FRAME_CACHE_MAX 30
150 printf(
" direction=%d,\n", (
int)ps->
direction);
151 printf(
" next=%d,\n", ps->next);
152 printf(
" once=%d,\n", ps->
once);
153 printf(
" turbo=%d,\n", ps->
turbo);
154 printf(
" pingpong=%d,\n", ps->
pingpong);
155 printf(
" noskip=%d,\n", ps->
noskip);
156 printf(
" sstep=%d,\n", ps->
sstep);
157 printf(
" pause=%d,\n", ps->pause);
158 printf(
" wait2=%d,\n", ps->
wait2);
159 printf(
" stopped=%d,\n", ps->
stopped);
160 printf(
" go=%d,\n\n", ps->
go);
243 #ifdef USE_FRAME_CACHE_LIMIT
254 #ifdef WITH_AUDASPACE
255 static double fps_movie;
258 #ifdef USE_FRAME_CACHE_LIMIT
271 .pics_size_in_memory = 0,
327 if (pic->
ibuf && pic->
ibuf != ibuf_keep) {
342 else if (pic->
anim) {
360 while (step-- && playanim) {
361 playanim = playanim->
next;
365 while (step++ && playanim) {
366 playanim = playanim->
prev;
388 void **r_buffer_cache_handle)
390 void *display_buffer;
391 bool force_fallback =
false;
392 *r_glsl_used =
false;
394 force_fallback |= (ibuf->
dither != 0.0f);
401 if (force_fallback) {
402 *r_glsl_used =
false;
403 display_buffer =
NULL;
430 else if (ibuf->
rect) {
431 display_buffer = ibuf->
rect;
440 display_buffer =
NULL;
452 return display_buffer;
457 void *display_buffer;
463 bool glsl_used =
false;
469 void *buffer_cache_handle =
NULL;
523 if (buffer_cache_handle) {
532 printf(
"%s: no ibuf for picture '%s'\n", __func__, picture ? picture->
name :
"<NIL>");
539 float span_x = (ps->
zoom * ibuf->
x) / (
float)ps->
win_x;
540 float span_y = (ps->
zoom * ibuf->
y) / (
float)ps->
win_y;
543 float offs_x = 0.5f * (1.0f - span_x);
544 float offs_y = 0.5f * (1.0f - span_y);
546 CLAMP(offs_x, 0.0f, 1.0f);
547 CLAMP(offs_y, 0.0f, 1.0f);
559 (
const float[4]){0.15, 0.15, 0.15, 1.0},
560 (
const float[4]){0.20, 0.20, 0.20, 1.0},
572 float fsizex_inv, fsizey_inv;
577 fsizex_inv = 1.0f / sizex;
578 fsizey_inv = 1.0f / sizey;
582 BLF_aspect(fontid, fsizex_inv, fsizey_inv, 1.0f);
583 BLF_position(fontid, 10.0f * fsizex_inv, 10.0f * fsizey_inv, 0.0f);
591 fac = 2.0f * fac - 1.0f;
617 PlayState *ps,
const char *
first,
int totframes,
int fstep,
int fontid)
633 picture->
frame = pic;
640 printf(
"couldn't open anim %s\n", first);
646 #ifdef USE_FRAME_CACHE_LIMIT
647 bool fill_cache =
true;
649 bool fill_cache =
false;
657 unsigned short digits;
663 filepath, fp_decoded.head, fp_decoded.tail, &fp_decoded.digits);
679 while (
IMB_ispic(filepath) && totframes) {
691 if (picture ==
NULL) {
692 printf(
"Not enough memory for pict struct '%s'\n", filepath);
711 printf(
"Couldn't get memory\n");
718 printf(
"Error while reading %s\n", filepath);
738 const bool display_imbuf =
ptottime > 1.0;
740 if (display_imbuf || fill_cache) {
748 #ifdef USE_FRAME_CACHE_LIMIT
750 picture->
ibuf = ibuf;
770 filepath, fp_decoded.head, fp_decoded.tail, fp_decoded.digits, fp_framenr);
793 #ifdef WITH_AUDASPACE
794 if (playback_handle) {
796 double speed = 1.0 / (
swaptime * fps_movie);
798 AUD_Handle_setPitch(playback_handle, speed);
827 #ifdef WITH_AUDASPACE
829 AUD_Handle_stop(scrub_handle);
833 if (playback_handle) {
834 AUD_Status status = AUD_Handle_getStatus(playback_handle);
835 if (status != AUD_STATUS_PLAYING) {
836 AUD_Handle_stop(playback_handle);
837 playback_handle = AUD_Device_play(audio_device, source, 1);
838 if (playback_handle) {
839 AUD_Handle_setPosition(playback_handle, i / fps_movie);
840 scrub_handle = AUD_pauseAfter(playback_handle, 1 / fps_movie);
845 AUD_Handle_setPosition(playback_handle, i / fps_movie);
846 scrub_handle = AUD_pauseAfter(playback_handle, 1 / fps_movie);
850 playback_handle = AUD_Device_play(audio_device, source, 1);
851 if (playback_handle) {
852 AUD_Handle_setPosition(playback_handle, i / fps_movie);
853 scrub_handle = AUD_pauseAfter(playback_handle, 1 / fps_movie);
890 switch (key_data->
key) {
920 switch (key_data->
key) {
1066 printf(
" Name: %s | Speed: %.2f frames/s\n",
1095 #ifdef WITH_AUDASPACE
1101 while (picture && picture != ps->
picture) {
1103 picture = picture->
next;
1105 if (playback_handle) {
1106 AUD_Handle_stop(playback_handle);
1108 playback_handle = AUD_Device_play(audio_device, source, 1);
1109 if (playback_handle) {
1110 AUD_Handle_setPosition(playback_handle, i / fps_movie);
1119 #ifdef WITH_AUDASPACE
1120 if (playback_handle) {
1121 AUD_Handle_stop(playback_handle);
1122 playback_handle =
NULL;
1132 #ifdef WITH_AUDASPACE
1137 while (picture && picture != ps->
picture) {
1139 picture = picture->
next;
1141 if (playback_handle) {
1142 AUD_Handle_stop(playback_handle);
1144 playback_handle = AUD_Device_play(audio_device, source, 1);
1145 if (playback_handle) {
1146 AUD_Handle_setPosition(playback_handle, i / fps_movie);
1162 #ifdef WITH_AUDASPACE
1163 if (playback_handle) {
1164 AUD_Handle_stop(playback_handle);
1165 playback_handle =
NULL;
1197 if (swaptime < ps->fstep / 5.0) {
1215 int cx, cy, sizex, sizey, inside_window;
1221 inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey);
1225 if (inside_window) {
1236 if (inside_window) {
1246 if (inside_window) {
1268 if (x_test != cd->
x || y_test != cd->
y) {
1321 for (
a = 0;
a < stra->
count;
a++) {
1324 printf(
"drop file %s\n", stra->
strings[
a]);
1345 posy = (scr_h - posy - sizey);
1366 if (ps->
zoom + zoom_offset > 0.0f) {
1367 ps->
zoom += zoom_offset;
1390 int start_x = 0, start_y = 0;
1424 if (argv[1][0] ==
'-') {
1425 switch (argv[1][1]) {
1431 start_x = atoi(argv[2]);
1432 start_y = atoi(argv[3]);
1437 printf(
"too few arguments for -p (need 2): skipping\n");
1442 double fps = atof(argv[2]);
1443 double fps_base = atof(argv[3]);
1455 printf(
"too few arguments for -f (need 2): skipping\n");
1459 sfra = atoi(argv[2]);
1465 efra = atoi(argv[2]);
1471 ps.
fstep = atoi(argv[2]);
1478 #ifdef USE_FRAME_CACHE_LIMIT
1479 const int memory_in_mb =
max_ii(0, atoi(argv[2]));
1480 g_frame_cache.memory_limit = (size_t)memory_in_mb * (1024 * 1024);
1487 printf(
"unknown option '%c': skipping\n", argv[1][1]);
1502 printf(
"%s: no filepath argument given\n", __func__);
1517 printf(
"%s: '%s' not an image file\n", __func__, filepath);
1527 printf(
"%s: '%s' couldn't open\n", __func__, filepath);
1560 if (maxwinx % ibuf->
x) {
1561 maxwinx = ibuf->
x * (1 + (maxwinx / ibuf->
x));
1563 if (maxwiny % ibuf->
y) {
1564 maxwiny = ibuf->
y * (1 + (maxwiny / ibuf->
y));
1577 if (sfra == -1 || efra == -1) {
1585 #ifdef WITH_AUDASPACE
1586 source = AUD_Sound_file(filepath);
1591 float frs_sec_base = 1.0;
1595 fps_movie = (
double)frs_sec / (
double)frs_sec_base;
1602 for (i = 2; i < argc; i++) {
1614 #define USE_IMB_CACHE
1629 printf(
"couldn't find pictures\n");
1644 #ifdef WITH_AUDASPACE
1645 if (playback_handle) {
1646 AUD_Handle_stop(playback_handle);
1648 playback_handle = AUD_Device_play(audio_device, source, 1);
1654 #ifndef USE_IMB_CACHE
1663 #ifdef USE_IMB_CACHE
1667 #ifdef USE_FRAME_CACHE_LIMIT
1692 printf(
"error: can't play this image type\n");
1710 if (ps.
go ==
false) {
1752 if (ps.
go ==
false) {
1776 #ifndef USE_IMB_CACHE
1784 #ifdef USE_FRAME_CACHE_LIMIT
1790 #ifdef WITH_AUDASPACE
1791 if (playback_handle) {
1792 AUD_Handle_stop(playback_handle);
1793 playback_handle =
NULL;
1796 AUD_Handle_stop(scrub_handle);
1797 scrub_handle =
NULL;
1799 AUD_Sound_free(source);
1833 printf(
"Error Totblock: %d\n",
totblock);
1843 const char *argv_next[2];
1844 bool looping =
true;
1846 #ifdef WITH_AUDASPACE
1848 AUD_DeviceSpecs specs;
1850 specs.rate = AUD_RATE_48000;
1851 specs.format = AUD_FORMAT_S16;
1852 specs.channels = AUD_CHANNELS_STEREO;
1856 if (!(audio_device = AUD_init(
NULL, specs, 1024,
"Blender"))) {
1857 audio_device = AUD_init(
"None", specs, 0,
"Blender");
1866 argv_next[0] = argv[0];
1867 argv_next[1] = filepath;
1878 #ifdef WITH_AUDASPACE
1879 AUD_exit(audio_device);
typedef float(TangentPoint)[2]
int ED_draw_imbuf_method(struct ImBuf *ibuf)
void BKE_images_exit(void)
void BLF_aspect(int fontid, float x, float y, float z)
void BLF_draw(int fontid, const char *str, size_t len) ATTR_NONNULL(2)
int BLF_load_mono_default(const bool unique)
void BLF_size(int fontid, int size, int dpi)
void BLF_enable(int fontid, int option)
void BLF_color4f(int fontid, float r, float g, float b, float a)
void BLF_position(int fontid, float x, float y, float z)
File and directory operations.
int BLI_open(const char *filename, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT
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_num_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
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
#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.
int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle, GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 *outX, GHOST_TInt32 *outY)
GHOST_SystemHandle GHOST_CreateSystem(void)
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle parent_windowhandle, const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, bool is_dialog, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings)
GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle, GHOST_TUns32 width, GHOST_TUns32 height)
void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
void GHOST_SetTitle(GHOST_WindowHandle windowhandle, const char *title)
GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle)
GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle, GHOST_TInt32 *x, GHOST_TInt32 *y)
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle, GHOST_TModifierKeyMask mask, int *isDown)
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle, GHOST_TUns32 *width, GHOST_TUns32 *height)
GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback, GHOST_TUserDataPtr userdata)
GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle)
@ GHOST_kWindowStateNormal
void * GHOST_TUserDataPtr
unsigned int GHOST_TUns32
@ GHOST_kEventWindowClose
@ GHOST_kEventDraggingDropDone
@ GHOST_kEventButtonUp
Mouse button event.
@ GHOST_kEventWindowActivate
@ GHOST_kEventWindowDeactivate
@ GHOST_kEventButtonDown
Mouse move event.
@ GHOST_kEventKeyDown
Trackpad event.
@ GHOST_kEventQuitRequest
@ GHOST_kDrawingContextTypeOpenGL
@ GHOST_kButtonMaskMiddle
@ GHOST_kModifierKeyRightControl
@ GHOST_kModifierKeyLeftControl
@ GHOST_kModifierKeyRightAlt
@ GHOST_kModifierKeyRightShift
@ GHOST_kModifierKeyLeftAlt
@ GHOST_kModifierKeyLeftShift
@ GHOST_kDragnDropTypeFilenames
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)
void GPU_shader_free_builtin_shaders(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)
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)
@ COLOR_ROLE_DEFAULT_BYTE
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_freeImBuf(struct ImBuf *ibuf)
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 RGB to Bright Vector Camera CLAMP
Platform independent time functions.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
void GPU_clear_color(float red, float green, float blue, float alpha)
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
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)
static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
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 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)
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 struct @1163 g_frame_cache
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)