-
Notifications
You must be signed in to change notification settings - Fork 89
[wip] Combine encoding into DeviceInterface #1213
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
base: main
Are you sure you want to change the base?
[wip] Combine encoding into DeviceInterface #1213
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1213
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 66622e4 with merge base e93fc31 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| return std::string("CPU Device Interface."); | ||
| } | ||
|
|
||
| UniqueAVFrame CpuDeviceInterface::convertTensorToAVFrameForEncoding( |
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.
CPU specific encoding implementation is removed from Encoder.cpp and added here.
| avFrame = convertTensorToAVFrame(currFrame, i); | ||
| } | ||
| UniqueAVFrame avFrame = deviceInterface_->convertTensorToAVFrameForEncoding( | ||
| currFrame, i, avCodecContext_.get()); |
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.
Device interface handles both CPU and CUDA, and removes repeated conditionals:
if (frames_.device().is_cuda && deviceInterface_) { ... }
| UniqueEncodingAVFormatContext avFormatContext_; | ||
| UniqueAVCodecContext avCodecContext_; | ||
| AVStream* avStream_ = nullptr; | ||
| UniqueSwsContext swsContext_; |
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.
This member variable is deleted in favor of the swsContext_ in CpuDeviceInterface.h.
| // It is here to isolate CUDA dependencies from CPU builds | ||
| // TODO Video-Encoder: Reconsider using video encoding functions in device | ||
| // interface | ||
| virtual UniqueAVFrame convertCUDATensorToAVFrameForEncoding( |
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.
We replace convertCUDATensor... with convertTensor... to integrate into the device interface pattern.
No description provided.