TAG: context-aware encoding