35
35
bool flag_wav_looping = false;
36
36
int flag_wav_looping_offset = 0 ;
37
37
int flag_wav_compress = 1 ;
38
+ bool flag_wav_compress_huffman = true;
38
39
int flag_wav_resample = 0 ;
39
40
bool flag_wav_mono = false;
40
41
const int OPUS_SAMPLE_RATE = 48000 ;
@@ -162,8 +163,6 @@ bool wav64_write(const char *infn, const char *outfn, FILE *out, wav_data_t* wav
162
163
} break ;
163
164
164
165
case 1 : { // vadpcm
165
- bool huffman = true;
166
-
167
166
// The state is 16 bytes per channel, but the runtime code requires to
168
167
// always allocate both channels even for mono files.
169
168
placeholder_set_offset (out , 48 , "state_size" );
@@ -212,16 +211,17 @@ bool wav64_write(const char *infn, const char *outfn, FILE *out, wav_data_t* wav
212
211
uint8_t * compbuf = malloc (maxcompbuflen );
213
212
uint8_t * ctxbuf = calloc (HUFF_CONTEXT_LEN , 1 );
214
213
int compbuflen = 0 ;
215
- if (huffman )
214
+ if (flag_wav_compress_huffman ) {
216
215
compbuflen = huffv_compress (dest , nframes * kVADPCMFrameByteSize * wav -> channels , compbuf , maxcompbuflen , ctxbuf , HUFF_CONTEXT_LEN );
217
216
218
- if (flag_verbose )
219
- fprintf (stderr , " huffman compressed %d bytes into %d bytes (ratio: %.1f)\n" ,
220
- nframes * kVADPCMFrameByteSize * wav -> channels , compbuflen ,
221
- 100.0f * compbuflen / (nframes * kVADPCMFrameByteSize * wav -> channels ));
217
+ if (flag_verbose )
218
+ fprintf (stderr , " huffman compressed %d bytes into %d bytes (ratio: %.1f%%)\n" ,
219
+ nframes * kVADPCMFrameByteSize * wav -> channels , compbuflen ,
220
+ 100.0f * compbuflen / (nframes * kVADPCMFrameByteSize * wav -> channels ));
221
+ }
222
222
223
223
uint8_t flags = 0 ;
224
- if (huffman ) flags |= (1 <<0 );
224
+ if (flag_wav_compress_huffman ) flags |= (1 <<0 );
225
225
226
226
struct vadpcm_vector state = {0 };
227
227
w8 (out , kPREDICTORS );
@@ -238,7 +238,7 @@ bool wav64_write(const char *infn, const char *outfn, FILE *out, wav_data_t* wav
238
238
239
239
// Start of samples data
240
240
placeholder_set (out , "samples" );
241
- if (huffman )
241
+ if (flag_wav_compress_huffman )
242
242
fwrite (compbuf , 1 , compbuflen , out );
243
243
else
244
244
fwrite (dest , 1 , nframes * kVADPCMFrameByteSize * wav -> channels , out );
0 commit comments