iio.c
// PCM reader                                                               {{{2
// PCM is a file format to store complex float images
// it is used by some people also for optical flow fields
PCM reader                                                               {{{2
PCM is a file format to store complex float images
it is used by some people also for optical flow fields
PCM reader {{{ 2 PCM is a file format to store complex float images it is used by some people also for optical flow fields
static int read_beheaded_pcm(struct iio_image *x,
		FILE *f, char *header, int nheader)
{
	(void)header;
	assert(nheader == 2);
	int w, h;
	float scale;
	if (1 != fscanf(f, " %d", &w)) return -1;
	if (1 != fscanf(f, " %d", &h)) return -2;
	if (1 != fscanf(f, " %g", &scale)) return -3;
	if (!isspace(pick_char_for_sure(f))) return -6;
	fprintf(stderr, "%d PCM w h scale = %d %d %g\n", nheader, w, h, scale);
	assert(sizeof(float) == 4);
	float *data = xmalloc(w * h * 2 * sizeof(float));
	int r = fread(data, sizeof(float), w * h * 2, f);
	if (r != w * h * 2) return (xfree(data),-7);
	x->dimension = 2;
	x->sizes[0] = w;
	x->sizes[1] = h;
	x->pixel_dimension = 2;
	x->type = IIO_TYPE_FLOAT;
	x->contiguous_data = false;
	x->data = data;
	return 0;
}
static int read_beheaded_pcm ( struct iio_image * x , FILE * f , char * header , int nheader ) { ( void ) header ; assert ( nheader == 2 ) ; int w , h ; float scale ; if ( 1 != fscanf ( f , " " , & w ) ) return -1 ; if ( 1 != fscanf ( f , " " , & h ) ) return -2 ; if ( 1 != fscanf ( f , " " , & scale ) ) return -3 ; if ( ! isspace ( pick_char_for_sure ( f ) ) ) return -6 ; fprintf ( stderr , " \n " , nheader , w , h , scale ) ; assert ( sizeof ( float ) == 4 ) ; float * data = xmalloc ( w * h * 2 * sizeof ( float ) ) ; int r = fread ( data , sizeof ( float ) , w * h * 2 , f ) ; if ( r != w * h * 2 ) return ( xfree ( data ) , -7 ) ; x -> dimension = 2 ; x -> sizes [ 0 ] = w ; x -> sizes [ 1 ] = h ; x -> pixel_dimension = 2 ; x -> type = IIO_TYPE_FLOAT ; x -> contiguous_data = false ; x -> data = data ; return 0 ; }
PCM reader                                                               {{{2
PCM is a file format to store complex float images
it is used by some people also for optical flow fields
PCM reader {{{ 2 PCM is a file format to store complex float images it is used by some people also for optical flow fields