Skip to content

Commit

Permalink
Rename qoi-fast -> qoi (qoi-rust) + update repo
Browse files Browse the repository at this point in the history
  • Loading branch information
aldanor committed Jan 6, 2022
1 parent 3cc5a26 commit 53ecac3
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "qoi-fast"
version = "0.2.0"
description = "Fast encoder/decoder for QOI (Quite Okay Image) format"
name = "qoi"
version = "0.4.0"
description = "VERY fast encoder/decoder for QOI (Quite Okay Image) format"
authors = ["Ivan Smirnov <rust@ivan.smirnov.ie>"]
edition = "2018"
readme = "README.md"
license = "MIT/Apache-2.0"
repository = "https://github.com/aldanor/qoi-fast"
homepage = "https://github.com/aldanor/qoi-fast"
documentation = "https://docs.rs/qoi-fast"
repository = "https://github.com/aldanor/qoi-rust"
homepage = "https://github.com/aldanor/qoi-rust"
documentation = "https://docs.rs/qoi"
categories = ["multimedia::images", "multimedia::encoding"]
keywords = ["qoi", "graphics", "image", "encoding"]
exclude = [
Expand Down Expand Up @@ -37,7 +37,7 @@ rand = "0.8"
libqoi = { path = "libqoi"}

[lib]
name = "qoi_fast"
name = "qoi"
path = "src/lib.rs"
doctest = false

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# [qoi-fast](https://crates.io/crates/qoi-fast)
# [qoi](https://crates.io/crates/qoi)

[![Build](https://github.com/aldanor/qoi-fast/workflows/CI/badge.svg)](https://github.com/aldanor/qoi-fast/actions?query=branch%3Amaster)
[![Latest Version](https://img.shields.io/crates/v/qoi-fast.svg)](https://crates.io/crates/qoi-fast)
[![Documentation](https://img.shields.io/docsrs/qoi-fast)](https://docs.rs/qoi-fast)
[![Build](https://github.com/aldanor/qoi-rust/workflows/CI/badge.svg)](https://github.com/aldanor/qoi-rust/actions?query=branch%3Amaster)
[![Latest Version](https://img.shields.io/crates/v/qoi.svg)](https://crates.io/crates/qoi)
[![Documentation](https://img.shields.io/docsrs/qoi)](https://docs.rs/qoi)
[![Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)
Expand All @@ -19,7 +19,7 @@ Fast encoder/decoder for [QOI image format](https://qoiformat.org/), implemented
### Examples

```rust
use qoi_fast::{encode_to_vec, decode_to_vec};
use qoi::{encode_to_vec, decode_to_vec};

let encoded = encode_to_vec(&pixels, width, height)?;
let (header, decoded) = decode_to_vec(&encoded)?;
Expand All @@ -34,7 +34,7 @@ assert_eq!(decoded, pixels);
```
decode:Mp/s encode:Mp/s decode:MB/s encode:MB/s
qoi.h 282.9 225.3 978.3 778.9
qoi-fast 427.4 290.0 1477.7 1002.9
qoi-rust 427.4 290.0 1477.7 1002.9
```

- Reference C implementation:
Expand Down
2 changes: 1 addition & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
# internal
libqoi = { path = "../libqoi" }
qoi-fast = { path = ".." }
qoi = { path = ".." }
# external
anyhow = "1.0"
bytemuck = "1.7"
Expand Down
14 changes: 7 additions & 7 deletions bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,21 @@ trait Codec {
fn decode(data: &[u8], img: &Image) -> Result<Self::Output>;
}

struct CodecQoiFast;
struct CodecQoiRust;

impl Codec for CodecQoiFast {
impl Codec for CodecQoiRust {
type Output = Vec<u8>;

fn name() -> &'static str {
"qoi-fast"
"qoi-rust"
}

fn encode(img: &Image) -> Result<Vec<u8>> {
Ok(qoi_fast::encode_to_vec(&img.data, img.width, img.height)?)
Ok(qoi::encode_to_vec(&img.data, img.width, img.height)?)
}

fn decode(data: &[u8], _img: &Image) -> Result<Vec<u8>> {
Ok(qoi_fast::decode_to_vec(data)?.1)
Ok(qoi::decode_to_vec(data)?.1)
}
}

Expand Down Expand Up @@ -215,7 +215,7 @@ impl ImageBench {
let (decoded, t_decode) = timeit(|| C::decode(encoded.as_ref(), img));
let decoded = decoded?;
let roundtrip = decoded.as_ref() == img.data.as_slice();
if C::name() == "qoi-fast" {
if C::name() == "qoi-rust" {
assert!(roundtrip, "{}: decoded data doesn't roundtrip", C::name());
} else {
ensure!(roundtrip, "{}: decoded data doesn't roundtrip", C::name());
Expand Down Expand Up @@ -374,7 +374,7 @@ fn bench_png(filename: &Path, seconds: f64, use_median: bool) -> Result<ImageBen
);
let mut bench = ImageBench::new(&img);
bench.run::<CodecQoiC>(&img, seconds)?;
bench.run::<CodecQoiFast>(&img, seconds)?;
bench.run::<CodecQoiRust>(&img, seconds)?;
bench.report(use_median);
Ok(bench)
}
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/decode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

use qoi_fast::{decode_header, decode_to_vec, Channels, ColorSpace, Header};
use qoi::{decode_header, decode_to_vec, Channels, ColorSpace, Header};

fuzz_target!(|input: (u16, u16, bool, &[u8])| {
let (w, h, is_4, data) = input;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/encode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

use qoi_fast::{encode_size_limit, encode_to_vec};
use qoi::{encode_size_limit, encode_to_vec};

fuzz_target!(|input: (bool, u8, &[u8])| {
let (is_4, w_frac, data) = input;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! ### Examples
//!
//! ```rust
//! use qoi_fast::{encode_to_vec, decode_to_vec};
//! use qoi::{encode_to_vec, decode_to_vec};
//!
//! let encoded = encode_to_vec(&pixels, width, height)?;
//! let (header, decoded) = decode_to_vec(&encoded)?;
Expand All @@ -25,7 +25,7 @@
//! ```
//! decode:Mp/s encode:Mp/s decode:MB/s encode:MB/s
//! qoi.h 282.9 225.3 978.3 778.9
//! qoi-fast 427.4 290.0 1477.7 1002.9
//! qoi-rust 427.4 290.0 1477.7 1002.9
//! ```
//!
//! - Reference C implementation:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ mod common;

use bytemuck::{cast_slice, Pod};

use qoi_fast::consts::{
use qoi::consts::{
QOI_HEADER_SIZE, QOI_OP_DIFF, QOI_OP_INDEX, QOI_OP_LUMA, QOI_OP_RGB, QOI_OP_RGBA, QOI_OP_RUN,
QOI_PADDING_SIZE,
};
use qoi_fast::{decode_to_vec, encode_to_vec};
use qoi::{decode_to_vec, encode_to_vec};

use self::common::hash;

Expand Down
14 changes: 7 additions & 7 deletions tests/test_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use rand::{
};

use libqoi::{qoi_decode, qoi_encode};
use qoi_fast::consts::{
use qoi::consts::{
QOI_HEADER_SIZE, QOI_MASK_2, QOI_OP_DIFF, QOI_OP_INDEX, QOI_OP_LUMA, QOI_OP_RGB, QOI_OP_RGBA,
QOI_OP_RUN, QOI_PADDING_SIZE,
};
use qoi_fast::{decode_header, decode_to_vec, encode_to_vec};
use qoi::{decode_header, decode_to_vec, encode_to_vec};

use self::common::hash;

Expand Down Expand Up @@ -291,20 +291,20 @@ fn test_generated() {
let encode_c = |data: &[u8], size| qoi_encode(data, size, 1, channels as _);
let decode_c = |data: &[u8]| qoi_decode(data, channels as _).map(|r| r.1);

check_roundtrip("qoi-fast -> qoi-fast", &img, channels as _, encode, decode);
check_roundtrip("qoi-fast -> qoi.h", &img, channels as _, encode, decode_c);
check_roundtrip("qoi.h -> qoi-fast", &img, channels as _, encode_c, decode);
check_roundtrip("qoi-rust -> qoi-rust", &img, channels as _, encode, decode);
check_roundtrip("qoi-rust -> qoi.h", &img, channels as _, encode, decode_c);
check_roundtrip("qoi.h -> qoi-rust", &img, channels as _, encode_c, decode);

let size = (img.len() / channels) as u32;
let encoded = encode(&img, size).unwrap();
let encoded_c = encode_c(&img, size).unwrap();
cfg_if! {
if #[cfg(feature = "reference")] {
let eq = encoded.as_slice() == encoded_c.as_ref();
assert!(eq, "qoi-fast [reference mode] doesn't match qoi.h");
assert!(eq, "qoi-rust [reference mode] doesn't match qoi.h");
} else {
let eq = encoded.len() == encoded_c.len();
assert!(eq, "qoi-fast [non-reference mode] length doesn't match qoi.h");
assert!(eq, "qoi-rust [non-reference mode] length doesn't match qoi.h");
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::{bail, Result};
use cfg_if::cfg_if;
use walkdir::{DirEntry, WalkDir};

use qoi_fast::{decode_to_vec, encode_to_vec};
use qoi::{decode_to_vec, encode_to_vec};

fn find_qoi_png_pairs(root: impl AsRef<Path>) -> Vec<(PathBuf, PathBuf)> {
let root = root.as_ref();
Expand Down

0 comments on commit 53ecac3

Please sign in to comment.