Commit graph

47596 commits

Author SHA1 Message Date
Lucas CHOLLET
2c98eff558 LibGfx: Consider component interleaving when reading a scan
Scan with only one component are by definition not interleaved, meaning
that each value is linearly ordered in the stream. Grayscale images
were supported thanks to a hack, by forcing the subsampling to 1.

Now we properly support grayscale image with other subsampling (even if
it doesn't make sense) and more generally scans with only one component
and any sampling factors.

While this solution is more general than the last one it also feels a
bit hackish. We should probably refactor the way we iterate over
components and macroblocks. But that's work for latter, especially when
we will add support for other subsampling than 4-2-2.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
893659c6aa LibGfx: Move HuffmanStream from the context to the Scan object
Huffman streams are encountered in the scan segment. They have nothing
to do outside this segment, hence they shouldn't outlive the scan.

Please note that this patch changes behavior. The stream is now reset
after each scan.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
ae124c19ef LibGfx: Don't assume that a scan include all components for the image
A scan can contain fewer components that the full image. However, if
there is multiple components, they have to follow the ordering of the
frame header. It means that we can loop over components of the image
and skip those that doesn't correspond.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
947698f29f LibGfx: Consider EOI as a supported marker
For now, we exit after the first scan without needing to parse `EOI`.
However, to read scans in a loop we will need to properly detect and
parse `EOI`.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
698605444b LibGfx: Remove restrictive checks
These checks are only valid for mono-scan SOF0 images, with tables
defined before the start of frame segment.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
d3231ca323 LibGfx: Log spectral information 2023-02-27 13:39:22 +01:00
Lucas CHOLLET
3719f94c63 LibGfx: Log image dimensions only once 2023-02-27 13:39:22 +01:00
Lucas CHOLLET
f98668f8b2 LibGfx: Only iterate components of the current scan
A scan can have fewer components than what the final image contains.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
9fa375b844 LibGfx: Differentiate scan-level and frame-level data for components
This patch brings us closer to the spec point of view. And while it
makes no functional changes, it reduces the number of places where you
can misuse scan-specific data and improve support for multiple scans.
2023-02-27 13:39:22 +01:00
Lucas CHOLLET
508ae37c6e LibGfx: Move scan-related information to its own struct
Putting them directly in the context isn't good for neither readability,
comprehension nor spec compliance.
2023-02-27 13:39:22 +01:00
Tim Ledbetter
cc4184cb47 LibGUI: Don't show non-visible actions in CommandPalette 2023-02-27 13:37:24 +01:00
Nico Weber
5d5f9f52a0 Utilities: Make file print more information for animated images 2023-02-27 13:29:57 +01:00
Nico Weber
a83f4ec186 WebServer: Remove a call to String::from_deprecated_string
guess_mime_type_based_on_filename() returns a StringView, so no
need to bring DeprecatedString's (implicit) ctor into this.

No behavior change.
2023-02-26 21:01:58 -05:00
Hendiadyoin1
8e5ebb04f4 LibJS: Use a pseudo top-level UnwindFrame in GenerateCFG
Previously we assumed that there is always one such frame, now there is.
2023-02-26 23:09:37 +01:00
kleines Filmröllchen
bd1cecb991 Meta: Lower QEMU DirectSound driver timer period to 2ms
10ms (the default) is ridiculous and causes all kinds of glitches if we
actually want to have a low-latency queue.
<https://gitlab.com/qemu-project/qemu/-/issues/1076#note_996636777>
suggests 2ms (and no lower than 1ms). This improves audio glitch
resistance at our current 512 sample buffer size, but going lower is
still not possible.
2023-02-26 22:27:42 +01:00
MacDue
6cf8eeb7a4 LibGfx: Return bool not ErrorOr<bool> from ImageDecoderPlugin::sniff()
Nobody made use of the ErrorOr return value and it just added more
chance of confusion, since it was not clear if failing to sniff an
image should return an error or false. The answer was false, if you
returned Error you'd crash the ImageDecoder.
2023-02-26 19:43:17 +01:00
MacDue
8d9cb538d6 LibGfx: Don't return an error for webp sniff failures
The correct thing to do here is return false, returing an error
crashes the ImageDecoder.
2023-02-26 19:43:17 +01:00
Hendiadyoin1
c696654294 LibJS: Add a missing include to FunctionKind.h 2023-02-26 19:40:09 +01:00
Hendiadyoin1
4c2b4c1a27 LibJS: Overhaul AsyncFunctionDriverWrapper to make it actually work
This object is responsible for handling async functions in bytecode,
and this commit fully rewrites it, now it does:
* creates and keeps alive a top level promise, which callers can attach
  their `then` clauses
* creates and clear a handle to itself, to assure that it does not get
  garbage collected
* properly handles all possible ways a async function could halt and
  when possible continues the execution immediately
2023-02-26 19:40:09 +01:00
Hendiadyoin1
de514f29ad LibJS: Align codegen AwaitExpressions to YieldExpressions
We use generators in bytecode to approximate async functions, but the
code generated by AwaitExpressions did not have the value processing
paths that Yield requires, eg the `generator.throw()` path, which is
used by AsyncFunctionDriverWrapper to signal Promise rejections.
2023-02-26 19:40:09 +01:00
Hendiadyoin1
1f6a0ef6e0 LibJS: Don't enter finally blocks upon yield in bytecode mode 2023-02-26 19:40:09 +01:00
Hendiadyoin1
088dc1b24b LibJS: Simplify Generator::perform_needed_unwinds
This does not need to cater to the needs of `break` and `continue
anymore, which allows us to simplify it a bit.
2023-02-26 19:40:09 +01:00
Hendiadyoin1
d65488b80c LibJS: Generate unwind chains for continue in Bytecode
This works similar to `break`
The `try-finally-continue` still do not pass with this, likely because
of binding issues.
2023-02-26 19:40:09 +01:00
Hendiadyoin1
f5376cb282 LibJS: Generate unwind chains for break in Bytecode
This uses a newly added instruction `ScheduleJump`
This instruction tells the finally proceeding it, that instead of
jumping to it's next block it should jump to the designated block.
2023-02-26 19:40:09 +01:00
Hendiadyoin1
495ba53e46 LibJS: Correctly handle unwind frames in the GenerateCFG pass
To achieve this it now uses recursive descend, to make the state
managements easier.

With this we now correctly handle try-catch-finally blocks correctly,
modeling all possible controll flows between these blocks, which allows
analysis and optimization passes to make more accurate descisions about
accessibility of the enclosed blocks
2023-02-26 19:40:09 +01:00
Hendiadyoin1
5181957da5 LibJS: VERIFY on unknown terminator opcodes in GenerateCFG
If we mess up in here it could break promises later optimization stages
assume, so rather than having wrong results, make it scream as load as
it can.
2023-02-26 19:40:09 +01:00
Hendiadyoin1
09fa3a17c7 LibJS: Allow to stringify empty Values without side effects 2023-02-26 19:40:09 +01:00
Tim Ledbetter
ec5d2a5144 Spreadsheet: Fix column index to number conversion
The output of Spreadsheet::convert_from_string() is now correct for
numbers larger than 26^2.
2023-02-26 21:06:21 +03:30
Tim Ledbetter
6b2f3ad6c8 AK: Fix DeprecatedString::bijective_base_from for large numbers
The output of the DeprecatedString::bijective_base_from() is now
correct for numbers larger than base^2.

This makes column names display correctly in Spreadsheet.
2023-02-26 21:06:21 +03:30
Nico Weber
fa34832297 LibGfx: Implement WebPImageDecoderPlugin::loop_count()
Turns out extended-lossless-animated.webp did have a loop count of 0.
So I opened it in Hex Fiend and changed the byte at position 42
(which is the first byte of the little-endian u16 storing the loop
count) to 0x2A, so that the test can compare the loop count to something
not 0.
2023-02-26 15:54:22 +01:00
Nico Weber
3c5450b8be LibGfx: Implement is_animated() and frame_count() for webp plugin 2023-02-26 15:54:22 +01:00
Nico Weber
0393a37843 LibGfx: Add some chunk validation to decode_webp_extended() 2023-02-26 15:54:22 +01:00
Nico Weber
9864963a08 LibGfx: In WebP, rename decode_webp_size to decode_webp_first_chunk
...and make it store the decoded details in the context.
2023-02-26 15:54:22 +01:00
Nico Weber
15d2e8ca2b LibGfx: In WebP, rename decode_webp_first_chunk to read_webp_first_chunk 2023-02-26 15:54:22 +01:00
Tim Ledbetter
799d570afc PixelPaint: Add "Apply Mask" action
This commit adds a "Apply Mask" action which merges the active layer
mask with the layer bitmap. The option is only displayed if the active
layer is masked.
2023-02-26 13:09:16 +01:00
Tim Ledbetter
062c9efa88 PixelPaint: Add "Delete Mask" action
This commit adds a "Delete Mask" action which deletes the active layer
mask. The option is only displayed if the active layer is masked.
2023-02-26 13:09:16 +01:00
Nico Weber
d66f143fb7 Tests: Add webp size decoding tests for webp 2023-02-26 12:21:40 +01:00
Nico Weber
3cfcd2397b Tests: Add one more webp test file
This is "Lossless animated WebP (5 KB) 4" from
https://developers.google.com/speed/webp/faq
2023-02-26 12:21:40 +01:00
Nico Weber
1bb3abd9ab Tests: Add one more webp test file
This is Discord's reencoded version of my profile picture,
which is GitHub's auto-generated avatar for my github profile.
2023-02-26 12:21:40 +01:00
Nico Weber
889a02f9df Tests: Add one more webp test file
It's a simple lossless file from:
https://developers.google.com/speed/webp/gallery2#webp_links

> "baby tux for my user page"
> Image Author: Fizyplankton
> This file is in the public domain.
2023-02-26 12:21:40 +01:00
Andrew Kaster
ce500ed170 Lagom: Look for clang the same way serenity.sh does in BuildFuzzers.sh
Also note that Xcode does not ship libfuzzer and is not usable for
a fuzzer build.
2023-02-26 08:11:08 +00:00
Ali Mohammad Pur
5bc1f135b7 Tests: Implement multi-value returns in test-wasm 2023-02-26 10:54:23 +03:30
Ali Mohammad Pur
8a36d8826f LibWeb: Implement the js-api portion of Wasm multi-value 2023-02-26 10:54:23 +03:30
Ali Mohammad Pur
6b50f23242 LibWasm+LibWeb: Sneak a JS::Completion into Wasm::Result
Imported functions in Wasm may throw JS exceptions, and we need to
preserve these exceptions so we can pass them to the calling JS code.

This also adds a `assert_wasm_result()` API to Result for cases where
only Wasm traps or values are expected (e.g. internal uses) to avoid
making LibWasm (pointlessly) handle JS exceptions that will never show
up in reality.
2023-02-26 10:54:23 +03:30
kleines Filmröllchen
1c3050245e LibDSP: Don't crash on out-of-bounds parameter value
We can just clamp instead.
2023-02-25 20:49:41 -07:00
kleines Filmröllchen
961e263129 AK: Add FixedPoint::clamp 2023-02-25 20:49:41 -07:00
kleines Filmröllchen
7b3b743f88 Piano: Move octave controls into main widget
This is not related to the track controls and it may move into another
separate widget in the future. The move also allows to simplify the
octave slider callback logic.
2023-02-25 20:49:41 -07:00
kleines Filmröllchen
376e7243a9 LibGUI: Use full text width for Label's preferred width
A label would prefer to be exactly as wide as its contained text
requires. This makes min_width: "fit" work better.
2023-02-25 20:49:41 -07:00
kleines Filmröllchen
9f5f6b3868 Piano: Clean up code style with help from clang-tidy
Includes shadowed variables and if-else return.
2023-02-25 20:49:41 -07:00
kleines Filmröllchen
401a21e4f4 Piano: Improve handling of possibly null parameter label
The current implementation could crash in various locations if the label
was null.
2023-02-25 20:49:41 -07:00