Skip to content

Commit

Permalink
feat: image processor redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
TroyKomodo committed May 4, 2024
1 parent fc48d0e commit a62e76d
Show file tree
Hide file tree
Showing 39 changed files with 1,588 additions and 313 deletions.
159 changes: 107 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
members = [
"platform/api",
"image_processor",
"image_processor/proto",
"video/edge",
"video/ingest",
"video/transcoder",
Expand Down
2 changes: 0 additions & 2 deletions ffmpeg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ bytes = { optional = true, version = "1" }
tokio = { optional = true, version = "1" }
crossbeam-channel = { optional = true, version = "0.5" }
tracing = { optional = true, version = "0.1" }
scuffle-utils = { path = "../utils", version = "*", optional = true, features = ["task"]}

[features]
default = []
task-abort = ["dep:scuffle-utils"]
channel = ["dep:bytes"]
tokio-channel = ["channel", "dep:tokio"]
crossbeam-channel = ["channel", "dep:crossbeam-channel"]
Expand Down
9 changes: 0 additions & 9 deletions ffmpeg/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ impl GenericDecoder {
}

pub fn send_packet(&mut self, packet: &Packet) -> Result<(), FfmpegError> {
#[cfg(feature = "task-abort")]
let _guard = scuffle_utils::task::AbortGuard::new();

// Safety: `packet` is a valid pointer, and `self.decoder` is a valid pointer.
let ret = unsafe { avcodec_send_packet(self.decoder.as_mut_ptr(), packet.as_ptr()) };

Expand All @@ -165,9 +162,6 @@ impl GenericDecoder {
}

pub fn send_eof(&mut self) -> Result<(), FfmpegError> {
#[cfg(feature = "task-abort")]
let _guard = scuffle_utils::task::AbortGuard::new();

// Safety: `self.decoder` is a valid pointer.
let ret = unsafe { avcodec_send_packet(self.decoder.as_mut_ptr(), std::ptr::null()) };

Expand All @@ -178,9 +172,6 @@ impl GenericDecoder {
}

pub fn receive_frame(&mut self) -> Result<Option<VideoFrame>, FfmpegError> {
#[cfg(feature = "task-abort")]
let _guard = scuffle_utils::task::AbortGuard::new();

let mut frame = Frame::new()?;

// Safety: `frame` is a valid pointer, and `self.decoder` is a valid pointer.
Expand Down
15 changes: 0 additions & 15 deletions ffmpeg/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,6 @@ impl Encoder {
outgoing_time_base: AVRational,
settings: impl Into<EncoderSettings>,
) -> Result<Self, FfmpegError> {
#[cfg(feature = "task-abort")]
let _abort_guard = scuffle_utils::task::AbortGuard::new();

if codec.as_ptr().is_null() {
return Err(FfmpegError::NoEncoder);
}
Expand Down Expand Up @@ -489,9 +486,6 @@ impl Encoder {
}

pub fn send_eof(&mut self) -> Result<(), FfmpegError> {
#[cfg(feature = "task-abort")]
let _abort_guard = scuffle_utils::task::AbortGuard::new();

// Safety: `self.encoder` is a valid pointer.
let ret = unsafe { avcodec_send_frame(self.encoder.as_mut_ptr(), std::ptr::null()) };
if ret == 0 {
Expand All @@ -502,9 +496,6 @@ impl Encoder {
}

pub fn send_frame(&mut self, frame: &Frame) -> Result<(), FfmpegError> {
#[cfg(feature = "task-abort")]
let _abort_guard = scuffle_utils::task::AbortGuard::new();

// Safety: `self.encoder` and `frame` are valid pointers.
let ret = unsafe { avcodec_send_frame(self.encoder.as_mut_ptr(), frame.as_ptr()) };
if ret == 0 {
Expand All @@ -515,9 +506,6 @@ impl Encoder {
}

pub fn receive_packet(&mut self) -> Result<Option<Packet>, FfmpegError> {
#[cfg(feature = "task-abort")]
let _abort_guard = scuffle_utils::task::AbortGuard::new();

let mut packet = Packet::new()?;

const AVERROR_EAGAIN: i32 = AVERROR(EAGAIN);
Expand Down Expand Up @@ -631,9 +619,6 @@ impl<T: Send + Sync> MuxerEncoder<T> {
}

pub fn send_eof(&mut self) -> Result<(), FfmpegError> {
#[cfg(feature = "task-abort")]
let _abort_guard = scuffle_utils::task::AbortGuard::new();

self.encoder.send_eof()?;
self.handle_packets()?;

Expand Down
Loading

0 comments on commit a62e76d

Please sign in to comment.