mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/smacker: Avoid code duplication
Besides the obvious advantage of less code this also has a performance impact: For GCC 9 the time spent on one call to smka_decode_frame() for the sample from ticket #2425 decreased from 1693619 to 1498127 decicycles. For Clang 9, it decreased from 1369089 to 1366465 decicycles. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
b2c42f0233
commit
6ffc7be5da
@ -671,37 +671,23 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
|
||||
for(i = 0; i <= stereo; i++)
|
||||
*samples++ = pred[i];
|
||||
for(; i < unp_size / 2; i++) {
|
||||
unsigned idx = 2 * (i & stereo);
|
||||
if (get_bits_left(&gb) < 0) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto error;
|
||||
}
|
||||
if(i & stereo) {
|
||||
if(vlc[2].table)
|
||||
res = get_vlc2(&gb, vlc[2].table, SMKTREE_BITS, 3);
|
||||
if (vlc[idx].table)
|
||||
res = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
|
||||
else
|
||||
res = values[2];
|
||||
res = values[idx];
|
||||
val = res;
|
||||
if(vlc[3].table)
|
||||
res = get_vlc2(&gb, vlc[3].table, SMKTREE_BITS, 3);
|
||||
if (vlc[++idx].table)
|
||||
res = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
|
||||
else
|
||||
res = values[3];
|
||||
res = values[idx];
|
||||
val |= res << 8;
|
||||
pred[1] += val;
|
||||
*samples++ = pred[1];
|
||||
} else {
|
||||
if(vlc[0].table)
|
||||
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
|
||||
else
|
||||
res = values[0];
|
||||
val = res;
|
||||
if(vlc[1].table)
|
||||
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
|
||||
else
|
||||
res = values[1];
|
||||
val |= res << 8;
|
||||
pred[0] += val;
|
||||
*samples++ = pred[0];
|
||||
}
|
||||
pred[idx / 2] += val;
|
||||
*samples++ = pred[idx / 2];
|
||||
}
|
||||
} else { //8-bit data
|
||||
for(i = stereo; i >= 0; i--)
|
||||
@ -709,25 +695,17 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,
|
||||
for(i = 0; i <= stereo; i++)
|
||||
*samples8++ = pred[i];
|
||||
for(; i < unp_size; i++) {
|
||||
unsigned idx = i & stereo;
|
||||
if (get_bits_left(&gb) < 0) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto error;
|
||||
}
|
||||
if(i & stereo){
|
||||
if(vlc[1].table)
|
||||
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
|
||||
if (vlc[idx].table)
|
||||
val = get_vlc2(&gb, vlc[idx].table, SMKTREE_BITS, 3);
|
||||
else
|
||||
res = values[1];
|
||||
pred[1] += res;
|
||||
*samples8++ = pred[1];
|
||||
} else {
|
||||
if(vlc[0].table)
|
||||
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
|
||||
else
|
||||
res = values[0];
|
||||
pred[0] += res;
|
||||
*samples8++ = pred[0];
|
||||
}
|
||||
val = values[idx];
|
||||
pred[idx] += val;
|
||||
*samples8++ = pred[idx];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user