-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New architecture for vk-video initialization.
This change allows users to initialize `vk-video` with wgpu surfaces for rendering to an on-screen window. This was previously overlooked and there was no possibility to guarantee a `VulkanCtx` was able to render on screen. This patch also adds an example h264 player to vk-video.
- Loading branch information
1 parent
efe10fa
commit 40ab0b7
Showing
24 changed files
with
1,733 additions
and
248 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::{ | ||
io::Read, | ||
sync::{mpsc::SyncSender, Arc}, | ||
time::Duration, | ||
}; | ||
|
||
use bytes::BytesMut; | ||
use vk_video::VulkanDevice; | ||
|
||
use crate::FrameWithPts; | ||
|
||
pub fn run_decoder( | ||
tx: SyncSender<super::FrameWithPts>, | ||
framerate: u64, | ||
vulkan_device: Arc<VulkanDevice>, | ||
mut bytestream_reader: impl Read, | ||
) { | ||
let mut decoder = vulkan_device.create_wgpu_textures_decoder().unwrap(); | ||
let frame_interval = 1.0 / (framerate as f64); | ||
let mut frame_number = 0u64; | ||
let mut buffer = BytesMut::zeroed(4096); | ||
|
||
while let Ok(n) = bytestream_reader.read(&mut buffer) { | ||
if n == 0 { | ||
return; | ||
} | ||
|
||
let decoded = decoder.decode(&buffer[..n], None).unwrap(); | ||
|
||
for f in decoded { | ||
let result = FrameWithPts { | ||
frame: f.frame, | ||
pts: Duration::from_secs_f64(frame_number as f64 * frame_interval), | ||
}; | ||
|
||
frame_number += 1; | ||
|
||
if tx.send(result).is_err() { | ||
return; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.