forked from pnggroup/libpng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a memory leak in the riffled palette optimization on ARM; refactor
Move deallocation of riffled_palette from png_write_destroy to png_read_destroy. The reader (not the writer) is the owner of riffled_palette. Move allocation and initialization of riffled_palette from png_do_read_transformations to png_init_palette_transformations. Allow riffled_palette inside png_struct only if the ARM Neon optimizations are enabled. Rename png_riffle_palette_rgba to png_riffle_palette_rgba8, etc., to better indicate the strict applicability of these routines. Fix an unused parameter warning in the build configurations where riffled palette optimization is not enabled. Fix indentation.
- Loading branch information
Showing
6 changed files
with
68 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions | ||
* | ||
* Copyright (c) 2018 Cosmin Truta | ||
* Copyright (c) 2018-2019 Cosmin Truta | ||
* Copyright (c) 2017-2018 Arm Holdings. All rights reserved. | ||
* Written by Richard Townsend <[email protected]>, February 2017. | ||
* | ||
|
@@ -20,9 +20,9 @@ | |
# include <arm_neon.h> | ||
#endif | ||
|
||
/* Build an RGBA palette from the RGB and separate alpha palettes. */ | ||
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */ | ||
void | ||
png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info) | ||
png_riffle_palette_rgba8(png_structrp png_ptr) | ||
{ | ||
png_const_colorp palette = png_ptr->palette; | ||
png_bytep riffled_palette = png_ptr->riffled_palette; | ||
|
@@ -38,16 +38,10 @@ png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info) | |
vdupq_n_u8(0xff), | ||
}}; | ||
|
||
if (row_info->bit_depth != 8) | ||
{ | ||
png_error(png_ptr, "bit_depth must be 8 for png_riffle_palette_rgba"); | ||
return; | ||
} | ||
|
||
/* First, riffle the RGB colours into a RGBA palette, the A value is | ||
* set to opaque for now. | ||
/* First, riffle the RGB colours into an RGBA8 palette. | ||
* The alpha component is set to opaque for now. | ||
*/ | ||
for (i = 0; i < (1 << row_info->bit_depth); i += 16) | ||
for (i = 0; i < 256; i += 16) | ||
{ | ||
uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i)); | ||
w.val[0] = v.val[0]; | ||
|
@@ -61,9 +55,9 @@ png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info) | |
riffled_palette[(i << 2) + 3] = trans_alpha[i]; | ||
} | ||
|
||
/* Expands a palettized row into RGBA. */ | ||
/* Expands a palettized row into RGBA8. */ | ||
int | ||
png_do_expand_palette_neon_rgba(png_structrp png_ptr, png_row_infop row_info, | ||
png_do_expand_palette_neon_rgba8(png_structrp png_ptr, png_row_infop row_info, | ||
png_const_bytep row, png_bytepp ssp, png_bytepp ddp) | ||
{ | ||
png_uint_32 row_width = row_info->width; | ||
|
@@ -103,9 +97,9 @@ png_do_expand_palette_neon_rgba(png_structrp png_ptr, png_row_infop row_info, | |
return i; | ||
} | ||
|
||
/* Expands a palettized row into RGB format. */ | ||
/* Expands a palettized row into RGB8. */ | ||
int | ||
png_do_expand_palette_neon_rgb(png_structrp png_ptr, png_row_infop row_info, | ||
png_do_expand_palette_neon_rgb8(png_structrp png_ptr, png_row_infop row_info, | ||
png_const_bytep row, png_bytepp ssp, png_bytepp ddp) | ||
{ | ||
png_uint_32 row_width = row_info->width; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters