Hello world!
blaind / webp-animation Goto Github PK
View Code? Open in Web Editor NEWA high-level Rust wrapper for decoding and encoding WebP animations
License: Apache License 2.0
A high-level Rust wrapper for decoding and encoding WebP animations
License: Apache License 2.0
Hello world!
I've been developing an experimental version of Miri that can execute foreign functions by interpreting LLVM bytecode.
Miri found the following error when executing the test webp_data::tests::test_encoder
at version 0.9.0 of webp-animation.
error: Undefined Behavior: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
--> .../rust/library/core/src/slice/raw.rs:101:9
|
101 | &*ptr::slice_from_raw_parts(data, len)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::slice::from_raw_parts::<'_, u8>` at .../rust/library/core/src/slice/raw.rs:101:9: 101:47
note: inside `webp_data::WebPData::as_slice`
--> src/webp_data.rs:27:18
|
27 | unsafe { slice::from_raw_parts(self.data.bytes, self.data.size) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `<webp_data::WebPData as std::ops::Deref>::deref`
--> src/webp_data.rs:41:9
|
41 | self.as_slice()
| ^^^^^^^^^^^^^^^
note: inside `webp_data::tests::test_encoder`
--> src/webp_data.rs:58:20
|
58 | assert_eq!(data.len(), 0);
| ^^^^^^^^^^
note: inside closure
--> src/webp_data.rs:56:23
|
55 | #[test]
| ------- in this procedural macro expansion
56 | fn test_encoder() {
|
It seems like WebPData::new()
does not actually initialize the WebPData
struct to point to valid memory. In particular, here's where data
is initialized in Rust:
let mut data = mem::zeroed();
webp::WebPDataInit(&mut data);
data
It seems like webp::WebPDataInit
just zero-initializes the memory that it's passed:
static inline void WebPDataInit(WebPData* webp_data) {
if (webp_data != ((void*)0)) {
memset(webp_data, 0, sizeof(*webp_data));
}
}
However, this shouldn't be necessary, since the memory being referenced has already been initialized by mem::zeroed()
in Rust. Anyway, it seems like the implementation of WebPData::as_slice
needs to account for the case when data
is NULL
.
Lines 25 to 26 in abe7664
The type i32
is used for timestamps in a lot of places.
Do you think you could switch to using Rust's std::time::Duration for timestamps instead?
This would make the interface look more like Rust and less like C, and it would have saved me some docs reading.
Hi!
My input is in RGB format, with no alpha channel.
To encode this I'd like to specify ColorMode::Rgb
, but the currently supported color modes have alpha channels:
Lines 40 to 48 in abe7664
Could you please add an RGB ColorMode
?
I want to make my animation run in a loop.
But searching for "loop" in here doesn't give me any hints on how to do that.
In the C library looping is part of the encoder options.
After decode an animated webp file I need to encode it to gif with another libray. It works but I dont know the frame rate and new gif has different speed.
Is there a way to get frame rates? If there is no such a feature it would be very useful.
Thank you for this amazing library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.