Skip to content

Commit

Permalink
update try merge
Browse files Browse the repository at this point in the history
  • Loading branch information
YoHoSo committed Jul 17, 2023
1 parent 6145ba5 commit 31f0aeb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ required-features = ["render", "dash"]
name = "vv"

[[bin]]
name = "ply_play"
name = "vvplay_asnyc"
required-features = ["render", "dash"]

[features]
Expand Down
8 changes: 4 additions & 4 deletions src/abr/quetra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ pub struct Quetra {
/// playback speed: how many seconds of video is consumed and played in 1 second
p: f64,
/// how often is the bitrate adaptation done (selected as 1s for now)
segment_frequency: u32,
_segment_frequency: u32,
/// segment size param for granularity of each buffer (selected as 1 for now)
segment_size: u32,
_segment_size: u32,
}

impl Quetra {
pub fn new(buffer_capacity: u64, fps: f32) -> Self {
Quetra {
k: buffer_capacity,
segment_frequency: 1,
segment_size: 1,
_segment_frequency: 1,
_segment_size: 1,
p: fps as f64 / 30.0,
}
}
Expand Down
50 changes: 47 additions & 3 deletions src/bin/ply_play.rs → src/bin/vvplay_asnyc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use vivotk::render::wgpu::{
renderer::Renderer,
};
use vivotk::utils::{
get_cosines, predict_quality, ExponentialMovingAverage, LastValue,
SimpleRunningAverage, GAEMA, LPEMA,
get_cosines, predict_quality, ExponentialMovingAverage, LastValue, SimpleRunningAverage, GAEMA,
LPEMA,
};
use vivotk::{BufMsg, PCMetadata};

Expand Down Expand Up @@ -548,10 +548,54 @@ fn is_remote_src(src: &str) -> bool {
src.starts_with("http://") || src.starts_with("https://")
}

fn infer_format(src: &String) -> String {
let choices = ["pcd", "ply", "bin", "http"];
const PCD: usize = 0;
const PLY: usize = 1;
const BIN: usize = 2;

if choices.contains(&src.as_str()) {
return src.clone();
}

let path = Path::new(src);
// infer by counting extension numbers (pcd ply and bin)

let mut choice_count = [0, 0, 0];
for file_entry in path.read_dir().unwrap() {
match file_entry {
Ok(entry) => {
if let Some(ext) = entry.path().extension() {
if ext.eq("pcd") {
choice_count[PCD] += 1;
} else if ext.eq("ply") {
choice_count[PLY] += 1;
} else if ext.eq("bin") {
choice_count[BIN] += 1;
}
}
}
Err(e) => {
eprintln!("{e}")
}
}
}

let max_index = choice_count
.iter()
.enumerate()
.max_by_key(|(_, &item)| item)
.map(|(index, _)| index);
choices[max_index.unwrap()].to_string()
}


fn main() {
// initialize logger
env_logger::init();
let args: Args = Args::parse();
let play_format = infer_format(&args.src);

let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(8)
.enable_all()
Expand Down Expand Up @@ -718,7 +762,7 @@ fn main() {
let mut dir = tokio::fs::read_dir(path).await.unwrap();
while let Some(entry) = dir.next_entry().await.unwrap() {
let f = entry.path();
if !f.extension().map(|f| "pcd".eq(f)).unwrap_or(false) {
if !f.extension().map(|f| play_format.as_str().eq(f)).unwrap_or(false) {
continue;
}
ply_files.push(f);
Expand Down
2 changes: 0 additions & 2 deletions src/pipeline/subcommands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub mod convert;
pub mod downsample;
pub mod info;
pub mod metrics;
pub mod play;
pub mod read;
pub mod render;
pub mod upsample;
Expand All @@ -12,7 +11,6 @@ pub use convert::Convert;
pub use downsample::Downsampler;
pub use info::Info;
pub use metrics::MetricsCalculator;
pub use play::Play;
pub use read::Read;
pub use render::Render;
pub use upsample::Upsampler;
Expand Down
99 changes: 0 additions & 99 deletions src/pipeline/subcommands/play.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/render/wgpu/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::render::wgpu::builder::{
};
use crate::render::wgpu::camera::{Camera, CameraState, CameraUniform};
use crate::render::wgpu::gpu::WindowGpu;
use crate::render::wgpu::reader::{RenderReader};
use crate::render::wgpu::reader::RenderReader;
use log::debug;
use std::iter;
use std::marker::PhantomData;
Expand Down

0 comments on commit 31f0aeb

Please sign in to comment.