gimp-gap r819 - in trunk: . docs/reference/txt gap libgapvidapi libgapvidutil vid_common vid_enc_avi vid_enc_ffmpeg
- From: wolfgangh svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp-gap r819 - in trunk: . docs/reference/txt gap libgapvidapi libgapvidutil vid_common vid_enc_avi vid_enc_ffmpeg
- Date: Mon, 9 Mar 2009 17:56:04 +0000 (UTC)
Author: wolfgangh
Date: Mon Mar 9 17:56:04 2009
New Revision: 819
URL: http://svn.gnome.org/viewvc/gimp-gap?rev=819&view=rev
Log:
check in of the missing changes (that completes the commit 2009.03.08 Rev. 818)
Modified:
trunk/ChangeLog
trunk/docs/reference/txt/gap_gimprc_params.txt
trunk/gap/Makefile.am
trunk/gap/gap_arr_dialog.c
trunk/gap/gap_audio_wav.c
trunk/gap/gap_decode_mplayer.c
trunk/gap/gap_decode_xanim.c
trunk/gap/gap_file_util.c
trunk/gap/gap_file_util.h
trunk/gap/gap_fmac_context.c
trunk/gap/gap_frame_fetcher.c
trunk/gap/gap_lib.c
trunk/gap/gap_lib.h
trunk/gap/gap_libgimpgap.h
trunk/gap/gap_lock.c
trunk/gap/gap_morph_exec.c
trunk/gap/gap_mov_dialog.c
trunk/gap/gap_mov_exec.c
trunk/gap/gap_mpege.c
trunk/gap/gap_navigator_dialog.c
trunk/gap/gap_onion_base.c
trunk/gap/gap_player_cache.c
trunk/gap/gap_player_dialog.c
trunk/gap/gap_split.c
trunk/gap/gap_story_dialog.c
trunk/gap/gap_story_file.c
trunk/gap/gap_story_properties.c
trunk/gap/gap_story_render_audio.c
trunk/gap/gap_story_render_processor.c
trunk/gap/gap_story_vthumb.c
trunk/gap/gap_video_index_creator.c
trunk/gap/gap_wr_color_curve.c
trunk/gap/gimplastvaldesc.c
trunk/libgapvidapi/gap_vid_api.c
trunk/libgapvidapi/gap_vid_api.h
trunk/libgapvidapi/gap_vid_api_ffmpeg.c
trunk/libgapvidapi/gap_vid_api_mpeg3.c
trunk/libgapvidapi/gap_vid_api_util.c
trunk/libgapvidapi/gap_vid_api_vidindex.c
trunk/libgapvidutil/gap_gve_misc_util.c
trunk/libgapvidutil/gap_gve_misc_util.h
trunk/libgapvidutil/gap_gve_png.c
trunk/vid_common/gap_cme_gui.c
trunk/vid_common/gap_cme_main.c
trunk/vid_enc_avi/gap_enc_avi_main.c
trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
Modified: trunk/docs/reference/txt/gap_gimprc_params.txt
==============================================================================
--- trunk/docs/reference/txt/gap_gimprc_params.txt (original)
+++ trunk/docs/reference/txt/gap_gimprc_params.txt Mon Mar 9 17:56:04 2009
@@ -166,9 +166,25 @@
# if turned off plaback clips according to their original pixelsize.
(video-storyboard-force-aspect-playback "yes")
+# maximal number of open videofiles for storyboard render
+# processor. The storyboard processor typically keeps more than
+# one videofile open when processing multiple input video clip
+# references within a storyboard. This is done for performance reasons.
+# But if there are too many open videofiles this may lead to
+# run out of memory and other resources. Therefore the number
+# of simultaneous open videofiles is limited to a default
+# of 12.
+# If you have less than 1GB of memory, you may use a smaller
+# value (minimum is 2) when you are running out of memory
+# while storyboard processing.
+# You still are able to process storyboards with many different
+# videoclips but this will be slower because there will be more
+# open, seek and close operations required with a smaller limit.
+(video-storyboard-max-open-videofiles 12)
+
# the video-libavformat-seek-gopsize parameter
-# enables native (fast) seek operations in the ffmeg (libavformat)
+# enables native (fast) seek operations in the ffmpeg (libavformat)
# video read access api.
# values <= 0 disables native seek operations.
# values > 4 define how many frames shall be sequentially read
@@ -190,8 +206,9 @@
# per frame. For frame exact operation on such (rare) videofiles
# you should disable native seek by setting the video-libavformat-seek-gopsize
# parameter to 0 and let gimp-gap create a videoindex.
-# (videoindex creation requires in initial full scann of the video,
-# but offers exact positioning. positioning via vidoeindex is slower than native seek)
+# (videoindex creation requires an initial full scann of the video,
+# but offers exact positioning.
+# positioning via vidoeindex is slower than native seek)
#
# an internal default value of 8 is used if no other value is configured.
# (this should be OK for most videofiles, if you work with mpeg2 dvd stuff
Modified: trunk/gap/Makefile.am
==============================================================================
--- trunk/gap/Makefile.am (original)
+++ trunk/gap/Makefile.am Mon Mar 9 17:56:04 2009
@@ -40,8 +40,6 @@
gap_audio_util.h \
gap_audio_wav.c \
gap_audio_wav.h \
- gap_file_util.c \
- gap_file_util.h \
gap_image.c \
gap_image.h \
gap_layer_copy.c \
Modified: trunk/gap/gap_arr_dialog.c
==============================================================================
--- trunk/gap/gap_arr_dialog.c (original)
+++ trunk/gap/gap_arr_dialog.c Mon Mar 9 17:56:04 2009
@@ -100,9 +100,9 @@
#include "libgimp/gimpui.h"
/* private includes */
+#include "gap_libgapbase.h"
#include "gap_arr_dialog.h"
#include "gap_stock.h"
-#include "gap_file_util.h"
#include "gap-intl.h"
/* default alignment for labels 0.0 == left, 1.0 == right */
Modified: trunk/gap/gap_audio_wav.c
==============================================================================
--- trunk/gap/gap_audio_wav.c (original)
+++ trunk/gap/gap_audio_wav.c Mon Mar 9 17:56:04 2009
@@ -18,10 +18,10 @@
#include <glib/gstdio.h>
+#include "gap_libgapbase.h"
#include "libgimp/gimp.h"
#include "gap-intl.h"
#include "gap_audio_wav.h"
-#include "gap_file_util.h"
extern int gap_debug;
Modified: trunk/gap/gap_decode_mplayer.c
==============================================================================
--- trunk/gap/gap_decode_mplayer.c (original)
+++ trunk/gap/gap_decode_mplayer.c Mon Mar 9 17:56:04 2009
@@ -188,10 +188,10 @@
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_lib.h"
#include "gap_arr_dialog.h"
#include "gap_decode_mplayer.h"
-#include "gap_file_util.h"
extern int gap_debug; /* ==0 ... dont print debug infos */
@@ -788,7 +788,7 @@
/* include process id of the current process in the temp dir name */
- l_pid = getpid();
+ l_pid = gap_base_getpid();
g_snprintf(tmp_dir, sizeof(tmp_dir), "tmp_mplayer_frames.%d", (int)l_pid);
if((gpp->basename[0] != '\0')
@@ -1143,10 +1143,7 @@
if(gap_debug) printf("poll started on mplayer pid: %d\n", (int)mplayer_pid);
- /* kill with signal 0 checks only if the process is alive (no signal is sent)
- * returns 0 if alive, 1 if no process with given pid found.
- */
- while (0 == kill(mplayer_pid, 0))
+ while (gap_base_is_pid_alive(mplayer_pid))
{
usleep(100000); /* sleep 1 second, and let mplayer write some frames */
Modified: trunk/gap/gap_decode_xanim.c
==============================================================================
--- trunk/gap/gap_decode_xanim.c (original)
+++ trunk/gap/gap_decode_xanim.c Mon Mar 9 17:56:04 2009
@@ -95,10 +95,10 @@
#define GAP_XANIM_HELP_ID "plug-in-gap-xanim-decode"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_lib.h"
#include "gap_arr_dialog.h"
#include "gap_decode_xanim.h"
-#include "gap_file_util.h"
extern int gap_debug; /* ==0 ... dont print debug infos */
Modified: trunk/gap/gap_file_util.c
==============================================================================
--- trunk/gap/gap_file_util.c (original)
+++ trunk/gap/gap_file_util.c Mon Mar 9 17:56:04 2009
@@ -23,321 +23,5 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* revision history:
- * version 1.2.1a; 2004.05.14 hof: created
- */
-
-/* SYTEM (UNIX) includes */
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include <glib/gstdio.h>
-
-/* GIMP includes */
-#include "gtk/gtk.h"
-#include "libgimp/gimp.h"
-
-
-#include "gap_file_util.h"
-
-extern int gap_debug; /* ==0 ... dont print debug infos */
-
-/*************************************************************
- * TOOL FUNCTIONS *
- *************************************************************/
-
-
-/* --------------------
- * gap_file_get_filesize
- * --------------------
- * get the filesize of a file.
- * in: fname: The filename of the file to check.
- * returns: The filesize.
- */
-gint32
-gap_file_get_filesize(const char *fname)
-{
- struct stat stat_buf;
-
- if (0 != g_stat(fname, &stat_buf))
- {
- printf ("stat error on '%s'\n", fname);
- return(0);
- }
-
- return((gint32)(stat_buf.st_size));
-}
-
-
-/* -----------------------
- * gap_file_load_file_segment
- * -----------------------
- * load one segment of (audio)data from a file.
- * into the buffer segment_data_ptr (must be allocated by the calling program)
- *
- * return number of bytes read from file
- */
-gint32
-gap_file_load_file_segment(const char *filename
- ,guchar *segment_data_ptr /* IN: pointer to memory at least segent_size large, OUT: filled with segment data */
- ,gint32 seek_index /* start byte of datasegment in file */
- ,gint32 segment_size /* segment size in byets (must be a multiple of 4) */
- )
-{
- FILE *fp;
- gint32 l_bytes_read;
-
-
- l_bytes_read = 0;
-
- fp = g_fopen(filename, "rb");
- if (fp)
- {
-
- fseek(fp, seek_index, SEEK_SET);
-
- /* read full segement size (or smaller rest until EOF) */
- l_bytes_read = fread(segment_data_ptr, 1, (size_t)segment_size, fp);
-
- fclose(fp);
- }
-
- if(gap_debug) printf("gap_file_load_file_segment: %s seek_idx:%d bytes_read:%d\n", filename, (int)seek_index, (int)l_bytes_read);
-
- return(l_bytes_read);
-
-} /* end gap_file_load_file_segment */
-
-
-/* -------------------------
- * gap_file_load_file_len
- * -------------------------
- * Load a file into a memory buffer
- * in: fname: The name of the file to load
- * returns: A pointer to the allocated buffer with the file content.
- */
-char *
-gap_file_load_file_len(const char *fname, gint32 *filelen)
-{
- FILE *fp;
- char *l_buff_ptr;
- long len;
-
- *filelen = 0;
-
- /* File Laenge ermitteln */
- len = gap_file_get_filesize(fname);
- if (len < 1)
- {
- return(NULL);
- }
-
- /* Buffer allocate */
- l_buff_ptr=(char *)g_malloc(len+1);
- if(l_buff_ptr == NULL)
- {
- printf ("calloc error (%d Bytes not available)\n", (int)len);
- return(NULL);
- }
- l_buff_ptr[len] = '\0';
-
- /* File in eine Buffer laden */
- fp = g_fopen(fname, "rb"); /* open read */
- if(fp == NULL)
- {
- printf ("open(read) error on '%s'\n", fname);
- return(NULL);
- }
- fread(l_buff_ptr, 1, (size_t)len, fp); /* read */
- fclose(fp); /* close */
-
- *filelen = len;
- return(l_buff_ptr);
-} /* end gap_file_load_file_len */
-
-/* -------------------------
- * gap_file_load_file
- * -------------------------
- */
-char *
-gap_file_load_file(const char *fname)
-{
- gint32 l_filelen;
-
- return(gap_file_load_file_len(fname, &l_filelen));
-} /* end gap_file_load_file */
-
-/* -------------------------
- * gap_file_chmod
- * -------------------------
- */
-int
-gap_file_chmod (const char *fname, int mode)
-{
- return(g_chmod(fname, mode));
-}
-
-/* -------------------------
- * gap_file_mkdir
- * -------------------------
- */
-int
-gap_file_mkdir (const char *fname, int mode)
-{
- return(g_mkdir(fname, mode));
-}
-
-
-
-/* ----------------------------------------------------
- * gap_file_chop_trailingspace_and_nl
- * ----------------------------------------------------
- * requires a '\0' terminated input buffer
- * chop trailing white space and newline chars
- * (by replacing those chars with \0 directly in the
- * specified buffer)
- */
-void
-gap_file_chop_trailingspace_and_nl(char *buffer)
-{
- int len;
- len = strlen(buffer);
- while(len > 0)
- {
- len--;
- if((buffer[len] == '\n')
- || (buffer[len] == '\r')
- || (buffer[len] == '\t')
- || (buffer[len] == ' '))
- {
- buffer[len] = '\0';
- }
- else
- {
- break;
- }
- }
-} /* end gap_file_chop_trailingspace_and_nl */
-
-
-/* ----------------------------------------------------
- * gap_file_make_abspath_filename
- * ----------------------------------------------------
- * check if filename is specified with absolute path,
- * if true: return 1:1 copy of filename
- * if false: prefix filename with path from container file.
- */
-char *
-gap_file_make_abspath_filename(const char *filename, const char *container_file)
-{
- gboolean l_path_is_relative;
- char *l_container_path;
- char *l_ptr;
- char *l_abs_name;
-
- l_abs_name = NULL;
- l_path_is_relative = TRUE;
- if(filename[0] == G_DIR_SEPARATOR)
- {
- l_path_is_relative = FALSE;
- }
-#ifdef G_OS_WIN32
- {
- gint l_idx;
-
- /* check for WIN/DOS styled abs pathname "Drive:\dir\file" */
- for(l_idx=0; filename[l_idx] != '\0'; l_idx++)
- {
- if(filename[l_idx] == DIR_ROOT)
- {
- l_path_is_relative = FALSE;
- break;
- }
- }
- }
-#endif
-
- if((l_path_is_relative) && (container_file != NULL))
- {
- l_container_path = g_strdup(container_file);
- l_ptr = &l_container_path[strlen(l_container_path)];
- while(l_ptr != l_container_path)
- {
- if((*l_ptr == G_DIR_SEPARATOR) || (*l_ptr == DIR_ROOT))
- {
- l_ptr++;
- *l_ptr = '\0'; /* terminate the string after the directorypath */
- break;
- }
- l_ptr--;
- }
- if(l_ptr != l_container_path)
- {
- /* prefix the filename with the container_path */
- l_abs_name = g_strdup_printf("%s%s", l_container_path, filename);
- }
- else
- {
- /* container_file has no path at all (and must be in the current dir)
- * (therefore we cant expand absolute path name)
- */
- l_abs_name = g_strdup(filename);
- }
- g_free(l_container_path);
- }
- else
- {
- /* use absolute filename as it is */
- l_abs_name = g_strdup(filename);
- }
-
- return(l_abs_name);
-
-} /* end gap_file_make_abspath_filename */
-
-
-/* --------------------------------
- * gap_file_build_absolute_filename
- * --------------------------------
- */
-char *
-gap_file_build_absolute_filename(const char * filename)
-{
- gchar *absolute;
- if (! g_path_is_absolute (filename))
- {
- gchar *current;
-
- current = g_get_current_dir ();
- absolute = g_build_filename (current, filename, NULL);
- g_free (current);
- }
- else
- {
- absolute = g_strdup (filename);
- }
- return (absolute);
-} /* end gap_file_build_absolute_filename */
-
-/* --------------------------------
- * gap_file_get_mtime
- * --------------------------------
- */
-gint32
-gap_file_get_mtime(const char *filename)
-{
- struct stat l_stat;
- if(filename != NULL)
- {
- if (0 == g_stat(filename, &l_stat))
- {
- return(l_stat.st_mtime);
- }
- }
- return(0);
-
-} /* end gap_file_get_mtime */
+/* the productive gap_file_util.c has moved to lbgapbase direcory */
Modified: trunk/gap/gap_file_util.h
==============================================================================
--- trunk/gap/gap_file_util.h (original)
+++ trunk/gap/gap_file_util.h Mon Mar 9 17:56:04 2009
@@ -26,63 +26,4 @@
* version 1.2.1a; 2004.05.14 hof: created
*/
-#ifndef GAP_FILE_UTIL_H
-#define GAP_FILE_UTIL_H
-
-#include "libgimp/gimp.h"
-
-/* G_DIR_SEPARATOR (is defined in glib.h if you have glib-1.2.0 or later) */
-#ifdef G_OS_WIN32
-
-/* Filenames in WIN/DOS Style */
-#ifndef G_DIR_SEPARATOR
-#define G_DIR_SEPARATOR '\\'
-#endif
-#define DIR_ROOT ':'
-
-#else /* !G_OS_WIN32 */
-
-/* Filenames in UNIX Style */
-#ifndef G_DIR_SEPARATOR
-#define G_DIR_SEPARATOR '/'
-#endif
-#define DIR_ROOT '/'
-
-#endif /* !G_OS_WIN32 */
-
-#ifdef G_OS_WIN32
-#include <direct.h> /* For _mkdir() */
-#define mkdir(path,mode) _mkdir(path)
-#endif
-
-
-#ifdef G_OS_WIN32
-#define GAP_FILE_MKDIR_MODE 0 /* not relevant for WIN mkdir */
-#else
-#define GAP_FILE_MKDIR_MODE (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
-#endif
-
-/* --------------------------*/
-/* PROCEDURE DECLARATIONS */
-/* --------------------------*/
-
-gint32 gap_file_get_filesize(const char *fname);
-char* gap_file_load_file(const char *fname);
-char* gap_file_load_file_len(const char *fname, gint32 *filelen);
-gint32 gap_file_load_file_segment(const char *filename
- ,guchar *segment_data_ptr /* IN: pointer to memory at least segent_size large, OUT: filled with segment data */
- ,gint32 seek_index /* start byte of datasegment in file */
- ,gint32 segment_size /* segment size in byets (must be a multiple of 4) */
- );
-
-int gap_file_chmod (const char *fname, int mode);
-int gap_file_mkdir (const char *fname, int mode);
-void gap_file_chop_trailingspace_and_nl(char *buff);
-char * gap_file_make_abspath_filename(const char *filename
- , const char *container_file);
-
-char * gap_file_build_absolute_filename(const char * filename);
-gint32 gap_file_get_mtime(const char *filename);
-
-
-#endif /* GAP_FILE_UTIL_H */
+/* the productive gap_file_util.h has moved to lbgapbase direcory */
Modified: trunk/gap/gap_fmac_context.c
==============================================================================
--- trunk/gap/gap_fmac_context.c (original)
+++ trunk/gap/gap_fmac_context.c Mon Mar 9 17:56:04 2009
@@ -38,9 +38,9 @@
#include <glib/gstdio.h>
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_fmac_context.h"
#include "gap_frame_fetcher.h"
-#include "gap_file_util.h"
#include "gap_val_file.h"
Modified: trunk/gap/gap_frame_fetcher.c
==============================================================================
--- trunk/gap/gap_frame_fetcher.c (original)
+++ trunk/gap/gap_frame_fetcher.c Mon Mar 9 17:56:04 2009
@@ -77,9 +77,9 @@
#include "libgimp/gimp.h"
+#include "gap_libgapbase.h"
#include "gap_libgimpgap.h"
#include "gap_lib_common_defs.h"
-#include "gap_file_util.h"
#include "gap_layer_copy.h"
//#include "gap_fmac_name.h"
@@ -175,7 +175,7 @@
if(filename == NULL)
{
- printf("p_load_cache_image: ** ERROR cant load filename == NULL! pid:%d\n", (int)getpid());
+ printf("p_load_cache_image: ** ERROR cant load filename == NULL! pid:%d\n", (int)gap_base_getpid());
return -1;
}
@@ -223,7 +223,7 @@
, gimp_image_get_filename(images[l_idi])
, (int)mtimefile
, (int)*mtime_ptr
- , (int)getpid()
+ , (int)gap_base_getpid()
);
}
gap_image_delete_immediate(images[l_idi]);
@@ -243,7 +243,7 @@
if(gap_debug)
{
printf("FrameFetcher: p_load_cache_image CACHE-HIT :%s (image_id:%d) pid:%d\n"
- , filename, (int)l_image_id, (int)getpid());
+ , filename, (int)l_image_id, (int)gap_base_getpid());
}
return(l_image_id);
}
@@ -253,7 +253,7 @@
if(gap_debug)
{
printf("FrameFetcher: loaded image from disk:%s (image_id:%d) pid:%d\n"
- , l_filename, (int)l_image_id, (int)getpid());
+ , l_filename, (int)l_image_id, (int)gap_base_getpid());
}
if((l_image_id >= 0) && (addToCache == TRUE))
@@ -275,7 +275,7 @@
, (int)l_first_chached_image_id
, gimp_image_get_filename(images[l_idi])
, (int)l_number_of_cached_images
- , (int)getpid()
+ , (int)gap_base_getpid()
);
}
gap_image_delete_immediate(l_first_chached_image_id);
@@ -326,7 +326,7 @@
if(gap_debug)
{
- printf("p_drop_image_cache START pid:%d\n", (int) getpid());
+ printf("p_drop_image_cache START pid:%d\n", (int) gap_base_getpid());
}
images = gimp_image_list(&nimages);
@@ -341,7 +341,7 @@
printf("FrameFetcher: CHECK (image_id:%d) name:%s pid:%d\n"
, (int)images[l_idi]
, gimp_image_get_filename(images[l_idi])
- , (int)getpid()
+ , (int)gap_base_getpid()
);
}
@@ -352,7 +352,7 @@
printf("FrameFetcher: DELETE (image_id:%d) name:%s pid:%d\n"
, (int)images[l_idi]
, gimp_image_get_filename(images[l_idi])
- , (int)getpid()
+ , (int)gap_base_getpid()
);
}
/* delete image from the duplicates cache */
@@ -367,7 +367,7 @@
if(gap_debug)
{
- printf("p_drop_image_cache END pid:%d\n", (int)getpid());
+ printf("p_drop_image_cache END pid:%d\n", (int)gap_base_getpid());
}
} /* end p_drop_image_cache */
@@ -515,7 +515,7 @@
gvc_new = g_malloc0(sizeof(GapFFetchGvahandCacheElem));
gvc_new->filename = g_strdup(filename);
gvc_new->seltrack = seltrack;
- gvc_new->mtime = GVA_file_get_mtime(filename);
+ gvc_new->mtime = gap_file_get_mtime(filename);
gvc_new->gvahand = l_gvahand;
if(gvcache->gvc_list == NULL)
@@ -592,7 +592,7 @@
printf("FrameFetcher: check (image_id:%d) name:%s pid:%d\n"
, (int)images[l_idi]
, gimp_image_get_filename(images[l_idi])
- , (int)getpid()
+ , (int)gap_base_getpid()
);
}
@@ -611,7 +611,7 @@
, (int)ffetch_user_id
, (int)*ffetch_user_id_ptr
, gimp_image_get_filename(images[l_idi])
- , (int)getpid()
+ , (int)gap_base_getpid()
);
}
/* delete image from the duplicates cache */
@@ -884,7 +884,7 @@
, new_usr_ptr->ffetch_user_id
, caller_name
, (int)&new_usr_ptr
- , (int) getpid()
+ , (int) gap_base_getpid()
);
}
return (max_ffetch_user_id);
@@ -919,7 +919,7 @@
{
printf("gap_frame_fetch_unregister_user: UNREGISTER ffetch_user_id:%d pid:%d\n"
, ffetch_user_id
- , (int) getpid()
+ , (int) gap_base_getpid()
);
}
Modified: trunk/gap/gap_lib.c
==============================================================================
--- trunk/gap/gap_lib.c (original)
+++ trunk/gap/gap_lib.c Mon Mar 9 17:56:04 2009
@@ -27,8 +27,8 @@
/* revision history:
* 2.1.0a 2005/03/10 hof: added active_layer_tracking feature
- * 2.1.0a 2004/12/04 hof: added gap_lib_shorten_filename
- * 2.1.0a 2004/04/18 hof: added gap_lib_fprintf_gdouble
+ * 2.1.0a 2004/12/04 hof: added gap_lib (base)_shorten_filename
+ * 2.1.0a 2004/04/18 hof: added gap_lib (base)_fprintf_gdouble
* 1.3.26a 2004/02/01 hof: added: gap_lib_alloc_ainfo_from_name
* 1.3.25a 2004/01/20 hof: - removed xvpics support (gap_lib_get_video_paste_name)
* 1.3.21e 2003/11/04 hof: - gimprc
@@ -523,225 +523,7 @@
} /* end p_do_active_layer_tracking */
-/* -----------------------------
- * gap_lib_shorten_filename
- * -----------------------------
- * resulting string is built from prefix filename and suffix
- * filename will be shortened when
- * prefix + " " + filename + " " + suffix
- * is longer then max_chars.
- * examples:
- * gap_lib_shorten_filenam("prefix", "this_is_a_very_long_filename", NULL, 20)
- * returns: "prefix ...g_filename"
- *
- * gap_lib_shorten_filenam("prefix", "shortname", NULL, 20)
- * returns: "prefix shortname"
- *
- * the caller is responsible to g_free the returned string
- */
-char *
-gap_lib_shorten_filename(const char *prefix
- ,const char *filename
- ,const char *suffix
- ,gint32 max_chars
- )
-{
- gint len_prefix;
- gint len_fname;
- const char *pfx;
- char *fnam;
- char *ret_string;
-
- len_prefix = 0;
- len_fname = 0;
- ret_string = NULL;
- pfx = prefix;
- if(prefix)
- {
- len_prefix = strlen(prefix);
- if((len_prefix + 10) > max_chars)
- {
- pfx = NULL;
- len_prefix = 0;
- }
- else
- {
- len_prefix++; /* for the space between prefix and fname */
- }
- }
-
-
- if(filename)
- {
- fnam = NULL;
-
- if(suffix)
- {
- fnam = g_strdup_printf("%s %s", filename, suffix);
- }
- else
- {
- fnam = g_strdup(filename);
- }
-
-
- len_fname = strlen(fnam);
- if((len_fname + len_prefix) <= max_chars)
- {
- if(pfx)
- {
- ret_string = g_strdup_printf("%s %s"
- ,pfx
- ,fnam
- );
- }
- else
- {
- ret_string = g_strdup_printf("%s"
- ,fnam
- );
- }
- }
- else
- {
- gint fname_idx;
- gint len_rest;
-
- len_rest = (max_chars - len_prefix - 3);
- fname_idx = len_fname - len_rest;
-
- if(pfx)
- {
- ret_string = g_strdup_printf("%s ...%s"
- ,pfx
- ,&fnam[fname_idx]
- );
- }
- else
- {
- ret_string = g_strdup_printf("...%s"
- ,&fnam[fname_idx]
- );
- }
- }
-
- g_free(fnam);
- return (ret_string);
-
- }
-
- ret_string = g_strdup(prefix);
- return(ret_string);
-} /* end gap_lib_shorten_filename */
-
-
-/* -----------------------------
- * gap_lib_strdup_add_underscore
- * -----------------------------
- * duplicates the specifed string and if last character is no underscore add one at end.
- * the caller is responsible to g_free the result after usage.
- */
-char *
-gap_lib_strdup_add_underscore(char *name)
-{
- int l_len;
- char *l_str;
- if(name == NULL)
- {
- return(g_strdup("\0"));
- }
-
- l_len = strlen(name);
- l_str = g_malloc(l_len+2);
- strcpy(l_str, name);
- if(l_len > 0)
- {
- if (name[l_len-1] != '_')
- {
- l_str[l_len ] = '_';
- l_str[l_len +1 ] = '\0';
- }
-
- }
- return(l_str);
-}
-
-/* -----------------------------
- * gap_lib_strdup_del_underscore
- * -----------------------------
- * duplicates the specifed string and delete the last character
- * if it is the underscore
- * the caller is responsible to g_free the result after usage.
- */
-char *
-gap_lib_strdup_del_underscore(char *name)
-{
- int l_len;
- char *l_str;
- if(name == NULL)
- {
- return(g_strdup("\0"));
- }
-
- l_len = strlen(name);
- l_str = g_strdup(name);
- if(l_len > 0)
- {
- if (l_str[l_len-1] == '_')
- {
- l_str[l_len -1 ] = '\0';
- }
-
- }
- return(l_str);
-}
-
-
-/* --------------------------------------------------------
- * gap_lib_dup_filename_and_replace_extension_by_underscore
- * --------------------------------------------------------
- * returns a duplicate of the specified filename where the extension
- * (.xcf .jpg ...) is cut off and rplaced by the underscore character.
- * example: filename = "image_000001.xcf"
- * returns "image_000001_"
- *
- * the caller is responsible to g_free the result after usage.
- */
-char *
-gap_lib_dup_filename_and_replace_extension_by_underscore(const char *filename)
-{
- int l_len;
- int l_idx;
- char *l_str;
- char *l_nameWithUnderscore;
-
- if(filename == NULL)
- {
- return (g_strdup("_"));
- }
-
- l_len = strlen(filename);
- l_str = g_strdup(filename);
-
- /* cut off the trailing .extension */
- for(l_idx = l_len -1; l_idx >= 0; l_idx--)
- {
- if (l_str[l_idx] == '.')
- {
- l_str[l_idx] = '\0';
- break;
- }
- }
-
- /* add underscore (if not already there) */
- l_nameWithUnderscore = gap_lib_strdup_add_underscore(l_str);
-
- g_free(l_str);
-
- return (l_nameWithUnderscore);
-
-} /* end gap_lib_dup_filename_and_replace_extension_by_underscore */
-
+
/* ============================================================================
* gap_lib_file_exists
@@ -3518,115 +3300,3 @@
} /* end gap_vid_edit_paste */
-/* --------------------------------
- * gap_lib_fprintf_gdouble
- * --------------------------------
- * print prefix and gdouble value to file
- * (always use "." as decimalpoint, independent of LOCALE language settings)
- */
-void
-gap_lib_fprintf_gdouble(FILE *fp, gdouble value, gint digits, gint precision_digits, const char *pfx)
-{
- gchar l_dbl_str[G_ASCII_DTOSTR_BUF_SIZE];
- gchar l_fmt_str[20];
- gint l_len;
-
- g_snprintf(l_fmt_str, sizeof(l_fmt_str), "%%.%df", (int)precision_digits);
- g_ascii_formatd(l_dbl_str, sizeof(l_dbl_str), l_fmt_str, value);
-
- fprintf(fp, "%s", pfx);
-
- /* make leading blanks */
- l_len = strlen(l_dbl_str) - (digits + 1 + precision_digits);
- while(l_len < 0)
- {
- fprintf(fp, " ");
- l_len++;
- }
- fprintf(fp, "%s", l_dbl_str);
-} /* end gap_lib_fprintf_gdouble */
-
-
-/* ============================================================================
- * gap_lib_sscan_flt_numbers
- * ============================================================================
- * scan the blank separated buffer for 2 integer and 13 float numbers.
- * always use "." as decimalpoint in the float numbers regardless to LANGUAGE settings
- * return a counter that tells how many numbers were scanned successfully
- */
-gint
-gap_lib_sscan_flt_numbers(gchar *buf
- , gdouble *farr
- , gint farr_max
- )
-{
- gint l_cnt;
- gchar *nptr;
- gchar *endptr;
-
- l_cnt =0;
- nptr = buf;
- while(l_cnt < farr_max)
- {
- endptr = nptr;
- farr[l_cnt] = g_ascii_strtod(nptr, &endptr);
- if(nptr == endptr)
- {
- break; /* pointer was not advanced because no valid floatnumber was scanned */
- }
- nptr = endptr;
-
- l_cnt++; /* count successful scans */
- }
-
- return (l_cnt);
-} /* end gap_lib_sscan_flt_numbers */
-
-
-/* --------------------------------
- * gap_lib_check_tooltips
- * --------------------------------
- * check and enable/disable tooltips according to global gimprc settings
- */
-gboolean
-gap_lib_check_tooltips(gboolean *old_state)
-{
- char *value_string;
- gboolean new_state;
- gboolean changed;
-
- new_state = TRUE;
- changed = TRUE;
-
- value_string = gimp_gimprc_query("show-tooltips");
- if(value_string != NULL)
- {
- if (strcmp(value_string, "no") == 0)
- {
- new_state = FALSE;
- }
- }
-
- if (old_state != NULL)
- {
- if(*old_state == new_state)
- {
- changed = FALSE;
- }
- }
-
- if (changed == TRUE)
- {
- if(new_state == TRUE)
- {
- gimp_help_enable_tooltips ();
- }
- else
- {
- gimp_help_disable_tooltips ();
- }
- }
-
- return (new_state);
-
-} /* end gap_lib_check_tooltips */
Modified: trunk/gap/gap_lib.h
==============================================================================
--- trunk/gap/gap_lib.h (original)
+++ trunk/gap/gap_lib.h Mon Mar 9 17:56:04 2009
@@ -37,7 +37,7 @@
* 1.1.29a; 2000/11/23 hof: gap locking (changed to procedures and placed here)
* 1.1.20a; 2000/04/25 hof: new: gap_lib_get_video_paste_name p_clear_video_paste
* 1.1.14a; 2000/01/02 hof: new: gap_lib_get_frame_nr
- * 1.1.8a; 1999/08/31 hof: new: gap_lib_strdup_del_underscore and gap_lib_strdup_add_underscore
+ * 1.1.8a; 1999/08/31 hof: new: gap_lib_strdup_del_underscore and gap_lib(base)_strdup_add_underscore
* 0.99.00; 1999/03/15 hof: prepared for win/dos filename conventions
* 0.96.02; 1998/08/05 hof: extended gap_dup (duplicate range instead of singele frame)
* added gap_shift (framesequence shift)
@@ -55,12 +55,6 @@
/* procedures used in other gap*.c files */
-char * gap_lib_shorten_filename(const char *prefix
- ,const char *filename
- ,const char *suffix
- ,gint32 max_chars
- );
-char * gap_lib_dup_filename_and_replace_extension_by_underscore(const char *filename);
int gap_lib_file_exists(const char *fname);
char* gap_lib_searchpath_for_exefile(const char *exefile, const char *path);
int gap_lib_file_copy(char *fname, char *fname_copy);
@@ -81,8 +75,6 @@
char* gap_lib_alloc_fname(char *basename, long nr, char *extension);
char* gap_lib_alloc_fname6(char *basename, long nr, char *extension, long default_digits);
gboolean gap_lib_exists_frame_nr(GapAnimInfo *ainfo_ptr, long nr, long *l_has_digits);
-char* gap_lib_strdup_add_underscore(char *name);
-char* gap_lib_strdup_del_underscore(char *name);
long gap_lib_get_frame_nr(gint32 image_id);
long gap_lib_get_frame_nr_from_name(char *fname);
@@ -94,8 +86,6 @@
gint32 gap_vid_edit_framecount(void);
gint gap_vid_edit_copy(GimpRunMode run_mode, gint32 image_id, long range_from, long range_to);
gint32 gap_vid_edit_paste(GimpRunMode run_mode, gint32 image_id, long paste_mode);
-gint32 gap_lib_getpid(void);
-gint gap_lib_pid_is_alive(gint32 pid);
gboolean gap_lib_gap_check_save_needed(gint32 image_id);
@@ -103,9 +93,6 @@
int gap_lib_delete_frame(GapAnimInfo *ainfo_ptr, long nr);
gint32 gap_lib_replace_image(GapAnimInfo *ainfo_ptr);
-void gap_lib_fprintf_gdouble(FILE *fp, gdouble value, gint digits, gint precision_digits, const char *pfx);
-gint gap_lib_sscan_flt_numbers(gchar *buf, gdouble *farr, gint farr_max);
-gboolean gap_lib_check_tooltips(gboolean *old_state);
#endif
Modified: trunk/gap/gap_libgimpgap.h
==============================================================================
--- trunk/gap/gap_libgimpgap.h (original)
+++ trunk/gap/gap_libgimpgap.h Mon Mar 9 17:56:04 2009
@@ -36,7 +36,6 @@
#include "gap-intl.h"
#include "gap_arr_dialog.h"
-#include "gap_file_util.h"
#include "gap_image.h"
#include "gap_layer_copy.h"
#include "gap_lib.h"
Modified: trunk/gap/gap_lock.c
==============================================================================
--- trunk/gap/gap_lock.c (original)
+++ trunk/gap/gap_lock.c Mon Mar 9 17:56:04 2009
@@ -51,6 +51,7 @@
#include "libgimp/gimp.h"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_lock.h"
extern int gap_debug; /* ==0 ... dont print debug infos */
@@ -63,41 +64,6 @@
gint32 pid;
} t_gap_lockdata;
-static gint32
-gap_lib_getpid(void)
-{
-#ifndef G_OS_WIN32
- /* for UNIX */
- return ((gint32)getpid());
-#else
- /* hof: dont know how to getpid on windows */
- return 0;
-#endif
-}
-
-static gint
-gap_lib_pid_is_alive(gint32 pid)
-{
-#ifndef G_OS_WIN32
- /* for UNIX */
-
- /* kill with signal 0 checks only if the process is alive (no signal is sent)
- * returns 0 if alive, 1 if no process with given pid found.
- */
- if (0 == kill(pid, 0))
- {
- return(TRUE);
- }
- return (FALSE);
-#else
- /* hof: dont know how to check on Windows
- * assume that process is always alive
- * (therefore on Windows locks will not be cleared
- * automatically after crashes of the locking process)
- */
- return(TRUE);
-#endif
-}
/* ============================================================================
@@ -128,7 +94,7 @@
{
if(l_locktab[l_idx].image_id == image_id)
{
- if(gap_lib_pid_is_alive(l_locktab[l_idx].pid))
+ if(gap_base_is_pid_alive(l_locktab[l_idx].pid))
{
if(run_mode == GIMP_RUN_INTERACTIVE)
{
@@ -183,7 +149,7 @@
for(l_idx=0; l_idx < l_nlocks_old; l_idx++)
{
if((l_locktab[l_idx].image_id < 0)
- || (!gap_lib_pid_is_alive(l_locktab[l_idx].pid)))
+ || (!gap_base_is_pid_alive(l_locktab[l_idx].pid)))
{
l_nlocks--; /* empty record found, dont need the extra record */
break;
@@ -199,7 +165,7 @@
}
l_locktab[l_idx].image_id = image_id;
- l_locktab[l_idx].pid = gap_lib_getpid();
+ l_locktab[l_idx].pid = gap_base_getpid();
gimp_set_data(GAP_LOCKTABLE_KEY, l_locktab, l_nlocks * sizeof(t_gap_lockdata));
Modified: trunk/gap/gap_morph_exec.c
==============================================================================
--- trunk/gap/gap_morph_exec.c (original)
+++ trunk/gap/gap_morph_exec.c Mon Mar 9 17:56:04 2009
@@ -52,6 +52,7 @@
#include "libgimp/gimp.h"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap-intl.h"
#include "gap_image.h"
#include "gap_morph_main.h"
@@ -250,13 +251,13 @@
,(int)mgup->mgpp->tween_steps
);
fprintf(l_fp, "AFFECT-RADIUS:");
- gap_lib_fprintf_gdouble(l_fp, mgup->mgpp->affect_radius, 4, 2, " ");
+ gap_base_fprintf_gdouble(l_fp, mgup->mgpp->affect_radius, 4, 2, " ");
fprintf(l_fp, " # pixels\n");
fprintf(l_fp, "INTENSITY:");
if(mgup->mgpp->use_gravity)
{
- gap_lib_fprintf_gdouble(l_fp, mgup->mgpp->gravity_intensity, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, mgup->mgpp->gravity_intensity, 2, 3, " ");
fprintf(l_fp, "\n");
}
else
@@ -292,10 +293,10 @@
for(wp = mgup->mgpp->master_wp_list; wp != NULL; wp = (GapMorphWorkPoint *)wp->next)
{
fprintf(l_fp, "WP: ");
- gap_lib_fprintf_gdouble(l_fp, wp->osrc_x, 4, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, wp->osrc_y, 4, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, wp->fdst_x, 4, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, wp->fdst_y, 4, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, wp->osrc_x, 4, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, wp->osrc_y, 4, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, wp->fdst_x, 4, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, wp->fdst_y, 4, 3, " ");
fprintf(l_fp, "\n"); /* terminate the output line */
}
@@ -387,7 +388,7 @@
if(strncmp(l_ptr, "LAYER-SIZES:", l_len) == 0)
{
l_ptr += l_len;
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
if(l_cnt >= 4)
{
src_scale_x = MAX(1,src_layer_width) / MAX(1,l_farr[0]);
@@ -408,7 +409,7 @@
if(strncmp(l_ptr, "TWEEN-STEPS:", l_len) == 0)
{
l_ptr += l_len;
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
if(l_cnt >= 1)
{
*tween_steps = MAX(1,l_farr[0]);
@@ -426,7 +427,7 @@
if(strncmp(l_ptr, "AFFECT-RADIUS:", l_len) == 0)
{
l_ptr += l_len;
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
if(l_cnt >= 1)
{
*affect_radius = MAX(0,l_farr[0]);
@@ -444,7 +445,7 @@
if(strncmp(l_ptr, "INTENSITY:", l_len) == 0)
{
l_ptr += l_len;
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
if(l_cnt >= 1)
{
*gravity_intensity = MAX(0,l_farr[0]);
@@ -466,7 +467,7 @@
if(strncmp(l_ptr, "QUALITY-WP-SELECT:", l_len) == 0)
{
l_ptr += l_len;
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
if(l_cnt >= 1)
{
*use_quality_wp_selection = FALSE;
@@ -488,7 +489,7 @@
if(strncmp(l_ptr, "WP:", l_len) == 0)
{
l_ptr += l_len;
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
if(l_cnt >= 4)
{
wp = g_new(GapMorphWorkPoint, 1);
Modified: trunk/gap/gap_mov_dialog.c
==============================================================================
--- trunk/gap/gap_mov_dialog.c (original)
+++ trunk/gap/gap_mov_dialog.c Mon Mar 9 17:56:04 2009
@@ -113,6 +113,7 @@
#include "libgimp/gimpui.h"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_layer_copy.h"
#include "gap_lib.h"
#include "gap_image.h"
@@ -459,7 +460,7 @@
pvals = mov_ptr->val_ptr;
- l_str = gap_lib_strdup_del_underscore(mov_ptr->dst_ainfo_ptr->basename);
+ l_str = gap_base_strdup_del_underscore(mov_ptr->dst_ainfo_ptr->basename);
mgp->pointfile_name = g_strdup_printf("%s.path_points", l_str);
g_free(l_str);
Modified: trunk/gap/gap_mov_exec.c
==============================================================================
--- trunk/gap/gap_mov_exec.c (original)
+++ trunk/gap/gap_mov_exec.c Mon Mar 9 17:56:04 2009
@@ -63,6 +63,7 @@
#include "libgimp/gimp.h"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap-intl.h"
#include "gap_layer_copy.h"
#include "gap_lib.h"
@@ -1441,11 +1442,11 @@
, (int)pvals->point[l_idx].p_x
, (int)pvals->point[l_idx].p_y
);
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].w_resize, 3, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].h_resize, 3, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].opacity, 3, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].rotation, 3, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].sel_feather_radius, 3, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].w_resize, 3, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].h_resize, 3, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].opacity, 3, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].rotation, 3, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].sel_feather_radius, 3, 3, " ");
num_optional_params = 0;
@@ -1474,17 +1475,17 @@
if(num_optional_params >= 8)
{
fprintf(l_fp, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].ttlx, 2, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].ttly, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].ttlx, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].ttly, 2, 3, " ");
fprintf(l_fp, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].ttrx, 2, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].ttry, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].ttrx, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].ttry, 2, 3, " ");
fprintf(l_fp, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].tblx, 2, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].tbly, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].tblx, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].tbly, 2, 3, " ");
fprintf(l_fp, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].tbrx, 2, 3, " ");
- gap_lib_fprintf_gdouble(l_fp, pvals->point[l_idx].tbry, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].tbrx, 2, 3, " ");
+ gap_base_fprintf_gdouble(l_fp, pvals->point[l_idx].tbry, 2, 3, " ");
}
/* conditional write keyframe */
@@ -1545,7 +1546,7 @@
/* check if line empty or comment only (starts with '#') */
if((*l_ptr != '#') && (*l_ptr != '\n') && (*l_ptr != '\0'))
{
- l_cnt = gap_lib_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
+ l_cnt = gap_base_sscan_flt_numbers(l_ptr, &l_farr[0], MAX_NUMVALUES_PER_LINE);
l_i1 = (gint)l_farr[0];
l_i2 = (gint)l_farr[1];
if(l_idx == -1)
Modified: trunk/gap/gap_mpege.c
==============================================================================
--- trunk/gap/gap_mpege.c (original)
+++ trunk/gap/gap_mpege.c Mon Mar 9 17:56:04 2009
@@ -63,6 +63,7 @@
#include "libgimp/gimp.h"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_lib.h"
#include "gap_arr_dialog.h"
#include "gap_mpege.h"
@@ -287,7 +288,7 @@
b_argv[2].but_txt = _("Gen + Encode");
b_argv[2].but_val = 1;
- l_str = gap_lib_strdup_del_underscore(ainfo_ptr->basename);
+ l_str = gap_base_strdup_del_underscore(ainfo_ptr->basename);
g_snprintf (l_outfile, MBUF_SIZE, "%s.mpg", l_str);
g_snprintf (l_parfile, MBUF_SIZE, "%s.par_mpg", l_str);
g_snprintf (l_startscript, MBUF_SIZE, "%s.sh", l_str);
Modified: trunk/gap/gap_navigator_dialog.c
==============================================================================
--- trunk/gap/gap_navigator_dialog.c (original)
+++ trunk/gap/gap_navigator_dialog.c Mon Mar 9 17:56:04 2009
@@ -117,6 +117,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include "gap_stock.h"
#include "gap_timeconv.h"
@@ -600,13 +601,12 @@
{
gimp_get_data(PLUGIN_NAME, &l_navid_pid);
+ /* note that the check gap_base_is_pid_alive implementation does not work on WINDOWS
+ */
#ifndef G_OS_WIN32
if(l_navid_pid != 0)
{
- /* kill with signal 0 checks only if the process is alive (no signal is sent)
- * returns 0 if alive, 1 if no process with given pid found.
- */
- if (0 == kill(l_navid_pid, 0))
+ if (gap_base_is_pid_alive(l_navid_pid))
{
gap_arr_msg_win(GIMP_RUN_INTERACTIVE, _("Cant open two or more video navigator windows."));
l_rc = -1;
@@ -618,7 +618,7 @@
if(l_rc == 0)
{
/* set pid data when navigator is running */
- l_navid_pid = getpid();
+ l_navid_pid = gap_base_getpid();
gimp_set_data(PLUGIN_NAME, &l_navid_pid, sizeof(pid_t));
if (strcmp (name, PLUGIN_NAME) == 0)
{
@@ -1237,7 +1237,7 @@
* (this table is updated automatically by gap_goto and other gap procedures
* to inform the navigator dialog about changes of the active image_id)
*/
- l_pid = getpid();
+ l_pid = gap_base_getpid();
l_new_image_id = gap_navat_get_active_image(image_id, l_pid);
if(l_new_image_id >= 0)
{
@@ -1455,7 +1455,7 @@
{
if(naviD == NULL) { return; }
- naviD->tooltip_on = gap_lib_check_tooltips(&naviD->tooltip_on);
+ naviD->tooltip_on = gap_base_check_tooltips(&naviD->tooltip_on);
} /* end navi_dialog_tooltips */
Modified: trunk/gap/gap_onion_base.c
==============================================================================
--- trunk/gap/gap_onion_base.c (original)
+++ trunk/gap/gap_onion_base.c Mon Mar 9 17:56:04 2009
@@ -43,6 +43,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include <gap_match.h>
#include <gap_lib.h>
#include <gap_layer_copy.h>
@@ -69,7 +70,7 @@
if(gap_debug) printf("gap_onion_base_mark_as_onionlayer: START\n");
l_parasite_data = g_malloc(sizeof(GapOnionBaseParasite_data));
- l_parasite_data->timestamp = time(0);
+ l_parasite_data->timestamp = gap_base_get_current_time();
l_parasite_data->tattoo = gimp_drawable_get_tattoo(layer_id);
if(gap_debug) printf("gap_onion_base_mark_as_onionlayer: tattoo is: %d\n", (int)l_parasite_data->tattoo);
Modified: trunk/gap/gap_player_cache.c
==============================================================================
--- trunk/gap/gap_player_cache.c (original)
+++ trunk/gap/gap_player_cache.c Mon Mar 9 17:56:04 2009
@@ -95,9 +95,9 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include "gap_player_main.h"
#include "gap_player_dialog.h"
-#include "gap_file_util.h"
#include "gap-intl.h"
@@ -131,7 +131,6 @@
static GapPlayerCacheAdmin* p_get_admin_ptr(void);
static void p_debug_printf_cache_list(GapPlayerCacheAdmin *admin_ptr);
static void p_debug_printf_cdata(GapPlayerCacheData *cdata);
-static gint32 p_get_mtime(const gchar *filename);
static void p_player_cache_shrink(GapPlayerCacheAdmin *admin_ptr, gint32 new_bytesize);
static void p_player_cache_remove_oldest_frame(GapPlayerCacheAdmin *admin_ptr);
@@ -425,25 +424,6 @@
/* ------------------------------
- * p_get_mtime
- * ------------------------------
- */
-static gint32
-p_get_mtime(const gchar *filename)
-{
- struct stat l_stat;
-
- if (0 == g_stat(filename, &l_stat))
- {
- return(l_stat.st_mtime);
- }
-
- return (0);
-
-} /* end p_get_mtime */
-
-
-/* ------------------------------
* p_get_elem_size
* ------------------------------
*/
@@ -952,7 +932,7 @@
abs_filename = gap_file_build_absolute_filename(filename);
ckey = g_strdup_printf("[ MOVIE]:%d:%s:%06d:%d:%1.3f"
- , (int)p_get_mtime(filename)
+ , (int)gap_file_get_mtime(filename)
, abs_filename
, (int)framenr
, (int)seltrack
@@ -976,7 +956,7 @@
abs_filename = gap_file_build_absolute_filename(filename);
ckey = g_strdup_printf("[ IMAGE]:%d:%s"
- , (int)p_get_mtime(filename)
+ , (int)gap_file_get_mtime(filename)
, abs_filename
);
g_free(abs_filename);
Modified: trunk/gap/gap_player_dialog.c
==============================================================================
--- trunk/gap/gap_player_dialog.c (original)
+++ trunk/gap/gap_player_dialog.c Mon Mar 9 17:56:04 2009
@@ -93,6 +93,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include "gap_player_main.h"
#include "gap_player_dialog.h"
#include "gap_pdb_calls.h"
@@ -110,7 +111,6 @@
#include "gap_onion_base.h"
#include "gap_audio_extract.h"
#include "gap_audio_extract.h"
-#include "gap_file_util.h"
#include "gap_drawable_vref_parasite.h"
#include "gap-intl.h"
@@ -387,7 +387,7 @@
static void
p_check_tooltips(void)
{
- gap_lib_check_tooltips(NULL);
+ gap_base_check_tooltips(NULL);
} /* end p_check_tooltips */
@@ -942,12 +942,10 @@
return(FALSE);
}
-#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
- if (GVA_file_get_mtime(l_audiofilename) < GVA_file_get_mtime(videofilename))
+ if (gap_file_get_mtime(l_audiofilename) < gap_file_get_mtime(videofilename))
{
return(FALSE);
}
-#endif
return (TRUE);
@@ -2131,7 +2129,7 @@
l_prefix = g_strdup(_("STB:"));
}
/* shortname prefix to indicate that displayed filename is from type storyboard file */
- frame_title = gap_lib_shorten_filename(l_prefix /* prefix short for storyboard */
+ frame_title = gap_base_shorten_filename(l_prefix /* prefix short for storyboard */
,gpp->stb_ptr->storyboardfile /* filenamepart */
,NULL /* suffix */
,MAX_CHARS
@@ -2145,7 +2143,7 @@
if(gpp->ainfo_ptr->ainfo_type == GAP_AINFO_MOVIE)
{
/* shortname prefix to indicate that displayed filename is a single videofile */
- frame_title = gap_lib_shorten_filename(_("VIDEO:") /* prefix short for storyboard */
+ frame_title = gap_base_shorten_filename(_("VIDEO:") /* prefix short for storyboard */
,gpp->ainfo_ptr->basename /* filenamepart */
,NULL /* suffix */
,MAX_CHARS
@@ -2157,7 +2155,7 @@
if(frame_title == NULL)
{
/* shortname prefix to indicate that displayed filename is basename of the frames */
- frame_title = gap_lib_shorten_filename(_("FRAMES:") /* prefix short for storyboard */
+ frame_title = gap_base_shorten_filename(_("FRAMES:") /* prefix short for storyboard */
,gpp->ainfo_ptr->basename /* filenamepart */
,NULL /* suffix */
,MAX_CHARS
Modified: trunk/gap/gap_split.c
==============================================================================
--- trunk/gap/gap_split.c (original)
+++ trunk/gap/gap_split.c Mon Mar 9 17:56:04 2009
@@ -60,6 +60,7 @@
#include "libgimp/gimp.h"
/* GAP includes */
+#include "gap_libgapbase.h"
#include "gap_layer_copy.h"
#include "gap_lib.h"
#include "gap_arr_dialog.h"
@@ -306,7 +307,7 @@
/* build the name for output image */
- l_str = gap_lib_dup_filename_and_replace_extension_by_underscore(ainfo_ptr->old_filename);
+ l_str = gap_base_dup_filename_and_replace_extension_by_underscore(ainfo_ptr->old_filename);
l_sav_name = gap_lib_alloc_fname6(l_str,
l_framenumber, /* start at 1 (not at 0) */
valPtr->extension,
@@ -432,7 +433,7 @@
}
}
- baseName = gap_lib_dup_filename_and_replace_extension_by_underscore(ainfo_ptr->old_filename);
+ baseName = gap_base_dup_filename_and_replace_extension_by_underscore(ainfo_ptr->old_filename);
buf = g_strdup_printf (_("Make a frame (diskfile) from each layer.\n"
"Frames are named in the style:\n"
Modified: trunk/gap/gap_story_dialog.c
==============================================================================
--- trunk/gap/gap_story_dialog.c (original)
+++ trunk/gap/gap_story_dialog.c Mon Mar 9 17:56:04 2009
@@ -47,6 +47,7 @@
#include <libgimp/gimpui.h>
#include <gdk/gdkkeysyms.h>
+#include "gap_libgapbase.h"
#include "gap_story_main.h"
#include "gap_story_undo.h"
#include "gap_story_dialog.h"
@@ -64,7 +65,6 @@
#include "gap_story_att_trans_dlg.h"
#include "gap_story_vthumb.h"
#include "gap_story_section_properties.h"
-#include "gap_file_util.h"
#include "gap_frame_fetcher.h"
#include "images/gap-stock-pixbufs.h"
@@ -394,10 +394,6 @@
);
GtkWidget * p_gtk_button_new_from_stock_icon(const char *stock_id);
-static gint32 p_get_gimprc_int_value (const char *gimprc_option_name
- , gint32 default_value, gint32 min_value, gint32 max_value);
-static gboolean p_get_gimprc_gboolean_value (const char *gimprc_option_name
- , gboolean default_value);
static gint32 p_get_gimprc_preview_size(const char *gimprc_option_name);
static void p_save_gimprc_preview_size(const char *gimprc_option_name, gint32 preview_size);
@@ -4843,7 +4839,7 @@
p_undo_redo_sensibility(sgpp);
- gap_lib_check_tooltips(NULL);
+ gap_base_check_tooltips(NULL);
} /* end p_widget_sensibility */
@@ -6334,7 +6330,7 @@
}
}
}
- l_txt = gap_lib_shorten_filename(l_hdr_txt /* prefix */
+ l_txt = gap_base_shorten_filename(l_hdr_txt /* prefix */
,l_fil_txt /* filenamepart */
,l_mod_txt /* suffix */
,l_max_chars
@@ -7537,7 +7533,7 @@
index_of_active_item = index;
}
- l_txt = gap_lib_shorten_filename(NULL /* prefix */
+ l_txt = gap_base_shorten_filename(NULL /* prefix */
,section->section_name /* filenamepart */
,NULL /* suffix */
,12 /* max_chars */
@@ -7906,57 +7902,6 @@
-/* -----------------------------------------
- * p_get_gimprc_int_value
- * -----------------------------------------
- */
-static gint32
-p_get_gimprc_int_value (const char *gimprc_option_name
- , gint32 default_value, gint32 min_value, gint32 max_value)
-{
- char *value_string;
- gint32 value;
-
- value = default_value;
-
- value_string = gimp_gimprc_query(gimprc_option_name);
- if(value_string)
- {
- value = atol(value_string);
- g_free(value_string);
- }
- return (CLAMP(value, min_value, max_value));
-
-} /* end p_get_gimprc_int_value */
-
-
-/* -----------------------------------------
- * p_get_gimprc_gboolean_value
- * -----------------------------------------
- */
-static gboolean
-p_get_gimprc_gboolean_value (const char *gimprc_option_name
- , gboolean default_value)
-{
- char *value_string;
- gboolean value;
-
- value = default_value;
-
- value_string = gimp_gimprc_query(gimprc_option_name);
- if(value_string)
- {
- value = FALSE;
- if((*value_string == 'y') || (*value_string == 'Y'))
- {
- value = FALSE;
- }
- g_free(value_string);
- }
- return (value);
-
-} /* end p_get_gimprc_gboolean_value */
-
/* ---------------------------------
* p_get_gimprc_preview_size
* ---------------------------------
@@ -8101,30 +8046,30 @@
p_get_gimprc_layout_settings(GapStbMainGlobalParams *sgpp)
{
sgpp->cll_thumbsize = p_get_gimprc_preview_size("video-cliplist-thumbnail_size");
- sgpp->cll_cols = p_get_gimprc_int_value("video-cliplist-columns"
+ sgpp->cll_cols = gap_base_get_gimprc_int_value("video-cliplist-columns"
, sgpp->cll_cols
, CLL_MIN_COL
, CLL_MAX_COL
);
- sgpp->cll_rows = p_get_gimprc_int_value("video-cliplist-rows"
+ sgpp->cll_rows = gap_base_get_gimprc_int_value("video-cliplist-rows"
, sgpp->cll_rows
, CLL_MIN_ROW
, CLL_MAX_ROW
);
sgpp->stb_thumbsize = p_get_gimprc_preview_size("video-storyboard-thumbnail_size");
- sgpp->stb_cols = p_get_gimprc_int_value("video-storyboard-columns"
+ sgpp->stb_cols = gap_base_get_gimprc_int_value("video-storyboard-columns"
, sgpp->stb_cols
, STB_MIN_COL
, STB_MAX_COL
);
- sgpp->stb_rows = p_get_gimprc_int_value("video-storyboard-rows"
+ sgpp->stb_rows = gap_base_get_gimprc_int_value("video-storyboard-rows"
, sgpp->stb_rows
, STB_MIN_ROW
, STB_MAX_ROW
);
- sgpp->force_stb_aspect = p_get_gimprc_gboolean_value("video-storyboard-force-aspect-playback"
+ sgpp->force_stb_aspect = gap_base_get_gimprc_gboolean_value("video-storyboard-force-aspect-playback"
, sgpp->force_stb_aspect
);
Modified: trunk/gap/gap_story_file.c
==============================================================================
--- trunk/gap/gap_story_file.c (original)
+++ trunk/gap/gap_story_file.c Mon Mar 9 17:56:04 2009
@@ -41,12 +41,12 @@
#include <libgimp/gimp.h>
+#include "gap_libgapbase.h"
#include "gap_story_syntax.h"
#include "gap_story_main.h"
#include "gap_story_file.h"
#include "gap_lib.h"
#include "gap_val_file.h"
-#include "gap_file_util.h"
#include "gap-intl.h"
Modified: trunk/gap/gap_story_properties.c
==============================================================================
--- trunk/gap/gap_story_properties.c (original)
+++ trunk/gap/gap_story_properties.c Mon Mar 9 17:56:04 2009
@@ -39,6 +39,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include "gap_story_main.h"
#include "gap_story_undo.h"
#include "gap_story_dialog.h"
@@ -2089,7 +2090,7 @@
}
}
- l_txt = gap_lib_shorten_filename(NULL /* prefix */
+ l_txt = gap_base_shorten_filename(NULL /* prefix */
,stb_elem->mask_name /* filenamepart */
,NULL /* suffix */
,32 /* max_chars */
@@ -2112,7 +2113,7 @@
* indicate invalid name by prefix "# " and add it as last entry to the combo box
*/
index_of_active_item = index;
- l_txt = gap_lib_shorten_filename("# " /* prefix */
+ l_txt = gap_base_shorten_filename("# " /* prefix */
,curr_mask_name /* filenamepart */
,NULL /* suffix */
,32 /* max_chars */
@@ -3344,7 +3345,7 @@
sensitive = TRUE;
if(pw->stb_elem_refptr->fmac_total_steps > 1)
{
- lbl_text = gap_lib_shorten_filename(_("Filtermacro2: ") /* prefix */
+ lbl_text = gap_base_shorten_filename(_("Filtermacro2: ") /* prefix */
,alt_fmac_name /* filenamepart */
,_(" (ON)") /* suffix */
,90 /* max_chars */
@@ -3352,7 +3353,7 @@
}
else
{
- lbl_text = gap_lib_shorten_filename(_("Filtermacro2: ") /* prefix */
+ lbl_text = gap_base_shorten_filename(_("Filtermacro2: ") /* prefix */
,alt_fmac_name /* filenamepart */
,_(" (OFF)") /* suffix */
,90 /* max_chars */
Modified: trunk/gap/gap_story_render_audio.c
==============================================================================
--- trunk/gap/gap_story_render_audio.c (original)
+++ trunk/gap/gap_story_render_audio.c Mon Mar 9 17:56:04 2009
@@ -32,8 +32,8 @@
#include "libgimp/gimp.h"
+#include "gap_libgapbase.h"
#include "gap_libgimpgap.h"
-#include "gap_file_util.h"
#include "gap_audio_util.h"
#include "gap_audio_wav.h"
#include "gap_story_sox.h"
Modified: trunk/gap/gap_story_render_processor.c
==============================================================================
--- trunk/gap/gap_story_render_processor.c (original)
+++ trunk/gap/gap_story_render_processor.c Mon Mar 9 17:56:04 2009
@@ -67,9 +67,9 @@
#include "libgimp/gimp.h"
+#include "gap_libgapbase.h"
#include "gap_libgimpgap.h"
#include "gap_lib_common_defs.h"
-#include "gap_file_util.h"
#include "gap_audio_util.h"
#include "gap_audio_wav.h"
#include "gap_story_file.h"
@@ -335,6 +335,13 @@
static gint32 p_create_unicolor_image(gint32 *layer_id, gint32 width , gint32 height
, gdouble r_f, gdouble g_f, gdouble b_f, gdouble a_f);
static gint32 p_prepare_RGB_image(gint32 image_id);
+
+static void p_limit_open_videohandles(GapStoryRenderVidHandle *vidhand
+ , gint32 master_frame_nr
+ , gint32 currently_open_videohandles
+ );
+
+
static t_GVA_Handle * p_try_to_steal_gvahand(GapStoryRenderVidHandle *vidhand
, gint32 master_frame_nr
, char *basename /* the videofile name */
@@ -4284,13 +4291,16 @@
if ((gimp_image_width(tmp_image_id) != calculated->width)
|| (gimp_image_height(tmp_image_id) != calculated->height) )
{
- if(gap_debug) printf("DEBUG: p_transform_and_add_layer scaling layer from %dx%d to %dx%d\n"
+ if(gap_debug)
+ {
+ printf("DEBUG: p_transform_and_add_layer scaling layer from %dx%d to %dx%d\n"
, (int)gimp_image_width(tmp_image_id)
, (int)gimp_image_height(tmp_image_id)
, (int)calculated->width
, (int)calculated->height
);
+ }
gimp_layer_scale(layer_id, calculated->width, calculated->height
, FALSE /* FALSE: centered at image TRUE: centered local on layer */
);
@@ -4453,6 +4463,76 @@
} /* end p_prepare_RGB_image */
/* ----------------------------------------------------
+ * p_limit_open_videohandles
+ * ----------------------------------------------------
+ * if the number of currently_open_videohandles exceeds a limit,
+ * then try to close the handle(s) until the number is below the limit.
+ * (but do not close handles that are involved in fetching the current master_frame_nr)
+ *
+ * This kind of garbage collection is useful for storyboards that are using many
+ * different videofile references and would run into memory and other resource problems
+ * when all handles are kept open until the end of rendering process.
+ * (note that each video handle has its own frame cache)
+ */
+static void
+p_limit_open_videohandles(GapStoryRenderVidHandle *vidhand
+ , gint32 master_frame_nr
+ , gint32 currently_open_videohandles
+ )
+{
+#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
+#define GAP_STB_DEFAULT_MAX_OPEN_VIDEOFILES 12
+ GapStoryRenderFrameRangeElem *frn_elem;
+ gint32 l_count_open_videohandles;
+ gint32 l_max_open_videohandles;
+
+
+ l_max_open_videohandles = gap_base_get_gimprc_int_value("video-storyboard-max-open-videofiles"
+ , GAP_STB_DEFAULT_MAX_OPEN_VIDEOFILES
+ , 2
+ , 100
+ );
+ l_count_open_videohandles = currently_open_videohandles;
+
+ if (l_count_open_videohandles <= l_max_open_videohandles)
+ {
+ /* we are below the limit, nothing left to do in that case */
+ return;
+ }
+
+ for (frn_elem = vidhand->frn_list; frn_elem != NULL; frn_elem = (GapStoryRenderFrameRangeElem *)frn_elem->next)
+ {
+ if((frn_elem->last_master_frame_access < master_frame_nr)
+ && (frn_elem->gvahand != NULL))
+ {
+ if(gap_debug)
+ {
+ printf("too many open videofiles %d detected (limit:%d) at master_frame_nr:%d\n"
+ " CLOSING GVA handle for video read access %s\n"
+ , (int)l_count_open_videohandles
+ , (int)l_max_open_videohandles
+ , (int)master_frame_nr
+ , frn_elem->basename
+ );
+ }
+ GVA_close(frn_elem->gvahand);
+ frn_elem->gvahand = NULL;
+ l_count_open_videohandles--;
+
+ if (l_count_open_videohandles <= l_max_open_videohandles)
+ {
+ return;
+ }
+
+ }
+ }
+#endif
+ return;
+
+} /* end p_limit_open_videohandles */
+
+
+/* ----------------------------------------------------
* p_try_to_steal_gvahand
* ----------------------------------------------------
* try to steal an alread open GVA handle for video read from another
@@ -4469,25 +4549,38 @@
, gint32 exact_seek
)
{
- GapStoryRenderFrameRangeElem *frn_elem;
- t_GVA_Handle *gvahand;
#ifdef GAP_ENABLE_VIDEOAPI_SUPPORT
+ GapStoryRenderFrameRangeElem *frn_elem;
+ gint32 l_count_open_videohandles;
+ l_count_open_videohandles = 0;
for (frn_elem = vidhand->frn_list; frn_elem != NULL; frn_elem = (GapStoryRenderFrameRangeElem *)frn_elem->next)
{
+ if (frn_elem->gvahand != NULL)
+ {
+ l_count_open_videohandles++;
+ }
if((frn_elem->exact_seek == exact_seek)
&& (frn_elem->last_master_frame_access < master_frame_nr)
&& (frn_elem->gvahand != NULL))
{
if(strcmp(frn_elem->basename, basename) == 0)
{
- if(gap_debug) printf("(RE)using an already open GVA handle for video read access %s\n", frn_elem->basename);
+ t_GVA_Handle *gvahand;
+
+ if(gap_debug)
+ {
+ printf("(RE)using an already open GVA handle for video read access %s\n"
+ , frn_elem->basename
+ );
+ }
gvahand = frn_elem->gvahand;
frn_elem->gvahand = NULL; /* steal from this element */
return(gvahand);
}
}
}
+ p_limit_open_videohandles(vidhand, master_frame_nr, l_count_open_videohandles);
#endif
return(NULL); /* nothing found to steal from, return NULL */
@@ -5580,6 +5673,12 @@
}
if(gfd->tmp_image_id < 0)
{
+ printf("\n** ERROR fetching master_frame_nr:%d, from framename:%s Current CLIP was:\n"
+ , (int)master_frame_nr
+ , (int)gfd->framename
+ );
+ gap_story_render_debug_print_frame_elem(gfd->frn_elem, -1);
+ printf("\n** storyboard render processing failed\n");
g_free(gfd->framename);
return -1;
}
@@ -5595,7 +5694,13 @@
}
- if(gap_debug) printf("p_prepare_RGB_image returned layer_id: %d, tmp_image_id:%d\n", (int)gfd->layer_id, (int)gfd->tmp_image_id);
+ if(gap_debug)
+ {
+ printf("p_prepare_RGB_image returned layer_id: %d, tmp_image_id:%d\n"
+ , (int)gfd->layer_id
+ , (int)gfd->tmp_image_id
+ );
+ }
if(gfd->comp_image_id < 0)
{
Modified: trunk/gap/gap_story_vthumb.c
==============================================================================
--- trunk/gap/gap_story_vthumb.c (original)
+++ trunk/gap/gap_story_vthumb.c Mon Mar 9 17:56:04 2009
@@ -45,11 +45,11 @@
#include <libgimp/gimpui.h>
#include <gdk/gdkkeysyms.h>
+#include "gap_libgapbase.h"
#include "gap_story_main.h"
#include "gap_story_dialog.h"
#include "gap_story_file.h"
#include "gap_arr_dialog.h"
-#include "gap_file_util.h"
#include "gap_story_render_processor.h"
#include "gap_story_vthumb.h"
Modified: trunk/gap/gap_video_index_creator.c
==============================================================================
--- trunk/gap/gap_video_index_creator.c (original)
+++ trunk/gap/gap_video_index_creator.c Mon Mar 9 17:56:04 2009
@@ -37,6 +37,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include "gap_arr_dialog.h"
#include "gap_story_file.h"
#include "gap_story_syntax.h"
@@ -411,6 +412,27 @@
/* --------------------------------
+ * p_is_valid_vindex_available
+ * --------------------------------
+ */
+static gboolean
+p_is_valid_vindex_available(t_GVA_Handle *gvahand)
+{
+ gboolean l_have_valid_vindex;
+
+ l_have_valid_vindex = FALSE;
+ if(gvahand->vindex)
+ {
+ if(gvahand->vindex->total_frames > 0)
+ {
+ l_have_valid_vindex = TRUE;
+ }
+ }
+
+ return (l_have_valid_vindex);
+}
+
+/* --------------------------------
* p_create_video_index
* --------------------------------
* check if specified filename is a videofile and if there is
@@ -493,13 +515,7 @@
}
}
- if(gvahand->vindex)
- {
- if(gvahand->vindex->total_frames > 0)
- {
- l_have_valid_vindex = TRUE;
- }
- }
+ l_have_valid_vindex = p_is_valid_vindex_available(gvahand);
if (vindex_file == NULL)
{
@@ -528,21 +544,38 @@
}
gvahand->create_vindex = TRUE;
- GVA_count_frames(gvahand);
+ GVA_count_frames(gvahand); /* here we CRREATE the vindex */
if ((vipp->cancel_video_api != TRUE)
- && (gvahand->vindex))
+ && (TRUE == p_is_valid_vindex_available(gvahand)))
{
p_set_vref_userdata(vipp->vref, _("vindex created (FULLSCAN OK)"));
}
else
{
char *usrdata;
-
- usrdata = g_strdup_printf(_("NO vindex created (SMART %.1f%% %d frames)")
- ,(float)vipp->breakPercentage
- ,(int)vipp->breakFrames
- );
+ if (vipp->val_ptr->mode == SMART_MODE)
+ {
+ if(g_file_test(vindex_file, G_FILE_TEST_EXISTS))
+ {
+ if(gap_debug)
+ {
+ printf("DELETE uncomplete vindex:%s\n", vindex_file);
+ }
+ g_remove(vindex_file);
+ }
+
+ usrdata = g_strdup_printf(_("NO vindex created (SMART %.1f%% %d frames)")
+ ,(float)vipp->breakPercentage
+ ,(int)vipp->breakFrames
+ );
+ }
+ else
+ {
+ usrdata = g_strdup_printf(_("incomplete vindex created (%d frames)")
+ ,(int)gvahand->frame_counter
+ );
+ }
p_set_vref_userdata(vipp->vref, usrdata);
g_free(usrdata);
}
@@ -813,7 +846,7 @@
,(int)vipp->numberOfVideos
);
- message = gap_lib_shorten_filename(NULL /* prefix */
+ message = gap_base_shorten_filename(NULL /* prefix */
,vref->videofile /* filenamepart */
,suffix /* suffix */
,90 /* l_max_chars */
@@ -1113,7 +1146,7 @@
gchar *processing_status;
label = g_strdup_printf("%3d.", (int)count_elem +1);
- video_filename = gap_lib_shorten_filename(NULL /* prefix */
+ video_filename = gap_base_shorten_filename(NULL /* prefix */
,vref->videofile /* filenamepart */
,NULL /* suffix */
,90 /* l_max_chars */
@@ -1193,7 +1226,7 @@
label = g_strdup_printf("%3d.", (int)count_elem +1);
numtxt = g_strdup_printf("%d", (int)count_elem);
- video_filename = gap_lib_shorten_filename(NULL /* prefix */
+ video_filename = gap_base_shorten_filename(NULL /* prefix */
,vref->videofile /* filenamepart */
,NULL /* suffix */
,90 /* l_max_chars */
Modified: trunk/gap/gap_wr_color_curve.c
==============================================================================
--- trunk/gap/gap_wr_color_curve.c (original)
+++ trunk/gap/gap_wr_color_curve.c Mon Mar 9 17:56:04 2009
@@ -59,8 +59,8 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "gap_libgapbase.h"
#include "gap_stock.h"
-#include "gap_file_util.h"
#include "gap-intl.h"
Modified: trunk/gap/gimplastvaldesc.c
==============================================================================
--- trunk/gap/gimplastvaldesc.c (original)
+++ trunk/gap/gimplastvaldesc.c Mon Mar 9 17:56:04 2009
@@ -58,7 +58,7 @@
*/
#include "gimplastvaldesc.h"
#endif
-
+#include "gap_libgapbase.h"
typedef struct GimpLastvalTokenTabType
{
@@ -285,7 +285,7 @@
return;
}
}
- l_timestamp = time(0);
+ l_timestamp = gap_base_get_current_time();
gimp_set_data(TIMESTAMP_DESCFILE_CHECKED, &l_timestamp, sizeof(l_timestamp));
p_init_token_table();
Modified: trunk/libgapvidapi/gap_vid_api.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api.c (original)
+++ trunk/libgapvidapi/gap_vid_api.c Mon Mar 9 17:56:04 2009
@@ -1585,7 +1585,7 @@
}
codec_name = p_gva_worker_get_codec_name(gvahand, codec_type, track_nr);
- //if(gap_debug)
+ if(gap_debug)
{
printf("GVA_get_codec_name: END codec_name:");
if (codec_name)
Modified: trunk/libgapvidapi/gap_vid_api.h
==============================================================================
--- trunk/libgapvidapi/gap_vid_api.h (original)
+++ trunk/libgapvidapi/gap_vid_api.h Mon Mar 9 17:56:04 2009
@@ -483,7 +483,6 @@
,gint32 *hdr_size
);
void GVA_md5_string(char *name, const char *uri);
-gint32 GVA_file_get_mtime(const char *filename);
gchar* GVA_filename_to_uri(const char *filename);
#endif
Modified: trunk/libgapvidapi/gap_vid_api_ffmpeg.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api_ffmpeg.c (original)
+++ trunk/libgapvidapi/gap_vid_api_ffmpeg.c Mon Mar 9 17:56:04 2009
@@ -49,7 +49,7 @@
/* MAX_PREV_OFFSET defines how to record defered url_offest frames of previous frames for byte positions in video index
* in tests the byte based seek takes us to n frames after the wanted frame. Therefore video index creation
- * tries to comensate this by recording the offsets of the nth pervious frame.
+ * tries to compensate this by recording the offsets of the nth pervious frame.
*
* tuning: values 1 upto 12 did not compensate enough.
* this resulted in more than 1 SYNC LOOP when positioning vio byte position and makes video index slower.
@@ -202,11 +202,6 @@
static guint16 p_gva_checksum(AVPicture *picture_yuv, gint32 height);
static t_GVA_RetCode p_wrapper_ffmpeg_get_next_frame(t_GVA_Handle *gvahand);
-static gint32 p_get_gimprc_int_value (const char *gimprc_option_name
- , gint32 default_value, gint32 min_value, gint32 max_value);
-static gboolean p_get_gimprc_gboolean_value (const char *gimprc_option_name
- , gboolean default_value);
-
static FILE * p_init_timecode_log(t_GVA_Handle *copy_gvahand);
static void p_timecode_check_and_log(FILE *fp_timecode_log, gint32 framenr
, t_GVA_ffmpeg *handle
@@ -1011,7 +1006,8 @@
/* --------- START potential CHUNK ----- */
/* make a copy of the raw data packages for one video frame.
* (we do not yet know if the raw data chunk is complete until
- * avcodec_decode_video the frame may
+ * avcodec_decode_video indicates a complete frame by setting the
+ * got_picture flag to TRUE)
*/
if (do_copy_raw_chunk_data == TRUE)
{
@@ -1322,7 +1318,7 @@
* (prefere_native_seek yes)
* if this flag is set to yes we use native seek and ignore the valid videoindex.
*/
- if(p_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
+ if(gap_base_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
{
p_get_video_analyse_results(gvahand);
}
@@ -1350,7 +1346,7 @@
handle->self_test_detected_seek_bug = FALSE;
handle->eof_timecode = AV_NOPTS_VALUE;
handle->video_libavformat_seek_gopsize
- = p_get_gimprc_int_value("video-libavformat-seek-gopsize", DEFAULT_NAT_SEEK_GOPSIZE, 0, MAX_NAT_SEEK_GOPSIZE);
+ = gap_base_get_gimprc_int_value("video-libavformat-seek-gopsize", DEFAULT_NAT_SEEK_GOPSIZE, 0, MAX_NAT_SEEK_GOPSIZE);
} /* end p_reset_proberead_results */
@@ -1388,7 +1384,7 @@
persitent_analyse_available = FALSE;
- if(p_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
+ if(gap_base_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
{
persitent_analyse_available =
p_get_video_analyse_results(gvahand);
@@ -1514,7 +1510,7 @@
printf("\n\n\n\n\n");
}
- if(p_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
+ if(gap_base_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
{
p_save_video_analyse_results(gvahand);
persitent_analyse_available = TRUE;
@@ -1656,6 +1652,15 @@
if(totalDetected >= totalPlausible)
{
+ l_rc = p_seek_native_timcode_based(gvahand, totalDetected);
+ if (l_rc == GVA_RET_OK)
+ {
+ l_rc = p_wrapper_ffmpeg_get_next_frame(gvahand);
+ }
+ if (l_rc != GVA_RET_OK)
+ {
+ totalDetected--;
+ }
gvahand->total_frames = totalDetected;
gvahand->all_frames_counted = TRUE;
}
@@ -1748,20 +1753,64 @@
* a videoindex has stored offsets of the keyframes
* that were optional created by the count_frames procedure.
* The videoindex based seek modifies the libavformat internal straem seek position
- * by an explicte call of url_fseek.
+ * by an explicte call seek call (either to byte position or to timecode target)
* The index also has information about the (compressed) frame length and a checksum.
- * In the Sync Loop(s) we try to find exactly the frame that is described in the index.
+ * In the inner Sync Loop(s) we try to find exactly the frame that is described in the index.
+ * The outer Loop (l_nloops) repeats the sync loop attempt by using a lower seek offset
+ * from the previous video index entry and uses more read operations (l_synctries)
+ * trying to find the target frame. (This is necessary because byte oriented
+ * seek operations do not work exact and may position the video stream
+ * AFTER the target frame.
+ *
* The postioning to last Group of pictures is done
- * by sequential read. (it should contain at least one keyframe (I-frame)
+ * by sequential read (l_readsteps). it should contain at least one keyframe (I-frame)
* that enables clean decoding of the following P and B frames
*
+ * video index table inner (synctries) and outer loop
+ *
+ * |-------------------------------------------|
+ * | [10] seek_nr:000100 offset: len16: DTS: |
+ * |-------------------------------------------|
+ *
+ *
+ * (only in case 1st attempt failed
+ * to seek the video stream
+ * to exact target position)
+ * |-------------------------------------------| l_nloops = 2
+ * | [11] seek_nr:000110 offset: len16: DTS: | | 1 l_synctries
+ * |-------------------------------------------| | 2
+ * | 3
+ * | 4
+ * | 5
+ * | 6
+ * | 7
+ * | 8
+ * | 9
+ * |-------------------------------------------| l_nloops = 1 | 10
+ * l_idx_target ------> | [12] seek_nr:000120 offset: len16: DTS: | | 1 l_synctries | 11
+ * |-------------------------------------------| | 2 | 12
+ * | 3 | 13
+ * | 4 | 14
+ * | 5 | 15
+ * | 6 | 16
+ * | 7 | 17
+ * | 8 | 18
+ * |-------------------------------------------| | 9 | 19
+ * l_idx_too_far -----> | [13] seek_nr:000130 offset: len16: DTS: | V 10 V 20
+ * |-------------------------------------------|
+ *
+ *
* - the fallback method emulates
* seek by pos-1 sequential read ops.
* seek backwards must always reopen to reset stream position to start.
* this is very slow, creating a videoindex is recommanded for GUI-based applications
- *
+ *
+ * seek operation to the start (the first few frames) always use sequential read
+ *
+ *
*/
#define GVA_IDX_SYNC_STEPSIZE 1
+#define GVA_FRAME_NEAR_START 24
static t_GVA_RetCode
p_seek_private(t_GVA_Handle *gvahand, gdouble pos, t_GVA_PosUnit pos_unit)
{
@@ -1770,7 +1819,9 @@
gint32 l_frame_pos;
gint32 l_url_frame_pos;
gint32 l_readsteps;
+ gint32 l_summary_read_ops;
gdouble l_progress_step;
+ gboolean l_vindex_is_usable;
t_GVA_Videoindex *vindex;
handle = (t_GVA_ffmpeg *)gvahand->decoder_handle;
@@ -1807,53 +1858,96 @@
if(gap_debug)
{
- printf("p_wrapper_ffmpeg_seek_frame: start: l_frame_pos: %d cur_seek:%d cur_frame:%d (prefere_native:%d gopsize:%d)\n"
+ printf("p_wrapper_ffmpeg_seek_frame: start: l_frame_pos: %d cur_seek:%d cur_frame:%d (prefere_native:%d gopsize:%d) video:%s\n"
, (int)l_frame_pos
, (int)gvahand->current_seek_nr
, (int)gvahand->current_frame_nr
, (int)handle->prefere_native_seek
, (int)handle->video_libavformat_seek_gopsize
+ , gvahand->filename
);
}
handle->dummy_read = TRUE;
l_url_frame_pos = 0;
+ l_vindex_is_usable = FALSE;
+ l_summary_read_ops = 0;
-
- /* check if we have a video index, if not try native timecode based seek
- */
- if((vindex == NULL) || (handle->prefere_native_seek))
+ if(l_frame_pos > GVA_FRAME_NEAR_START)
{
- /* try native av_seek_frame if enabled by gimprc configuration
- * (native seek is disabled if video_libavformat_seek_gopsize == 0)
+ /* check if we have a usable video index */
+ if(vindex != NULL)
+ {
+ if(vindex->tabsize_used > 0)
+ {
+ gint32 l_max_seek; /* seek to frames above this numer via video index will be slow */
+
+ l_max_seek = vindex->ofs_tab[vindex->tabsize_used-1].seek_nr + (2 * vindex->stepsize);
+ if(l_frame_pos <= l_max_seek)
+ {
+ l_vindex_is_usable = TRUE;
+ if(gap_debug)
+ {
+ printf("VINDEX flag l_vindex_is_usable is TRUE l_max_seek:%d (vindex->tabsize_used:%d)\n"
+ , (int)l_max_seek
+ , (int)vindex->tabsize_used
+ );
+ }
+ }
+ else
+ {
+ if(gap_debug)
+ {
+ p_debug_print_videoindex(vindex);
+ }
+ printf("WARNING VINDEX flag l_vindex_is_usable is FALSE, the video Index is NOT COMPLETE ! for video:%s\n"
+ " l_frame_pos:%d l_max_seek:%d (vindex->tabsize_used:%d) total_frames:%d\n"
+ , gvahand->filename
+ , (int)l_frame_pos
+ , (int)l_max_seek
+ , (int)vindex->tabsize_used
+ , (int)gvahand->total_frames
+ );
+ }
+ }
+ }
+
+
+ /* check conditions and try native timecode based seek if conditions permit native seek.
*/
- if (handle->video_libavformat_seek_gopsize > 0)
+ if((l_vindex_is_usable != TRUE) || (handle->prefere_native_seek))
{
- l_rc_rd = p_seek_native_timcode_based(gvahand, l_frame_pos);
- if(l_rc_rd == GVA_RET_OK)
+ /* try native av_seek_frame if enabled by gimprc configuration
+ * (native seek is disabled if video_libavformat_seek_gopsize == 0)
+ */
+ if (handle->video_libavformat_seek_gopsize > 0)
{
- if(gap_debug)
+ l_rc_rd = p_seek_native_timcode_based(gvahand, l_frame_pos);
+ if(l_rc_rd == GVA_RET_OK)
{
- printf("NATIVE SEEK performed for videofile:%s\n"
- , gvahand->filename
- );
+ if(gap_debug)
+ {
+ printf("NATIVE SEEK performed for videofile:%s\n"
+ , gvahand->filename
+ );
+ }
+ return (l_rc_rd);
}
- return (l_rc_rd);
- }
- }
+ }
+ }
+
}
- if(vindex != NULL)
+ /* use video index where possible */
+ if((vindex != NULL) && (l_frame_pos > GVA_FRAME_NEAR_START))
{
gint64 seek_pos;
gint32 l_idx;
- gint32 l_extra_tries_at_end;
-
- l_extra_tries_at_end = 0;
if(gap_debug)
{
+ //p_debug_print_videoindex(vindex);
printf("VIDEO INDEX is available for videofile:%s vindex->tabsize_used:%d\n"
, gvahand->filename
, (int)vindex->tabsize_used
@@ -1896,6 +1990,14 @@
while(vindex->ofs_tab[l_idx].seek_nr < l_pos_min)
{
l_idx++;
+ if(l_idx > vindex->tabsize_used -1)
+ {
+ l_idx = vindex->tabsize_used -1;
+ printf("WARNING: videoindex is NOT complete ! Seek to frame numers > seek_nr:%d will be VERY SLOW!\n"
+ , (int)vindex->ofs_tab[l_idx].seek_nr
+ );
+ break;
+ }
if(gap_debug)
{
printf("SEEK: lower idx adjustment l_idx: %d l_pos_min:%d seek_nr[%d]:%d\n"
@@ -1905,10 +2007,6 @@
, (int)l_idx
);
}
- if(l_idx > vindex->tabsize_used -1)
- {
- break;
- }
}
}
@@ -1937,15 +2035,32 @@
if(l_idx > 0)
{
gint32 l_idx_target;
+ gint32 l_idx_too_far; /* next index position after the target
+ * when this position is reached we are already too far
+ * and must retry with a lower position at next attempt
+ */
+ gboolean l_target_found;
+ l_target_found = FALSE;
l_idx_target = l_idx;
+ l_idx_too_far = l_idx_target + 1;
+ if (l_idx_too_far > vindex->tabsize_used -1)
+ {
+ l_idx_too_far = -1; /* mark as invalid */
+ }
l_readsteps = l_frame_pos - gvahand->current_seek_nr;
if((l_readsteps > vindex->stepsize)
|| (l_readsteps < 0))
{
- gint32 l_synctries;
- gint32 l_nloops;
+ gint32 l_nloops; /* number of seek attempts with different recorded videoindex entries
+ * (outer loop)
+ */
+ gint32 l_synctries; /* number of frame read attempts until
+ * the frame read from video stream matches
+ * the ident data of the recorded frame in the videoindex[l_idx]
+ * (inner loop counter)
+ */
l_nloops = 1;
while((l_idx >= 0) && (l_nloops < 12))
@@ -1976,7 +2091,7 @@
);
}
- l_synctries = 4 + MAX_PREV_OFFSET + (vindex->stepsize * GVA_IDX_SYNC_STEPSIZE) + l_extra_tries_at_end;
+ l_synctries = 4 + MAX_PREV_OFFSET + (vindex->stepsize * GVA_IDX_SYNC_STEPSIZE * l_nloops);
/* SYNC READ loop
* seek to offest found in the index table
@@ -2029,25 +2144,24 @@
gvahand->current_seek_nr = vindex->ofs_tab[vindex->tabsize_used].uni.offset_gint64;
- l_rc_rd = GVA_RET_OK;
- while((l_rc_rd == GVA_RET_OK)
- && (l_synctries > 0))
+ while(l_synctries > 0)
{
gboolean l_potentialCanditate;
l_potentialCanditate = FALSE;
l_rc_rd = p_wrapper_ffmpeg_get_next_frame(gvahand);
+ l_summary_read_ops++;
if(l_rc_rd != GVA_RET_OK)
{
- l_extra_tries_at_end += vindex->stepsize;
l_synctries = -1;
if(gap_debug)
{
- printf("EOF or ERROR while SEEK_SYNC_LOOP l_extra_tries_at_end:%d\n", (int)l_extra_tries_at_end);
+ printf("EOF or ERROR while SEEK_SYNC_LOOP\n");
}
break;
}
+
//
// printf("SEEK_SYNC_LOOP: idx_frame_len:%d got_frame_length16:%d Key:%d dts:%lld\n"
// , (int)vindex->ofs_tab[l_idx_target].frame_length
@@ -2064,14 +2178,14 @@
* (an additional length check would fail in this situation due to the buggy
* length information)
*/
- if(TRUE == p_areTimecodesEqualWithTolerance(vindex->ofs_tab[l_idx].timecode_dts, handle->vid_pkt.dts))
+ if(TRUE == p_areTimecodesEqualWithTolerance(vindex->ofs_tab[l_idx_target].timecode_dts, handle->vid_pkt.dts))
{
l_potentialCanditate = TRUE;
}
}
else
{
- /* handling for old index formats without timecode */
+ /* handling for index without usable timecode */
if(vindex->ofs_tab[l_idx_target].frame_length == handle->got_frame_length16)
{
l_potentialCanditate = TRUE;
@@ -2086,15 +2200,44 @@
if(l_checksum == vindex->ofs_tab[l_idx_target].checksum)
{
/* we have found the wanted (key) frame */
+ l_target_found = TRUE;
+ break;
+ }
+ else if ((vindex->ofs_tab[l_idx_target].timecode_dts != AV_NOPTS_VALUE)
+ && (TRUE == p_areTimecodesEqualWithTolerance(vindex->ofs_tab[l_idx_target].timecode_dts, handle->vid_pkt.dts)))
+ {
+ /* ignore the checksum missmatch when DTS timecode is matching
+ */
+ if(gap_debug)
+ {
+ printf("SEEK_SYNC_LOOP: CHKSUM_MISSMATCH: CHECKSUM[%d]:%d l_checksum:%d but DTS equal:%lld \n"
+ , (int)l_idx_target
+ , (int)vindex->ofs_tab[l_idx_target].checksum
+ , (int)l_checksum
+ , handle->vid_pkt.dts
+ );
+ }
+ l_target_found = TRUE;
break;
}
else
{
+ /* checksum missmatch is non critical in most cases.
+ * a) there may be frames where the packed length is equal to the
+ * wanted frame (NOT CRITICAL)
+ * b) after seek to a non-keyframe and subsequent reads
+ * the resulting frame may be the wanted frame but is corrupted
+ * (due to some missing delta information that was not yet read)
+ * in this case the frame delivers wrong checksum. (CRITICAL)
+ * this code assumes case a) and
+ * continues searching for an exactly matching frame
+ * but also respects case b) in the next outer loop attempt.
+ * (with l_nloops == 2 where we start from a lower seek position)
+ * this shall increase the chance to perfectly decode the frame
+ * and deliver the correct checksum.
+ */
if(gap_debug)
{
- /* checksum missmatch is non critical
- * continue searching for an exactly matching frame
- */
printf("SEEK_SYNC_LOOP: CHKSUM_MISSMATCH: CHECKSUM[%d]:%d l_checksum:%d\n"
, (int)l_idx_target
, (int)vindex->ofs_tab[l_idx_target].checksum
@@ -2103,12 +2246,34 @@
}
}
}
+ else
+ {
+ if (l_idx_too_far > 0) /* check for valid index */
+ {
+ /* Check if we are already AFTER the wanted position */
+ if(vindex->ofs_tab[l_idx_too_far].frame_length == handle->got_frame_length16)
+ {
+ guint16 l_checksum;
+
+ l_checksum = p_gva_checksum(handle->picture_yuv, gvahand->height);
+ if(l_checksum == vindex->ofs_tab[l_idx_too_far].checksum)
+ {
+ l_synctries = -1;
+ if(gap_debug)
+ {
+ printf("SEEK_SYNC_LOOP position is already after wanted target\n");
+ }
+ break;
+ }
+ }
+ }
+ }
l_synctries--;
} /* end while */
- if(l_synctries <= 0)
+ if(l_target_found != TRUE)
{
/* index sync search failed, try with previous index in the table */
if(l_idx < GVA_IDX_SYNC_STEPSIZE)
@@ -2132,14 +2297,14 @@
, (int)l_url_frame_pos
);
}
- gvahand->current_seek_nr = (gint32)l_url_frame_pos;
+ gvahand->current_seek_nr = l_url_frame_pos;
l_readsteps = l_frame_pos - gvahand->current_seek_nr;
if(gap_debug)
{
- printf("SEEK: l_readsteps: %d\n", (int)l_readsteps);
+ printf("SEEK: sync loop success remaining l_readsteps: %d\n", (int)l_readsteps);
}
- break; /* OK, we are now at read position of the wanted keyframe */
+ break; /* OK, escape from outer loop, we are now at read position of the wanted keyframe */
}
if(l_dts_timecode_usable == TRUE)
@@ -2158,6 +2323,18 @@
l_idx -= GVA_IDX_SYNC_STEPSIZE;
}
l_nloops++;
+ } /* end outer loop (l_nloops) */
+
+ if (l_target_found != TRUE)
+ {
+ p_ffmpeg_vid_reopen_read(handle, gvahand);
+ gvahand->current_seek_nr = 1;
+ l_url_frame_pos = 0;
+ if(gap_debug)
+ {
+ printf("SEEK: target frame not found, fallback to slow sequential read from begin\n");
+ }
+
}
}
@@ -2165,16 +2342,22 @@
}
}
+
+ /* fallback to sequential read */
+
if(l_url_frame_pos == 0)
{
/* emulate seek with N steps of read ops */
- if(l_frame_pos < gvahand->current_seek_nr)
+ if((l_frame_pos < gvahand->current_seek_nr) /* position backwards ? */
+ || (gvahand->current_seek_nr < 0)) /* inplausible current position ? */
{
+ /* reopen and read from start */
p_ffmpeg_vid_reopen_read(handle, gvahand);
l_readsteps = l_frame_pos -1;
}
else
{
+ /* continue read from current position */
l_readsteps = l_frame_pos - gvahand->current_seek_nr;
}
}
@@ -2190,6 +2373,7 @@
&& (l_rc_rd == GVA_RET_OK))
{
l_rc_rd = p_wrapper_ffmpeg_get_next_frame(gvahand);
+ l_summary_read_ops++;
gvahand->percentage_done = CLAMP(gvahand->percentage_done + l_progress_step, 0.0, 1.0);
if(gvahand->do_gimp_progress) { gimp_progress_update (gvahand->percentage_done); }
@@ -2212,10 +2396,12 @@
{
if(gap_debug)
{
- printf("p_wrapper_ffmpeg_seek_frame: SEEK OK: l_frame_pos: %d cur_seek:%d cur_frame:%d\n"
+ printf("p_wrapper_ffmpeg_seek_frame: SEEK OK: l_frame_pos: %d cur_seek:%d cur_frame:%d l_summary_read_ops:%d video:%s\n"
, (int)l_frame_pos
, (int)gvahand->current_seek_nr
, (int)gvahand->current_frame_nr
+ , (int)l_summary_read_ops
+ , gvahand->filename
);
}
@@ -2244,7 +2430,7 @@
* In both cases this procedure can calculate the correct timecode that
* is required for frame exact postioning.
*
- * Some videos use variable timecode all over the video. For scuh videos
+ * Some videos use variable timecode all over the video. For such videos
* where no typical pattern can be detected, the native timecodebased seek
* is not possible.
* Some videoformats do not allow seek at all.
@@ -2279,7 +2465,7 @@
gboolean l_retry;
#define NATIVE_SEEK_GOP_INCREASE 24
-
+#define NATIVE_SEEK_EXTRA_PREREADS_NEAR_END 22
handle = (t_GVA_ffmpeg *)gvahand->decoder_handle;
@@ -2941,7 +3127,7 @@
gvahand->percentage_done = 0.0;
persitent_analyse_available = FALSE;
- if(p_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
+ if(gap_base_get_gimprc_gboolean_value(GIMPRC_PERSISTENT_ANALYSE, ANALYSE_DEFAULT))
{
persitent_analyse_available = p_seek_timecode_reliability_self_test(gvahand);
gvahand->percentage_done = 0.0;
@@ -4274,71 +4460,6 @@
} /* end p_gva_checksum */
-/* -----------------------------------------
- * p_get_gimprc_int_value
- * -----------------------------------------
- */
-static gint32
-p_get_gimprc_int_value (const char *gimprc_option_name
- , gint32 default_value, gint32 min_value, gint32 max_value)
-{
- char *value_string;
- gint32 value;
-
- value = default_value;
-
- value_string = gimp_gimprc_query(gimprc_option_name);
- if(value_string)
- {
- value = atol(value_string);
- g_free(value_string);
- }
-
- value = CLAMP(value, min_value, max_value);
- if(gap_debug)
- {
- printf("GIMPRC parameter:%s value:%d\n", gimprc_option_name, value);
- }
- return (value);
-
-} /* end p_get_gimprc_int_value */
-
-
-/* -----------------------------------------
- * p_get_gimprc_gboolean_value
- * -----------------------------------------
- */
-static gboolean
-p_get_gimprc_gboolean_value (const char *gimprc_option_name
- , gboolean default_value)
-{
- char *value_string;
- gboolean value;
-
- value = default_value;
-
- value_string = gimp_gimprc_query(gimprc_option_name);
- if(value_string)
- {
- if ((*value_string == 'y') || (*value_string == 'Y'))
- {
- value = TRUE;
- }
- else
- {
- value = FALSE;
- }
- g_free(value_string);
- }
-
- if(gap_debug)
- {
- printf("GIMPRC parameter:%s value:%d\n", gimprc_option_name, value);
- }
- return (value);
-
-} /* end p_get_gimprc_gboolean_value */
-
/* ----------------------------------
* p_init_timecode_log
@@ -4356,7 +4477,7 @@
gchar *timecode_logfile_name;
gimprc_timecode_log
- = p_get_gimprc_int_value("video-libavformat-timecodelog", 0, 0, 1);
+ = gap_base_get_gimprc_int_value("video-libavformat-timecodelog", 0, 0, 1);
fp_timecode_log = NULL;
timecode_logfile_name = g_strdup("\0");
@@ -4548,7 +4669,7 @@
analysefile_name = p_create_analysefile_name(gvahand);
/* current videofile timestamp */
- master_handle->timestamp = GVA_file_get_mtime(gvahand->filename);
+ master_handle->timestamp = gap_file_get_mtime(gvahand->filename);
master_handle->readsteps_probe_timecode = READSTEPS_PROBE_TIMECODE;
@@ -4602,7 +4723,7 @@
, master_handle->vid_input_context->duration
, p_timecode_to_frame_nr(master_handle, stt+duration3)
, p_timecode_to_frame_nr(master_handle, master_handle->eof_timecode)
- , p_get_gimprc_int_value("video-libavformat-seek-gopsize", DEFAULT_NAT_SEEK_GOPSIZE, 0, MAX_NAT_SEEK_GOPSIZE)
+ , gap_base_get_gimprc_int_value("video-libavformat-seek-gopsize", DEFAULT_NAT_SEEK_GOPSIZE, 0, MAX_NAT_SEEK_GOPSIZE)
, master_handle->video_libavformat_seek_gopsize
);
}
@@ -4667,7 +4788,7 @@
scanned_items = gap_val_scann_filevalues(keylist, analysefile_name);
gap_val_free_keylist(keylist);
- curr_mtime = GVA_file_get_mtime(gvahand->filename);
+ curr_mtime = gap_file_get_mtime(gvahand->filename);
ret = TRUE;
Modified: trunk/libgapvidapi/gap_vid_api_mpeg3.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api_mpeg3.c (original)
+++ trunk/libgapvidapi/gap_vid_api_mpeg3.c Mon Mar 9 17:56:04 2009
@@ -304,7 +304,7 @@
handle->main_handle = mpeg3_open(filename, &l_error_return);
- //if(gap_debug)
+ if(gap_debug)
{
printf("GVA: libmpeg3 OPEN handle->main_handle:%d l_error_return:%d\n"
, (int)handle->main_handle
Modified: trunk/libgapvidapi/gap_vid_api_util.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api_util.c (original)
+++ trunk/libgapvidapi/gap_vid_api_util.c Mon Mar 9 17:56:04 2009
@@ -244,22 +244,6 @@
}
} /* end GVA_md5_string */
-/* --------------------------------
- * GVA_file_get_mtime
- * --------------------------------
- */
-gint32
-GVA_file_get_mtime(const char *filename)
-{
- struct stat l_stat;
-
- if (0 == g_stat(filename, &l_stat))
- {
- return(l_stat.st_mtime);
- }
- return(0);
-
-} /* end GVA_file_get_mtime */
/* --------------------------------
* GVA_filename_to_uri
Modified: trunk/libgapvidapi/gap_vid_api_vidindex.c
==============================================================================
--- trunk/libgapvidapi/gap_vid_api_vidindex.c (original)
+++ trunk/libgapvidapi/gap_vid_api_vidindex.c Mon Mar 9 17:56:04 2009
@@ -196,6 +196,7 @@
return(toc_file);
} /* end GVA_build_video_toc_filename */
+
/* ----------------------------------
* GVA_new_videoindex
* ----------------------------------
@@ -210,12 +211,13 @@
{
vindex->tabtype = GVA_IDX_TT_GINT64;
vindex->videoindex_filename = NULL;
- vindex->tocfile = NULL;
vindex->videofile_uri = NULL;
+ vindex->tocfile = NULL;
vindex->stepsize = GVA_VIDINDEXTAB_DEFAULT_STEPSIZE;
vindex->tabsize_used = 0;
vindex->tabsize_allocated = 0;
vindex->track = 1;
+ vindex->total_frames = 0;
vindex->mtime = 0; /* is set later when saved to file */
vindex->ofs_tab = NULL;
}
@@ -225,6 +227,8 @@
} /* end GVA_new_videoindex */
+
+
/* ----------------------------------
* GVA_free_videoindex
* ----------------------------------
@@ -390,7 +394,7 @@
, vindex->hdr.val_mtim);
}
- l_mtime = GVA_file_get_mtime(filename);
+ l_mtime = gap_file_get_mtime(filename);
if(p_equal_mtime(l_mtime, vindex->mtime) == TRUE)
{
l_flen = atol(vindex->hdr.val_flen);
@@ -558,7 +562,7 @@
return (FALSE);
}
- vindex->mtime = GVA_file_get_mtime(filename);
+ vindex->mtime = gap_file_get_mtime(filename);
/* use one or 2 extra bytes for one or 2 terminating \0 characters
* (l_flen must be even number)
Modified: trunk/libgapvidutil/gap_gve_misc_util.c
==============================================================================
--- trunk/libgapvidutil/gap_gve_misc_util.c (original)
+++ trunk/libgapvidutil/gap_gve_misc_util.c Mon Mar 9 17:56:04 2009
@@ -41,6 +41,7 @@
#include "libgimp/gimp.h"
+#include "gap_libgapbase.h"
#include "gap_gve_misc_util.h"
@@ -141,15 +142,137 @@
} /* end p_gap_build_enc_cancel_request_filename */
+/* -----------------------------------------------
+ * p_get_number_at_end_of_string
+ * -----------------------------------------------
+ * return number at end of the specified string
+ * return -1 in case the string does not end with a number
+ */
+static gint32
+p_get_number_at_end_of_string(const char *name)
+{
+ gint32 number;
+
+ number = -1;
+ if (name)
+ {
+ gint32 idx;
+
+ idx = strlen(name) -1;
+ while(idx >= 0)
+ {
+ if((name[idx] >= '0') && (name[idx] <= '9'))
+ {
+ number = atol(&name[idx]);
+ }
+ else
+ {
+ break;
+ }
+ idx--;
+ }
+ }
+
+ return (number);
+} /* end p_get_number_at_end_of_string */
+
+
+/* -----------------------------------------------
+ * p_gap_delete_old_communication_files
+ * -----------------------------------------------
+ * delete older communication files (if there are any)
+ * this kind of cleanup tries to remove old comminication files
+ * that may be still there
+ * if a previous call to the master video encoder crashed or was killed.
+ */
+static void
+p_gap_delete_old_communication_files()
+{
+ GDir *l_dirp;
+ const gchar *l_entry;
+ const char *l_directory;
+
+#define SECONDS_OF_ONE_HOUR 3600
+
+ l_directory = gimp_directory();
+ l_dirp = g_dir_open( l_directory, 0, NULL );
+ if(l_dirp)
+ {
+ gint32 l_ref_mtime;
+
+ l_ref_mtime = gap_base_get_current_time();
+
+ while ( (l_entry = g_dir_read_name( l_dirp )) != NULL )
+ {
+ if(gap_debug)
+ {
+ printf("delete_old_communication_files: l_entry:%s\n", l_entry);
+ }
+ if (strncmp(l_entry, "gap_master_videoencoder_", strlen("gap_master_videoencoder_")) == 0)
+ {
+ char *l_filename;
+ gint32 l_mtime;
+ gint32 l_diff_time;
+ gint32 l_pid;
+ gint32 l_delete_flag;
+
+ l_delete_flag = FALSE;
+ l_filename = g_build_filename(l_directory, l_entry, NULL);
+ l_pid = p_get_number_at_end_of_string(l_entry);
+ l_mtime = gap_file_get_mtime(l_filename);
+ l_diff_time = l_ref_mtime - l_mtime;
+
+ if(l_pid >= 0)
+ {
+ /* note: detection of a not-running process works only on unix systems */
+ if(!gap_base_is_pid_alive(l_pid))
+ {
+ l_delete_flag = TRUE; /* delete commounication files immediate when refered process is not running */
+ }
+ else
+ {
+ /* assume old communication file when it did not change in the last hour
+ * (for NON unix operating systems)
+ */
+ if (l_diff_time > SECONDS_OF_ONE_HOUR)
+ {
+ l_delete_flag = TRUE; /* delete commounication files immediate when refered process is not running */
+ }
+ }
+ }
+
+ if (l_delete_flag == TRUE)
+ {
+ if(gap_debug)
+ {
+ printf("DELETE file: %s l_ref_mtime:%d l_mtime:%d diff:%d l_pid:%d\n"
+ , l_filename
+ , (int)l_ref_mtime
+ , (int)l_mtime
+ , (int)l_diff_time
+ , (int)l_pid
+ );
+ }
+ g_remove(l_filename);
+ }
+ g_free(l_filename);
+
+ }
+ }
+ g_dir_close( l_dirp );
+
+ }
+
+} /* end p_gap_delete_old_communication_files */
/* ---------------------------------------
- * gap_gve_misc_cleanup_GapGveMasterEncoder
+ * p_private_cleanup_GapGveMasterEncoder
* ---------------------------------------
* cleanup (remove communication files)
* typically called by the master videoencoder when encoding has finished.
*/
-void
-gap_gve_misc_cleanup_GapGveMasterEncoder(gint32 master_encoder_id)
+static void
+p_private_cleanup_GapGveMasterEncoder(gint32 master_encoder_id)
{
char *filename;
@@ -167,10 +290,23 @@
g_remove(filename);
}
g_free(filename);
+
+} /* end p_private_cleanup_GapGveMasterEncoder */
+/* ---------------------------------------
+ * gap_gve_misc_cleanup_GapGveMasterEncoder
+ * ---------------------------------------
+ * cleanup (remove communication files)
+ * typically called by the master videoencoder when encoding has finished.
+ */
+void
+gap_gve_misc_cleanup_GapGveMasterEncoder(gint32 master_encoder_id)
+{
+ p_private_cleanup_GapGveMasterEncoder(master_encoder_id);
+ p_gap_delete_old_communication_files();
+
} /* end gap_gve_misc_cleanup_GapGveMasterEncoder */
-
/* ------------------------------------------
* gap_gve_misc_initGapGveMasterEncoderStatus
* ------------------------------------------
@@ -180,7 +316,7 @@
gap_gve_misc_initGapGveMasterEncoderStatus(GapGveMasterEncoderStatus *encStatus
, gint32 master_encoder_id, gint32 total_frames)
{
- gap_gve_misc_cleanup_GapGveMasterEncoder(master_encoder_id);
+ p_private_cleanup_GapGveMasterEncoder(master_encoder_id);
encStatus->master_encoder_id = master_encoder_id;
encStatus->total_frames = total_frames;
@@ -188,7 +324,7 @@
encStatus->frames_encoded = 0;
encStatus->frames_copied_lossless = 0;
encStatus->current_pass = 0;
-// encStatus->pidOfRunningEncoder = 0;
+ encStatus->pidOfRunningEncoder = 0;
gap_gve_misc_do_master_encoder_progress(encStatus);
}
@@ -213,7 +349,7 @@
{
printf("p_write_encoder_status: frames_processed:%d, PID:%d filename:%s\n"
, (int) encStatus->frames_processed
- , (int) getpid()
+ , (int) gap_base_getpid()
, filename
);
}
@@ -261,7 +397,7 @@
{
printf("p_read_encoder_status: ERROR unexpected contetent in communication filename:%s\n PID:%d id expected: %d but found: %d\n"
, filename
- , (int) getpid()
+ , (int) gap_base_getpid()
, (int) master_encoder_id
, (int) encBuffer.master_encoder_id
);
@@ -271,7 +407,7 @@
{
printf("p_read_encoder_status: frames_processed:%d, PID:%d filename:%s\n"
, (int) encStatus->frames_processed
- , (int) getpid()
+ , (int) gap_base_getpid()
, filename
);
}
@@ -280,7 +416,7 @@
{
printf("p_read_encoder_status: ERROR cold not open communication filename:%s PID:%d\n"
, filename
- , (int) getpid()
+ , (int) gap_base_getpid()
);
}
@@ -297,7 +433,11 @@
void
gap_gve_misc_do_master_encoder_progress(GapGveMasterEncoderStatus *encStatus)
{
- p_write_encoder_status(encStatus);
+ if(encStatus)
+ {
+ encStatus->pidOfRunningEncoder = gap_base_getpid();
+ p_write_encoder_status(encStatus);
+ }
}
Modified: trunk/libgapvidutil/gap_gve_misc_util.h
==============================================================================
--- trunk/libgapvidutil/gap_gve_misc_util.h (original)
+++ trunk/libgapvidutil/gap_gve_misc_util.h Mon Mar 9 17:56:04 2009
@@ -56,6 +56,7 @@
gint32 frames_encoded;
gint32 frames_copied_lossless;
gint32 current_pass; /* 0 for single pass encoders, 1 or 2 for two-pass encoder */
+ gint32 pidOfRunningEncoder; /* 0 if not yet known */
} GapGveMasterEncoderStatus;
Modified: trunk/libgapvidutil/gap_gve_png.c
==============================================================================
--- trunk/libgapvidutil/gap_gve_png.c (original)
+++ trunk/libgapvidutil/gap_gve_png.c Mon Mar 9 17:56:04 2009
@@ -45,10 +45,12 @@
#include "libgimp/gimp.h"
/* GAP includes */
-#include "gap_file_util.h"
+#include "gap_libgapbase.h"
#include "gtk/gtk.h"
+extern int gap_debug;
+
/* --------------------------------
* p_save_as_tmp_png_file
* --------------------------------
@@ -62,7 +64,7 @@
GimpParam *return_vals;
int nreturn_vals;
- //if(gap_debug)
+ if(gap_debug)
{
printf("GAP: PNG encode via call of %s on filename: %s, image_id:%d, drawable_id:%d %s\n"
, l_called_proc
Modified: trunk/vid_common/gap_cme_gui.c
==============================================================================
--- trunk/vid_common/gap_cme_gui.c (original)
+++ trunk/vid_common/gap_cme_gui.c Mon Mar 9 17:56:04 2009
@@ -57,6 +57,7 @@
#include "gap-intl.h"
+#include "gap_libgapbase.h"
#include "gap_cme_main.h"
#include "gap_cme_gui.h"
#include "gap_cme_callbacks.h"
@@ -3996,31 +3997,12 @@
gtk_widget_show(gpp->cme__encoder_status_frame);
+
p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_total, gpp->encStatus.total_frames);
p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_done, gpp->encStatus.frames_processed);
p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_encoded, gpp->encStatus.frames_encoded);
p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_copied_lossless, gpp->encStatus.frames_copied_lossless);
-
- label = gpp->cme__label_enc_time_elapsed;
- if((label != NULL)
- && (gpp->video_encoder_run_state == GAP_CME_ENC_RUN_STATE_RUNNING))
- {
- time_t l_currentUtcTimeInSecs;
- gint32 l_secsElapsed;
- char *buffer;
-
- l_currentUtcTimeInSecs = time(NULL);
- l_secsElapsed = l_currentUtcTimeInSecs - gpp->encoder_started_on_utc_seconds;
-
- buffer = g_strdup_printf("%d:%02d:%02d"
- , (int)l_secsElapsed / 3600
- , (int)(l_secsElapsed / 60) % 60
- , (int)l_secsElapsed % 60
- );
- gtk_label_set_text(GTK_LABEL(label), buffer);
- g_free(buffer);
- }
pbar = gpp->cme__progressbar_status;
@@ -4028,7 +4010,7 @@
{
gdouble l_progress;
char *l_msg;
-
+
switch (gpp->encStatus.current_pass)
{
case 1:
@@ -4073,7 +4055,43 @@
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR (pbar), l_progress);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar), l_msg);
g_free(l_msg);
+
+ if (gpp->encStatus.pidOfRunningEncoder != 0)
+ {
+ if (!gap_base_is_pid_alive(gpp->encStatus.pidOfRunningEncoder))
+ {
+ if (gpp->video_encoder_run_state == GAP_CME_ENC_RUN_STATE_RUNNING)
+ {
+ gpp->video_encoder_run_state = GAP_CME_ENC_RUN_STATE_FINISHED;
+ }
+ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar), _("ENCODER process has terminated"));
+ return;
+ }
+ }
+ }
+
+
+ label = gpp->cme__label_enc_time_elapsed;
+ if((label != NULL)
+ && (gpp->video_encoder_run_state == GAP_CME_ENC_RUN_STATE_RUNNING))
+ {
+ time_t l_currentUtcTimeInSecs;
+ gint32 l_secsElapsed;
+ char *buffer;
+
+ l_currentUtcTimeInSecs = time(NULL);
+ l_secsElapsed = l_currentUtcTimeInSecs - gpp->encoder_started_on_utc_seconds;
+
+ buffer = g_strdup_printf("%d:%02d:%02d"
+ , (int)l_secsElapsed / 3600
+ , (int)(l_secsElapsed / 60) % 60
+ , (int)l_secsElapsed % 60
+ );
+ gtk_label_set_text(GTK_LABEL(label), buffer);
+ g_free(buffer);
}
+
+
// if (gpp->video_encoder_run_state == GAP_CME_ENC_RUN_STATE_RUNNING)
// {
// /* detect if encoder has finished (required for asynchron calls since GIMP-2.6) */
@@ -4148,7 +4166,7 @@
}
gap_gve_misc_initGapGveMasterEncoderStatus(&gpp->encStatus
- , getpid() /* master_encoder_id */
+ , gap_base_getpid() /* master_encoder_id */
, abs(gpp->val.range_to - gpp->val.range_from) + 1 /* total_frames */
);
@@ -4302,7 +4320,7 @@
/* ---------- dialog ----------*/
gap_gve_misc_initGapGveMasterEncoderStatus(&gpp->encStatus
- , getpid() /* master_encoder_id */
+ , gap_base_getpid() /* master_encoder_id */
, 1 /* total_frames */
);
gap_gve_misc_set_master_encoder_cancel_request(&gpp->encStatus, FALSE);
Modified: trunk/vid_common/gap_cme_main.c
==============================================================================
--- trunk/vid_common/gap_cme_main.c (original)
+++ trunk/vid_common/gap_cme_main.c Mon Mar 9 17:56:04 2009
@@ -51,10 +51,10 @@
#include "gap-intl.h"
+#include "gap_libgapbase.h"
#include "gap_cme_main.h"
#include "gap_cme_gui.h"
-#include "gap_file_util.h"
#include "gap_gve_sox.h"
#include "gap_gve_story.h"
#include "gap_libgimpgap.h"
@@ -337,8 +337,7 @@
printf("MAIN before gap_cme_gui_master_encoder_dialog ------------------\n");
}
- /* note that the dialog alrady performs the encoding (as worker thread)
- */
+ /* note that the dialog alrady performs the encoding (as worker thread) */
l_rc = gap_cme_gui_master_encoder_dialog (gpp);
@@ -373,31 +372,31 @@
}
/* wait 8 seconds to give the encoder process a chance to exit
- * (and/or accept a possible cancel request)
- */
+ * (and/or accept a possible cancel request)
+ */
sleep(8);
if(gap_debug)
{
- printf("MAIN cleanup ------------------\n");
+ printf("MAIN cleanup ------------------\n");
}
/* clean up removes the communication file and the cancel request file (if there is any)
- * note that this shall happen after the encoder process has exited.
- * (otherwise the files used for communication may be created again after the
- * following cleanup
- */
+ * note that this shall happen after the encoder process has exited.
+ * (otherwise the files used for communication may be created again after the
+ * following cleanup
+ */
gap_gve_misc_cleanup_GapGveMasterEncoder(gpp->encStatus.master_encoder_id);
-
}
else
{
values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
}
- if((l_rc < 0) && (values[0].data.d_status == GIMP_PDB_SUCCESS))
- {
+
+ if((l_rc < 0) && (values[0].data.d_status == GIMP_PDB_SUCCESS))
+ {
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
- }
+ }
} /* end run */
Modified: trunk/vid_enc_avi/gap_enc_avi_main.c
==============================================================================
--- trunk/vid_enc_avi/gap_enc_avi_main.c (original)
+++ trunk/vid_enc_avi/gap_enc_avi_main.c Mon Mar 9 17:56:04 2009
@@ -50,7 +50,7 @@
#include "gap_gvetypes.h"
-#include "gap_file_util.h"
+#include "gap_libgapbase.h"
#include "gap_libgimpgap.h"
#include "gap_audio_wav.h"
#include "gap_arr_dialog.h" /* for the GUI provisorium */
Modified: trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
==============================================================================
--- trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c (original)
+++ trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c Mon Mar 9 17:56:04 2009
@@ -3401,7 +3401,7 @@
l_check_flags = GAP_VID_CHCHK_FLAG_SIZE;
l_vcodec_list = p_setup_check_flags(epp, &l_check_flags);
- //if(gap_debug)
+ if(gap_debug)
{
printf("p_ffmpeg_encode: START\n");
printf(" current_pass: %d (twoPassFlag:%d)\n", current_pass, epp->twoPassFlag);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]