aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-05-03 18:30:59 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2022-07-07 21:52:52 +0200
commit08e82e5b572b440f4faf160d2eac923ca47a59f8 (patch)
tree90982d829f61e95655469c04f8edb0b457adf7cc
parent5c2fa59f3272360e7df7b69fce722ac06017e371 (diff)
downloadffmpeg-08e82e5b572b440f4faf160d2eac923ca47a59f8.tar.gz
avcodec/smacker: Optimize constant 16bit audio output
Reviewed-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/smacker.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 179c70f1ee..5d94a54179 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -601,7 +601,7 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame,
int i, res, ret;
int unp_size;
int bits, stereo;
- unsigned pred[2], val;
+ unsigned pred[2], val, val2;
if (buf_size <= 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
@@ -672,7 +672,11 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame,
pred[i] = av_bswap16(get_bits(&gb, 16));
for(i = 0; i <= stereo; i++)
*samples++ = pred[i];
- for(; i < unp_size / 2; i++) {
+ unp_size /= 2;
+
+ if (vlc[0 ].table || vlc[ 1].table ||
+ vlc[2*stereo].table || vlc[2*stereo+1].table) {
+ for(; i < unp_size ; i++) {
unsigned idx = 2 * (i & stereo);
if (get_bits_left(&gb) < 0) {
ret = AVERROR_INVALIDDATA;
@@ -691,6 +695,22 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame,
pred[idx / 2] += val;
*samples++ = pred[idx / 2];
}
+ } else if (stereo) {
+ val = 256*values[1] + values[0];
+ val2 = 256*values[3] + values[2];
+ for(; i < unp_size; i+=2) {
+ pred[0] += val;
+ pred[1] += val2;
+ *samples++ = pred[0];
+ *samples++ = pred[1];
+ }
+ } else {
+ val = 256*values[1] + values[0];
+ for(; i < unp_size; i++) {
+ pred[0] += val;
+ *samples++ = pred[0];
+ }
+ }
} else { //8-bit data
for(i = stereo; i >= 0; i--)
pred[i] = get_bits(&gb, 8);