Hi there,
I'm new on this forum and I need your help.
So far I am trying to read Raw data, accessing the Bayer data. My code is working well except I have sometimes segfault on the same line: sometimes I read one pic, sometime I segfault on the same pic.
Here a piece of my code :
libraw_data_t *raw = libraw_init(0); int i; int npixels; unsigned short *data=NULL; int ret = libraw_open_file(raw, name); HANDLE_ALL_ERRORS(ret); ret = libraw_unpack(raw); HANDLE_ALL_ERRORS(ret); int raw_width = raw->sizes.raw_width; int raw_height = raw->sizes.raw_height; npixels = raw_width * raw_height; data = (WORD*) calloc(1, npixels * sizeof(WORD)); if (!data) { return -1; } WORD *buf = data; int offset = raw_width * raw->rawdata.sizes.top_margin + raw->rawdata.sizes.left_margin; for (i = 0; i < npixels; i++) { buf[i] = raw->rawdata.raw_image[i + offset]; } .......
The line causing trouble is
buf[i] = raw->rawdata.raw_image[i + offset];
Program received signal SIGSEGV, Segmentation fault. 0x000000000043f20d in readraw_in_cfa (name=0x1056410 "/home/lock/Projet/Pictures/RAW/trails/IMG_3828.CR2", fit=0x666d60 <gfit>) at image_formats_libraries.c:790 790 buf[i] = raw->rawdata.raw_image[i + offset];
But as I said, sometimes it is wotking very well and I see no "pattern" in the segfault.
Did I make something wrong ?
Thanks for your help,
lock
I solved the problem Thanks
I solved the problem
Thanks