When people speak of a H1B transfer, they are speaking of the rule that allows you to start working for a new employer after their petition is received by the USCIS, as opposed to having to wait for its approval as would be the case if you were outside of the United States. In either context, each employer files its own, independent petition. If you have been counted against the cap, your current employer's cancellation of your visa won't change that fact for your next employer's application.
If your current employer 'cancels' your H1B visa -- another misnomer, as all they can actually do is file a written withdrawal of their petition, with the rest being up to the USCIS -- and your visa is canceled by the USCIS, you will be expected to return home. You cannot "transfer" after that point, as you will no longer be in H1b status. You also go out of status if you are fired.
If the actual concern here is that, if you give notice to work for a new employer, your current employer might request the withdrawal of its petition to try to prevent the transfer, you can consider the possibility of premium processing. There's a significant fee, but the typical processing time for a transfer is cut to fifteen days. That would normally allow your employer to get an answer on its petition, followed by your giving two weeks notice to your employer (at which time it's too late for your employer to harm your transfer) within the space of about a month.

