MCPcopy Create free account
hub / github.com/zhuker/lamejs / putbits2

Method putbits2

src/main/java/mp3/BitStream.java:100–128  ·  view source on GitHub ↗

write j bits into the bit stream

(final LameInternalFlags gfc, final int val, int j)

Source from the content-addressed store, hash-verified

98 * write j bits into the bit stream
99 */
100 private void putbits2(final LameInternalFlags gfc, final int val, int j) {
101 assert (j < MAX_LENGTH - 2);
102
103 while (j > 0) {
104 int k;
105 if (bufBitIdx == 0) {
106 bufBitIdx = 8;
107 bufByteIdx++;
108 assert (bufByteIdx < Lame.LAME_MAXMP3BUFFER);
109 assert (gfc.header[gfc.w_ptr].write_timing >= totbit);
110 if (gfc.header[gfc.w_ptr].write_timing == totbit) {
111 putheader_bits(gfc);
112 }
113 buf[bufByteIdx] = 0;
114 }
115
116 k = Math.min(j, bufBitIdx);
117 j -= k;
118
119 bufBitIdx -= k;
120
121 assert (j < MAX_LENGTH);
122 /* 32 too large on 32 bit machines */
123 assert (bufBitIdx < MAX_LENGTH);
124
125 buf[bufByteIdx] |= ((val >> j) << bufBitIdx);
126 totbit += k;
127 }
128 }
129
130 /**
131 * write j bits into the bit stream, ignoring frame headers

Callers 4

drain_into_ancillaryMethod · 0.95
huffman_coder_count1Method · 0.95
HuffmancodeMethod · 0.95
writeMainDataMethod · 0.95

Calls 1

putheader_bitsMethod · 0.95

Tested by

no test coverage detected