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:tom.kaitchuck@gmail.com) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.7.2 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [bitvec](https://github.com/bitvecto-rs/bitvec) | 1.0.1 | | MIT |
| [bumpalo](https://github.com/fitzgen/bumpalo) | 3.16.0 | [Nick Fitzgerald](mailto:fitzgen@gmail.com) | Apache-2.0 or MIT |
| [bytecount](https://github.com/llogiq/bytecount) | 0.6.8 | [Andre Bogus](mailto:bogusandre@gmail.de) and [Joshua Landau](mailto:joshua@landau.ws) | Apache-2.0 or MIT |
| [bytemuck](https://github.com/Lokathor/bytemuck) | 1.16.0 | [Lokathor](mailto:zefria@gmail.com) | Apache-2.0, MIT, or Zlib |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:alex@alexcrichton.com) | 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:detegr@gmail.com) | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | 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:stjepang@gmail.com) | Apache-2.0 or MIT |
| flapfli | 3.1.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
| flapfli | 3.1.1 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
| [funty](https://github.com/myrrlyn/funty) | 2.0.0 | [myrrlyn](mailto:self@myrrlyn.dev) | MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.13.6 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.14.5 | [Amanieu d'Antras](mailto:amanieu@gmail.com) | Apache-2.0 or MIT |
Expand All @@ -37,7 +36,7 @@
| [tap](https://github.com/myrrlyn/tap) | 1.0.1 | [Elliott Linder](mailto:elliott.darfink@gmail.com) and [myrrlyn](mailto:self@myrrlyn.dev) | MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.10.1 | [Steven Allen](mailto:steven@stebalien.com), The Rust Project Developers, [Ashley Mannix](mailto:ashleymannix@live.com.au), and [Jason White](mailto:me@jasonwhite.io) | Apache-2.0 or MIT |
| [terminal_size](https://github.com/eminence/terminal-size) | 0.3.0 | [Andrew Chin](mailto:achin@eminence32.net) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.12 | [kwantam](mailto:kwantam@gmail.com) and [Manish Goregaokar](mailto:manishsmail@gmail.com) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.13 | [kwantam](mailto:kwantam@gmail.com) and [Manish Goregaokar](mailto:manishsmail@gmail.com) | Apache-2.0 or MIT |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [wyz](https://github.com/myrrlyn/wyz) | 0.5.1 | [myrrlyn](mailto:self@myrrlyn.dev) | MIT |
| [zerocopy](https://github.com/google/zerocopy) | 0.7.34 | [Joshua Liebow-Feeser](mailto:joshlf@google.com) | 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 <josh@blobfolio.com>"]
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 <josh@blobfolio.com>"]
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.