MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decode_decorrelation_matrix

Function decode_decorrelation_matrix

libavcodec/wmaprodec.c:755–798  ·  view source on GitHub ↗

*@brief Calculate a decorrelation matrix from the bitstream parameters. *@param s codec context *@param chgroup channel group for which the matrix needs to be calculated */

Source from the content-addressed store, hash-verified

753 *@param chgroup channel group for which the matrix needs to be calculated
754 */
755static void decode_decorrelation_matrix(WMAProDecodeCtx *s,
756 WMAProChannelGrp *chgroup)
757{
758 int i;
759 int offset = 0;
760 int8_t rotation_offset[WMAPRO_MAX_CHANNELS * WMAPRO_MAX_CHANNELS];
761 memset(chgroup->decorrelation_matrix, 0, s->nb_channels *
762 s->nb_channels * sizeof(*chgroup->decorrelation_matrix));
763
764 for (i = 0; i < chgroup->num_channels * (chgroup->num_channels - 1) >> 1; i++)
765 rotation_offset[i] = get_bits(&s->gb, 6);
766
767 for (i = 0; i < chgroup->num_channels; i++)
768 chgroup->decorrelation_matrix[chgroup->num_channels * i + i] =
769 get_bits1(&s->gb) ? 1.0 : -1.0;
770
771 for (i = 1; i < chgroup->num_channels; i++) {
772 int x;
773 for (x = 0; x < i; x++) {
774 int y;
775 for (y = 0; y < i + 1; y++) {
776 float v1 = chgroup->decorrelation_matrix[x * chgroup->num_channels + y];
777 float v2 = chgroup->decorrelation_matrix[i * chgroup->num_channels + y];
778 int n = rotation_offset[offset + x];
779 float sinv;
780 float cosv;
781
782 if (n < 32) {
783 sinv = sin64[n];
784 cosv = sin64[32 - n];
785 } else {
786 sinv = sin64[64 - n];
787 cosv = -sin64[n - 32];
788 }
789
790 chgroup->decorrelation_matrix[y + x * chgroup->num_channels] =
791 (v1 * sinv) - (v2 * cosv);
792 chgroup->decorrelation_matrix[y + i * chgroup->num_channels] =
793 (v1 * cosv) + (v2 * sinv);
794 }
795 }
796 offset += i;
797 }
798}
799
800/**
801 *@brief Decode channel transformation parameters

Callers 1

decode_channel_transformFunction · 0.85

Calls 2

get_bits1Function · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected