{"record":{"id":"4d0697a603fe4d98","repo":"DrKLO/Telegram","slug":"error-encoder-doesn-t-match-decoder-n","errorCode":null,"errorMessage":"Error: encoder doesn't match decoder\\n","messagePattern":"Error: encoder doesn't match decoder\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"TMessagesProj/jni/opus/celt/opus_custom_demo.c","lineNumber":201,"sourceCode":"#endif\n      count++;\n      fwrite(out+skip*channels, sizeof(short), (ret-skip)*channels, fout);\n      skip = 0;\n   }\n   PRINT_MIPS(stderr);\n\n   opus_custom_encoder_destroy(enc);\n   opus_custom_decoder_destroy(dec);\n   fclose(fin);\n   fclose(fout);\n   opus_custom_mode_destroy(mode);\n   free(in);\n   free(out);\n#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH)\n   if (rmsd > 0)\n   {\n      rmsd = sqrt(rmsd/(1.0*frame_size*channels*count));\n      fprintf (stderr, \"Error: encoder doesn't match decoder\\n\");\n      fprintf (stderr, \"RMS mismatch is %f\\n\", rmsd);\n      return 1;\n   } else {\n      fprintf (stderr, \"Encoder matches decoder!!\\n\");\n   }\n#endif\n   return 0;\n}\n\n","sourceCodeStart":183,"sourceCodeEnd":211,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/opus/celt/opus_custom_demo.c#L183-L211","documentation":"Only emitted under #if !(FIXED_POINT && !CUSTOM_MODES) && defined(RESYNTH): after the full encode/decode round trip, the computed RMS difference between input and output samples (rmsd) is > 0, meaning the encoder/decoder pair is not perfectly reconstructive for this input. The message is a self-test failure indicating the Opus build is numerically inconsistent.","triggerScenarios":"rmsd = sqrt(sum((in[i]-out[i])^2) / (frame_size*channels*count)) > 0. This requires RESYNTH to be defined at compile time. Any non-zero divergence between encode-then-decode samples triggers it. Expected in lossy modes; suspicious for a build intended to be transparent at the given bitrate.","commonSituations":"Running the demo on a build with RESYNTH enabled (a developer/QA build, not a release build); low bytes_per_packet causing lossy quantization; a buggy or mis-compiled opus (e.g. mixed fixed/float objects); bit-error or packet-loss simulation introducing divergence.","solutions":["Confirm whether RESYNTH divergence is expected for your bitrate — increase bytes_per_packet and re-test.","Disable the bit-error / packet-loss simulation (use 9-arg form without a high loss rate) to isolate codec behavior.","Rebuild opus cleanly with consistent FIXED_POINT/FLOAT settings across all translation units.","If divergence is expected lossy behavior, treat this message as informational rather than a failure."],"exampleFix":"// before (lossy: small bytes_per_packet causes expected divergence)\n./test_opus_custom 48000 1 480 20 input.sw output.sw\n\n// after (transparent at higher bitrate; divergence ~0)\n./test_opus_custom 48000 1 480 120 input.sw output.sw","handlingStrategy":"validation","validationCode":"// Confirm divergence is expected for the bitrate before treating as failure.\nif (rmsd > RMSD_TOLERANCE) {\n    fprintf(stderr, \"RMS mismatch %f exceeds tolerance for bitrate\\n\", rmsd);\n    return 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rebuild opus with consistent FIXED_POINT/FLOAT settings across all translation units.","Disable bit-error/packet-loss simulation when checking codec transparency.","Increase bytes_per_packet to verify divergence shrinks (lossy behavior is expected at low rates)."],"tags":["opus","resynth","self-test","numerical","audio","build-config","c"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}