int ia_swscale( ia_swscale_t* c, ia_image_t* iaf, int32_t width, int32_t height ) { ia_image_t* iar = ia_image_create( width, height ); if( iar == NULL ) { return -1; } int s_stride[4] = {width*2, 0, 0, 0}; int d_stride[4] = {width*3, 0, 0, 0}; uint8_t* s_slice[4] = {iaf->pix, 0, 0, 0}; uint8_t* d_slice[4] = {iar->pix, 0, 0, 0}; if( sws_scale(c, s_slice, s_stride, 0, height, d_slice, d_stride) != height ) { return -1; } FreeImage_Unload( (FIBITMAP*)iaf->dib ); iaf->dib = iar->dib; iaf->pix = iar->pix; pthread_mutex_destroy( &iar->mutex ); pthread_cond_destroy( &iar->cond_ro ); pthread_cond_destroy( &iar->cond_rw ); ia_free( iar ); return 0; }
void v4l_close (ia_v4l_t* v) { uninit_device (v); close_device (v); ia_free (v); }
void ia_ffmpeg_close (ia_ffmpeg_t* ffio) { ia_free( ffio->img_convert_ctx ); // Free the RGB image av_free(ffio->buffer); av_free(ffio->pFrameRGB); // Free the YUV frame av_free(ffio->pFrame); // Close the codec avcodec_close(ffio->pCodecCtx); // Close the video file av_close_input_file(ffio->pFormatCtx); ia_free( ffio ); }
static void uninit_device (ia_v4l_t* v) { unsigned int i; io_method io = v->io; void* buffer = v->mmap_buffer; size_t length = v->mmap_length; struct buffer* buffers = v->buffers; switch (io) { case IO_METHOD_MMAP: if (-1 == ia_munmap (buffer, length)) errno_exit ("munmap"); ia_free (buffers); break; default: break; } }
void* analyze_exec( void* vptr ) { int no_filter = 0; ia_exec_t* iax = (ia_exec_t*) vptr; const int i_maxrefs = iax->ias->param->i_maxrefs; ia_image_t** iaim = malloc( sizeof(ia_image_t*)*i_maxrefs ); if( !iaim ) ia_pthread_exit( NULL ); while( 1 ) { ia_image_t *iaf, *iar; int i, j; uint64_t current_frame; /* wait for input buf (wait for input manager signal) */ iaf = ia_queue_pop( iax->ias->input_queue ); if( iaf->eoi ) { ia_queue_shove( iax->ias->output_queue, iaf, iaf->i_frame ); break; } current_frame = iaf->i_frame; ia_queue_shove_sorted( iax->ias->proc_queue, iaf, iaf->i_frame ); if( current_frame < (uint32_t) i_maxrefs ) continue; for( i = i_maxrefs-1, j = 0; i >= 0; i--, j++ ) { for( ;; ) { iaim[i] = ia_queue_pek( iax->ias->proc_queue, current_frame-j ); if( iaim[i] ) break; usleep( 50 ); } } /* wait for output buf (wait for output manager signal) */ iar = ia_image_create( iax->ias->param->i_width, iax->ias->param->i_height ); iar->i_frame = current_frame; /* do processing */ for ( j = 0; iax->ias->param->filter[j] != 0 && no_filter >= 0; j++ ) { if( filters.exec[iax->ias->param->filter[j]] ) filters.exec[iax->ias->param->filter[j]]( iax->ias, iax->ias->fparam[iax->ias->param->filter[j]], iaim, iar ); else no_filter++; } /* mark the no filter flag if no filters were specified */ if( no_filter == j || no_filter == -1 ) no_filter = -1; else no_filter = 0; /* close input buf (signal manage input) */ for( i = 0; i < i_maxrefs; i++ ) ia_queue_sht( iax->ias->proc_queue, iaim[i], i_maxrefs ); /* close output buf (signal manage output) */ ia_queue_push_sorted( iax->ias->output_queue, iar, iar->i_frame ); } ia_free( iaim ); ia_free( iax ); ia_pthread_exit( NULL ); return NULL; }
void ia_swscale_close( ia_swscale_t* c ) { ia_free( c ); }