2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-05-24 21:20:25 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
|
|
|
|
|
|
iLBC Speech Coder ANSI-C Source Code
|
|
|
|
|
|
|
|
|
|
WebRtcIlbcfix_Decode.c
|
|
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "defines.h"
|
|
|
|
|
#include "simple_lsf_dequant.h"
|
|
|
|
|
#include "decoder_interpolate_lsf.h"
|
|
|
|
|
#include "index_conv_dec.h"
|
|
|
|
|
#include "do_plc.h"
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
#include "enhancer_interface.h"
|
|
|
|
|
#include "xcorr_coef.h"
|
|
|
|
|
#include "lsf_check.h"
|
|
|
|
|
#include "decode_residual.h"
|
|
|
|
|
#include "unpack_bits.h"
|
|
|
|
|
#include "hp_output.h"
|
2016-08-24 02:46:44 -07:00
|
|
|
#include "init_decode.h"
|
2013-10-22 10:27:23 +00:00
|
|
|
#ifndef WEBRTC_ARCH_BIG_ENDIAN
|
2011-07-07 08:21:25 +00:00
|
|
|
#include "swap_bytes.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------*
|
|
|
|
|
* main decoder function
|
|
|
|
|
*---------------------------------------------------------------*/
|
|
|
|
|
|
2016-08-24 02:46:44 -07:00
|
|
|
int WebRtcIlbcfix_DecodeImpl(
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t *decblock, /* (o) decoded signal block */
|
|
|
|
|
const uint16_t *bytes, /* (i) encoded signal bits */
|
2014-12-17 15:23:29 +00:00
|
|
|
IlbcDecoder *iLBCdec_inst, /* (i/o) the decoder state
|
2011-07-07 08:21:25 +00:00
|
|
|
structure */
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t mode /* (i) 0: bad packet, PLC,
|
2011-07-07 08:21:25 +00:00
|
|
|
1: normal */
|
|
|
|
|
) {
|
2016-08-24 02:46:44 -07:00
|
|
|
const int old_mode = iLBCdec_inst->mode;
|
|
|
|
|
const int old_use_enhancer = iLBCdec_inst->use_enhancer;
|
|
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i;
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t order_plus_one;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t last_bit;
|
|
|
|
|
int16_t *data;
|
2011-07-07 08:21:25 +00:00
|
|
|
/* Stack based */
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t decresidual[BLOCKL_MAX];
|
|
|
|
|
int16_t PLCresidual[BLOCKL_MAX + LPC_FILTERORDER];
|
|
|
|
|
int16_t syntdenum[NSUB_MAX*(LPC_FILTERORDER+1)];
|
|
|
|
|
int16_t PLClpc[LPC_FILTERORDER + 1];
|
2013-10-22 10:27:23 +00:00
|
|
|
#ifndef WEBRTC_ARCH_BIG_ENDIAN
|
2013-04-09 00:28:06 +00:00
|
|
|
uint16_t swapped[NO_OF_WORDS_30MS];
|
2012-07-14 00:34:54 +00:00
|
|
|
#endif
|
2011-07-07 08:21:25 +00:00
|
|
|
iLBC_bits *iLBCbits_inst = (iLBC_bits*)PLCresidual;
|
|
|
|
|
|
|
|
|
|
/* Reuse some buffers that are non overlapping in order to save stack memory */
|
|
|
|
|
data = &PLCresidual[LPC_FILTERORDER];
|
|
|
|
|
|
2012-05-24 21:20:25 +00:00
|
|
|
if (mode) { /* the data are good */
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* decode data */
|
|
|
|
|
|
|
|
|
|
/* Unpacketize bits into parameters */
|
|
|
|
|
|
2013-10-22 10:27:23 +00:00
|
|
|
#ifndef WEBRTC_ARCH_BIG_ENDIAN
|
2012-07-14 00:34:54 +00:00
|
|
|
WebRtcIlbcfix_SwapBytes(bytes, iLBCdec_inst->no_of_words, swapped);
|
|
|
|
|
last_bit = WebRtcIlbcfix_UnpackBits(swapped, iLBCbits_inst, iLBCdec_inst->mode);
|
|
|
|
|
#else
|
|
|
|
|
last_bit = WebRtcIlbcfix_UnpackBits(bytes, iLBCbits_inst, iLBCdec_inst->mode);
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Check for bit errors */
|
|
|
|
|
if (iLBCbits_inst->startIdx<1)
|
|
|
|
|
mode = 0;
|
|
|
|
|
if ((iLBCdec_inst->mode==20) && (iLBCbits_inst->startIdx>3))
|
|
|
|
|
mode = 0;
|
|
|
|
|
if ((iLBCdec_inst->mode==30) && (iLBCbits_inst->startIdx>5))
|
|
|
|
|
mode = 0;
|
|
|
|
|
if (last_bit==1)
|
|
|
|
|
mode = 0;
|
|
|
|
|
|
2012-05-24 21:20:25 +00:00
|
|
|
if (mode) { /* No bit errors was detected, continue decoding */
|
2011-07-07 08:21:25 +00:00
|
|
|
/* Stack based */
|
2013-04-09 00:28:06 +00:00
|
|
|
int16_t lsfdeq[LPC_FILTERORDER*LPC_N_MAX];
|
|
|
|
|
int16_t weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX];
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* adjust index */
|
|
|
|
|
WebRtcIlbcfix_IndexConvDec(iLBCbits_inst->cb_index);
|
|
|
|
|
|
|
|
|
|
/* decode the lsf */
|
2013-04-09 00:28:06 +00:00
|
|
|
WebRtcIlbcfix_SimpleLsfDeQ(lsfdeq, (int16_t*)(iLBCbits_inst->lsf), iLBCdec_inst->lpc_n);
|
2011-07-07 08:21:25 +00:00
|
|
|
WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCdec_inst->lpc_n);
|
|
|
|
|
WebRtcIlbcfix_DecoderInterpolateLsp(syntdenum, weightdenum,
|
|
|
|
|
lsfdeq, LPC_FILTERORDER, iLBCdec_inst);
|
|
|
|
|
|
|
|
|
|
/* Decode the residual using the cb and gain indexes */
|
2016-08-24 02:46:44 -07:00
|
|
|
if (!WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst,
|
|
|
|
|
decresidual, syntdenum))
|
|
|
|
|
goto error;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* preparing the plc for a future loss! */
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
WebRtcIlbcfix_DoThePlc(
|
|
|
|
|
PLCresidual, PLClpc, 0, decresidual,
|
|
|
|
|
syntdenum + (LPC_FILTERORDER + 1) * (iLBCdec_inst->nsub - 1),
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
iLBCdec_inst->last_lag, iLBCdec_inst);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* Use the output from doThePLC */
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode == 0) {
|
|
|
|
|
/* the data is bad (either a PLC call
|
|
|
|
|
* was made or a bit error was detected)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* packet loss conceal */
|
|
|
|
|
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
WebRtcIlbcfix_DoThePlc(PLCresidual, PLClpc, 1, decresidual, syntdenum,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
iLBCdec_inst->last_lag, iLBCdec_inst);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl);
|
|
|
|
|
|
|
|
|
|
order_plus_one = LPC_FILTERORDER + 1;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < iLBCdec_inst->nsub; i++) {
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(syntdenum+(i*order_plus_one),
|
|
|
|
|
PLClpc, order_plus_one);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((*iLBCdec_inst).use_enhancer == 1) { /* Enhancer activated */
|
|
|
|
|
|
|
|
|
|
/* Update the filter and filter coefficients if there was a packet loss */
|
|
|
|
|
if (iLBCdec_inst->prev_enh_pl==2) {
|
|
|
|
|
for (i=0;i<iLBCdec_inst->nsub;i++) {
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(&(iLBCdec_inst->old_syntdenum[i*(LPC_FILTERORDER+1)]),
|
|
|
|
|
syntdenum, (LPC_FILTERORDER+1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* post filtering */
|
|
|
|
|
(*iLBCdec_inst).last_lag =
|
|
|
|
|
WebRtcIlbcfix_EnhancerInterface(data, decresidual, iLBCdec_inst);
|
|
|
|
|
|
|
|
|
|
/* synthesis filtering */
|
|
|
|
|
|
|
|
|
|
/* Set up the filter state */
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(&data[-LPC_FILTERORDER], iLBCdec_inst->syntMem, LPC_FILTERORDER);
|
|
|
|
|
|
|
|
|
|
if (iLBCdec_inst->mode==20) {
|
|
|
|
|
/* Enhancer has 40 samples delay */
|
|
|
|
|
i=0;
|
|
|
|
|
WebRtcSpl_FilterARFastQ12(
|
|
|
|
|
data, data,
|
|
|
|
|
iLBCdec_inst->old_syntdenum + (i+iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1),
|
|
|
|
|
LPC_FILTERORDER+1, SUBL);
|
|
|
|
|
|
|
|
|
|
for (i=1; i < iLBCdec_inst->nsub; i++) {
|
|
|
|
|
WebRtcSpl_FilterARFastQ12(
|
|
|
|
|
data+i*SUBL, data+i*SUBL,
|
|
|
|
|
syntdenum+(i-1)*(LPC_FILTERORDER+1),
|
|
|
|
|
LPC_FILTERORDER+1, SUBL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (iLBCdec_inst->mode==30) {
|
|
|
|
|
/* Enhancer has 80 samples delay */
|
|
|
|
|
for (i=0; i < 2; i++) {
|
|
|
|
|
WebRtcSpl_FilterARFastQ12(
|
|
|
|
|
data+i*SUBL, data+i*SUBL,
|
|
|
|
|
iLBCdec_inst->old_syntdenum + (i+4)*(LPC_FILTERORDER+1),
|
|
|
|
|
LPC_FILTERORDER+1, SUBL);
|
|
|
|
|
}
|
|
|
|
|
for (i=2; i < iLBCdec_inst->nsub; i++) {
|
|
|
|
|
WebRtcSpl_FilterARFastQ12(
|
|
|
|
|
data+i*SUBL, data+i*SUBL,
|
|
|
|
|
syntdenum+(i-2)*(LPC_FILTERORDER+1),
|
|
|
|
|
LPC_FILTERORDER+1, SUBL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Save the filter state */
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &data[iLBCdec_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER);
|
|
|
|
|
|
|
|
|
|
} else { /* Enhancer not activated */
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t lag;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* Find last lag (since the enhancer is not called to give this info) */
|
|
|
|
|
lag = 20;
|
|
|
|
|
if (iLBCdec_inst->mode==20) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
lag = WebRtcIlbcfix_XcorrCoef(
|
2011-07-07 08:21:25 +00:00
|
|
|
&decresidual[iLBCdec_inst->blockl-60],
|
|
|
|
|
&decresidual[iLBCdec_inst->blockl-60-lag],
|
|
|
|
|
60,
|
|
|
|
|
80, lag, -1);
|
|
|
|
|
} else {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
lag = WebRtcIlbcfix_XcorrCoef(
|
2011-07-07 08:21:25 +00:00
|
|
|
&decresidual[iLBCdec_inst->blockl-ENH_BLOCKL],
|
|
|
|
|
&decresidual[iLBCdec_inst->blockl-ENH_BLOCKL-lag],
|
|
|
|
|
ENH_BLOCKL,
|
|
|
|
|
100, lag, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store lag (it is needed if next packet is lost) */
|
Match existing type usage better.
This makes a variety of small changes to synchronize bits of code using different types, remove useless code or casts, and add explicit casts in some places previously doing implicit ones. For example:
* Change a few type declarations to better match how the majority of code uses those objects.
* Eliminate "< 0" check for unsigned values.
* Replace "(float)sin(x)", where |x| is also a float, with "sinf(x)", and similar.
* Add casts to uint32_t in many places timestamps were used and the existing code stored signed values into the unsigned objects.
* Remove downcasts when the results would be passed to a larger type, e.g. calling "foo((int16_t)x)" with an int |x| when foo() takes an int instead of an int16_t.
* Similarly, add casts when passing a larger type to a function taking a smaller one.
* Add casts to int16_t when doing something like "int16_t = int16_t + int16_t" as the "+" operation would implicitly upconvert to int, and similar.
* Use "false" instead of "0" for setting a bool.
* Shift a few temp types when doing a multi-stage calculation involving typecasts, so as to put the most logical/semantically correct type possible into the temps. For example, when doing "int foo = int + int; size_t bar = (size_t)foo + size_t;", we might change |foo| to a size_t and move the cast if it makes more sense for |foo| to be represented as a size_t.
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=andrew, asapersson, henrika
Review URL: https://codereview.webrtc.org/1168753002
Cr-Commit-Position: refs/heads/master@{#9419}
2015-06-11 12:55:50 -07:00
|
|
|
(*iLBCdec_inst).last_lag = lag;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
/* copy data and run synthesis filter */
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(data, decresidual, iLBCdec_inst->blockl);
|
|
|
|
|
|
|
|
|
|
/* Set up the filter state */
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(&data[-LPC_FILTERORDER], iLBCdec_inst->syntMem, LPC_FILTERORDER);
|
|
|
|
|
|
|
|
|
|
for (i=0; i < iLBCdec_inst->nsub; i++) {
|
|
|
|
|
WebRtcSpl_FilterARFastQ12(
|
|
|
|
|
data+i*SUBL, data+i*SUBL,
|
|
|
|
|
syntdenum + i*(LPC_FILTERORDER+1),
|
|
|
|
|
LPC_FILTERORDER+1, SUBL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Save the filter state */
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &data[iLBCdec_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(decblock,data,iLBCdec_inst->blockl);
|
|
|
|
|
|
|
|
|
|
/* High pass filter the signal (with upscaling a factor 2 and saturation) */
|
2013-04-09 00:28:06 +00:00
|
|
|
WebRtcIlbcfix_HpOutput(decblock, (int16_t*)WebRtcIlbcfix_kHpOutCoefs,
|
2011-07-07 08:21:25 +00:00
|
|
|
iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx,
|
|
|
|
|
iLBCdec_inst->blockl);
|
|
|
|
|
|
|
|
|
|
WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->old_syntdenum,
|
|
|
|
|
syntdenum, iLBCdec_inst->nsub*(LPC_FILTERORDER+1));
|
|
|
|
|
|
|
|
|
|
iLBCdec_inst->prev_enh_pl=0;
|
|
|
|
|
|
|
|
|
|
if (mode==0) { /* PLC was used */
|
|
|
|
|
iLBCdec_inst->prev_enh_pl=1;
|
|
|
|
|
}
|
2016-08-24 02:46:44 -07:00
|
|
|
|
|
|
|
|
return 0; // Success.
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
// The decoder got sick from eating that data. Reset it and return.
|
|
|
|
|
WebRtcIlbcfix_InitDecode(iLBCdec_inst, old_mode, old_use_enhancer);
|
|
|
|
|
return -1; // Error
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|