Add Context::new_with_codec

Allows calling `avcodec_alloc_context3` with an AVCodec, setting the default values.
This commit is contained in:
Luke Street
2024-04-01 12:54:59 -06:00
parent 7871f3b953
commit 2c38f000a5
+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();