feat(codec): access time_base on context

This commit is contained in:
tilpner
2023-05-24 17:22:59 +02:00
committed by Till Höppner
parent bb8dc49245
commit bdcd40570d
2 changed files with 11 additions and 11 deletions
+11 -1
View File
@@ -5,7 +5,7 @@ use libc::c_int;
#[cfg(feature = "ffmpeg_3_1")]
use super::Parameters;
use super::{decoder::Decoder, encoder::Encoder, threading, Compliance, Debug, Flags, Id};
use crate::{ffi::*, media, Codec, Error};
use crate::{ffi::*, media, Codec, Error, Rational};
pub struct Context {
ptr: *mut AVCodecContext,
@@ -121,6 +121,16 @@ impl Context {
}
}
}
pub fn time_base(&self) -> Rational {
unsafe { Rational::from((*self.as_ptr()).time_base) }
}
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R) {
unsafe {
(*self.as_mut_ptr()).time_base = value.into().into();
}
}
}
impl Default for Context {
-10
View File
@@ -134,16 +134,6 @@ impl Encoder {
}
}
pub fn time_base(&self) -> Rational {
unsafe { Rational::from((*self.as_ptr()).time_base) }
}
pub fn set_time_base<R: Into<Rational>>(&mut self, value: R) {
unsafe {
(*self.as_mut_ptr()).time_base = value.into().into();
}
}
pub fn set_frame_rate<R: Into<Rational>>(&mut self, value: Option<R>) {
unsafe {
if let Some(value) = value {