Takes a raw input stream containing frames with correct timestamps but
possibly out of order and inserts additional show-existing-frame
packets to correct the ordering.
(cherry picked from commit 34e051d16850701694410a0e72e0e4ff3a5ec293)
(cherry picked from commit b43b95f4789b6e60f9684918fd3c0a5f3f18aef6)
Also converted from bitstream to get_bits.