Skip to content

Commit

Permalink
revert palette and alpha after parsing
Browse files Browse the repository at this point in the history
This avoids having to do it each time you use it.
Warning: breaking change
  • Loading branch information
gwen-lg committed Jul 12, 2024
1 parent 86f0981 commit d9da70b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vobsub/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::{
},
};
use cast;
use iter_fixed::IntoIteratorFixed;
use log::{trace, warn};
use nom::{
bits::{bits, complete::take as take_bits},
Expand Down Expand Up @@ -408,6 +409,9 @@ where
//

let end = cast::usize(initial_control_offset + 2);
// reverse palette & alpha once for all
let palette = palette.into_iter_fixed().rev().collect();
let alpha = alpha.into_iter_fixed().rev().collect();
let image_data = VobSubRleImageData::new(raw_data, rle_offsets, end)?;
let rle_image = VobSubRleImage::new(area, palette, alpha, image_data);

Expand Down Expand Up @@ -614,8 +618,8 @@ mod tests {
})
.unwrap()
);
assert_eq!(*sub1.image.palette(), [0, 3, 1, 0]);
assert_eq!(*sub1.image.alpha(), [15, 15, 15, 0]);
assert_eq!(*sub1.image.palette(), [0, 1, 3, 0]);
assert_eq!(*sub1.image.alpha(), [0, 15, 15, 15]);
subs.next().expect("missing sub 2").unwrap();
assert!(subs.next().is_none());
}
Expand Down

0 comments on commit d9da70b

Please sign in to comment.