Add Context::new_with_codec

Allows calling `avcodec_alloc_context3` with an AVCodec, setting the default values.
This commit is contained in:
Luke Street
2023-10-30 11:30:06 -04:00
parent 04e6df4f9d
commit a8c9dbea84
+9
View File
@@ -41,6 +41,15 @@ impl Context {
}
}
pub fn new_with_codec(codec: Codec) -> Self {
unsafe {
Context {
ptr: avcodec_alloc_context3(codec.as_ptr()),
owner: None,
}
}
}
pub fn from_parameters<P: Into<Parameters>>(parameters: P) -> Result<Self, Error> {
let parameters = parameters.into();
let mut context = Self::new();