Commit Graph

410 Commits

Author SHA1 Message Date
Mike Welsh 4a04923d04 audio: Add mp3_metadata function 2022-09-06 19:04:16 -07:00
Mike Welsh 3137306975 audio: Support loading external MP3s 2022-09-06 19:04:16 -07:00
= 2b3249c9a4 core: Made core no longer depend on software video decoders 2022-09-04 17:46:58 -07:00
= f0013bdec8 video: Moved individual decoders to software video backend 2022-09-04 17:46:58 -07:00
= bf242bfb09 video: Moved SoftwareVideoBackend to software decoder crate 2022-09-04 17:46:58 -07:00
= 7c839ef8ae video: Add software video crate, moved VideoDecoder to it 2022-09-04 17:46:58 -07:00
= 8b12185d61 video: Moved NullVideoBackend from core to video 2022-09-04 17:46:58 -07:00
= aff49cd891 video: Moved VideoBackend from core to video 2022-09-04 17:46:58 -07:00
= 7c464295e2 video: Moved VideoStreamHandle from core to video 2022-09-04 17:46:58 -07:00
= fd7086adef video: Moved EncodedFrame, DecodedFrame and FrameDependency from core to video 2022-09-04 17:46:58 -07:00
= b7cf800f88 video: Made ruffle_video crate, moved core video Error to it 2022-09-04 17:46:58 -07:00
= 72da1535b7 core: Made video::Error not depend on invidiaul codecs 2022-09-04 17:46:58 -07:00
TÖRÖK Attila f75eee389a core/mp3: More lenient MP3 buffer underrun detection 2022-09-02 20:38:24 -07:00
= f180183ec5 core: Add audio feature, made dasp optional 2022-08-28 21:10:05 -07:00
= c6c22cebc9 core: Make nellymoser optional, enable on desktop and web 2022-08-28 21:10:05 -07:00
= b7dcd26c38 core: Use Cow<str> for FullscreenError in UI backend, as it can't ever be anything else 2022-08-25 23:43:21 +02:00
= 1c7bfd8c5f core: Use real Error enums for video backend 2022-08-25 23:43:21 +02:00
= 5b5ee7d448 core: Made audio backend use actual real error enums, and not box<error> 2022-08-25 23:43:21 +02:00
= 3a1947445e core: Made SwfSlice::to_subslice return an empty slice in case of errors 2022-08-21 20:12:10 -07:00
Mike Welsh b38fce230d audio: Add AudioBackend::volume/set_volume 2022-08-20 11:53:42 -07:00
Nathan Adams 824b4aa8d1 render: Moved render backend from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 760da753fb render: Moved Transform from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 35082b687f render: Moved shape_utils from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 91a7047ebb render: Moved Matrix from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams 9fd8fd938e render: Moved render utils from core to render 2022-08-14 18:38:14 -07:00
Nathan Adams bc0c7cbccb render: Made new render crate, moved Bitmap stuff to it 2022-08-14 18:38:14 -07:00
Nathan Adams 94282dfe73 core: Moved render utils into own module 2022-08-14 18:38:14 -07:00
Nathan Adams 0bb14193c6 core: Moved Bitmap into its own module for refactoring rendering 2022-08-14 18:38:14 -07:00
Nathan Adams beab50cde7 core: Moved NullRenderer into its own module in preparation for refactoring 2022-08-14 18:38:14 -07:00
relrelb d70697b4f3 web: Refactor `WebNavigatorBackend`
Store `base_url` as `Option<Url>` instead of `Option<String>`, so
we don't need to parse it on each URL resolve.
2022-08-14 17:49:05 -07:00
Aaron Hill 71571b9594 avm2: Add URLRequest.method and use it URLLoader 2022-08-11 19:50:58 +02:00
Nathan Adams 4b19910791 audio: Avoid panic with supposed MP3s that are too small 2022-08-09 17:59:02 +03:00
relrelb e42a6b62e6 core: Require `target` in `NavigatorBackend::navigate_to_url`
Make the `target` parameter just a `String` instead of an `Option<String>`.
`None` is not needed as it's totally equivalent to an empty string.
2022-08-06 11:20:03 +03:00
TÖRÖK Attila 820196d066 audio: Handle AudioCompression::UncompressedUnknownEndian in AudioMixer::make_seekable_decoder()
The same way as it is done in decoders::make_decoder().
2022-08-01 21:39:01 +03:00
Adrian Wielgosik 5be7f425f0 avm2: Migrate all Events to AS, remove EventData. 2022-07-30 12:34:12 -07:00
Mike Welsh 30b185cbd4 audio: Reset symphonia decoder on loop 2022-07-28 21:25:33 -07:00
TÖRÖK Attila 7249db9052 audio: Fix crash/gap at the end of MP3 loops 2022-07-28 21:25:33 -07:00
Mike Welsh ffb57467eb audio: Add `AudioBackend::position_resolution`
This returns the approximate interval that the audio backend
updates the sound position information. This is used for syncing
animation to embedded "stream" audio tracks, and fixes some
stuttering in cases where the syncing was being too strict.
2022-07-28 21:25:33 -07:00
Mike Welsh 405c7194b0 audio: Remove `AudioBackend::preload_sound_stream` fns
No longer necessary now that web audio mixing is done on Rust side.
2022-07-28 21:25:33 -07:00
relrelb f643048c1c core: Introduce `Request`
Which holds both a URL and what was `RequestOptions` formerly.
2022-07-09 09:43:42 +03:00
Aaron Hill a79aa08f08
core: Free render backend resources on `BitmapData.dispose`
Currently, all three render backends hold on texture-related
resources indefinitely (`register_bitmap` pushes to a `Vec`,
and never removes anything). As a result, the resources used
by the render backend (which may include GPU memory) will grow
over time, even if the corresponding `BitmapData` has been deallocated.

This commit adds a new `unregister_bitmap` method, which is called from
`BitmapData.dispose`. All render backs are changed to now use an
`FnvHashMap<BitmapHandle, _>` instead of a `Vec`, allowing us to
remove individual entries.

Currently, we only call `unregister_bitmap in response to
`BitmapData.dispose` - when `BitmapData` is freed by the
garbage collector, `unregister_bitmap` is *not* called.
This will be addressed in a future PR.
2022-06-29 15:16:43 -07:00
relrelb bd88e5e95a render: Remove unused `unmultiply_alpha_rgba` 2022-06-11 08:28:24 +03:00
relrelb 53ef80f514 render: Introduce `RenderBackend::register_bitmap`
Since all `RenderBackend::register_bitmap_*` implementations are
identical now, move them to the default implementation of `RenderBackend`.

Also, turn `RenderBackend::register_bitmap_raw` into `RenderBackend::register_bitmap`,
which accepts a single `Bitmap` parameter.
2022-06-02 15:27:29 -07:00
relrelb 4fb77edfb1 render: Move `srgb_to_linear` to `common_tess`
Since it's the only user of it. Also make it mutate the float array
parameter instead of returning a new one, just to simply things a
bit.
2022-05-31 21:48:11 +03:00
Mike Welsh de99dcd37b core: Add `BitmapFormat::bytes_per_pixel` 2022-05-19 10:43:54 -07:00
Mike Welsh 48f7ff5f4d core: Add `Bitmap::to_rgba` 2022-05-19 10:43:54 -07:00
Mike Welsh e710f3fa0e core: Clean up `render::Bitmap`
* Make `BitmapFormat` a fieldless enum and move `data` to its own
   field for ease of use.
 * Make `Bitmap` fields private.
2022-05-19 10:43:54 -07:00
Mike Welsh 6615ed17f9 core: Verify bitmap length after decoding
Guarantee bitmap data after decoding has the expected length for
the given width+height+format. This eases the burden from backends
to worry about this. Pad or truncate the data if it doesn't have
the expected size.
2022-05-19 10:43:54 -07:00
Mike Welsh b88e77573d core: Handle greyscale PNGs
`render::decode_png` now handles greyscale or greyscale+alpha PNGs.
2022-05-19 10:43:54 -07:00
Mike Welsh f550abd18d web: Fix some warnings
Fix warnings caused by desktop-only code.
2022-05-09 22:28:43 -07:00
relrelb bce4075c69 core: Remove `url_from_relative_path`
The remaining caller was `SwfMovie::from_path`, which is now changed
to be simpler, and a little stricter (panics if `Url::from_file_path`
fails, though it shouldn't happen with canonicalized paths).
2022-05-09 10:06:52 -07:00
nosamu f39537f984 docs: Correct issue number in code comment 2022-05-08 14:27:15 +03:00
Mike Welsh 5730c8db94 core: Clamp color values in DefineBitsJPEG3 (fix #6893)
The colors in a DefineBitsJPEG3 tag should be premultiplied alpha,
but in some SWFs they are incorrectly not premultiplied. Flash
Player clamps the color values to the alpha in this case to allow
these images to work more as expected.

Fixes #6893.
2022-05-07 09:46:44 -07:00
relrelb 87ce0f56b7 core: Remove `NavigatorBackend::resolve_relative_url`
The resolved URL only used by `NavigatorBackend::fetch`. So simply
inline `NavigatorBackend::resolve_relative_url` into `NavigatorBackend::fetch`,
per implementation.
2022-05-07 09:06:53 -07:00
relrelb ea665d91f2 core: Introduce and use `Response::url` 2022-05-07 09:06:53 -07:00
relrelb 2517d8de4b core: Introduce struct `Response`
Currently it's a trivial wrapper around `Vec<u8>`, but more fields
will be added in the future (e.g. response URL, HTTP status code).
2022-05-07 09:06:53 -07:00
relrelb babf49aaf9 chore: `.filter_map(..).next()` -> `.find_map(..)`
Per the rust-analyzer diagnostic: https://rust-analyzer.github.io/manual.html#replace-filter-map-next-with-find-map
2022-04-30 10:41:46 -07:00
Mike Welsh 2453626dec core: Add MemoryStorageBackend::new 2022-04-29 09:14:32 -07:00
relrelb 25d47da528 render: Improve CMYK to RGB conversion
Use integer arithmetic, which is more accurate and efficient.
2022-04-18 22:00:48 -07:00
relrelb 87e85e16da render: Make `rgb5_component` a lambda
This way the `compressed` parameter becomes implicit.
2022-04-16 13:52:59 -07:00
relrelb 8feeadf578 render: Use `std::borrow::Cow`
Also apply some nearby refactors.
2022-04-16 13:52:59 -07:00
relrelb eeaec947b3 render: Remove unneeded `pub`s
And remove the dead `glue_swf_jpeg_to_tables` function.
2022-04-16 13:52:59 -07:00
relrelb 9b4108444f render: Strip 16-bit PNG samples to 8-bit
PNGs with 16-bit samples were not being normalized to 8-bit, screwing up their
appearance.

Add the `STRIP_16` transformation using `Transformations::normalize_to_color8()`,
which is equivalent to `Transformations::EXPAND | Transformations::STRIP_16`.
Also warn in case `png` outputs a color type other than `Rgb` and `Rgba`.
Due to the `EXPAND` transformation, this may be only `Grayscale` or
`GrayscaleAlpha`. `Indexed` is converted to either `Rgb` or `Rgba`.

Fixes #6662.
2022-04-16 12:45:55 -07:00
Mike Welsh c0dff98d84 chore: Fix len_zero warning in symphonia Mp3Decoder 2022-04-11 20:15:13 -07:00
Mike Welsh 24f00238a7 audio: Fix symphonia feature
This feature stopped building with the bump to symphonia 0.5, which
added a `Sync` bound to its traits.

 * Add `Sync` bounds to our own internal audio traits to match.
 * nellymoser::Decoder was also tweaked to add a Sync bound.
 * Lock the nellymoser dependency to a specific git commit.
2022-04-11 15:25:15 -07:00
Mike Welsh 6ec3049e02 desktop: Use floats for audio start/endpoints calculation (fix #6569)
Integer math was used when calculating a sound's start/endpoints,
because it was assumed that the sound sample rate was always an
even divisor of 44100Hz. However, some third party tools can embed
MP3s with other samples rates, such as #6569 which has a 16000Hz
MP3. This could also occur for dynamically loaded MP3s. This
results in the sound starting at an incorrect position.

Use floating point math to ensure the correct position is
caluclated.

Fixes #6569.
2022-04-03 15:50:43 -07:00
relrelb e06506c2b9 render: Implement `CMYK32` jpeg pixel format 2022-04-02 01:17:38 +03:00
Mike Welsh a671d2977b core: Pre-multiply alpha when loading PNG/GIF data (fix #6559)
When decoding PNG/GIF data, convert the image to premultiplied
alpha so that it plays nicely with the renderer.

This applies to both dynamically loaded images and to PNG/GIF data
embedded inside a DefineBitsJPEG tag. This is in contrast to
DefineBitsLossless and DefineBitsJPEG tags w/ alpha, which are
already premultiplied in the SWF.

Also remove unnecessary clamps now that Rust defines casts as
saturating.

Fixes #6559.
2022-03-29 13:41:04 -07:00
relrelb 161071e8c4 core: Re-implement `NullExecutor`
Make it a thin abstraction layer over either the `futures` or `wasm-bindgen-futures`
crates, as already done in `render/wgpu/src/uniform_buffer.rs`,
instead of a hand-made single-thread executor.

Ideally this would also be usable on desktop, but I didn't manage to
get `LocalPool` working with `winit` (it needs to post a task to the
`EventLoopProxy` as a wake procedure).
2022-03-26 10:03:42 -07:00
relrelb ad944800be core: Perfer `Loader`'s `FetchError`
`NetworkError` and `NetworkUnavailable` were rarely used, and they
were very similar to `FetchError`.
2022-03-17 20:31:59 -07:00
relrelb 8a17d88c77 core: Remove `NavigatorBackend::time_since_launch`
`core` already depends on the `instant` crate which abstracts
`std::instant::Instant` and polyfills it on Web. Use it to replace
`NavigatorBackend::time_since_launch` in order to make `NavigatorBackend`
a little smaller and more simple.
2022-03-17 00:08:44 +02:00
relrelb 031126a1b8 core: Remove `LocaleBackend`
Previously there were 3 implementations of `LocaleBackend`:
`DesktopLocaleBackend`, `WebLocaleBackend` and `NullLocaleBackend`.

While `DesktopLocaleBackend`, `WebLocaleBackend` were identical,
`NullLocaleBackend` always returned a fixed date/time for tests
determinism.

Unify them in a single file, and use `cfg!(test)` and a new dedicated
`deterministic` feature to decide whether to mock date/time or not.
This should not cause any behavioral changes.
2022-03-16 19:57:53 +02:00
relrelb f8f2764ac7 chore: Stop using traits available in prelude
This commit does the same as 36353df7f7,
cleaning up any leftovers and new code added since.
2022-03-14 01:16:00 +02:00
Mike Welsh 55da3cd7d0 chore: Add .cargo/config.toml for workspace-level lint config
Currently it is not directly possible to configure lints for the
entire workspace via TOML, which forced us to repeat `#![allow]`
blocks in each crate.

embark pointed out this workaround to configure lints at the
workspace level via RUSTFLAGS:

https://github.com/EmbarkStudios/rust-ecosystem/issues/22#issuecomment-947011395

Remove the common `#![allow]` blocks and switch to this method for
global lint config.

Temporarily allow `needless_borrow` lint, buggy pending this fix:
https://github.com/rust-lang/rust-clippy/pull/8355
2022-01-29 14:22:44 -08:00
David Wendt 87a9a543ba chore: Fix clippy lint on nightly 2022-01-22 19:58:32 -08:00
David Wendt 016cd6ccc0 avm2: Make event construction take an `EventData` parameter.
This also necessitated the introduction of a `FullScreenEvent` data type.
2022-01-22 19:58:32 -08:00
relrelb b39ab9034c core: Remove `Player::is_mouse_down`
Now that `InputManager` tracks the mouse button, it can be used
instead.
2022-01-10 01:18:49 -08:00
relrelb 573aa89c9a core: Handle mouse events in `InputManager::handle_event` 2022-01-10 01:18:49 -08:00
Mike Welsh 2653c5f5c3 audio: Handle gaps in MP3 SoundStreamBlock tags (fix #3817)
An MP3 "stream" sound can sometimes have frames without a
SoundStreamBlock tag, despite the SWF spec saying there should
at least be a tag with 0 samples on each frame. Ruffle would
stop the sound in this case, but the Flash Player may or may not
stop thje sound in the audio depending on the number of "empty"
frames. This could cause the audio to stutter as it continuously
stopped and restarted.

Handle this by keeping track of how many samples we've encountered
in MP3 blocks, and deducting the amount of samples consumed by each
timeline frame. Stop the sound if we run out of samples, as opposed
to when we hit a frame without a SoundStreamBlock.

Fixes #3817.
2022-01-07 13:23:53 -08:00
Mike Welsh b2f7c98f88 audio: Sync animation with embedded audio streams
This is a first pass at syncing animation and audio playback when
and embedded audio stream is playing.

Fixes #3020, #3663, #3958.
2022-01-07 13:23:53 -08:00
TÖRÖK Attila 6f68938591 video/vp6: Fix keyframe detection on Vp6WithAlpha videos 2021-12-29 11:28:05 +01:00
relrelb 07c5330456 core: Introduce `InputManager`
`InputManager` encapsulates the common logic that previously the
`UiBackend`s used to implement.
2021-12-15 14:20:30 -08:00
TÖRÖK Attila 95665bdc47 video: Extract software decoders (or glue) into their own modules, add screenvideo feature 2021-12-14 19:41:17 -07:00
TÖRÖK Attila fdc448533d video: Add Flash Screen Video (V1 only) decoder
Thanks a lot for the code and the help, Kostya!
2021-12-14 19:41:17 -07:00
relrelb ce2eff8b25 render: Stub L16 JPEG pixel format
16-bit luminance (grayscale) images are very rare, so it's hard to
tell what the expected behavior should be.
2021-12-10 00:28:45 +02:00
relrelb 00accf3e2a render: Rename `register_bitmap_jpeg_3` to `register_bitmap_jpeg_3_or_4`
It's actually used by both DefineBitsJpeg3 and DefineBitsJpeg4 tags.
2021-12-04 21:32:16 +02:00
Moulins 9701b817f5 core: Replace WStr<'_> and WStrMut<'_> by a single DST type WStr 2021-11-27 11:20:47 -07:00
Moulins 84b4e33036 core: implement FromWStr for various enum types 2021-11-27 11:20:47 -07:00
relrelb b32ec3cf6c audio: Calculate sound transform values using 30-bit integers
The fix in #5218 wasn't sufficient; 30-bit arithmetic should be used
along all the way when calculating an effective sound transform.

For example, a sound transform composited by volumes `-0x80000000` and
`25` should end up as effectively 0, whereas previously it would have
been calculated as `-0x80000000 * 25 / 100 = -0x20000000`, which is a
30-bit integer that hasn't been truncated.

Fixes #5655.
2021-11-27 12:09:33 +02:00
relrelb 0a3ede31dc core: Remove unused `Downcast` 2021-11-26 10:45:30 +02:00
TÖRÖK Attila 0e4d2d48f5 video/vp6: Don't throw an error on skip frames, reuse the last frame instead 2021-11-22 17:08:31 +01:00
Tal Hayon 7ed38850fd core: implement displayState for Stage in avm1/2 2021-11-11 16:20:05 -07:00
David Wendt c78e5e31fd core: Store `DisplayObjectBase` in `InteractiveObjectBase`.
This also necessitated removing the `impl_display_object` family of macros, as you cannot name a field of a field in a macro expression. I tried. So instead I've reverted to standard default method inheritance, in the same way we did with AVM2 objects.
2021-11-09 16:48:29 -07:00
Mike Welsh 11ae981890 audio: Fix skipping initial frame of MP3 audio
The changes in #5498 caused the samples from the initial MP3 frame
to be skipped. This was noticable in:
https://www.newgrounds.com/portal/view/1

This change properly removes the redundant `num_samples` variable
and considers the samples from the initial MP3 frame.
2021-10-21 10:25:47 -07:00
Mike Welsh 7745c9137f audio: Grab MP3 sample rate directly from MP3 data
MP3 data in an SWF can be of a different sample rate than
indicated in the SWF tag, so grab the sample rate from the MP3
decoder instead of passing it in from the SWF tag.

Also, a general clean up of the MP3 decoders.

Fixes #335.
2021-10-17 20:34:15 -07:00
Mike Welsh 3dfa5ade18 audio: Ask decoder for sound sample rate
Don't rely on the sample rate in the SWF tags, as this could differ
from the actual sample rate of the audio (see #335).
2021-10-17 20:34:15 -07:00
Mike Welsh 60f5dc2477 avm2: Implement SoundChannel.position
Fix various issues with `SoundChannel`:
 * Change `avm2::Object::as_sound_instance` to `as_sound_channel`.
 * Cache sound position in `SoundChannelObject`.
 * `SoundInfo::in_sample` is in units of 44100Hz.
 * Clamp `num_loops` to 1.
2021-10-16 22:53:25 -07:00
Mike Welsh 105c889f5f desktop: Implement AudioBackend::get_sound_position 2021-10-16 22:53:25 -07:00
Mike Welsh bca31b2c51 audio: Grab Sound.position from audio backend
* Change `AudioBackend::get_sound_position` to return `f64` to
   match `AudioBackend::get_sound_duration`.
 * Wire up `AudioBackend::get_sound_position` to `Sound.position`.
 * Remove unimplmeneted warning from `Sound.position`.
2021-10-16 22:53:25 -07:00
Chris Midgley c5ad8e76ee
audio: Fail to create invalid ADPCM decoder 2021-10-13 23:12:32 -07:00
relrelb b8152f431e core: Use `SwfSlice::read_from` 2021-10-08 13:22:45 -07:00
TÖRÖK Attila 3869950578 video/vp6: Add VP6[A] video decoding support
Gated behind the "vp6" feature, enabled by default.
Utilizing a heavily stripped-down version of the NihAV project,
retaining only the VP6 decoder, relicensed under MIT.
Including VP6WithAlpha decoding, proper FrameDependency reporting,
and cropping the unwanted encoded pixels on the right/bottom manually.
2021-10-04 22:33:06 -07:00
relrelb 05d8f13b26 audio: ADPCM small cleanup 2021-09-30 20:16:04 +03:00
relrelb b9307af78f audio: Move ADPCM's tables out of `AdpcmDecoder` 2021-09-30 20:16:04 +03:00
relrelb 50ec497c60 audio: Introduce `AdpcmDecoder::channels`
This reduces duplicated code.
2021-09-30 20:16:04 +03:00
relrelb 4deaaed75c audio: Inline `AdpcmDecoder::next_sample` 2021-09-30 20:16:04 +03:00
relrelb 99827caf2b audio: Localize `AdpcmDecoder::{left,right}_step`
Since they were used only in a single scope.
2021-09-30 20:16:04 +03:00
relrelb 923201d2e4 chore: Appease clippy 2021-09-10 15:42:37 +02:00
relrelb 1f96c2fcb8 audio: Small cleanup 2021-09-07 18:28:17 -07:00
relrelb 65205ac6d7 audio: Store sound transform values in 30-bit integers
It seems like Flash stores sound transform values in 30-bit unsigned integers:
* Negative values are equivalent to their absolute value.
* Specifically, 0x40000000, -0x40000000 and -0x80000000 are equivalent to zero.
2021-09-07 18:28:17 -07:00
Mike Welsh 483995823f core: Add symphonia as optional MP3 decoder
Add symphonia_mp3 feature to enable symphonia as an MP3 decoder.
This is a pure Rust MP3 decoder that could be used on web.
2021-09-07 16:48:34 -07:00
Mike Welsh 94d02fa653 core: Add AudioMixer to core
Pull out the audio mixing code from desktop and add it to core.
This will allow other backends to use it (such as the web audio
backend) to get consistent audio across all platforms.
2021-09-07 16:48:34 -07:00
Tal Hayon 4625ca0e0b web: fix base param 2021-09-07 16:45:35 -07:00
David Wendt 364ee62c92 avm2: Impl `SoundChannel`'s `soundComplete` event.
This includes a test that is currently ignored because `NullAudioBackend` can't fire complete events.
2021-09-03 16:47:02 -06:00
David Wendt 9c6c64e4e3 core: `NullAudioBackend` should falsely report all sounds as not playing, like the real backends
This prevents sounds from being removed from the `AudioManager`, which allows sound transforms to be placed on them in tests.
2021-09-03 16:47:02 -06:00
David Wendt b6167c2f86 avm2: Allow playing sounds with a given `SoundTransform`. 2021-09-03 16:47:02 -06:00
David Wendt 116fb1f323 avm2: Impl `Sound.play`
This does not (yet) implement the third `SoundTransform` parameter on `play`.
2021-09-03 16:47:02 -06:00
David Wendt 3b6eea2a1d core: Report sound duration as `f64` and round down in AS1 2021-09-03 16:47:02 -06:00
David Wendt e4c6e29b8a core: `NullAudioBackend` should not report latency seek data as part of the size of a sound. 2021-09-03 16:47:02 -06:00
David Wendt d7f2f782c4 avm2: Impl `Sound.length`
This also adds duration tracking for `NullAudioBackend`.
2021-09-03 16:47:02 -06:00
David Wendt 89b411593f avm2: Impl `Sound.bytesTotal` 2021-09-03 16:47:02 -06:00
relrelb 1e7bdaa226 chore: Minor improvement 2021-08-22 01:03:10 +03:00
Tomasz Konojacki a3747ade5e core: fix integer overflow in ADPCM decoder
The maximum possible value of delta is 63483, so it needs to be
declared as u16.

Fixes #5030
2021-08-22 01:03:10 +03:00
David Wendt 57fffbe699 video: Use the new `H263State.parse_picture` convenience method 2021-08-21 14:13:55 -06:00
Mike Welsh 1f951b6b9f core: Add h263 feature 2021-08-21 14:13:55 -06:00
Mike Welsh a05f81b393 video: Add VideoDecoder trait
Change VideoStream to use a VideoDecoder trait instead of an enum.
This will make it a little easier as more codecs are added, and
allow us to easily enable/disable codecs behind features.
2021-08-21 14:13:55 -06:00
David Wendt 48fa03b87d video: Reuse the same bitmap whenever possible 2021-08-21 14:13:55 -06:00
David Wendt 05692cee67 video: Allow pictures with half-pixels in chroma by widening the chroma buffers to the next pixel in that direction. 2021-08-21 14:13:55 -06:00
David Wendt 43f76de602 video: Move software decoding into core now that we don't need to specialize per-renderer 2021-08-21 14:13:55 -06:00
David Wendt 885805f887 core: Half-implement an H.263 decoder 2021-08-21 14:13:55 -06:00
relrelb da7cd453cf chore: Fix png update 2021-08-18 09:01:21 +03:00
Adrian Wielgosik b940e7f00f Extension: Sidestep CORS issues by offering to load the SWF in a tab 2021-08-02 21:28:16 +02:00
relrelb 87e9dda250 chore: Use from_le_bytes in more places 2021-07-09 19:56:52 +03:00
relrelb 29b3225772 core: Fix ADPCM decoder
Store samples and steps as i16 instead of i32.
2021-07-09 19:55:09 +03:00
relrelb 25b8013a99 core: Refactor PCM decoder a bit
Extract a `read_sample` method to avoid code duplication, and use
the byteorder crate as already done in other places.
2021-07-09 19:52:30 +03:00
relrelb 169c79fa3a chore: Minor cleanups 2021-06-26 23:05:11 +03:00
relrelb 0fd1c05fd5 chore: Use into() in more places 2021-06-22 11:49:41 -07:00
Mike Welsh e3d0538999 core: Add AudioManager::stream_buffer_time 2021-06-20 01:25:27 -07:00
Adrian Wielgosik 867b7ffcad
core: Preallocate bitmaps for remaining cases in decode_define_bits_lossless 2021-06-17 15:43:36 -07:00
Mike Welsh 554aa7fd63 core: Add backend::render::BitmapSource trait
This interface handles returning a bitmap given an ID and is used
by the render backend to get the bitmap used for a bitmap fill.
This will allow for bitmap fills in the drawing API, as these will
manage their own list of bitmaps.
This also  removes the MovieLibrary dependency from render backends
and will allow for better decoupling in the future.
2021-06-13 20:03:53 -07:00
Mike Welsh d23ea90459 swf: Change Matrix to use Fixed16 for a, b, c, d
Matrices in an SWF file store their scale/skew components in
in 16.16 format (fbits).

Split `ruffle_core::Matrix` and `swf::Matrix`. `swf::Matrix` now
stores its data as `Fixed16` instead of immediately converting to
`f32`.
2021-06-08 14:57:15 -07:00
relrelb b8eae51888 swf: Move num_colors into BitmapFormat::ColorMap8 2021-06-07 11:29:28 -07:00
relrelb f82faf9603 chore: Appease clippy 2021-06-05 10:16:00 -07:00
CUB3D cd1cde1708 avm1: Implement de/serialization of shared objects into Flash Player Lso format 2021-05-09 23:20:32 -07:00
Mike Welsh ba7fd1b2b9 chore: Appease clippy, bump url
Bump url and avoid `Url::into_string` deprecation warnings.
Fix `single_char_pattern` clippy lints.
2021-05-07 20:51:26 -07:00
Mike Welsh dca97afdd7 chore: Remove puremp3 feature
Wasn't being used, remove the puremp3 dependency.
2021-05-02 19:31:01 -07:00
Mike Welsh b9d84c0a82 chore: Appease clippy
Honor the branches-sharing-code lint.
2021-04-15 00:02:27 -07:00
relrelb 20d6fcc128 chore: Remove unnecessary type annotations 2021-04-10 18:39:16 -07:00
relrelb f8b589fc24 core: Fix panic in remove_invalid_jpeg_data
`data` could be shorter than 4 bytes.
2021-04-09 14:47:19 -07:00
relrelb 732efb27c4 render: Fix RGB15 bitmaps decoding
Each row should be padded to 2.
2021-04-05 20:10:35 -06:00