From 8a237aa206124245fdfaf4f03f552538852142a4 Mon Sep 17 00:00:00 2001 From: niels Date: Wed, 20 Mar 2013 21:37:59 +0100 Subject: [PATCH 01/32] drop sub_id assignment --- veejay-current/veejay-server/libel/vj-avcodec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/veejay-current/veejay-server/libel/vj-avcodec.c b/veejay-current/veejay-server/libel/vj-avcodec.c index 648bd9f5..abd90503 100644 --- a/veejay-current/veejay-server/libel/vj-avcodec.c +++ b/veejay-current/veejay-server/libel/vj-avcodec.c @@ -203,7 +203,6 @@ static vj_encoder *vj_avcodec_new_encoder( int id, editlist *el, char *filename) e->context->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; e->context->flags = CODEC_FLAG2_FAST | CODEC_FLAG_QSCALE; e->context->gop_size = 0; - e->context->sub_id = 0; e->context->workaround_bugs = FF_BUG_AUTODETECT; e->context->prediction_method = 0; e->context->dct_algo = FF_DCT_AUTO; From 7720c811f5f84d58ae95b3b5fffe90216b0802d5 Mon Sep 17 00:00:00 2001 From: niels Date: Sat, 20 Apr 2013 00:52:04 +0200 Subject: [PATCH 02/32] add VIMS to play next sample (sequencer -> next, next sample or stream). trigger with SPACE_BAR. required CAPS_LOCK on (shared with start/stop macro recorder) --- veejay-current/veejay-server/veejay/vims.h | 1 + .../veejay-server/veejay/vj-event.c | 56 +++++++++++++++++++ .../veejay-server/veejay/vj-event.h | 1 + .../veejay-server/veejay/vj-eventman.c | 9 +++ 4 files changed, 67 insertions(+) diff --git a/veejay-current/veejay-server/veejay/vims.h b/veejay-current/veejay-server/veejay/vims.h index d4f0a8f8..ff41590d 100644 --- a/veejay-current/veejay-server/veejay/vims.h +++ b/veejay-current/veejay-server/veejay/vims.h @@ -168,6 +168,7 @@ enum { VIMS_SAMPLE_KF_GET = 146, VIMS_SAMPLE_KF_RESET = 147, VIMS_SAMPLE_HOLD_FRAME = 148, + VIMS_SAMPLE_NEXT = 149, VIMS_STREAM_COLOR = 202, VIMS_STREAM_SELECT = 201, VIMS_STREAM_ACTIVATE = 205, diff --git a/veejay-current/veejay-server/veejay/vj-event.c b/veejay-current/veejay-server/veejay/vj-event.c index dbbc20e0..e55e2dc0 100644 --- a/veejay-current/veejay-server/veejay/vj-event.c +++ b/veejay-current/veejay-server/veejay/vj-event.c @@ -179,6 +179,7 @@ enum { }; #ifdef HAVE_SDL +#define VIMS_MOD_CAPSLOCK 4 #define VIMS_MOD_SHIFT 3 #define VIMS_MOD_NONE 0 #define VIMS_MOD_CTRL 2 @@ -302,6 +303,7 @@ static struct { /* hardcoded keyboard layout (the default keys) */ { VIMS_MACRO, SDLK_SPACE, VIMS_MOD_NONE, "2 1" }, { VIMS_MACRO, SDLK_SPACE, VIMS_MOD_SHIFT, "1 1" }, { VIMS_MACRO, SDLK_SPACE, VIMS_MOD_CTRL, "0 0" }, + { VIMS_MACRO, SDLK_SPACE, VIMS_MOD_CAPSLOCK, "3 1"}, { VIMS_MACRO_SELECT, SDLK_F1, VIMS_MOD_CTRL, "0" }, { VIMS_MACRO_SELECT, SDLK_F2, VIMS_MOD_CTRL, "1" }, { VIMS_MACRO_SELECT, SDLK_F3, VIMS_MOD_CTRL, "2" }, @@ -1812,6 +1814,9 @@ int vj_event_single_fire(void *ptr , SDL_Event event, int pressed) vims_mod = VIMS_MOD_ALT; if( (mod & KMOD_CTRL) || (mod & KMOD_CTRL) ) vims_mod = VIMS_MOD_CTRL; + if( (mod & KMOD_CAPS) ) { + vims_mod = VIMS_MOD_CAPSLOCK; + } int vims_key = key->keysym.sym; int index = vims_mod * SDLK_LAST + vims_key; @@ -10323,6 +10328,53 @@ void vj_event_font_set_size_and_font( void *ptr, const char format[], va_list ap } #endif +void vj_event_sample_next( void *ptr, const char format[], va_list ap) +{ + veejay_t *v = (veejay_t*) ptr; + if( v->seq->active ){ + int p = v->seq->current + 1; + int n = v->seq->samples[ p ]; + if( sample_exists( n ) ) { + veejay_set_sample(v, n ); + } + } + if( SAMPLE_PLAYING(v)) { + int n = v->uc->sample_id + 1; + if( sample_exists(n) ) { + veejay_set_sample(v,n ); + } else { + n = 1; + int stop = sample_size() -1; + while(!sample_exists(n) ) { + n ++; + if( n > stop ) { + return; + } + } + veejay_set_sample(v, n ); + } + } + else if ( STREAM_PLAYING(v)) { + int n = v->uc->sample_id + 1; + if( vj_tag_exists(n) ) { + veejay_change_playback_mode(v, VJ_PLAYBACK_MODE_TAG, n ); + + } + else { + n = 1; + int stop = vj_tag_size()-1; + while( !vj_tag_exists(n) ) { + n ++; + if( n > stop ) { + return; + } + } + veejay_change_playback_mode( v, VJ_PLAYBACK_MODE_TAG, n ); + } + } +} + + void vj_event_sequencer_add_sample( void *ptr, const char format[], va_list ap ) { int args[5]; @@ -10501,6 +10553,10 @@ void vj_event_set_macro_status( void *ptr, const char format[], va_list ap ) veejay_msg(VEEJAY_MSG_INFO, "No keystrokes to playback!"); } } + else if ( args[0] == 3 ) + { + vj_event_sample_next( v , NULL, NULL ); + } } void vj_event_stop() diff --git a/veejay-current/veejay-server/veejay/vj-event.h b/veejay-current/veejay-server/veejay/vj-event.h index 86a34c99..c2ee363e 100644 --- a/veejay-current/veejay-server/veejay/vj-event.h +++ b/veejay-current/veejay-server/veejay/vj-event.h @@ -111,6 +111,7 @@ void vj_event_play_speed_kb ( void *ptr, const char format[], va_list ap ); void vj_event_play_slow ( void *ptr, const char format[], va_list ap ); void vj_event_play_stop ( void *ptr, const char format[], va_list ap ); void vj_event_prev_second ( void *ptr, const char format[], va_list ap ); +void vj_event_sample_next( void *ptr, const char format[], va_list ap); void vj_event_sample_clear_all ( void *ptr, const char format[], va_list ap ); void vj_event_sample_copy ( void *ptr, const char format[], va_list ap ); void vj_event_sample_del ( void *ptr, const char format[], va_list ap ); diff --git a/veejay-current/veejay-server/veejay/vj-eventman.c b/veejay-current/veejay-server/veejay/vj-eventman.c index 7b8d2614..1a7b6112 100644 --- a/veejay-current/veejay-server/veejay/vj-eventman.c +++ b/veejay-current/veejay-server/veejay/vj-eventman.c @@ -944,6 +944,15 @@ void vj_init_vevo_events(void) 5, NULL ); + index_map_[VIMS_SAMPLE_NEXT] = _new_event( + NULL, + VIMS_SAMPLE_NEXT, + "Play next sample in queue", + vj_event_sample_next, + 0, + VIMS_ALLOW_ANY, + NULL ); + index_map_[VIMS_SAMPLE_SET_POSITION] = _new_event( "%d %d %d", VIMS_SAMPLE_SET_POSITION, From 8a2f037711b27520d31ac91a0aecdd068b6bba68 Mon Sep 17 00:00:00 2001 From: niels Date: Sat, 20 Apr 2013 01:01:27 +0200 Subject: [PATCH 03/32] spacebar + capslock --- veejay-current/veejay-server/man/veejay.1 | 4 +++- veejay-current/veejay-server/veejay/vj-event.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/veejay-current/veejay-server/man/veejay.1 b/veejay-current/veejay-server/man/veejay.1 index a9cb6958..857149cd 100644 --- a/veejay-current/veejay-server/man/veejay.1 +++ b/veejay-current/veejay-server/man/veejay.1 @@ -501,7 +501,6 @@ Decrease parameter 7 of selected effect .B [i] Increase parameter 7 of selected effect .TP - .B SHIFT + spacebar Start keystroke recorder. The keystroke recorder records most of the received VIMS messages and plays them @@ -519,6 +518,9 @@ recorded VIMS messages. Clear recorded keystrokes. This clears all VIMS messages in the current selected macro slot. .TP +.B spacebar (CAPS-LOCK on) +Plays the next sample in queue (in playing direction) +.TP .B CTRL + [ F1 - F12 ] Select a slot to record keystrokes to (default=0) Use this if you want to record multiple keystrokes. You diff --git a/veejay-current/veejay-server/veejay/vj-event.c b/veejay-current/veejay-server/veejay/vj-event.c index e55e2dc0..20e5d815 100644 --- a/veejay-current/veejay-server/veejay/vj-event.c +++ b/veejay-current/veejay-server/veejay/vj-event.c @@ -10332,22 +10332,25 @@ void vj_event_sample_next( void *ptr, const char format[], va_list ap) { veejay_t *v = (veejay_t*) ptr; if( v->seq->active ){ - int p = v->seq->current + 1; + int s = (v->settings->current_playback_speed < 0 ? -1 : 1 ); + int p = v->seq->current + s; + if( p < 0 ) p = 0; int n = v->seq->samples[ p ]; if( sample_exists( n ) ) { veejay_set_sample(v, n ); } } if( SAMPLE_PLAYING(v)) { - int n = v->uc->sample_id + 1; + int s = (v->settings->current_playback_speed < 0 ? -1 : 1 ); + int n = v->uc->sample_id + s; if( sample_exists(n) ) { veejay_set_sample(v,n ); } else { - n = 1; + n = v->uc->sample_id; int stop = sample_size() -1; while(!sample_exists(n) ) { - n ++; - if( n > stop ) { + n += s; + if( n > stop || n < 1 ) { return; } } From d24901f5b41c65fb0f83d4865b3943f0aeea17e0 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 22 Apr 2013 00:08:20 +0200 Subject: [PATCH 04/32] read VIMS messages larger then 4096 bytes (FX Anim and others, large packet) bump version --- veejay-current/veejay-client/configure.ac | 4 +- .../veejay-server/libvjnet/vj-server.c | 52 +++++++++++++++---- .../veejay-server/libvjnet/vj-server.h | 3 +- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index 0dbecfd4..8a4c7713 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([reloaded],[1.5.26],[nwelburg@gmail.com]) +AC_INIT([reloaded],[1.5.27],[nwelburg@gmail.com]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/gveejay.c]) RELOADED_MAJOR_VERSION=1 RELOADED_MINOR_VERSION=5 -RELOADED_MICRO_VERSION=26 +RELOADED_MICRO_VERSION=27 RELOADED_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION RELOADED_CODENAME="Reloaded - build $RELOADED_MAJOR_VERSION $RELOADED_MINOR_VERSION $RELOADED_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) diff --git a/veejay-current/veejay-server/libvjnet/vj-server.c b/veejay-current/veejay-server/libvjnet/vj-server.c index 9749d113..42d33d5e 100644 --- a/veejay-current/veejay-server/libvjnet/vj-server.c +++ b/veejay-current/veejay-server/libvjnet/vj-server.c @@ -339,7 +339,8 @@ vj_server *vj_server_alloc(int port_offset, char *mcast_group_name, int type) if (!vjs) return NULL; - vjs->recv_buf = (char*) vj_calloc(sizeof(char) * (RECV_SIZE+1024) ); + vjs->recv_bufsize = RECV_SIZE * 1024; //@ 4 MB receive buffer + vjs->recv_buf = (char*) vj_calloc(sizeof(char) * vjs->recv_bufsize); if(!vjs->recv_buf) { if(vjs) free(vjs); @@ -678,8 +679,6 @@ int _vj_server_empty_queue(vj_server *vje, int link_id) Link[link_id]->n_queued = 0; Link[link_id]->n_retrieved = 0; - veejay_memset( vje->recv_buf, 0, RECV_SIZE ); - return 1; } @@ -960,11 +959,46 @@ int vj_server_update( vj_server *vje, int id ) int bytes_received = 0; if(!vje->use_mcast) { - bytes_received = recv( sock_fd, vje->recv_buf, RECV_SIZE, 0 ); + + int max = vje->recv_bufsize; + int bytes_left = 1; + char *ptr = vje->recv_buf; + int readmore = 0; + + n = recv( sock_fd, ptr, 1, 0 ); + if( n != 1 ) { + bytes_received = -1; + } + else { + if( *ptr == 'V' || *ptr == 'K' || *ptr == 'D' ) { + ptr ++; +readmore_lbl: + n = recv( sock_fd, ptr, RECV_SIZE, 0 ); + if( n == - 1) { + if( errno == EAGAIN ) { + goto readmore_lbl; + } + veejay_msg( 0, "Error: %s", strerror(errno) ); + bytes_received = -1; + } + if( n == RECV_SIZE && errno == EAGAIN) + { // deal with large messages + ptr += n; + bytes_received += n; + if( bytes_received > max ) { + veejay_msg(VEEJAY_MSG_ERROR,"VIMS message does not fit receive buffer."); + return -1; + } + goto readmore_lbl; + } + bytes_received += n; + } + } + //bytes_received = recv( sock_fd, vje->recv_buf, RECV_SIZE, 0 ); #ifdef STRICT_CHECKING if( vje->logfd ) { - fprintf(vje->logfd, "received %d of %d bytes from handle %d (link %d)\n", - bytes_received,RECV_SIZE, Link[id]->handle,id ); + fprintf(vje->logfd, "received %d bytes from handle %d (link %d)\n", + bytes_received,Link[id]->handle,id ); printbuf( vje->logfd, vje->recv_buf, bytes_received ); } #endif @@ -981,7 +1015,7 @@ int vj_server_update( vj_server *vje, int id ) veejay_msg(0, "Networking error with socket %d: %s",sock_fd,strerror(errno)); } if( bytes_received == 0 ) { - veejay_msg(0, "Link %d closed connection, terminating client connection.",id); + veejay_msg(VEEJAY_MSG_WARNING, "Link %d closed connection, terminating client connection.",id); } return -1; // close client now } @@ -991,10 +1025,10 @@ int vj_server_update( vj_server *vje, int id ) int bytes_left = bytes_received; int n_msg = _vj_verify_msg( vje, id, msg_buf, bytes_left ); - + if(n_msg == 0 && bytes_received > 0) { - veejay_msg(VEEJAY_MSG_ERROR, "Invalid instruction '%s'", msg_buf ); + veejay_msg(VEEJAY_MSG_ERROR, "Invalid VIMS instruction '%s'", msg_buf ); #ifdef STRICT_CHECKING if( vje->logfd ) { fprintf(vje->logfd, "no valid messages in buffer!\n" ); diff --git a/veejay-current/veejay-server/libvjnet/vj-server.h b/veejay-current/veejay-server/libvjnet/vj-server.h index 6ba8d40f..ce83e876 100644 --- a/veejay-current/veejay-server/libvjnet/vj-server.h +++ b/veejay-current/veejay-server/libvjnet/vj-server.h @@ -44,7 +44,8 @@ typedef struct vj_server_t { int send_size; int recv_size; int mcast_gray; - FILE *logfd; + FILE *logfd; + int recv_bufsize; } vj_server; vj_server *vj_server_alloc(int port, char *mcast_group_name, int type); From 54bdfcfac2b83b69b0dd94987a1a6d59bd141ced Mon Sep 17 00:00:00 2001 From: niels Date: Wed, 24 Apr 2013 17:50:19 +0200 Subject: [PATCH 05/32] verify index value --- veejay-current/veejay-client/src/vj-api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/veejay-current/veejay-client/src/vj-api.c b/veejay-current/veejay-client/src/vj-api.c index 6edb68b5..72f3fb2f 100644 --- a/veejay-current/veejay-client/src/vj-api.c +++ b/veejay-current/veejay-client/src/vj-api.c @@ -4730,6 +4730,9 @@ static void reload_keys() index = (val[1] * MOD_OFFSET) + val[2]; + if( index < 0 || index >= VIMS_MAX ) + continue; + vims_keys_list[ index ].keyval = val[2]; vims_keys_list[ index ].state = val[1]; vims_keys_list[ index ].event_id = val[0]; From a73ff717804605a91ccf5d543102dcb48ae1dd10 Mon Sep 17 00:00:00 2001 From: niels Date: Fri, 17 May 2013 00:04:28 +0200 Subject: [PATCH 06/32] fix possible segfault in yuv encoders - added lzo self test if compiled with STRICT_CHECKING - align lzo work buffer - fix offsets for lzo headers - added scaler to network receiver (tcp/unicast) - added utility function to libvevo to set string arrays refactored low level network send/receive message (vims) - changed vj_client_read_i - fallback to sending raw frames if compression fails (tcp/unicast) - added VEEJAY_SERVER_RECEIVE_BUFFER_SIZE to customize raw send and recv window sizes - fixed possible queue overload (vims) - increased maximum message in vims queue (768) - handle EAGAIN in server net i/o - added message on CAPS-LOCK modifier space bar - refactored sending (un)compressed video frames - --- .../veejay-server/libel/vj-avcodec.c | 34 ++- veejay-current/veejay-server/liblzo/lzo.c | 154 +++++++++--- veejay-current/veejay-server/liblzo/lzo.h | 5 +- .../veejay-server/libstream/vj-net.c | 31 ++- .../veejay-server/libvevo/libvevo.h | 2 + veejay-current/veejay-server/libvevo/vevo.c | 59 +++++ veejay-current/veejay-server/libvjnet/cmd.c | 42 ++-- .../veejay-server/libvjnet/vj-client.c | 223 ++++++++---------- .../veejay-server/libvjnet/vj-server.c | 44 +++- .../veejay-server/veejay/vj-event.c | 1 + .../veejay-server/veejay/vj-perform.c | 121 +++++----- 11 files changed, 440 insertions(+), 276 deletions(-) diff --git a/veejay-current/veejay-server/libel/vj-avcodec.c b/veejay-current/veejay-server/libel/vj-avcodec.c index abd90503..e8b6b58d 100644 --- a/veejay-current/veejay-server/libel/vj-avcodec.c +++ b/veejay-current/veejay-server/libel/vj-avcodec.c @@ -33,7 +33,9 @@ #include #include - +#ifdef STRICT_CHECKING +#include +#endif //#define YUV420_ONLY_CODEC(id) ( ( id == CODEC_ID_MJPEG || id == CODEC_ID_MJPEGB || id == CODEC_ID_MSMPEG4V3 || id == CODEC_ID_MPEG4) ? 1: 0) @@ -486,38 +488,34 @@ static void long2str(unsigned char *dst, int32_t n) static int vj_avcodec_lzo( vj_encoder *av, uint8_t *src[3], uint8_t *dst , int buf_len ) { uint8_t *dstI = dst + (3 * 4); - int size1 = 0, size2=0,size3=0; + uint32_t s1,s2,s3; + uint32_t *size1 = &s1, *size2=&s2,*size3=&s3; int i; - - i = lzo_compress( av->lzo, src[0], dstI, &size1 , av->len); + + i = lzo_compress( av->lzo, src[0], dstI, size1 , av->len); if( i == 0 ) { veejay_msg(0,"\tunable to compress Y plane"); return 0; } - dstI += size1; - - i = lzo_compress( av->lzo, src[1], dstI, &size2 , av->uv_len ); + i = lzo_compress( av->lzo, src[1], dstI + s1, size2 , av->uv_len ); if( i == 0 ) { veejay_msg(0,"\tunable to compress U plane"); return 0; } - - dstI += size2; - i = lzo_compress( av->lzo, src[2], dstI, &size3 , av->uv_len ); + i = lzo_compress( av->lzo, src[2], dstI + (s1 + s2), size3 , av->uv_len ); if( i == 0 ) { veejay_msg(0,"\tunable to compress V plane"); return 0; } - - long2str( dst, size1 ); - long2str( dst+4,size2); - long2str( dst+8,size3); - - return (size1 + size2 + size3 + 12); + long2str( dst, s1 ); + long2str( dst+4,s2); + long2str( dst+8,s3); + + return (s1 + s2 + s3 + 12); } static int vj_avcodec_copy_frame( vj_encoder *av, uint8_t *src[3], uint8_t *dst, int in_fmt ) { @@ -559,7 +557,7 @@ static int vj_avcodec_copy_frame( vj_encoder *av, uint8_t *src[3], uint8_t *dst if( av->encoder_id == 998 ) { - uint8_t *dest[3] = { dst, dst + (av->len), dst + (av->len + av->uv_len) }; + uint8_t *dest[4] = { dst, dst + (av->len), dst + (av->len + av->uv_len), NULL }; int strides[4] = { av->len, av->uv_len, av->uv_len, 0 }; vj_frame_copy( src, dest, strides ); @@ -574,7 +572,7 @@ static int vj_avcodec_copy_frame( vj_encoder *av, uint8_t *src[3], uint8_t *dst if( av->encoder_id == 997 ) { - uint8_t *dest[3] = { dst, dst + (av->len), dst + (av->len + av->uv_len) }; + uint8_t *dest[4] = { dst, dst + (av->len), dst + (av->len + av->uv_len), NULL }; int strides[4] = { av->len, av->uv_len,av->uv_len, 0 }; vj_frame_copy( src, dest, strides ); diff --git a/veejay-current/veejay-server/liblzo/lzo.c b/veejay-current/veejay-server/liblzo/lzo.c index 4b27152a..ff821906 100644 --- a/veejay-current/veejay-server/liblzo/lzo.c +++ b/veejay-current/veejay-server/liblzo/lzo.c @@ -1,5 +1,5 @@ /* veejay - Linux VeeJay - * (C) 2002-2006 Niels Elburg + * (C) 2002-2013 Niels Elburg * * * This program is free software; you can redistribute it and/or modify @@ -25,7 +25,6 @@ #include #include #include - #include #include #include @@ -51,27 +50,109 @@ void lzo_free( void *lzo ) } l = NULL; } +/* +void lzo_print_buf( uint8_t *buf, int len ) +{ + int i; + printf("------ %p, %d\n", buf, len ); + printf("line : "); + for( i = 1; i < 32; i ++ ) { + printf(". "); + } + printf("\n"); + for(i = 0; i < len ; i ++ ) { + if( (i%32) == 0 ) + printf("\nline %04d: ",i); + printf("%02x", buf[i] ); + } + printf("\n"); +} +*/ +static int lzo_verify_compression(uint8_t *in, int in_len, uint8_t *out , int *out_lenptr, uint8_t *wrkmem) +{ + int out_len = 0; + int r = lzo1x_1_compress( in, in_len, out, &out_len, wrkmem ); + if( r == LZO_E_OK ) { + veejay_msg(VEEJAY_MSG_DEBUG, "LZO (test) Compressed %lu bytes into %lu bytes\n", + (unsigned long) in_len, (unsigned long) out_len ); + *out_lenptr = out_len; + } else { + veejay_msg(VEEJAY_MSG_ERROR, "LZO (test) Compression error: %d", r ); + return 0; + } + + if( out_len >= in_len ) { + veejay_msg(VEEJAY_MSG_ERROR, "LZO (test) Block contains incompressible data."); + return 0; + } + + int new_len = in_len; + r = lzo1x_decompress( out, out_len, in, &new_len, NULL ); + if( r == LZO_E_OK && new_len == in_len ) { + veejay_msg(VEEJAY_MSG_DEBUG, "LZO (test) Decompressed %lu (%lu) bytes back into %lu bytes\n", + (unsigned long) *out_lenptr,out_len, (unsigned long) in_len ); + return 1; + } + + veejay_msg(VEEJAY_MSG_ERROR, "LZO (test) Decompression error: %d", r ); + + return 0; + +} + +#define LZO_ALIGN_SIZE(size) \ + ( ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ) * sizeof(lzo_align_t) void *lzo_new( ) { lzot *l = (lzot*) vj_calloc(sizeof(lzot)); if (lzo_init() != LZO_E_OK) { - veejay_msg(VEEJAY_MSG_ERROR, "Unable to initialize LZO. Could be buggy compiler"); + veejay_msg(VEEJAY_MSG_ERROR, "LZO Unable to initialize. Could be buggy compiler?"); free( l ); return NULL; } l->wrkmem = (lzo_bytep) - vj_calloc( LZO1X_1_MEM_COMPRESS ); + vj_calloc( LZO_ALIGN_SIZE( LZO1X_1_MEM_COMPRESS ) ); if(l->wrkmem == NULL ) { - veejay_msg(VEEJAY_MSG_ERROR, "Cannot allocate work memory for LZO1X_1"); + veejay_msg(VEEJAY_MSG_ERROR, "LZO Cannot allocate work memory for LZO1X_1"); if(l) free(l); return NULL; } - veejay_msg(VEEJAY_MSG_DEBUG,"LZO real-time data compression library (v%s, %s).", + + + +#ifdef STRICT_CHECKING + uint8_t in[16384]; + uint8_t out[16834]; + + memset( in, 1, sizeof(in) ); + memset( out, 0, sizeof(out)); + + int out_len = 0; + + int lzo_verify_compression_result = lzo_verify_compression( &in, sizeof(in), &out, &out_len, l->wrkmem ); + + assert( lzo_verify_compression_result == 1 ); + + if( lzo_verify_compression_result == 1 ) { + int i; + for( i = 0; i < sizeof(in); i ++ ) { + if( in[i] != 1 ) //decompression back into 'in' + veejay_msg(VEEJAY_MSG_ERROR, "LZO verify error at byte pos %d.", i ); + + assert( in[i] == 1 ); + } + + veejay_msg(VEEJAY_MSG_DEBUG, "LZO verified compression algorithms successfully."); + } +#endif + + + veejay_msg(VEEJAY_MSG_DEBUG,"LZO real-time data compression library (v%s, %s) enabled.", lzo_version_string(), lzo_version_date()); l->tmp[0] = NULL; @@ -86,24 +167,26 @@ static uint32_t str2ulong(unsigned char *str) return ( str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24) ); } -int lzo_compress( void *lzo, uint8_t *src, uint8_t *plane, unsigned int *size, int ilen ) +long lzo_compress( void *lzo, uint8_t *src, uint8_t *plane, unsigned int *size, int ilen ) { lzo_uint out_len =0; - lzo_uint len = ilen; + lzo_uint src_len = ilen; lzot *l = (lzot*) lzo; lzo_bytep dst = plane; - lzo_uintp dst_len = (lzo_uintp) size; lzo_voidp wrkmem = l->wrkmem; - int r = lzo1x_1_compress( src, len, dst, dst_len, wrkmem ); - if( r != LZO_E_OK ) - return 0; - - if( dst[0] == 2 && src[1] == dst[1] && src[2] == dst[2] && src[3] == dst[3] && r == 0 ) { - veejay_msg(0 , "compression failed. Reported at http://bugs.dyne.org #353 "); + int r = lzo1x_1_compress( src, src_len, dst, size, wrkmem ); + if( r != LZO_E_OK || r < 0 ) + { + veejay_msg(0, "LZO Compression error: %d", r ); return 0; } - return (*size); + long res = (long) (*size); +#ifdef STRICT_CHECKING + assert( res > 0 ); +#endif + + return res; } long lzo_decompress_el( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int uv_len) @@ -114,28 +197,27 @@ long lzo_decompress_el( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *ds unsigned int sum = 0; lzot *l = (lzot*) lzo; lzo_uint result_len = 0; - lzo_uint offset = 16; + lzo_uint offset = 12; + len[0] = str2ulong( linbuf ); len[1] = str2ulong( linbuf+4 ); len[2] = str2ulong( linbuf+8 ); - mode = str2ulong( linbuf+12 ); if(len[0] == 0 && len[1] == 0 ) { veejay_msg(VEEJAY_MSG_DEBUG, "%s", linbuf ); return -1; } - if(len[1] ==0 && len[2] == 0 ) - mode = 1; - for( i = 0; i < 3; i ++ ) { - if( len[i] <= 0 ) + if( len[i] <= 0 ) { continue; + } + const lzo_bytep src = (lzo_bytep) (linbuf+offset); - veejay_msg(0, "decompressing plane %d, size %d to %p... (%d,%d,%d) off=%d", i, len[i], linbuf+offset,len[0],len[1],len[2],offset ); + int r = lzo1x_decompress( src, len[i], dst[i], &result_len, l->wrkmem ); - if( r != LZO_E_OK ) + if( r != LZO_E_OK || r < 0 ) return 0; sum += result_len; offset += len[i]; @@ -143,11 +225,6 @@ long lzo_decompress_el( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *ds result_len = 0; } - if(mode == 1) { - vj_frame_clear1( dst[1],128, uv_len ); - vj_frame_clear1( dst[2],128, uv_len ); - } - return (long)sum; } @@ -168,7 +245,7 @@ long lzo_decompress( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3 mode = str2ulong( linbuf+12 ); if( len[0] != stride1 || len[1] != stride2 || len[2] != stride3 ) { - veejay_msg(0, "Data corruption."); + veejay_msg(0, "LZO received corrupted packet."); return 0; } @@ -184,8 +261,9 @@ long lzo_decompress( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3 if( len[i] <= 0 ) continue; - const lzo_bytep src = (lzo_bytep) (linbuf+offset); - int r = lzo1x_decompress( src, len[i], dst[i], &result_len, l->wrkmem ); + // const lzo_bytep src = (lzo_bytep) (linbuf+offset); + + int r = lzo1x_decompress( linbuf+offset, len[i], dst[i], &result_len, l->wrkmem ); if( r != LZO_E_OK ) return 0; sum += result_len; @@ -211,8 +289,8 @@ long lzo_decompress422into420( void *lzo, uint8_t *linbuf, int linbuf_len, uint int mode = 0; lzot *l = (lzot*) lzo; lzo_uint result_len = 0; - lzo_uint offset = 16; - + lzo_uint offset = 0; + /* len[0] = str2ulong( linbuf ); len[1] = str2ulong( linbuf+4 ); len[2] = str2ulong( linbuf+8 ); @@ -222,7 +300,7 @@ long lzo_decompress422into420( void *lzo, uint8_t *linbuf, int linbuf_len, uint veejay_msg(0, "Data corruption."); return 0; } - +*/ len[0] = stride1; len[1] = stride2; len[2] = stride3; @@ -275,13 +353,13 @@ long lzo_decompress420into422( void *lzo, uint8_t *linbuf, int linbuf_len, uint int mode= 0; lzot *l = (lzot*) lzo; lzo_uint result_len = 0; - lzo_uint offset = 16; - + lzo_uint offset = 0; +/* len[0] = str2ulong( linbuf ); len[1] = str2ulong( linbuf+4 ); len[2] = str2ulong( linbuf+8 ); mode = str2ulong( linbuf+12 ); - +*/ if( l->tmp[0] == NULL ) { l->tmp[0] = vj_malloc(sizeof(uint8_t) * w * h * 3); // will do l->tmp[1] = l->tmp[0] + ( w * h ); diff --git a/veejay-current/veejay-server/liblzo/lzo.h b/veejay-current/veejay-server/liblzo/lzo.h index 0f6edf05..19d6dfde 100644 --- a/veejay-current/veejay-server/liblzo/lzo.h +++ b/veejay-current/veejay-server/liblzo/lzo.h @@ -21,10 +21,9 @@ #define LZOH void *lzo_new( ); - +void lzo_print_buf( uint8_t *buf, int len ); void lzo_free( void *lzo ); - -int lzo_compress( void *lzo, uint8_t *src, uint8_t *plane, unsigned int *size, int ilen ); +long lzo_compress( void *lzo, uint8_t *src, uint8_t *plane, unsigned int *size, int ilen ); long lzo_decompress422into420( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h, uint32_t s1, uint32_t s2, uint32_t s3 ); long lzo_decompress420into422( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h ); diff --git a/veejay-current/veejay-server/libstream/vj-net.c b/veejay-current/veejay-server/libstream/vj-net.c index d05e1be2..58604adb 100644 --- a/veejay-current/veejay-server/libstream/vj-net.c +++ b/veejay-current/veejay-server/libstream/vj-net.c @@ -33,7 +33,9 @@ #include #include #include +#include +#define RUP8(num)(((num)+8)&~8) #ifdef STRICT_CHECKING #include @@ -54,6 +56,7 @@ typedef struct int in_h; int af; uint8_t *buf; + void *scaler; } threaded_t; #define STATE_INACTIVE 0 @@ -95,9 +98,6 @@ void *reader_thread(void *data) v->lzo = lzo_new(); success = vj_client_connect_dat( v, tag->source_name,tag->video_channel ); - - - t->buf = (uint8_t*) vj_calloc(sizeof(uint8_t) * 2048 * 1500 ); if( success > 0 ) { veejay_msg(VEEJAY_MSG_INFO, "Connecton established with %s:%d",tag->source_name, @@ -106,13 +106,16 @@ void *reader_thread(void *data) else if ( tag->source_type != VJ_TAG_TYPE_MCAST ) { veejay_msg(0, "Unable to connect to %s: %d", tag->source_name, tag->video_channel+5); - free(t->buf); pthread_exit(&(t->thread)); return NULL; } unsigned int optimistic = 1; unsigned int optimal = 8; + unsigned int bufsize = t->w * t->h * 4; + + t->buf = (uint8_t*) vj_calloc(sizeof(uint8_t) * RUP8( bufsize ) ); + for( ;; ) { @@ -186,8 +189,8 @@ void *reader_thread(void *data) { if(lock(t) != 0 ) //@ lock memory region to write goto NETTHREADEXIT; - - ret = vj_client_read_i ( v, t->buf,0 ); + + ret = vj_client_read_i ( v, t->buf,bufsize ); if( ret <= 0 ) { if( tag->source_type == VJ_TAG_TYPE_NET ) @@ -271,6 +274,8 @@ NETTHREADRETRY: vj_client_close(v); veejay_msg(VEEJAY_MSG_INFO, "Network thread with %s: %d was told to exit",tag->source_name,tag->video_channel+5); vj_client_free(v); + if( t->scaler ) + yuv_free_swscaler( t->scaler ); free(t->buf); pthread_exit( &(t->thread)); return NULL; @@ -281,6 +286,8 @@ NETTHREADEXIT: vj_client_close(v); veejay_msg(VEEJAY_MSG_INFO, "Network thread with %s: %d was aborted",tag->source_name,tag->video_channel+5); vj_client_free(v); + if( t->scaler ) + yuv_free_swscaler( t->scaler ); free(t->buf); pthread_exit( &(t->thread)); @@ -356,9 +363,19 @@ int net_thread_get_frame( vj_tag *tag, uint8_t *buffer[3] ) b = yuv_yuv_template( buffer[0],buffer[1], buffer[2],t->w,t->h,t->f); + if(lock(t) != 0) return 0; - yuv_convert_any_ac(a,b, a->format,b->format ); + + if( t->scaler == NULL ) { + sws_template sws_templ; + memset( &sws_templ, 0, sizeof(sws_template)); + sws_templ.flags = yuv_which_scaler(); + t->scaler = yuv_init_swscaler( a,b, &sws_templ, yuv_sws_get_cpu_flags() ); + } + + yuv_convert_and_scale( t->scaler, a,b ); + t->have_frame = 0; if(unlock(t)!=0) return 0; diff --git a/veejay-current/veejay-server/libvevo/libvevo.h b/veejay-current/veejay-server/libvevo/libvevo.h index a05d3ff3..93be06cd 100644 --- a/veejay-current/veejay-server/libvevo/libvevo.h +++ b/veejay-current/veejay-server/libvevo/libvevo.h @@ -119,6 +119,8 @@ int vevo_property_softref( void *port, const char *key ); int vevo_port_get_total_size( vevo_port_t *port ); +char **vevo_property_get_string_arr( vevo_port_t *p, const char *key ); + #define VEVO_ATOM_TYPE_FUNCPTR 11 #define VEVO_ATOM_TYPE_VOIDPTR 65 #define VEVO_ATOM_TYPE_INT 1 diff --git a/veejay-current/veejay-server/libvevo/vevo.c b/veejay-current/veejay-server/libvevo/vevo.c index c0a4513b..c79957e1 100644 --- a/veejay-current/veejay-server/libvevo/vevo.c +++ b/veejay-current/veejay-server/libvevo/vevo.c @@ -3531,6 +3531,29 @@ char *vevo_property_get_utf8string( void *port, const char *key ) return NULL; } +char **vevo_property_get_string_arr( vevo_port_t *p, const char *key ) +{ + int n = vevo_property_num_elements( p, key ); + if( n == 0 ) + return NULL; + char **retval = vj_malloc(sizeof(char*) * n ); + if( retval == NULL ) + return NULL; + int i; + for( i = 0; i < n ; i ++ ) { + retval[i] = vj_calloc( vevo_property_element_size(p,key,i) + 1 ); + int err = vevo_property_get( p, key, i, &retval[i] ); + if( err != VEVO_NO_ERROR ) { + for( -- i; i >= 0; i -- ) { + free( retval[i] ); + } + free(retval); + return NULL; + } + } + return retval; +} + int vevo_property_del(vevo_port_t * p, const char *key ) @@ -3948,3 +3971,39 @@ void vevo_dom_dump( void *p, FILE *file ) if( lvl == 0 ) fclose(file); }*/ + + +int vevo_write_xml( vevo_port_t *root, const char *destination, char *hiearchy[] ) +{ + char *encoding = "UTF-8"; + char **properties = vevo_list_properties( root ); + if( properties == NULL ) + return 0; +/* xmlNodePtr childnode; + xmlDocPtr doc = xmlNewDoc( "1.0" ); + xmlNodePtr rootnode = + xmlNewDocNode( doc, NULL , (const xmlChar*) hiearchy[0], NULL ); + xmlDocSetRootElement( doc, rootnode ); + + int i = 0; + int level = 1; + while( properties[i] != NULL ) + { + int atom_type = vevo_property_atom_type( root, properties[i] ); + void *port = NULL; + + childnode = xmlNewChild( rootnode, NULL, (const xmlChar*) + hierachy[ level ], NULL ); + vevo_property_get( port, properties[i], 0, &port ); + + + i++; + } + + xmlNodePtr childnode = xmlNewChild( rootnode, NULL, (const xmlChar*) "timeline", NULL ); +*/ + + return 1; + +} + diff --git a/veejay-current/veejay-server/libvjnet/cmd.c b/veejay-current/veejay-server/libvjnet/cmd.c index e8bb6230..8bfd2715 100644 --- a/veejay-current/veejay-server/libvjnet/cmd.c +++ b/veejay-current/veejay-server/libvjnet/cmd.c @@ -61,9 +61,9 @@ struct hostent *sock_gethostbyname(const char *name) { struct host_list *current = (struct host_list *) pthread_getspecific(ghbn_key); if (!current) { - current = (struct host_list *) calloc(1, sizeof(struct host_list)); + current = (struct host_list *) calloc(1, sizeof(struct host_list)); current->hostent.h_name = "busy"; - ref_count++; + ref_count++; pthread_setspecific(ghbn_key, current); } @@ -177,6 +177,7 @@ int sock_t_connect( vj_sock_t *s, char *host, int port ) } veejay_msg(VEEJAY_MSG_DEBUG, "Connected to host '%s' port %d, fd %d", host,port,s->sock_fd ); + veejay_msg(VEEJAY_MSG_DEBUG, "Receive buffer size is %d bytes, send buffer size is %d bytes", s->recv_size, s->send_size ); return 1; } @@ -240,7 +241,7 @@ static int timed_recv( int fd, void *buf, const int len, int timeout ) return -5; return recv( fd, buf, len, 0 ); -}*/ +} void sock_t_set_timeout( vj_sock_t *s, int t ) { @@ -248,30 +249,38 @@ void sock_t_set_timeout( vj_sock_t *s, int t ) setsockopt( s->sock_fd, SOL_SOCKET, SO_SNDTIMEO, (char*) &opt, sizeof(int)); setsockopt( s->sock_fd, SOL_SOCKET, SO_RCVTIMEO, (char*) &opt, sizeof(int)); } +*/ int sock_t_recv( vj_sock_t *s, void *dst, int len ) { int done = 0; - int bytes_left = s->recv_size; + int bytes_left = len; int n; + int bytes_done = 0; - if( len < bytes_left ) - bytes_left = len; - - while( done < len ) + while( bytes_left > 0 ) { +sock_t_recv_lbl: //@ setup socket with SO_RCVTIMEO - n = recv( s->sock_fd, dst+done,bytes_left, 0 ); + n = recv( s->sock_fd, dst + bytes_done, bytes_left, MSG_WAITALL ); if ( n <= 0 ) { - return -1; + if( n == -1 ) { + if( errno == EAGAIN ) { + veejay_msg(VEEJAY_MSG_ERROR, "Strange things happen in strange places. EAGAIN but socket is MSG_WAITALL"); + goto sock_t_recv_lbl; + + } + veejay_msg(0, "Error while receiving from network: %s", strerror(errno)); + } + + return n; } - - done += n; - - if( (len-done) < s->recv_size ) - bytes_left = len - done; + + bytes_done += n; + bytes_left -= n; } - return done; + + return bytes_done; } int sock_t_send( vj_sock_t *s, unsigned char *buf, int len ) @@ -305,6 +314,7 @@ int sock_t_send_fd( int fd, int send_size, unsigned char *buf, int len ) int n; #ifdef STRICT_CHECKING assert( buf != NULL ); + assert( len > 0 ); #endif unsigned int length = len; diff --git a/veejay-current/veejay-server/libvjnet/vj-client.c b/veejay-current/veejay-server/libvjnet/vj-client.c index 040de98c..c5d23329 100644 --- a/veejay-current/veejay-server/libvjnet/vj-client.c +++ b/veejay-current/veejay-server/libvjnet/vj-client.c @@ -53,8 +53,7 @@ vj_client *vj_client_alloc( int w, int h, int f ) { - vj_client *v = (vj_client*) malloc(sizeof(vj_client)); - memset(v, 0, sizeof(vj_client)); + vj_client *v = (vj_client*) vj_calloc(sizeof(vj_client)); if(!v) { return NULL; @@ -64,19 +63,13 @@ vj_client *vj_client_alloc( int w, int h, int f ) v->cur_width = w; v->cur_height = h; v->cur_fmt = get_ffmpeg_pixfmt(f); - v->space = NULL; - v->blob = (unsigned char*) malloc(sizeof(unsigned char) * PACKET_LEN ); + v->blob = (unsigned char*) vj_calloc(sizeof(unsigned char) * PACKET_LEN ); if(!v->blob ) { veejay_msg(0, "Memory allocation error."); free(v); return NULL; } - memset( v->blob,0,sizeof(unsigned char) * PACKET_LEN ); v->mcast = 0; - if( w > 0 && h > 0 ) { - v->space = (uint8_t*) malloc( sizeof(uint8_t) * w * h * 4 ); - memset(v->space,0,sizeof(uint8_t)*w*h*4); - } return v; } @@ -97,9 +90,7 @@ void vj_client_free(vj_client *v) if(v->blob) free(v->blob); if(v->lzo) - free(v->lzo); - if(v->space) - free(v->space); + lzo_free(v->lzo); free(v); v = NULL; } @@ -108,13 +99,13 @@ void vj_client_free(vj_client *v) #ifdef STRICT_CHECKING static int verify_integrity( char *buf, int len ) { if( len < 0 || buf == NULL ) { - veejay_msg(VEEJAY_MSG_DEBUG, "nothing to send"); + veejay_msg(VEEJAY_MSG_DEBUG, "Nothing to send"); return 0; } int i; for ( i = 0; i < len; i ++ ) { if( buf[i] == '\0' ) { - veejay_msg(VEEJAY_MSG_DEBUG, "end of string at pos %d, should have been pos %d", + veejay_msg(VEEJAY_MSG_DEBUG, "End of string at pos %d, should have been pos %d", i, len ); return 0; } @@ -268,14 +259,20 @@ int vj_client_poll( vj_client *v, int sock_type ) #endif } -static void vj_client_decompress( vj_client *t,uint8_t *in, uint8_t *out, int data_len, int Y, int UV , int header_len, +static long vj_client_decompress( vj_client *t,uint8_t *in, uint8_t *out, int data_len, int Y, int UV , int header_len, uint32_t s1, uint32_t s2, uint32_t s3) { - uint8_t *d[3] = { + uint8_t *dst[3] = { out, out + Y, out + Y + UV }; - lzo_decompress( t->lzo, ( in == NULL ? t->space: in ), data_len, d, UV,s1,s2,s3 ); + + + long total = lzo_decompress( t->lzo, ( in == NULL ? t->space: in ), data_len, dst, UV,s1,s2,s3 ); + if( total != (Y+UV+UV) ) + veejay_msg(0, "Error decompressing: expected %d bytes got %d.", (Y+UV+UV),total); + + return total; } static uint32_t getint(uint8_t *in, int len ) { @@ -340,11 +337,11 @@ static int vj_client_parse_salsaman( vj_client *v,uint8_t *partial_header, int p static int vj_client_packet_negotiate( vj_client *v, int *tokens ) { - uint8_t line[45]; + uint8_t line[44]; - //@ 1. read 44 bytes and see if its us veejay_memset( line,0, sizeof(line)); int plen = sock_t_recv( v->fd[0], line, 44 ); + if( plen == 0 ) { veejay_msg(VEEJAY_MSG_DEBUG, "Remote closed connection."); return -1; @@ -356,35 +353,32 @@ static int vj_client_packet_negotiate( vj_client *v, int *tokens ) return -1; } - //@ there is 44 bytes read, identify producer software here, - //@ the function below parses the header in LiVES - /* - int res = vj_client_parse_salsaman( v, line, 44, tokens ); - if( res == 0 ) { - veejay_msg(0, "Error parsing salsaman header!"); - return -1; - } + int n = sscanf( line, "%04d%04d%04d%08d%08d%08d%08d", + &tokens[0], + &tokens[1], + &tokens[2], + + &tokens[3], + &tokens[4], + &tokens[5], + &tokens[6]); + + if( n != 7 ) { + veejay_msg(0, "Unable to parse header data: '%s'", line ); return 0; - */ - - - - // default: packet is from veejay - tokens[0] = getint( line , 4 ); - tokens[1] = getint( line + 4, 4 ); - tokens[2] = getint( line + 8, 4 ); - tokens[3] = getint( line + 12, 8 ); - - tokens[4] = getint( line + 12 + 8, 8 ); - tokens[5] = getint( line + 12 + 16, 8 ); - tokens[6] = getint( line + 12 + 24, 8 ); + } + if( tokens[3] > 0 ) { + if( v->lzo == NULL ) { + v->lzo = lzo_new(); + } + } return 1; } -int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) +int vj_client_read_i( vj_client *v, uint8_t *dst, int dstlen ) { uint8_t line[128]; uint32_t p[4] = {0, 0,0,0 }; @@ -397,6 +391,9 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) int conv = 1; int y_len = 0; int uv_len = 0; + + memset( tokens,0,sizeof(tokens)); + if( v->mcast == 1) { uint8_t *in = mcast_recv_frame( v->r, &p[0],&p[1], &p[2], &plen ); @@ -419,15 +416,17 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) case PIX_FMT_YUVJ420P: uv_len = y_len / 4;break; default: - veejay_msg(VEEJAY_MSG_ERROR, "Unknown data format: %02x", v->in_fmt); + uv_len = y_len; break; + veejay_msg(VEEJAY_MSG_WARNING, "Unknown data format: %02x, assuming equal plane sizes."); break; } - + strides[0] = getint( in + 12 + 8, 8 ); strides[1] = getint( in + 12 + 16, 8 ); strides[2] = getint( in + 12 + 24, 8 ); - vj_client_decompress( v,in, dst, p[3], y_len, uv_len , plen, strides[0],strides[1],strides[2]); + if( vj_client_decompress( v,in, dst, plen, y_len, uv_len , plen, strides[0],strides[1],strides[2]) == 0 ) + return 0; if( p[0] != v->cur_width || p[1] != v->cur_height ) return 2; @@ -439,74 +438,37 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) { //@ result returns software package id int result = vj_client_packet_negotiate( v, tokens ); - if( result == 0 ) { //@ ids are out of thin air - - //@ header is from lives - /* - if( v->cur_width != tokens[ SALSAMAN_VSIZE ] || v->cur_height != tokens[SALSAMAN_HSIZE] ) { - //@ no changing of sizes on the fly - veejay_msg(VEEJAY_MSG_ERROR, "Unexpected video frame format"); - int n; - for( n = 0;n < 16; n ++ ) { - veejay_msg(VEEJAY_MSG_DEBUG, "%d: [%d] %02x ", n,tokens[n],tokens[n]); - } - return 0; - } + if( result == 0 ) { + veejay_msg(0, "Unable to read frame header."); + return -1; + } + p[0] = tokens[0]; //w + p[1] = tokens[1]; //h + p[2] = tokens[2]; //fmt + p[3] = tokens[3]; //compr len + strides[0] = tokens[4]; // 0 + strides[1] = tokens[5]; // 1 + strides[2] = tokens[6]; // 2 - //@ read information from the header and figure out which pixelformat it is - v->in_fmt = weed_palette2_pixfmt( tokens[SALSAMAN_PALETTE] , tokens[SALSAMAN_SUBSPACE ] ); - if( v->in_fmt == -1 ) { - veejay_msg(VEEJAY_MSG_ERROR, "No support for weed palette %d", tokens[SALSAMAN_PALETTE]); - return 0; - } - - //@ assign required values for veejay (format,width,height) - v->in_width = tokens[SALSAMAN_VSIZE]; - v->in_height= tokens[SALSAMAN_HSIZE]; - - //@ start reading rest of frame, assuming size is given by SALSAMAN_DATASIZE - int n = sock_t_recv( v->c[0]->fd,v->space, tokens[SALSAMAN_DATASIZE] ); - if( n <= 0 ) { - if( n == -1 ) { - veejay_msg(VEEJAY_MSG_ERROR, "Error '%s' while reading socket", strerror(errno)); - } else { - veejay_msg(VEEJAY_MSG_DEBUG,"Remote closed connection"); - } + v->in_width = p[0]; + v->in_height = p[1]; + v->in_fmt = p[2]; + + if( v->space == NULL || v->in_width != v->orig_width || v->in_height != v->orig_height ) { + if( v->space ) free(v->space); + v->space = vj_calloc(sizeof(uint8_t) * v->in_width * v->in_height * 4 ); + if(!v->space) { + veejay_msg(0,"Could not allocate memory for network stream."); return -1; } - //@ ready - //@ vj-net.c + v->orig_width = v->in_width; + v->orig_height = v->in_height; + } - //@ returning 2 means caller will scale - return 2; - */ - return 0; - } else if ( result == 1 ) { - //@ header is veejay - p[0] = tokens[0]; - p[1] = tokens[1]; - p[2] = tokens[2]; - p[3] = tokens[3]; - strides[0] = tokens[4]; - strides[1] = tokens[5]; - strides[2] = tokens[6]; - - v->in_width = p[0]; - v->in_height = p[1]; - v->in_fmt = p[2]; - - if( v->in_width != v->orig_width || v->in_height != v->orig_height ) { - free(v->space); - v->space = vj_calloc(sizeof(uint8_t) * v->in_width * v->in_height * 4 ); - if(!v->space) - return -1; - v->orig_width = v->in_width; - v->orig_height = v->in_height; - } - - uv_len = 0; - y_len = p[0] * p[1]; + uv_len = 0; + y_len = p[0] * p[1]; + if( p[3] > 0 ) { switch(v->in_fmt ) //@ veejay is sending compressed YUV data, calculate UV size { case PIX_FMT_YUV422P: @@ -517,11 +479,17 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) case PIX_FMT_YUVJ420P: uv_len = y_len / 4;break; default: - veejay_msg(VEEJAY_MSG_ERROR, "Unknown data format: %02x", v->in_fmt); + uv_len = y_len; + veejay_msg(VEEJAY_MSG_WARNING, "Unknown data format: %02x, assuming equal plane sizes.", v->in_fmt); break; } int n = sock_t_recv( v->fd[0],v->space,p[3] ); +#ifdef STRICT_CHECKING + if( n > 0 ) assert( n == p[3] ); + if( p[3] > 0 ) assert( p[3] == (16 + strides[0] + strides[1] + strides[2]) ); +#endif + if( n <= 0 ) { if( n == -1 ) { veejay_msg(VEEJAY_MSG_ERROR, "Error '%s' while reading socket", strerror(errno)); @@ -538,11 +506,32 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) } //@ decompress YUV buffer - vj_client_decompress( v,NULL, dst, p[3], y_len, uv_len , plen, strides[0],strides[1],strides[2]); + vj_client_decompress( v,v->space, dst, p[3], y_len, uv_len , 0, strides[0],strides[1],strides[2]); + + if( v->in_fmt == v->cur_fmt && v->cur_width == p[0] && v->cur_height == p[1] ) + return 1; return 2; //@ caller will scale frame in dst } else { - return 0; + + int i,n; + for( i = 0;i < 3; i ++ ) { + if( strides[i] == 0 ) + continue; + + n = sock_t_recv( v->fd[0], dst[i], strides[i] ); + if( n != strides[i] ) { + veejay_msg(0, "Error receiving packet"); + return -1; + } + } + + if( v->in_fmt == v->cur_fmt && v->cur_width == p[0] && v->cur_height == p[1] ) + return 1; + + + return 2; + } return 0; @@ -553,26 +542,12 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int len ) int vj_client_read_no_wait(vj_client *v, int sock_type, uint8_t *dst, int bytes ) { -#ifdef STRICT_CHECKING - int n = sock_t_recv( v->fd[ sock_type ] ,dst, bytes ); - veejay_msg(VEEJAY_MSG_DEBUG, "%s: type %d, socket %p: %d bytes [%s]", - __FUNCTION__, sock_type, v->fd[sock_type], bytes, dst ); - return n; -#else return sock_t_recv( v->fd[ sock_type ], dst, bytes ); -#endif } int vj_client_read(vj_client *v, int sock_type, uint8_t *dst, int bytes ) { -#ifndef STRICT_CHECKING return sock_t_recv( v->fd[ sock_type ], dst, bytes ); -#else - int n = sock_t_recv( v->fd[ sock_type ], dst, bytes ); - veejay_msg(VEEJAY_MSG_DEBUG, "type %d, read %d bytes '[%s]' from socket %p (port %d)", - sock_type, bytes, dst, v->fd[sock_type], v->ports[ sock_type] ); - return n; -#endif } int vj_client_send_buf(vj_client *v, int sock_type,unsigned char *buf, int len) { diff --git a/veejay-current/veejay-server/libvjnet/vj-server.c b/veejay-current/veejay-server/libvjnet/vj-server.c index 42d33d5e..ee853bbc 100644 --- a/veejay-current/veejay-server/libvjnet/vj-server.c +++ b/veejay-current/veejay-server/libvjnet/vj-server.c @@ -63,7 +63,7 @@ typedef struct int type; } vj_proto; -#define VJ_MAX_PENDING_MSG 128 +#define VJ_MAX_PENDING_MSG 768 #define RECV_SIZE (4096) #ifdef STRICT_CHECKING static void printbuf( FILE *f, uint8_t *buf , int len ) @@ -207,7 +207,7 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) return 0; } - if (setsockopt( vjs->handle, SOL_SOCKET, SO_REUSEADDR, (const char*) &on, sizeof(on) )== -1) + if (setsockopt( vjs->handle, SOL_SOCKET, SO_REUSEADDR, (const char*) &on, sizeof(on) )== -1) { veejay_msg(VEEJAY_MSG_ERROR, "%s", strerror(errno)); return 0; @@ -222,12 +222,14 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) port_num = port_offset + VJ_STA_PORT; vjs->myself.sin_port = htons(port_num); - veejay_memset(&(vjs->myself.sin_zero), 0, 8); + veejay_memset(&(vjs->myself.sin_zero), 0, sizeof(vjs->myself.sin_zero)); + if (bind(vjs->handle, (struct sockaddr *) &(vjs->myself), sizeof(vjs->myself) ) == -1 ) { veejay_msg(VEEJAY_MSG_ERROR, "%s", strerror(errno)); return 0; } + if (listen(vjs->handle, VJ_MAX_CONNECTIONS) == -1) { veejay_msg(VEEJAY_MSG_ERROR, "%s", strerror(errno)); @@ -273,6 +275,8 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) } #endif + veejay_msg(VEEJAY_MSG_DEBUG, "Port: %d [ receive buffer is %d bytes, send buffer is %d bytes ]", port_num, vjs->recv_size, vjs->send_size ); + int flag = 1; if( setsockopt( vjs->handle, IPPROTO_TCP, TCP_NODELAY, (char*) &flag, sizeof(int)) == -1 ) { @@ -283,7 +287,7 @@ static int _vj_server_classic(vj_server *vjs, int port_offset) link = (vj_link **) vj_malloc(sizeof(vj_link *) * VJ_MAX_CONNECTIONS); if(!link) { - veejay_msg(VEEJAY_MSG_ERROR, "Out of memory"); + veejay_msg(VEEJAY_MSG_ERROR, "Server: Out of memory"); return 0; } @@ -343,11 +347,25 @@ vj_server *vj_server_alloc(int port_offset, char *mcast_group_name, int type) vjs->recv_buf = (char*) vj_calloc(sizeof(char) * vjs->recv_bufsize); if(!vjs->recv_buf) { - if(vjs) free(vjs); + free(vjs); return NULL; } vjs->server_type = type; + + char *str_rbufsize = getenv( "VEEJAY_SERVER_RECEIVE_BUFFER_SIZE" ); + if( str_rbufsize != NULL ) { + vjs->recv_bufsize = atoi( str_rbufsize ); + free(vjs->recv_buf); + vjs->recv_buf = (char*) vj_calloc(sizeof(char) * vjs->recv_bufsize ); + if( vjs->recv_buf == NULL ) { + free(vjs); + return NULL; + } + veejay_msg(VEEJAY_MSG_INFO, "Changed receive buffer size to %d bytes (%2.2fKb)", + vjs->recv_bufsize, (float) vjs->recv_bufsize / 1024.0f ); + } + #ifdef STRICT_CHECKING char *netlog = getenv("VEEJAY_LOG_NET_IO" ); @@ -361,7 +379,7 @@ vj_server *vj_server_alloc(int port_offset, char *mcast_group_name, int type) } else { fprintf( vjs->logfd, "Server setup: port %d, name %s type %d\n", port_offset,mcast_group_name,type); - fprintf( vjs->logfd, "receive buffer size: %d bytes\n", RECV_SIZE); + fprintf( vjs->logfd, "receive buffer size: %d bytes\n", vjs->recv_bufsize); } } #endif @@ -381,7 +399,7 @@ vj_server *vj_server_alloc(int port_offset, char *mcast_group_name, int type) return vjs; } - return NULL; + return NULL; } @@ -516,7 +534,7 @@ int vj_server_send_frame( vj_server *vje, int link_id, uint8_t *buf, int len, { return vj_server_send_frame_now( vje, link_id, buf, len ); } else { - veejay_msg(VEEJAY_MSG_DEBUG, "Link %d's socket not ready for immediate send: %s", link_id, strerror(errno)); + veejay_msg(VEEJAY_MSG_ERROR, "Link %d's socket not ready for immediate send: %s", link_id, strerror(errno)); } return 0; } @@ -845,11 +863,11 @@ static int _vj_parse_msg(vj_server *vje,int link_id, char *buf, int buf_len ) num_msg++; } - if(num_msg >= (VJ_MAX_PENDING_MSG-1) ) + if(num_msg >= VJ_MAX_PENDING_MSG ) { veejay_msg(VEEJAY_MSG_ERROR, "VIMS server queue full - got %d/%d messages.", num_msg,VJ_MAX_PENDING_MSG ); - return VJ_MAX_PENDING_MSG-1; // cant take more + return VJ_MAX_PENDING_MSG; // cant take more } i += ( 5 + slen); @@ -973,7 +991,7 @@ int vj_server_update( vj_server *vje, int id ) if( *ptr == 'V' || *ptr == 'K' || *ptr == 'D' ) { ptr ++; readmore_lbl: - n = recv( sock_fd, ptr, RECV_SIZE, 0 ); + n = recv( sock_fd, ptr, RECV_SIZE, 0 ); //@ read 4 kb if( n == - 1) { if( errno == EAGAIN ) { goto readmore_lbl; @@ -981,7 +999,7 @@ readmore_lbl: veejay_msg( 0, "Error: %s", strerror(errno) ); bytes_received = -1; } - if( n == RECV_SIZE && errno == EAGAIN) + if( n == RECV_SIZE && errno == EAGAIN) //@ read 4kb, but still data left { // deal with large messages ptr += n; bytes_received += n; @@ -1050,7 +1068,7 @@ readmore_lbl: } return nn; } else { - veejay_msg(VEEJAY_MSG_ERROR, "Too many messages in queue. Abort client"); + veejay_msg(VEEJAY_MSG_ERROR, "Queue too small to handle all VIMS messages."); return -1; } return 0; diff --git a/veejay-current/veejay-server/veejay/vj-event.c b/veejay-current/veejay-server/veejay/vj-event.c index 20e5d815..a529fa56 100644 --- a/veejay-current/veejay-server/veejay/vj-event.c +++ b/veejay-current/veejay-server/veejay/vj-event.c @@ -10554,6 +10554,7 @@ void vj_event_set_macro_status( void *ptr, const char format[], va_list ap ) else { veejay_msg(VEEJAY_MSG_INFO, "No keystrokes to playback!"); + veejay_msg(VEEJAY_MSG_INFO, "Use CAPS-LOCK modifier to jump to next or previous sample."); } } else if ( args[0] == 3 ) diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index 67c2ccb7..9657aa74 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -1072,7 +1072,7 @@ void vj_perform_init_output_frame( veejay_t *info, uint8_t **frame, } -static void long2str(unsigned char *dst, int32_t n) +static void long2str(uint8_t *dst, uint32_t n) { dst[0] = (n )&0xff; dst[1] = (n>> 8)&0xff; @@ -1080,63 +1080,56 @@ static void long2str(unsigned char *dst, int32_t n) dst[3] = (n>>24)&0xff; } -static int vj_perform_compress_frame( veejay_t *info, uint8_t *dst, uint32_t *p1_len, uint32_t *p2_len, uint32_t *p3_len) +static uint32_t vj_perform_compress_frame( veejay_t *info, uint8_t *dst, uint32_t *p1_len, uint32_t *p2_len, uint32_t *p3_len) { const int len = info->effect_frame1->width * info->effect_frame1->height; const int uv_len = info->effect_frame1->uv_len; - uint8_t *dstI = dst + (sizeof(uint8_t) * 16); - unsigned int size1=0,size2=0,size3=0; - int i = lzo_compress( lzo_ , primary_buffer[info->out_buf]->Y, dstI, &size1, len ); + uint8_t *dstI = dst + 16; + + int i = lzo_compress( lzo_ , primary_buffer[info->out_buf]->Y, dstI, p1_len, len ); if( i == 0 ) { veejay_msg(VEEJAY_MSG_ERROR, "Unable to compress Y plane"); -#ifdef STRICT_CHECKING - assert(0); -#endif return 0; } - dstI += size1; - *p1_len = size1; - - if( info->settings->mcast_mode == 1 ) { - //@ only compress Y plane, set mode in header - /* long2str( dst,size1); - long2str( dst+4,0); - long2str( dst+8,0); - long2str( dst+12, info->settings->mcast_mode );*/ - return size1; - } - - i = lzo_compress( lzo_, primary_buffer[info->out_buf]->Cb, dstI, &size2, uv_len ); + uint32_t size1 = ( *p1_len ); +#ifdef STRICT_CHECKING + assert(size1>0); +#endif + dstI = dst + 16 + (sizeof(uint8_t) * size1 ); + + i = lzo_compress( lzo_, primary_buffer[info->out_buf]->Cb, dstI, p2_len, uv_len ); if( i == 0 ) { veejay_msg(VEEJAY_MSG_ERROR, "Unable to compress U plane"); -#ifdef STRICT_CHECKING - assert(0); -#endif return 0; } - dstI += size2; - *p2_len = size2; - i = lzo_compress( lzo_, primary_buffer[info->out_buf]->Cr, dstI, &size3, uv_len ); + uint32_t size2 = ( *p2_len ); +#ifdef STRICT_CHECKING + assert( size2 > 0); +#endif + dstI = dst + 16 + size1 + size2; + + i = lzo_compress( lzo_, primary_buffer[info->out_buf]->Cr, dstI, p3_len, uv_len ); if( i == 0 ) { veejay_msg(VEEJAY_MSG_ERROR, "Unable to compress V plane"); -#ifdef STRICT_CHECKING - assert(0); -#endif return 0; } - *p3_len = size3; + uint32_t size3 = ( *p3_len ); + +#ifdef STRICT_CHECKING + assert( size3 > 0 ); +#endif long2str( dst,size1); long2str( dst+4, size2 ); long2str( dst+8, size3 ); long2str( dst+12,info->settings->mcast_mode ); - return (size1+size2+size3+16); + return 1; } void vj_perform_done_s2( veejay_t *info ) { @@ -1148,47 +1141,61 @@ void vj_perform_done_s2( veejay_t *info ) { int vj_perform_send_primary_frame_s2(veejay_t *info, int mcast, int to_mcast_link_id) { unsigned char info_line[128]; - - int compr_len = 0; + int compr_ok = 0; uint32_t planes[3]; - const int data_len = 44; + int data_len = 44; memset(info_line, 0, sizeof(info_line) ); if(socket_buffer == NULL ) - socket_buffer = vj_malloc( RUP8( info->effect_frame1->width * info->effect_frame1->height )); + socket_buffer = vj_malloc( + RUP8( info->effect_frame1->width * info->effect_frame1->height * 3 ) + ); uint8_t *sbuf = socket_buffer + (sizeof(uint8_t) * data_len ); if( sbic == 0 ) { - compr_len = vj_perform_compress_frame(info,sbuf, &planes[0], &planes[1], &planes[2]); -#ifdef STRICT_CHECKING - assert( compr_len > 0 ); -#endif + compr_ok = vj_perform_compress_frame(info,sbuf, &planes[0], &planes[1], &planes[2]); + int total = planes[0] + planes[1] + planes[2] + 16; + if( compr_ok == 0 ) { + planes[0] = info->effect_frame1->width * info->effect_frame1->height; + planes[1] = info->effect_frame1->uv_len; + planes[2] = planes[1]; + veejay_msg(VEEJAY_MSG_WARNING, "Failed to compress frame, sending raw planes: [%d,%d,%d]", + planes[0],planes[1],planes[2] ); + total = 0; + } sbic = 1; /* peer to peer connection */ - snprintf(info_line, - data_len + 1, //@ '\0' counts - "%04d%04d%04d%08d%08d%08d%08d", info->effect_frame1->width, - info->effect_frame1->height, info->effect_frame1->format, - compr_len,planes[0],planes[1],planes[2] ); - - veejay_memcpy( socket_buffer, info_line, sizeof(uint8_t) * data_len ); + sprintf(info_line, + "%04d%04d%04d%08d%08d%08d%08d", + info->effect_frame1->width, + info->effect_frame1-> + height,info->effect_frame1->format, + total, + planes[0], + planes[1], + planes[2] ); + + + veejay_memcpy( socket_buffer, info_line, 44 ); + if( compr_ok == 0 ) + { + veejay_memcpy( socket_buffer + 44 , primary_buffer[info->out_buf]->Y, info->effect_frame1->len ); + veejay_memcpy( socket_buffer + 44 + info->effect_frame1->len, + primary_buffer[info->out_buf]->Cb, info->effect_frame1->uv_len ); + veejay_memcpy( socket_buffer + 44 + info->effect_frame1->len + info->effect_frame1->uv_len, + primary_buffer[info->out_buf]->Cr, info->effect_frame1->uv_len ); + data_len += 16 + info->effect_frame1->len + (info->effect_frame1->uv_len * 2); + } else { + data_len += 16 + planes[0] + planes[1] + planes[2]; + } } int id = (mcast ? 2: 3); - int __socket_len = data_len + compr_len; + int __socket_len = data_len; int i; -#ifdef STRICT_CHECKING - for( i = 0; i < 8 ; i++ ) { - if( info->rlinks[i] != -1 ) { - veejay_msg(VEEJAY_MSG_DEBUG, "Send cached frame to link %d now", - info->rlinks[i]); - } - } -#endif - if(!mcast) { for( i = 0; i < 8 ; i++ ) { From 5e30587c6a8626dafa43a2917408217f743e636c Mon Sep 17 00:00:00 2001 From: niels Date: Fri, 17 May 2013 19:13:55 +0200 Subject: [PATCH 07/32] clean up lzo, fix warnings --- veejay-current/veejay-server/liblzo/lzo.c | 106 ++++------------------ veejay-current/veejay-server/liblzo/lzo.h | 14 +-- 2 files changed, 21 insertions(+), 99 deletions(-) diff --git a/veejay-current/veejay-server/liblzo/lzo.c b/veejay-current/veejay-server/liblzo/lzo.c index ff821906..27fe0a48 100644 --- a/veejay-current/veejay-server/liblzo/lzo.c +++ b/veejay-current/veejay-server/liblzo/lzo.c @@ -68,9 +68,9 @@ void lzo_print_buf( uint8_t *buf, int len ) printf("\n"); } */ -static int lzo_verify_compression(uint8_t *in, int in_len, uint8_t *out , int *out_lenptr, uint8_t *wrkmem) +static int lzo_verify_compression(uint8_t *in, int in_len, uint8_t *out , lzo_uint *out_lenptr, uint8_t *wrkmem) { - int out_len = 0; + lzo_uint out_len = 0; int r = lzo1x_1_compress( in, in_len, out, &out_len, wrkmem ); if( r == LZO_E_OK ) { veejay_msg(VEEJAY_MSG_DEBUG, "LZO (test) Compressed %lu bytes into %lu bytes\n", @@ -86,7 +86,7 @@ static int lzo_verify_compression(uint8_t *in, int in_len, uint8_t *out , int *o return 0; } - int new_len = in_len; + lzo_uint new_len = in_len; r = lzo1x_decompress( out, out_len, in, &new_len, NULL ); if( r == LZO_E_OK && new_len == in_len ) { veejay_msg(VEEJAY_MSG_DEBUG, "LZO (test) Decompressed %lu (%lu) bytes back into %lu bytes\n", @@ -129,12 +129,14 @@ void *lzo_new( ) uint8_t in[16384]; uint8_t out[16834]; - memset( in, 1, sizeof(in) ); - memset( out, 0, sizeof(out)); + veejay_memset( in, 1, sizeof(in) ); + veejay_memset( out, 0, sizeof(out)); - int out_len = 0; + lzo_bytep inp = (lzo_bytep) &in[0]; + lzo_bytep outp = (lzo_bytep) &out[0]; - int lzo_verify_compression_result = lzo_verify_compression( &in, sizeof(in), &out, &out_len, l->wrkmem ); + lzo_uint out_len = 0; + int lzo_verify_compression_result = lzo_verify_compression( inp, sizeof(in), outp, &out_len, l->wrkmem ); assert( lzo_verify_compression_result == 1 ); @@ -174,7 +176,7 @@ long lzo_compress( void *lzo, uint8_t *src, uint8_t *plane, unsigned int *size, lzot *l = (lzot*) lzo; lzo_bytep dst = plane; lzo_voidp wrkmem = l->wrkmem; - int r = lzo1x_1_compress( src, src_len, dst, size, wrkmem ); + int r = lzo1x_1_compress( src, src_len, dst, (lzo_uint*) size, wrkmem ); if( r != LZO_E_OK || r < 0 ) { veejay_msg(0, "LZO Compression error: %d", r ); @@ -273,100 +275,33 @@ long lzo_decompress( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3 } if(mode == 1) { - vj_frame_clear1( dst[1],128, uv_len ); - vj_frame_clear1( dst[2],128, uv_len ); + veejay_memset( dst[1], 128, uv_len ); + veejay_memset( dst[2], 128, uv_len ); } return (long)sum; } -long lzo_decompress422into420( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h, - uint32_t stride1, uint32_t stride2, uint32_t stride3 ) -{ - int i; - lzo_uint len[3] = { 0,0,0}; - int sum = 0; - int mode = 0; - lzot *l = (lzot*) lzo; - lzo_uint result_len = 0; - lzo_uint offset = 0; - /* - len[0] = str2ulong( linbuf ); - len[1] = str2ulong( linbuf+4 ); - len[2] = str2ulong( linbuf+8 ); - mode = str2ulong( linbuf+12 ); - - if( len[0] != stride1 || len[1] != stride2 || len[2] != stride3 ) { - veejay_msg(0, "Data corruption."); - return 0; - } -*/ - len[0] = stride1; - len[1] = stride2; - len[2] = stride3; - -/* - len[0] = str2ulong( linbuf ); - len[1] = str2ulong( linbuf+4 ); - len[2] = str2ulong( linbuf+8 ); - mode = str2ulong( linbuf+12 ); -*/ - - if(len[1] ==0 && len[2] == 0 ) - mode = 1; - - - - if( l->tmp[0] == NULL ) { - l->tmp[0] = vj_malloc(sizeof(uint8_t) * w * h * 3); // will do - l->tmp[1] = l->tmp[0] + w * h; - l->tmp[2] = l->tmp[1] + ( (w>>1)*h); - } - - for( i = 0; i <= 2; i ++ ) - { - if(len[i] <= 0) - continue; - - const lzo_bytep src = (lzo_bytep) (linbuf+offset); - int r = lzo1x_decompress( src, len[i], l->tmp[i], &result_len, l->wrkmem ); - if( r != LZO_E_OK ) - return 0; - sum += result_len; - offset += len[i]; - } - - vj_frame_copy1( l->tmp[0], dst[0], w*h); - if( mode == 1 ) { - vj_frame_clear1(dst[1],128,( (w>>1)*h)); - vj_frame_clear1(dst[2],128,( (w>>1)*h)); - } else { - yuv422to420planar( l->tmp, dst, w, h ); - } - return (long)sum; -} long lzo_decompress420into422( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h ) { int i; lzo_uint len[3] = { 0,0,0}; int sum = 0; - int mode= 0; lzot *l = (lzot*) lzo; lzo_uint result_len = 0; lzo_uint offset = 0; -/* + len[0] = str2ulong( linbuf ); len[1] = str2ulong( linbuf+4 ); len[2] = str2ulong( linbuf+8 ); - mode = str2ulong( linbuf+12 ); -*/ + if( l->tmp[0] == NULL ) { - l->tmp[0] = vj_malloc(sizeof(uint8_t) * w * h * 3); // will do + l->tmp[0] = vj_malloc(sizeof(uint8_t) * w * h * 2); // will do l->tmp[1] = l->tmp[0] + ( w * h ); l->tmp[2] = l->tmp[1] + ( (w>>1) * (h>>1)); } - for( i = 0; i <= 2; i ++ ) + for( i = 0; i < 3; i ++ ) { if( len[i] <= 0 ) continue; @@ -379,13 +314,8 @@ long lzo_decompress420into422( void *lzo, uint8_t *linbuf, int linbuf_len, uint } vj_frame_copy1( l->tmp[0], dst[0], w*h); - if(mode == 1) { - vj_frame_clear1(dst[1],128,( (w>>1)*h)); - vj_frame_clear1(dst[2],128,( (w>>1)*h)); - } - else { - yuv420to422planar( l->tmp, dst, w, h ); - } + yuv420to422planar( l->tmp, dst, w, h ); + return (long)sum; } diff --git a/veejay-current/veejay-server/liblzo/lzo.h b/veejay-current/veejay-server/liblzo/lzo.h index 19d6dfde..a9bb5020 100644 --- a/veejay-current/veejay-server/liblzo/lzo.h +++ b/veejay-current/veejay-server/liblzo/lzo.h @@ -24,16 +24,8 @@ void *lzo_new( ); void lzo_print_buf( uint8_t *buf, int len ); void lzo_free( void *lzo ); long lzo_compress( void *lzo, uint8_t *src, uint8_t *plane, unsigned int *size, int ilen ); -long lzo_decompress422into420( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h, - uint32_t s1, uint32_t s2, uint32_t s3 ); -long lzo_decompress420into422( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h ); - - -long lzo_decompress2( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst ); - -long lzo_decompress_el( void *lzo, uint8_t *linbuf, int linbuf_len,uint8_t *dst[3], int uv_len); - -long lzo_decompress( void *lzo, uint8_t *linbuf, int linbuf_len,uint8_t *dst[3], int uv_len, - uint32_t s1, uint32_t s2, uint32_t s3 ); +long lzo_decompress420into422( void *lzo, uint8_t *linbuf, int linbuf_len, uint8_t *dst[3], int w, int h ); +long lzo_decompress_el( void *lzo, uint8_t *linbuf, int linbuf_len,uint8_t *dst[3], int uv_len); +long lzo_decompress( void *lzo, uint8_t *linbuf, int linbuf_len,uint8_t *dst[3], int uv_len, uint32_t s1, uint32_t s2, uint32_t s3 ); #endif From 7364f891a1ab237a328c97e54339a660fcc3d999 Mon Sep 17 00:00:00 2001 From: niels Date: Fri, 17 May 2013 22:43:15 +0200 Subject: [PATCH 08/32] dump plugin info on activate if compiled with strict checking - fixed possible crash on plug_activate on 64 bit systems (all plugin types) - deprecate duplicate function - libvevo supports wider keys on 64 bits systems - fix bug in fallback method network frame send - smaller cosmetic fixes - --- .../veejay-server/libplugger/frei0r-loader.c | 9 +- .../veejay-server/libplugger/livido-loader.c | 4 +- .../veejay-server/libplugger/plugload.c | 54 ++++++---- .../veejay-server/libplugger/utility.c | 28 +++--- .../veejay-server/libplugger/utility.h | 4 +- .../veejay-server/libsample/sampleadm.c | 10 +- .../veejay-server/libstream/vj-tag.c | 36 +++---- veejay-current/veejay-server/libvevo/vevo.c | 98 +++++++++++-------- .../veejay-server/libvje/effects/diff.c | 2 +- .../veejay-server/libvjmsg/vj-common.c | 10 +- .../veejay-server/libvjnet/mcastreceiver.c | 1 + .../veejay-server/libvjnet/vj-client.c | 19 ++-- veejay-current/veejay-server/libyuv/yuvconv.c | 8 +- .../veejay-server/livido-plugins/lvd_shmin.c | 4 +- .../veejay-server/veejay/vj-event.c | 4 +- veejay-current/veejay-server/veejay/vj-shm.c | 3 +- 16 files changed, 158 insertions(+), 136 deletions(-) diff --git a/veejay-current/veejay-server/libplugger/frei0r-loader.c b/veejay-current/veejay-server/libplugger/frei0r-loader.c index e6f11c89..eacc35c4 100644 --- a/veejay-current/veejay-server/libplugger/frei0r-loader.c +++ b/veejay-current/veejay-server/libplugger/frei0r-loader.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef STRICT_CHECKING #include @@ -366,7 +367,6 @@ void* deal_with_fr( void *handle, char *name) len = 1023; strncpy( tmp_name, finfo.name, len ); - char *plug_name = strdup(tmp_name); vevo_property_set( port, "num_params", VEVO_ATOM_TYPE_INT, 1, &r_params ); @@ -397,8 +397,6 @@ void* deal_with_fr( void *handle, char *name) veejay_msg(VEEJAY_MSG_DEBUG, "\tparameters: %d, input channels: %d, output channels: %d, format: %x", r_params,n_inputs,n_outputs, pixfmt ); #endif - - return port; } @@ -540,7 +538,6 @@ void frei0r_plug_free( void *plugin ) f0r_deinit_f base; if( vevo_property_get( plugin, "deinit", 0, &base) == VEVO_NO_ERROR ) (*base)(); -// vevo_property_get( plugin, "f0r_p", 0, &n ); } int frei0r_process_frame_f( void *plugin ) @@ -647,7 +644,7 @@ void frei0r_plug_param_f( void *port, int seq_no, void *dargs ) (*inf)( &finfo, seq_no ); char key[20]; - sprintf(key, "p%02d", seq_no ); + snprintf(key, sizeof(key)-1, "p%02d", seq_no ); void *param = NULL; if(vevo_property_get( parent, key, 0, ¶m )!=VEVO_NO_ERROR) @@ -693,5 +690,3 @@ void frei0r_plug_control( void *port, int *args ) { } - - diff --git a/veejay-current/veejay-server/libplugger/livido-loader.c b/veejay-current/veejay-server/libplugger/livido-loader.c index 4a114e99..ee52fc1a 100644 --- a/veejay-current/veejay-server/libplugger/livido-loader.c +++ b/veejay-current/veejay-server/libplugger/livido-loader.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1461,9 +1462,6 @@ void* deal_with_livido( void *handle, const char *name ) return NULL; } - plugin_name = get_str_vevo( filter_templ, "name" ); - - int n_params = livido_scan_parameters( filter_templ, port ); diff --git a/veejay-current/veejay-server/libplugger/plugload.c b/veejay-current/veejay-server/libplugger/plugload.c index d27b9ec0..cd3b62d0 100644 --- a/veejay-current/veejay-server/libplugger/plugload.c +++ b/veejay-current/veejay-server/libplugger/plugload.c @@ -66,6 +66,8 @@ static int n_fr_ = 0; static int n_lvd_ = 0; static int base_fmt_ = -1; +static void* instantiate_plugin( const void *plugin, int w , int h ); + static int select_f( const struct dirent *d ) { return ( strstr( d->d_name, ".so" ) != NULL ); @@ -86,7 +88,7 @@ char *plug_describe_param( void *plugin, int p ) } -static void *instantiate_plugin( void *plugin, int w , int h ) +static void* instantiate_plugin( const void *plugin, int w , int h ) { int type = 0; #ifdef STRICT_CHECKING @@ -96,25 +98,28 @@ static void *instantiate_plugin( void *plugin, int w , int h ) #ifdef STRICT_CHECKING assert( error == VEVO_NO_ERROR ); #endif + if( error != VEVO_NO_ERROR ) + return NULL; + void *instance = NULL; + switch( type ) { case VEVO_PLUG_LIVIDO: - return livido_plug_init( plugin,w,h, base_fmt_ ); + instance = livido_plug_init( plugin,w,h, base_fmt_ ); break; case VEVO_PLUG_FF: - return freeframe_plug_init( plugin,w,h); + instance = freeframe_plug_init( plugin,w,h); break; case VEVO_PLUG_FR: - return frei0r_plug_init( plugin,w,h,base_fmt_ ); + instance = frei0r_plug_init( plugin,w,h,base_fmt_ ); break; default: -#ifdef STRICT_CHECKING - assert(0); -#endif + veejay_msg(0, "Plugin type not supported."); break; } - return NULL; + + return instance; } @@ -517,7 +522,7 @@ int plug_find_generator_plugins(int *total, int seq ) int plug_sys_detect_plugins(void) { - index_map_ = (vevo_port_t**) vj_malloc(sizeof(vevo_port_t*) * 256 ); + index_map_ = (vevo_port_t**) vj_calloc(sizeof(vevo_port_t*) * 256 ); illegal_plugins_ = vpn( VEVO_ILLEGAL ); #ifdef STRICT_CHECKING assert( illegal_plugins_ != NULL ); @@ -814,12 +819,21 @@ char *plug_describe( int fx_id ) void *plug_activate( int fx_id ) { - if(!index_map_[fx_id] ) + if(index_map_[fx_id] == NULL) { veejay_msg(0,"Plugin %d is not loaded",fx_id); return NULL; } - return instantiate_plugin( index_map_[fx_id], base_width_,base_height_); + + void *instance = instantiate_plugin( index_map_[fx_id], base_width_,base_height_); +#ifdef STRICT_CHECKING + if( instance ) vevo_port_dump(instance,0); +#endif + if( instance == NULL ) { + veejay_msg(0, "Error instantiating plugin."); + return NULL; + } + return instance; } void plug_clear_namespace( void *fx_instance, void *data ) @@ -903,9 +917,9 @@ void plug_concatenate_all(void *osc, void *msg) char *plug_get_name( int fx_id ) { - if(!index_map_[fx_id] ) + if(index_map_[fx_id] == NULL ) return NULL; - char *name = get_str_vevo( index_map_[fx_id], "name" ); + char *name = vevo_property_get_string( index_map_[fx_id], "name" ); return name; } @@ -941,8 +955,8 @@ int plug_get_fx_id_by_name( const char *name ) } int plug_get_num_output_channels( int fx_id ) { - if(!index_map_[fx_id] ) - return NULL; + if(index_map_[fx_id] == NULL) + return 0; int res = 0; int error = vevo_property_get( index_map_[fx_id], "num_outputs",0,&res); @@ -954,8 +968,8 @@ int plug_get_num_output_channels( int fx_id ) } int plug_get_num_input_channels( int fx_id ) { - if(!index_map_[fx_id] ) - return NULL; + if(index_map_[fx_id] == NULL ) + return 0; int res = 0; int error = vevo_property_get( index_map_[fx_id], "num_inputs",0,&res); @@ -968,8 +982,8 @@ int plug_get_num_input_channels( int fx_id ) int plug_get_num_parameters( int fx_id ) { - if(!index_map_[fx_id] ) - return NULL; + if(index_map_[fx_id] == NULL ) + return 0; int res = 0; int error = vevo_property_get( index_map_[fx_id], "num_params",0,&res); @@ -1052,7 +1066,7 @@ int plug_get_coord_parameter_as_dbl( void *fx_instance,const char *key, int k, d vj_effect *plug_get_plugin( int fx_id ) { void *port = index_map_[fx_id]; - if(!port) + if(port == NULL) return NULL; vj_effect *vje = (vj_effect*) vj_calloc(sizeof(vj_effect)); diff --git a/veejay-current/veejay-server/libplugger/utility.c b/veejay-current/veejay-server/libplugger/utility.c index 0a09a2f2..36263d98 100644 --- a/veejay-current/veejay-server/libplugger/utility.c +++ b/veejay-current/veejay-server/libplugger/utility.c @@ -40,21 +40,27 @@ #include #endif -char *get_str_vevo( void *port, const char *key ) -{ - size_t len = vevo_property_element_size( port, key, 0 ); - char *ret = NULL; - if(len<=0) return NULL; - ret = (char*) vj_malloc(sizeof(char) * len ); - vevo_property_get( port, key, 0, &ret ); - return ret; + +char *get_str_vevo( void *port, const char *key ){ + return vevo_property_get_string(port,key); } + char *alloc_str_vevo( void *port, const char *key ) { - size_t len = vevo_property_element_size( port, key, 0 ); - char *ret = NULL; + size_t len = vevo_property_element_size( port, key,0 ); + char *ret = NULL; + if(len<=0) return NULL; - ret = (char*) vj_malloc(sizeof(char) * len ); + + if( vevo_property_get( port, key,0,NULL ) != VEVO_NO_ERROR ) + return NULL; + +#ifdef STRICT_CHECKING + int at = vevo_property_atom_type( port, key ); + + assert( at == VEVO_ATOM_TYPE_STRING || at == VEVO_ATOM_TYPE_UTF8STRING ); +#endif + ret = (char*) vj_malloc(sizeof(char) * len ); return ret; } diff --git a/veejay-current/veejay-server/libplugger/utility.h b/veejay-current/veejay-server/libplugger/utility.h index 336c7d48..1eaf9ae7 100644 --- a/veejay-current/veejay-server/libplugger/utility.h +++ b/veejay-current/veejay-server/libplugger/utility.h @@ -19,8 +19,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -char *get_str_vevo( void *port, const char *key ); -char *alloc_str_vevo( void *port, const char *key ); +char *get_str_vevo( void *port, const char *key ) __attribute__ ((deprecated )); +char *alloc_str_vevo( void *port, const char *key ) __attribute__ ((deprecated)); double *get_dbl_arr_vevo( void *port, const char *key ); void clone_prop_vevo( void *port, void *to_port, const char *key, const char *as_key ); void util_convertrgba32( uint8_t **data, int w, int h,int in_pix_fmt,int shiftv, void *out_buffer ); diff --git a/veejay-current/veejay-server/libsample/sampleadm.c b/veejay-current/veejay-server/libsample/sampleadm.c index 8fd390e5..aae948f6 100644 --- a/veejay-current/veejay-server/libsample/sampleadm.c +++ b/veejay-current/veejay-server/libsample/sampleadm.c @@ -129,8 +129,13 @@ static hash_val_t int_hash(const void *key) ****************************************************************************************************/ static int int_compare(const void *key1, const void *key2) { - return ((int) key1 < (int) key2 ? -1 : - ((int) key1 > (int) key2 ? +1 : 0)); +#ifdef ARCH_X86_64 + return ((int64_t) key1 < (int64_t) key2 ? -1 : + ((int64_t) key1 < (int64_t) key2 ? + 1 : 0 )); +#else + return ((int32_t) key1 < (int32_t) key2 ? -1 : + ((int32_t) key1 > (int32_t) key2 ? +1 : 0)); +#endif } int sample_update(sample_info *sample, int s1) { @@ -1012,7 +1017,6 @@ int sample_set_resume(int s1,long position) if(!sample) return -1; sample->resume_pos = position; - sample_update(s1,sample); return 1; } long sample_get_resume(int s1) diff --git a/veejay-current/veejay-server/libstream/vj-tag.c b/veejay-current/veejay-server/libstream/vj-tag.c index fd9b44fe..3d8ca957 100644 --- a/veejay-current/veejay-server/libstream/vj-tag.c +++ b/veejay-current/veejay-server/libstream/vj-tag.c @@ -64,6 +64,8 @@ #endif #include +#include + static veejay_t *_tag_info = NULL; static hash_t *TagHash = NULL; static int this_tag_id = 0; @@ -1099,15 +1101,10 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int int agen = plug_find_generator_plugins( &total, 0 ); if( agen >= 0 ) { - char *plugname = plug_get_name( agen ); channel = agen; - veejay_msg(VEEJAY_MSG_INFO, "First available generator is '%s'",plugname ); - free(plugname); } } - - if(channel >= 0 || filename != NULL) { char *plugname = NULL; if( filename != NULL ) { @@ -1116,17 +1113,13 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int channel = plug_get_idx_by_name( filename ); if( channel == - 1) { veejay_msg(0, "'%s' not found.",filename ); - if( vj_tag_del( tag->id ) == 0 ) { - free(tag->source_name ); - free(tag); - } + free(tag->source_name ); + free(tag); return -1; } } } - plugname = plug_get_name( channel ); - int foo_arg = vj_shm_get_id(); if( extra != 0 ) //@ vj_shm_set_id is a hack FIXME @@ -1134,25 +1127,24 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int tag->generator = plug_activate(channel); - vj_shm_set_id( foo_arg ); + if(tag->generator != NULL) { + vj_shm_set_id( foo_arg ); - if(tag->generator ) { if( plug_get_num_input_channels( channel ) > 0 || - plug_get_num_output_channels( channel ) != 1 ) { - veejay_msg(0, "Plug '%s' is not a generator", plugname); + plug_get_num_output_channels( channel ) == 0 ) { + veejay_msg(0, "Plug '%s' is not a generator", filename); plug_deactivate(tag->generator); - tag->generator = NULL; - free(plugname); + free(tag->source_name); + free(tag); return -1; } - strcpy( tag->source_name, plugname ); - veejay_msg(VEEJAY_MSG_DEBUG, " -> %s", plugname ); - free(plugname); + strcpy( tag->source_name, filename ); } else { - veejay_msg(VEEJAY_MSG_ERROR, "Failed to initialize generator '%s'",plugname); - free(plugname); + veejay_msg(VEEJAY_MSG_ERROR, "Failed to initialize generator '%s'",filename); + free(tag->source_name); + free(tag); return -1; } } diff --git a/veejay-current/veejay-server/libvevo/vevo.c b/veejay-current/veejay-server/libvevo/vevo.c index c79957e1..d375c210 100644 --- a/veejay-current/veejay-server/libvevo/vevo.c +++ b/veejay-current/veejay-server/libvevo/vevo.c @@ -132,6 +132,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * the atom_t structure */ + +#ifdef ARCH_X86_64 +typedef uint64_t ukey_t; +#else +typedef uint32_t ukey_t; +#endif + typedef void (*vevo_set_func)(void *ctx, int32_t type, int32_t value ); typedef int (*vevo_get_func)(void *ctx ); @@ -169,7 +176,7 @@ typedef struct { */ typedef struct { vevo_storage_t *st; - uint32_t key; + ukey_t key; void *next; } vevo_property_t; @@ -181,7 +188,7 @@ typedef struct { */ typedef struct { const char *key; - uint32_t hash_code; /* vevo uses a integer representation of key, eliminates strcmp */ + ukey_t hash_code; /* vevo uses a integer representation of key, eliminates strcmp */ void *next; } port_index_t; @@ -237,7 +244,7 @@ static const char *vevo_split_token_( const char *s, const char delim, char *buf \param hash_key hash value \param stor vevo_storage_t */ -static vevo_property_t *prop_node_new(__vevo_port_t *port, uint32_t hash_key, +static vevo_property_t *prop_node_new(__vevo_port_t *port, ukey_t hash_key, vevo_storage_t * stor) { vevo_property_t *p = @@ -268,7 +275,7 @@ static void prop_node_free(__vevo_port_t *port,vevo_property_t * p) \param key hash value \param t vevo_storage_t */ -static vevo_property_t *prop_node_append(vevo_port_t * p, uint32_t key, +static vevo_property_t *prop_node_append(vevo_port_t * p, ukey_t key, vevo_storage_t * t) { __vevo_port_t *port = (__vevo_port_t *) p; @@ -295,7 +302,7 @@ static vevo_property_t *prop_node_append(vevo_port_t * p, uint32_t key, \param port \param key hash value */ -static vevo_property_t *prop_node_get(vevo_port_t * p, uint32_t key) +static vevo_property_t *prop_node_get(vevo_port_t * p, ukey_t key) { __vevo_port_t *port = (__vevo_port_t *) p; #ifdef STRICT_CHECKING @@ -317,7 +324,7 @@ static vevo_property_t *prop_node_get(vevo_port_t * p, uint32_t key) \param hash_key calculated hash value \return port_index_t new mmemonic */ -static port_index_t *port_node_new(__vevo_port_t *port,const char *key, uint32_t hash_key) +static port_index_t *port_node_new(__vevo_port_t *port,const char *key, ukey_t hash_key) { // port_index_t *i = (port_index_t *) vevo_malloc(sizeof(port_index_t)); port_index_t *i = (port_index_t *) vevo_pool_alloc_node( @@ -353,7 +360,7 @@ static void port_node_free(__vevo_port_t *port,port_index_t * node) \param hash_key calculated hash value */ static void port_node_append(vevo_port_t * p, const char *key, - uint32_t hash_key) + ukey_t hash_key) { #ifdef STRICT_CHECKING assert(p != NULL); @@ -382,7 +389,7 @@ static void port_node_append(vevo_port_t * p, const char *key, //! \define property_exists Check if a property exists //#define property_exists( port, key ) hash_lookup( (hash_t*) port->table, (const void*) key ) -static inline hnode_t *property_exists( __vevo_port_t *port, uint32_t key ) +static inline hnode_t *property_exists( __vevo_port_t *port, ukey_t key ) { return (hnode_t*) hash_lookup( (hash_t*) port->table,(const void*) key ); } @@ -428,9 +435,9 @@ storage_put_atom_value(__vevo_port_t * port, void *src, int n, \param str string \return calculated hash value */ -static inline uint32_t hash_key_code( const char *str ) +static inline ukey_t hash_key_code( const char *str ) { - uint32_t hash = 5381; + ukey_t hash = 5381; int c; while ((c = *str++)) @@ -448,7 +455,7 @@ static inline uint32_t hash_key_code( const char *str ) int vevo_property_soft_reference(vevo_port_t * p, const char *key) { __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; if ((node = prop_node_get(port, hash_key)) != NULL) { @@ -479,7 +486,7 @@ int vevo_property_soft_reference(vevo_port_t * p, const char *key) static int vevo_property_finalize(vevo_port_t * p, const char *key) { __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; if ((node = prop_node_get(port, hash_key)) != NULL) { @@ -503,7 +510,7 @@ static int vevo_property_finalize(vevo_port_t * p, const char *key) int vevo_property_protect( vevo_port_t *p, const char *key ) { __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; if ((node = prop_node_get(port, hash_key)) != NULL) { @@ -524,7 +531,7 @@ int vevo_property_protect( vevo_port_t *p, const char *key ) int vevo_property_softref( vevo_port_t *p, const char *key ) { __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; if ((node = prop_node_get(port, hash_key)) != NULL) { @@ -547,7 +554,7 @@ static int vevo_property_exists( vevo_port_t *p, const char *key) { __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; if ((node = prop_node_get(port, hash_key)) != NULL) @@ -573,7 +580,7 @@ static void vevo_port_add_property( vevo_port_t *p,int finalize, const char *key { __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); vevo_storage_t *stor = vevo_new_storage(p); storage_put_atom_value(port, src, num_elements, stor, atom_type); if(finalize) @@ -990,7 +997,7 @@ static hash_val_t int_hash(const void *key) */ static int key_compare(const void *key1, const void *key2) { - return ((const uint32_t) key1 == (const uint32_t) key2 ? 0 : 1); + return ((const ukey_t) key1 == (const ukey_t) key2 ? 0 : 1); } //! Get the number of elements in an Atom @@ -1008,7 +1015,7 @@ int vevo_property_num_elements(vevo_port_t * p, const char *key) if(!p) return -1; __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node; @@ -1041,7 +1048,7 @@ int vevo_property_atom_type(vevo_port_t * p, const char *key) #ifdef STRICT_CHECKING assert(port != NULL); #endif - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node; @@ -1094,7 +1101,7 @@ int vevo_property_atom_size(vevo_port_t * p, const char *key) #ifdef STRICT_CHECKING assert(port != NULL); #endif - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node; @@ -1128,7 +1135,7 @@ static int vevo_property_is_protected(vevo_port_t * p, const char *key) #ifdef STRICT_CHECKING assert(port != NULL); #endif - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node; @@ -1165,7 +1172,7 @@ vevo_property_element_size(vevo_port_t * p, const char *key, const int idx ) assert(key != NULL); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); #ifdef STRICT_CHECKING assert( port ); #endif @@ -1458,7 +1465,7 @@ vevo_property_is_soft_referenced(vevo_port_t * p, assert( key != NULL ); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); #ifdef STRICT_CHECKING assert( port != NULL ); #endif @@ -1505,7 +1512,7 @@ vevo_property_set(vevo_port_t * p, assert( vevo_atom_size(atom_type) > 0 ); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); int new = 1; void *node = NULL; #ifdef STRICT_CHECKING @@ -1603,7 +1610,7 @@ vevo_property_set_f(vevo_port_t * p, assert( key != NULL ); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); int new = 1; void *node = NULL; #ifdef STRICT_CHECKING @@ -1707,7 +1714,7 @@ vevo_property_get(vevo_port_t * p, const char *key, int idx, void *dst) assert( idx >= 0 ); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; @@ -1749,7 +1756,7 @@ vevo_property_call(vevo_port_t * p, const char *key, void *ctx, int32_t type, in assert( key != NULL ); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; @@ -1795,7 +1802,7 @@ vevo_property_call_get(vevo_port_t * p, const char *key, void *ctx ) assert( key != NULL ); #endif __vevo_port_t *port = (__vevo_port_t *) p; - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *node = NULL; @@ -3474,22 +3481,27 @@ char *vevo_property_get_string( void *port, const char *key ) size_t len = vevo_property_element_size( port, key,0 ); char *ret = NULL; - if(len<=0) return NULL; + if(len<=0) + return NULL; - if( vevo_property_get( port, key,0,NULL ) != VEVO_NO_ERROR ) - return NULL; - - int at = vevo_property_atom_type( port, key ); + if( vevo_property_get( port, key,0,NULL ) != VEVO_NO_ERROR ) + return NULL; -#ifdef STRICT_CHECKING - assert( at == VEVO_ATOM_TYPE_STRING || at == VEVO_ATOM_TYPE_UTF8STRING ); +#ifdef STRICT_CHECKING + int at = vevo_property_atom_type( port, key ); + assert( at == VEVO_ATOM_TYPE_STRING || at == VEVO_ATOM_TYPE_UTF8STRING ); #endif - ret = (char*) vj_malloc(sizeof(char) * len ); - int err = vevo_property_get( port, key, 0, &ret ); - if( err != VEVO_NO_ERROR ) { - if(ret) free(ret); - return NULL; - } + + ret = (char*) vj_malloc(sizeof(char) * len ); + if(ret == NULL) { + return NULL; + } + + int err = vevo_property_get( port, key, 0, &ret ); + if( err != VEVO_NO_ERROR ) { + if(ret) free(ret); + return NULL; + } //@ string stored in utf8 //n if( at == VEVO_ATOM_TYPE_UTF8STRING ) { // gsize in,out; @@ -3572,7 +3584,7 @@ vevo_property_del(vevo_port_t * p, //@ find value in hash and release from pool - uint32_t hash_key = hash_key_code(key); + ukey_t hash_key = hash_key_code(key); if (!port->table) { vevo_property_t *pnode = NULL; if ((pnode = prop_node_get(port, hash_key)) != NULL) { @@ -3600,7 +3612,7 @@ vevo_property_del(vevo_port_t * p, do { - uint32_t idxkey = hash_key_code( node->key ); + ukey_t idxkey = hash_key_code( node->key ); if( idxkey == hash_key ) { //node at beginning of list? if( node == list ) { diff --git a/veejay-current/veejay-server/libvje/effects/diff.c b/veejay-current/veejay-server/libvje/effects/diff.c index 1c8c3472..a38c177d 100644 --- a/veejay-current/veejay-server/libvje/effects/diff.c +++ b/veejay-current/veejay-server/libvje/effects/diff.c @@ -185,7 +185,7 @@ void diff_apply(void *ed, VJFrame *frame, free(tmp); */ //@ clear distance transform map - vj_frame_clear1( dt_map, 0 , len * sizeof(uint32_t) ); + vj_frame_clear1( (uint8_t*) dt_map, 0 , len * sizeof(uint32_t) ); //@ todo: optimize with mmx binarify( ud->data, static_bg, frame->data[0], threshold, reverse,len ); diff --git a/veejay-current/veejay-server/libvjmsg/vj-common.c b/veejay-current/veejay-server/libvjmsg/vj-common.c index e0069598..d3c7f1a1 100644 --- a/veejay-current/veejay-server/libvjmsg/vj-common.c +++ b/veejay-current/veejay-server/libvjmsg/vj-common.c @@ -42,6 +42,7 @@ #include #include +#include #include /* Bug in gcc prevents from using CPP_DEMANGLE in pure "C" */ @@ -144,8 +145,11 @@ static void veejay_addr2line_bt( int n, void *addr, char *sym ) address = addr; if( info.dli_fbase >= (const void*)0x40000000) +#ifdef ARCH_X86_64 + addr = (void*)((const char*) address - (uint64_t) info.dli_fbase ); +#else addr = (void*)((const char*) address - (unsigned int ) info.dli_fbase); - +#endif snprintf( cmd,sizeof(cmd), "addr2line --functions --demangle -e $(which %s) %p", info.dli_fname, address); out = popen( cmd, "r"); if(!out) { @@ -255,7 +259,7 @@ void veejay_backtrace_handler(int n , void *dist, void *x) if( !dladdr( ip, &info )) break; - char *symname = info.dli_sname; + char *symname = (char*) info.dli_sname; #ifndef NO_CPP_DEMANGLE int status; char *tmp = __cxa_demangle( symname, NULL, 0, @@ -298,7 +302,7 @@ void veejay_backtrace_handler(int n , void *dist, void *x) report_bug(); - exit(0); + _exit(0); } void veejay_set_debug_level(int level) diff --git a/veejay-current/veejay-server/libvjnet/mcastreceiver.c b/veejay-current/veejay-server/libvjnet/mcastreceiver.c index 3715e5a2..f290e124 100644 --- a/veejay-current/veejay-server/libvjnet/mcastreceiver.c +++ b/veejay-current/veejay-server/libvjnet/mcastreceiver.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/veejay-current/veejay-server/libvjnet/vj-client.c b/veejay-current/veejay-server/libvjnet/vj-client.c index c5d23329..5e0cd9ac 100644 --- a/veejay-current/veejay-server/libvjnet/vj-client.c +++ b/veejay-current/veejay-server/libvjnet/vj-client.c @@ -514,18 +514,13 @@ int vj_client_read_i( vj_client *v, uint8_t *dst, int dstlen ) return 2; //@ caller will scale frame in dst } else { - int i,n; - for( i = 0;i < 3; i ++ ) { - if( strides[i] == 0 ) - continue; - - n = sock_t_recv( v->fd[0], dst[i], strides[i] ); - if( n != strides[i] ) { - veejay_msg(0, "Error receiving packet"); - return -1; - } - } - + int n = sock_t_recv( v->fd[0], dst, strides[0] + strides[1] + strides[2] ); + if( n != (strides[0] + strides[1] + strides[2] ) ) + { + veejay_msg(0, "Broken video packet"); + return -1; + } + if( v->in_fmt == v->cur_fmt && v->cur_width == p[0] && v->cur_height == p[1] ) return 1; diff --git a/veejay-current/veejay-server/libyuv/yuvconv.c b/veejay-current/veejay-server/libyuv/yuvconv.c index 023f9b8b..7ef1932e 100644 --- a/veejay-current/veejay-server/libyuv/yuvconv.c +++ b/veejay-current/veejay-server/libyuv/yuvconv.c @@ -326,9 +326,9 @@ void yuv_plane_sizes( VJFrame *src, int *p1, int *p2, int *p3, int *p4 ) case PIX_FMT_RGBA: if( p1 != NULL ) *p1 = src->len * 4; - *p2 = NULL; - *p3 = NULL; - *p4 = NULL; + *p2 = 0; + *p3 = 0; + *p4 = 0; break; default: if(p1 != NULL) { @@ -575,7 +575,7 @@ void *yuv_fx_context_create( VJFrame *src, VJFrame *dst, int src_fmt, int dst_fm void yuv_fx_context_process( void *ctx, VJFrame *src, VJFrame *dst ) { - sws_scale( ctx, src->data, src->stride,0,src->height,dst->data,dst->stride ); + sws_scale( (struct SwsContext*) ctx, src->data, src->stride,0,src->height,dst->data,dst->stride ); } void yuv_fx_context_destroy( void *ctx ) diff --git a/veejay-current/veejay-server/livido-plugins/lvd_shmin.c b/veejay-current/veejay-server/livido-plugins/lvd_shmin.c index 10d40180..6dbb0d1b 100644 --- a/veejay-current/veejay-server/livido-plugins/lvd_shmin.c +++ b/veejay-current/veejay-server/livido-plugins/lvd_shmin.c @@ -86,8 +86,8 @@ livido_init_f init_instance( livido_port_t *my_instance ) char *home = getenv("HOME"); snprintf(path,sizeof(path)-1, "%s/.veejay/veejay.shm", home ); int fd = open( path, O_RDWR ); - if(!fd) { - printf("no env var VEEJAY_SHMID set and no file '%s' found!",path ); + if(fd <= 0) { + printf("no env var VEEJAY_SHMID set and no file '%s' found!\n",path ); return LIVIDO_ERROR_HARDWARE; } char buf[256]; diff --git a/veejay-current/veejay-server/veejay/vj-event.c b/veejay-current/veejay-server/veejay/vj-event.c index a529fa56..c0397375 100644 --- a/veejay-current/veejay-server/veejay/vj-event.c +++ b/veejay-current/veejay-server/veejay/vj-event.c @@ -1505,8 +1505,8 @@ int vj_event_parse_msg( void *ptr, char *msg, int msg_len ) if( dbg_msg == NULL ) { veejay_msg(VEEJAY_MSG_WARNING, "No event knownn by '%d' (%s)", net_id,msg ); } else { - veejay_msg(VEEJAY_MSG_DEBUG, "VIMS '%s' %s", - msg,dbg_msg ); + veejay_msg(VEEJAY_MSG_DEBUG, "VIMS '%s' %s",msg,dbg_msg ); + free(dbg_msg); } #endif #ifndef STRICT_CHECKING diff --git a/veejay-current/veejay-server/veejay/vj-shm.c b/veejay-current/veejay-server/veejay/vj-shm.c index e4127098..ad6cba1b 100644 --- a/veejay-current/veejay-server/veejay/vj-shm.c +++ b/veejay-current/veejay-server/veejay/vj-shm.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -352,7 +353,7 @@ void *vj_shm_new_master( const char *homedir, VJFrame *frame) //@ attach v->sms = shmat( v->shm_id, NULL , 0 ); - if( v->sms == NULL || v->sms == (uint8_t*) (-1) ) { + if( v->sms == NULL || v->sms == (char*) (-1) ) { shmctl( v->shm_id, IPC_RMID, NULL ); veejay_msg(0, "Failed to attach to shared memory:%s",strerror(errno)); failed_init_cleanup(v); From 1c08aba0b5446d027567084633904e698773a824 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 20 May 2013 23:37:55 +0200 Subject: [PATCH 09/32] gracefully exit if playback thread cannot be started --- .../veejay-server/veejay/liblavplayvj.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/veejay-current/veejay-server/veejay/liblavplayvj.c b/veejay-current/veejay-server/veejay/liblavplayvj.c index 29a4e5ae..0160e51c 100644 --- a/veejay-current/veejay-server/veejay/liblavplayvj.c +++ b/veejay-current/veejay-server/veejay/liblavplayvj.c @@ -3283,10 +3283,17 @@ int veejay_main(veejay_t * info) veejay_msg(VEEJAY_MSG_WARNING, "Unable to pin playback timer to cpu #1"); } - if (pthread_create(&(settings->playback_thread),&attr, - veejay_playback_thread, (void *) info)) { - veejay_msg(VEEJAY_MSG_ERROR, "Failed to create playback timer thread"); - return -1; + int err = pthread_create(&(settings->playback_thread),&attr, + veejay_playback_thread, (void *) info); + if( err != 0 ) { + switch( err ) { + case EAGAIN: + veejay_msg(VEEJAY_MSG_ERROR, "Insufficient resources to create playback timer thread."); + break; + default: + veejay_msg(VEEJAY_MSG_ERROR, "Failed to create playback timer thread "); + } + return 0; } return 1; From 30ad18e3493e06c74747336e6605e933f0235f4e Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 00:01:24 +0200 Subject: [PATCH 10/32] fix freeze when server is started on single cpu system (attempted to set affinity for playback thread) --- .../veejay-server/veejay/liblavplayvj.c | 51 +++++++++++-------- veejay-current/veejay-server/veejay/vj-shm.c | 7 +++ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/veejay-current/veejay-server/veejay/liblavplayvj.c b/veejay-current/veejay-server/veejay/liblavplayvj.c index 0160e51c..6a3a381e 100644 --- a/veejay-current/veejay-server/veejay/liblavplayvj.c +++ b/veejay-current/veejay-server/veejay/liblavplayvj.c @@ -3267,34 +3267,45 @@ veejay_t *veejay_malloc() int veejay_main(veejay_t * info) { - video_playback_setup *settings = - (video_playback_setup *) info->settings; + video_playback_setup *settings = (video_playback_setup *) info->settings; pthread_attr_t attr; cpu_set_t cpuset; - /* Flush the Linux File buffers to disk */ - sync(); - - CPU_ZERO( &cpuset ); - CPU_SET ( 1, &cpuset ); /* run on cpu 1 */ + memset( &attr, 0 , sizeof(pthread_attr_t)); - pthread_attr_init( &attr ); - if( pthread_attr_setaffinity_np( &attr, sizeof(cpuset) , &cpuset ) != 0 ) { - veejay_msg(VEEJAY_MSG_WARNING, "Unable to pin playback timer to cpu #1"); + /* Flush the Linux File buffers to disk */ + sync(); + + if( task_num_cpus() > 1 ) { + CPU_ZERO( &cpuset ); + CPU_SET ( 1, &cpuset ); /* run on cpu 1 */ + + int err = pthread_attr_init( &attr ); + if( err == ENOMEM ) { + veejay_msg(VEEJAY_MSG_ERROR, "Out of memory error."); + return 0; + + } + if( pthread_attr_setaffinity_np( &attr, sizeof(cpuset) , &cpuset ) != 0 ) { + veejay_msg(VEEJAY_MSG_WARNING, "Unable to pin playback timer to cpu #1"); + } + else { + veejay_msg(VEEJAY_MSG_INFO,"Pinned playback timer thread to cpu #1"); + } } - int err = pthread_create(&(settings->playback_thread),&attr, + int err = pthread_create(&(settings->playback_thread),&attr, veejay_playback_thread, (void *) info); - if( err != 0 ) { - switch( err ) { - case EAGAIN: - veejay_msg(VEEJAY_MSG_ERROR, "Insufficient resources to create playback timer thread."); - break; - default: - veejay_msg(VEEJAY_MSG_ERROR, "Failed to create playback timer thread "); + if( err != 0 ) { + switch( err ) { + case EAGAIN: + veejay_msg(VEEJAY_MSG_ERROR, "Insufficient resources to create playback timer thread."); + break; + default: + veejay_msg(VEEJAY_MSG_ERROR, "Failed to create playback timer thread, code %d ", err); + } + return 0; } - return 0; - } return 1; } diff --git a/veejay-current/veejay-server/veejay/vj-shm.c b/veejay-current/veejay-server/veejay/vj-shm.c index ad6cba1b..b35dc802 100644 --- a/veejay-current/veejay-server/veejay/vj-shm.c +++ b/veejay-current/veejay-server/veejay/vj-shm.c @@ -331,7 +331,14 @@ static void failed_init_cleanup( vj_shm_t *v ) //@ new producer, puts frame in shm void *vj_shm_new_master( const char *homedir, VJFrame *frame) { +#ifdef STRICT_CHECKING + assert( frame->width > 0 ); + assert( frame->height > 0 ); +#endif vj_shm_t *v = (vj_shm_t*) vj_calloc(sizeof(vj_shm_t)); +#ifdef STRICT_CHECKING + assert( v != NULL ); +#endif v->parent = 1; if( vj_shm_file_ref( v, homedir ) == -1 ) { From d14e90ba398fb37089970c66ea20c9e00abae632 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 00:41:13 +0200 Subject: [PATCH 11/32] fixed bug when intializing (mjpeg) encoder --- veejay-current/veejay-server/libel/vj-avcodec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/veejay-current/veejay-server/libel/vj-avcodec.c b/veejay-current/veejay-server/libel/vj-avcodec.c index e8b6b58d..f0728529 100644 --- a/veejay-current/veejay-server/libel/vj-avcodec.c +++ b/veejay-current/veejay-server/libel/vj-avcodec.c @@ -203,12 +203,11 @@ static vj_encoder *vj_avcodec_new_encoder( int id, editlist *el, char *filename) e->context->qblur = 0.0; e->context->max_b_frames = 0; e->context->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; - e->context->flags = CODEC_FLAG2_FAST | CODEC_FLAG_QSCALE; + // e->context->flags = CODEC_FLAG2_FAST | CODEC_FLAG_QSCALE; e->context->gop_size = 0; e->context->workaround_bugs = FF_BUG_AUTODETECT; e->context->prediction_method = 0; e->context->dct_algo = FF_DCT_AUTO; - e->context->pix_fmt = get_ffmpeg_pixfmt( out_pixel_format ); if(YUV420_ONLY_CODEC(id)) From 7afb4c6791844b030af2e7ad3aff018859b6e462 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 00:43:06 +0200 Subject: [PATCH 12/32] bump to 1.5.28 --- veejay-current/veejay-server/configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index 0b66a7c7..7c2298f8 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([veejay],[1.5.26],[http://www.veejayhq.net]) +AC_INIT([veejay],[1.5.28],[http://www.veejayhq.net]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([veejay/veejay.c]) VEEJAY_MAJOR_VERSION=1 VEEJAY_MINOR_VERSION=5 -VEEJAY_MICRO_VERSION=27 +VEEJAY_MICRO_VERSION=28 VEEJAY_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION VEEJAY_CODENAME="Veejay Classic - build $VEEJAY_MINOR_VERSION $VEEJAY_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) From c1b5fdc307ad761a22b24e1dcb0cb776d6fc1204 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 00:44:05 +0200 Subject: [PATCH 13/32] update client to require 1.5.28 --- veejay-current/veejay-client/configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index 8a4c7713..606f3383 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([reloaded],[1.5.27],[nwelburg@gmail.com]) +AC_INIT([reloaded],[1.5.28],[nwelburg@gmail.com]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/gveejay.c]) RELOADED_MAJOR_VERSION=1 RELOADED_MINOR_VERSION=5 -RELOADED_MICRO_VERSION=27 +RELOADED_MICRO_VERSION=28 RELOADED_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION RELOADED_CODENAME="Reloaded - build $RELOADED_MAJOR_VERSION $RELOADED_MINOR_VERSION $RELOADED_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) @@ -178,7 +178,7 @@ fi dnl Check for Veejay have_veejay=false -PKG_CHECK_MODULES( VEEJAY, [veejay >= 1.5.26 ], +PKG_CHECK_MODULES( VEEJAY, [veejay >= 1.5.28 ], [ AC_SUBST(VEEJAY_CFLAGS) AC_SUBST(VEEJAY_LIBS) @@ -188,7 +188,7 @@ PKG_CHECK_MODULES( VEEJAY, [veejay >= 1.5.26 ], [have_veejay=false]) if test x$have_veejay != xtrue ; then - AC_MSG_ERROR([Cannot find veejay 1.5.26 or later]) + AC_MSG_ERROR([Cannot find veejay 1.5.28 or later]) fi have_pixbuf=false @@ -690,7 +690,7 @@ AC_MSG_NOTICE([ Good luck! You can be the first! ]) fi AC_MSG_NOTICE([]) AC_MSG_NOTICE([ Required dependencies:]) -AC_MSG_NOTICE([ - Veejay 1.5.26 : ${have_veejay}]) +AC_MSG_NOTICE([ - Veejay 1.5.28 : ${have_veejay}]) AC_MSG_NOTICE([ - POSIX Threads (pthread) : ${have_pthread}]) AC_MSG_NOTICE([ - FFmpeg AVCodec : ${have_avcodec} ]) AC_MSG_NOTICE([ - FFmpeg Swscaler : ${have_swscale} ]) From a6412b7bf80efbb57bb3763a7f48d13881399d46 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 00:51:33 +0200 Subject: [PATCH 14/32] copyright notice update --- veejay-current/veejay-server/veejay/vj-perform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index 9657aa74..1c33d395 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -125,7 +125,7 @@ static const char *intro = static const char *license = "This program is licensed as\nFree Software (GNU/GPL version 2)\n\nFor more information see:\nhttp://veejayhq.net\nhttp://veejay.dyne.org\nhttp://www.sourceforge.net/projects/veejay\nhttp://www.gnu.org"; static const char *copyr = - "(C) 2002-2008 Copyright N.Elburg et all (nwelburg@gmail.com)\n"; + "(C) 2002-2013 Copyright N.Elburg et all (nwelburg@gmail.com)\n"; #define MLIMIT(var, low, high) \ if((var) < (low)) { var = (low); } \ From b9de9b1ccaa2f31f80f0059912fe8926d83b18a2 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 01:07:06 +0200 Subject: [PATCH 15/32] enable qscale for mjpeg encoder --- veejay-current/veejay-server/libel/vj-avcodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/veejay-current/veejay-server/libel/vj-avcodec.c b/veejay-current/veejay-server/libel/vj-avcodec.c index f0728529..901d81a3 100644 --- a/veejay-current/veejay-server/libel/vj-avcodec.c +++ b/veejay-current/veejay-server/libel/vj-avcodec.c @@ -203,7 +203,7 @@ static vj_encoder *vj_avcodec_new_encoder( int id, editlist *el, char *filename) e->context->qblur = 0.0; e->context->max_b_frames = 0; e->context->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; - // e->context->flags = CODEC_FLAG2_FAST | CODEC_FLAG_QSCALE; + e->context->flags = CODEC_FLAG_QSCALE; e->context->gop_size = 0; e->context->workaround_bugs = FF_BUG_AUTODETECT; e->context->prediction_method = 0; From 39c85513410cc2702a1aa20ad92f605632935411 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 21 May 2013 22:02:49 +0200 Subject: [PATCH 16/32] be verbosive when memory allocation fails added verbose logging to sayVIMS, commandline option -v added vj_mem_init bump sayVIMS to 1.1.4 --- .../veejay-server/libvjmem/vj-x86.c | 25 ++++++++++++++++-- veejay-current/veejay-utils/configure.ac | 4 +-- veejay-current/veejay-utils/src/sayVIMS.c | 26 ++++++++++++------- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/veejay-current/veejay-server/libvjmem/vj-x86.c b/veejay-current/veejay-server/libvjmem/vj-x86.c index 07d974c9..9e07d4eb 100644 --- a/veejay-current/veejay-server/libvjmem/vj-x86.c +++ b/veejay-current/veejay-server/libvjmem/vj-x86.c @@ -27,13 +27,17 @@ #include #include #include +#include +#ifdef STRICT_CHECKING +#include +#endif extern void find_best_memcpy(void); extern void find_best_memset(void); extern int find_best_threaded_memcpy(int w, int h); extern void yuyv_plane_init(); static int MEM_ALIGNMENT_SIZE = 0; -static int CACHE_LINE_SIZE = 16; +static int CACHE_LINE_SIZE = 64; #ifdef ARCH_X86 @@ -179,9 +183,26 @@ void *vj_malloc_(size_t size) return NULL; void *ptr = NULL; #ifdef HAVE_POSIX_MEMALIGN - posix_memalign( &ptr, MEM_ALIGNMENT_SIZE, size ); + size_t aligned_size = (size + 3) & ~0x03; +#ifdef STRICT_CHECKING + assert( MEM_ALIGNMENT_SIZE > 0 ); +#endif + int err = posix_memalign( &ptr, MEM_ALIGNMENT_SIZE, aligned_size ); + if( err == EINVAL ) + { + veejay_msg(0, "Memory is not a multiple of %d : %d", sizeof(void*), aligned_size ); + return NULL; + } + if( err == ENOMEM ) + { + veejay_msg(0, "Unable to allocate %d bytes of memory",size ); + return NULL; + } #else #ifdef HAVE_MEMALIGN +#ifdef STRICT_CHECKING + assert( MEM_ALIGNMENT_SIZE > 0 ); +#endif ptr = memalign( MEM_ALIGNMENT_SIZE, size ); #else ptr = malloc ( size ) ; diff --git a/veejay-current/veejay-utils/configure.ac b/veejay-current/veejay-utils/configure.ac index 80783c37..3593bfba 100644 --- a/veejay-current/veejay-utils/configure.ac +++ b/veejay-current/veejay-utils/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([veejay-utils],[1.1.3],[veejay-users@lists.sourceforge.net]) +AC_INIT([veejay-utils],[1.1.4],[veejay-users@lists.sourceforge.net]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/sayVIMS.c]) VEEJAY_MAJOR_VERSION=1 VEEJAY_MINOR_VERSION=1 -VEEJAY_MICRO_VERSION=3 +VEEJAY_MICRO_VERSION=4 VEEJAY_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION VEEJAY_CODENAME="Veejay Utilities - build $VEEJAY_MINOR_VERSION $VEEJAY_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) diff --git a/veejay-current/veejay-utils/src/sayVIMS.c b/veejay-current/veejay-utils/src/sayVIMS.c index 34762985..592cd21b 100644 --- a/veejay-current/veejay-utils/src/sayVIMS.c +++ b/veejay-current/veejay-utils/src/sayVIMS.c @@ -30,9 +30,10 @@ #include #include #include +#include +#include static int interactive = 0; static int port_num = 3490; -static char *filename = NULL; static char *group_name = NULL; static char *host_name = NULL; static vj_client *sayvims = NULL; @@ -40,10 +41,10 @@ static int colors = 0; static int fd_in = 0; // stdin static int single_msg = 0; static int dump = 0; - +static int verbose = 0; /* count played frames (delay) */ static void vj_flush(int frames) { - int n = 0; + char status[100]; bzero(status,100); @@ -87,6 +88,7 @@ static void Usage(char *progname) fprintf(stderr, " -m\t\tSend single message\n"); fprintf(stderr, " -c\t\tColored output\n"); fprintf(stderr, " -d\t\tDump status to stdout\n"); + fprintf(stderr, " -v\t\t\n"); fprintf(stderr, "Messages to send to veejay must be wrapped in quotes\n"); fprintf(stderr, "You can send multiple messages by seperating them with a whitespace\n"); fprintf(stderr, "Example: %s \"600:;\"\n",progname); @@ -129,6 +131,10 @@ static int set_option(const char *name, char *value) { dump = 1; } + else if(strcmp(name,"v") == 0 ) + { + verbose = 1; + } else err++; return err; @@ -159,18 +165,14 @@ int main(int argc, char *argv[]) { int i; int n = 0; - int x = 0; - int k =0; - char msg[20]; char option[2]; - char ibuf[1024]; int err = 0; FILE *infile; - veejay_set_debug_level(1); + veejay_set_debug_level(verbose); // parse commandline parameters - while( ( n = getopt(argc,argv, "h:g:p:micd")) != EOF) + while( ( n = getopt(argc,argv, "h:g:p:micdv")) != EOF) { sprintf(option,"%c",n); err += set_option( option,optarg); @@ -182,6 +184,10 @@ int main(int argc, char *argv[]) return -1; } + vj_mem_init(); + + veejay_set_debug_level( verbose ); + sayvims = sayvims_connect(); if(!sayvims) { @@ -220,7 +226,6 @@ int main(int argc, char *argv[]) else { /* read from stdin*/ - int not_done = 1; infile = fdopen( fd_in, "r" ); if(!infile) { @@ -251,6 +256,7 @@ int main(int argc, char *argv[]) } + vj_flush(1); vj_client_close(sayvims); vj_client_free(sayvims); From d2e3030866a18ab9dc79ac46091e870462e38af8 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 4 Jun 2013 19:53:23 +0200 Subject: [PATCH 17/32] drop ffmpeg from reloaded build (not needed) keep avutil for pix format declarations --- veejay-current/veejay-client/configure.ac | 31 ++------------------ veejay-current/veejay-client/src/Makefile.am | 4 +-- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index 606f3383..6d359d84 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -522,37 +522,14 @@ fi AC_MSG_RESULT($CFLAGS) - -AC_DEFINE_UNQUOTED(HAVE_FFMPEG_UNINSTALLED,, - [Defined if building against uninstalled FFmpeg source]) - -PKG_CHECK_MODULES(LIBAVUTIL, [libavutil >= 49.7.0],have_avutil=true,have_avutil=false) -PKG_CHECK_MODULES(LIBAVCODEC,[libavcodec >= 51.57.2],have_avcodec=true,have_avcodec=false) -PKG_CHECK_MODULES(LIBAVFORMAT,[libavformat >= 52.14.0],have_avformat=true,have_avformat=false) -PKG_CHECK_MODULES(LIBSWSCALE,[libswscale >= 0.7.1],have_swscale=true,have_swscale=false) -if test x$have_swscale = xfalse; -then - AC_MSG_ERROR([libswscale not found.]) -fi +PKG_CHECK_MODULES(LIBAVUTIL,[libavutil >= 49.7], have_avutil=true,have_avutil=false]) if test x$have_avutil = xfalse; then - AC_MSG_ERROR([libavutil not found.]) -fi -if test x$have_avformat = xfalse; -then - AC_MSG_ERROR([libavformat not found.]) -fi -if test x$have_avcodec = xfalse; -then - AC_MSG_ERROR([libavcodec not found.]) + AC_MSG_ERROR([libavutil not found.]) fi -FFMPEG_CFLAGS="${LIBAVFORMAT_CFLAGS} ${LIBAVCODEC_CFLAGS} ${LIBAVUTIL_CFLAGS} ${LIBSWSCALE_CFLAGS}" -FFMPEG_LIBS="${LIBAVFORMAT_LIBS} ${LIBAVCODEC_LIBS} ${LIBAVUTIL_LIBS} ${LIBSWSCALE_LIBS}" +FFMPEG_CFLAGS="${LIBAVUTIL_CFLAGS}" AC_SUBST(FFMPEG_CFLAGS) -AC_SUBST(FFMPEG_LIBS) - - dnl ********************************************************************** dnl All the conditional stuff for the Makefiles AM_CONDITIONAL(HAVE_ASM_MMX, test x$have_asm_mmx = xtrue) @@ -692,7 +669,5 @@ AC_MSG_NOTICE([]) AC_MSG_NOTICE([ Required dependencies:]) AC_MSG_NOTICE([ - Veejay 1.5.28 : ${have_veejay}]) AC_MSG_NOTICE([ - POSIX Threads (pthread) : ${have_pthread}]) -AC_MSG_NOTICE([ - FFmpeg AVCodec : ${have_avcodec} ]) -AC_MSG_NOTICE([ - FFmpeg Swscaler : ${have_swscale} ]) AC_MSG_NOTICE([ - GDK Pixbuf support : ${have_pixbuf}]) AC_MSG_NOTICE([ - Alsa support (midi sequencer) : ${have_alsa}]) diff --git a/veejay-current/veejay-client/src/Makefile.am b/veejay-current/veejay-client/src/Makefile.am index 3999dd91..0a706424 100644 --- a/veejay-current/veejay-client/src/Makefile.am +++ b/veejay-current/veejay-client/src/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in MAINTAINERCLEANFILES = Makefile.in AM_CFLAGS=$(OP_CFLAGS) -INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(VEEJAY_CFLAGS ) $(GTK_CFLAGS) \ +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(VEEJAY_CFLAGS) $(GTK_CFLAGS) \ $(GLIB_CFLAGS) $(FFMPEG_CFLAGS) $(GLADE_CFLAGS) -DGNOMELOCALEDIR=\""$(datadir)/locale"\" -DRELOADED_DATADIR=\""$(reloaded_datadir)"\" RELOADED_BIN=reloaded @@ -11,5 +11,5 @@ bin_PROGRAMS = $(RELOADED_BIN) EXTRA_DIST = common.h curve.h fastintfns.h format_codes.h keyboard.h mjpeg_logging.h mjpeg_types.h mpegconsts.h mpegtimecode.h multitrack.h sequence.h tracksources.h utils.h videodev_mjpeg.h vj-api.h vmidi.h yuv4mpeg.h yuv4mpeg_intern.h cellrendererspin.h gtkcolorsel.h gtkhsv.h gtkknob.h gtktimeselection.h callback.c reloaded_LDFLAGS = $(VEEJAY_LIBS) $(GTK_LIBS) $(GLIB_LIBS) \ -$(GLADE_LIBS) $(FFMPEG_LIBS) $(ALSA_LIBS) -lgthread-2.0 -export-dynamic +$(GLADE_LIBS) $(ALSA_LIBS) -lgthread-2.0 -export-dynamic From 927a5bd33b627d8e5e2b16d8d7965e85f86da510 Mon Sep 17 00:00:00 2001 From: niels Date: Fri, 7 Jun 2013 20:24:15 +0200 Subject: [PATCH 18/32] drop unicap dependency --- veejay-current/veejay-server/configure.ac | 23 - .../veejay-server/libstream/Makefile.am | 6 +- .../veejay-server/libstream/vj-tag.c | 162 +- .../veejay-server/libstream/vj-unicap.c | 1486 ----------------- .../veejay-server/libstream/vj-unicap.h | 54 - .../veejay-server/veejay/Makefile.am | 2 +- veejay-current/veejay-server/veejay/veejay.c | 3 - 7 files changed, 6 insertions(+), 1730 deletions(-) delete mode 100644 veejay-current/veejay-server/libstream/vj-unicap.c delete mode 100644 veejay-current/veejay-server/libstream/vj-unicap.h diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index 7c2298f8..996c7749 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -106,10 +106,6 @@ AC_ARG_WITH(jpeg-mmx, AC_HELP_STRING([--with-jpegmmx=PFX], [Prefix where jpeg-mmx is installed (optional).])) -AC_ARG_WITH(unicap, AC_HELP_STRING([--without-unicap], [Do not use unicap]), - [], [with_unicap=yes]) - - AC_ARG_WITH(v4l2, AC_HELP_STRING([--without-v4l2],[Do not use Video4Linux]), [], [with_v4l2=yes]) @@ -830,23 +826,6 @@ else AC_DEFINE(HAVE_LIBLO,,[define if liblo]) fi -have_unicap=false -if test x$with_unicap != xno; then -PKG_CHECK_MODULES( UNICAP, libunicap >= 0.1.0,have_unicap=true,have_unicap=false) -fi - -if test x$have_unicap = xfalse ; then - AC_MSG_WARN([Could not find optional library libunicap]) -else -have_unicap=true -AC_SUBST(HAVE_UNICAP) -AC_DEFINE(HAVE_UNICAP,,[define if unicap]) -fi - -AC_SUBST(UNICAP_CFLAGS) -AC_SUBST(UNICAP_LIBS) - - dnl ********************************************************************* dnl Check for the DirectFB library (for Matrox G550 Tvout) dnl @@ -966,7 +945,6 @@ AM_CONDITIONAL(HAVE_V4L2, test x$have_V4l2 = xtrue) AM_CONDITIONAL(SUPPORT_READ_DV2, test x$have_libdv = xtrue) AM_CONDITIONAL(HAVE_DL_DLOPEN, test x$have_dl_dlopen = xtrue) AM_CONDITIONAL(HAVE_JPEG,test x$have_jpeg = xtrue) -AM_CONDITIONAL(HAVE_UNICAP,test x$have_unicap = xtrue) AM_CONDITIONAL(HAVE_LIBLO,test x$have_liblo = xtrue) dnl ********************************************************************* dnl Check for what warnings we want gcc to use and adjust the CFLAGS @@ -1125,7 +1103,6 @@ AC_MSG_NOTICE([ - DirectFB support : ${have_directfb}]) AC_MSG_NOTICE([ - libDV (digital video) support : ${have_libdv} ]) AC_MSG_NOTICE([ - QuickTime support : ${have_libquicktime} ]) AC_MSG_NOTICE([ - Jack Audio Connection Kit : ${have_jack}]) -AC_MSG_NOTICE([ - Unicap Imaging : ${have_unicap} ]) AC_MSG_NOTICE([ - Liblo OSC client : ${have_liblo}]) AC_MSG_NOTICE([ - V4L2 (default) : ${have_v4l2}]) AC_MSG_NOTICE([ - V4L1 (obsolete) : ${have_v4l}]) diff --git a/veejay-current/veejay-server/libstream/Makefile.am b/veejay-current/veejay-server/libstream/Makefile.am index 66936c1a..ce119664 100644 --- a/veejay-current/veejay-server/libstream/Makefile.am +++ b/veejay-current/veejay-server/libstream/Makefile.am @@ -7,10 +7,10 @@ INCLUDES = -I$(top_srcdir) -I$(includedir) -I$(top_srcdir)/vjmem \ -I$(top_srcdir)/libhash \ -I$(top_srcdir)/mjpegtools \ $(XML2_CFLAGS) \ - $(FFMPEG_CFLAGS) $(PTHREAD_CFLAGS) $(UNICAP_CFLAGS) + $(FFMPEG_CFLAGS) $(PTHREAD_CFLAGS) STREAM_LIB_FILE = libstream.la noinst_LTLIBRARIES = $(STREAM_LIB_FILE) -libstream_la_SOURCES = frequencies.c v4lutils.c v4lvideo.c vj-unicap.c vj-yuv4mpeg.c vj-net.c vj-dv1394.c vj-vloopback.c vj-tag.c v4l2utils.c +libstream_la_SOURCES = frequencies.c v4lutils.c v4lvideo.c vj-yuv4mpeg.c vj-net.c vj-dv1394.c vj-vloopback.c vj-tag.c v4l2utils.c pkginclude_HEADERS = vj-net.h EXTRA_DIST = dv1394.h v4lutils.h v4l2utils.h vj-dv1394.h vj-tag.h vj-vloopback.h \ - frequencies.h v4lvideo.h vj-net.h vj-unicap.h vj-yuv4mpeg.h + frequencies.h v4lvideo.h vj-net.h vj-yuv4mpeg.h diff --git a/veejay-current/veejay-server/libstream/vj-tag.c b/veejay-current/veejay-server/libstream/vj-tag.c index 3d8ca957..1652509d 100644 --- a/veejay-current/veejay-server/libstream/vj-tag.c +++ b/veejay-current/veejay-server/libstream/vj-tag.c @@ -54,9 +54,6 @@ #ifdef HAVE_V4L2 #include #endif -#ifdef HAVE_UNICAP -#include -#endif #include #include #ifdef HAVE_FREETYPE @@ -74,9 +71,6 @@ static int next_avail_tag = 0; static int avail_tag[SAMPLE_MAX_SAMPLES]; static int last_added_tag = 0; static int video_driver_ = -1; // V4lUtils -#ifdef HAVE_UNICAP -static void *unicap_data_= NULL; -#endif //forward decl static int no_v4l2_threads_ = 0; @@ -138,9 +132,6 @@ void vj_tag_free(void) if( vj_tag_input) free(vj_tag_input); -#ifdef HAVE_UNICAP - vj_unicap_deinit(unicap_data_); -#endif } @@ -224,9 +215,6 @@ static int vj_tag_update(vj_tag *tag, int id) { int vj_tag_num_devices() { -#ifdef HAVE_UNICAP - return vj_unicap_num_capture_devices( unicap_data_ ); -#endif #ifdef HAVE_V4L return v4lvideo_templ_num_devices(); #elif HAVE_V4L2 @@ -241,9 +229,7 @@ char *vj_tag_scan_devices( void ) int i; int len = 0; char **device_list = NULL; -#ifdef HAVE_UNICAP - device_list = vj_unicap_get_devices(unicap_data_, &num); -#elif HAVE_V4L +#ifdef HAVE_V4L device_list = v4lvideo_templ_get_devices(&num); #elif HAVE_V4L2 device_list = v4l2_get_device_list(); @@ -299,17 +285,12 @@ int vj_tag_init(int width, int height, int pix_fmt, int video_driver) vj_tag_input->depth = 3; vj_tag_input->pix_fmt = pix_fmt; video_driver_ = video_driver; -#ifndef HAVE_UNICAP video_driver_ = 1; -#endif vj_tag_input->uv_len = (width*height) / 2; memset( &_tmp, 0, sizeof(VJFrame)); _tmp.len = width * height; -#ifdef HAVE_UNICAP - unicap_data_= (void*) vj_unicap_init(); -#endif _temp_buffer[0] = (uint8_t*) vj_malloc(sizeof(uint8_t)*width*height); _temp_buffer[1] = (uint8_t*) vj_malloc(sizeof(uint8_t)*width*height); _temp_buffer[2] = (uint8_t*) vj_malloc(sizeof(uint8_t)*width*height); @@ -453,52 +434,7 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int veejay_msg(VEEJAY_MSG_DEBUG, "Using v4l2"); #endif return 1; - } else { -#ifdef HAVE_UNICAP - vj_tag_input->unicap[stream_nr] = vj_unicap_new_device( unicap_data_, device_num ); - if(!vj_tag_input->unicap[stream_nr] ) - { - veejay_msg(0,"Unable to open device %d", device_num); - return 0; - } - if(!vj_unicap_configure_device( vj_tag_input->unicap[stream_nr] , - pixfmt, width,height, has_composite)) - { - veejay_msg(0,"Unable to configure device %d",channel); - vj_unicap_free_device( unicap_data_,vj_tag_input->unicap[stream_nr] ); - return 0; - } - else - veejay_msg(VEEJAY_MSG_DEBUG, "Configured device %d with Unicap", channel); - sprintf(refname, "%d",channel ); - tag->extra = strdup(refname); - - char **props = vj_unicap_get_list( vj_tag_input->unicap[stream_nr] ); - int i; - double v = 0.0; - for( i = 0; props[i] != NULL ; i ++ ) { - if(strncasecmp("video norm", props[i],10 ) == 0 ) { - if( norm == 'p' || norm == 'P' ) - vj_unicap_select_value(vj_tag_input->unicap[tag->index],UNICAP_PAL,0); - else - vj_unicap_select_value( vj_tag_input->unicap[tag->index],UNICAP_NTSC,0 ); - } - else if (strncasecmp( "video source", props[i], 12 ) == 0 ) - { - int cha = channel + UNICAP_SOURCE0; - if(cha <=UNICAP_SOURCE4) - vj_unicap_select_value( vj_tag_input->unicap[tag->index], - cha,0 ); - } - free(props[i]); - } - free(props); -#else - veejay_msg(VEEJAY_MSG_ERROR, "Unicap support not compiled in."); - return 0; -#endif - } - //set channel + } return 1; } @@ -892,10 +828,6 @@ int vj_tag_composite(int t1) if(!tag) return 0; if(tag->source_type != VJ_TAG_TYPE_V4L ) return 0; -#ifdef HAVE_UNICAP - if(tag->capture_type==0) - return vj_unicap_composite_status( vj_tag_input->unicap[ tag->index ] ); -#endif if(tag->capture_type==1) { #ifdef HAVE_V4L return v4lvideo_get_composite_status( vj_tag_input->unicap[tag->index]); @@ -1312,11 +1244,6 @@ int vj_tag_del(int id) /* stop streaming in first */ switch(tag->source_type) { case VJ_TAG_TYPE_V4L: -#ifdef HAVE_UNICAP - if(!tag->capture_type) - vj_unicap_free_device(unicap_data_, vj_tag_input->unicap[tag->index] ); -#endif - if(tag->capture_type==1) { #ifdef HAVE_V4L2 if( no_v4l2_threads_ ) { @@ -1915,11 +1842,6 @@ int vj_tag_set_brightness(int t1, int value) v4lvideo_set_brightness( vj_tag_input->unicap[tag->index], value ); #endif } -#ifdef HAVE_UNICAP - else { - vj_unicap_select_value( vj_tag_input->unicap[tag->index],UNICAP_BRIGHTNESS,(double)value); - } -#endif } return 1; } @@ -1941,11 +1863,6 @@ int vj_tag_set_white(int t1, int value) v4l2_set_temperature( vj_tag_input->unicap[tag->index],value); #endif } -#ifdef HAVE_UNICAP - else { - vj_unicap_select_value( vj_tag_input->unicap[tag->index],UNICAP_WHITE,(double) value ); - } -#endif } return 1; } @@ -1959,11 +1876,6 @@ int vj_tag_set_hue(int t1, int value) veejay_msg(VEEJAY_MSG_ERROR,"Hue valid range is 0 - 65535"); return -1; } -#ifdef HAVE_UNICAP - if(tag->capture_type==0) { - vj_unicap_select_value( vj_tag_input->unicap[tag->index],UNICAP_HUE,(double)value); - } -#endif if( tag->capture_type==1) { #ifdef HAVE_V4L v4lvideo_set_hue( vj_tag_input->unicap[tag->index], value ); @@ -1991,11 +1903,6 @@ int vj_tag_set_contrast(int t1,int value) v4l2_set_contrast( vj_tag_input->unicap[tag->index], value ); #endif } -#ifdef HAVE_UNICAP - else { - vj_unicap_select_value( vj_tag_input->unicap[tag->index],UNICAP_CONTRAST, (double) value); - } -#endif } return 1; } @@ -2018,11 +1925,6 @@ int vj_tag_set_color(int t1, int value) v4l2_set_contrast( vj_tag_input->unicap[tag->index],value); #endif } -#ifdef HAVE_UNICAP - else { - vj_unicap_select_value( vj_tag_input->unicap[tag->index], UNICAP_COLOR, (double)value); - } -#endif } return 1; } @@ -2056,31 +1958,6 @@ int vj_tag_get_v4l_properties(int t1, return 0; } -#ifdef HAVE_UNICAP - if( tag->capture_type == 0 ) { - char **props = vj_unicap_get_list( vj_tag_input->unicap[tag->index] ); - int i; - for( i = 0; props[i] != NULL ; i ++ ) - { - double dvalue = 0.0; - vj_unicap_get_value( vj_tag_input->unicap[tag->index] , - props[i], VEVO_ATOM_TYPE_DOUBLE, &dvalue ); - if(strncasecmp( props[i], "brightness",8) == 0 ) { - *brightness = (int) dvalue; - } else if(strncasecmp( props[i], "hue",3 ) == 0 ) { - *hue = (int) dvalue; - } else if( strncasecmp( props[i], "contrast", 8) == 0 ){ - *contrast = (int) dvalue; - } else if (strncasecmp( props[i], "white", 5 ) == 0 ){ - *white = (int) dvalue; - } else if (strncasecmp( props[i], "color",5 ) == 0 ){ - *color = (int) dvalue; - } - free(props[i]); - } - free(props); - } -#endif return 0; } @@ -2537,10 +2414,6 @@ int vj_tag_disable(int t1) { } #endif -#ifdef HAVE_UNICAP - if( tag->capture_type == 0 ) - vj_unicap_set_pause( vj_tag_input->unicap[tag->index], 1 ); -#endif } #ifdef USE_GDK_PIXBUF @@ -2589,15 +2462,6 @@ int vj_tag_enable(int t1) { } #endif } -#ifdef HAVE_UNICAP - if(tag->capture_type == 0 ) { - int sta = vj_unicap_status( vj_tag_input->unicap[tag->index]); - if( sta == 0 ) - tag->active = vj_unicap_start_capture( vj_tag_input->unicap[tag->index]); - if( vj_unicap_get_pause( vj_tag_input->unicap[tag->index] ) ) - vj_unicap_set_pause( vj_tag_input->unicap[tag->index] , 0 ); - } -#endif vj_tag_update(tag,t1); return 1; } @@ -2685,22 +2549,6 @@ int vj_tag_set_active(int t1, int active) } #endif } -#ifdef HAVE_UNICAP - else { - if(active) { - int sta =vj_unicap_status( vj_tag_input->unicap[tag->index]); - if(sta == 0 ) - active = vj_unicap_start_capture( vj_tag_input->unicap[tag->index]); - if(active ) { - if( vj_unicap_get_pause( vj_tag_input->unicap[ tag->index] ) ) - vj_unicap_set_pause( vj_tag_input->unicap[tag->index] , 0 ); - } - } else { - if( !vj_unicap_get_pause( vj_tag_input->unicap[ tag->index ] ) ) - vj_unicap_set_pause( vj_tag_input->unicap[tag->index] , 1 ); - } - } -#endif tag->active = active; break; case VJ_TAG_TYPE_YUV4MPEG: @@ -3614,12 +3462,6 @@ int vj_tag_get_frame(int t1, uint8_t *buffer[3], uint8_t * abuffer) veejay_memset( buffer[2], 128, uv_len ); } } -#ifdef HAVE_UNICAP - else { - if(vj_unicap_status(vj_tag_input->unicap[tag->index]) ) - vj_unicap_grab_frame( vj_tag_input->unicap[tag->index], buffer, width,height ); - } -#endif switch( tag->noise_suppression ) { case V4L_BLACKFRAME: tag->cali_duration = tag->bf_count; diff --git a/veejay-current/veejay-server/libstream/vj-unicap.c b/veejay-current/veejay-server/libstream/vj-unicap.c deleted file mode 100644 index 4c07b59c..00000000 --- a/veejay-current/veejay-server/libstream/vj-unicap.c +++ /dev/null @@ -1,1486 +0,0 @@ -/* veejay - Linux VeeJay Unicap interface - * (C) 2002-2006 Niels Elburg - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include -#ifdef HAVE_UNICAP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef STRICT_CHECKING -#include -#endif - -#define BUFFERS 4 - -typedef struct -{ - unicap_handle_t handle; - unicap_device_t device; - unicap_format_t format_spec; - unicap_format_t format; - unicap_data_buffer_t buffer; - unicap_data_buffer_t mbuf[BUFFERS]; - pthread_mutex_t mutex; - pthread_t thread; - pthread_attr_t attr; - uint8_t *priv_buf; - int state; - int errors; - int deviceID; - int sizes[3]; - int active; - int rgb; - void *sampler; - char *ctrl[16]; - int option[16]; - int ready; - int frame_size; - int pause; - int dst_width; - int dst_height; - int src_width; - int src_height; - int dst_fmt; - int src_fmt; - int src_sizes[3]; - int dst_sizes[3]; - sws_template template; - void *scaler; - int composite; -} vj_unicap_t; - -static struct { - int i; - char *s; -} pixstr[] = { - {PIX_FMT_YUV420P, "YUVPIX_FMT_YUV420P"}, -{ PIX_FMT_YUV422P, "4:2:2 planar, Y-Cb-Cr ( 422P )"}, -{ PIX_FMT_YUVJ420P, "4:2:0 planar, Y-U-V (420P JPEG)"}, -{ PIX_FMT_YUVJ422P, "4:2:2 planar, Y-U-V (422P JPEG)"}, -{ PIX_FMT_RGB24, "RGB 24 bit"}, -{ PIX_FMT_BGR24, "BGR 24 bit"}, -{ PIX_FMT_YUV444P, "YUV 4:4:4 planar, Y-Cb-Cr (444P)"}, -{ PIX_FMT_YUVJ444P, "YUV 4:4:4 planar, Y-U-V (444P JPEG)"}, -{ PIX_FMT_RGB32, "RGB 32 bit"}, -{ PIX_FMT_BGR32, "BGR 32 bit"}, -{ PIX_FMT_GRAY8, "Greyscale"}, -{ PIX_FMT_RGB32_1, "RGB 32 bit LE"}, -{ 0 , NULL} - -}; - - -static const char *unicap_pf_str(int i) -{ - int j; - for( j = 0; pixstr[j].s != NULL ; j ++ ) { - if( i == pixstr[j].i ) - return pixstr[j].s; - } - return NULL; -} - -static void unicap_report_error( vj_unicap_t *v, char *err_msg ) -{ - - veejay_msg(0,"%s: %s", err_msg, v->device.identifier ); - veejay_msg(VEEJAY_MSG_DEBUG, - "Capture device delivers in %s, %dx%d strides=%d,%d,%d", - unicap_pf_str(v->src_fmt), v->src_width,v->src_height,v->src_sizes[0],v->src_sizes[1],v->src_sizes[2]); - veejay_msg(VEEJAY_MSG_DEBUG, - "System expects %s, %dx%d, strides=%d,%d,%d", - unicap_pf_str(v->dst_fmt), v->dst_width,v->dst_height,v->dst_sizes[0],v->dst_sizes[1],v->dst_sizes[2]); - -} - -typedef struct -{ - unicap_handle_t handle; - unicap_device_t device; - unicap_format_t format_spec; - unicap_format_t format; - unicap_data_buffer_t buffer; - void *device_list; - int num_devices; - int devices[16]; -} unicap_driver_t; - -static void *unicap_reader_thread(void *data); -static int vj_unicap_start_capture_( void *vut ); -static int vj_unicap_stop_capture_( void *vut ); -extern int get_ffmpeg_pixfmt( int id ); -static void vj_unicap_new_frame_cb( unicap_event_t event, unicap_handle_t handle, - unicap_data_buffer_t *ready_buffer, vj_unicap_t *v ); - -#ifdef STRICT_CHECKING -static void lock__(vj_unicap_t *t, const char *f, int line) { - pthread_mutex_lock(&(t->mutex)); -} -static void unlock__(vj_unicap_t *t, const char *f, int line) { - pthread_mutex_unlock(&(t->mutex)); -} -#define lock_(t) lock__(t,__FUNCTION__,__LINE__) -#define unlock_(t) unlock__(t, __FUNCTION__ ,__LINE__) - -#else -static void lock_(vj_unicap_t *t) -{ - pthread_mutex_lock( &(t->mutex )); -} -static void unlock_(vj_unicap_t *t) -{ - pthread_mutex_unlock( &(t->mutex )); -} -#endif - -static int vj_unicap_scan_enumerate_devices(void *unicap) -{ - int i=0; - unicap_driver_t *ud = (unicap_driver_t*) unicap; - char key[64]; - - memset( &(ud->device) , 0, sizeof(unicap_device_t)); - - unicap_void_device(&(ud->device)); - - - while( SUCCESS( unicap_enumerate_devices( NULL, &(ud->device), i )) ) - { - char *device_name = strdup( ud->device.identifier ); - void *device_port = vpn( VEVO_ANONYMOUS_PORT ); - char *device_location = strdup( ud->device.device ); - int error = vevo_property_set( device_port, - "name", - VEVO_ATOM_TYPE_STRING, - 1, - &device_name); - - veejay_msg( VEEJAY_MSG_DEBUG, "\tDevice %d: %s (%s)", i, ud->device.identifier, device_location ); - -#ifdef STRICT_CHECKING - assert( error == VEVO_NO_ERROR ); -#endif - sprintf(key ,"%d", i ); - error = vevo_property_set( ud->device_list, key, VEVO_ATOM_TYPE_PORTPTR,1,&device_port ); - -#ifdef STRICT_CHECKING - assert( error == VEVO_NO_ERROR ); -#endif - error = vevo_property_set( device_port, - "device", - VEVO_ATOM_TYPE_STRING, - 1, - &device_location ); -#ifdef STRICT_CHECKING - assert( error == VEVO_NO_ERROR ); -#endif - - free( device_location ); - free(device_name); - i++; - } - return i; -} - - -char **vj_unicap_get_devices(void *unicap, int *n_dev) -{ - int i,j=0; - unicap_driver_t *ud = (unicap_driver_t*) unicap; - char **result = NULL; - - if( ud->num_devices <= 0 ) - { - veejay_msg(0, "I didn't find any capture devices"); - return NULL; - } - - char **items = vevo_list_properties( ud->device_list ); - if(! items ) - { - veejay_msg(0, "Empty list of capture devices"); - return NULL; - } - - int len = 1; - int error = 0; - for ( i = 0; items[i] != NULL ; i ++ ) - { - error = vevo_property_get( ud->device_list,items[i], 0, NULL ); - if( error == VEVO_NO_ERROR ) - len ++; - } - - result = vj_calloc( sizeof(char*) * len ); - for( i = 0; items[i] != NULL ; i ++ ) - { - void *port = NULL; - error = vevo_property_get( ud->device_list, items[i], 0, &port ); - if( error == VEVO_NO_ERROR ) - { - size_t name_len = vevo_property_element_size( port, "name", 0 ); - char *name = (char*) vj_calloc( name_len ); - vevo_property_get( port, "name",0,&name ); - name_len = vevo_property_element_size( port, "device", 0 ); - char *loc = (char*) vj_calloc( name_len ); - vevo_property_get( port, "device", 0, &loc ); - int new_len = strlen(loc) + strlen(name) + 8; - - char *text = vj_calloc( new_len ); - snprintf(text, new_len, "%03d%s%03d%s",strlen(name), name,strlen(loc), loc ); - - free(name); - free(loc); - - result[j] = strdup(text ); - free(text); - j++; - } - free(items[i]); - } - free(items ); - - *n_dev = j; - return result; -} - -void *vj_unicap_init(void) -{ - unicap_driver_t *ud = (unicap_driver_t*) vj_calloc(sizeof(unicap_driver_t)); - ud->device_list = vpn( VEVO_ANONYMOUS_PORT ); - ud->num_devices = vj_unicap_scan_enumerate_devices( (void*) ud ); - veejay_msg(1, "Found %d capture devices on this system", ud->num_devices); - return ud; -} - -void vj_unicap_deinit(void *dud ) -{ - unicap_driver_t *ud = (unicap_driver_t*) dud; - if( ud ) - { - //vevo_port_recursive_free( ud->device_list ); - free(ud); - } - dud = NULL; -} - -int vj_unicap_property_is_menu( void *ud, char *key ) -{ - unicap_property_t property; - unicap_property_t property_spec; - int i; - unicap_void_property( &property_spec ); - unicap_void_property( &property ); - vj_unicap_t *vut = (vj_unicap_t*) ud; - unicap_lock_properties( vut->handle ); - - for( i = 0; SUCCESS( unicap_enumerate_properties( vut->handle, - &property_spec, &property, i ) ); i ++ ) - { - unicap_void_property( &property ); - - unicap_get_property( vut->handle, &property); - if( strcmp( property.identifier, key ) == 0 ) - { - unicap_unlock_properties( vut->handle); - if( property.type == UNICAP_PROPERTY_TYPE_MENU ) - return 1; - else - return 0; - } - } - unicap_unlock_properties( vut->handle); - return 0; -} -int vj_unicap_property_is_range( void *ud, char *key ) -{ - unicap_property_t property; - unicap_property_t property_spec; - int i; - unicap_void_property( &property_spec ); - unicap_void_property( &property ); - vj_unicap_t *vut = (vj_unicap_t*) ud; - unicap_lock_properties( vut->handle ); - - for( i = 0; SUCCESS( unicap_enumerate_properties( vut->handle, - &property_spec, &property, i ) ); i ++ ) - { - unicap_get_property( vut->handle, &property); - if( strcmp( property.identifier, key ) == 0 ) - { - unicap_unlock_properties( vut->handle); - if( property.type == UNICAP_PROPERTY_TYPE_RANGE ) - return 1; - else - return 0; - } - } - unicap_unlock_properties( vut->handle); - return 0; -} - -int vj_unicap_select_value( void *ud, int key, double attr ) -{ - unicap_property_t property; - unicap_property_t property_spec; - int i; - unicap_void_property( &property_spec ); - unicap_void_property( &property ); - vj_unicap_t *vut = (vj_unicap_t*) ud; - - if(! vut->ctrl[key] ) - { - veejay_msg(VEEJAY_MSG_DEBUG, "Capture device %s has no property %x", - vut->device.identifier, key ); - return 0; - } - - unicap_lock_properties( vut->handle ); - - for( i = 0; SUCCESS( unicap_enumerate_properties( vut->handle, - &property_spec, &property, i ) ); i ++ ) - { - unicap_get_property( vut->handle, &property); - if( strcmp( property.identifier, vut->ctrl[key] ) == 0 ) - { - if( property.type == UNICAP_PROPERTY_TYPE_MENU ) - { - int idx = vut->option[ key ]; - veejay_strncpy( property.menu_item, property.menu.menu_items[idx], strlen( property.menu.menu_items[idx]) ); - unicap_set_property( vut->handle, &property ); - unicap_unlock_properties( vut->handle ); - return 1; - } - if( property.type == UNICAP_PROPERTY_TYPE_RANGE ) - { - double fval = attr; - if(fval < property.range.min) - fval = property.range.min; - else if(fval > property.range.max) - fval = property.range.max; - property.value = fval; - unicap_set_property( vut->handle, &property ); - unicap_unlock_properties( vut->handle ); - return 1; - } - } - } - unicap_unlock_properties( vut->handle ); - - return 0; -} - -int vj_unicap_get_range( void *ud, char *key, double *min , double *max ) -{ - unicap_property_t property; - unicap_property_t property_spec; - int i; - unicap_void_property( &property_spec ); - unicap_void_property( &property ); - vj_unicap_t *vut = (vj_unicap_t*) ud; - unicap_lock_properties( vut->handle ); - - for( i = 0; SUCCESS( unicap_enumerate_properties( vut->handle, - &property_spec, &property, i ) ); i ++ ) - { - // memset( &property,0,sizeof(unicap_property_t)); - unicap_get_property( vut->handle, &property); - - if( strcasecmp( property.identifier, key ) == 0 ) - { - - if( property.type == UNICAP_PROPERTY_TYPE_MENU ) - { - *min = 0.0; - *max = (double) property.menu.menu_item_count; - unicap_unlock_properties( vut->handle ); - - return 1; - } - if( property.type == UNICAP_PROPERTY_TYPE_RANGE ) - { - *min = property.range.min; - *max = property.range.max; - unicap_unlock_properties( vut->handle ); - - return 1; - } - } - } - unicap_unlock_properties( vut->handle ); - - return 0; -} - -char **vj_unicap_get_list( void *ud ) -{ - unicap_property_t property; - unicap_property_t property_spec; - int i; - unicap_void_property( &property_spec ); - vj_unicap_t *vut = (vj_unicap_t*) ud; - unicap_lock_properties( vut->handle ); - - for( i = 0; SUCCESS( unicap_enumerate_properties( vut->handle, - &property_spec, &property, i ) ); i ++ ) - { - } - - int n = i; - - char **res = (char**) vj_calloc(sizeof(char*) * (n+1) ); - - for( i = 0;i < n; i ++ ) - { - if( SUCCESS( unicap_enumerate_properties(vut->handle, - &property_spec,&property,i ) ) ) - { - res[i] = strdup( property.identifier ); - } - } - - unicap_unlock_properties( vut->handle ); - - return res; -} - - -int vj_unicap_get_value( void *ud, char *key, int atom_type, void *value ) -{ - unicap_property_t property; - unicap_property_t property_spec; - int i; - unicap_void_property( &property_spec ); - vj_unicap_t *vut = (vj_unicap_t*) ud; - unicap_lock_properties( vut->handle ); - - for( i = 0; SUCCESS( unicap_enumerate_properties( vut->handle, - &property_spec, &property, i ) ); i ++ ) - { - unicap_get_property( vut->handle, &property); - - if( strcmp( property.identifier, key ) != 0 ) - continue; - - if( property.type == UNICAP_PROPERTY_TYPE_MENU ) - { -#ifdef STRICT_CHECKING - assert( atom_type == VEVO_ATOM_TYPE_DOUBLE ); -#endif - int n = property.menu.menu_item_count; - int j; - for( j =0; j < n; j ++ ) - { - if( strcmp( property.menu_item, property.menu.menu_items[j] ) == 0 ) - { - double *dval = value; - *dval = (double) j; - unicap_unlock_properties( vut->handle ); - - return 1; - } - } - } - if( property.type == UNICAP_PROPERTY_TYPE_RANGE ) - { -#ifdef STRICT_CHECKING - assert( atom_type == VEVO_ATOM_TYPE_DOUBLE ); -#endif - double *dval = value; - *dval = property.value; - unicap_unlock_properties( vut->handle ); - - return 1; - } - } - unicap_unlock_properties( vut->handle ); - - return 0; -} - -int vj_unicap_num_capture_devices( void *dud ) -{ - unicap_driver_t *ud = (unicap_driver_t*) dud; - return ud->num_devices; -} - -void *vj_unicap_new_device( void *dud, int device_id ) -{ - unicap_driver_t *ud = (unicap_driver_t*) dud; - if( ud->num_devices <= 0 ) - { - veejay_msg(0, "I didn't find any capture devices"); - return NULL; - } - if( ud->devices[ device_id ] ) - { - veejay_msg(0, "Device ID %d already openened in use by Veejay"); - return NULL; - } - - if( device_id < 0 || device_id >= ud->num_devices ) - { - veejay_msg(0, "I only found %d devices, requested: %d", ud->num_devices,device_id ); - return NULL; - } - - veejay_msg(VEEJAY_MSG_DEBUG, "Trying to open Capture Device %d", device_id); - - vj_unicap_t *vut = (vj_unicap_t*) vj_calloc(sizeof(vj_unicap_t)); - veejay_memset(vut->ctrl, 0 , sizeof(char*) *16 ); - veejay_memset(vut->option,0, sizeof(int) * 16 ); - vut->deviceID = device_id; - - if( !SUCCESS( unicap_enumerate_devices( NULL, &(vut->device), device_id ) ) ) - { - veejay_msg(0, "Failed to get info for device '%s'\n", vut->device.identifier ); - free(vut); - return NULL; - } - - if( !SUCCESS( unicap_open( &(vut->handle), &(vut->device) ) ) ) - { - veejay_msg(0, "Failed to open capture device '%s'\n", vut->device.identifier ); - free(vut); - return NULL; - } - - ud->devices[ vut->deviceID ] = 1; - veejay_msg(2, "Using device '%s'", vut->device.identifier); - - pthread_mutex_init( &(vut->mutex), NULL ); - - return (void*) vut; -} -static unsigned int -get_fourcc(char * fourcc) -{ - return ((((unsigned int)(fourcc[0])<<0)| - ((unsigned int)(fourcc[1])<<8)| - ((unsigned int)(fourcc[2])<<16)| - ((unsigned int)(fourcc[3])<<24))); -} - -static inline int get_shift_size(int fmt) -{ - switch(fmt) - { - case FMT_420: - case FMT_420F: - return 1; - case FMT_422: - case FMT_422F: - return 1; - default: - break; - } - return 0; -} - -int vj_unicap_composite_status(void *ud ) -{ - vj_unicap_t *vut = (vj_unicap_t*) ud; - return vut->composite; -} - - -int vj_unicap_configure_device( void *ud, int pixel_format, int w, int h, int composite ) -{ - vj_unicap_t *vut = (vj_unicap_t*) ud; - unsigned int fourcc = 0; - int found_native = 0; - int i; - unicap_lock_properties( vut->handle ); - - unicap_void_format( &(vut->format_spec)); - unicap_void_format( &(vut->format) ); - - vut->composite = composite; - vut->dst_fmt = get_ffmpeg_pixfmt( pixel_format ); - vut->src_fmt = get_ffmpeg_pixfmt( pixel_format ); - vut->format.buffer_type = UNICAP_BUFFER_TYPE_USER; - vut->template.flags = yuv_which_scaler(); - vut->scaler = NULL; - - switch( pixel_format ) { - case FMT_420: - case FMT_420F: - fourcc = get_fourcc("YU12" );break; - case FMT_422: - case FMT_422F: - fourcc = get_fourcc("422P");break; - } - -/* if( vut->composite ) { - switch(vut->composite) { - case 1: - vut->dst_fmt = PIX_FMT_YUV444P; - break; - case 2: - vut->dst_fmt = PIX_FMT_GRAY8; - break; - } - }*/ - - for( i = 0; SUCCESS( unicap_enumerate_formats( vut->handle, NULL, &(vut->format), i ) ); i ++ ) - { - if( fourcc == vut->format.fourcc ) - { - veejay_msg(VEEJAY_MSG_INFO, "Found native colorspace '%s'", vut->format.identifier); - found_native = 1; - break; - } - if( vut->format.fourcc == get_fourcc("RGB3") || vut->format.fourcc == get_fourcc("BGR3") ) - break; - } - - int maxw = vut->format.max_size.width; - int maxh = vut->format.max_size.height; - int minw = vut->format.min_size.width; - int minh = vut->format.min_size.height; - int search = 0; - int j = 0; - - if( w > maxw || h > maxh ) { - veejay_msg(VEEJAY_MSG_WARNING, "%s does not support %dx%d, using %dx%d instead with a software scaler.", - vut->device.identifier, w,h,maxw,maxh ); - search = 1; - } else { - vut->src_width = w; - vut->src_height= h; - vut->dst_width = w; - vut->dst_height = h; - vut->dst_sizes[0] = vut->dst_width * vut->dst_height; - - if ( vut->format.fourcc == get_fourcc("422P" ) ) { - vut->src_sizes[0] = vut->src_width * vut->src_height; - vut->src_sizes[1] = vut->src_sizes[0]/2; - vut->src_sizes[2] = vut->src_sizes[1]/2; - vut->src_fmt = PIX_FMT_YUV422P; - vut->frame_size = vut->src_sizes[0] + vut->src_sizes[1] + vut->src_sizes[2]; - } else if ( vut->format.fourcc == get_fourcc("420P")) { - vut->src_sizes[0] = vut->src_width * vut->src_height; - vut->src_sizes[1] = vut->src_sizes[0]/4; - vut->src_sizes[2] = vut->src_sizes[1]/4; - vut->src_fmt = PIX_FMT_YUV420P; - vut->frame_size = vut->src_sizes[0] + vut->src_sizes[1] + vut->src_sizes[2]; - } - vut->format.buffer_size = vut->frame_size; - vut->format.size.width = vut->src_width; - vut->format.size.height = vut->src_height; - - if(vut->frame_size<=0 ) - search = 1; - } - - if( search || !SUCCESS( unicap_set_format( vut->handle, &(vut->format) ) ) ) - { - int try_format[10] = { maxw,maxh,720,576,640,480,320,240, minw,minh }; - int good = 0; - for( i = 0; i < 10 ; i +=2 ) { - vut->src_width = try_format[i]; - vut->src_height= try_format[i+1]; - vut->dst_width = w; - vut->dst_height = h; - vut->dst_sizes[0] = vut->dst_width * vut->dst_height; - - if ( vut->format.fourcc == get_fourcc("422P" ) ) { - vut->src_sizes[0] = vut->src_width * vut->src_height; - vut->src_sizes[1] = vut->src_sizes[0]/2; - vut->src_sizes[2] = vut->src_sizes[1]/2; - vut->src_fmt = PIX_FMT_YUV422P; - vut->frame_size = vut->src_sizes[0] + vut->src_sizes[1] + vut->src_sizes[2]; - } else if ( vut->format.fourcc == get_fourcc("420P")) { - vut->src_sizes[0] = vut->src_width * vut->src_height; - vut->src_sizes[1] = vut->src_sizes[0]/4; - vut->src_sizes[2] = vut->src_sizes[1]/4; - vut->src_fmt = PIX_FMT_YUV420P; - vut->frame_size = vut->src_sizes[0] + vut->src_sizes[1] + vut->src_sizes[2]; - } else if( ( vut->format.fourcc == get_fourcc("RGB3") ) - || (vut->format.fourcc == get_fourcc("BGR3") ) ) { - vut->src_sizes[0] = vut->src_width * 3; - vut->src_sizes[1] = 0; vut->src_sizes[2] = 0; - vut->src_fmt = PIX_FMT_RGB24; - vut->rgb = 1; - if(vut->format.fourcc == get_fourcc("BGR3") ) - vut->src_fmt = PIX_FMT_BGR24; - vut->frame_size = vut->src_width * vut->src_height * 3; - }/* else if ( (vut->format.fourcc == get_fourcc("RGB4") ) || - (vut->format.fourcc == get_fourcc("BGR4") ) ) { - vut->src_sizes[0] = vut->src_width * 4; - vut->src_sizes[1] = 0; vut->src_sizes[2] = 0; - vut->src_fmt = PIX_FMT_RGB32; - vut->rgb = 1; - if(vut->format.fourcc == get_fourcc("BGR4") ) - vut->src_fmt = PIX_FMT_BGR32; - vut->frame_size = vut->src_width * vut->src_height * 4; - } */ -#ifdef STRICT_CHECKING - else { - veejay_msg(0, "Invalid pixel format: %s", vut->format.identifier); - assert( 0 ); - } -#endif - - vut->format.buffer_size = vut->frame_size; - vut->format.size.width = vut->src_width; - vut->format.size.height = vut->src_height; - - if( SUCCESS( unicap_set_format( vut->handle, &(vut->format)) ) ) - { - veejay_msg(VEEJAY_MSG_WARNING, - "(OK) Source %dx%d in %s , Dest %dx%d in %s (%d bytes framebuffer)", - vut->src_width,vut->src_height,vut->format.identifier,vut->dst_width, - vut->dst_height, unicap_pf_str(vut->dst_fmt), - vut->format.buffer_size ); - - good = 1; - break; - } - else - { - veejay_msg(VEEJAY_MSG_ERROR, - "(FAIL) Source %dx%d in %s , Dest %dx%d in %s (%d bytes framebuffer)", - vut->src_width,vut->src_height,vut->format.identifier,vut->dst_width, - vut->dst_height, unicap_pf_str(vut->dst_fmt), - vut->format.buffer_size ); - } - } - - if(!good) { - veejay_msg(VEEJAY_MSG_ERROR,"Cannot configure capture device %s", vut->format.identifier ); - unicap_unlock_properties( vut->handle ); - return 0; - } - } - else - { - veejay_msg(VEEJAY_MSG_INFO, "Okay, Capture device delivers %s image, %d x %d %d bytes buffer", - vut->format.identifier, vut->format.size.width,vut->format.size.height, - vut->format.buffer_size ); - - vut->src_width = vut->format.size.width; - vut->src_height= vut->format.size.height; - vut->dst_width = w; - vut->dst_height = h; - vut->dst_sizes[0] = vut->dst_width * vut->dst_height; - if ( vut->format.fourcc == get_fourcc("422P" ) ) { - vut->src_sizes[0] = vut->src_width * vut->src_height; - vut->src_sizes[1] = vut->src_sizes[0]/2; - vut->src_sizes[2] = vut->src_sizes[1]/2; - vut->src_fmt = PIX_FMT_YUV422P; - vut->frame_size = vut->src_sizes[0] + vut->src_sizes[1] + vut->src_sizes[2]; - } else if ( vut->format.fourcc == get_fourcc("420P")) { - vut->src_sizes[0] = vut->src_width * vut->src_height; - vut->src_sizes[1] = vut->src_sizes[0]/4; - vut->src_sizes[2] = vut->src_sizes[1]/4; - vut->src_fmt = PIX_FMT_YUV420P; - vut->frame_size = vut->src_sizes[0] + vut->src_sizes[1] + vut->src_sizes[2]; - } else if( ( vut->format.fourcc == get_fourcc("RGB3") ) - || (vut->format.fourcc == get_fourcc("BGR3") ) ) { - vut->src_sizes[0] = vut->src_width * 3; - vut->src_sizes[1] = 0; vut->src_sizes[2] = 0; - vut->src_fmt = PIX_FMT_RGB24; - vut->rgb = 1; - if(vut->format.fourcc == get_fourcc("BGR3") ) - vut->src_fmt = PIX_FMT_BGR24; - vut->frame_size = vut->src_width * vut->src_height * 3; - } -#ifdef STRICT_CHECKING - else { - veejay_msg(0, "Invalid pixel format: %s", vut->format.identifier); - assert( 0 ); - } -#endif - - vut->format.buffer_size = vut->frame_size; - vut->format.size.width = vut->src_width; - vut->format.size.height = vut->src_height; - - if( SUCCESS( unicap_set_format( vut->handle, &(vut->format)) ) ) - { - veejay_msg(VEEJAY_MSG_WARNING, - "(OK) Source %dx%d in %s , Dest %dx%d in %s (%d bytes framebuffer)", - vut->src_width,vut->src_height,vut->format.identifier,vut->dst_width, - vut->dst_height, unicap_pf_str(vut->dst_fmt), - vut->format.buffer_size ); - } - else - { - veejay_msg(VEEJAY_MSG_ERROR, - "(FAIL) Source %dx%d in %s , Dest %dx%d in %s (%d bytes framebuffer)", - vut->src_width,vut->src_height,vut->format.identifier,vut->dst_width, - vut->dst_height, unicap_pf_str(vut->dst_fmt), - vut->format.buffer_size ); - return 0; - } - - - - } - -/* if(vut->composite) { - vut->dst_sizes[1] = vut->dst_sizes[0]; - vut->dst_sizes[2] = vut->dst_sizes[0]; - } else */ - if(pixel_format == FMT_420F || pixel_format == FMT_420 ) { - vut->dst_sizes[1] = vut->dst_sizes[0]/4; - vut->dst_sizes[2] = vut->dst_sizes[1]; - } else { - vut->dst_sizes[1] = vut->dst_sizes[0]/2; - vut->dst_sizes[2] = vut->dst_sizes[1]; - } - - -// buffer alloced - char **properties = vj_unicap_get_list( vut ); - if(!properties) - { - veejay_msg(0, "No properties for this capture device ?!"); - unicap_unlock_properties( vut->handle ); - return 1; - } - - for( i = 0; properties[i] != NULL && i < 16; i ++ ) - { - if(strncasecmp( properties[i], "brightness",10 ) == 0 ) { - vut->ctrl[UNICAP_BRIGHTNESS] = strdup( properties[i] ); - } else if (strncasecmp( properties[i], "color", 5 ) == 0 ) { - vut->ctrl[UNICAP_COLOR] = strdup( properties[i]); - } else if (strncasecmp( properties[i], "saturation", 10 ) == 0 ) { - vut->ctrl[UNICAP_SATURATION] = strdup( properties[i] ); - } else if (strncasecmp( properties[i], "hue", 3 ) == 0 ) { - vut->ctrl[UNICAP_HUE] = strdup( properties[i] ); - } else if(strncasecmp( properties[i], "white", 5) == 0 ) { - vut->ctrl[UNICAP_WHITE] = strdup(properties[i]); - } else if (strncasecmp( properties[i], "contrast", 8 ) == 0 ) { - vut->ctrl[UNICAP_CONTRAST] = strdup( properties[i] ); - } else if (strncasecmp( properties[i], "video source",12) == 0 ) { - unicap_property_t p; - unicap_void_property( &p ); - strcpy( p.identifier, properties[i] );//, strlen( properties[i])); - unicap_get_property( vut->handle, &p ); - for(j=0;joption[UNICAP_SOURCE0+j] = j; - vut->ctrl[UNICAP_SOURCE0+j] = strdup(properties[i]); - } - }else if (strncasecmp( properties[i], "video norm",10) == 0 ) { - unicap_property_t p; - unicap_void_property( &p ); - strcpy( p.identifier, properties[i] ); //, strlen(i)); - unicap_get_property( vut->handle, &p ); - for(j=0;jctrl[UNICAP_PAL] = strdup(properties[i]); - vut->option[UNICAP_PAL] = j; - } - else if( strncasecmp( p.menu.menu_items[j], "ntsc", 4 ) == 0 ) - { - vut->ctrl[UNICAP_NTSC] = strdup(properties[i]); - vut->option[UNICAP_NTSC] = j; - } - } - } - - free( properties[i]); - } - free(properties); - - - unicap_unlock_properties( vut->handle ); - - return 1; -} - -int vj_unicap_start_capture( void *vut ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; -#ifdef STRICT_CHECKING - assert( v->priv_buf == NULL ); - assert( v->active == 0 ); -#endif - - veejay_msg(VEEJAY_MSG_INFO,"Preparing to capture from device %s", v->device.identifier ); -#ifndef USE_UNICAP_CB - pthread_attr_init(&(v->attr) ); - pthread_attr_setdetachstate(&(v->attr), PTHREAD_CREATE_DETACHED ); - - int err = pthread_create( &(v->thread), NULL, - unicap_reader_thread, vut ); - - pthread_attr_destroy( &(v->attr) ); - - if( err == 0 ) - { - veejay_msg(VEEJAY_MSG_INFO, "Spawned new capture thread for device %s", v->device.identifier ); - return 1; - } - v->state = 0; - veejay_msg(VEEJAY_MSG_ERROR, - "Unable to start capture thread for device %s: %s", v->device.identifier, strerror(err)); - return 0; -#else - if(!vj_unicap_start_capture_(vut)) - veejay_msg(VEEJAY_MSG_ERROR, "Unable to start capture thread for device %s", - v->device.identifier ); - else - { - veejay_msg(VEEJAY_MSG_INFO, "Capturing from device %s", v->device.identifier ); - return 1; - } - - return 0; -#endif -} - -int vj_unicap_stop_capture( void *vut ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; - - veejay_msg(VEEJAY_MSG_INFO, "Stopping capture from device %s", v->device.identifier ); -#ifndef USE_UNICAP_CB - lock_ ( vut ); - v->state = 0; - unlock_( vut ); - - usleep( 200 * 1000 ); //@ bad way to sync threads - - lock_( vut ); - if( v->active ) - veejay_msg(VEEJAY_MSG_INFO, "Capture thread still running. Cancel %s", v->device.identifier); - unlock_(vut); - pthread_cancel( v->thread ); - - if(v->active) - { - veejay_msg(VEEJAY_MSG_WARNING, "Cleaning up capture thread from device %s",v->device.identifier); - vj_unicap_stop_capture_( vut ); - } -#else - //@todo -#endif - return 1; -} - - - - -static int vj_unicap_start_capture_( void *vut ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; -#ifdef STRICT_CHECKING - assert( v->priv_buf == NULL ); - assert( v->buffer.data == NULL ); - assert( v->active == 0 ); - assert( v->state == 0 ); -#endif - int i; - - if( v->src_width == v->dst_width && v->src_height == v->dst_height ) { - v->priv_buf = (uint8_t*) vj_calloc( v->dst_width * v->dst_height * 4 * sizeof(uint8_t) ); - v->buffer.data = vj_malloc( v->frame_size * sizeof(uint8_t) ); - if(!v->rgb){ - veejay_memset( v->buffer.data, 0, v->src_sizes[1] ); - veejay_memset( v->buffer.data + v->src_sizes[0], 128, v->src_sizes[1] + v->src_sizes[2]); - } else { - veejay_memset( v->buffer.data, 0, v->src_sizes[0]); - } - for( i = 0; i < BUFFERS; i ++ ) - { - veejay_memset( &(v->mbuf[i]),0x0, sizeof(unicap_data_buffer_t)); - v->mbuf[i].data = vj_malloc(v->frame_size * sizeof(uint8_t)); - } - - } else { -#ifdef STRICT_CHECKING - assert( v->dst_width > 0 ); - assert( v->dst_height > 0 ); - assert( v->frame_size > 0 ); -#endif - v->priv_buf = (uint8_t*) vj_calloc( v->dst_width * v->dst_height * 4 * sizeof(uint8_t) ); - v->buffer.data = vj_calloc( v->format.buffer_size * sizeof(uint8_t) * 2 ); - for( i = 0; i < BUFFERS; i ++ ) - { - veejay_memset( &(v->mbuf[i]),0x0, sizeof(unicap_data_buffer_t)); - v->mbuf[i].data = vj_calloc(v->format.buffer_size * sizeof(uint8_t)); - } - - - } - - - v->buffer.buffer_size = v->format.buffer_size; - -#ifdef USE_UNICAP_CB - unicap_register_callback( v->handle, UNICAP_EVENT_NEW_FRAME, - (unicap_callback_t) vj_unicap_new_frame_cb, &v ); -#endif - if( !SUCCESS( unicap_start_capture( v->handle ) ) ) - { - free(v->priv_buf); - v->priv_buf = NULL; - unicap_report_error(v, "Failed to start capture on device" ); - return 0; - } -#ifndef USE_UNICAP_CB -/* if( ! SUCCESS( unicap_queue_buffer( v->handle, &(v->buffer) )) ) - { - veejay_msg(VEEJAY_MSG_DEBUG, "%s:%d Failed to queue buffer ",__FUNCTION__,__LINE__); - free(v->priv_buf); - v->priv_buf = NULL; - return 0; - } -*/ - for( i = 0; i < BUFFERS; i ++ ) { - - if( ! SUCCESS( unicap_queue_buffer( v->handle, &(v->mbuf[i]) )) ) - { - veejay_msg(VEEJAY_MSG_DEBUG, "%s:%d Failed to queue buffer ",__FUNCTION__,__LINE__); - free(v->priv_buf); - v->priv_buf = NULL; - return 0; - } - } -#endif - v->active = 1; -#ifdef USE_UNICAP_CB - v->state = 1; - veejay_msg(VEEJAY_MSG_INFO,"Started capture from device %s", v->device.identifier ); -#else - veejay_msg(VEEJAY_MSG_INFO, "Thread: started capture from device %s", v->device.identifier ); -#endif - return 1; -} - -int vj_unicap_get_pause( void *vut ) { - vj_unicap_t *v = (vj_unicap_t*) vut; - return v->pause; -} - -void vj_unicap_set_pause( void *vut , int status ) { - vj_unicap_t *v = (vj_unicap_t*) vut; - lock_(vut); - v->pause = status; - unlock_(vut); -} - -int vj_unicap_grab_frame( void *vut, uint8_t *buffer[3], const int width, const int height ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; -// lock_( vut ); - - if(v->active == 0 || v->state == 0 ) - { -// unlock_(vut); - return 0; - } - - if( v->pause ) - { -// unlock_(vut); - return 1; - } - -#ifdef STRICT_CHECKING - assert(v->priv_buf != NULL ); -#endif -//veejay_msg(0, "Copy captured frame:%dx%d, sizes=%d,%d,%d,dst=%d,%d,%d,rgb=%d", -// v->src_width,v->src_height,v->sizes[0],v->sizes[1],v->sizes[2], -// v->dst_sizes[0],v->dst_sizes[1],v->dst_sizes[2],v->rgb ); - lock_(vut); - if( v->src_width == v->dst_width && v->src_height == v->dst_height ) - { - uint8_t *src[3]; - int y = v->sizes[0]; - int u = v->sizes[1]; - int uu = v->sizes[2]; - - if( !v->rgb ) { - src[0] = v->priv_buf; - src[1] = v->priv_buf + v->sizes[0]; - src[2] = v->priv_buf + v->sizes[0] + v->sizes[1]; - } else { - src[0] = v->priv_buf; - src[1] = v->priv_buf + v->dst_sizes[0]; - src[2] = v->priv_buf + v->dst_sizes[0] + v->dst_sizes[1]; - u = v->dst_sizes[1]; - uu = v->dst_sizes[2]; - y = v->dst_sizes[0]; - } - veejay_memcpy( buffer[0], src[0], y ); - veejay_memcpy( buffer[1], src[1], u ); - veejay_memcpy( buffer[2], src[2], uu ); - } else { - uint8_t *src[3] = { - v->priv_buf, - v->priv_buf + v->dst_sizes[0], - v->priv_buf + v->dst_sizes[0] + v->dst_sizes[1] }; - veejay_memcpy( buffer[0], src[0], v->dst_sizes[0] ); - veejay_memcpy( buffer[1], src[1], v->dst_sizes[1] ); - veejay_memcpy( buffer[2], src[2], v->dst_sizes[2] ); - } - - unlock_(vut); - return 1; -} -#ifndef USE_UNICAP_CB - -static void print_fps( ) -{ - static struct timeval next,current; - static int count = 0; - suseconds_t usec; - - if( count == 0 ) - { - gettimeofday(&next, NULL); - next.tv_sec += 1; - } - - count++; - - gettimeofday(¤t, NULL); - - if( timercmp( &next, ¤t, <= ) ) - { - printf( "FPS: %d\n", count ); - count = 0; - } -} - -int vj_unicap_grab_a_frame( void *vut ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; - unicap_data_buffer_t *ready_buffer = NULL; - uint8_t *buffer[3]; - int i; - if( v->src_width == v->dst_width && v->src_height == v->dst_height ) - { - buffer[0] = v->priv_buf; - buffer[1] = v->priv_buf + v->sizes[0]; - buffer[2] = v->priv_buf + v->sizes[0] + v->sizes[1]; - } else { - buffer[0] = v->priv_buf; - buffer[1] =v->priv_buf + v->dst_sizes[0]; - buffer[2] =v->priv_buf + v->dst_sizes[0] + v->dst_sizes[1]; - } - - if(!v->active) - { - veejay_msg(VEEJAY_MSG_ERROR, "Capture not started on device %d", v->deviceID); - return 0; - } - - int buffers_ready = 0; - - if( v->state == 0 || v->active == 0 ) - { - return 0; - } - - - if(!SUCCESS(unicap_poll_buffer( v->handle, &buffers_ready ) ) ) { - buffers_ready = 1; - } - - if( buffers_ready == 0 ) - return 0; - - for( i = 0; i < buffers_ready-1; i ++ ) { - if(! SUCCESS(unicap_wait_buffer(v->handle, &ready_buffer ) )) - { - veejay_msg(VEEJAY_MSG_WARNING, "Failed to wait for buffer from device %s", - v->device.identifier ); - return 1; - } - unicap_queue_buffer( v->handle, ready_buffer ); - } - - if( (!SUCCESS(unicap_wait_buffer(v->handle,&ready_buffer ) ) ) ) { - veejay_msg(0, "Failed to wait for buffer on device"); - return 1; - } - - if( ready_buffer->buffer_size <= 0 ) - { - veejay_msg(0, "Unicap returned a buffer of size 0!"); - return 0; - } - - if(!ready_buffer->data ) - { - veejay_msg(0, "Unicap returned a NULL buffer!"); - return 0; - } - //print_fps(); - lock_(vut); - if(!v->rgb) - { - if( v->src_width == v->dst_width && v->src_height == v->dst_height ) - { - veejay_memcpy( buffer[0], ready_buffer->data, v->sizes[0] ); - veejay_memcpy( buffer[1], ready_buffer->data + v->sizes[0], v->sizes[1] ); - veejay_memcpy( buffer[2], ready_buffer->data + v->sizes[0] +v->sizes[1] , v->sizes[2]); - } - else { - VJFrame *srci = yuv_yuv_template( ready_buffer->data, - ready_buffer->data + v->src_sizes[0], - ready_buffer->data + v->src_sizes[0] + v->src_sizes[1], - v->src_width, - v->src_height, v->src_fmt ); - VJFrame *dsti = yuv_yuv_template( buffer[0],buffer[1],buffer[2], - v->dst_width,v->dst_height, v->dst_fmt ); - if(!v->scaler) { - v->scaler = yuv_init_swscaler( srci,dsti,&(v->template),yuv_sws_get_cpu_flags()); - } - - yuv_convert_and_scale( v->scaler, srci,dsti ); - free(srci); - free(dsti); - } - } - else - { - if( v->src_width == v->dst_width && v->src_height == v->dst_height ) - { - VJFrame *srci = yuv_rgb_template( ready_buffer->data, v->src_width,v->src_height, v->src_fmt ); - VJFrame *dsti = yuv_yuv_template( v->priv_buf, - v->priv_buf + v->dst_sizes[0], - v->priv_buf + v->dst_sizes[0] + v->dst_sizes[1], - v->dst_width, - v->dst_height, - v->dst_fmt ); - if(!v->scaler) { - v->scaler = yuv_init_swscaler( srci,dsti,&(v->template),yuv_sws_get_cpu_flags()); - } - yuv_convert_and_scale_from_rgb( v->scaler, srci,dsti ); - - - free(srci); - free(dsti); - } - else { - VJFrame *srci = yuv_rgb_template( ready_buffer->data, v->src_width,v->src_height, v->src_fmt ); - VJFrame *dsti = yuv_yuv_template( v->priv_buf, - v->priv_buf + v->dst_sizes[0], - v->priv_buf + v->dst_sizes[0] + v->dst_sizes[1], - v->dst_width,v->dst_height, v->dst_fmt ); - if(!v->scaler) { - v->scaler = yuv_init_swscaler( srci,dsti,&(v->template),yuv_sws_get_cpu_flags()); - } - yuv_convert_and_scale_from_rgb( v->scaler, srci,dsti ); - free(srci); - free(dsti); - } - } - unlock_(vut); - - if( ! SUCCESS( unicap_queue_buffer( v->handle, ready_buffer) )) - { - veejay_msg(VEEJAY_MSG_DEBUG, "%s:%d Failed to queue buffer ",__FUNCTION__,__LINE__); - return 0; - } - if(v->dst_fmt == PIX_FMT_GRAY8) { - veejay_memset( buffer[1], 128, v->dst_sizes[0]); - veejay_memset( buffer[2], 128, v->dst_sizes[0]); - } - - return 1; -} -#else -static void vj_unicap_new_frame_cb( unicap_event_t event, unicap_handle_t handle, - unicap_data_buffer_t *ready_buffer, vj_unicap_t *v ) -{ -veejay_msg(0, "%s: wait",__FUNCTION__); - lock_(v); - - uint8_t *buffer[3] = - { - v->priv_buf, - v->priv_buf + v->sizes[0], - v->priv_buf + v->sizes[0] + v->sizes[1] - }; - - if( v->deinterlace ) - { - } - else - { - if(!v->rgb) - { - veejay_memcpy( buffer[0], ready_buffer->data, v->sizes[0] ); - veejay_memcpy( buffer[1], ready_buffer->data + v->sizes[0], v->sizes[1] ); - veejay_memcpy( buffer[2], ready_buffer->data + v->sizes[0] +v->sizes[1] , v->sizes[2]); - } - else - { - VJFrame *srci = yuv_rgb_template( ready_buffer->data, v->src_width,v->src_height, vut->src_fmt ); - VJFrame *dsti = yuv_yuv_template( buffer[0],buffer[1],buffer[2], v->dst_width,v->dst_height, vut->dst_fmt ); - - yuv_convert_any_ac(srci,dsti, srci->format, dsti->format ); - - free(srci); - free(dsti); - } - } - unlock_(v); -} -#endif - - -static int vj_unicap_stop_capture_( void *vut ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; - - - if( !SUCCESS( unicap_stop_capture( v->handle ) ) ) - { - veejay_msg(0,"Failed to stop capture on device: %s\n", v->device.identifier ); - } - - if(v->priv_buf) - free(v->priv_buf); - if(v->buffer.data) - free(v->buffer.data); - v->priv_buf = NULL; - v->buffer.data = NULL; - v->active = 0; - v->state = 0; - veejay_msg(VEEJAY_MSG_INFO, "Stopped capture from device %s", - v->device.identifier ); - return 1; -} - -int vj_unicap_status(void *vut) -{ - if(!vut) return 0; - vj_unicap_t *v = (vj_unicap_t*) vut; - return v->active; -} - -#ifndef USE_UNICAP_CB -static void unicap_delay(long nsec ) -{ - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = nsec * 1000000; - nanosleep( &ts, NULL ); -} - - -static void *unicap_reader_thread(void *data) -{ - vj_unicap_t *v = (vj_unicap_t*) data; - - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - - - if(! vj_unicap_start_capture_( data ) ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Thread:Unable to start capture from device %s", v->device.identifier); - if(v->priv_buf) - free(v->priv_buf); - if(v->buffer.data) - free(v->buffer.data); - if(v->scaler) - yuv_free_swscaler(v->scaler); - v->priv_buf = NULL; - v->buffer.data = NULL; - v->active = 0; - v->state = 0; - v->scaler = NULL; - pthread_exit(NULL); - return NULL; - } - - v->state = 1; // thread run - //long s = 85000; - while( v->state ) - { - if( v->active ) - { - if(vj_unicap_grab_a_frame( data )==0) - { - veejay_msg(VEEJAY_MSG_ERROR, "Unable to grab a frame from capture device %d", v->deviceID); - v->errors = (v->errors + 1) % 5; - if( v->errors == 4 ) { - veejay_msg(VEEJAY_MSG_ERROR, "Stopping capture device."); - v->state = 0; - } else { - unicap_delay(5000); - } - } else { - v->errors = 0; - } - } - } - - veejay_msg(VEEJAY_MSG_INFO, "Thread was told to stop capturing from device %d", v->deviceID); - vj_unicap_stop_capture_(data); - - pthread_exit(NULL); - - return NULL; -} -#endif -void vj_unicap_free_device( void *dud, void *vut ) -{ - vj_unicap_t *v = (vj_unicap_t*) vut; - unicap_driver_t *d = (unicap_driver_t*) dud; - - if( v->active ) - vj_unicap_stop_capture( vut ); - - d->devices[ v->deviceID ] = 0; - - if( v->handle ) - { - if( !SUCCESS( unicap_close( v->handle ) ) ) - { - veejay_msg(0, "Failed to close the device: %s\n", v->device.identifier ); - } - } - - int i = 0; - for( i = 0 ; i < 16 ; i ++ ) - { - if(v->ctrl[i]) - free(v->ctrl[i]); - } - - free( v ); - v = NULL; -} -#endif diff --git a/veejay-current/veejay-server/libstream/vj-unicap.h b/veejay-current/veejay-server/libstream/vj-unicap.h deleted file mode 100644 index fae7d256..00000000 --- a/veejay-current/veejay-server/libstream/vj-unicap.h +++ /dev/null @@ -1,54 +0,0 @@ -/* veejay - Linux VeeJay Unicap interface - * (C) 2002-2006 Niels Elburg - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef VJUNICAPHH -#define VJUNICAPHH -void *vj_unicap_init(void); -void vj_unicap_deinit(void *dud ); -int vj_unicap_num_capture_devices( void *dud ); -char **vj_unicap_get_devices(void *unicap, int *n); -void *vj_unicap_new_device( void *ud, int device_id ); -int vj_unicap_configure_device( void *ud, int pixel_format, int w, int h, int composite ); -int vj_unicap_start_capture( void *vut ); -int vj_unicap_grab_frame( void *vut, uint8_t *buffer[3], const int w, const int h ); -int vj_unicap_stop_capture( void *vut ); -int vj_unicap_composite_status(void *ud ); -int vj_unicap_status(void *vut); -void vj_unicap_free_device( void *dud, void *vut ); -char **vj_unicap_get_list( void *ud ); -int vj_unicap_get_value( void *ud, char *key, int atom_type, void *value ); -int vj_unicap_select_value( void *ud, int key, double ); - -void vj_unicap_set_pause( void *vut , int status ); -int vj_unicap_get_pause( void *vut ); - -#define UNICAP_BRIGHTNESS 0 -#define UNICAP_COLOR 1 -#define UNICAP_SATURATION 2 -#define UNICAP_HUE 3 -#define UNICAP_CONTRAST 4 -#define UNICAP_SOURCE0 5 -#define UNICAP_SOURCE1 6 -#define UNICAP_SOURCE2 7 -#define UNICAP_SOURCE3 8 -#define UNICAP_SOURCE4 9 -#define UNICAP_PAL 10 -#define UNICAP_NTSC 11 -#define UNICAP_WHITE 12 -#endif - diff --git a/veejay-current/veejay-server/veejay/Makefile.am b/veejay-current/veejay-server/veejay/Makefile.am index 4fb28222..6c43bcfb 100644 --- a/veejay-current/veejay-server/veejay/Makefile.am +++ b/veejay-current/veejay-server/veejay/Makefile.am @@ -57,7 +57,7 @@ libveejay_la_LIBADD = -L$(top_builddir)/mjpegtools/ -lmjpegutils \ -L$(top_builddir)/libvevo -lvevo libveejay_la_LDFLAGS += $(SDL_LIBS) $(DIRECTFB_LIBS) $(X_LIBS) $(PTHREAD_LIBS) $(FT_LDFLAGS) $(FT_LIBS) \ - $(XML2_LIBS) $(JPEG_LIBS) $(UNICAP_LIBS) $(LIBLO_LIBS) \ + $(XML2_LIBS) $(JPEG_LIBS) $(LIBLO_LIBS) \ $(FFMPEG_LIBS) $(XINERAMA_LIBS) \ $(LIBDV_LIBS) $(LIBM_LIBS) $(PIXBUF_LIBS) $(JACK_LIBS) $(LIBQUICKTIME_LIBS) $(RT_LIBS) \ -DDYNAMIC -O3 -Wall -rdynamic -Wl,-no-undefined diff --git a/veejay-current/veejay-server/veejay/veejay.c b/veejay-current/veejay-server/veejay/veejay.c index a386a982..99014811 100644 --- a/veejay-current/veejay-server/veejay/veejay.c +++ b/veejay-current/veejay-server/veejay/veejay.c @@ -112,9 +112,6 @@ static void CompiledWith() veejay_msg(VEEJAY_MSG_INFO,"\tUse software scaler"); #ifdef HAVE_JACK veejay_msg(VEEJAY_MSG_INFO,"\tUsing Jack audio server"); -#endif -#ifdef HAVE_UNICAP - veejay_msg(VEEJAY_MSG_INFO,"\tSupport for Unicap ( setenv VEEJAY_CAPTURE_DRIVER=unicap )"); #endif veejay_msg(VEEJAY_MSG_INFO,"\tUsing Video4linux"); #ifdef SUPPORT_READ_DV2 From 7669973362251c1e6bb4208cd69518a62846e2c8 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 1 Jul 2013 21:45:44 +0200 Subject: [PATCH 19/32] no changelog in PKGBUILD, drop one init call --- veejay-current/veejay-server/PKGBUILD | 2 +- veejay-current/veejay-server/configure.ac | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/veejay-current/veejay-server/PKGBUILD b/veejay-current/veejay-server/PKGBUILD index 535cab7f..6f756b20 100644 --- a/veejay-current/veejay-server/PKGBUILD +++ b/veejay-current/veejay-server/PKGBUILD @@ -13,7 +13,7 @@ depends=('libxml2' 'ffmpeg' 'ffmpeg-compat' 'sdl' 'gtk2' 'gdk-pixbuf2' 'libsm' ) optdepends=('unicap' 'liblo' 'libdv' 'libquicktime' 'jack') source=() md5sums=() -changelog=('ChangeLog') +changelog=() backup=() replaces=() diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index 996c7749..8205776e 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -17,7 +17,6 @@ AC_CANONICAL_TARGET AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([1.7]) AM_MAINTAINER_MODE -AM_INIT_AUTOMAKE([dist-bzip2]) AC_DEFINE(VEEJAY,1,[Building Veejay]) AC_DEFINE(HAVE_CONFIG_H,1,[Include config.h]) From 42a7aa73ec657286d404a22ad2cec446a5b3f0e3 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 1 Jul 2013 21:47:47 +0200 Subject: [PATCH 20/32] drop init call --- veejay-current/veejay-client/configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index 6d359d84..2b9fd733 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -16,7 +16,6 @@ AC_CANONICAL_TARGET AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([1.7]) AM_MAINTAINER_MODE -AM_INIT_AUTOMAKE([dist-bzip2]) AC_DEFINE(HAVE_CONFIG_H,1,[Include config.h]) # libtool versioning From a778cba1be407c260cf9c94bfb8a68a9d1f3f288 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 9 Sep 2013 21:56:26 +0200 Subject: [PATCH 21/32] fix resource loading when install prefix is used, fix enable-debug configure option --- veejay-current/veejay-client/configure.ac | 8 +++++--- veejay-current/veejay-client/gveejay-paths.sh.in | 6 ------ veejay-current/veejay-client/src/vj-api.c | 5 +++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index 2b9fd733..a7aec4ec 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -219,6 +219,8 @@ dnl Look for X AC_PATH_XTRA AM_CONDITIONAL(HAVE_X, test x$have_x = xyes) +debugCFLAGS=-g + AC_MSG_CHECKING(whether to compile in profiling information) if test "x$enable_profiling" = "xyes" ; then debugCFLAGS="$debugCFLAGS -fprofile-arcs -ftest-coverage" @@ -230,7 +232,7 @@ else fi AC_MSG_CHECKING(whether to compile in assertion checking) if test "x$enable_strict" = "xyes" ; then - debugCFLAGS="$debugCFLAGS -g -DSTRICT_CHECKING" + debugCFLAGS="$debugCFLAGS -DSTRICT_CHECKING" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) @@ -507,7 +509,6 @@ then AC_MSG_NOTICE([enable_debug = $enable_debug]) if test "x$enable_debug" != "xyes" ; then - AC_MSG_NOTICE([debug koekje]) if test $ac_cv_flag_sse = yes; then CFLAGS="$CFLAGS -msse -mfpmath=sse" AC_MSG_NOTICE([cflags aangepast]) @@ -595,7 +596,7 @@ if test x"$with_extra_cflags" != "x"; then CXXFLAGS="$CXXFLAGS $with_extra_cflags" fi -reloaded_datadir="${datadir}/reloaded" +reloaded_datadir="${datarootdir}/reloaded" AC_SUBST(reloaded_datadir) sh gveejay-paths.sh > gveejay-paths.h @@ -670,3 +671,4 @@ AC_MSG_NOTICE([ - Veejay 1.5.28 : ${have_veejay}]) AC_MSG_NOTICE([ - POSIX Threads (pthread) : ${have_pthread}]) AC_MSG_NOTICE([ - GDK Pixbuf support : ${have_pixbuf}]) AC_MSG_NOTICE([ - Alsa support (midi sequencer) : ${have_alsa}]) +AC_MSG_NOTICE([]) diff --git a/veejay-current/veejay-client/gveejay-paths.sh.in b/veejay-current/veejay-client/gveejay-paths.sh.in index ca89f217..7fcc6a1b 100644 --- a/veejay-current/veejay-client/gveejay-paths.sh.in +++ b/veejay-current/veejay-client/gveejay-paths.sh.in @@ -1,10 +1,4 @@ #!/bin/sh -e - -prefix="@prefix@" -datadir="@datadir@" - -DATADIRNAME="@DATADIRNAME@" - reloaded_datadir="@reloaded_datadir@" cat << EOF diff --git a/veejay-current/veejay-client/src/vj-api.c b/veejay-current/veejay-client/src/vj-api.c index 72f3fb2f..ef978e7d 100644 --- a/veejay-current/veejay-client/src/vj-api.c +++ b/veejay-current/veejay-client/src/vj-api.c @@ -6828,7 +6828,6 @@ void vj_gui_init(char *glade_file, int launcher, char *hostname, int port_num, } snprintf( glade_path, sizeof(glade_path), "%s/%s",RELOADED_DATADIR,glade_file); - veejay_memset( gui->status_tokens, 0, sizeof(int) * STATUS_TOKENS ); veejay_memset( gui->sample, 0, 2 ); veejay_memset( gui->selection, 0, 3 ); @@ -6849,9 +6848,11 @@ void vj_gui_init(char *glade_file, int launcher, char *hostname, int port_num, gui->client = NULL; gui->main_window = glade_xml_new(glade_path,NULL,NULL); - if(!gui->main_window) + if(gui->main_window == NULL) { free(gui); + veejay_msg( 0, "Cannot find '%s'", glade_path ); + return; } info = gui; From 283e05de057a3608413e75b89d7dd64504c2fd77 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 23 Sep 2013 20:16:34 +0200 Subject: [PATCH 22/32] fixed a problem in negotiating image resolution and pixel format, fixed jpeg decoding --- .../veejay-server/libstream/v4l2utils.c | 224 ++++++++++-------- 1 file changed, 119 insertions(+), 105 deletions(-) diff --git a/veejay-current/veejay-server/libstream/v4l2utils.c b/veejay-current/veejay-server/libstream/v4l2utils.c index cd14f41f..1a7ab0f5 100644 --- a/veejay-current/veejay-server/libstream/v4l2utils.c +++ b/veejay-current/veejay-server/libstream/v4l2utils.c @@ -118,7 +118,7 @@ typedef struct int frames_done[N_FRAMES]; int frameidx; int frame_ready; - uint8_t *tmpbuf; + uint8_t *tmpbuf[3]; int is_streaming; int pause_read; int pause_capture; @@ -483,7 +483,7 @@ static void v4l2_enum_frame_sizes( v4l2info *v ) } } -static int v4l2_tryout_pixel_format( v4l2info *v, int pf, int w, int h ) +static int v4l2_tryout_pixel_format( v4l2info *v, int pf, int w, int h, int *src_w, int *src_h, int *src_pf ) { struct v4l2_format format; memset( &format, 0, sizeof(format)); @@ -518,14 +518,18 @@ static int v4l2_tryout_pixel_format( v4l2info *v, int pf, int w, int h ) return 0; } - veejay_msg(VEEJAY_MSG_INFO,"v4l2: Device supports capture in %4.4s (%dx%d)", + veejay_msg(VEEJAY_MSG_DEBUG,"v4l2: Query %dx%d in %d, device supports capture in %4.4s (%dx%d)", + w,h,pf, (char*) &format.fmt.pix.pixelformat, format.fmt.pix.width, format.fmt.pix.height ); + *src_w = format.fmt.pix.width; + *src_h = format.fmt.pix.height; + *src_pf = format.fmt.pix.pixelformat; - return 1; + return ( pf == format.fmt.pix.pixelformat); } static void v4l2_setup_jpeg_capture(v4l2info *v, int wid, int hei) @@ -535,7 +539,11 @@ static void v4l2_setup_jpeg_capture(v4l2info *v, int wid, int hei) jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DQT; // DQT ioctl(v->fd, VIDIOC_S_JPEGCOMP, &jpegcomp); v->is_jpeg = 1; - v->tmpbuf = (uint8_t*) vj_malloc(sizeof(uint8_t) * wid * hei * 3 ); + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: configure temporary buffer for jpeg decoding: %dx%d" , wid,hei ); + + v->tmpbuf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * wid * hei * 3 ); + v->tmpbuf[1] = v->tmpbuf[0] + (wid * hei); + v->tmpbuf[2] = v->tmpbuf[1] + (wid * hei); } static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_id ) @@ -559,7 +567,10 @@ static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_ v->picture->data[0] = vj_malloc(wid * hei + wid); v->picture->data[1] = vj_malloc(wid * hei + wid); v->picture->data[2] = vj_malloc(wid * hei + wid); - v->tmpbuf = (uint8_t*) vj_malloc(sizeof(uint8_t) * wid * hei * 3 ); + v->tmpbuf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * wid * hei * 3 ); + v->tmpbuf[1] = v->tmpbuf[0] + (wid * hei); + v->tmpbuf[2] = v->tmpbuf[1] + (wid * hei); + if( v->codec->capabilities & CODEC_CAP_TRUNCATED) v->c->flags |= CODEC_FLAG_TRUNCATED; @@ -571,66 +582,60 @@ static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_ free(v->picture->data[2]); free(v->picture); av_free(v->c); - free(v->tmpbuf); + free(v->tmpbuf[0]); return 0; } return 1; } -static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int hei, uint32_t *candidate) +static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int hei, uint32_t *candidate, uint32_t *dw, uint32_t *dh) { struct v4l2_format format; int native_pixel_format = v4l2_ffmpeg2v4l2( host_fmt ); + char *greycap = getenv( "VEEJAY_V4L2_GREYSCALE_ONLY" ); //@ does user want grey scale capture if( greycap ) { int gc = atoi(greycap); if( gc == 1 ) { - int have_gs = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_GREY, wid,hei ); + int have_gs = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_GREY, wid,hei,dw,dh, candidate ); if( have_gs ) { veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Setting grey scale (env)"); v->grey=1; - *candidate = V4L2_PIX_FMT_GREY; return 1; } } } //@ does capture card support our native format + int supported = v4l2_tryout_pixel_format( v, native_pixel_format, wid, hei,dw,dh,candidate ); + if( supported ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports native format" ); + return 1; + } - int supported = v4l2_tryout_pixel_format( v, native_pixel_format, wid, hei ); - if( supported ) { - *candidate = native_pixel_format; - return 1; - } - //@ does capture support YUYV or UYVU - supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_YUYV, wid, hei ); + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_YUYV, wid, hei,dw,dh,candidate ); if( supported ) { - *candidate = V4L2_PIX_FMT_YUYV; - return 1; } - - supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_UYVY, wid, hei ); + + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_UYVY, wid, hei,dw,dh,candidate ); if( supported ) { - *candidate = V4L2_PIX_FMT_UYVY; return 1; } - + //@ or RGB 24/32 - supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_RGB24, wid, hei ); + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_RGB24, wid, hei ,dw,dh,candidate); if( supported ) { - *candidate = V4L2_PIX_FMT_RGB24; return 1; } - - supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_RGB32, wid, hei ); + + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_RGB32, wid, hei,dw,dh,candidate ); if( supported ) { - *candidate = V4L2_PIX_FMT_RGB32; return 1; } @@ -643,14 +648,15 @@ static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int if( v->supported_pixel_formats[k] == V4L2_PIX_FMT_JPEG ) { v4l2_setup_jpeg_capture( v, wid,hei ); - *candidate = V4L2_PIX_FMT_YUV420; + *candidate = V4L2_PIX_FMT_JPEG; return 1; } if( v->supported_pixel_formats[k] == V4L2_PIX_FMT_MJPEG) { if( v4l2_setup_avcodec_capture( v, wid,hei, CODEC_ID_MJPEG ) == 0 ) continue; - *candidate = V4L2_PIX_FMT_YUV420; + *candidate = v->supported_pixel_formats[k]; + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Using MJPEG decoder" ); return 1; } @@ -670,10 +676,12 @@ static int v4l2_configure_format( v4l2info *v, int host_fmt, int wid, int hei ) struct v4l2_format format; uint32_t cap_pf = 0; + uint32_t src_wid = 0; + uint32_t src_hei = 0; memset( &format, 0, sizeof(format)); - int res = v4l2_negotiate_pixel_format(v, host_fmt, wid, hei, &cap_pf ); + int res = v4l2_negotiate_pixel_format(v, host_fmt, wid, hei, &cap_pf, &src_wid, &src_hei ); if( res == 0 ) { veejay_msg(VEEJAY_MSG_ERROR, "v4l2: sorry but I don't know how to handle your capture device just yet!"); @@ -682,18 +690,26 @@ static int v4l2_configure_format( v4l2info *v, int host_fmt, int wid, int hei ) if( res == 1 ) { v->format.fmt.pix.pixelformat = cap_pf; - v->format.fmt.pix.width = wid; - v->format.fmt.pix.height = hei; + v->format.fmt.pix.width = src_wid; + v->format.fmt.pix.height = src_hei; - v->info = yuv_yuv_template( NULL,NULL,NULL,wid, hei, + v->info = yuv_yuv_template( NULL,NULL,NULL,src_wid, src_hei, v4l2_pixelformat2ffmpeg( cap_pf ) ); yuv_plane_sizes( v->info, &(v->planes[0]),&(v->planes[1]),&(v->planes[2]),&(v->planes[3]) ); - veejay_msg(VEEJAY_MSG_INFO, "v4l2: Final configuration is in %s (%dx%d)", + veejay_msg(VEEJAY_MSG_INFO, "v4l2: Using scaler, destination format is in %s (%dx%d), source is in %dx%d", (char*) &cap_pf, wid, - hei ); + hei, src_wid,src_hei ); + + if( cap_pf == V4L2_PIX_FMT_JPEG ) { + v->info->data[0] = v->tmpbuf[0]; + v->info->data[1] = v->tmpbuf[1]; + v->info->data[2] = v->tmpbuf[2]; + + + } return 1; } @@ -1141,52 +1157,45 @@ static int v4l2_pull_frame_intern( v4l2info *v ) int got_picture = 0; - switch(v->is_jpeg) { - case 1: -#ifdef HAVE_JPEG - v4l2_set_output_pointers(v,v->tmpbuf); - length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); - if( length == 0 ) { //@ success - length = 1; - } -#else - veejay_msg(0, "v4l2: veejay was compiled without libjpeg"); - return 0; -#endif - break; - case 2: - // length = avcodec_decode_video( v->c, v->picture, &got_picture, v->tmpbuf,src ); - length = -1; - if( length == -1 ) { - veejay_msg(0,"v4l2: error while decoding frame"); - return 0; - } - v->info->data[0] = v->picture->data[0]; - v->info->data[1] = v->picture->data[1]; - v->info->data[2] = v->picture->data[2]; + if(!v->is_jpeg) + v4l2_set_output_pointers( v,src ); - break; - default: - v4l2_set_output_pointers(v,src); - break; + if( v->scaler == NULL ) + { + sws_template templ; + memset(&templ,0,sizeof(sws_template)); + templ.flags = yuv_which_scaler(); + v->scaler = yuv_init_swscaler( v->info,v->frames[ 0 ], &templ, yuv_sws_get_cpu_flags() ); } - - if( v->scaler == NULL ) - { - sws_template templ; - memset(&templ,0,sizeof(sws_template)); - templ.flags = yuv_which_scaler(); - v->scaler = yuv_init_swscaler( v->info,v->frames[ 0 ], &templ, yuv_sws_get_cpu_flags() ); + + if( v->is_jpeg == 1 ) { + length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); + if( length == 0 ) { //@ success + length = 1; } - - yuv_convert_and_scale( v->scaler, v->info, v->frames[ v->frameidx ] ); - - lock_(v->video_info); + } else if( v->is_jpeg == 2 ) { + AVPacket pkt; + veejay_memset( &pkt, 0, sizeof(AVPacket)); + pkt.data = src; + pkt.size = n; + + length = avcodec_decode_video2( v->c, v->picture, &got_picture, &pkt ); + if( length == -1 ) { + veejay_msg(0,"v4l2: error while decoding mjpeg frame"); + } + v->info->data[0] = v->picture->data[0]; + v->info->data[1] = v->picture->data[1]; + v->info->data[2] = v->picture->data[2]; + } + + yuv_convert_and_scale( v->scaler, v->info, v->frames[ v->frameidx ] ); + + lock_(v->video_info); v->frames_done[v->frameidx] = 1; v->frame_ready = v->frameidx; v->frameidx = (v->frameidx + 1) % N_FRAMES; - unlock_(v->video_info); - signal_(v->video_info); + unlock_(v->video_info); + signal_(v->video_info); if(!v->rw) { if( -1 == vioctl( v->fd, VIDIOC_QBUF, &(v->buffer))) { @@ -1252,36 +1261,41 @@ int v4l2_pull_frame(void *vv,VJFrame *dst) int got_picture = 0; - switch(v->is_jpeg) { -#ifdef HAVE_JPEG - case 1: - v4l2_set_output_pointers(v,v->tmpbuf); - length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); - if( length == 0 ) { //@ success - length = 1; - } - break; -#endif - case 2: - //length = avcodec_decode_video( v->c, v->picture, &got_picture, v->tmpbuf,src ); - length = -1; - if( length == -1 ) { - veejay_msg(0,"v4l2: error while decoding frame"); - return 0; - } - v->info->data[0] = v->picture->data[0]; - v->info->data[1] = v->picture->data[1]; - v->info->data[2] = v->picture->data[2]; + if(!v->is_jpeg) + v4l2_set_output_pointers( v,src ); - break; - default: - v4l2_set_output_pointers(v,src); - break; + if( v->scaler == NULL ) + { + sws_template templ; + memset(&templ,0,sizeof(sws_template)); + templ.flags = yuv_which_scaler(); + v->scaler = yuv_init_swscaler( v->info,v->frames[ 0 ], &templ, yuv_sws_get_cpu_flags() ); } + + if( v->is_jpeg == 1 ) { + length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); + if( length == 0 ) { //@ success + length = 1; + } + } else if( v->is_jpeg ==2 ) { + AVPacket pkt; + veejay_memset( &pkt, 0, sizeof(AVPacket)); + pkt.data = src; + pkt.size = n; + + length = avcodec_decode_video2( v->c, v->picture, &got_picture, &pkt ); + if( length == -1 ) { + veejay_msg(0,"v4l2: error while decoding frame"); + } + v->info->data[0] = v->picture->data[0]; + v->info->data[1] = v->picture->data[1]; + v->info->data[2] = v->picture->data[2]; + } + + yuv_convert_and_scale( v->scaler, v->info, v->frames[ v->frameidx ] ); + + - if( length > 0 ) { - yuv_convert_and_scale( v->scaler, v->info, dst ); - } if(!v->rw) { if( -1 == vioctl( v->fd, VIDIOC_QBUF, &(v->buffer))) { veejay_msg(0, "v4l2: VIDIOC_QBUF failed with %s", strerror(errno)); @@ -1338,8 +1352,8 @@ void v4l2_close( void *d ) if(v->c) { av_free(v->c); } - if(v->tmpbuf) { - free(v->tmpbuf); + if(v->tmpbuf[0]) { + free(v->tmpbuf[0]); } if(v->codec) { From e5752f967ae3092379c81f8ca72a50c0e83cfe21 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 24 Sep 2013 20:46:10 +0200 Subject: [PATCH 23/32] fix v4l2loopback streaming, get format before setting it, do not assume card reports capabilities correctly, --- .../veejay-server/libstream/v4l2utils.c | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/veejay-current/veejay-server/libstream/v4l2utils.c b/veejay-current/veejay-server/libstream/v4l2utils.c index 1a7ab0f5..c9b3709f 100644 --- a/veejay-current/veejay-server/libstream/v4l2utils.c +++ b/veejay-current/veejay-server/libstream/v4l2utils.c @@ -365,6 +365,9 @@ static int v4l2_enum_video_standards( v4l2info *v, char norm ) strerror(errno)); } + if( v->is_vloopback ) + return 1; + memset( &standard, 0,sizeof(standard)); standard.index = 0; @@ -423,8 +426,7 @@ static void v4l2_enum_frame_sizes( v4l2info *v ) struct v4l2_fmtdesc fmtdesc; struct v4l2_frmsizeenum fmtsize; struct v4l2_frmivalenum frmival; - const char *buf_types[] = { "Video Capture" , "Video Output", "Video Overlay" }; - const char *flags[] = { "uncompressed", "compressed" }; + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: discovering supported video formats"); //@clear mem @@ -437,11 +439,9 @@ static void v4l2_enum_frame_sizes( v4l2info *v ) for( fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmtdesc.type < V4L2_BUF_TYPE_VIDEO_OVERLAY; fmtdesc.type ++ ) { - // fmtdesc.index = 0; while( vioctl( v->fd, VIDIOC_ENUM_FMT, &fmtdesc ) >= 0 ) { - veejay_msg(VEEJAY_MSG_DEBUG,"v4l2: Enumerate (%d,%s)", fmtdesc.index, buf_types[ fmtdesc.type ] ); + veejay_msg(VEEJAY_MSG_DEBUG,"v4l2: Enumerate (%d, Video Capture)", fmtdesc.index); veejay_msg(VEEJAY_MSG_DEBUG,"\tindex:%d", fmtdesc.index ); - veejay_msg(VEEJAY_MSG_DEBUG,"\tflags:%s", flags[ fmtdesc.type ] ); veejay_msg(VEEJAY_MSG_DEBUG,"\tdescription:%s", fmtdesc.description ); veejay_msg(VEEJAY_MSG_DEBUG,"\tpixelformat:%c%c%c%c", fmtdesc.pixelformat & 0xff, @@ -452,25 +452,6 @@ static void v4l2_enum_frame_sizes( v4l2info *v ) v->supported_pixel_formats[ pf_cnt ] = fmtdesc.pixelformat; pf_cnt = (pf_cnt + 1 ) % loop_limit; - //@ some other day - /* memset( &fmtsize, 0, sizeof(fmtsize)); - fmtsize.pixel_format = fmtdesc.pixelformat; - - while( vioctl( v->fd, VIDIOC_ENUM_FRAMESIZES, &fmtsize ) >= 0 ) { - if( fmtsize.type == V4L2_FRMSIZE_TYPE_DISCRETE ) { - veejay_msg(VEEJAY_MSG_DEBUG, "\t\t%d x %d", fmtsize.discrete.width, fmtsize.discrete.height ); - } else if( fmtsize.type == V4L2_FRMSIZE_TYPE_STEPWISE ) { - veejay_msg(VEEJAY_MSG_DEBUG,"\t\t%d x %d - %d x %d with step %d / %d", - fmtsize.stepwise.min_width, - fmtsize.stepwise.min_height, - fmtsize.stepwise.max_width, - fmtsize.stepwise.min_height, - fmtsize.stepwise.step_width, - fmtsize.stepwise.step_height ); - } - fmtsize.index++; - } - */ fmtdesc.index ++; loop_limit --; //@ endless loop in enumerating video formats @@ -489,21 +470,35 @@ static int v4l2_tryout_pixel_format( v4l2info *v, int pf, int w, int h, int *src memset( &format, 0, sizeof(format)); format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; +/* format.fmt.pix.width = w; + format.fmt.pix.height= h; + format.fmt.pix.field = V4L2_FIELD_NONE; // V4L2_FIELD_ANY; + format.fmt.pix.pixelformat = pf; +*/ + if( vioctl( v->fd, VIDIOC_G_FMT, &format ) == -1 ) { + veejay_msg(VEEJAY_MSG_WARNING, "v4l2: VIDIOC_G_FMT failed with %s", strerror(errno)); + } + format.fmt.pix.width = w; format.fmt.pix.height= h; - format.fmt.pix.field = V4L2_FIELD_ANY; + + if( v->is_vloopback ) + format.fmt.pix.field = V4L2_FIELD_NONE; + else + format.fmt.pix.field = V4L2_FIELD_ANY; format.fmt.pix.pixelformat = pf; - + if( vioctl( v->fd, VIDIOC_TRY_FMT, &format ) == 0 ) { if( format.fmt.pix.pixelformat == pf ) { - veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: VIDIOC_TRY_FMT reports OK: %4.4s", - (char*) &format.fmt.pix.pixelformat ); if( vioctl( v->fd, VIDIOC_S_FMT, &format ) == -1 ) { veejay_msg(0, "v4l2: After VIDIOC_TRY_FMT , VIDIOC_S_FMT fails for: %4.4s", (char*) &format.fmt.pix.pixelformat); return 0; } + *src_w = format.fmt.pix.width; + *src_h = format.fmt.pix.height; + *src_pf = format.fmt.pix.pixelformat; return 1; } } @@ -638,8 +633,13 @@ static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int if( supported ) { return 1; } - - +/* + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_JPEG, wid,hei,dw,dh,candidate ); + if( supported ) { + v4l2_setup_jpeg_capture( v, wid,hei ); + return 1; + } +*/ //@ try anything else int k; for( k = 0; k < 64; k ++ ) { @@ -698,17 +698,13 @@ static int v4l2_configure_format( v4l2info *v, int host_fmt, int wid, int hei ) yuv_plane_sizes( v->info, &(v->planes[0]),&(v->planes[1]),&(v->planes[2]),&(v->planes[3]) ); - veejay_msg(VEEJAY_MSG_INFO, "v4l2: Using scaler, destination format is in %s (%dx%d), source is in %dx%d", - (char*) &cap_pf, - wid, - hei, src_wid,src_hei ); + veejay_msg(VEEJAY_MSG_INFO, "v4l2: output in %dx%d, source in %dx%d", + wid,hei, src_wid,src_hei ); if( cap_pf == V4L2_PIX_FMT_JPEG ) { v->info->data[0] = v->tmpbuf[0]; v->info->data[1] = v->tmpbuf[1]; v->info->data[2] = v->tmpbuf[2]; - - } return 1; @@ -721,7 +717,7 @@ static int v4l2_configure_format( v4l2info *v, int host_fmt, int wid, int hei ) static void v4l2_set_output_pointers( v4l2info *v, void *src ) { uint8_t *map = (uint8_t*) src; -//@A + if( v->planes[0] > 0 ) { v->info->data[0] = map; } @@ -879,8 +875,8 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi } if( (v->capability.capabilities & V4L2_CAP_READWRITE ) == 0 ) { - veejay_msg(VEEJAY_MSG_ERROR, "v4l2: %s does not support read/write interface.", v->capability.card); - can_read = 0; + veejay_msg(VEEJAY_MSG_WARNING, "v4l2: %s claims not to support read/write interface.", v->capability.card); + // can_read = 0; } if( can_stream == 0 && can_read == 0 ) { @@ -975,7 +971,7 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi if( v->rw == 0 ) { v->reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v->reqbuf.memory= V4L2_MEMORY_MMAP; - v->reqbuf.count = 32; + v->reqbuf.count = 2; if( -1 == vioctl( fd, VIDIOC_REQBUFS, &(v->reqbuf)) ) { if( errno == EINVAL ) { @@ -989,6 +985,12 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi } veejay_msg(VEEJAY_MSG_INFO, "v4l2: Card supports %d buffers", v->reqbuf.count ); + if( v->reqbuf.count > 2 ) + { + v->reqbuf.count = 2; + veejay_msg(VEEJAY_MSG_INFO, "v4l2: Using %d buffers", v->reqbuf.count ); + } + v->buffers = (bufs*) calloc( v->reqbuf.count, sizeof(*v->buffers)); int i; From 5b6df67860e35d5203f60401592b734fae738ec3 Mon Sep 17 00:00:00 2001 From: niels Date: Tue, 8 Oct 2013 23:22:47 +0200 Subject: [PATCH 24/32] fix v4l2 streaming for HD webcams (properly support mmap capture and mjpeg), fix warning and error messages, bit of cleanup, dropped jpeg decoder --- .../veejay-server/libstream/v4l2utils.c | 291 ++++++++++-------- .../veejay-server/libstream/vj-tag.c | 1 - 2 files changed, 159 insertions(+), 133 deletions(-) diff --git a/veejay-current/veejay-server/libstream/v4l2utils.c b/veejay-current/veejay-server/libstream/v4l2utils.c index c9b3709f..facb82d2 100644 --- a/veejay-current/veejay-server/libstream/v4l2utils.c +++ b/veejay-current/veejay-server/libstream/v4l2utils.c @@ -237,10 +237,12 @@ static int v4l2_start_video_capture( v4l2info *v ) static int v4l2_vidioc_qbuf( v4l2info *v ) { + v->buftype = V4L2_BUF_TYPE_VIDEO_CAPTURE; + int i; for( i = 0; i < v->reqbuf.count ; i ++ ) { veejay_memset( &(v->buffer),0,sizeof(v->buffer)); - v->buffer.type = v->reqbuf.type; + v->buffer.type = v->buftype; //v->reqbuf.type; v->buffer.memory=V4L2_MEMORY_MMAP; v->buffer.index = i; @@ -286,10 +288,11 @@ int v4l2_pixelformat2ffmpeg( int pf ) case V4L2_PIX_FMT_YUV32: return PIX_FMT_YUV444P; case V4L2_PIX_FMT_MJPEG: - return PIX_FMT_YUVJ420P; //@ FIXME untested + return PIX_FMT_YUVJ420P; //@ does not matter case V4L2_PIX_FMT_JPEG: return PIX_FMT_YUVJ420P; //@ decode_jpeg_raw downsamples all yuv, FIXME: format negotation default: + veejay_msg(0, "v4l2: Unhandled pixel format: %d", pf ); break; } return PIX_FMT_BGR24; @@ -354,6 +357,8 @@ static int v4l2_enum_video_standards( v4l2info *v, char norm ) v4l2_std_id current; memset( &input, 0,sizeof(input)); + memset( ¤t,0,sizeof(current)); + if( -1 == vioctl( v->fd, VIDIOC_G_INPUT, &input.index )) { veejay_msg(VEEJAY_MSG_WARNING, "v4l2: VIDIOC_G_INPUT failed with %s", strerror(errno)); @@ -504,7 +509,6 @@ static int v4l2_tryout_pixel_format( v4l2info *v, int pf, int w, int h, int *src } if( vioctl( v->fd, VIDIOC_S_FMT, &format ) == -1 ) { - veejay_msg(0,"v4l2: negotation of data fails with %s", strerror(errno)); return 0; } @@ -526,7 +530,7 @@ static int v4l2_tryout_pixel_format( v4l2info *v, int pf, int w, int h, int *src return ( pf == format.fmt.pix.pixelformat); } - +/* static void v4l2_setup_jpeg_capture(v4l2info *v, int wid, int hei) { struct v4l2_jpegcompression jpegcomp; @@ -540,13 +544,18 @@ static void v4l2_setup_jpeg_capture(v4l2info *v, int wid, int hei) v->tmpbuf[1] = v->tmpbuf[0] + (wid * hei); v->tmpbuf[2] = v->tmpbuf[1] + (wid * hei); } - +*/ static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_id ) { struct v4l2_jpegcompression jpegcomp; + memset( &jpegcomp, 0, sizeof(jpegcomp)); + ioctl(v->fd, VIDIOC_G_JPEGCOMP, &jpegcomp); + jpegcomp.jpeg_markers |= V4L2_JPEG_MARKER_DQT; // DQT + ioctl(v->fd, VIDIOC_S_JPEGCOMP, &jpegcomp); + v->is_jpeg = 2; v->codec = avcodec_find_decoder( codec_id ); @@ -601,6 +610,8 @@ static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Setting grey scale (env)"); v->grey=1; return 1; + } else { + veejay_msg(VEEJAY_MSG_WARNING, "v4l2: User requested greyscale video but device does not support it."); } } } @@ -611,55 +622,59 @@ static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports native format" ); return 1; } + + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_JPEG, wid,hei,dw,dh,candidate ); + if( supported ) { + // v4l2_setup_jpeg_capture( v, wid,hei ); + if( v4l2_setup_avcodec_capture( v, wid,hei, CODEC_ID_MJPEG ) == 0 ) { + veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Failed to intialize MJPEG decoder."); + return 0; + } + + *candidate = V4L2_PIX_FMT_JPEG; + return 1; + } + + supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_MJPEG, wid, hei,dw,dh,candidate ); + if( supported ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports MJPEG format"); + if( v4l2_setup_avcodec_capture( v, wid,hei, CODEC_ID_MJPEG ) == 0 ) { + veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Failed to intialize MJPEG decoder."); + return 0; + } + *candidate = V4L2_PIX_FMT_MJPEG; + return 1; + } + //@ does capture support YUYV or UYVU supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_YUYV, wid, hei,dw,dh,candidate ); if( supported ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports YUY2" ); return 1; } - - supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_UYVY, wid, hei,dw,dh,candidate ); - if( supported ) { - return 1; - } - + //@ or RGB 24/32 supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_RGB24, wid, hei ,dw,dh,candidate); if( supported ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports RGB 24 bit" ); return 1; + } supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_RGB32, wid, hei,dw,dh,candidate ); if( supported ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Capture device supports RGB 32 bit"); return 1; } -/* - supported = v4l2_tryout_pixel_format( v, V4L2_PIX_FMT_JPEG, wid,hei,dw,dh,candidate ); - if( supported ) { - v4l2_setup_jpeg_capture( v, wid,hei ); - return 1; - } -*/ + //@ try anything else + /* int k; for( k = 0; k < 64; k ++ ) { if( v->supported_pixel_formats[k] == 0 ) continue; - if( v->supported_pixel_formats[k] == V4L2_PIX_FMT_JPEG ) { - v4l2_setup_jpeg_capture( v, wid,hei ); - *candidate = V4L2_PIX_FMT_JPEG; - return 1; - } - - if( v->supported_pixel_formats[k] == V4L2_PIX_FMT_MJPEG) { - if( v4l2_setup_avcodec_capture( v, wid,hei, CODEC_ID_MJPEG ) == 0 ) - continue; - *candidate = v->supported_pixel_formats[k]; - veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Using MJPEG decoder" ); - return 1; - } - int pf = v4l2_pixelformat2ffmpeg( v->supported_pixel_formats[k] ); if( pf >= 0 ) { *candidate = v->supported_pixel_formats[k]; @@ -667,7 +682,10 @@ static int v4l2_negotiate_pixel_format( v4l2info *v, int host_fmt, int wid, int } } - + */ + + veejay_msg(VEEJAY_MSG_ERROR, "v4l2: No supported pixel format found!"); + return 0; } @@ -688,6 +706,11 @@ static int v4l2_configure_format( v4l2info *v, int host_fmt, int wid, int hei ) return 0; } + if( src_wid == 0 || src_hei == 0 ) { + src_wid = wid; + src_hei = hei; + } + if( res == 1 ) { v->format.fmt.pix.pixelformat = cap_pf; v->format.fmt.pix.width = src_wid; @@ -700,13 +723,13 @@ static int v4l2_configure_format( v4l2info *v, int host_fmt, int wid, int hei ) veejay_msg(VEEJAY_MSG_INFO, "v4l2: output in %dx%d, source in %dx%d", wid,hei, src_wid,src_hei ); - +/* if( cap_pf == V4L2_PIX_FMT_JPEG ) { v->info->data[0] = v->tmpbuf[0]; v->info->data[1] = v->tmpbuf[1]; v->info->data[2] = v->tmpbuf[2]; } - +*/ return 1; } @@ -849,6 +872,7 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi if( v->grey == 1 ) { dst_fmt = PIX_FMT_GRAY8; + veejay_msg(VEEJAY_MSG_WARNING,"v4l2: User requested greyscale video"); } if( -1 == vioctl( fd, VIDIOC_QUERYCAP, &(v->capability) ) ) { @@ -875,8 +899,8 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi } if( (v->capability.capabilities & V4L2_CAP_READWRITE ) == 0 ) { - veejay_msg(VEEJAY_MSG_WARNING, "v4l2: %s claims not to support read/write interface.", v->capability.card); - // can_read = 0; + veejay_msg(VEEJAY_MSG_WARNING, "v4l2: %s does not support read/write interface.", v->capability.card); + can_read = 0; } if( can_stream == 0 && can_read == 0 ) { @@ -923,12 +947,10 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi //@ which video input ? int chan = v4l2_channel_choose( v, input_channel ); if(chan == -1) { - veejay_msg(0, "v4l2: Video device has no input channels ? What video device is that?"); + veejay_msg(VEEJAY_MSG_WARNING, "v4l2: Video device without input channels ? Guessing 0 is valid..."); chan = 0; - // free(v); - // close(fd); - // return NULL; } + if( -1 == vioctl( fd, VIDIOC_S_INPUT, &chan )) { int lvl = 0; if( errno == EINVAL ) @@ -939,15 +961,11 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi close(fd); return NULL; } - } v->input.index = chan; if( -1 == vioctl( fd, VIDIOC_ENUMINPUT, &(v->input)) ) { - veejay_msg(0, "v4l2: VIDIOC_ENUMINPUT failed with %s", strerror(errno)); - //free(v); - //close(fd); - //return NULL; + veejay_msg(VEEJAY_MSG_WARNING, "v4l2: VIDIOC_ENUMINPUT failed with %s", strerror(errno)); } @@ -971,7 +989,7 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi if( v->rw == 0 ) { v->reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v->reqbuf.memory= V4L2_MEMORY_MMAP; - v->reqbuf.count = 2; + v->reqbuf.count = N_FRAMES; if( -1 == vioctl( fd, VIDIOC_REQBUFS, &(v->reqbuf)) ) { if( errno == EINVAL ) { @@ -985,9 +1003,9 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi } veejay_msg(VEEJAY_MSG_INFO, "v4l2: Card supports %d buffers", v->reqbuf.count ); - if( v->reqbuf.count > 2 ) + if( v->reqbuf.count > N_FRAMES ) { - v->reqbuf.count = 2; + v->reqbuf.count = N_FRAMES; veejay_msg(VEEJAY_MSG_INFO, "v4l2: Using %d buffers", v->reqbuf.count ); } @@ -1009,12 +1027,7 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi } v->buffers[i].length = v->buffer.length; - v->buffers[i].start = mmap( NULL, - v->buffer.length, - PROT_READ | PROT_WRITE, - MAP_SHARED, - fd, - v->buffer.m.offset ); + v->buffers[i].start = mmap( NULL, v->buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED,fd, v->buffer.m.offset ); if( MAP_FAILED == v->buffers[i].start ) { veejay_msg(0, "v4l2: mmap( NULL, %d , PROT_READ|PROT_WRITE , MAP_SHARED , %d, %d ) failed.", @@ -1030,10 +1043,8 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi v->rw = 1; goto v4l2_rw_fallback; } - } - if( v4l2_vidioc_qbuf( v ) == -1 ) { veejay_msg(0, "v4l2: VIDIOC_QBUF failed with:%d, %s", errno,strerror(errno)); free(v->buffers); @@ -1073,9 +1084,7 @@ v4l2_rw_fallback: v->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; v->format.fmt.pix.width = wid; v->format.fmt.pix.height = hei; - //format.fmt.pix.pixelformat; - //format.fmt.pix.field - // + if( -1 == vioctl( v->fd, VIDIOC_S_FMT, &(v->format) ) ) { veejay_msg(0, "V4l2: VIDIOC_S_FMT failed with %s", strerror(errno)); close(v->fd); @@ -1162,6 +1171,33 @@ static int v4l2_pull_frame_intern( v4l2info *v ) if(!v->is_jpeg) v4l2_set_output_pointers( v,src ); + + if( v->is_jpeg == 1 ) { + length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); + if( length == 0 ) { //@ success + length = 1; + } + } else if( v->is_jpeg == 2 ) { + AVPacket pkt; + memset( &pkt, 0, sizeof(AVPacket)); + pkt.data = src; + pkt.size = length; + + int res = avcodec_decode_video2( + v->c, + v->picture, + &got_picture, + &pkt ); + + v->info->data[0] = v->picture->data[0]; + v->info->data[1] = v->picture->data[1]; + v->info->data[2] = v->picture->data[2]; + v->info->stride[0] = v->picture->linesize[0]; + v->info->stride[1] = v->picture->linesize[1]; + v->info->stride[2] = v->picture->linesize[2]; + v->info->format = v->picture->format; + } + if( v->scaler == NULL ) { sws_template templ; @@ -1170,26 +1206,6 @@ static int v4l2_pull_frame_intern( v4l2info *v ) v->scaler = yuv_init_swscaler( v->info,v->frames[ 0 ], &templ, yuv_sws_get_cpu_flags() ); } - if( v->is_jpeg == 1 ) { - length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); - if( length == 0 ) { //@ success - length = 1; - } - } else if( v->is_jpeg == 2 ) { - AVPacket pkt; - veejay_memset( &pkt, 0, sizeof(AVPacket)); - pkt.data = src; - pkt.size = n; - - length = avcodec_decode_video2( v->c, v->picture, &got_picture, &pkt ); - if( length == -1 ) { - veejay_msg(0,"v4l2: error while decoding mjpeg frame"); - } - v->info->data[0] = v->picture->data[0]; - v->info->data[1] = v->picture->data[1]; - v->info->data[2] = v->picture->data[2]; - } - yuv_convert_and_scale( v->scaler, v->info, v->frames[ v->frameidx ] ); lock_(v->video_info); @@ -1266,6 +1282,33 @@ int v4l2_pull_frame(void *vv,VJFrame *dst) if(!v->is_jpeg) v4l2_set_output_pointers( v,src ); + + if( v->is_jpeg == 1 ) { + length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); + if( length == 0 ) { //@ success + length = 1; + } + } else if( v->is_jpeg == 2 ) { + AVPacket pkt; + memset( &pkt, 0, sizeof(AVPacket)); + pkt.data = src; + pkt.size = length; + + int res = avcodec_decode_video2( + v->c, + v->picture, + &got_picture, + &pkt ); + + v->info->data[0] = v->picture->data[0]; + v->info->data[1] = v->picture->data[1]; + v->info->data[2] = v->picture->data[2]; + v->info->stride[0] = v->picture->linesize[0]; + v->info->stride[1] = v->picture->linesize[1]; + v->info->stride[2] = v->picture->linesize[2]; + v->info->format = v->picture->format; + } + if( v->scaler == NULL ) { sws_template templ; @@ -1274,28 +1317,8 @@ int v4l2_pull_frame(void *vv,VJFrame *dst) v->scaler = yuv_init_swscaler( v->info,v->frames[ 0 ], &templ, yuv_sws_get_cpu_flags() ); } - if( v->is_jpeg == 1 ) { - length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); - if( length == 0 ) { //@ success - length = 1; - } - } else if( v->is_jpeg ==2 ) { - AVPacket pkt; - veejay_memset( &pkt, 0, sizeof(AVPacket)); - pkt.data = src; - pkt.size = n; - - length = avcodec_decode_video2( v->c, v->picture, &got_picture, &pkt ); - if( length == -1 ) { - veejay_msg(0,"v4l2: error while decoding frame"); - } - v->info->data[0] = v->picture->data[0]; - v->info->data[1] = v->picture->data[1]; - v->info->data[2] = v->picture->data[2]; - } - yuv_convert_and_scale( v->scaler, v->info, v->frames[ v->frameidx ] ); - + if(!v->rw) { @@ -1330,26 +1353,27 @@ void v4l2_close( void *d ) if( v->scaler ) yuv_free_swscaler( v->scaler ); - if( v->frames) { - int c; - if( !v->picture ) - { - for ( i = 0; i < N_FRAMES; i ++ ) { - for( c = 0; c < 4; c ++ ) { - if( v->out_planes[c] ) - free(v->frames[i]->data[c]); - } - free(v->frames[i]); + int c; + if( !v->picture ) + { + for ( i = 0; i < N_FRAMES; i ++ ) { + for( c = 0; c < 4; c ++ ) { + if( v->out_planes[c] ) + free(v->frames[i]->data[c]); } + free(v->frames[i]); } - free(v->frames); } + + if(v->picture) { free(v->picture->data[0]); free(v->picture->data[1]); free(v->picture->data[2]); - free(v->picture); + av_free(v->picture); + v->picture = NULL; + } if(v->c) { av_free(v->c); @@ -1893,6 +1917,7 @@ static void *v4l2_grabber_thread( void *v ) if(!v4l2_verify_file( i->file ) ) { i->stop = 1; + veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Not a device file: %s" , i->file ); pthread_exit(NULL); return NULL; } @@ -1900,6 +1925,7 @@ static void *v4l2_grabber_thread( void *v ) v4l2info *v4l2 = v4l2open( i->file, i->channel, i->host_fmt, i->wid, i->hei, i->fps, i->norm ); if( v4l2 == NULL ) { veejay_msg(0, "v4l2: error opening v4l2 device '%s'",i->file ); + unlock_(v); pthread_exit(NULL); return NULL; } @@ -1907,29 +1933,24 @@ static void *v4l2_grabber_thread( void *v ) i->v4l2 = v4l2; v4l2->video_info = i; v4l2->threaded = 1; - if(v4l2==NULL) { - unlock_(v); - pthread_exit(NULL); - return NULL; - } - - int j,c; - int planes[4]; - yuv_plane_sizes( v4l2->frames[0], &(planes[0]),&(planes[1]),&(planes[2]),&(planes[3]) ); + int j,c; + int planes[4]; + yuv_plane_sizes( v4l2->frames[0], &(planes[0]),&(planes[1]),&(planes[2]),&(planes[3]) ); +//@ FIXME: VEEJAY_V4L2_NO_THREADING=1 and no framebuffer is allocated ... - for( j = 0; j < N_FRAMES; j ++ ) { - for( c = 0; c < 4; c ++ ) { - if( planes[c] > 0 ) { - v4l2->frames[j]->data[c] = (uint8_t*) vj_malloc(sizeof(uint8_t) * planes[c] ); - veejay_msg(VEEJAY_MSG_DEBUG, "%d: allocated buffer[%d] = %d bytes", j,c,planes[c]); - } + for( j = 0; j < N_FRAMES; j ++ ) { + for( c = 0; c < 4; c ++ ) { + if( planes[c] > 0 ) { + v4l2->frames[j]->data[c] = (uint8_t*) vj_malloc(sizeof(uint8_t) * planes[c] ); + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: %d: allocated buffer[%d] = %d bytes", j,c,planes[c]); } - v4l2->frames_done[j] = 0; } + v4l2->frames_done[j] = 0; + } - for( c = 0; c < 4; c ++ ) - v4l2->out_planes[c] = planes[c]; + for( c = 0; c < 4; c ++ ) + v4l2->out_planes[c] = planes[c]; veejay_msg(VEEJAY_MSG_INFO, "v4l2: capture format: %d x %d (%x)", v4l2->info->width,v4l2->info->height, v4l2->info->format ); @@ -1986,6 +2007,7 @@ static void *v4l2_grabber_thread( void *v ) } if( i->stop ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Closing video capture device"); v4l2_close(v4l2); pthread_exit(NULL); return NULL; @@ -2003,6 +2025,7 @@ int v4l2_thread_start( v4l2_thread_info *i ) // pthread_attr_destroy( &(i->attr) ); if( err == 0 ) { + veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: Started video capture thread."); return 1; } @@ -2092,11 +2115,14 @@ void *v4l2_thread_new( char *file, int channel, int host_fmt, int wid, int hei, if( v4l2_thread_start( i ) == 0 ) { free(i->file); free(i); + veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Unable to start"); return NULL; } int ready = 0; - int retries = 40; + + int retries = 4000; + //@ wait until thread is ready while(retries) { ready = i->grabbing; @@ -2110,6 +2136,7 @@ void *v4l2_thread_new( char *file, int channel, int host_fmt, int wid, int hei, } if( i->stop ) { + veejay_msg(VEEJAY_MSG_ERROR, "v4l2: Grabber thread was told to exit."); pthread_mutex_destroy(&(i->mutex)); pthread_cond_destroy(&(i->cond)); } diff --git a/veejay-current/veejay-server/libstream/vj-tag.c b/veejay-current/veejay-server/libstream/vj-tag.c index 1652509d..604e9148 100644 --- a/veejay-current/veejay-server/libstream/vj-tag.c +++ b/veejay-current/veejay-server/libstream/vj-tag.c @@ -431,7 +431,6 @@ int _vj_tag_new_unicap( vj_tag * tag, int stream_nr, int width, int height, int } sprintf(refname, "%d", channel ); tag->extra = strdup(refname); - veejay_msg(VEEJAY_MSG_DEBUG, "Using v4l2"); #endif return 1; } From 08c1d3ab1e23f0e8523a91fcd17e1c5c62868388 Mon Sep 17 00:00:00 2001 From: niels Date: Wed, 9 Oct 2013 20:27:56 +0200 Subject: [PATCH 25/32] fix crash in nervous, fix possible crash in cameleon --- veejay-current/veejay-server/libvje/effects/chameleon.c | 3 ++- veejay-current/veejay-server/libvje/effects/nervous.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/veejay-current/veejay-server/libvje/effects/chameleon.c b/veejay-current/veejay-server/libvje/effects/chameleon.c index 5c10a166..7fe90a9c 100644 --- a/veejay-current/veejay-server/libvje/effects/chameleon.c +++ b/veejay-current/veejay-server/libvje/effects/chameleon.c @@ -231,7 +231,8 @@ void chameleon_apply( VJFrame *frame, int width, int height, int mode) const int len = (width * height); VJFrame source; int strides[4] = { len, len, len, 0 }; - vj_frame_copy1( frame->data, tmpimage, strides ); + + vj_frame_copy( frame->data, tmpimage, strides ); veejay_memcpy( &source, frame, sizeof(VJFrame)); source.data[0] = tmpimage[0]; diff --git a/veejay-current/veejay-server/libvje/effects/nervous.c b/veejay-current/veejay-server/libvje/effects/nervous.c index 61abf0ae..1c3aa796 100644 --- a/veejay-current/veejay-server/libvje/effects/nervous.c +++ b/veejay-current/veejay-server/libvje/effects/nervous.c @@ -92,10 +92,10 @@ void nervous_apply( VJFrame *frame, int width, int height, int delay) uint8_t *NCb= nervous_buf[1] + (uv_len * frames_elapsed ); uint8_t *NCr= nervous_buf[2] + (uv_len * frames_elapsed ); - uint8_t *dest[3] = { NY, NCb, NCr }; + uint8_t *dest[4] = { NY, NCb, NCr, NULL }; int strides[4] = { len, uv_len,uv_len, 0 }; // copy original into nervous buf - vj_frame_copy1( frame->data, dest, strides ); + vj_frame_copy( frame->data, dest, strides ); if(frames_elapsed > 0) { @@ -111,7 +111,7 @@ void nervous_apply( VJFrame *frame, int width, int height, int delay) dest[1] = sCb; dest[2] = sCr; - vj_frame_copy1( dest, frame->data, strides ); + vj_frame_copy( dest, frame->data, strides ); } frames_elapsed ++; From 138aaddc5b03150ead24d5073449010fb7c20434 Mon Sep 17 00:00:00 2001 From: niels Date: Wed, 9 Oct 2013 20:29:37 +0200 Subject: [PATCH 26/32] bump version to 1.5.29 --- veejay-current/veejay-server/configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index 8205776e..a133ec7b 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([veejay],[1.5.28],[http://www.veejayhq.net]) +AC_INIT([veejay],[1.5.29],[http://www.veejayhq.net]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([veejay/veejay.c]) VEEJAY_MAJOR_VERSION=1 VEEJAY_MINOR_VERSION=5 -VEEJAY_MICRO_VERSION=28 +VEEJAY_MICRO_VERSION=29 VEEJAY_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION VEEJAY_CODENAME="Veejay Classic - build $VEEJAY_MINOR_VERSION $VEEJAY_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) From f995c5690af326b34b4561b73c337e655c3fcde7 Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 30 Dec 2013 21:35:31 +0100 Subject: [PATCH 27/32] build fixes --- veejay-current/veejay-client/configure.ac | 23 +++++++++- veejay-current/veejay-client/src/Makefile.am | 6 +-- veejay-current/veejay-client/src/callback.c | 4 ++ veejay-current/veejay-client/src/keyboard.c | 4 +- veejay-current/veejay-client/src/vj-api.c | 46 ++++++++++++++----- veejay-current/veejay-server/configure.ac | 20 +++++--- veejay-current/veejay-server/libel/lav_io.c | 3 +- .../veejay-server/libstream/v4l2utils.c | 12 +++-- .../veejay-server/veejay/liblavplayvj.c | 15 +++--- veejay-current/veejay-server/veejay/veejay.c | 4 ++ .../veejay-server/veejay/vj-event.c | 23 +++++++--- veejay-current/veejay-server/veejay/vj-font.c | 4 +- .../veejay-server/veejay/vj-perform.c | 9 +++- 13 files changed, 128 insertions(+), 45 deletions(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index a7aec4ec..b6635a7f 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -201,6 +201,21 @@ if test x$with_pixbuf != xno ; then [have_pixbuf=false]) fi +have_sdl=false +if test x$with_sdl != xno ; then + PKG_CHECK_MODULES(SDL, [sdl >= 1.2], + [ + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + have_sdl=true + AC_DEFINE(HAVE_SDL,1,[use sdl keybindings])], + [have_sdl=false]) +fi + +if test x$have_sdl != xtrue ; then + AC_MSG_WARN([Cannot find SDL, reloaded will not be able to map keybindings]) +fi + dnl ******************************************************************** dnl Check to see if __progname is provided by the system dnl ******************************************************************** @@ -522,12 +537,18 @@ fi AC_MSG_RESULT($CFLAGS) -PKG_CHECK_MODULES(LIBAVUTIL,[libavutil >= 49.7], have_avutil=true,have_avutil=false]) +PKG_CHECK_MODULES(LIBAVUTIL,[libavutil >= 49.7], have_avutil=true,have_avutil=false) if test x$have_avutil = xfalse; then AC_MSG_ERROR([libavutil not found.]) fi +PKG_CHECK_MODULES( LIBX11, x11, have_x11=true,have_x11=false) +if test x$have_x11 = xfalse; +then + AC_MSG_ERROR([libx11 not found.]) +fi + FFMPEG_CFLAGS="${LIBAVUTIL_CFLAGS}" AC_SUBST(FFMPEG_CFLAGS) dnl ********************************************************************** diff --git a/veejay-current/veejay-client/src/Makefile.am b/veejay-current/veejay-client/src/Makefile.am index 0a706424..8bd63ea2 100644 --- a/veejay-current/veejay-client/src/Makefile.am +++ b/veejay-current/veejay-client/src/Makefile.am @@ -1,8 +1,8 @@ ## Process this file with automake to produce Makefile.in MAINTAINERCLEANFILES = Makefile.in AM_CFLAGS=$(OP_CFLAGS) -INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(VEEJAY_CFLAGS) $(GTK_CFLAGS) \ - $(GLIB_CFLAGS) $(FFMPEG_CFLAGS) $(GLADE_CFLAGS) -DGNOMELOCALEDIR=\""$(datadir)/locale"\" -DRELOADED_DATADIR=\""$(reloaded_datadir)"\" + INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(VEEJAY_CFLAGS) $(GTK_CFLAGS) \ + $(GLIB_CFLAGS) $(FFMPEG_CFLAGS) $(GLADE_CFLAGS) -DGNOMELOCALEDIR=\""$(datadir)/locale"\" -DRELOADED_DATADIR=\""$(reloaded_datadir)"\" RELOADED_BIN=reloaded reloaded_SOURCES = gtkcolorsel.c gtkknob.c cellrendererspin.c gtktimeselection.c vj-midi.c curve.c utils.c tracksources.c gveejay.c keyboard.c sequence.c multitrack.c vj-api.c mjpeg_logging.c mpegconsts.c mpegtimecode.c yuv4mpeg.c yuv4mpeg_ratio.c ${reloaded_headers} @@ -11,5 +11,5 @@ bin_PROGRAMS = $(RELOADED_BIN) EXTRA_DIST = common.h curve.h fastintfns.h format_codes.h keyboard.h mjpeg_logging.h mjpeg_types.h mpegconsts.h mpegtimecode.h multitrack.h sequence.h tracksources.h utils.h videodev_mjpeg.h vj-api.h vmidi.h yuv4mpeg.h yuv4mpeg_intern.h cellrendererspin.h gtkcolorsel.h gtkhsv.h gtkknob.h gtktimeselection.h callback.c reloaded_LDFLAGS = $(VEEJAY_LIBS) $(GTK_LIBS) $(GLIB_LIBS) \ -$(GLADE_LIBS) $(ALSA_LIBS) -lgthread-2.0 -export-dynamic +$(GLADE_LIBS) $(ALSA_LIBS) $(LIBM_LIBS) $(LIBX11_LIBS) -lgthread-2.0 -export-dynamic diff --git a/veejay-current/veejay-client/src/callback.c b/veejay-current/veejay-client/src/callback.c index 012a7782..4c77e724 100644 --- a/veejay-current/veejay-client/src/callback.c +++ b/veejay-current/veejay-client/src/callback.c @@ -1357,6 +1357,7 @@ void on_vims_take_clicked(GtkWidget *widget, gpointer user_data) } void on_button_key_detach_clicked(GtkWidget *widget, gpointer user) { +#ifdef HAVE_SDL int key_val = info->uc.pressed_key; int key_mod = info->uc.pressed_mod; @@ -1374,10 +1375,12 @@ void on_button_key_detach_clicked(GtkWidget *widget, gpointer user) else vj_msg(VEEJAY_MSG_INFO, "Key binding %s released", strkey ); } +#endif } void on_vims_key_clicked( GtkWidget *widget, gpointer user_data) { +#ifdef HAVE_SDL char which_vims[128]; sprintf(which_vims, "Press a key to bind VIMS %03d", info->uc.selected_vims_entry ); @@ -1409,6 +1412,7 @@ void on_vims_key_clicked( GtkWidget *widget, gpointer user_data) event_id, sdlkey_by_id(key_val) ); } } +#endif } diff --git a/veejay-current/veejay-client/src/keyboard.c b/veejay-current/veejay-client/src/keyboard.c index 8dbd1192..36b253ae 100644 --- a/veejay-current/veejay-client/src/keyboard.c +++ b/veejay-current/veejay-client/src/keyboard.c @@ -16,8 +16,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - +#include #include +#ifdef HAVE_SDL #include "keyboard.h" static struct { @@ -327,4 +328,5 @@ gboolean key_snooper(GtkWidget *w, GdkEventKey *event, gpointer user_data) { return FALSE; } +#endif // gtk_key_snooper_install diff --git a/veejay-current/veejay-client/src/vj-api.c b/veejay-current/veejay-client/src/vj-api.c index ef978e7d..93918ea3 100644 --- a/veejay-current/veejay-client/src/vj-api.c +++ b/veejay-current/veejay-client/src/vj-api.c @@ -54,7 +54,9 @@ #include #include #include +#ifdef HAVE_SDL #include +#endif #include #include #include @@ -1577,9 +1579,22 @@ void about_dialog() char blob[1024]; char *os_str = produce_os_str(); - sprintf(blob, "Veejay - A visual instrument and realtime video sampler for GNU/Linux\n%s", os_str ); + const gchar *donate = +{ + "You can donate cryptocoins!\n"\ + "Bitcoin: 1PUNRsv8vDt1upTx9tTpY5sH8mHW1DTrKJ\n"\ + "Devcoin: 1DtYKQx6kLnCxX5S8atf6b3dD42A2UavvE\n"\ + "Litecoin: LcccLQCB7DbqGj9u52urRjVi43yYz7WeND\n"\ + "Feathercoin: 6i4G4C9jEZuL6R7vSspZ6JMAUP2zb6M1Yu\n" + +}; + + sprintf(blob, "Veejay - A visual instrument and realtime video sampler for GNU/Linux\n%s\n%s", os_str, donate ); + free(os_str); + + const gchar *license = { "This program is Free Software; You can redistribute it and/or modify\n" \ @@ -1628,6 +1643,7 @@ gboolean dialogkey_snooper( GtkWidget *w, GdkEventKey *event, gpointer user_data { return FALSE; } +#ifdef HAVE_SDL if(event->type == GDK_KEY_PRESS) { gchar tmp[100]; @@ -1648,11 +1664,11 @@ gboolean dialogkey_snooper( GtkWidget *w, GdkEventKey *event, gpointer user_data g_free(utf8_text); } } - +#endif return FALSE; } - -gboolean key_handler( GtkWidget *w, GdkEventKey *event, gpointer user_data) +#ifdef HAVE_SDL +static gboolean key_handler( GtkWidget *w, GdkEventKey *event, gpointer user_data) { if(event->type != GDK_KEY_PRESS) return FALSE; @@ -1667,7 +1683,7 @@ gboolean key_handler( GtkWidget *w, GdkEventKey *event, gpointer user_data) } return FALSE; } - +#endif static int check_format_string( char *args, char *format ) { if(!format || !args ) @@ -1735,7 +1751,7 @@ prompt_keydialog(const char *title, char *msg) gtk_container_add( GTK_CONTAINER(hbox1), arglabel ); gtk_container_add( GTK_CONTAINER(hbox1), pentry ); } - +#ifdef HAVE_SDL if( info->uc.selected_vims_entry ) { char tmp[100]; @@ -1757,7 +1773,7 @@ prompt_keydialog(const char *title, char *msg) gtk_entry_set_text( GTK_ENTRY(keyentry), tmp ); } } - +#endif gtk_container_add( GTK_CONTAINER( GTK_DIALOG( dialog )->vbox ), hbox1 ); gtk_container_add( GTK_CONTAINER( GTK_DIALOG( dialog )->vbox ), hbox2 ); @@ -4464,15 +4480,16 @@ gboolean int m=0; gchar *key = NULL; gchar *mod = NULL; - +#ifdef HAVE_SDL gtk_tree_model_get(model,&iter, VIMS_KEY, &key, -1); gtk_tree_model_get(model,&iter, VIMS_MOD, &mod, -1); - +#endif if(sscanf( vimsid, "%d", &event_id )) { +#ifdef HAVE_SDL k = sdlkey_by_name( key ); m = sdlmod_by_name( mod ); - +#endif info->uc.selected_vims_entry = event_id; if( event_id >= VIMS_BUNDLE_START && event_id < VIMS_BUNDLE_END ) @@ -4486,7 +4503,7 @@ gboolean if( n_params > 0 && text ) info->uc.selected_vims_args = strdup( text ); - + info->uc.selected_vims_accel[0] = m; info->uc.selected_vims_accel[1] = k; @@ -4805,8 +4822,13 @@ static void reload_bundles() gchar *g_descr = NULL; gchar *g_format = NULL; gchar *g_content = NULL; +#ifdef HAVE_SDL gchar *g_keyname = sdlkey_by_id( val[1] ); gchar *g_keymod = sdlmod_by_id( val[2] ); +#else + gchar *g_keyname = "N/A"; + gchar *g_keymod = ""; +#endif gchar *g_vims[5]; sprintf( (char*) g_vims, "%03d", val[0] ); @@ -7312,7 +7334,9 @@ gboolean is_alive( int *do_sync ) else { info->watch.state = STATE_PLAYING; +#ifdef HAVE_SDL info->key_id = gtk_key_snooper_install( key_handler , NULL); +#endif multrack_audoadd( info->mt, remote, port ); *do_sync = 1; if( user_preview ) { diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index a133ec7b..7184a5a2 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([veejay],[1.5.29],[http://www.veejayhq.net]) +AC_INIT([veejay],[1.5.30],[http://www.veejayhq.net]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([veejay/veejay.c]) VEEJAY_MAJOR_VERSION=1 VEEJAY_MINOR_VERSION=5 -VEEJAY_MICRO_VERSION=29 +VEEJAY_MICRO_VERSION=30 VEEJAY_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION VEEJAY_CODENAME="Veejay Classic - build $VEEJAY_MINOR_VERSION $VEEJAY_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) @@ -808,13 +808,21 @@ dnl ******************************************************************** dnl Check for the SDL library (for software playback) dnl (defines SDL_CFLAGS and SDL_LIBS) dnl ******************************************************************** +dnl have_sdl=false +dnl if test x$with_sdl != xno ; then +dnl AM_PATH_SDL(1.2.3,[ +dnl have_sdl=true +dnl AC_DEFINE(HAVE_SDL,, [SDL library present])],,) +dnl fi + have_sdl=false if test x$with_sdl != xno ; then -AM_PATH_SDL(1.2.3,[ - have_sdl=true - AC_DEFINE(HAVE_SDL,, [SDL library present])],,) +PKG_CHECK_MODULES( SDL, sdl >= 1.2, have_sdl=true,have_sdl=false) +if test x$have_sdl = xfalse ; then + AC_MSG_ERROR([Could not find SDL 1.2 library!]) +fi +AC_DEFINE(HAVE_SDL,1,[SDL library is installed]) fi - have_liblo=false PKG_CHECK_MODULES( LIBLO, liblo >= 0.26,have_liblo=true,have_liblo=false) if test x$have_liblo = xfalse ; then diff --git a/veejay-current/veejay-server/libel/lav_io.c b/veejay-current/veejay-server/libel/lav_io.c index 93922708..b2e03145 100644 --- a/veejay-current/veejay-server/libel/lav_io.c +++ b/veejay-current/veejay-server/libel/lav_io.c @@ -1853,8 +1853,7 @@ const char *lav_strerror(void) return AVI_strerror(); default: /* No or unknown video format */ - if(errno) strerror(errno); - else sprintf(error_string,"No or unknown video format"); + sprintf(error_string,"No or unknown video format"); return error_string; } } diff --git a/veejay-current/veejay-server/libstream/v4l2utils.c b/veejay-current/veejay-server/libstream/v4l2utils.c index facb82d2..3bf58db9 100644 --- a/veejay-current/veejay-server/libstream/v4l2utils.c +++ b/veejay-current/veejay-server/libstream/v4l2utils.c @@ -1171,13 +1171,15 @@ static int v4l2_pull_frame_intern( v4l2info *v ) if(!v->is_jpeg) v4l2_set_output_pointers( v,src ); - +#ifdef HAVE_JPEG if( v->is_jpeg == 1 ) { length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); if( length == 0 ) { //@ success length = 1; } - } else if( v->is_jpeg == 2 ) { + } else +#endif + if( v->is_jpeg == 2 ) { AVPacket pkt; memset( &pkt, 0, sizeof(AVPacket)); pkt.data = src; @@ -1282,13 +1284,15 @@ int v4l2_pull_frame(void *vv,VJFrame *dst) if(!v->is_jpeg) v4l2_set_output_pointers( v,src ); - +#ifdef HAVE_JPEG if( v->is_jpeg == 1 ) { length = decode_jpeg_raw( src, n, 0,0, v->info->width,v->info->height,v->info->data[0],v->info->data[1],v->info->data[2] ); if( length == 0 ) { //@ success length = 1; } - } else if( v->is_jpeg == 2 ) { + } else +#endif + if( v->is_jpeg == 2 ) { AVPacket pkt; memset( &pkt, 0, sizeof(AVPacket)); pkt.data = src; diff --git a/veejay-current/veejay-server/veejay/liblavplayvj.c b/veejay-current/veejay-server/veejay/liblavplayvj.c index 6a3a381e..cc2bb976 100644 --- a/veejay-current/veejay-server/veejay/liblavplayvj.c +++ b/veejay-current/veejay-server/veejay/liblavplayvj.c @@ -1083,13 +1083,12 @@ static int veejay_screen_update(veejay_t * info ) vj_perform_get_primary_frame(info,frame); +#ifdef HAVE_SDL if(check_vp) { if( info->video_out == 0 ) { - if(!vj_sdl_lock( info->sdl[0] ) ) return 0; - composite_blit_yuyv( info->composite,frame, vj_sdl_get_yuv_overlay(info->sdl[0]),settings->composite); if(!vj_sdl_unlock( info->sdl[0]) ) return 0; @@ -1098,7 +1097,7 @@ static int veejay_screen_update(veejay_t * info ) skip_update = 1; } } - +#endif if( info->shm && vj_shm_get_status(info->shm) == 1 ) { int plane_sizes[4] = { info->effect_frame1->len, info->effect_frame1->uv_len, @@ -1139,7 +1138,8 @@ static int veejay_screen_update(veejay_t * info ) } #endif #endif - + +#ifdef HAVE_SDL if(skip_update) { if(info->video_out == 0 ) { for(i = 0 ; i < MAX_SDL_OUT; i ++ ) @@ -1157,7 +1157,7 @@ static int veejay_screen_update(veejay_t * info ) */ return 1; } - +#endif switch (info->video_out) { #ifdef HAVE_SDL @@ -1361,8 +1361,7 @@ void veejay_pipe_write_status(veejay_t * info) 0, 0, 0, - mstatus, - 0 ); + mstatus); break; case VJ_PLAYBACK_MODE_TAG: if( vj_tag_sprint_status( info->uc->sample_id,cache_used,info->seq->active,info->seq->current, info->real_fps, @@ -2453,7 +2452,7 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags, int gen_t if (seteuid(getuid()) < 0) { /* fixme: get rid of sys_errlist and use sys_strerror */ - veejay_msg(VEEJAY_MSG_ERROR, "Can't set effective user-id: %s", sys_errlist[errno]); + veejay_msg(VEEJAY_MSG_ERROR, "Can't set effective user-id: %s", strerror(errno)); return -1; } if(info->load_action_file ) { diff --git a/veejay-current/veejay-server/veejay/veejay.c b/veejay-current/veejay-server/veejay/veejay.c index 99014811..4374ea46 100644 --- a/veejay-current/veejay-server/veejay/veejay.c +++ b/veejay-current/veejay-server/veejay/veejay.c @@ -637,6 +637,10 @@ static void print_license() veejay_msg(VEEJAY_MSG_INFO, "The license must be included in the (source) package (COPYING)"); + + veejay_msg(VEEJAY_MSG_INFO, + "Veejay's BTC donation address: 1PUNRsv8vDt1upTx9tTpY5sH8mHW1DTrKJ"); + veejay_msg(VEEJAY_MSG_INFO, "\tLTC donation address: LcccLQCB7DbqGj9u52urRjVi43yYz7WeND"); } static void donothing(int sig) diff --git a/veejay-current/veejay-server/veejay/vj-event.c b/veejay-current/veejay-server/veejay/vj-event.c index c0397375..785eae44 100644 --- a/veejay-current/veejay-server/veejay/vj-event.c +++ b/veejay-current/veejay-server/veejay/vj-event.c @@ -358,12 +358,14 @@ veejay_msg(VEEJAY_MSG_INFO, "--------------------------------------------------- #define SEND_MSG(v,str)\ {\ -if(vj_server_send(v->vjs[VEEJAY_PORT_CMD], v->uc->current_link, (uint8_t*) str, strlen(str)) < 0) { \ +int bf_len = strlen(str);\ +if(bf_len && vj_server_send(v->vjs[VEEJAY_PORT_CMD], v->uc->current_link, (uint8_t*) str, bf_len) < 0) { \ _vj_server_del_client( v->vjs[VEEJAY_PORT_CMD], v->uc->current_link); \ _vj_server_del_client( v->vjs[VEEJAY_PORT_STA], v->uc->current_link); \ _vj_server_del_client( v->vjs[VEEJAY_PORT_DAT], v->uc->current_link);} \ } + /* some macros for commonly used checks */ #ifdef STRICT_CHECKING @@ -2676,9 +2678,9 @@ void vj_event_init_keyboard_defaults() void vj_event_init() { int i; - +#ifdef HAVE_SDL veejay_memset( keyboard_event_map_, 0, sizeof(keyboard_event_map_)); - +#endif vj_init_vevo_events(); #ifdef HAVE_SDL if( !(keyboard_events = hash_create( HASHCOUNT_T_MAX, int_bundle_compare, int_bundle_hash))) @@ -2962,10 +2964,13 @@ void vj_event_send_keylist( void *ptr, const char format[], va_list ap ) veejay_t *v = (veejay_t*) ptr; unsigned int i,len=0; char message[256]; - char *blob = vj_calloc( 1024 * 32 ); + char *blob = NULL; char line[512]; char header[7]; int skip = 0; +#ifdef HAVE_SDL + blob = vj_calloc( 1024 * 64 ); + if(!hash_isempty( keyboard_events )) { hscan_t scan; @@ -3006,11 +3011,12 @@ void vj_event_send_keylist( void *ptr, const char format[], va_list ap ) } } } - +#endif sprintf( header, "%06d", len ); SEND_MSG( v, header ); - SEND_MSG( v, blob ); + if( blob != NULL ) + SEND_MSG( v, blob ); free( blob ); @@ -7454,16 +7460,19 @@ void vj_event_viewport_frontback(void *ptr, const char format[], va_list ap) veejay_msg(VEEJAY_MSG_INFO, "Saved calibration to sample %d",v->uc->sample_id ); } composite_set_ui(v->composite, 0 ); +#ifdef HAVE_SDL if(v->video_out==0 || v->video_out == 2) vj_sdl_grab( v->sdl[0], 0 ); +#endif } else { composite_set_ui( v->composite, 1 ); v->settings->composite = 1; v->use_osd=3; +#ifdef HAVE_SDL if(v->video_out==0 || v->video_out == 2) vj_sdl_grab( v->sdl[0], 1 ); - +#endif veejay_msg(VEEJAY_MSG_INFO, "You can now calibrate your projection/camera, press CTRL-s again to exit."); } } diff --git a/veejay-current/veejay-server/veejay/vj-font.c b/veejay-current/veejay-server/veejay/vj-font.c index c7c26fd1..181e94f2 100644 --- a/veejay-current/veejay-server/veejay/vj-font.c +++ b/veejay-current/veejay-server/veejay/vj-font.c @@ -1105,8 +1105,10 @@ static int find_fonts(vj_font_t *ec, char *path) int n = scandir(path, &files, dir_selector,alphasort); if(n < 0) + { + veejay_msg(0, "Error reading %s: %s", path, strerror(errno)); return 0; - + } while( n -- ) { char tmp[1024]; diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index 1c33d395..c0f173ce 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -127,6 +127,9 @@ static const char *license = static const char *copyr = "(C) 2002-2013 Copyright N.Elburg et all (nwelburg@gmail.com)\n"; +static const char *donateaddr = + "Veejay's BTC donation address: 1PUNRsv8vDt1upTx9tTpY5sH8mHW1DTrKJ\n\tLTC donation address: LcccLQCB7DbqGj9u52urRjVi43yYz7WeND\n"; + #define MLIMIT(var, low, high) \ if((var) < (low)) { var = (low); } \ if((var) > (high)) { var = (high); } @@ -3160,7 +3163,7 @@ static char *vj_perform_print_credits( veejay_t *info ) { char text[1024]; veejay_memset(text,0,sizeof(text)); - snprintf(text, 1024,"This is Veejay version %s\n%s\n%s\n%s\n",VERSION,intro,copyr,license); + snprintf(text, 1024,"This is Veejay version %s\n%s\n%s\n%s\n%s",VERSION,intro,copyr,license,donateaddr); return strdup(text); } @@ -3358,12 +3361,15 @@ static void vj_perform_finish_render( veejay_t *info, video_playback_setup *sett sample_reload_config( info->composite,info->uc->sample_id, 1 ); // settings->composite); } +#ifdef HAVE_SDL if( info->video_out == 0 ) { //@ release focus vj_sdl_grab( info->sdl[0], 0 ); } +#endif } +#ifdef HAVE_SDL if( info->use_osd == 2 ) { osd_text = vj_perform_print_credits(info); placement= 1; @@ -3375,6 +3381,7 @@ static void vj_perform_finish_render( veejay_t *info, video_playback_setup *sett osd_text = viewport_get_my_help( composite_get_vp(info->composite ) ); more_text = vj_perform_osd_status(info); } +#endif } if( settings->composite ) { From 4259f319f9f065548f6a403087e1dd2da79cff3b Mon Sep 17 00:00:00 2001 From: niels Date: Mon, 30 Dec 2013 22:10:48 +0100 Subject: [PATCH 28/32] bump version of reloaded too --- veejay-current/veejay-client/configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index b6635a7f..efa05ebc 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([reloaded],[1.5.28],[nwelburg@gmail.com]) +AC_INIT([reloaded],[1.5.30],[nwelburg@gmail.com]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/gveejay.c]) RELOADED_MAJOR_VERSION=1 RELOADED_MINOR_VERSION=5 -RELOADED_MICRO_VERSION=28 +RELOADED_MICRO_VERSION=30 RELOADED_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION RELOADED_CODENAME="Reloaded - build $RELOADED_MAJOR_VERSION $RELOADED_MINOR_VERSION $RELOADED_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) From e649dfb5a84ad763cc367e63aafaa94372b398b5 Mon Sep 17 00:00:00 2001 From: niels Date: Sat, 1 Feb 2014 17:45:23 +0100 Subject: [PATCH 29/32] arch build fixes (ffmpeg-compat) some bugfixes removed changelog from PKGBUILD bumped version --- veejay-current/veejay-server/PKGBUILD | 3 +- veejay-current/veejay-server/README | 7 ++ veejay-current/veejay-server/configure.ac | 75 +++++++++------ .../veejay-server/libel/vj-avcodec.c | 21 ++++- veejay-current/veejay-server/libel/vj-el.c | 93 +++++++++++++++---- veejay-current/veejay-server/libel/vj-mmap.c | 4 +- .../libplugger/freeframe-loader.c | 5 +- .../veejay-server/libstream/v4l2utils.c | 16 +++- .../veejay-server/libvje/effects/ripple.c | 2 +- .../veejay-server/libvje/effects/scratcher.c | 2 +- .../veejay-server/libvje/effects/softblur.c | 2 +- .../veejay-server/libvjmem/memcpy.c | 2 +- .../veejay-server/libvjmsg/vj-common.c | 2 +- .../veejay-server/libyuv/subsample.c | 4 +- veejay-current/veejay-server/libyuv/yuvconv.c | 8 +- .../veejay-server/veejay/Makefile.am | 4 +- .../veejay-server/veejay/vj-perform.c | 4 + veejay-current/veejay-server/veejay/vj-task.c | 9 +- 18 files changed, 188 insertions(+), 75 deletions(-) diff --git a/veejay-current/veejay-server/PKGBUILD b/veejay-current/veejay-server/PKGBUILD index 6f756b20..29b546e7 100644 --- a/veejay-current/veejay-server/PKGBUILD +++ b/veejay-current/veejay-server/PKGBUILD @@ -10,10 +10,9 @@ license=('GPL') groups=() conflicts=('veejay') depends=('libxml2' 'ffmpeg' 'ffmpeg-compat' 'sdl' 'gtk2' 'gdk-pixbuf2' 'libsm' ) -optdepends=('unicap' 'liblo' 'libdv' 'libquicktime' 'jack') +optdepends=('liblo' 'libdv' 'libquicktime' 'jack') source=() md5sums=() -changelog=() backup=() replaces=() diff --git a/veejay-current/veejay-server/README b/veejay-current/veejay-server/README index 12b17912..39c9e8a2 100644 --- a/veejay-current/veejay-server/README +++ b/veejay-current/veejay-server/README @@ -32,6 +32,13 @@ While playing, you can record the resulting video directly to disk (video sampli ====== quick install: + check that PKG_CONFIG_PATH is set: + echo $PKG_CONFIG_PATH + + on some distributions, like Arch, you need to install ffmpeg-compat + and set PKG_CONFIG_PATH to first include /usr/lib/ffmpeg-compat/pkg-config + follow by the other directories that contain .pc files. + order of packages: veejay-server, veejay-client, veejay-utils diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index 7184a5a2..babeda0d 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([veejay],[1.5.30],[http://www.veejayhq.net]) +AC_INIT([veejay],[1.5.31],[http://www.veejayhq.net]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([veejay/veejay.c]) VEEJAY_MAJOR_VERSION=1 VEEJAY_MINOR_VERSION=5 -VEEJAY_MICRO_VERSION=30 +VEEJAY_MICRO_VERSION=31 VEEJAY_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION VEEJAY_CODENAME="Veejay Classic - build $VEEJAY_MINOR_VERSION $VEEJAY_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) @@ -553,9 +553,9 @@ AC_MSG_RESULT($CFLAGS) AC_DEFINE_UNQUOTED(HAVE_FFMPEG_UNINSTALLED,, [Defined if building against uninstalled FFmpeg source]) -PKG_CHECK_MODULES(LIBAVUTIL, [libavutil >= 49.7.0],have_avutil=true,have_avutil=false) -PKG_CHECK_MODULES(LIBAVCODEC,[libavcodec >= 51.57.2],have_avcodec=true,have_avcodec=false) -PKG_CHECK_MODULES(LIBAVFORMAT,[libavformat >= 52.14.0],have_avformat=true,have_avformat=false) +PKG_CHECK_MODULES(LIBAVUTIL, [libavutil >= 49.7.0 libavutil < 52.48],have_avutil=true,have_avutil=false) +PKG_CHECK_MODULES(LIBAVCODEC,[libavcodec >= 51.35.2 libavcodec < 55.39],have_avcodec=true,have_avcodec=false) +PKG_CHECK_MODULES(LIBAVFORMAT,[libavformat >= 52.14.0 libavformat < 55.19],have_avformat=true,have_avformat=false) PKG_CHECK_MODULES(LIBSWSCALE,[libswscale >= 0.7.1],have_swscale=true,have_swscale=false) if test x$have_swscale = xfalse; then @@ -571,7 +571,7 @@ then fi if test x$have_avcodec = xfalse; then - AC_MSG_ERROR([libavcodec not found.]) + AC_MSG_ERROR([libavcodec >= 51.57 not found.]) fi FFMPEG_CFLAGS="${LIBAVFORMAT_CFLAGS} ${LIBAVCODEC_CFLAGS} ${LIBAVUTIL_CFLAGS} ${LIBSWSCALE_CFLAGS}" @@ -903,28 +903,42 @@ fi have_freetype=false -AC_CHECK_PROG(FREETYPE_CONFIG, freetype-config,yes,no) -if test $FREETYPE_CONFIG = yes; then - FT_CFLAGS="`freetype-config --cflags`" - FT_WORD="`freetype-config --libs`" - FT_LDFLAGS="" - FT_LIBS="" - for word in $FT_WORD ; do - beginning=`echo $word | cut -c -2` - if test ".$beginning" = ".-L"; then - FT_LDFLAGS="$FT_LDFLAGS $word" +have_freetype2=false +PKG_CHECK_MODULES( FREETYPE2, [freetype2], [ + AC_SUBST(FREETYPE2_CFLAGS) + AC_SUBST(FREETYPE2_LIBS) + AC_DEFINE(HAVE_FREETYPE,,[compiling with freetype]) + have_freetype2=true], + [have_freetype2=false] ) + +if test x$have_freetype2 != xtrue; then + AC_CHECK_PROG(FREETYPE_CONFIG, freetype-config,yes,no) + if test $FREETYPE_CONFIG = yes; then + FREETYPE_CFLAGS="`freetype-config --cflags`" + FREETYPE_WORD="`freetype-config --libs`" + FREETYPE_LIBS="" + for word in $FREETYPE_WORD; do + beginning=`echo $word |cut -c -2` + if test ".$beginning" = ".-L"; then + FREETYPE_LDFLAGS="$FREETYPE_LDFLAGS $word" + else + FREETYPE_LIBS="$FREETYPE_LIBS $word" + fi + done + AC_DEFINE(HAVE_FREETYPE,,[compiling with freetype]) + AC_SUBST(FREETYPE_LIBS) + AC_SUBST(FREETYPE_LDFLAGS) + AC_SUBST(FREETYPE_CFLAGS) + have_freetype=true + AC_MSG_NOTICE([Compiling with FreeType]) else - FT_LIBS="$FT_LIBS $word" + AC_MSG_ERROR([Cannot find the freetype-config program]) fi - done - AC_DEFINE(HAVE_FREETYPE,,[Compiling with FreeType]) - AC_SUBST(FT_LIBS) - AC_SUBST(FT_LDFLAGS) - AC_SUBST(FT_CFLAGS) - have_freetype=true else - AC_MSG_ERROR([Cannot find the freetype-config program]) -fi + AC_MSG_NOTICE([Compiling with FreeType2]) +fi + + dnl ********************************************************************** dnl All the conditional stuff for the Makefiles @@ -953,6 +967,7 @@ AM_CONDITIONAL(SUPPORT_READ_DV2, test x$have_libdv = xtrue) AM_CONDITIONAL(HAVE_DL_DLOPEN, test x$have_dl_dlopen = xtrue) AM_CONDITIONAL(HAVE_JPEG,test x$have_jpeg = xtrue) AM_CONDITIONAL(HAVE_LIBLO,test x$have_liblo = xtrue) +AM_CONDITIONAL(HAVE_FREETYPE2, test x$have_freetype2 = xtrue) dnl ********************************************************************* dnl Check for what warnings we want gcc to use and adjust the CFLAGS dnl as needed. This only works for GCC. @@ -1100,7 +1115,15 @@ AC_MSG_NOTICE([ - FFmpeg AVCodec : ${have_avcodec} ]) AC_MSG_NOTICE([ - FFmpeg Swscaler : ${have_swscale} ]) AC_MSG_NOTICE([ - FFmpeg avutil : ${have_avutil} ]) AC_MSG_NOTICE([ - SDL support : ${have_sdl}]) -AC_MSG_NOTICE([ - Freetype support : ${have_freetype}]) + +if test "$have_freetype" = "true"; then + AC_MSG_NOTICE([ - Freetype support : ${have_freetype}]) +fi + +if test "$have_freetype2" = "true"; then + AC_MSG_NOTICE([ - FreeType 2 support : ${have_freetype2}]) +fi + AC_MSG_NOTICE([ - XML c library for Gnome : ${have_xml2}]) AC_MSG_NOTICE([ - JPEG support : ${have_jpeg} ]) AC_MSG_NOTICE([ - GDK Pixbuf support : ${have_pixbuf}]) diff --git a/veejay-current/veejay-server/libel/vj-avcodec.c b/veejay-current/veejay-server/libel/vj-avcodec.c index 901d81a3..565c508b 100644 --- a/veejay-current/veejay-server/libel/vj-avcodec.c +++ b/veejay-current/veejay-server/libel/vj-avcodec.c @@ -189,7 +189,12 @@ static vj_encoder *vj_avcodec_new_encoder( int id, editlist *el, char *filename) if(id != CODEC_ID_DVVIDEO ) { #endif - e->context = avcodec_alloc_context(); + +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 8, 0) + e->context = avcodec_alloc_context(); +#else + e->context = avcodec_alloc_context3(e->codec); +#endif e->context->bit_rate = 2750 * 1024; e->context->width = el->video_width; e->context->height = el->video_height; @@ -217,7 +222,11 @@ static vj_encoder *vj_avcodec_new_encoder( int id, editlist *el, char *filename) char *descr = vj_avcodec_get_codec_name( id ); - if ( avcodec_open( e->context, e->codec ) < 0 ) +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 8, 0) + if ( avcodec_open( e->context, e->codec ) < 0 ) +#else + if ( avcodec_open2( e->context, e->codec, NULL ) < 0 ) +#endif { veejay_msg(VEEJAY_MSG_ERROR, "Cannot open codec '%s'" , descr ); if(e->context) free(e->context); @@ -465,8 +474,12 @@ int vj_avcodec_init( int pixel_format, int verbose) #else av_log_set_level( AV_LOG_VERBOSE ); #endif - av_register_all(); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avcodec_register_all(); +#else + av_register_all(); +#endif return 1; } @@ -658,6 +671,6 @@ int vj_avcodec_encode_audio( void *encoder, int format, uint8_t *src, uint8_t * if(format == ENCODER_YUV420 || ENCODER_YUV422 == format) return 0; vj_encoder *av = encoder; - int ret = avcodec_encode_audio( av->context, src, len, nsamples ); + int ret = avcodec_encode_audio( av->context, dst, len, (const short*) src ); return ret; } diff --git a/veejay-current/veejay-server/libel/vj-el.c b/veejay-current/veejay-server/libel/vj-el.c index c0a0d2aa..02f24c8e 100644 --- a/veejay-current/veejay-server/libel/vj-el.c +++ b/veejay-current/veejay-server/libel/vj-el.c @@ -240,8 +240,12 @@ static const char *el_pixfmt_str(int i) void free_av_packet( AVPacket *pkt ) { if( pkt ) { - if( pkt->destruct ) - pkt->destruct(pkt); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + // av_destruct_packet(pkt); +#else + // if( pkt->destruct ) + // pkt->destruct(pkt); +#endif pkt->data = NULL; pkt->size = 0; } @@ -484,7 +488,7 @@ vj_decoder *_el_new_decoder( int id , int width, int height, float fps, int pixe } else if( id != CODEC_ID_YUV422 && id != CODEC_ID_YUV420 && id != CODEC_ID_YUV420F && id != CODEC_ID_YUV422F) { d->codec = avcodec_find_decoder( id ); -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) d->context = avcodec_alloc_context3(NULL); /* stripe was here! */ #else d->context = avcodec_alloc_context(); @@ -501,8 +505,12 @@ vj_decoder *_el_new_decoder( int id , int width, int height, float fps, int pixe tc ); d->context->thread_type = FF_THREAD_FRAME; d->context->thread_count = tc; - - if ( avcodec_open( d->context, d->codec ) < 0 ) + +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 8, 0) + if ( avcodec_open( d->context, d->codec ) < 0 ) +#else + if ( avcodec_open2( d->context, d->codec, NULL ) < 0 ) +#endif { veejay_msg(VEEJAY_MSG_ERROR, "Error initializing decoder %d",id); _el_free_decoder( d ); @@ -1092,7 +1100,7 @@ int vj_el_set_bogus_length( editlist *el, long nframe, int len ) return 1; } -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) static int avcodec_decode_video( AVCodecContext *avctx, AVFrame *picture, int *got_picture, uint8_t *data, int pktsize ) { AVPacket pkt; veejay_memset( &pkt, 0, sizeof(AVPacket)); @@ -1307,6 +1315,7 @@ int vj_el_get_video_frame(editlist *el, long nframe, uint8_t *dst[3]) pict2.linesize[1] = el->video_width >> 1; pict2.linesize[2] = el->video_width >> 1; pict2.linesize[0] = el->video_width; + avpicture_deinterlace( &pict2, (const AVPicture*) d->frame, @@ -1382,7 +1391,7 @@ int detect_pixel_format_with_ffmpeg( const char *filename ) AVInputFormat *av_input_format = NULL; AVFrame *av_frame = NULL; AVPacket pkt; -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) int err = avformat_open_input( &avformat_ctx, filename, NULL, NULL ); #else int err = av_open_input_file( &avformat_ctx,filename,NULL,0,NULL ); @@ -1392,30 +1401,55 @@ int detect_pixel_format_with_ffmpeg( const char *filename ) veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: Unable to open %s: %d",filename,err ); return -1; } -#if (LIBAVFORMAT_VERSION_MAJOR >= 53 ) + +#if (LIBAVFORMAT_VERSION_MAJOR <= 53 ) err = avformat_find_stream_info( avformat_ctx, NULL ); #else err = av_find_stream_info( avformat_ctx ); #endif + + +#ifdef STRICT_CHECKING +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + av_dump_format( avformat_ctx,0,filename,0 ); +#endif +#endif + + if( err > 0 ) { + char buf[1024]; + av_strerror( err, buf, sizeof(buf)-1); + veejay_msg(VEEJAY_MSG_DEBUG, "%s" , buf ); + } + if(err < 0 ) { veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: Stream information found in %s",filename); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avformat_close_input(&avformat_ctx); +#else av_close_input_file( avformat_ctx ); +#endif return -1; } - av_read_play(avformat_ctx); - - int i,j; - int n = avformat_ctx->nb_streams; + + unsigned int i,j; + unsigned int n = avformat_ctx->nb_streams; int vi = -1; int pix_fmt = -1; veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: File has %d %s", n, ( n == 1 ? "stream" : "streams") ); + if( n > 65535 ) { + veejay_msg(VEEJAY_MSG_WARNING, "FFmpeg: Probably doesn't work, got garbage from open_input." ); + veejay_msg(VEEJAY_MSG_WARNING, "Build veejay with an older ffmpeg (for example, FFmpeg 0.8.15 \"Love\")"); + return -1; + } + + for( i=0; i < n; i ++ ) { if( avformat_ctx->streams[i]->codec ) { -#if (LIBAVFORMAT_VERSION_MAJOR >= 53) +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) #if (LIBAVFORMAT_VERSION_MINOR <= 5 ) if( avformat_ctx->streams[i]->codec->codec_type < CODEC_ID_MP2 ) #else @@ -1436,15 +1470,24 @@ further: if( !sup_codec ) { veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: Unrecognized file %s", avformat_ctx->streams[i]->codec->codec_name ); - av_close_input_file( avformat_ctx ); - return -1; +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avformat_close_input(&avformat_ctx); +#else + av_close_input_file( avformat_ctx ); +#endif + + return -1; } codec = avcodec_find_decoder( avformat_ctx->streams[i]->codec->codec_id ); if( codec == NULL ) { veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: Unable to find decoder for codec %s", avformat_ctx->streams[i]->codec->codec_name); - av_close_input_file( avformat_ctx ); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avformat_close_input(&avformat_ctx); +#else + av_close_input_file( avformat_ctx ); +#endif return -1; } vi = i; @@ -1455,13 +1498,21 @@ further: if( vi == -1 ) { veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: No video streams found"); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avformat_close_input(&avformat_ctx); +#else av_close_input_file( avformat_ctx ); +#endif return -1; } codec_ctx = avformat_ctx->streams[vi]->codec; avformat_stream=avformat_ctx->streams[vi]; - if ( avcodec_open( codec_ctx, codec ) < 0 ) { +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 8, 0) + if ( avcodec_open( codec_ctx, codec ) < 0 ) { +#else + if ( avcodec_open2( codec_ctx, codec, NULL ) < 0 ) { +#endif veejay_msg(VEEJAY_MSG_DEBUG, "FFmpeg: Unable to open %s decoder (codec %x)", codec_ctx->codec_name, codec_ctx->codec_id); return -1; @@ -1485,7 +1536,11 @@ further: av_free(f); free_av_packet(&pkt); avcodec_close( codec_ctx ); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avformat_close_input(&avformat_ctx); +#else av_close_input_file( avformat_ctx ); +#endif return -1; } @@ -1497,7 +1552,11 @@ further: free_av_packet(&pkt); avcodec_close( codec_ctx ); +#if (LIBAVFORMAT_VERSION_MAJOR <= 53) + avformat_close_input(&avformat_ctx); +#else av_close_input_file( avformat_ctx ); +#endif av_free(f); return pix_fmt; diff --git a/veejay-current/veejay-server/libel/vj-mmap.c b/veejay-current/veejay-server/libel/vj-mmap.c index c63a2bd6..faa848f9 100644 --- a/veejay-current/veejay-server/libel/vj-mmap.c +++ b/veejay-current/veejay-server/libel/vj-mmap.c @@ -39,8 +39,8 @@ void mmap_free(mmap_region_t *map) mmap_region_t * mmap_file(int fd, int offset, int length, int fs) { - mmap_region_t *map = (mmap_region_t*) malloc(sizeof( mmap_region_t )); - memset( map, 0, sizeof( mmap_region_t )); + mmap_region_t *map = (mmap_region_t*) vj_malloc(sizeof( mmap_region_t )); + veejay_memset( map, 0, sizeof( mmap_region_t )); map->fd = fd; map->page_size = getpagesize(); diff --git a/veejay-current/veejay-server/libplugger/freeframe-loader.c b/veejay-current/veejay-server/libplugger/freeframe-loader.c index 9a63d069..a838725a 100644 --- a/veejay-current/veejay-server/libplugger/freeframe-loader.c +++ b/veejay-current/veejay-server/libplugger/freeframe-loader.c @@ -73,6 +73,9 @@ static void *yuv_conv_ = NULL; #define FF_CAP_V_BITS_VIDEO FF_CAP_16BITVIDEO #endif*/ +static void freeframe_copy_parameters( void *srcPort, void *dst, int n_params ); + + void freeframe_destroy( ) { int i; yuv_free_swscaler( rgb_conv_ ); @@ -632,7 +635,7 @@ void freeframe_plug_param_f( void *plugin, int seq_no, void *dargs ) -void freeframe_copy_parameters( void *srcPort, void *dst, int n_params ) +static void freeframe_copy_parameters( void *srcPort, void *dst, int n_params ) { int p; for( p = 0; p < n_params; p ++ ) { diff --git a/veejay-current/veejay-server/libstream/v4l2utils.c b/veejay-current/veejay-server/libstream/v4l2utils.c index 3bf58db9..e58575c8 100644 --- a/veejay-current/veejay-server/libstream/v4l2utils.c +++ b/veejay-current/veejay-server/libstream/v4l2utils.c @@ -563,8 +563,11 @@ static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_ veejay_msg(0, "v4l2: (untested) Codec not found."); return 0; } - - v->c = avcodec_alloc_context(); +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 8, 0) + v->c = avcodec_alloc_context(); +#else + v->c = avcodec_alloc_context3(v->codec); +#endif v->c->width= wid; v->c->height= hei; v->picture = avcodec_alloc_frame(); @@ -577,8 +580,11 @@ static int v4l2_setup_avcodec_capture( v4l2info *v, int wid, int hei, int codec_ if( v->codec->capabilities & CODEC_CAP_TRUNCATED) v->c->flags |= CODEC_FLAG_TRUNCATED; - - if( avcodec_open( v->c, v->codec ) < 0 ) +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 8, 0) + if( avcodec_open( v->c, v->codec ) < 0 ) +#else + if( avcodec_open2( v->c, v->codec, NULL ) < 0 ) +#endif { veejay_msg(0, "v4l2: (untested) Error opening codec"); free(v->picture->data[0]); @@ -1387,7 +1393,7 @@ void v4l2_close( void *d ) } if(v->codec) { - avcodec_close(v->codec); + avcodec_close(v->c); v->codec = NULL; } diff --git a/veejay-current/veejay-server/libvje/effects/ripple.c b/veejay-current/veejay-server/libvje/effects/ripple.c index e6864b49..10d78e14 100644 --- a/veejay-current/veejay-server/libvje/effects/ripple.c +++ b/veejay-current/veejay-server/libvje/effects/ripple.c @@ -173,7 +173,7 @@ void ripple_apply(VJFrame *frame, int width, int height, int _w, int _a , int _a sx = (int) (x+z * ripple_cos[a]); sy = (int) (y+z * ripple_sin[a]); - if(sy > (height-1)) sy = height-1; + if(sy >= (height-1)) sy = height-1; if(sx > width) sx = width; if(sx < 0) sx =0; if(sy < 0) sy =0; diff --git a/veejay-current/veejay-server/libvje/effects/scratcher.c b/veejay-current/veejay-server/libvje/effects/scratcher.c index b9402b76..523cdd96 100644 --- a/veejay-current/veejay-server/libvje/effects/scratcher.c +++ b/veejay-current/veejay-server/libvje/effects/scratcher.c @@ -100,7 +100,7 @@ void store_frame(VJFrame *src, int w, int h, int n, int no_reverse) if (!nreverse) { vj_frame_copy( src->data, dest, strides ); } else { - vj_frame_copy( dest, src, strides ); + vj_frame_copy( dest, src->data, strides ); } if (nreverse) diff --git a/veejay-current/veejay-server/libvje/effects/softblur.c b/veejay-current/veejay-server/libvje/effects/softblur.c index 03ebb5d4..86b2cf62 100644 --- a/veejay-current/veejay-server/libvje/effects/softblur.c +++ b/veejay-current/veejay-server/libvje/effects/softblur.c @@ -160,7 +160,7 @@ static void mmx_blur(uint8_t *buffer, int width, int height) // : "mm0", "mm1", "mm2", "mm3", "mm6"); } - len = (width*height)-1; + len = (width*height)-4; for (i = len; i > scrsh; i -= 4) { __asm __volatile diff --git a/veejay-current/veejay-server/libvjmem/memcpy.c b/veejay-current/veejay-server/libvjmem/memcpy.c index 277ad5b7..a8ef78fa 100644 --- a/veejay-current/veejay-server/libvjmem/memcpy.c +++ b/veejay-current/veejay-server/libvjmem/memcpy.c @@ -1195,7 +1195,7 @@ static void vj_frame_copy_job( void *arg ) { assert( info->input[i] != NULL ); } #endif - if( info->strides[i] == 0 || info->output[i] == NULL || info->output[i] == NULL ) + if( info->strides[i] <= 0 || info->output[i] == NULL || info->output[i] == NULL ) continue; veejay_memcpy( info->output[i], info->input[i], info->strides[i] ); } diff --git a/veejay-current/veejay-server/libvjmsg/vj-common.c b/veejay-current/veejay-server/libvjmsg/vj-common.c index d3c7f1a1..14b9ea50 100644 --- a/veejay-current/veejay-server/libvjmsg/vj-common.c +++ b/veejay-current/veejay-server/libvjmsg/vj-common.c @@ -41,7 +41,7 @@ #include #include #include - +#include #include #include diff --git a/veejay-current/veejay-server/libyuv/subsample.c b/veejay-current/veejay-server/libyuv/subsample.c index 110704ee..af09fa9d 100644 --- a/veejay-current/veejay-server/libyuv/subsample.c +++ b/veejay-current/veejay-server/libyuv/subsample.c @@ -929,11 +929,11 @@ void chroma_subsample(subsample_mode_t mode, VJFrame *frame, uint8_t *ycbcr[] ) void chroma_supersample(subsample_mode_t mode,VJFrame *frame, uint8_t *ycbcr[] ) { if( vj_task_available() ) { - void *data = vj_task_alloc_internal_buf( frame->uv_len * 2 ); //@ 4:2:2 + void *data = vj_task_alloc_internal_buf( frame->uv_len * 4 ); //@ 4:2:2 uint8_t *plane = (uint8_t*) data; uint8_t *vplane = plane + frame->uv_len; - uint8_t *planes[3] = { NULL, plane,vplane }; + uint8_t *planes[4] = { NULL, plane,vplane,NULL }; int strides[4] = { 0, frame->uv_len, frame->uv_len, 0 }; vj_frame_copy( ycbcr, planes,strides); vj_task_set_sampling ( 1 ); diff --git a/veejay-current/veejay-server/libyuv/yuvconv.c b/veejay-current/veejay-server/libyuv/yuvconv.c index 7ef1932e..c6f30e57 100644 --- a/veejay-current/veejay-server/libyuv/yuvconv.c +++ b/veejay-current/veejay-server/libyuv/yuvconv.c @@ -617,7 +617,7 @@ void yuv_convert_any3( void *scaler, VJFrame *src, int src_stride[3], VJFrame *d { veejay_msg(0,"sws_getContext failed."); if(s)free(s); - return NULL; + return; } /* struct SwsContext *ctx = sws_getContext( @@ -1272,10 +1272,8 @@ void yuv_convert_and_scale_rgb(void *sws , VJFrame *src, VJFrame *dst) void yuv_convert_and_scale(void *sws , VJFrame *src, VJFrame *dst) { vj_sws *s = (vj_sws*) sws; - - int src_stride[3]; - int dst_stride[3]; - + int src_stride[3] = { src->width,0,0 }; + int dst_stride[3] = { dst->width,0,0 }; /* int n = 0; if( src->format == PIX_FMT_RGBA || src->format == PIX_FMT_BGRA || src->format == PIX_FMT_ARGB || diff --git a/veejay-current/veejay-server/veejay/Makefile.am b/veejay-current/veejay-server/veejay/Makefile.am index 6c43bcfb..9183ad04 100644 --- a/veejay-current/veejay-server/veejay/Makefile.am +++ b/veejay-current/veejay-server/veejay/Makefile.am @@ -19,7 +19,7 @@ INCLUDES = -I$(top_srcdir) -I$(includedir) \ -I$(top_srcdir)/libvevo \ -I$(top_srcdir)/liblzo \ -I$(top_srcdir)/bio2jack \ - $(FFMPEG_CFLAGS) $(LIBQUICKTIME_CFLAGS) $(FT_CFLAGS) \ + $(FFMPEG_CFLAGS) $(LIBQUICKTIME_CFLAGS) $(FREETYPE_CFLAGS) $(FREETYPE2_CFLAGS) \ $(AVIPLAY_CFLAGS) $(XML2_CFLAGS) $(GTK_CFLAGS) $(DV_FLAGS) $(X_CFLAGS) $(LIBLO_CFLAGS) \ $(DIRECTFB_CFLAGS) $(SDL_CFLAGS) $(JPEG_CFLAGS) $(JACK_CFLAGS) $(PTHREAD_CFLAGS) @@ -56,7 +56,7 @@ libveejay_la_LIBADD = -L$(top_builddir)/mjpegtools/ -lmjpegutils \ -L$(top_builddir)/libsamplerec -lsamplerec \ -L$(top_builddir)/libvevo -lvevo -libveejay_la_LDFLAGS += $(SDL_LIBS) $(DIRECTFB_LIBS) $(X_LIBS) $(PTHREAD_LIBS) $(FT_LDFLAGS) $(FT_LIBS) \ +libveejay_la_LDFLAGS += $(SDL_LIBS) $(DIRECTFB_LIBS) $(X_LIBS) $(PTHREAD_LIBS) $(FT_LDFLAGS) $(FREETYPE_LIBS) $(FREETYPE2_LIBS) \ $(XML2_LIBS) $(JPEG_LIBS) $(LIBLO_LIBS) \ $(FFMPEG_LIBS) $(XINERAMA_LIBS) \ $(LIBDV_LIBS) $(LIBM_LIBS) $(PIXBUF_LIBS) $(JACK_LIBS) $(LIBQUICKTIME_LIBS) $(RT_LIBS) \ diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index c0f173ce..9fa15302 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -61,6 +61,10 @@ #define PERFORM_AUDIO_SIZE 16384 +#ifndef SAMPLE_FMT_S16 +#define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16 +#endif + typedef struct { uint8_t *Y; uint8_t *Cb; diff --git a/veejay-current/veejay-server/veejay/vj-task.c b/veejay-current/veejay-server/veejay/vj-task.c index 09d5d256..6192b7bb 100644 --- a/veejay-current/veejay-server/veejay/vj-task.c +++ b/veejay-current/veejay-server/veejay/vj-task.c @@ -236,7 +236,8 @@ int task_start(int max_workers) max_p = min_p; - struct sched_param param; +// struct sched_param param; +// veejay_memset( ¶m, 0, sizeof(struct sched_param)); cpu_set_t cpuset; pthread_cond_init( &tasks_completed, NULL ); pthread_cond_init( ¤t_task, NULL ); @@ -245,9 +246,9 @@ int task_start(int max_workers) for( i = 0 ; i < max_workers; i ++ ) { thr_id[i] = i; pthread_attr_init( &p_attr[i] ); - pthread_attr_setstacksize( &p_attr[i], 128 * 1024 ); - pthread_attr_setschedpolicy( &p_attr[i], SCHED_FIFO ); - pthread_attr_setschedparam( &p_attr[i], ¶m ); + pthread_attr_setstacksize( &p_attr[i], 256 * 1024 ); +// pthread_attr_setschedpolicy( &p_attr[i], SCHED_FIFO ); +// pthread_attr_setschedparam( &p_attr[i], ¶m ); if( n_cpu > 1 ) { CPU_ZERO(&cpuset); From 6939b05a387baeba2e251c99955aee6e0fbe08d5 Mon Sep 17 00:00:00 2001 From: niels Date: Sat, 22 Feb 2014 19:24:47 +0100 Subject: [PATCH 30/32] fix CODEC_TYPE_VIDEO --- veejay-current/veejay-server/configure.ac | 1 - veejay-current/veejay-server/libel/Makefile.am | 2 +- veejay-current/veejay-server/libel/vj-el.c | 9 +-------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index babeda0d..d8f187f4 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -1136,6 +1136,5 @@ AC_MSG_NOTICE([ - Jack Audio Connection Kit : ${have_jack}]) AC_MSG_NOTICE([ - Liblo OSC client : ${have_liblo}]) AC_MSG_NOTICE([ - V4L2 (default) : ${have_v4l2}]) AC_MSG_NOTICE([ - V4L1 (obsolete) : ${have_v4l}]) -#AC_MSG_NOTICE([ - libsamplerate : ${have_samplerate}]) cat NEWS diff --git a/veejay-current/veejay-server/libel/Makefile.am b/veejay-current/veejay-server/libel/Makefile.am index 4f682ab1..584687ee 100644 --- a/veejay-current/veejay-server/libel/Makefile.am +++ b/veejay-current/veejay-server/libel/Makefile.am @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CFLAGS=$(OP_CFLAGS) INCLUDES = -I$(top_srcdir) -I$(includedir) -I$(top_srcdir)/vjmem \ -I$(top_srcdir)/vjmsg \ - -I$(top_srcdir)/mjpegtools $(FFMPEG_AVUTIL_CFLAGS) $(FFMPEG_AVFORMAT_CFLAGS) $(FFMPEG_AVCODEC_CFLAGS) $(FFMPEG_SWSCALER_CFLAGS) $(PIXBUF_CFLAGS) \ + -I$(top_srcdir)/mjpegtools $(FFMPEG_CFLAGS) $(PIXBUF_CFLAGS) \ $(LIBQUICKTIME_CFLAGS) VJEL_LIB_FILE = libel.la diff --git a/veejay-current/veejay-server/libel/vj-el.c b/veejay-current/veejay-server/libel/vj-el.c index 02f24c8e..00cf4113 100644 --- a/veejay-current/veejay-server/libel/vj-el.c +++ b/veejay-current/veejay-server/libel/vj-el.c @@ -50,6 +50,7 @@ #include #include #include + #ifdef SUPPORT_READ_DV2 #include "rawdv.h" #include "vj-dv.h" @@ -1449,15 +1450,7 @@ int detect_pixel_format_with_ffmpeg( const char *filename ) { if( avformat_ctx->streams[i]->codec ) { -#if (LIBAVFORMAT_VERSION_MAJOR <= 53) - #if (LIBAVFORMAT_VERSION_MINOR <= 5 ) - if( avformat_ctx->streams[i]->codec->codec_type < CODEC_ID_MP2 ) - #else if( avformat_ctx->streams[i]->codec->codec_type < CODEC_ID_FIRST_AUDIO ) - #endif -#else - if( avformat_ctx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO ) -#endif { int sup_codec = 0; for( j = 0; _supported_codecs[j].name != NULL; j ++ ) { From cbae0b1063dd3a461b475fe0dce544a759342640 Mon Sep 17 00:00:00 2001 From: niels Date: Sat, 22 Feb 2014 19:47:40 +0100 Subject: [PATCH 31/32] define $(FFMPEG_CFLAGS) in Makefile.am for libyuv --- veejay-current/veejay-server/libyuv/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/veejay-current/veejay-server/libyuv/Makefile.am b/veejay-current/veejay-server/libyuv/Makefile.am index f50ad70a..a4e3d45f 100644 --- a/veejay-current/veejay-server/libyuv/Makefile.am +++ b/veejay-current/veejay-server/libyuv/Makefile.am @@ -2,7 +2,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CFLAGS=$(YUVCFLAGS) -INCLUDES = -I$(top_srcdir) -I$(includedir) -I$(top_srcdir)/aclib -I$(top_srcdir)/vjmem -I$(top_srcdir)/vjmsg -I$(top_srcdir)/libpostproc +INCLUDES = -I$(top_srcdir) -I$(includedir) -I$(top_srcdir)/aclib -I$(top_srcdir)/vjmem -I$(top_srcdir)/vjmsg -I$(top_srcdir)/libpostproc -I$(FFMPEG_CFLAGS) YUV_LIB_FILE = libyuv.la pkginclude_HEADERS=yuvconv.h EXTRA_DIST = mmx.h yuvconv.h mmx_macros.h From 136a4bf5dccb26747f388e5f3dbe5e612fa39f4a Mon Sep 17 00:00:00 2001 From: niels Date: Sat, 22 Feb 2014 19:48:41 +0100 Subject: [PATCH 32/32] fix $(FFMPEG_CFLAGS) for libsamplerec/Makefile.am --- veejay-current/veejay-server/libsamplerec/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/veejay-current/veejay-server/libsamplerec/Makefile.am b/veejay-current/veejay-server/libsamplerec/Makefile.am index 4d772c80..8a0ec586 100644 --- a/veejay-current/veejay-server/libsamplerec/Makefile.am +++ b/veejay-current/veejay-server/libsamplerec/Makefile.am @@ -5,7 +5,7 @@ INCLUDES = -I$(top_srcdir) -I$(includedir)\ -I$(top_srcdir)/vjmsg \ -I$(top_srcdir)/libel \ -I$(top_srcdir)/mjpegtools \ - $(XML2_CFLAGS) + $(XML2_CFLAGS) $(FFMPEG_CFLAGS) AM_CFLAGS=$(OP_CFLAGS) SAMPLEREC_LIB_FILE = libsamplerec.la noinst_LTLIBRARIES = $(SAMPLEREC_LIB_FILE)