WIP - fixing some parameters in video filter

This commit is contained in:
lif 2020-01-25 12:15:59 -08:00
parent e4046986d2
commit b1bde52bb0
1 changed files with 15 additions and 7 deletions

View File

@ -43,16 +43,17 @@ fn video_filter(
};
let pixel_aspect = av_info.geometry.aspect_ratio / (av_info.geometry.base_width as f32 / av_info.geometry.base_height as f32);
let args = format!(
"buffer=width={}:height={}:pix_fmt={}:frame_rate={}:pixel_aspect={}",
"width={}:height={}:pix_fmt={}:frame_rate={}:pixel_aspect={}",
av_info.geometry.base_width,
av_info.geometry.base_height,
pix_fmt,
av_info.timing.fps,
if av_info.timing.fps == 0.0 { 60.0 } else { av_info.timing.fps },
pixel_aspect,
);
vfilter.add(&filter::find("buffer").unwrap(), "in", &args);
eprintln!("{}", args);
vfilter.add(&filter::find("buffer").unwrap(), "in", &args)?;
//scale?
vfilter.add(&filter::find("buffersink").unwrap(), "out", "");
vfilter.add(&filter::find("buffersink").unwrap(), "out", "")?;
{
let mut out = vfilter.get("out").unwrap();
@ -72,9 +73,9 @@ fn audio_filter(
) -> Result<filter::Graph, ffmpeg::Error> {
let mut afilter = filter::Graph::new();
let args = format!("sample_rate={}:sample_fmt=s16:channel_layout=stereo", sample_rate);
afilter.add(&filter::find("abuffer").unwrap(), "in", &args);
afilter.add(&filter::find("abuffer").unwrap(), "in", &args)?;
//aresample?
afilter.add(&filter::find("abuffersink").unwrap(), "out", "");
afilter.add(&filter::find("abuffersink").unwrap(), "out", "")?;
{
let mut out = afilter.get("out").unwrap();
@ -233,8 +234,8 @@ impl retro::wrapper::Handler for MyEmulator {
fn set_system_av_info(&mut self, system_av_info: SystemAvInfo) -> bool {
self.video_encoder.set_frame_rate(system_av_info.timing.fps.into());
self.audio_encoder.set_rate(system_av_info.timing.sample_rate.round() as i32);
self.set_geometry(system_av_info.geometry);
self.av_info.timing = system_av_info.timing;
self.set_geometry(system_av_info.geometry);
true
}
@ -243,6 +244,13 @@ impl retro::wrapper::Handler for MyEmulator {
self.video_encoder.set_height(geometry.base_height);
self.video_encoder.set_aspect_ratio(geometry.aspect_ratio as f64);
self.av_info.geometry = geometry;
let pixel_format = match self.video_pixel_format {
format::Pixel::RGB555 => PixelFormat::ARGB1555,
format::Pixel::RGB32 => PixelFormat::ARGB8888,
format::Pixel::RGB565 => PixelFormat::RGB565,
_ => unimplemented!(),
};
self.video_filter = video_filter(&self.video_encoder, &self.av_info, pixel_format).unwrap();
true
}
}