Skip to content

Commit

Permalink
[vk-video] Various minor fixes (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzywilczek authored Oct 17, 2024
1 parent d189e80 commit 7ec0fdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
11 changes: 2 additions & 9 deletions vk-video/src/parser/au_splitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,31 @@ impl AUSplitter {
// defguardp first_mb_in_slice_zero(a)
// when a.first_mb_in_slice == 0 and
// a.nal_unit_type in [1, 2, 5]
//
fn first_mb_in_slice_zero(slice: &Slice) -> bool {
slice.header.first_mb_in_slice == 0
}

// defguardp frame_num_differs(a, b) when a.frame_num != b.frame_num
//
fn frame_num_differs(last: &Slice, curr: &Slice) -> bool {
last.header.frame_num != curr.header.frame_num
}

// defguardp pic_parameter_set_id_differs(a, b)
// when a.pic_parameter_set_id != b.pic_parameter_set_id
//
fn pps_id_differs(last: &Slice, curr: &Slice) -> bool {
last.pps_id != curr.pps_id
}

// defguardp field_pic_flag_differs(a, b) when a.field_pic_flag != b.field_pic_flag
//
// defguardp bottom_field_flag_differs(a, b) when a.bottom_field_flag != b.bottom_field_flag
//
fn field_pic_flag_differs(last: &Slice, curr: &Slice) -> bool {
last.header.field_pic != curr.header.field_pic
}

// defguardp nal_ref_idc_differs_one_zero(a, b)
// when (a.nal_ref_idc == 0 or b.nal_ref_idc == 0) and
// a.nal_ref_idc != b.nal_ref_idc
//
fn nal_ref_idc_differs_one_zero(last: &Slice, curr: &Slice) -> bool {
(last.nal_header.nal_ref_idc() == 0 || curr.nal_header.nal_ref_idc() == 0)
&& last.nal_header.nal_ref_idc() != curr.nal_header.nal_ref_idc()
Expand All @@ -85,7 +80,6 @@ fn nal_ref_idc_differs_one_zero(last: &Slice, curr: &Slice) -> bool {
// when a.pic_order_cnt_type == 0 and b.pic_order_cnt_type == 0 and
// (a.pic_order_cnt_lsb != b.pic_order_cnt_lsb or
// a.delta_pic_order_cnt_bottom != b.delta_pic_order_cnt_bottom)
//
fn pic_order_cnt_zero_check(last: &Slice, curr: &Slice) -> bool {
let (last_pic_order_cnt_lsb, last_delta_pic_order_cnt_bottom) =
match last.header.pic_order_cnt_lsb {
Expand All @@ -111,20 +105,19 @@ fn pic_order_cnt_zero_check(last: &Slice, curr: &Slice) -> bool {
|| last_delta_pic_order_cnt_bottom != curr_delta_pic_order_cnt_bottom
}

// TODO
// defguardp pic_order_cnt_one_check_zero(a, b)
// when a.pic_order_cnt_type == 1 and b.pic_order_cnt_type == 1 and
// hd(a.delta_pic_order_cnt) != hd(b.delta_pic_order_cnt)
// TODO

// TODO
// defguardp pic_order_cnt_one_check_one(a, b)
// when a.pic_order_cnt_type == 1 and b.pic_order_cnt_type == 1 and
// hd(hd(a.delta_pic_order_cnt)) != hd(hd(b.delta_pic_order_cnt))
// TODO

// defguardp idr_and_non_idr(a, b)
// when (a.nal_unit_type == 5 or b.nal_unit_type == 5) and
// a.nal_unit_type != b.nal_unit_type
//
fn idr_and_non_idr(last: &Slice, curr: &Slice) -> bool {
(last.nal_header.nal_unit_type().id() == 5) ^ (curr.nal_header.nal_unit_type().id() == 5)
}
Expand Down
24 changes: 7 additions & 17 deletions vk-video/src/vulkan_decoder/vulkan_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use ash::{vk, Entry};
use tracing::{error, info};
use tracing::{debug, error};

use super::{
Allocator, CommandBuffer, CommandPool, DebugMessenger, Device, H264ProfileInfo, Instance,
Expand Down Expand Up @@ -142,13 +142,6 @@ impl VulkanCtx {
) -> Result<Self, VulkanCtxError> {
let entry = Arc::new(unsafe { Entry::load()? });

let instance_extension_properties =
unsafe { entry.enumerate_instance_extension_properties(None)? };
info!(
"instance_extension_properties amount: {}",
instance_extension_properties.len()
);

let api_version = vk::make_api_version(0, 1, 3, 0);
let app_info = vk::ApplicationInfo {
api_version,
Expand Down Expand Up @@ -248,9 +241,6 @@ impl VulkanCtx {

let wgpu_features = wgpu_features | wgpu::Features::TEXTURE_FORMAT_NV12;

// TODO: we can only get the required extensions after exposing the adapter; the creation
// of the adapter and verification of whether the device supports all extensions should
// happen while picking the device.
let wgpu_extensions = wgpu_adapter
.adapter
.required_device_extensions(wgpu_features);
Expand Down Expand Up @@ -495,7 +485,7 @@ fn find_device<'a>(
.max_dpb_slots(caps.max_dpb_slots)
.max_active_reference_pictures(caps.max_active_reference_pictures)
.std_header_version(caps.std_header_version);
info!("caps: {caps:#?}");
debug!("video_caps: {caps:#?}");

let flags = decode_caps.flags;

Expand Down Expand Up @@ -563,7 +553,7 @@ fn find_device<'a>(
.contains(vk::QueueFlags::VIDEO_DECODE_KHR)
})
.map(|(i, _)| i)
.collect::<Vec<_>>(); // TODO: have to split the queues
.collect::<Vec<_>>();

let Some(transfer_queue_idx) = queues
.iter()
Expand Down Expand Up @@ -603,10 +593,10 @@ fn find_device<'a>(
continue;
};

info!("deocde_caps: {decode_caps:#?}");
info!("h264_caps: {h264_caps:#?}");
info!("dpb_format_properties: {h264_dpb_format_properties:#?}");
info!("dst_format_properties: {h264_dst_format_properties:#?}");
debug!("deocde_caps: {decode_caps:#?}");
debug!("h264_caps: {h264_caps:#?}");
debug!("dpb_format_properties: {h264_dpb_format_properties:#?}");
debug!("dst_format_properties: {h264_dst_format_properties:#?}");

return Ok(ChosenDevice {
physical_device: device,
Expand Down

0 comments on commit 7ec0fdc

Please sign in to comment.