Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
80f8b33
extract first frame from rawspeed
maruncz Apr 1, 2022
6ced718
load all images - not working
maruncz Apr 3, 2022
6fbdbb7
corrected handling of number of frames
maruncz Apr 5, 2022
97e0afc
added pipe debug output
maruncz Apr 6, 2022
18f2458
modified rawprepare to handle multiple frames
maruncz Apr 6, 2022
d66fd5c
attempt to disable rawprepase opencl version
maruncz Apr 6, 2022
b2925b5
hide debug function
maruncz Apr 6, 2022
3903443
revert unintended change
maruncz Apr 7, 2022
a2435e1
rawprepare probably fixed
maruncz Apr 8, 2022
a52d866
some work in demosaic
maruncz Apr 14, 2022
ee1c14b
some demosaic experiments
maruncz Apr 19, 2022
ed12c60
this should behave like monochrome passthru but doesn't
maruncz Apr 19, 2022
302ac0c
there is some systematic error, htat i cannot see
maruncz Apr 20, 2022
4ef692e
looks ok, but still issues with frame offset
maruncz Apr 20, 2022
27a81cb
looks like issue with frame offset input to rawprepare
maruncz Apr 20, 2022
24c6ac7
looks like issue fixed
maruncz Apr 21, 2022
d56a042
first non working pixelshift debayer candidate
maruncz Apr 21, 2022
a4829d9
cleanup
maruncz Apr 21, 2022
8436228
probably working algorithm, pixelshift checkbox unreliable, doesn't w…
maruncz Apr 21, 2022
a4a9d78
bumped version of demosaic
maruncz Apr 22, 2022
31f0591
wb supports multiframe
maruncz Apr 22, 2022
ebb32ea
cleanup
maruncz Apr 23, 2022
55563d4
checkbox now correctly respond, but demosaic is not reprocesing
maruncz Apr 23, 2022
ece9ac3
demosaic gui is now correctly showing and hiding controls
maruncz Apr 23, 2022
97dbf52
added tooltip for pixelshift
maruncz Apr 23, 2022
0ef76d3
corrected problem with margins
maruncz Apr 24, 2022
2d5402a
revert temporary workaround
maruncz Apr 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 273 additions & 126 deletions src/common/imageio_rawspeed.cc

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/common/mipmap_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void *dt_mipmap_cache_alloc(dt_mipmap_buffer_t *buf, const dt_image_t *img)
const int ht = img->height;

const size_t bpp = dt_iop_buffer_dsc_to_bpp(&img->buf_dsc);
const size_t buffer_size = (size_t)wd * ht * bpp + sizeof(*dsc);
const size_t buffer_size = (size_t)wd * ht * bpp * img->buf_dsc.frames + sizeof(*dsc);

// buf might have been alloc'ed before,
// so only check size and re-alloc if necessary:
Expand Down Expand Up @@ -337,7 +337,7 @@ void dt_mipmap_cache_allocate_dynamic(void *data, dt_cache_entry_t *entry)

entry->data = dt_alloc_align(64, entry->data_size);

// fprintf(stderr, "[mipmap cache] alloc dynamic for key %u %p\n", key, *buf);
fprintf(stderr, "[mipmap cache] alloc dynamic for key %u %p %lu\n", entry->key, entry->data, entry->data_size);
if(!(entry->data))
{
fprintf(stderr, "[mipmap cache] memory allocation failed!\n");
Expand Down Expand Up @@ -1285,10 +1285,11 @@ static void _init_8(uint8_t *buf, uint32_t *width, uint32_t *height, float *isca
*iscale = 1.0f;
*color_space = dt_mipmap_cache_get_colorspace();
}
fprintf(stderr, "[mipmap init 8] export image %u finished (sizes %d %d => %d %d)!\n", imgid, wd, ht,
dat.head.width, dat.head.height);
}

// fprintf(stderr, "[mipmap init 8] export image %u finished (sizes %d %d => %d %d)!\n", imgid, wd, ht,
// dat.head.width, dat.head.height);


// any errors?
if(res)
Expand Down
1 change: 1 addition & 0 deletions src/develop/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void default_input_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_de
void default_output_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece,
dt_iop_buffer_dsc_t *dsc)
{
dsc->frames = 1;
dsc->channels = 4;
dsc->datatype = TYPE_FLOAT;
dsc->cst = self->output_colorspace(self, pipe, piece);
Expand Down
2 changes: 2 additions & 0 deletions src/develop/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ typedef struct dt_iop_buffer_dsc_t
{
/** how many channels the data has? 1 or 4 */
unsigned int channels;
/** how many frames in multiframe images */
unsigned frames;
/** what is the datatype? */
dt_iop_buffer_type_t datatype;
/** Bayer demosaic pattern */
Expand Down
172 changes: 166 additions & 6 deletions src/develop/pixelpipe_hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <errno.h>

#define DEBUG_PIXELPIPE

typedef enum dt_pixelpipe_flow_t
{
Expand Down Expand Up @@ -106,6 +109,141 @@ static char *_pipe_type_to_str(int pipe_type)
return r;
}

#ifdef DEBUG_PIXELPIPE
static void save_debug_bitmap(dt_dev_pixelpipe_t *pipe, const char *name, void *out, const dt_iop_roi_t *roi_out)
{
if(pipe->type != DT_DEV_PIXELPIPE_FULL)
{
return;
}

int single_channel = pipe->dsc.channels == 1;
int floating = pipe->dsc.datatype == TYPE_FLOAT;


char ext[8];
if(floating)
{
snprintf(ext,8,"pfm");
}
else
{
if(single_channel)
{
snprintf(ext,8,"pgm");
}
else
{
snprintf(ext,8,"ppm");
}
}

char filename[128];
snprintf(filename, 128, "save_debug_bitmap_%s_%s.%s", name, _pipe_type_to_str(pipe->type), ext);
for(int i = 0; i < 128; ++i)
{
if(filename[i] == '\0')
{
break;
}
if((filename[i] == ' ') || (filename[i] == '/'))
{
filename[i] = '_';
}
}

FILE *file = g_fopen(filename, "w");
if(file == NULL)
{
fprintf(stderr, "error opening debug file: %s, %s\n", filename, strerror(errno));
return;
}
if(floating)
{
if(!single_channel)
{
fprintf(file, "PF\n");
}
else
{
fprintf(file, "Pf\n");
}
}
else
{
if(single_channel)
{
fprintf(file, "P2\n");
}
else
{
fprintf(file, "P3\n");
}
}
fprintf(file, "%i %i\n", roi_out->width, roi_out->height * pipe->dsc.frames);
if(floating)
{
fprintf(file, "-1.0\n");
}
else
{
fprintf(file,"%i\n", 16384);
}
if(floating)
{
float *ptr = (float *)out;
if((pipe->dsc.channels == 1) || (pipe->dsc.channels == 3))
{
for(size_t f = 0; f < pipe->dsc.frames; ++f)
{
float *tmp = ptr + (f * roi_out->width * roi_out->height);
for(size_t i = 0; i < roi_out->width; ++i)
{
for(size_t j = 0; j < roi_out->height; ++j)
{
const size_t pout = j + (roi_out->height * (i));
fwrite(tmp + pout, sizeof(float) * pipe->dsc.channels, 1, file);
}
}
}
}
else
{
for(size_t i = 0; i < roi_out->height * roi_out->width * pipe->dsc.frames * pipe->dsc.channels;
i += pipe->dsc.channels)
{
for(size_t j = 0; j < 3; ++j)
{
fwrite(ptr + i + j, sizeof(float), 1, file);
}
}
}
}
else
{
if(single_channel)
{
uint16_t *ptr = (uint16_t *)out;
for(size_t f = 0; f < pipe->dsc.frames; ++f)
{
uint16_t *tmp = ptr + (f * roi_out->width * roi_out->height);
for(size_t i = 0; i < roi_out->width; ++i)
{
for(size_t j = 0; j < roi_out->height; ++j)
{
const size_t pout = j + (roi_out->height * (i));
fprintf(file,"%hu ",tmp[pout]);
//fwrite(tmp + pout, sizeof(uint16_t), 1, file);
}
fprintf(file,"\n");
}
}
}
}
fclose(file);
}
#endif

int dt_dev_pixelpipe_init_export(dt_dev_pixelpipe_t *pipe, int32_t width, int32_t height, int levels,
gboolean store_masks)
{
Expand Down Expand Up @@ -1097,7 +1235,7 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
if(module) g_strlcpy(module_name, module->op, MIN(sizeof(module_name), sizeof(module->op)));
get_output_format(module, pipe, piece, dev, *out_format);
const size_t bpp = dt_iop_buffer_dsc_to_bpp(*out_format);
const size_t bufsize = (size_t)bpp * roi_out->width * roi_out->height;
const size_t bufsize = (size_t)bpp * roi_out->width * roi_out->height * pipe->image.buf_dsc.frames;

// 1) if cached buffer is still available, return data
if(dt_atomic_get_int(&pipe->shutdown))
Expand Down Expand Up @@ -1171,19 +1309,31 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
const int in_y = MAX(roi_in.y, 0);
const int cp_width = MAX(0, MIN(roi_out->width, pipe->iwidth - in_x));
const int cp_height = MIN(roi_out->height, pipe->iheight - in_y);
const int frames = pipe->dsc.frames;

//fprintf(stderr, "[pipe] %s, input: %p\n", _pipe_type_to_str(pipe->type), pipe->input);
//fprintf(stderr, "[pipe] %s, output: %p\n", _pipe_type_to_str(pipe->type), *output);

if (cp_width > 0)
{
#ifdef _OPENMP
#pragma omp parallel for default(none) \
dt_omp_firstprivate(bpp, cp_height, cp_width, in_x, in_y) \
dt_omp_firstprivate(bpp, cp_height, cp_width, in_x, in_y, frames) \
shared(pipe, roi_out, roi_in, output) \
schedule(static)
#endif
for(int j = 0; j < cp_height; j++)
memcpy(((char *)*output) + (size_t)bpp * j * roi_out->width,
((char *)pipe->input) + (size_t)bpp * (in_x + (in_y + j) * pipe->iwidth),
(size_t)bpp * cp_width);
for(int f = 0; f < frames; ++f)
{
char *ptr = ((char *)pipe->input) + (f * bpp * pipe->iheight * pipe->iwidth);
char *outptr = ((char *)*output) + (f * bpp * roi_out->height * roi_out->width);
for(int j = 0; j < cp_height; j++)
memcpy(outptr + (size_t)bpp * j * roi_out->width,
ptr + (size_t)bpp * (in_x + (in_y + j) * pipe->iwidth), (size_t)bpp * cp_width);
}

#ifdef DEBUG_PIXELPIPE
//save_debug_bitmap(pipe,"load",*output,roi_out);
#endif
}
}
else
Expand Down Expand Up @@ -1230,6 +1380,8 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
g_list_previous(modules), g_list_previous(pieces), pos - 1))
return 1;

//fprintf(stderr,"[pipe] %s, module: %s, input: %p\n",_pipe_type_to_str(pipe->type), module->op ,input);

const size_t in_bpp = dt_iop_buffer_dsc_to_bpp(input_format);

piece->dsc_out = piece->dsc_in = *input_format;
Expand Down Expand Up @@ -1259,6 +1411,8 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
// if(module) printf("reserving new buf in cache for module %s %s: %ld buf %p\n", module->op, pipe ==
// dev->preview_pipe ? "[preview]" : "", hash, *output);

//fprintf(stderr,"[pipe] %s, module: %s, output: %p\n",_pipe_type_to_str(pipe->type), module->op ,*output);

if(dt_atomic_get_int(&pipe->shutdown))
{
return 1;
Expand Down Expand Up @@ -1910,6 +2064,7 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
return 1;
}
#else // HAVE_OPENCL

if (pixelpipe_process_on_CPU(pipe, dev, input, input_format, &roi_in, output, out_format, roi_out,
module, piece, &tiling, &pixelpipe_flow))
return 1;
Expand Down Expand Up @@ -2031,6 +2186,11 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
}
}

#ifdef DEBUG_PIXELPIPE
save_debug_bitmap(pipe,dt_history_item_get_name(module),*output,roi_out);
#endif


// 4) colorpicker and scopes:
if(dt_atomic_get_int(&pipe->shutdown))
{
Expand Down
2 changes: 1 addition & 1 deletion src/external/rawspeed
Submodule rawspeed updated 152 files
Loading