2021-05-26 11:31:52 +02:00
|
|
|
/*
|
2024-03-28 16:01:58 +01:00
|
|
|
* another ugly experiment (please explain)
|
2021-05-26 11:31:52 +02:00
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdint.h>
|
2021-06-11 06:50:13 +02:00
|
|
|
#include <string.h>
|
2021-05-26 11:31:52 +02:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
2022-01-22 14:47:46 +01:00
|
|
|
/* --------------------------------------------------------------- */
|
2021-05-26 11:31:52 +02:00
|
|
|
|
|
|
|
int triplane_muxer(FloatImg *sr, FloatImg *sg, FloatImg *sb,
|
2024-10-27 16:37:10 +01:00
|
|
|
FloatImg *dst)
|
2021-05-26 11:31:52 +02:00
|
|
|
{
|
|
|
|
int sz;
|
|
|
|
|
|
|
|
if (FIMG_TYPE_RGB != dst->type) {
|
|
|
|
fprintf(stderr, "%s: dst picz must be RGB, was %d\n",
|
|
|
|
__func__, dst->type);
|
|
|
|
return -99;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( fimg_images_not_compatible(sr, sg) ||
|
|
|
|
fimg_images_not_compatible(sr, sb) ||
|
|
|
|
fimg_images_not_compatible(sr, dst) ) {
|
|
|
|
fprintf(stderr, "%s: compatibility error\n", __func__);
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
sz = sr->width * sr->height * sizeof(float);
|
|
|
|
|
|
|
|
memcpy(dst->R, sr->R, sz);
|
|
|
|
memcpy(dst->G, sg->G, sz);
|
|
|
|
memcpy(dst->B, sb->B, sz);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-22 14:47:46 +01:00
|
|
|
/* --------------------------------------------------------------- */
|
2021-05-26 11:31:52 +02:00
|
|
|
int try_this_muxplane(char *fr, char *fg, char *fb, char *dst, int flags)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
FloatImg imr, img, imb, dest;
|
|
|
|
|
2021-10-15 23:21:02 +02:00
|
|
|
fprintf(stderr, "muxing: %s %s %s -> %s\n", fr, fg, fb, dst);
|
2021-05-26 11:31:52 +02:00
|
|
|
|
2024-10-27 16:37:10 +01:00
|
|
|
if (flags) {
|
|
|
|
fprintf(stderr, "%s: flag non 0 ?\n", __FILE__);
|
|
|
|
}
|
|
|
|
|
2021-05-26 11:31:52 +02:00
|
|
|
foo = fimg_create_from_dump(fr, &imr);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
foo = fimg_create_from_dump(fg, &img);
|
|
|
|
if (foo) {
|
2024-03-28 16:01:58 +01:00
|
|
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fg);
|
2021-05-26 11:31:52 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
foo = fimg_create_from_dump(fb, &imb);
|
|
|
|
if (foo) {
|
2024-03-28 16:01:58 +01:00
|
|
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fb);
|
2021-05-26 11:31:52 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fimg_clone(&imr, &dest, 0);
|
|
|
|
|
2024-10-27 16:37:10 +01:00
|
|
|
foo = triplane_muxer(&imr, &img, &imb, &dest);
|
2021-05-26 11:31:52 +02:00
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: err %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
2022-01-22 14:47:46 +01:00
|
|
|
foo = fimg_export_picture(&dest, dst, 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: err %d exporting to %s\n", __func__, foo, dst);
|
|
|
|
return foo;
|
|
|
|
}
|
2021-05-26 11:31:52 +02:00
|
|
|
|
2022-01-21 14:48:45 +01:00
|
|
|
fimg_destroy(&imr); fimg_destroy(&img);
|
2022-01-22 14:47:46 +01:00
|
|
|
fimg_destroy(&imb); fimg_destroy(&dest);
|
2022-01-21 14:48:45 +01:00
|
|
|
|
2021-05-26 11:31:52 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2022-01-22 14:47:46 +01:00
|
|
|
/* --------------------------------------------------------------- */
|
2021-05-26 11:31:52 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
if (5 != argc) {
|
2021-10-15 23:21:02 +02:00
|
|
|
fprintf(stderr, "ERROR: %s need four fimg files arguments\n",
|
|
|
|
argv[0]);
|
2021-05-26 11:31:52 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-01-22 14:47:46 +01:00
|
|
|
/*
|
|
|
|
* and now, we have to decipher options on the
|
|
|
|
* command line.
|
|
|
|
*/
|
|
|
|
|
2021-05-26 11:31:52 +02:00
|
|
|
foo = try_this_muxplane(argv[1], argv[2], argv[3], argv[4], 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "oups %d\n", foo);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-01-22 14:47:46 +01:00
|
|
|
/* --------------------------------------------------------------- */
|