diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-08-05 00:03:44 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-08-05 00:03:44 +0200 |
| commit | ba67e5506bd93eef064d72883ff94dbadee14082 (patch) | |
| tree | 2c3c77cc1d9e951d8f59f778e1c3f9226ed03f56 /src/blind-set-alpha.c | |
| parent | fix typo and alphabetical order of commands (diff) | |
| download | blind-ba67e5506bd93eef064d72883ff94dbadee14082.tar.gz blind-ba67e5506bd93eef064d72883ff94dbadee14082.tar.bz2 blind-ba67e5506bd93eef064d72883ff94dbadee14082.tar.xz | |
Add support for skipping conversion to CIEXYZ (not complete)
Some tools are colour space agnostic or even encoding
agnostic, by skipping conversion to CIEXYZ when these
tools are used, the rendering time can be significantly
reduced. The video can also be split horizontally and
vertically, and latted merged back, so it is not necessary
to convert the entire video if only parts of it actually
need it.
Because some tools are less agnostic than other tools,
partial conversion to CIEXYZ is also added.
blind-convert must be updated, and all tools most be test
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-set-alpha.c')
| -rw-r--r-- | src/blind-set-alpha.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/blind-set-alpha.c b/src/blind-set-alpha.c index c548673..31c4df4 100644 --- a/src/blind-set-alpha.c +++ b/src/blind-set-alpha.c @@ -6,18 +6,18 @@ USAGE("[-i] alpha-stream") #define PROCESS(TYPE, INV)\ do {\ size_t i;\ - TYPE a;\ - for (i = 0; i < n; i += colour->pixel_size) {\ - a = INV ((TYPE *)(alpha->buf + i))[1];\ - a *= ((TYPE *)(alpha->buf + i))[3];\ - ((TYPE *)(colour->buf + i))[3] *= a;\ - }\ + TYPE *luma = (TYPE *)(alpha->buf) + alpha->luma_chan;\ + TYPE *alph = (TYPE *)(alpha->buf) + alpha->alpha_chan;\ + TYPE *out = (TYPE *)(colour->buf) + colour->alpha_chan;\ + n /= colour->chan_size;\ + for (i = 0; i < n; i += colour->n_chan)\ + out[i] *= (INV luma[i]) * alph[i];\ } while (0) -static void process_xyza (struct stream *colour, struct stream *alpha, size_t n) {PROCESS(double,);} -static void process_xyza_i (struct stream *colour, struct stream *alpha, size_t n) {PROCESS(double, 1 -);} -static void process_xyzaf (struct stream *colour, struct stream *alpha, size_t n) {PROCESS(float,);} -static void process_xyzaf_i(struct stream *colour, struct stream *alpha, size_t n) {PROCESS(float, 1 -);} +static void process_lf (struct stream *colour, struct stream *alpha, size_t n) {PROCESS(double,);} +static void process_lf_i(struct stream *colour, struct stream *alpha, size_t n) {PROCESS(double, 1 -);} +static void process_f (struct stream *colour, struct stream *alpha, size_t n) {PROCESS(float,);} +static void process_f_i (struct stream *colour, struct stream *alpha, size_t n) {PROCESS(float, 1 -);} int main(int argc, char *argv[]) @@ -40,10 +40,12 @@ main(int argc, char *argv[]) eopen_stream(&colour, NULL); eopen_stream(&alpha, argv[0]); - if (!strcmp(colour.pixfmt, "xyza")) - process = invert ? process_xyza_i : process_xyza; - else if (!strcmp(colour.pixfmt, "xyza f")) - process = invert ? process_xyzaf_i : process_xyzaf; + CHECK_CHANS(&colour, != -1, != -1); + CHECK_ALPHA(&colour); + if (colour.encoding == DOUBLE) + process = invert ? process_lf_i : process_lf; + else if (colour.encoding == FLOAT) + process = invert ? process_f_i : process_f; else eprintf("pixel format %s is not supported, try xyza\n", colour.pixfmt); |
