Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decoder/stateless: let the backends decide which resources they need #89

Merged
merged 22 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ce96e0e
decoder/stateless/h264: remove PictureData argument from new_picture
Gnurou Jul 9, 2024
da2b33e
decoder/stateless/h264: let the backend decide which resources it needs
Gnurou Jul 9, 2024
7ea6b82
decoder/stateless/vp8: let the backend decide which resources it needs
Gnurou Jul 9, 2024
87ac422
decoder/stateless/vp9/vaapi: check for resources first in submit_picture
Gnurou Jul 10, 2024
3b4b05b
decoder/stateless/vp9: check for decoding state only once per superframe
Gnurou Jul 10, 2024
fc07cd3
decoder/stateless/vp9: check for available output buffers only if we …
Gnurou Jul 10, 2024
af3257c
decoder/stateless/vp9: split backend picture creation and submission
Gnurou Jul 10, 2024
18db9df
decoder/stateless/vp9: split display of existing frame into its own m…
Gnurou Jul 10, 2024
e6e1e75
decoder/stateless/vp9: do not request resources for already decoded f…
Gnurou Jul 10, 2024
4fec1f5
decoder/stateless/vp9: let the backend decide which resources it needs
Gnurou Jul 10, 2024
db441e5
decoder/stateless/h265: remove pic argument from new_picture method
Gnurou Jul 10, 2024
75e4e05
decoder/stateless/h265: remove unused timestamp parameter from Pictur…
Gnurou Jul 10, 2024
f21da15
decoder/stateless/h265: remove unneeded PPS fetch
Gnurou Jul 10, 2024
add177c
decoder/stateless/h265: check if negotiation is needed before resourc…
Gnurou Jul 10, 2024
02dc0ad
decoder/stateless/h265: remove cur_pps_id member
Gnurou Jul 11, 2024
1aeea56
decoder/stateless/h265: avoid using cur_sps_id where possible
Gnurou Jul 11, 2024
718ec47
decoder/stateless/h265: let the backend decide which resources it needs
Gnurou Jul 11, 2024
895327a
decoder/stateless/av1: process one OBU per decode call
Gnurou Jul 10, 2024
cebb5df
decoder/stateless/av1/vaapi: optimize new_picture a bit
Gnurou Jul 10, 2024
25d67b8
decoder/stateless/av1: split backend picture creation from initializa…
Gnurou Jul 10, 2024
009fb67
decoder/stateless/av1: let the backend decide which resources it needs
Gnurou Jul 11, 2024
353dc6d
decoder/stateless: add error type for new_picture methods
Gnurou Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/codec/h265/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ impl PictureData {
first_picture_after_eos: bool,
prev_tid0_pic: Option<&PictureData>,
max_pic_order_cnt_lsb: i32,
_timestamp: u64,
) -> Self {
let hdr = &slice.header;
let nalu_type = slice.nalu.header.type_;
Expand Down
36 changes: 34 additions & 2 deletions src/decoder/stateless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,28 @@ use crate::decoder::StreamInfo;
use crate::DecodedFormat;
use crate::Resolution;

/// Error returned by `new_picture` methods of the backend, usually to indicate which kind of
/// resource is needed before the picture can be successfully created.
#[derive(Error, Debug)]
pub enum NewPictureError {
/// Indicates that the backend needs one output buffer to be returned to the pool before it can
/// proceed.
#[error("need one output buffer to be returned before operation can proceed")]
OutOfOutputBuffers,
/// No frame pool could satisfy the frame requirements. This indicate either an unhandled DRC
/// or an invalid stream.
#[error("no frame pool can satisfy the requested frame resolution {0:?}")]
NoFramePool(Resolution),
/// An unrecoverable backend error has occured.
#[error(transparent)]
BackendError(#[from] anyhow::Error),
}

pub type NewPictureResult<T> = Result<T, NewPictureError>;

/// Error returned by stateless backend methods.
#[derive(Error, Debug)]
pub enum StatelessBackendError {
#[error("not enough resources to proceed with the operation now")]
OutOfResources,
#[error(transparent)]
Other(#[from] anyhow::Error),
}
Expand Down Expand Up @@ -85,6 +102,21 @@ pub enum DecodeError {
BackendError(#[from] StatelessBackendError),
}

/// Convenience conversion for codecs that process a single frame per decode call.
impl From<NewPictureError> for DecodeError {
fn from(err: NewPictureError) -> Self {
match err {
NewPictureError::OutOfOutputBuffers => DecodeError::NotEnoughOutputBuffers(1),
e @ NewPictureError::NoFramePool(_) => {
DecodeError::BackendError(StatelessBackendError::Other(anyhow::anyhow!(e)))
}
NewPictureError::BackendError(e) => {
DecodeError::BackendError(StatelessBackendError::Other(e))
}
}
}
}

mod private {
use super::*;

Expand Down
Loading
Loading