зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1684652 - Drop some unneeded casts. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D100580
This commit is contained in:
Родитель
8e8a8fc213
Коммит
62c417fe2e
|
@ -723,8 +723,8 @@ fn modular_transform_create_input(in_0: &Profile) -> Option<Box<qcms_modular_tra
|
|||
append_transform(lut_transform, next_transform);
|
||||
}
|
||||
} else if in_0.mAB.is_some()
|
||||
&& (*in_0.mAB.as_deref().unwrap()).num_in_channels as i32 == 3
|
||||
&& (*in_0.mAB.as_deref().unwrap()).num_out_channels as i32 == 3
|
||||
&& (*in_0.mAB.as_deref().unwrap()).num_in_channels == 3
|
||||
&& (*in_0.mAB.as_deref().unwrap()).num_out_channels == 3
|
||||
{
|
||||
let mAB_transform = modular_transform_create_mAB(in_0.mAB.as_deref().unwrap());
|
||||
if mAB_transform.is_none() {
|
||||
|
@ -794,8 +794,8 @@ fn modular_transform_create_output(out: &Profile) -> Option<Box<qcms_modular_tra
|
|||
append_transform(lut_transform, next_transform);
|
||||
}
|
||||
} else if out.mBA.is_some()
|
||||
&& (*out.mBA.as_deref().unwrap()).num_in_channels as i32 == 3
|
||||
&& (*out.mBA.as_deref().unwrap()).num_out_channels as i32 == 3
|
||||
&& (*out.mBA.as_deref().unwrap()).num_in_channels == 3
|
||||
&& (*out.mBA.as_deref().unwrap()).num_out_channels == 3
|
||||
{
|
||||
let lut_transform_0 = modular_transform_create_mAB(out.mBA.as_deref().unwrap());
|
||||
if lut_transform_0.is_none() {
|
||||
|
|
|
@ -191,12 +191,12 @@ struct mem_source<'a> {
|
|||
pub type uInt8Number = u8;
|
||||
#[inline]
|
||||
fn uInt8Number_to_float(a: uInt8Number) -> f32 {
|
||||
a as i32 as f32 / 255.0
|
||||
a as f32 / 255.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn uInt16Number_to_float(a: uInt16Number) -> f32 {
|
||||
a as i32 as f32 / 65535.0
|
||||
a as f32 / 65535.0
|
||||
}
|
||||
|
||||
fn cpu_to_be32(v: u32) -> be32 {
|
||||
|
@ -295,7 +295,7 @@ fn check_profile_version(src: &mut mem_source) {
|
|||
invalid_source(src, "Unsupported minor revision");
|
||||
}
|
||||
*/
|
||||
if reserved1 as i32 != 0 || reserved2 as i32 != 0 {
|
||||
if reserved1 != 0 || reserved2 != 0 {
|
||||
invalid_source(src, "Invalid reserved bytes");
|
||||
};
|
||||
}
|
||||
|
@ -555,19 +555,16 @@ fn read_tag_s15Fixed16ArrayType(src: &mut mem_source, index: &tag_index, tag_id:
|
|||
invalid: false,
|
||||
};
|
||||
if let Some(tag) = tag {
|
||||
let mut i: u8;
|
||||
let offset: u32 = tag.offset;
|
||||
let type_0: u32 = read_u32(src, offset as usize);
|
||||
// Check mandatory type signature for s16Fixed16ArrayType
|
||||
if type_0 != CHROMATIC_TYPE {
|
||||
invalid_source(src, "unexpected type, expected \'sf32\'");
|
||||
}
|
||||
i = 0u8;
|
||||
while (i as i32) < 9 {
|
||||
matrix.m[(i as i32 / 3) as usize][(i as i32 % 3) as usize] = s15Fixed16Number_to_float(
|
||||
read_s15Fixed16Number(src, (offset + 8 + (i as i32 * 4) as u32) as usize),
|
||||
for i in 0..=8 {
|
||||
matrix.m[(i / 3) as usize][(i % 3) as usize] = s15Fixed16Number_to_float(
|
||||
read_s15Fixed16Number(src, (offset + 8 + (i * 4) as u32) as usize),
|
||||
);
|
||||
i += 1
|
||||
}
|
||||
matrix.invalid = false
|
||||
} else {
|
||||
|
@ -705,14 +702,14 @@ fn read_tag_lutmABType(src: &mut mem_source, tag: &tag) -> Option<Box<lutmABType
|
|||
}
|
||||
num_in_channels = read_u8(src, (offset + 8) as usize);
|
||||
num_out_channels = read_u8(src, (offset + 9) as usize);
|
||||
if num_in_channels as i32 > 10 || num_out_channels as i32 > 10 {
|
||||
if num_in_channels > 10 || num_out_channels > 10 {
|
||||
return None;
|
||||
}
|
||||
// We require 3in/out channels since we only support RGB->XYZ (or RGB->LAB)
|
||||
// XXX: If we remove this restriction make sure that the number of channels
|
||||
// is less or equal to the maximum number of mAB curves in qcmsint.h
|
||||
// also check for clut_size overflow. Also make sure it's != 0
|
||||
if num_in_channels as i32 != 3 || num_out_channels as i32 != 3 {
|
||||
if num_in_channels != 3 || num_out_channels != 3 {
|
||||
return None;
|
||||
}
|
||||
// some of this data is optional and is denoted by a zero offset
|
||||
|
@ -740,7 +737,7 @@ fn read_tag_lutmABType(src: &mut mem_source, tag: &tag) -> Option<Box<lutmABType
|
|||
b_curve_offset += offset
|
||||
}
|
||||
if clut_offset != 0 {
|
||||
debug_assert!(num_in_channels as i32 == 3);
|
||||
debug_assert!(num_in_channels == 3);
|
||||
// clut_size can not overflow since lg(256^num_in_channels) = 24 bits.
|
||||
i = 0;
|
||||
while i < num_in_channels as u32 {
|
||||
|
@ -765,7 +762,7 @@ fn read_tag_lutmABType(src: &mut mem_source, tag: &tag) -> Option<Box<lutmABType
|
|||
i = 0;
|
||||
while i < num_in_channels as u32 {
|
||||
lut.num_grid_points[i as usize] = read_u8(src, (clut_offset + i) as usize);
|
||||
if lut.num_grid_points[i as usize] as i32 == 0 {
|
||||
if lut.num_grid_points[i as usize] == 0 {
|
||||
invalid_source(src, "bad grid_points");
|
||||
}
|
||||
i += 1
|
||||
|
@ -804,7 +801,7 @@ fn read_tag_lutmABType(src: &mut mem_source, tag: &tag) -> Option<Box<lutmABType
|
|||
if clut_offset != 0 {
|
||||
clut_precision = read_u8(src, (clut_offset + 16) as usize);
|
||||
let mut clut_table = Vec::with_capacity(clut_size as usize);
|
||||
if clut_precision as i32 == 1 {
|
||||
if clut_precision == 1 {
|
||||
for i in 0..clut_size {
|
||||
clut_table.push(uInt8Number_to_float(read_uInt8Number(
|
||||
src,
|
||||
|
@ -812,7 +809,7 @@ fn read_tag_lutmABType(src: &mut mem_source, tag: &tag) -> Option<Box<lutmABType
|
|||
)));
|
||||
}
|
||||
lut.clut_table = Some(clut_table);
|
||||
} else if clut_precision as i32 == 2 {
|
||||
} else if clut_precision == 2 {
|
||||
for i in 0..clut_size {
|
||||
clut_table.push(uInt16Number_to_float(read_uInt16Number(
|
||||
src,
|
||||
|
@ -879,7 +876,7 @@ fn read_tag_lutType(src: &mut mem_source, tag: &tag) -> Option<Box<lutType>> {
|
|||
invalid_source(src, "CLUT must not be empty.");
|
||||
return None;
|
||||
}
|
||||
if in_chan as i32 != 3 || out_chan as i32 != 3 {
|
||||
if in_chan != 3 || out_chan != 3 {
|
||||
invalid_source(src, "CLUT only supports RGB");
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -1113,9 +1113,9 @@ fn transform_precacheLUT_float(
|
|||
for x in 0..samples {
|
||||
for y in 0..samples {
|
||||
for z in 0..samples {
|
||||
src.push(x as i32 as f32 / (samples - 1) as f32);
|
||||
src.push(y as i32 as f32 / (samples - 1) as f32);
|
||||
src.push(z as i32 as f32 / (samples - 1) as f32);
|
||||
src.push(x as f32 / (samples - 1) as f32);
|
||||
src.push(y as f32 / (samples - 1) as f32);
|
||||
src.push(z as f32 / (samples - 1) as f32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1165,7 +1165,7 @@ pub fn transform_create(
|
|||
precache = true
|
||||
}
|
||||
// This precache assumes RGB_SIGNATURE (fails on GRAY_SIGNATURE, for instance)
|
||||
if SUPPORTS_ICCV4.load(Ordering::Relaxed) as i32 != 0
|
||||
if SUPPORTS_ICCV4.load(Ordering::Relaxed)
|
||||
&& (in_type == DATA_RGB_8 || in_type == DATA_RGBA_8 || in_type == DATA_BGRA_8)
|
||||
&& (in_0.A2B0.is_some() || out.B2A0.is_some() || in_0.mAB.is_some() || out.mAB.is_some())
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче