48#ifdef OJPH_COMPILER_MSVC
50 #define unlikely(x) (x)
52 #define likely(x) __builtin_expect((x), 1)
53 #define unlikely(x) __builtin_expect((x), 0)
92 for (
int i = 0;
i < 2048; ++
i)
146 for (
int i = 0;
i < 2048; ++
i)
210 for (
int i = 5;
i < 33; ++
i)
257 melp->buf_size = buffer_size;
258 melp->remaining_bits = 8;
270 melp->remaining_bits--;
271 if (
melp->remaining_bits == 0) {
273 melp->remaining_bits = (
melp->tmp == 0xFF ? 7 : 8);
283 static const int mel_exp[13] = {0,0,0,1,1,1,2,2,2,3,3,4,5};
323 vlcp->buf = data + buffer_size - 1;
325 vlcp->buf_size = buffer_size;
330 vlcp->last_greater_than_8F =
true;
340 while (
vlcp->used_bits >= 8) {
344 tmp =
vlcp->tmp & 0x7F;
346 if (
likely(tmp != 0x7F)) {
347 tmp =
vlcp->tmp & 0xFF;
349 vlcp->last_greater_than_8F = tmp > 0x8F;
351 vlcp->used_bits -= 8;
354 vlcp->last_greater_than_8F =
false;
356 vlcp->used_bits -= 7;
360 tmp =
vlcp->tmp & 0xFF;
362 vlcp->last_greater_than_8F = tmp > 0x8F;
364 vlcp->used_bits -= 8;
387 OJPH_ERROR(0x00020003,
"mel encoder's buffer is full");
399 OJPH_ERROR(0x00020004,
"vlc encoder's buffer is full");
426 msp->buf_size = buffer_size;
438 if (
msp->pos >=
msp->buf_size)
439 OJPH_ERROR(0x00020005,
"magnitude sign encoder's buffer is full");
445 if (
msp->used_bits >=
msp->max_bits)
448 msp->max_bits = (
msp->tmp == 0xFF) ? 7 : 8;
461 int t =
msp->max_bits -
msp->used_bits;
462 msp->tmp |= (0xFF & ((1U <<
t) - 1)) <<
msp->used_bits;
464 if (
msp->tmp != 0xFF)
466 if (
msp->pos >=
msp->buf_size)
467 OJPH_ERROR(0x00020006,
"magnitude sign encoder's buffer is full");
471 else if (
msp->max_bits == 7)
475#define ZERO _mm512_setzero_epi32()
476#define ONE _mm512_set1_epi32(1)
479static void print_epi32(
const char *msg, __m512i &val)
481 uint32_t A[16] = {0};
483 _mm512_store_epi32(A, val);
486 for (
int i = 0; i < 16; ++i) {
545 _mm512_set_epi32(14, 12, 10, 8, 6, 4, 2, 0, 14, 12, 10, 8, 6, 4, 2, 0),
546 _mm512_set_epi32(15, 13, 11, 9, 7, 5, 3, 1, 15, 13, 11, 9, 7, 5, 3, 1),
855 auto mask = 1 << (
i + 1);
927 }
else if (
u_q[
i] > 2 &&
u_q[
i + 1] > 0) {
1010 const int ms_size = (16384 * 16 + 14) / 15;
1027 ui32 p = 30 - missing_msbs;
1039 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
1043 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15
1047 for (
ui32 i = 0;
i < 32; ++
i) {
1075 for (
ui32 y = 0; y < height; y += 2)
1086 ui32 *
sp = buf + y * stride;
1103 if (y + 1 < height) {
void get_buffer(ui32 needed_bytes, coded_lists *&p)
static bool uvlc_init_tables()
Initializes uvlc_tbl0 and uvlc_tbl1 tables.
static bool vlc_init_tables()
Initializes vlc_tbl0 and vlc_tbl1 tables, from table0.h and table1.h.
ui16 vlc_tbl0[1024]
vlc_tbl0 contains decoding information for initial row of quads
ui16 vlc_tbl1[1024]
vlc_tbl1 contains decoding information for non-initial row of quads
static void ms_terminate(ms_struct *msp)
static void update_lep(ui32 x, __m512i &prev_e_val_vec, __m512i *eq_vec, __m512i *e_val_vec, const __m512i left_shift)
static int ulvc_cwd_suf[33]
static int ulvc_cwd_suf_len[33]
static void proc_mel_encode2(mel_struct *melp, __m512i &cq_vec, __m512i &rho_vec, __m512i u_q_vec, ui32 ignore, const __m512i right_shift)
static void proc_mel_encode1(mel_struct *melp, __m512i &cq_vec, __m512i &rho_vec, __m512i u_q_vec, ui32 ignore, const __m512i right_shift)
static void proc_vlc_encode2(vlc_struct *vlcp, ui32 *tuple, ui32 *u_q, ui32 ignore)
static void vlc_encode(vlc_struct *vlcp, int cwd, int cwd_len)
static __m512i cal_eps_vec(__m512i *eq_vec, __m512i &u_q_vec, __m512i &e_qmax_vec)
static void terminate_mel_vlc(mel_struct *melp, vlc_struct *vlcp)
static void proc_pixel(__m512i *src_vec, ui32 p, __m512i *eq_vec, __m512i *s_vec, __m512i &rho_vec, __m512i &e_qmax_vec)
static void mel_init(dec_mel_st *melp, ui8 *bbuf, int lcup, int scup)
Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read addre...
static void proc_ms_encode(ms_struct *msp, __m512i &tuple_vec, __m512i &uq_vec, __m512i &rho_vec, __m512i *s_vec)
static void rotate_matrix(__m512i *matrix)
static void ms_init(ms_struct *msp, ui32 buffer_size, ui8 *data)
static void ms_encode(ms_struct *msp, ui32 cwd, int cwd_len)
static int ulvc_cwd_pre_len[33]
static __m512i proc_cq2(ui32 x, __m512i *cx_val_vec, __m512i &rho_vec, const __m512i right_shift)
static int ulvc_cwd_pre[33]
static void mel_encode(mel_struct *melp, bool bit)
static void mel_emit_bit(mel_struct *melp, int v)
static void proc_vlc_encode1(vlc_struct *vlcp, ui32 *tuple, ui32 *u_q, ui32 ignore)
static __m512i cal_tuple(__m512i &cq_vec, __m512i &rho_vec, __m512i &eps_vec, ui32 *vlc_tbl)
static void update_lcxp(ui32 x, __m512i &prev_cx_val_vec, __m512i &rho_vec, __m512i *cx_val_vec, const __m512i left_shift)
static bool tables_initialized
static __m512i proc_cq1(ui32 x, __m512i *cx_val_vec, __m512i &rho_vec, const __m512i right_shift)
static void vlc_init(vlc_struct *vlcp, ui32 buffer_size, ui8 *data)
void ojph_encode_codeblock_avx512(ui32 *buf, ui32 missing_msbs, ui32 num_passes, ui32 width, ui32 height, ui32 stride, ui32 *lengths, ojph::mem_elastic_allocator *elastic, ojph::coded_lists *&coded)
@ X86_CPU_EXT_LEVEL_AVX512
static ui32 population_count(ui32 val)
OJPH_EXPORT int get_cpu_ext_level()
#define OJPH_ERROR(t,...)
bool last_greater_than_8F