Commit af50ce92 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Implements OPUS_MULTISTREAM_{EN|DE}CODER_GET_STATE

Untested
parent c63cc122
......@@ -443,6 +443,25 @@ int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...)
}
}
break;
case OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST:
{
int s;
opus_int32 stream_id;
OpusEncoder **value;
stream_id = va_arg(ap, opus_int32);
if (stream_id<0 || stream_id >= st->layout.nb_streams)
ret = OPUS_BAD_ARG;
value = va_arg(ap, OpusEncoder**);
for (s=0;s<stream_id;s++)
{
if (s < st->layout.nb_coupled_streams)
ptr += align(coupled_size);
else
ptr += align(mono_size);
}
*value = (OpusEncoder*)ptr;
}
break;
default:
ret = OPUS_UNIMPLEMENTED;
break;
......@@ -728,7 +747,6 @@ int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...)
case OPUS_GET_FINAL_RANGE_REQUEST:
{
int s;
/* This only works for int32* params, but that's all we have right now */
opus_uint32 *value = va_arg(ap, opus_uint32*);
for (s=0;s<st->layout.nb_streams;s++)
{
......@@ -748,7 +766,6 @@ int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...)
case OPUS_RESET_STATE:
{
int s;
/* This only works for int32* params, but that's all we have right now */
for (s=0;s<st->layout.nb_streams;s++)
{
OpusDecoder *dec;
......@@ -764,6 +781,25 @@ int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...)
}
}
break;
case OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST:
{
int s;
opus_int32 stream_id;
OpusDecoder **value;
stream_id = va_arg(ap, opus_int32);
if (stream_id<0 || stream_id >= st->layout.nb_streams)
ret = OPUS_BAD_ARG;
value = va_arg(ap, OpusDecoder**);
for (s=0;s<stream_id;s++)
{
if (s < st->layout.nb_coupled_streams)
ptr += align(coupled_size);
else
ptr += align(mono_size);
}
*value = (OpusDecoder*)ptr;
}
break;
default:
ret = OPUS_UNIMPLEMENTED;
break;
......
......@@ -38,6 +38,15 @@
typedef struct OpusMSEncoder OpusMSEncoder;
typedef struct OpusMSDecoder OpusMSDecoder;
#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr)))
#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr)))
#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120
#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y)
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y)
OPUS_EXPORT OpusMSEncoder *opus_multistream_encoder_create(
opus_int32 Fs, /**< Sampling rate of input signal (Hz) */
int channels, /**< Number of channels (1/2) in input signal */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment