Commit cf42ee54 authored by Committed by Derek BuitenhuisBrowse files
Make FrameInvariants invariant in encode_frame().
Despite the name, we were passing FrameInvariants to encode_frame() as &mut. There were two places that it actually mutated the contents. 1) In write_sequence_header_obu(), several fields were set to constants. Given that we write the sequence header multiple times, but its contents should never change, the initialization does not belong in this function, as that is just asking to violate this constraint if we ever make them non-constant. Instead just initialize the fields when the rest of the FrameInvariant struct is initialized, since the values are currently constant anyway. We can find a better place than write_sequence_header_obu() (one that really is called once per sequence) if we ever want to make them non-constant. 2) The ref_frame_sign_bias fields are initialized at the very start of encode_frame(). These can instead be initialized in new_inter_frame() as soon as ref_frames[i] is set. With the above two changes we can drop the &mut and ensure that FrameInvariants really is invariant.