2 /* pngget.c - retrieval of values from info struct
4 * libpng 1.2.5 - October 3, 2002
5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2002 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
15 png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
17 if (png_ptr != NULL && info_ptr != NULL)
18 return(info_ptr->valid & flag);
24 png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
26 if (png_ptr != NULL && info_ptr != NULL)
27 return(info_ptr->rowbytes);
32 #if defined(PNG_INFO_IMAGE_SUPPORTED)
34 png_get_rows(png_structp png_ptr, png_infop info_ptr)
36 if (png_ptr != NULL && info_ptr != NULL)
37 return(info_ptr->row_pointers);
43 #ifdef PNG_EASY_ACCESS_SUPPORTED
44 /* easy access to info, added in libpng-0.99 */
46 png_get_image_width(png_structp png_ptr, png_infop info_ptr)
48 if (png_ptr != NULL && info_ptr != NULL)
50 return info_ptr->width;
56 png_get_image_height(png_structp png_ptr, png_infop info_ptr)
58 if (png_ptr != NULL && info_ptr != NULL)
60 return info_ptr->height;
66 png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
68 if (png_ptr != NULL && info_ptr != NULL)
70 return info_ptr->bit_depth;
76 png_get_color_type(png_structp png_ptr, png_infop info_ptr)
78 if (png_ptr != NULL && info_ptr != NULL)
80 return info_ptr->color_type;
86 png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
88 if (png_ptr != NULL && info_ptr != NULL)
90 return info_ptr->filter_type;
96 png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
98 if (png_ptr != NULL && info_ptr != NULL)
100 return info_ptr->interlace_type;
106 png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
108 if (png_ptr != NULL && info_ptr != NULL)
110 return info_ptr->compression_type;
116 png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
118 if (png_ptr != NULL && info_ptr != NULL)
119 #if defined(PNG_pHYs_SUPPORTED)
120 if (info_ptr->valid & PNG_INFO_pHYs)
122 png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
123 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
125 else return (info_ptr->x_pixels_per_unit);
134 png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
136 if (png_ptr != NULL && info_ptr != NULL)
137 #if defined(PNG_pHYs_SUPPORTED)
138 if (info_ptr->valid & PNG_INFO_pHYs)
140 png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
141 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
143 else return (info_ptr->y_pixels_per_unit);
152 png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
154 if (png_ptr != NULL && info_ptr != NULL)
155 #if defined(PNG_pHYs_SUPPORTED)
156 if (info_ptr->valid & PNG_INFO_pHYs)
158 png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
159 if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
160 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
162 else return (info_ptr->x_pixels_per_unit);
170 #ifdef PNG_FLOATING_POINT_SUPPORTED
172 png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
174 if (png_ptr != NULL && info_ptr != NULL)
175 #if defined(PNG_pHYs_SUPPORTED)
176 if (info_ptr->valid & PNG_INFO_pHYs)
178 png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
179 if (info_ptr->x_pixels_per_unit == 0)
182 return ((float)((float)info_ptr->y_pixels_per_unit
183 /(float)info_ptr->x_pixels_per_unit));
193 png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
195 if (png_ptr != NULL && info_ptr != NULL)
196 #if defined(PNG_oFFs_SUPPORTED)
197 if (info_ptr->valid & PNG_INFO_oFFs)
199 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
200 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
202 else return (info_ptr->x_offset);
211 png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
213 if (png_ptr != NULL && info_ptr != NULL)
214 #if defined(PNG_oFFs_SUPPORTED)
215 if (info_ptr->valid & PNG_INFO_oFFs)
217 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
218 if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
220 else return (info_ptr->y_offset);
229 png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
231 if (png_ptr != NULL && info_ptr != NULL)
232 #if defined(PNG_oFFs_SUPPORTED)
233 if (info_ptr->valid & PNG_INFO_oFFs)
235 png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
236 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
238 else return (info_ptr->x_offset);
247 png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
249 if (png_ptr != NULL && info_ptr != NULL)
250 #if defined(PNG_oFFs_SUPPORTED)
251 if (info_ptr->valid & PNG_INFO_oFFs)
253 png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
254 if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
256 else return (info_ptr->y_offset);
264 #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
266 png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
268 return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
273 png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
275 return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
280 png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
282 return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
287 png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
289 return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
294 png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
296 return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
300 #if defined(PNG_pHYs_SUPPORTED)
302 png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
303 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
305 png_uint_32 retval = 0;
307 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
309 png_debug1(1, "in %s retrieval function\n", "pHYs");
312 *res_x = info_ptr->x_pixels_per_unit;
313 retval |= PNG_INFO_pHYs;
317 *res_y = info_ptr->y_pixels_per_unit;
318 retval |= PNG_INFO_pHYs;
320 if (unit_type != NULL)
322 *unit_type = (int)info_ptr->phys_unit_type;
323 retval |= PNG_INFO_pHYs;
326 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
327 if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
333 #endif /* PNG_pHYs_SUPPORTED */
334 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
336 /* png_get_channels really belongs in here, too, but it's been around longer */
338 #endif /* PNG_EASY_ACCESS_SUPPORTED */
341 png_get_channels(png_structp png_ptr, png_infop info_ptr)
343 if (png_ptr != NULL && info_ptr != NULL)
344 return(info_ptr->channels);
350 png_get_signature(png_structp png_ptr, png_infop info_ptr)
352 if (png_ptr != NULL && info_ptr != NULL)
353 return(info_ptr->signature);
358 #if defined(PNG_bKGD_SUPPORTED)
360 png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
361 png_color_16p *background)
363 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
364 && background != NULL)
366 png_debug1(1, "in %s retrieval function\n", "bKGD");
367 *background = &(info_ptr->background);
368 return (PNG_INFO_bKGD);
374 #if defined(PNG_cHRM_SUPPORTED)
375 #ifdef PNG_FLOATING_POINT_SUPPORTED
377 png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
378 double *white_x, double *white_y, double *red_x, double *red_y,
379 double *green_x, double *green_y, double *blue_x, double *blue_y)
381 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
383 png_debug1(1, "in %s retrieval function\n", "cHRM");
385 *white_x = (double)info_ptr->x_white;
387 *white_y = (double)info_ptr->y_white;
389 *red_x = (double)info_ptr->x_red;
391 *red_y = (double)info_ptr->y_red;
393 *green_x = (double)info_ptr->x_green;
395 *green_y = (double)info_ptr->y_green;
397 *blue_x = (double)info_ptr->x_blue;
399 *blue_y = (double)info_ptr->y_blue;
400 return (PNG_INFO_cHRM);
405 #ifdef PNG_FIXED_POINT_SUPPORTED
407 png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
408 png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
409 png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
410 png_fixed_point *blue_x, png_fixed_point *blue_y)
412 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
414 png_debug1(1, "in %s retrieval function\n", "cHRM");
416 *white_x = info_ptr->int_x_white;
418 *white_y = info_ptr->int_y_white;
420 *red_x = info_ptr->int_x_red;
422 *red_y = info_ptr->int_y_red;
424 *green_x = info_ptr->int_x_green;
426 *green_y = info_ptr->int_y_green;
428 *blue_x = info_ptr->int_x_blue;
430 *blue_y = info_ptr->int_y_blue;
431 return (PNG_INFO_cHRM);
438 #if defined(PNG_gAMA_SUPPORTED)
439 #ifdef PNG_FLOATING_POINT_SUPPORTED
441 png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
443 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
444 && file_gamma != NULL)
446 png_debug1(1, "in %s retrieval function\n", "gAMA");
447 *file_gamma = (double)info_ptr->gamma;
448 return (PNG_INFO_gAMA);
453 #ifdef PNG_FIXED_POINT_SUPPORTED
455 png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
456 png_fixed_point *int_file_gamma)
458 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
459 && int_file_gamma != NULL)
461 png_debug1(1, "in %s retrieval function\n", "gAMA");
462 *int_file_gamma = info_ptr->int_gamma;
463 return (PNG_INFO_gAMA);
470 #if defined(PNG_sRGB_SUPPORTED)
472 png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
474 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
475 && file_srgb_intent != NULL)
477 png_debug1(1, "in %s retrieval function\n", "sRGB");
478 *file_srgb_intent = (int)info_ptr->srgb_intent;
479 return (PNG_INFO_sRGB);
485 #if defined(PNG_iCCP_SUPPORTED)
487 png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
488 png_charpp name, int *compression_type,
489 png_charpp profile, png_uint_32 *proflen)
491 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
492 && name != NULL && profile != NULL && proflen != NULL)
494 png_debug1(1, "in %s retrieval function\n", "iCCP");
495 *name = info_ptr->iccp_name;
496 *profile = info_ptr->iccp_profile;
497 /* compression_type is a dummy so the API won't have to change
498 if we introduce multiple compression types later. */
499 *proflen = (int)info_ptr->iccp_proflen;
500 *compression_type = (int)info_ptr->iccp_compression;
501 return (PNG_INFO_iCCP);
507 #if defined(PNG_sPLT_SUPPORTED)
509 png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
510 png_sPLT_tpp spalettes)
512 if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
513 *spalettes = info_ptr->splt_palettes;
514 return ((png_uint_32)info_ptr->splt_palettes_num);
518 #if defined(PNG_hIST_SUPPORTED)
520 png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
522 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
525 png_debug1(1, "in %s retrieval function\n", "hIST");
526 *hist = info_ptr->hist;
527 return (PNG_INFO_hIST);
534 png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
535 png_uint_32 *width, png_uint_32 *height, int *bit_depth,
536 int *color_type, int *interlace_type, int *compression_type,
540 if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
541 bit_depth != NULL && color_type != NULL)
543 int pixel_depth, channels;
544 png_uint_32 rowbytes_per_pixel;
546 png_debug1(1, "in %s retrieval function\n", "IHDR");
547 *width = info_ptr->width;
548 *height = info_ptr->height;
549 *bit_depth = info_ptr->bit_depth;
550 if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
551 png_error(png_ptr, "Invalid bit depth");
552 *color_type = info_ptr->color_type;
553 if (info_ptr->color_type > 6)
554 png_error(png_ptr, "Invalid color type");
555 if (compression_type != NULL)
556 *compression_type = info_ptr->compression_type;
557 if (filter_type != NULL)
558 *filter_type = info_ptr->filter_type;
559 if (interlace_type != NULL)
560 *interlace_type = info_ptr->interlace_type;
562 /* check for potential overflow of rowbytes */
563 if (*color_type == PNG_COLOR_TYPE_PALETTE)
565 else if (*color_type & PNG_COLOR_MASK_COLOR)
569 if (*color_type & PNG_COLOR_MASK_ALPHA)
571 pixel_depth = *bit_depth * channels;
572 rowbytes_per_pixel = (pixel_depth + 7) >> 3;
573 if (width == 0 || *width > PNG_MAX_UINT)
574 png_error(png_ptr, "Invalid image width");
575 if (height == 0 || *height > PNG_MAX_UINT)
576 png_error(png_ptr, "Invalid image height");
577 if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
580 "Width too large for libpng to process image data.");
587 #if defined(PNG_oFFs_SUPPORTED)
589 png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
590 png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
592 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
593 && offset_x != NULL && offset_y != NULL && unit_type != NULL)
595 png_debug1(1, "in %s retrieval function\n", "oFFs");
596 *offset_x = info_ptr->x_offset;
597 *offset_y = info_ptr->y_offset;
598 *unit_type = (int)info_ptr->offset_unit_type;
599 return (PNG_INFO_oFFs);
605 #if defined(PNG_pCAL_SUPPORTED)
607 png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
608 png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
609 png_charp *units, png_charpp *params)
611 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
612 && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
613 nparams != NULL && units != NULL && params != NULL)
615 png_debug1(1, "in %s retrieval function\n", "pCAL");
616 *purpose = info_ptr->pcal_purpose;
617 *X0 = info_ptr->pcal_X0;
618 *X1 = info_ptr->pcal_X1;
619 *type = (int)info_ptr->pcal_type;
620 *nparams = (int)info_ptr->pcal_nparams;
621 *units = info_ptr->pcal_units;
622 *params = info_ptr->pcal_params;
623 return (PNG_INFO_pCAL);
629 #if defined(PNG_sCAL_SUPPORTED)
630 #ifdef PNG_FLOATING_POINT_SUPPORTED
632 png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
633 int *unit, double *width, double *height)
635 if (png_ptr != NULL && info_ptr != NULL &&
636 (info_ptr->valid & PNG_INFO_sCAL))
638 *unit = info_ptr->scal_unit;
639 *width = info_ptr->scal_pixel_width;
640 *height = info_ptr->scal_pixel_height;
641 return (PNG_INFO_sCAL);
646 #ifdef PNG_FIXED_POINT_SUPPORTED
648 png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
649 int *unit, png_charpp width, png_charpp height)
651 if (png_ptr != NULL && info_ptr != NULL &&
652 (info_ptr->valid & PNG_INFO_sCAL))
654 *unit = info_ptr->scal_unit;
655 *width = info_ptr->scal_s_width;
656 *height = info_ptr->scal_s_height;
657 return (PNG_INFO_sCAL);
665 #if defined(PNG_pHYs_SUPPORTED)
667 png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
668 png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
670 png_uint_32 retval = 0;
672 if (png_ptr != NULL && info_ptr != NULL &&
673 (info_ptr->valid & PNG_INFO_pHYs))
675 png_debug1(1, "in %s retrieval function\n", "pHYs");
678 *res_x = info_ptr->x_pixels_per_unit;
679 retval |= PNG_INFO_pHYs;
683 *res_y = info_ptr->y_pixels_per_unit;
684 retval |= PNG_INFO_pHYs;
686 if (unit_type != NULL)
688 *unit_type = (int)info_ptr->phys_unit_type;
689 retval |= PNG_INFO_pHYs;
697 png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
700 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
703 png_debug1(1, "in %s retrieval function\n", "PLTE");
704 *palette = info_ptr->palette;
705 *num_palette = info_ptr->num_palette;
706 png_debug1(3, "num_palette = %d\n", *num_palette);
707 return (PNG_INFO_PLTE);
712 #if defined(PNG_sBIT_SUPPORTED)
714 png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
716 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
719 png_debug1(1, "in %s retrieval function\n", "sBIT");
720 *sig_bit = &(info_ptr->sig_bit);
721 return (PNG_INFO_sBIT);
727 #if defined(PNG_TEXT_SUPPORTED)
729 png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
732 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
734 png_debug1(1, "in %s retrieval function\n",
735 (png_ptr->chunk_name[0] == '\0' ? "text"
736 : (png_const_charp)png_ptr->chunk_name));
737 if (text_ptr != NULL)
738 *text_ptr = info_ptr->text;
739 if (num_text != NULL)
740 *num_text = info_ptr->num_text;
741 return ((png_uint_32)info_ptr->num_text);
743 if (num_text != NULL)
749 #if defined(PNG_tIME_SUPPORTED)
751 png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
753 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
756 png_debug1(1, "in %s retrieval function\n", "tIME");
757 *mod_time = &(info_ptr->mod_time);
758 return (PNG_INFO_tIME);
764 #if defined(PNG_tRNS_SUPPORTED)
766 png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
767 png_bytep *trans, int *num_trans, png_color_16p *trans_values)
769 png_uint_32 retval = 0;
770 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
772 png_debug1(1, "in %s retrieval function\n", "tRNS");
773 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
777 *trans = info_ptr->trans;
778 retval |= PNG_INFO_tRNS;
780 if (trans_values != NULL)
781 *trans_values = &(info_ptr->trans_values);
783 else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
785 if (trans_values != NULL)
787 *trans_values = &(info_ptr->trans_values);
788 retval |= PNG_INFO_tRNS;
793 if(num_trans != NULL)
795 *num_trans = info_ptr->num_trans;
796 retval |= PNG_INFO_tRNS;
803 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
805 png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
806 png_unknown_chunkpp unknowns)
808 if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
809 *unknowns = info_ptr->unknown_chunks;
810 return ((png_uint_32)info_ptr->unknown_chunks_num);
814 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
816 png_get_rgb_to_gray_status (png_structp png_ptr)
818 return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
822 #if defined(PNG_USER_CHUNKS_SUPPORTED)
824 png_get_user_chunk_ptr(png_structp png_ptr)
826 return (png_ptr? png_ptr->user_chunk_ptr : NULL);
832 png_get_compression_buffer_size(png_structp png_ptr)
834 return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
839 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
840 /* this function was added to libpng 1.2.0 and should exist by default */
842 png_get_asm_flags (png_structp png_ptr)
844 return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
847 /* this function was added to libpng 1.2.0 and should exist by default */
849 png_get_asm_flagmask (int flag_select)
851 png_uint_32 settable_asm_flags = 0;
853 if (flag_select & PNG_SELECT_READ)
854 settable_asm_flags |=
855 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
856 PNG_ASM_FLAG_MMX_READ_INTERLACE |
857 PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
858 PNG_ASM_FLAG_MMX_READ_FILTER_UP |
859 PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
860 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
861 /* no non-MMX flags yet */
864 /* GRR: no write-flags yet, either, but someday... */
865 if (flag_select & PNG_SELECT_WRITE)
866 settable_asm_flags |=
867 PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
870 return settable_asm_flags; /* _theoretically_ settable capabilities only */
872 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
875 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
876 /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
877 /* this function was added to libpng 1.2.0 */
879 png_get_mmx_flagmask (int flag_select, int *compilerID)
881 png_uint_32 settable_mmx_flags = 0;
883 if (flag_select & PNG_SELECT_READ)
884 settable_mmx_flags |=
885 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
886 PNG_ASM_FLAG_MMX_READ_INTERLACE |
887 PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
888 PNG_ASM_FLAG_MMX_READ_FILTER_UP |
889 PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
890 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
892 /* GRR: no MMX write support yet, but someday... */
893 if (flag_select & PNG_SELECT_WRITE)
894 settable_mmx_flags |=
895 PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
898 if (compilerID != NULL) {
899 #ifdef PNG_USE_PNGVCRD
900 *compilerID = 1; /* MSVC */
902 #ifdef PNG_USE_PNGGCCRD
903 *compilerID = 2; /* gcc/gas */
905 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
910 return settable_mmx_flags; /* _theoretically_ settable capabilities only */
913 /* this function was added to libpng 1.2.0 */
915 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
917 return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
920 /* this function was added to libpng 1.2.0 */
922 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
924 return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
926 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
927 #endif /* PNG_1_0_X */