%Copyright (C) 2007-2015  Brian Langenberger
%This work is licensed under the
%Creative Commons Attribution-Share Alike 3.0 United States License.
%To view a copy of this license, visit
%http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to
%Creative Commons,
%171 Second Street, Suite 300,
%San Francisco, California, 94105, USA.

\subsection{Computing QLP Coefficients and Residual}
\label{alac:compute_qlp_coeffs}
{\relsize{-1}
  \input{alac/algorithms/compute_qlp_coeffs}
}


\clearpage

\subsubsection{Windowing the Input Samples}
\label{alac:window}
{\relsize{-1}
  \input{flac/algorithms/encode_window_samples}
}

\subsubsection{Autocorrelating Windowed Samples}
\label{alac:autocorrelate}
{\relsize{-1}
  \input{flac/algorithms/encode_autocorrelate}
}

\subsubsection{LP Coefficient Calculation}
\label{alac:compute_lp_coeffs}
{\relsize{-1}
  \input{flac/algorithms/encode_lp_coeffs}
}

\subsubsection{Quantizing LP Coefficients}
\label{alac:quantize_lp_coeffs}
\input{alac/algorithms/quantize_coeffs}

\subsubsection{Quantizing Coefficients Example}
\begin{align*}
e &\leftarrow \texttt{0.00} + \texttt{2.29} \times 2 ^ 9 = \texttt{1170.49} \\
\textsf{QLP coefficient}_0 &\leftarrow \texttt{round}(\texttt{1170.49}) = \texttt{\color{blue}1170} \\
e &\leftarrow \texttt{1170.49} - 1170 = \texttt{0.49} \\
e &\leftarrow \texttt{0.49} + \texttt{-2.13} \times 2 ^ 9 = \texttt{-1087.81} \\
\textsf{QLP coefficient}_1 &\leftarrow \texttt{round}(\texttt{-1087.81}) = \texttt{\color{blue}-1088} \\
e &\leftarrow \texttt{-1087.81} - -1088 = \texttt{0.19} \\
e &\leftarrow \texttt{0.19} + \texttt{1.10} \times 2 ^ 9 = \texttt{564.59} \\
\textsf{QLP coefficient}_2 &\leftarrow\texttt{round}(\texttt{564.59}) = \texttt{\color{blue}565} \\
e &\leftarrow \texttt{564.59} - 565 = \texttt{-0.41} \\
e &\leftarrow \texttt{-0.41} + \texttt{-0.31} \times 2 ^ 9 = \texttt{-161.35} \\
\textsf{QLP coefficient}_3 &\leftarrow \texttt{round}(\texttt{-161.35}) = \texttt{\color{blue}-161} \\
e &\leftarrow \texttt{-161.35} - -161 = \texttt{-0.35} \\
\end{align*}
