Frame saving bug fixes

master
Stefan Jahn 3 years ago
parent 6a12c34087
commit 3a95c90f7c

@ -2,6 +2,10 @@
* tool to check and gain some basic information about videodum-files * 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 <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

@ -1,3 +1,4 @@
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
/* /*
@ -63,7 +64,9 @@ void debayer_grbg16_simple (uint16_t * src, int src_w, int src_h,
#define UPRI (*(src-src_w+1)) #define UPRI (*(src-src_w+1))
#define DNLE (*(src+src_w-1)) #define DNLE (*(src+src_w-1))
#define DNRI (*(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++;
/* /*

@ -3,6 +3,7 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
#include <tiffio.h> #include <tiffio.h>
#include "dng.h" #include "dng.h"
@ -123,6 +124,7 @@ int DNG::writeFile(void * data) {
struct tm tm; struct tm tm;
char timestamp[64]; char timestamp[64];
/* get time stamp */
time (&abs_ts); time (&abs_ts);
gmtime_r (&abs_ts, &tm); gmtime_r (&abs_ts, &tm);
sprintf(timestamp, "%04d:%02d:%02d %02d:%02d:%02d", sprintf(timestamp, "%04d:%02d:%02d %02d:%02d:%02d",
@ -148,10 +150,12 @@ int DNG::writeFile(void * data) {
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SamplesPerPixel); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SamplesPerPixel);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); 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 static const short CFARepeatPattern[] = { 2,2 }; // 2x2 CFA
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_CFA);
TIFFSetField(tif, TIFFTAG_CFAREPEATPATTERNDIM, CFARepeatPattern); 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 // 0 = Red, 1 = Green, 2 = Blue
TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\001\000\002\001"); // GRBG TIFFSetField(tif, TIFFTAG_CFAPATTERN, "\001\000\002\001"); // GRBG
} }

@ -21,7 +21,7 @@ SER::SER() {
memcpy(header.FileID, "LUCAM-RECORDER", strlen("LUCAM-RECORDER")); memcpy(header.FileID, "LUCAM-RECORDER", strlen("LUCAM-RECORDER"));
header.LuID = 0; header.LuID = 0;
header.ColorID = SER_COLORID_RGB; header.ColorID = SER_COLORID_RGB;
header.LittleEndian = 1; header.LittleEndian = 0; // opposite meaning of the specification
header.ImageWidth = 0; header.ImageWidth = 0;
header.ImageHeight = 0; header.ImageHeight = 0;
header.PixelDepthPerPlane = 8; header.PixelDepthPerPlane = 8;
@ -243,6 +243,7 @@ int SER::appendFrame(void *data) {
/* ensure we have enough memory allocated for timestamps */ /* ensure we have enough memory allocated for timestamps */
if(FramePointer >= NumberOfTimeStamps) { if(FramePointer >= NumberOfTimeStamps) {
while(FramePointer >= NumberOfTimeStamps)
NumberOfTimeStamps *= 2; NumberOfTimeStamps *= 2;
if((TimeStamps = (int64_t *)realloc(TimeStamps, sizeof(header.DateTime) * NumberOfTimeStamps)) == NULL) { if((TimeStamps = (int64_t *)realloc(TimeStamps, sizeof(header.DateTime) * NumberOfTimeStamps)) == NULL) {
fprintf(stderr, "Error: failed to re-allocate %lu bytes for timestamps\n", fprintf(stderr, "Error: failed to re-allocate %lu bytes for timestamps\n",

Loading…
Cancel
Save