aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2023-03-14 11:11:31 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2023-03-14 11:11:31 +0100
commit2757a0289c980aeba002609c777815b51ace8e56 (patch)
tree0872e7aa66fb001aa034b44f16ae1dcdfec3293f
parent5f9bf7648f667952b787c77afde07d23ac7c01de (diff)
downloadnihav-2757a0289c980aeba002609c777815b51ace8e56.tar.gz
introduce a way for encoder to manifest its capabilities
-rw-r--r--nihav-commonfmt/src/codecs/cinepakenc.rs1
-rw-r--r--nihav-commonfmt/src/codecs/pcm.rs1
-rw-r--r--nihav-commonfmt/src/codecs/zmbvenc.rs1
-rw-r--r--nihav-core/src/codecs/mod.rs11
-rw-r--r--nihav-duck/src/codecs/truemotionrtenc.rs1
-rw-r--r--nihav-duck/src/codecs/vp6enc/mod.rs1
-rw-r--r--nihav-duck/src/codecs/vp7enc/mod.rs1
-rw-r--r--nihav-flash/src/codecs/adpcmenc.rs1
-rw-r--r--nihav-indeo/src/codecs/indeo3enc/mod.rs1
-rw-r--r--nihav-llaudio/src/codecs/flacenc.rs1
-rw-r--r--nihav-ms/src/codecs/imaadpcmenc.rs1
-rw-r--r--nihav-ms/src/codecs/msadpcm.rs1
-rw-r--r--nihav-ms/src/codecs/msvideo1enc.rs1
-rw-r--r--nihav-realmedia/src/codecs/cookenc.rs1
14 files changed, 24 insertions, 0 deletions
diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs
index ff86a52..f4ac9b2 100644
--- a/nihav-commonfmt/src/codecs/cinepakenc.rs
+++ b/nihav-commonfmt/src/codecs/cinepakenc.rs
@@ -958,6 +958,7 @@ impl NAEncoder for CinepakEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { 0 }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-commonfmt/src/codecs/pcm.rs b/nihav-commonfmt/src/codecs/pcm.rs
index 3bc67c0..b2dd817 100644
--- a/nihav-commonfmt/src/codecs/pcm.rs
+++ b/nihav-commonfmt/src/codecs/pcm.rs
@@ -200,6 +200,7 @@ impl NAEncoder for PCMEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_CBR }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-commonfmt/src/codecs/zmbvenc.rs b/nihav-commonfmt/src/codecs/zmbvenc.rs
index 0c8b945..332cc0e 100644
--- a/nihav-commonfmt/src/codecs/zmbvenc.rs
+++ b/nihav-commonfmt/src/codecs/zmbvenc.rs
@@ -398,6 +398,7 @@ impl NAEncoder for ZMBVEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_SKIPFRAME }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-core/src/codecs/mod.rs b/nihav-core/src/codecs/mod.rs
index b6a1820..5cf7d07 100644
--- a/nihav-core/src/codecs/mod.rs
+++ b/nihav-core/src/codecs/mod.rs
@@ -210,6 +210,13 @@ pub const ENC_MODE_CBR: u64 = 1 << 0;
/// Encoding parameter flag to force constant framerate mode.
pub const ENC_MODE_CFR: u64 = 1 << 1;
+/// Encoder supports constant bitrate mode.
+pub const ENC_CAPS_CBR: u64 = 1 << 0;
+/// Encoder supports skip frames.
+pub const ENC_CAPS_SKIPFRAME: u64 = 1 << 1;
+/// Encoder supports mid-stream parameters change.
+pub const ENC_CAPS_PARAMCHANGE: u64 = 1 << 2;
+
/// Encoding parameters.
#[derive(Clone,Copy,PartialEq)]
pub struct EncodeParameters {
@@ -300,6 +307,10 @@ pub trait NAEncoder: NAOptionHandler {
/// // convert input into format defined in target_params, feed to the encoder, ...
/// ```
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters>;
+ /// Queries encoder capabilities.
+ ///
+ /// See `ENC_CAPS_*` for examples.
+ fn get_capabilities(&self) -> u64;
/// Initialises the encoder.
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef>;
/// Takes a single frame for encoding.
diff --git a/nihav-duck/src/codecs/truemotionrtenc.rs b/nihav-duck/src/codecs/truemotionrtenc.rs
index c80a4b8..47236dd 100644
--- a/nihav-duck/src/codecs/truemotionrtenc.rs
+++ b/nihav-duck/src/codecs/truemotionrtenc.rs
@@ -181,6 +181,7 @@ impl NAEncoder for TMRTEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_PARAMCHANGE }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-duck/src/codecs/vp6enc/mod.rs b/nihav-duck/src/codecs/vp6enc/mod.rs
index d706fe7..9eea91d 100644
--- a/nihav-duck/src/codecs/vp6enc/mod.rs
+++ b/nihav-duck/src/codecs/vp6enc/mod.rs
@@ -680,6 +680,7 @@ impl NAEncoder for VP6Encoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { 0 }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-duck/src/codecs/vp7enc/mod.rs b/nihav-duck/src/codecs/vp7enc/mod.rs
index 8a31f10..a73a571 100644
--- a/nihav-duck/src/codecs/vp7enc/mod.rs
+++ b/nihav-duck/src/codecs/vp7enc/mod.rs
@@ -280,6 +280,7 @@ impl NAEncoder for VP7Encoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { 0 }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-flash/src/codecs/adpcmenc.rs b/nihav-flash/src/codecs/adpcmenc.rs
index 9cd04f7..c7bf3aa 100644
--- a/nihav-flash/src/codecs/adpcmenc.rs
+++ b/nihav-flash/src/codecs/adpcmenc.rs
@@ -81,6 +81,7 @@ impl NAEncoder for ADPCMEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_CBR }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-indeo/src/codecs/indeo3enc/mod.rs b/nihav-indeo/src/codecs/indeo3enc/mod.rs
index dc638bc..eefa3d7 100644
--- a/nihav-indeo/src/codecs/indeo3enc/mod.rs
+++ b/nihav-indeo/src/codecs/indeo3enc/mod.rs
@@ -199,6 +199,7 @@ impl NAEncoder for Indeo3Encoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_SKIPFRAME }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-llaudio/src/codecs/flacenc.rs b/nihav-llaudio/src/codecs/flacenc.rs
index 8b5b44d..3b99294 100644
--- a/nihav-llaudio/src/codecs/flacenc.rs
+++ b/nihav-llaudio/src/codecs/flacenc.rs
@@ -417,6 +417,7 @@ impl NAEncoder for FLACEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { 0 }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-ms/src/codecs/imaadpcmenc.rs b/nihav-ms/src/codecs/imaadpcmenc.rs
index 15e76fb..a113d5d 100644
--- a/nihav-ms/src/codecs/imaadpcmenc.rs
+++ b/nihav-ms/src/codecs/imaadpcmenc.rs
@@ -215,6 +215,7 @@ impl NAEncoder for IMAADPCMEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_CBR }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-ms/src/codecs/msadpcm.rs b/nihav-ms/src/codecs/msadpcm.rs
index 768eb74..179b097 100644
--- a/nihav-ms/src/codecs/msadpcm.rs
+++ b/nihav-ms/src/codecs/msadpcm.rs
@@ -336,6 +336,7 @@ impl NAEncoder for MSADPCMEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_CBR }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs
index 5d50b9a..4507e08 100644
--- a/nihav-ms/src/codecs/msvideo1enc.rs
+++ b/nihav-ms/src/codecs/msvideo1enc.rs
@@ -835,6 +835,7 @@ impl NAEncoder for MSVideo1Encoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_SKIPFRAME }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),
diff --git a/nihav-realmedia/src/codecs/cookenc.rs b/nihav-realmedia/src/codecs/cookenc.rs
index 70f471b..3b9e3c4 100644
--- a/nihav-realmedia/src/codecs/cookenc.rs
+++ b/nihav-realmedia/src/codecs/cookenc.rs
@@ -768,6 +768,7 @@ impl NAEncoder for CookEncoder {
}
}
}
+ fn get_capabilities(&self) -> u64 { ENC_CAPS_CBR }
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
NACodecTypeInfo::None => Err(EncoderError::FormatError),