mirror of https://git.videolan.org/git/ffmpeg.git
avcodec/vlc: Use union of uint8_t and uint16_t in VLC_MULTI_ELEM
It is more natural and simplifies writing these arrays. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
4ab82d2fb6
commit
a8e518e3a7
|
@ -542,7 +542,7 @@ static inline int BS_FUNC(read_vlc_multi)(BSCTX *bc, uint8_t dst[8],
|
||||||
unsigned idx = BS_FUNC(peek)(bc, bits);
|
unsigned idx = BS_FUNC(peek)(bc, bits);
|
||||||
int ret, nb_bits, code, n = Jtable[idx].len;
|
int ret, nb_bits, code, n = Jtable[idx].len;
|
||||||
if (Jtable[idx].num) {
|
if (Jtable[idx].num) {
|
||||||
AV_COPY64U(dst, Jtable[idx].val);
|
AV_COPY64U(dst, Jtable[idx].val8);
|
||||||
ret = Jtable[idx].num;
|
ret = Jtable[idx].num;
|
||||||
} else {
|
} else {
|
||||||
code = table[idx].sym;
|
code = table[idx].sym;
|
||||||
|
|
|
@ -440,8 +440,8 @@ static void add_level(VLC_MULTI_ELEM *table, const int is16bit,
|
||||||
code = curcode + (buf[t].code >> curlen);
|
code = curcode + (buf[t].code >> curlen);
|
||||||
newlimit = curlimit - l;
|
newlimit = curlimit - l;
|
||||||
l += curlen;
|
l += curlen;
|
||||||
if (is16bit) AV_WN16(info.val+2*curlevel, sym);
|
if (is16bit) info.val16[curlevel] = sym;
|
||||||
else info.val[curlevel] = sym&0xFF;
|
else info.val8[curlevel] = sym&0xFF;
|
||||||
|
|
||||||
if (curlevel) { // let's not add single entries
|
if (curlevel) { // let's not add single entries
|
||||||
uint32_t val = code >> (32 - numbits);
|
uint32_t val = code >> (32 - numbits);
|
||||||
|
@ -468,7 +468,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
|
||||||
{
|
{
|
||||||
int minbits, maxbits, max;
|
int minbits, maxbits, max;
|
||||||
unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, };
|
unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, };
|
||||||
VLC_MULTI_ELEM info = { { 0, }, 0, 0, };
|
VLC_MULTI_ELEM info = { 0 };
|
||||||
int count0 = 0;
|
int count0 = 0;
|
||||||
|
|
||||||
for (int j = 0; j < 1<<numbits; j++) {
|
for (int j = 0; j < 1<<numbits; j++) {
|
||||||
|
@ -500,9 +500,9 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
|
||||||
table[j].len = single->table[j].len;
|
table[j].len = single->table[j].len;
|
||||||
table[j].num = single->table[j].len > 0 ? 1 : 0;
|
table[j].num = single->table[j].len > 0 ? 1 : 0;
|
||||||
if (is16bit)
|
if (is16bit)
|
||||||
AV_WN16(table[j].val, single->table[j].sym);
|
table[j].val16[0] = single->table[j].sym;
|
||||||
else
|
else
|
||||||
table[j].val[0] = single->table[j].sym;
|
table[j].val8[0] = single->table[j].sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_level(table, is16bit, nb_codes, numbits, buf,
|
add_level(table, is16bit, nb_codes, numbits, buf,
|
||||||
|
|
|
@ -40,7 +40,10 @@ typedef struct VLC {
|
||||||
} VLC;
|
} VLC;
|
||||||
|
|
||||||
typedef struct VLC_MULTI_ELEM {
|
typedef struct VLC_MULTI_ELEM {
|
||||||
uint8_t val[VLC_MULTI_MAX_SYMBOLS];
|
union {
|
||||||
|
uint8_t val8[VLC_MULTI_MAX_SYMBOLS];
|
||||||
|
uint16_t val16[VLC_MULTI_MAX_SYMBOLS / 2];
|
||||||
|
};
|
||||||
int8_t len; // -31,32
|
int8_t len; // -31,32
|
||||||
uint8_t num;
|
uint8_t num;
|
||||||
} VLC_MULTI_ELEM;
|
} VLC_MULTI_ELEM;
|
||||||
|
|
Loading…
Reference in New Issue