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

[GStreamer] Rewrite inner decoder leveraging the GStreamerElementHarness #8971

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

philn
Copy link
Member

@philn philn commented Jan 23, 2023

fa3503d

[GStreamer] Rewrite inner decoder leveraging the GStreamerElementHarness
https://bugs.webkit.org/show_bug.cgi?id=250934

Reviewed by Xabier Rodriguez-Calvar.

The previous decoder implementation relied on a GStreamer pipeline involving giostreamsrc,
decodebin3 and appsinks. Due to the highly asynchronous behavior of that pipeline the decoder
heavily relied on Locks and Conditions making the code hard to follow and debug.

The new implementation relies on two element harnesses, the first one is in charge of parsing (with
parsebin), the first parsed video output stream is then plugged to a decode harness, directly hooked
to the platform video decoder, so no queue is involved. The decoding no longer involves additional
threads, so we can simplify the code and entirely get rid of InnerDecoder.

Canonical link: https://commits.webkit.org/259430@main

50b6913

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ webkitpy βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
❌ πŸ›  πŸ§ͺ jsc βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  jsc-armv7
βœ… πŸ›  πŸ§ͺ jsc-arm64 βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ§ͺ services βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ›  jsc-mips
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim βœ… πŸ§ͺ jsc-mips-tests

@philn philn self-assigned this Jan 23, 2023
@philn philn added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label Jan 23, 2023
@philn philn requested a review from calvaris January 23, 2023 14:06
@philn
Copy link
Member Author

philn commented Jan 23, 2023

The decoder diff won't be easy to read... I'd advise to read the final code instead.

Copy link
Contributor

@calvaris calvaris left a comment

Choose a reason for hiding this comment

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

Other than the changes I also commented, I think it could be a good idea to change the interface of pushBuffer and pushBufferFull for them to take a GRefPtr&& that gives an explicit view of ownership. Maybe even all push* functions could use a similar interface.

The downside of this is that you have to WTFMove objects and adopt the ones with [transfer full] before passing them down, or we'd be leaking.

About this I don't have a strong opinion so I just leave it here as "food for thought".

@philn philn requested a review from calvaris January 25, 2023 16:58
@@ -1041,6 +1041,19 @@ void fillVideoInfoColorimetryFromColorSpace(GstVideoInfo* info, const PlatformVi
GST_VIDEO_INFO_COLORIMETRY(info).range = GST_VIDEO_COLOR_RANGE_UNKNOWN;
}

void configureVideoDecoderForHarnessing(const GRefPtr<GstElement>& element)
{
auto elementHasProperty = [&](const char* name) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not the first time I see this, please strongly consider moving this to GStreamerCommon and refactor all appearances. It does not have to be in this PR though.

@philn philn added the merge-queue Applied to send a pull request to merge-queue label Jan 26, 2023
https://bugs.webkit.org/show_bug.cgi?id=250934

Reviewed by Xabier Rodriguez-Calvar.

The previous decoder implementation relied on a GStreamer pipeline involving giostreamsrc,
decodebin3 and appsinks. Due to the highly asynchronous behavior of that pipeline the decoder
heavily relied on Locks and Conditions making the code hard to follow and debug.

The new implementation relies on two element harnesses, the first one is in charge of parsing (with
parsebin), the first parsed video output stream is then plugged to a decode harness, directly hooked
to the platform video decoder, so no queue is involved. The decoding no longer involves additional
threads, so we can simplify the code and entirely get rid of InnerDecoder.

Canonical link: https://commits.webkit.org/259430@main
@webkit-commit-queue
Copy link
Collaborator

Committed 259430@main (fa3503d): https://commits.webkit.org/259430@main

Reviewed commits have been landed. Closing PR #8971 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit fa3503d into WebKit:main Jan 26, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jan 26, 2023
@philn philn deleted the eng/250934 branch January 26, 2023 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
4 participants