NV code: Used with modifcations
| 4061 | |
| 4062 | // NV code: Used with modifcations |
| 4063 | static int unquantize(AMD_BC6H_Format& bc6h_format, int q, int prec) |
| 4064 | { |
| 4065 | int unq = 0, s; |
| 4066 | |
| 4067 | switch (bc6h_format.format) |
| 4068 | { |
| 4069 | // modify this case to move the multiplication by 31 after interpolation. |
| 4070 | // Need to use finish_unquantize. |
| 4071 | |
| 4072 | // since we have 16 bits available, let's unquantize this to 16 bits unsigned |
| 4073 | // thus the scale factor is [0-7c00)/[0-10000) = 31/64 |
| 4074 | case UNSIGNED_F16: |
| 4075 | if (prec >= 15) |
| 4076 | unq = q; |
| 4077 | else if (q == 0) |
| 4078 | unq = 0; |
| 4079 | else if (q == ((1 << prec) - 1)) |
| 4080 | unq = U16MAX; |
| 4081 | else |
| 4082 | unq = (q * (U16MAX + 1) + (U16MAX + 1) / 2) >> prec; |
| 4083 | break; |
| 4084 | |
| 4085 | // here, let's stick with S16 (no apparent quality benefit from going to S17) |
| 4086 | // range is (-7c00..7c00)/(-8000..8000) = 31/32 |
| 4087 | case SIGNED_F16: |
| 4088 | // don't remove this test even though it appears equivalent to the code below |
| 4089 | // as it isn't -- the code below can overflow for prec = 16 |
| 4090 | if (prec >= 16) |
| 4091 | unq = q; |
| 4092 | else |
| 4093 | { |
| 4094 | if (q < 0) |
| 4095 | { |
| 4096 | s = 1; |
| 4097 | q = -q; |
| 4098 | } |
| 4099 | else |
| 4100 | s = 0; |
| 4101 | |
| 4102 | if (q == 0) |
| 4103 | unq = 0; |
| 4104 | else if (q >= ((1 << (prec - 1)) - 1)) |
| 4105 | unq = s ? -S16MAX : S16MAX; |
| 4106 | else |
| 4107 | { |
| 4108 | unq = (q * (S16MAX + 1) + (S16MAX + 1) / 2) >> (prec - 1); |
| 4109 | if (s) |
| 4110 | unq = -unq; |
| 4111 | } |
| 4112 | } |
| 4113 | break; |
| 4114 | } |
| 4115 | return unq; |
| 4116 | } |
| 4117 | |
| 4118 | static int lerp(int a, int b, int i, int denom) |
| 4119 | { |
no outgoing calls
no test coverage detected