-
Notifications
You must be signed in to change notification settings - Fork 631
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
Improve video decoder seeking and reset behavior #5830
Conversation
Signed-off-by: Joaquin Anton Guirao <[email protected]>
} | ||
} | ||
|
||
if (av_state_->codec_params_->codec_type != AVMEDIA_TYPE_VIDEO) { |
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.
Where av_state_->codec_params_->codec_type
from if av_state_->codec_params_->codec_type
is false?
@@ -282,6 +293,7 @@ class DLL_PUBLIC FramesDecoderBase { | |||
std::optional<MemoryVideoFile> memory_video_file_ = {}; | |||
|
|||
std::optional<int> num_frames_ = {}; | |||
std::optional<bool> is_seekable_ = {}; |
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.
Does it need to be optional?
if (!is_seekable_.has_value()) { | ||
is_seekable_ = ret >= 0; | ||
} |
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.
Looks convoluted
uint8_t *av_io_buffer = static_cast<uint8_t *>(av_malloc(default_av_buffer_size)); | ||
AVIOContext *av_io_context = avio_alloc_context( | ||
av_io_buffer, default_av_buffer_size, 0, &memory_video_file_.value(), | ||
detail::read_memory_video_file, nullptr, detail::seek_memory_video_file); | ||
av_state_->ctx_->pb = av_io_context; |
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.
- What if allocation fails?
- Shouldn't we clean up
av_state_->ctx_->pb
?
auto custom_ctx = ctx_->pb;
auto custom_buffer = ctx_->pb ? ctx_->pb->buffer : nullptr;
if (custom_dealloc) {
av_freep(&custom_buffer);
avio_context_free(&custom_ctx);
}
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.
- I'll handle that
- No need, it already gets cleaned up when we do
av_state_ = std::make_unique<AvState>();
3f64339
to
40dd932
Compare
!build |
CI MESSAGE: [24605517]: BUILD STARTED |
int AvState::OpenFile(const std::string& filename) { | ||
LOG_LINE << "Opening file " << filename << std::endl; | ||
CloseInput(); | ||
DALI_ENFORCE((ctx_ = avformat_alloc_context()), "Could not alloc avformat context"); |
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.
I'm not sure if we should put assignment to DALI_ENFORCE
Signed-off-by: Joaquin Anton Guirao <[email protected]>
40dd932
to
28b9821
Compare
Signed-off-by: Joaquin Anton Guirao <[email protected]>
CI MESSAGE: [24606155]: BUILD STARTED |
CI MESSAGE: [24606525]: BUILD STARTED |
Signed-off-by: Joaquin Anton Guirao <[email protected]>
CI MESSAGE: [24611381]: BUILD STARTED |
CI MESSAGE: [24611422]: BUILD STARTED |
CI MESSAGE: [24606525]: BUILD FAILED |
CI MESSAGE: [24606155]: BUILD FAILED |
} | ||
av_state_->frame_ = av_frame_alloc(); | ||
if (ret != 0) { |
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.
Typo?
if (ret != 0) { | |
if (av_state_->frame_ == nullptr) { |
CI MESSAGE: [24611381]: BUILD FAILED |
CI MESSAGE: [24611422]: BUILD FAILED |
Signed-off-by: Joaquin Anton Guirao <[email protected]>
CI MESSAGE: [24670395]: BUILD STARTED |
Signed-off-by: Joaquin Anton Guirao <[email protected]>
CI MESSAGE: [24670395]: BUILD PASSED |
Category:
Refactoring / New feature / Bug fix
Description:
Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A