So, when you open both the source and the encoded video using *the same player* (PotPlayer), they have the same colours (provided you set colour correction to off). But if you open them in different players (one in PotPlayer, one in MeGui), they look different. Clearly then, the two players are disagreeing with each other about how the colours should be rendered on screen.
poisondeathray's explanation for that is probably correct... Or it could be a bug in either MeGui or PotPlayer. Nothing points to AviSynth as causing the problem.
Hope that helps.