aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-19 22:49:57 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-19 22:53:35 +0100
commitb11edbd289e454a173914049ae4643a5498520d9 (patch)
tree2b34c6bf71819bbe156b155404820c78778f572d /libavcodec
parent31fb029f2d9e7facb5eb2899b0c8bdb16df17997 (diff)
downloadffmpeg-b11edbd289e454a173914049ae4643a5498520d9.tar.gz
avcodec/dss_sp: Avoid a slow division and modulo in the pitch_lag calculation
Also check the combined_pitch for validity (which is needed to keep the behavior identical in the error case) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/dss_sp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c
index 462418bca4..42ba1c42c2 100644
--- a/libavcodec/dss_sp.c
+++ b/libavcodec/dss_sp.c
@@ -50,6 +50,7 @@ typedef struct DssSpFrame {
} DssSpFrame;
typedef struct DssSpContext {
+ AVCodecContext *avctx;
int32_t excitation[288 + 6];
int32_t history[187];
DssSpFrame fparam;
@@ -296,6 +297,7 @@ static av_cold int dss_sp_decode_init(AVCodecContext *avctx)
memset(p->history, 0, sizeof(p->history));
p->pulse_dec_mode = 1;
+ p->avctx = avctx;
return 0;
}
@@ -400,10 +402,15 @@ static void dss_sp_unpack_coeffs(DssSpContext *p, const uint8_t *src)
combined_pitch /= 151;
- for (i = 1; i < SUBFRAMES; i++) {
+ for (i = 1; i < SUBFRAMES - 1; i++) {
fparam->pitch_lag[i] = combined_pitch % 48;
combined_pitch /= 48;
}
+ if (combined_pitch > 47) {
+ av_log (p->avctx, AV_LOG_WARNING, "combined_pitch was too large\n");
+ combined_pitch = 0;
+ }
+ fparam->pitch_lag[i] = combined_pitch;
pitch_lag = fparam->pitch_lag[0];
for (i = 1; i < SUBFRAMES; i++) {