png_rgb_to_gray optimization fixes

This fixes the code that optimizes RGB to Gray transformations that only
selected on channel and clarifies the handling of max_depth in the transform
code.  It eliminates some UNTESTED cases and removes the write 'invert alpha'
UNTESTED macro because, while there are no test cases for it, code review
some months after writing it suggests it is ok.

Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
John Bowler
2015-09-24 17:33:32 -07:00
parent bf51c644f7
commit d394d889e1
5 changed files with 50 additions and 25 deletions

View File

@@ -6048,7 +6048,7 @@ update_palette(png_structp png_ptr, png_cache_paramsp cp,
cp->tend.dp = cache.b8;
check_depth =
png_run_this_transform_list_forwards(&cp->tend, cp->start, cp->end);
png_run_this_transform_list_forwards(&cp->tend, cp->start, *cp->end);
/* If we get here these two things must be true or there are been some
* buggy difference of opinion between the INIT code and the actual run:
@@ -6308,7 +6308,7 @@ make_cache(png_structp png_ptr, png_cache_paramsp cp, unsigned int max_depth)
{
unsigned int check_depth =
png_run_this_transform_list_forwards(&cp->tend, cp->start, cp->end);
png_run_this_transform_list_forwards(&cp->tend, cp->start, *cp->end);
/* This must not change: */
affirm(PNG_TC_PIXEL_DEPTH(cp->tend) == opd && check_depth == max_depth);
@@ -6590,7 +6590,7 @@ png_read_init_transform_mech(png_structp png_ptr, png_transform_controlp tc)
*/
{
png_transformp *list = &png_ptr->transform_list;
unsigned int max_depth = 0U;
unsigned int max_depth;
png_cache_params cp;
/* PNG color-mapped data must be handled here so that the palette is updated
@@ -6610,6 +6610,7 @@ png_read_init_transform_mech(png_structp png_ptr, png_transform_controlp tc)
cp.end = cp.start = list;
cp.tend = cp.tstart = *tc;
init_caching(png_ptr, &cp);
max_depth = PNG_TC_PIXEL_DEPTH(cp.tend);
while (*cp.end != NULL)
{
@@ -6660,7 +6661,9 @@ png_read_init_transform_mech(png_structp png_ptr, png_transform_controlp tc)
*/
if (cp.tend.caching)
{
png_transformp tr = *cp.end;
handle_cache(png_ptr, &cp, max_depth);
affirm(tr == *cp.end);
max_depth = PNG_TC_PIXEL_DEPTH(cp.tend);
}