Commit graph

62029 commits

Author SHA1 Message Date
Zaggy1024
2d04f89347 Tests/LibMedia: Move video decode testing function to a header
This will be useful for other video codecs, but putting all codecs in
one file will be a little messy.

(cherry picked from commit 48a21d5d6a203563eab60922f8c24202d0ed7e10)
2024-07-04 22:09:32 +02:00
Zaggy1024
1dbe715690 LibMedia/Matroska: Make SampleIterator getters const
(cherry picked from commit 32714878ad9e5c15b2e46428bbc7bebfe8fe3029)
2024-07-04 22:09:32 +02:00
Zaggy1024
f57d2acf05 LibMedia: Retrieve codec initialization data from Matroska files
This is necessary to give H.264 decoders the data they need to
initialize, including frame size and profile.

(cherry picked from commit 457a69786b788d3158813156d11e70980f50f7b7)
2024-07-04 22:09:32 +02:00
Zaggy1024
b2668c8c6c LibMedia/Matroska: Move the definition get_codec_id_for_track up
The function is separated from the string-to-enum function it uses, and
the order is also inconsistent with header.

(cherry picked from commit bf1e0fac94e0d8599c0c540c24883ca5f5ea4131)
2024-07-04 22:09:32 +02:00
Zaggy1024
def171b4a8 LibMedia/Matroska: Make track entries ref-counted
These aren't particularly small objects, but we were still copying them
around all over the place. When TrackEntry contains data buffers, they
won't need to be copied as well.

(cherry picked from commit 55fda2068b7334acaba2673c80c01c019aaf7075)
2024-07-04 22:09:32 +02:00
Zaggy1024
2dfa68085a LibMedia: Store YUV planes as byte arrays with no padding for 8-bit
This should halve the size of frames in memory for frames with 8-bit
color components, which is the majority of videos.

Calculation of the size of subsampled planes has also been consolidated
into a struct. There are likely some places that will still need to
change over to this, but it should prevent issues due to differing
handling of rounding/ceiling.

(cherry picked from commit 40fe0cb9d5c40a5ee568a3196bf19452ea8fed2b)
2024-07-04 22:09:32 +02:00
Zaggy1024
1fe34874ca LibMedia: Split output bitmap size assertions to individual lines
Now Clang will stop complaining about DeMorgan's theorem.

(cherry picked from commit b49d3dcf6fbe972a46555d751e998c1e7bd5e4a2)
2024-07-04 22:09:32 +02:00
Zaggy1024
e0f3bc2b32 LibMedia: Remove fixed-point path for BT.2020 matrix coefficients
BT.2020 will mainly be used with bit depths greater than 8, so having
this specialization is mostly pointless until we use fixed-point math
for higher bit depths.

(cherry picked from commit fe2a63d485bc9d494b06a780043eae21adfd6854)
2024-07-04 22:09:32 +02:00
Zaggy1024
a6153cb062 LibMedia: Ensure that buffers passed to SubsampledYUVFrame are moved
(cherry picked from commit 6f8389c48377244e631a4eb1a7423d89033a64bc)
2024-07-04 22:09:32 +02:00
Zaggy1024
d7b24c0c30 LibMedia/Matroska: Actually read out the video color range
Apparently I forgot to put read the value for this field, though this
generally doesn't matter since video bitstreams usually specify CICP as
well.

(cherry picked from commit d3f88b4987730e396bc41c2674edddb53845cb37)
2024-07-04 22:09:32 +02:00
Zaggy1024
9e2abedbf9 LibMedia: Add formatters for CICP and its components
This is often useful for debugging.

(cherry picked from commit a99ff1fcb4ed7636f7c6ab47425f0b2feb2ecbd9)
2024-07-04 22:09:32 +02:00
Zaggy1024
9592f8766f LibMedia: Remove unused includes from VideoSampleData.h
(cherry picked from commit 291c1c3bd0af42e9c94dba4e7f256ba2c2d7a6b8)
2024-07-04 22:09:32 +02:00
Zaggy1024
55173b7b08 LibMedia: Make Media::Sample final using Variant for auxiliary data
We don't need to allocate these little things onto the heap, that's
silly.

(cherry picked from commit 5a6950be8ea0830dd5b810e6a6bd7e2e8326e4df)
2024-07-04 22:09:32 +02:00
Zaggy1024
0a525881b6 LibMedia: Rename LibVideo to LibMedia
This change is in preparation for implementing audio codecs into the
library and using audio as timing for video playback.

(cherry picked from commit 7c10e1a08d7a109b63c9258578eb98aa9dcc1425)
2024-07-04 22:09:32 +02:00
Dennis Camera
9fa81ae1fb LibCrypto: Use ARM C Language Extensions (ACLE) for CRC32 intrinsics
The __builtin_arm_* intrinsics don't exist on all ARMv8 systems.
Use the standardized ACLE intrinsics, instead.
2024-07-04 15:36:10 +02:00
Nico Weber
ab156c5034 animation: Add a flag to disable inter-frame color compression 2024-07-04 10:04:54 +02:00
Nico Weber
4156d69cbe LibGfx/WebPWriter: Opt in WebPAnimationWriter to inter frame compression
No effect on sunset-retro.png since that's not animated.

        wow.gif (nee giphy.gif) (184k):
            1.4M -> 255K
            74.0 ms ± 1.1 ms -> 86.9 ms ± 3.3 ms

    (from 7.6x as big as the gif input to 1.4x as big.
    About 82% smaller, for a 16% slowdown.)

        7z7c.gif (11K):
            8.4K -> 8.6K
            12.9 ms ± 0.5 ms -> 12.7 ms ± 0.5 ms

    (2.4% bigger, so the transform makes things a bit worse for this
    image.)
2024-07-04 10:04:54 +02:00
Nico Weber
d0b1598806 LibGfx/AnimationWriter: Compress identical pixels in consecutive frames
AnimationWriter already only stores the smallest rect that contains
changing pixels between two frames. For example, when doing a screen
recording and only the mouse cursor moves, we already only encode
the pixels in the (single) rectangle containing old and new mouse cursor
positions.

Within that rectangle, there can still be many pixels that are identical
over the two frames. When possible, we now replace all identical pixels
with transparent black. This has two advantages:

1. It can reduce the number of colors in the image. In particular,
   for wow.gif (and likely many other gifs), new frames had more
   than 256 colors before, and have fewer than 256 colors after this
   change.

2. Long run of identical pixels compress better.

In some cases, this transform might make things slighly worse,
for example if the input image already consists of long runs of
a single color. We'll now add another color to it (transparent black),
without it helping much. And the decoder now must do some blending,
slowing down decoding a bit.

But most of the time this should be a pretty big win. We can tweak
the heuristic when to do it later.

This transform is possible when:

* The new frame doesn't already have transparent pixels (which are
  different from the old frame)

* The encoder/decoder can handle frames with transparent pixels

For the latter reason, encoders currently have to opt in to this.
2024-07-04 10:04:54 +02:00
Aliaksandr Kalenik
0130372531 LibWeb: Reschedule HTML event loop processing if navigable needs repaint
This is an attempt to fix the hanging CI on macOS caused by some
screenshot requests being stuck unprocessed. With this change, we at
least make sure that the HTML event loop processing, which triggers
repainting, will happen as long as there are navigables that need to be
repainted.

(cherry picked from commit 72b4d44d07e12cc04bde90872e2f31aaab64aa00)
2024-07-03 10:06:51 +02:00
Nicolas Danelon
cfa3a91fb5 UI/AppKit: Make the header buttons more accessible
By Setting setBordered propperty on header buttons to `Yes` this
path makes the whole button clickable. Previously the only the
icon was clickable, now it's easy to click.

(cherry picked from commit af909784547c4f0ea8218ce464f45b3a1b0f4cb7)
2024-07-03 10:06:28 +02:00
Kevin Meyer
cf139d9bd0 Ladybird/AppKit: Enable reload action
Is necessary, since history navigation was refactored

(cherry picked from commit 8a7afffdd357b3fb16c7e6c6ff32198165294b60)
2024-07-03 10:06:11 +02:00
Ryan Castellucci
a2a6bc5348 Documentation: Fix some minor ESL grammar issues
There are a few instances where comments and documentation have minor
grammar issues likely resulting from English being the author's second
language.

This PR fixes several such cases, changing to idiomatic English and
resolving where it is unclear whether the user or program/code is
being referred to.
2024-07-03 00:17:46 +02:00
Andrew Kaster
4103a9cfd2 LibWeb: Use double as the argument for AnimationFrameCallbacks
This avoids an unnecessary lossy conversion for the current time from
double to i32. And avoids an UBSAN failure on macOS that's dependent
on the current uptime.

(cherry picked from commit 55c1b5d1f4d7c82f0a68323260cb2e0f7de2faae,
amended to fix a typo in the commit message)
2024-07-02 14:21:39 +02:00
Nico Weber
ee129a3c7d Meta: Make disk_usage() not depend on GNU du
BSD `du` can also print apparent size, it just needs a different flag.

Makes `serenity.sh run` get a bit farther trying to build the disk
image on macOS without brew installed. No intended behavior change
elsewhere.
2024-07-01 23:26:18 +02:00
Bastiaan van der Plaat
52023e38dc LibWeb/Geometry: Make DOMRect doubles unrestricted
(cherry picked from commit bff6c0680aff5862e05c68af03a653f2250328b4)
2024-07-01 23:03:47 +02:00
Tim Ledbetter
077c0319b3 sed: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
Tim Ledbetter
c921930593 grep: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
Tim Ledbetter
5070830acc cut: Don't skip final character when using byte or character ranges 2024-07-01 13:46:00 +02:00
Tim Ledbetter
f3fbcb28e7 cut: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
Tim Ledbetter
4663b2fee6 comm: Support reading arbitrarily long lines 2024-07-01 13:46:00 +02:00
kleines Filmröllchen
9f0ab281ce AudioServer: Handle missing audio device gracefully
On several platforms, we don't yet have audio
support, so audio devices are missing. Instead of
having AudioServer crash repeatedly, and not
having the ability to open any app that relies on
it, we should instead handle missing devices
gracefully. This implementation is minimal, audio
device hotplugging support and such should be
implemented together with multi-device support.
AudioServer will start up and seem to function
normally without an audio device, but it will
pretend the device has a sample rate of 44.1 kHz
and all audio input is discarded.
2024-07-01 12:47:52 +02:00
brody-qq
e254810d0a Kernel/Memory: Remove duplicate code in try_create_purgeable_with_size()
The methods try_create_with_size() and try_create_purgeable_with_size()
on AnonymousVMObject are almost identical, other than one member
that gets set (m_purgeable). This patch makes
try_create_purgeable_with_size() call try_create_with_size() so that
both methods re-use the same code.
2024-07-01 12:47:32 +02:00
Tim Ledbetter
d4f135b2c6 UI/Qt: Ignore tab bar middle clicks if the user didn't click on a tab
This avoids a segfault that would previously occur when middle clicking
to close a tab if only 1 tab was open.

(cherry picked from commit b95c05b6115c8eb84fe6fec55f5152db852fe743)
2024-07-01 12:45:47 +02:00
Tim Ledbetter
d9245bc5ac LibWeb: Implement the HTMLTrackElement.kind attribute
This reflects the HTML `kind` attribute.

(cherry picked from commit bdaa7f0e8ed738ad0bd6e19878f296436fe40377)
2024-07-01 12:45:34 +02:00
Nico Weber
5ff69579a4 LibGfx/WebPWriter: Implement run-length encoding
This implements the start of lossless webp's compression scheme,
which is almost, but not quite, entirely unlike deflate.

The green channel is now green-or-length, and has up to 280
entries, instead of up to 256 before. We now use the 40-entry
distance code (even though it only ever stores 1s now).

Due to this, a few places change to taking spans instead of
Array<256>s.

The spec only has the transform from prefix or distance code
to value. The inverse prefix_decompose() in this patch is
my own invention. I checked with a python script that it's
a true inverse (see PR for the script).

We now look for back-references with a distance of 1, which is
equivalent to run-length encoding. It's fairly fast to compute,
but leaves compression on the table. Full window-based
back references will be in a future PR.

We also still don't do color cache entries yet, but that should
be fairly straightforward to add. (It will make the green channel
larger than 280 entries.)

We still use a single global huffman table for the entire image.
Doing one per tile should be doable with the organization we now
have, and might also be in a future PR.

File sizes, and perf numbers on HEAD before this patch series (see
previous commit for perf comparison to previous commit):

    sunset-retro.png (876K):
        1.7M -> 1.6M,
        25.3 ms ± 0.5 ms -> 27.5 ms ± 0.8 ms

(helps little; from 1.94x as input to 1.83x as large.
About 5% smaller, for about a 10% slowdown.)

    wow.gif (nee giphy.gif) (184k):
        3.9M -> 1.4M
        105.7 ms ± 1.7 ms -> 74.0 ms ± 1.1 ms

(from 21.2x as big as the gif input to 7.6x as big.
About 64% smaller, for a 28% speed _up_.)

    7z7c.gif (11K):
        40K -> 8.4K
        13.9 ms ± 0.6 ms -> 12.9 ms ± 0.5 ms

(from 3.6x as big as the gif input to 0.76x as big :^)
About 79% smaller, for a 7% speed _up_.)
2024-07-01 00:29:39 +02:00
Nico Weber
3f1c562aa3 LibGfx/WebPWriter: Extract can_write_as_simple_code_lengths()
Pure code move, no behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber
f5bbc69e6a LibGfx/WebPWriter: Extract compute_and_write_prefix_code_group()
Pure code move, no behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber
2627721e0b LibGfx/WebPWriter: Extract bitmap_to_symbols() function
Pure code move, no behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber
580134241e LibGfx/WebPWriter: Separate symbol generation from statistics collection
We now do this in two passes instead of in one. This is virtually free
performance-wise, and allows nicer factoring.

Perf numbers after this change (see previous commit for perf numbers
before):

    Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
      Time (mean ± σ): 26.7 ms ± 0.8 ms

    Benchmark 1: animation -o 7z7c.webp 7z7c.gif
      Time (mean ± σ): 14.5 ms ± 0.6 ms

    Benchmark 1: animation -o wow.webp wow.gif
      Time (mean ± σ): 108.2 ms ± 2.2 ms
2024-07-01 00:29:39 +02:00
Nico Weber
85739def89 LibGfx/WebPWriter: Use symbols for writing image data
No behavior change yet, but this will allow us to emit distance/length
and color cache symbols in addition to literal symbols.

Not super expensive perf-wise. Before:

    Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
      Time (mean ± σ): 25.3 ms ± 0.5 ms

    Benchmark 1: animation -o 7z7c.webp 7z7c.gif
      Time (mean ± σ): 13.9 ms ± 0.6 ms

    Benchmark 1: animation -o wow.webp wow.gif
      Time (mean ± σ): 105.7 ms ± 1.7 ms

After:

    Benchmark 1: image -o sunset-retro.webp sunset-retro.bmp
      Time (mean ± σ): 26.1 ms ± 0.6 ms

    Benchmark 1: animation -o 7z7c.webp 7z7c.gif
      Time (mean ± σ): 14.4 ms ± 0.6 ms

    Benchmark 1: animation -o wow.webp wow.gif
      Time (mean ± σ): 106.5 ms ± 1.9 ms
2024-07-01 00:29:39 +02:00
Nico Weber
7c6176f983 LibCompress: Detemplatize generate_huffman_lengths()
Take Spans instead of Arrays. There's no need to have one copy of this
function for every possible array size passed to it.

Hardcode the inline size of the BinaryHeap to 288 for now. If this
becomes a performance issue in the future, we can make that size
an (optional) template parameter then.

No behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber
9cc688041a AK: Give IntrusiveBinaryHeap template args named types
Works around https://gcc.gnu.org/PR70413. Without this, the next
commit would cause -Wsubobject-linkage warnings for AK/BinaryHeap.h
when used in LibCompress/Huffman.h.

We can undo this once we're on GCC 14 everywhere.

No behavior change.
2024-07-01 00:29:39 +02:00
Nico Weber
59ef7d0d4e LibGfx/WebPLoaderLossless: Add a spec comment 2024-07-01 00:29:39 +02:00
Nico Weber
e54fc640f0 LibGfx/WebPWriter: Tweak dbgln_if() output
The writer logging now looks more like the reader logging, making
it easier to spot disagreements.
2024-07-01 00:29:39 +02:00
Ali Mohammad Pur
f6c3b33333 LibWasm/WASI: Don't convert enums and u8s into i64
Doing so results in incorrect values being created, ultimately leading
to traps or errors.
2024-06-30 21:55:55 +02:00
kleines Filmröllchen
540e8e5523 Meta: Enable VirtIO on Windows QEMU
VirtIO was probably broken on Windows versions of
QEMU, but this seems to no longer be the case.
Enabling VirtIO is currently required for RISC-V
mouse and keyboard support.
2024-06-30 14:33:30 +02:00
Dan Klishch
2360df3ab8 Everywhere: Define even more destructors out of line
You guessed it, this fixes compilation with LLVM trunk.
2024-06-30 08:52:07 +02:00
Dan Klishch
c03cca7b2f AK+LibTest: Choose definition of CO_TRY and CO_TRY_OR_FAIL more robustly
There are three compiler bugs that influence this decision:

 - Clang writing to (validly) destroyed coroutine frame with -O0 and
   -fsanitize=null,address under some conditions
   (https://godbolt.org/z/17Efq5Ma5) (AK_COROUTINE_DESTRUCTION_BROKEN);

 - GCC being unable to handle statement expressions in coroutines
   (AK_COROUTINE_STATEMENT_EXPRS_BROKEN);

 - GCC being unable to deduce template type parameter for TryAwaiter
   with nested CO_TRYs (AK_COROUTINE_TYPE_DEDUCTION_BROKEN).

Instead of growing an ifdef soup in AK/Coroutine.h and
LibTest/AsyncTestCase.h, define three macros in AK/Platform.h that
correspond to these bugs and use them accordingly in the said files.
2024-06-29 20:15:05 -06:00
Liav A.
6fc3908818 Utilities/init: Add "drop to emergency shell" functionality
In case the user requests this, init can drop directly to a shell
without trying to spawn SystemServer.

To test this on x86-64, run:
```
Meta/serenity.sh run x86_64 GNU "init_args=emergency"
```

Also, init will drop to emergency shell if mounting filesystems with
`mount -a` failed for some reason.

This functionality can be useful in many cases.
For example, if the user needs to perform a command that must not alter
a corrupted filesystem state, then this mode is useful as the filesystem
should be mounted in read-only mode.
Another example is the ability to get a functioning system in case
SystemServer behaves badly or inconsistently, or the user specified a
wrong fstab entry, so proceeding to boot is probably a bad option.
2024-06-30 00:20:45 +02:00
Liav A.
1e73a584a7 Userland: Move basic system init functionality out of SystemServer
Let's make SystemServer simpler by not involving it with the basic
system initialization sequence.
That initialization sequence can be done in another program that
theoretically can be put in another filesystem.

Co-authored-by: Tim Schumacher <timschumi@gmx.de>
2024-06-30 00:20:45 +02:00