avcodec/sheervideo: Improve creating VLC tables
Don't needlessly copy an array around; don't create a table with default symbols; and use smaller types to save stack space: The longest code here is 16 bits, so one can store the codes in this type. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
11a6347f9e
commit
1bff2f3d92
@ -1782,25 +1782,20 @@ static void decode_rgb(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
|
|||||||
|
|
||||||
static int build_vlc(VLC *vlc, const uint8_t *len, int count)
|
static int build_vlc(VLC *vlc, const uint8_t *len, int count)
|
||||||
{
|
{
|
||||||
uint32_t codes[1024];
|
uint16_t codes[1024];
|
||||||
uint8_t bits[1024];
|
unsigned index;
|
||||||
uint16_t syms[1024];
|
|
||||||
uint64_t index;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
codes[i] = index >> (32 - len[i]);
|
codes[i] = index >> (32 - len[i]);
|
||||||
bits[i] = len[i];
|
index += 1U << (32 - len[i]);
|
||||||
syms[i] = i;
|
|
||||||
index += 1ULL << (32 - len[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_free_vlc(vlc);
|
ff_free_vlc(vlc);
|
||||||
return ff_init_vlc_sparse(vlc, 12, count,
|
return init_vlc(vlc, 12, count,
|
||||||
bits, sizeof(*bits), sizeof(*bits),
|
len, sizeof(*len), sizeof(*len),
|
||||||
codes, sizeof(*codes), sizeof(*codes),
|
codes, sizeof(*codes), sizeof(*codes), 0);
|
||||||
syms, sizeof(*syms), sizeof(*syms), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_frame(AVCodecContext *avctx,
|
static int decode_frame(AVCodecContext *avctx,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user