Skip to main content

check_streaming_output_honesty

Function check_streaming_output_honesty 

Source
pub fn check_streaming_output_honesty<E, D>(
    enc: E,
    dec: D,
    img: &TestImage,
) -> Conformance
where E: EncoderConfig, D: DecoderConfig, <E::Job as EncodeJob>::Enc: Encoder<Error = E::Error>,
Expand description

Verify the OutputTiming an encoder’s begin reports, and EncodeCapabilities::streaming_output behind it.

Run it with a configuration that streams as well as the default: a configuration that reports OutputTiming::AT_FINISH passes without exercising the streaming path. To verify a lag of L rows the image must be taller than L + 2 x strip, where strip is the encoder’s preferred_strip_height (at most a quarter of the image); a shorter image fails the check rather than passing it unverified. check_all picks a tall enough image.

  • Without push_rows the codec must not declare streaming_output.
  • begin may reject the declaration as UnsupportedOperation::RowLevelEncode (this configuration cannot encode from rows); any other error fails the check.
  • A streaming timing needs streaming_output declared and a lag below the image height.
  • AT_FINISH: pending_output stays empty until finish.
  • Streaming with lag L: between any two points of the encode L or more rows apart (after begin and after each strip but the last), bytes become pending. That catches an understated lag and an encoder that stalls after its first strip.
  • Draining all pending bytes after every strip, and separately draining uneven prefixes (one byte, a few, all but one, and once more than is pending, which clamps), each yield, with finish’s remainder, exactly the bytes of the same encode left undrained. Those bytes decode to the pixels of the one-shot encode. (Not to a plain push_rows encode: an encoder may need the image size before its first row, through begin or with_canvas_size.)
  • Draining with take_output, into an empty vector and into a non-empty one, yields the same bytes and leaves nothing pending.
  • After a streaming begin, a second begin and a one-shot encode are errors.
  • begin with a zero width or height is accepted exactly when encode of that size succeeds (or declines as RowLevelEncode).
  • A refused begin leaves the encoder unchanged: after the first such zero-size refusal, begin with the real size on the same encoder reports the same timing and streams the same file.
  • Every run reports the same timing.