Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use crate::{

const MAX_DECODE_RETRIES: usize = 16;

// Mesa radeonsi rejects H.264 decode contexts below 64x64 with
// VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED, which hid VA-API on AMD GPUs.
const _: () = assert!(INITIAL_CONTEXT_SIZE >= 64);
// Mesa radeonsi rejects H.264 decode contexts below 64x64 and V4L2-backed
// drivers (Qualcomm iris) below 96x96; a smaller probe hid working decoders.
const _: () = assert!(INITIAL_CONTEXT_SIZE >= 96);

fn h264_access_unit_payload(data: &[u8]) -> &[u8] {
let end = data
Expand Down Expand Up @@ -240,7 +240,10 @@ pub(crate) struct VaApiDecoder {
impl VaApiDecoder {
pub fn probe() -> std::result::Result<String, String> {
let (display, decoder) = open_h264_device()?;
let probe_frame = VaFrame::new(Resolution::from((16, 16)), Resolution::from((16, 16)));
let probe_frame = VaFrame::new(
Resolution::from((INITIAL_CONTEXT_SIZE, INITIAL_CONTEXT_SIZE)),
Resolution::from((INITIAL_CONTEXT_SIZE, INITIAL_CONTEXT_SIZE)),
);
drop(
probe_frame
.to_native_handle(&display)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,14 @@ pub struct VaapiBackend<V: VideoFrame> {
}

/// Edge length of the placeholder VAContext created before the first SPS.
pub const INITIAL_CONTEXT_SIZE: u32 = 64;
/// Mesa radeonsi needs at least 64x64, V4L2-backed drivers (Qualcomm iris
/// through the msm VA driver) at least 96x96.
pub const INITIAL_CONTEXT_SIZE: u32 = 128;

impl<V: VideoFrame> VaapiBackend<V> {
pub(crate) fn new(display: Arc<libva::Display>, supports_context_reuse: bool) -> Self {
// Placeholder until the first SPS arrives (`new_sequence` replaces the
// context). Mesa radeonsi (AMD VCN) rejects H.264 decode contexts
// smaller than 64x64 with VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED.
// context), sized by INITIAL_CONTEXT_SIZE for the drivers' minimums.
let init_stream_info = StreamInfo {
format: DecodedFormat::NV12,
coded_resolution: Resolution::from((INITIAL_CONTEXT_SIZE, INITIAL_CONTEXT_SIZE)),
Expand Down