aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-15 17:08:02 +0200
committerMattias Andrée <maandree@kth.se>2017-07-15 17:08:02 +0200
commit3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f (patch)
treee8b08fe9b0cdc208f66582309377bc3c1817fe1f /src/stream.c
parentGenerate USING_BINARY{32,64} (diff)
downloadblind-3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f.tar.gz
blind-3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f.tar.bz2
blind-3569a10c97d41913dbf7cf3114cb4d2d5f17dc7f.tar.xz
Some improvements and fixes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/stream.c')
-rw-r--r--src/stream.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/stream.c b/src/stream.c
index 1cfb372..7ce32e2 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -95,12 +95,22 @@ enopen_stream(int status, struct stream *stream, const char *file)
int
set_pixel_size(struct stream *stream)
{
- if (!strcmp(stream->pixfmt, "xyza"))
- stream->pixel_size = 4 * sizeof(double);
- else if (!strcmp(stream->pixfmt, "xyza f"))
- stream->pixel_size = 4 * sizeof(float);
- else
+ if (!strcmp(stream->pixfmt, "xyza")) {
+ stream->n_chan = 4;
+ stream->chan_size = sizeof(double);
+ stream->space = CIEXYZ;
+ stream->alpha = UNPREMULTIPLIED;
+ stream->encoding = DOUBLE;
+ } else if (!strcmp(stream->pixfmt, "xyza f")) {
+ stream->n_chan = 4;
+ stream->chan_size = sizeof(float);
+ stream->space = CIEXYZ;
+ stream->alpha = UNPREMULTIPLIED;
+ stream->encoding = FLOAT;
+ } else {
return -1;
+ }
+ stream->pixel_size = stream->n_chan * stream->chan_size;
stream->row_size = stream->pixel_size * stream->width;
stream->col_size = stream->pixel_size * stream->height;
stream->frame_size = stream->pixel_size * stream->height * stream->width;
@@ -212,31 +222,31 @@ encheck_compat(int status, const struct stream *a, const struct stream *b)
const char *
get_pixel_format(const char *specified, const char *current)
{
- const char *base = NULL;
- int as_float = 0;
+ enum colour_space space;
+ enum encoding encoding;
if (!strcmp(current, "xyza"))
- base = "xyza";
+ space = CIEXYZ, encoding = DOUBLE;
else if (!strcmp(current, "xyza f"))
- base = "xyza", as_float = 1;
+ space = CIEXYZ, encoding = FLOAT;
else
return specified;
if (!strcmp(specified, "xyza"))
- base = "xyza";
+ space = CIEXYZ;
else if (!strcmp(specified, "xyza f"))
return "xyza f";
else if (!strcmp(specified, "xyza !f"))
return "xyza";
else if (!strcmp(specified, "f"))
- as_float = 1;
+ encoding = FLOAT;
else if (!strcmp(specified, "!f"))
- as_float = 0;
+ encoding = DOUBLE;
else
return specified;
- if (!strcmp(base, "xyza"))
- return as_float ? "xyza f" : "xyza";
+ if (space == CIEXYZ)
+ return encoding == FLOAT ? "xyza f" : "xyza";
else
return specified;
}