ref: 44a24be844d616ea1c824e2b676612c474f8e5e4
parent: 056b062e8874931b0c71074bc74866703009015b
author: Mans Rullgard <mans@mansr.com>
date: Fri Jul 31 14:57:14 EDT 2020
spectrogram: replace non-text string literals with arrays
--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -87,26 +87,65 @@
#define secs(cols) \
((double)(cols) * p->step_size * p->block_steps / effp->in_signal.rate)
-static unsigned char const alt_palette[] =
- "\0\0\0\0\0\3\0\1\5\0\1\10\0\1\12\0\1\13\0\1\16\1\2\20\1\2\22\1\2\25\1\2\26"
- "\1\2\30\1\3\33\1\3\35\1\3\37\1\3\40\1\3\"\1\3$\1\3%\1\3'\1\3(\1\3*\1\3,\1"
- "\3.\1\3/\1\3""0\1\3""2\1\3""4\2\3""6\4\3""8\5\3""9\7\3;\11\3=\13\3?\16\3"
- "A\17\2B\21\2D\23\2F\25\2H\27\2J\30\2K\32\2M\35\2O\40\2Q$\2S(\2U+\2W0\2Z3"
- "\2\\7\2_;\2a>\2cB\2eE\2hI\2jM\2lQ\2nU\2pZ\2r_\2tc\2uh\2vl\2xp\3zu\3|z\3}"
- "~\3~\203\3\200\207\3\202\214\3\204\220\3\205\223\3\203\226\3\200\230\3~\233"
- "\3|\236\3z\240\3x\243\3u\246\3s\251\3q\253\3o\256\3m\261\3j\263\3h\266\3"
- "f\272\3b\274\3^\300\3Z\303\3V\307\3R\312\3N\315\3J\321\3F\324\3C\327\3>\333"
- "\3:\336\3""6\342\3""2\344\3/\346\7-\350\15,\352\21+\354\27*\355\33)\356\40"
- "(\360&'\362*&\364/$\3654#\3669#\370>!\372C\40\374I\40\374O\"\374V&\374]*"
- "\374d,\374k0\374r3\374z7\375\201;\375\210>\375\217B\375\226E\375\236I\375"
- "\245M\375\254P\375\261T\375\267X\375\274\\\375\301a\375\306e\375\313i\375"
- "\320m\376\325q\376\332v\376\337z\376\344~\376\351\202\376\356\206\376\363"
- "\213\375\365\217\374\366\223\373\367\230\372\367\234\371\370\241\370\371"
- "\245\367\371\252\366\372\256\365\372\263\364\373\267\363\374\274\361\375"
- "\300\360\375\305\360\376\311\357\376\314\357\376\317\360\376\321\360\376"
- "\324\360\376\326\360\376\330\360\376\332\361\377\335\361\377\337\361\377"
- "\341\361\377\344\361\377\346\362\377\350\362\377\353";
-#define alt_palette_len ((array_length(alt_palette) - 1) / 3)
+static const unsigned char alt_palette[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x05,
+ 0x00, 0x01, 0x08, 0x00, 0x01, 0x0a, 0x00, 0x01, 0x0b,
+ 0x00, 0x01, 0x0e, 0x01, 0x02, 0x10, 0x01, 0x02, 0x12,
+ 0x01, 0x02, 0x15, 0x01, 0x02, 0x16, 0x01, 0x02, 0x18,
+ 0x01, 0x03, 0x1b, 0x01, 0x03, 0x1d, 0x01, 0x03, 0x1f,
+ 0x01, 0x03, 0x20, 0x01, 0x03, 0x22, 0x01, 0x03, 0x24,
+ 0x01, 0x03, 0x25, 0x01, 0x03, 0x27, 0x01, 0x03, 0x28,
+ 0x01, 0x03, 0x2a, 0x01, 0x03, 0x2c, 0x01, 0x03, 0x2e,
+ 0x01, 0x03, 0x2f, 0x01, 0x03, 0x30, 0x01, 0x03, 0x32,
+ 0x01, 0x03, 0x34, 0x02, 0x03, 0x36, 0x04, 0x03, 0x38,
+ 0x05, 0x03, 0x39, 0x07, 0x03, 0x3b, 0x09, 0x03, 0x3d,
+ 0x0b, 0x03, 0x3f, 0x0e, 0x03, 0x41, 0x0f, 0x02, 0x42,
+ 0x11, 0x02, 0x44, 0x13, 0x02, 0x46, 0x15, 0x02, 0x48,
+ 0x17, 0x02, 0x4a, 0x18, 0x02, 0x4b, 0x1a, 0x02, 0x4d,
+ 0x1d, 0x02, 0x4f, 0x20, 0x02, 0x51, 0x24, 0x02, 0x53,
+ 0x28, 0x02, 0x55, 0x2b, 0x02, 0x57, 0x30, 0x02, 0x5a,
+ 0x33, 0x02, 0x5c, 0x37, 0x02, 0x5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, 0xf1, 0xff, 0xe6, 0xf2, 0xff, 0xe8,
+};
+#define alt_palette_len (array_length(alt_palette) / 3)
static int getopts(sox_effect_t * effp, int argc, char **argv)
{
@@ -412,18 +451,25 @@
static void make_palette(priv_t const * p, png_color * palette)
{
+ static const unsigned char black[] = { 0x00, 0x00, 0x00 };
+ static const unsigned char dgrey[] = { 0x3f, 0x3f, 0x3f };
+ static const unsigned char mgrey[] = { 0x7f, 0x7f, 0x7f };
+ static const unsigned char lgrey[] = { 0xbf, 0xbf, 0xbf };
+ static const unsigned char white[] = { 0xff, 0xff, 0xff };
+ static const unsigned char lbgnd[] = { 0xdd, 0xd8, 0xd0 };
+ static const unsigned char mbgnd[] = { 0xdf, 0xdf, 0xdf };
int i;
if (p->light_background) {
- memcpy(palette++, (p->monochrome)? "\337\337\337":"\335\330\320", (size_t)3);
- memcpy(palette++, "\0\0\0" , (size_t)3);
- memcpy(palette++, "\077\077\077", (size_t)3);
- memcpy(palette++, "\077\077\077", (size_t)3);
+ memcpy(palette++, p->monochrome ? mbgnd : lbgnd, 3);
+ memcpy(palette++, black, 3);
+ memcpy(palette++, dgrey, 3);
+ memcpy(palette++, dgrey, 3);
} else {
- memcpy(palette++, "\0\0\0" , (size_t)3);
- memcpy(palette++, "\377\377\377", (size_t)3);
- memcpy(palette++, "\277\277\277", (size_t)3);
- memcpy(palette++, "\177\177\177", (size_t)3);
+ memcpy(palette++, black, 3);
+ memcpy(palette++, white, 3);
+ memcpy(palette++, lgrey, 3);
+ memcpy(palette++, mgrey, 3);
}
for (i = 0; i < p->spectrum_points; ++i) {
double c[3], x = (double)i / (p->spectrum_points - 1);
@@ -474,24 +520,46 @@
}
}
-static const Bytef fixed[] =
- "x\332eT\241\266\2450\fDVV>Y\371$re%2\237\200|2\22YY\211D\"+\337'<y\345\312"
- "\375\fd\345f\222\224\313\236\235{\270\344L\247a\232\4\246\351\201d\230\222"
- "\304D\364^ \352\362S\"m\347\311\237\237\27\64K\243\2302\265\35\v\371<\363y"
- "\354_\226g\354\214)e \2458\341\17\20J4\215[z<\271\277\367\0\63\64@\177\330c"
- "\227\204 Ir.\5$U\200\260\224\326S\17\200=\\k\20QA\334%\342\20*\303P\234\211"
- "\366\36#\370R\276_\316s-\345\222Dlz\363my*;\217\373\346z\267\343\236\364\246"
- "\236\365\2419\305p\333\267\23(\207\265\333\233\325Y\342\243\265\357\262\215"
- "\263t\271$\276\226ea\271.\367&\320\347\202_\234\27\377\345\222\253?\3422\364"
- "\207y\256\236\229\331\33\f\376\227\266\"\356\253j\366\363\347\334US\34]\371?"
- "\255\371\336\372z\265v\34\226\247\32\324\217\334\337\317U4\16\316{N\370\31"
- "\365\357iL\231y\33y\264\211D7\337\4\244\261\220D\346\1\261\357\355>\3\342"
- "\223\363\0\303\277\f[\214A,p\34`\255\355\364\37\372\224\342\277\f\207\255\36"
- "_V\7\34\241^\316W\257\177\b\242\300\34\f\276\33?/9_\331f\346\36\25Y)\2301"
- "\257\2414|\35\365\237\3424k\3\244\3\242\261\6\b\275>z$\370\215:\270\363w\36/"
- "\265kF\v\20o6\242\301\364\336\27\325\257\321\364fs\231\215G\32=\257\305Di"
- "\304^\177\304R\364Q=\225\373\33\320\375\375\372\200\337\37\374}\334\337\20"
- "\364\310(]\304\267b\177\326Yrj\312\277\373\233\37\340";
+static const Bytef fixed[] = {
+ 0x78, 0xda, 0x65, 0x54, 0xa1, 0xb6, 0xa5, 0x30, 0x0c, 0x44, 0x56, 0x56,
+ 0x3e, 0x59, 0xf9, 0x24, 0x72, 0x65, 0x25, 0x32, 0x9f, 0x80, 0x7c, 0x32,
+ 0x12, 0x59, 0x59, 0x89, 0x44, 0x22, 0x2b, 0xdf, 0x27, 0x3c, 0x79, 0xe5,
+ 0xca, 0xfd, 0x0c, 0x64, 0xe5, 0x66, 0x92, 0x94, 0xcb, 0x9e, 0x9d, 0x7b,
+ 0xb8, 0xe4, 0x4c, 0xa7, 0x61, 0x9a, 0x04, 0xa6, 0xe9, 0x81, 0x64, 0x98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0xc5, 0x44, 0x69, 0xc4, 0x5e, 0x7f, 0xc4, 0x52, 0xf4, 0x51,
+ 0x3d, 0x95, 0xfb, 0x1b, 0xd0, 0xfd, 0xfd, 0xfa, 0x80, 0xdf, 0x1f, 0xfc,
+ 0x7d, 0xdc, 0xdf, 0x10, 0xf4, 0xc8, 0x28, 0x5d, 0xc4, 0xb7, 0x62, 0x7f,
+ 0xd6, 0x59, 0x72, 0x6a, 0xca, 0xbf, 0xfb, 0x9b, 0x1f, 0xe0,
+};
static unsigned char * font;
#define font_x 5
#define font_y 12
@@ -575,7 +643,7 @@
}
lsx_debug("signal-max=%g", p->max);
font = lsx_malloc(font_len);
- assert(uncompress(font, &font_len, fixed, sizeof(fixed)-1) == Z_OK);
+ assert(uncompress(font, &font_len, fixed, sizeof(fixed)) == Z_OK);
make_palette(p, palette);
memset(pixels, Background, cols * rows * sizeof(*pixels));
png_init_io(png, file);