alaw
Functions
-
int main(int argc, char *argv[])
alaw [ option ] [ infile ]
-v double
absolute maximum value of input \((0 < V)\)
-a double
compression factor \((1 \le A)\)
infile str
double-type input data sequence
stdout
double-type compressed data sequence
In the below example, 16-bit data read from
data.short
is compressed to 8-bit A-law format.x2x +sd data.short | alaw | quantize > data.alaw
- Parameters:
argc – [in] Number of arguments.
argv – [in] Argument vector.
- Returns:
0 on success, 1 on failure.
-
class ALawCompression
Nonlinearly compress data based on A-law algorithm.
Given the input data \(x(n)\), the compression is performed as follows:
\[\begin{split} y(n) = V \, \mathrm{sgn}(x(n)) \left\{ \begin{array}{ll} \frac{A \frac{|x(n)|}{V}}{1 + \log A}, & \frac{|x(n)|}{V} < \frac{1}{A} \\ \frac{1 + \log(A \frac{|x(n)|}{V})}{1 + \log A}, & \frac{|x(n)|}{V} \ge \frac{1}{A} \end{array} \right. \end{split}\]where \(V\) is the absolute maximum value of the input data and \(A\) is the compression factor, which is typically set to 87.6.Public Functions
-
ALawCompression(double abs_max_value, double compression_factor)
- Parameters:
abs_max_value – [in] Absolute maximum value.
compression_factor – [in] Compression factor, \(A\).
-
inline double GetAbsMaxValue() const
- Returns:
Absolute maximum value.
-
inline double GetCompressionFactor() const
- Returns:
Compression factor.
-
inline bool IsValid() const
- Returns:
True if this object is valid.
-
bool Run(double input, double *output) const
- Parameters:
input – [in] Input data.
output – [out] Output data.
- Returns:
True on success, false on failure.
-
bool Run(double *input_and_output) const
- Parameters:
input_and_output – [inout] Input/output data.
- Returns:
True on success, false on failure.
-
ALawCompression(double abs_max_value, double compression_factor)