|
1 | 1 | /* |
2 | 2 | * Copyright © 2017 Frechdachs <frechdachs@rekt.cc> |
3 | | - * This work is free. You can redistribute it and/or modify it under the |
4 | | - * terms of the Do What The Fuck You Want To Public License, Version 2, |
5 | | - * as published by Sam Hocevar. See the COPYING file for more details. |
| 3 | + * This program is free software. It comes without any warranty, to |
| 4 | + * the extent permitted by applicable law. You can redistribute it |
| 5 | + * and/or modify it under the terms of the Do What The Fuck You Want |
| 6 | + * To Public License, Version 2, as published by Sam Hocevar. |
| 7 | + * See the COPYING file for more details. |
6 | 8 | */ |
7 | 9 |
|
8 | 10 |
|
@@ -100,7 +102,8 @@ void multiply_banded_matrix_with_diagonal(int rows, int bandwidth, std::vector<d |
100 | 102 |
|
101 | 103 | // LDLT decomposition (variant of Cholesky decomposition) |
102 | 104 | // Input is only the upper part of a banded symmetrical matrix in compressed form. |
103 | | -// The input matrix is modified in-place and equals L' in compressed form after decomposition. |
| 105 | +// The input matrix is modified in-place and contains L' and D in compressed form |
| 106 | +// after decomposition. The main diagonal of ones of L' is not saved. |
104 | 107 | void banded_ldlt_decomposition(int rows, int bandwidth, std::vector<double> &matrix) |
105 | 108 | { |
106 | 109 | int c = (bandwidth + 1) / 2; |
@@ -645,8 +648,14 @@ static void VS_CC debilinear_create(const VSMap *in, VSMap *out, void *userData, |
645 | 648 | if (err) |
646 | 649 | d.shift_v = 0; |
647 | 650 |
|
| 651 | + if (d.width < 1 || d.height < 1) { |
| 652 | + vsapi->setError(out, "Descale: width and height must be bigger than 0."); |
| 653 | + vsapi->freeNode(d.node); |
| 654 | + return; |
| 655 | + } |
| 656 | + |
648 | 657 | if (d.width > d.vi->width || d.height > d.vi->height) { |
649 | | - vsapi->setError(out, "Descale: Output dimension has to be smaller or equal to input dimension."); |
| 658 | + vsapi->setError(out, "Descale: Output dimension has to be smaller than or equal to input dimension."); |
650 | 659 | vsapi->freeNode(d.node); |
651 | 660 | return; |
652 | 661 | } |
@@ -712,8 +721,14 @@ static void VS_CC debicubic_create(const VSMap *in, VSMap *out, void *userData, |
712 | 721 | if (err) |
713 | 722 | d.shift_v = 0; |
714 | 723 |
|
| 724 | + if (d.width < 1 || d.height < 1) { |
| 725 | + vsapi->setError(out, "Descale: width and height must be bigger than 0."); |
| 726 | + vsapi->freeNode(d.node); |
| 727 | + return; |
| 728 | + } |
| 729 | + |
715 | 730 | if (d.width > d.vi->width || d.height > d.vi->height) { |
716 | | - vsapi->setError(out, "Descale: Output dimension has to be smaller or equal to input dimension."); |
| 731 | + vsapi->setError(out, "Descale: Output dimension has to be smaller than or equal to input dimension."); |
717 | 732 | vsapi->freeNode(d.node); |
718 | 733 | return; |
719 | 734 | } |
@@ -775,8 +790,20 @@ static void VS_CC delanczos_create(const VSMap *in, VSMap *out, void *userData, |
775 | 790 | if (err) |
776 | 791 | d.shift_v = 0; |
777 | 792 |
|
| 793 | + if (d.width < 1 || d.height < 1) { |
| 794 | + vsapi->setError(out, "Descale: width and height must be bigger than 0."); |
| 795 | + vsapi->freeNode(d.node); |
| 796 | + return; |
| 797 | + } |
| 798 | + |
778 | 799 | if (d.width > d.vi->width || d.height > d.vi->height) { |
779 | | - vsapi->setError(out, "Descale: Output dimension has to be smaller or equal to input dimension."); |
| 800 | + vsapi->setError(out, "Descale: Output dimension has to be smaller than or equal to input dimension."); |
| 801 | + vsapi->freeNode(d.node); |
| 802 | + return; |
| 803 | + } |
| 804 | + |
| 805 | + if (d.taps < 1) { |
| 806 | + vsapi->setError(out, "Descale: taps must be bigger than 0."); |
780 | 807 | vsapi->freeNode(d.node); |
781 | 808 | return; |
782 | 809 | } |
@@ -834,8 +861,14 @@ static void VS_CC despline16_create(const VSMap *in, VSMap *out, void *userData, |
834 | 861 | if (err) |
835 | 862 | d.shift_v = 0; |
836 | 863 |
|
| 864 | + if (d.width < 1 || d.height < 1) { |
| 865 | + vsapi->setError(out, "Descale: width and height must be bigger than 0."); |
| 866 | + vsapi->freeNode(d.node); |
| 867 | + return; |
| 868 | + } |
| 869 | + |
837 | 870 | if (d.width > d.vi->width || d.height > d.vi->height) { |
838 | | - vsapi->setError(out, "Descale: Output dimension has to be smaller or equal to input dimension."); |
| 871 | + vsapi->setError(out, "Descale: Output dimension has to be smaller than or equal to input dimension."); |
839 | 872 | vsapi->freeNode(d.node); |
840 | 873 | return; |
841 | 874 | } |
@@ -893,8 +926,14 @@ static void VS_CC despline36_create(const VSMap *in, VSMap *out, void *userData, |
893 | 926 | if (err) |
894 | 927 | d.shift_v = 0; |
895 | 928 |
|
| 929 | + if (d.width < 1 || d.height < 1) { |
| 930 | + vsapi->setError(out, "Descale: width and height must be bigger than 0."); |
| 931 | + vsapi->freeNode(d.node); |
| 932 | + return; |
| 933 | + } |
| 934 | + |
896 | 935 | if (d.width > d.vi->width || d.height > d.vi->height) { |
897 | | - vsapi->setError(out, "Descale: Output dimension has to be smaller or equal to input dimension."); |
| 936 | + vsapi->setError(out, "Descale: Output dimension has to be smaller than or equal to input dimension."); |
898 | 937 | vsapi->freeNode(d.node); |
899 | 938 | return; |
900 | 939 | } |
|
0 commit comments