mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-15 12:20:03 +01:00
bugfixes to a few FX, fixed multi thread task balancer,fixed removing shm segment on close, do not fail opening v4l2 device that report no input sources or channels.
This commit is contained in:
@@ -84,7 +84,6 @@
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavcodec/avcodec.h>
|
||||
//#include <pthread.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
typedef struct {
|
||||
void *start;
|
||||
size_t length;
|
||||
@@ -320,8 +319,6 @@ static int v4l2_ffmpeg2v4l2( int pf)
|
||||
default:
|
||||
#ifdef STRICT_CHECKING
|
||||
assert( pf >= 0 );
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "v4l2: using BGR24 (default) for unhandled pixfmt '%s'",
|
||||
av_pix_fmt_descriptors[ pf ] );
|
||||
#endif
|
||||
return V4L2_PIX_FMT_BGR24;
|
||||
}
|
||||
@@ -905,15 +902,16 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi
|
||||
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?");
|
||||
free(v);
|
||||
close(fd);
|
||||
return NULL;
|
||||
chan = 0;
|
||||
// free(v);
|
||||
// close(fd);
|
||||
// return NULL;
|
||||
}
|
||||
if( -1 == vioctl( fd, VIDIOC_S_INPUT, &chan )) {
|
||||
int lvl = 0;
|
||||
if( errno == EINVAL )
|
||||
lvl = VEEJAY_MSG_WARNING;
|
||||
veejay_msg(0, "v4l2: VIDIOC_S_INPUT failed with %s, arg was %x", strerror(errno),chan);
|
||||
veejay_msg(lvl, "v4l2: VIDIOC_S_INPUT failed with %s, arg was %x", strerror(errno),chan);
|
||||
if( errno != EINVAL ) {
|
||||
free(v);
|
||||
close(fd);
|
||||
@@ -925,9 +923,9 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi
|
||||
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;
|
||||
//free(v);
|
||||
//close(fd);
|
||||
//return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -991,6 +989,8 @@ void *v4l2open ( const char *file, const int input_channel, int host_fmt, int wi
|
||||
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.",
|
||||
v->buffer.length,fd, v->buffer.m.offset );
|
||||
// int k;
|
||||
// for( k = 0; k < i; k ++ )
|
||||
// munmap( v->buffer[k].start, v->buffer[k].length );
|
||||
@@ -1061,11 +1061,6 @@ v4l2_rw_fallback:
|
||||
v->sizeimage = v->format.fmt.pix.sizeimage;
|
||||
v->buffers = (bufs*) calloc( 1, sizeof(*v->buffers));
|
||||
veejay_msg(VEEJAY_MSG_DEBUG,"v4l2: read/write buffer size is %d bytes", v->format.fmt.pix.sizeimage );
|
||||
if(v->is_jpeg) {
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "v4l2: requested format %s -> %s, %d x %d",
|
||||
&(v->format.fmt.pix.pixelformat), av_pix_fmt_descriptors[ v->info->format ],
|
||||
v->format.fmt.pix.width, v->format.fmt.pix.height );
|
||||
}
|
||||
|
||||
v->buffers[0].length = v->sizeimage;
|
||||
v->buffers[0].start = malloc( v->sizeimage * 2 );
|
||||
@@ -1280,6 +1275,7 @@ void v4l2_close( void *d )
|
||||
v4l2info *v = (v4l2info*) d;
|
||||
int i;
|
||||
|
||||
|
||||
if( v->rw == 0 ) {
|
||||
if( -1 == vioctl( v->fd, VIDIOC_STREAMOFF, &(v->buftype)) ) {
|
||||
veejay_msg(0, "v4l2: VIDIOC_STREAMOFF failed with %s", strerror(errno));
|
||||
@@ -1898,8 +1894,8 @@ static void *v4l2_grabber_thread( void *v )
|
||||
for( c = 0; c < 4; c ++ )
|
||||
v4l2->out_planes[c] = planes[c];
|
||||
|
||||
veejay_msg(VEEJAY_MSG_INFO, "v4l2: capture format: %d x %d (%s)",
|
||||
v4l2->info->width,v4l2->info->height, av_pix_fmt_descriptors[ v4l2->info->format ].name );
|
||||
veejay_msg(VEEJAY_MSG_INFO, "v4l2: capture format: %d x %d (%x)",
|
||||
v4l2->info->width,v4l2->info->height, v4l2->info->format );
|
||||
|
||||
i->grabbing = 1;
|
||||
i->retries = max_retries;
|
||||
@@ -2063,18 +2059,16 @@ void *v4l2_thread_new( char *file, int channel, int host_fmt, int wid, int hei,
|
||||
}
|
||||
|
||||
int ready = 0;
|
||||
int retries = 50;
|
||||
int retries = 40;
|
||||
//@ wait until thread is ready
|
||||
while(1) {
|
||||
usleep(100);
|
||||
lock_(i);
|
||||
while(retries) {
|
||||
ready = i->grabbing;
|
||||
if( i->stop ) {
|
||||
ready = i->stop;
|
||||
}
|
||||
unlock_(i);
|
||||
if(ready)
|
||||
break;
|
||||
break;
|
||||
usleep(1000);
|
||||
retries--;
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ void chromamagic_addlum(VJFrame *frame, VJFrame *frame2, int width,
|
||||
void chromamagic_exclusive(VJFrame *frame, VJFrame *frame2, int width, int height, int op_a) {
|
||||
unsigned int i;
|
||||
const int len = frame->len;
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Cb = frame->data[1];
|
||||
uint8_t *Cr = frame->data[2];
|
||||
uint8_t *Y2 = frame2->data[0];
|
||||
@@ -294,29 +294,24 @@ void chromamagic_exclusive(VJFrame *frame, VJFrame *frame2, int width, int heigh
|
||||
const unsigned int o2 = 255 - a;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
a = Y[i];
|
||||
b = Y2[i];
|
||||
|
||||
a *= o1;
|
||||
b *= o2;
|
||||
a = a >> 8;
|
||||
b = b >> 8;
|
||||
|
||||
Y[i] = (a+b) - ((a * b) >> 8);
|
||||
|
||||
a = Cb[i]-128;
|
||||
b = Cb2[i]-128;
|
||||
c = (a + b) - (( a * b) >> 8);
|
||||
c += 128;
|
||||
Cb[i] = CLAMP_UV(c);
|
||||
|
||||
|
||||
a = Cr[i]-128;
|
||||
b = Cr2[i]-128;
|
||||
c = (a + b) - ((a*b) >> 8);
|
||||
c += 128;
|
||||
Cr[i] = CLAMP_UV(c);
|
||||
a = Y[i];
|
||||
b = Y2[i];
|
||||
c = a + (2 * b) - op_a;
|
||||
Y[i] = CLAMP_Y(c - (( a * b ) >> 8 ));
|
||||
}
|
||||
for( i = 0; i < len ; i ++ ) {
|
||||
a = Cb[i];
|
||||
b = Cb2[i];
|
||||
|
||||
c = a + (2 * b);
|
||||
Cb[i] = CLAMP_UV(c - 0xff);
|
||||
|
||||
a = Cr[i];
|
||||
b = Cr2[i];
|
||||
c = a + (2 * b);
|
||||
Cr[i] = CLAMP_UV(c - 0xff);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void chromamagic_diffnegate(VJFrame *frame, VJFrame *frame2, int width, int height, int op_a) {
|
||||
|
||||
@@ -78,13 +78,17 @@ void complexsync_apply(VJFrame *frame, VJFrame *frame2, int width, int height, i
|
||||
|
||||
const unsigned int region = width * val;
|
||||
int strides[4] = { region, region, region, 0 };
|
||||
vj_frame_copy( frame->data, c_outofsync_buffer, strides );
|
||||
|
||||
vj_frame_copy( frame2->data, frame->data, strides );
|
||||
int i;
|
||||
for( i = 0; i < 3; i ++ )
|
||||
vj_frame_copy1( frame->data[i], c_outofsync_buffer[i], strides[i] );
|
||||
|
||||
for( i = 0; i < 3; i ++ )
|
||||
vj_frame_copy1( frame2->data[i], frame->data[i], strides[i] );
|
||||
|
||||
if( (len - region) > 0)
|
||||
{
|
||||
uint8_t *dest[3] = { Y + region, Cb + region, Cr + region };
|
||||
uint8_t *dest[4] = { Y + region, Cb + region, Cr + region, NULL };
|
||||
vj_frame_copy( c_outofsync_buffer, dest, strides );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,11 +68,15 @@ static int N__ = 0;
|
||||
|
||||
int lumamask_malloc(int width, int height)
|
||||
{
|
||||
buf[0] = (uint8_t*)vj_yuvalloc(width,height);
|
||||
buf[0] = (uint8_t*)vj_malloc( sizeof(uint8_t) * width * height);
|
||||
if(!buf[0]) return 0;
|
||||
buf[1] = buf[0] + (width *height);
|
||||
buf[2] = buf[1] + (width *height);
|
||||
|
||||
veejay_memset( buf[0], 0, width * height );
|
||||
|
||||
buf[1] = buf[0] + (width *height);
|
||||
veejay_memset( buf[1], 128, width * height );
|
||||
buf[2] = buf[1] + (width *height);
|
||||
veejay_memset( buf[2], 128, width * height );
|
||||
n__ = 0;
|
||||
N__ = 0;
|
||||
return 1;
|
||||
@@ -111,11 +115,8 @@ void lumamask_apply( VJFrame *frame, VJFrame *frame2, int width,
|
||||
uint8_t *Cb2 = frame2->data[1];
|
||||
uint8_t *Cr2 = frame2->data[2];
|
||||
|
||||
// keep copy of original frame
|
||||
veejay_memcpy(buf[0], Y, width * height );
|
||||
veejay_memcpy(buf[1], Cb, (width * height) );
|
||||
veejay_memcpy(buf[2], Cr, (width * height) );
|
||||
|
||||
int strides[4] = { width * height, width * height, width * height ,0};
|
||||
vj_frame_copy( frame->data, buf, strides );
|
||||
|
||||
if( border )
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ vj_effect *opacity_init(int w, int h)
|
||||
ve->limits[1][0] = 255;
|
||||
ve->defaults[0] = 150;
|
||||
ve->description = "Normal Overlay";
|
||||
ve->sub_format = 0;
|
||||
ve->sub_format = 1;
|
||||
ve->extra_frame = 1;
|
||||
ve->parallel = 1;
|
||||
ve->has_user = 0;
|
||||
@@ -164,14 +164,7 @@ static void opacity_apply_job( void *arg )
|
||||
void opacity_apply( VJFrame *frame, VJFrame *frame2, int width,
|
||||
int height, int opacity)
|
||||
{
|
||||
/* if( vj_task_available() ) {
|
||||
vj_task_set_from_frame( frame );
|
||||
vj_task_set_int( opacity );
|
||||
vj_task_run( frame->data, frame2->data, NULL, NULL, 3, &opacity_apply_job );
|
||||
} else {
|
||||
*/
|
||||
opacity_apply1( frame,frame2,width,height,opacity );
|
||||
// }
|
||||
}
|
||||
|
||||
void opacity_applyN( VJFrame *frame, VJFrame *frame2, int width,
|
||||
|
||||
@@ -64,6 +64,7 @@ int radcor_malloc( int width, int height )
|
||||
if(!badbuf)
|
||||
return 0;
|
||||
Map = (uint32_t*) vj_malloc( RUP8(width * height * sizeof(uint32_t)));
|
||||
veejay_memset( Map, 0, RUP8(width * height * sizeof(uint32_t)) );
|
||||
if(!Map)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
@@ -59,10 +59,13 @@ void rawval_apply( VJFrame *frame, int width, int height,
|
||||
const int new_color_cb, const int new_color_cr)
|
||||
{
|
||||
unsigned int i;
|
||||
const int uv_len = frame->uv_len;
|
||||
int uv_len = frame->uv_len;
|
||||
uint8_t *Cb= frame->data[1];
|
||||
uint8_t *Cr= frame->data[2];
|
||||
|
||||
if( frame->ssm )
|
||||
uv_len = frame->len;
|
||||
|
||||
for (i = 0; i < uv_len; i++) {
|
||||
if (Cb[i] >= new_color_cb)
|
||||
Cb[i] = color_cb;
|
||||
|
||||
@@ -224,12 +224,12 @@ void rotozoom_apply( VJFrame *frame, int width, int height, int mode,
|
||||
int strides[4] = { width*height,width*height,width*height,0};
|
||||
switch (autom) { /* alas must do memcpy */
|
||||
case 0:
|
||||
vj_frame_copy1( frame->data, rotobuffer, strides );
|
||||
vj_frame_copy( frame->data, rotobuffer, strides );
|
||||
rotozoom2_apply(frame, rotobuffer, width, height, mode, rotate,
|
||||
zoom);
|
||||
break;
|
||||
case 1:
|
||||
vj_frame_copy1( frame->data,rotobuffer, strides );
|
||||
vj_frame_copy( frame->data,rotobuffer, strides );
|
||||
rotozoom1_apply(frame, rotobuffer, width, height, mode, rotate,
|
||||
zoom);
|
||||
break;
|
||||
|
||||
@@ -1189,8 +1189,15 @@ static void vj_frame_copy_job( void *arg ) {
|
||||
assert( task_get_workers() > 0 );
|
||||
#endif
|
||||
for( i = 0; i < 4; i ++ ) {
|
||||
if( info->strides[i] > 0 )
|
||||
veejay_memcpy( info->output[i], info->input[i], info->strides[i] );
|
||||
#ifdef STRICT_CHECKING
|
||||
if( info->strides[i] > 0 ) {
|
||||
assert( info->output[i] != NULL );
|
||||
assert( info->input[i] != NULL );
|
||||
}
|
||||
#endif
|
||||
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] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1201,6 +1208,12 @@ static void vj_frame_clear_job( void *arg ) {
|
||||
assert( task_get_workers() > 0 );
|
||||
#endif
|
||||
for( i = 0; i < 4; i ++ ) {
|
||||
#ifdef STRICT_CHECKING
|
||||
if( info->strides[i] > 0 ) {
|
||||
assert( info->input[i] != NULL );
|
||||
assert( info->output[i] != NULL );
|
||||
}
|
||||
#endif
|
||||
if( info->strides[i] > 0 )
|
||||
veejay_memset( info->input[i], info->iparam, info->strides[i] );
|
||||
}
|
||||
@@ -1278,17 +1291,27 @@ void vj_frame_slow_threaded( uint8_t **p0_buffer, uint8_t **p1_buffer, uint8_t *
|
||||
void vj_frame_simple_clear( uint8_t **input, int *strides, int v )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < 4; i ++ )
|
||||
if( strides[i] > 0 )
|
||||
veejay_memset( input[i], v,strides[i] );
|
||||
for( i = 0; i < 4; i ++ ) {
|
||||
if( input[i] == NULL || strides[i] == 0 )
|
||||
continue;
|
||||
veejay_memset( input[i], v , strides[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vj_frame_simple_copy( uint8_t **input, uint8_t **output, int *strides, int planes )
|
||||
void vj_frame_simple_copy( uint8_t **input, uint8_t **output, int *strides )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < planes; i ++ )
|
||||
veejay_memcpy( output[i],input[i], strides[i] );
|
||||
for( i = 0; i < 4; i ++ ) {
|
||||
#ifdef STRICT_CHECKING
|
||||
if( strides[i] > 0 ) {
|
||||
assert( input[i] != NULL );
|
||||
assert( output[i] != NULL );
|
||||
}
|
||||
#endif
|
||||
if( input[i] != NULL && output[i] != NULL && strides[i] > 0 )
|
||||
veejay_memcpy( output[i],input[i], strides[i] );
|
||||
}
|
||||
}
|
||||
|
||||
void *(* vj_frame_copy)( uint8_t **input, uint8_t **output, int *strides ) = 0;
|
||||
|
||||
@@ -215,7 +215,7 @@ void *vj_yuvalloc( unsigned int w, unsigned int h )
|
||||
{
|
||||
size_t len = RUP8(w * h * 3);
|
||||
unsigned char *ptr = vj_malloc( len );
|
||||
|
||||
if(!ptr) return NULL;
|
||||
veejay_memset( ptr, 0, (w*h));
|
||||
veejay_memset( ptr + (w*h), 128, (w*h)*2);
|
||||
return ptr;
|
||||
|
||||
@@ -90,18 +90,21 @@ void vj_shm_free(void *vv)
|
||||
int res = pthread_rwlock_destroy( &data->rwlock );
|
||||
|
||||
res = shmdt( v->sms );
|
||||
if(res ) {
|
||||
if(res==-1 ) {
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Failed to detach shared memory: %s",strerror(errno));
|
||||
}
|
||||
res = shmctl( v->shm_id, IPC_RMID, NULL );
|
||||
if( res ) {
|
||||
if( res==-1 ) {
|
||||
veejay_msg(0, "Failed to remove shared memory %d: %s", v->shm_id, strerror(errno));
|
||||
} else {
|
||||
veejay_msg(VEEJAY_MSG_INFO, "Shared resource will %d be destroyed.", v->shm_id );
|
||||
}
|
||||
|
||||
if( v->file ) {
|
||||
remove(v->file);
|
||||
res = remove(v->file);
|
||||
if( res == -1 ) {
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "Unable to remove file %s", v->file);
|
||||
}
|
||||
free(v->file);
|
||||
}
|
||||
|
||||
|
||||
@@ -501,7 +501,7 @@ void vj_task_set_from_frame( VJFrame *in )
|
||||
v->strides[0] = (v->width * v->height);
|
||||
v->uv_width = in->uv_width;
|
||||
v->uv_height = in->uv_height / n;
|
||||
v->strides[1] = (v->width * v->uv_height) / n;
|
||||
v->strides[1] = v->uv_width * v->uv_height; //(v->width * v->uv_height) / n;
|
||||
v->strides[2] = v->strides[1];
|
||||
v->shiftv = in->shift_v;
|
||||
v->shifth = in->shift_h;
|
||||
|
||||
Reference in New Issue
Block a user