Skip to content

Commit

Permalink
Merge branch 'main' into fix-modular-section-assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
veluca93 authored Dec 24, 2024
2 parents 288c6fc + 1315510 commit c9f18be
Show file tree
Hide file tree
Showing 20 changed files with 1,146 additions and 154 deletions.
35 changes: 26 additions & 9 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@ jobs:
run:
./ci/pull_request_checks.sh

rust:
name: Test, Format and Clippy
runs-on: [ubuntu-latest]
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
check: [format, clippy, test]
features: [all, default]
exclude:
# Remove the "format+all" combination, since it is the same as "format+default"
- check: format
features: all
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -38,20 +47,28 @@ jobs:
with:
components: clippy, rustfmt

- name: Build artefact caching
- name: Rust cache
uses: Swatinem/[email protected]

- name: Format
# format
- name: Cargo fmt (check)
if: ${{ matrix.check == 'format' }}
run: cargo fmt --all -- --check

- name: Clippy
# clippy
- name: Clippy with all features
if: ${{ matrix.check == 'clippy' && matrix.features == 'all' }}
run: cargo clippy --release --all-targets --all-features --tests --all -- -D warnings

- name: Clippy with default features
if: ${{ matrix.check == 'clippy' && matrix.features == 'default' }}
run: cargo clippy --release --all-targets --tests --all -- -D warnings

- name: Run tests
# test
- name: Tests with all features
if: ${{ matrix.check == 'test' && matrix.features == 'all' }}
run: cargo test --release --all --no-fail-fast --all-features

- name: Run tests with default features
- name: Tests with default features
if: ${{ matrix.check == 'test' && matrix.features == 'default' }}
run: cargo test --release --all --no-fail-fast
11 changes: 5 additions & 6 deletions jxl/src/entropy_coding/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use std::fmt::Debug;
use crate::bit_reader::BitReader;
use crate::entropy_coding::decode::*;
use crate::error::{Error, Result};
use crate::util::tracing_wrappers::*;
use crate::util::*;
use crate::util::{tracing_wrappers::*, CeilLog2, NewWithCapacity};

pub const HUFFMAN_MAX_BITS: usize = 15;
const TABLE_BITS: usize = 8;
Expand Down Expand Up @@ -104,7 +103,7 @@ impl Table {
TABLE_SIZE
]),
(2, _) => {
let mut ret = Vec::with_capacity(TABLE_SIZE);
let mut ret = Vec::new_with_capacity(TABLE_SIZE)?;
for _ in 0..(TABLE_SIZE >> 1) {
ret.push(TableEntry {
bits: 1,
Expand All @@ -118,7 +117,7 @@ impl Table {
Ok(ret)
}
(3, _) => {
let mut ret = Vec::with_capacity(TABLE_SIZE);
let mut ret = Vec::new_with_capacity(TABLE_SIZE)?;
for _ in 0..(TABLE_SIZE >> 2) {
ret.push(TableEntry {
bits: 1,
Expand All @@ -140,7 +139,7 @@ impl Table {
Ok(ret)
}
(4, false) => {
let mut ret = Vec::with_capacity(TABLE_SIZE);
let mut ret = Vec::new_with_capacity(TABLE_SIZE)?;
for _ in 0..(TABLE_SIZE >> 2) {
ret.push(TableEntry {
bits: 2,
Expand All @@ -162,7 +161,7 @@ impl Table {
Ok(ret)
}
(4, true) => {
let mut ret = Vec::with_capacity(TABLE_SIZE);
let mut ret = Vec::new_with_capacity(TABLE_SIZE)?;
symbols[2..4].sort_unstable();
for _ in 0..(TABLE_SIZE >> 3) {
ret.push(TableEntry {
Expand Down
2 changes: 1 addition & 1 deletion jxl/src/entropy_coding/hybrid_uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use crate::bit_reader::BitReader;
use crate::error::Error;

use crate::util::*;
use crate::util::CeilLog2;

#[derive(Debug)]
pub struct HybridUint {
Expand Down
20 changes: 19 additions & 1 deletion jxl/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ pub enum Error {
InvalidPredictor(u32),
#[error("Invalid modular mode property: {0}")]
InvalidProperty(u32),
#[error("Invalid alpha channel for blending: {0}, limit is {1}")]
PatchesInvalidAlphaChannel(usize, usize),
#[error("Invalid patch blend mode: {0}, limit is {1}")]
PatchesInvalidBlendMode(u8, u8),
#[error("Invalid Patch: negative {0}-coordinate: {1} base {0}, {2} delta {0}")]
PatchesInvalidDelta(String, usize, i32),
#[error("Invalid position specified in reference frame in {0}-coordinate: {0}0 + {0}size = {1} + {2} > {3} = reference_frame {0}size")]
PatchesInvalidPosition(String, usize, usize, usize),
#[error("Patches invalid reference frame at index {0}")]
PatchesInvalidReference(usize),
#[error("Invalid Patch {0}: at {1} + {2} > {3}")]
PatchesOutOfBounds(String, usize, usize, usize),
#[error("Patches cannot use frames saved post color transforms")]
PatchesPostColorTransform(),
#[error("Too many {0}: {1}, limit is {2}")]
PatchesTooMany(String, usize, usize),
#[error("Reference too large: {0}, limit is {1}")]
PatchesRefTooLarge(usize, usize),
#[error("Point list is empty")]
PointListEmpty,
#[error("Too large area for spline: {0}, limit is {1}")]
Expand All @@ -122,7 +140,7 @@ pub enum Error {
#[error("Too many splines: {0}, limit is {1}")]
SplinesTooMany(u32, u32),
#[error("Spline has adjacent coinciding control points: point[{0}]: {1:?}, point[{2}]: {3:?}")]
SplineAdjacentCoincidingControlPoints(u32, Point, u32, Point),
SplineAdjacentCoincidingControlPoints(usize, Point, usize, Point),
#[error("Too many control points for splines: {0}, limit is {1}")]
SplinesTooManyControlPoints(u32, u32),
#[error(
Expand Down
1 change: 1 addition & 0 deletions jxl/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
// license that can be found in the LICENSE file.

pub mod noise;
pub mod patches;
pub mod spline;
Loading

0 comments on commit c9f18be

Please sign in to comment.