Skip to content
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

Restructure the video/video_reader C++ codebase #3311

Merged
merged 5 commits into from
Jan 28, 2021

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented Jan 27, 2021

Fixes #3155

Copy link
Contributor Author

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I provide explanations to some modifications below:

.def("set_current_stream", &Video::setCurrentStream)
.def("get_metadata", &Video::getStreamMetadata)
.def("seek", &Video::Seek)
.def("next", &Video::Next);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from register.cpp

@@ -417,95 +418,6 @@ torch::List<torch::Tensor> readVideo(
return result;
}

torch::List<torch::Tensor> readVideoFromMemory(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving out of the anonymous namespace.

torch::List<torch::Tensor> probeVideoFromMemory(torch::Tensor input_video) {
} // namespace

torch::List<torch::Tensor> read_video_from_memory(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"public" methods.

m.def("read_video_from_memory", read_video_from_memory);
m.def("read_video_from_file", read_video_from_file);
m.def("probe_video_from_memory", probe_video_from_memory);
m.def("probe_video_from_file", probe_video_from_file);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration of methods within the namespaces at the end of the file.

@@ -18,8 +14,13 @@ PyMODINIT_FUNC PyInit_video_reader(void) {
}
#endif

using namespace ffmpeg;

namespace vision {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow similar pattern as vision::ops

namespace vision {
namespace video_reader {

torch::List<torch::Tensor> read_video_from_memory(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public methods in header

@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #3311 (4802cde) into master (691ec6d) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3311   +/-   ##
=======================================
  Coverage   73.93%   73.93%           
=======================================
  Files         104      104           
  Lines        9594     9594           
  Branches     1531     1531           
=======================================
  Hits         7093     7093           
  Misses       2024     2024           
  Partials      477      477           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 691ec6d...4802cde. Read the comment docs.

@datumbox datumbox changed the title [WIP] Restructure the video/video_reader C++ codebase Restructure the video/video_reader C++ codebase Jan 27, 2021
@datumbox datumbox requested a review from fmassa January 27, 2021 20:18
datumbox added a commit to datumbox/vision that referenced this pull request Jan 27, 2021
datumbox added a commit to datumbox/vision that referenced this pull request Jan 27, 2021
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thanks!

One thing I was thinking was if in the future we would want to move decoder inside video, and have both video_reader and video.cpp within the video folder.
Something like

io/
    image/
    video/
        decoder/
        video.cpp
        video_reader_legacy.cpp (renamed from video_reader)
        ...

This is minor though, but just passed through my mind as something which could improve in clarity about the role of the different video decoders

@datumbox
Copy link
Contributor Author

datumbox commented Jan 28, 2021

@fmassa Do you think it makes sense to move decoder and video_reader in video now? The next release brings LOTS of changes on the C++ API, so we might as well do that now?

Edit: We agreed to do it on a separate PR to take care of building code on FBcode.

Note: This PR will need special handling for merging into FBcode. See D26110952.

@datumbox datumbox merged commit e95a3d2 into pytorch:master Jan 28, 2021
@datumbox datumbox deleted the refactor/video branch January 28, 2021 10:09
@datumbox datumbox mentioned this pull request Jan 28, 2021
13 tasks
facebook-github-bot pushed a commit that referenced this pull request Feb 2, 2021
Summary:
* Moving registration of video methods in Video.cpp and removing unnecessary includes.

* Rename files according to cpp styles.

* Adding namespaces and moving private methods to anonymous namespaces.

* Syncing method names.

* Fixing minor issues.

Reviewed By: fmassa

Differential Revision: D26197746

fbshipit-source-id: dfeaa3144574899e5dfe32fee21575a8c3602cd0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restructure and clean up the video/video_reader C++ implementations
3 participants