{"record":{"id":"abf53159398fa0fc","repo":"DrKLO/Telegram","slug":"jpeg-quantization-tables-are-numbered-0-d","errorCode":null,"errorMessage":"JPEG quantization tables are numbered 0..%d\n","messagePattern":"JPEG quantization tables are numbered 0\\.\\.(.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/rdswitch.c","lineNumber":590,"sourceCode":"set_quant_slots (j_compress_ptr cinfo, char *arg)\n/* Process a quantization-table-selectors parameter string, of the form\n *     N[,N,...]\n * If there are more components than parameters, the last value is replicated.\n */\n{\n  int val = 0;                  /* default table # */\n  int ci;\n  char ch;\n\n  for (ci = 0; ci < MAX_COMPONENTS; ci++) {\n    if (*arg) {\n      ch = ',';                 /* if not set by sscanf, will be ',' */\n      if (sscanf(arg, \"%d%c\", &val, &ch) < 1)\n        return FALSE;\n      if (ch != ',')            /* syntax check */\n        return FALSE;\n      if (val < 0 || val >= NUM_QUANT_TBLS) {\n        fprintf(stderr, \"JPEG quantization tables are numbered 0..%d\\n\",\n                NUM_QUANT_TBLS-1);\n        return FALSE;\n      }\n      cinfo->comp_info[ci].quant_tbl_no = val;\n      while (*arg && *arg++ != ','); /* advance to next segment of arg\n                                        string */\n    } else {\n      /* reached end of parameter, set remaining components to last table */\n      cinfo->comp_info[ci].quant_tbl_no = val;\n    }\n  }\n  return TRUE;\n}\n\n\nGLOBAL(boolean)\nset_sample_factors (j_compress_ptr cinfo, char *arg)\n/* Process a sample-factors parameter string, of the form","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/rdswitch.c#L572-L608","documentation":"The set_quant_slots function processes the -qslots argument, which maps color components to quantization table indices. JPEG supports NUM_QUANT_TBLS tables (typically 4, numbered 0-3). If any table index in the argument is negative or >= NUM_QUANT_TBLS, the function prints this error and returns FALSE. This validates the component-to-table mapping before compression begins.","triggerScenarios":"Passing -qslots with a value outside 0..NUM_QUANT_TBLS-1 (typically 0..3). For example 'cjpeg -qslots 4 image.bmp' or '-qslots 0,5' where 5 exceeds the table limit. The sscanf parses the integer and the bounds check fires.","commonSituations":"Misunderstanding the number of available quantization tables; passing a 1-based index instead of 0-based; using a table number that was defined in a different build or library version; typos in the argument string.","solutions":["Use only table indices 0 through NUM_QUANT_TBLS-1 (typically 0-3).","Remember indices are 0-based: 0=luminance, 1=chrominance is the standard mapping.","For a standard YCbCr image, -qslots 0,1,1 maps Y to table 0 and Cb/Cr to table 1."],"exampleFix":"# before\ncjpeg -qslots 0,5 image.bmp > out.jpg\n# after\ncjpeg -qslots 0,1,1 image.bmp > out.jpg","handlingStrategy":"validation","validationCode":"// Pre-validate qslots argument before calling set_quant_slots\nstatic boolean validate_qslots_arg(const char *arg) {\n  const char *p = arg;\n  while (*p) {\n    int val;\n    char ch = ',';\n    if (sscanf(p, \"%d%c\", &val, &ch) < 1) return FALSE;\n    if (val < 0 || val >= NUM_QUANT_TBLS) return FALSE;\n    while (*p && *p++ != ',') ;\n  }\n  return TRUE;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only table indices 0 to NUM_QUANT_TBLS-1 (typically 0-3).","Remember indices are 0-based.","For standard YCbCr: -qslots 0,1,1 is the default luminance/chrominance mapping.","Validate each comma-separated value is in range before passing."],"tags":["validation","quantization","argument-error","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}