1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

qcelpdec: K&R formatting cosmetics

Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
Asen Lekov 2011-12-19 01:32:54 +02:00 committed by Diego Biurrun
parent 2fd291846b
commit 25c2d76b68

View File

@ -44,8 +44,7 @@
#undef NDEBUG
#include <assert.h>
typedef enum
{
typedef enum {
I_F_Q = -1, /**< insufficient frame quality */
SILENCE,
RATE_OCTAVE,
@ -54,8 +53,7 @@ typedef enum
RATE_FULL
} qcelp_packet_rate;
typedef struct
{
typedef struct {
AVFrame avframe;
GetBitContext gb;
qcelp_packet_rate bitrate;
@ -132,9 +130,9 @@ static int decode_lspf(QCELPContext *q, float *lspf)
for (i = 0; i < 10; i++) {
q->predictor_lspf[i] =
lspf[i] = (q->frame.lspv[i] ? QCELP_LSP_SPREAD_FACTOR
: -QCELP_LSP_SPREAD_FACTOR)
+ predictors[i] * QCELP_LSP_OCTAVE_PREDICTOR
+ (i + 1) * ((1 - QCELP_LSP_OCTAVE_PREDICTOR)/11);
: -QCELP_LSP_SPREAD_FACTOR) +
predictors[i] * QCELP_LSP_OCTAVE_PREDICTOR +
(i + 1) * ((1 - QCELP_LSP_OCTAVE_PREDICTOR) / 11);
}
smooth = q->octave_count < 10 ? .875 : 0.1;
} else {
@ -147,8 +145,8 @@ static int decode_lspf(QCELPContext *q, float *lspf)
for (i = 0; i < 10; i++) {
q->predictor_lspf[i] =
lspf[i] = (i + 1) * ( 1 - erasure_coeff)/11
+ erasure_coeff * predictors[i];
lspf[i] = (i + 1) * (1 - erasure_coeff) / 11 +
erasure_coeff * predictors[i];
}
smooth = 0.125;
}
@ -199,8 +197,8 @@ static int decode_lspf(QCELPContext *q, float *lspf)
*
* TIA/EIA/IS-733 2.4.6.2
*/
static void decode_gain_and_index(QCELPContext *q,
float *gain) {
static void decode_gain_and_index(QCELPContext *q, float *gain)
{
int i, subframes_count, g1[16];
float slope;
@ -240,8 +238,8 @@ static void decode_gain_and_index(QCELPContext *q,
}
} else if (q->bitrate != SILENCE) {
if (q->bitrate == RATE_OCTAVE) {
g1[0] = 2 * q->frame.cbgain[0]
+ av_clip((q->prev_g1[0] + q->prev_g1[1]) / 2 - 5, 0, 54);
g1[0] = 2 * q->frame.cbgain[0] +
av_clip((q->prev_g1[0] + q->prev_g1[1]) / 2 - 5, 0, 54);
subframes_count = 8;
} else {
assert(q->bitrate == I_F_Q);
@ -353,15 +351,16 @@ static void compute_svector(QCELPContext *q, const float *gain,
// FIR filter
fir_filter_value = 0.0;
for (j = 0; j < 10; j++)
fir_filter_value += qcelp_rnd_fir_coefs[j ]
* (rnd[-j ] + rnd[-20+j]);
fir_filter_value += qcelp_rnd_fir_coefs[j] *
(rnd[-j] + rnd[-20+j]);
fir_filter_value += qcelp_rnd_fir_coefs[10] * rnd[-10];
*cdn_vector++ = tmp_gain * fir_filter_value;
rnd++;
}
}
memcpy(q->rnd_fir_filter_mem, q->rnd_fir_filter_mem + 160, 20 * sizeof(float));
memcpy(q->rnd_fir_filter_mem, q->rnd_fir_filter_mem + 160,
20 * sizeof(float));
break;
case RATE_OCTAVE:
cbseed = q->first16bits;
@ -396,8 +395,7 @@ static void compute_svector(QCELPContext *q, const float *gain,
*
* TIA/EIA/IS-733 2.4.8.3, 2.4.8.6
*/
static void apply_gain_ctrl(float *v_out, const float *v_ref,
const float *v_in)
static void apply_gain_ctrl(float *v_out, const float *v_ref, const float *v_in)
{
int i;
@ -473,12 +471,10 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
int i;
const float *v_synthesis_filtered, *v_pre_filtered;
if(q->bitrate >= RATE_HALF ||
q->bitrate == SILENCE ||
if (q->bitrate >= RATE_HALF || q->bitrate == SILENCE ||
(q->bitrate == I_F_Q && (q->prev_bitrate >= RATE_HALF))) {
if (q->bitrate >= RATE_HALF) {
// Compute gain & lag for the whole frame.
for (i = 0; i < 4; i++) {
q->pitch_gain[i] = q->frame.plag[i] ? (q->frame.pgain[i] + 1) * 0.25 : 0.0;
@ -519,8 +515,7 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector)
apply_gain_ctrl(cdn_vector, v_synthesis_filtered, v_pre_filtered);
} else {
memcpy(q->pitch_synthesis_filter_mem, cdn_vector + 17,
143 * sizeof(float));
memcpy(q->pitch_synthesis_filter_mem, cdn_vector + 17, 143 * sizeof(float));
memcpy(q->pitch_pre_filter_mem, cdn_vector + 17, 143 * sizeof(float));
memset(q->pitch_gain, 0, sizeof(q->pitch_gain));
memset(q->pitch_lag, 0, sizeof(q->pitch_lag));
@ -616,7 +611,8 @@ static qcelp_packet_rate buf_size2bitrate(const int buf_size)
*
* TIA/EIA/IS-733 2.4.8.7.1
*/
static qcelp_packet_rate determine_bitrate(AVCodecContext *avctx, const int buf_size,
static qcelp_packet_rate determine_bitrate(AVCodecContext *avctx,
const int buf_size,
const uint8_t **buf)
{
qcelp_packet_rate bitrate;
@ -652,8 +648,8 @@ static qcelp_packet_rate determine_bitrate(AVCodecContext *avctx, const int buf_
static void warn_insufficient_frame_quality(AVCodecContext *avctx,
const char *message)
{
av_log(avctx, AV_LOG_WARNING, "Frame #%d, IFQ: %s\n", avctx->frame_number,
message);
av_log(avctx, AV_LOG_WARNING, "Frame #%d, IFQ: %s\n",
avctx->frame_number, message);
}
static void postfilter(QCELPContext *q, float *samples, float *lpc)
@ -682,7 +678,8 @@ static void postfilter(QCELPContext *q, float *samples, float *lpc)
ff_tilt_compensation(&q->postfilter_tilt_mem, 0.3, pole_out + 10, 160);
ff_adaptive_gain_control(samples, pole_out + 10,
ff_dot_productf(q->formant_mem + 10, q->formant_mem + 10, 160),
ff_dot_productf(q->formant_mem + 10,
q->formant_mem + 10, 160),
160, 0.9375, &q->postfilter_agc_mem);
}
@ -719,8 +716,8 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
if (q->bitrate > SILENCE) {
const QCELPBitmap *bitmaps = qcelp_unpacking_bitmaps_per_rate[q->bitrate];
const QCELPBitmap *bitmaps_end = qcelp_unpacking_bitmaps_per_rate[q->bitrate]
+ qcelp_unpacking_bitmaps_lengths[q->bitrate];
const QCELPBitmap *bitmaps_end = qcelp_unpacking_bitmaps_per_rate[q->bitrate] +
qcelp_unpacking_bitmaps_lengths[q->bitrate];
uint8_t *unpacked_data = (uint8_t *)&q->frame;
init_get_bits(&q->gb, buf, 8 * buf_size);
@ -759,7 +756,6 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,
goto erasure;
}
apply_pitch_filters(q, outbuffer);
if (q->bitrate == I_F_Q) {
@ -776,8 +772,7 @@ erasure:
formant_mem = q->formant_mem + 10;
for (i = 0; i < 4; i++) {
interpolate_lpc(q, quantized_lspf, lpc, i);
ff_celp_lp_synthesis_filterf(formant_mem, lpc, outbuffer + i * 40, 40,
10);
ff_celp_lp_synthesis_filterf(formant_mem, lpc, outbuffer + i * 40, 40, 10);
formant_mem += 40;
}
@ -795,8 +790,7 @@ erasure:
return buf_size;
}
AVCodec ff_qcelp_decoder =
{
AVCodec ff_qcelp_decoder = {
.name = "qcelp",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_QCELP,