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

avcodec/wmalosslessdec: optimize sign operation

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
zhaoxiu.zeng 2015-02-14 00:51:27 +08:00 committed by Michael Niedermayer
parent bc0a440e88
commit 80f1378005

View File

@ -175,6 +175,8 @@ typedef struct WmallDecodeCtx {
int channel_coeffs[WMALL_MAX_CHANNELS][WMALL_BLOCK_MAX_SIZE];
} WmallDecodeCtx;
/** Get sign of integer (1 for positive, -1 for negative and 0 for zero) */
#define WMASIGN(x) ((x > 0) - (x < 0))
static av_cold int decode_init(AVCodecContext *avctx)
{
@ -631,22 +633,14 @@ static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
for (i = 0; i < order * num_channels; i++)
s->mclms_coeffs[i + ich * order * num_channels] +=
s->mclms_updates[s->mclms_recent + i];
for (j = 0; j < ich; j++) {
if (s->channel_residues[j][icoef] > 0)
s->mclms_coeffs_cur[ich * num_channels + j] += 1;
else if (s->channel_residues[j][icoef] < 0)
s->mclms_coeffs_cur[ich * num_channels + j] -= 1;
}
for (j = 0; j < ich; j++)
s->mclms_coeffs_cur[ich * num_channels + j] += WMASIGN(s->channel_residues[j][icoef]);
} else if (pred_error < 0) {
for (i = 0; i < order * num_channels; i++)
s->mclms_coeffs[i + ich * order * num_channels] -=
s->mclms_updates[s->mclms_recent + i];
for (j = 0; j < ich; j++) {
if (s->channel_residues[j][icoef] > 0)
s->mclms_coeffs_cur[ich * num_channels + j] -= 1;
else if (s->channel_residues[j][icoef] < 0)
s->mclms_coeffs_cur[ich * num_channels + j] += 1;
}
for (j = 0; j < ich; j++)
s->mclms_coeffs_cur[ich * num_channels + j] -= WMASIGN(s->channel_residues[j][icoef]);
}
}
@ -658,11 +652,7 @@ static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
else if (s->channel_residues[ich][icoef] < -range)
s->mclms_prevvalues[s->mclms_recent] = -range;
s->mclms_updates[s->mclms_recent] = 0;
if (s->channel_residues[ich][icoef] > 0)
s->mclms_updates[s->mclms_recent] = 1;
else if (s->channel_residues[ich][icoef] < 0)
s->mclms_updates[s->mclms_recent] = -1;
s->mclms_updates[s->mclms_recent] = WMASIGN(s->channel_residues[ich][icoef]);
}
if (s->mclms_recent == 0) {
@ -724,12 +714,7 @@ static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int input)
}
s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
if (!input)
s->cdlms[ich][ilms].lms_updates[recent] = 0;
else if (input < 0)
s->cdlms[ich][ilms].lms_updates[recent] = -s->update_speed[ich];
else
s->cdlms[ich][ilms].lms_updates[recent] = s->update_speed[ich];
s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich];
s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2;
s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1;
@ -773,9 +758,6 @@ static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
s->update_speed[ich] = 8;
}
/** Get sign of integer (1 for positive, -1 for negative and 0 for zero) */
#define WMASIGN(x) ((x > 0) - (x < 0))
static void revert_cdlms(WmallDecodeCtx *s, int ch,
int coef_begin, int coef_end)
{