-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: address technical debt across codebase #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a8d5a1
e0a1da8
7639dde
98c8a44
0b9e6a8
22efe8a
122909f
4b942f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -94,12 +94,28 @@ impl VideoComposer for RsmpegVideoComposer { | |||||||||||||||||||||||||||||||||||||||||||
| let mut stream_mapping: Vec<Option<usize>> = Vec::new(); | ||||||||||||||||||||||||||||||||||||||||||||
| for stream in first_input.streams().iter() { | ||||||||||||||||||||||||||||||||||||||||||||
| let mut out_stream = output_ctx.new_stream(); | ||||||||||||||||||||||||||||||||||||||||||||
| // SAFETY: avcodec_parameters_alloc allocates a new parameters struct. | ||||||||||||||||||||||||||||||||||||||||||||
| // We check for null before calling avcodec_parameters_copy. | ||||||||||||||||||||||||||||||||||||||||||||
| // avcodec_parameters_copy returns 0 on success, negative on error. | ||||||||||||||||||||||||||||||||||||||||||||
| // On error, we free the allocated struct before returning. | ||||||||||||||||||||||||||||||||||||||||||||
| // The from_raw conversion is safe because we verified the pointer is non-null. | ||||||||||||||||||||||||||||||||||||||||||||
| let codecpar = unsafe { | ||||||||||||||||||||||||||||||||||||||||||||
| let new_par = ffi::avcodec_parameters_alloc(); | ||||||||||||||||||||||||||||||||||||||||||||
| ffi::avcodec_parameters_copy(new_par, stream.codecpar().as_ptr() as *const _); | ||||||||||||||||||||||||||||||||||||||||||||
| rsmpeg::avcodec::AVCodecParameters::from_raw( | ||||||||||||||||||||||||||||||||||||||||||||
| std::ptr::NonNull::new(new_par).unwrap(), | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
| let new_par = std::ptr::NonNull::new(new_par) | ||||||||||||||||||||||||||||||||||||||||||||
| .ok_or_else(|| RoboflowError::other("failed to allocate codec parameters"))?; | ||||||||||||||||||||||||||||||||||||||||||||
| let ret = ffi::avcodec_parameters_copy( | ||||||||||||||||||||||||||||||||||||||||||||
| new_par.as_ptr(), | ||||||||||||||||||||||||||||||||||||||||||||
| stream.codecpar().as_ptr() as *const _, | ||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||
| if ret < 0 { | ||||||||||||||||||||||||||||||||||||||||||||
| let mut ptr = new_par.as_ptr(); | ||||||||||||||||||||||||||||||||||||||||||||
| ffi::avcodec_parameters_free(&mut ptr); | ||||||||||||||||||||||||||||||||||||||||||||
| return Err(RoboflowError::other(format!( | ||||||||||||||||||||||||||||||||||||||||||||
| "avcodec_parameters_copy failed: error code {}", | ||||||||||||||||||||||||||||||||||||||||||||
| ret | ||||||||||||||||||||||||||||||||||||||||||||
| ))); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+106
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Memory leak on the error path: if
Suggested change
Fix it with Roo Code or mention @roomote and request a fix. |
||||||||||||||||||||||||||||||||||||||||||||
| rsmpeg::avcodec::AVCodecParameters::from_raw(new_par) | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
| out_stream.set_codecpar(codecpar); | ||||||||||||||||||||||||||||||||||||||||||||
| out_stream.set_time_base(AVRational { | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roboflow_mediais now optional but used unconditionally. Sincecommonmodule is used by multiple formats, either:roboflow_mediaalways required (not optional), OR#[cfg(feature = "lerobot")]Current state will cause compilation errors when default features are disabled.
Prompt To Fix With AI