diff options
-rw-r--r-- | unpremultiply-div.c | 25 | ||||
-rw-r--r-- | unpremultiply-inv.c | 25 | ||||
-rw-r--r-- | unpremultiply-invb.c | 27 | ||||
-rw-r--r-- | unpremultiply-lut.c | 25 | ||||
-rw-r--r-- | unpremultiply-lutb.c | 35 | ||||
-rw-r--r-- | unpremultiply-sse2.S | 27 | ||||
-rw-r--r-- | unpremultiply.c | 25 |
7 files changed, 181 insertions, 8 deletions
diff --git a/unpremultiply-div.c b/unpremultiply-div.c index 543149c..a58ce4f 100644 --- a/unpremultiply-div.c +++ b/unpremultiply-div.c @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2009 M Joonas Pihlaja + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + /* Reference implementation using divisions. Since the slow path is * so very slow this version specialises runs of constant or solid * pixels. */ diff --git a/unpremultiply-inv.c b/unpremultiply-inv.c index cc037f8..4b9e811 100644 --- a/unpremultiply-inv.c +++ b/unpremultiply-inv.c @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2009 M Joonas Pihlaja + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + /* Basic unpremultiplier using reciprocal multiplication from a 1KB * table of reciprocals. */ #include <stdint.h> diff --git a/unpremultiply-invb.c b/unpremultiply-invb.c index a2b17bf..bd43094 100644 --- a/unpremultiply-invb.c +++ b/unpremultiply-invb.c @@ -1,7 +1,32 @@ +/* + * Copyright (c) 2009 M Joonas Pihlaja + * Copyright (c) 2009 Paul-Virak Khuong + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + /* An unpremultiplier using reciprocal multiplication. It specialises * constant runs and solid runs of pixels with low overhead loops and * uses only a 1KB table of reciprocals. */ -/* gcc -c -W -Wall -O3 -funroll-all-loops -fomit-frame-pointer -std=c99 unpremultiply-inv32.c */ #include <stdint.h> #include <stddef.h> diff --git a/unpremultiply-lut.c b/unpremultiply-lut.c index 4954f51..7a3d8a9 100644 --- a/unpremultiply-lut.c +++ b/unpremultiply-lut.c @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2009 M Joonas Pihlaja + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + /* Basic unpremultiplier using a 64KB division table. It has the * advantage over the others that it can clamp the result into range * without any cost, so it is safe to pass it superluminant input diff --git a/unpremultiply-lutb.c b/unpremultiply-lutb.c index bdbe039..f8db573 100644 --- a/unpremultiply-lutb.c +++ b/unpremultiply-lutb.c @@ -1,10 +1,33 @@ +/* + * Copyright (c) 2009 M Joonas Pihlaja + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + /* An unpremultiplier using a 64KB division table. It specialises - * constant runs and solid runs of pixels, but not quite as well as - * unpremultiply-inv32 (but it could given some more effort.) It has - * the advantage over the others that it can clamp the result into - * range without any cost so that the output doesn't overflow should - * there be superluminant pixels in the input. It's also reasonably - * fast if you have enough L1. */ + * constant runs and solid runs of pixels. It has the advantage over + * the others that it can clamp the result into range without any + * additional cost so that the output doesn't overflow should there be + * superluminant pixels in the input. */ #include <stddef.h> #include <stdint.h> diff --git a/unpremultiply-sse2.S b/unpremultiply-sse2.S index b98cc51..6ebb0f0 100644 --- a/unpremultiply-sse2.S +++ b/unpremultiply-sse2.S @@ -1,4 +1,28 @@ ;;; +;;; Copyright (c) 2009 M Joonas Pihlaja +;;; +;;; Permission is hereby granted, free of charge, to any person +;;; obtaining a copy of this software and associated documentation +;;; files (the "Software"), to deal in the Software without +;;; restriction, including without limitation the rights to use, +;;; copy, modify, merge, publish, distribute, sublicense, and/or sell +;;; copies of the Software, and to permit persons to whom the +;;; Software is furnished to do so, subject to the following +;;; conditions: +;;; +;;; The above copyright notice and this permission notice shall be +;;; included in all copies or substantial portions of the Software. +;;; +;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +;;; OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +;;; OTHER DEALINGS IN THE SOFTWARE. + +;;; ;;; Unpremultiply routine for SSE2/AMD64. ;;; ;;; This file exports a function unpremultiply_with_sse2() that @@ -9,7 +33,8 @@ ;;; uint32_t const *src, ;;; unsigned long num_pixels); ;;; -;;; Tested with nasm 2.06rc2. +;;; Assembled with nasm 2.06rc2. +;;; section .text ; We're only using rax-rbp in this file so that diff --git a/unpremultiply.c b/unpremultiply.c index 9beebd0..0f3e13c 100644 --- a/unpremultiply.c +++ b/unpremultiply.c @@ -6,6 +6,31 @@ gcc $CFLAGS -c *.c gcc $CFLAGS -o `basename $0 .c` *.o exit $? */ +/* + * Copyright (c) 2009 M Joonas Pihlaja + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + /* Test driver for unpremultipliers. */ #include <assert.h> #include <stdint.h> |