{"record":{"id":"5e36c7088075dd07","repo":"DrKLO/Telegram","slug":"s-can-t-read-qtable-file","errorCode":null,"errorMessage":"%s: can't read qtable file\n","messagePattern":"(.+?): can't read qtable file\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/cjpeg.c","lineNumber":624,"sourceCode":"      usage();                  /* bogus switch */\n    }\n  }\n\n  /* Post-switch-scanning cleanup */\n\n  if (for_real) {\n\n    /* Set quantization tables for selected quality. */\n    /* Some or all may be overridden if -qtables is present. */\n    if (qualityarg != NULL)     /* process -quality if it was present */\n      if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) {\n        fprintf(stderr, \"%s: can't set quality ratings\\n\", progname);\n        usage();\n      }\n\n    if (qtablefile != NULL)     /* process -qtables if it was present */\n      if (! read_quant_tables(cinfo, qtablefile, force_baseline)) {\n        fprintf(stderr, \"%s: can't read qtable file\\n\", progname);\n        usage();\n      }\n\n    if (qslotsarg != NULL)      /* process -qslots if it was present */\n      if (!set_quant_slots(cinfo, qslotsarg))\n        usage();\n\n    /* set_quality_ratings sets default subsampling, so the explicit\n       subsampling must be set after it */\n    if (samplearg != NULL)      /* process -sample if it was present */\n      if (! set_sample_factors(cinfo, samplearg)) {\n        fprintf(stderr, \"%s: can't set sample factors\\n\", progname);\n        usage();\n      }\n\n#ifdef C_PROGRESSIVE_SUPPORTED\n    if (simple_progressive)     /* process -progressive; -scans can override */\n      jpeg_simple_progression(cinfo);","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/cjpeg.c#L606-L642","documentation":"cjpeg calls read_quant_tables() to load -qtables from a plain-ASCII file of 64 decimal integers per table (comments with # allowed, up to NUM_QUANT_TBLS tables). It returns FALSE if the file cannot be opened, contains too many tables, has invalid/non-numeric data, or non-numeric residue after a table. The wrapper prints this message and calls usage().","triggerScenarios":"Passing -qtables <file> where the file is missing, unreadable, contains fewer/more than 64 values per table, more than NUM_QUANT_TBLS tables, or any non-numeric token not part of a # comment.","commonSituations":"Hand-authored quant tables with formatting errors; binary files mistakenly passed as text quant tables; truncated downloads; line-ending or locale issues that inject unexpected characters; a wrong path pointing at a non-table file.","solutions":["Open the file in a text editor and confirm it is 1..NUM_QUANT_TBLS tables of exactly 64 integer values each, whitespace-separated, comments starting with #.","Verify the path exists and is readable; check the error printed just before this line by read_quant_tables (e.g. 'Invalid table data', 'Too many tables', 'Non-numeric data').","Regenerate the table file with a script that emits 64 ints per table to avoid off-by-one counts."],"exampleFix":"# before: file has 63 values per table -> read_quant_tables fails\ncjpeg -qtables bad.txt input.ppm > out.jpg\n# after: ensure exactly 64 values per table\npython3 -c \"print(' '.join(['16']*64))\" > good.txt\ncjpeg -qtables good.txt input.ppm > out.jpg","handlingStrategy":"validation","validationCode":"#!/bin/sh\n# Validate a quant-table file: 64 ints per table, max NUM_QUANT_TBLS (4) tables\nqfile=\"$1\"\n[ -r \"$qfile\" ] || { echo \"qtable file unreadable: $qfile\" >&2; exit 1; }\nawk '\n{ for (i=1;i<=NF;i++) if ($i !~ /^[-+]?[0-9]+$/) {print \"non-numeric: \"$i>\"/dev/stderr\"; exit 1} n+=NF }\nEND{ if (n==0 || n%64!=0 || n/64>4) {print \"bad table count/values: \"n>\"/dev/stderr\"; exit 1} }\n' \"$qfile\" || exit 1\ncjpeg -qtables \"$qfile\" in.ppm > out.jpg","typeGuard":"// n/a: file-content validation in the caller.","tryCatchPattern":"if ! cjpeg -qtables \"$QFILE\" in.ppm > out.jpg 2>/tmp/e; then\n  grep -Eq \"can't read qtable file|Invalid table data|Too many tables|Non-numeric data\" /tmp/e && { echo \"fix qtable file: $QFILE\"; exit 1; }\nfi","preventionTips":["Generate quant-table files programmatically so counts are always exactly 64 per table.","Diff your table file against a known-good one when an error appears.","Keep table assets under version control."],"tags":["mozjpeg","cjpeg","file-parse","quant-table","qtables"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}