mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-03 05:10:03 +02:00
avcodec/vp3: Remove code duplication when initializing Theora VLCs
theora_init_huffman_tables() does essentially the same as ff_init_vlcs_from_lengths(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
802fc678b2
commit
420476ec78
@ -2319,20 +2319,6 @@ static av_cold int init_frames(Vp3DecodeContext *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int theora_init_huffman_tables(VLC *vlc, const HuffTable *huff)
|
|
||||||
{
|
|
||||||
uint32_t code = 0, codes[32];
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < huff->nb_entries; i++) {
|
|
||||||
codes[i] = code >> (31 - huff->entries[i].len);
|
|
||||||
code += 0x80000000U >> huff->entries[i].len;
|
|
||||||
}
|
|
||||||
return ff_init_vlc_sparse(vlc, 11, huff->nb_entries,
|
|
||||||
&huff->entries[0].len, sizeof(huff->entries[0]), 1,
|
|
||||||
codes, 4, 4,
|
|
||||||
&huff->entries[0].sym, sizeof(huff->entries[0]), 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static av_cold int vp3_decode_init(AVCodecContext *avctx)
|
static av_cold int vp3_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
Vp3DecodeContext *s = avctx->priv_data;
|
Vp3DecodeContext *s = avctx->priv_data;
|
||||||
@ -2460,7 +2446,12 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
|
for (i = 0; i < FF_ARRAY_ELEMS(s->coeff_vlc); i++) {
|
||||||
ret = theora_init_huffman_tables(&s->coeff_vlc[i], &s->huffman_table[i]);
|
const HuffTable *tab = &s->huffman_table[i];
|
||||||
|
|
||||||
|
ret = ff_init_vlc_from_lengths(&s->coeff_vlc[i], 11, tab->nb_entries,
|
||||||
|
&tab->entries[0].len, sizeof(*tab->entries),
|
||||||
|
&tab->entries[0].sym, sizeof(*tab->entries), 1,
|
||||||
|
0, 0, avctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user