History

L3_huffman: special case for linbits=0, ~10% speedup

lieff committed 7 years ago

Commit eb485bc1 parent 128614f1 file · +56 −25Browse files

Unified · Split

minimp3.h+56−25
@@ -767,41 +767,72 @@ static void L3_huffman(float *dst, bs_t *bs, const L3_gr_info_t *gr_info, const · 766 unmodified lines
767767 int sfb_cnt = gr_info->region_count[ireg++];
768768 const int16_t *codebook = tabs + tabindex[tab_num];
769769 int linbits = g_linbits[tab_num];
770− do
770+ if (linbits)
771771 {
772− np = *sfb++ / 2;
773− pairs_to_decode = MINIMP3_MIN(big_val_cnt, np);
774− one = *scf++;
775772 do
776773 {
777− int j, w = 5;
778− int leaf = codebook[PEEK_BITS(w)];
779− while (leaf < 0)
774+ np = *sfb++ / 2;
775+ pairs_to_decode = MINIMP3_MIN(big_val_cnt, np);
776+ one = *scf++;
777+ do
780778 {
781− FLUSH_BITS(w);
782− w = leaf & 7;
783− leaf = codebook[PEEK_BITS(w) - (leaf >> 3)];
784− }
785− FLUSH_BITS(leaf >> 8);
779+ int j, w = 5;
780+ int leaf = codebook[PEEK_BITS(w)];
781+ while (leaf < 0)
782+ {
783+ FLUSH_BITS(w);
784+ w = leaf & 7;
785+ leaf = codebook[PEEK_BITS(w) - (leaf >> 3)];
786+ }
787+ FLUSH_BITS(leaf >> 8);
786788
787− for (j = 0; j < 2; j++, dst++, leaf >>= 4)
789+ for (j = 0; j < 2; j++, dst++, leaf >>= 4)
790+ {
791+ int lsb = leaf & 0x0F;
792+ if (lsb == 15)
793+ {
794+ lsb += PEEK_BITS(linbits);
795+ FLUSH_BITS(linbits);
796+ CHECK_BITS;
797+ *dst = one*L3_pow_43(lsb)*((int32_t)bs_cache < 0 ? -1: 1);
798+ } else
799+ {
800+ *dst = g_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
801+ }
802+ FLUSH_BITS(lsb ? 1 : 0);
803+ }
804+ CHECK_BITS;
805+ } while (--pairs_to_decode);
806+ } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
807+ } else
808+ {
809+ do
810+ {
811+ np = *sfb++ / 2;
812+ pairs_to_decode = MINIMP3_MIN(big_val_cnt, np);
813+ one = *scf++;
814+ do
788815 {
789− int lsb = leaf & 0x0F;
790− if (lsb == 15 && linbits)
816+ int j, w = 5;
817+ int leaf = codebook[PEEK_BITS(w)];
818+ while (leaf < 0)
791819 {
792− lsb += PEEK_BITS(linbits);
793− FLUSH_BITS(linbits);
794− CHECK_BITS;
795− *dst = one*L3_pow_43(lsb)*((int32_t)bs_cache < 0 ? -1: 1);
796− } else
820+ FLUSH_BITS(w);
821+ w = leaf & 7;
822+ leaf = codebook[PEEK_BITS(w) - (leaf >> 3)];
823+ }
824+ FLUSH_BITS(leaf >> 8);
825+
826+ for (j = 0; j < 2; j++, dst++, leaf >>= 4)
797827 {
828+ int lsb = leaf & 0x0F;
798829 *dst = g_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
830+ FLUSH_BITS(lsb ? 1 : 0);
799831 }
800− FLUSH_BITS(lsb ? 1 : 0);
801− }
802− CHECK_BITS;
803− } while (--pairs_to_decode);
804− } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
832+ CHECK_BITS;
833+ } while (--pairs_to_decode);
834+ } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
835+ }
805836 }
806837
807838 for (np = 1 - big_val_cnt;; dst += 4)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t