It depends which optocouplers you will use
Cheap
PC817 has 6Vr,
4N25, TLP250,TLP250, TLP351f ...
? 5Vr, so we need to make some tricks if 5Vcc MPU is used
While I like this 3 pin MPU driving can add another 1N4148 in series or one 1N4148 and transistors to drive those 3 pins MPU outputs at safe lets say 4.3V<5V, while depending on MPU and other tasks it has to do, I wouldn't like stress too much MPU pins with currents from direct optocouplers leds in parallel.
Anyway I've checked my MPU datasheet and its pins should survive even shorting both leds by assident
Made today fast prototyping using classic oldschool methods and have nice development single layer PCB with classic red LEDs which were driven from 9V battery via 2.2k resistors and it looks like this trick with 3 pins driving those 4 H-bridge optocoupler leds works
Need to check all posible 8 input combinations if is it possible to short one side of this H-bridge by assident, but probably not-I mean, assuming proper timing of mosfets gates
Update: With NPWM (NOT PWM) 1 (high) not possible to short circuit any side,
but with NPWM 0 (low) temporary shorts possible, but this is not desired sequence and disabling PWM (1 high in this case) allows choose (set) POS or NEG first than add NPWM if needed.
BTW: However it is interesting that in this datasheet of 5mm THT LED:
http://optoelectronics.liteon.com/upload/download/DS20-2007-0003/S_110_LTW-2S3D8.pdfthey wrote something like this and no Vr value?
8. Reverse voltage (VR) condition is applied for IR test only. The device is not designed for reverse
operation.5VR for 5mm THT yellow led is here:
http://optoelectronics.liteon.com/upload/download/DS-20-99-0254/S_110_LTL2H3KSK.pdfThis is not designed to drive classic leds, but optocouplers, but it looks like that in the term of this 5Vr voltage of some optocouplers input diodes it can make sense drive them in series rather than in parallel with tricky reverse voltages to switch some of them off when only 3 MPU pins are used to drive them in simple H-bridge shown above with brake and bootstrap precharging modes.