DRED integration work in progress
This commit is contained in:
parent
0edb3954e8
commit
8623012b30
5 changed files with 23 additions and 7 deletions
|
@ -47,7 +47,7 @@ void dred_deinit_decoder(DREDDec *dec)
|
|||
DRED_rdovae_destroy_decoder(dec->rdovae_dec);
|
||||
}
|
||||
|
||||
void dred_decode_redundancy_package(DREDDec *dec, float *features, opus_uint8 *bytes, int num_bytes)
|
||||
void dred_decode_redundancy_package(DREDDec *dec, float *features, const opus_uint8 *bytes, int num_bytes)
|
||||
{
|
||||
const opus_uint16 *p0 = DRED_rdovae_get_p0_pointer();
|
||||
const opus_uint16 *quant_scales = DRED_rdovae_get_quant_scales_pointer();
|
||||
|
@ -64,7 +64,7 @@ void dred_decode_redundancy_package(DREDDec *dec, float *features, opus_uint8 *b
|
|||
celt_assert(DRED_NUM_REDUNDANCY_FRAMES % 2 == 0);
|
||||
|
||||
/* decode initial state and initialize RDOVAE decoder */
|
||||
ec_dec_init(&dec->ec_dec, bytes, num_bytes);
|
||||
ec_dec_init(&dec->ec_dec, (unsigned char*)bytes, num_bytes);
|
||||
dred_decode_state(&dec->ec_dec, state);
|
||||
DRED_rdovae_dec_init_states(dec->rdovae_dec, state);
|
||||
|
||||
|
|
|
@ -39,4 +39,4 @@ void init_dred_decoder(DREDDec *dec);
|
|||
|
||||
void dred_deinit_decoder(DREDDec *dec);
|
||||
|
||||
void dred_decode_redundancy_package(DREDDec *dec, float *features, opus_uint8 *bytes, int num_bytes);
|
||||
void dred_decode_redundancy_package(DREDDec *dec, float *features, const opus_uint8 *bytes, int num_bytes);
|
||||
|
|
|
@ -38,7 +38,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "lpcnet.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NEURAL_FEC
|
||||
#include "dred_encoder.h"
|
||||
#include "dred_decoder.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
@ -258,6 +261,10 @@ typedef struct {
|
|||
#ifdef NEURAL_PLC
|
||||
/* FIXME: We should include the state struct directly to preserve the state shadow copy property. */
|
||||
LPCNetPLCState *lpcnet;
|
||||
#ifdef ENABLE_NEURAL_FEC
|
||||
DREDDec dred_decoder;
|
||||
float fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES];
|
||||
#endif
|
||||
#endif
|
||||
} silk_PLC_struct;
|
||||
|
||||
|
|
|
@ -1054,6 +1054,8 @@ int opus_decoder_dred_input(OpusDecoder *st, const unsigned char *data,
|
|||
|
||||
/* Get the padding section of the packet. */
|
||||
ret = opus_packet_parse_impl(data, len, 0, NULL, frames, size, NULL, NULL, &data0, &len0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
data = data0;
|
||||
len = len0;
|
||||
/* Scan extensions in order until we find the earliest frame with DRED data. */
|
||||
|
@ -1085,6 +1087,9 @@ int opus_decoder_dred_input(OpusDecoder *st, const unsigned char *data,
|
|||
}
|
||||
if (payload != NULL)
|
||||
{
|
||||
silk_decoder_state *silk_dec;
|
||||
silk_dec = (silk_decoder_state*)((char*)st+st->silk_dec_offset);
|
||||
dred_decode_redundancy_package(&silk_dec->sPLC.dred_decoder, silk_dec->sPLC.fec_features, payload, payload_len);
|
||||
/* Found something -- do the decoding. */
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -2179,15 +2179,19 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
|
|||
}
|
||||
/* Count ToC and redundancy */
|
||||
ret += 1+redundancy_bytes;
|
||||
if (0) {
|
||||
opus_extension_data extension = {127, 0, (const unsigned char *)"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 50};
|
||||
#ifdef ENABLE_NEURAL_FEC
|
||||
if (1) {
|
||||
DREDEnc *dred = &((silk_encoder*)silk_enc)->state_Fxx[0].sCmn.dred_encoder;
|
||||
opus_extension_data extension = {127, 0, dred->ec_buffer, dred->ec_encoder.storage};
|
||||
ret = opus_packet_pad_impl(data, ret, max_data_bytes, !st->use_vbr, &extension, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
RESTORE_STACK;
|
||||
return OPUS_INTERNAL_ERROR;
|
||||
}
|
||||
} else if (!st->use_vbr)
|
||||
} else
|
||||
#endif
|
||||
if (!st->use_vbr)
|
||||
{
|
||||
if (opus_packet_pad(data, ret, max_data_bytes) != OPUS_OK)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue