Skip to content

Commit 8ba77e7

Browse files
lu-zerobarrbrain
authored andcommitted
Document the internal processing limit and error out when it is hit
The current rate control code would error out once i32::MAX frames are totaled.
1 parent 04a8e50 commit 8ba77e7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/api/context.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ impl<T: Pixel> Context<T> {
6464
///
6565
/// # Errors
6666
///
67-
/// If this method is called with a frame after the encoder has been flushed,
68-
/// the [`EncoderStatus::EnoughData`] error is returned.
67+
/// If this method is called with a frame after the encoder has been flushed
68+
/// or the encoder internal limit is hit (`std::i32::MAX` frames) the
69+
/// [`EncoderStatus::EnoughData`] error is returned.
6970
///
7071
/// # Examples
7172
///
@@ -109,7 +110,12 @@ impl<T: Pixel> Context<T> {
109110
self.is_flushing = true;
110111
} else if self.is_flushing {
111112
return Err(EncoderStatus::EnoughData);
113+
// The rate control can process at most std::i32::MAX frames
114+
} else if self.inner.frame_count == std::i32::MAX as u64 - 1 {
115+
self.inner.limit = Some(self.inner.frame_count);
116+
self.is_flushing = true;
112117
}
118+
113119
let inner = &mut self.inner;
114120
let pool = &mut self.pool;
115121

0 commit comments

Comments
 (0)