Enabled refcounted frames. Fixed sorting order back to how it was (which was correct). Free frames with av_frame_free instead of av_free.
removed debug code from test