Commit Graph

49605 Commits

Author SHA1 Message Date
Zaggy1024
b10da81c7c LibVideo: Fast-path converting colors by only matrix coefficients
We don't need to run through the whole floating-point color converter
for videos that use sRGB transfer characteristics and BT.709 color
primaries. This commit adds a new templated inlining function to
ColorConverter to do a very fast fixed-point YCbCr to RGB conversion.

With the fast path, frame conversion times go from ~7.8ms down to
~3.7ms. The fast path can benefit a lot more from extra SIMD vector
width, as well.
2023-04-25 17:44:36 -04:00
Zaggy1024
d6b867ba89 LibVideo/VP9: Force inlining of inverse_transform_2d() and the IDCT
Clang was reluctant to inline these for some reason. However, inlining
them seems to be quite beneficial, reducing decoding time in an intra-
heavy video by about 21% (~12.7s -> ~10.0s).
2023-04-25 17:44:36 -04:00
Zaggy1024
90c0e1ad8f LibVideo/VP9: Pre-calculate the quantizers at the start of each frame
Quantizers are a constant for the whole frame, except when segment
features override them, in which case they are a constant per segment
ID. We take advantage of this by pre-calculating those after reading
the quantization parameters and segmentation features for a frame.
This results in a small 1.5% improvement (~12.9s -> ~12.7s).
2023-04-25 17:44:36 -04:00
Zaggy1024
094b0d8a78 LibVideo/VP9: Use an enum to select segment features
This throws out some ugly `#define`s we had that were taking the role
of an enum anyway. We now have some nice getters in the contexts that
take the place of the combo of `seg_feature_active()` and then doing a
lookup in `FrameContext::m_segmentation_features` directly.
2023-04-25 17:44:36 -04:00
Zaggy1024
6e6cc1ddb2 LibVideo/VP9: Make a lookup table for bit reversals
Bit reversals are used very often in intra-predicted frames. Turning
these into a constexpr lookup table reduces the branching needed for
block transforms significantly. This reduces the times spent decoding
an intra-heavy 1080p video by about 9% (~14.3s -> ~12.9s).
2023-04-25 17:44:36 -04:00
Zaggy1024
f6764beead LibVideo/VP9: Specialize transforms on their block size
Previously, the block sizes would be checked at runtime to
determine the transform size to apply for residuals. Making the block
sizes into constant expressions allows all the loops to be unrolled
and reduces branching significantly.

This results in about a 26% improvement (~18s -> ~13.2s) in speed in an
intra-heavy test video.
2023-04-25 17:44:36 -04:00
Zaggy1024
5b4c1056f1 LibVideo/Color: Always inline convert_yuv_to_full_range_rgb()
Inlining the color conversion reduces time spent for frame conversions
in a 1080p video from ~12ms down to ~9ms.
2023-04-25 17:44:36 -04:00
Zaggy1024
8ad0dff5c2 LibVideo/VP9: Implement unscaled fast paths in inter prediction
Inter-prediction convolution filters are selected based on the
subpixel position determined for the motion vector relative to the
block being predicted. The subpixel position 0 only uses one single
sample in the center of the convolution, not averaging any other
samples. Let's call this a copy.

Reference frames can also be a different size relative to the frame
being predicted, but in almost every case, that scale will be 1:1
for every single frame in a video.

Taking into account these facts, we can create multiple fast paths for
inter prediction. These fast paths are only active when scaling is 1:1.

If we are doing a copy in both dimensions, then we can do a straight
memcpy from the reference frame to the output block buffer. In videos
where there is no motion, this is a dramatic speedup.

If we are doing a copy in one dimension, we can just do one convolution
and average directly into the output block buffer.

If we aren't doing a copy in either dimension, we can still cut out a
few operations from the convolution loops, since we only need to
advance our samples by whole pixels instead of subpixels.

These fast paths result in about a 34% improvement (~31.2s -> ~20.6s)
in a video which relies heavily on intra-predicted blocks due to high
motion. In videos with less motion, the improvement will be even
greater.

Also, note that the accumulators in these faster loops are only 16-bit.
High bit-depth videos will overflow those, so for now the fast path is
only used for 8-bit videos.
2023-04-25 17:44:36 -04:00
Zaggy1024
8cd72ad1ed LibVideo/VP9: Use the Y scale value in predict_inter_block()
A typo caused the Y scale value to never be used, so if a reference
frame's aspect ratio didn't match up with the current frame's, it would
decode incorrectly.

Some comments have been added to clarify the frame-constants used in
the function as well.
2023-04-25 17:44:36 -04:00
Zaggy1024
7a58577fee LibVideo: Convert subsampled frames in a vectorization-friendly way
This change reduces the time spent converting frames for display in
a 1080p video from ~19ms per frame to ~12ms per frame.
2023-04-25 17:44:36 -04:00
Zaggy1024
f2c0cee522 LibVideo/VP9: Consolidate frame size calculations
This moves all the frame size calculation to `FrameContext`, where the
subsampling is easily accessible to determine the size for each plane.
The internal framebuffer size has also been reduced to the exact frame
size that is output.
2023-04-25 17:44:36 -04:00
Zaggy1024
57c7389200 LibVideo/VP9: Fix rounding of components in the motion vector selection
The division in the `round_mv_...()` functions contained in the motion
vector selection process was done by bit shifting right. However, since
bit shifting negative values will truncate towards the negative end, it
was flooring instead of rounding.

This changes it to match the spec and rely on the compiler to simplify
down to a bit shift.
2023-04-25 17:44:36 -04:00
Jelle Raaijmakers
7b10c8048c WindowServer: Draw stretched wallpapers with bilinear blending
This improves the quality of stretched photos and artwork considerably,
and I'd argue that this is what users will expect by default.
2023-04-25 22:37:57 +02:00
Fabian Dellwing
6acf03d9a8 Ports: Add default zshrc
Previosly we had a very messed up PS1 as the Shell PROMPT is not
unset correctly.

We now provide a default `zshrc` file for the system that uses
sane values for basic categories like aliases, autocompletion and
history management to make the port more usable. It also forces
the prompt to be the default zsh one.
2023-04-25 20:48:51 +02:00
Timothy Flynn
3d4d0a1243 Kernel: Colorize log message for paths which haven't been unveiled
The log message can be hard to spot in a sea of debug messages. Colorize
it to make the message more immediately pop out.
2023-04-25 18:04:15 +02:00
nipos
938a4e26b5 LibCore: Include sys/ucred.h in System.h for FreeBSD 2023-04-25 18:04:05 +02:00
Timothy Flynn
374a24d84c LibVideo: Remove hook to override LibVideo's playback timers
This was added to allow Ladybird to override the timers with Qt timers.
2023-04-25 18:02:22 +02:00
Timothy Flynn
78ad471367 LibWeb: Remove custom playback timer from HTMLMediaElement
After the EventLoop changes, we do not need to override LibVideo's timer
with a Qt timer for Ladybird. The timer callback provided here also does
not need the JS::SafeFunction wrapper that Platform::Timer provides.
2023-04-25 18:02:22 +02:00
Andreas Kling
e5b97f4a57 WebContent: Always update layout before dumping layout tree
This fixes an issue where layout tests were sometimes flakey because
we tried dumping the layout tree before one had been built(!)
2023-04-25 18:01:35 +02:00
Andreas Kling
e66313e536 LibCore: Remove unused cruft in EventLoop.h 2023-04-25 18:01:35 +02:00
Andreas Kling
7b963e1e98 LibCore+Ladybird: Add EventLoopManager interface for persistent state
Things such as timers and notifiers aren't specific to one instance of
Core::EventLoop, so let's not tie them down to EventLoopImplementation.

Instead, move those APIs + signals & a few other things to a new
EventLoopManager interface. EventLoopManager also knows how to create a
new EventLoopImplementation object.
2023-04-25 18:01:35 +02:00
Andreas Kling
c21eb30a2b Ladybird+LibCore: Use QCoreApplication to drive the main Qt event loop
Using QEventLoop works for everything but it breaks *one* little feature
that we care about: automatically quitting the app when all windows have
been closed.

That only works if you drive the outermost main event loop with a
QCoreApplication instead of a QEventLoop. This is unfortunate, as it
complicates our API a little bit, but I'm sure we can think of a way to
make this nicer someday.

In order for QCoreApplication::exec() to process our own
ThreadEventQueue, we now have a zero-timer that we kick whenever new
events are posted to the thread queue.
2023-04-25 18:01:35 +02:00
Jelle Raaijmakers
0f22dfa634 LibAudio: Make WavWriter check if a file was set during destruction
`WavWriter` can be constructed without a file, which should probably be
made impossible at some point. For now, let's not crash `Piano` when you
close the application.
2023-04-25 15:34:14 +02:00
Andreas Kling
1c6c3685c4 Ladybird: Remove Web::Platform plugins for Qt in favor of LibCore
Now that the Core::EventLoop is driven by a QEventLoop in Ladybird,
we don't need to patch LibWeb with Web::Platform plugins.

This patch removes EventLoopPluginQt and TimerQt.

Note that we can't just replace the Web::Platform abstractions with
LibCore stuff immediately, since the Web::Platform APIs use
JS::SafeFunction for callbacks.
2023-04-25 14:48:40 +02:00
Andreas Kling
3494c2382d Ladybird: Run the Core::EventLoop with a Qt backend
This patch adds EventLoopImplementationQt which is a full replacement
for the Core::EventLoopImplementationUnix that uses Qt's event loop
as a backend instead.

This means that Core::Timer, Core::Notifier, and Core::Event delivery
are all driven by Qt primitives in the Ladybird UI and WC processes.
2023-04-25 14:48:40 +02:00
Andreas Kling
31289a8d57 LibCore: Add a hook for custom construction of EventLoopImplementation 2023-04-25 14:48:40 +02:00
Andreas Kling
16c47ccff6 LibCore: Big first step towards pluggable Core::EventLoop
The EventLoop is now a wrapper around an EventLoopImplementation.
Our old EventLoop code has moved into EventLoopImplementationUnix and
continues to work as before.

The main difference is that all the separate thread_local variables have
been collected into a file-local ThreadData data structure.

The goal here is to allow running Core::EventLoop with a totally
different backend, such as Qt for Ladybird.
2023-04-25 14:48:40 +02:00
Andreas Kling
3de8dd921e Userland: Remove serialize-to-JSON functions only used for Inspector 2023-04-25 14:48:40 +02:00
Andreas Kling
c756e021a7 Userland: Remove "Inspector" program and related utilities
This program has never lived up to its original idea, and has been
broken for years (property editing, etc). It's also unmaintained and
off-by-default since forever.

At this point, Inspector is more of a maintenance burden than a feature,
so this commit removes it from the system, along with the mechanism in
Core::EventLoop that enables it.

If we decide we want the feature again in the future, it can be
reimplemented better. :^)
2023-04-25 14:48:40 +02:00
Andreas Kling
203e84c378 LibCore: Remove unused EventLoop::Private::lock
This mutex is no longer used for anything.
2023-04-25 14:48:40 +02:00
Andreas Kling
a6a2caf6db LibCore: Remove unused "client ID" from InspectorServerConnection
This was sharing an ID allocator with event loop timers for some reason.
More importantly, it wasn't actually used for anything.
2023-04-25 14:48:40 +02:00
Andreas Kling
8e7d7b0ec2 LibCore: Remove some unnecessary includes from EventLoop.h 2023-04-25 14:48:40 +02:00
Andreas Kling
029f5b0dad LibCore: Move deferred_invoke() implementation out of line 2023-04-25 14:48:40 +02:00
Andreas Kling
411d36719e LibCore: Simplify Core::Notifier by only allowing one event type
Not a single client of this API actually used the event mask feature to
listen for readability AND writability.

Let's simplify the API and have only one hook: on_activation.
2023-04-25 14:48:40 +02:00
Andreas Kling
1587caef84 LibCore: Move event queueing to a per-thread event queue
Instead of juggling events between individual instances of
Core::EventLoop, move queueing and processing to a separate per-thread
queue (ThreadEventQueue).
2023-04-25 14:48:40 +02:00
Andreas Kling
3a70a16ca7 LibCore: Remove unused EventLoop::wake_current() 2023-04-25 14:48:40 +02:00
Andreas Kling
9601b516b8 LibCore: Remove awkward EventLoop::wake_once() API
This was used in exactly one place, to avoid sending multiple
CustomEvents to the enqueuer thread in Audio::ConnectionToServer.

Instead of this, we now just send a CustomEvent and wake the enqueuer
thread. If it wakes up and has multiple CustomEvents, they get delivered
and ignored in no time anyway. Since they only get ignored if there's
no work to be done, this seems harmless.
2023-04-25 14:48:40 +02:00
Tim Ledbetter
896d1e4f42 LibSQL: Handle statements with malformed exists expressions correctly
Previously, statements containing malformed exists expressions such as:

`INSERT INTO t(a) VALUES (SELECT 1)`;

could cause the parser to crash. The parser will now return an error
message instead.
2023-04-25 08:32:21 -04:00
Emil Militzer
880878e552 LibWeb: Add missing valid-identifiers for display CSS property 2023-04-25 13:46:11 +02:00
Aliaksandr Kalenik
ce9d9a10b8 LibWeb: Start fleshing out Navigable::navigate()
Start implementation of https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate

Co-authored-by: Andreas Kling <kling@serenityos.org>
2023-04-25 12:54:01 +02:00
Aliaksandr Kalenik
1ee4a3e310 LibWeb: Add m_ongoing_navigation in Navigable 2023-04-25 12:54:01 +02:00
Andreas Kling
2626e28bb6 LibWeb: Add HTML::Task::Source::NavigationAndTraversal 2023-04-25 12:54:01 +02:00
Andreas Kling
aef36ce828 LibWeb: Add ReferrerPolicy::EmptyString
One of the valid enum values for "referrer policy" is the empty string.
Since we're using an enum for this, just add it as an enum value.
2023-04-25 12:54:01 +02:00
Andreas Kling
4d8edf65b5 LibWeb: Add HistoryHandlingBehavior::Push
Also add FIXMEs about removing no-longer-used enum values.
2023-04-25 12:54:01 +02:00
Aliaksandr Kalenik
5446c7adc3 LibWeb: Add HTML::POSTResource
This is "POST resource" from the HTML spec.
2023-04-25 12:54:01 +02:00
Emil Militzer
50af15e6b8 LibWeb: Fix the update of the favicon during navigation
The check on the currently active document for an existing favicon has
been removed. It caused an issue during navigation because the active
document will only be updated after the load and the favicon check has
been executed against the old document.
2023-04-25 06:50:34 -04:00
Zaggy1024
eba72fa3a7 LibVideo/VP9: Wait for workers to finish when there are decoding errors
Previously, the `Parser::decode_tiles()` function wouldn't wait for the
tile-decoding workers to finish before exiting the function, which
could mean that the data the threads are working with could become
invalid if the decoder is deleted after an error is encountered.
2023-04-25 06:35:13 -04:00
Pankaj Raghav
8944ca830f Kernel: Remove is_sharing_with_others API from GenericInterruptHandler
is_sharing_with_others API was never really put to use properly since
it was introduced. The only place where it is used in Interrupts.cpp is
in conjuction with is_shared_handler() which is only true for
SharedIRQHandler and is_sharing_with_others will always return false.

Remove that API.
2023-04-25 10:18:39 +02:00
Pankaj Raghav
756a73471e Kernel: Use SpinlockProtected list in SharedIRQHandler
Adding handlers to the SharedIRQHandler without any lock is not thread
safe. Use SpinlockProtected list instead.
2023-04-25 10:18:39 +02:00
Pankaj Raghav
fd8a154f8c Kernel: Set IRQHandler m_shared_with_others when the irq is shared
If IRQHandler's IRQ is shared, then disable_irq() should not call the
controller to disable that IRQ as some other device might be using it.
IRQHandler had a private variable to indicate if it is being shared:
m_shared_with_others but it was never modified even if the IRQ was
shared.

Add a new member function set_shared_with_others() to enable/disable
m_shared_with_others member of IRQHandler class. This function is
called when an IRQHandler is being added/removed as a part of
SharedIRQHandler.
2023-04-25 10:18:39 +02:00