mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 07:47:12 +02:00
format
This commit is contained in:
@ -106,10 +106,9 @@ static PyObject *decode(PyObject *Py_UNUSED(self), PyObject *args,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (n_threads == 1){
|
||||
if (n_threads == 1) {
|
||||
pm_decode(src, dst, pm, n_frames, n_rows * n_cols);
|
||||
}else{
|
||||
} else {
|
||||
// Multithreaded processing
|
||||
pthread_t *threads = malloc(sizeof(pthread_t *) * n_threads);
|
||||
thread_args *arguments = malloc(sizeof(thread_args) * n_threads);
|
||||
@ -120,7 +119,8 @@ static PyObject *decode(PyObject *Py_UNUSED(self), PyObject *args,
|
||||
arguments[i].src = src + (i * frames_per_thread * pm_size);
|
||||
arguments[i].dst = dst + (i * frames_per_thread * pm_size);
|
||||
arguments[i].pm = pm;
|
||||
arguments[i].n_frames = frames_per_thread; // TODO! not matching frames.
|
||||
arguments[i].n_frames =
|
||||
frames_per_thread; // TODO! not matching frames.
|
||||
arguments[i].n_pixels = n_rows * n_cols;
|
||||
assigned_frames += frames_per_thread;
|
||||
}
|
||||
@ -128,7 +128,7 @@ static PyObject *decode(PyObject *Py_UNUSED(self), PyObject *args,
|
||||
|
||||
for (size_t i = 0; i < n_threads; i++) {
|
||||
pthread_create(&threads[i], NULL, (void *)thread_pmdecode,
|
||||
&arguments[i]);
|
||||
&arguments[i]);
|
||||
}
|
||||
for (size_t i = 0; i < n_threads; i++) {
|
||||
pthread_join(threads[i], NULL);
|
||||
@ -136,8 +136,6 @@ static PyObject *decode(PyObject *Py_UNUSED(self), PyObject *args,
|
||||
free(threads);
|
||||
free(arguments);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Py_DECREF(raw_data);
|
||||
Py_DECREF(pixel_map);
|
||||
|
@ -1,17 +1,18 @@
|
||||
#include "pm_decode.h"
|
||||
#include "thread_utils.h"
|
||||
|
||||
void thread_pmdecode(void* args){
|
||||
thread_args* a;
|
||||
a = (thread_args *) args;
|
||||
void thread_pmdecode(void *args) {
|
||||
thread_args *a;
|
||||
a = (thread_args *)args;
|
||||
pm_decode(a->src, a->dst, a->pm, a->n_frames, a->n_pixels);
|
||||
}
|
||||
|
||||
void pm_decode(uint16_t* src, uint16_t* dst, uint32_t* pm, size_t n_frames, size_t n_pixels){
|
||||
for(size_t i = 0; i<n_frames; i++){
|
||||
for(size_t j=0; j<n_pixels; j++){
|
||||
void pm_decode(uint16_t *src, uint16_t *dst, uint32_t *pm, size_t n_frames,
|
||||
size_t n_pixels) {
|
||||
for (size_t i = 0; i < n_frames; i++) {
|
||||
for (size_t j = 0; j < n_pixels; j++) {
|
||||
*dst++ = src[pm[j]];
|
||||
}
|
||||
src += n_pixels;
|
||||
}
|
||||
src += n_pixels;
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
//Wrapper to be used with pthreads
|
||||
void thread_pmdecode(void* args);
|
||||
#include <stdint.h>
|
||||
// Wrapper to be used with pthreads
|
||||
void thread_pmdecode(void *args);
|
||||
|
||||
|
||||
void pm_decode(uint16_t* src, uint16_t* dst, uint32_t* pm, size_t n_frames, size_t n_pixels);
|
||||
void pm_decode(uint16_t *src, uint16_t *dst, uint32_t *pm, size_t n_frames,
|
||||
size_t n_pixels);
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
typedef struct{
|
||||
uint16_t* src;
|
||||
uint16_t* dst;
|
||||
uint32_t* pm;
|
||||
#include <stdint.h>
|
||||
typedef struct {
|
||||
uint16_t *src;
|
||||
uint16_t *dst;
|
||||
uint32_t *pm;
|
||||
size_t n_frames;
|
||||
size_t n_pixels;
|
||||
}thread_args;
|
||||
} thread_args;
|
Reference in New Issue
Block a user