mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-01-27 02:28:22 +00:00
media: ffmpeg: Add a separate flush helper for encoder.
The decoder and encoder uses different calls for flushing. Add a new flush_encoder helper for that, and rename the existing one to flush_decoder. BUG=b:239897269 TEST=cargo test --features "video-decoder,ffmpeg" -p ffmpeg -p devices Change-Id: Id237424209dc8d64d43424570003d735ee164d36 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3868598 Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Commit-Queue: Tatsuyuki Ishi <ishitatsuyuki@google.com>
This commit is contained in:
parent
8a2af8f2ff
commit
f30d6fd9e8
2 changed files with 11 additions and 2 deletions
|
@ -303,7 +303,7 @@ impl FfmpegDecoderSession {
|
|||
// Start flushing. `try_receive_frame` will return `FlushCompleted` when the
|
||||
// flush is completed. `TryAgain` will not be returned again until the flush is
|
||||
// completed.
|
||||
match self.context.flush() {
|
||||
match self.context.flush_decoder() {
|
||||
// Call ourselves again so we can process the flush.
|
||||
Ok(()) => self.try_receive_frame(),
|
||||
Err(err) => {
|
||||
|
|
|
@ -520,10 +520,19 @@ impl AvCodecContext {
|
|||
/// frames for them.
|
||||
///
|
||||
/// The flush process is complete when `try_receive_frame` returns `FlushCompleted`,
|
||||
pub fn flush(&mut self) -> Result<(), AvError> {
|
||||
pub fn flush_decoder(&mut self) -> Result<(), AvError> {
|
||||
// Safe because the context is valid through the life of this object.
|
||||
AvError::result(unsafe { ffi::avcodec_send_packet(self.0, std::ptr::null()) })
|
||||
}
|
||||
|
||||
/// Ask the context to start flushing, i.e. to process all pending input frames and produce
|
||||
/// packets for them.
|
||||
///
|
||||
/// The flush process is complete when `try_receive_packet` returns `FlushCompleted`,
|
||||
pub fn flush_encoder(&mut self) -> Result<(), AvError> {
|
||||
// Safe because the context is valid through the life of this object.
|
||||
AvError::result(unsafe { ffi::avcodec_send_frame(self.0, std::ptr::null()) })
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for types that can be used as data provider for a `AVBuffer`.
|
||||
|
|
Loading…
Reference in a new issue