summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/tsv_video_buffer.rs1
-rw-r--r--src/bin/tsv_video_stream.rs7
-rw-r--r--src/bin/tsv_view.rs4
-rw-r--r--src/ffmpeg.rs12
-rw-r--r--src/gpu.rs10
-rw-r--r--src/uniform.rs4
6 files changed, 19 insertions, 19 deletions
diff --git a/src/bin/tsv_video_buffer.rs b/src/bin/tsv_video_buffer.rs
index 3a244a8..1152193 100644
--- a/src/bin/tsv_video_buffer.rs
+++ b/src/bin/tsv_video_buffer.rs
@@ -50,6 +50,7 @@ fn main() {
}
let mut info = ffmpeg::probe_video(ff_args, max_frames);
+ log::info!("probe results: {:?}", info);
let num_frames = match (info.num_frames, max_frames) {
(Some(a), Some(b)) => u32::min(a, b),
(Some(a), None) => a,
diff --git a/src/bin/tsv_video_stream.rs b/src/bin/tsv_video_stream.rs
index c2db35c..2345c99 100644
--- a/src/bin/tsv_video_stream.rs
+++ b/src/bin/tsv_video_stream.rs
@@ -34,12 +34,7 @@ fn main() {
}
let info = ffmpeg::probe_video(ff_args, None);
- log::info!(
- "{}x{} @ {:.2}fps, tsv image: {name}",
- info.width,
- info.height,
- info.fps
- );
+ log::info!("probe results: {:?}", info);
let instance = gpu::create_instance();
let adapter = gpu::create_adapter(&instance, None);
diff --git a/src/bin/tsv_view.rs b/src/bin/tsv_view.rs
index 885a8c4..13cb06d 100644
--- a/src/bin/tsv_view.rs
+++ b/src/bin/tsv_view.rs
@@ -72,7 +72,7 @@ impl ApplicationHandler for App {
let surface_format = surface_caps
.formats
.iter()
- .find(|f| f.is_srgb())
+ .find(|f| !f.is_srgb())
.copied()
.unwrap_or(surface_caps.formats[0]);
@@ -91,7 +91,7 @@ impl ApplicationHandler for App {
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
- format: wgpu::TextureFormat::Rgba8UnormSrgb,
+ format: wgpu::TextureFormat::Rgba8Unorm,
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
view_formats: &[],
});
diff --git a/src/ffmpeg.rs b/src/ffmpeg.rs
index fbfdc94..3c385c4 100644
--- a/src/ffmpeg.rs
+++ b/src/ffmpeg.rs
@@ -90,6 +90,7 @@ fn filter_probe_args(ff_args: &[String]) -> Vec<String> {
out
}
+#[derive(Debug)]
pub struct VideoInfo {
pub width: u32,
pub height: u32,
@@ -106,7 +107,7 @@ pub fn probe_video(ff_args: &[String], max_frames: Option<u32>) -> VideoInfo {
.args(["-select_streams", "v:0"])
.args([
"-show_entries",
- "stream=codec_tag_string,width,height,pix_fmt,r_frame_rate,nb_frames",
+ "stream=codec_tag_string,width,height,pix_fmt,r_frame_rate,nb_frames:format=duration",
])
.args(["-of", "csv=p=0"])
.args(&probe_args)
@@ -120,8 +121,8 @@ pub fn probe_video(ff_args: &[String], max_frames: Option<u32>) -> VideoInfo {
let stdout = String::from_utf8_lossy(&output.stdout);
let line = stdout.trim();
- let parts: Vec<&str> = line.split(',').collect();
- if parts.len() != 6 {
+ let parts: Vec<&str> = line.split(&[',', '\n']).collect();
+ if parts.len() != 7 {
panic!("unexpected ffprobe output: {line}");
}
@@ -137,7 +138,10 @@ pub fn probe_video(ff_args: &[String], max_frames: Option<u32>) -> VideoInfo {
} else {
parts[4].parse().expect("parse fps")
};
- let num_frames = parts[5].parse().ok().or(max_frames);
+ let num_frames = parts[5].parse::<u32>().ok().or(max_frames).or_else(|| {
+ let duration: f64 = parts[6].parse().ok()?;
+ Some((duration * fps) as u32)
+ });
VideoInfo {
width,
diff --git a/src/gpu.rs b/src/gpu.rs
index 38c39f3..7f44354 100644
--- a/src/gpu.rs
+++ b/src/gpu.rs
@@ -129,14 +129,14 @@ pub const TSV_FORMAT: ImgFormat = ImgFormat::R8G8B8A8;
/// Convert a TSV ImgFormat to a wgpu TextureFormat.
pub fn img_format_to_wgpu(fmt: ImgFormat) -> wgpu::TextureFormat {
match fmt {
- ImgFormat::R8G8B8A8 => wgpu::TextureFormat::Rgba8UnormSrgb,
- ImgFormat::R8G8B8 => wgpu::TextureFormat::Rgba8UnormSrgb,
- ImgFormat::B8G8R8A8 => wgpu::TextureFormat::Bgra8UnormSrgb,
- ImgFormat::B8G8R8 => wgpu::TextureFormat::Bgra8UnormSrgb,
+ ImgFormat::R8G8B8A8 => wgpu::TextureFormat::Rgba8Unorm,
+ ImgFormat::R8G8B8 => wgpu::TextureFormat::Rgba8Unorm,
+ ImgFormat::B8G8R8A8 => wgpu::TextureFormat::Bgra8Unorm,
+ ImgFormat::B8G8R8 => wgpu::TextureFormat::Bgra8Unorm,
ImgFormat::BC1_RGBA => wgpu::TextureFormat::Bc1RgbaUnorm,
ImgFormat::BC3_RGBA => wgpu::TextureFormat::Bc3RgbaUnorm,
ImgFormat::BC7_RGBA => wgpu::TextureFormat::Bc7RgbaUnorm,
- ImgFormat::Undefined => wgpu::TextureFormat::Rgba8UnormSrgb,
+ ImgFormat::Undefined => wgpu::TextureFormat::Rgba8Unorm,
}
}
diff --git a/src/uniform.rs b/src/uniform.rs
index a428102..c8f55c2 100644
--- a/src/uniform.rs
+++ b/src/uniform.rs
@@ -412,7 +412,7 @@ pub struct TextureResource {
impl TextureResource {
pub fn new(device: &wgpu::Device, id: String, tsv_name: String) -> Self {
- let format = wgpu::TextureFormat::Rgba8UnormSrgb;
+ let format = wgpu::TextureFormat::Rgba8Unorm;
let view_dimension = wgpu::TextureViewDimension::D2;
let dimension = view_dimension_to_texture_dimension(view_dimension);
let (texture, view) =
@@ -1140,7 +1140,7 @@ fn create_placeholder_texture(
slot: &TextureBindingSlot,
) -> (wgpu::Texture, wgpu::TextureView) {
let format = match slot.sample_type {
- wgpu::TextureSampleType::Float { .. } => wgpu::TextureFormat::Rgba8UnormSrgb,
+ wgpu::TextureSampleType::Float { .. } => wgpu::TextureFormat::Rgba8Unorm,
wgpu::TextureSampleType::Sint => wgpu::TextureFormat::Rgba8Sint,
wgpu::TextureSampleType::Uint => wgpu::TextureFormat::Rgba8Uint,
wgpu::TextureSampleType::Depth => wgpu::TextureFormat::Depth32Float,