mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/sheervideo: Simplify creating VLC table
ff_init_vlc_from_lengths() can be used to offload the computation of the codes; it also needn't check whether the codes are already properly ordered (they are). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
f31bf4a1f9
commit
d4a4a6747d
@ -1784,11 +1784,10 @@ static void decode_rgb(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb)
|
|||||||
static av_cold int build_vlc(VLC *vlc, const SheerTable *table)
|
static av_cold int build_vlc(VLC *vlc, const SheerTable *table)
|
||||||
{
|
{
|
||||||
const uint8_t *cur = table->lens;
|
const uint8_t *cur = table->lens;
|
||||||
uint16_t codes[1024];
|
|
||||||
uint8_t lens[1024];
|
uint8_t lens[1024];
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
|
|
||||||
for (unsigned step = 1, len = 1, index = 0; len > 0; len += step) {
|
for (int step = 1, len = 1; len > 0; len += step) {
|
||||||
unsigned new_count = count;
|
unsigned new_count = count;
|
||||||
|
|
||||||
if (len == 16) {
|
if (len == 16) {
|
||||||
@ -1797,17 +1796,13 @@ static av_cold int build_vlc(VLC *vlc, const SheerTable *table)
|
|||||||
} else
|
} else
|
||||||
new_count += *cur++;
|
new_count += *cur++;
|
||||||
|
|
||||||
for (; count < new_count; count++) {
|
for (; count < new_count; count++)
|
||||||
codes[count] = index >> (32 - len);
|
|
||||||
index += 1U << (32 - len);
|
|
||||||
lens[count] = len;
|
lens[count] = len;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_free_vlc(vlc);
|
ff_free_vlc(vlc);
|
||||||
return init_vlc(vlc, SHEER_VLC_BITS, count,
|
return ff_init_vlc_from_lengths(vlc, SHEER_VLC_BITS, count,
|
||||||
lens, sizeof(*lens), sizeof(*lens),
|
lens, sizeof(*lens), NULL, 0, 0, 0, 0, NULL);
|
||||||
codes, sizeof(*codes), sizeof(*codes), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_frame(AVCodecContext *avctx,
|
static int decode_frame(AVCodecContext *avctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user