diff options
author | Thomas White <taw@physics.org> | 2021-04-29 14:44:24 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-04-29 14:44:57 +0200 |
commit | f269d912c0a8c382f48cc821f69a1ee72e973c83 (patch) | |
tree | 69d474373302b6455de92cf32cac6f2aa0909370 /libcrystfel | |
parent | 97b686a0e75f9ac5f96b573e1e93819a4b41501f (diff) |
MsgPack: Handle floating-point data, fix array read
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/image-msgpack.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libcrystfel/src/image-msgpack.c b/libcrystfel/src/image-msgpack.c index d1249345..e1c9bb66 100644 --- a/libcrystfel/src/image-msgpack.c +++ b/libcrystfel/src/image-msgpack.c @@ -392,6 +392,7 @@ static int load_msgpack_data(struct panel_template *p, int fs, ss; float *fdata; + int32_t *in_data = (int32_t *)data_obj->via.bin.ptr; fdata = malloc(PANEL_WIDTH(p) * PANEL_HEIGHT(p) * sizeof(float)); if ( fdata == NULL ) return 1; @@ -399,7 +400,25 @@ static int load_msgpack_data(struct panel_template *p, for ( ss=0; ss<PANEL_HEIGHT(p); ss++ ) { for ( fs=0; fs<PANEL_WIDTH(p); fs++ ) { size_t idx = fs+p->orig_min_fs + (ss+p->orig_min_ss)*data_size_fs; - fdata[fs+ss*PANEL_WIDTH(p)] = data_obj->via.bin.ptr[idx]; + fdata[fs+ss*PANEL_WIDTH(p)] = in_data[idx]; + } + } + + data = fdata; + + } else if ( strcmp(dtype, "<f4") == 0 ) { + + int fs, ss; + float *fdata; + float *in_data = (float *)data_obj->via.bin.ptr; + + fdata = malloc(PANEL_WIDTH(p) * PANEL_HEIGHT(p) * sizeof(float)); + if ( fdata == NULL ) return 1; + + for ( ss=0; ss<PANEL_HEIGHT(p); ss++ ) { + for ( fs=0; fs<PANEL_WIDTH(p); fs++ ) { + size_t idx = fs+p->orig_min_fs + (ss+p->orig_min_ss)*data_size_fs; + fdata[fs+ss*PANEL_WIDTH(p)] = in_data[idx]; } } |