Skip to content

Commit

Permalink
release: 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Jun 13, 2024
2 parents 3207019 + 7a34e24 commit 494208d
Show file tree
Hide file tree
Showing 22 changed files with 2,623 additions and 2,171 deletions.
11 changes: 5 additions & 6 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Project Dependencies
Package: flaca
Version: 3.1.0
Generated: 2024-05-29 06:04:26 UTC
Version: 3.1.1
Generated: 2024-06-13 17:53:19 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.11 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.7.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [bitvec](https://github.com/bitvecto-rs/bitvec) | 1.0.1 | | MIT |
| [bumpalo](https://github.com/fitzgen/bumpalo) | 3.16.0 | [Nick Fitzgerald](mailto:[email protected]) | Apache-2.0 or MIT |
| [bytecount](https://github.com/llogiq/bytecount) | 0.6.8 | [Andre Bogus](mailto:[email protected]) and [Joshua Landau](mailto:[email protected]) | Apache-2.0 or MIT |
| [bytemuck](https://github.com/Lokathor/bytemuck) | 1.16.0 | [Lokathor](mailto:[email protected]) | Apache-2.0, MIT, or Zlib |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
Expand All @@ -17,10 +16,10 @@
| [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) | 0.8.20 | | Apache-2.0 or MIT |
| [ctrlc](https://github.com/Detegr/rust-ctrlc.git) | 3.4.4 | [Antti Keränen](mailto:[email protected]) | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [equivalent](https://github.com/cuviper/equivalent) | 1.0.1 | | Apache-2.0 or MIT |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.1.0 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| flapfli | 3.1.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| flapfli | 3.1.1 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [funty](https://github.com/myrrlyn/funty) | 2.0.0 | [myrrlyn](mailto:[email protected]) | MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.13.6 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.14.5 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
Expand All @@ -37,7 +36,7 @@
| [tap](https://github.com/myrrlyn/tap) | 1.0.1 | [Elliott Linder](mailto:[email protected]) and [myrrlyn](mailto:[email protected]) | MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.10.1 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [terminal_size](https://github.com/eminence/terminal-size) | 0.3.0 | [Andrew Chin](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.12 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.13 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [wyz](https://github.com/myrrlyn/wyz) | 0.5.1 | [myrrlyn](mailto:[email protected]) | MIT |
| [zerocopy](https://github.com/google/zerocopy) | 0.7.34 | [Joshua Liebow-Feeser](mailto:[email protected]) | Apache-2.0, BSD-2-Clause, or MIT |
3 changes: 2 additions & 1 deletion flaca/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flaca"
version = "3.1.0"
version = "3.1.1"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand Down Expand Up @@ -117,6 +117,7 @@ crossbeam-channel = "=0.5.*"
ctrlc = "=3.4.4"
dactyl = "0.7.*"
dowser = "0.9.*"
libc = "0.2.*"
write_atomic = "0.5.*"

[dependencies.flapfli]
Expand Down
59 changes: 56 additions & 3 deletions flaca/src/image/jpegtran.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,64 @@ use mozjpeg_sys::{
use std::{
ffi::{
c_int,
c_uchar,
c_ulong,
c_void,
},
marker::PhantomPinned,
ops::Deref,
};
use flapfli::EncodedImage;



#[derive(Debug)]
/// # Encoded Image.
///
/// This holds a buffer pointer and size for an image allocated in C-land. It
/// exists primarily to enforce cleanup at destruction, but also makes it easy
/// to view the data as a slice.
pub(super) struct EncodedJPEG {
/// # Buffer.
buf: *mut c_uchar,

/// # Buffer Size.
size: c_ulong,
}

impl Deref for EncodedJPEG {
type Target = [u8];

#[allow(clippy::cast_possible_truncation, unsafe_code)]
fn deref(&self) -> &Self::Target {
if self.is_empty() { &[] }
else {
unsafe { std::slice::from_raw_parts(self.buf, self.size as usize) }
}
}
}

impl Drop for EncodedJPEG {
#[allow(unsafe_code)]
fn drop(&mut self) {
if ! self.is_empty() {
unsafe { libc::free(self.buf.cast::<c_void>()); }
self.buf = std::ptr::null_mut();
}
}
}

impl EncodedJPEG {
/// # New.
const fn new() -> Self {
Self {
buf: std::ptr::null_mut(),
size: 0,
}
}

/// # Is Empty?
fn is_empty(&self) -> bool { self.size == 0 || self.buf.is_null() }
}



Expand All @@ -68,7 +121,7 @@ use flapfli::EncodedImage;
/// ## Safety
///
/// The data should be valid JPEG data. Weird things could happen if it isn't.
pub(super) fn optimize(src: &[u8]) -> Option<EncodedImage<c_ulong>> {
pub(super) fn optimize(src: &[u8]) -> Option<EncodedJPEG> {
let mut transformoption = jpeg_transform_info {
transform: JXFORM_CODE_JXFORM_NONE,
perfect: 0,
Expand Down Expand Up @@ -140,7 +193,7 @@ pub(super) fn optimize(src: &[u8]) -> Option<EncodedImage<c_ulong>> {
dstinfo.cinfo.optimize_coding = 1;

// Compress!
let mut out = EncodedImage::default();
let mut out = EncodedJPEG::new();
unsafe {
// Enable "progressive".
jpeg_simple_progression(&mut dstinfo.cinfo);
Expand Down
8 changes: 5 additions & 3 deletions flapfli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flapfli"
version = "3.1.0"
version = "3.1.1"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand All @@ -16,10 +16,12 @@ exclude = [
]

[dependencies]
bumpalo = "=3.16.0"
crc32fast = "=1.4.*"
dactyl = "0.7.*"
libc = "0.2.*"

[dependencies.ahash]
version = "=0.8.*"
default-features = false

[build-dependencies]
bindgen = "0.69.*"
Expand Down
Loading

0 comments on commit 494208d

Please sign in to comment.