Rename qoi-fast -> qoi (qoi-rust) + update repo

This commit is contained in:
Ivan Smirnov 2022-01-06 03:59:32 +03:00
parent 3cc5a260fb
commit 53ecac38a9
10 changed files with 35 additions and 35 deletions

View file

@ -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 = [
@ -37,7 +37,7 @@ rand = "0.8"
libqoi = { path = "libqoi"}
[lib]
name = "qoi_fast"
name = "qoi"
path = "src/lib.rs"
doctest = false

View file

@ -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)
@ -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)?;
@ -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:

View file

@ -9,7 +9,7 @@ publish = false
[dependencies]
# internal
libqoi = { path = "../libqoi" }
qoi-fast = { path = ".." }
qoi = { path = ".." }
# external
anyhow = "1.0"
bytemuck = "1.7"

View file

@ -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)
}
}
@ -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());
@ -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)
}

View file

@ -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;

View file

@ -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;

View file

@ -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)?;
@ -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:

View file

@ -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;

View file

@ -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;
@ -291,9 +291,9 @@ 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();
@ -301,10 +301,10 @@ fn test_generated() {
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");
}
}

View file

@ -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();