Skip to content

Commit 9d83edd

Browse files
committed
looks like issue fixed
copy between imageio and pixelpipe was wrong
1 parent e8c873d commit 9d83edd

File tree

5 files changed

+127
-36
lines changed

5 files changed

+127
-36
lines changed

src/common/imageio_rawspeed.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,19 @@ dt_imageio_retval_t dt_imageio_open_rawspeed(dt_image_t *img, const char *filena
512512
*/
513513
if(isMultiFrame)
514514
{
515+
/*for(size_t f = 0; f < r.size(); ++f)
516+
{
517+
char *ptr = (char *)r.get(f)->getDataUncropped(0, 0);
518+
int value = (((float)f+1) / ((float)(r.size()+2))) * img->raw_white_point;
519+
for(int j = 0; j < dimUncropped.y; ++j)
520+
{
521+
uint16_t * start = (uint16_t*)(ptr + (j * r.get(f)->pitch));
522+
for(int i=0;i<dimUncropped.x;++i)
523+
{
524+
start[i] = value;
525+
}
526+
}
527+
}*/
515528
const size_t bufSize_mipmap = (size_t)img->width * img->height * img->buf_dsc.frames * r.get(0)->getBpp();
516529
const size_t bufSize_rawspeed = (size_t)r.get(0)->pitch * dimUncropped.y * r.size();
517530
const size_t frame_size = bufSize_mipmap / r.size();

src/develop/pixelpipe_hb.c

Lines changed: 103 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,29 @@ static void save_debug_bitmap(dt_dev_pixelpipe_t *pipe, const char *name, void *
117117
return;
118118
}
119119

120+
int single_channel = pipe->dsc.channels == 1;
121+
int floating = pipe->dsc.datatype == TYPE_FLOAT;
122+
123+
124+
char ext[8];
125+
if(floating)
126+
{
127+
snprintf(ext,8,"pfm");
128+
}
129+
else
130+
{
131+
if(single_channel)
132+
{
133+
snprintf(ext,8,"pgm");
134+
}
135+
else
136+
{
137+
snprintf(ext,8,"ppm");
138+
}
139+
}
140+
120141
char filename[128];
121-
snprintf(filename, 128, "save_debug_bitmap_%s_%s.pfm", name, _pipe_type_to_str(pipe->type));
142+
snprintf(filename, 128, "save_debug_bitmap_%s_%s.%s", name, _pipe_type_to_str(pipe->type), ext);
122143
for(int i = 0; i < 128; ++i)
123144
{
124145
if(filename[i] == '\0')
@@ -137,40 +158,85 @@ static void save_debug_bitmap(dt_dev_pixelpipe_t *pipe, const char *name, void *
137158
fprintf(stderr, "error opening debug file: %s, %s\n", filename, strerror(errno));
138159
return;
139160
}
140-
if(pipe->dsc.channels > 1)
161+
if(floating)
141162
{
142-
fprintf(file, "PF\n");
163+
if(!single_channel)
164+
{
165+
fprintf(file, "PF\n");
166+
}
167+
else
168+
{
169+
fprintf(file, "Pf\n");
170+
}
143171
}
144172
else
145173
{
146-
fprintf(file, "Pf\n");
174+
if(single_channel)
175+
{
176+
fprintf(file, "P2\n");
177+
}
178+
else
179+
{
180+
fprintf(file, "P3\n");
181+
}
147182
}
148183
fprintf(file, "%i %i\n", roi_out->width, roi_out->height * pipe->dsc.frames);
149-
fprintf(file, "-1.0\n");
150-
float *ptr = (float *)out;
151-
if((pipe->dsc.channels == 1) || (pipe->dsc.channels == 3))
184+
if(floating)
185+
{
186+
fprintf(file, "-1.0\n");
187+
}
188+
else
189+
{
190+
fprintf(file,"%i\n", 16384);
191+
}
192+
if(floating)
152193
{
153-
for(size_t f = 0; f < pipe->dsc.frames; ++f)
194+
float *ptr = (float *)out;
195+
if((pipe->dsc.channels == 1) || (pipe->dsc.channels == 3))
154196
{
155-
float *tmp = ptr + (f * roi_out->width * roi_out->height);
156-
for(size_t i = 0; i < roi_out->width; ++i)
197+
for(size_t f = 0; f < pipe->dsc.frames; ++f)
157198
{
158-
for(size_t j = 0; j < roi_out->height; ++j)
199+
float *tmp = ptr + (f * roi_out->width * roi_out->height);
200+
for(size_t i = 0; i < roi_out->width; ++i)
159201
{
160-
const size_t pout = j + (roi_out->height * (i));
161-
fwrite(tmp + pout, sizeof(float) * pipe->dsc.channels, 1, file);
202+
for(size_t j = 0; j < roi_out->height; ++j)
203+
{
204+
const size_t pout = j + (roi_out->height * (i));
205+
fwrite(tmp + pout, sizeof(float) * pipe->dsc.channels, 1, file);
206+
}
207+
}
208+
}
209+
}
210+
else
211+
{
212+
for(size_t i = 0; i < roi_out->height * roi_out->width * pipe->dsc.frames * pipe->dsc.channels;
213+
i += pipe->dsc.channels)
214+
{
215+
for(size_t j = 0; j < 3; ++j)
216+
{
217+
fwrite(ptr + i + j, sizeof(float), 1, file);
162218
}
163219
}
164220
}
165221
}
166222
else
167223
{
168-
for(size_t i = 0; i < roi_out->height * roi_out->width * pipe->dsc.frames * pipe->dsc.channels;
169-
i += pipe->dsc.channels)
224+
if(single_channel)
170225
{
171-
for(size_t j = 0; j < 3; ++j)
226+
uint16_t *ptr = (uint16_t *)out;
227+
for(size_t f = 0; f < pipe->dsc.frames; ++f)
172228
{
173-
fwrite(ptr + i + j, sizeof(float), 1, file);
229+
uint16_t *tmp = ptr + (f * roi_out->width * roi_out->height);
230+
for(size_t i = 0; i < roi_out->width; ++i)
231+
{
232+
for(size_t j = 0; j < roi_out->height; ++j)
233+
{
234+
const size_t pout = j + (roi_out->height * (i));
235+
fprintf(file,"%hu ",tmp[pout]);
236+
//fwrite(tmp + pout, sizeof(uint16_t), 1, file);
237+
}
238+
fprintf(file,"\n");
239+
}
174240
}
175241
}
176242
}
@@ -1245,6 +1311,9 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
12451311
const int cp_height = MIN(roi_out->height, pipe->iheight - in_y);
12461312
const int frames = pipe->dsc.frames;
12471313

1314+
//fprintf(stderr, "[pipe] %s, input: %p\n", _pipe_type_to_str(pipe->type), pipe->input);
1315+
//fprintf(stderr, "[pipe] %s, output: %p\n", _pipe_type_to_str(pipe->type), *output);
1316+
12481317
if (cp_width > 0)
12491318
{
12501319
#ifdef _OPENMP
@@ -1253,10 +1322,18 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
12531322
shared(pipe, roi_out, roi_in, output) \
12541323
schedule(static)
12551324
#endif
1256-
for(int j = 0; j < cp_height * frames; j++)
1257-
memcpy(((char *)*output) + (size_t)bpp * j * roi_out->width,
1258-
((char *)pipe->input) + (size_t)bpp * (in_x + (in_y + j) * pipe->iwidth),
1259-
(size_t)bpp * cp_width);
1325+
for(int f = 0; f < frames; ++f)
1326+
{
1327+
char *ptr = ((char *)pipe->input) + (f * bpp * pipe->iheight * pipe->iwidth);
1328+
char *outptr = ((char *)*output) + (f * bpp * roi_out->height * roi_out->width);
1329+
for(int j = 0; j < cp_height; j++)
1330+
memcpy(outptr + (size_t)bpp * j * roi_out->width,
1331+
ptr + (size_t)bpp * (in_x + (in_y + j) * pipe->iwidth), (size_t)bpp * cp_width);
1332+
}
1333+
1334+
#ifdef DEBUG_PIXELPIPE
1335+
save_debug_bitmap(pipe,"load",*output,roi_out);
1336+
#endif
12601337
}
12611338
}
12621339
else
@@ -1303,6 +1380,8 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
13031380
g_list_previous(modules), g_list_previous(pieces), pos - 1))
13041381
return 1;
13051382

1383+
//fprintf(stderr,"[pipe] %s, module: %s, input: %p\n",_pipe_type_to_str(pipe->type), module->op ,input);
1384+
13061385
const size_t in_bpp = dt_iop_buffer_dsc_to_bpp(input_format);
13071386

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

1414+
//fprintf(stderr,"[pipe] %s, module: %s, output: %p\n",_pipe_type_to_str(pipe->type), module->op ,*output);
1415+
13351416
if(dt_atomic_get_int(&pipe->shutdown))
13361417
{
13371418
return 1;
@@ -1982,6 +2063,7 @@ static int dt_dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe, dt_develop_t *
19822063
return 1;
19832064
}
19842065
#else // HAVE_OPENCL
2066+
19852067
if (pixelpipe_process_on_CPU(pipe, dev, input, input_format, &roi_in, output, out_format, roi_out,
19862068
module, piece, &tiling, &pixelpipe_flow))
19872069
return 1;

src/iop/demosaic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2995,7 +2995,7 @@ void process_pixelshift(dt_dev_pixelpipe_iop_t *piece, const float *const in, fl
29952995
}
29962996
}
29972997
}
2998-
fprintf(stderr,"pout: %lu\n", pout+4);
2998+
//fprintf(stderr,"pout: %lu\n", pout+4);
29992999
}
30003000

30013001

src/iop/rawprepare.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static void convert_uint_float(const uint16_t *const in, float *const out, const
275275
dt_omp_firstprivate(csx, csy, d, in, out, roi_in, roi_out) \
276276
schedule(static) collapse(2)
277277
#endif
278-
for(int j = 0; j < roi_out->height-100; j++)
278+
for(int j = 0; j < roi_out->height; j++)
279279
{
280280
for(int i = 0; i < roi_out->width; i++)
281281
{
@@ -287,7 +287,7 @@ static void convert_uint_float(const uint16_t *const in, float *const out, const
287287
}
288288
}
289289

290-
for(int j = roi_out->height-100; j < roi_out->height; j++)
290+
/*for(int j = roi_out->height-100; j < roi_out->height; j++)
291291
{
292292
for(int i = 0; i < roi_out->width; i++)
293293
{
@@ -297,7 +297,7 @@ static void convert_uint_float(const uint16_t *const in, float *const out, const
297297
298298
out[pout] = 0.0f;
299299
}
300-
}
300+
}*/
301301
}
302302

303303
static void convert_float_float(const float *const in, float *const out, const dt_iop_roi_t *const roi_in,
@@ -355,13 +355,13 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const
355355
{
356356
const dt_iop_rawprepare_data_t *const d = (dt_iop_rawprepare_data_t *)piece->data;
357357

358-
fprintf(stderr,"rawprepare %s\n", dt_pixelpipe_name(piece->pipe->type));
359-
fprintf(stderr, "roi in %d %d %d %d\n", roi_in->x, roi_in->y, roi_in->width, roi_in->height);
360-
fprintf(stderr, "roi out %d %d %d %d\n", roi_out->x, roi_out->y, roi_out->width, roi_out->height);
358+
//fprintf(stderr,"rawprepare %s\n", dt_pixelpipe_name(piece->pipe->type));
359+
//fprintf(stderr, "roi in %d %d %d %d\n", roi_in->x, roi_in->y, roi_in->width, roi_in->height);
360+
//fprintf(stderr, "roi out %d %d %d %d\n", roi_out->x, roi_out->y, roi_out->width, roi_out->height);
361361
/*fprintf(stderr,"frame size in: %d\n", roi_in->width * roi_in->height);
362362
fprintf(stderr,"frame size iout: %d\n", roi_out->width * roi_out->height);*/
363-
fprintf(stderr,"i: %p\n",ivoid);
364-
fprintf(stderr,"o: %p\n",ovoid);
363+
//fprintf(stderr,"i: %p\n",ivoid);
364+
//fprintf(stderr,"o: %p\n",ovoid);
365365

366366
const int csx = compute_proper_crop(piece, roi_in, d->x);
367367
const int csy = compute_proper_crop(piece, roi_in, d->y);
@@ -378,11 +378,7 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const
378378
const uint16_t *const frame_in = in + (f * roi_in->width * roi_in->height);
379379
float *const frame_out = out + (f * roi_out->width * roi_out->height);
380380
convert_uint_float(frame_in, frame_out, roi_in, roi_out, csx, csy, d);
381-
fprintf(stderr, "frame %lu: %p\n", f, frame_in);
382-
/*for(size_t i=0;i<roi_out->width * roi_out->height;++i)
383-
{
384-
frame_out[i] = (float)f / (float)piece->dsc_out.frames;
385-
}*/
381+
//fprintf(stderr, "frame %lu: %p\n", f, frame_in);
386382
}
387383

388384
piece->pipe->dsc.filters = dt_rawspeed_crop_dcraw_filters(self->dev->image_storage.buf_dsc.filters, csx, csy);

0 commit comments

Comments
 (0)