ARM NEON Compositor  master
Fast SIMD alpha overlay and blending for ARM
Enumerations | Functions

Functions to rescale the color values by dividing by 255. More...

+ Collaboration diagram for Rescale:

Enumerations

enum  RescaleType {
  Div255_Round, Div255_Round_Approx, Div255_Floor, Div256_Round,
  Div256_Floor
}
 How to carry out the rescaling after performing the alpha overlay. More...
 

Functions

uint8x8_t div256_floor (uint16x8_t x)
 This is a flooring division by 256, which is close enough to 255, but the result may be one bit too small. More...
 
uint8x8_t div256_round (uint16x8_t x)
 This is a rounding division by 256, which is close enough to 255, but the result may be one bit too small. More...
 
uint8x8_t div255_floor (uint16x8_t x)
 This is an exact flooring division by 255, this is the correct divisor, but requires a little bit more code, and doesn't round the result. More...
 
uint8x8_t div255_round_approx (uint16x8_t x)
 This is an approximation of a rounding division by 255, this is the correct divisor, and it rounds the result correctly 99.80621337890625% of the time. More...
 
uint8x8_t div255_round (uint16x8_t x)
 This is an exact rounding division by 255, this is the correct divisor, and the result is rounded correctly in 100% of the cases. More...
 
uint8_t div256_floor (uint16_t x)
 This is a flooring division by 256, which is close enough to 255, but the result may be one bit too small. More...
 
uint8_t div256_round (uint16_t x)
 This is a rounding division by 256, which is close enough to 255, but the result may be one bit too small. More...
 
uint8_t div255_floor (uint16_t x)
 This is an exact flooring division by 255, this is the correct divisor, but requires a little bit more code, and doesn't round the result. More...
 
uint8_t div255_round (uint16_t x)
 This is an exact rounding division by 255, this is the correct divisor, and the result is rounded correctly in 100% of the cases. More...
 
uint8_t div255_round_approx (uint16_t x)
 Uses div255_round, and is exact. More...
 
template<RescaleType rescale_type = RescaleType::Div255_Round>
uint8x8_t rescale (uint16x8_t x)
 Rescale the 16-bit color product by dividing by 255 or an approximation thereof. More...
 
template<RescaleType rescale_type = RescaleType::Div255_Round>
uint8_t rescale (uint16_t x)
 Rescale the 16-bit color product by dividing by 255 or an approximation thereof. More...
 

Detailed Description

Functions to rescale the color values by dividing by 255.

Enumeration Type Documentation

◆ RescaleType

enum RescaleType
strong

How to carry out the rescaling after performing the alpha overlay.

The product has to be divided by 255 to be exact, but other divisions can be used for (small) performance gains.

Enumerator
Div255_Round 

Exact rounding division by 255.

See div255_round

Div255_Round_Approx 

Approximate rounding division by 255, correct in 99.806% of the cases.

See div255_round_approx

Div255_Floor 

Exact flooring division by 255.

See div255_floor

Div256_Round 

Fast, rounding division by 256.

See div256_round

Div256_Floor 

Fast, flooring division by 256.

See div256_floor

Definition at line 12 of file rescale_type.hpp.

Function Documentation

◆ div256_floor() [1/2]

uint8x8_t div256_floor ( uint16x8_t  x)
inline

This is a flooring division by 256, which is close enough to 255, but the result may be one bit too small.

Definition at line 16 of file rescale.hpp.

◆ div256_round() [1/2]

uint8x8_t div256_round ( uint16x8_t  x)
inline

This is a rounding division by 256, which is close enough to 255, but the result may be one bit too small.

Definition at line 22 of file rescale.hpp.

◆ div255_floor() [1/2]

uint8x8_t div255_floor ( uint16x8_t  x)
inline

This is an exact flooring division by 255, this is the correct divisor, but requires a little bit more code, and doesn't round the result.

Definition at line 37 of file rescale.hpp.

◆ div255_round_approx() [1/2]

uint8x8_t div255_round_approx ( uint16x8_t  x)
inline

This is an approximation of a rounding division by 255, this is the correct divisor, and it rounds the result correctly 99.80621337890625% of the time.

That is, the result is one unit too large in 127 out of all 2¹⁶ possible input values.

This function is just as cheap as the div255_floor function.

Definition at line 57 of file rescale.hpp.

◆ div255_round() [1/2]

uint8x8_t div255_round ( uint16x8_t  x)
inline

This is an exact rounding division by 255, this is the correct divisor, and the result is rounded correctly in 100% of the cases.

(Compared to std::round(x / 255.0))

The result is incorrect for very large numbers where the quotient would overflow an 8-bit integer.

Definition at line 76 of file rescale.hpp.

◆ div256_floor() [2/2]

uint8_t div256_floor ( uint16_t  x)
inline

This is a flooring division by 256, which is close enough to 255, but the result may be one bit too small.

Definition at line 153 of file rescale.hpp.

◆ div256_round() [2/2]

uint8_t div256_round ( uint16_t  x)
inline

This is a rounding division by 256, which is close enough to 255, but the result may be one bit too small.

Definition at line 159 of file rescale.hpp.

◆ div255_floor() [2/2]

uint8_t div255_floor ( uint16_t  x)
inline

This is an exact flooring division by 255, this is the correct divisor, but requires a little bit more code, and doesn't round the result.

Definition at line 165 of file rescale.hpp.

◆ div255_round() [2/2]

uint8_t div255_round ( uint16_t  x)
inline

This is an exact rounding division by 255, this is the correct divisor, and the result is rounded correctly in 100% of the cases.

(Compared to std::round(x / 255.0))

Definition at line 175 of file rescale.hpp.

◆ div255_round_approx() [2/2]

uint8_t div255_round_approx ( uint16_t  x)
inline

Uses div255_round, and is exact.

Definition at line 184 of file rescale.hpp.

◆ rescale() [1/2]

uint8x8_t rescale ( uint16x8_t  x)
inline

Rescale the 16-bit color product by dividing by 255 or an approximation thereof.

Parameters
xThe 16-bit product to rescale.
Template Parameters
rescale_typeThe rescaling mode to use. See RescaleType.

Definition at line 200 of file rescale.hpp.

◆ rescale() [2/2]

uint8_t rescale ( uint16_t  x)
inline

Rescale the 16-bit color product by dividing by 255 or an approximation thereof.

Parameters
xThe 16-bit product to rescale.
Template Parameters
rescale_typeThe rescaling mode to use. See RescaleType.

Definition at line 214 of file rescale.hpp.