diff options
author | zhaoxiu.zeng <zhaoxiu.zeng@gmail.com> | 2015-02-14 00:51:27 +0800 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-13 18:34:29 +0100 |
commit | 80f13780051fd9afa924e1c0db2eb36701592c75 (patch) | |
tree | 706ed206ddc164db455a9199fe77999c8ddee47d /libavcodec | |
parent | bc0a440e889a874426c2a8d476031e1a9c52fb42 (diff) | |
download | ffmpeg-80f13780051fd9afa924e1c0db2eb36701592c75.tar.gz |
avcodec/wmalosslessdec: optimize sign operation
Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/wmalosslessdec.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 9bd5e7b17b..19165941f1 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -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) { |