{"record":{"id":"7d88ed8a0e450f7b","repo":"DrKLO/Telegram","slug":"sampling-rate-must-be-8000-12000-16000-24000-o","errorCode":null,"errorMessage":"Sampling rate must be 8000, 12000, 16000, 24000, or 48000\\n","messagePattern":"Sampling rate must be 8000, 12000, 16000, 24000, or 48000\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"TMessagesProj/jni/opus/src/opus_compare.c","lineNumber":205,"sourceCode":"  int      max_compare;\n  if(_argc<3||_argc>6){\n    fprintf(stderr,\"Usage: %s [-s] [-r rate2] <file1.sw> <file2.sw>\\n\",\n     _argv[0]);\n    return EXIT_FAILURE;\n  }\n  nchannels=1;\n  if(strcmp(_argv[1],\"-s\")==0){\n    nchannels=2;\n    _argv++;\n  }\n  rate=48000;\n  ybands=NBANDS;\n  yfreqs=NFREQS;\n  downsample=1;\n  if(strcmp(_argv[1],\"-r\")==0){\n    rate=atoi(_argv[2]);\n    if(rate!=8000&&rate!=12000&&rate!=16000&&rate!=24000&&rate!=48000){\n      fprintf(stderr,\n       \"Sampling rate must be 8000, 12000, 16000, 24000, or 48000\\n\");\n      return EXIT_FAILURE;\n    }\n    downsample=48000/rate;\n    switch(rate){\n      case  8000:ybands=13;break;\n      case 12000:ybands=15;break;\n      case 16000:ybands=17;break;\n      case 24000:ybands=19;break;\n    }\n    yfreqs=NFREQS/downsample;\n    _argv+=2;\n  }\n  fin1=fopen(_argv[1],\"rb\");\n  if(fin1==NULL){\n    fprintf(stderr,\"Error opening '%s'.\\n\",_argv[1]);\n    return EXIT_FAILURE;\n  }","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/opus/src/opus_compare.c#L187-L223","documentation":"The -r rate2 value is not one of the five Opus-supported sample rates. opus_compare only operates at 8000, 12000, 16000, 24000, or 48000 Hz because those are the only rates for which the psychoacoustic band tables (ybands) are defined.","triggerScenarios":"rate (from atoi(_argv[2]) after -r) is not in {8000,12000,16000,24000,48000}. The tool then exits before opening any file. The default rate is 48000 if -r is omitted.","commonSituations":"Passing a common-but-unsupported rate like 22050 or 44100; passing a non-numeric string that atoi turns into 0; typo in the rate.","solutions":["Use one of the five supported rates with -r.","Resample the input .sw files to a supported rate before comparing.","Omit -r entirely to default to 48000."],"exampleFix":"// before\n./opus_compare -r 44100 file1.sw file2.sw\n\n// after\n./opus_compare -r 48000 file1.sw file2.sw","handlingStrategy":"validation","validationCode":"// Validate the rate against the allowed set.\nif (rate!=8000&&rate!=12000&&rate!=16000&&rate!=24000&&rate!=48000) {\n    fprintf(stderr, \"Sampling rate must be 8000, 12000, 16000, 24000, or 48000\\n\");\n    return EXIT_FAILURE;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resample inputs to one of the five supported rates before comparing.","Omit -r to default to 48000.","Validate the -r argument is numeric before atoi."],"tags":["opus","opus-compare","sample-rate","validation","audio","c"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}