big cleanup, word on metadata

This commit is contained in:
tTh
2022-07-06 10:27:55 +02:00
parent aa2ced081a
commit c7a51ec7a0
49 changed files with 348 additions and 105 deletions

View File

@@ -21,7 +21,15 @@ int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k)
float kr, kg, kb, kdiv;
int nbb, foo;
kr = kg = kb = 1.0; /* canonic random values */
if (k) {
/* some random funky values ... */
kr = 0.789; kg = 0.523; kb = 0.349;
}
else {
/* ... and canonic random values */
kr = kg = kb = 1.0;
}
kdiv = kr + kg + kb;
/* we must check the validity of our parameters */
@@ -59,6 +67,10 @@ int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused)
int foo, nbb;
/* we must check the validity of our parameters */
if (notused) {
fprintf(stderr, "notused was %d, must be 0 in %s\n",
notused, __func__);
}
if (FIMG_TYPE_RGB != src->type || FIMG_TYPE_RGB != dst->type) {
fprintf(stderr, "%s : bad image type\n", __func__);
return -18;

View File

@@ -94,8 +94,8 @@ if (NULL == pmd) {
}
else {
/* OK, get some funky metadatas */
fprintf(stderr, "OK %s get funky metadatas\n", __func__);
fprintf(stderr, "acquisition values %f %d\n", pmd->fval, pmd->count);
// fprintf(stderr, "%s get metadatas\n", __func__);
fprintf(stderr, "acqu fval=%f count=%d\n", pmd->fval, pmd->count);
}
fp = fopen(fname, "w");
@@ -111,7 +111,7 @@ filehead.t = fimg->type;
/* XXX metadata */
if (NULL != pmd) {
fprintf(stderr, "ok, %s give an 'a' flag\n", __func__);
// fprintf(stderr, "ok, %s give an 'a' flag\n", __func__);
filehead.magic[4] = 'a';
}
@@ -125,7 +125,7 @@ if (1 != foo) {
/* we have metadata, put them on tape */
if (NULL != pmd) {
fprintf(stderr, ">>> %s write metadata %p\n", __func__, pmd);
// fprintf(stderr, ">>> %s write metadata %p\n", __func__, pmd);
foo = fwrite(pmd, sizeof(FimgMetaData), 1, fp);
if (1 != foo) {
perror(fname);
@@ -296,7 +296,7 @@ fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head);
/*
* may be we can crash coredump here if the head
* descriptor from calleris not blank ?
* descriptor from caller is not blank ?
*/
fp = fopen(fname, "r");
@@ -328,7 +328,8 @@ if (foo) {
* Oh boy, we have to skeep the metadata chunck
*/
if ('a' == filehead.magic[4]) {
fprintf(stderr, "OMG %s metadata !!!\n", __func__);
if (verbosity)
{ fprintf(stderr, "%s: %s has metadata\n", __func__, fname); }
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
if (foo) {
fprintf(stderr, "%s : shit hit the fan\n", __func__);

View File

@@ -303,6 +303,11 @@ int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused)
{
double coef;
if (notused) {
fprintf(stderr, "notused was %d, must be 0 in %s\n",
notused, __func__);
}
if (fi->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
__func__, fi->type);
@@ -324,6 +329,7 @@ if (verbosity) {
fprintf(stderr, "image @ %p\n", fi);
fprintf(stderr, "fval %f\n", fi->fval);
fprintf(stderr, "count %d\n", fi->count);
fprintf(stderr, "maxima %f\n", maxima);
fprintf(stderr, "coef %f\n", coef);
}

View File

@@ -23,9 +23,14 @@ int fimg_load_from_pnm(char *fname, FloatImg *head, int notused)
FILE *fp;
int width, height, maxval;
int foo, line, column;
unsigned char *buffline, *idxrd, dummychar;
unsigned char *buffline, *idxrd;
float *Rptr, *Gptr, *Bptr;
if (notused) {
fprintf(stderr, "notused was %d, must be 0 in %s\n",
notused, __func__);
}
if (NULL==head) {
fprintf(stderr, "%s : head ptr is %p\n", __func__, head);
return -8;
@@ -58,6 +63,7 @@ if (foo) {
}
#if DEBUG_LEVEL
unsigned char dummychar;
fread(&dummychar, 1, 1, fp);
fprintf(stderr, "%s : dummychar %xx\n", __func__, dummychar);
#else

View File

@@ -24,6 +24,8 @@ double fimg_timer_set(int whot)
{
double current;
if (whot) fprintf(stderr, "in %s whot is %d\n", __func__, whot);
current = dtime();
#if DEBUG_LEVEL
@@ -36,6 +38,9 @@ return memory_time;
double fimg_timer_get(int whot)
{
double current;
if (whot) fprintf(stderr, "in %s whot is %d\n", __func__, whot);
current = dtime();
return current - memory_time;
}

View File

@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
@@ -14,6 +15,9 @@
extern int verbosity; /* must be declared around main() */
/* ---------------------------------------------------------------- */
/*
* specific function because magic field is NOT an asciiz !
*/
static void puts_magic_8(char *ptr, FILE *fp)
{
int foo;
@@ -37,10 +41,13 @@ fprintf(stderr, ">>> %s ( %p '%s' 0x%08x )\n", __func__,
pmd, title, notused);
#endif
if (notused) {
fprintf(stderr, "notused was %d, must be 0 in %s\n",
notused, __func__);
}
if (NULL != title) {
fprintf(stderr, "==== metadate for %s\n", title);
}
if (verbosity) {
fprintf(stderr, "sizeof(metadata) = %ld\n", \
sizeof(FimgMetaData));
@@ -49,9 +56,10 @@ if (verbosity) {
/* SHOW TIMESTAMP HERE */
fprintf(stderr, "seconds sc. epoch = %ld\n", pmd->timestamp.tv_sec);
fprintf(stderr, "date & time = %s", ctime(&pmd->timestamp.tv_sec));
doubletime = (double)pmd->timestamp.tv_sec + \
(double)pmd->timestamp.tv_usec / 1e6;
fprintf(stderr, "dtime of day = %e\n", doubletime);
fprintf(stderr, "dtime of day = %12.3f\n", doubletime);
fprintf(stderr, "creator pid = %ld\n", pmd->cpid);
fprintf(stderr, "float value = %.3f\n", pmd->fval);
fprintf(stderr, "counter = %d\n", pmd->count);
@@ -85,8 +93,8 @@ if (foo) {
}
else {
if (verbosity > 1) {
fprintf(stderr, " set TimeOfDay to %12ld , %8ld\n", \
tvl.tv_sec, tvl.tv_usec);
fprintf(stderr, "%s : set TimeOfDay to %12ld %8ld\n", \
__func__, tvl.tv_sec, tvl.tv_usec);
}
memcpy(&(pmd->timestamp), &tvl, sizeof(struct timeval));
}

21
lib/t.c
View File

@@ -22,7 +22,7 @@ int foo;
fprintf(stderr, "-------- %s ( %s ) --------\n", __func__, fname);
foo = fimg_default_metadata(&Md);
foo = fimg_default_metadata(&Md, 0);
// foo = fimg_show_metadata(&Md, "default from t.c", 0);
@@ -33,8 +33,11 @@ if (foo) {
}
foo = fimg_show_metadata(&Md, fname, 0);
return -1;
if (foo) {
fprintf(stderr, "%s: show metadata -> %d\n", __func__, foo);
return foo;
}
return 0;
}
/* ---------------------------------------------------------------- */
int essai_save_plane(int wot)
@@ -100,7 +103,8 @@ if (foo) {
fprintf(stderr, "%s err create A %d\n", __func__, foo);
return foo;
}
fimg_hdeg_a(&A, KDEG);
if (k) fimg_hdeg_a(&A, KDEG);
else fimg_vdeg_a(&A, KDEG);
foo = fimg_create(&B, WI, HI, FIMG_TYPE_RGB);
if (foo) {
@@ -297,6 +301,12 @@ fimg_save_as_pnm(&copy, "cos_010.pnm", 0);
fimg_destroy(&dessin); fimg_destroy(&copy);
return 0;
}
/* ---------------------------------------------------------------- */
void help_me_obiwan(void)
{
}
/* ---------------------------------------------------------------- */
int main(int argc, char *argv[])
@@ -305,9 +315,10 @@ int foo, opt;
// char outname[100];
int gray = 0;
while ((opt = getopt(argc, argv, "gn:v")) != -1) {
while ((opt = getopt(argc, argv, "ghn:v")) != -1) {
switch(opt) {
case 'g': gray++; break;
case 'h': help_me_obiwan(); break;
case 'n': foo=atoi(optarg); break;
case 'v': verbosity++; break;
default: