Some fields were incorrectly reset (to NULL) when calling avcodec_copy_context().