7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /* pngpread.c - read a png file in push mode
26 *
27 * This file is available under and governed by the GNU General Public
28 * License version 2 only, as published by the Free Software Foundation.
29 * However, the following notice accompanied the original version of this
30 * file and, per its terms, should not be removed:
31 *
32 * Last changed in libpng 1.6.35 [July 15, 2018]
33 * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
34 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
35 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
36 *
37 * This code is released under the libpng license.
38 * For conditions of distribution and use, see the disclaimer
39 * and license in png.h
40 */
41
42 #include "pngpriv.h"
43
44 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
45
46 /* Push model modes */
47 #define PNG_READ_SIG_MODE 0
48 #define PNG_READ_CHUNK_MODE 1
49 #define PNG_READ_IDAT_MODE 2
50 #define PNG_READ_tEXt_MODE 4
51 #define PNG_READ_zTXt_MODE 5
52 #define PNG_READ_DONE_MODE 6
53 #define PNG_READ_iTXt_MODE 7
54 #define PNG_ERROR_MODE 8
55
983 png_push_have_row(png_ptr, NULL);
984 png_read_push_finish_row(png_ptr);
985 }
986 }
987 }
988 else
989 #endif
990 {
991 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
992 png_read_push_finish_row(png_ptr);
993 }
994 }
995
996 void /* PRIVATE */
997 png_read_push_finish_row(png_structrp png_ptr)
998 {
999 #ifdef PNG_READ_INTERLACING_SUPPORTED
1000 /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
1001
1002 /* Start of interlace block */
1003 static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
1004
1005 /* Offset to next interlace block */
1006 static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
1007
1008 /* Start of interlace block in the y direction */
1009 static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
1010
1011 /* Offset to next interlace block in the y direction */
1012 static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
1013
1014 /* Height of interlace block. This is not currently used - if you need
1015 * it, uncomment it here and in png.h
1016 static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
1017 */
1018 #endif
1019
1020 png_ptr->row_number++;
1021 if (png_ptr->row_number < png_ptr->num_rows)
1022 return;
1023
1024 #ifdef PNG_READ_INTERLACING_SUPPORTED
1025 if (png_ptr->interlaced != 0)
1026 {
1027 png_ptr->row_number = 0;
1028 memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
1029
1030 do
1031 {
1032 png_ptr->pass++;
1033 if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
1034 (png_ptr->pass == 3 && png_ptr->width < 3) ||
1035 (png_ptr->pass == 5 && png_ptr->width < 2))
1036 png_ptr->pass++;
|
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /* pngpread.c - read a png file in push mode
26 *
27 * Copyright (c) 2018 Cosmin Truta
28 * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
29 * Copyright (c) 1996-1997 Andreas Dilger
30 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
31 *
32 * This code is released under the libpng license.
33 * For conditions of distribution and use, see the disclaimer
34 * and license in png.h
35 */
36
37 #include "pngpriv.h"
38
39 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
40
41 /* Push model modes */
42 #define PNG_READ_SIG_MODE 0
43 #define PNG_READ_CHUNK_MODE 1
44 #define PNG_READ_IDAT_MODE 2
45 #define PNG_READ_tEXt_MODE 4
46 #define PNG_READ_zTXt_MODE 5
47 #define PNG_READ_DONE_MODE 6
48 #define PNG_READ_iTXt_MODE 7
49 #define PNG_ERROR_MODE 8
50
978 png_push_have_row(png_ptr, NULL);
979 png_read_push_finish_row(png_ptr);
980 }
981 }
982 }
983 else
984 #endif
985 {
986 png_push_have_row(png_ptr, png_ptr->row_buf + 1);
987 png_read_push_finish_row(png_ptr);
988 }
989 }
990
991 void /* PRIVATE */
992 png_read_push_finish_row(png_structrp png_ptr)
993 {
994 #ifdef PNG_READ_INTERLACING_SUPPORTED
995 /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
996
997 /* Start of interlace block */
998 static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
999
1000 /* Offset to next interlace block */
1001 static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
1002
1003 /* Start of interlace block in the y direction */
1004 static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
1005
1006 /* Offset to next interlace block in the y direction */
1007 static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
1008
1009 /* Height of interlace block. This is not currently used - if you need
1010 * it, uncomment it here and in png.h
1011 static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
1012 */
1013 #endif
1014
1015 png_ptr->row_number++;
1016 if (png_ptr->row_number < png_ptr->num_rows)
1017 return;
1018
1019 #ifdef PNG_READ_INTERLACING_SUPPORTED
1020 if (png_ptr->interlaced != 0)
1021 {
1022 png_ptr->row_number = 0;
1023 memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
1024
1025 do
1026 {
1027 png_ptr->pass++;
1028 if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
1029 (png_ptr->pass == 3 && png_ptr->width < 3) ||
1030 (png_ptr->pass == 5 && png_ptr->width < 2))
1031 png_ptr->pass++;
|