/* Copyright (c) 2017 Google Inc.
Written by Andrew Allen */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
opus_int32 opus_projection_ambisonics_encoder_get_size(int channels, int mapping_family)
{ int nb_streams; int nb_coupled_streams; int order_plus_one; int mixing_matrix_rows, mixing_matrix_cols; int demixing_matrix_rows, demixing_matrix_cols;
opus_int32 mixing_matrix_size, demixing_matrix_size;
opus_int32 encoder_size; int ret;
ret = get_streams_from_channels(channels, mapping_family, &nb_streams,
&nb_coupled_streams, &order_plus_one); if (ret != OPUS_OK) return 0;
int opus_projection_ambisonics_encoder_init(OpusProjectionEncoder *st, opus_int32 Fs, int channels, int mapping_family, int *streams, int *coupled_streams, int application)
{
MappingMatrix *mixing_matrix;
MappingMatrix *demixing_matrix;
OpusMSEncoder *ms_encoder; int i; int ret; int order_plus_one; unsignedchar mapping[255];
OpusProjectionEncoder *opus_projection_ambisonics_encoder_create(
opus_int32 Fs, int channels, int mapping_family, int *streams, int *coupled_streams, int application, int *error)
{ int size; int ret;
OpusProjectionEncoder *st;
/* Allocate space for the projection encoder. */
size = opus_projection_ambisonics_encoder_get_size(channels, mapping_family); if (!size) { if (error)
*error = OPUS_ALLOC_FAIL; return NULL;
}
st = (OpusProjectionEncoder *)opus_alloc(size); if (!st)
{ if (error)
*error = OPUS_ALLOC_FAIL; return NULL;
}
/* Initialize projection encoder with provided settings. */
ret = opus_projection_ambisonics_encoder_init(st, Fs, channels,
mapping_family, streams, coupled_streams, application); if (ret != OPUS_OK)
{
opus_free(st);
st = NULL;
} if (error)
*error = ret; return st;
}
int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...)
{
va_list ap;
MappingMatrix *demixing_matrix;
OpusMSEncoder *ms_encoder; int ret = OPUS_OK;
va_start(ap, request); switch(request)
{ case OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*); if (!value)
{ goto bad_arg;
}
*value =
ms_encoder->layout.nb_channels * (ms_encoder->layout.nb_streams
+ ms_encoder->layout.nb_coupled_streams) * sizeof(opus_int16);
} break; case OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST:
{
opus_int32 *value = va_arg(ap, opus_int32*); if (!value)
{ goto bad_arg;
}
*value = demixing_matrix->gain;
} break; case OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST:
{ int i, j, k, l; int nb_input_streams; int nb_output_streams; unsignedchar *external_char;
opus_int16 *internal_short;
opus_int32 external_size;
opus_int32 internal_size;
/* (I/O is in relation to the decoder's perspective). */
nb_input_streams = ms_encoder->layout.nb_streams +
ms_encoder->layout.nb_coupled_streams;
nb_output_streams = ms_encoder->layout.nb_channels;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.