diff --git a/src/encoder/stateless.rs b/src/encoder/stateless.rs index 33ba0cef..4677b966 100644 --- a/src/encoder/stateless.rs +++ b/src/encoder/stateless.rs @@ -179,9 +179,9 @@ pub(super) trait Predictor { } /// Generic trait for stateless encoder backends -pub trait StatelessVideoEncoderBackend +pub trait StatelessVideoEncoderBackend: Sized where - Codec: StatelessCodec, + Codec: StatelessCodec, { /// Backend's specific representation of the input frame, transformed with [`import_picture`]. /// Might be a wrapper of the input handle with additional backend specific data or a copy of @@ -211,7 +211,7 @@ pub trait StatelessEncoderBackendImport { } /// Trait helping contain all codec specific and backend specific types -pub trait StatelessCodecSpecific: StatelessCodec +pub trait StatelessCodec: Sized where Backend: StatelessVideoEncoderBackend, { @@ -231,8 +231,6 @@ where type ReferencePromise: BackendPromise; } -pub trait StatelessCodec: Sized {} - /// Stateless video encoder interface. pub trait StatelessVideoEncoder { /// Enqueues the frame for encoding. The implementation will drop the handle after it is no @@ -290,21 +288,20 @@ where /// Helper aliases for codec and backend specific types type Picture = >::Picture; -type Reference = >::Reference; +type Reference = >::Reference; -type Request = >::Request; +type Request = >::Request; -type CodedPromise = >::CodedPromise; +type CodedPromise = >::CodedPromise; -type ReferencePromise = - >::ReferencePromise; +type ReferencePromise = >::ReferencePromise; type BoxPredictor = Box, Reference, Request>>; pub struct StatelessEncoder where Backend: StatelessVideoEncoderBackend, - Codec: StatelessCodec + StatelessCodecSpecific, + Codec: StatelessCodec, { /// Pending frame output promise queue output_queue: OutputQueue>, @@ -335,14 +332,14 @@ where pub trait StatelessEncoderExecute where Backend: StatelessVideoEncoderBackend, - Codec: StatelessCodec + StatelessCodecSpecific, + Codec: StatelessCodec, { fn execute(&mut self, request: Request) -> EncodeResult<()>; } impl StatelessEncoder where - Codec: StatelessCodec + StatelessCodecSpecific, + Codec: StatelessCodec, Backend: StatelessVideoEncoderBackend, Self: StatelessEncoderExecute, { @@ -387,7 +384,7 @@ where impl StatelessVideoEncoder for StatelessEncoder where - Codec: StatelessCodec + StatelessCodecSpecific, + Codec: StatelessCodec, Backend: StatelessVideoEncoderBackend, Backend: StatelessEncoderBackendImport, Self: StatelessEncoderExecute, diff --git a/src/encoder/stateless/h264.rs b/src/encoder/stateless/h264.rs index 2e6cbef6..c9332fb9 100644 --- a/src/encoder/stateless/h264.rs +++ b/src/encoder/stateless/h264.rs @@ -18,7 +18,6 @@ use crate::encoder::stateless::FrameMetadata; use crate::encoder::stateless::Predictor; use crate::encoder::stateless::StatelessBackendResult; use crate::encoder::stateless::StatelessCodec; -use crate::encoder::stateless::StatelessCodecSpecific; use crate::encoder::stateless::StatelessEncoder; use crate::encoder::stateless::StatelessEncoderBackendImport; use crate::encoder::stateless::StatelessEncoderExecute; @@ -158,7 +157,7 @@ where pub struct H264; -impl StatelessCodecSpecific for H264 +impl StatelessCodec for H264 where Backend: StatelessVideoEncoderBackend, { @@ -171,8 +170,6 @@ where type ReferencePromise = ReferencePromise; } -impl StatelessCodec for H264 {} - /// Trait for stateless encoder backend for H.264 pub trait StatelessH264EncoderBackend: StatelessVideoEncoderBackend { /// Submit a [`BackendRequest`] to the backend. This operation returns both a diff --git a/src/encoder/stateless/vp9.rs b/src/encoder/stateless/vp9.rs index 5a47aff9..8d09b7f9 100644 --- a/src/encoder/stateless/vp9.rs +++ b/src/encoder/stateless/vp9.rs @@ -12,7 +12,6 @@ use crate::encoder::stateless::EncodeResult; use crate::encoder::stateless::Predictor; use crate::encoder::stateless::StatelessBackendResult; use crate::encoder::stateless::StatelessCodec; -use crate::encoder::stateless::StatelessCodecSpecific; use crate::encoder::stateless::StatelessEncoder; use crate::encoder::stateless::StatelessEncoderExecute; use crate::encoder::stateless::StatelessVideoEncoderBackend; @@ -83,7 +82,7 @@ pub struct BackendRequest { pub struct VP9; -impl StatelessCodecSpecific for VP9 +impl StatelessCodec for VP9 where Backend: StatelessVideoEncoderBackend, { @@ -96,8 +95,6 @@ where type ReferencePromise = Backend::ReconPromise; } -impl StatelessCodec for VP9 {} - pub trait StatelessVP9EncoderBackend: StatelessVideoEncoderBackend { fn encode_frame( &mut self,