diff --git a/checkdumpfile.cc b/checkdumpfile.cc index 212ff90..6dbf62e 100644 --- a/checkdumpfile.cc +++ b/checkdumpfile.cc @@ -2,6 +2,10 @@ * tool to check and gain some basic information about videodum-files */ +/* enable files > 2GB on 32 bit systems */ +#define _LARGEFILE64_SOURCE 1 +#define _FILE_OFFSET_BITS 64 + #include #include #include diff --git a/debayer.cc b/debayer.cc index 7c65f5d..87f8550 100644 --- a/debayer.cc +++ b/debayer.cc @@ -1,3 +1,4 @@ +#include #include /* @@ -63,7 +64,9 @@ void debayer_grbg16_simple (uint16_t * src, int src_w, int src_h, #define UPRI (*(src-src_w+1)) #define DNLE (*(src+src_w-1)) #define DNRI (*(src+src_w+1)) -#define STORE *(dst++) = (r>>8)&0xff; *(dst++) = (g>>8)&0xff; *(dst++) = (b>>8) & 0xff; src++; + +#define BITCONV(d) ((d>>8) & 0xff) +#define STORE *(dst++) = BITCONV(r); *(dst++) = BITCONV(g); *(dst++) = BITCONV(b); src++; /* diff --git a/dng.cc b/dng.cc index dff5385..2f22cc5 100644 --- a/dng.cc +++ b/dng.cc @@ -3,6 +3,7 @@ */ #include +#include #include #include #include "dng.h" @@ -122,7 +123,8 @@ int DNG::writeFile(void * data) { time_t abs_ts; struct tm tm; char timestamp[64]; - + + /* get time stamp */ time (&abs_ts); gmtime_r (&abs_ts, &tm); sprintf(timestamp, "%04d:%02d:%02d %02d:%02d:%02d", @@ -147,11 +149,13 @@ int DNG::writeFile(void * data) { TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SamplesPerPixel); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - - if(ColorID == DNG_COLORID_RAW8 || ColorID == DNG_COLORID_RAW8) { + + if(ColorID == DNG_COLORID_RAW8 || ColorID == DNG_COLORID_RAW16) { static const short CFARepeatPattern[] = { 2,2 }; // 2x2 CFA TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA); TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, CFARepeatPattern); + TIFFSetField(tif, TIFFTAG_CFALAYOUT, 1); + TIFFSetField(tif, TIFFTAG_CFAPLANECOLOR, 3, "\000\001\002"); // RGB // 0 = Red, 1 = Green, 2 = Blue TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\001\000\002\001"); // GRBG } diff --git a/ser.cc b/ser.cc index 76e1217..70dab1c 100644 --- a/ser.cc +++ b/ser.cc @@ -21,7 +21,7 @@ SER::SER() { memcpy(header.FileID, "LUCAM-RECORDER", strlen("LUCAM-RECORDER")); header.LuID = 0; header.ColorID = SER_COLORID_RGB; - header.LittleEndian = 1; + header.LittleEndian = 0; // opposite meaning of the specification header.ImageWidth = 0; header.ImageHeight = 0; header.PixelDepthPerPlane = 8; @@ -234,7 +234,7 @@ int SER::appendFrame(void *data) { fprintf(stderr, "Error: appending frame, SER file not yet specified\n"); return -1; } - + /* write frame data */ if(fwrite(data, FrameSize, 1, FileDesc) != 1) { fprintf(stderr, "Error: failed write SER frame (%s)\n", strerror(errno)); @@ -243,7 +243,8 @@ int SER::appendFrame(void *data) { /* ensure we have enough memory allocated for timestamps */ if(FramePointer >= NumberOfTimeStamps) { - NumberOfTimeStamps *= 2; + while(FramePointer >= NumberOfTimeStamps) + NumberOfTimeStamps *= 2; if((TimeStamps = (int64_t *)realloc(TimeStamps, sizeof(header.DateTime) * NumberOfTimeStamps)) == NULL) { fprintf(stderr, "Error: failed to re-allocate %lu bytes for timestamps\n", sizeof(header.DateTime) * (long)NumberOfTimeStamps);