Instrument Neutral Distributed Interface INDI  2.0.0
Classes | Macros | Typedefs | Functions
dsp.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <sys/types.h>
#include <time.h>
#include <assert.h>
#include <pthread.h>
#include <fits_extensions.h>

Go to the source code of this file.

Classes

struct  dsp_point_t
 Indicates a dot or line inside a dsp_stream. More...
 
struct  dsp_offset_t
 Indicates an offset. More...
 
struct  dsp_star_t
 A star or object contained into a buffer. More...
 
struct  dsp_triangle_t
 A star or object contained into a buffer. More...
 
struct  dsp_align_info_t
 Alignment informations needed. More...
 
union  dsp_complex
 Complex number array struct, used in Fourier Transform functions. More...
 
struct  dsp_region_t
 Delimits a region in a single dimension of a buffer. More...
 
union  dsp_location_t
 The location type. More...
 
struct  dsp_stream_t
 Contains a set of informations and data relative to a buffer and how to use it. More...
 

Macros

#define DLL_EXPORT   extern
 
#define __bswap_16(a)   __builtin_bswap16(a)
 
#define __bswap_32(a)   __builtin_bswap32(a)
 
#define __bswap_64(a)   __builtin_bswap64(a)
 
#define DSP_MAX_STARS   200
 
#define dsp_t_max   255
 
#define dsp_t_min   -dsp_t_max
 
#define DSP_DEBUG
 
#define DSP_DEBUG_INFO   0
 
#define DSP_DEBUG_ERROR   1
 
#define DSP_DEBUG_WARNING   2
 
#define DSP_DEBUG_DEBUG   3
 
#define pdbg(x, ...)
 
#define pinfo(...)   pdbg(DSP_DEBUG_INFO, __VA_ARGS__)
 
#define perr(...)   pdbg(DSP_DEBUG_ERROR, __VA_ARGS__)
 
#define pwarn(...)   pdbg(DSP_DEBUG_WARNING, __VA_ARGS__)
 
#define pgarb(...)   pdbg(DSP_DEBUG_DEBUG, __VA_ARGS__)
 
#define pfunc   pgarb("%s\n", __func__)
 
#define start_gettime
 
#define end_gettime
 
#define Min(a, b)
 if min() is not present you can use this one More...
 
#define Max(a, b)
 if max() is not present you can use this one More...
 
#define Log(a, b)   ( log(a) / log(b) )
 Logarithm of a with arbitrary base b. More...
 
#define DSP_ALIGN_TRANSLATED   1
 The stream is translated by the reference. More...
 
#define DSP_ALIGN_SCALED   2
 The stream is scaled by the reference. More...
 
#define DSP_ALIGN_ROTATED   4
 The stream is rotated by the reference. More...
 
#define DSP_ALIGN_NO_MATCH   8
 No matches were found during comparison. More...
 
#define dsp_stats_min(buf, len)
 Gets the minimum value of the input stream. More...
 
#define dsp_stats_max(buf, len)
 Gets the maximum value of the input stream. More...
 
#define dsp_stats_mid(buf, len)
 Gets the middle value of the input stream. More...
 
#define dsp_stats_minimum_index(buf, len)
 Gets minimum value's position into the buffer. More...
 
#define dsp_stats_maximum_index(buf, len)
 Gets maximum value's position into the buffer. More...
 
#define dsp_stats_mean(buf, len)
 A mean calculator. More...
 
#define dsp_stats_stddev(buf, len)
 Standard deviation of the inut stream. More...
 
#define dsp_stats_val_count(buf, len, val)
 Counts value occurrences into stream. More...
 
#define dsp_stats_val_sum(buf, len)
 Cumulative sum of all the values on the stream. More...
 
#define dsp_stats_range_count(buf, len, lo, hi)
 Counts value ranging occurrences into stream. More...
 
#define dsp_stats_compare(in1, in2, len)
 Compare two buffers. More...
 
#define dsp_buffer_stretch(buf, len, _mn, _mx)
 Stretch minimum and maximum values of the input stream. More...
 
#define dsp_buffer_set(buf, len, _val)
 Fill the buffer with the passed value. More...
 
#define dsp_buffer_normalize(buf, len, mn, mx)
 Normalize the input stream to the minimum and maximum values. More...
 
#define dsp_buffer_reverse(buf, len)
 Reverse the order of the buffer elements. More...
 
#define dsp_buffer_swap(in, len)
 Change the in buffer elements endianness. More...
 
#define dsp_buffer_copy(in, out, len)
 Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type. More...
 
#define dsp_buffer_copy_stepping(in, out, inlen, outlen, instep, outstep)
 Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type. More...
 

Typedefs

typedef double dsp_t
 
typedef double complex_t[2]
 
typedef struct dsp_point_t dsp_point
 Indicates a dot or line inside a dsp_stream. More...
 
typedef struct dsp_offset_t dsp_offset
 Indicates an offset. More...
 
typedef struct dsp_star_t dsp_star
 A star or object contained into a buffer. More...
 
typedef struct dsp_triangle_t dsp_triangle
 A star or object contained into a buffer. More...
 
typedef struct dsp_align_info_t dsp_align_info
 Alignment informations needed. More...
 
typedef struct dsp_region_t dsp_region
 Delimits a region in a single dimension of a buffer. More...
 
typedef union dsp_location_t dsp_location
 The location type. More...
 
typedef void *(* dsp_func_t) (void *,...)
 Multi-dimensional processing delegate function. More...
 
typedef struct dsp_stream_t dsp_stream
 Contains a set of informations and data relative to a buffer and how to use it. More...
 
typedef struct dsp_stream_tdsp_stream_p
 

Functions

DLL_EXPORT unsigned long int dsp_max_threads (unsigned long value)
 get/set the maximum number of threads allowed More...
 
DLL_EXPORT void dsp_set_debug_level (int value)
 set the debug level More...
 
DLL_EXPORT int dsp_get_debug_level ()
 get the debug level More...
 
DLL_EXPORT void dsp_set_app_name (char *name)
 set the application name More...
 
DLL_EXPORT char * dsp_get_app_name ()
 get the application name More...
 
DLL_EXPORT void dsp_set_stdout (FILE *f)
 set the output log streeam More...
 
DLL_EXPORT void dsp_set_stderr (FILE *f)
 set the error log streeam More...
 
DLL_EXPORT void dsp_print (int x, char *str)
 log a message to the error or output streams More...
 
DLL_EXPORT void dsp_fourier_dft (dsp_stream_p stream, int exp)
 Perform a discrete Fourier Transform of a dsp_stream. More...
 
DLL_EXPORT void dsp_fourier_idft (dsp_stream_p stream)
 Perform an inverse discrete Fourier Transform of a dsp_stream. More...
 
DLL_EXPORT void dsp_fourier_2dsp (dsp_stream_p stream)
 Fill the magnitude and phase buffers with the current data in stream->dft. More...
 
DLL_EXPORT void dsp_fourier_2complex_t (dsp_stream_p stream)
 Obtain the complex fourier tranform from the current magnitude and phase buffers. More...
 
DLL_EXPORT void dsp_fourier_phase_mag_array_get_complex (double *mag, double *phi, complex_t *out, int len)
 Obtain a complex array from phase and magnitude arrays. More...
 
DLL_EXPORT double * dsp_fourier_complex_array_get_magnitude (dsp_complex in, int len)
 Obtain a complex number's array magnitudes. More...
 
DLL_EXPORT double * dsp_fourier_complex_array_get_phase (dsp_complex in, int len)
 Obtain a complex number's array phases. More...
 
DLL_EXPORT void dsp_filter_squarelaw (dsp_stream_p stream)
 A square law filter. More...
 
DLL_EXPORT void dsp_filter_lowpass (dsp_stream_p stream, double frequency)
 A low pass filter. More...
 
DLL_EXPORT void dsp_filter_highpass (dsp_stream_p stream, double frequency)
 A high pass filter. More...
 
DLL_EXPORT void dsp_filter_bandpass (dsp_stream_p stream, double LowFrequency, double HighFrequency)
 A band pass filter. More...
 
DLL_EXPORT void dsp_filter_bandreject (dsp_stream_p stream, double LowFrequency, double HighFrequency)
 A band reject filter. More...
 
DLL_EXPORT void dsp_convolution_convolution (dsp_stream_p stream, dsp_stream_p matrix)
 A cross-convolution processor. More...
 
DLL_EXPORT void dsp_convolution_correlation (dsp_stream_p stream, dsp_stream_p matrix)
 A cross-correlation processor. More...
 
DLL_EXPORT double * dsp_stats_histogram (dsp_stream_p stream, int size)
 Histogram of the inut stream. More...
 
DLL_EXPORT void dsp_buffer_shift (dsp_stream_p stream)
 Shift a stream on each dimension. More...
 
DLL_EXPORT void dsp_buffer_removemean (dsp_stream_p stream)
 Subtract mean from stream. More...
 
DLL_EXPORT void dsp_buffer_max (dsp_stream_p stream, dsp_t *in, int len)
 Subtract elements of one stream from another's. More...
 
DLL_EXPORT void dsp_buffer_min (dsp_stream_p stream, dsp_t *in, int len)
 Sum elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_sub (dsp_stream_p stream, dsp_t *in, int len)
 Subtract elements of one stream from another's. More...
 
DLL_EXPORT void dsp_buffer_sum (dsp_stream_p stream, dsp_t *in, int len)
 Sum elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_div (dsp_stream_p stream, dsp_t *in, int len)
 Divide elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_mul (dsp_stream_p stream, dsp_t *in, int len)
 Multiply elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_pow (dsp_stream_p stream, dsp_t *in, int len)
 Expose elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_log (dsp_stream_p stream, dsp_t *in, int len)
 Logarithm elements of one stream using another's as base. More...
 
DLL_EXPORT void dsp_buffer_sub1 (dsp_stream_p stream, dsp_t val)
 Subtract a value from elements of the input stream. More...
 
DLL_EXPORT void dsp_buffer_1sub (dsp_stream_p stream, dsp_t val)
 Subtract each element of the input stream a value. More...
 
DLL_EXPORT void dsp_buffer_sum1 (dsp_stream_p stream, dsp_t val)
 Sum elements of the input stream to a value. More...
 
DLL_EXPORT void dsp_buffer_div1 (dsp_stream_p stream, double val)
 Divide elements of the input stream to a value. More...
 
DLL_EXPORT void dsp_buffer_1div (dsp_stream_p stream, double val)
 Divide a value to each element of the input stream. More...
 
DLL_EXPORT void dsp_buffer_mul1 (dsp_stream_p stream, double val)
 Multiply elements of the input stream to a value. More...
 
DLL_EXPORT void dsp_buffer_pow1 (dsp_stream_p stream, double val)
 Expose elements of the input stream to the given power. More...
 
DLL_EXPORT void dsp_buffer_log1 (dsp_stream_p stream, double val)
 Logarithm elements of the input stream using the given base. More...
 
DLL_EXPORT void dsp_buffer_median (dsp_stream_p stream, int size, int median)
 Median elements of the input stream. More...
 
DLL_EXPORT void dsp_buffer_sigma (dsp_stream_p stream, int size)
 Standard deviation of each element of the input stream within the given size. More...
 
DLL_EXPORT void dsp_buffer_deviate (dsp_stream_p stream, dsp_t *deviation, dsp_t mindeviation, dsp_t maxdeviation)
 Deviate forward the first input stream using the second stream as indexing reference. More...
 
DLL_EXPORT void dsp_stream_alloc_buffer (dsp_stream_p stream, int len)
 Allocate a buffer with length len on the stream passed as argument. More...
 
DLL_EXPORT void dsp_stream_set_buffer (dsp_stream_p stream, void *buffer, int len)
 Set the buffer of the stream passed as argument to a specific memory location. More...
 
DLL_EXPORT dsp_tdsp_stream_get_buffer (dsp_stream_p stream)
 Return the buffer of the stream passed as argument. More...
 
DLL_EXPORT void dsp_stream_free_buffer (dsp_stream_p stream)
 Free the buffer of the DSP Stream passed as argument. More...
 
DLL_EXPORT dsp_stream_p dsp_stream_new (void)
 Allocate a new DSP stream type. More...
 
DLL_EXPORT void dsp_stream_free (dsp_stream_p stream)
 Free the DSP stream passed as argument. More...
 
DLL_EXPORT dsp_stream_p dsp_stream_copy (dsp_stream_p stream)
 Create a copy of the DSP stream passed as argument. More...
 
DLL_EXPORT void dsp_stream_add_child (dsp_stream_p stream, dsp_stream_p child)
 Add a child to the DSP Stream passed as argument. More...
 
DLL_EXPORT void dsp_stream_add_star (dsp_stream_p stream, dsp_star star)
 Add a star to the DSP Stream passed as argument. More...
 
DLL_EXPORT void dsp_stream_del_star (dsp_stream_p stream, int n)
 Remove the star with index n to a DSP stream. More...
 
DLL_EXPORT void dsp_stream_add_triangle (dsp_stream_p stream, dsp_triangle triangle)
 Add a triangle to the DSP Stream passed as argument. More...
 
DLL_EXPORT void dsp_stream_del_triangle (dsp_stream_p stream, int index)
 Remove the triangle with index n to a DSP stream. More...
 
DLL_EXPORT void dsp_stream_calc_triangles (dsp_stream_p stream)
 Calculate the triangles in the stream struct. More...
 
DLL_EXPORT void dsp_stream_del_child (dsp_stream_p stream, int n)
 Remove the child with index n to a DSP stream. More...
 
DLL_EXPORT void dsp_stream_add_dim (dsp_stream_p stream, int len)
 Add a dimension with length len to a DSP stream. More...
 
DLL_EXPORT void dsp_stream_set_dim (dsp_stream_p stream, int dim, int size)
 Set a dimension size to a DSP stream. More...
 
DLL_EXPORT void dsp_stream_del_dim (dsp_stream_p stream, int n)
 Remove the dimension with index n to a DSP stream. More...
 
DLL_EXPORT int dsp_stream_set_position (dsp_stream_p stream, int *pos)
 Obtain the position the DSP stream by parsing multidimensional indexes. More...
 
DLL_EXPORT int * dsp_stream_get_position (dsp_stream_p stream, int index)
 Return the multidimensional positional indexes of a DSP stream by specify a linear index. More...
 
DLL_EXPORT void * dsp_stream_exec (dsp_stream_p stream, void *args,...)
 Execute the function callback pointed by the func field of the passed stream. More...
 
DLL_EXPORT void dsp_stream_crop (dsp_stream_p stream)
 Crop the buffers of the stream passed as argument by reading the ROI field. More...
 
DLL_EXPORT void dsp_stream_rotate (dsp_stream_p stream)
 Rotate a stream around an axis and offset. More...
 
DLL_EXPORT void dsp_stream_translate (dsp_stream_p stream)
 Translate a stream. More...
 
DLL_EXPORT void dsp_stream_scale (dsp_stream_p stream)
 Scale a stream. More...
 
DLL_EXPORT void dsp_stream_align (dsp_stream_p in)
 Perform scale, translate and rotate transformations in-place. More...
 
DLL_EXPORT void dsp_signals_whitenoise (dsp_stream_p stream)
 Generate white noise. More...
 
DLL_EXPORT void dsp_signals_sinewave (dsp_stream_p stream, double samplefreq, double freq)
 Generate a sinusoidal wave. More...
 
DLL_EXPORT void dsp_signals_sawtoothwave (dsp_stream_p stream, double samplefreq, double freq)
 Generate a sawtooth wave. More...
 
DLL_EXPORT void dsp_signals_triwave (dsp_stream_p stream, double samplefreq, double freq)
 Generate a triangular wave. More...
 
DLL_EXPORT void dsp_modulation_frequency (dsp_stream_p stream, double samplefreq, double freq, double bandwidth)
 Generate a frequency modulated wave. More...
 
DLL_EXPORT void dsp_modulation_amplitude (dsp_stream_p stream, double samplefreq, double freq)
 Generate an amplitude modulated wave. More...
 
DLL_EXPORT dsp_stream_pdsp_file_read_fits (const char *filename, int *channels, int stretch)
 Read a FITS file and fill a dsp_stream_p with its content. More...
 
DLL_EXPORT void dsp_file_write_fits (const char *filename, int bpp, dsp_stream_p stream)
 Write the dsp_stream_p into a FITS file,. More...
 
DLL_EXPORT void dsp_file_write_fits_composite (const char *filename, int components, int bpp, dsp_stream_p *stream)
 Write the components dsp_stream_p array into a JPEG file,. More...
 
DLL_EXPORT dsp_stream_pdsp_file_read_jpeg (const char *filename, int *channels, int stretch)
 Read a JPEG file and fill a array of dsp_stream_p with its content, each color channel has its own stream in this array and an additional grayscale at end will be added. More...
 
DLL_EXPORT void dsp_file_write_jpeg (const char *filename, int quality, dsp_stream_p stream)
 Write the stream into a JPEG file,. More...
 
DLL_EXPORT void dsp_file_write_jpeg_composite (const char *filename, int components, int quality, dsp_stream_p *stream)
 Write the components dsp_stream_p array into a JPEG file,. More...
 
DLL_EXPORT dsp_tdsp_file_bayer_2_gray (dsp_t *src, int width, int height)
 Convert a bayer pattern dsp_t array into a grayscale array. More...
 
DLL_EXPORT dsp_tdsp_file_bayer_2_rgb (dsp_t *src, int red, int width, int height)
 Convert a bayer pattern dsp_t array into a ordered 3 RGB array. More...
 
DLL_EXPORT dsp_stream_pdsp_stream_from_components (dsp_t *buf, int dims, int *sizes, int components)
 Convert a color component dsp_t array into a dsp_stream_p array each element containing the single components. More...
 
DLL_EXPORT dsp_stream_pdsp_buffer_rgb_to_components (void *buf, int dims, int *sizes, int components, int bpp, int stretch)
 Convert an RGB color dsp_t array into a dsp_stream_p array each element containing the single components. More...
 
DLL_EXPORT void dsp_buffer_components_to_rgb (dsp_stream_p *stream, void *rgb, int components, int bpp)
 Convert a component dsp_stream_p array into an RGB dsp_t array. More...
 
DLL_EXPORT dsp_tdsp_file_composite_2_bayer (dsp_stream_p *src, int red, int width, int height)
 Convert a component dsp_stream_p array into a bayer dsp_t array. More...
 
DLL_EXPORT void dsp_file_write_fits_bayer (const char *filename, int components, int bpp, dsp_stream_p *stream)
 Write a FITS file from a dsp_stream_p array. More...
 
DLL_EXPORT dsp_tdsp_file_bayer_2_composite (dsp_t *src, int red, int width, int height)
 Convert a bayer pattern dsp_t array into a contiguos component array. More...
 
DLL_EXPORT dsp_align_info dsp_align_fill_info (dsp_triangle t1, dsp_triangle t2)
 Fill a dsp_align_info struct by comparing two triangles. More...
 
DLL_EXPORT dsp_triangle dsp_align_calc_triangle (dsp_star *stars)
 Create a dsp_triangle struct. More...
 
DLL_EXPORT int dsp_align_get_offset (dsp_stream_p ref, dsp_stream_p to_align, double tolerance, double target_score)
 Calculate offsets, rotation and scaling of two streams giving reference alignment point. More...
 
DLL_EXPORT int dsp_qsort_double_asc (const void *arg1, const void *arg2)
 Callback function for qsort for double type ascending ordering. More...
 
DLL_EXPORT int dsp_qsort_double_desc (const void *arg1, const void *arg2)
 Callback function for qsort for double type descending ordering. More...
 
DLL_EXPORT int dsp_qsort_star_diameter_asc (const void *arg1, const void *arg2)
 Callback function for qsort for dsp_star ascending ordering by their diameters. More...
 
DLL_EXPORT int dsp_qsort_star_diameter_desc (const void *arg1, const void *arg2)
 Callback function for qsort for dsp_star descending ordering by their diameters. More...
 

Macro Definition Documentation

◆ __bswap_16

#define __bswap_16 (   a)    __builtin_bswap16(a)

Definition at line 33 of file dsp.h.

◆ __bswap_32

#define __bswap_32 (   a)    __builtin_bswap32(a)

Definition at line 34 of file dsp.h.

◆ __bswap_64

#define __bswap_64 (   a)    __builtin_bswap64(a)

Definition at line 35 of file dsp.h.

◆ DLL_EXPORT

#define DLL_EXPORT   extern

Definition at line 27 of file dsp.h.