summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniels <niels@dyne.org>2015-07-29 20:07:42 (GMT)
committer niels <niels@dyne.org>2015-07-29 20:07:42 (GMT)
commitab7969db1bf3e73f7030b57760048822cce1cb3e (patch)
treef062575a8cf0b1e8dcfabf776686a0afd34b4683
parent0cfdc258e271acf0005e971be6636fd928df1ef1 (diff)
optimized formatting status message (divide and conquer sprintf format)
-rw-r--r--veejay-current/veejay-server/libsample/sampleadm.c65
-rw-r--r--veejay-current/veejay-server/libstream/vj-tag.c60
-rw-r--r--veejay-current/veejay-server/libvjmem/memcpy.c12
-rw-r--r--veejay-current/veejay-server/libvjmem/vjmem.h25
-rw-r--r--veejay-current/veejay-server/veejay/liblavplayvj.c73
5 files changed, 123 insertions, 112 deletions
diff --git a/veejay-current/veejay-server/libsample/sampleadm.c b/veejay-current/veejay-server/libsample/sampleadm.c
index 73dbfbc..9f8c715 100644
--- a/veejay-current/veejay-server/libsample/sampleadm.c
+++ b/veejay-current/veejay-server/libsample/sampleadm.c
@@ -2513,8 +2513,8 @@ int sample_chain_sprint_status( int s1,int cache,int sa,int ca, int pfps, int fr
sample_info *sample;
sample = sample_get(s1);
- if (!sample)
- {
+ if (!sample)
+ {
return -1;
}
int e_a, e_d, e_s;
@@ -2532,38 +2532,35 @@ int sample_chain_sprint_status( int s1,int cache,int sa,int ca, int pfps, int fr
e_s = sample->encoder_total_frames_recorded;
}
- veejay_sprintf(str,MESSAGE_SIZE,
- "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
- pfps,
- frame,
- mode,
- s1,
- sample->effect_toggle,
- sample->first_frame,
- sample->last_frame,
- sample->speed,
- sample->looptype,
- e_a,
- e_d,
- e_s,
- sample_size(),
- sample->marker_start,
- sample->marker_end,
- sample->selected_entry,
- total_slots,
- cache,
- curfps,
- lo,
- hi,
- sa,
- ca,
- (int)( sample->fader_val ),
- sample->dup,
- macro);
-
-
-
- return 0;
+ char *ptr = str;
+ ptr = vj_sprintf( ptr, pfps ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, frame ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, mode ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, s1 ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->effect_toggle ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->first_frame ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->last_frame ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->speed ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->looptype ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, e_a); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, e_d ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, e_s ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample_size() ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->marker_start ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->marker_end ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->selected_entry ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, total_slots ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, cache ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, curfps ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, lo ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, hi ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sa ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, ca ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, (int) sample->fader_val ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sample->dup ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, macro );
+
+ return 0;
}
diff --git a/veejay-current/veejay-server/libstream/vj-tag.c b/veejay-current/veejay-server/libstream/vj-tag.c
index 4d96dd0..2732a3a 100644
--- a/veejay-current/veejay-server/libstream/vj-tag.c
+++ b/veejay-current/veejay-server/libstream/vj-tag.c
@@ -3609,37 +3609,35 @@ int vj_tag_sprint_status( int tag_id,int cache,int sa, int ca, int pfps,int fram
{
vj_tag *tag;
tag = vj_tag_get(tag_id);
- //if (!tag)
- //return -1;
-
- snprintf(str, MESSAGE_SIZE,
- "%d %d %d %d %d %d %d %d %d %d %ld %ld %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
- pfps,
- frame,
- mode,
- tag_id,
- tag->effect_toggle,
- tag->color_r, // no start, but color
- tag->color_g, // no end,
- tag->color_b, // no speed,
- 0, // no looping
- tag->encoder_active,
- tag->encoder_frames_to_record,
- tag->encoder_total_frames_recorded,
- vj_tag_size()-1,
- tag->source_type, // no markers
- tag->n_frames, // no markers
- tag->selected_entry,
- ts,
- cache,
- curfps,
- lo,
- hi,
- sa,
- ca,
- (int)(tag->fader_val),
- 0,
- macro);
+
+ char *ptr = str;
+ ptr = vj_sprintf( ptr, pfps ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, frame ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, mode ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag_id ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->effect_toggle ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->color_r ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->color_g ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->color_b ); *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->encoder_active ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->encoder_frames_to_record ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->encoder_total_frames_recorded ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, vj_tag_size() - 1 ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->source_type ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->n_frames ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, tag->selected_entry ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, ts ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, cache ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, curfps ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, (int) lo ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, (int) hi ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, sa ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, ca ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, (int) tag->fader_val ); *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, macro );
+
return 0;
}
diff --git a/veejay-current/veejay-server/libvjmem/memcpy.c b/veejay-current/veejay-server/libvjmem/memcpy.c
index 054cb5c..1e3be0b 100644
--- a/veejay-current/veejay-server/libvjmem/memcpy.c
+++ b/veejay-current/veejay-server/libvjmem/memcpy.c
@@ -1889,3 +1889,15 @@ char *vj_strndup( const char *s, size_t n )
return ptr ? memcpy( ptr,s,n ) : NULL;
}
+
+char *vj_sprintf( char *dst, int value )
+{
+ char number[16];
+ int n;
+ snprintf(number,sizeof(number),"%d", value);
+ n = strlen( number );
+ *dst = '\0';
+ strcat( dst, number );
+ return dst + n;
+}
+
diff --git a/veejay-current/veejay-server/libvjmem/vjmem.h b/veejay-current/veejay-server/libvjmem/vjmem.h
index 90cf0a5..9ad8f2f 100644
--- a/veejay-current/veejay-server/libvjmem/vjmem.h
+++ b/veejay-current/veejay-server/libvjmem/vjmem.h
@@ -22,30 +22,30 @@
#define MAX_WORKERS 256
-extern void *(* veejay_memcpy)(void *to, const void *from, size_t len);
-extern void *(* veejay_memset)(void *to, uint8_t val, size_t len);
-extern void vj_mem_init(void);
+extern void *(* veejay_memcpy)(void *to, const void *from, size_t len);
+extern void *(* veejay_memset)(void *to, uint8_t val, size_t len);
+extern void vj_mem_init(void);
extern int vj_mem_threaded_init(int w, int h);
-extern void vj_mem_threaded_stop(void);
-extern char *get_memcpy_descr( void );
+extern void vj_mem_threaded_stop(void);
+extern char *get_memcpy_descr( void );
extern char *get_memset_descr( void );
extern void *vj_malloc_(size_t size);
-extern void *vj_calloc_(size_t size );
+extern void *vj_calloc_(size_t size );
extern void memcpy_report();
#define vj_malloc(i) vj_malloc_(i)
#define vj_calloc(i) vj_calloc_(i)
-extern void fast_memset_dirty(void * to, int val, size_t len);
-extern void fast_memset_finish();
+extern void fast_memset_dirty(void * to, int val, size_t len);
+extern void fast_memset_finish();
extern void packed_plane_clear( size_t len, void *to );
extern void yuyv_plane_clear( size_t len, void *to );
extern int cpu_cache_size();
extern int get_cache_line_size();
extern char *veejay_strncat( char *s1, char *s2, size_t n );
extern char *veejay_strncpy( char *s1, const char *s2, size_t n );
-extern void yuyv_plane_init();
-extern void yuyv_plane_clear( size_t len, void *to );
+extern void yuyv_plane_init();
+extern void yuyv_plane_clear( size_t len, void *to );
extern char **vje_build_param_list( int num, ... );
extern void *(*vj_frame_copy)( uint8_t **input, uint8_t **output, int *strides );
extern void *(*vj_frame_clear)( uint8_t **input, int *strides, unsigned int val );
@@ -55,8 +55,9 @@ extern uint8_t num_threaded_tasks();
extern void vj_frame_slow_threaded( uint8_t **p0_buffer, uint8_t **p1_buffer, uint8_t **img, int len, int uv_len,const float frac );
extern void benchmark_veejay(int w, int h);
extern void *vj_hmalloc(size_t sze, const char *name);
-extern char *vj_strdup(const char *s);
-extern char *vj_strndup(const char *s, size_t n );
+extern char *vj_strdup(const char *s);
+extern char *vj_strndup(const char *s, size_t n );
+extern char *vj_sprintf(char *dst, int value);
extern void vj_simple_pool_free( void *ptr );
extern void *vj_simple_pool_alloc( void *ptr, size_t s );
extern void *vj_simple_pool_init( size_t s );
diff --git a/veejay-current/veejay-server/veejay/liblavplayvj.c b/veejay-current/veejay-server/veejay/liblavplayvj.c
index 83fa72e..948e89a 100644
--- a/veejay-current/veejay-server/veejay/liblavplayvj.c
+++ b/veejay-current/veejay-server/veejay/liblavplayvj.c
@@ -1090,19 +1090,19 @@ void veejay_pipe_write_status(veejay_t * info)
int total_slots = sample_size()-1;
int tags = vj_tag_true_size() -1;
int cache_used = 0;
+ int mstatus = vj_event_macro_status();
+ int curfps = (int) ( 100.0f / settings->spvf );
+
if(tags>0)
total_slots+=tags;
-
- int mstatus = vj_event_macro_status();
- int curfps = (int) ( 100.0f / settings->spvf );
-
- switch (info->uc->playback_mode) {
+
+ switch (info->uc->playback_mode) {
case VJ_PLAYBACK_MODE_SAMPLE:
- cache_used = sample_cache_used(0);
+ cache_used = sample_cache_used(0);
- if( info->settings->randplayer.mode ==
- RANDMODE_SAMPLE)
+ if( info->settings->randplayer.mode == RANDMODE_SAMPLE)
pm = VJ_PLAYBACK_MODE_PATTERN;
+
if( sample_chain_sprint_status
(info->uc->sample_id,cache_used,info->seq->size,info->seq->current,info->real_fps,settings->current_frame_num, pm, total_slots,info->seq->rec_id,curfps,settings->cycle_count[0],settings->cycle_count[1],mstatus,info->status_what ) != 0)
{
@@ -1112,33 +1112,36 @@ void veejay_pipe_write_status(veejay_t * info)
break;
case VJ_PLAYBACK_MODE_PLAIN:
// 26 status symbols
- snprintf(info->status_what,MESSAGE_SIZE, " %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
- info->real_fps,
- settings->current_frame_num,
- info->uc->playback_mode,
- 0,
- 0,
- settings->min_frame_num,
- settings->max_frame_num,
- settings->current_playback_speed,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- total_slots,
- cache_used,
- curfps,
- settings->cycle_count[0],
- settings->cycle_count[1],
- 0,
- 0,
- 0,
- 0,
- mstatus);
+ {
+ char *ptr = info->status_what;
+ *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, info->real_fps ); *ptr++= ' ';
+ ptr = vj_sprintf( ptr, settings->current_frame_num ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, info->uc->playback_mode ); *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, settings->min_frame_num ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, settings->max_frame_num ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, settings->current_playback_speed ); *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, total_slots ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, cache_used ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, curfps ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, settings->cycle_count[0] ); *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, settings->cycle_count[1] ); *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ *ptr++ = '0'; *ptr++ = ' ';
+ ptr = vj_sprintf( ptr, mstatus );
+ }
break;
case VJ_PLAYBACK_MODE_TAG:
if( vj_tag_sprint_status( info->uc->sample_id,cache_used,info->seq->size,info->seq->current, info->real_fps,