DrKLO/Telegram · error
Invalid table data in file %s
Error message
Invalid table data in file %s
What it means
While reading a quantization table, read_quant_tables expects exactly 64 integer values per table. After reading the first value successfully, if any subsequent read_text_integer call fails (returns 0), it means the file ended prematurely or contains non-numeric data mid-table. The function reports invalid table data, closes the file, and returns FALSE.
Source
Thrown at TMessagesProj/jni/mozjpeg/rdswitch.c:112
long val;
unsigned int table[DCTSIZE2];
if ((fp = fopen(filename, "r")) == NULL) {
fprintf(stderr, "Can't open table file %s\n", filename);
return FALSE;
}
tblno = 0;
while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */
if (tblno >= NUM_QUANT_TBLS) {
fprintf(stderr, "Too many tables in file %s\n", filename);
fclose(fp);
return FALSE;
}
table[0] = (unsigned int) val;
for (i = 1; i < DCTSIZE2; i++) {
if (! read_text_integer(fp, &val, &termchar)) {
fprintf(stderr, "Invalid table data in file %s\n", filename);
fclose(fp);
return FALSE;
}
table[i] = (unsigned int) val;
}
#if JPEG_LIB_VERSION >= 70
jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
force_baseline);
#else
jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
force_baseline);
#endif
tblno++;
}
if (termchar != EOF) {
fprintf(stderr, "Non-numeric data in file %s\n", filename);
fclose(fp);View on GitHub (pinned to 45ab8f4308)
Solutions
- Ensure each table contains exactly 64 whitespace-separated decimal integers.
- Validate the file format programmatically: count tokens per table block before passing it to cjpeg.
- Regenerate the table file using a script that guarantees 64 values per table.
Example fix
# before (table file with 63 values in one block)
# after (ensure exactly 64 values per table block)
python3 -c "print(' '.join(['%d' % (i+1) for i in range(64)]))" > table.qtl Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate: ensure each table block has exactly 64 integers
#include <stdio.h>
static boolean validate_quant_file(const char *filename) {
FILE *fp = fopen(filename, "r");
if (!fp) return FALSE;
long val; int termchar, vals = 0;
while (read_text_integer(fp, &val, &termchar)) {
vals++;
}
fclose(fp);
return (vals % DCTSIZE2 == 0);
} Prevention
- Generate quantization table files programmatically to guarantee 64 values per table.
- Count tokens per table block using awk or a script before passing to cjpeg.
- Avoid hand-editing table files; use templates and sed for controlled modifications.
When it happens
Trigger: A quantization table file where a table has fewer than 64 values; a non-numeric token appears within a 64-value table block; the file is truncated in the middle of a table definition.
Common situations: Hand-edited table files with missing values; files generated by a script with an off-by-one error in the loop; copy-paste errors that dropped values; encoding issues (BOM, non-ASCII digits).
Related errors
- Non-numeric data in file %s
- Too many tables in file %s
- JPEG quantization tables are numbered 0..%d
- %s: skip region exceeds image height %d\n
- %s: crop dimensions exceed image dimensions %d x %d\n
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/fc13efcba68e0b16.
Report an issue: GitHub.