TRAVIS_OS_NAME=linux TRAVIS_PYTHON_VERSION=3.9-dev <<<<<< ENV .appveyor.yml .ci/after_success.sh .ci/build.sh .ci/install.sh .ci/test.sh .coveragerc .editorconfig .gitattributes .github/CONTRIBUTING.md .github/FUNDING.yml .github/ISSUE_TEMPLATE/ISSUE_REPORT.md .github/PULL_REQUEST_TEMPLATE.md .github/SECURITY.md .github/mergify.yml .github/workflows/lint.yml .github/workflows/macos-install.sh .github/workflows/system-info.py .github/workflows/test-docker.yml .github/workflows/test-windows.yml .github/workflows/test.yml .gitignore .pre-commit-config.yaml .readthedocs.yml .travis.yml CHANGES.rst LICENSE MANIFEST.in Makefile README.md RELEASING.md Tests/32bit_segfault_check.py Tests/README.rst Tests/__init__.py Tests/bench_cffi_access.py Tests/check_fli_oob.py Tests/check_fli_overflow.py Tests/check_icns_dos.py Tests/check_imaging_leaks.py Tests/check_j2k_dos.py Tests/check_j2k_leaks.py Tests/check_j2k_overflow.py Tests/check_jp2_overflow.py Tests/check_jpeg_leaks.py Tests/check_large_memory.py Tests/check_large_memory_numpy.py Tests/check_libtiff_segfault.py Tests/check_png_dos.py Tests/conftest.py Tests/createfontdatachunk.py Tests/fonts/10x20-ISO8859-1.pcf Tests/fonts/10x20.pbm Tests/fonts/10x20.pil Tests/fonts/AdobeVFPrototype.ttf Tests/fonts/ArefRuqaa-Regular.ttf Tests/fonts/BungeeColor-Regular_colr_Windows.ttf Tests/fonts/DejaVuSans-24-1-stripped.ttf Tests/fonts/DejaVuSans-24-2-stripped.ttf Tests/fonts/DejaVuSans-24-4-stripped.ttf Tests/fonts/DejaVuSans-24-8-stripped.ttf Tests/fonts/DejaVuSans.ttf Tests/fonts/FreeMono.ttf Tests/fonts/KhmerOSBattambang-Regular.ttf Tests/fonts/LICENSE.txt Tests/fonts/NotoColorEmoji.ttf Tests/fonts/NotoNastaliqUrdu-Regular.ttf Tests/fonts/NotoSans-Regular.ttf Tests/fonts/NotoSansJP-Regular.otf Tests/fonts/NotoSansSymbols-Regular.ttf Tests/fonts/OpenSansCondensed-LightItalic.ttf Tests/fonts/TINY5x3GX.ttf Tests/fonts/ter-x20b-cp1250.pbm Tests/fonts/ter-x20b-cp1250.pil Tests/fonts/ter-x20b-iso8859-1.pbm Tests/fonts/ter-x20b-iso8859-1.pil Tests/fonts/ter-x20b-iso8859-2.pbm Tests/fonts/ter-x20b-iso8859-2.pil Tests/fonts/ter-x20b.pcf Tests/helper.py Tests/icc/LICENSE.txt Tests/icc/sRGB_IEC61966-2-1_black_scaled.icc Tests/icc/sRGB_v4_ICC_preference.icc Tests/images/00r0_gray_l.jp2 Tests/images/00r1_graya_la.jp2 Tests/images/01r_00.pcx Tests/images/10ct_32bit_128.tiff Tests/images/12bit.cropped.tif Tests/images/12in16bit.tif Tests/images/16_bit_binary.pgm Tests/images/16_bit_binary_pgm.png Tests/images/16_bit_noise.tif Tests/images/16bit.MM.cropped.tif Tests/images/16bit.MM.deflate.tif Tests/images/16bit.cropped.j2k Tests/images/16bit.cropped.jp2 Tests/images/16bit.cropped.tif Tests/images/16bit.deflate.tif Tests/images/16bit.s.tif Tests/images/1_trns.png Tests/images/7x13.png Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.dds Tests/images/DXGI_FORMAT_BC7_UNORM_SRGB.png Tests/images/DXGI_FORMAT_R8G8B8A8_UNORM_SRGB.dds Tests/images/DXGI_FORMAT_R8G8B8A8_UNORM_SRGB.png Tests/images/WAlaska.wind.7days.grb Tests/images/a.fli Tests/images/a_fli.png Tests/images/anim_frame1.webp Tests/images/anim_frame2.webp Tests/images/apng/blend_op_over.png Tests/images/apng/blend_op_over_near_transparent.png Tests/images/apng/blend_op_source_near_transparent.png Tests/images/apng/blend_op_source_solid.png Tests/images/apng/blend_op_source_transparent.png Tests/images/apng/chunk_actl_after_idat.png Tests/images/apng/chunk_multi_actl.png Tests/images/apng/chunk_no_actl.png Tests/images/apng/chunk_no_fctl.png Tests/images/apng/chunk_no_fdat.png Tests/images/apng/chunk_repeat_fctl.png Tests/images/apng/delay.png Tests/images/apng/delay_round.png Tests/images/apng/delay_short_max.png Tests/images/apng/delay_zero_denom.png Tests/images/apng/delay_zero_numer.png Tests/images/apng/dispose_op_background.png Tests/images/apng/dispose_op_background_before_region.png Tests/images/apng/dispose_op_background_final.png Tests/images/apng/dispose_op_background_p_mode.png Tests/images/apng/dispose_op_background_region.png Tests/images/apng/dispose_op_none.png Tests/images/apng/dispose_op_none_region.png Tests/images/apng/dispose_op_previous.png Tests/images/apng/dispose_op_previous_final.png Tests/images/apng/dispose_op_previous_first.png Tests/images/apng/dispose_op_previous_region.png Tests/images/apng/fctl_actl.png Tests/images/apng/mode_16bit.png Tests/images/apng/mode_greyscale.png Tests/images/apng/mode_greyscale_alpha.png Tests/images/apng/mode_palette.png Tests/images/apng/mode_palette_1bit_alpha.png Tests/images/apng/mode_palette_alpha.png Tests/images/apng/num_plays.png Tests/images/apng/num_plays_1.png Tests/images/apng/sequence_fdat_fctl.png Tests/images/apng/sequence_gap.png Tests/images/apng/sequence_reorder.png Tests/images/apng/sequence_reorder_chunk.png Tests/images/apng/sequence_repeat.png Tests/images/apng/sequence_repeat_chunk.png Tests/images/apng/sequence_start.png Tests/images/apng/single_frame.png Tests/images/apng/single_frame_default.png Tests/images/apng/split_fdat.png Tests/images/apng/split_fdat_zero_chunk.png Tests/images/apng/syntax_num_frames_high.png Tests/images/apng/syntax_num_frames_invalid.png Tests/images/apng/syntax_num_frames_low.png Tests/images/apng/syntax_num_frames_zero.png Tests/images/apng/syntax_num_frames_zero_default.png Tests/images/app13-multiple.jpg Tests/images/app13.jpg Tests/images/argb-32bpp_MipMaps-1.dds Tests/images/argb-32bpp_MipMaps-1.png Tests/images/bad_palette_entry.gpl Tests/images/bad_palette_file.gpl Tests/images/balloon.jpf Tests/images/bc7-argb-8bpp_MipMaps-1.dds Tests/images/bc7-argb-8bpp_MipMaps-1.png Tests/images/binary_preview_map.eps Tests/images/bitmap_font_1_basic.png Tests/images/bitmap_font_1_raqm.png Tests/images/bitmap_font_2_basic.png Tests/images/bitmap_font_2_raqm.png Tests/images/bitmap_font_4_basic.png Tests/images/bitmap_font_4_raqm.png Tests/images/bitmap_font_8_basic.png Tests/images/bitmap_font_8_raqm.png Tests/images/blp/blp1_jpeg.blp Tests/images/blp/blp2_dxt1.blp Tests/images/blp/blp2_dxt1.png Tests/images/blp/blp2_dxt1a.blp Tests/images/blp/blp2_dxt1a.png Tests/images/blp/blp2_raw.blp Tests/images/blp/blp2_raw.png Tests/images/bmp/README.txt Tests/images/bmp/b/badbitcount.bmp Tests/images/bmp/b/badbitssize.bmp Tests/images/bmp/b/baddens1.bmp Tests/images/bmp/b/baddens2.bmp Tests/images/bmp/b/badfilesize.bmp Tests/images/bmp/b/badheadersize.bmp Tests/images/bmp/b/badpalettesize.bmp Tests/images/bmp/b/badplanes.bmp Tests/images/bmp/b/badrle.bmp Tests/images/bmp/b/badwidth.bmp Tests/images/bmp/b/pal8badindex.bmp Tests/images/bmp/b/reallybig.bmp Tests/images/bmp/b/rletopdown.bmp Tests/images/bmp/b/shortfile.bmp Tests/images/bmp/g/pal1.bmp Tests/images/bmp/g/pal1bg.bmp Tests/images/bmp/g/pal1wb.bmp Tests/images/bmp/g/pal4.bmp Tests/images/bmp/g/pal4rle.bmp Tests/images/bmp/g/pal8-0.bmp Tests/images/bmp/g/pal8.bmp Tests/images/bmp/g/pal8nonsquare.bmp Tests/images/bmp/g/pal8os2.bmp Tests/images/bmp/g/pal8rle.bmp Tests/images/bmp/g/pal8topdown.bmp Tests/images/bmp/g/pal8v4.bmp Tests/images/bmp/g/pal8v5.bmp Tests/images/bmp/g/pal8w124.bmp Tests/images/bmp/g/pal8w125.bmp Tests/images/bmp/g/pal8w126.bmp Tests/images/bmp/g/rgb16-565.bmp Tests/images/bmp/g/rgb16-565pal.bmp Tests/images/bmp/g/rgb16.bmp Tests/images/bmp/g/rgb24.bmp Tests/images/bmp/g/rgb24pal.bmp Tests/images/bmp/g/rgb32.bmp Tests/images/bmp/g/rgb32bf.bmp Tests/images/bmp/html/bkgd.png Tests/images/bmp/html/bmpsuite.html Tests/images/bmp/html/fakealpha.png Tests/images/bmp/html/pal1.png Tests/images/bmp/html/pal1bg.png Tests/images/bmp/html/pal1p1.png Tests/images/bmp/html/pal2.png Tests/images/bmp/html/pal4.png Tests/images/bmp/html/pal4rletrns-0.png Tests/images/bmp/html/pal4rletrns-b.png Tests/images/bmp/html/pal4rletrns.png Tests/images/bmp/html/pal8.png Tests/images/bmp/html/pal8nonsquare-e.png Tests/images/bmp/html/pal8nonsquare-v.png Tests/images/bmp/html/pal8rletrns-0.png Tests/images/bmp/html/pal8rletrns-b.png Tests/images/bmp/html/pal8rletrns.png Tests/images/bmp/html/pal8w124.png Tests/images/bmp/html/pal8w125.png Tests/images/bmp/html/pal8w126.png Tests/images/bmp/html/rgb16-231.png Tests/images/bmp/html/rgb16-565.png Tests/images/bmp/html/rgb16.png Tests/images/bmp/html/rgb24.jpg Tests/images/bmp/html/rgb24.png Tests/images/bmp/html/rgba16-4444.png Tests/images/bmp/html/rgba32.png Tests/images/bmp/q/pal1p1.bmp Tests/images/bmp/q/pal2.bmp Tests/images/bmp/q/pal4rletrns.bmp Tests/images/bmp/q/pal8offs.bmp Tests/images/bmp/q/pal8os2sp.bmp Tests/images/bmp/q/pal8os2v2-16.bmp Tests/images/bmp/q/pal8os2v2.bmp Tests/images/bmp/q/pal8oversizepal.bmp Tests/images/bmp/q/pal8rletrns.bmp Tests/images/bmp/q/rgb16-231.bmp Tests/images/bmp/q/rgb24jpeg.bmp Tests/images/bmp/q/rgb24largepal.bmp Tests/images/bmp/q/rgb24lprof.bmp Tests/images/bmp/q/rgb24png.bmp Tests/images/bmp/q/rgb24prof.bmp Tests/images/bmp/q/rgb32-111110.bmp Tests/images/bmp/q/rgb32bf-xbgr.bmp Tests/images/bmp/q/rgb32fakealpha.bmp Tests/images/bmp/q/rgba16-4444.bmp Tests/images/bmp/q/rgba32.bmp Tests/images/bmp/q/rgba32abf.bmp Tests/images/broken.png Tests/images/broken_data_stream.png Tests/images/bw_gradient.png Tests/images/caption_6_33_22.png Tests/images/cbdt_notocoloremoji.png Tests/images/cbdt_notocoloremoji_mask.png Tests/images/chi.gif Tests/images/clipboard.dib Tests/images/clipboard_target.png Tests/images/cmx3g8_wv_1998.260_0745_mcidas.ara Tests/images/cmx3g8_wv_1998.260_0745_mcidas.png Tests/images/color_snakes.png Tests/images/colr_bungee.png Tests/images/colr_bungee_mask.png Tests/images/combined_larger_than_size.psd Tests/images/compression.tif Tests/images/copyleft.png Tests/images/copyleft.tiff Tests/images/corner.lut Tests/images/courB08.bdf Tests/images/courB08.pbm Tests/images/courB08.pil Tests/images/create_eps.gnuplot Tests/images/custom_gimp_palette.gpl Tests/images/decompression_bomb.gif Tests/images/decompression_bomb.ico Tests/images/deerstalker.cur Tests/images/default_font.png Tests/images/dilation4.lut Tests/images/dilation8.lut Tests/images/dispose_bgnd.gif Tests/images/dispose_none.gif Tests/images/dispose_prev.gif Tests/images/drawing.emf Tests/images/drawing.wmf Tests/images/drawing_emf_ref.png Tests/images/drawing_roundDown.emf Tests/images/drawing_wmf_ref.png Tests/images/drawing_wmf_ref_144.png Tests/images/dummy.container Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.dds Tests/images/dxt1-rgb-4bbp-noalpha_MipMaps-1.png Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.dds Tests/images/dxt3-argb-8bbp-explicitalpha_MipMaps-1.png Tests/images/dxt5-argb-8bbp-interpolatedalpha_MipMaps-1.dds Tests/images/dxt5-argb-8bbp-interpolatedalpha_MipMaps-1.png Tests/images/edge.lut Tests/images/effect_mandelbrot.png Tests/images/effect_spread.png Tests/images/empty_gps_ifd.jpg Tests/images/erosion4.lut Tests/images/erosion8.lut Tests/images/exif-200dpcm.jpg Tests/images/exif-72dpi-int.jpg Tests/images/exif-dpi-zerodivision.jpg Tests/images/exif-ifd-offset.jpg Tests/images/exif.png Tests/images/exif_gps.jpg Tests/images/exif_gps_typeerror.jpg Tests/images/exif_imagemagick.png Tests/images/exif_text.png Tests/images/exif_typeerror.jpg Tests/images/fli_oob/02r/02r00.fli Tests/images/fli_oob/02r/notes Tests/images/fli_oob/02r/others/02r01.fli Tests/images/fli_oob/02r/others/02r02.fli Tests/images/fli_oob/02r/others/02r03.fli Tests/images/fli_oob/02r/others/02r04.fli Tests/images/fli_oob/02r/reproducing Tests/images/fli_oob/03r/03r00.fli Tests/images/fli_oob/03r/notes Tests/images/fli_oob/03r/others/03r01.fli Tests/images/fli_oob/03r/others/03r02.fli Tests/images/fli_oob/03r/others/03r03.fli Tests/images/fli_oob/03r/others/03r04.fli Tests/images/fli_oob/03r/others/03r05.fli Tests/images/fli_oob/03r/others/03r06.fli Tests/images/fli_oob/03r/others/03r07.fli Tests/images/fli_oob/03r/others/03r08.fli Tests/images/fli_oob/03r/others/03r09.fli Tests/images/fli_oob/03r/others/03r10.fli Tests/images/fli_oob/03r/others/03r11.fli Tests/images/fli_oob/03r/reproducing Tests/images/fli_oob/04r/04r00.fli Tests/images/fli_oob/04r/initial.fli Tests/images/fli_oob/04r/notes Tests/images/fli_oob/04r/others/04r01.fli Tests/images/fli_oob/04r/others/04r02.fli Tests/images/fli_oob/04r/others/04r03.fli Tests/images/fli_oob/04r/others/04r04.fli Tests/images/fli_oob/04r/others/04r05.fli Tests/images/fli_oob/04r/reproducing Tests/images/fli_oob/05r/05r00.fli Tests/images/fli_oob/05r/notes Tests/images/fli_oob/05r/others/05r01.fli Tests/images/fli_oob/05r/others/05r02.fli Tests/images/fli_oob/05r/others/05r03.fli Tests/images/fli_oob/05r/others/05r04.fli Tests/images/fli_oob/05r/others/05r05.fli Tests/images/fli_oob/05r/others/05r06.fli Tests/images/fli_oob/05r/others/05r07.fli Tests/images/fli_oob/05r/reproducing Tests/images/fli_oob/06r/06r00.fli Tests/images/fli_oob/06r/notes Tests/images/fli_oob/06r/others/06r01.fli Tests/images/fli_oob/06r/others/06r02.fli Tests/images/fli_oob/06r/others/06r03.fli Tests/images/fli_oob/06r/others/06r04.fli Tests/images/fli_oob/06r/reproducing Tests/images/fli_oob/patch0/000000 Tests/images/fli_oob/patch0/000001 Tests/images/fli_oob/patch0/000002 Tests/images/fli_oob/patch0/000003 Tests/images/fli_overflow.fli Tests/images/fli_overrun.bin Tests/images/fli_overrun2.bin Tests/images/flower.jpg Tests/images/flower.webp Tests/images/flower2.jpg Tests/images/flower2.webp Tests/images/frozenpond.mpo Tests/images/ftex_dxt1.ftc Tests/images/ftex_dxt1.png Tests/images/ftex_uncompressed.ftu Tests/images/ftex_uncompressed.png Tests/images/fujifilm.mpo Tests/images/g4-fillorder-test.png Tests/images/g4-fillorder-test.tif Tests/images/g4-multi.tiff Tests/images/g4_orientation_1.tif Tests/images/g4_orientation_2.tif Tests/images/g4_orientation_3.tif Tests/images/g4_orientation_4.tif Tests/images/g4_orientation_5.tif Tests/images/g4_orientation_6.tif Tests/images/g4_orientation_7.tif Tests/images/g4_orientation_8.tif Tests/images/gbr.gbr Tests/images/gbr.png Tests/images/gfs.t06z.rassda.tm00.bufr_d Tests/images/gif_header_data.pkl Tests/images/gimp_gradient.ggr Tests/images/gimp_gradient_with_name.ggr Tests/images/hdf5.h5 Tests/images/high_ascii_chars.png Tests/images/hopper-XYZ.png Tests/images/hopper.Lab.tif Tests/images/hopper.bmp Tests/images/hopper.bw Tests/images/hopper.dcx Tests/images/hopper.fits Tests/images/hopper.fli Tests/images/hopper.gd Tests/images/hopper.gif Tests/images/hopper.iccprofile.tif Tests/images/hopper.iccprofile_binary.tif Tests/images/hopper.ico Tests/images/hopper.im Tests/images/hopper.jpg Tests/images/hopper.mic Tests/images/hopper.msp Tests/images/hopper.p7 Tests/images/hopper.pcd Tests/images/hopper.png Tests/images/hopper.pnm Tests/images/hopper.ppm Tests/images/hopper.psd Tests/images/hopper.pxr Tests/images/hopper.ras Tests/images/hopper.rgb Tests/images/hopper.sgi Tests/images/hopper.spider Tests/images/hopper.tar Tests/images/hopper.tif Tests/images/hopper.wal Tests/images/hopper.webp Tests/images/hopper.xbm Tests/images/hopper.xpm Tests/images/hopper16.rgb Tests/images/hopper_16bit_qtables.jpg Tests/images/hopper_256x256.ico Tests/images/hopper_45.png Tests/images/hopper_bad.p7 Tests/images/hopper_bad_checksum.msp Tests/images/hopper_bad_exif.jpg Tests/images/hopper_bw_500.png Tests/images/hopper_draw.ico Tests/images/hopper_emboss.bmp Tests/images/hopper_emboss_more.bmp Tests/images/hopper_g4.tif Tests/images/hopper_g4_500.tif Tests/images/hopper_gray.jpg Tests/images/hopper_gray_4bpp.tif Tests/images/hopper_idat_after_image_end.png Tests/images/hopper_jpg.tif Tests/images/hopper_long_name.im Tests/images/hopper_lzw.tif Tests/images/hopper_merged.psd Tests/images/hopper_orientation_2.jpg Tests/images/hopper_orientation_2.webp Tests/images/hopper_orientation_3.jpg Tests/images/hopper_orientation_3.webp Tests/images/hopper_orientation_4.jpg Tests/images/hopper_orientation_4.webp Tests/images/hopper_orientation_5.jpg Tests/images/hopper_orientation_5.webp Tests/images/hopper_orientation_6.jpg Tests/images/hopper_orientation_6.webp Tests/images/hopper_orientation_7.jpg Tests/images/hopper_orientation_7.webp Tests/images/hopper_orientation_8.jpg Tests/images/hopper_orientation_8.webp Tests/images/hopper_roundDown.bmp Tests/images/hopper_roundDown_2.tif Tests/images/hopper_roundDown_3.tif Tests/images/hopper_roundDown_None.tif Tests/images/hopper_roundUp_2.tif Tests/images/hopper_roundUp_3.tif Tests/images/hopper_roundUp_None.tif Tests/images/hopper_underscore.xbm Tests/images/hopper_unexpected.ico Tests/images/hopper_unknown_pixel_mode.tif Tests/images/hopper_webp_bits.ppm Tests/images/hopper_webp_write.ppm Tests/images/hopper_zero_comment_subblocks.gif Tests/images/i_trns.png Tests/images/icc-after-SOF.jpg Tests/images/icc_profile.png Tests/images/icc_profile_big.jpg Tests/images/icc_profile_none.png Tests/images/ifd_tag_type.tiff Tests/images/illu10_no_preview.eps Tests/images/illu10_preview.eps Tests/images/illuCS6_no_preview.eps Tests/images/illuCS6_preview.eps Tests/images/imagedraw/line_horizontal_slope1px_w2px.png Tests/images/imagedraw/line_horizontal_w101px.png Tests/images/imagedraw/line_horizontal_w2px_inverted.png Tests/images/imagedraw/line_horizontal_w2px_normal.png Tests/images/imagedraw/line_horizontal_w3px.png Tests/images/imagedraw/line_oblique_45_w3px_a.png Tests/images/imagedraw/line_oblique_45_w3px_b.png Tests/images/imagedraw/line_vertical_slope1px_w2px.png Tests/images/imagedraw/line_vertical_w101px.png Tests/images/imagedraw/line_vertical_w2px_inverted.png Tests/images/imagedraw/line_vertical_w2px_normal.png Tests/images/imagedraw/line_vertical_w3px.png Tests/images/imagedraw/square.png Tests/images/imagedraw/triangle_right.png Tests/images/imagedraw2_text.png Tests/images/imagedraw_arc.png Tests/images/imagedraw_arc_end_le_start.png Tests/images/imagedraw_arc_high.png Tests/images/imagedraw_arc_no_loops.png Tests/images/imagedraw_arc_width.png Tests/images/imagedraw_arc_width_fill.png Tests/images/imagedraw_arc_width_non_whole_angle.png Tests/images/imagedraw_arc_width_pieslice.png Tests/images/imagedraw_big_rectangle.png Tests/images/imagedraw_bitmap.png Tests/images/imagedraw_chord_L.png Tests/images/imagedraw_chord_RGB.png Tests/images/imagedraw_chord_too_fat.png Tests/images/imagedraw_chord_width.png Tests/images/imagedraw_chord_width_fill.png Tests/images/imagedraw_chord_zero_width.png Tests/images/imagedraw_ellipse_L.png Tests/images/imagedraw_ellipse_RGB.png Tests/images/imagedraw_ellipse_edge.png Tests/images/imagedraw_ellipse_translucent.png Tests/images/imagedraw_ellipse_various_sizes.png Tests/images/imagedraw_ellipse_various_sizes_filled.png Tests/images/imagedraw_ellipse_width.png Tests/images/imagedraw_ellipse_width_fill.png Tests/images/imagedraw_ellipse_width_large.png Tests/images/imagedraw_ellipse_zero_width.png Tests/images/imagedraw_floodfill2.png Tests/images/imagedraw_floodfill_L.png Tests/images/imagedraw_floodfill_RGB.png Tests/images/imagedraw_floodfill_RGBA.png Tests/images/imagedraw_floodfill_not_negative.png Tests/images/imagedraw_line.png Tests/images/imagedraw_line_joint_curve.png Tests/images/imagedraw_outline_chord_L.png Tests/images/imagedraw_outline_chord_RGB.png Tests/images/imagedraw_outline_ellipse_L.png Tests/images/imagedraw_outline_ellipse_RGB.png Tests/images/imagedraw_outline_pieslice_L.png Tests/images/imagedraw_outline_pieslice_RGB.png Tests/images/imagedraw_outline_polygon_L.png Tests/images/imagedraw_outline_polygon_RGB.png Tests/images/imagedraw_outline_rectangle_L.png Tests/images/imagedraw_outline_rectangle_RGB.png Tests/images/imagedraw_outline_shape_L.png Tests/images/imagedraw_outline_shape_RGB.png Tests/images/imagedraw_pieslice.png Tests/images/imagedraw_pieslice_wide.png Tests/images/imagedraw_pieslice_width.png Tests/images/imagedraw_pieslice_width_fill.png Tests/images/imagedraw_pieslice_zero_width.png Tests/images/imagedraw_point.png Tests/images/imagedraw_polygon.png Tests/images/imagedraw_polygon_1px_high.png Tests/images/imagedraw_polygon_kite_L.png Tests/images/imagedraw_polygon_kite_RGB.png Tests/images/imagedraw_rectangle.png Tests/images/imagedraw_rectangle_I.png Tests/images/imagedraw_rectangle_width.png Tests/images/imagedraw_rectangle_width_fill.png Tests/images/imagedraw_rectangle_zero_width.png Tests/images/imagedraw_regular_octagon.png Tests/images/imagedraw_shape1.png Tests/images/imagedraw_shape2.png Tests/images/imagedraw_square.png Tests/images/imagedraw_square_rotate_45.png Tests/images/imagedraw_stroke_descender.png Tests/images/imagedraw_stroke_different.png Tests/images/imagedraw_stroke_multiline.png Tests/images/imagedraw_stroke_same.png Tests/images/imagedraw_wide_line_dot.png Tests/images/imagedraw_wide_line_larger_than_int.png Tests/images/imageops_pad_h_0.jpg Tests/images/imageops_pad_h_1.jpg Tests/images/imageops_pad_h_2.jpg Tests/images/imageops_pad_v_0.jpg Tests/images/imageops_pad_v_1.jpg Tests/images/imageops_pad_v_2.jpg Tests/images/input_bw_five_bands.fpx Tests/images/invalid-exif-without-x-resolution.jpg Tests/images/invalid-exif.jpg Tests/images/invalid.spider Tests/images/iptc.jpg Tests/images/iptc_roundDown.jpg Tests/images/iptc_roundUp.jpg Tests/images/iss634.apng Tests/images/iss634.gif Tests/images/iss634.webp Tests/images/issue_2278.tif Tests/images/issue_2811.gif Tests/images/itxt_chunks.png Tests/images/jpeg_ff00_header.jpg Tests/images/junk_jpeg_header.jpg Tests/images/l2rgb_read.bmp Tests/images/l_trns.png Tests/images/la.tga Tests/images/lab-green.tif Tests/images/lab-red.tif Tests/images/lab.tif Tests/images/libtiff_segfault.tif Tests/images/linear_gradient.png Tests/images/morph_a.png Tests/images/multiline_text.png Tests/images/multiline_text_center.png Tests/images/multiline_text_right.png Tests/images/multiline_text_spacing.png Tests/images/multipage-lastframe.tif Tests/images/multipage-mmap.tiff Tests/images/multipage.tiff Tests/images/negative_size.ppm Tests/images/no-dpi-in-exif.jpg Tests/images/no_cursors.cur Tests/images/no_rows_per_strip.tif Tests/images/non_zero_bb.eps Tests/images/non_zero_bb.png Tests/images/non_zero_bb_scale2.png Tests/images/old-style-jpeg-compression.png Tests/images/old-style-jpeg-compression.tif Tests/images/p_trns_single.png Tests/images/pcx_overrun.bin Tests/images/pcx_overrun2.bin Tests/images/photoshop-200dpi-broken.jpg Tests/images/photoshop-200dpi.jpg Tests/images/pil123p.png Tests/images/pil123rgba.png Tests/images/pil136.png Tests/images/pil136.tiff Tests/images/pil168.png Tests/images/pil168.tif Tests/images/pil184.pcx Tests/images/pil_sample_cmyk.eps Tests/images/pil_sample_cmyk.jpg Tests/images/pil_sample_rgb.jpg Tests/images/pillow.icns Tests/images/pillow.ico Tests/images/pillow2.icns Tests/images/pillow3.icns Tests/images/png_decompression_dos.png Tests/images/pngtest_bad.png.bin Tests/images/pport_g4.tif Tests/images/python.ico Tests/images/radial_gradient.png Tests/images/radial_gradients.png Tests/images/raw_negative_stride.bin Tests/images/rdf.tif Tests/images/rectangle_surrounding_text.png Tests/images/reqd_showpage.eps Tests/images/reqd_showpage.png Tests/images/rgb.jpg Tests/images/rgb32bf-rgba.bmp Tests/images/rgb32rle.tga Tests/images/rgb_trns.png Tests/images/rgb_trns_ycbc.j2k Tests/images/rgb_trns_ycbc.jp2 Tests/images/rotate_45_no_fill.png Tests/images/rotate_45_with_fill.png Tests/images/sgi_crash.bin Tests/images/sgi_overrun.bin Tests/images/sgi_overrun_expandrow.bin Tests/images/sgi_overrun_expandrow2.bin Tests/images/sgi_overrun_expandrowF04.bin Tests/images/standard_embedded.png Tests/images/sugarshack.mpo Tests/images/sugarshack_bad_mpo_header.jpg Tests/images/sugarshack_frame_size.mpo Tests/images/sugarshack_ifd_offset.mpo Tests/images/sugarshack_no_data.mpo Tests/images/sunraster.im1 Tests/images/sunraster.im1.png Tests/images/tRNS_null_1x1.png Tests/images/test-card-lossless.jp2 Tests/images/test-card-lossy-tiled.jp2 Tests/images/test-card.png Tests/images/test-ole-file.doc Tests/images/test.colors.gif Tests/images/test.gpl Tests/images/test_Nastalifont_text.png Tests/images/test_anchor_multiline_lm_center.png Tests/images/test_anchor_multiline_lm_left.png Tests/images/test_anchor_multiline_lm_right.png Tests/images/test_anchor_multiline_ma_center.png Tests/images/test_anchor_multiline_md_center.png Tests/images/test_anchor_multiline_mm_center.png Tests/images/test_anchor_multiline_mm_left.png Tests/images/test_anchor_multiline_mm_right.png Tests/images/test_anchor_multiline_rm_center.png Tests/images/test_anchor_multiline_rm_left.png Tests/images/test_anchor_multiline_rm_right.png Tests/images/test_anchor_quick_ls.png Tests/images/test_anchor_quick_ma.png Tests/images/test_anchor_quick_mb.png Tests/images/test_anchor_quick_md.png Tests/images/test_anchor_quick_mm.png Tests/images/test_anchor_quick_ms.png Tests/images/test_anchor_quick_mt.png Tests/images/test_anchor_quick_rs.png Tests/images/test_anchor_ttb_f_lt.png Tests/images/test_anchor_ttb_f_mm.png Tests/images/test_anchor_ttb_f_rb.png Tests/images/test_anchor_ttb_f_sm.png Tests/images/test_arabictext_features.png Tests/images/test_combine_caron.png Tests/images/test_combine_caron_below.png Tests/images/test_combine_caron_below_lb.png Tests/images/test_combine_caron_below_ld.png Tests/images/test_combine_caron_below_ls.png Tests/images/test_combine_caron_below_ttb.png Tests/images/test_combine_caron_below_ttb_lb.png Tests/images/test_combine_caron_la.png Tests/images/test_combine_caron_ls.png Tests/images/test_combine_caron_lt.png Tests/images/test_combine_caron_ttb.png Tests/images/test_combine_caron_ttb_lt.png Tests/images/test_combine_double_breve_below.png Tests/images/test_combine_double_breve_below_ma.png Tests/images/test_combine_double_breve_below_ra.png Tests/images/test_combine_double_breve_below_ttb.png Tests/images/test_combine_double_breve_below_ttb_mt.png Tests/images/test_combine_double_breve_below_ttb_rt.png Tests/images/test_combine_double_breve_below_ttb_st.png Tests/images/test_combine_multiline_lm_center.png Tests/images/test_combine_multiline_lm_left.png Tests/images/test_combine_multiline_lm_right.png Tests/images/test_combine_multiline_mm_center.png Tests/images/test_combine_multiline_mm_left.png Tests/images/test_combine_multiline_mm_right.png Tests/images/test_combine_multiline_rm_center.png Tests/images/test_combine_multiline_rm_left.png Tests/images/test_combine_multiline_rm_right.png Tests/images/test_combine_overline.png Tests/images/test_combine_overline_la.png Tests/images/test_combine_overline_ra.png Tests/images/test_combine_overline_ttb.png Tests/images/test_combine_overline_ttb_mt.png Tests/images/test_combine_overline_ttb_rt.png Tests/images/test_combine_overline_ttb_st.png Tests/images/test_complex_unicode_text.png Tests/images/test_complex_unicode_text2.png Tests/images/test_direction_ltr.png Tests/images/test_direction_rtl.png Tests/images/test_direction_ttb.png Tests/images/test_direction_ttb_stroke.png Tests/images/test_draw_pbm_target.png Tests/images/test_draw_pbm_ter_en_target.png Tests/images/test_draw_pbm_ter_pl_target.png Tests/images/test_extents.gif Tests/images/test_kerning_features.png Tests/images/test_language.png Tests/images/test_ligature_features.png Tests/images/test_text.png Tests/images/test_x_max_and_y_offset.png Tests/images/test_y_offset.png Tests/images/text_mono.gif Tests/images/tga/common/1x1_l.png Tests/images/tga/common/1x1_l_bl_raw.tga Tests/images/tga/common/1x1_l_bl_rle.tga Tests/images/tga/common/1x1_l_tl_raw.tga Tests/images/tga/common/1x1_l_tl_rle.tga Tests/images/tga/common/200x32_l.png Tests/images/tga/common/200x32_l_bl_raw.tga Tests/images/tga/common/200x32_l_bl_rle.tga Tests/images/tga/common/200x32_l_tl_raw.tga Tests/images/tga/common/200x32_l_tl_rle.tga Tests/images/tga/common/200x32_la.png Tests/images/tga/common/200x32_la_bl_raw.tga Tests/images/tga/common/200x32_la_bl_rle.tga Tests/images/tga/common/200x32_la_tl_raw.tga Tests/images/tga/common/200x32_la_tl_rle.tga Tests/images/tga/common/200x32_p.png Tests/images/tga/common/200x32_p_bl_raw.tga Tests/images/tga/common/200x32_p_bl_rle.tga Tests/images/tga/common/200x32_p_tl_raw.tga Tests/images/tga/common/200x32_p_tl_rle.tga Tests/images/tga/common/200x32_rgb.png Tests/images/tga/common/200x32_rgb_bl_raw.tga Tests/images/tga/common/200x32_rgb_bl_rle.tga Tests/images/tga/common/200x32_rgb_tl_raw.tga Tests/images/tga/common/200x32_rgb_tl_rle.tga Tests/images/tga/common/200x32_rgba.png Tests/images/tga/common/200x32_rgba_bl_raw.tga Tests/images/tga/common/200x32_rgba_bl_rle.tga Tests/images/tga/common/200x32_rgba_tl_raw.tga Tests/images/tga/common/200x32_rgba_tl_rle.tga Tests/images/tga/common/readme.txt Tests/images/tga_id_field.tga Tests/images/tiff_16bit_RGB.tiff Tests/images/tiff_16bit_RGB_target.png Tests/images/tiff_16bit_RGBa.tiff Tests/images/tiff_16bit_RGBa_target.png Tests/images/tiff_adobe_deflate.png Tests/images/tiff_adobe_deflate.tif Tests/images/tiff_gray_2_4_bpp/hopper2.tif Tests/images/tiff_gray_2_4_bpp/hopper2I.tif Tests/images/tiff_gray_2_4_bpp/hopper2IR.tif Tests/images/tiff_gray_2_4_bpp/hopper2R.tif Tests/images/tiff_gray_2_4_bpp/hopper4.tif Tests/images/tiff_gray_2_4_bpp/hopper4I.tif Tests/images/tiff_gray_2_4_bpp/hopper4IR.tif Tests/images/tiff_gray_2_4_bpp/hopper4R.tif Tests/images/tiff_overflow_rows_per_strip.tif Tests/images/tiff_strip_cmyk_16l_jpeg.tif Tests/images/tiff_strip_cmyk_jpeg.tif Tests/images/tiff_strip_planar_raw.tif Tests/images/tiff_strip_planar_raw_with_overviews.tif Tests/images/tiff_strip_raw.tif Tests/images/tiff_strip_ycbcr_jpeg_1x1_sampling.tif Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif Tests/images/tiff_tiled_cmyk_jpeg.tif Tests/images/tiff_tiled_planar_raw.tif Tests/images/tiff_tiled_raw.tif Tests/images/tiff_tiled_ycbcr_jpeg_1x1_sampling.tif Tests/images/tiff_tiled_ycbcr_jpeg_2x2_sampling.tif Tests/images/tiff_wrong_bits_per_sample.tiff Tests/images/total-pages-zero.tif Tests/images/transparent.gif Tests/images/transparent.png Tests/images/transparent.sgi Tests/images/transparent.webp Tests/images/transparent_background_text.png Tests/images/truncated_image.png Tests/images/truncated_jpeg.jpg Tests/images/tv.rgb Tests/images/tv16.sgi Tests/images/uint16_1_4660.tif Tests/images/unbound_variable.jp2 Tests/images/uncompressed_rgb.dds Tests/images/uncompressed_rgb.png Tests/images/unicode_extended.png Tests/images/unimplemented_dxgi_format.dds Tests/images/unimplemented_pixel_format.dds Tests/images/variation_adobe.png Tests/images/variation_adobe_axes.png Tests/images/variation_adobe_name.png Tests/images/variation_adobe_older_harfbuzz.png Tests/images/variation_adobe_older_harfbuzz_axes.png Tests/images/variation_adobe_older_harfbuzz_name.png Tests/images/variation_tiny.png Tests/images/variation_tiny_axes.png Tests/images/variation_tiny_name.png Tests/images/xmp_tags_orientation.png Tests/images/zero_bb.eps Tests/images/zero_bb.png Tests/images/zero_bb_emptyline.eps Tests/images/zero_bb_scale2.png Tests/test_000_sanity.py Tests/test_binary.py Tests/test_bmp_reference.py Tests/test_box_blur.py Tests/test_color_lut.py Tests/test_core_resources.py Tests/test_decompression_bomb.py Tests/test_features.py Tests/test_file_apng.py Tests/test_file_blp.py Tests/test_file_bmp.py Tests/test_file_bufrstub.py Tests/test_file_container.py Tests/test_file_cur.py Tests/test_file_dcx.py Tests/test_file_dds.py Tests/test_file_eps.py Tests/test_file_fitsstub.py Tests/test_file_fli.py Tests/test_file_fpx.py Tests/test_file_ftex.py Tests/test_file_gbr.py Tests/test_file_gd.py Tests/test_file_gif.py Tests/test_file_gimpgradient.py Tests/test_file_gimppalette.py Tests/test_file_gribstub.py Tests/test_file_hdf5stub.py Tests/test_file_icns.py Tests/test_file_ico.py Tests/test_file_im.py Tests/test_file_iptc.py Tests/test_file_jpeg.py Tests/test_file_jpeg2k.py Tests/test_file_libtiff.py Tests/test_file_libtiff_small.py Tests/test_file_mcidas.py Tests/test_file_mic.py Tests/test_file_mpo.py Tests/test_file_msp.py Tests/test_file_palm.py Tests/test_file_pcd.py Tests/test_file_pcx.py Tests/test_file_pdf.py Tests/test_file_pixar.py Tests/test_file_png.py Tests/test_file_ppm.py Tests/test_file_psd.py Tests/test_file_sgi.py Tests/test_file_spider.py Tests/test_file_sun.py Tests/test_file_tar.py Tests/test_file_tga.py Tests/test_file_tiff.py Tests/test_file_tiff_metadata.py Tests/test_file_wal.py Tests/test_file_webp.py Tests/test_file_webp_alpha.py Tests/test_file_webp_animated.py Tests/test_file_webp_lossless.py Tests/test_file_webp_metadata.py Tests/test_file_wmf.py Tests/test_file_xbm.py Tests/test_file_xpm.py Tests/test_file_xvthumb.py Tests/test_font_bdf.py Tests/test_font_leaks.py Tests/test_font_pcf.py Tests/test_font_pcf_charsets.py Tests/test_format_hsv.py Tests/test_format_lab.py Tests/test_image.py Tests/test_image_access.py Tests/test_image_array.py Tests/test_image_convert.py Tests/test_image_copy.py Tests/test_image_crop.py Tests/test_image_draft.py Tests/test_image_entropy.py Tests/test_image_filter.py Tests/test_image_frombytes.py Tests/test_image_fromqimage.py Tests/test_image_getbands.py Tests/test_image_getbbox.py Tests/test_image_getcolors.py Tests/test_image_getdata.py Tests/test_image_getextrema.py Tests/test_image_getim.py Tests/test_image_getpalette.py Tests/test_image_getprojection.py Tests/test_image_histogram.py Tests/test_image_load.py Tests/test_image_mode.py Tests/test_image_paste.py Tests/test_image_point.py Tests/test_image_putalpha.py Tests/test_image_putdata.py Tests/test_image_putpalette.py Tests/test_image_quantize.py Tests/test_image_reduce.py Tests/test_image_resample.py Tests/test_image_resize.py Tests/test_image_rotate.py Tests/test_image_split.py Tests/test_image_thumbnail.py Tests/test_image_tobitmap.py Tests/test_image_tobytes.py Tests/test_image_transform.py Tests/test_image_transpose.py Tests/test_imagechops.py Tests/test_imagecms.py Tests/test_imagecolor.py Tests/test_imagedraw.py Tests/test_imagedraw2.py Tests/test_imageenhance.py Tests/test_imagefile.py Tests/test_imagefont.py Tests/test_imagefontctl.py Tests/test_imagegrab.py Tests/test_imagemath.py Tests/test_imagemorph.py Tests/test_imageops.py Tests/test_imageops_usm.py Tests/test_imagepalette.py Tests/test_imagepath.py Tests/test_imageqt.py Tests/test_imagesequence.py Tests/test_imageshow.py Tests/test_imagestat.py Tests/test_imagetk.py Tests/test_imagewin.py Tests/test_imagewin_pointers.py Tests/test_lib_image.py Tests/test_lib_pack.py Tests/test_locale.py Tests/test_main.py Tests/test_map.py Tests/test_mode_i16.py Tests/test_numpy.py Tests/test_pdfparser.py Tests/test_pickle.py Tests/test_psdraw.py Tests/test_pyroma.py Tests/test_qt_image_fromqpixmap.py Tests/test_qt_image_toqimage.py Tests/test_qt_image_toqpixmap.py Tests/test_sgi_crash.py Tests/test_shell_injection.py Tests/test_tiff_crashes.py Tests/test_tiff_ifdrational.py Tests/test_uploader.py Tests/test_util.py Tests/test_webp_leaks.py codecov.yml conftest.py depends/README.rst depends/diffcover-install.sh depends/diffcover-run.sh depends/download-and-extract.sh depends/install_extra_test_images.sh depends/install_imagequant.sh depends/install_openjpeg.sh depends/install_raqm.sh depends/install_raqm_cmake.sh depends/install_webp.sh depends/termux.sh docs/COPYING docs/Guardfile docs/Makefile docs/PIL.rst docs/about.rst docs/conf.py docs/deprecations.rst docs/example/DdsImagePlugin.py docs/example/anchors.png docs/example/anchors.py docs/handbook/appendices.rst docs/handbook/concepts.rst docs/handbook/image-file-formats.rst docs/handbook/index.rst docs/handbook/overview.rst docs/handbook/text-anchors.rst docs/handbook/tutorial.rst docs/handbook/writing-your-own-file-decoder.rst docs/index.rst docs/installation.rst docs/make.bat docs/porting.rst docs/reference/ExifTags.rst docs/reference/Image.rst docs/reference/ImageChops.rst docs/reference/ImageCms.rst docs/reference/ImageColor.rst docs/reference/ImageDraw.rst docs/reference/ImageEnhance.rst docs/reference/ImageFile.rst docs/reference/ImageFilter.rst docs/reference/ImageFont.rst docs/reference/ImageGrab.rst docs/reference/ImageMath.rst docs/reference/ImageMorph.rst docs/reference/ImageOps.rst docs/reference/ImagePalette.rst docs/reference/ImagePath.rst docs/reference/ImageQt.rst docs/reference/ImageSequence.rst docs/reference/ImageShow.rst docs/reference/ImageStat.rst docs/reference/ImageTk.rst docs/reference/ImageWin.rst docs/reference/JpegPresets.rst docs/reference/PSDraw.rst docs/reference/PixelAccess.rst docs/reference/PyAccess.rst docs/reference/TiffTags.rst docs/reference/block_allocator.rst docs/reference/features.rst docs/reference/index.rst docs/reference/internal_design.rst docs/reference/internal_modules.rst docs/reference/limits.rst docs/reference/open_files.rst docs/reference/plugins.rst docs/releasenotes/2.7.0.rst docs/releasenotes/2.8.0.rst docs/releasenotes/3.0.0.rst docs/releasenotes/3.1.0.rst docs/releasenotes/3.1.1.rst docs/releasenotes/3.1.2.rst docs/releasenotes/3.2.0.rst docs/releasenotes/3.3.0.rst docs/releasenotes/3.3.2.rst docs/releasenotes/3.4.0.rst docs/releasenotes/4.0.0.rst docs/releasenotes/4.1.0.rst docs/releasenotes/4.1.1.rst docs/releasenotes/4.2.0.rst docs/releasenotes/4.2.1.rst docs/releasenotes/4.3.0.rst docs/releasenotes/5.0.0.rst docs/releasenotes/5.1.0.rst docs/releasenotes/5.2.0.rst docs/releasenotes/5.3.0.rst docs/releasenotes/5.4.0.rst docs/releasenotes/5.4.1.rst docs/releasenotes/6.0.0.rst docs/releasenotes/6.1.0.rst docs/releasenotes/6.2.0.rst docs/releasenotes/6.2.1.rst docs/releasenotes/6.2.2.rst docs/releasenotes/7.0.0.rst docs/releasenotes/7.1.0.rst docs/releasenotes/7.1.1.rst docs/releasenotes/7.1.2.rst docs/releasenotes/7.2.0.rst docs/releasenotes/8.0.0.rst docs/releasenotes/8.0.1.rst docs/releasenotes/index.rst docs/releasenotes/template.rst docs/resources/anchor_horizontal.svg docs/resources/anchor_vertical.svg docs/resources/css/dark.css docs/resources/favicon.ico docs/resources/js/script.js requirements.txt selftest.py setup.cfg setup.py src/PIL/BdfFontFile.py src/PIL/BlpImagePlugin.py src/PIL/BmpImagePlugin.py src/PIL/BufrStubImagePlugin.py src/PIL/ContainerIO.py src/PIL/CurImagePlugin.py src/PIL/DcxImagePlugin.py src/PIL/DdsImagePlugin.py src/PIL/EpsImagePlugin.py src/PIL/ExifTags.py src/PIL/FitsStubImagePlugin.py src/PIL/FliImagePlugin.py src/PIL/FontFile.py src/PIL/FpxImagePlugin.py src/PIL/FtexImagePlugin.py src/PIL/GbrImagePlugin.py src/PIL/GdImageFile.py src/PIL/GifImagePlugin.py src/PIL/GimpGradientFile.py src/PIL/GimpPaletteFile.py src/PIL/GribStubImagePlugin.py src/PIL/Hdf5StubImagePlugin.py src/PIL/IcnsImagePlugin.py src/PIL/IcoImagePlugin.py src/PIL/ImImagePlugin.py src/PIL/Image.py src/PIL/ImageChops.py src/PIL/ImageCms.py src/PIL/ImageColor.py src/PIL/ImageDraw.py src/PIL/ImageDraw2.py src/PIL/ImageEnhance.py src/PIL/ImageFile.py src/PIL/ImageFilter.py src/PIL/ImageFont.py src/PIL/ImageGrab.py src/PIL/ImageMath.py src/PIL/ImageMode.py src/PIL/ImageMorph.py src/PIL/ImageOps.py src/PIL/ImagePalette.py src/PIL/ImagePath.py src/PIL/ImageQt.py src/PIL/ImageSequence.py src/PIL/ImageShow.py src/PIL/ImageStat.py src/PIL/ImageTk.py src/PIL/ImageTransform.py src/PIL/ImageWin.py src/PIL/ImtImagePlugin.py src/PIL/IptcImagePlugin.py src/PIL/Jpeg2KImagePlugin.py src/PIL/JpegImagePlugin.py src/PIL/JpegPresets.py src/PIL/McIdasImagePlugin.py src/PIL/MicImagePlugin.py src/PIL/MpegImagePlugin.py src/PIL/MpoImagePlugin.py src/PIL/MspImagePlugin.py src/PIL/PSDraw.py src/PIL/PaletteFile.py src/PIL/PalmImagePlugin.py src/PIL/PcdImagePlugin.py src/PIL/PcfFontFile.py src/PIL/PcxImagePlugin.py src/PIL/PdfImagePlugin.py src/PIL/PdfParser.py src/PIL/PixarImagePlugin.py src/PIL/PngImagePlugin.py src/PIL/PpmImagePlugin.py src/PIL/PsdImagePlugin.py src/PIL/PyAccess.py src/PIL/SgiImagePlugin.py src/PIL/SpiderImagePlugin.py src/PIL/SunImagePlugin.py src/PIL/TarIO.py src/PIL/TgaImagePlugin.py src/PIL/TiffImagePlugin.py src/PIL/TiffTags.py src/PIL/WalImageFile.py src/PIL/WebPImagePlugin.py src/PIL/WmfImagePlugin.py src/PIL/XVThumbImagePlugin.py src/PIL/XbmImagePlugin.py src/PIL/XpmImagePlugin.py src/PIL/__init__.py src/PIL/__main__.py src/PIL/_binary.py src/PIL/_tkinter_finder.py src/PIL/_util.py src/PIL/_version.py src/PIL/features.py src/Tk/_tkmini.h src/Tk/tkImaging.c src/_imaging.c src/_imagingcms.c src/_imagingft.c src/_imagingmath.c src/_imagingmorph.c src/_imagingtk.c src/_webp.c src/decode.c src/display.c src/encode.c src/libImaging/Access.c src/libImaging/AlphaComposite.c src/libImaging/Bands.c src/libImaging/BcnDecode.c src/libImaging/Bit.h src/libImaging/BitDecode.c src/libImaging/Blend.c src/libImaging/BoxBlur.c src/libImaging/Chops.c src/libImaging/ColorLUT.c src/libImaging/Convert.c src/libImaging/ConvertYCbCr.c src/libImaging/Copy.c src/libImaging/Crop.c src/libImaging/Dib.c src/libImaging/Draw.c src/libImaging/Effects.c src/libImaging/EpsEncode.c src/libImaging/Except.c src/libImaging/File.c src/libImaging/Fill.c src/libImaging/Filter.c src/libImaging/FliDecode.c src/libImaging/Geometry.c src/libImaging/GetBBox.c src/libImaging/Gif.h src/libImaging/GifDecode.c src/libImaging/GifEncode.c src/libImaging/HexDecode.c src/libImaging/Histo.c src/libImaging/ImDib.h src/libImaging/ImPlatform.h src/libImaging/Imaging.h src/libImaging/ImagingUtils.h src/libImaging/Jpeg.h src/libImaging/Jpeg2K.h src/libImaging/Jpeg2KDecode.c src/libImaging/Jpeg2KEncode.c src/libImaging/JpegDecode.c src/libImaging/JpegEncode.c src/libImaging/Matrix.c src/libImaging/ModeFilter.c src/libImaging/Negative.c src/libImaging/Offset.c src/libImaging/Pack.c src/libImaging/PackDecode.c src/libImaging/Palette.c src/libImaging/Paste.c src/libImaging/PcdDecode.c src/libImaging/PcxDecode.c src/libImaging/PcxEncode.c src/libImaging/Point.c src/libImaging/Quant.c src/libImaging/QuantHash.c src/libImaging/QuantHash.h src/libImaging/QuantHeap.c src/libImaging/QuantHeap.h src/libImaging/QuantOctree.c src/libImaging/QuantOctree.h src/libImaging/QuantPngQuant.c src/libImaging/QuantPngQuant.h src/libImaging/QuantTypes.h src/libImaging/RankFilter.c src/libImaging/Raw.h src/libImaging/RawDecode.c src/libImaging/RawEncode.c src/libImaging/Reduce.c src/libImaging/Resample.c src/libImaging/Sgi.h src/libImaging/SgiRleDecode.c src/libImaging/Storage.c src/libImaging/SunRleDecode.c src/libImaging/TgaRleDecode.c src/libImaging/TgaRleEncode.c src/libImaging/TiffDecode.c src/libImaging/TiffDecode.h src/libImaging/Unpack.c src/libImaging/UnpackYCC.c src/libImaging/UnsharpMask.c src/libImaging/XbmDecode.c src/libImaging/XbmEncode.c src/libImaging/ZipCodecs.h src/libImaging/ZipDecode.c src/libImaging/ZipEncode.c src/libImaging/codec_fd.c src/libImaging/raqm.h src/map.c src/outline.c src/path.c tox.ini winbuild/README.md winbuild/build.rst winbuild/build_prepare.py winbuild/fribidi.cmake winbuild/raqm.cmake winbuild/tiff.opt <<<<<< network # path=/home/travis/build/python-pillow/Pillow/src#libImaging#RawDecode.c.gcov -: 0:Source:src/libImaging/RawDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/RawDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/RawDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for raw (uncompressed) image data -: 6: * -: 7: * history: -: 8: * 96-03-07 fl rewritten -: 9: * -: 10: * Copyright (c) Fredrik Lundh 1996. -: 11: * Copyright (c) Secret Labs AB 1997. -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16: -: 17:#include "Imaging.h" -: 18: -: 19:#include "Raw.h" -: 20: -: 21: -: 22:int function ImagingRawDecode called 15399 returned 100% blocks executed 95% 15399: 23:ImagingRawDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 24:{ -: 25: enum { LINE = 1, SKIP }; 15399: 26: RAWSTATE* rawstate = state->context; -: 27: -: 28: UINT8* ptr; -: 29: 15399: 30: if (state->state == 0) { branch 0 taken 97% (fallthrough) branch 1 taken 3% -: 31: -: 32: /* Initialize context variables */ -: 33: -: 34: /* get size of image data and padding */ 14893: 35: state->bytes = (state->xsize * state->bits + 7) / 8; 14893: 36: if (rawstate->stride) { branch 0 taken 90% (fallthrough) branch 1 taken 10% 13426: 37: rawstate->skip = rawstate->stride - state->bytes; 13426: 38: if (rawstate->skip < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 39: state->errcode = IMAGING_CODEC_CONFIG; 1: 40: return -1; -: 41: } -: 42: } else { 1467: 43: rawstate->skip = 0; -: 44: } -: 45: -: 46: /* check image orientation */ 14892: 47: if (state->ystep < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 98: 48: state->y = state->ysize-1; 98: 49: state->ystep = -1; -: 50: } else { 14794: 51: state->ystep = 1; -: 52: } -: 53: 14892: 54: state->state = LINE; -: 55: -: 56: } -: 57: -: 58: ptr = buf; -: 59: -: 60: for (;;) { -: 61: 443591: 62: if (state->state == SKIP) { branch 0 taken 97% (fallthrough) branch 1 taken 3% -: 63: -: 64: /* Skip padding between lines */ -: 65: 428193: 66: if (bytes < rawstate->skip) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 67: return ptr - buf; -: 68: } -: 69: 428193: 70: ptr += rawstate->skip; 428193: 71: bytes -= rawstate->skip; -: 72: 428193: 73: state->state = LINE; -: 74: -: 75: } -: 76: 443591: 77: if (bytes < state->bytes) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 511: 78: return ptr - buf; -: 79: } -: 80: -: 81: /* Unpack data */ 886160: 82: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 443080: 83: state->xoff * im->pixelsize, ptr, state->xsize); -: 84: 443080: 85: ptr += state->bytes; 443080: 86: bytes -= state->bytes; -: 87: 443080: 88: state->y += state->ystep; -: 89: 443080: 90: if (state->y < 0 || state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 97% (fallthrough) branch 3 taken 3% -: 91: /* End of file (errcode = 0) */ -: 92: return -1; -: 93: } -: 94: 428193: 95: state->state = SKIP; -: 96: 428193: 97: } -: 98: -: 99:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#PackDecode.c.gcov -: 0:Source:src/libImaging/PackDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/PackDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/PackDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for PackBits image data. -: 6: * -: 7: * history: -: 8: * 96-04-19 fl Created -: 9: * -: 10: * Copyright (c) Fredrik Lundh 1996. -: 11: * Copyright (c) Secret Labs AB 1997. -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16: -: 17:#include "Imaging.h" -: 18: -: 19:int function ImagingPackbitsDecode called 21 returned 100% blocks executed 84% 21: 20:ImagingPackbitsDecode(Imaging im, ImagingCodecState state, -: 21: UINT8* buf, Py_ssize_t bytes) -: 22:{ -: 23: UINT8 n; -: 24: UINT8* ptr; -: 25: int i; -: 26: 21: 27: ptr = buf; -: 28: -: 29: for (;;) { -: 30: 24288: 31: if (bytes < 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 32: return ptr - buf; -: 33: } -: 34: 24288: 35: if (ptr[0] & 0x80) { branch 0 taken 59% (fallthrough) branch 1 taken 41% -: 36: 14438: 37: if (ptr[0] == 0x80) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 38: /* Nop */ #####: 39: ptr++; bytes--; #####: 40: continue; -: 41: } -: 42: -: 43: /* Run */ 14438: 44: if (bytes < 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 45: return ptr - buf; -: 46: } -: 47: 80260: 48: for (n = 257 - ptr[0]; n > 0; n--) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 65822: 49: if (state->x >= state->bytes) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 50: /* state->errcode = IMAGING_CODEC_OVERRUN; */ -: 51: break; -: 52: } 65822: 53: state->buffer[state->x++] = ptr[1]; -: 54: } -: 55: 14438: 56: ptr += 2; bytes -= 2; -: 57: -: 58: } else { -: 59: -: 60: /* Literal */ 9850: 61: n = ptr[0]+2; -: 62: 9850: 63: if (bytes < n) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 64: return ptr - buf; -: 65: } -: 66: 278242: 67: for (i = 1; i < n; i++) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 278242: 68: if (state->x >= state->bytes) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 69: /* state->errcode = IMAGING_CODEC_OVERRUN; */ -: 70: break; -: 71: } 278242: 72: state->buffer[state->x++] = ptr[i]; -: 73: } -: 74: 9850: 75: ptr += n; bytes -= n; -: 76: -: 77: } -: 78: 24288: 79: if (state->x >= state->bytes) { branch 0 taken 89% branch 1 taken 11% (fallthrough) -: 80: -: 81: /* Got a full line, unpack it */ 8064: 82: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 5376: 83: state->xoff * im->pixelsize, state->buffer, -: 84: state->xsize); -: 85: 2688: 86: state->x = 0; -: 87: 2688: 88: if (++state->y >= state->ysize) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 89: /* End of file (errcode = 0) */ -: 90: return -1; -: 91: } -: 92: } -: 93: -: 94: } -: 95:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#outline.c.gcov -: 0:Source:src/outline.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/outline.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/outline.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * THIS IS WORK IN PROGRESS. -: 3: * -: 4: * The Python Imaging Library. -: 5: * -: 6: * "arrow" outline stuff. the contents of this module -: 7: * will be merged with the path module and the rest of -: 8: * the arrow graphics package, but not before PIL 1.1. -: 9: * use at your own risk. -: 10: * -: 11: * history: -: 12: * 99-01-10 fl Added to PIL (experimental) -: 13: * -: 14: * Copyright (c) Secret Labs AB 1999. -: 15: * Copyright (c) Fredrik Lundh 1999. -: 16: * -: 17: * See the README file for information on usage and redistribution. -: 18: */ -: 19: -: 20:#include "Python.h" -: 21: -: 22:#include "libImaging/Imaging.h" -: 23: -: 24: -: 25:/* -------------------------------------------------------------------- */ -: 26:/* Class */ -: 27: -: 28:typedef struct { -: 29: PyObject_HEAD -: 30: ImagingOutline outline; -: 31:} OutlineObject; -: 32: -: 33:static PyTypeObject OutlineType; -: 34: -: 35:#define PyOutline_Check(op) (Py_TYPE(op) == &OutlineType) -: 36: -: 37:static OutlineObject* function _outline_new called 3 returned 100% blocks executed 100% 3: 38:_outline_new(void) -: 39:{ -: 40: OutlineObject *self; -: 41: 3: 42: if (PyType_Ready(&OutlineType) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 43: return NULL; -: 44: } -: 45: 3: 46: self = PyObject_New(OutlineObject, &OutlineType); call 0 returned 100% 3: 47: if (self == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 48: return NULL; -: 49: } -: 50: 3: 51: self->outline = ImagingOutlineNew(); call 0 returned 100% -: 52: 3: 53: return self; -: 54:} -: 55: -: 56:static void function _outline_dealloc called 3 returned 100% blocks executed 100% 3: 57:_outline_dealloc(OutlineObject* self) -: 58:{ 3: 59: ImagingOutlineDelete(self->outline); call 0 returned 100% 3: 60: PyObject_Del(self); call 0 returned 100% 3: 61:} -: 62: -: 63:ImagingOutline function PyOutline_AsOutline called 8 returned 100% blocks executed 100% 8: 64:PyOutline_AsOutline(PyObject* outline) -: 65:{ 8: 66: if (PyOutline_Check(outline)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 8: 67: return ((OutlineObject*) outline)->outline; -: 68: } -: 69: -: 70: return NULL; -: 71:} -: 72: -: 73: -: 74:/* -------------------------------------------------------------------- */ -: 75:/* Factories */ -: 76: -: 77:PyObject* function PyOutline_Create called 3 returned 100% blocks executed 100% 3: 78:PyOutline_Create(PyObject* self, PyObject* args) -: 79:{ 3: 80: if (!PyArg_ParseTuple(args, ":outline")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 81: return NULL; -: 82: } -: 83: 3: 84: return (PyObject*) _outline_new(); call 0 returned 100% -: 85:} -: 86: -: 87: -: 88:/* -------------------------------------------------------------------- */ -: 89:/* Methods */ -: 90: -: 91:static PyObject* function _outline_move called 3 returned 100% blocks executed 100% 3: 92:_outline_move(OutlineObject* self, PyObject* args) -: 93:{ -: 94: float x0, y0; 3: 95: if (!PyArg_ParseTuple(args, "ff", &x0, &y0)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 96: return NULL; -: 97: } -: 98: 3: 99: ImagingOutlineMove(self->outline, x0, y0); call 0 returned 100% -: 100: 3: 101: Py_INCREF(Py_None); 3: 102: return Py_None; -: 103:} -: 104: -: 105:static PyObject* function _outline_line called 3 returned 100% blocks executed 100% 3: 106:_outline_line(OutlineObject* self, PyObject* args) -: 107:{ -: 108: float x1, y1; 3: 109: if (!PyArg_ParseTuple(args, "ff", &x1, &y1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 110: return NULL; -: 111: } -: 112: 3: 113: ImagingOutlineLine(self->outline, x1, y1); call 0 returned 100% -: 114: 3: 115: Py_INCREF(Py_None); 3: 116: return Py_None; -: 117:} -: 118: -: 119:static PyObject* function _outline_curve called 3 returned 100% blocks executed 100% 3: 120:_outline_curve(OutlineObject* self, PyObject* args) -: 121:{ -: 122: float x1, y1, x2, y2, x3, y3; 3: 123: if (!PyArg_ParseTuple(args, "ffffff", &x1, &y1, &x2, &y2, &x3, &y3)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 124: return NULL; -: 125: } -: 126: 3: 127: ImagingOutlineCurve(self->outline, x1, y1, x2, y2, x3, y3); call 0 returned 100% -: 128: 3: 129: Py_INCREF(Py_None); 3: 130: return Py_None; -: 131:} -: 132: -: 133:static PyObject* function _outline_close called 8 returned 100% blocks executed 100% 8: 134:_outline_close(OutlineObject* self, PyObject* args) -: 135:{ 8: 136: if (!PyArg_ParseTuple(args, ":close")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 137: return NULL; -: 138: } -: 139: 8: 140: ImagingOutlineClose(self->outline); call 0 returned 100% -: 141: 8: 142: Py_INCREF(Py_None); 8: 143: return Py_None; -: 144:} -: 145: -: 146:static PyObject* function _outline_transform called 0 returned 0% blocks executed 0% #####: 147:_outline_transform(OutlineObject* self, PyObject* args) -: 148:{ -: 149: double a[6]; #####: 150: if (!PyArg_ParseTuple(args, "(dddddd)", a+0, a+1, a+2, a+3, a+4, a+5)) { call 0 never executed branch 1 never executed branch 2 never executed -: 151: return NULL; -: 152: } -: 153: #####: 154: ImagingOutlineTransform(self->outline, a); call 0 never executed -: 155: #####: 156: Py_INCREF(Py_None); #####: 157: return Py_None; -: 158:} -: 159: -: 160:static struct PyMethodDef _outline_methods[] = { -: 161: {"line", (PyCFunction)_outline_line, 1}, -: 162: {"curve", (PyCFunction)_outline_curve, 1}, -: 163: {"move", (PyCFunction)_outline_move, 1}, -: 164: {"close", (PyCFunction)_outline_close, 1}, -: 165: {"transform", (PyCFunction)_outline_transform, 1}, -: 166: {NULL, NULL} /* sentinel */ -: 167:}; -: 168: -: 169:static PyTypeObject OutlineType = { -: 170: PyVarObject_HEAD_INIT(NULL, 0) -: 171: "Outline", /*tp_name*/ -: 172: sizeof(OutlineObject), /*tp_size*/ -: 173: 0, /*tp_itemsize*/ -: 174: /* methods */ -: 175: (destructor)_outline_dealloc,/*tp_dealloc*/ -: 176: 0, /*tp_print*/ -: 177: 0, /*tp_getattr*/ -: 178: 0, /*tp_setattr*/ -: 179: 0, /*tp_compare*/ -: 180: 0, /*tp_repr*/ -: 181: 0, /*tp_as_number */ -: 182: 0, /*tp_as_sequence */ -: 183: 0, /*tp_as_mapping */ -: 184: 0, /*tp_hash*/ -: 185: 0, /*tp_call*/ -: 186: 0, /*tp_str*/ -: 187: 0, /*tp_getattro*/ -: 188: 0, /*tp_setattro*/ -: 189: 0, /*tp_as_buffer*/ -: 190: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 191: 0, /*tp_doc*/ -: 192: 0, /*tp_traverse*/ -: 193: 0, /*tp_clear*/ -: 194: 0, /*tp_richcompare*/ -: 195: 0, /*tp_weaklistoffset*/ -: 196: 0, /*tp_iter*/ -: 197: 0, /*tp_iternext*/ -: 198: _outline_methods, /*tp_methods*/ -: 199: 0, /*tp_members*/ -: 200: 0, /*tp_getset*/ -: 201:}; <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#BitDecode.c.gcov -: 0:Source:src/libImaging/BitDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/BitDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/BitDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for packed bitfields (converts to floating point) -: 6: * -: 7: * history: -: 8: * 97-05-31 fl created (much more than originally intended) -: 9: * -: 10: * Copyright (c) Fredrik Lundh 1997. -: 11: * Copyright (c) Secret Labs AB 1997. -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16: -: 17:#include "Imaging.h" -: 18: -: 19:#include "Bit.h" -: 20: -: 21: -: 22:int function ImagingBitDecode called 0 returned 0% blocks executed 0% #####: 23:ImagingBitDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 24:{ #####: 25: BITSTATE* bitstate = state->context; -: 26: UINT8* ptr; -: 27: #####: 28: if (state->state == 0) { branch 0 never executed branch 1 never executed -: 29: -: 30: /* Initialize context variables */ -: 31: -: 32: /* this decoder only works for float32 image buffers */ #####: 33: if (im->type != IMAGING_TYPE_FLOAT32) { branch 0 never executed branch 1 never executed #####: 34: state->errcode = IMAGING_CODEC_CONFIG; #####: 35: return -1; -: 36: } -: 37: -: 38: /* sanity check */ #####: 39: if (bitstate->bits < 1 || bitstate->bits >= 32) { branch 0 never executed branch 1 never executed #####: 40: state->errcode = IMAGING_CODEC_CONFIG; #####: 41: return -1; -: 42: } -: 43: #####: 44: bitstate->mask = (1<bits)-1; -: 45: #####: 46: if (bitstate->sign) { branch 0 never executed branch 1 never executed #####: 47: bitstate->signmask = (1<<(bitstate->bits-1)); -: 48: } -: 49: -: 50: /* check image orientation */ #####: 51: if (state->ystep < 0) { branch 0 never executed branch 1 never executed #####: 52: state->y = state->ysize-1; #####: 53: state->ystep = -1; -: 54: } else { #####: 55: state->ystep = 1; -: 56: } -: 57: #####: 58: state->state = 1; -: 59: -: 60: } -: 61: -: 62: ptr = buf; -: 63: #####: 64: while (bytes > 0) { branch 0 never executed branch 1 never executed -: 65: #####: 66: UINT8 byte = *ptr; -: 67: #####: 68: ptr++; #####: 69: bytes--; -: 70: -: 71: /* get a byte from the input stream and insert in the bit buffer */ #####: 72: if (bitstate->fill&1) { branch 0 never executed branch 1 never executed -: 73: /* fill MSB first */ #####: 74: bitstate->bitbuffer |= (unsigned long) byte << bitstate->bitcount; -: 75: } else { -: 76: /* fill LSB first */ #####: 77: bitstate->bitbuffer = (bitstate->bitbuffer << 8) | byte; -: 78: } -: 79: #####: 80: bitstate->bitcount += 8; -: 81: #####: 82: while (bitstate->bitcount >= bitstate->bits) { branch 0 never executed branch 1 never executed -: 83: -: 84: /* get a pixel from the bit buffer */ -: 85: unsigned long data; -: 86: FLOAT32 pixel; -: 87: #####: 88: if (bitstate->fill&2) { branch 0 never executed branch 1 never executed -: 89: /* store LSB first */ #####: 90: data = bitstate->bitbuffer & bitstate->mask; #####: 91: if (bitstate->bitcount > 32) { branch 0 never executed branch 1 never executed -: 92: /* bitbuffer overflow; restore it from last input byte */ #####: 93: bitstate->bitbuffer = byte >> (8 - (bitstate->bitcount - -: 94: bitstate->bits)); -: 95: } else { #####: 96: bitstate->bitbuffer >>= bitstate->bits; -: 97: } -: 98: } else { -: 99: /* store MSB first */ #####: 100: data = (bitstate->bitbuffer >> (bitstate->bitcount - -: 101: bitstate->bits)) #####: 102: & bitstate->mask; -: 103: } -: 104: #####: 105: bitstate->bitcount -= bitstate->bits; -: 106: #####: 107: if (bitstate->lutsize > 0) { branch 0 never executed branch 1 never executed -: 108: /* map through lookup table */ #####: 109: if (data <= 0) { branch 0 never executed branch 1 never executed #####: 110: pixel = bitstate->lut[0]; #####: 111: } else if (data >= bitstate->lutsize) { branch 0 never executed branch 1 never executed #####: 112: pixel = bitstate->lut[bitstate->lutsize-1]; -: 113: } else { #####: 114: pixel = bitstate->lut[data]; -: 115: } -: 116: } else { -: 117: /* convert */ #####: 118: if (data & bitstate->signmask) { branch 0 never executed branch 1 never executed -: 119: /* image memory contains signed data */ #####: 120: pixel = (FLOAT32) (INT32) (data | ~bitstate->mask); -: 121: } else { #####: 122: pixel = (FLOAT32) data; -: 123: } -: 124: } -: 125: #####: 126: *(FLOAT32*)(&im->image32[state->y][state->x]) = pixel; -: 127: -: 128: /* step forward */ #####: 129: if (++state->x >= state->xsize) { branch 0 never executed branch 1 never executed -: 130: /* new line */ #####: 131: state->y += state->ystep; #####: 132: if (state->y < 0 || state->y >= state->ysize) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 133: /* end of file (errcode = 0) */ -: 134: return -1; -: 135: } #####: 136: state->x = 0; -: 137: /* reset bit buffer */ #####: 138: if (bitstate->pad > 0) { branch 0 never executed branch 1 never executed #####: 139: bitstate->bitcount = 0; -: 140: } -: 141: } -: 142: } -: 143: } -: 144: #####: 145: return ptr - buf; -: 146:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#map.c.gcov -: 0:Source:src/map.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/map.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/map.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * standard memory mapping interface for the Imaging library -: 5: * -: 6: * history: -: 7: * 1998-03-05 fl added Win32 read mapping -: 8: * 1999-02-06 fl added "I;16" support -: 9: * 2003-04-21 fl added PyImaging_MapBuffer primitive -: 10: * -: 11: * Copyright (c) 1998-2003 by Secret Labs AB. -: 12: * Copyright (c) 2003 by Fredrik Lundh. -: 13: * -: 14: * See the README file for information on usage and redistribution. -: 15: */ -: 16: -: 17:/* -: 18: * FIXME: should move the memory mapping primitives into libImaging! -: 19: */ -: 20: -: 21:#include "Python.h" -: 22: -: 23:#include "libImaging/Imaging.h" -: 24: -: 25:/* compatibility wrappers (defined in _imaging.c) */ -: 26:extern int PyImaging_CheckBuffer(PyObject* buffer); -: 27:extern int PyImaging_GetBuffer(PyObject* buffer, Py_buffer *view); -: 28: -: 29:/* -------------------------------------------------------------------- */ -: 30:/* Standard mapper */ -: 31: -: 32:typedef struct { -: 33: PyObject_HEAD -: 34: char* base; -: 35: int size; -: 36: int offset; -: 37:#ifdef _WIN32 -: 38: HANDLE hFile; -: 39: HANDLE hMap; -: 40:#endif -: 41:} ImagingMapperObject; -: 42: -: 43:static PyTypeObject ImagingMapperType; -: 44: -: 45:ImagingMapperObject* function PyImaging_MapperNew called 0 returned 0% blocks executed 0% #####: 46:PyImaging_MapperNew(const char* filename, int readonly) -: 47:{ -: 48: ImagingMapperObject *mapper; -: 49: #####: 50: if (PyType_Ready(&ImagingMapperType) < 0) { call 0 never executed branch 1 never executed branch 2 never executed -: 51: return NULL; -: 52: } -: 53: #####: 54: mapper = PyObject_New(ImagingMapperObject, &ImagingMapperType); call 0 never executed #####: 55: if (mapper == NULL) { branch 0 never executed branch 1 never executed -: 56: return NULL; -: 57: } -: 58: #####: 59: mapper->base = NULL; #####: 60: mapper->size = mapper->offset = 0; -: 61: -: 62:#ifdef _WIN32 -: 63: mapper->hFile = (HANDLE)-1; -: 64: mapper->hMap = (HANDLE)-1; -: 65: -: 66: /* FIXME: currently supports readonly mappings only */ -: 67: mapper->hFile = CreateFile( -: 68: filename, -: 69: GENERIC_READ, -: 70: FILE_SHARE_READ, -: 71: NULL, OPEN_EXISTING, -: 72: FILE_ATTRIBUTE_NORMAL, -: 73: NULL); -: 74: if (mapper->hFile == (HANDLE)-1) { -: 75: PyErr_SetString(PyExc_OSError, "cannot open file"); -: 76: Py_DECREF(mapper); -: 77: return NULL; -: 78: } -: 79: -: 80: mapper->hMap = CreateFileMapping( -: 81: mapper->hFile, NULL, -: 82: PAGE_READONLY, -: 83: 0, 0, NULL); -: 84: if (mapper->hMap == (HANDLE)-1) { -: 85: CloseHandle(mapper->hFile); -: 86: PyErr_SetString(PyExc_OSError, "cannot map file"); -: 87: Py_DECREF(mapper); -: 88: return NULL; -: 89: } -: 90: -: 91: mapper->base = (char*) MapViewOfFile( -: 92: mapper->hMap, -: 93: FILE_MAP_READ, -: 94: 0, 0, 0); -: 95: -: 96: mapper->size = GetFileSize(mapper->hFile, 0); -: 97:#endif -: 98: #####: 99: return mapper; -: 100:} -: 101: -: 102:static void function mapping_dealloc called 0 returned 0% blocks executed 0% #####: 103:mapping_dealloc(ImagingMapperObject* mapper) -: 104:{ -: 105:#ifdef _WIN32 -: 106: if (mapper->base != 0) { -: 107: UnmapViewOfFile(mapper->base); -: 108: } -: 109: if (mapper->hMap != (HANDLE)-1) { -: 110: CloseHandle(mapper->hMap); -: 111: } -: 112: if (mapper->hFile != (HANDLE)-1) { -: 113: CloseHandle(mapper->hFile); -: 114: } -: 115: mapper->base = 0; -: 116: mapper->hMap = mapper->hFile = (HANDLE)-1; -: 117:#endif #####: 118: PyObject_Del(mapper); call 0 never executed #####: 119:} -: 120: -: 121:/* -------------------------------------------------------------------- */ -: 122:/* standard file operations */ -: 123: -: 124:static PyObject* function mapping_read called 0 returned 0% blocks executed 0% #####: 125:mapping_read(ImagingMapperObject* mapper, PyObject* args) -: 126:{ -: 127: PyObject* buf; -: 128: #####: 129: int size = -1; #####: 130: if (!PyArg_ParseTuple(args, "|i", &size)) { call 0 never executed branch 1 never executed branch 2 never executed -: 131: return NULL; -: 132: } -: 133: -: 134: /* check size */ #####: 135: if (size < 0 || mapper->offset + size > mapper->size) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 136: size = mapper->size - mapper->offset; -: 137: } #####: 138: if (size < 0) { branch 0 never executed branch 1 never executed #####: 139: size = 0; -: 140: } -: 141: #####: 142: buf = PyBytes_FromStringAndSize(NULL, size); call 0 never executed #####: 143: if (!buf) { branch 0 never executed branch 1 never executed -: 144: return NULL; -: 145: } -: 146: #####: 147: if (size > 0) { branch 0 never executed branch 1 never executed #####: 148: memcpy(PyBytes_AsString(buf), mapper->base + mapper->offset, size); call 0 never executed #####: 149: mapper->offset += size; -: 150: } -: 151: -: 152: return buf; -: 153:} -: 154: -: 155:static PyObject* function mapping_seek called 0 returned 0% blocks executed 0% #####: 156:mapping_seek(ImagingMapperObject* mapper, PyObject* args) -: 157:{ -: 158: int offset; #####: 159: int whence = 0; #####: 160: if (!PyArg_ParseTuple(args, "i|i", &offset, &whence)) { call 0 never executed branch 1 never executed branch 2 never executed -: 161: return NULL; -: 162: } -: 163: #####: 164: switch (whence) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 165: case 0: /* SEEK_SET */ #####: 166: mapper->offset = offset; #####: 167: break; -: 168: case 1: /* SEEK_CUR */ #####: 169: mapper->offset += offset; #####: 170: break; -: 171: case 2: /* SEEK_END */ #####: 172: mapper->offset = mapper->size + offset; #####: 173: break; -: 174: default: -: 175: /* FIXME: raise ValueError? */ -: 176: break; -: 177: } -: 178: #####: 179: Py_INCREF(Py_None); #####: 180: return Py_None; -: 181:} -: 182: -: 183:/* -------------------------------------------------------------------- */ -: 184:/* map entire image */ -: 185: -: 186:extern PyObject*PyImagingNew(Imaging im); -: 187: -: 188:static void function ImagingDestroyMap called 0 returned 0% blocks executed 0% #####: 189:ImagingDestroyMap(Imaging im) -: 190:{ #####: 191: return; /* nothing to do! */ -: 192:} -: 193: -: 194:static PyObject* function mapping_readimage called 0 returned 0% blocks executed 0% #####: 195:mapping_readimage(ImagingMapperObject* mapper, PyObject* args) -: 196:{ -: 197: int y, size; -: 198: Imaging im; -: 199: -: 200: char* mode; -: 201: int xsize; -: 202: int ysize; -: 203: int stride; -: 204: int orientation; #####: 205: if (!PyArg_ParseTuple(args, "s(ii)ii", &mode, &xsize, &ysize, call 0 never executed branch 1 never executed branch 2 never executed -: 206: &stride, &orientation)) { -: 207: return NULL; -: 208: } -: 209: #####: 210: if (stride <= 0) { branch 0 never executed branch 1 never executed -: 211: /* FIXME: maybe we should call ImagingNewPrologue instead */ #####: 212: if (!strcmp(mode, "L") || !strcmp(mode, "P")) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed branch 6 never executed branch 7 never executed #####: 213: stride = xsize; #####: 214: } else if (!strcmp(mode, "I;16") || !strcmp(mode, "I;16B")) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 215: stride = xsize * 2; -: 216: } else { #####: 217: stride = xsize * 4; -: 218: } -: 219: } -: 220: #####: 221: size = ysize * stride; -: 222: #####: 223: if (mapper->offset + size > mapper->size) { branch 0 never executed branch 1 never executed #####: 224: PyErr_SetString(PyExc_OSError, "image file truncated"); call 0 never executed #####: 225: return NULL; -: 226: } -: 227: #####: 228: im = ImagingNewPrologue(mode, xsize, ysize); call 0 never executed #####: 229: if (!im) { branch 0 never executed branch 1 never executed -: 230: return NULL; -: 231: } -: 232: -: 233: /* setup file pointers */ #####: 234: if (orientation > 0) { branch 0 never executed branch 1 never executed #####: 235: for (y = 0; y < ysize; y++) { branch 0 never executed branch 1 never executed #####: 236: im->image[y] = mapper->base + mapper->offset + y * stride; -: 237: } -: 238: } else { #####: 239: for (y = 0; y < ysize; y++) { branch 0 never executed branch 1 never executed #####: 240: im->image[ysize-y-1] = mapper->base + mapper->offset + y * stride; -: 241: } -: 242: } -: 243: #####: 244: im->destroy = ImagingDestroyMap; -: 245: #####: 246: mapper->offset += size; -: 247: #####: 248: return PyImagingNew(im); call 0 never executed -: 249:} -: 250: -: 251:static struct PyMethodDef methods[] = { -: 252: /* standard file interface */ -: 253: {"read", (PyCFunction)mapping_read, 1}, -: 254: {"seek", (PyCFunction)mapping_seek, 1}, -: 255: /* extensions */ -: 256: {"readimage", (PyCFunction)mapping_readimage, 1}, -: 257: {NULL, NULL} /* sentinel */ -: 258:}; -: 259: -: 260:static PyTypeObject ImagingMapperType = { -: 261: PyVarObject_HEAD_INIT(NULL, 0) -: 262: "ImagingMapper", /*tp_name*/ -: 263: sizeof(ImagingMapperObject), /*tp_size*/ -: 264: 0, /*tp_itemsize*/ -: 265: /* methods */ -: 266: (destructor)mapping_dealloc, /*tp_dealloc*/ -: 267: 0, /*tp_print*/ -: 268: 0, /*tp_getattr*/ -: 269: 0, /*tp_setattr*/ -: 270: 0, /*tp_compare*/ -: 271: 0, /*tp_repr*/ -: 272: 0, /*tp_as_number */ -: 273: 0, /*tp_as_sequence */ -: 274: 0, /*tp_as_mapping */ -: 275: 0, /*tp_hash*/ -: 276: 0, /*tp_call*/ -: 277: 0, /*tp_str*/ -: 278: 0, /*tp_getattro*/ -: 279: 0, /*tp_setattro*/ -: 280: 0, /*tp_as_buffer*/ -: 281: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 282: 0, /*tp_doc*/ -: 283: 0, /*tp_traverse*/ -: 284: 0, /*tp_clear*/ -: 285: 0, /*tp_richcompare*/ -: 286: 0, /*tp_weaklistoffset*/ -: 287: 0, /*tp_iter*/ -: 288: 0, /*tp_iternext*/ -: 289: methods, /*tp_methods*/ -: 290: 0, /*tp_members*/ -: 291: 0, /*tp_getset*/ -: 292:}; -: 293: -: 294:PyObject* function PyImaging_Mapper called 0 returned 0% blocks executed 0% #####: 295:PyImaging_Mapper(PyObject* self, PyObject* args) -: 296:{ -: 297: char* filename; #####: 298: if (!PyArg_ParseTuple(args, "s", &filename)) { call 0 never executed branch 1 never executed branch 2 never executed -: 299: return NULL; -: 300: } -: 301: #####: 302: return (PyObject*) PyImaging_MapperNew(filename, 1); call 0 never executed -: 303:} -: 304: -: 305:/* -------------------------------------------------------------------- */ -: 306:/* Buffer mapper */ -: 307: -: 308:typedef struct ImagingBufferInstance { -: 309: struct ImagingMemoryInstance im; -: 310: PyObject* target; -: 311: Py_buffer view; -: 312:} ImagingBufferInstance; -: 313: -: 314:static void function mapping_destroy_buffer called 106 returned 100% blocks executed 100% 106: 315:mapping_destroy_buffer(Imaging im) -: 316:{ 106: 317: ImagingBufferInstance* buffer = (ImagingBufferInstance*) im; -: 318: 106: 319: PyBuffer_Release(&buffer->view); call 0 returned 100% 212: 320: Py_XDECREF(buffer->target); 106: 321:} -: 322: -: 323:PyObject* function PyImaging_MapBuffer called 107 returned 100% blocks executed 77% 107: 324:PyImaging_MapBuffer(PyObject* self, PyObject* args) -: 325:{ -: 326: Py_ssize_t y, size; -: 327: Imaging im; -: 328: -: 329: PyObject* target; -: 330: Py_buffer view; -: 331: char* mode; -: 332: char* codec; -: 333: Py_ssize_t offset; -: 334: int xsize, ysize; -: 335: int stride; -: 336: int ystep; -: 337: 107: 338: if (!PyArg_ParseTuple(args, "O(ii)sn(sii)", &target, &xsize, &ysize, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 339: &codec, &offset, &mode, &stride, &ystep)) { -: 340: return NULL; -: 341: } -: 342: 107: 343: if (!PyImaging_CheckBuffer(target)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 344: PyErr_SetString(PyExc_TypeError, "expected string or buffer"); call 0 never executed #####: 345: return NULL; -: 346: } -: 347: 107: 348: if (stride <= 0) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 85: 349: if (!strcmp(mode, "L") || !strcmp(mode, "P")) { branch 0 taken 64% (fallthrough) branch 1 taken 36% branch 2 taken 36% (fallthrough) branch 3 taken 64% branch 4 taken 26% (fallthrough) branch 5 taken 74% branch 6 taken 26% (fallthrough) branch 7 taken 74% 62: 350: stride = xsize; 23: 351: } else if (!strncmp(mode, "I;16", 4)) { branch 0 taken 78% (fallthrough) branch 1 taken 22% 18: 352: stride = xsize * 2; -: 353: } else { 5: 354: stride = xsize * 4; -: 355: } -: 356: } -: 357: 107: 358: if (stride > 0 && ysize > PY_SSIZE_T_MAX / stride) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 359: PyErr_SetString(PyExc_MemoryError, "Integer overflow in ysize"); call 0 never executed #####: 360: return NULL; -: 361: } -: 362: 107: 363: size = (Py_ssize_t) ysize * stride; -: 364: 107: 365: if (offset > PY_SSIZE_T_MAX - size) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 366: PyErr_SetString(PyExc_MemoryError, "Integer overflow in offset"); call 0 never executed #####: 367: return NULL; -: 368: } -: 369: -: 370: /* check buffer size */ 107: 371: if (PyImaging_GetBuffer(target, &view) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 372: return NULL; -: 373: } -: 374: 107: 375: if (view.len < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 376: PyErr_SetString(PyExc_ValueError, "buffer has negative size"); call 0 never executed #####: 377: PyBuffer_Release(&view); call 0 never executed #####: 378: return NULL; -: 379: } 107: 380: if (offset + size > view.len) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 381: PyErr_SetString(PyExc_ValueError, "buffer is not large enough"); call 0 returned 100% 1: 382: PyBuffer_Release(&view); call 0 returned 100% 1: 383: return NULL; -: 384: } -: 385: 106: 386: im = ImagingNewPrologueSubtype( call 0 returned 100% -: 387: mode, xsize, ysize, sizeof(ImagingBufferInstance)); 106: 388: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 389: PyBuffer_Release(&view); call 0 never executed #####: 390: return NULL; -: 391: } -: 392: -: 393: /* setup file pointers */ 106: 394: if (ystep > 0) { branch 0 taken 35% (fallthrough) branch 1 taken 65% 48947: 395: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 48947: 396: im->image[y] = (char*)view.buf + offset + y * stride; -: 397: } -: 398: } else { 2157: 399: for (y = 0; y < ysize; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 2157: 400: im->image[ysize-y-1] = (char*)view.buf + offset + y * stride; -: 401: } -: 402: } -: 403: 106: 404: im->destroy = mapping_destroy_buffer; -: 405: 106: 406: Py_INCREF(target); 106: 407: ((ImagingBufferInstance*) im)->target = target; 106: 408: ((ImagingBufferInstance*) im)->view = view; -: 409: 106: 410: return PyImagingNew(im); call 0 returned 100% -: 411:} -: 412: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Offset.c.gcov -: 0:Source:src/libImaging/Offset.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Offset.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Offset.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * offset an image in x and y directions -: 6: * -: 7: * history: -: 8: * 96-07-22 fl: Created -: 9: * 98-11-01 cgw@pgt.com: Fixed negative-array index bug -: 10: * -: 11: * Copyright (c) Fredrik Lundh 1996. -: 12: * Copyright (c) Secret Labs AB 1997. -: 13: * -: 14: * See the README file for information on usage and redistribution. -: 15: */ -: 16: -: 17: -: 18:#include "Imaging.h" -: 19: -: 20: -: 21:Imaging function ImagingOffset called 5 returned 100% blocks executed 87% 5: 22:ImagingOffset(Imaging im, int xoffset, int yoffset) -: 23:{ -: 24: int x, y; -: 25: Imaging imOut; -: 26: 5: 27: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 28: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 29: } -: 30: 5: 31: imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize); call 0 returned 100% 5: 32: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 33: return NULL; -: 34: } -: 35: 5: 36: ImagingCopyPalette(imOut, im); call 0 returned 100% -: 37: -: 38: /* make offsets positive to avoid negative coordinates */ 5: 39: xoffset %= im->xsize; 5: 40: xoffset = im->xsize - xoffset; 5: 41: if (xoffset < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 42: xoffset += im->xsize; -: 43: } -: 44: 5: 45: yoffset %= im->ysize; 5: 46: yoffset = im->ysize - yoffset; 5: 47: if (yoffset < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 48: yoffset += im->ysize; -: 49: } -: 50: -: 51:#define OFFSET(image)\ -: 52: for (y = 0; y < im->ysize; y++) {\ -: 53: for (x = 0; x < im->xsize; x++) {\ -: 54: int yi = (y + yoffset) % im->ysize;\ -: 55: int xi = (x + xoffset) % im->xsize;\ -: 56: imOut->image[y][x] = im->image[yi][xi];\ -: 57: }\ -: 58: } -: 59: 5: 60: if (im->image8) { branch 0 taken 60% (fallthrough) branch 1 taken 40% 32768: 61: OFFSET(image8) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% (fallthrough) branch 3 taken 1% -: 62: } else { 30000: 63: OFFSET(image32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% (fallthrough) branch 3 taken 1% -: 64: } -: 65: -: 66: return imOut; -: 67:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#BoxBlur.c.gcov -: 0:Source:src/libImaging/BoxBlur.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/BoxBlur.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/BoxBlur.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Imaging.h" -: 2: -: 3: -: 4:#define MAX(x, y) (((x) > (y)) ? (x) : (y)) -: 5:#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -: 6: -: 7: -: 8:typedef UINT8 pixel[4]; -: 9: -: 10:void static inline function ImagingLineBoxBlur32 called 13172 returned 100% blocks executed 100% 13172: 11:ImagingLineBoxBlur32(pixel *lineOut, pixel *lineIn, int lastx, int radius, int edgeA, -: 12: int edgeB, UINT32 ww, UINT32 fw) -: 13:{ -: 14: int x; -: 15: UINT32 acc[4]; -: 16: UINT32 bulk[4]; -: 17: -: 18: #define MOVE_ACC(acc, subtract, add) \ -: 19: acc[0] += lineIn[add][0] - lineIn[subtract][0]; \ -: 20: acc[1] += lineIn[add][1] - lineIn[subtract][1]; \ -: 21: acc[2] += lineIn[add][2] - lineIn[subtract][2]; \ -: 22: acc[3] += lineIn[add][3] - lineIn[subtract][3]; -: 23: -: 24: #define ADD_FAR(bulk, acc, left, right) \ -: 25: bulk[0] = (acc[0] * ww) + (lineIn[left][0] + lineIn[right][0]) * fw; \ -: 26: bulk[1] = (acc[1] * ww) + (lineIn[left][1] + lineIn[right][1]) * fw; \ -: 27: bulk[2] = (acc[2] * ww) + (lineIn[left][2] + lineIn[right][2]) * fw; \ -: 28: bulk[3] = (acc[3] * ww) + (lineIn[left][3] + lineIn[right][3]) * fw; -: 29: -: 30: #define SAVE(x, bulk) \ -: 31: lineOut[x][0] = (UINT8)((bulk[0] + (1 << 23)) >> 24); \ -: 32: lineOut[x][1] = (UINT8)((bulk[1] + (1 << 23)) >> 24); \ -: 33: lineOut[x][2] = (UINT8)((bulk[2] + (1 << 23)) >> 24); \ -: 34: lineOut[x][3] = (UINT8)((bulk[3] + (1 << 23)) >> 24); -: 35: -: 36: /* Compute acc for -1 pixel (outside of image): -: 37: From "-radius-1" to "-1" get first pixel, -: 38: then from "0" to "radius-1". */ 13172: 39: acc[0] = lineIn[0][0] * (radius + 1); 13172: 40: acc[1] = lineIn[0][1] * (radius + 1); 13172: 41: acc[2] = lineIn[0][2] * (radius + 1); 13172: 42: acc[3] = lineIn[0][3] * (radius + 1); -: 43: /* As radius can be bigger than xsize, iterate to edgeA -1. */ 45464: 44: for (x = 0; x < edgeA - 1; x++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 32292: 45: acc[0] += lineIn[x][0]; 32292: 46: acc[1] += lineIn[x][1]; 32292: 47: acc[2] += lineIn[x][2]; 32292: 48: acc[3] += lineIn[x][3]; -: 49: } -: 50: /* Then multiply remainder to last x. */ 13172: 51: acc[0] += lineIn[lastx][0] * (radius - edgeA + 1); 13172: 52: acc[1] += lineIn[lastx][1] * (radius - edgeA + 1); 13172: 53: acc[2] += lineIn[lastx][2] * (radius - edgeA + 1); 13172: 54: acc[3] += lineIn[lastx][3] * (radius - edgeA + 1); -: 55: 13172: 56: if (edgeA <= edgeB) branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 57: { -: 58: /* Subtract pixel from left ("0"). -: 59: Add pixels from radius. */ 45276: 60: for (x = 0; x < edgeA; x++) { branch 0 taken 78% branch 1 taken 22% (fallthrough) 45276: 61: MOVE_ACC(acc, 0, x + radius); 45276: 62: ADD_FAR(bulk, acc, 0, x + radius + 1); 45276: 63: SAVE(x, bulk); -: 64: } -: 65: /* Subtract previous pixel from "-radius". -: 66: Add pixels from radius. */ 1550308: 67: for (x = edgeA; x < edgeB; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1550308: 68: MOVE_ACC(acc, x - radius - 1, x + radius); 1550308: 69: ADD_FAR(bulk, acc, x - radius - 1, x + radius + 1); 1550308: 70: SAVE(x, bulk); -: 71: } -: 72: /* Subtract previous pixel from "-radius". -: 73: Add last pixel. */ 45276: 74: for (x = edgeB; x <= lastx; x++) { branch 0 taken 78% branch 1 taken 22% 45276: 75: MOVE_ACC(acc, x - radius - 1, lastx); 45276: 76: ADD_FAR(bulk, acc, x - radius - 1, lastx); 45276: 77: SAVE(x, bulk); -: 78: } -: 79: } -: 80: else -: 81: { 22: 82: for (x = 0; x < edgeB; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 83: MOVE_ACC(acc, 0, x + radius); 22: 84: ADD_FAR(bulk, acc, 0, x + radius + 1); 22: 85: SAVE(x, bulk); -: 86: } 166: 87: for (x = edgeB; x < edgeA; x++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 166: 88: MOVE_ACC(acc, 0, lastx); 166: 89: ADD_FAR(bulk, acc, 0, lastx); 166: 90: SAVE(x, bulk); -: 91: } 22: 92: for (x = edgeA; x <= lastx; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 93: MOVE_ACC(acc, x - radius - 1, lastx); 22: 94: ADD_FAR(bulk, acc, x - radius - 1, lastx); 22: 95: SAVE(x, bulk); -: 96: } -: 97: } -: 98: -: 99: #undef MOVE_ACC -: 100: #undef ADD_FAR -: 101: #undef SAVE 13172: 102:} -: 103: -: 104: -: 105:void static inline function ImagingLineBoxBlur8 called 21832 returned 100% blocks executed 100% 21832: 106:ImagingLineBoxBlur8(UINT8 *lineOut, UINT8 *lineIn, int lastx, int radius, int edgeA, -: 107: int edgeB, UINT32 ww, UINT32 fw) -: 108:{ -: 109: int x; -: 110: UINT32 acc; -: 111: UINT32 bulk; -: 112: -: 113: #define MOVE_ACC(acc, subtract, add) \ -: 114: acc += lineIn[add] - lineIn[subtract]; -: 115: -: 116: #define ADD_FAR(bulk, acc, left, right) \ -: 117: bulk = (acc * ww) + (lineIn[left] + lineIn[right]) * fw; -: 118: -: 119: #define SAVE(x, bulk) \ -: 120: lineOut[x] = (UINT8)((bulk + (1 << 23)) >> 24) -: 121: 21832: 122: acc = lineIn[0] * (radius + 1); 88256: 123: for (x = 0; x < edgeA - 1; x++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 66424: 124: acc += lineIn[x]; -: 125: } 21832: 126: acc += lineIn[lastx] * (radius - edgeA + 1); -: 127: 21832: 128: if (edgeA <= edgeB) branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 129: { 88068: 130: for (x = 0; x < edgeA; x++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 88068: 131: MOVE_ACC(acc, 0, x + radius); 88068: 132: ADD_FAR(bulk, acc, 0, x + radius + 1); 88068: 133: SAVE(x, bulk); -: 134: } 50738380: 135: for (x = edgeA; x < edgeB; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 50738380: 136: MOVE_ACC(acc, x - radius - 1, x + radius); 50738380: 137: ADD_FAR(bulk, acc, x - radius - 1, x + radius + 1); 50738380: 138: SAVE(x, bulk); -: 139: } 88068: 140: for (x = edgeB; x <= lastx; x++) { branch 0 taken 80% branch 1 taken 20% 88068: 141: MOVE_ACC(acc, x - radius - 1, lastx); 88068: 142: ADD_FAR(bulk, acc, x - radius - 1, lastx); 88068: 143: SAVE(x, bulk); -: 144: } -: 145: } -: 146: else -: 147: { 22: 148: for (x = 0; x < edgeB; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 149: MOVE_ACC(acc, 0, x + radius); 22: 150: ADD_FAR(bulk, acc, 0, x + radius + 1); 22: 151: SAVE(x, bulk); -: 152: } 166: 153: for (x = edgeB; x < edgeA; x++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 166: 154: MOVE_ACC(acc, 0, lastx); 166: 155: ADD_FAR(bulk, acc, 0, lastx); 166: 156: SAVE(x, bulk); -: 157: } 22: 158: for (x = edgeA; x <= lastx; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 159: MOVE_ACC(acc, x - radius - 1, lastx); 22: 160: ADD_FAR(bulk, acc, x - radius - 1, lastx); 22: 161: SAVE(x, bulk); -: 162: } -: 163: } -: 164: -: 165: #undef MOVE_ACC -: 166: #undef ADD_FAR -: 167: #undef SAVE 21832: 168:} -: 169: -: 170: -: 171: -: 172:Imaging function ImagingHorizontalBoxBlur called 226 returned 100% blocks executed 96% 226: 173:ImagingHorizontalBoxBlur(Imaging imOut, Imaging imIn, float floatRadius) -: 174:{ -: 175: ImagingSectionCookie cookie; -: 176: -: 177: int y; -: 178: 226: 179: int radius = (int) floatRadius; 226: 180: UINT32 ww = (UINT32) (1 << 24) / (floatRadius * 2 + 1); 226: 181: UINT32 fw = ((1 << 24) - (radius * 2 + 1) * ww) / 2; -: 182: 226: 183: int edgeA = MIN(radius + 1, imIn->xsize); 226: 184: int edgeB = MAX(imIn->xsize - radius - 1, 0); -: 185: 226: 186: UINT32 *lineOut = calloc(imIn->xsize, sizeof(UINT32)); 226: 187: if (lineOut == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 188: return ImagingError_MemoryError(); call 0 never executed -: 189: } -: 190: -: 191: // printf(">>> %d %d %d\n", radius, ww, fw); -: 192: 226: 193: ImagingSectionEnter(&cookie); call 0 returned 100% -: 194: 226: 195: if (imIn->image8) branch 0 taken 68% (fallthrough) branch 1 taken 32% -: 196: { 21832: 197: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% 47798: 198: ImagingLineBoxBlur8( branch 0 taken 19% (fallthrough) branch 1 taken 81% call 2 returned 100% 4134: 199: (imIn == imOut ? (UINT8 *) lineOut : imOut->image8[y]), 21832: 200: imIn->image8[y], 21832: 201: imIn->xsize - 1, -: 202: radius, edgeA, edgeB, -: 203: ww, fw -: 204: ); 21832: 205: if (imIn == imOut) { branch 0 taken 81% (fallthrough) branch 1 taken 19% -: 206: // Commit. 17698: 207: memcpy(imOut->image8[y], lineOut, imIn->xsize); -: 208: } -: 209: } -: 210: } -: 211: else -: 212: { 13172: 213: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 28758: 214: ImagingLineBoxBlur32( branch 0 taken 18% (fallthrough) branch 1 taken 82% call 2 returned 100% 2414: 215: imIn == imOut ? (pixel *) lineOut : (pixel *) imOut->image32[y], 13172: 216: (pixel *) imIn->image32[y], 13172: 217: imIn->xsize - 1, -: 218: radius, edgeA, edgeB, -: 219: ww, fw -: 220: ); 13172: 221: if (imIn == imOut) { branch 0 taken 82% (fallthrough) branch 1 taken 18% -: 222: // Commit. 10758: 223: memcpy(imOut->image32[y], lineOut, imIn->xsize * 4); -: 224: } -: 225: } -: 226: } -: 227: 226: 228: ImagingSectionLeave(&cookie); call 0 returned 100% -: 229: 226: 230: free(lineOut); -: 231: 226: 232: return imOut; -: 233:} -: 234: -: 235: -: 236:Imaging function ImagingBoxBlur called 72 returned 100% blocks executed 96% 72: 237:ImagingBoxBlur(Imaging imOut, Imaging imIn, float radius, int n) -: 238:{ -: 239: int i; -: 240: Imaging imTransposed; -: 241: 72: 242: if (n < 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 243: return ImagingError_ValueError( call 0 never executed -: 244: "number of passes must be greater than zero" -: 245: ); -: 246: } -: 247: 144: 248: if (strcmp(imIn->mode, imOut->mode) || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 72: 249: imIn->type != imOut->type || 72: 250: imIn->bands != imOut->bands || branch 0 taken 100% (fallthrough) branch 1 taken 0% 72: 251: imIn->xsize != imOut->xsize || branch 0 taken 0% (fallthrough) branch 1 taken 100% 72: 252: imIn->ysize != imOut->ysize) { #####: 253: return ImagingError_Mismatch(); call 0 never executed -: 254: } -: 255: 72: 256: if (imIn->type != IMAGING_TYPE_UINT8) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 6: 257: return ImagingError_ModeError(); call 0 returned 100% -: 258: } -: 259: 129: 260: if (!(strcmp(imIn->mode, "RGB") == 0 || branch 0 taken 42% (fallthrough) branch 1 taken 58% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 83% (fallthrough) branch 7 taken 17% branch 8 taken 71% (fallthrough) branch 9 taken 29% branch 10 taken 88% (fallthrough) branch 11 taken 13% 94: 261: strcmp(imIn->mode, "RGBA") == 0 || branch 0 taken 97% (fallthrough) branch 1 taken 3% 77: 262: strcmp(imIn->mode, "RGBa") == 0 || branch 0 taken 100% (fallthrough) branch 1 taken 0% 76: 263: strcmp(imIn->mode, "RGBX") == 0 || branch 0 taken 79% (fallthrough) branch 1 taken 21% 68: 264: strcmp(imIn->mode, "CMYK") == 0 || branch 0 taken 30% (fallthrough) branch 1 taken 70% 39: 265: strcmp(imIn->mode, "L") == 0 || branch 0 taken 77% (fallthrough) branch 1 taken 23% branch 2 taken 89% (fallthrough) branch 3 taken 11% 9: 266: strcmp(imIn->mode, "LA") == 0 || branch 0 taken 22% (fallthrough) branch 1 taken 78% branch 2 taken 50% (fallthrough) branch 3 taken 50% 8: 267: strcmp(imIn->mode, "La") == 0)) { branch 0 taken 13% (fallthrough) branch 1 taken 88% branch 2 taken 100% (fallthrough) branch 3 taken 0% 7: 268: return ImagingError_ModeError(); call 0 returned 100% -: 269: } -: 270: 59: 271: imTransposed = ImagingNewDirty(imIn->mode, imIn->ysize, imIn->xsize); call 0 returned 100% 59: 272: if (!imTransposed) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 273: return NULL; -: 274: } -: 275: -: 276: /* Apply blur in one dimension. -: 277: Use imOut as a destination at first pass, -: 278: then use imOut as a source too. */ 59: 279: ImagingHorizontalBoxBlur(imOut, imIn, radius); 113: 280: for (i = 1; i < n; i ++) { call 0 returned 100% branch 1 taken 48% branch 2 taken 52% (fallthrough) 54: 281: ImagingHorizontalBoxBlur(imOut, imOut, radius); call 0 returned 100% -: 282: } -: 283: /* Transpose result for blur in another direction. */ 59: 284: ImagingTranspose(imTransposed, imOut); -: 285: -: 286: /* Reuse imTransposed as a source and destination there. */ 172: 287: for (i = 0; i < n; i ++) { call 0 returned 100% branch 1 taken 66% branch 2 taken 34% (fallthrough) 113: 288: ImagingHorizontalBoxBlur(imTransposed, imTransposed, radius); call 0 returned 100% -: 289: } -: 290: /* Restore original orientation. */ 59: 291: ImagingTranspose(imOut, imTransposed); call 0 returned 100% -: 292: 59: 293: ImagingDelete(imTransposed); call 0 returned 100% -: 294: 59: 295: return imOut; -: 296:} -: 297: -: 298: function ImagingGaussianBlur called 32 returned 100% blocks executed 100% 32: 299:Imaging ImagingGaussianBlur(Imaging imOut, Imaging imIn, float radius, -: 300: int passes) -: 301:{ -: 302: float sigma2, L, l, a; -: 303: 32: 304: sigma2 = radius * radius / passes; -: 305: // from http://www.mia.uni-saarland.de/Publications/gwosdek-ssvm11.pdf -: 306: // [7] Box length. 32: 307: L = sqrt(12.0 * sigma2 + 1.0); -: 308: // [11] Integer part of box radius. 32: 309: l = floor((L - 1.0) / 2.0); -: 310: // [14], [Fig. 2] Fractional part of box radius. 32: 311: a = (2 * l + 1) * (l * (l + 1) - 3 * sigma2); 32: 312: a /= 6 * (sigma2 - (l + 1) * (l + 1)); -: 313: 32: 314: return ImagingBoxBlur(imOut, imIn, l + a, passes); call 0 returned 100% -: 315:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ZipDecode.c.gcov -: 0:Source:src/libImaging/ZipDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/ZipDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/ZipDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for ZIP (deflated) image data. -: 6: * -: 7: * history: -: 8: * 1996-12-14 fl Created (for PNG) -: 9: * 1997-01-15 fl Prepared to read TIFF/ZIP -: 10: * 2001-11-19 fl PNG incomplete read patch (from Bernhard Herzog) -: 11: * -: 12: * Copyright (c) Fredrik Lundh 1996. -: 13: * Copyright (c) Secret Labs AB 1997-2001. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21:#ifdef HAVE_LIBZ -: 22: -: 23:#include "ZipCodecs.h" -: 24: -: 25:static const int OFFSET[] = { 7, 3, 3, 1, 1, 0, 0 }; -: 26:static const int STARTING_COL[] = { 0, 4, 0, 2, 0, 1, 0 }; -: 27:static const int STARTING_ROW[] = { 0, 0, 4, 0, 2, 0, 1 }; -: 28:static const int COL_INCREMENT[] = { 8, 8, 4, 4, 2, 2, 1 }; -: 29:static const int ROW_INCREMENT[] = { 8, 8, 8, 4, 4, 2, 2 }; -: 30: -: 31:/* Get the length in bytes of a scanline in the pass specified, -: 32: * for interlaced images */ -: 33:static int get_row_len(ImagingCodecState state, int pass) -: 34:{ 140: 35: int row_len = (state->xsize + OFFSET[pass]) / COL_INCREMENT[pass]; 140: 36: return ((row_len * state->bits) + 7) / 8; -: 37:} -: 38: -: 39:/* -------------------------------------------------------------------- */ -: 40:/* Decoder */ -: 41:/* -------------------------------------------------------------------- */ -: 42: -: 43:int function ImagingZipDecode called 1623 returned 100% blocks executed 80% 1623: 44:ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 45:{ 1623: 46: ZIPSTATE* context = (ZIPSTATE*) state->context; -: 47: int err; -: 48: int n; -: 49: UINT8* ptr; -: 50: int i, bpp; -: 51: int row_len; -: 52: 1623: 53: if (!state->state) { branch 0 taken 65% (fallthrough) branch 1 taken 35% -: 54: -: 55: /* Initialization */ 1059: 56: if (context->mode == ZIP_PNG || context->mode == ZIP_PNG_PALETTE) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1059: 57: context->prefix = 1; /* PNG */ -: 58: } -: 59: -: 60: /* overflow check for malloc */ 1059: 61: if (state->bytes > INT_MAX - 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 62: state->errcode = IMAGING_CODEC_MEMORY; #####: 63: return -1; -: 64: } -: 65: /* Expand standard buffer to make room for the (optional) filter -: 66: prefix, and allocate a buffer to hold the previous line */ 1059: 67: free(state->buffer); -: 68: /* malloc check ok, overflow checked above */ 1059: 69: state->buffer = (UINT8*) malloc(state->bytes+1); 1059: 70: context->previous = (UINT8*) malloc(state->bytes+1); 1059: 71: if (!state->buffer || !context->previous) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 72: state->errcode = IMAGING_CODEC_MEMORY; #####: 73: return -1; -: 74: } -: 75: 1059: 76: context->last_output = 0; -: 77: -: 78: /* Initialize to black */ 2118: 79: memset(context->previous, 0, state->bytes+1); -: 80: -: 81: /* Setup decompression context */ 1059: 82: context->z_stream.zalloc = (alloc_func) NULL; 1059: 83: context->z_stream.zfree = (free_func) NULL; 1059: 84: context->z_stream.opaque = (voidpf) NULL; -: 85: 1059: 86: err = inflateInit(&context->z_stream); call 0 returned 100% 1059: 87: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 88: state->errcode = IMAGING_CODEC_CONFIG; #####: 89: free(context->previous); #####: 90: context->previous = NULL; #####: 91: return -1; -: 92: } -: 93: 1059: 94: if (context->interlaced) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 17: 95: context->pass = 0; 17: 96: state->y = STARTING_ROW[context->pass]; -: 97: } -: 98: -: 99: /* Ready to decode */ 1059: 100: state->state = 1; -: 101: -: 102: } -: 103: 1623: 104: if (context->interlaced) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 76: 105: row_len = get_row_len(state, context->pass); -: 106: } else { 1585: 107: row_len = state->bytes; -: 108: } -: 109: -: 110: /* Setup the source buffer */ 1623: 111: context->z_stream.next_in = buf; 1623: 112: context->z_stream.avail_in = bytes; -: 113: -: 114: /* Decompress what we've got this far */ 190425: 115: while (context->z_stream.avail_in > 0) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 116: 188788: 117: context->z_stream.next_out = state->buffer + context->last_output; 188788: 118: context->z_stream.avail_out = 188788: 119: row_len + context->prefix - context->last_output; -: 120: 188788: 121: err = inflate(&context->z_stream, Z_NO_FLUSH); call 0 returned 100% -: 122: 188788: 123: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 124: /* Something went wrong inside the compression library */ #####: 125: if (err == Z_DATA_ERROR) { branch 0 never executed branch 1 never executed #####: 126: state->errcode = IMAGING_CODEC_BROKEN; #####: 127: } else if (err == Z_MEM_ERROR) { branch 0 never executed branch 1 never executed #####: 128: state->errcode = IMAGING_CODEC_MEMORY; -: 129: } else { #####: 130: state->errcode = IMAGING_CODEC_CONFIG; -: 131: } #####: 132: free(context->previous); #####: 133: context->previous = NULL; #####: 134: inflateEnd(&context->z_stream); call 0 never executed #####: 135: return -1; -: 136: } -: 137: 188788: 138: n = row_len + context->prefix - context->z_stream.avail_out; -: 139: 188788: 140: if (n < row_len + context->prefix) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 656: 141: context->last_output = n; 656: 142: break; /* need more input data */ -: 143: } -: 144: -: 145: /* Apply predictor */ 188132: 146: switch (context->mode) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% -: 147: case ZIP_PNG: 188132: 148: switch (state->buffer[0]) { branch 0 taken 41% branch 1 taken 5% branch 2 taken 1% branch 3 taken 16% branch 4 taken 1% branch 5 taken 36% -: 149: case 0: -: 150: break; -: 151: case 1: -: 152: /* prior */ 8824: 153: bpp = (state->bits + 7) / 8; 11854902: 154: for (i = bpp+1; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% 11846078: 155: state->buffer[i] += state->buffer[i-bpp]; -: 156: } -: 157: break; -: 158: case 2: -: 159: /* up */ 239676473: 160: for (i = 1; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% 239676473: 161: state->buffer[i] += context->previous[i]; -: 162: } -: 163: break; -: 164: case 3: -: 165: /* average */ 2757: 166: bpp = (state->bits + 7) / 8; 11312: 167: for (i = 1; i <= bpp; i++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 8555: 168: state->buffer[i] += context->previous[i]/2; -: 169: } 2771301: 170: for (; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% 5542602: 171: state->buffer[i] += 2771301: 172: (state->buffer[i-bpp] + context->previous[i])/2; -: 173: } -: 174: break; -: 175: case 4: -: 176: /* paeth filtering */ 30671: 177: bpp = (state->bits + 7) / 8; 118332: 178: for (i = 1; i <= bpp; i++) { branch 0 taken 74% branch 1 taken 26% (fallthrough) 87661: 179: state->buffer[i] += context->previous[i]; -: 180: } 73559410: 181: for (; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% -: 182: int a, b, c; -: 183: int pa, pb, pc; -: 184: -: 185: /* fetch pixels */ 73559410: 186: a = state->buffer[i-bpp]; 73559410: 187: b = context->previous[i]; 73559410: 188: c = context->previous[i-bpp]; -: 189: -: 190: /* distances to surrounding pixels */ 73559410: 191: pa = abs(b - c); 73559410: 192: pb = abs(a - c); 73559410: 193: pc = abs(a + b - 2*c); -: 194: -: 195: /* pick predictor with the shortest distance */ 147118820: 196: state->buffer[i] += branch 0 taken 28% (fallthrough) branch 1 taken 72% branch 2 taken 80% (fallthrough) branch 3 taken 20% 73559410: 197: (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; -: 198: -: 199: } -: 200: break; -: 201: default: 3: 202: state->errcode = IMAGING_CODEC_UNKNOWN; 3: 203: free(context->previous); 3: 204: context->previous = NULL; 3: 205: inflateEnd(&context->z_stream); call 0 returned 100% 3: 206: return -1; -: 207: } -: 208: break; -: 209: case ZIP_TIFF_PREDICTOR: #####: 210: bpp = (state->bits + 7) / 8; #####: 211: for (i = bpp+1; i <= row_len; i++) { branch 0 never executed branch 1 never executed #####: 212: state->buffer[i] += state->buffer[i-bpp]; -: 213: } -: 214: break; -: 215: } -: 216: -: 217: /* Stuff data into the image */ 188129: 218: if (context->interlaced) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 4794: 219: int col = STARTING_COL[context->pass]; 4794: 220: if (state->bits >= 8) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 221: /* Stuff pixels in their correct location, one by one */ 413100: 222: for (i = 0; i < row_len; i += ((state->bits + 7) / 8)) { branch 0 taken 99% branch 1 taken 1% 1239300: 223: state->shuffle((UINT8*) im->image[state->y] + call 0 returned 100% 413100: 224: col * im->pixelsize, 413100: 225: state->buffer + context->prefix + i, 1); 413100: 226: col += COL_INCREMENT[context->pass]; -: 227: } -: 228: } else { -: 229: /* Handle case with more than a pixel in each byte */ #####: 230: int row_bits = ((state->xsize + OFFSET[context->pass]) #####: 231: / COL_INCREMENT[context->pass]) * state->bits; #####: 232: for (i = 0; i < row_bits; i += state->bits) { branch 0 never executed branch 1 never executed #####: 233: UINT8 byte = *(state->buffer + context->prefix + (i / 8)); #####: 234: byte <<= (i % 8); #####: 235: state->shuffle((UINT8*) im->image[state->y] + call 0 never executed #####: 236: col * im->pixelsize, &byte, 1); #####: 237: col += COL_INCREMENT[context->pass]; -: 238: } -: 239: } -: 240: /* Find next valid scanline */ 4794: 241: state->y += ROW_INCREMENT[context->pass]; 9690: 242: while (state->y >= state->ysize || row_len <= 0) { branch 0 taken 2% branch 1 taken 98% (fallthrough) branch 2 taken 0% branch 3 taken 100% 119: 243: context->pass++; 119: 244: if (context->pass == 7) { branch 0 taken 14% (fallthrough) branch 1 taken 86% -: 245: /* Force exit below */ 17: 246: state->y = state->ysize; 17: 247: break; -: 248: } 102: 249: state->y = STARTING_ROW[context->pass]; 204: 250: row_len = get_row_len(state, context->pass); -: 251: /* Since we're moving to the "first" line, the previous line -: 252: * should be black to make filters work correctly */ 102: 253: memset(state->buffer, 0, state->bytes+1); -: 254: } -: 255: } else { 550005: 256: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 183335: 257: state->xoff * im->pixelsize, 183335: 258: state->buffer + context->prefix, -: 259: state->xsize); 183335: 260: state->y++; -: 261: } -: 262: -: 263: /* all inflate output has been consumed */ 188129: 264: context->last_output = 0; -: 265: 188129: 266: if (state->y >= state->ysize || err == Z_STREAM_END) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 267: -: 268: /* The image and the data should end simultaneously */ -: 269: /* if (state->y < state->ysize || err != Z_STREAM_END) -: 270: state->errcode = IMAGING_CODEC_BROKEN; */ -: 271: 950: 272: free(context->previous); 950: 273: context->previous = NULL; 950: 274: inflateEnd(&context->z_stream); call 0 returned 100% 950: 275: return -1; /* end of file (errcode=0) */ -: 276: -: 277: } -: 278: -: 279: /* Swap buffer pointers */ 187179: 280: ptr = state->buffer; 187179: 281: state->buffer = context->previous; 187179: 282: context->previous = ptr; -: 283: -: 284: } -: 285: 670: 286: return bytes; /* consumed all of it */ -: 287: -: 288:} -: 289: -: 290: function ImagingZipDecodeCleanup called 2120 returned 100% blocks executed 100% 2120: 291:int ImagingZipDecodeCleanup(ImagingCodecState state){ -: 292: /* called to free the decompression engine when the decode terminates -: 293: due to a corrupt or truncated image -: 294: */ 2120: 295: ZIPSTATE* context = (ZIPSTATE*) state->context; -: 296: -: 297: /* Clean up */ 2120: 298: if (context->previous) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 106: 299: inflateEnd(&context->z_stream); call 0 returned 100% 106: 300: free(context->previous); 106: 301: context->previous = NULL; -: 302: } 2120: 303: return -1; -: 304:} -: 305: -: 306:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#_imagingmath.c.gcov -: 0:Source:src/_imagingmath.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/_imagingmath.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/_imagingmath.gcda -: 0:Runs:2 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * -: 4: * a simple math add-on for the Python Imaging Library -: 5: * -: 6: * history: -: 7: * 1999-02-15 fl Created -: 8: * 2005-05-05 fl Simplified and cleaned up for PIL 1.1.6 -: 9: * -: 10: * Copyright (c) 1999-2005 by Secret Labs AB -: 11: * Copyright (c) 2005 by Fredrik Lundh -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16:#include "Python.h" -: 17: -: 18:#include "libImaging/Imaging.h" -: 19: -: 20:#include "math.h" -: 21:#include "float.h" -: 22: -: 23:#define MAX_INT32 2147483647.0 -: 24:#define MIN_INT32 -2147483648.0 -: 25: -: 26:#define UNOP(name, op, type)\ -: 27:void name(Imaging out, Imaging im1)\ -: 28:{\ -: 29: int x, y;\ -: 30: for (y = 0; y < out->ysize; y++) {\ -: 31: type* p0 = (type*) out->image[y];\ -: 32: type* p1 = (type*) im1->image[y];\ -: 33: for (x = 0; x < out->xsize; x++) {\ -: 34: *p0 = op(type, *p1);\ -: 35: p0++; p1++;\ -: 36: }\ -: 37: }\ -: 38:} -: 39: -: 40:#define BINOP(name, op, type)\ -: 41:void name(Imaging out, Imaging im1, Imaging im2)\ -: 42:{\ -: 43: int x, y;\ -: 44: for (y = 0; y < out->ysize; y++) {\ -: 45: type* p0 = (type*) out->image[y];\ -: 46: type* p1 = (type*) im1->image[y];\ -: 47: type* p2 = (type*) im2->image[y];\ -: 48: for (x = 0; x < out->xsize; x++) {\ -: 49: *p0 = op(type, *p1, *p2);\ -: 50: p0++; p1++; p2++;\ -: 51: }\ -: 52: }\ -: 53:} -: 54: -: 55:#define NEG(type, v1) -(v1) -: 56:#define INVERT(type, v1) ~(v1) -: 57: -: 58:#define ADD(type, v1, v2) (v1)+(v2) -: 59:#define SUB(type, v1, v2) (v1)-(v2) -: 60:#define MUL(type, v1, v2) (v1)*(v2) -: 61: -: 62:#define MIN(type, v1, v2) ((v1)<(v2))?(v1):(v2) -: 63:#define MAX(type, v1, v2) ((v1)>(v2))?(v1):(v2) -: 64: -: 65:#define AND(type, v1, v2) (v1)&(v2) -: 66:#define OR(type, v1, v2) (v1)|(v2) -: 67:#define XOR(type, v1, v2) (v1)^(v2) -: 68:#define LSHIFT(type, v1, v2) (v1)<<(v2) -: 69:#define RSHIFT(type, v1, v2) (v1)>>(v2) -: 70: -: 71:#define ABS_I(type, v1) abs((v1)) -: 72:#define ABS_F(type, v1) fabs((v1)) -: 73: -: 74:/* -------------------------------------------------------------------- -: 75: * some day, we should add FPE protection mechanisms. see pyfpe.h for -: 76: * details. -: 77: * -: 78: * PyFPE_START_PROTECT("Error in foobar", return 0) -: 79: * PyFPE_END_PROTECT(result) -: 80: */ -: 81: -: 82:#define DIV_I(type, v1, v2) ((v2)!=0)?(v1)/(v2):0 -: 83:#define DIV_F(type, v1, v2) ((v2)!=0.0F)?(v1)/(v2):0.0F -: 84: -: 85:#define MOD_I(type, v1, v2) ((v2)!=0)?(v1)%(v2):0 -: 86:#define MOD_F(type, v1, v2) ((v2)!=0.0F)?fmod((v1),(v2)):0.0F -: 87: function powi called 2 returned 100% blocks executed 100% 2: 88:static int powi(int x, int y) -: 89:{ 2: 90: double v = pow(x, y) + 0.5; 2: 91: if (errno == EDOM) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 92: return 0; -: 93: } 2: 94: if (v < MIN_INT32) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 95: v = MIN_INT32; 2: 96: } else if (v > MAX_INT32) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1: 97: v = MAX_INT32; -: 98: } 2: 99: return (int) v; -: 100:} -: 101: -: 102:#define POW_I(type, v1, v2) powi(v1, v2) -: 103:#define POW_F(type, v1, v2) powf(v1, v2) /* FIXME: EDOM handling */ -: 104: -: 105:#define DIFF_I(type, v1, v2) abs((v1)-(v2)) -: 106:#define DIFF_F(type, v1, v2) fabs((v1)-(v2)) -: 107: -: 108:#define EQ(type, v1, v2) (v1)==(v2) -: 109:#define NE(type, v1, v2) (v1)!=(v2) -: 110:#define LT(type, v1, v2) (v1)<(v2) -: 111:#define LE(type, v1, v2) (v1)<=(v2) -: 112:#define GT(type, v1, v2) (v1)>(v2) -: 113:#define GE(type, v1, v2) (v1)>=(v2) -: 114: function abs_I called 1732 returned 100% blocks executed 100% 1732: 115:UNOP(abs_I, ABS_I, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function neg_I called 1 returned 100% blocks executed 100% 1: 116:UNOP(neg_I, NEG, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 117: function add_I called 9 returned 100% blocks executed 100% 9: 118:BINOP(add_I, ADD, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 94% branch 3 taken 6% (fallthrough) function sub_I called 1731 returned 100% blocks executed 100% 1731: 119:BINOP(sub_I, SUB, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function mul_I called 1 returned 100% blocks executed 100% 1: 120:BINOP(mul_I, MUL, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function div_I called 1 returned 100% blocks executed 100% 1: 121:BINOP(div_I, DIV_I, INT32) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) function mod_I called 6 returned 100% blocks executed 100% 6: 122:BINOP(mod_I, MOD_I, INT32) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) function pow_I called 2 returned 100% blocks executed 100% 2: 123:BINOP(pow_I, POW_I, INT32) call 0 returned 100% branch 1 taken 50% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 50% (fallthrough) function diff_I called 0 returned 0% blocks executed 0% #####: 124:BINOP(diff_I, DIFF_I, INT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 125: function invert_I called 3 returned 100% blocks executed 100% 3: 126:UNOP(invert_I, INVERT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function and_I called 4 returned 100% blocks executed 100% 4: 127:BINOP(and_I, AND, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function or_I called 4 returned 100% blocks executed 100% 4: 128:BINOP(or_I, OR, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function xor_I called 4 returned 100% blocks executed 100% 4: 129:BINOP(xor_I, XOR, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function lshift_I called 4 returned 100% blocks executed 100% 4: 130:BINOP(lshift_I, LSHIFT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function rshift_I called 4 returned 100% blocks executed 100% 4: 131:BINOP(rshift_I, RSHIFT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 132: function min_I called 1 returned 100% blocks executed 100% 1: 133:BINOP(min_I, MIN, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function max_I called 1 returned 100% blocks executed 100% 1: 134:BINOP(max_I, MAX, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 135: function eq_I called 12 returned 100% blocks executed 100% 12: 136:BINOP(eq_I, EQ, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function ne_I called 10 returned 100% blocks executed 100% 10: 137:BINOP(ne_I, NE, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function lt_I called 4 returned 100% blocks executed 100% 4: 138:BINOP(lt_I, LT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function le_I called 4 returned 100% blocks executed 100% 4: 139:BINOP(le_I, LE, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function gt_I called 4 returned 100% blocks executed 100% 4: 140:BINOP(gt_I, GT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function ge_I called 4 returned 100% blocks executed 100% 4: 141:BINOP(ge_I, GE, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 142: function abs_F called 19 returned 100% blocks executed 100% 19: 143:UNOP(abs_F, ABS_F, FLOAT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function neg_F called 0 returned 0% blocks executed 0% #####: 144:UNOP(neg_F, NEG, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 145: function add_F called 3 returned 100% blocks executed 100% 3: 146:BINOP(add_F, ADD, FLOAT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function sub_F called 20 returned 100% blocks executed 100% 20: 147:BINOP(sub_F, SUB, FLOAT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function mul_F called 1 returned 100% blocks executed 100% 1: 148:BINOP(mul_F, MUL, FLOAT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function div_F called 1 returned 100% blocks executed 100% 1: 149:BINOP(div_F, DIV_F, FLOAT32) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) function mod_F called 0 returned 0% blocks executed 0% #####: 150:BINOP(mod_F, MOD_F, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function pow_F called 2 returned 100% blocks executed 100% 2: 151:BINOP(pow_F, POW_F, FLOAT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function diff_F called 0 returned 0% blocks executed 0% #####: 152:BINOP(diff_F, DIFF_F, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 153: function min_F called 0 returned 0% blocks executed 0% #####: 154:BINOP(min_F, MIN, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function max_F called 0 returned 0% blocks executed 0% #####: 155:BINOP(max_F, MAX, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed -: 156: function eq_F called 0 returned 0% blocks executed 0% #####: 157:BINOP(eq_F, EQ, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function ne_F called 0 returned 0% blocks executed 0% #####: 158:BINOP(ne_F, NE, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function lt_F called 0 returned 0% blocks executed 0% #####: 159:BINOP(lt_F, LT, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function le_F called 0 returned 0% blocks executed 0% #####: 160:BINOP(le_F, LE, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function gt_F called 0 returned 0% blocks executed 0% #####: 161:BINOP(gt_F, GT, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function ge_F called 0 returned 0% blocks executed 0% #####: 162:BINOP(ge_F, GE, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed -: 163: -: 164:static PyObject * function _unop called 1755 returned 100% blocks executed 100% 1755: 165:_unop(PyObject* self, PyObject* args) -: 166:{ -: 167: Imaging out; -: 168: Imaging im1; -: 169: void (*unop)(Imaging, Imaging); -: 170: -: 171: Py_ssize_t op, i0, i1; 1755: 172: if (!PyArg_ParseTuple(args, "nnn", &op, &i0, &i1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 173: return NULL; -: 174: } -: 175: 1755: 176: out = (Imaging) i0; 1755: 177: im1 = (Imaging) i1; -: 178: 1755: 179: unop = (void*) op; -: 180: 1755: 181: unop(out, im1); call 0 returned 100% -: 182: 1755: 183: Py_INCREF(Py_None); 1755: 184: return Py_None; -: 185:} -: 186: -: 187:static PyObject * function _binop called 1837 returned 100% blocks executed 100% 1837: 188:_binop(PyObject* self, PyObject* args) -: 189:{ -: 190: Imaging out; -: 191: Imaging im1; -: 192: Imaging im2; -: 193: void (*binop)(Imaging, Imaging, Imaging); -: 194: -: 195: Py_ssize_t op, i0, i1, i2; 1837: 196: if (!PyArg_ParseTuple(args, "nnnn", &op, &i0, &i1, &i2)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 197: return NULL; -: 198: } -: 199: 1837: 200: out = (Imaging) i0; 1837: 201: im1 = (Imaging) i1; 1837: 202: im2 = (Imaging) i2; -: 203: 1837: 204: binop = (void*) op; -: 205: 1837: 206: binop(out, im1, im2); call 0 returned 100% -: 207: 1837: 208: Py_INCREF(Py_None); 1837: 209: return Py_None; -: 210:} -: 211: -: 212:static PyMethodDef _functions[] = { -: 213: {"unop", _unop, 1}, -: 214: {"binop", _binop, 1}, -: 215: {NULL, NULL} -: 216:}; -: 217: -: 218:static void function install called 80 returned 100% blocks executed 78% 80: 219:install(PyObject *d, char* name, void* value) -: 220:{ 80: 221: PyObject *v = PyLong_FromSsize_t((Py_ssize_t) value); call 0 returned 100% 80: 222: if (!v || PyDict_SetItemString(d, name, v)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 returned 100% branch 3 taken 0% (fallthrough) branch 4 taken 100% #####: 223: PyErr_Clear(); call 0 never executed -: 224: } 80: 225: Py_XDECREF(v); 80: 226:} -: 227: -: 228:static int function setup_module called 2 returned 100% blocks executed 100% 2: 229:setup_module(PyObject* m) { 2: 230: PyObject* d = PyModule_GetDict(m); call 0 returned 100% -: 231: 2: 232: install(d, "abs_I", abs_I); call 0 returned 100% 2: 233: install(d, "neg_I", neg_I); call 0 returned 100% 2: 234: install(d, "add_I", add_I); call 0 returned 100% 2: 235: install(d, "sub_I", sub_I); call 0 returned 100% 2: 236: install(d, "diff_I", diff_I); call 0 returned 100% 2: 237: install(d, "mul_I", mul_I); call 0 returned 100% 2: 238: install(d, "div_I", div_I); call 0 returned 100% 2: 239: install(d, "mod_I", mod_I); call 0 returned 100% 2: 240: install(d, "min_I", min_I); call 0 returned 100% 2: 241: install(d, "max_I", max_I); call 0 returned 100% 2: 242: install(d, "pow_I", pow_I); call 0 returned 100% -: 243: 2: 244: install(d, "invert_I", invert_I); call 0 returned 100% 2: 245: install(d, "and_I", and_I); call 0 returned 100% 2: 246: install(d, "or_I", or_I); call 0 returned 100% 2: 247: install(d, "xor_I", xor_I); call 0 returned 100% 2: 248: install(d, "lshift_I", lshift_I); call 0 returned 100% 2: 249: install(d, "rshift_I", rshift_I); call 0 returned 100% -: 250: 2: 251: install(d, "eq_I", eq_I); call 0 returned 100% 2: 252: install(d, "ne_I", ne_I); call 0 returned 100% 2: 253: install(d, "lt_I", lt_I); call 0 returned 100% 2: 254: install(d, "le_I", le_I); call 0 returned 100% 2: 255: install(d, "gt_I", gt_I); call 0 returned 100% 2: 256: install(d, "ge_I", ge_I); call 0 returned 100% -: 257: 2: 258: install(d, "abs_F", abs_F); call 0 returned 100% 2: 259: install(d, "neg_F", neg_F); call 0 returned 100% 2: 260: install(d, "add_F", add_F); call 0 returned 100% 2: 261: install(d, "sub_F", sub_F); call 0 returned 100% 2: 262: install(d, "diff_F", diff_F); call 0 returned 100% 2: 263: install(d, "mul_F", mul_F); call 0 returned 100% 2: 264: install(d, "div_F", div_F); call 0 returned 100% 2: 265: install(d, "mod_F", mod_F); call 0 returned 100% 2: 266: install(d, "min_F", min_F); call 0 returned 100% 2: 267: install(d, "max_F", max_F); call 0 returned 100% 2: 268: install(d, "pow_F", pow_F); call 0 returned 100% -: 269: 2: 270: install(d, "eq_F", eq_F); call 0 returned 100% 2: 271: install(d, "ne_F", ne_F); call 0 returned 100% 2: 272: install(d, "lt_F", lt_F); call 0 returned 100% 2: 273: install(d, "le_F", le_F); call 0 returned 100% 2: 274: install(d, "gt_F", gt_F); call 0 returned 100% 2: 275: install(d, "ge_F", ge_F); call 0 returned 100% -: 276: 2: 277: return 0; -: 278:} -: 279: -: 280:PyMODINIT_FUNC function PyInit__imagingmath called 2 returned 100% blocks executed 100% 2: 281:PyInit__imagingmath(void) { -: 282: PyObject* m; -: 283: -: 284: static PyModuleDef module_def = { -: 285: PyModuleDef_HEAD_INIT, -: 286: "_imagingmath", /* m_name */ -: 287: NULL, /* m_doc */ -: 288: -1, /* m_size */ -: 289: _functions, /* m_methods */ -: 290: }; -: 291: 2: 292: m = PyModule_Create(&module_def); call 0 returned 100% -: 293: 2: 294: if (setup_module(m) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 295: return NULL; -: 296: } -: 297: 2: 298: return m; -: 299:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Reduce.c.gcov -: 0:Source:src/libImaging/Reduce.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Reduce.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Reduce.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Imaging.h" -: 2: -: 3:#include -: 4: -: 5:#define ROUND_UP(f) ((int) ((f) >= 0.0 ? (f) + 0.5F : (f) - 0.5F)) -: 6: -: 7: -: 8:UINT32 function division_UINT32 called 882 returned 100% blocks executed 100% 882: 9:division_UINT32(int divider, int result_bits) -: 10:{ 882: 11: UINT32 max_dividend = (1 << result_bits) * divider; 882: 12: float max_int = (1 << 30) * 4.0; 882: 13: return (UINT32) (max_int / max_dividend); -: 14:} -: 15: -: 16: -: 17:void function ImagingReduceNxN called 129 returned 100% blocks executed 100% 129: 18:ImagingReduceNxN(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 19:{ -: 20: /* The most general implementation for any xscale and yscale -: 21: */ -: 22: int x, y, xx, yy; 129: 23: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 129: 24: UINT32 amend = yscale * xscale / 2; -: 25: 129: 26: if (imIn->image8) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 1235: 27: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% 1235: 28: int yy_from = box[1] + y*yscale; 120321: 29: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 119086: 30: int xx_from = box[0] + x*xscale; 119086: 31: UINT32 ss = amend; 459494: 32: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 74% branch 1 taken 26% (fallthrough) 340408: 33: UINT8 *line0 = (UINT8 *)imIn->image8[yy]; 340408: 34: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 1101928: 35: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 69% branch 1 taken 31% (fallthrough) 2284560: 36: ss += line0[xx + 0] + line0[xx + 1] + 1523040: 37: line1[xx + 0] + line1[xx + 1]; -: 38: } 340408: 39: if (xscale & 0x01) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 187924: 40: ss += line0[xx + 0] + line1[xx + 0]; -: 41: } -: 42: } 119086: 43: if (yscale & 0x01) { branch 0 taken 54% (fallthrough) branch 1 taken 46% 64750: 44: UINT8 *line = (UINT8 *)imIn->image8[yy]; 190180: 45: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 66% branch 1 taken 34% (fallthrough) 125430: 46: ss += line[xx + 0] + line[xx + 1]; -: 47: } 64750: 48: if (xscale & 0x01) { branch 0 taken 51% (fallthrough) branch 1 taken 49% 32772: 49: ss += line[xx + 0]; -: 50: } -: 51: } 119086: 52: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 53: } -: 54: } -: 55: } else { 4225: 56: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 4225: 57: int yy_from = box[1] + y*yscale; 4225: 58: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 144786: 59: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 144786: 60: int xx_from = box[0] + x*xscale; -: 61: UINT32 v; 144786: 62: UINT32 ss0 = amend, ss3 = amend; 591574: 63: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 446788: 64: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 446788: 65: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1550440: 66: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 3310956: 67: ss0 += line0[xx*4 + 0] + line0[xx*4 + 4] + 2207304: 68: line1[xx*4 + 0] + line1[xx*4 + 4]; 3310956: 69: ss3 += line0[xx*4 + 3] + line0[xx*4 + 7] + 2207304: 70: line1[xx*4 + 3] + line1[xx*4 + 7]; -: 71: } 446788: 72: if (xscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 178000: 73: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 178000: 74: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 75: } -: 76: } 144786: 77: if (yscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 57206: 78: UINT8 *line = (UINT8 *)imIn->image[yy]; 189020: 79: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 131814: 80: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 131814: 81: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 82: } 57206: 83: if (xscale & 0x01) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 26786: 84: ss0 += line[xx*4 + 0]; 26786: 85: ss3 += line[xx*4 + 3]; -: 86: } -: 87: } 144786: 88: v = MAKE_UINT32( -: 89: (ss0 * multiplier) >> 24, 0, -: 90: 0, (ss3 * multiplier) >> 24); 289572: 91: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 92: } 2450: 93: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 50506: 94: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 50506: 95: int xx_from = box[0] + x*xscale; -: 96: UINT32 v; 50506: 97: UINT32 ss0 = amend, ss1 = amend, ss2 = amend; 206354: 98: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 155848: 99: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 155848: 100: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 540760: 101: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 1154736: 102: ss0 += line0[xx*4 + 0] + line0[xx*4 + 4] + 769824: 103: line1[xx*4 + 0] + line1[xx*4 + 4]; 1154736: 104: ss1 += line0[xx*4 + 1] + line0[xx*4 + 5] + 769824: 105: line1[xx*4 + 1] + line1[xx*4 + 5]; 1154736: 106: ss2 += line0[xx*4 + 2] + line0[xx*4 + 6] + 769824: 107: line1[xx*4 + 2] + line1[xx*4 + 6]; -: 108: } 155848: 109: if (xscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 62116: 110: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 62116: 111: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 62116: 112: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; -: 113: } -: 114: } 50506: 115: if (yscale & 0x01) { branch 0 taken 39% (fallthrough) branch 1 taken 61% 19946: 116: UINT8 *line = (UINT8 *)imIn->image[yy]; 65900: 117: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 45954: 118: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 45954: 119: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 45954: 120: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; -: 121: } 19946: 122: if (xscale & 0x01) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 9344: 123: ss0 += line[xx*4 + 0]; 9344: 124: ss1 += line[xx*4 + 1]; 9344: 125: ss2 += line[xx*4 + 2]; -: 126: } -: 127: } 50506: 128: v = MAKE_UINT32( -: 129: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 130: (ss2 * multiplier) >> 24, 0); 101012: 131: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 132: } -: 133: } else { // bands == 4 144786: 134: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 144786: 135: int xx_from = box[0] + x*xscale; -: 136: UINT32 v; 144786: 137: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 591574: 138: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 446788: 139: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 446788: 140: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1550440: 141: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 3310956: 142: ss0 += line0[xx*4 + 0] + line0[xx*4 + 4] + 2207304: 143: line1[xx*4 + 0] + line1[xx*4 + 4]; 3310956: 144: ss1 += line0[xx*4 + 1] + line0[xx*4 + 5] + 2207304: 145: line1[xx*4 + 1] + line1[xx*4 + 5]; 3310956: 146: ss2 += line0[xx*4 + 2] + line0[xx*4 + 6] + 2207304: 147: line1[xx*4 + 2] + line1[xx*4 + 6]; 3310956: 148: ss3 += line0[xx*4 + 3] + line0[xx*4 + 7] + 2207304: 149: line1[xx*4 + 3] + line1[xx*4 + 7]; -: 150: } 446788: 151: if (xscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 178000: 152: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 178000: 153: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 178000: 154: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; 178000: 155: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 156: } -: 157: } 144786: 158: if (yscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 57206: 159: UINT8 *line = (UINT8 *)imIn->image[yy]; 189020: 160: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 131814: 161: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 131814: 162: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 131814: 163: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; 131814: 164: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 165: } 57206: 166: if (xscale & 0x01) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 26786: 167: ss0 += line[xx*4 + 0]; 26786: 168: ss1 += line[xx*4 + 1]; 26786: 169: ss2 += line[xx*4 + 2]; 26786: 170: ss3 += line[xx*4 + 3]; -: 171: } -: 172: } 144786: 173: v = MAKE_UINT32( -: 174: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 175: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 289572: 176: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 177: } -: 178: } -: 179: } -: 180: } 129: 181:} -: 182: -: 183: -: 184:void function ImagingReduce1xN called 40 returned 100% blocks executed 100% 40: 185:ImagingReduce1xN(Imaging imOut, Imaging imIn, int box[4], int yscale) -: 186:{ -: 187: /* Optimized implementation for xscale = 1. -: 188: */ -: 189: int x, y, yy; 40: 190: int xscale = 1; 40: 191: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 40: 192: UINT32 amend = yscale * xscale / 2; -: 193: 40: 194: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 314: 195: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% 314: 196: int yy_from = box[1] + y*yscale; 117350: 197: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 117036: 198: int xx = box[0] + x*xscale; 117036: 199: UINT32 ss = amend; 393642: 200: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 276606: 201: UINT8 *line0 = (UINT8 *)imIn->image8[yy]; 276606: 202: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 276606: 203: ss += line0[xx + 0] + line1[xx + 0]; -: 204: } 117036: 205: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42534: 206: UINT8 *line = (UINT8 *)imIn->image8[yy]; 42534: 207: ss += line[xx + 0]; -: 208: } 117036: 209: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 210: } -: 211: } -: 212: } else { 1966: 213: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 1966: 214: int yy_from = box[1] + y*yscale; 1966: 215: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 335448: 216: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 335448: 217: int xx = box[0] + x*xscale; -: 218: UINT32 v; 335448: 219: UINT32 ss0 = amend, ss3 = amend; 1128276: 220: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 792828: 221: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 792828: 222: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 792828: 223: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 792828: 224: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 225: } 335448: 226: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 121932: 227: UINT8 *line = (UINT8 *)imIn->image[yy]; 121932: 228: ss0 += line[xx*4 + 0]; 121932: 229: ss3 += line[xx*4 + 3]; -: 230: } 335448: 231: v = MAKE_UINT32( -: 232: (ss0 * multiplier) >> 24, 0, -: 233: 0, (ss3 * multiplier) >> 24); 670896: 234: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 235: } 1140: 236: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 117036: 237: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 117036: 238: int xx = box[0] + x*xscale; -: 239: UINT32 v; 117036: 240: UINT32 ss0 = amend, ss1 = amend, ss2 = amend; 393642: 241: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 276606: 242: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 276606: 243: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 276606: 244: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 276606: 245: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 276606: 246: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; -: 247: } 117036: 248: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42534: 249: UINT8 *line = (UINT8 *)imIn->image[yy]; 42534: 250: ss0 += line[xx*4 + 0]; 42534: 251: ss1 += line[xx*4 + 1]; 42534: 252: ss2 += line[xx*4 + 2]; -: 253: } 117036: 254: v = MAKE_UINT32( -: 255: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 256: (ss2 * multiplier) >> 24, 0); 234072: 257: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 258: } -: 259: } else { // bands == 4 335448: 260: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 335448: 261: int xx = box[0] + x*xscale; -: 262: UINT32 v; 335448: 263: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 1128276: 264: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 792828: 265: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 792828: 266: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 792828: 267: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 792828: 268: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 792828: 269: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; 792828: 270: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 271: } 335448: 272: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 121932: 273: UINT8 *line = (UINT8 *)imIn->image[yy]; 121932: 274: ss0 += line[xx*4 + 0]; 121932: 275: ss1 += line[xx*4 + 1]; 121932: 276: ss2 += line[xx*4 + 2]; 121932: 277: ss3 += line[xx*4 + 3]; -: 278: } 335448: 279: v = MAKE_UINT32( -: 280: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 281: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 670896: 282: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 283: } -: 284: } -: 285: } -: 286: } 40: 287:} -: 288: -: 289: -: 290:void function ImagingReduceNx1 called 40 returned 100% blocks executed 100% 40: 291:ImagingReduceNx1(Imaging imOut, Imaging imIn, int box[4], int xscale) -: 292:{ -: 293: /* Optimized implementation for yscale = 1. -: 294: */ -: 295: int x, y, xx; 40: 296: int yscale = 1; 40: 297: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 40: 298: UINT32 amend = yscale * xscale / 2; -: 299: 40: 300: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 1618: 301: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 1618: 302: int yy = box[1] + y*yscale; 1618: 303: UINT8 *line = (UINT8 *)imIn->image8[yy]; 119229: 304: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 117611: 305: int xx_from = box[0] + x*xscale; 117611: 306: UINT32 ss = amend; 395582: 307: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 277971: 308: ss += line[xx + 0] + line[xx + 1]; -: 309: } 117611: 310: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42749: 311: ss += line[xx + 0]; -: 312: } 117611: 313: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 314: } -: 315: } -: 316: } else { 10118: 317: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 10118: 318: int yy = box[1] + y*yscale; 10118: 319: UINT8 *line = (UINT8 *)imIn->image[yy]; 10118: 320: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 337129: 321: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 337129: 322: int xx_from = box[0] + x*xscale; -: 323: UINT32 v; 337129: 324: UINT32 ss0 = amend, ss3 = amend; 1133896: 325: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 796767: 326: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 796767: 327: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 328: } 337129: 329: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 122509: 330: ss0 += line[xx*4 + 0]; 122509: 331: ss3 += line[xx*4 + 3]; -: 332: } 337129: 333: v = MAKE_UINT32( -: 334: (ss0 * multiplier) >> 24, 0, -: 335: 0, (ss3 * multiplier) >> 24); 674258: 336: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 337: } 5868: 338: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 117611: 339: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 117611: 340: int xx_from = box[0] + x*xscale; -: 341: UINT32 v; 117611: 342: UINT32 ss0 = amend, ss1 = amend, ss2 = amend; 395582: 343: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 277971: 344: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 277971: 345: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 277971: 346: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; -: 347: } 117611: 348: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42749: 349: ss0 += line[xx*4 + 0]; 42749: 350: ss1 += line[xx*4 + 1]; 42749: 351: ss2 += line[xx*4 + 2]; -: 352: } 117611: 353: v = MAKE_UINT32( -: 354: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 355: (ss2 * multiplier) >> 24, 0); 235222: 356: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 357: } -: 358: } else { // bands == 4 337129: 359: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 337129: 360: int xx_from = box[0] + x*xscale; -: 361: UINT32 v; 337129: 362: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 1133896: 363: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 796767: 364: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 796767: 365: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 796767: 366: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; 796767: 367: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 368: } 337129: 369: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 122509: 370: ss0 += line[xx*4 + 0]; 122509: 371: ss1 += line[xx*4 + 1]; 122509: 372: ss2 += line[xx*4 + 2]; 122509: 373: ss3 += line[xx*4 + 3]; -: 374: } 337129: 375: v = MAKE_UINT32( -: 376: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 377: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 674258: 378: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 379: } -: 380: } -: 381: } -: 382: } 40: 383:} -: 384: -: 385:void function ImagingReduce1x2 called 20 returned 100% blocks executed 100% 20: 386:ImagingReduce1x2(Imaging imOut, Imaging imIn, int box[4]) -: 387:{ -: 388: /* Optimized implementation for xscale = 1 and yscale = 2. -: 389: */ 20: 390: int xscale = 1, yscale = 2; -: 391: int x, y; -: 392: UINT32 ss0, ss1, ss2, ss3; 20: 393: UINT32 amend = yscale * xscale / 2; -: 394: 20: 395: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 403: 396: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 403: 397: int yy = box[1] + y*yscale; 403: 398: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 403: 399: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 150189: 400: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 149786: 401: int xx = box[0] + x*xscale; 299572: 402: ss0 = line0[xx + 0] + 149786: 403: line1[xx + 0]; 149786: 404: imOut->image8[y][x] = (ss0 + amend) >> 1; -: 405: } -: 406: } -: 407: } else { 2521: 408: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2521: 409: int yy = box[1] + y*yscale; 2521: 410: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 2521: 411: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 2521: 412: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 429108: 413: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 429108: 414: int xx = box[0] + x*xscale; -: 415: UINT32 v; 858216: 416: ss0 = line0[xx*4 + 0] + 429108: 417: line1[xx*4 + 0]; 858216: 418: ss3 = line0[xx*4 + 3] + 429108: 419: line1[xx*4 + 3]; 429108: 420: v = MAKE_UINT32((ss0 + amend) >> 1, 0, -: 421: 0, (ss3 + amend) >> 1); 858216: 422: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 423: } 1462: 424: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 149786: 425: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 149786: 426: int xx = box[0] + x*xscale; -: 427: UINT32 v; 299572: 428: ss0 = line0[xx*4 + 0] + 149786: 429: line1[xx*4 + 0]; 299572: 430: ss1 = line0[xx*4 + 1] + 149786: 431: line1[xx*4 + 1]; 299572: 432: ss2 = line0[xx*4 + 2] + 149786: 433: line1[xx*4 + 2]; 149786: 434: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 435: (ss2 + amend) >> 1, 0); 299572: 436: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 437: } -: 438: } else { // bands == 4 429108: 439: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 429108: 440: int xx = box[0] + x*xscale; -: 441: UINT32 v; 858216: 442: ss0 = line0[xx*4 + 0] + 429108: 443: line1[xx*4 + 0]; 858216: 444: ss1 = line0[xx*4 + 1] + 429108: 445: line1[xx*4 + 1]; 858216: 446: ss2 = line0[xx*4 + 2] + 429108: 447: line1[xx*4 + 2]; 858216: 448: ss3 = line0[xx*4 + 3] + 429108: 449: line1[xx*4 + 3]; 429108: 450: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 451: (ss2 + amend) >> 1, (ss3 + amend) >> 1); 858216: 452: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 453: } -: 454: } -: 455: } -: 456: } 20: 457:} -: 458: -: 459: -: 460:void function ImagingReduce2x1 called 20 returned 100% blocks executed 100% 20: 461:ImagingReduce2x1(Imaging imOut, Imaging imIn, int box[4]) -: 462:{ -: 463: /* Optimized implementation for xscale = 2 and yscale = 1. -: 464: */ 20: 465: int xscale = 2, yscale = 1; -: 466: int x, y; -: 467: UINT32 ss0, ss1, ss2, ss3; 20: 468: UINT32 amend = yscale * xscale / 2; -: 469: 20: 470: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 809: 471: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 809: 472: int yy = box[1] + y*yscale; 809: 473: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 150835: 474: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 150026: 475: int xx = box[0] + x*xscale; 150026: 476: ss0 = line0[xx + 0] + line0[xx + 1]; 150026: 477: imOut->image8[y][x] = (ss0 + amend) >> 1; -: 478: } -: 479: } -: 480: } else { 5059: 481: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5059: 482: int yy = box[1] + y*yscale; 5059: 483: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 5059: 484: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 429844: 485: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 429844: 486: int xx = box[0] + x*xscale; -: 487: UINT32 v; 429844: 488: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4]; 429844: 489: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7]; 429844: 490: v = MAKE_UINT32((ss0 + amend) >> 1, 0, -: 491: 0, (ss3 + amend) >> 1); 859688: 492: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 493: } 2934: 494: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 150026: 495: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 150026: 496: int xx = box[0] + x*xscale; -: 497: UINT32 v; 150026: 498: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4]; 150026: 499: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5]; 150026: 500: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6]; 150026: 501: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 502: (ss2 + amend) >> 1, 0); 300052: 503: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 504: } -: 505: } else { // bands == 4 429844: 506: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 429844: 507: int xx = box[0] + x*xscale; -: 508: UINT32 v; 429844: 509: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4]; 429844: 510: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5]; 429844: 511: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6]; 429844: 512: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7]; 429844: 513: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 514: (ss2 + amend) >> 1, (ss3 + amend) >> 1); 859688: 515: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 516: } -: 517: } -: 518: } -: 519: } 20: 520:} -: 521: -: 522: -: 523:void function ImagingReduce2x2 called 27 returned 100% blocks executed 100% 27: 524:ImagingReduce2x2(Imaging imOut, Imaging imIn, int box[4]) -: 525:{ -: 526: /* Optimized implementation for xscale = 2 and yscale = 2. -: 527: */ 27: 528: int xscale = 2, yscale = 2; -: 529: int x, y; -: 530: UINT32 ss0, ss1, ss2, ss3; 27: 531: UINT32 amend = yscale * xscale / 2; -: 532: 27: 533: if (imIn->image8) { branch 0 taken 78% (fallthrough) branch 1 taken 22% 541: 534: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 541: 535: int yy = box[1] + y*yscale; 541: 536: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 541: 537: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 103447: 538: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 102906: 539: int xx = box[0] + x*xscale; 308718: 540: ss0 = line0[xx + 0] + line0[xx + 1] + 205812: 541: line1[xx + 0] + line1[xx + 1]; 102906: 542: imOut->image8[y][x] = (ss0 + amend) >> 2; -: 543: } -: 544: } -: 545: } else { 3173: 546: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3173: 547: int yy = box[1] + y*yscale; 3173: 548: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 3173: 549: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 3173: 550: if (imIn->bands == 2) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 214404: 551: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 214404: 552: int xx = box[0] + x*xscale; -: 553: UINT32 v; 643212: 554: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + 428808: 555: line1[xx*4 + 0] + line1[xx*4 + 4]; 643212: 556: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + 428808: 557: line1[xx*4 + 3] + line1[xx*4 + 7]; 214404: 558: v = MAKE_UINT32((ss0 + amend) >> 2, 0, -: 559: 0, (ss3 + amend) >> 2); 428808: 560: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 561: } 2114: 562: } else if (imIn->bands == 3) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 237378: 563: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 237378: 564: int xx = box[0] + x*xscale; -: 565: UINT32 v; 712134: 566: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + 474756: 567: line1[xx*4 + 0] + line1[xx*4 + 4]; 712134: 568: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + 474756: 569: line1[xx*4 + 1] + line1[xx*4 + 5]; 712134: 570: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + 474756: 571: line1[xx*4 + 2] + line1[xx*4 + 6]; 237378: 572: v = MAKE_UINT32((ss0 + amend) >> 2, (ss1 + amend) >> 2, -: 573: (ss2 + amend) >> 2, 0); 474756: 574: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 575: } -: 576: } else { // bands == 4 214404: 577: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 214404: 578: int xx = box[0] + x*xscale; -: 579: UINT32 v; 643212: 580: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + 428808: 581: line1[xx*4 + 0] + line1[xx*4 + 4]; 643212: 582: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + 428808: 583: line1[xx*4 + 1] + line1[xx*4 + 5]; 643212: 584: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + 428808: 585: line1[xx*4 + 2] + line1[xx*4 + 6]; 643212: 586: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + 428808: 587: line1[xx*4 + 3] + line1[xx*4 + 7]; 214404: 588: v = MAKE_UINT32((ss0 + amend) >> 2, (ss1 + amend) >> 2, -: 589: (ss2 + amend) >> 2, (ss3 + amend) >> 2); 428808: 590: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 591: } -: 592: } -: 593: } -: 594: } 27: 595:} -: 596: -: 597: -: 598:void function ImagingReduce1x3 called 21 returned 100% blocks executed 100% 21: 599:ImagingReduce1x3(Imaging imOut, Imaging imIn, int box[4]) -: 600:{ -: 601: /* Optimized implementation for xscale = 1 and yscale = 3. -: 602: */ 21: 603: int xscale = 1, yscale = 3; -: 604: int x, y; -: 605: UINT32 ss0, ss1, ss2, ss3; 21: 606: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 21: 607: UINT32 amend = yscale * xscale / 2; -: 608: 21: 609: if (imIn->image8) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 272: 610: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 272: 611: int yy = box[1] + y*yscale; 272: 612: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 272: 613: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 272: 614: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 100330: 615: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 100058: 616: int xx = box[0] + x*xscale; 300174: 617: ss0 = line0[xx + 0] + 200116: 618: line1[xx + 0] + 100058: 619: line2[xx + 0]; 100058: 620: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 621: } -: 622: } -: 623: } else { 1683: 624: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1683: 625: int yy = box[1] + y*yscale; 1683: 626: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1683: 627: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1683: 628: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1683: 629: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 286584: 630: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 286584: 631: int xx = box[0] + x*xscale; -: 632: UINT32 v; 859752: 633: ss0 = line0[xx*4 + 0] + 573168: 634: line1[xx*4 + 0] + 286584: 635: line2[xx*4 + 0]; 859752: 636: ss3 = line0[xx*4 + 3] + 573168: 637: line1[xx*4 + 3] + 286584: 638: line2[xx*4 + 3]; 286584: 639: v = MAKE_UINT32( -: 640: ((ss0 + amend) * multiplier) >> 24, 0, -: 641: 0, ((ss3 + amend) * multiplier) >> 24); 573168: 642: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 643: } 976: 644: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 100028: 645: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 100028: 646: int xx = box[0] + x*xscale; -: 647: UINT32 v; 300084: 648: ss0 = line0[xx*4 + 0] + 200056: 649: line1[xx*4 + 0] + 100028: 650: line2[xx*4 + 0]; 300084: 651: ss1 = line0[xx*4 + 1] + 200056: 652: line1[xx*4 + 1] + 100028: 653: line2[xx*4 + 1]; 300084: 654: ss2 = line0[xx*4 + 2] + 200056: 655: line1[xx*4 + 2] + 100028: 656: line2[xx*4 + 2]; 100028: 657: v = MAKE_UINT32( -: 658: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 659: ((ss2 + amend) * multiplier) >> 24, 0); 200056: 660: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 661: } -: 662: } else { // bands == 4 286584: 663: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 286584: 664: int xx = box[0] + x*xscale; -: 665: UINT32 v; 859752: 666: ss0 = line0[xx*4 + 0] + 573168: 667: line1[xx*4 + 0] + 286584: 668: line2[xx*4 + 0]; 859752: 669: ss1 = line0[xx*4 + 1] + 573168: 670: line1[xx*4 + 1] + 286584: 671: line2[xx*4 + 1]; 859752: 672: ss2 = line0[xx*4 + 2] + 573168: 673: line1[xx*4 + 2] + 286584: 674: line2[xx*4 + 2]; 859752: 675: ss3 = line0[xx*4 + 3] + 573168: 676: line1[xx*4 + 3] + 286584: 677: line2[xx*4 + 3]; 286584: 678: v = MAKE_UINT32( -: 679: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 680: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 573168: 681: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 682: } -: 683: } -: 684: } -: 685: } 21: 686:} -: 687: -: 688: -: 689:void function ImagingReduce3x1 called 21 returned 100% blocks executed 100% 21: 690:ImagingReduce3x1(Imaging imOut, Imaging imIn, int box[4]) -: 691:{ -: 692: /* Optimized implementation for xscale = 3 and yscale = 1. -: 693: */ 21: 694: int xscale = 3, yscale = 1; -: 695: int x, y; -: 696: UINT32 ss0, ss1, ss2, ss3; 21: 697: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 21: 698: UINT32 amend = yscale * xscale / 2; -: 699: 21: 700: if (imIn->image8) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 819: 701: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 819: 702: int yy = box[1] + y*yscale; 819: 703: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 100629: 704: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 99810: 705: int xx = box[0] + x*xscale; 99810: 706: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2]; 99810: 707: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 708: } -: 709: } -: 710: } else { 5059: 711: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5059: 712: int yy = box[1] + y*yscale; 5059: 713: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 5059: 714: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 285750: 715: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 285750: 716: int xx = box[0] + x*xscale; -: 717: UINT32 v; 285750: 718: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8]; 285750: 719: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11]; 285750: 720: v = MAKE_UINT32( -: 721: ((ss0 + amend) * multiplier) >> 24, 0, -: 722: 0, ((ss3 + amend) * multiplier) >> 24); 571500: 723: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 724: } 2934: 725: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 99780: 726: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 99780: 727: int xx = box[0] + x*xscale; -: 728: UINT32 v; 99780: 729: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8]; 99780: 730: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9]; 99780: 731: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10]; 99780: 732: v = MAKE_UINT32( -: 733: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 734: ((ss2 + amend) * multiplier) >> 24, 0); 199560: 735: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 736: } -: 737: } else { // bands == 4 285750: 738: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 285750: 739: int xx = box[0] + x*xscale; -: 740: UINT32 v; 285750: 741: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8]; 285750: 742: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9]; 285750: 743: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10]; 285750: 744: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11]; 285750: 745: v = MAKE_UINT32( -: 746: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 747: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 571500: 748: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 749: } -: 750: } -: 751: } -: 752: } 21: 753:} -: 754: -: 755: -: 756:void function ImagingReduce3x3 called 26 returned 100% blocks executed 100% 26: 757:ImagingReduce3x3(Imaging imOut, Imaging imIn, int box[4]) -: 758:{ -: 759: /* Optimized implementation for xscale = 3 and yscale = 3. -: 760: */ 26: 761: int xscale = 3, yscale = 3; -: 762: int x, y; -: 763: UINT32 ss0, ss1, ss2, ss3; 26: 764: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 26: 765: UINT32 amend = yscale * xscale / 2; -: 766: 26: 767: if (imIn->image8) { branch 0 taken 73% (fallthrough) branch 1 taken 27% 500: 768: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 500: 769: int yy = box[1] + y*yscale; 500: 770: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 500: 771: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 500: 772: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 55379: 773: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 54879: 774: int xx = box[0] + x*xscale; 164637: 775: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2] + 164637: 776: line1[xx + 0] + line1[xx + 1] + line1[xx + 2] + 109758: 777: line2[xx + 0] + line2[xx + 1] + line2[xx + 2]; 54879: 778: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 779: } -: 780: } -: 781: } else { 1767: 782: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1767: 783: int yy = box[1] + y*yscale; 1767: 784: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1767: 785: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1767: 786: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1767: 787: if (imIn->bands == 2) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 95190: 788: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 95190: 789: int xx = box[0] + x*xscale; -: 790: UINT32 v; 285570: 791: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + 285570: 792: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + 190380: 793: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8]; 285570: 794: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + 285570: 795: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + 190380: 796: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11]; 95190: 797: v = MAKE_UINT32( -: 798: ((ss0 + amend) * multiplier) >> 24, 0, -: 799: 0, ((ss3 + amend) * multiplier) >> 24); 190380: 800: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 801: } 1060: 802: } else if (imIn->bands == 3) { branch 0 taken 67% (fallthrough) branch 1 taken 33% 36758: 803: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 36758: 804: int xx = box[0] + x*xscale; -: 805: UINT32 v; 110274: 806: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + 110274: 807: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + 73516: 808: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8]; 110274: 809: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + 110274: 810: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + 73516: 811: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9]; 110274: 812: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + 110274: 813: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + 73516: 814: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10]; 36758: 815: v = MAKE_UINT32( -: 816: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 817: ((ss2 + amend) * multiplier) >> 24, 0); 73516: 818: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 819: } -: 820: } else { // bands == 4 95190: 821: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 95190: 822: int xx = box[0] + x*xscale; -: 823: UINT32 v; 285570: 824: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + 285570: 825: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + 190380: 826: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8]; 285570: 827: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + 285570: 828: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + 190380: 829: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9]; 285570: 830: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + 285570: 831: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + 190380: 832: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10]; 285570: 833: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + 285570: 834: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + 190380: 835: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11]; 95190: 836: v = MAKE_UINT32( -: 837: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 838: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 190380: 839: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 840: } -: 841: } -: 842: } -: 843: } 26: 844:} -: 845: -: 846:void function ImagingReduce4x4 called 20 returned 100% blocks executed 100% 20: 847:ImagingReduce4x4(Imaging imOut, Imaging imIn, int box[4]) -: 848:{ -: 849: /* Optimized implementation for xscale = 4 and yscale = 4. -: 850: */ 20: 851: int xscale = 4, yscale = 4; -: 852: int x, y; -: 853: UINT32 ss0, ss1, ss2, ss3; 20: 854: UINT32 amend = yscale * xscale / 2; -: 855: 20: 856: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 200: 857: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 200: 858: int yy = box[1] + y*yscale; 200: 859: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 200: 860: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 200: 861: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 200: 862: UINT8 *line3 = (UINT8 *)imIn->image8[yy + 3]; 18770: 863: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 18570: 864: int xx = box[0] + x*xscale; 55710: 865: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2] + line0[xx + 3] + 55710: 866: line1[xx + 0] + line1[xx + 1] + line1[xx + 2] + line1[xx + 3] + 55710: 867: line2[xx + 0] + line2[xx + 1] + line2[xx + 2] + line2[xx + 3] + 37140: 868: line3[xx + 0] + line3[xx + 1] + line3[xx + 2] + line3[xx + 3]; 18570: 869: imOut->image8[y][x] = (ss0 + amend) >> 4; -: 870: } -: 871: } -: 872: } else { 1252: 873: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1252: 874: int yy = box[1] + y*yscale; 1252: 875: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1252: 876: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1252: 877: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1252: 878: UINT8 *line3 = (UINT8 *)imIn->image[yy + 3]; 1252: 879: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 53268: 880: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 53268: 881: int xx = box[0] + x*xscale; -: 882: UINT32 v; 159804: 883: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + 159804: 884: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + 159804: 885: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + 106536: 886: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12]; 159804: 887: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + 159804: 888: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + 159804: 889: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + 106536: 890: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15]; 53268: 891: v = MAKE_UINT32((ss0 + amend) >> 4, 0, -: 892: 0, (ss3 + amend) >> 4); 106536: 893: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 894: } 726: 895: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 18570: 896: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 18570: 897: int xx = box[0] + x*xscale; -: 898: UINT32 v; 55710: 899: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + 55710: 900: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + 55710: 901: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + 37140: 902: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12]; 55710: 903: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + 55710: 904: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + 55710: 905: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + 37140: 906: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13]; 55710: 907: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + 55710: 908: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + 55710: 909: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + 37140: 910: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14]; 18570: 911: v = MAKE_UINT32((ss0 + amend) >> 4, (ss1 + amend) >> 4, -: 912: (ss2 + amend) >> 4, 0); 37140: 913: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 914: } -: 915: } else { // bands == 4 53268: 916: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 53268: 917: int xx = box[0] + x*xscale; -: 918: UINT32 v; 159804: 919: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + 159804: 920: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + 159804: 921: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + 106536: 922: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12]; 159804: 923: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + 159804: 924: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + 159804: 925: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + 106536: 926: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13]; 159804: 927: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + 159804: 928: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + 159804: 929: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + 106536: 930: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14]; 159804: 931: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + 159804: 932: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + 159804: 933: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + 106536: 934: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15]; 53268: 935: v = MAKE_UINT32((ss0 + amend) >> 4, (ss1 + amend) >> 4, -: 936: (ss2 + amend) >> 4, (ss3 + amend) >> 4); 106536: 937: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 938: } -: 939: } -: 940: } -: 941: } 20: 942:} -: 943: -: 944: -: 945:void function ImagingReduce5x5 called 20 returned 100% blocks executed 100% 20: 946:ImagingReduce5x5(Imaging imOut, Imaging imIn, int box[4]) -: 947:{ -: 948: /* Fast special case for xscale = 5 and yscale = 5. -: 949: */ 20: 950: int xscale = 5, yscale = 5; -: 951: int x, y; -: 952: UINT32 ss0, ss1, ss2, ss3; 20: 953: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 20: 954: UINT32 amend = yscale * xscale / 2; -: 955: 20: 956: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 161: 957: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% 161: 958: int yy = box[1] + y*yscale; 161: 959: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 161: 960: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 161: 961: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 161: 962: UINT8 *line3 = (UINT8 *)imIn->image8[yy + 3]; 161: 963: UINT8 *line4 = (UINT8 *)imIn->image8[yy + 4]; 12083: 964: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 11922: 965: int xx = box[0] + x*xscale; 35766: 966: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2] + line0[xx + 3] + line0[xx + 4] + 35766: 967: line1[xx + 0] + line1[xx + 1] + line1[xx + 2] + line1[xx + 3] + line1[xx + 4] + 35766: 968: line2[xx + 0] + line2[xx + 1] + line2[xx + 2] + line2[xx + 3] + line2[xx + 4] + 35766: 969: line3[xx + 0] + line3[xx + 1] + line3[xx + 2] + line3[xx + 3] + line3[xx + 4] + 23844: 970: line4[xx + 0] + line4[xx + 1] + line4[xx + 2] + line4[xx + 3] + line4[xx + 4]; 11922: 971: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 972: } -: 973: } -: 974: } else { 1007: 975: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 1007: 976: int yy = box[1] + y*yscale; 1007: 977: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1007: 978: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1007: 979: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1007: 980: UINT8 *line3 = (UINT8 *)imIn->image[yy + 3]; 1007: 981: UINT8 *line4 = (UINT8 *)imIn->image[yy + 4]; 1007: 982: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 34146: 983: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 34146: 984: int xx = box[0] + x*xscale; -: 985: UINT32 v; 102438: 986: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + line0[xx*4 + 16] + 102438: 987: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + line1[xx*4 + 16] + 102438: 988: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + line2[xx*4 + 16] + 102438: 989: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12] + line3[xx*4 + 16] + 68292: 990: line4[xx*4 + 0] + line4[xx*4 + 4] + line4[xx*4 + 8] + line4[xx*4 + 12] + line4[xx*4 + 16]; 102438: 991: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + line0[xx*4 + 19] + 102438: 992: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + line1[xx*4 + 19] + 102438: 993: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + line2[xx*4 + 19] + 102438: 994: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15] + line3[xx*4 + 19] + 68292: 995: line4[xx*4 + 3] + line4[xx*4 + 7] + line4[xx*4 + 11] + line4[xx*4 + 15] + line4[xx*4 + 19]; 34146: 996: v = MAKE_UINT32( -: 997: ((ss0 + amend) * multiplier) >> 24, 0, -: 998: 0, ((ss3 + amend) * multiplier) >> 24); 68292: 999: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1000: } 584: 1001: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 11922: 1002: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 11922: 1003: int xx = box[0] + x*xscale; -: 1004: UINT32 v; 35766: 1005: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + line0[xx*4 + 16] + 35766: 1006: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + line1[xx*4 + 16] + 35766: 1007: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + line2[xx*4 + 16] + 35766: 1008: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12] + line3[xx*4 + 16] + 23844: 1009: line4[xx*4 + 0] + line4[xx*4 + 4] + line4[xx*4 + 8] + line4[xx*4 + 12] + line4[xx*4 + 16]; 35766: 1010: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + line0[xx*4 + 17] + 35766: 1011: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + line1[xx*4 + 17] + 35766: 1012: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + line2[xx*4 + 17] + 35766: 1013: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13] + line3[xx*4 + 17] + 23844: 1014: line4[xx*4 + 1] + line4[xx*4 + 5] + line4[xx*4 + 9] + line4[xx*4 + 13] + line4[xx*4 + 17]; 35766: 1015: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + line0[xx*4 + 18] + 35766: 1016: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + line1[xx*4 + 18] + 35766: 1017: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + line2[xx*4 + 18] + 35766: 1018: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14] + line3[xx*4 + 18] + 23844: 1019: line4[xx*4 + 2] + line4[xx*4 + 6] + line4[xx*4 + 10] + line4[xx*4 + 14] + line4[xx*4 + 18]; 11922: 1020: v = MAKE_UINT32( -: 1021: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 1022: ((ss2 + amend) * multiplier) >> 24, 0); 23844: 1023: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1024: } -: 1025: } else { // bands == 4 34146: 1026: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 34146: 1027: int xx = box[0] + x*xscale; -: 1028: UINT32 v; 102438: 1029: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + line0[xx*4 + 16] + 102438: 1030: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + line1[xx*4 + 16] + 102438: 1031: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + line2[xx*4 + 16] + 102438: 1032: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12] + line3[xx*4 + 16] + 68292: 1033: line4[xx*4 + 0] + line4[xx*4 + 4] + line4[xx*4 + 8] + line4[xx*4 + 12] + line4[xx*4 + 16]; 102438: 1034: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + line0[xx*4 + 17] + 102438: 1035: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + line1[xx*4 + 17] + 102438: 1036: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + line2[xx*4 + 17] + 102438: 1037: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13] + line3[xx*4 + 17] + 68292: 1038: line4[xx*4 + 1] + line4[xx*4 + 5] + line4[xx*4 + 9] + line4[xx*4 + 13] + line4[xx*4 + 17]; 102438: 1039: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + line0[xx*4 + 18] + 102438: 1040: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + line1[xx*4 + 18] + 102438: 1041: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + line2[xx*4 + 18] + 102438: 1042: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14] + line3[xx*4 + 18] + 68292: 1043: line4[xx*4 + 2] + line4[xx*4 + 6] + line4[xx*4 + 10] + line4[xx*4 + 14] + line4[xx*4 + 18]; 102438: 1044: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + line0[xx*4 + 19] + 102438: 1045: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + line1[xx*4 + 19] + 102438: 1046: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + line2[xx*4 + 19] + 102438: 1047: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15] + line3[xx*4 + 19] + 68292: 1048: line4[xx*4 + 3] + line4[xx*4 + 7] + line4[xx*4 + 11] + line4[xx*4 + 15] + line4[xx*4 + 19]; 34146: 1049: v = MAKE_UINT32( -: 1050: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 1051: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 68292: 1052: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1053: } -: 1054: } -: 1055: } -: 1056: } 20: 1057:} -: 1058: -: 1059: -: 1060:void function ImagingReduceCorners called 384 returned 100% blocks executed 100% 384: 1061:ImagingReduceCorners(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 1062:{ -: 1063: /* Fill the last row and the last column for any xscale and yscale. -: 1064: */ -: 1065: int x, y, xx, yy; -: 1066: 384: 1067: if (imIn->image8) { branch 0 taken 19% (fallthrough) branch 1 taken 81% 72: 1068: if (box[2] % xscale) { branch 0 taken 51% (fallthrough) branch 1 taken 49% 37: 1069: int scale = (box[2] % xscale) * yscale; 37: 1070: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 37: 1071: UINT32 amend = scale / 2; 3406: 1072: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3369: 1073: int yy_from = box[1] + y*yscale; 3369: 1074: UINT32 ss = amend; 3369: 1075: x = box[2] / xscale; -: 1076: 13328: 1077: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 9959: 1078: UINT8 *line = (UINT8 *)imIn->image8[yy]; 47111: 1079: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 79% branch 1 taken 21% (fallthrough) 37152: 1080: ss += line[xx + 0]; -: 1081: } -: 1082: } 3369: 1083: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 1084: } -: 1085: } 72: 1086: if (box[3] % yscale) { branch 0 taken 74% (fallthrough) branch 1 taken 26% 53: 1087: int scale = xscale * (box[3] % yscale); 53: 1088: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 53: 1089: UINT32 amend = scale / 2; 53: 1090: y = box[3] / yscale; 5364: 1091: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5311: 1092: int xx_from = box[0] + x*xscale; 5311: 1093: UINT32 ss = amend; 17168: 1094: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 69% branch 1 taken 31% (fallthrough) 11857: 1095: UINT8 *line = (UINT8 *)imIn->image8[yy]; 53284: 1096: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 78% branch 1 taken 22% (fallthrough) 41427: 1097: ss += line[xx + 0]; -: 1098: } -: 1099: } 5311: 1100: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 1101: } -: 1102: } 72: 1103: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 51% (fallthrough) branch 1 taken 49% branch 2 taken 65% (fallthrough) branch 3 taken 35% 24: 1104: int scale = (box[2] % xscale) * (box[3] % yscale); 24: 1105: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 24: 1106: UINT32 amend = scale / 2; 24: 1107: UINT32 ss = amend; 24: 1108: x = box[2] / xscale; 24: 1109: y = box[3] / yscale; 116: 1110: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 79% branch 1 taken 21% (fallthrough) 92: 1111: UINT8 *line = (UINT8 *)imIn->image8[yy]; 586: 1112: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 494: 1113: ss += line[xx + 0]; -: 1114: } -: 1115: } 24: 1116: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 1117: } -: 1118: } else { 312: 1119: if (box[2] % xscale) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 148: 1120: int scale = (box[2] % xscale) * yscale; 148: 1121: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 148: 1122: UINT32 amend = scale / 2; 17543: 1123: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 17395: 1124: int yy_from = box[1] + y*yscale; -: 1125: UINT32 v; 17395: 1126: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 17395: 1127: x = box[2] / xscale; -: 1128: 59204: 1129: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 41809: 1130: UINT8 *line = (UINT8 *)imIn->image[yy]; 181544: 1131: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 139735: 1132: ss0 += line[xx*4 + 0]; 139735: 1133: ss1 += line[xx*4 + 1]; 139735: 1134: ss2 += line[xx*4 + 2]; 139735: 1135: ss3 += line[xx*4 + 3]; -: 1136: } -: 1137: } 17395: 1138: v = MAKE_UINT32( -: 1139: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 1140: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 34790: 1141: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1142: } -: 1143: } 312: 1144: if (box[3] % yscale) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 226: 1145: int scale = xscale * (box[3] % yscale); 226: 1146: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 226: 1147: UINT32 amend = scale / 2; 226: 1148: y = box[3] / yscale; 27071: 1149: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 26845: 1150: int xx_from = box[0] + x*xscale; -: 1151: UINT32 v; 26845: 1152: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 90802: 1153: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 63957: 1154: UINT8 *line = (UINT8 *)imIn->image[yy]; 267841: 1155: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 203884: 1156: ss0 += line[xx*4 + 0]; 203884: 1157: ss1 += line[xx*4 + 1]; 203884: 1158: ss2 += line[xx*4 + 2]; 203884: 1159: ss3 += line[xx*4 + 3]; -: 1160: } -: 1161: } 26845: 1162: v = MAKE_UINT32( -: 1163: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 1164: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 53690: 1165: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1166: } -: 1167: } 312: 1168: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 47% (fallthrough) branch 1 taken 53% branch 2 taken 66% (fallthrough) branch 3 taken 34% 97: 1169: int scale = (box[2] % xscale) * (box[3] % yscale); 97: 1170: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 97: 1171: UINT32 amend = scale / 2; -: 1172: UINT32 v; 97: 1173: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 97: 1174: x = box[2] / xscale; 97: 1175: y = box[3] / yscale; 526: 1176: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 429: 1177: UINT8 *line = (UINT8 *)imIn->image[yy]; 2935: 1178: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 85% branch 1 taken 15% (fallthrough) 2506: 1179: ss0 += line[xx*4 + 0]; 2506: 1180: ss1 += line[xx*4 + 1]; 2506: 1181: ss2 += line[xx*4 + 2]; 2506: 1182: ss3 += line[xx*4 + 3]; -: 1183: } -: 1184: } 97: 1185: v = MAKE_UINT32( -: 1186: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 1187: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 194: 1188: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1189: } -: 1190: } 384: 1191:} -: 1192: -: 1193: -: 1194:void function ImagingReduceNxN_32bpc called 108 returned 100% blocks executed 98% 108: 1195:ImagingReduceNxN_32bpc(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 1196:{ -: 1197: /* The most general implementation for any xscale and yscale -: 1198: */ -: 1199: int x, y, xx, yy; 108: 1200: double multiplier = 1.0 / (yscale * xscale); -: 1201: 108: 1202: switch(imIn->type) { branch 0 taken 50% branch 1 taken 50% branch 2 taken 0% -: 1203: case IMAGING_TYPE_INT32: 5930: 1204: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 5930: 1205: int yy_from = box[1] + y*yscale; 929243: 1206: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 923313: 1207: int xx_from = box[0] + x*xscale; 923313: 1208: double ss = 0; 1774613: 1209: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 48% branch 1 taken 52% (fallthrough) 851300: 1210: INT32 *line0 = (INT32 *)imIn->image32[yy]; 851300: 1211: INT32 *line1 = (INT32 *)imIn->image32[yy + 1]; 1466228: 1212: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 42% branch 1 taken 58% (fallthrough) 1844784: 1213: ss += line0[xx + 0] + line0[xx + 1] + 1229856: 1214: line1[xx + 0] + line1[xx + 1]; -: 1215: } 851300: 1216: if (xscale & 0x01) { branch 0 taken 76% (fallthrough) branch 1 taken 24% 645610: 1217: ss += line0[xx + 0] + line1[xx + 0]; -: 1218: } -: 1219: } 923313: 1220: if (yscale & 0x01) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 575077: 1221: INT32 *line = (INT32 *)imIn->image32[yy]; 1205882: 1222: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 52% branch 1 taken 48% (fallthrough) 630805: 1223: ss += line[xx + 0] + line[xx + 1]; -: 1224: } 575077: 1225: if (xscale & 0x01) { branch 0 taken 59% (fallthrough) branch 1 taken 41% 339587: 1226: ss += line[xx + 0]; -: 1227: } -: 1228: } 923313: 1229: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1230: } -: 1231: } -: 1232: break; -: 1233: -: 1234: case IMAGING_TYPE_FLOAT32: 5930: 1235: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5930: 1236: int yy_from = box[1] + y*yscale; 929243: 1237: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 923313: 1238: int xx_from = box[0] + x*xscale; 923313: 1239: double ss = 0; 1774613: 1240: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 48% branch 1 taken 52% (fallthrough) 851300: 1241: FLOAT32 *line0 = (FLOAT32 *)imIn->image32[yy]; 851300: 1242: FLOAT32 *line1 = (FLOAT32 *)imIn->image32[yy + 1]; 1466228: 1243: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 42% branch 1 taken 58% (fallthrough) 1844784: 1244: ss += line0[xx + 0] + line0[xx + 1] + 1229856: 1245: line1[xx + 0] + line1[xx + 1]; -: 1246: } 851300: 1247: if (xscale & 0x01) { branch 0 taken 76% (fallthrough) branch 1 taken 24% 645610: 1248: ss += line0[xx + 0] + line1[xx + 0]; -: 1249: } -: 1250: } 923313: 1251: if (yscale & 0x01) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 575077: 1252: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 1205882: 1253: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 52% branch 1 taken 48% (fallthrough) 630805: 1254: ss += line[xx + 0] + line[xx + 1]; -: 1255: } 575077: 1256: if (xscale & 0x01) { branch 0 taken 59% (fallthrough) branch 1 taken 41% 339587: 1257: ss += line[xx + 0]; -: 1258: } -: 1259: } 923313: 1260: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1261: } -: 1262: } -: 1263: break; -: 1264: } 108: 1265:} -: 1266: -: 1267: -: 1268:void function ImagingReduceCorners_32bpc called 108 returned 100% blocks executed 96% 108: 1269:ImagingReduceCorners_32bpc(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 1270:{ -: 1271: /* Fill the last row and the last column for any xscale and yscale. -: 1272: */ -: 1273: int x, y, xx, yy; -: 1274: 108: 1275: switch(imIn->type) { branch 0 taken 50% branch 1 taken 50% branch 2 taken 0% -: 1276: case IMAGING_TYPE_INT32: 54: 1277: if (box[2] % xscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% 26: 1278: double multiplier = 1.0 / ((box[2] % xscale) * yscale); 2867: 1279: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2841: 1280: int yy_from = box[1] + y*yscale; 2841: 1281: double ss = 0; 2841: 1282: x = box[2] / xscale; 9540: 1283: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 6699: 1284: INT32 *line = (INT32 *)imIn->image32[yy]; 28368: 1285: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 21669: 1286: ss += line[xx + 0]; -: 1287: } -: 1288: } 2841: 1289: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1290: } -: 1291: } 54: 1292: if (box[3] % yscale) { branch 0 taken 74% (fallthrough) branch 1 taken 26% 40: 1293: double multiplier = 1.0 / (xscale * (box[3] % yscale)); 40: 1294: y = box[3] / yscale; 4355: 1295: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4315: 1296: int xx_from = box[0] + x*xscale; 4315: 1297: double ss = 0; 14502: 1298: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 10187: 1299: INT32 *line = (INT32 *)imIn->image32[yy]; 42371: 1300: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 32184: 1301: ss += line[xx + 0]; -: 1302: } -: 1303: } 4315: 1304: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1305: } -: 1306: } 54: 1307: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% branch 2 taken 65% (fallthrough) branch 3 taken 35% 17: 1308: double multiplier = 1.0 / ((box[2] % xscale) * (box[3] % yscale)); 17: 1309: double ss = 0; 17: 1310: x = box[2] / xscale; 17: 1311: y = box[3] / yscale; 92: 1312: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 75: 1313: INT32 *line = (INT32 *)imIn->image32[yy]; 465: 1314: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 390: 1315: ss += line[xx + 0]; -: 1316: } -: 1317: } 17: 1318: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1319: } -: 1320: break; -: 1321: -: 1322: case IMAGING_TYPE_FLOAT32: 54: 1323: if (box[2] % xscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% 26: 1324: double multiplier = 1.0 / ((box[2] % xscale) * yscale); 2867: 1325: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2841: 1326: int yy_from = box[1] + y*yscale; 2841: 1327: double ss = 0; 2841: 1328: x = box[2] / xscale; 9540: 1329: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 6699: 1330: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 28368: 1331: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 21669: 1332: ss += line[xx + 0]; -: 1333: } -: 1334: } 2841: 1335: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1336: } -: 1337: } 54: 1338: if (box[3] % yscale) { branch 0 taken 74% (fallthrough) branch 1 taken 26% 40: 1339: double multiplier = 1.0 / (xscale * (box[3] % yscale)); 40: 1340: y = box[3] / yscale; 4355: 1341: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4315: 1342: int xx_from = box[0] + x*xscale; 4315: 1343: double ss = 0; 14502: 1344: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 10187: 1345: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 42371: 1346: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 32184: 1347: ss += line[xx + 0]; -: 1348: } -: 1349: } 4315: 1350: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1351: } -: 1352: } 54: 1353: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% branch 2 taken 65% (fallthrough) branch 3 taken 35% 17: 1354: double multiplier = 1.0 / ((box[2] % xscale) * (box[3] % yscale)); 17: 1355: double ss = 0; 17: 1356: x = box[2] / xscale; 17: 1357: y = box[3] / yscale; 92: 1358: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 75: 1359: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 465: 1360: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 390: 1361: ss += line[xx + 0]; -: 1362: } -: 1363: } 17: 1364: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1365: } -: 1366: break; -: 1367: } 108: 1368:} -: 1369: -: 1370: -: 1371:Imaging function ImagingReduce called 495 returned 100% blocks executed 100% 495: 1372:ImagingReduce(Imaging imIn, int xscale, int yscale, int box[4]) -: 1373:{ -: 1374: ImagingSectionCookie cookie; 495: 1375: Imaging imOut = NULL; -: 1376: 495: 1377: if (strcmp(imIn->mode, "P") == 0 || strcmp(imIn->mode, "1") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 1% (fallthrough) branch 7 taken 99% 2: 1378: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 1379: } -: 1380: 493: 1381: if (imIn->type == IMAGING_TYPE_SPECIAL) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 1382: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 1383: } -: 1384: 984: 1385: imOut = ImagingNewDirty(imIn->mode, call 0 returned 100% 492: 1386: (box[2] + xscale - 1) / xscale, 492: 1387: (box[3] + yscale - 1) / yscale); 492: 1388: if ( ! imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1389: return NULL; -: 1390: } -: 1391: 492: 1392: ImagingSectionEnter(&cookie); call 0 returned 100% -: 1393: 492: 1394: switch(imIn->type) { branch 0 taken 78% branch 1 taken 22% branch 2 taken 0% -: 1395: case IMAGING_TYPE_UINT8: 384: 1396: if (xscale == 1) { branch 0 taken 21% (fallthrough) branch 1 taken 79% 81: 1397: if (yscale == 2) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 20: 1398: ImagingReduce1x2(imOut, imIn, box); call 0 returned 100% 61: 1399: } else if (yscale == 3) { branch 0 taken 34% (fallthrough) branch 1 taken 66% 21: 1400: ImagingReduce1x3(imOut, imIn, box); call 0 returned 100% -: 1401: } else { 40: 1402: ImagingReduce1xN(imOut, imIn, box, yscale); call 0 returned 100% -: 1403: } 303: 1404: } else if (yscale == 1) { branch 0 taken 27% (fallthrough) branch 1 taken 73% 81: 1405: if (xscale == 2) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 20: 1406: ImagingReduce2x1(imOut, imIn, box); call 0 returned 100% 61: 1407: } else if (xscale == 3) { branch 0 taken 34% (fallthrough) branch 1 taken 66% 21: 1408: ImagingReduce3x1(imOut, imIn, box); call 0 returned 100% -: 1409: } else { 40: 1410: ImagingReduceNx1(imOut, imIn, box, xscale); call 0 returned 100% -: 1411: } 222: 1412: } else if (xscale == yscale && xscale <= 5) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 93: 1413: if (xscale == 2) { branch 0 taken 29% (fallthrough) branch 1 taken 71% 27: 1414: ImagingReduce2x2(imOut, imIn, box); call 0 returned 100% 66: 1415: } else if (xscale == 3) { branch 0 taken 39% (fallthrough) branch 1 taken 61% 26: 1416: ImagingReduce3x3(imOut, imIn, box); call 0 returned 100% 40: 1417: } else if (xscale == 4) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 20: 1418: ImagingReduce4x4(imOut, imIn, box); call 0 returned 100% -: 1419: } else { 20: 1420: ImagingReduce5x5(imOut, imIn, box); call 0 returned 100% -: 1421: } -: 1422: } else { 129: 1423: ImagingReduceNxN(imOut, imIn, box, xscale, yscale); call 0 returned 100% -: 1424: } -: 1425: 384: 1426: ImagingReduceCorners(imOut, imIn, box, xscale, yscale); call 0 returned 100% 384: 1427: break; -: 1428: -: 1429: case IMAGING_TYPE_INT32: -: 1430: case IMAGING_TYPE_FLOAT32: 108: 1431: ImagingReduceNxN_32bpc(imOut, imIn, box, xscale, yscale); call 0 returned 100% -: 1432: 108: 1433: ImagingReduceCorners_32bpc(imOut, imIn, box, xscale, yscale); call 0 returned 100% 108: 1434: break; -: 1435: } -: 1436: 492: 1437: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1438: 492: 1439: return imOut; -: 1440:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Access.c.gcov -: 0:Source:src/libImaging/Access.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Access.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Access.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * imaging access objects -: 6: * -: 7: * Copyright (c) Fredrik Lundh 2009. -: 8: * -: 9: * See the README file for information on usage and redistribution. -: 10: */ -: 11: -: 12: -: 13:#include "Imaging.h" -: 14: -: 15:/* use Tests/make_hash.py to calculate these values */ -: 16:#define ACCESS_TABLE_SIZE 27 -: 17:#define ACCESS_TABLE_HASH 3078 -: 18: -: 19:static struct ImagingAccessInstance access_table[ACCESS_TABLE_SIZE]; -: 20: -: 21:static inline UINT32 -: 22:hash(const char* mode) -: 23:{ 53741: 24: UINT32 i = ACCESS_TABLE_HASH; 147044: 25: while (*mode) { branch 0 taken 63% branch 1 taken 37% (fallthrough) branch 2 taken 76% branch 3 taken 24% (fallthrough) 93303: 26: i = ((i<<5) + i) ^ (UINT8) *mode++; -: 27: } 53741: 28: return i % ACCESS_TABLE_SIZE; -: 29:} -: 30: -: 31:static ImagingAccess function add_item called 63 returned 100% blocks executed 63% 63: 32:add_item(const char* mode) -: 33:{ 63: 34: UINT32 i = hash(mode); -: 35: /* printf("hash %s => %d\n", mode, i); */ 63: 36: if (access_table[i].mode && strcmp(access_table[i].mode, mode) != 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed #####: 37: fprintf(stderr, "AccessInit: hash collision: %d for both %s and %s\n", -: 38: i, mode, access_table[i].mode); #####: 39: exit(1); call 0 never executed -: 40: } 63: 41: access_table[i].mode = mode; 63: 42: return &access_table[i]; -: 43:} -: 44: -: 45:/* fetch pointer to pixel line */ -: 46: -: 47:static void* function line_8 called 0 returned 0% blocks executed 0% #####: 48:line_8(Imaging im, int x, int y) -: 49:{ #####: 50: return &im->image8[y][x]; -: 51:} -: 52: -: 53:static void* function line_16 called 0 returned 0% blocks executed 0% #####: 54:line_16(Imaging im, int x, int y) -: 55:{ #####: 56: return &im->image8[y][x+x]; -: 57:} -: 58: -: 59:static void* function line_32 called 0 returned 0% blocks executed 0% #####: 60:line_32(Imaging im, int x, int y) -: 61:{ #####: 62: return &im->image32[y][x]; -: 63:} -: 64: -: 65:/* fetch individual pixel */ -: 66: -: 67:static void function get_pixel called 30335 returned 100% blocks executed 71% 30335: 68:get_pixel(Imaging im, int x, int y, void* color) -: 69:{ 30335: 70: char* out = color; -: 71: -: 72: /* generic pixel access*/ -: 73: 30335: 74: if (im->image8) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 75: out[0] = im->image8[y][x]; -: 76: } else { 30335: 77: UINT8* p = (UINT8*) &im->image32[y][x]; 30335: 78: if (im->type == IMAGING_TYPE_UINT8 && im->bands == 2) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 30335: 79: out[0] = p[0]; 30335: 80: out[1] = p[3]; 30335: 81: return; -: 82: } #####: 83: memcpy(out, p, im->pixelsize); -: 84: } -: 85:} -: 86: -: 87:static void function get_pixel_8 called 4120100 returned 100% blocks executed 100% 4120100: 88:get_pixel_8(Imaging im, int x, int y, void* color) -: 89:{ 4120100: 90: char* out = color; 4120100: 91: out[0] = im->image8[y][x]; 4120100: 92:} -: 93: -: 94:static void function get_pixel_16L called 18037 returned 100% blocks executed 100% 18037: 95:get_pixel_16L(Imaging im, int x, int y, void* color) -: 96:{ 18037: 97: UINT8* in = (UINT8*) &im->image[y][x+x]; -: 98:#ifdef WORDS_BIGENDIAN -: 99: UINT16 out = in[0] + (in[1]<<8); -: 100: memcpy(color, &out, sizeof(out)); -: 101:#else 18037: 102: memcpy(color, in, sizeof(UINT16)); -: 103:#endif 18037: 104:} -: 105: -: 106:static void function get_pixel_16B called 9427 returned 100% blocks executed 100% 9427: 107:get_pixel_16B(Imaging im, int x, int y, void* color) -: 108:{ 9427: 109: UINT8* in = (UINT8*) &im->image[y][x+x]; -: 110:#ifdef WORDS_BIGENDIAN -: 111: memcpy(color, in, sizeof(UINT16)); -: 112:#else 9427: 113: UINT16 out = in[1] + (in[0]<<8); 9427: 114: memcpy(color, &out, sizeof(out)); -: 115:#endif 9427: 116:} -: 117: -: 118:static void function get_pixel_32 called 463564 returned 100% blocks executed 100% 463564: 119:get_pixel_32(Imaging im, int x, int y, void* color) -: 120:{ 927128: 121: memcpy(color, &im->image32[y][x], sizeof(INT32)); 463564: 122:} -: 123: -: 124:static void function get_pixel_32L called 0 returned 0% blocks executed 0% #####: 125:get_pixel_32L(Imaging im, int x, int y, void* color) -: 126:{ #####: 127: UINT8* in = (UINT8*) &im->image[y][x*4]; -: 128:#ifdef WORDS_BIGENDIAN -: 129: INT32 out = in[0] + (in[1]<<8) + (in[2]<<16) + (in[3]<<24); -: 130: memcpy(color, &out, sizeof(out)); -: 131:#else #####: 132: memcpy(color, in, sizeof(INT32)); -: 133:#endif #####: 134:} -: 135: -: 136:static void function get_pixel_32B called 0 returned 0% blocks executed 0% #####: 137:get_pixel_32B(Imaging im, int x, int y, void* color) -: 138:{ #####: 139: UINT8* in = (UINT8*) &im->image[y][x*4]; -: 140:#ifdef WORDS_BIGENDIAN -: 141: memcpy(color, in, sizeof(INT32)); -: 142:#else #####: 143: INT32 out = in[3] + (in[2]<<8) + (in[1]<<16) + (in[0]<<24); #####: 144: memcpy(color, &out, sizeof(out)); -: 145:#endif #####: 146:} -: 147: -: 148:/* store individual pixel */ -: 149: -: 150:static void function put_pixel called 5139 returned 100% blocks executed 75% 5139: 151:put_pixel(Imaging im, int x, int y, const void* color) -: 152:{ 5139: 153: if (im->image8) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 154: im->image8[y][x] = *((UINT8*) color); -: 155: } else { 5139: 156: memcpy(&im->image32[y][x], color, sizeof(INT32)); -: 157: } 5139: 158:} -: 159: -: 160:static void function put_pixel_8 called 211306 returned 100% blocks executed 100% 211306: 161:put_pixel_8(Imaging im, int x, int y, const void* color) -: 162:{ 211306: 163: im->image8[y][x] = *((UINT8*) color); 211306: 164:} -: 165: -: 166:static void function put_pixel_16L called 10546 returned 100% blocks executed 100% 10546: 167:put_pixel_16L(Imaging im, int x, int y, const void* color) -: 168:{ 21092: 169: memcpy(&im->image8[y][x+x], color, 2); 10546: 170:} -: 171: -: 172:static void function put_pixel_16B called 232 returned 100% blocks executed 100% 232: 173:put_pixel_16B(Imaging im, int x, int y, const void* color) -: 174:{ 232: 175: const char* in = color; 232: 176: UINT8* out = (UINT8*) &im->image8[y][x+x]; 232: 177: out[0] = in[1]; 232: 178: out[1] = in[0]; 232: 179:} -: 180: -: 181:static void function put_pixel_32L called 0 returned 0% blocks executed 0% #####: 182:put_pixel_32L(Imaging im, int x, int y, const void* color) -: 183:{ #####: 184: memcpy(&im->image8[y][x*4], color, 4); #####: 185:} -: 186: -: 187:static void function put_pixel_32B called 0 returned 0% blocks executed 0% #####: 188:put_pixel_32B(Imaging im, int x, int y, const void* color) -: 189:{ #####: 190: const char* in = color; #####: 191: UINT8* out = (UINT8*) &im->image8[y][x*4]; #####: 192: out[0] = in[3]; #####: 193: out[1] = in[2]; #####: 194: out[2] = in[1]; #####: 195: out[3] = in[0]; #####: 196:} -: 197: -: 198:static void function put_pixel_32 called 141120 returned 100% blocks executed 100% 141120: 199:put_pixel_32(Imaging im, int x, int y, const void* color) -: 200:{ 282240: 201: memcpy(&im->image32[y][x], color, sizeof(INT32)); 141120: 202:} -: 203: -: 204:void function ImagingAccessInit called 3 returned 100% blocks executed 100% 3: 205:ImagingAccessInit() -: 206:{ -: 207:#define ADD(mode_, line_, get_pixel_, put_pixel_) \ -: 208: { ImagingAccess access = add_item(mode_); \ -: 209: access->line = line_; \ -: 210: access->get_pixel = get_pixel_; \ -: 211: access->put_pixel = put_pixel_; \ -: 212: } -: 213: -: 214: /* populate access table */ 3: 215: ADD("1", line_8, get_pixel_8, put_pixel_8); call 0 returned 100% 3: 216: ADD("L", line_8, get_pixel_8, put_pixel_8); call 0 returned 100% 3: 217: ADD("LA", line_32, get_pixel, put_pixel); call 0 returned 100% 3: 218: ADD("La", line_32, get_pixel, put_pixel); call 0 returned 100% 3: 219: ADD("I", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 220: ADD("I;16", line_16, get_pixel_16L, put_pixel_16L); call 0 returned 100% 3: 221: ADD("I;16L", line_16, get_pixel_16L, put_pixel_16L); call 0 returned 100% 3: 222: ADD("I;16B", line_16, get_pixel_16B, put_pixel_16B); call 0 returned 100% 3: 223: ADD("I;32L", line_32, get_pixel_32L, put_pixel_32L); call 0 returned 100% 3: 224: ADD("I;32B", line_32, get_pixel_32B, put_pixel_32B); call 0 returned 100% 3: 225: ADD("F", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 226: ADD("P", line_8, get_pixel_8, put_pixel_8); call 0 returned 100% 3: 227: ADD("PA", line_32, get_pixel, put_pixel); call 0 returned 100% 3: 228: ADD("RGB", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 229: ADD("RGBA", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 230: ADD("RGBa", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 231: ADD("RGBX", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 232: ADD("CMYK", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 233: ADD("YCbCr", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 234: ADD("LAB", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 235: ADD("HSV", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 236:} -: 237: -: 238:ImagingAccess function ImagingAccessNew called 53678 returned 100% blocks executed 100% 53678: 239:ImagingAccessNew(Imaging im) -: 240:{ 107356: 241: ImagingAccess access = &access_table[hash(im->mode)]; 53678: 242: if (im->mode[0] != access->mode[0] || strcmp(im->mode, access->mode) != 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 243: return NULL; -: 244: } 53671: 245: return access; -: 246:} -: 247: -: 248:void function _ImagingAccessDelete called 0 returned 0% blocks executed 0% #####: 249:_ImagingAccessDelete(Imaging im, ImagingAccess access) -: 250:{ -: 251: #####: 252:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#TiffDecode.c.gcov -: 0:Source:src/libImaging/TiffDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/TiffDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/TiffDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id: //modules/pil/libImaging/TiffDecode.c#1 $ -: 4: * -: 5: * LibTiff-based Group3 and Group4 decoder -: 6: * -: 7: * -: 8: * started modding to use non-private tiff functions to port to libtiff 4.x -: 9: * eds 3/12/12 -: 10: * -: 11: */ -: 12: -: 13:#include "Imaging.h" -: 14: -: 15:#ifdef HAVE_LIBTIFF -: 16: -: 17:#ifndef uint -: 18:#define uint uint32 -: 19:#endif -: 20: -: 21:#include "TiffDecode.h" -: 22: -: 23:/* Convert C file descriptor to WinApi HFILE if LibTiff was compiled with tif_win32.c -: 24: * -: 25: * This cast is safe, as the top 32-bits of HFILE are guaranteed to be zero, -: 26: * see https://docs.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication -: 27: */ -: 28:#ifndef USE_WIN32_FILEIO -: 29:#define fd_to_tiff_fd(fd) (fd) -: 30:#else -: 31:#define fd_to_tiff_fd(fd) ((int)_get_osfhandle(fd)) -: 32:#endif -: 33: function dump_state called 683 returned 100% blocks executed 100% 683: 34:void dump_state(const TIFFSTATE *state){ -: 35: TRACE(("State: Location %u size %d eof %d data: %p ifd: %d\n", (uint)state->loc, -: 36: (int)state->size, (uint)state->eof, state->data, state->ifd)); 683: 37:} -: 38: -: 39:/* -: 40: procs for TIFFOpenClient -: 41:*/ -: 42: function _tiffReadProc called 54 returned 100% blocks executed 100% 54: 43:tsize_t _tiffReadProc(thandle_t hdata, tdata_t buf, tsize_t size) { 54: 44: TIFFSTATE *state = (TIFFSTATE *)hdata; -: 45: tsize_t to_read; -: 46: -: 47: TRACE(("_tiffReadProc: %d \n", (int)size)); 54: 48: dump_state(state); call 0 returned 100% -: 49: 54: 50: to_read = min(size, min(state->size, (tsize_t)state->eof) - (tsize_t)state->loc); -: 51: TRACE(("to_read: %d\n", (int)to_read)); -: 52: 54: 53: _TIFFmemcpy(buf, (UINT8 *)state->data + state->loc, to_read); call 0 returned 100% 54: 54: state->loc += (toff_t)to_read; -: 55: -: 56: TRACE( ("location: %u\n", (uint)state->loc)); 54: 57: return to_read; -: 58:} -: 59: function _tiffWriteProc called 85 returned 100% blocks executed 100% 85: 60:tsize_t _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) { 85: 61: TIFFSTATE *state = (TIFFSTATE *)hdata; -: 62: tsize_t to_write; -: 63: -: 64: TRACE(("_tiffWriteProc: %d \n", (int)size)); 85: 65: dump_state(state); call 0 returned 100% -: 66: 85: 67: to_write = min(size, state->size - (tsize_t)state->loc); 85: 68: if (state->flrealloc && size>to_write) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 1% (fallthrough) branch 3 taken 99% -: 69: tdata_t new_data; -: 70: tsize_t newsize=state->size; 5: 71: while (newsize < (size + state->size)) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 4: 72: if (newsize > INT_MAX - 64*1024){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 73: return 0; -: 74: } 4: 75: newsize += 64*1024; -: 76: // newsize*=2; // UNDONE, by 64k chunks? -: 77: } -: 78: TRACE(("Reallocing in write to %d bytes\n", (int)newsize)); -: 79: /* malloc check ok, overflow checked above */ 1: 80: new_data = realloc(state->data, newsize); 1: 81: if (!new_data) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 82: // fail out -: 83: return 0; -: 84: } 1: 85: state->data = new_data; 1: 86: state->size = newsize; 1: 87: to_write = size; -: 88: } -: 89: -: 90: TRACE(("to_write: %d\n", (int)to_write)); -: 91: 85: 92: _TIFFmemcpy((UINT8 *)state->data + state->loc, buf, to_write); call 0 returned 100% 85: 93: state->loc += (toff_t)to_write; 85: 94: state->eof = max(state->loc, state->eof); -: 95: 85: 96: dump_state(state); call 0 returned 100% 85: 97: return to_write; -: 98:} -: 99: function _tiffSeekProc called 98 returned 100% blocks executed 86% 98: 100:toff_t _tiffSeekProc(thandle_t hdata, toff_t off, int whence) { 98: 101: TIFFSTATE *state = (TIFFSTATE *)hdata; -: 102: -: 103: TRACE(("_tiffSeekProc: off: %u whence: %d \n", (uint)off, whence)); 98: 104: dump_state(state); call 0 returned 100% 98: 105: switch (whence) { branch 0 taken 71% branch 1 taken 0% branch 2 taken 29% branch 3 taken 0% -: 106: case 0: 70: 107: state->loc = off; 70: 108: break; -: 109: case 1: #####: 110: state->loc += off; #####: 111: break; -: 112: case 2: 28: 113: state->loc = state->eof + off; 28: 114: break; -: 115: } 98: 116: dump_state(state); call 0 returned 100% 98: 117: return state->loc; -: 118:} -: 119: function _tiffCloseProc called 24 returned 100% blocks executed 100% 24: 120:int _tiffCloseProc(thandle_t hdata) { 24: 121: TIFFSTATE *state = (TIFFSTATE *)hdata; -: 122: -: 123: TRACE(("_tiffCloseProc \n")); 24: 124: dump_state(state); call 0 returned 100% -: 125: 24: 126: return 0; -: 127:} -: 128: -: 129: function _tiffSizeProc called 4 returned 100% blocks executed 100% 4: 130:toff_t _tiffSizeProc(thandle_t hdata) { 4: 131: TIFFSTATE *state = (TIFFSTATE *)hdata; -: 132: -: 133: TRACE(("_tiffSizeProc \n")); 4: 134: dump_state(state); call 0 returned 100% -: 135: 4: 136: return (toff_t)state->size; -: 137:} -: 138: function _tiffMapProc called 10 returned 100% blocks executed 100% 10: 139:int _tiffMapProc(thandle_t hdata, tdata_t* pbase, toff_t* psize) { 10: 140: TIFFSTATE *state = (TIFFSTATE *)hdata; -: 141: -: 142: TRACE(("_tiffMapProc input size: %u, data: %p\n", (uint)*psize, *pbase)); 10: 143: dump_state(state); call 0 returned 100% -: 144: 10: 145: *pbase = state->data; 10: 146: *psize = state->size; -: 147: TRACE(("_tiffMapProc returning size: %u, data: %p\n", (uint)*psize, *pbase)); 10: 148: return (1); -: 149:} -: 150: function _tiffNullMapProc called 0 returned 0% blocks executed 0% #####: 151:int _tiffNullMapProc(thandle_t hdata, tdata_t* pbase, toff_t* psize) { -: 152: (void) hdata; (void) pbase; (void) psize; #####: 153: return (0); -: 154:} -: 155: function _tiffUnmapProc called 10 returned 100% blocks executed 100% 10: 156:void _tiffUnmapProc(thandle_t hdata, tdata_t base, toff_t size) { -: 157: TRACE(("_tiffUnMapProc\n")); -: 158: (void) hdata; (void) base; (void) size; 10: 159:} -: 160: function ImagingLibTiffInit called 77 returned 100% blocks executed 100% 77: 161:int ImagingLibTiffInit(ImagingCodecState state, int fp, uint32 offset) { 77: 162: TIFFSTATE *clientstate = (TIFFSTATE *)state->context; -: 163: -: 164: TRACE(("initing libtiff\n")); -: 165: TRACE(("filepointer: %d \n", fp)); -: 166: TRACE(("State: count %d, state %d, x %d, y %d, ystep %d\n", state->count, state->state, -: 167: state->x, state->y, state->ystep)); -: 168: TRACE(("State: xsize %d, ysize %d, xoff %d, yoff %d \n", state->xsize, state->ysize, -: 169: state->xoff, state->yoff)); -: 170: TRACE(("State: bits %d, bytes %d \n", state->bits, state->bytes)); -: 171: TRACE(("State: context %p \n", state->context)); -: 172: 77: 173: clientstate->loc = 0; 77: 174: clientstate->size = 0; 77: 175: clientstate->data = 0; 77: 176: clientstate->fp = fp; 77: 177: clientstate->ifd = offset; 77: 178: clientstate->eof = 0; -: 179: 77: 180: return 1; -: 181:} -: 182: -: 183: function ReadTile called 23 returned 100% blocks executed 100% 23: 184:int ReadTile(TIFF* tiff, UINT32 col, UINT32 row, UINT32* buffer) { 23: 185: uint16 photometric = 0; -: 186: 23: 187: TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); call 0 returned 100% -: 188: -: 189: // To avoid dealing with YCbCr subsampling, let libtiff handle it 23: 190: if (photometric == PHOTOMETRIC_YCBCR) { branch 0 taken 26% (fallthrough) branch 1 taken 74% -: 191: UINT32 tile_width, tile_height, swap_line_size, i_row; -: 192: UINT32* swap_line; -: 193: 6: 194: TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_width); call 0 returned 100% 6: 195: TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_height); call 0 returned 100% -: 196: 6: 197: swap_line_size = tile_width * sizeof(UINT32); 6: 198: if (tile_width != swap_line_size / sizeof(UINT32)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 199: return -1; -: 200: } -: 201: -: 202: /* Read the tile into an RGBA array */ 6: 203: if (!TIFFReadRGBATile(tiff, col, row, buffer)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 204: return -1; -: 205: } -: 206: 6: 207: swap_line = (UINT32*)malloc(swap_line_size); 6: 208: if (swap_line == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 209: return -1; -: 210: } -: 211: /* -: 212: * For some reason the TIFFReadRGBATile() function chooses the -: 213: * lower left corner as the origin. Vertically mirror scanlines. -: 214: */ 768: 215: for(i_row = 0; i_row < tile_height / 2; i_row++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 216: UINT32 *top_line, *bottom_line; -: 217: 768: 218: top_line = buffer + tile_width * i_row; 768: 219: bottom_line = buffer + tile_width * (tile_height - i_row - 1); -: 220: 1536: 221: memcpy(swap_line, top_line, 4*tile_width); 1536: 222: memcpy(top_line, bottom_line, 4*tile_width); 1536: 223: memcpy(bottom_line, swap_line, 4*tile_width); -: 224: } -: 225: 6: 226: free(swap_line); -: 227: 6: 228: return 0; -: 229: } -: 230: 17: 231: if (TIFFReadTile(tiff, (tdata_t)buffer, col, row, 0, 0) == -1) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 232: TRACE(("Decode Error, Tile at %dx%d\n", col, row)); -: 233: return -1; -: 234: } -: 235: -: 236: TRACE(("Successfully read tile at %dx%d; \n\n", col, row)); -: 237: 17: 238: return 0; -: 239:} -: 240: function ReadStrip called 213 returned 100% blocks executed 100% 213: 241:int ReadStrip(TIFF* tiff, UINT32 row, UINT32* buffer) { 213: 242: uint16 photometric = 0; // init to not PHOTOMETRIC_YCBCR 213: 243: TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); call 0 returned 100% -: 244: -: 245: // To avoid dealing with YCbCr subsampling, let libtiff handle it 213: 246: if (photometric == PHOTOMETRIC_YCBCR) { branch 0 taken 15% (fallthrough) branch 1 taken 85% -: 247: TIFFRGBAImage img; 32: 248: char emsg[1024] = ""; -: 249: UINT32 rows_per_strip, rows_to_read; -: 250: int ok; -: 251: -: 252: 32: 253: TIFFGetFieldDefaulted(tiff, TIFFTAG_ROWSPERSTRIP, &rows_per_strip); call 0 returned 100% 32: 254: if ((row % rows_per_strip) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 255: TRACE(("Row passed to ReadStrip() must be first in a strip.")); -: 256: return -1; -: 257: } -: 258: 32: 259: if (TIFFRGBAImageOK(tiff, emsg) && TIFFRGBAImageBegin(&img, tiff, 0, emsg)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% call 3 returned 100% branch 4 taken 100% (fallthrough) branch 5 taken 0% -: 260: TRACE(("Initialized RGBAImage\n")); -: 261: 32: 262: img.req_orientation = ORIENTATION_TOPLEFT; 32: 263: img.row_offset = row; 32: 264: img.col_offset = 0; -: 265: 32: 266: rows_to_read = min(rows_per_strip, img.height - row); -: 267: -: 268: TRACE(("rows to read: %d\n", rows_to_read)); 32: 269: ok = TIFFRGBAImageGet(&img, buffer, img.width, rows_to_read); call 0 returned 100% -: 270: 32: 271: TIFFRGBAImageEnd(&img); call 0 returned 100% -: 272: } else { -: 273: ok = 0; -: 274: } -: 275: 32: 276: if (ok == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 277: TRACE(("Decode Error, row %d; msg: %s\n", row, emsg)); -: 278: return -1; -: 279: } -: 280: 32: 281: return 0; -: 282: } -: 283: 181: 284: if (TIFFReadEncodedStrip(tiff, TIFFComputeStrip(tiff, row, 0), (tdata_t)buffer, -1) == -1) { call 0 returned 100% call 1 returned 100% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 285: TRACE(("Decode Error, strip %d\n", TIFFComputeStrip(tiff, row, 0))); -: 286: return -1; -: 287: } -: 288: 181: 289: return 0; -: 290:} -: 291: function ImagingLibTiffDecode called 77 returned 100% blocks executed 79% 77: 292:int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_ssize_t bytes) { 77: 293: TIFFSTATE *clientstate = (TIFFSTATE *)state->context; 77: 294: char *filename = "tempfile.tif"; 77: 295: char *mode = "r"; -: 296: TIFF *tiff; -: 297: -: 298: /* buffer is the encoded file, bytes is the length of the encoded file */ -: 299: /* it all ends up in state->buffer, which is a uint8* from Imaging.h */ -: 300: -: 301: TRACE(("in decoder: bytes %d\n", bytes)); -: 302: TRACE(("State: count %d, state %d, x %d, y %d, ystep %d\n", state->count, state->state, -: 303: state->x, state->y, state->ystep)); -: 304: TRACE(("State: xsize %d, ysize %d, xoff %d, yoff %d \n", state->xsize, state->ysize, -: 305: state->xoff, state->yoff)); -: 306: TRACE(("State: bits %d, bytes %d \n", state->bits, state->bytes)); -: 307: TRACE(("Buffer: %p: %c%c%c%c\n", buffer, (char)buffer[0], (char)buffer[1],(char)buffer[2], (char)buffer[3])); -: 308: TRACE(("State->Buffer: %c%c%c%c\n", (char)state->buffer[0], (char)state->buffer[1],(char)state->buffer[2], (char)state->buffer[3])); -: 309: TRACE(("Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \n", -: 310: im->mode, im->type, im->bands, im->xsize, im->ysize)); -: 311: TRACE(("Image: image8 %p, image32 %p, image %p, block %p \n", -: 312: im->image8, im->image32, im->image, im->block)); -: 313: TRACE(("Image: pixelsize: %d, linesize %d \n", -: 314: im->pixelsize, im->linesize)); -: 315: 77: 316: dump_state(clientstate); call 0 returned 100% 77: 317: clientstate->size = bytes; 77: 318: clientstate->eof = clientstate->size; 77: 319: clientstate->loc = 0; 77: 320: clientstate->data = (tdata_t)buffer; 77: 321: clientstate->flrealloc = 0; 77: 322: dump_state(clientstate); call 0 returned 100% -: 323: 77: 324: TIFFSetWarningHandler(NULL); call 0 returned 100% 77: 325: TIFFSetWarningHandlerExt(NULL); call 0 returned 100% -: 326: 77: 327: if (clientstate->fp) { branch 0 taken 87% (fallthrough) branch 1 taken 13% -: 328: TRACE(("Opening using fd: %d\n",clientstate->fp)); 67: 329: lseek(clientstate->fp,0,SEEK_SET); // Sometimes, I get it set to the end. call 0 returned 100% 67: 330: tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode); call 0 returned 100% -: 331: } else { -: 332: TRACE(("Opening from string\n")); 10: 333: tiff = TIFFClientOpen(filename, mode, call 0 returned 100% -: 334: (thandle_t) clientstate, -: 335: _tiffReadProc, _tiffWriteProc, -: 336: _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, -: 337: _tiffMapProc, _tiffUnmapProc); -: 338: } -: 339: 77: 340: if (!tiff){ branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 341: TRACE(("Error, didn't get the tiff\n")); #####: 342: state->errcode = IMAGING_CODEC_BROKEN; #####: 343: return -1; -: 344: } -: 345: 77: 346: if (clientstate->ifd){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 347: int rv; 77: 348: uint32 ifdoffset = clientstate->ifd; -: 349: TRACE(("reading tiff ifd %u\n", ifdoffset)); 77: 350: rv = TIFFSetSubDirectory(tiff, ifdoffset); call 0 returned 100% 77: 351: if (!rv){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 352: TRACE(("error in TIFFSetSubDirectory")); -: 353: return -1; -: 354: } -: 355: } -: 356: 77: 357: if (TIFFIsTiled(tiff)) { call 0 returned 100% branch 1 taken 5% (fallthrough) branch 2 taken 95% -: 358: INT32 x, y, tile_y; -: 359: UINT32 tile_width, tile_length, current_tile_width, row_byte_size; -: 360: UINT8 *new_data; -: 361: 4: 362: TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_width); call 0 returned 100% 4: 363: TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_length); call 0 returned 100% -: 364: -: 365: /* overflow check for row_byte_size calculation */ 4: 366: if ((UINT32) INT_MAX / state->bits < tile_width) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 367: state->errcode = IMAGING_CODEC_MEMORY; #####: 368: TIFFClose(tiff); call 0 never executed #####: 369: return -1; -: 370: } -: 371: -: 372: // We could use TIFFTileSize, but for YCbCr data it returns subsampled data size 4: 373: row_byte_size = (tile_width * state->bits + 7) / 8; -: 374: -: 375: /* overflow check for realloc */ 4: 376: if (INT_MAX / row_byte_size < tile_length) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 377: state->errcode = IMAGING_CODEC_MEMORY; #####: 378: TIFFClose(tiff); call 0 never executed #####: 379: return -1; -: 380: } -: 381: 4: 382: state->bytes = row_byte_size * tile_length; -: 383: 4: 384: if (TIFFTileSize(tiff) > state->bytes) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 385: // If the strip size as expected by LibTiff isn't what we're expecting, abort. #####: 386: state->errcode = IMAGING_CODEC_MEMORY; #####: 387: TIFFClose(tiff); call 0 never executed #####: 388: return -1; -: 389: } -: 390: -: 391: /* realloc to fit whole tile */ -: 392: /* malloc check above */ 4: 393: new_data = realloc (state->buffer, state->bytes); 4: 394: if (!new_data) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 395: state->errcode = IMAGING_CODEC_MEMORY; #####: 396: TIFFClose(tiff); call 0 never executed #####: 397: return -1; -: 398: } -: 399: 4: 400: state->buffer = new_data; -: 401: -: 402: TRACE(("TIFFTileSize: %d\n", state->bytes)); -: 403: 12: 404: for (y = state->yoff; y < state->ysize; y += tile_length) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 31: 405: for (x = state->xoff; x < state->xsize; x += tile_width) { branch 0 taken 74% branch 1 taken 26% (fallthrough) 23: 406: if (ReadTile(tiff, x, y, (UINT32*) state->buffer) == -1) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 407: TRACE(("Decode Error, Tile at %dx%d\n", x, y)); #####: 408: state->errcode = IMAGING_CODEC_BROKEN; #####: 409: TIFFClose(tiff); call 0 never executed #####: 410: return -1; -: 411: } -: 412: -: 413: TRACE(("Read tile at %dx%d; \n\n", x, y)); -: 414: 23: 415: current_tile_width = min((INT32) tile_width, state->xsize - x); -: 416: -: 417: // iterate over each line in the tile and stuff data into image 1633: 418: for (tile_y = 0; tile_y < min((INT32) tile_length, state->ysize - y); tile_y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 419: TRACE(("Writing tile data at %dx%d using tile_width: %d; \n", tile_y + y, x, current_tile_width)); -: 420: -: 421: // UINT8 * bbb = state->buffer + tile_y * row_byte_size; -: 422: // TRACE(("chars: %x%x%x%x\n", ((UINT8 *)bbb)[0], ((UINT8 *)bbb)[1], ((UINT8 *)bbb)[2], ((UINT8 *)bbb)[3])); -: 423: 3220: 424: state->shuffle((UINT8*) im->image[tile_y + y] + x * im->pixelsize, call 0 returned 100% 1610: 425: state->buffer + tile_y * row_byte_size, -: 426: current_tile_width -: 427: ); -: 428: } -: 429: } -: 430: } -: 431: } else { -: 432: INT32 strip_row; -: 433: UINT8 *new_data; -: 434: UINT32 rows_per_strip, row_byte_size; -: 435: int ret; -: 436: 73: 437: ret = TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &rows_per_strip); call 0 returned 100% 73: 438: if (ret != 1) { branch 0 taken 4% (fallthrough) branch 1 taken 96% 3: 439: rows_per_strip = state->ysize; -: 440: } -: 441: TRACE(("RowsPerStrip: %u \n", rows_per_strip)); -: 442: -: 443: // We could use TIFFStripSize, but for YCbCr data it returns subsampled data size 73: 444: row_byte_size = (state->xsize * state->bits + 7) / 8; -: 445: -: 446: /* overflow check for realloc */ 73: 447: if (INT_MAX / row_byte_size < rows_per_strip) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 448: state->errcode = IMAGING_CODEC_MEMORY; 1: 449: TIFFClose(tiff); call 0 returned 100% 1: 450: return -1; -: 451: } -: 452: 72: 453: state->bytes = rows_per_strip * row_byte_size; -: 454: -: 455: TRACE(("StripSize: %d \n", state->bytes)); -: 456: 72: 457: if (TIFFStripSize(tiff) > state->bytes) { call 0 returned 100% branch 1 taken 3% (fallthrough) branch 2 taken 97% -: 458: // If the strip size as expected by LibTiff isn't what we're expecting, abort. -: 459: // man: TIFFStripSize returns the equivalent size for a strip of data as it would be returned in a -: 460: // call to TIFFReadEncodedStrip ... -: 461: 2: 462: state->errcode = IMAGING_CODEC_MEMORY; 2: 463: TIFFClose(tiff); call 0 returned 100% 2: 464: return -1; -: 465: } -: 466: -: 467: /* realloc to fit whole strip */ -: 468: /* malloc check above */ 70: 469: new_data = realloc (state->buffer, state->bytes); 70: 470: if (!new_data) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 471: state->errcode = IMAGING_CODEC_MEMORY; #####: 472: TIFFClose(tiff); call 0 never executed #####: 473: return -1; -: 474: } -: 475: 70: 476: state->buffer = new_data; -: 477: 283: 478: for (; state->y < state->ysize; state->y += rows_per_strip) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 213: 479: if (ReadStrip(tiff, state->y, (UINT32 *)state->buffer) == -1) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 480: TRACE(("Decode Error, strip %d\n", TIFFComputeStrip(tiff, state->y, 0))); #####: 481: state->errcode = IMAGING_CODEC_BROKEN; #####: 482: TIFFClose(tiff); call 0 never executed #####: 483: return -1; -: 484: } -: 485: -: 486: TRACE(("Decoded strip for row %d \n", state->y)); -: 487: -: 488: // iterate over each row in the strip and stuff data into image 27344: 489: for (strip_row = 0; strip_row < min((INT32) rows_per_strip, state->ysize - state->y); strip_row++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 490: TRACE(("Writing data into line %d ; \n", state->y + strip_row)); -: 491: -: 492: // UINT8 * bbb = state->buffer + strip_row * (state->bytes / rows_per_strip); -: 493: // TRACE(("chars: %x %x %x %x\n", ((UINT8 *)bbb)[0], ((UINT8 *)bbb)[1], ((UINT8 *)bbb)[2], ((UINT8 *)bbb)[3])); -: 494: 82032: 495: state->shuffle((UINT8*) im->image[state->y + state->yoff + strip_row] + call 0 returned 100% 27344: 496: state->xoff * im->pixelsize, 27344: 497: state->buffer + strip_row * row_byte_size, -: 498: state->xsize); -: 499: } -: 500: } -: 501: } -: 502: 74: 503: TIFFClose(tiff); call 0 returned 100% -: 504: TRACE(("Done Decoding, Returning \n")); -: 505: // Returning -1 here to force ImageFile.load to break, rather than -: 506: // even think about looping back around. 74: 507: return -1; -: 508:} -: 509: function ImagingLibTiffEncodeInit called 41 returned 100% blocks executed 100% 41: 510:int ImagingLibTiffEncodeInit(ImagingCodecState state, char *filename, int fp) { -: 511: // Open the FD or the pointer as a tiff file, for writing. -: 512: // We may have to do some monkeying around to make this really work. -: 513: // If we have a fp, then we're good. -: 514: // If we have a memory string, we're probably going to have to malloc, then -: 515: // shuffle bytes into the writescanline process. -: 516: // Going to have to deal with the directory as well. -: 517: 41: 518: TIFFSTATE *clientstate = (TIFFSTATE *)state->context; 41: 519: int bufsize = 64*1024; 41: 520: char *mode = "w"; -: 521: -: 522: TRACE(("initing libtiff\n")); -: 523: TRACE(("Filename %s, filepointer: %d \n", filename, fp)); -: 524: TRACE(("State: count %d, state %d, x %d, y %d, ystep %d\n", state->count, state->state, -: 525: state->x, state->y, state->ystep)); -: 526: TRACE(("State: xsize %d, ysize %d, xoff %d, yoff %d \n", state->xsize, state->ysize, -: 527: state->xoff, state->yoff)); -: 528: TRACE(("State: bits %d, bytes %d \n", state->bits, state->bytes)); -: 529: TRACE(("State: context %p \n", state->context)); -: 530: 41: 531: clientstate->loc = 0; 41: 532: clientstate->size = 0; 41: 533: clientstate->eof =0; 41: 534: clientstate->data = 0; 41: 535: clientstate->flrealloc = 0; 41: 536: clientstate->fp = fp; -: 537: 41: 538: state->state = 0; -: 539: 41: 540: if (fp) { branch 0 taken 66% (fallthrough) branch 1 taken 34% -: 541: TRACE(("Opening using fd: %d for writing \n",clientstate->fp)); 27: 542: clientstate->tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode); call 0 returned 100% -: 543: } else { -: 544: // malloc a buffer to write the tif, we're going to need to realloc or something if we need bigger. -: 545: TRACE(("Opening a buffer for writing \n")); -: 546: /* malloc check ok, small constant allocation */ 14: 547: clientstate->data = malloc(bufsize); 14: 548: clientstate->size = bufsize; 14: 549: clientstate->flrealloc=1; -: 550: 14: 551: if (!clientstate->data) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 552: TRACE(("Error, couldn't allocate a buffer of size %d\n", bufsize)); -: 553: return 0; -: 554: } -: 555: 14: 556: clientstate->tiff = TIFFClientOpen(filename, mode, call 0 returned 100% -: 557: (thandle_t) clientstate, -: 558: _tiffReadProc, _tiffWriteProc, -: 559: _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, -: 560: _tiffNullMapProc, _tiffUnmapProc); /*force no mmap*/ -: 561: -: 562: } -: 563: 41: 564: if (!clientstate->tiff) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 565: TRACE(("Error, couldn't open tiff file\n")); -: 566: return 0; -: 567: } -: 568: 41: 569: return 1; -: 570: -: 571:} -: 572: function ImagingLibTiffMergeFieldInfo called 48 returned 100% blocks executed 100% 48: 573:int ImagingLibTiffMergeFieldInfo(ImagingCodecState state, TIFFDataType field_type, int key, int is_var_length){ -: 574: // Refer to libtiff docs (http://www.simplesystems.org/libtiff/addingtags.html) 48: 575: TIFFSTATE *clientstate = (TIFFSTATE *)state->context; -: 576: char field_name[10]; -: 577: uint32 n; 48: 578: int status = 0; -: 579: -: 580: // custom fields added with ImagingLibTiffMergeFieldInfo are only used for -: 581: // decoding, ignore readcount; 48: 582: int readcount = 0; -: 583: // we support writing a single value, or a variable number of values 48: 584: int writecount = 1; -: 585: // whether the first value should encode the number of values. 48: 586: int passcount = 0; -: 587: 48: 588: TIFFFieldInfo info[] = { -: 589: { key, readcount, writecount, field_type, FIELD_CUSTOM, 1, passcount, field_name } -: 590: }; -: 591: 48: 592: if (is_var_length) { branch 0 taken 38% (fallthrough) branch 1 taken 63% 18: 593: info[0].field_writecount = -1; -: 594: } -: 595: 48: 596: if (is_var_length && field_type != TIFF_ASCII) { branch 0 taken 38% (fallthrough) branch 1 taken 63% 18: 597: info[0].field_passcount = 1; -: 598: } -: 599: 48: 600: n = sizeof(info) / sizeof(info[0]); -: 601: -: 602: // Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7 -: 603:#if TIFFLIB_VERSION >= 20111221 && TIFFLIB_VERSION != 20120218 && TIFFLIB_VERSION != 20120922 48: 604: status = TIFFMergeFieldInfo(clientstate->tiff, info, n); call 0 returned 100% -: 605:#else -: 606: TIFFMergeFieldInfo(clientstate->tiff, info, n); -: 607:#endif 48: 608: return status; -: 609:} -: 610: function ImagingLibTiffSetField called 510 returned 100% blocks executed 100% 510: 611:int ImagingLibTiffSetField(ImagingCodecState state, ttag_t tag, ...){ -: 612: // after tif_dir.c->TIFFSetField. 510: 613: TIFFSTATE *clientstate = (TIFFSTATE *)state->context; -: 614: va_list ap; -: 615: int status; -: 616: 510: 617: va_start(ap, tag); 510: 618: status = TIFFVSetField(clientstate->tiff, tag, ap); call 0 returned 100% 510: 619: va_end(ap); 510: 620: return status; -: 621:} -: 622: -: 623: function ImagingLibTiffEncode called 71 returned 100% blocks executed 77% 71: 624:int ImagingLibTiffEncode(Imaging im, ImagingCodecState state, UINT8* buffer, int bytes) { -: 625: /* One shot encoder. Encode everything to the tiff in the clientstate. -: 626: If we're running off of a FD, then run once, we're good, everything -: 627: ends up in the file, we close and we're done. -: 628: -: 629: If we're going to memory, then we need to write the whole file into memory, then -: 630: parcel it back out to the pystring buffer bytes at a time. -: 631: -: 632: */ -: 633: 71: 634: TIFFSTATE *clientstate = (TIFFSTATE *)state->context; 71: 635: TIFF *tiff = clientstate->tiff; -: 636: -: 637: TRACE(("in encoder: bytes %d\n", bytes)); -: 638: TRACE(("State: count %d, state %d, x %d, y %d, ystep %d\n", state->count, state->state, -: 639: state->x, state->y, state->ystep)); -: 640: TRACE(("State: xsize %d, ysize %d, xoff %d, yoff %d \n", state->xsize, state->ysize, -: 641: state->xoff, state->yoff)); -: 642: TRACE(("State: bits %d, bytes %d \n", state->bits, state->bytes)); -: 643: TRACE(("Buffer: %p: %c%c%c%c\n", buffer, (char)buffer[0], (char)buffer[1],(char)buffer[2], (char)buffer[3])); -: 644: TRACE(("State->Buffer: %c%c%c%c\n", (char)state->buffer[0], (char)state->buffer[1],(char)state->buffer[2], (char)state->buffer[3])); -: 645: TRACE(("Image: mode %s, type %d, bands: %d, xsize %d, ysize %d \n", -: 646: im->mode, im->type, im->bands, im->xsize, im->ysize)); -: 647: TRACE(("Image: image8 %p, image32 %p, image %p, block %p \n", -: 648: im->image8, im->image32, im->image, im->block)); -: 649: TRACE(("Image: pixelsize: %d, linesize %d \n", -: 650: im->pixelsize, im->linesize)); -: 651: 71: 652: dump_state(clientstate); call 0 returned 100% -: 653: 71: 654: if (state->state == 0) { branch 0 taken 58% (fallthrough) branch 1 taken 42% -: 655: TRACE(("Encoding line bt line")); 16802: 656: while(state->y < state->ysize){ branch 0 taken 99% branch 1 taken 1% (fallthrough) 33522: 657: state->shuffle(state->buffer, call 0 returned 100% 16761: 658: (UINT8*) im->image[state->y + state->yoff] + 16761: 659: state->xoff * im->pixelsize, -: 660: state->xsize); -: 661: 16761: 662: if (TIFFWriteScanline(tiff, (tdata_t)(state->buffer), (uint32)state->y, 0) == -1) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 663: TRACE(("Encode Error, row %d\n", state->y)); #####: 664: state->errcode = IMAGING_CODEC_BROKEN; #####: 665: TIFFClose(tiff); call 0 never executed #####: 666: if (!clientstate->fp){ branch 0 never executed branch 1 never executed #####: 667: free(clientstate->data); -: 668: } -: 669: return -1; -: 670: } 16761: 671: state->y++; -: 672: } -: 673: 41: 674: if (state->y == state->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 41: 675: state->state=1; -: 676: -: 677: TRACE(("Flushing \n")); 41: 678: if (!TIFFFlush(tiff)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 679: TRACE(("Error flushing the tiff")); -: 680: // likely reason is memory. #####: 681: state->errcode = IMAGING_CODEC_MEMORY; #####: 682: TIFFClose(tiff); call 0 never executed #####: 683: if (!clientstate->fp){ branch 0 never executed branch 1 never executed #####: 684: free(clientstate->data); -: 685: } -: 686: return -1; -: 687: } -: 688: TRACE(("Closing \n")); 41: 689: TIFFClose(tiff); call 0 returned 100% -: 690: // reset the clientstate metadata to use it to read out the buffer. 41: 691: clientstate->loc = 0; 41: 692: clientstate->size = clientstate->eof; // redundant? -: 693: } -: 694: } -: 695: 71: 696: if (state->state == 1 && !clientstate->fp) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 62% (fallthrough) branch 3 taken 38% 44: 697: int read = (int)_tiffReadProc(clientstate, (tdata_t)buffer, (tsize_t)bytes); call 0 returned 100% -: 698: TRACE(("Buffer: %p: %c%c%c%c\n", buffer, (char)buffer[0], (char)buffer[1],(char)buffer[2], (char)buffer[3])); 44: 699: if (clientstate->loc == clientstate->eof) { branch 0 taken 32% (fallthrough) branch 1 taken 68% -: 700: TRACE(("Hit EOF, calling an end, freeing data")); 14: 701: state->errcode = IMAGING_CODEC_END; 14: 702: free(clientstate->data); -: 703: } -: 704: return read; -: 705: } -: 706: 27: 707: state->errcode = IMAGING_CODEC_END; 27: 708: return 0; -: 709:} -: 710: -: 711:const char* function ImagingTiffVersion called 3 returned 100% blocks executed 100% 3: 712:ImagingTiffVersion(void) -: 713:{ 3: 714: return TIFFGetVersion(); call 0 returned 100% -: 715:} -: 716: -: 717:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#path.c.gcov -: 0:Source:src/path.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/path.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/path.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * 2D path utilities -: 5: * -: 6: * history: -: 7: * 1996-11-04 fl Added to PIL (incomplete) -: 8: * 1996-11-05 fl Added sequence semantics -: 9: * 1997-02-28 fl Fixed getbbox -: 10: * 1997-06-12 fl Added id attribute -: 11: * 1997-06-14 fl Added slicing and setitem -: 12: * 1998-12-29 fl Improved sequence handling (from Richard Jones) -: 13: * 1999-01-10 fl Fixed IndexError test for 1.5 (from Fred Drake) -: 14: * 2000-10-12 fl Added special cases for tuples and lists -: 15: * 2002-10-27 fl Added clipping boilerplate -: 16: * 2004-09-19 fl Added tolist(flat) variant -: 17: * 2005-05-06 fl Added buffer interface support to path constructor -: 18: * -: 19: * notes: -: 20: * FIXME: fill in remaining slots in the sequence api -: 21: * -: 22: * Copyright (c) 1997-2005 by Secret Labs AB -: 23: * Copyright (c) 1997-2005 by Fredrik Lundh -: 24: * -: 25: * See the README file for information on usage and redistribution. -: 26: */ -: 27: -: 28: -: 29:#include "Python.h" -: 30:#include "libImaging/Imaging.h" -: 31: -: 32:#include -: 33: -: 34:/* compatibility wrappers (defined in _imaging.c) */ -: 35:extern int PyImaging_CheckBuffer(PyObject* buffer); -: 36:extern int PyImaging_GetBuffer(PyObject* buffer, Py_buffer *view); -: 37: -: 38:/* -------------------------------------------------------------------- */ -: 39:/* Class */ -: 40:/* -------------------------------------------------------------------- */ -: 41: -: 42:typedef struct { -: 43: PyObject_HEAD -: 44: Py_ssize_t count; -: 45: double *xy; -: 46: int index; /* temporary use, e.g. in decimate */ -: 47:} PyPathObject; -: 48: -: 49:static PyTypeObject PyPathType; -: 50: -: 51:static double* function alloc_array called 2934 returned 100% blocks executed 67% 2934: 52:alloc_array(Py_ssize_t count) -: 53:{ -: 54: double* xy; 2934: 55: if (count < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 56: PyErr_NoMemory(); call 0 never executed #####: 57: return NULL; -: 58: } 2934: 59: if ((unsigned long long)count > (SIZE_MAX / (2 * sizeof(double))) - 1 ) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 60: PyErr_NoMemory(); call 0 returned 100% 1: 61: return NULL; -: 62: } 2933: 63: xy = malloc(2 * count * sizeof(double) + 1); 2933: 64: if (!xy) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 65: PyErr_NoMemory(); call 0 never executed -: 66: } -: 67: return xy; -: 68:} -: 69: -: 70:static PyPathObject* function path_new called 11 returned 100% blocks executed 83% 11: 71:path_new(Py_ssize_t count, double* xy, int duplicate) -: 72:{ -: 73: PyPathObject *path; -: 74: 11: 75: if (duplicate) { branch 0 taken 9% (fallthrough) branch 1 taken 91% -: 76: /* duplicate path */ 1: 77: double* p = alloc_array(count); call 0 returned 100% 1: 78: if (!p) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 79: return NULL; -: 80: } 2: 81: memcpy(p, xy, count * 2 * sizeof(double)); 1: 82: xy = p; -: 83: } -: 84: 11: 85: if (PyType_Ready(&PyPathType) < 0) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 86: free(xy); #####: 87: return NULL; -: 88: } -: 89: 11: 90: path = PyObject_New(PyPathObject, &PyPathType); call 0 returned 100% 11: 91: if (path == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 92: free(xy); #####: 93: return NULL; -: 94: } -: 95: 11: 96: path->count = count; 11: 97: path->xy = xy; -: 98: 11: 99: return path; -: 100:} -: 101: -: 102:static void function path_dealloc called 11 returned 100% blocks executed 100% 11: 103:path_dealloc(PyPathObject* path) -: 104:{ 11: 105: free(path->xy); 11: 106: PyObject_Del(path); call 0 returned 100% 11: 107:} -: 108: -: 109:/* -------------------------------------------------------------------- */ -: 110:/* Helpers */ -: 111:/* -------------------------------------------------------------------- */ -: 112: -: 113:#define PyPath_Check(op) (Py_TYPE(op) == &PyPathType) -: 114: -: 115:Py_ssize_t function PyPath_Flatten called 2932 returned 100% blocks executed 57% 2932: 116:PyPath_Flatten(PyObject* data, double **pxy) -: 117:{ -: 118: Py_ssize_t i, j, n; -: 119: double *xy; -: 120: 2932: 121: if (PyPath_Check(data)) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 122: /* This was another path object. */ 1: 123: PyPathObject *path = (PyPathObject*) data; 1: 124: xy = alloc_array(path->count); call 0 returned 100% 1: 125: if (!xy) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 126: return -1; -: 127: } 2: 128: memcpy(xy, path->xy, 2 * path->count * sizeof(double)); 1: 129: *pxy = xy; 1: 130: return path->count; -: 131: } -: 132: 2931: 133: if (PyImaging_CheckBuffer(data)) { call 0 returned 100% branch 1 taken 1% (fallthrough) branch 2 taken 99% -: 134: /* Assume the buffer contains floats */ -: 135: Py_buffer buffer; 2: 136: if (PyImaging_GetBuffer(data, &buffer) == 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 2: 137: float *ptr = (float*) buffer.buf; 2: 138: n = buffer.len / (2 * sizeof(float)); 2: 139: xy = alloc_array(n); call 0 returned 100% 2: 140: if (!xy) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 2: 141: return -1; -: 142: } 4: 143: for (i = 0; i < n+n; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 4: 144: xy[i] = ptr[i]; -: 145: } 2: 146: *pxy = xy; 2: 147: PyBuffer_Release(&buffer); call 0 returned 100% 2: 148: return n; -: 149: } #####: 150: PyErr_Clear(); call 0 never executed -: 151: } -: 152: 2929: 153: if (!PySequence_Check(data)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 154: PyErr_SetString(PyExc_TypeError, "argument must be sequence"); call 0 never executed #####: 155: return -1; -: 156: } -: 157: 2929: 158: j = 0; 2929: 159: n = PyObject_Length(data); call 0 returned 100% -: 160: /* Just in case __len__ breaks (or doesn't exist) */ 2929: 161: if (PyErr_Occurred()) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 162: return -1; -: 163: } -: 164: -: 165: /* Allocate for worst case */ 2929: 166: xy = alloc_array(n); call 0 returned 100% 2929: 167: if (!xy) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 168: return -1; -: 169: } -: 170: -: 171: /* Copy table to path array */ 5858: 172: if (PyList_Check(data)) { branch 0 taken 78% (fallthrough) branch 1 taken 22% 9014: 173: for (i = 0; i < n; i++) { branch 0 taken 80% branch 1 taken 20% -: 174: double x, y; 9014: 175: PyObject *op = PyList_GET_ITEM(data, i); 9014: 176: if (PyFloat_Check(op)) { branch 0 taken 99% (fallthrough) branch 1 taken 1% call 2 returned 100% branch 3 taken 0% (fallthrough) branch 4 taken 100% 4: 177: xy[j++] = PyFloat_AS_DOUBLE(op); 18020: 178: } else if (PyLong_Check(op)) { branch 0 taken 95% (fallthrough) branch 1 taken 5% 8558: 179: xy[j++] = (float) PyLong_AS_LONG(op); call 0 returned 100% 452: 180: } else if (PyNumber_Check(op)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 181: xy[j++] = PyFloat_AsDouble(op); call 0 never executed 452: 182: } else if (PyArg_ParseTuple(op, "dd", &x, &y)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 452: 183: xy[j++] = x; 452: 184: xy[j++] = y; -: 185: } else { #####: 186: free(xy); #####: 187: return -1; -: 188: } -: 189: } 1286: 190: } else if (PyTuple_Check(data)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% 1582: 191: for (i = 0; i < n; i++) { branch 0 taken 71% branch 1 taken 29% -: 192: double x, y; 1582: 193: PyObject *op = PyTuple_GET_ITEM(data, i); 1582: 194: if (PyFloat_Check(op)) { branch 0 taken 87% (fallthrough) branch 1 taken 13% call 2 returned 100% branch 3 taken 0% (fallthrough) branch 4 taken 100% 200: 195: xy[j++] = PyFloat_AS_DOUBLE(op); 2764: 196: } else if (PyLong_Check(op)) { branch 0 taken 77% (fallthrough) branch 1 taken 23% 1070: 197: xy[j++] = (float) PyLong_AS_LONG(op); call 0 returned 100% 312: 198: } else if (PyNumber_Check(op)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 199: xy[j++] = PyFloat_AsDouble(op); call 0 never executed 312: 200: } else if (PyArg_ParseTuple(op, "dd", &x, &y)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 312: 201: xy[j++] = x; 312: 202: xy[j++] = y; -: 203: } else { #####: 204: free(xy); #####: 205: return -1; -: 206: } -: 207: } -: 208: } else { #####: 209: for (i = 0; i < n; i++) { branch 0 never executed branch 1 never executed -: 210: double x, y; #####: 211: PyObject *op = PySequence_GetItem(data, i); call 0 never executed #####: 212: if (!op) { branch 0 never executed branch 1 never executed -: 213: /* treat IndexError as end of sequence */ #####: 214: if (PyErr_Occurred() && call 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed #####: 215: PyErr_ExceptionMatches(PyExc_IndexError)) { call 0 never executed #####: 216: PyErr_Clear(); call 0 never executed #####: 217: break; -: 218: } else { #####: 219: free(xy); #####: 220: return -1; -: 221: } -: 222: } #####: 223: if (PyFloat_Check(op)) { branch 0 never executed branch 1 never executed call 2 never executed branch 3 never executed branch 4 never executed #####: 224: xy[j++] = PyFloat_AS_DOUBLE(op); #####: 225: } else if (PyLong_Check(op)) { branch 0 never executed branch 1 never executed #####: 226: xy[j++] = (float) PyLong_AS_LONG(op); call 0 never executed #####: 227: } else if (PyNumber_Check(op)) { call 0 never executed branch 1 never executed branch 2 never executed #####: 228: xy[j++] = PyFloat_AsDouble(op); call 0 never executed #####: 229: } else if (PyArg_ParseTuple(op, "dd", &x, &y)) { call 0 never executed branch 1 never executed branch 2 never executed #####: 230: xy[j++] = x; #####: 231: xy[j++] = y; -: 232: } else { #####: 233: Py_DECREF(op); #####: 234: free(xy); #####: 235: return -1; -: 236: } #####: 237: Py_DECREF(op); -: 238: } -: 239: } -: 240: 2929: 241: if (j & 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 242: PyErr_SetString(PyExc_ValueError, "wrong number of coordinates"); call 0 never executed #####: 243: free(xy); #####: 244: return -1; -: 245: } -: 246: 2929: 247: *pxy = xy; 2929: 248: return j/2; -: 249:} -: 250: -: 251: -: 252:/* -------------------------------------------------------------------- */ -: 253:/* Factories */ -: 254:/* -------------------------------------------------------------------- */ -: 255: -: 256:PyObject* function PyPath_Create called 11 returned 100% blocks executed 100% 11: 257:PyPath_Create(PyObject* self, PyObject* args) -: 258:{ -: 259: PyObject* data; -: 260: Py_ssize_t count; -: 261: double *xy; -: 262: 11: 263: if (PyArg_ParseTuple(args, "n:Path", &count)) { call 0 returned 100% branch 1 taken 9% (fallthrough) branch 2 taken 91% -: 264: -: 265: /* number of vertices */ 1: 266: xy = alloc_array(count); call 0 returned 100% 1: 267: if (!xy) { branch 0 taken 0% branch 1 taken 100% -: 268: return NULL; -: 269: } -: 270: -: 271: } else { -: 272: -: 273: /* sequence or other path */ 10: 274: PyErr_Clear(); call 0 returned 100% 10: 275: if (!PyArg_ParseTuple(args, "O", &data)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 276: return NULL; -: 277: } -: 278: 10: 279: count = PyPath_Flatten(data, &xy); call 0 returned 100% 10: 280: if (count < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 281: return NULL; -: 282: } -: 283: } -: 284: 10: 285: return (PyObject*) path_new(count, xy, 0); call 0 returned 100% -: 286:} -: 287: -: 288: -: 289:/* -------------------------------------------------------------------- */ -: 290:/* Methods */ -: 291:/* -------------------------------------------------------------------- */ -: 292: -: 293:static PyObject* function path_compact called 1 returned 100% blocks executed 100% 1: 294:path_compact(PyPathObject* self, PyObject* args) -: 295:{ -: 296: /* Simple-minded method to shorten path. A point is removed if -: 297: the city block distance to the previous point is less than the -: 298: given distance */ -: 299: Py_ssize_t i, j; -: 300: double *xy; -: 301: 1: 302: double cityblock = 2.0; -: 303: 1: 304: if (!PyArg_ParseTuple(args, "|d:compact", &cityblock)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 305: return NULL; -: 306: } -: 307: 1: 308: xy = self->xy; -: 309: -: 310: /* remove bogus vertices */ 5: 311: for (i = j = 1; i < self->count; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 4: 312: if (fabs(xy[j+j-2]-xy[i+i]) + fabs(xy[j+j-1]-xy[i+i+1]) >= cityblock) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 2: 313: xy[j+j] = xy[i+i]; 2: 314: xy[j+j+1] = xy[i+i+1]; 2: 315: j++; -: 316: } -: 317: } -: 318: 1: 319: i = self->count - j; 1: 320: self->count = j; -: 321: -: 322: /* shrink coordinate array */ -: 323: /* malloc check ok, self->count is smaller than it was before */ 1: 324: self->xy = realloc(self->xy, 2 * self->count * sizeof(double)); -: 325: 1: 326: return Py_BuildValue("i", i); /* number of removed vertices */ call 0 returned 100% -: 327:} -: 328: -: 329:static PyObject* function path_getbbox called 1 returned 100% blocks executed 87% 1: 330:path_getbbox(PyPathObject* self, PyObject* args) -: 331:{ -: 332: /* Find bounding box */ -: 333: Py_ssize_t i; -: 334: double *xy; -: 335: double x0, y0, x1, y1; -: 336: 1: 337: if (!PyArg_ParseTuple(args, ":getbbox")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 338: return NULL; -: 339: } -: 340: 1: 341: xy = self->xy; -: 342: 1: 343: x0 = x1 = xy[0]; 1: 344: y0 = y1 = xy[1]; -: 345: 5: 346: for (i = 1; i < self->count; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 4: 347: if (xy[i+i] < x0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 348: x0 = xy[i+i]; -: 349: } 4: 350: if (xy[i+i] > x1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 4: 351: x1 = xy[i+i]; -: 352: } 4: 353: if (xy[i+i+1] < y0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 354: y0 = xy[i+i+1]; -: 355: } 4: 356: if (xy[i+i+1] > y1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 4: 357: y1 = xy[i+i+1]; -: 358: } -: 359: } -: 360: 1: 361: return Py_BuildValue("dddd", x0, y0, x1, y1); call 0 returned 100% -: 362:} -: 363: -: 364:static PyObject* function path_getitem called 36 returned 100% blocks executed 100% 36: 365:path_getitem(PyPathObject* self, Py_ssize_t i) -: 366:{ 36: 367: if (i < 0) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 1: 368: i = self->count + i; -: 369: } 36: 370: if (i < 0 || i >= self->count) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 36% (fallthrough) branch 3 taken 64% 13: 371: PyErr_SetString(PyExc_IndexError, "path index out of range"); call 0 returned 100% 13: 372: return NULL; -: 373: } -: 374: 23: 375: return Py_BuildValue("dd", self->xy[i+i], self->xy[i+i+1]); call 0 returned 100% -: 376:} -: 377: -: 378:static PyObject* function path_getslice called 1 returned 100% blocks executed 70% 1: 379:path_getslice(PyPathObject* self, Py_ssize_t ilow, Py_ssize_t ihigh) -: 380:{ -: 381: /* adjust arguments */ 1: 382: if (ilow < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 383: ilow = 0; 1: 384: } else if (ilow >= self->count) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 385: ilow = self->count; -: 386: } 1: 387: if (ihigh < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 388: ihigh = 0; -: 389: } 1: 390: if (ihigh < ilow) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 391: ihigh = ilow; 1: 392: } else if (ihigh > self->count) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 393: ihigh = self->count; -: 394: } -: 395: 1: 396: return (PyObject*) path_new(ihigh - ilow, self->xy + ilow * 2, 1); call 0 returned 100% -: 397:} -: 398: -: 399:static Py_ssize_t function path_len called 27 returned 100% blocks executed 100% 27: 400:path_len(PyPathObject* self) -: 401:{ 27: 402: return self->count; -: 403:} -: 404: -: 405:static PyObject* function path_map called 0 returned 0% blocks executed 0% #####: 406:path_map(PyPathObject* self, PyObject* args) -: 407:{ -: 408: /* Map coordinate set through function */ -: 409: Py_ssize_t i; -: 410: double *xy; -: 411: PyObject* function; -: 412: #####: 413: if (!PyArg_ParseTuple(args, "O:map", &function)) { call 0 never executed branch 1 never executed branch 2 never executed -: 414: return NULL; -: 415: } -: 416: #####: 417: xy = self->xy; -: 418: -: 419: /* apply function to coordinate set */ #####: 420: for (i = 0; i < self->count; i++) { branch 0 never executed branch 1 never executed #####: 421: double x = xy[i+i]; #####: 422: double y = xy[i+i+1]; #####: 423: PyObject* item = PyObject_CallFunction(function, "dd", x, y); call 0 never executed #####: 424: if (!item || !PyArg_ParseTuple(item, "dd", &x, &y)) { branch 0 never executed branch 1 never executed call 2 never executed branch 3 never executed branch 4 never executed #####: 425: Py_XDECREF(item); #####: 426: return NULL; -: 427: } #####: 428: xy[i+i] = x; #####: 429: xy[i+i+1] = y; #####: 430: Py_DECREF(item); -: 431: } -: 432: #####: 433: Py_INCREF(Py_None); #####: 434: return Py_None; -: 435:} -: 436: -: 437:static int function path_setitem called 0 returned 0% blocks executed 0% #####: 438:path_setitem(PyPathObject* self, Py_ssize_t i, PyObject* op) -: 439:{ -: 440: double* xy; -: 441: #####: 442: if (i < 0 || i >= self->count) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 443: PyErr_SetString(PyExc_IndexError, call 0 never executed -: 444: "path assignment index out of range"); #####: 445: return -1; -: 446: } -: 447: #####: 448: if (op == NULL) { branch 0 never executed branch 1 never executed #####: 449: PyErr_SetString(PyExc_TypeError, call 0 never executed -: 450: "cannot delete from path"); #####: 451: return -1; -: 452: } -: 453: #####: 454: xy = &self->xy[i+i]; -: 455: #####: 456: if (!PyArg_ParseTuple(op, "dd", &xy[0], &xy[1])) { call 0 never executed branch 1 never executed branch 2 never executed -: 457: return -1; -: 458: } -: 459: #####: 460: return 0; -: 461:} -: 462: -: 463:static PyObject* function path_tolist called 4 returned 100% blocks executed 90% 4: 464:path_tolist(PyPathObject* self, PyObject* args) -: 465:{ -: 466: PyObject *list; -: 467: Py_ssize_t i; -: 468: 4: 469: int flat = 0; 4: 470: if (!PyArg_ParseTuple(args, "|i:tolist", &flat)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 471: return NULL; -: 472: } -: 473: 4: 474: if (flat) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 2: 475: list = PyList_New(self->count*2); 14: 476: for (i = 0; i < self->count*2; i++) { call 0 returned 100% branch 1 taken 86% branch 2 taken 14% -: 477: PyObject* item; 12: 478: item = PyFloat_FromDouble(self->xy[i]); call 0 returned 100% 12: 479: if (!item) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 480: goto error; -: 481: } 12: 482: PyList_SetItem(list, i, item); call 0 returned 100% -: 483: } -: 484: } else { 2: 485: list = PyList_New(self->count); 8: 486: for (i = 0; i < self->count; i++) { call 0 returned 100% branch 1 taken 75% branch 2 taken 25% -: 487: PyObject* item; 6: 488: item = Py_BuildValue("dd", self->xy[i+i], self->xy[i+i+1]); call 0 returned 100% 6: 489: if (!item) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 490: goto error; -: 491: } 6: 492: PyList_SetItem(list, i, item); call 0 returned 100% -: 493: } -: 494: } -: 495: -: 496: return list; -: 497: -: 498:error: -: 499: Py_DECREF(list); -: 500: return NULL; -: 501:} -: 502: -: 503:static PyObject* function path_transform called 1 returned 100% blocks executed 63% 1: 504:path_transform(PyPathObject* self, PyObject* args) -: 505:{ -: 506: /* Apply affine transform to coordinate set */ -: 507: Py_ssize_t i; -: 508: double *xy; -: 509: double a, b, c, d, e, f; -: 510: 1: 511: double wrap = 0.0; -: 512: 1: 513: if (!PyArg_ParseTuple(args, "(dddddd)|d:transform", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 514: &a, &b, &c, &d, &e, &f, -: 515: &wrap)) { -: 516: return NULL; -: 517: } -: 518: 1: 519: xy = self->xy; -: 520: -: 521: /* transform the coordinate set */ 1: 522: if (b == 0.0 && d == 0.0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 523: /* scaling */ 3: 524: for (i = 0; i < self->count; i++) { branch 0 taken 75% branch 1 taken 25% 3: 525: xy[i+i] = a*xy[i+i]+c; 3: 526: xy[i+i+1] = e*xy[i+i+1]+f; -: 527: } -: 528: } else { -: 529: /* affine transform */ #####: 530: for (i = 0; i < self->count; i++) { branch 0 never executed branch 1 never executed #####: 531: double x = xy[i+i]; #####: 532: double y = xy[i+i+1]; #####: 533: xy[i+i] = a*x+b*y+c; #####: 534: xy[i+i+1] = d*x+e*y+f; -: 535: } -: 536: } -: 537: -: 538: /* special treatment of geographical map data */ 1: 539: if (wrap != 0.0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 540: for (i = 0; i < self->count; i++) { branch 0 never executed branch 1 never executed #####: 541: xy[i+i] = fmod(xy[i+i], wrap); -: 542: } -: 543: } -: 544: 1: 545: Py_INCREF(Py_None); 1: 546: return Py_None; -: 547:} -: 548: -: 549:static struct PyMethodDef methods[] = { -: 550: {"getbbox", (PyCFunction)path_getbbox, 1}, -: 551: {"tolist", (PyCFunction)path_tolist, 1}, -: 552: {"compact", (PyCFunction)path_compact, 1}, -: 553: {"map", (PyCFunction)path_map, 1}, -: 554: {"transform", (PyCFunction)path_transform, 1}, -: 555: {NULL, NULL} /* sentinel */ -: 556:}; -: 557: -: 558:static PyObject* function path_getattr_id called 0 returned 0% blocks executed 0% #####: 559:path_getattr_id(PyPathObject* self, void* closure) -: 560:{ #####: 561: return Py_BuildValue("n", (Py_ssize_t) self->xy); call 0 never executed -: 562:} -: 563: -: 564:static struct PyGetSetDef getsetters[] = { -: 565: { "id", (getter) path_getattr_id }, -: 566: { NULL } -: 567:}; -: 568: -: 569:static PyObject* function path_subscript called 4 returned 100% blocks executed 83% 4: 570:path_subscript(PyPathObject* self, PyObject* item) { 4: 571: if (PyIndex_Check(item)) { call 0 returned 100% branch 1 taken 50% (fallthrough) branch 2 taken 50% -: 572: Py_ssize_t i; 2: 573: i = PyNumber_AsSsize_t(item, PyExc_IndexError); call 0 returned 100% 2: 574: if (i == -1 && PyErr_Occurred()) { branch 0 taken 50% (fallthrough) branch 1 taken 50% call 2 returned 100% branch 3 taken 100% (fallthrough) branch 4 taken 0% -: 575: return NULL; -: 576: } 2: 577: return path_getitem(self, i); call 0 returned 100% -: 578: } 2: 579: if (PySlice_Check(item)) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1: 580: int len = 4; -: 581: Py_ssize_t start, stop, step, slicelength; -: 582: 1: 583: if (PySlice_GetIndicesEx(item, len, &start, &stop, &step, &slicelength) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% call 3 returned 100% branch 4 taken 100% (fallthrough) branch 5 taken 0% -: 584: return NULL; -: 585: } -: 586: 1: 587: if (slicelength <= 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 588: double *xy = alloc_array(0); call 0 never executed #####: 589: return (PyObject*) path_new(0, xy, 0); call 0 never executed -: 590: } 1: 591: else if (step == 1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 592: return path_getslice(self, start, stop); call 0 returned 100% -: 593: } -: 594: else { #####: 595: PyErr_SetString(PyExc_TypeError, "slice steps not supported"); call 0 never executed #####: 596: return NULL; -: 597: } -: 598: } -: 599: else { 1: 600: PyErr_Format(PyExc_TypeError, call 0 returned 100% -: 601: "Path indices must be integers, not %.200s", -: 602: Py_TYPE(item)->tp_name); 1: 603: return NULL; -: 604: } -: 605:} -: 606: -: 607:static PySequenceMethods path_as_sequence = { -: 608: (lenfunc)path_len, /*sq_length*/ -: 609: (binaryfunc)0, /*sq_concat*/ -: 610: (ssizeargfunc)0, /*sq_repeat*/ -: 611: (ssizeargfunc)path_getitem, /*sq_item*/ -: 612: (ssizessizeargfunc)path_getslice, /*sq_slice*/ -: 613: (ssizeobjargproc)path_setitem, /*sq_ass_item*/ -: 614: (ssizessizeobjargproc)0, /*sq_ass_slice*/ -: 615:}; -: 616: -: 617:static PyMappingMethods path_as_mapping = { -: 618: (lenfunc)path_len, -: 619: (binaryfunc)path_subscript, -: 620: NULL -: 621:}; -: 622: -: 623:static PyTypeObject PyPathType = { -: 624: PyVarObject_HEAD_INIT(NULL, 0) -: 625: "Path", /*tp_name*/ -: 626: sizeof(PyPathObject), /*tp_size*/ -: 627: 0, /*tp_itemsize*/ -: 628: /* methods */ -: 629: (destructor)path_dealloc, /*tp_dealloc*/ -: 630: 0, /*tp_print*/ -: 631: 0, /*tp_getattr*/ -: 632: 0, /*tp_setattr*/ -: 633: 0, /*tp_compare*/ -: 634: 0, /*tp_repr*/ -: 635: 0, /*tp_as_number */ -: 636: &path_as_sequence, /*tp_as_sequence */ -: 637: &path_as_mapping, /*tp_as_mapping */ -: 638: 0, /*tp_hash*/ -: 639: 0, /*tp_call*/ -: 640: 0, /*tp_str*/ -: 641: 0, /*tp_getattro*/ -: 642: 0, /*tp_setattro*/ -: 643: 0, /*tp_as_buffer*/ -: 644: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 645: 0, /*tp_doc*/ -: 646: 0, /*tp_traverse*/ -: 647: 0, /*tp_clear*/ -: 648: 0, /*tp_richcompare*/ -: 649: 0, /*tp_weaklistoffset*/ -: 650: 0, /*tp_iter*/ -: 651: 0, /*tp_iternext*/ -: 652: methods, /*tp_methods*/ -: 653: 0, /*tp_members*/ -: 654: getsetters, /*tp_getset*/ -: 655:}; -: 656: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#_imaging.c.gcov -: 0:Source:src/_imaging.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/_imaging.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/_imaging.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * the imaging library bindings -: 5: * -: 6: * history: -: 7: * 1995-09-24 fl Created -: 8: * 1996-03-24 fl Ready for first public release (release 0.0) -: 9: * 1996-03-25 fl Added fromstring (for Jack's "img" library) -: 10: * 1996-03-28 fl Added channel operations -: 11: * 1996-03-31 fl Added point operation -: 12: * 1996-04-08 fl Added new/new_block/new_array factories -: 13: * 1996-04-13 fl Added decoders -: 14: * 1996-05-04 fl Added palette hack -: 15: * 1996-05-12 fl Compile cleanly as C++ -: 16: * 1996-05-19 fl Added matrix conversions, gradient fills -: 17: * 1996-05-27 fl Added display_mode -: 18: * 1996-07-22 fl Added getbbox, offset -: 19: * 1996-07-23 fl Added sequence semantics -: 20: * 1996-08-13 fl Added logical operators, point mode -: 21: * 1996-08-16 fl Modified paste interface -: 22: * 1996-09-06 fl Added putdata methods, use abstract interface -: 23: * 1996-11-01 fl Added xbm encoder -: 24: * 1996-11-04 fl Added experimental path stuff, draw_lines, etc -: 25: * 1996-12-10 fl Added zip decoder, crc32 interface -: 26: * 1996-12-14 fl Added modulo arithmetics -: 27: * 1996-12-29 fl Added zip encoder -: 28: * 1997-01-03 fl Added fli and msp decoders -: 29: * 1997-01-04 fl Added experimental sun_rle and tga_rle decoders -: 30: * 1997-01-05 fl Added gif encoder, getpalette hack -: 31: * 1997-02-23 fl Added histogram mask -: 32: * 1997-05-12 fl Minor tweaks to match the IFUNC95 interface -: 33: * 1997-05-21 fl Added noise generator, spread effect -: 34: * 1997-06-05 fl Added mandelbrot generator -: 35: * 1997-08-02 fl Modified putpalette to coerce image mode if necessary -: 36: * 1998-01-11 fl Added INT32 support -: 37: * 1998-01-22 fl Fixed draw_points to draw the last point too -: 38: * 1998-06-28 fl Added getpixel, getink, draw_ink -: 39: * 1998-07-12 fl Added getextrema -: 40: * 1998-07-17 fl Added point conversion to arbitrary formats -: 41: * 1998-09-21 fl Added support for resampling filters -: 42: * 1998-09-22 fl Added support for quad transform -: 43: * 1998-12-29 fl Added support for arcs, chords, and pieslices -: 44: * 1999-01-10 fl Added some experimental arrow graphics stuff -: 45: * 1999-02-06 fl Added draw_bitmap, font acceleration stuff -: 46: * 2001-04-17 fl Fixed some egcs compiler nits -: 47: * 2001-09-17 fl Added screen grab primitives (win32) -: 48: * 2002-03-09 fl Added stretch primitive -: 49: * 2002-03-10 fl Fixed filter handling in rotate -: 50: * 2002-06-06 fl Added I, F, and RGB support to putdata -: 51: * 2002-06-08 fl Added rankfilter -: 52: * 2002-06-09 fl Added support for user-defined filter kernels -: 53: * 2002-11-19 fl Added clipboard grab primitives (win32) -: 54: * 2002-12-11 fl Added draw context -: 55: * 2003-04-26 fl Tweaks for Python 2.3 beta 1 -: 56: * 2003-05-21 fl Added createwindow primitive (win32) -: 57: * 2003-09-13 fl Added thread section hooks -: 58: * 2003-09-15 fl Added expand helper -: 59: * 2003-09-26 fl Added experimental LA support -: 60: * 2004-02-21 fl Handle zero-size images in quantize -: 61: * 2004-06-05 fl Added ptr attribute (used to access Imaging objects) -: 62: * 2004-06-05 fl Don't crash when fetching pixels from zero-wide images -: 63: * 2004-09-17 fl Added getcolors -: 64: * 2004-10-04 fl Added modefilter -: 65: * 2005-10-02 fl Added access proxy -: 66: * 2006-06-18 fl Always draw last point in polyline -: 67: * -: 68: * Copyright (c) 1997-2006 by Secret Labs AB -: 69: * Copyright (c) 1995-2006 by Fredrik Lundh -: 70: * -: 71: * See the README file for information on usage and redistribution. -: 72: */ -: 73: -: 74:#define PY_SSIZE_T_CLEAN -: 75:#include "Python.h" -: 76: -: 77:#ifdef HAVE_LIBJPEG -: 78:#include "jconfig.h" -: 79:#endif -: 80: -: 81:#ifdef HAVE_LIBZ -: 82:#include "zlib.h" -: 83:#endif -: 84: -: 85:#ifdef HAVE_LIBTIFF -: 86:#ifndef _TIFFIO_ -: 87:#include -: 88:#endif -: 89:#endif -: 90: -: 91:#include "libImaging/Imaging.h" -: 92: -: 93:#define _USE_MATH_DEFINES -: 94:#include -: 95: -: 96:/* Configuration stuff. Feel free to undef things you don't need. */ -: 97:#define WITH_IMAGECHOPS /* ImageChops support */ -: 98:#define WITH_IMAGEDRAW /* ImageDraw support */ -: 99:#define WITH_MAPPING /* use memory mapping to read some file formats */ -: 100:#define WITH_IMAGEPATH /* ImagePath stuff */ -: 101:#define WITH_ARROW /* arrow graphics stuff (experimental) */ -: 102:#define WITH_EFFECTS /* special effects */ -: 103:#define WITH_QUANTIZE /* quantization support */ -: 104:#define WITH_RANKFILTER /* rank filter */ -: 105:#define WITH_MODEFILTER /* mode filter */ -: 106:#define WITH_THREADING /* "friendly" threading support */ -: 107:#define WITH_UNSHARPMASK /* Kevin Cazabon's unsharpmask module */ -: 108: -: 109:#undef VERBOSE -: 110: -: 111:#define B16(p, i) ((((int)p[(i)]) << 8) + p[(i)+1]) -: 112:#define L16(p, i) ((((int)p[(i)+1]) << 8) + p[(i)]) -: 113:#define S16(v) ((v) < 32768 ? (v) : ((v) - 65536)) -: 114: -: 115:/* -------------------------------------------------------------------- */ -: 116:/* OBJECT ADMINISTRATION */ -: 117:/* -------------------------------------------------------------------- */ -: 118: -: 119:typedef struct { -: 120: PyObject_HEAD -: 121: Imaging image; -: 122: ImagingAccess access; -: 123:} ImagingObject; -: 124: -: 125:static PyTypeObject Imaging_Type; -: 126: -: 127:#ifdef WITH_IMAGEDRAW -: 128: -: 129:typedef struct -: 130:{ -: 131: /* to write a character, cut out sxy from glyph data, place -: 132: at current position plus dxy, and advance by (dx, dy) */ -: 133: int dx, dy; -: 134: int dx0, dy0, dx1, dy1; -: 135: int sx0, sy0, sx1, sy1; -: 136:} Glyph; -: 137: -: 138:typedef struct { -: 139: PyObject_HEAD -: 140: ImagingObject* ref; -: 141: Imaging bitmap; -: 142: int ysize; -: 143: int baseline; -: 144: Glyph glyphs[256]; -: 145:} ImagingFontObject; -: 146: -: 147:static PyTypeObject ImagingFont_Type; -: 148: -: 149:typedef struct { -: 150: PyObject_HEAD -: 151: ImagingObject* image; -: 152: UINT8 ink[4]; -: 153: int blend; -: 154:} ImagingDrawObject; -: 155: -: 156:static PyTypeObject ImagingDraw_Type; -: 157: -: 158:#endif -: 159: -: 160:typedef struct { -: 161: PyObject_HEAD -: 162: ImagingObject* image; -: 163: int readonly; -: 164:} PixelAccessObject; -: 165: -: 166:static PyTypeObject PixelAccess_Type; -: 167: -: 168:PyObject* function PyImagingNew called 53810 returned 100% blocks executed 75% 53810: 169:PyImagingNew(Imaging imOut) -: 170:{ -: 171: ImagingObject* imagep; -: 172: 53810: 173: if (!imOut) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 174: return NULL; -: 175: } -: 176: 53593: 177: imagep = PyObject_New(ImagingObject, &Imaging_Type); call 0 returned 100% 53593: 178: if (imagep == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 179: ImagingDelete(imOut); call 0 never executed #####: 180: return NULL; -: 181: } -: 182: -: 183:#ifdef VERBOSE -: 184: printf("imaging %p allocated\n", imagep); -: 185:#endif -: 186: 53593: 187: imagep->image = imOut; 53593: 188: imagep->access = ImagingAccessNew(imOut); call 0 returned 100% -: 189: 53593: 190: return (PyObject*) imagep; -: 191:} -: 192: -: 193:static void function _dealloc called 53593 returned 100% blocks executed 100% 53593: 194:_dealloc(ImagingObject* imagep) -: 195:{ -: 196: -: 197:#ifdef VERBOSE -: 198: printf("imaging %p deleted\n", imagep); -: 199:#endif -: 200: -: 201: if (imagep->access) { -: 202: ImagingAccessDelete(imagep->image, imagep->access); -: 203: } 53593: 204: ImagingDelete(imagep->image); call 0 returned 100% 53593: 205: PyObject_Del(imagep); call 0 returned 100% 53593: 206:} -: 207: -: 208:#define PyImaging_Check(op) (Py_TYPE(op) == &Imaging_Type) -: 209: function PyImaging_AsImaging called 35980 returned 100% blocks executed 60% 35980: 210:Imaging PyImaging_AsImaging(PyObject *op) -: 211:{ 35980: 212: if (!PyImaging_Check(op)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 213: PyErr_BadInternalCall(); call 0 never executed #####: 214: return NULL; -: 215: } -: 216: 35980: 217: return ((ImagingObject *)op)->image; -: 218:} -: 219: -: 220: -: 221:/* -------------------------------------------------------------------- */ -: 222:/* THREAD HANDLING */ -: 223:/* -------------------------------------------------------------------- */ -: 224: function ImagingSectionEnter called 2138450 returned 100% blocks executed 100% 2138450: 225:void ImagingSectionEnter(ImagingSectionCookie* cookie) -: 226:{ -: 227:#ifdef WITH_THREADING 2138450: 228: *cookie = (PyThreadState *) PyEval_SaveThread(); call 0 returned 100% -: 229:#endif 2138450: 230:} -: 231: function ImagingSectionLeave called 2138450 returned 100% blocks executed 100% 2138450: 232:void ImagingSectionLeave(ImagingSectionCookie* cookie) -: 233:{ -: 234:#ifdef WITH_THREADING 2138450: 235: PyEval_RestoreThread((PyThreadState*) *cookie); call 0 returned 100% -: 236:#endif 2138450: 237:} -: 238: -: 239:/* -------------------------------------------------------------------- */ -: 240:/* BUFFER HANDLING */ -: 241:/* -------------------------------------------------------------------- */ -: 242:/* Python compatibility API */ -: 243: function PyImaging_CheckBuffer called 3038 returned 100% blocks executed 100% 3038: 244:int PyImaging_CheckBuffer(PyObject* buffer) -: 245:{ 3038: 246: return PyObject_CheckBuffer(buffer); call 0 returned 100% -: 247:} -: 248: function PyImaging_GetBuffer called 109 returned 100% blocks executed 100% 109: 249:int PyImaging_GetBuffer(PyObject* buffer, Py_buffer *view) -: 250:{ -: 251: /* must call check_buffer first! */ 109: 252: return PyObject_GetBuffer(buffer, view, PyBUF_SIMPLE); call 0 returned 100% -: 253:} -: 254: -: 255:/* -------------------------------------------------------------------- */ -: 256:/* EXCEPTION REROUTING */ -: 257:/* -------------------------------------------------------------------- */ -: 258: -: 259:/* error messages */ -: 260:static const char* must_be_sequence = "argument must be a sequence"; -: 261:static const char* must_be_two_coordinates = -: 262: "coordinate list must contain exactly 2 coordinates"; -: 263:static const char* wrong_mode = "unrecognized image mode"; -: 264:static const char* wrong_raw_mode = "unrecognized raw mode"; -: 265:static const char* outside_image = "image index out of range"; -: 266:static const char* outside_palette = "palette index out of range"; -: 267:static const char* wrong_palette_size = "invalid palette size"; -: 268:static const char* no_palette = "image has no palette"; -: 269:static const char* readonly = "image is readonly"; -: 270:/* static const char* no_content = "image has no content"; */ -: 271: -: 272:void * function ImagingError_OSError called 0 returned 0% blocks executed 0% #####: 273:ImagingError_OSError(void) -: 274:{ #####: 275: PyErr_SetString(PyExc_OSError, "error when accessing file"); call 0 never executed #####: 276: return NULL; -: 277:} -: 278: -: 279:void * function ImagingError_MemoryError called 2 returned 100% blocks executed 100% 2: 280:ImagingError_MemoryError(void) -: 281:{ 2: 282: return PyErr_NoMemory(); call 0 returned 100% -: 283:} -: 284: -: 285:void * function ImagingError_Mismatch called 0 returned 0% blocks executed 0% #####: 286:ImagingError_Mismatch(void) -: 287:{ #####: 288: PyErr_SetString(PyExc_ValueError, "images do not match"); call 0 never executed #####: 289: return NULL; -: 290:} -: 291: -: 292:void * function ImagingError_ModeError called 32 returned 100% blocks executed 100% 32: 293:ImagingError_ModeError(void) -: 294:{ 32: 295: PyErr_SetString(PyExc_ValueError, "image has wrong mode"); call 0 returned 100% 32: 296: return NULL; -: 297:} -: 298: -: 299:void * function ImagingError_ValueError called 265 returned 100% blocks executed 100% 265: 300:ImagingError_ValueError(const char *message) -: 301:{ 265: 302: PyErr_SetString( branch 0 taken 99% (fallthrough) branch 1 taken 1% call 2 returned 100% -: 303: PyExc_ValueError, -: 304: (message) ? (char*) message : "unrecognized argument value" -: 305: ); 265: 306: return NULL; -: 307:} -: 308: -: 309:void function ImagingError_Clear called 0 returned 0% blocks executed 0% #####: 310:ImagingError_Clear(void) -: 311:{ #####: 312: PyErr_Clear(); call 0 never executed #####: 313:} -: 314: -: 315:/* -------------------------------------------------------------------- */ -: 316:/* HELPERS */ -: 317:/* -------------------------------------------------------------------- */ -: 318: -: 319:static int function getbands called 1 returned 100% blocks executed 100% 1: 320:getbands(const char* mode) -: 321:{ -: 322: Imaging im; -: 323: int bands; -: 324: -: 325: /* FIXME: add primitive to libImaging to avoid extra allocation */ 1: 326: im = ImagingNew(mode, 0, 0); call 0 returned 100% 1: 327: if (!im) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 328: return -1; -: 329: } -: 330: 1: 331: bands = im->bands; -: 332: 1: 333: ImagingDelete(im); call 0 returned 100% -: 334: 1: 335: return bands; -: 336:} -: 337: -: 338:#define TYPE_UINT8 (0x100|sizeof(UINT8)) -: 339:#define TYPE_INT32 (0x200|sizeof(INT32)) -: 340:#define TYPE_FLOAT16 (0x500|sizeof(FLOAT16)) -: 341:#define TYPE_FLOAT32 (0x300|sizeof(FLOAT32)) -: 342:#define TYPE_DOUBLE (0x400|sizeof(double)) -: 343: -: 344:static void* function getlist called 406 returned 100% blocks executed 95% 406: 345:getlist(PyObject* arg, Py_ssize_t* length, const char* wrong_length, int type) -: 346:{ -: 347: /* - allocates and returns a c array of the items in the -: 348: python sequence arg. -: 349: - the size of the returned array is in length -: 350: - all of the arg items must be numeric items of the type -: 351: specified in type -: 352: - sequence length is checked against the length parameter IF -: 353: an error parameter is passed in wrong_length -: 354: - caller is responsible for freeing the memory -: 355: */ -: 356: -: 357: Py_ssize_t i, n; -: 358: int itemp; -: 359: double dtemp; -: 360: FLOAT32 ftemp; -: 361: UINT8* list; -: 362: PyObject* seq; -: 363: PyObject* op; -: 364: 406: 365: if ( ! PySequence_Check(arg)) { call 0 returned 100% branch 1 taken 1% (fallthrough) branch 2 taken 99% 1: 366: PyErr_SetString(PyExc_TypeError, must_be_sequence); call 0 returned 100% 1: 367: return NULL; -: 368: } -: 369: 405: 370: n = PySequence_Size(arg); call 0 returned 100% 405: 371: if (length && wrong_length && n != *length) { branch 0 taken 88% (fallthrough) branch 1 taken 12% branch 2 taken 1% (fallthrough) branch 3 taken 99% 5: 372: PyErr_SetString(PyExc_ValueError, wrong_length); call 0 returned 100% 5: 373: return NULL; -: 374: } -: 375: -: 376: /* malloc check ok, type & ff is just a sizeof(something) -: 377: calloc checks for overflow */ 400: 378: list = calloc(n, type & 0xff); 400: 379: if ( ! list) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 380: return PyErr_NoMemory(); call 0 never executed -: 381: } -: 382: 400: 383: seq = PySequence_Fast(arg, must_be_sequence); call 0 returned 100% 400: 384: if ( ! seq) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 385: free(list); #####: 386: return NULL; -: 387: } -: 388: 166950: 389: for (i = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 333900: 390: op = PySequence_Fast_GET_ITEM(seq, i); branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 391: // DRY, branch prediction is going to work _really_ well -: 392: // on this switch. And 3 fewer loops to copy/paste. 166950: 393: switch (type) { branch 0 taken 39% branch 1 taken 12% branch 2 taken 48% branch 3 taken 1% branch 4 taken 0% -: 394: case TYPE_UINT8: 65536: 395: itemp = PyLong_AsLong(op); call 0 returned 100% 65536: 396: list[i] = CLIP8(itemp); branch 0 taken 99% (fallthrough) branch 1 taken 1% 65536: 397: break; -: 398: case TYPE_INT32: 19968: 399: itemp = PyLong_AsLong(op); call 0 returned 100% 19968: 400: memcpy(list + i * sizeof(INT32), &itemp, sizeof(itemp)); -: 401: break; -: 402: case TYPE_FLOAT32: 79664: 403: ftemp = (FLOAT32)PyFloat_AsDouble(op); call 0 returned 100% 79664: 404: memcpy(list + i * sizeof(ftemp), &ftemp, sizeof(ftemp)); -: 405: break; -: 406: case TYPE_DOUBLE: 1782: 407: dtemp = PyFloat_AsDouble(op); call 0 returned 100% 1782: 408: memcpy(list + i * sizeof(dtemp), &dtemp, sizeof(dtemp)); -: 409: break; -: 410: } -: 411: } -: 412: 400: 413: Py_DECREF(seq); -: 414: 400: 415: if (PyErr_Occurred()) { call 0 returned 100% branch 1 taken 1% (fallthrough) branch 2 taken 99% 1: 416: free(list); 1: 417: return NULL; -: 418: } -: 419: 399: 420: if (length) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 399: 421: *length = n; -: 422: } -: 423: -: 424: return list; -: 425:} -: 426: -: 427:FLOAT32 function float16tofloat32 called 2709 returned 100% blocks executed 100% 2709: 428:float16tofloat32(const FLOAT16 in) { -: 429: UINT32 t1; -: 430: UINT32 t2; -: 431: UINT32 t3; -: 432: FLOAT32 out[1] = {0}; -: 433: 2709: 434: t1 = in & 0x7fff; // Non-sign bits 2709: 435: t2 = in & 0x8000; // Sign bit 2709: 436: t3 = in & 0x7c00; // Exponent -: 437: 2709: 438: t1 <<= 13; // Align mantissa on MSB 2709: 439: t2 <<= 16; // Shift sign bit into position -: 440: 2709: 441: t1 += 0x38000000; // Adjust bias -: 442: 2709: 443: t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero branch 0 taken 91% (fallthrough) branch 1 taken 9% -: 444: 2709: 445: t1 |= t2; // Re-insert sign bit -: 446: 2709: 447: memcpy(out, &t1, 4); 2709: 448: return out[0]; -: 449:} -: 450: -: 451:static inline PyObject* function getpixel.isra.4 called 4641763 returned 100% blocks executed 95% 4641763: 452:getpixel(Imaging im, ImagingAccess access, int x, int y) -: 453:{ -: 454: union { -: 455: UINT8 b[4]; -: 456: UINT16 h; -: 457: INT32 i; -: 458: FLOAT32 f; -: 459: } pixel; -: 460: 4641763: 461: if (x < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 49286: 462: x = im->xsize + x; -: 463: } 4641763: 464: if (y < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 49286: 465: y = im->ysize + y; -: 466: } -: 467: 4641763: 468: if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 1% (fallthrough) branch 7 taken 99% 300: 469: PyErr_SetString(PyExc_IndexError, outside_image); call 0 returned 100% -: 470: return NULL; -: 471: } -: 472: 4641463: 473: access->get_pixel(im, x, y, &pixel); call 0 returned 100% -: 474: 4641463: 475: switch (im->type) { branch 0 taken 95% branch 1 taken 3% branch 2 taken 1% branch 3 taken 1% branch 4 taken 0% -: 476: case IMAGING_TYPE_UINT8: 4431908: 477: switch (im->bands) { branch 0 taken 93% branch 1 taken 1% branch 2 taken 5% branch 3 taken 2% branch 4 taken 0% -: 478: case 1: 4120100: 479: return PyLong_FromLong(pixel.b[0]); call 0 returned 100% -: 480: case 2: 30335: 481: return Py_BuildValue("BB", pixel.b[0], pixel.b[1]); call 0 returned 100% -: 482: case 3: 200110: 483: return Py_BuildValue("BBB", pixel.b[0], pixel.b[1], pixel.b[2]); call 0 returned 100% -: 484: case 4: 81363: 485: return Py_BuildValue("BBBB", pixel.b[0], pixel.b[1], pixel.b[2], pixel.b[3]); call 0 returned 100% -: 486: } -: 487: break; -: 488: case IMAGING_TYPE_INT32: 119633: 489: return PyLong_FromLong(pixel.i); call 0 returned 100% -: 490: case IMAGING_TYPE_FLOAT32: 62458: 491: return PyFloat_FromDouble(pixel.f); call 0 returned 100% -: 492: case IMAGING_TYPE_SPECIAL: 27464: 493: if (strncmp(im->mode, "I;16", 4) == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 27464: 494: return PyLong_FromLong(pixel.h); call 0 returned 100% -: 495: } -: 496: break; -: 497: } -: 498: -: 499: /* unknown type */ #####: 500: Py_INCREF(Py_None); -: 501: return Py_None; -: 502:} -: 503: -: 504:static char* function getink called 409628 returned 100% blocks executed 93% 409628: 505:getink(PyObject* color, Imaging im, char* ink) -: 506:{ 409628: 507: int g=0, b=0, a=0; 409628: 508: double f=0; -: 509: /* Windows 64 bit longs are 32 bits, and 0xFFFFFFFF (white) is a -: 510: python long (not int) that raises an overflow error when trying -: 511: to return it into a 32 bit C long -: 512: */ 409628: 513: PY_LONG_LONG r = 0; -: 514: FLOAT32 ftmp; -: 515: INT32 itmp; -: 516: -: 517: /* fill ink buffer (four bytes) with something that can -: 518: be cast to either UINT8 or INT32 */ -: 519: 409628: 520: int rIsInt = 0; 819256: 521: if (PyTuple_Check(color) && PyTuple_Size(color) == 1) { branch 0 taken 45% (fallthrough) branch 1 taken 55% call 2 returned 100% branch 3 taken 1% (fallthrough) branch 4 taken 99% 6: 522: color = PyTuple_GetItem(color, 0); call 0 returned 100% -: 523: } 819256: 524: if (im->type == IMAGING_TYPE_UINT8 || branch 0 taken 99% (fallthrough) branch 1 taken 1% 409628: 525: im->type == IMAGING_TYPE_INT32 || -: 526: im->type == IMAGING_TYPE_SPECIAL) { 819100: 527: if (PyLong_Check(color)) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 227229: 528: r = PyLong_AsLongLong(color); call 0 returned 100% 227229: 529: if (r == -1 && PyErr_Occurred()) { branch 0 taken 1% (fallthrough) branch 1 taken 99% call 2 returned 100% branch 3 taken 98% branch 4 taken 2% -: 530: return NULL; -: 531: } -: 532: rIsInt = 1; 182321: 533: } else if (im->type == IMAGING_TYPE_UINT8) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 364624: 534: if (!PyTuple_Check(color)) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 12: 535: PyErr_SetString(PyExc_TypeError, "color must be int or tuple"); call 0 returned 100% 12: 536: return NULL; -: 537: } -: 538: } else { 9: 539: PyErr_SetString(PyExc_TypeError, "color must be int or single-element tuple"); call 0 returned 100% 9: 540: return NULL; -: 541: } -: 542: } -: 543: 409600: 544: switch (im->type) { branch 0 taken 99% branch 1 taken 1% branch 2 taken 1% branch 3 taken 1% branch 4 taken 0% -: 545: case IMAGING_TYPE_UINT8: -: 546: /* unsigned integer */ 409326: 547: if (im->bands == 1) { branch 0 taken 55% (fallthrough) branch 1 taken 45% -: 548: /* unsigned integer, single layer */ 226052: 549: if (rIsInt != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 550: if (!PyArg_ParseTuple(color, "L", &r)) { call 0 never executed branch 1 never executed branch 2 never executed -: 551: return NULL; -: 552: } -: 553: } 226052: 554: ink[0] = (char) CLIP8(r); branch 0 taken 82% (fallthrough) branch 1 taken 18% branch 2 taken 99% (fallthrough) branch 3 taken 1% 226052: 555: ink[1] = ink[2] = ink[3] = 0; -: 556: } else { 183274: 557: a = 255; 183274: 558: if (rIsInt) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 559: /* compatibility: ABGR */ 974: 560: a = (UINT8) (r >> 24); 974: 561: b = (UINT8) (r >> 16); 974: 562: g = (UINT8) (r >> 8); 974: 563: r = (UINT8) r; -: 564: } else { 182300: 565: if (im->bands == 2) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 5185: 566: if (!PyArg_ParseTuple(color, "L|i", &r, &a)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 567: return NULL; -: 568: } 5185: 569: g = b = r; -: 570: } else { 177115: 571: if (!PyArg_ParseTuple(color, "Lii|i", &r, &g, &b, &a)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 572: return NULL; -: 573: } -: 574: } -: 575: } 183274: 576: ink[0] = (char) CLIP8(r); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 183274: 577: ink[1] = (char) CLIP8(g); branch 0 taken 92% (fallthrough) branch 1 taken 8% branch 2 taken 100% (fallthrough) branch 3 taken 0% 183274: 578: ink[2] = (char) CLIP8(b); branch 0 taken 92% (fallthrough) branch 1 taken 8% branch 2 taken 100% (fallthrough) branch 3 taken 0% 183274: 579: ink[3] = (char) CLIP8(a); branch 0 taken 98% (fallthrough) branch 1 taken 2% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 580: } -: 581: return ink; -: 582: case IMAGING_TYPE_INT32: -: 583: /* signed integer */ 95: 584: itmp = r; 95: 585: memcpy(ink, &itmp, sizeof(itmp)); 95: 586: return ink; -: 587: case IMAGING_TYPE_FLOAT32: -: 588: /* floating point */ 78: 589: f = PyFloat_AsDouble(color); call 0 returned 100% 78: 590: if (f == -1.0 && PyErr_Occurred()) { branch 0 taken 0% (fallthrough) branch 1 taken 100% call 2 never executed branch 3 never executed branch 4 never executed -: 591: return NULL; -: 592: } 78: 593: ftmp = f; 78: 594: memcpy(ink, &ftmp, sizeof(ftmp)); 78: 595: return ink; -: 596: case IMAGING_TYPE_SPECIAL: 101: 597: if (strncmp(im->mode, "I;16", 4) == 0) { branch 0 taken 95% (fallthrough) branch 1 taken 5% 96: 598: ink[0] = (UINT8) r; 96: 599: ink[1] = (UINT8) (r >> 8); 96: 600: ink[2] = ink[3] = 0; 96: 601: return ink; -: 602: } -: 603: } -: 604: 5: 605: PyErr_SetString(PyExc_ValueError, wrong_mode); call 0 returned 100% 5: 606: return NULL; -: 607:} -: 608: -: 609:/* -------------------------------------------------------------------- */ -: 610:/* FACTORIES */ -: 611:/* -------------------------------------------------------------------- */ -: 612: -: 613:static PyObject* function _fill called 15851 returned 100% blocks executed 100% 15851: 614:_fill(PyObject* self, PyObject* args) -: 615:{ -: 616: char* mode; -: 617: int xsize, ysize; -: 618: PyObject* color; -: 619: char buffer[4]; -: 620: Imaging im; -: 621: 15851: 622: xsize = ysize = 256; 15851: 623: color = NULL; -: 624: 15851: 625: if (!PyArg_ParseTuple(args, "s|(ii)O", &mode, &xsize, &ysize, &color)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 626: return NULL; -: 627: } -: 628: 15851: 629: im = ImagingNewDirty(mode, xsize, ysize); call 0 returned 100% 15851: 630: if (!im) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 631: return NULL; -: 632: } -: 633: 15845: 634: buffer[0] = buffer[1] = buffer[2] = buffer[3] = 0; 15845: 635: if (color) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 15836: 636: if (!getink(color, im, buffer)) { call 0 returned 100% branch 1 taken 1% (fallthrough) branch 2 taken 99% 4: 637: ImagingDelete(im); call 0 returned 100% 4: 638: return NULL; -: 639: } -: 640: } -: 641: -: 642: 15841: 643: (void) ImagingFill(im, buffer); call 0 returned 100% -: 644: 15841: 645: return PyImagingNew(im); call 0 returned 100% -: 646:} -: 647: -: 648:static PyObject* function _new called 6227 returned 100% blocks executed 100% 6227: 649:_new(PyObject* self, PyObject* args) -: 650:{ -: 651: char* mode; -: 652: int xsize, ysize; -: 653: 6227: 654: if (!PyArg_ParseTuple(args, "s(ii)", &mode, &xsize, &ysize)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 655: return NULL; -: 656: } -: 657: 6227: 658: return PyImagingNew(ImagingNew(mode, xsize, ysize)); call 0 returned 100% call 1 returned 100% -: 659:} -: 660: -: 661:static PyObject* function _new_block called 5 returned 100% blocks executed 100% 5: 662:_new_block(PyObject* self, PyObject* args) -: 663:{ -: 664: char* mode; -: 665: int xsize, ysize; -: 666: 5: 667: if (!PyArg_ParseTuple(args, "s(ii)", &mode, &xsize, &ysize)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 668: return NULL; -: 669: } -: 670: 5: 671: return PyImagingNew(ImagingNewBlock(mode, xsize, ysize)); call 0 returned 100% call 1 returned 100% -: 672:} -: 673: -: 674:static PyObject* function _linear_gradient called 12 returned 100% blocks executed 100% 12: 675:_linear_gradient(PyObject* self, PyObject* args) -: 676:{ -: 677: char* mode; -: 678: 12: 679: if (!PyArg_ParseTuple(args, "s", &mode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 680: return NULL; -: 681: } -: 682: 12: 683: return PyImagingNew(ImagingFillLinearGradient(mode)); call 0 returned 100% call 1 returned 100% -: 684:} -: 685: -: 686:static PyObject* function _radial_gradient called 3 returned 100% blocks executed 100% 3: 687:_radial_gradient(PyObject* self, PyObject* args) -: 688:{ -: 689: char* mode; -: 690: 3: 691: if (!PyArg_ParseTuple(args, "s", &mode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 692: return NULL; -: 693: } -: 694: 3: 695: return PyImagingNew(ImagingFillRadialGradient(mode)); call 0 returned 100% call 1 returned 100% -: 696:} -: 697: -: 698:static PyObject* function _alpha_composite called 6 returned 100% blocks executed 100% 6: 699:_alpha_composite(ImagingObject* self, PyObject* args) -: 700:{ -: 701: ImagingObject* imagep1; -: 702: ImagingObject* imagep2; -: 703: 6: 704: if (!PyArg_ParseTuple(args, "O!O!", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 705: &Imaging_Type, &imagep1, -: 706: &Imaging_Type, &imagep2)) { -: 707: return NULL; -: 708: } -: 709: 6: 710: return PyImagingNew(ImagingAlphaComposite(imagep1->image, imagep2->image)); call 0 returned 100% call 1 returned 100% -: 711:} -: 712: -: 713:static PyObject* function _blend called 19 returned 100% blocks executed 100% 19: 714:_blend(ImagingObject* self, PyObject* args) -: 715:{ -: 716: ImagingObject* imagep1; -: 717: ImagingObject* imagep2; -: 718: double alpha; -: 719: 19: 720: alpha = 0.5; 19: 721: if (!PyArg_ParseTuple(args, "O!O!|d", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 722: &Imaging_Type, &imagep1, -: 723: &Imaging_Type, &imagep2, -: 724: &alpha)) { -: 725: return NULL; -: 726: } -: 727: 19: 728: return PyImagingNew(ImagingBlend(imagep1->image, imagep2->image, call 0 returned 100% call 1 returned 100% -: 729: (float) alpha)); -: 730:} -: 731: -: 732:/* -------------------------------------------------------------------- */ -: 733:/* METHODS */ -: 734:/* -------------------------------------------------------------------- */ -: 735: -: 736:static INT16* function _prepare_lut_table called 44 returned 100% blocks executed 92% 44: 737:_prepare_lut_table(PyObject* table, Py_ssize_t table_size) -: 738:{ -: 739: int i; -: 740: Py_buffer buffer_info; 44: 741: INT32 data_type = TYPE_FLOAT32; 44: 742: float item = 0; 44: 743: void* table_data = NULL; 44: 744: int free_table_data = 0; -: 745: INT16* prepared; -: 746: -: 747: /* NOTE: This value should be the same as in ColorLUT.c */ -: 748: #define PRECISION_BITS (16 - 8 - 2) -: 749: 44: 750: const char* wrong_size = ("The table should have table_channels * " -: 751: "size1D * size2D * size3D float items."); -: 752: 44: 753: if (PyObject_CheckBuffer(table)) { call 0 returned 100% branch 1 taken 18% (fallthrough) branch 2 taken 82% 8: 754: if ( ! PyObject_GetBuffer(table, &buffer_info, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 755: PyBUF_CONTIG_RO | PyBUF_FORMAT)) { 8: 756: if (buffer_info.ndim == 1 && buffer_info.shape[0] == table_size) { branch 0 taken 88% (fallthrough) branch 1 taken 13% branch 2 taken 86% (fallthrough) branch 3 taken 14% 6: 757: if (strlen(buffer_info.format) == 1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 758: switch (buffer_info.format[0]) { branch 0 taken 33% branch 1 taken 17% branch 2 taken 17% branch 3 taken 33% -: 759: case 'e': 2: 760: data_type = TYPE_FLOAT16; 2: 761: table_data = buffer_info.buf; 2: 762: break; -: 763: case 'f': 1: 764: data_type = TYPE_FLOAT32; 1: 765: table_data = buffer_info.buf; 1: 766: break; -: 767: case 'd': 1: 768: data_type = TYPE_DOUBLE; 1: 769: table_data = buffer_info.buf; 1: 770: break; -: 771: } -: 772: } -: 773: } 8: 774: PyBuffer_Release(&buffer_info); call 0 returned 100% -: 775: } -: 776: } -: 777: 44: 778: if ( ! table_data) { branch 0 taken 91% (fallthrough) branch 1 taken 9% 40: 779: free_table_data = 1; 40: 780: table_data = getlist(table, &table_size, wrong_size, TYPE_FLOAT32); call 0 returned 100% 40: 781: if ( ! table_data) { branch 0 taken 85% (fallthrough) branch 1 taken 15% -: 782: return NULL; -: 783: } -: 784: } -: 785: -: 786: /* malloc check ok, max is 2 * 4 * 65**3 = 2197000 */ 38: 787: prepared = (INT16*) malloc(sizeof(INT16) * table_size); 38: 788: if ( ! prepared) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 789: if (free_table_data) { branch 0 never executed branch 1 never executed #####: 790: free(table_data); -: 791: } #####: 792: return (INT16*) PyErr_NoMemory(); call 0 never executed -: 793: } -: 794: 85652: 795: for (i = 0; i < table_size; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 796: FLOAT16 htmp; -: 797: double dtmp; 85652: 798: switch (data_type) { branch 0 taken 3% branch 1 taken 94% branch 2 taken 2% branch 3 taken 0% -: 799: case TYPE_FLOAT16: 2709: 800: memcpy(&htmp, ((char*) table_data) + i * sizeof(htmp), sizeof(htmp)); 2709: 801: item = float16tofloat32(htmp); call 0 returned 100% 2709: 802: break; -: 803: case TYPE_FLOAT32: 80864: 804: memcpy(&item, ((char*) table_data) + i * sizeof(FLOAT32), sizeof(FLOAT32)); -: 805: break; -: 806: case TYPE_DOUBLE: 2079: 807: memcpy(&dtmp, ((char*) table_data) + i * sizeof(dtmp), sizeof(dtmp)); 2079: 808: item = (FLOAT32) dtmp; 2079: 809: break; -: 810: } -: 811: /* Max value for INT16 */ 85652: 812: if (item >= (0x7fff - 0.5) / (255 << PRECISION_BITS)) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 12: 813: prepared[i] = 0x7fff; 36: 814: continue; -: 815: } -: 816: /* Min value for INT16 */ 85640: 817: if (item <= (-0x8000 + 0.5) / (255 << PRECISION_BITS)) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 12: 818: prepared[i] = -0x8000; 12: 819: continue; -: 820: } 85628: 821: if (item < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 12: 822: prepared[i] = item * (255 << PRECISION_BITS) - 0.5; -: 823: } else { 85616: 824: prepared[i] = item * (255 << PRECISION_BITS) + 0.5; -: 825: } -: 826: } -: 827: -: 828: #undef PRECISION_BITS 38: 829: if (free_table_data) { branch 0 taken 89% (fallthrough) branch 1 taken 11% 34: 830: free(table_data); -: 831: } -: 832: return prepared; -: 833:} -: 834: -: 835: -: 836:static PyObject* function _color_lut_3d called 48 returned 100% blocks executed 100% 48: 837:_color_lut_3d(ImagingObject* self, PyObject* args) -: 838:{ -: 839: char* mode; -: 840: int filter; -: 841: int table_channels; -: 842: int size1D, size2D, size3D; -: 843: PyObject* table; -: 844: -: 845: INT16* prepared_table; -: 846: Imaging imOut; -: 847: 48: 848: if ( ! PyArg_ParseTuple(args, "siiiiiO:color_lut_3d", &mode, &filter, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 849: &table_channels, &size1D, &size2D, &size3D, -: 850: &table)) { -: 851: return NULL; -: 852: } -: 853: -: 854: /* actually, it is trilinear */ 48: 855: if (filter != IMAGING_TRANSFORM_BILINEAR) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 1: 856: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 857: "Only LINEAR filter is supported."); 1: 858: return NULL; -: 859: } -: 860: 47: 861: if (1 > table_channels || table_channels > 4) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 1: 862: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 863: "table_channels should be from 1 to 4"); 1: 864: return NULL; -: 865: } -: 866: 90: 867: if (2 > size1D || size1D > 65 || branch 0 taken 96% (fallthrough) branch 1 taken 4% branch 2 taken 100% (fallthrough) branch 3 taken 0% 132: 868: 2 > size2D || size2D > 65 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 88: 869: 2 > size3D || size3D > 65 branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 870: ) { 2: 871: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 872: "Table size in any dimension should be from 2 to 65"); 2: 873: return NULL; -: 874: } -: 875: 44: 876: prepared_table = _prepare_lut_table( call 0 returned 100% 44: 877: table, table_channels * size1D * size2D * size3D); 44: 878: if ( ! prepared_table) { branch 0 taken 86% (fallthrough) branch 1 taken 14% -: 879: return NULL; -: 880: } -: 881: 38: 882: imOut = ImagingNewDirty(mode, self->image->xsize, self->image->ysize); call 0 returned 100% 38: 883: if ( ! imOut) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 1: 884: free(prepared_table); 1: 885: return NULL; -: 886: } -: 887: 37: 888: if ( ! ImagingColorLUT3D_linear(imOut, self->image, call 0 returned 100% branch 1 taken 19% (fallthrough) branch 2 taken 81% -: 889: table_channels, size1D, size2D, size3D, -: 890: prepared_table)) { 7: 891: free(prepared_table); 7: 892: ImagingDelete(imOut); call 0 returned 100% 7: 893: return NULL; -: 894: } -: 895: 30: 896: free(prepared_table); -: 897: 30: 898: return PyImagingNew(imOut); call 0 returned 100% -: 899:} -: 900: -: 901:static PyObject* function _convert called 8090 returned 100% blocks executed 67% 8090: 902:_convert(ImagingObject* self, PyObject* args) -: 903:{ -: 904: char* mode; 8090: 905: int dither = 0; 8090: 906: ImagingObject *paletteimage = NULL; -: 907: 8090: 908: if (!PyArg_ParseTuple(args, "s|iO", &mode, &dither, &paletteimage)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 909: return NULL; -: 910: } 8090: 911: if (paletteimage != NULL) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 5: 912: if (!PyImaging_Check(paletteimage)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 913: PyObject_Print((PyObject *)paletteimage, stderr, 0); call 0 never executed #####: 914: PyErr_SetString(PyExc_ValueError, "palette argument must be image with mode 'P'"); call 0 never executed #####: 915: return NULL; -: 916: } 5: 917: if (paletteimage->image->palette == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 918: PyErr_SetString(PyExc_ValueError, "null palette"); call 0 never executed #####: 919: return NULL; -: 920: } -: 921: } -: 922: 8090: 923: return PyImagingNew(ImagingConvert(self->image, mode, paletteimage ? paletteimage->image->palette : NULL, dither)); branch 0 taken 1% (fallthrough) branch 1 taken 99% call 2 returned 100% call 3 returned 100% -: 924:} -: 925: -: 926:static PyObject* function _convert2 called 5 returned 100% blocks executed 100% 5: 927:_convert2(ImagingObject* self, PyObject* args) -: 928:{ -: 929: ImagingObject* imagep1; -: 930: ImagingObject* imagep2; 5: 931: if (!PyArg_ParseTuple(args, "O!O!", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 932: &Imaging_Type, &imagep1, -: 933: &Imaging_Type, &imagep2)) { -: 934: return NULL; -: 935: } -: 936: 5: 937: if (!ImagingConvert2(imagep1->image, imagep2->image)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 938: return NULL; -: 939: } -: 940: 5: 941: Py_INCREF(Py_None); 5: 942: return Py_None; -: 943:} -: 944: -: 945:static PyObject* function _convert_matrix called 4 returned 100% blocks executed 100% 4: 946:_convert_matrix(ImagingObject* self, PyObject* args) -: 947:{ -: 948: char* mode; -: 949: float m[12]; 4: 950: if (!PyArg_ParseTuple(args, "s(ffff)", &mode, m+0, m+1, m+2, m+3)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 4: 951: PyErr_Clear(); call 0 returned 100% 4: 952: if (!PyArg_ParseTuple(args, "s(ffffffffffff)", &mode, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 953: m+0, m+1, m+2, m+3, -: 954: m+4, m+5, m+6, m+7, -: 955: m+8, m+9, m+10, m+11)){ -: 956: return NULL; -: 957: } -: 958: } -: 959: 4: 960: return PyImagingNew(ImagingConvertMatrix(self->image, mode, m)); call 0 returned 100% call 1 returned 100% -: 961:} -: 962: -: 963:static PyObject* function _convert_transparent called 8 returned 100% blocks executed 100% 8: 964:_convert_transparent(ImagingObject* self, PyObject* args) -: 965:{ -: 966: char* mode; -: 967: int r,g,b; 8: 968: if (PyArg_ParseTuple(args, "s(iii)", &mode, &r, &g, &b)) { call 0 returned 100% branch 1 taken 25% (fallthrough) branch 2 taken 75% 2: 969: return PyImagingNew(ImagingConvertTransparent(self->image, mode, r, g, b)); call 0 returned 100% call 1 returned 100% -: 970: } 6: 971: PyErr_Clear(); call 0 returned 100% 6: 972: if (PyArg_ParseTuple(args, "si", &mode, &r)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 6: 973: return PyImagingNew(ImagingConvertTransparent(self->image, mode, r, 0, 0)); call 0 returned 100% call 1 returned 100% -: 974: } -: 975: return NULL; -: 976:} -: 977: -: 978:static PyObject* function _copy called 2631 returned 100% blocks executed 100% 2631: 979:_copy(ImagingObject* self, PyObject* args) -: 980:{ 2631: 981: if (!PyArg_ParseTuple(args, "")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 982: return NULL; -: 983: } -: 984: 2631: 985: return PyImagingNew(ImagingCopy(self->image)); call 0 returned 100% call 1 returned 100% -: 986:} -: 987: -: 988:static PyObject* function _crop called 4182 returned 100% blocks executed 100% 4182: 989:_crop(ImagingObject* self, PyObject* args) -: 990:{ -: 991: int x0, y0, x1, y1; 4182: 992: if (!PyArg_ParseTuple(args, "(iiii)", &x0, &y0, &x1, &y1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 993: return NULL; -: 994: } -: 995: 4182: 996: return PyImagingNew(ImagingCrop(self->image, x0, y0, x1, y1)); call 0 returned 100% call 1 returned 100% -: 997:} -: 998: -: 999:static PyObject* function _expand_image called 47 returned 100% blocks executed 100% 47: 1000:_expand_image(ImagingObject* self, PyObject* args) -: 1001:{ -: 1002: int x, y; 47: 1003: int mode = 0; 47: 1004: if (!PyArg_ParseTuple(args, "ii|i", &x, &y, &mode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1005: return NULL; -: 1006: } -: 1007: 47: 1008: return PyImagingNew(ImagingExpand(self->image, x, y, mode)); call 0 returned 100% call 1 returned 100% -: 1009:} -: 1010: -: 1011:static PyObject* function _filter called 47 returned 100% blocks executed 92% 47: 1012:_filter(ImagingObject* self, PyObject* args) -: 1013:{ -: 1014: PyObject* imOut; -: 1015: Py_ssize_t kernelsize; -: 1016: FLOAT32* kerneldata; -: 1017: -: 1018: int xsize, ysize, i; -: 1019: float divisor, offset; 47: 1020: PyObject* kernel = NULL; 47: 1021: if (!PyArg_ParseTuple(args, "(ii)ffO", &xsize, &ysize, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1022: &divisor, &offset, &kernel)) { -: 1023: return NULL; -: 1024: } -: 1025: -: 1026: /* get user-defined kernel */ 47: 1027: kerneldata = getlist(kernel, &kernelsize, NULL, TYPE_FLOAT32); call 0 returned 100% 47: 1028: if (!kerneldata) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1029: return NULL; -: 1030: } 47: 1031: if (kernelsize != (Py_ssize_t) xsize * (Py_ssize_t) ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 1032: free(kerneldata); #####: 1033: return ImagingError_ValueError("bad kernel size"); call 0 never executed -: 1034: } -: 1035: 599: 1036: for (i = 0; i < kernelsize; ++i) { branch 0 taken 93% branch 1 taken 7% (fallthrough) 599: 1037: kerneldata[i] /= divisor; -: 1038: } -: 1039: 47: 1040: imOut = PyImagingNew( call 0 returned 100% call 1 returned 100% -: 1041: ImagingFilter(self->image, xsize, ysize, kerneldata, offset) -: 1042: ); -: 1043: 47: 1044: free(kerneldata); -: 1045: 47: 1046: return imOut; -: 1047:} -: 1048: -: 1049:#ifdef WITH_UNSHARPMASK -: 1050:static PyObject* function _gaussian_blur called 16 returned 100% blocks executed 100% 16: 1051:_gaussian_blur(ImagingObject* self, PyObject* args) -: 1052:{ -: 1053: Imaging imIn; -: 1054: Imaging imOut; -: 1055: 16: 1056: float radius = 0; 16: 1057: int passes = 3; 16: 1058: if (!PyArg_ParseTuple(args, "f|i", &radius, &passes)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1059: return NULL; -: 1060: } -: 1061: 16: 1062: imIn = self->image; 16: 1063: imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize); call 0 returned 100% 16: 1064: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1065: return NULL; -: 1066: } -: 1067: 16: 1068: if (!ImagingGaussianBlur(imOut, imIn, radius, passes)) { call 0 returned 100% branch 1 taken 25% (fallthrough) branch 2 taken 75% 4: 1069: ImagingDelete(imOut); call 0 returned 100% 4: 1070: return NULL; -: 1071: } -: 1072: 12: 1073: return PyImagingNew(imOut); call 0 returned 100% -: 1074:} -: 1075:#endif -: 1076: -: 1077:static PyObject* function _getpalette called 997 returned 100% blocks executed 87% 997: 1078:_getpalette(ImagingObject* self, PyObject* args) -: 1079:{ -: 1080: PyObject* palette; 997: 1081: int palettesize = 256; -: 1082: int bits; -: 1083: ImagingShuffler pack; -: 1084: 997: 1085: char* mode = "RGB"; 997: 1086: char* rawmode = "RGB"; 997: 1087: if (!PyArg_ParseTuple(args, "|ss", &mode, &rawmode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1088: return NULL; -: 1089: } -: 1090: 997: 1091: if (!self->image->palette) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 551: 1092: PyErr_SetString(PyExc_ValueError, no_palette); call 0 returned 100% 551: 1093: return NULL; -: 1094: } -: 1095: 446: 1096: pack = ImagingFindPacker(mode, rawmode, &bits); call 0 returned 100% 446: 1097: if (!pack) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1098: PyErr_SetString(PyExc_ValueError, wrong_raw_mode); call 0 never executed #####: 1099: return NULL; -: 1100: } -: 1101: 446: 1102: palette = PyBytes_FromStringAndSize(NULL, palettesize * bits / 8); call 0 returned 100% 446: 1103: if (!palette) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1104: return NULL; -: 1105: } -: 1106: 446: 1107: pack((UINT8*) PyBytes_AsString(palette), call 0 returned 100% call 1 returned 100% 446: 1108: self->image->palette->palette, palettesize); -: 1109: 446: 1110: return palette; -: 1111:} -: 1112: -: 1113:static PyObject* function _getpalettemode called 99 returned 100% blocks executed 60% 99: 1114:_getpalettemode(ImagingObject* self, PyObject* args) -: 1115:{ 99: 1116: if (!self->image->palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1117: PyErr_SetString(PyExc_ValueError, no_palette); call 0 never executed #####: 1118: return NULL; -: 1119: } -: 1120: 99: 1121: return PyUnicode_FromString(self->image->palette->mode); call 0 returned 100% -: 1122:} -: 1123: -: 1124:static inline int function _getxy called 553613 returned 100% blocks executed 43% 553613: 1125:_getxy(PyObject* xy, int* x, int *y) -: 1126:{ -: 1127: PyObject* value; -: 1128: 1107226: 1129: if (!PyTuple_Check(xy) || PyTuple_GET_SIZE(xy) != 2) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 1130: goto badarg; -: 1131: } -: 1132: 553613: 1133: value = PyTuple_GET_ITEM(xy, 0); 1107226: 1134: if (PyLong_Check(value)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 553613: 1135: *x = PyLong_AS_LONG(value); call 0 returned 100% #####: 1136: } else if (PyFloat_Check(value)) { branch 0 never executed branch 1 never executed call 2 never executed branch 3 never executed branch 4 never executed #####: 1137: *x = (int) PyFloat_AS_DOUBLE(value); -: 1138: } else { -: 1139: goto badval; -: 1140: } -: 1141: 553613: 1142: value = PyTuple_GET_ITEM(xy, 1); 1107226: 1143: if (PyLong_Check(value)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 553613: 1144: *y = PyLong_AS_LONG(value); call 0 returned 100% #####: 1145: } else if (PyFloat_Check(value)) { branch 0 never executed branch 1 never executed call 2 never executed branch 3 never executed branch 4 never executed #####: 1146: *y = (int) PyFloat_AS_DOUBLE(value); -: 1147: } else { -: 1148: goto badval; -: 1149: } -: 1150: -: 1151: return 0; -: 1152: -: 1153: badarg: #####: 1154: PyErr_SetString( call 0 never executed -: 1155: PyExc_TypeError, -: 1156: "argument must be sequence of length 2" -: 1157: ); #####: 1158: return -1; -: 1159: -: 1160: badval: #####: 1161: PyErr_SetString( call 0 never executed -: 1162: PyExc_TypeError, -: 1163: "an integer is required" -: 1164: ); #####: 1165: return -1; -: 1166:} -: 1167: -: 1168:static PyObject* function _getpixel called 67953 returned 100% blocks executed 67% 67953: 1169:_getpixel(ImagingObject* self, PyObject* args) -: 1170:{ -: 1171: PyObject* xy; -: 1172: int x, y; -: 1173: 67953: 1174: if (PyTuple_GET_SIZE(args) != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1175: PyErr_SetString( call 0 never executed -: 1176: PyExc_TypeError, -: 1177: "argument 1 must be sequence of length 2" -: 1178: ); #####: 1179: return NULL; -: 1180: } -: 1181: 67953: 1182: xy = PyTuple_GET_ITEM(args, 0); -: 1183: 67953: 1184: if (_getxy(xy, &x, &y)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1185: return NULL; -: 1186: } -: 1187: 67953: 1188: if (self->access == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1189: Py_INCREF(Py_None); #####: 1190: return Py_None; -: 1191: } -: 1192: 67953: 1193: return getpixel(self->image, self->access, x, y); call 0 returned 100% -: 1194:} -: 1195: -: 1196:union hist_extrema { -: 1197: UINT8 u[2]; -: 1198: INT32 i[2]; -: 1199: FLOAT32 f[2]; -: 1200:}; -: 1201: -: 1202:static union hist_extrema* function parse_histogram_extremap.isra.3 called 1968 returned 100% blocks executed 88% 1968: 1203:parse_histogram_extremap(ImagingObject* self, PyObject* extremap, -: 1204: union hist_extrema* ep) -: 1205:{ -: 1206: int i0, i1; -: 1207: double f0, f1; -: 1208: 1968: 1209: if (extremap) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 10: 1210: switch (self->image->type) { branch 0 taken 60% branch 1 taken 20% branch 2 taken 20% branch 3 taken 0% -: 1211: case IMAGING_TYPE_UINT8: 6: 1212: if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1213: return NULL; -: 1214: } 6: 1215: ep->u[0] = CLIP8(i0); branch 0 taken 0% (fallthrough) branch 1 taken 100% 6: 1216: ep->u[1] = CLIP8(i1); branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1217: break; -: 1218: case IMAGING_TYPE_INT32: 2: 1219: if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1220: return NULL; -: 1221: } 2: 1222: ep->i[0] = i0; 2: 1223: ep->i[1] = i1; -: 1224: break; -: 1225: case IMAGING_TYPE_FLOAT32: 2: 1226: if (!PyArg_ParseTuple(extremap, "dd", &f0, &f1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1227: return NULL; -: 1228: } 2: 1229: ep->f[0] = (FLOAT32) f0; 2: 1230: ep->f[1] = (FLOAT32) f1; -: 1231: break; -: 1232: default: -: 1233: return NULL; -: 1234: } -: 1235: } else { -: 1236: return NULL; -: 1237: } -: 1238: return ep; -: 1239:} -: 1240: -: 1241:static PyObject* function _histogram called 1958 returned 100% blocks executed 89% 1958: 1242:_histogram(ImagingObject* self, PyObject* args) -: 1243:{ -: 1244: ImagingHistogram h; -: 1245: PyObject* list; -: 1246: int i; -: 1247: union hist_extrema extrema; -: 1248: union hist_extrema* ep; -: 1249: 1958: 1250: PyObject* extremap = NULL; 1958: 1251: ImagingObject* maskp = NULL; 1958: 1252: if (!PyArg_ParseTuple(args, "|OO!", &extremap, &Imaging_Type, &maskp)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1253: return NULL; -: 1254: } -: 1255: -: 1256: /* Using a var to avoid allocations. */ 1958: 1257: ep = parse_histogram_extremap(self, extremap, &extrema); call 0 returned 100% 1958: 1258: h = ImagingGetHistogram(self->image, (maskp) ? maskp->image : NULL, ep); branch 0 taken 1% (fallthrough) branch 1 taken 99% call 2 returned 100% -: 1259: 1958: 1260: if (!h) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1261: return NULL; -: 1262: } -: 1263: -: 1264: /* Build an integer list containing the histogram */ 1958: 1265: list = PyList_New(h->bands * 256); 515494: 1266: for (i = 0; i < h->bands * 256; i++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) -: 1267: PyObject* item; 513536: 1268: item = PyLong_FromLong(h->histogram[i]); call 0 returned 100% 513536: 1269: if (item == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1270: Py_DECREF(list); -: 1271: list = NULL; -: 1272: break; -: 1273: } 513536: 1274: PyList_SetItem(list, i, item); call 0 returned 100% -: 1275: } -: 1276: -: 1277: /* Destroy the histogram structure */ 1958: 1278: ImagingHistogramDelete(h); call 0 returned 100% -: 1279: 1958: 1280: return list; -: 1281:} -: 1282: -: 1283:static PyObject* function _entropy called 10 returned 100% blocks executed 94% 10: 1284:_entropy(ImagingObject* self, PyObject* args) -: 1285:{ -: 1286: ImagingHistogram h; -: 1287: int idx, length; -: 1288: long sum; -: 1289: double entropy, fsum, p; -: 1290: union hist_extrema extrema; -: 1291: union hist_extrema* ep; -: 1292: 10: 1293: PyObject* extremap = NULL; 10: 1294: ImagingObject* maskp = NULL; 10: 1295: if (!PyArg_ParseTuple(args, "|OO!", &extremap, &Imaging_Type, &maskp)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1296: return NULL; -: 1297: } -: 1298: -: 1299: /* Using a local var to avoid allocations. */ 10: 1300: ep = parse_histogram_extremap(self, extremap, &extrema); call 0 returned 100% 10: 1301: h = ImagingGetHistogram(self->image, (maskp) ? maskp->image : NULL, ep); branch 0 taken 0% (fallthrough) branch 1 taken 100% call 2 returned 100% -: 1302: 10: 1303: if (!h) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1304: return NULL; -: 1305: } -: 1306: -: 1307: /* Calculate the histogram entropy */ -: 1308: /* First, sum the histogram data */ 10: 1309: length = h->bands * 256; 10: 1310: sum = 0; 5642: 1311: for (idx = 0; idx < length; idx++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5632: 1312: sum += h->histogram[idx]; -: 1313: } -: 1314: -: 1315: /* Next, normalize the histogram data, */ -: 1316: /* using the histogram sum value */ 10: 1317: fsum = (double)sum; 10: 1318: entropy = 0.0; 5642: 1319: for (idx = 0; idx < length; idx++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5632: 1320: p = (double)h->histogram[idx] / fsum; 5632: 1321: if (p != 0.0) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 4444: 1322: entropy += p * log(p) * M_LOG2E; -: 1323: } -: 1324: } -: 1325: -: 1326: /* Destroy the histogram structure */ 10: 1327: ImagingHistogramDelete(h); call 0 returned 100% -: 1328: 10: 1329: return PyFloat_FromDouble(-entropy); call 0 returned 100% -: 1330:} -: 1331: -: 1332:#ifdef WITH_MODEFILTER -: 1333:static PyObject* function _modefilter called 20 returned 100% blocks executed 100% 20: 1334:_modefilter(ImagingObject* self, PyObject* args) -: 1335:{ -: 1336: int size; 20: 1337: if (!PyArg_ParseTuple(args, "i", &size)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1338: return NULL; -: 1339: } -: 1340: 20: 1341: return PyImagingNew(ImagingModeFilter(self->image, size)); call 0 returned 100% call 1 returned 100% -: 1342:} -: 1343:#endif -: 1344: -: 1345:static PyObject* function _offset called 5 returned 100% blocks executed 100% 5: 1346:_offset(ImagingObject* self, PyObject* args) -: 1347:{ -: 1348: int xoffset, yoffset; 5: 1349: if (!PyArg_ParseTuple(args, "ii", &xoffset, &yoffset)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1350: return NULL; -: 1351: } -: 1352: 5: 1353: return PyImagingNew(ImagingOffset(self->image, xoffset, yoffset)); call 0 returned 100% call 1 returned 100% -: 1354:} -: 1355: -: 1356:static PyObject* function _paste called 14589 returned 100% blocks executed 100% 14589: 1357:_paste(ImagingObject* self, PyObject* args) -: 1358:{ -: 1359: int status; -: 1360: char ink[4]; -: 1361: -: 1362: PyObject* source; -: 1363: int x0, y0, x1, y1; 14589: 1364: ImagingObject* maskp = NULL; 14589: 1365: if (!PyArg_ParseTuple(args, "O(iiii)|O!", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1366: &source, -: 1367: &x0, &y0, &x1, &y1, -: 1368: &Imaging_Type, &maskp)) { -: 1369: return NULL; -: 1370: } -: 1371: 14589: 1372: if (PyImaging_Check(source)) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 29014: 1373: status = ImagingPaste( branch 0 taken 4% (fallthrough) branch 1 taken 96% call 2 returned 100% call 3 returned 100% -: 1374: self->image, PyImaging_AsImaging(source), 14507: 1375: (maskp) ? maskp->image : NULL, -: 1376: x0, y0, x1, y1 -: 1377: ); -: 1378: -: 1379: } else { 82: 1380: if (!getink(source, self->image, ink)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1381: return NULL; -: 1382: } 164: 1383: status = ImagingFill2( branch 0 taken 29% (fallthrough) branch 1 taken 71% call 2 returned 100% -: 1384: self->image, ink, 82: 1385: (maskp) ? maskp->image : NULL, -: 1386: x0, y0, x1, y1 -: 1387: ); -: 1388: } -: 1389: 14589: 1390: if (status < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1391: return NULL; -: 1392: } -: 1393: 14589: 1394: Py_INCREF(Py_None); 14589: 1395: return Py_None; -: 1396:} -: 1397: -: 1398:static PyObject* function _point called 45 returned 100% blocks executed 72% 45: 1399:_point(ImagingObject* self, PyObject* args) -: 1400:{ -: 1401: static const char* wrong_number = "wrong number of lut entries"; -: 1402: -: 1403: Py_ssize_t n; -: 1404: int i, bands; -: 1405: Imaging im; -: 1406: -: 1407: PyObject* list; -: 1408: char* mode; 45: 1409: if (!PyArg_ParseTuple(args, "Oz", &list, &mode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1410: return NULL; -: 1411: } -: 1412: 46: 1413: if (mode && !strcmp(mode, "F")) { branch 0 taken 7% (fallthrough) branch 1 taken 93% branch 2 taken 33% (fallthrough) branch 3 taken 67% branch 4 taken 33% (fallthrough) branch 5 taken 67% -: 1414: FLOAT32* data; -: 1415: -: 1416: /* map from 8-bit data to floating point */ 1: 1417: n = 256; 1: 1418: data = getlist(list, &n, wrong_number, TYPE_FLOAT32); call 0 returned 100% 1: 1419: if (!data) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1420: return NULL; -: 1421: } 1: 1422: im = ImagingPoint(self->image, mode, (void*) data); call 0 returned 100% 1: 1423: free(data); -: 1424: 45: 1425: } else if (!strcmp(self->image->mode, "I") && mode && !strcmp(mode, "L")) { branch 0 taken 5% (fallthrough) branch 1 taken 95% branch 2 taken 5% (fallthrough) branch 3 taken 95% branch 4 taken 50% (fallthrough) branch 5 taken 50% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 100% (fallthrough) branch 9 taken 0% -: 1426: UINT8* data; -: 1427: -: 1428: /* map from 16-bit subset of 32-bit data to 8-bit */ -: 1429: /* FIXME: support arbitrary number of entries (requires API change) */ 1: 1430: n = 65536; 1: 1431: data = getlist(list, &n, wrong_number, TYPE_UINT8); call 0 returned 100% 1: 1432: if (!data) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1433: return NULL; -: 1434: } 1: 1435: im = ImagingPoint(self->image, mode, (void*) data); call 0 returned 100% 1: 1436: free(data); -: 1437: -: 1438: } else { -: 1439: INT32* data; -: 1440: UINT8 lut[1024]; -: 1441: 43: 1442: if (mode) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 1: 1443: bands = getbands(mode); call 0 returned 100% 1: 1444: if (bands < 0) { branch 0 taken 100% branch 1 taken 0% 1: 1445: return NULL; -: 1446: } -: 1447: } else { 42: 1448: bands = self->image->bands; -: 1449: } -: 1450: -: 1451: /* map to integer data */ 43: 1452: n = 256 * bands; 43: 1453: data = getlist(list, &n, wrong_number, TYPE_INT32); call 0 returned 100% 43: 1454: if (!data) { branch 0 taken 98% (fallthrough) branch 1 taken 2% -: 1455: return NULL; -: 1456: } -: 1457: 42: 1458: if (mode && !strcmp(mode, "I")) { branch 0 taken 2% (fallthrough) branch 1 taken 98% branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 1459: im = ImagingPoint(self->image, mode, (void*) data); call 0 never executed 42: 1460: } else if (mode && bands > 1) { branch 0 taken 2% (fallthrough) branch 1 taken 98% branch 2 taken 100% (fallthrough) branch 3 taken 0% #####: 1461: for (i = 0; i < 256; i++) { branch 0 never executed branch 1 never executed #####: 1462: lut[i*4] = CLIP8(data[i]); branch 0 never executed branch 1 never executed #####: 1463: lut[i*4+1] = CLIP8(data[i+256]); branch 0 never executed branch 1 never executed #####: 1464: lut[i*4+2] = CLIP8(data[i+512]); branch 0 never executed branch 1 never executed #####: 1465: if (n > 768) { branch 0 never executed branch 1 never executed #####: 1466: lut[i*4+3] = CLIP8(data[i+768]); branch 0 never executed branch 1 never executed -: 1467: } -: 1468: } #####: 1469: im = ImagingPoint(self->image, mode, (void*) lut); call 0 never executed -: 1470: } else { -: 1471: /* map individual bands */ 19968: 1472: for (i = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 19968: 1473: lut[i] = CLIP8(data[i]); branch 0 taken 93% (fallthrough) branch 1 taken 7% -: 1474: } 42: 1475: im = ImagingPoint(self->image, mode, (void*) lut); call 0 returned 100% -: 1476: } 42: 1477: free(data); -: 1478: } -: 1479: 44: 1480: return PyImagingNew(im); call 0 returned 100% -: 1481:} -: 1482: -: 1483:static PyObject* function _point_transform called 4 returned 100% blocks executed 100% 4: 1484:_point_transform(ImagingObject* self, PyObject* args) -: 1485:{ 4: 1486: double scale = 1.0; 4: 1487: double offset = 0.0; 4: 1488: if (!PyArg_ParseTuple(args, "|dd", &scale, &offset)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1489: return NULL; -: 1490: } -: 1491: 4: 1492: return PyImagingNew(ImagingPointTransform(self->image, scale, offset)); call 0 returned 100% call 1 returned 100% -: 1493:} -: 1494: -: 1495:static PyObject* function _putdata called 40 returned 100% blocks executed 67% 40: 1496:_putdata(ImagingObject* self, PyObject* args) -: 1497:{ -: 1498: Imaging image; -: 1499: // i & n are # pixels, require py_ssize_t. x can be as large as n. y, just because. -: 1500: Py_ssize_t n, i, x, y; -: 1501: -: 1502: PyObject* data; 40: 1503: PyObject* seq = NULL; -: 1504: PyObject* op; 40: 1505: double scale = 1.0; 40: 1506: double offset = 0.0; -: 1507: 40: 1508: if (!PyArg_ParseTuple(args, "O|dd", &data, &scale, &offset)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1509: return NULL; -: 1510: } -: 1511: 40: 1512: if (!PySequence_Check(data)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 1513: PyErr_SetString(PyExc_TypeError, must_be_sequence); call 0 never executed #####: 1514: return NULL; -: 1515: } -: 1516: 40: 1517: image = self->image; -: 1518: 40: 1519: n = PyObject_Length(data); call 0 returned 100% 40: 1520: if (n > (Py_ssize_t)image->xsize * (Py_ssize_t)image->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1521: PyErr_SetString(PyExc_TypeError, "too many data entries"); call 0 never executed #####: 1522: return NULL; -: 1523: } -: 1524: 40: 1525: if (image->image8) { branch 0 taken 60% (fallthrough) branch 1 taken 40% 48: 1526: if (PyBytes_Check(data)) { branch 0 taken 4% (fallthrough) branch 1 taken 96% -: 1527: unsigned char* p; 1: 1528: p = (unsigned char*) PyBytes_AS_STRING(data); 1: 1529: if (scale == 1.0 && offset == 0.0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 1530: /* Plain string data */ 16: 1531: for (i = y = 0; i < n; i += image->xsize, y++) { branch 0 taken 94% branch 1 taken 6% 16: 1532: x = n - i; 16: 1533: if (x > (int) image->xsize) { branch 0 taken 94% (fallthrough) branch 1 taken 6% 15: 1534: x = image->xsize; -: 1535: } 32: 1536: memcpy(image->image8[y], p+i, x); -: 1537: } -: 1538: } else { -: 1539: /* Scaled and clipped string data */ #####: 1540: for (i = x = y = 0; i < n; i++) { branch 0 never executed branch 1 never executed #####: 1541: image->image8[y][x] = CLIP8((int) (p[i] * scale + offset)); branch 0 never executed branch 1 never executed #####: 1542: if (++x >= (int) image->xsize) { branch 0 never executed branch 1 never executed #####: 1543: x = 0, y++; -: 1544: } -: 1545: } -: 1546: } -: 1547: } else { 23: 1548: seq = PySequence_Fast(data, must_be_sequence); call 0 returned 100% 23: 1549: if (!seq) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1550: PyErr_SetString(PyExc_TypeError, must_be_sequence); call 0 never executed #####: 1551: return NULL; -: 1552: } 23: 1553: if (scale == 1.0 && offset == 0.0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 1554: /* Clipped data */ 4070356: 1555: for (i = x = y = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% 8140712: 1556: op = PySequence_Fast_GET_ITEM(seq, i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 4070356: 1557: image->image8[y][x] = (UINT8) CLIP8(PyLong_AsLong(op)); call 0 returned 100% branch 1 taken 94% (fallthrough) branch 2 taken 6% call 3 returned 100% branch 4 taken 100% (fallthrough) branch 5 taken 0% call 6 returned 100% 4070356: 1558: if (++x >= (int) image->xsize){ branch 0 taken 1% (fallthrough) branch 1 taken 99% 5836: 1559: x = 0, y++; -: 1560: } -: 1561: } -: 1562: -: 1563: } else { -: 1564: /* Scaled and clipped data */ #####: 1565: for (i = x = y = 0; i < n; i++) { branch 0 never executed branch 1 never executed #####: 1566: PyObject *op = PySequence_Fast_GET_ITEM(seq, i); branch 0 never executed branch 1 never executed #####: 1567: image->image8[y][x] = CLIP8( call 0 never executed branch 1 never executed branch 2 never executed call 3 never executed branch 4 never executed branch 5 never executed call 6 never executed -: 1568: (int) (PyFloat_AsDouble(op) * scale + offset)); #####: 1569: if (++x >= (int) image->xsize){ branch 0 never executed branch 1 never executed #####: 1570: x = 0, y++; -: 1571: } -: 1572: } -: 1573: } 23: 1574: PyErr_Clear(); /* Avoid weird exceptions */ call 0 returned 100% -: 1575: } -: 1576: } else { -: 1577: /* 32-bit images */ 16: 1578: seq = PySequence_Fast(data, must_be_sequence); call 0 returned 100% 16: 1579: if (!seq) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1580: PyErr_SetString(PyExc_TypeError, must_be_sequence); call 0 never executed #####: 1581: return NULL; -: 1582: } 16: 1583: switch (image->type) { branch 0 taken 25% branch 1 taken 13% branch 2 taken 63% -: 1584: case IMAGING_TYPE_INT32: 16393: 1585: for (i = x = y = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32786: 1586: op = PySequence_Fast_GET_ITEM(seq, i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 32786: 1587: IMAGING_PIXEL_INT32(image, x, y) = 16393: 1588: (INT32) (PyFloat_AsDouble(op) * scale + offset); call 0 returned 100% 16393: 1589: if (++x >= (int) image->xsize){ branch 0 taken 1% (fallthrough) branch 1 taken 99% 131: 1590: x = 0, y++; -: 1591: } -: 1592: } 2: 1593: PyErr_Clear(); /* Avoid weird exceptions */ call 0 returned 100% 2: 1594: break; -: 1595: case IMAGING_TYPE_FLOAT32: 46393: 1596: for (i = x = y = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 92786: 1597: op = PySequence_Fast_GET_ITEM(seq, i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 92786: 1598: IMAGING_PIXEL_FLOAT32(image, x, y) = 46393: 1599: (FLOAT32) (PyFloat_AsDouble(op) * scale + offset); call 0 returned 100% 46393: 1600: if (++x >= (int) image->xsize){ branch 0 taken 1% (fallthrough) branch 1 taken 99% 331: 1601: x = 0, y++; -: 1602: } -: 1603: } 4: 1604: PyErr_Clear(); /* Avoid weird exceptions */ call 0 returned 100% 4: 1605: break; -: 1606: default: 32800: 1607: for (i = x = y = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 1608: union { -: 1609: char ink[4]; -: 1610: INT32 inkint; -: 1611: } u; -: 1612: 32800: 1613: u.inkint = 0; -: 1614: 65600: 1615: op = PySequence_Fast_GET_ITEM(seq, i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 32800: 1616: if (!op || !getink(op, image, u.ink)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 returned 100% branch 3 taken 0% (fallthrough) branch 4 taken 100% #####: 1617: Py_DECREF(seq); #####: 1618: return NULL; -: 1619: } -: 1620: /* FIXME: what about scale and offset? */ 32800: 1621: image->image32[y][x] = u.inkint; 32800: 1622: if (++x >= (int) image->xsize){ branch 0 taken 1% (fallthrough) branch 1 taken 99% 270: 1623: x = 0, y++; -: 1624: } -: 1625: } 10: 1626: PyErr_Clear(); /* Avoid weird exceptions */ call 0 returned 100% 10: 1627: break; -: 1628: } -: 1629: } -: 1630: 40: 1631: Py_XDECREF(seq); -: 1632: 40: 1633: Py_INCREF(Py_None); 40: 1634: return Py_None; -: 1635:} -: 1636: -: 1637:#ifdef WITH_QUANTIZE -: 1638: -: 1639:static PyObject* function _quantize called 26 returned 100% blocks executed 78% 26: 1640:_quantize(ImagingObject* self, PyObject* args) -: 1641:{ 26: 1642: int colours = 256; 26: 1643: int method = 0; 26: 1644: int kmeans = 0; 26: 1645: if (!PyArg_ParseTuple(args, "|iii", &colours, &method, &kmeans)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1646: return NULL; -: 1647: } -: 1648: 26: 1649: if (!self->image->xsize || !self->image->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 1650: /* no content; return an empty image */ #####: 1651: return PyImagingNew( call 0 never executed call 1 never executed -: 1652: ImagingNew("P", self->image->xsize, self->image->ysize) -: 1653: ); -: 1654: } -: 1655: 26: 1656: return PyImagingNew(ImagingQuantize(self->image, colours, method, kmeans)); call 0 returned 100% call 1 returned 100% -: 1657:} -: 1658:#endif -: 1659: -: 1660:static PyObject* function _putpalette called 976 returned 100% blocks executed 88% 976: 1661:_putpalette(ImagingObject* self, PyObject* args) -: 1662:{ -: 1663: ImagingShuffler unpack; -: 1664: int bits; -: 1665: -: 1666: char* rawmode; -: 1667: UINT8* palette; -: 1668: Py_ssize_t palettesize; 976: 1669: if (!PyArg_ParseTuple(args, "sy#", &rawmode, &palette, &palettesize)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1670: return NULL; -: 1671: } -: 1672: 1824: 1673: if (strcmp(self->image->mode, "L") && strcmp(self->image->mode, "LA") && branch 0 taken 13% (fallthrough) branch 1 taken 87% branch 2 taken 88% (fallthrough) branch 3 taken 12% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 99% (fallthrough) branch 9 taken 1% branch 10 taken 2% (fallthrough) branch 11 taken 98% 864: 1674: strcmp(self->image->mode, "P") && strcmp(self->image->mode, "PA")) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 0% (fallthrough) branch 7 taken 100% #####: 1675: PyErr_SetString(PyExc_ValueError, wrong_mode); call 0 never executed #####: 1676: return NULL; -: 1677: } -: 1678: 976: 1679: unpack = ImagingFindUnpacker("RGB", rawmode, &bits); call 0 returned 100% 976: 1680: if (!unpack) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1681: PyErr_SetString(PyExc_ValueError, wrong_raw_mode); call 0 never executed #####: 1682: return NULL; -: 1683: } -: 1684: 976: 1685: if ( palettesize * 8 / bits > 256) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 1686: PyErr_SetString(PyExc_ValueError, wrong_palette_size); call 0 returned 100% 1: 1687: return NULL; -: 1688: } -: 1689: 975: 1690: ImagingPaletteDelete(self->image->palette); call 0 returned 100% -: 1691: 1950: 1692: strcpy(self->image->mode, strlen(self->image->mode) == 2 ? "PA" : "P"); branch 0 taken 98% (fallthrough) branch 1 taken 2% -: 1693: 975: 1694: self->image->palette = ImagingPaletteNew("RGB"); call 0 returned 100% -: 1695: 975: 1696: unpack(self->image->palette->palette, palette, palettesize * 8 / bits); call 0 returned 100% -: 1697: 975: 1698: Py_INCREF(Py_None); 975: 1699: return Py_None; -: 1700:} -: 1701: -: 1702:static PyObject* function _putpalettealpha called 408 returned 100% blocks executed 60% 408: 1703:_putpalettealpha(ImagingObject* self, PyObject* args) -: 1704:{ -: 1705: int index; 408: 1706: int alpha = 0; 408: 1707: if (!PyArg_ParseTuple(args, "i|i", &index, &alpha)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1708: return NULL; -: 1709: } -: 1710: 408: 1711: if (!self->image->palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1712: PyErr_SetString(PyExc_ValueError, no_palette); call 0 never executed #####: 1713: return NULL; -: 1714: } -: 1715: 408: 1716: if (index < 0 || index >= 256) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1717: PyErr_SetString(PyExc_ValueError, outside_palette); call 0 never executed #####: 1718: return NULL; -: 1719: } -: 1720: 816: 1721: strcpy(self->image->palette->mode, "RGBA"); 408: 1722: self->image->palette->palette[index*4+3] = (UINT8) alpha; -: 1723: 408: 1724: Py_INCREF(Py_None); 408: 1725: return Py_None; -: 1726:} -: 1727: -: 1728:static PyObject* function _putpalettealphas called 35 returned 100% blocks executed 69% 35: 1729:_putpalettealphas(ImagingObject* self, PyObject* args) -: 1730:{ -: 1731: int i; -: 1732: UINT8 *values; -: 1733: Py_ssize_t length; 35: 1734: if (!PyArg_ParseTuple(args, "y#", &values, &length)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1735: return NULL; -: 1736: } -: 1737: 35: 1738: if (!self->image->palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1739: PyErr_SetString(PyExc_ValueError, no_palette); call 0 never executed #####: 1740: return NULL; -: 1741: } -: 1742: 35: 1743: if (length > 256) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1744: PyErr_SetString(PyExc_ValueError, outside_palette); call 0 never executed #####: 1745: return NULL; -: 1746: } -: 1747: 70: 1748: strcpy(self->image->palette->mode, "RGBA"); 8487: 1749: for (i=0; iimage->palette->palette[i*4+3] = (UINT8) values[i]; -: 1751: } -: 1752: 35: 1753: Py_INCREF(Py_None); 35: 1754: return Py_None; -: 1755:} -: 1756: -: 1757:static PyObject* function _putpixel called 91439 returned 100% blocks executed 100% 91439: 1758:_putpixel(ImagingObject* self, PyObject* args) -: 1759:{ -: 1760: Imaging im; -: 1761: char ink[4]; -: 1762: -: 1763: int x, y; -: 1764: PyObject* color; 91439: 1765: if (!PyArg_ParseTuple(args, "(ii)O", &x, &y, &color)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1766: return NULL; -: 1767: } -: 1768: 91439: 1769: im = self->image; -: 1770: 91439: 1771: if (x < 0) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 32834: 1772: x = im->xsize + x; -: 1773: } 91439: 1774: if (y < 0) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 32834: 1775: y = im->ysize + y; -: 1776: } -: 1777: 91439: 1778: if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 0% (fallthrough) branch 7 taken 100% 88: 1779: PyErr_SetString(PyExc_IndexError, outside_image); call 0 returned 100% 88: 1780: return NULL; -: 1781: } -: 1782: 91351: 1783: if (!getink(color, im, ink)) { call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 1784: return NULL; -: 1785: } -: 1786: 91322: 1787: if (self->access) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 91322: 1788: self->access->put_pixel(im, x, y, ink); call 0 returned 100% -: 1789: } -: 1790: 91322: 1791: Py_INCREF(Py_None); 91322: 1792: return Py_None; -: 1793:} -: 1794: -: 1795:#ifdef WITH_RANKFILTER -: 1796:static PyObject* function _rankfilter called 45 returned 100% blocks executed 100% 45: 1797:_rankfilter(ImagingObject* self, PyObject* args) -: 1798:{ -: 1799: int size, rank; 45: 1800: if (!PyArg_ParseTuple(args, "ii", &size, &rank)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1801: return NULL; -: 1802: } -: 1803: 45: 1804: return PyImagingNew(ImagingRankFilter(self->image, size, rank)); call 0 returned 100% call 1 returned 100% -: 1805:} -: 1806:#endif -: 1807: -: 1808:static PyObject* function _resize called 11060 returned 100% blocks executed 100% 11060: 1809:_resize(ImagingObject* self, PyObject* args) -: 1810:{ -: 1811: Imaging imIn; -: 1812: Imaging imOut; -: 1813: -: 1814: int xsize, ysize; 11060: 1815: int filter = IMAGING_TRANSFORM_NEAREST; 11060: 1816: float box[4] = {0, 0, 0, 0}; -: 1817: 11060: 1818: imIn = self->image; 11060: 1819: box[2] = imIn->xsize; 11060: 1820: box[3] = imIn->ysize; -: 1821: 11060: 1822: if (!PyArg_ParseTuple(args, "(ii)|i(ffff)", &xsize, &ysize, &filter, call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 1823: &box[0], &box[1], &box[2], &box[3])) { -: 1824: return NULL; -: 1825: } -: 1826: 11054: 1827: if (xsize < 1 || ysize < 1) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1828: return ImagingError_ValueError("height and width must be > 0"); call 0 returned 100% -: 1829: } -: 1830: 11052: 1831: if (box[0] < 0 || box[1] < 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 12: 1832: return ImagingError_ValueError("box offset can't be negative"); call 0 returned 100% -: 1833: } -: 1834: 11040: 1835: if (box[2] > imIn->xsize || box[3] > imIn->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 12: 1836: return ImagingError_ValueError("box can't exceed original image size"); call 0 returned 100% -: 1837: } -: 1838: 11028: 1839: if (box[2] - box[0] < 0 || box[3] - box[1] < 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 18: 1840: return ImagingError_ValueError("box can't be empty"); call 0 returned 100% -: 1841: } -: 1842: -: 1843: // If box's coordinates are int and box size matches requested size 11010: 1844: if (box[0] - (int) box[0] == 0 && box[2] - box[0] == xsize branch 0 taken 9% (fallthrough) branch 1 taken 91% branch 2 taken 10% (fallthrough) branch 3 taken 90% 104: 1845: && box[1] - (int) box[1] == 0 && box[3] - box[1] == ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 23% (fallthrough) branch 3 taken 77% 24: 1846: imOut = ImagingCrop(imIn, box[0], box[1], box[2], box[3]); call 0 returned 100% -: 1847: } 10986: 1848: else if (filter == IMAGING_TRANSFORM_NEAREST) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 1849: double a[6]; -: 1850: 110: 1851: memset(a, 0, sizeof a); 110: 1852: a[0] = (double) (box[2] - box[0]) / xsize; 110: 1853: a[4] = (double) (box[3] - box[1]) / ysize; 110: 1854: a[2] = box[0]; 110: 1855: a[5] = box[1]; -: 1856: 110: 1857: imOut = ImagingNewDirty(imIn->mode, xsize, ysize); call 0 returned 100% -: 1858: 110: 1859: imOut = ImagingTransform( call 0 returned 100% -: 1860: imOut, imIn, IMAGING_TRANSFORM_AFFINE, -: 1861: 0, 0, xsize, ysize, -: 1862: a, filter, 1); -: 1863: } -: 1864: else { 10876: 1865: imOut = ImagingResample(imIn, xsize, ysize, filter, box); call 0 returned 100% -: 1866: } -: 1867: 11010: 1868: return PyImagingNew(imOut); call 0 returned 100% -: 1869:} -: 1870: -: 1871:static PyObject* function _reduce called 513 returned 100% blocks executed 100% 513: 1872:_reduce(ImagingObject* self, PyObject* args) -: 1873:{ -: 1874: Imaging imIn; -: 1875: Imaging imOut; -: 1876: -: 1877: int xscale, yscale; 513: 1878: int box[4] = {0, 0, 0, 0}; -: 1879: 513: 1880: imIn = self->image; 513: 1881: box[2] = imIn->xsize; 513: 1882: box[3] = imIn->ysize; -: 1883: 513: 1884: if (!PyArg_ParseTuple(args, "(ii)|(iiii)", &xscale, &yscale, call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 1885: &box[0], &box[1], &box[2], &box[3])) { -: 1886: return NULL; -: 1887: } -: 1888: 511: 1889: if (xscale < 1 || yscale < 1) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 0% (fallthrough) branch 3 taken 100% 2: 1890: return ImagingError_ValueError("scale must be > 0"); call 0 returned 100% -: 1891: } -: 1892: 509: 1893: if (box[0] < 0 || box[1] < 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1894: return ImagingError_ValueError("box offset can't be negative"); call 0 returned 100% -: 1895: } -: 1896: 507: 1897: if (box[2] > imIn->xsize || box[3] > imIn->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1898: return ImagingError_ValueError("box can't exceed original image size"); call 0 returned 100% -: 1899: } -: 1900: 505: 1901: if (box[2] <= box[0] || box[3] <= box[1]) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1902: return ImagingError_ValueError("box can't be empty"); call 0 returned 100% -: 1903: } -: 1904: 503: 1905: if (xscale == 1 && yscale == 1) { branch 0 taken 22% (fallthrough) branch 1 taken 78% branch 2 taken 7% (fallthrough) branch 3 taken 93% 8: 1906: imOut = ImagingCrop(imIn, box[0], box[1], box[2], box[3]); call 0 returned 100% -: 1907: } else { -: 1908: // Change box format: (left, top, width, height) 495: 1909: box[2] -= box[0]; 495: 1910: box[3] -= box[1]; 495: 1911: imOut = ImagingReduce(imIn, xscale, yscale, box); call 0 returned 100% -: 1912: } -: 1913: 503: 1914: return PyImagingNew(imOut); call 0 returned 100% -: 1915:} -: 1916: -: 1917: -: 1918:#define IS_RGB(mode)\ -: 1919: (!strcmp(mode, "RGB") || !strcmp(mode, "RGBA") || !strcmp(mode, "RGBX")) -: 1920: -: 1921:static PyObject* function im_setmode called 22 returned 100% blocks executed 100% 22: 1922:im_setmode(ImagingObject* self, PyObject* args) -: 1923:{ -: 1924: /* attempt to modify the mode of an image in place */ -: 1925: -: 1926: Imaging im; -: 1927: -: 1928: char* mode; -: 1929: Py_ssize_t modelen; 22: 1930: if (!PyArg_ParseTuple(args, "s#:setmode", &mode, &modelen)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1931: return NULL; -: 1932: } -: 1933: 22: 1934: im = self->image; -: 1935: -: 1936: /* move all logic in here to the libImaging primitive */ -: 1937: 22: 1938: if (!strcmp(im->mode, mode)) { branch 0 taken 86% (fallthrough) branch 1 taken 14% -: 1939: ; /* same mode; always succeeds */ 19: 1940: } else if (IS_RGB(im->mode) && IS_RGB(mode)) { branch 0 taken 79% (fallthrough) branch 1 taken 21% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 32% (fallthrough) branch 7 taken 68% branch 8 taken 83% (fallthrough) branch 9 taken 17% branch 10 taken 20% (fallthrough) branch 11 taken 80% branch 12 taken 93% (fallthrough) branch 13 taken 7% branch 14 taken 100% (fallthrough) branch 15 taken 0% branch 16 taken 100% (fallthrough) branch 17 taken 0% branch 18 taken 93% (fallthrough) branch 19 taken 7% branch 20 taken 21% (fallthrough) branch 21 taken 79% branch 22 taken 33% (fallthrough) branch 23 taken 67% -: 1941: /* color to color */ 26: 1942: strcpy(im->mode, mode); 13: 1943: im->bands = modelen; 13: 1944: if (!strcmp(mode, "RGBA")) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 11: 1945: (void) ImagingFillBand(im, 3, 255); call 0 returned 100% -: 1946: } -: 1947: } else { -: 1948: /* trying doing an in-place conversion */ 6: 1949: if (!ImagingConvertInPlace(im, mode)) { call 0 returned 100% branch 1 taken 33% (fallthrough) branch 2 taken 67% -: 1950: return NULL; -: 1951: } -: 1952: } -: 1953: -: 1954: if (self->access) { -: 1955: ImagingAccessDelete(im, self->access); -: 1956: } 18: 1957: self->access = ImagingAccessNew(im); call 0 returned 100% -: 1958: 18: 1959: Py_INCREF(Py_None); 18: 1960: return Py_None; -: 1961:} -: 1962: -: 1963: -: 1964:static PyObject* function _transform2 called 274 returned 100% blocks executed 92% 274: 1965:_transform2(ImagingObject* self, PyObject* args) -: 1966:{ -: 1967: static const char* wrong_number = "wrong number of matrix entries"; -: 1968: -: 1969: Imaging imOut; -: 1970: Py_ssize_t n; -: 1971: double *a; -: 1972: -: 1973: ImagingObject* imagep; -: 1974: int x0, y0, x1, y1; -: 1975: int method; -: 1976: PyObject* data; 274: 1977: int filter = IMAGING_TRANSFORM_NEAREST; 274: 1978: int fill = 1; 274: 1979: if (!PyArg_ParseTuple(args, "(iiii)O!iO|ii", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1980: &x0, &y0, &x1, &y1, -: 1981: &Imaging_Type, &imagep, -: 1982: &method, &data, -: 1983: &filter, &fill)) { -: 1984: return NULL; -: 1985: } -: 1986: 274: 1987: switch (method) { branch 0 taken 75% branch 1 taken 22% branch 2 taken 3% branch 3 taken 0% -: 1988: case IMAGING_TRANSFORM_AFFINE: 205: 1989: n = 6; 205: 1990: break; -: 1991: case IMAGING_TRANSFORM_PERSPECTIVE: 60: 1992: n = 8; 60: 1993: break; -: 1994: case IMAGING_TRANSFORM_QUAD: 9: 1995: n = 8; 9: 1996: break; -: 1997: default: #####: 1998: n = -1; /* force error */ -: 1999: } -: 2000: 274: 2001: a = getlist(data, &n, wrong_number, TYPE_DOUBLE); call 0 returned 100% 274: 2002: if (!a) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2003: return NULL; -: 2004: } -: 2005: 548: 2006: imOut = ImagingTransform( call 0 returned 100% 274: 2007: self->image, imagep->image, method, -: 2008: x0, y0, x1, y1, a, filter, fill); -: 2009: 274: 2010: free(a); -: 2011: 274: 2012: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2013: return NULL; -: 2014: } -: 2015: 274: 2016: Py_INCREF(Py_None); 274: 2017: return Py_None; -: 2018:} -: 2019: -: 2020:static PyObject* function _transpose called 291 returned 100% blocks executed 87% 291: 2021:_transpose(ImagingObject* self, PyObject* args) -: 2022:{ -: 2023: Imaging imIn; -: 2024: Imaging imOut; -: 2025: -: 2026: int op; 291: 2027: if (!PyArg_ParseTuple(args, "i", &op)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2028: return NULL; -: 2029: } -: 2030: 291: 2031: imIn = self->image; -: 2032: 291: 2033: switch (op) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 43% (fallthrough) branch 3 taken 57% branch 4 taken 0% (fallthrough) branch 5 taken 100% -: 2034: case 0: /* flip left right */ -: 2035: case 1: /* flip top bottom */ -: 2036: case 3: /* rotate 180 */ 125: 2037: imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize); call 0 returned 100% 125: 2038: break; -: 2039: case 2: /* rotate 90 */ -: 2040: case 4: /* rotate 270 */ -: 2041: case 5: /* transpose */ -: 2042: case 6: /* transverse */ 166: 2043: imOut = ImagingNewDirty(imIn->mode, imIn->ysize, imIn->xsize); call 0 returned 100% 166: 2044: break; -: 2045: default: #####: 2046: PyErr_SetString(PyExc_ValueError, "No such transpose operation"); call 0 never executed #####: 2047: return NULL; -: 2048: } -: 2049: 291: 2050: if (imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 291: 2051: switch (op) { branch 0 taken 12% branch 1 taken 11% branch 2 taken 24% branch 3 taken 20% branch 4 taken 16% branch 5 taken 9% branch 6 taken 9% branch 7 taken 0% -: 2052: case 0: 34: 2053: (void) ImagingFlipLeftRight(imOut, imIn); call 0 returned 100% 34: 2054: break; -: 2055: case 1: 32: 2056: (void) ImagingFlipTopBottom(imOut, imIn); call 0 returned 100% 32: 2057: break; -: 2058: case 2: 70: 2059: (void) ImagingRotate90(imOut, imIn); call 0 returned 100% 70: 2060: break; -: 2061: case 3: 59: 2062: (void) ImagingRotate180(imOut, imIn); call 0 returned 100% 59: 2063: break; -: 2064: case 4: 46: 2065: (void) ImagingRotate270(imOut, imIn); call 0 returned 100% 46: 2066: break; -: 2067: case 5: 25: 2068: (void) ImagingTranspose(imOut, imIn); call 0 returned 100% 25: 2069: break; -: 2070: case 6: 25: 2071: (void) ImagingTransverse(imOut, imIn); call 0 returned 100% 25: 2072: break; -: 2073: } -: 2074: } -: 2075: 291: 2076: return PyImagingNew(imOut); call 0 returned 100% -: 2077:} -: 2078: -: 2079:#ifdef WITH_UNSHARPMASK -: 2080:static PyObject* function _unsharp_mask called 16 returned 100% blocks executed 100% 16: 2081:_unsharp_mask(ImagingObject* self, PyObject* args) -: 2082:{ -: 2083: Imaging imIn; -: 2084: Imaging imOut; -: 2085: -: 2086: float radius; -: 2087: int percent, threshold; 16: 2088: if (!PyArg_ParseTuple(args, "fii", &radius, &percent, &threshold)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2089: return NULL; -: 2090: } -: 2091: 16: 2092: imIn = self->image; 16: 2093: imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize); call 0 returned 100% 16: 2094: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2095: return NULL; -: 2096: } -: 2097: 16: 2098: if (!ImagingUnsharpMask(imOut, imIn, radius, percent, threshold)) { call 0 returned 100% branch 1 taken 75% (fallthrough) branch 2 taken 25% -: 2099: return NULL; -: 2100: } -: 2101: 12: 2102: return PyImagingNew(imOut); call 0 returned 100% -: 2103:} -: 2104:#endif -: 2105: -: 2106:static PyObject* function _box_blur called 40 returned 100% blocks executed 100% 40: 2107:_box_blur(ImagingObject* self, PyObject* args) -: 2108:{ -: 2109: Imaging imIn; -: 2110: Imaging imOut; -: 2111: -: 2112: float radius; 40: 2113: int n = 1; 40: 2114: if (!PyArg_ParseTuple(args, "f|i", &radius, &n)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2115: return NULL; -: 2116: } -: 2117: 40: 2118: imIn = self->image; 40: 2119: imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize); call 0 returned 100% 40: 2120: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2121: return NULL; -: 2122: } -: 2123: 40: 2124: if (!ImagingBoxBlur(imOut, imIn, radius, n)) { call 0 returned 100% branch 1 taken 13% (fallthrough) branch 2 taken 88% 5: 2125: ImagingDelete(imOut); call 0 returned 100% 5: 2126: return NULL; -: 2127: } -: 2128: 35: 2129: return PyImagingNew(imOut); call 0 returned 100% -: 2130:} -: 2131: -: 2132:/* -------------------------------------------------------------------- */ -: 2133: -: 2134:static PyObject* function _isblock called 5 returned 100% blocks executed 100% 5: 2135:_isblock(ImagingObject* self, PyObject* args) -: 2136:{ 5: 2137: return PyBool_FromLong(self->image->block != NULL); call 0 returned 100% -: 2138:} -: 2139: -: 2140:static PyObject* function _getbbox called 158 returned 100% blocks executed 100% 158: 2141:_getbbox(ImagingObject* self, PyObject* args) -: 2142:{ -: 2143: int bbox[4]; 158: 2144: if (!ImagingGetBBox(self->image, bbox)) { call 0 returned 100% branch 1 taken 18% (fallthrough) branch 2 taken 82% 29: 2145: Py_INCREF(Py_None); 29: 2146: return Py_None; -: 2147: } -: 2148: 129: 2149: return Py_BuildValue("iiii", bbox[0], bbox[1], bbox[2], bbox[3]); call 0 returned 100% -: 2150:} -: 2151: -: 2152:static PyObject* function _getcolors called 20 returned 100% blocks executed 100% 20: 2153:_getcolors(ImagingObject* self, PyObject* args) -: 2154:{ -: 2155: ImagingColorItem* items; -: 2156: int i, colors; -: 2157: PyObject* out; -: 2158: 20: 2159: int maxcolors = 256; 20: 2160: if (!PyArg_ParseTuple(args, "i:getcolors", &maxcolors)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2161: return NULL; -: 2162: } -: 2163: 20: 2164: items = ImagingGetColors(self->image, maxcolors, &colors); call 0 returned 100% 20: 2165: if (!items) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2166: return NULL; -: 2167: } -: 2168: 20: 2169: if (colors > maxcolors) { branch 0 taken 30% (fallthrough) branch 1 taken 70% 6: 2170: out = Py_None; 6: 2171: Py_INCREF(out); -: 2172: } else { 14: 2173: out = PyList_New(colors); 50274: 2174: for (i = 0; i < colors; i++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 50260: 2175: ImagingColorItem* v = &items[i]; 50260: 2176: PyObject* item = Py_BuildValue( call 0 returned 100% call 1 returned 100% -: 2177: "iN", v->count, getpixel(self->image, self->access, v->x, v->y) -: 2178: ); 50260: 2179: PyList_SetItem(out, i, item); call 0 returned 100% -: 2180: } -: 2181: } -: 2182: 20: 2183: free(items); -: 2184: 20: 2185: return out; -: 2186:} -: 2187: -: 2188:static PyObject* function _getextrema called 29 returned 100% blocks executed 91% 29: 2189:_getextrema(ImagingObject* self, PyObject* args) -: 2190:{ -: 2191: union { -: 2192: UINT8 u[2]; -: 2193: INT32 i[2]; -: 2194: FLOAT32 f[2]; -: 2195: UINT16 s[2]; -: 2196: } extrema; -: 2197: int status; -: 2198: 29: 2199: status = ImagingGetExtrema(self->image, &extrema); call 0 returned 100% 29: 2200: if (status < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2201: return NULL; -: 2202: } -: 2203: 29: 2204: if (status) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 29: 2205: switch (self->image->type) { branch 0 taken 62% branch 1 taken 14% branch 2 taken 17% branch 3 taken 7% branch 4 taken 0% -: 2206: case IMAGING_TYPE_UINT8: 18: 2207: return Py_BuildValue("BB", extrema.u[0], extrema.u[1]); call 0 returned 100% -: 2208: case IMAGING_TYPE_INT32: 4: 2209: return Py_BuildValue("ii", extrema.i[0], extrema.i[1]); call 0 returned 100% -: 2210: case IMAGING_TYPE_FLOAT32: 5: 2211: return Py_BuildValue("dd", extrema.f[0], extrema.f[1]); call 0 returned 100% -: 2212: case IMAGING_TYPE_SPECIAL: 2: 2213: if (strcmp(self->image->mode, "I;16") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 2: 2214: return Py_BuildValue("HH", extrema.s[0], extrema.s[1]); call 0 returned 100% -: 2215: } -: 2216: } -: 2217: } -: 2218: #####: 2219: Py_INCREF(Py_None); #####: 2220: return Py_None; -: 2221:} -: 2222: -: 2223:static PyObject* function _getprojection called 10 returned 100% blocks executed 83% 10: 2224:_getprojection(ImagingObject* self, PyObject* args) -: 2225:{ -: 2226: unsigned char* xprofile; -: 2227: unsigned char* yprofile; -: 2228: PyObject* result; -: 2229: -: 2230: /* malloc check ok */ 10: 2231: xprofile = malloc(self->image->xsize); 10: 2232: yprofile = malloc(self->image->ysize); -: 2233: 10: 2234: if (xprofile == NULL || yprofile == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2235: free(xprofile); #####: 2236: free(yprofile); #####: 2237: return PyErr_NoMemory(); call 0 never executed -: 2238: } -: 2239: 10: 2240: ImagingGetProjection(self->image, (unsigned char *)xprofile, (unsigned char *)yprofile); call 0 returned 100% -: 2241: 20: 2242: result = Py_BuildValue("y#y#", call 0 returned 100% 10: 2243: xprofile, (Py_ssize_t)self->image->xsize, 10: 2244: yprofile, (Py_ssize_t)self->image->ysize); -: 2245: 10: 2246: free(xprofile); 10: 2247: free(yprofile); -: 2248: 10: 2249: return result; -: 2250:} -: 2251: -: 2252:/* -------------------------------------------------------------------- */ -: 2253: -: 2254:static PyObject* function _getband called 159 returned 100% blocks executed 100% 159: 2255:_getband(ImagingObject* self, PyObject* args) -: 2256:{ -: 2257: int band; -: 2258: 159: 2259: if (!PyArg_ParseTuple(args, "i", &band)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2260: return NULL; -: 2261: } -: 2262: 159: 2263: return PyImagingNew(ImagingGetBand(self->image, band)); call 0 returned 100% call 1 returned 100% -: 2264:} -: 2265: -: 2266:static PyObject* function _fillband called 9 returned 100% blocks executed 100% 9: 2267:_fillband(ImagingObject* self, PyObject* args) -: 2268:{ -: 2269: int band; -: 2270: int color; -: 2271: 9: 2272: if (!PyArg_ParseTuple(args, "ii", &band, &color)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2273: return NULL; -: 2274: } -: 2275: 9: 2276: if (!ImagingFillBand(self->image, band, color)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2277: return NULL; -: 2278: } -: 2279: 9: 2280: Py_INCREF(Py_None); 9: 2281: return Py_None; -: 2282:} -: 2283: -: 2284:static PyObject* function _putband called 61 returned 100% blocks executed 100% 61: 2285:_putband(ImagingObject* self, PyObject* args) -: 2286:{ -: 2287: ImagingObject* imagep; -: 2288: int band; 61: 2289: if (!PyArg_ParseTuple(args, "O!i", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2290: &Imaging_Type, &imagep, -: 2291: &band)) { -: 2292: return NULL; -: 2293: } -: 2294: 61: 2295: if (!ImagingPutBand(self->image, imagep->image, band)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2296: return NULL; -: 2297: } -: 2298: 61: 2299: Py_INCREF(Py_None); 61: 2300: return Py_None; -: 2301:} -: 2302: -: 2303:static PyObject* function _merge called 253 returned 100% blocks executed 100% 253: 2304:_merge(PyObject* self, PyObject* args) -: 2305:{ -: 2306: char* mode; 253: 2307: ImagingObject *band0 = NULL; 253: 2308: ImagingObject *band1 = NULL; 253: 2309: ImagingObject *band2 = NULL; 253: 2310: ImagingObject *band3 = NULL; 253: 2311: Imaging bands[4] = {NULL, NULL, NULL, NULL}; -: 2312: 253: 2313: if (!PyArg_ParseTuple(args, "sO!|O!O!O!", &mode, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2314: &Imaging_Type, &band0, &Imaging_Type, &band1, -: 2315: &Imaging_Type, &band2, &Imaging_Type, &band3)) { -: 2316: return NULL; -: 2317: } -: 2318: 253: 2319: if (band0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 253: 2320: bands[0] = band0->image; -: 2321: } 253: 2322: if (band1) { branch 0 taken 92% (fallthrough) branch 1 taken 8% 233: 2323: bands[1] = band1->image; -: 2324: } 253: 2325: if (band2) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 205: 2326: bands[2] = band2->image; -: 2327: } 253: 2328: if (band3) { branch 0 taken 49% (fallthrough) branch 1 taken 51% 125: 2329: bands[3] = band3->image; -: 2330: } -: 2331: 253: 2332: return PyImagingNew(ImagingMerge(mode, bands)); call 0 returned 100% call 1 returned 100% -: 2333:} -: 2334: -: 2335:static PyObject* function _split called 1246 returned 100% blocks executed 77% 1246: 2336:_split(ImagingObject* self, PyObject* args) -: 2337:{ 1246: 2338: int fails = 0; -: 2339: Py_ssize_t i; -: 2340: PyObject* list; -: 2341: PyObject* imaging_object; 1246: 2342: Imaging bands[4] = {NULL, NULL, NULL, NULL}; -: 2343: 1246: 2344: if ( ! ImagingSplit(self->image, bands)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2345: return NULL; -: 2346: } -: 2347: 1246: 2348: list = PyTuple_New(self->image->bands); 5118: 2349: for (i = 0; i < self->image->bands; i++) { call 0 returned 100% branch 1 taken 76% branch 2 taken 24% (fallthrough) 3872: 2350: imaging_object = PyImagingNew(bands[i]); call 0 returned 100% 3872: 2351: if ( ! imaging_object) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2352: fails += 1; -: 2353: } 3872: 2354: PyTuple_SET_ITEM(list, i, imaging_object); -: 2355: } 1246: 2356: if (fails) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 2357: Py_DECREF(list); -: 2358: list = NULL; -: 2359: } -: 2360: return list; -: 2361:} -: 2362: -: 2363:/* -------------------------------------------------------------------- */ -: 2364: -: 2365:#ifdef WITH_IMAGECHOPS -: 2366: -: 2367:static PyObject* function _chop_invert called 2 returned 100% blocks executed 100% 2: 2368:_chop_invert(ImagingObject* self, PyObject* args) -: 2369:{ 2: 2370: return PyImagingNew(ImagingNegative(self->image)); call 0 returned 100% call 1 returned 100% -: 2371:} -: 2372: -: 2373:static PyObject* function _chop_lighter called 3 returned 100% blocks executed 100% 3: 2374:_chop_lighter(ImagingObject* self, PyObject* args) -: 2375:{ -: 2376: ImagingObject* imagep; -: 2377: 3: 2378: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2379: return NULL; -: 2380: } -: 2381: 3: 2382: return PyImagingNew(ImagingChopLighter(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2383:} -: 2384: -: 2385:static PyObject* function _chop_darker called 3 returned 100% blocks executed 100% 3: 2386:_chop_darker(ImagingObject* self, PyObject* args) -: 2387:{ -: 2388: ImagingObject* imagep; -: 2389: 3: 2390: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2391: return NULL; -: 2392: } -: 2393: 3: 2394: return PyImagingNew(ImagingChopDarker(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2395:} -: 2396: -: 2397:static PyObject* function _chop_difference called 3 returned 100% blocks executed 100% 3: 2398:_chop_difference(ImagingObject* self, PyObject* args) -: 2399:{ -: 2400: ImagingObject* imagep; -: 2401: 3: 2402: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2403: return NULL; -: 2404: } -: 2405: 3: 2406: return PyImagingNew(ImagingChopDifference(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2407:} -: 2408: -: 2409:static PyObject* function _chop_multiply called 4 returned 100% blocks executed 100% 4: 2410:_chop_multiply(ImagingObject* self, PyObject* args) -: 2411:{ -: 2412: ImagingObject* imagep; -: 2413: 4: 2414: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2415: return NULL; -: 2416: } -: 2417: 4: 2418: return PyImagingNew(ImagingChopMultiply(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2419:} -: 2420: -: 2421:static PyObject* function _chop_screen called 2 returned 100% blocks executed 100% 2: 2422:_chop_screen(ImagingObject* self, PyObject* args) -: 2423:{ -: 2424: ImagingObject* imagep; -: 2425: 2: 2426: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2427: return NULL; -: 2428: } -: 2429: 2: 2430: return PyImagingNew(ImagingChopScreen(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2431:} -: 2432: -: 2433:static PyObject* function _chop_add called 6 returned 100% blocks executed 100% 6: 2434:_chop_add(ImagingObject* self, PyObject* args) -: 2435:{ -: 2436: ImagingObject* imagep; -: 2437: float scale; -: 2438: int offset; -: 2439: 6: 2440: scale = 1.0; 6: 2441: offset = 0; -: 2442: 6: 2443: if (!PyArg_ParseTuple(args, "O!|fi", &Imaging_Type, &imagep, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2444: &scale, &offset)) { -: 2445: return NULL; -: 2446: } -: 2447: 6: 2448: return PyImagingNew(ImagingChopAdd(self->image, imagep->image, call 0 returned 100% call 1 returned 100% -: 2449: scale, offset)); -: 2450:} -: 2451: -: 2452:static PyObject* function _chop_subtract called 6 returned 100% blocks executed 100% 6: 2453:_chop_subtract(ImagingObject* self, PyObject* args) -: 2454:{ -: 2455: ImagingObject* imagep; -: 2456: float scale; -: 2457: int offset; -: 2458: 6: 2459: scale = 1.0; 6: 2460: offset = 0; -: 2461: 6: 2462: if (!PyArg_ParseTuple(args, "O!|fi", &Imaging_Type, &imagep, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2463: &scale, &offset)) { -: 2464: return NULL; -: 2465: } -: 2466: 6: 2467: return PyImagingNew(ImagingChopSubtract(self->image, imagep->image, call 0 returned 100% call 1 returned 100% -: 2468: scale, offset)); -: 2469:} -: 2470: -: 2471:static PyObject* function _chop_and called 12 returned 100% blocks executed 100% 12: 2472:_chop_and(ImagingObject* self, PyObject* args) -: 2473:{ -: 2474: ImagingObject* imagep; -: 2475: 12: 2476: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2477: return NULL; -: 2478: } -: 2479: 12: 2480: return PyImagingNew(ImagingChopAnd(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2481:} -: 2482: -: 2483:static PyObject* function _chop_or called 12 returned 100% blocks executed 100% 12: 2484:_chop_or(ImagingObject* self, PyObject* args) -: 2485:{ -: 2486: ImagingObject* imagep; -: 2487: 12: 2488: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2489: return NULL; -: 2490: } -: 2491: 12: 2492: return PyImagingNew(ImagingChopOr(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2493:} -: 2494: -: 2495:static PyObject* function _chop_xor called 12 returned 100% blocks executed 100% 12: 2496:_chop_xor(ImagingObject* self, PyObject* args) -: 2497:{ -: 2498: ImagingObject* imagep; -: 2499: 12: 2500: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2501: return NULL; -: 2502: } -: 2503: 12: 2504: return PyImagingNew(ImagingChopXor(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2505:} -: 2506: -: 2507:static PyObject* function _chop_add_modulo called 3 returned 100% blocks executed 100% 3: 2508:_chop_add_modulo(ImagingObject* self, PyObject* args) -: 2509:{ -: 2510: ImagingObject* imagep; -: 2511: 3: 2512: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2513: return NULL; -: 2514: } -: 2515: 3: 2516: return PyImagingNew(ImagingChopAddModulo(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2517:} -: 2518: -: 2519:static PyObject* function _chop_subtract_modulo called 74 returned 100% blocks executed 100% 74: 2520:_chop_subtract_modulo(ImagingObject* self, PyObject* args) -: 2521:{ -: 2522: ImagingObject* imagep; -: 2523: 74: 2524: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2525: return NULL; -: 2526: } -: 2527: 74: 2528: return PyImagingNew(ImagingChopSubtractModulo(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2529:} -: 2530: -: 2531:static PyObject* function _chop_soft_light called 2 returned 100% blocks executed 100% 2: 2532:_chop_soft_light(ImagingObject* self, PyObject* args) -: 2533:{ -: 2534: ImagingObject* imagep; -: 2535: 2: 2536: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2537: return NULL; -: 2538: } -: 2539: 2: 2540: return PyImagingNew(ImagingChopSoftLight(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2541:} -: 2542: -: 2543:static PyObject* function _chop_hard_light called 2 returned 100% blocks executed 100% 2: 2544:_chop_hard_light(ImagingObject* self, PyObject* args) -: 2545:{ -: 2546: ImagingObject* imagep; -: 2547: 2: 2548: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2549: return NULL; -: 2550: } -: 2551: 2: 2552: return PyImagingNew(ImagingChopHardLight(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2553:} -: 2554: -: 2555:static PyObject* function _chop_overlay called 2 returned 100% blocks executed 100% 2: 2556:_chop_overlay(ImagingObject* self, PyObject* args) -: 2557:{ -: 2558: ImagingObject* imagep; -: 2559: 2: 2560: if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2561: return NULL; -: 2562: } -: 2563: 2: 2564: return PyImagingNew(ImagingOverlay(self->image, imagep->image)); call 0 returned 100% call 1 returned 100% -: 2565:} -: 2566:#endif -: 2567: -: 2568: -: 2569:/* -------------------------------------------------------------------- */ -: 2570: -: 2571:#ifdef WITH_IMAGEDRAW -: 2572: -: 2573:static PyObject* function _font_new called 16 returned 100% blocks executed 75% 16: 2574:_font_new(PyObject* self_, PyObject* args) -: 2575:{ -: 2576: ImagingFontObject *self; -: 2577: int i, y0, y1; -: 2578: static const char* wrong_length = "descriptor table has wrong size"; -: 2579: -: 2580: ImagingObject* imagep; -: 2581: unsigned char* glyphdata; -: 2582: Py_ssize_t glyphdata_length; 16: 2583: if (!PyArg_ParseTuple(args, "O!y#", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2584: &Imaging_Type, &imagep, -: 2585: &glyphdata, &glyphdata_length)) { -: 2586: return NULL; -: 2587: } -: 2588: 16: 2589: if (glyphdata_length != 256 * 20) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2590: PyErr_SetString(PyExc_ValueError, wrong_length); call 0 never executed #####: 2591: return NULL; -: 2592: } -: 2593: 16: 2594: self = PyObject_New(ImagingFontObject, &ImagingFont_Type); call 0 returned 100% 16: 2595: if (self == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2596: return NULL; -: 2597: } -: 2598: -: 2599: /* glyph bitmap */ 16: 2600: self->bitmap = imagep->image; -: 2601: 16: 2602: y0 = y1 = 0; -: 2603: -: 2604: /* glyph glyphs */ 4112: 2605: for (i = 0; i < 256; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4096: 2606: self->glyphs[i].dx = S16(B16(glyphdata, 0)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2607: self->glyphs[i].dy = S16(B16(glyphdata, 2)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2608: self->glyphs[i].dx0 = S16(B16(glyphdata, 4)); branch 0 taken 10% (fallthrough) branch 1 taken 90% 4096: 2609: self->glyphs[i].dy0 = S16(B16(glyphdata, 6)); branch 0 taken 83% (fallthrough) branch 1 taken 17% 4096: 2610: self->glyphs[i].dx1 = S16(B16(glyphdata, 8)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2611: self->glyphs[i].dy1 = S16(B16(glyphdata, 10)); branch 0 taken 4% (fallthrough) branch 1 taken 96% 4096: 2612: self->glyphs[i].sx0 = S16(B16(glyphdata, 12)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2613: self->glyphs[i].sy0 = S16(B16(glyphdata, 14)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2614: self->glyphs[i].sx1 = S16(B16(glyphdata, 16)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2615: self->glyphs[i].sy1 = S16(B16(glyphdata, 18)); branch 0 taken 0% (fallthrough) branch 1 taken 100% 4096: 2616: if (self->glyphs[i].dy0 < y0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 40: 2617: y0 = self->glyphs[i].dy0; -: 2618: } 4096: 2619: if (self->glyphs[i].dy1 > y1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 22: 2620: y1 = self->glyphs[i].dy1; -: 2621: } 4096: 2622: glyphdata += 20; -: 2623: } -: 2624: 16: 2625: self->baseline = -y0; 16: 2626: self->ysize = y1 - y0; -: 2627: -: 2628: /* keep a reference to the bitmap object */ 16: 2629: Py_INCREF(imagep); 16: 2630: self->ref = imagep; -: 2631: 16: 2632: return (PyObject*) self; -: 2633:} -: 2634: -: 2635:static void function _font_dealloc called 16 returned 100% blocks executed 100% 16: 2636:_font_dealloc(ImagingFontObject* self) -: 2637:{ 32: 2638: Py_XDECREF(self->ref); 16: 2639: PyObject_Del(self); call 0 returned 100% 16: 2640:} -: 2641: -: 2642:static inline int -: 2643:textwidth(ImagingFontObject* self, const unsigned char* text) -: 2644:{ -: 2645: int xsize; -: 2646: 1026107: 2647: for (xsize = 0; *text; text++) { branch 0 taken 36% branch 1 taken 64% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) 1024922: 2648: xsize += self->glyphs[*text].dx; -: 2649: } -: 2650: -: 2651: return xsize; -: 2652:} -: 2653: function _font_text_asBytes called 1187 returned 100% blocks executed 92% 1187: 2654:void _font_text_asBytes(PyObject* encoded_string, unsigned char** text){ -: 2655: /* Allocates *text, returns a 'new reference'. Caller is required to free */ -: 2656: 1187: 2657: PyObject* bytes = NULL; 1187: 2658: Py_ssize_t len = 0; -: 2659: char *buffer; -: 2660: 1187: 2661: *text = NULL; -: 2662: 1187: 2663: if (PyUnicode_CheckExact(encoded_string)){ branch 0 taken 32% (fallthrough) branch 1 taken 68% 380: 2664: bytes = PyUnicode_AsLatin1String(encoded_string); call 0 returned 100% 380: 2665: if (!bytes) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 2666: return; -: 2667: } 378: 2668: PyBytes_AsStringAndSize(bytes, &buffer, &len); call 0 returned 100% 1614: 2669: } else if (PyBytes_Check(encoded_string)) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 42: 2670: PyBytes_AsStringAndSize(encoded_string, &buffer, &len); call 0 returned 100% -: 2671: } -: 2672: 1185: 2673: *text = calloc(len+1,1); 1185: 2674: if (*text) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1185: 2675: memcpy(*text, buffer, len); -: 2676: } else { #####: 2677: ImagingError_MemoryError(); call 0 never executed -: 2678: } 1185: 2679: if (bytes) { branch 0 taken 32% (fallthrough) branch 1 taken 68% -: 2680: Py_DECREF(bytes); -: 2681: } -: 2682: -: 2683: return; -: 2684:} -: 2685: -: 2686: -: 2687:static PyObject* function _font_getmask called 108 returned 100% blocks executed 83% 108: 2688:_font_getmask(ImagingFontObject* self, PyObject* args) -: 2689:{ -: 2690: Imaging im; -: 2691: Imaging bitmap; -: 2692: int x, b; 108: 2693: int i=0; -: 2694: int status; -: 2695: Glyph* glyph; -: 2696: -: 2697: PyObject* encoded_string; -: 2698: -: 2699: unsigned char* text; 108: 2700: char* mode = ""; -: 2701: 108: 2702: if (!PyArg_ParseTuple(args, "O|s:getmask", &encoded_string, &mode)){ call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2703: return NULL; -: 2704: } -: 2705: 108: 2706: _font_text_asBytes(encoded_string, &text); call 0 returned 100% 108: 2707: if (!text) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2708: return NULL; -: 2709: } -: 2710: 216: 2711: im = ImagingNew(self->bitmap->mode, textwidth(self, text), self->ysize); call 0 returned 100% 108: 2712: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2713: free(text); #####: 2714: ImagingError_MemoryError(); call 0 never executed #####: 2715: return NULL; -: 2716: } -: 2717: 108: 2718: b = 0; 108: 2719: (void) ImagingFill(im, &b); call 0 returned 100% -: 2720: 108: 2721: b = self->baseline; 1024432: 2722: for (x = 0; text[i]; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1024324: 2723: glyph = &self->glyphs[text[i]]; 1024324: 2724: bitmap = ImagingCrop( call 0 returned 100% -: 2725: self->bitmap, -: 2726: glyph->sx0, glyph->sy0, glyph->sx1, glyph->sy1 -: 2727: ); 1024324: 2728: if (!bitmap) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2729: goto failed; -: 2730: } 4097296: 2731: status = ImagingPaste( call 0 returned 100% -: 2732: im, bitmap, NULL, 4097296: 2733: glyph->dx0+x, glyph->dy0+b, glyph->dx1+x, glyph->dy1+b -: 2734: ); 1024324: 2735: ImagingDelete(bitmap); call 0 returned 100% 1024324: 2736: if (status < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2737: goto failed; -: 2738: } 1024324: 2739: x = x + glyph->dx; 1024324: 2740: b = b + glyph->dy; -: 2741: } 108: 2742: free(text); 108: 2743: return PyImagingNew(im); call 0 returned 100% -: 2744: -: 2745: failed: #####: 2746: free(text); #####: 2747: ImagingDelete(im); call 0 never executed #####: 2748: Py_RETURN_NONE; -: 2749:} -: 2750: -: 2751:static PyObject* function _font_getsize called 1079 returned 100% blocks executed 100% 1079: 2752:_font_getsize(ImagingFontObject* self, PyObject* args) -: 2753:{ -: 2754: unsigned char* text; -: 2755: PyObject* encoded_string; -: 2756: PyObject* val; -: 2757: 1079: 2758: if (!PyArg_ParseTuple(args, "O:getsize", &encoded_string)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2759: return NULL; -: 2760: } -: 2761: 1079: 2762: _font_text_asBytes(encoded_string, &text); call 0 returned 100% 1079: 2763: if (!text) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 2764: return NULL; -: 2765: } -: 2766: 2154: 2767: val = Py_BuildValue("ii", textwidth(self, text), self->ysize); call 0 returned 100% 1077: 2768: free(text); 1077: 2769: return val; -: 2770:} -: 2771: -: 2772:static struct PyMethodDef _font_methods[] = { -: 2773: {"getmask", (PyCFunction)_font_getmask, 1}, -: 2774: {"getsize", (PyCFunction)_font_getsize, 1}, -: 2775: {NULL, NULL} /* sentinel */ -: 2776:}; -: 2777: -: 2778:/* -------------------------------------------------------------------- */ -: 2779: -: 2780:static PyObject* function _draw_new called 400 returned 100% blocks executed 100% 400: 2781:_draw_new(PyObject* self_, PyObject* args) -: 2782:{ -: 2783: ImagingDrawObject *self; -: 2784: -: 2785: ImagingObject* imagep; 400: 2786: int blend = 0; 400: 2787: if (!PyArg_ParseTuple(args, "O!|i", &Imaging_Type, &imagep, &blend)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2788: return NULL; -: 2789: } -: 2790: 400: 2791: self = PyObject_New(ImagingDrawObject, &ImagingDraw_Type); call 0 returned 100% 400: 2792: if (self == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2793: return NULL; -: 2794: } -: 2795: -: 2796: /* keep a reference to the image object */ 400: 2797: Py_INCREF(imagep); 400: 2798: self->image = imagep; -: 2799: 400: 2800: self->ink[0] = self->ink[1] = self->ink[2] = self->ink[3] = 0; -: 2801: 400: 2802: self->blend = blend; -: 2803: 400: 2804: return (PyObject*) self; -: 2805:} -: 2806: -: 2807:static void function _draw_dealloc called 400 returned 100% blocks executed 100% 400: 2808:_draw_dealloc(ImagingDrawObject* self) -: 2809:{ 800: 2810: Py_XDECREF(self->image); 400: 2811: PyObject_Del(self); call 0 returned 100% 400: 2812:} -: 2813: -: 2814:extern Py_ssize_t PyPath_Flatten(PyObject* data, double **xy); -: 2815: -: 2816:static PyObject* function _draw_ink called 3290 returned 100% blocks executed 100% 3290: 2817:_draw_ink(ImagingDrawObject* self, PyObject* args) -: 2818:{ 3290: 2819: INT32 ink = 0; -: 2820: PyObject* color; 3290: 2821: if (!PyArg_ParseTuple(args, "O", &color)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2822: return NULL; -: 2823: } -: 2824: 3290: 2825: if (!getink(color, self->image->image, (char*) &ink)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2826: return NULL; -: 2827: } -: 2828: 3290: 2829: return PyLong_FromLong((int) ink); call 0 returned 100% -: 2830:} -: 2831: -: 2832:static PyObject* function _draw_arc called 12 returned 100% blocks executed 82% 12: 2833:_draw_arc(ImagingDrawObject* self, PyObject* args) -: 2834:{ -: 2835: double* xy; -: 2836: Py_ssize_t n; -: 2837: -: 2838: PyObject* data; -: 2839: int ink; 12: 2840: int width = 0; -: 2841: float start, end; 12: 2842: if (!PyArg_ParseTuple(args, "Offi|i", &data, &start, &end, &ink, &width)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2843: return NULL; -: 2844: } -: 2845: 12: 2846: n = PyPath_Flatten(data, &xy); call 0 returned 100% 12: 2847: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2848: return NULL; -: 2849: } 12: 2850: if (n != 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2851: PyErr_SetString(PyExc_TypeError, must_be_two_coordinates); call 0 never executed #####: 2852: free(xy); #####: 2853: return NULL; -: 2854: } -: 2855: 60: 2856: n = ImagingDrawArc(self->image->image, call 0 returned 100% 24: 2857: (int) xy[0], (int) xy[1], 24: 2858: (int) xy[2], (int) xy[3], -: 2859: start, end, &ink, width, self->blend -: 2860: ); -: 2861: 12: 2862: free(xy); -: 2863: 12: 2864: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2865: return NULL; -: 2866: } -: 2867: 12: 2868: Py_INCREF(Py_None); 12: 2869: return Py_None; -: 2870:} -: 2871: -: 2872:static PyObject* function _draw_bitmap called 350 returned 100% blocks executed 82% 350: 2873:_draw_bitmap(ImagingDrawObject* self, PyObject* args) -: 2874:{ -: 2875: double *xy; -: 2876: Py_ssize_t n; -: 2877: -: 2878: PyObject *data; -: 2879: ImagingObject* bitmap; -: 2880: int ink; 350: 2881: if (!PyArg_ParseTuple(args, "OO!i", &data, &Imaging_Type, &bitmap, &ink)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2882: return NULL; -: 2883: } -: 2884: 350: 2885: n = PyPath_Flatten(data, &xy); call 0 returned 100% 350: 2886: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2887: return NULL; -: 2888: } 350: 2889: if (n != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2890: PyErr_SetString(PyExc_TypeError, call 0 never executed -: 2891: "coordinate list must contain exactly 1 coordinate" -: 2892: ); #####: 2893: free(xy); #####: 2894: return NULL; -: 2895: } -: 2896: 1750: 2897: n = ImagingDrawBitmap( call 0 returned 100% 1400: 2898: self->image->image, (int) xy[0], (int) xy[1], bitmap->image, -: 2899: &ink, self->blend -: 2900: ); -: 2901: 350: 2902: free(xy); -: 2903: 350: 2904: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2905: return NULL; -: 2906: } -: 2907: 350: 2908: Py_INCREF(Py_None); 350: 2909: return Py_None; -: 2910:} -: 2911: -: 2912:static PyObject* function _draw_chord called 20 returned 100% blocks executed 82% 20: 2913:_draw_chord(ImagingDrawObject* self, PyObject* args) -: 2914:{ -: 2915: double* xy; -: 2916: Py_ssize_t n; -: 2917: -: 2918: PyObject* data; -: 2919: int ink, fill; 20: 2920: int width = 0; -: 2921: float start, end; 20: 2922: if (!PyArg_ParseTuple(args, "Offii|i", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2923: &data, &start, &end, &ink, &fill, &width)) { -: 2924: return NULL; -: 2925: } -: 2926: 20: 2927: n = PyPath_Flatten(data, &xy); call 0 returned 100% 20: 2928: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2929: return NULL; -: 2930: } 20: 2931: if (n != 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2932: PyErr_SetString(PyExc_TypeError, must_be_two_coordinates); call 0 never executed #####: 2933: free(xy); #####: 2934: return NULL; -: 2935: } -: 2936: 100: 2937: n = ImagingDrawChord(self->image->image, call 0 returned 100% 40: 2938: (int) xy[0], (int) xy[1], 40: 2939: (int) xy[2], (int) xy[3], -: 2940: start, end, &ink, fill, width, self->blend -: 2941: ); -: 2942: 20: 2943: free(xy); -: 2944: 20: 2945: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2946: return NULL; -: 2947: } -: 2948: 20: 2949: Py_INCREF(Py_None); 20: 2950: return Py_None; -: 2951:} -: 2952: -: 2953:static PyObject* function _draw_ellipse called 2091 returned 100% blocks executed 82% 2091: 2954:_draw_ellipse(ImagingDrawObject* self, PyObject* args) -: 2955:{ -: 2956: double* xy; -: 2957: Py_ssize_t n; -: 2958: -: 2959: PyObject* data; -: 2960: int ink; 2091: 2961: int fill = 0; 2091: 2962: int width = 0; 2091: 2963: if (!PyArg_ParseTuple(args, "Oi|ii", &data, &ink, &fill, &width)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 2964: return NULL; -: 2965: } -: 2966: 2091: 2967: n = PyPath_Flatten(data, &xy); call 0 returned 100% 2091: 2968: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2969: return NULL; -: 2970: } 2091: 2971: if (n != 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 2972: PyErr_SetString(PyExc_TypeError, must_be_two_coordinates); call 0 never executed #####: 2973: free(xy); #####: 2974: return NULL; -: 2975: } -: 2976: 10455: 2977: n = ImagingDrawEllipse(self->image->image, call 0 returned 100% 4182: 2978: (int) xy[0], (int) xy[1], 4182: 2979: (int) xy[2], (int) xy[3], -: 2980: &ink, fill, width, self->blend -: 2981: ); -: 2982: 2091: 2983: free(xy); -: 2984: 2091: 2985: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 2986: return NULL; -: 2987: } -: 2988: 2091: 2989: Py_INCREF(Py_None); 2091: 2990: return Py_None; -: 2991:} -: 2992: -: 2993:static PyObject* function _draw_lines called 221 returned 100% blocks executed 90% 221: 2994:_draw_lines(ImagingDrawObject* self, PyObject* args) -: 2995:{ -: 2996: double *xy; -: 2997: Py_ssize_t i, n; -: 2998: -: 2999: PyObject *data; -: 3000: int ink; 221: 3001: int width = 0; 221: 3002: if (!PyArg_ParseTuple(args, "Oi|i", &data, &ink, &width)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3003: return NULL; -: 3004: } -: 3005: 221: 3006: n = PyPath_Flatten(data, &xy); call 0 returned 100% 221: 3007: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3008: return NULL; -: 3009: } -: 3010: 221: 3011: if (width <= 1) { branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 3012: double *p = NULL; 163: 3013: for (i = 0; i < n-1; i++) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 163: 3014: p = &xy[i+i]; 978: 3015: if (ImagingDrawLine( call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% 163: 3016: self->image->image, 652: 3017: (int) p[0], (int) p[1], (int) p[2], (int) p[3], -: 3018: &ink, self->blend) < 0) { #####: 3019: free(xy); #####: 3020: return NULL; -: 3021: } -: 3022: } 161: 3023: if (p) {/* draw last point */ branch 0 taken 99% (fallthrough) branch 1 taken 1% 640: 3024: ImagingDrawPoint( call 0 returned 100% 160: 3025: self->image->image, 320: 3026: (int) p[2], (int) p[3], -: 3027: &ink, self->blend -: 3028: ); -: 3029: } -: 3030: } else { 140: 3031: for (i = 0; i < n-1; i++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 140: 3032: double *p = &xy[i+i]; 840: 3033: if (ImagingDrawWideLine( call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% 140: 3034: self->image->image, 560: 3035: (int) p[0], (int) p[1], (int) p[2], (int) p[3], -: 3036: &ink, width, self->blend) < 0) { #####: 3037: free(xy); #####: 3038: return NULL; -: 3039: } -: 3040: } -: 3041: } -: 3042: 221: 3043: free(xy); -: 3044: 221: 3045: Py_INCREF(Py_None); 221: 3046: return Py_None; -: 3047:} -: 3048: -: 3049:static PyObject* function _draw_points called 2 returned 100% blocks executed 92% 2: 3050:_draw_points(ImagingDrawObject* self, PyObject* args) -: 3051:{ -: 3052: double *xy; -: 3053: Py_ssize_t i, n; -: 3054: -: 3055: PyObject *data; -: 3056: int ink; 2: 3057: if (!PyArg_ParseTuple(args, "Oi", &data, &ink)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3058: return NULL; -: 3059: } -: 3060: 2: 3061: n = PyPath_Flatten(data, &xy); call 0 returned 100% 2: 3062: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3063: return NULL; -: 3064: } -: 3065: 6: 3066: for (i = 0; i < n; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 3067: double *p = &xy[i+i]; 6: 3068: if (ImagingDrawPoint(self->image->image, (int) p[0], (int) p[1], call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 3069: &ink, self->blend) < 0) { #####: 3070: free(xy); #####: 3071: return NULL; -: 3072: } -: 3073: } -: 3074: 2: 3075: free(xy); -: 3076: 2: 3077: Py_INCREF(Py_None); 2: 3078: return Py_None; -: 3079:} -: 3080: -: 3081:#ifdef WITH_ARROW -: 3082: -: 3083:/* from outline.c */ -: 3084:extern ImagingOutline PyOutline_AsOutline(PyObject* outline); -: 3085: -: 3086:static PyObject* function _draw_outline called 8 returned 100% blocks executed 80% 8: 3087:_draw_outline(ImagingDrawObject* self, PyObject* args) -: 3088:{ -: 3089: ImagingOutline outline; -: 3090: -: 3091: PyObject* outline_; -: 3092: int ink; 8: 3093: int fill = 0; 8: 3094: if (!PyArg_ParseTuple(args, "Oi|i", &outline_, &ink, &fill)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3095: return NULL; -: 3096: } -: 3097: 8: 3098: outline = PyOutline_AsOutline(outline_); call 0 returned 100% 8: 3099: if (!outline) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 3100: PyErr_SetString(PyExc_TypeError, "expected outline object"); call 0 never executed #####: 3101: return NULL; -: 3102: } -: 3103: 8: 3104: if (ImagingDrawOutline(self->image->image, outline, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3105: &ink, fill, self->blend) < 0) { -: 3106: return NULL; -: 3107: } -: 3108: 8: 3109: Py_INCREF(Py_None); 8: 3110: return Py_None; -: 3111:} -: 3112: -: 3113:#endif -: 3114: -: 3115:static PyObject* function _draw_pieslice called 53 returned 100% blocks executed 82% 53: 3116:_draw_pieslice(ImagingDrawObject* self, PyObject* args) -: 3117:{ -: 3118: double* xy; -: 3119: Py_ssize_t n; -: 3120: -: 3121: PyObject* data; -: 3122: int ink, fill; 53: 3123: int width = 0; -: 3124: float start, end; 53: 3125: if (!PyArg_ParseTuple(args, "Offii|i", &data, &start, &end, &ink, &fill, &width)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3126: return NULL; -: 3127: } -: 3128: 53: 3129: n = PyPath_Flatten(data, &xy); call 0 returned 100% 53: 3130: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3131: return NULL; -: 3132: } 53: 3133: if (n != 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 3134: PyErr_SetString(PyExc_TypeError, must_be_two_coordinates); call 0 never executed #####: 3135: free(xy); #####: 3136: return NULL; -: 3137: } -: 3138: 265: 3139: n = ImagingDrawPieslice(self->image->image, call 0 returned 100% 106: 3140: (int) xy[0], (int) xy[1], 106: 3141: (int) xy[2], (int) xy[3], -: 3142: start, end, &ink, fill, width, self->blend -: 3143: ); -: 3144: 53: 3145: free(xy); -: 3146: 53: 3147: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3148: return NULL; -: 3149: } -: 3150: 53: 3151: Py_INCREF(Py_None); 53: 3152: return Py_None; -: 3153:} -: 3154: -: 3155:static PyObject* function _draw_polygon called 26 returned 100% blocks executed 80% 26: 3156:_draw_polygon(ImagingDrawObject* self, PyObject* args) -: 3157:{ -: 3158: double *xy; -: 3159: int *ixy; -: 3160: Py_ssize_t n, i; -: 3161: -: 3162: PyObject* data; -: 3163: int ink; 26: 3164: int fill = 0; 26: 3165: if (!PyArg_ParseTuple(args, "Oi|i", &data, &ink, &fill)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3166: return NULL; -: 3167: } -: 3168: 26: 3169: n = PyPath_Flatten(data, &xy); call 0 returned 100% 26: 3170: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3171: return NULL; -: 3172: } 26: 3173: if (n < 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 3174: PyErr_SetString(PyExc_TypeError, call 0 never executed -: 3175: "coordinate list must contain at least 2 coordinates" -: 3176: ); #####: 3177: free(xy); #####: 3178: return NULL; -: 3179: } -: 3180: -: 3181: /* Copy list of vertices to array */ 26: 3182: ixy = (int*) calloc(n, 2 * sizeof(int)); -: 3183: 169: 3184: for (i = 0; i < n; i++) { branch 0 taken 85% branch 1 taken 15% (fallthrough) 143: 3185: ixy[i+i] = (int) xy[i+i]; 143: 3186: ixy[i+i+1] = (int) xy[i+i+1]; -: 3187: } -: 3188: 26: 3189: free(xy); -: 3190: 26: 3191: if (ImagingDrawPolygon(self->image->image, n, ixy, call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 3192: &ink, fill, self->blend) < 0) { #####: 3193: free(ixy); #####: 3194: return NULL; -: 3195: } -: 3196: 26: 3197: free(ixy); -: 3198: 26: 3199: Py_INCREF(Py_None); 26: 3200: return Py_None; -: 3201:} -: 3202: -: 3203:static PyObject* function _draw_rectangle called 147 returned 100% blocks executed 82% 147: 3204:_draw_rectangle(ImagingDrawObject* self, PyObject* args) -: 3205:{ -: 3206: double* xy; -: 3207: Py_ssize_t n; -: 3208: -: 3209: PyObject* data; -: 3210: int ink; 147: 3211: int fill = 0; 147: 3212: int width = 0; 147: 3213: if (!PyArg_ParseTuple(args, "Oi|ii", &data, &ink, &fill, &width)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3214: return NULL; -: 3215: } -: 3216: 147: 3217: n = PyPath_Flatten(data, &xy); call 0 returned 100% 147: 3218: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3219: return NULL; -: 3220: } 147: 3221: if (n != 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 3222: PyErr_SetString(PyExc_TypeError, must_be_two_coordinates); call 0 never executed #####: 3223: free(xy); #####: 3224: return NULL; -: 3225: } -: 3226: 735: 3227: n = ImagingDrawRectangle(self->image->image, call 0 returned 100% 294: 3228: (int) xy[0], (int) xy[1], 294: 3229: (int) xy[2], (int) xy[3], -: 3230: &ink, fill, width, self->blend -: 3231: ); -: 3232: 147: 3233: free(xy); -: 3234: 147: 3235: if (n < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3236: return NULL; -: 3237: } -: 3238: 147: 3239: Py_INCREF(Py_None); 147: 3240: return Py_None; -: 3241:} -: 3242: -: 3243:static struct PyMethodDef _draw_methods[] = { -: 3244:#ifdef WITH_IMAGEDRAW -: 3245: /* Graphics (ImageDraw) */ -: 3246: {"draw_lines", (PyCFunction)_draw_lines, 1}, -: 3247:#ifdef WITH_ARROW -: 3248: {"draw_outline", (PyCFunction)_draw_outline, 1}, -: 3249:#endif -: 3250: {"draw_polygon", (PyCFunction)_draw_polygon, 1}, -: 3251: {"draw_rectangle", (PyCFunction)_draw_rectangle, 1}, -: 3252: {"draw_points", (PyCFunction)_draw_points, 1}, -: 3253: {"draw_arc", (PyCFunction)_draw_arc, 1}, -: 3254: {"draw_bitmap", (PyCFunction)_draw_bitmap, 1}, -: 3255: {"draw_chord", (PyCFunction)_draw_chord, 1}, -: 3256: {"draw_ellipse", (PyCFunction)_draw_ellipse, 1}, -: 3257: {"draw_pieslice", (PyCFunction)_draw_pieslice, 1}, -: 3258: {"draw_ink", (PyCFunction)_draw_ink, 1}, -: 3259:#endif -: 3260: {NULL, NULL} /* sentinel */ -: 3261:}; -: 3262: -: 3263:#endif -: 3264: -: 3265: -: 3266:static PyObject* function pixel_access_new called 233272 returned 100% blocks executed 100% 233272: 3267:pixel_access_new(ImagingObject* imagep, PyObject* args) -: 3268:{ -: 3269: PixelAccessObject *self; -: 3270: 233272: 3271: int readonly = 0; 233272: 3272: if (!PyArg_ParseTuple(args, "|i", &readonly)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3273: return NULL; -: 3274: } -: 3275: 233272: 3276: self = PyObject_New(PixelAccessObject, &PixelAccess_Type); call 0 returned 100% 233272: 3277: if (self == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3278: return NULL; -: 3279: } -: 3280: -: 3281: /* keep a reference to the image object */ 233272: 3282: Py_INCREF(imagep); 233272: 3283: self->image = imagep; -: 3284: 233272: 3285: self->readonly = readonly; -: 3286: 233272: 3287: return (PyObject*) self; -: 3288:} -: 3289: -: 3290:static void function pixel_access_dealloc called 233272 returned 100% blocks executed 100% 233272: 3291:pixel_access_dealloc(PixelAccessObject* self) -: 3292:{ 466544: 3293: Py_XDECREF(self->image); 233272: 3294: PyObject_Del(self); call 0 returned 100% 233272: 3295:} -: 3296: -: 3297:static PyObject * function pixel_access_getitem called 219391 returned 100% blocks executed 100% 219391: 3298:pixel_access_getitem(PixelAccessObject *self, PyObject *xy) -: 3299:{ -: 3300: int x, y; 219391: 3301: if (_getxy(xy, &x, &y)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3302: return NULL; -: 3303: } -: 3304: 219391: 3305: return getpixel(self->image->image, self->image->access, x, y); call 0 returned 100% -: 3306:} -: 3307: -: 3308:static int function pixel_access_setitem called 266269 returned 100% blocks executed 81% 266269: 3309:pixel_access_setitem(PixelAccessObject *self, PyObject *xy, PyObject *color) -: 3310:{ 266269: 3311: Imaging im = self->image->image; -: 3312: char ink[4]; -: 3313: int x, y; -: 3314: 266269: 3315: if (self->readonly) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 3316: (void) ImagingError_ValueError(readonly); call 0 never executed #####: 3317: return -1; -: 3318: } -: 3319: 266269: 3320: if (_getxy(xy, &x, &y)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3321: return -1; -: 3322: } -: 3323: 266269: 3324: if (x < 0) { branch 0 taken 6% (fallthrough) branch 1 taken 94% 16384: 3325: x = im->xsize + x; -: 3326: } 266269: 3327: if (y < 0) { branch 0 taken 6% (fallthrough) branch 1 taken 94% 16384: 3328: y = im->ysize + y; -: 3329: } -: 3330: 266269: 3331: if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 0% (fallthrough) branch 7 taken 100% #####: 3332: PyErr_SetString(PyExc_IndexError, outside_image); call 0 never executed #####: 3333: return -1; -: 3334: } -: 3335: 266269: 3336: if (!color) {/* FIXME: raise exception? */ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3337: return 0; -: 3338: } -: 3339: 266269: 3340: if (!getink(color, im, ink)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3341: return -1; -: 3342: } -: 3343: 266269: 3344: self->image->access->put_pixel(im, x, y, ink); call 0 returned 100% -: 3345: 266269: 3346: return 0; -: 3347:} -: 3348: -: 3349:/* -------------------------------------------------------------------- */ -: 3350:/* EFFECTS (experimental) */ -: 3351:/* -------------------------------------------------------------------- */ -: 3352: -: 3353:#ifdef WITH_EFFECTS -: 3354: -: 3355:static PyObject* function _effect_mandelbrot called 2 returned 100% blocks executed 100% 2: 3356:_effect_mandelbrot(ImagingObject* self, PyObject* args) -: 3357:{ 2: 3358: int xsize = 512; 2: 3359: int ysize = 512; -: 3360: double extent[4]; 2: 3361: int quality = 100; -: 3362: 2: 3363: extent[0] = -3; extent[1] = -2.5; 2: 3364: extent[2] = 2; extent[3] = 2.5; -: 3365: 2: 3366: if (!PyArg_ParseTuple(args, "|(ii)(dddd)i", &xsize, &ysize, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3367: &extent[0], &extent[1], &extent[2], &extent[3], -: 3368: &quality)) { -: 3369: return NULL; -: 3370: } -: 3371: 2: 3372: return PyImagingNew(ImagingEffectMandelbrot(xsize, ysize, extent, quality)); call 0 returned 100% call 1 returned 100% -: 3373:} -: 3374: -: 3375:static PyObject* function _effect_noise called 1 returned 100% blocks executed 100% 1: 3376:_effect_noise(ImagingObject* self, PyObject* args) -: 3377:{ -: 3378: int xsize, ysize; 1: 3379: float sigma = 128; 1: 3380: if (!PyArg_ParseTuple(args, "(ii)|f", &xsize, &ysize, &sigma)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3381: return NULL; -: 3382: } -: 3383: 1: 3384: return PyImagingNew(ImagingEffectNoise(xsize, ysize, sigma)); call 0 returned 100% call 1 returned 100% -: 3385:} -: 3386: -: 3387:static PyObject* function _effect_spread called 2 returned 100% blocks executed 100% 2: 3388:_effect_spread(ImagingObject* self, PyObject* args) -: 3389:{ -: 3390: int dist; -: 3391: 2: 3392: if (!PyArg_ParseTuple(args, "i", &dist)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3393: return NULL; -: 3394: } -: 3395: 2: 3396: return PyImagingNew(ImagingEffectSpread(self->image, dist)); call 0 returned 100% call 1 returned 100% -: 3397:} -: 3398: -: 3399:#endif -: 3400: -: 3401:/* -------------------------------------------------------------------- */ -: 3402:/* UTILITIES */ -: 3403:/* -------------------------------------------------------------------- */ -: 3404: -: 3405: -: 3406:static PyObject* function _getcodecstatus called 15 returned 100% blocks executed 80% 15: 3407:_getcodecstatus(PyObject* self, PyObject* args) -: 3408:{ -: 3409: int status; -: 3410: char* msg; -: 3411: 15: 3412: if (!PyArg_ParseTuple(args, "i", &status)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3413: return NULL; -: 3414: } -: 3415: 15: 3416: switch (status) { branch 0 taken 0% branch 1 taken 13% branch 2 taken 7% branch 3 taken 0% branch 4 taken 13% branch 5 taken 67% -: 3417: case IMAGING_CODEC_OVERRUN: -: 3418: msg = "buffer overrun"; break; -: 3419: case IMAGING_CODEC_BROKEN: #####: 3420: msg = "broken data stream"; break; -: 3421: case IMAGING_CODEC_UNKNOWN: 2: 3422: msg = "unrecognized data stream contents"; break; -: 3423: case IMAGING_CODEC_CONFIG: 1: 3424: msg = "codec configuration error"; break; -: 3425: case IMAGING_CODEC_MEMORY: #####: 3426: msg = "out of memory"; break; -: 3427: default: 4: 3428: Py_RETURN_NONE; -: 3429: } -: 3430: 13: 3431: return PyUnicode_FromString(msg); call 0 returned 100% -: 3432:} -: 3433: -: 3434:/* -------------------------------------------------------------------- */ -: 3435:/* DEBUGGING HELPERS */ -: 3436:/* -------------------------------------------------------------------- */ -: 3437: -: 3438: -: 3439:static PyObject* function _save_ppm called 9 returned 100% blocks executed 100% 9: 3440:_save_ppm(ImagingObject* self, PyObject* args) -: 3441:{ -: 3442: char* filename; -: 3443: 9: 3444: if (!PyArg_ParseTuple(args, "s", &filename)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3445: return NULL; -: 3446: } -: 3447: 9: 3448: if (!ImagingSavePPM(self->image, filename)) { call 0 returned 100% branch 1 taken 89% (fallthrough) branch 2 taken 11% -: 3449: return NULL; -: 3450: } -: 3451: 8: 3452: Py_INCREF(Py_None); 8: 3453: return Py_None; -: 3454:} -: 3455: -: 3456: -: 3457:/* -------------------------------------------------------------------- */ -: 3458: -: 3459:/* methods */ -: 3460: -: 3461:static struct PyMethodDef methods[] = { -: 3462: -: 3463: /* Put commonly used methods first */ -: 3464: {"getpixel", (PyCFunction)_getpixel, 1}, -: 3465: {"putpixel", (PyCFunction)_putpixel, 1}, -: 3466: -: 3467: {"pixel_access", (PyCFunction)pixel_access_new, 1}, -: 3468: -: 3469: /* Standard processing methods (Image) */ -: 3470: {"color_lut_3d", (PyCFunction)_color_lut_3d, 1}, -: 3471: {"convert", (PyCFunction)_convert, 1}, -: 3472: {"convert2", (PyCFunction)_convert2, 1}, -: 3473: {"convert_matrix", (PyCFunction)_convert_matrix, 1}, -: 3474: {"convert_transparent", (PyCFunction)_convert_transparent, 1}, -: 3475: {"copy", (PyCFunction)_copy, 1}, -: 3476: {"crop", (PyCFunction)_crop, 1}, -: 3477: {"expand", (PyCFunction)_expand_image, 1}, -: 3478: {"filter", (PyCFunction)_filter, 1}, -: 3479: {"histogram", (PyCFunction)_histogram, 1}, -: 3480: {"entropy", (PyCFunction)_entropy, 1}, -: 3481:#ifdef WITH_MODEFILTER -: 3482: {"modefilter", (PyCFunction)_modefilter, 1}, -: 3483:#endif -: 3484: {"offset", (PyCFunction)_offset, 1}, -: 3485: {"paste", (PyCFunction)_paste, 1}, -: 3486: {"point", (PyCFunction)_point, 1}, -: 3487: {"point_transform", (PyCFunction)_point_transform, 1}, -: 3488: {"putdata", (PyCFunction)_putdata, 1}, -: 3489:#ifdef WITH_QUANTIZE -: 3490: {"quantize", (PyCFunction)_quantize, 1}, -: 3491:#endif -: 3492:#ifdef WITH_RANKFILTER -: 3493: {"rankfilter", (PyCFunction)_rankfilter, 1}, -: 3494:#endif -: 3495: {"resize", (PyCFunction)_resize, 1}, -: 3496: {"reduce", (PyCFunction)_reduce, 1}, -: 3497: {"transpose", (PyCFunction)_transpose, 1}, -: 3498: {"transform2", (PyCFunction)_transform2, 1}, -: 3499: -: 3500: {"isblock", (PyCFunction)_isblock, 1}, -: 3501: -: 3502: {"getbbox", (PyCFunction)_getbbox, 1}, -: 3503: {"getcolors", (PyCFunction)_getcolors, 1}, -: 3504: {"getextrema", (PyCFunction)_getextrema, 1}, -: 3505: {"getprojection", (PyCFunction)_getprojection, 1}, -: 3506: -: 3507: {"getband", (PyCFunction)_getband, 1}, -: 3508: {"putband", (PyCFunction)_putband, 1}, -: 3509: {"split", (PyCFunction)_split, 1}, -: 3510: {"fillband", (PyCFunction)_fillband, 1}, -: 3511: -: 3512: {"setmode", (PyCFunction)im_setmode, 1}, -: 3513: -: 3514: {"getpalette", (PyCFunction)_getpalette, 1}, -: 3515: {"getpalettemode", (PyCFunction)_getpalettemode, 1}, -: 3516: {"putpalette", (PyCFunction)_putpalette, 1}, -: 3517: {"putpalettealpha", (PyCFunction)_putpalettealpha, 1}, -: 3518: {"putpalettealphas", (PyCFunction)_putpalettealphas, 1}, -: 3519: -: 3520:#ifdef WITH_IMAGECHOPS -: 3521: /* Channel operations (ImageChops) */ -: 3522: {"chop_invert", (PyCFunction)_chop_invert, 1}, -: 3523: {"chop_lighter", (PyCFunction)_chop_lighter, 1}, -: 3524: {"chop_darker", (PyCFunction)_chop_darker, 1}, -: 3525: {"chop_difference", (PyCFunction)_chop_difference, 1}, -: 3526: {"chop_multiply", (PyCFunction)_chop_multiply, 1}, -: 3527: {"chop_screen", (PyCFunction)_chop_screen, 1}, -: 3528: {"chop_add", (PyCFunction)_chop_add, 1}, -: 3529: {"chop_subtract", (PyCFunction)_chop_subtract, 1}, -: 3530: {"chop_add_modulo", (PyCFunction)_chop_add_modulo, 1}, -: 3531: {"chop_subtract_modulo", (PyCFunction)_chop_subtract_modulo, 1}, -: 3532: {"chop_and", (PyCFunction)_chop_and, 1}, -: 3533: {"chop_or", (PyCFunction)_chop_or, 1}, -: 3534: {"chop_xor", (PyCFunction)_chop_xor, 1}, -: 3535: {"chop_soft_light", (PyCFunction)_chop_soft_light, 1}, -: 3536: {"chop_hard_light", (PyCFunction)_chop_hard_light, 1}, -: 3537: {"chop_overlay", (PyCFunction)_chop_overlay, 1}, -: 3538: -: 3539:#endif -: 3540: -: 3541:#ifdef WITH_UNSHARPMASK -: 3542: /* Kevin Cazabon's unsharpmask extension */ -: 3543: {"gaussian_blur", (PyCFunction)_gaussian_blur, 1}, -: 3544: {"unsharp_mask", (PyCFunction)_unsharp_mask, 1}, -: 3545:#endif -: 3546: -: 3547: {"box_blur", (PyCFunction)_box_blur, 1}, -: 3548: -: 3549:#ifdef WITH_EFFECTS -: 3550: /* Special effects */ -: 3551: {"effect_spread", (PyCFunction)_effect_spread, 1}, -: 3552:#endif -: 3553: -: 3554: /* Misc. */ -: 3555: {"new_block", (PyCFunction)_new_block, 1}, -: 3556: -: 3557: {"save_ppm", (PyCFunction)_save_ppm, 1}, -: 3558: -: 3559: {NULL, NULL} /* sentinel */ -: 3560:}; -: 3561: -: 3562: -: 3563:/* attributes */ -: 3564: -: 3565:static PyObject* function _getattr_mode called 198006 returned 100% blocks executed 100% 198006: 3566:_getattr_mode(ImagingObject* self, void* closure) -: 3567:{ 198006: 3568: return PyUnicode_FromString(self->image->mode); call 0 returned 100% -: 3569:} -: 3570: -: 3571:static PyObject* function _getattr_size called 49884 returned 100% blocks executed 100% 49884: 3572:_getattr_size(ImagingObject* self, void* closure) -: 3573:{ 49884: 3574: return Py_BuildValue("ii", self->image->xsize, self->image->ysize); call 0 returned 100% -: 3575:} -: 3576: -: 3577:static PyObject* function _getattr_bands called 1750 returned 100% blocks executed 100% 1750: 3578:_getattr_bands(ImagingObject* self, void* closure) -: 3579:{ 1750: 3580: return PyLong_FromLong(self->image->bands); call 0 returned 100% -: 3581:} -: 3582: -: 3583:static PyObject* function _getattr_id called 9387 returned 100% blocks executed 100% 9387: 3584:_getattr_id(ImagingObject* self, void* closure) -: 3585:{ 9387: 3586: return PyLong_FromSsize_t((Py_ssize_t) self->image); call 0 returned 100% -: 3587:} -: 3588: -: 3589:static PyObject* function _getattr_ptr called 1 returned 100% blocks executed 100% 1: 3590:_getattr_ptr(ImagingObject* self, void* closure) -: 3591:{ 1: 3592: return PyCapsule_New(self->image, IMAGING_MAGIC, NULL); call 0 returned 100% -: 3593:} -: 3594: -: 3595:static PyObject* function _getattr_unsafe_ptrs called 118 returned 100% blocks executed 100% 118: 3596:_getattr_unsafe_ptrs(ImagingObject* self, void* closure) -: 3597:{ 118: 3598: return Py_BuildValue("(sn)(sn)(sn)", call 0 returned 100% -: 3599: "image8", self->image->image8, -: 3600: "image32", self->image->image32, 118: 3601: "image", self->image->image -: 3602: ); -: 3603:}; -: 3604: -: 3605: -: 3606:static struct PyGetSetDef getsetters[] = { -: 3607: { "mode", (getter) _getattr_mode }, -: 3608: { "size", (getter) _getattr_size }, -: 3609: { "bands", (getter) _getattr_bands }, -: 3610: { "id", (getter) _getattr_id }, -: 3611: { "ptr", (getter) _getattr_ptr }, -: 3612: { "unsafe_ptrs", (getter) _getattr_unsafe_ptrs }, -: 3613: { NULL } -: 3614:}; -: 3615: -: 3616:/* basic sequence semantics */ -: 3617: -: 3618:static Py_ssize_t function image_length called 732872 returned 100% blocks executed 100% 732872: 3619:image_length(ImagingObject *self) -: 3620:{ 732872: 3621: Imaging im = self->image; -: 3622: 732872: 3623: return (Py_ssize_t) im->xsize * im->ysize; -: 3624:} -: 3625: -: 3626:static PyObject * function image_item called 4304159 returned 100% blocks executed 100% 4304159: 3627:image_item(ImagingObject *self, Py_ssize_t i) -: 3628:{ -: 3629: int x, y; 4304159: 3630: Imaging im = self->image; -: 3631: 4304159: 3632: if (im->xsize > 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 4304158: 3633: x = i % im->xsize; 4304158: 3634: y = i / im->xsize; -: 3635: } else { -: 3636: x = y = 0; /* leave it to getpixel to raise an exception */ -: 3637: } -: 3638: 4304159: 3639: return getpixel(im, self->access, x, y); call 0 returned 100% -: 3640:} -: 3641: -: 3642:static PySequenceMethods image_as_sequence = { -: 3643: (lenfunc) image_length, /*sq_length*/ -: 3644: (binaryfunc) NULL, /*sq_concat*/ -: 3645: (ssizeargfunc) NULL, /*sq_repeat*/ -: 3646: (ssizeargfunc) image_item, /*sq_item*/ -: 3647: (ssizessizeargfunc) NULL, /*sq_slice*/ -: 3648: (ssizeobjargproc) NULL, /*sq_ass_item*/ -: 3649: (ssizessizeobjargproc) NULL, /*sq_ass_slice*/ -: 3650:}; -: 3651: -: 3652: -: 3653:/* type description */ -: 3654: -: 3655:static PyTypeObject Imaging_Type = { -: 3656: PyVarObject_HEAD_INIT(NULL, 0) -: 3657: "ImagingCore", /*tp_name*/ -: 3658: sizeof(ImagingObject), /*tp_size*/ -: 3659: 0, /*tp_itemsize*/ -: 3660: /* methods */ -: 3661: (destructor)_dealloc, /*tp_dealloc*/ -: 3662: 0, /*tp_print*/ -: 3663: 0, /*tp_getattr*/ -: 3664: 0, /*tp_setattr*/ -: 3665: 0, /*tp_compare*/ -: 3666: 0, /*tp_repr*/ -: 3667: 0, /*tp_as_number */ -: 3668: &image_as_sequence, /*tp_as_sequence */ -: 3669: 0, /*tp_as_mapping */ -: 3670: 0, /*tp_hash*/ -: 3671: 0, /*tp_call*/ -: 3672: 0, /*tp_str*/ -: 3673: 0, /*tp_getattro*/ -: 3674: 0, /*tp_setattro*/ -: 3675: 0, /*tp_as_buffer*/ -: 3676: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 3677: 0, /*tp_doc*/ -: 3678: 0, /*tp_traverse*/ -: 3679: 0, /*tp_clear*/ -: 3680: 0, /*tp_richcompare*/ -: 3681: 0, /*tp_weaklistoffset*/ -: 3682: 0, /*tp_iter*/ -: 3683: 0, /*tp_iternext*/ -: 3684: methods, /*tp_methods*/ -: 3685: 0, /*tp_members*/ -: 3686: getsetters, /*tp_getset*/ -: 3687:}; -: 3688: -: 3689:#ifdef WITH_IMAGEDRAW -: 3690: -: 3691:static PyTypeObject ImagingFont_Type = { -: 3692: PyVarObject_HEAD_INIT(NULL, 0) -: 3693: "ImagingFont", /*tp_name*/ -: 3694: sizeof(ImagingFontObject), /*tp_size*/ -: 3695: 0, /*tp_itemsize*/ -: 3696: /* methods */ -: 3697: (destructor)_font_dealloc, /*tp_dealloc*/ -: 3698: 0, /*tp_print*/ -: 3699: 0, /*tp_getattr*/ -: 3700: 0, /*tp_setattr*/ -: 3701: 0, /*tp_compare*/ -: 3702: 0, /*tp_repr*/ -: 3703: 0, /*tp_as_number */ -: 3704: 0, /*tp_as_sequence */ -: 3705: 0, /*tp_as_mapping */ -: 3706: 0, /*tp_hash*/ -: 3707: 0, /*tp_call*/ -: 3708: 0, /*tp_str*/ -: 3709: 0, /*tp_getattro*/ -: 3710: 0, /*tp_setattro*/ -: 3711: 0, /*tp_as_buffer*/ -: 3712: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 3713: 0, /*tp_doc*/ -: 3714: 0, /*tp_traverse*/ -: 3715: 0, /*tp_clear*/ -: 3716: 0, /*tp_richcompare*/ -: 3717: 0, /*tp_weaklistoffset*/ -: 3718: 0, /*tp_iter*/ -: 3719: 0, /*tp_iternext*/ -: 3720: _font_methods, /*tp_methods*/ -: 3721: 0, /*tp_members*/ -: 3722: 0, /*tp_getset*/ -: 3723:}; -: 3724: -: 3725:static PyTypeObject ImagingDraw_Type = { -: 3726: PyVarObject_HEAD_INIT(NULL, 0) -: 3727: "ImagingDraw", /*tp_name*/ -: 3728: sizeof(ImagingDrawObject), /*tp_size*/ -: 3729: 0, /*tp_itemsize*/ -: 3730: /* methods */ -: 3731: (destructor)_draw_dealloc, /*tp_dealloc*/ -: 3732: 0, /*tp_print*/ -: 3733: 0, /*tp_getattr*/ -: 3734: 0, /*tp_setattr*/ -: 3735: 0, /*tp_compare*/ -: 3736: 0, /*tp_repr*/ -: 3737: 0, /*tp_as_number */ -: 3738: 0, /*tp_as_sequence */ -: 3739: 0, /*tp_as_mapping */ -: 3740: 0, /*tp_hash*/ -: 3741: 0, /*tp_call*/ -: 3742: 0, /*tp_str*/ -: 3743: 0, /*tp_getattro*/ -: 3744: 0, /*tp_setattro*/ -: 3745: 0, /*tp_as_buffer*/ -: 3746: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 3747: 0, /*tp_doc*/ -: 3748: 0, /*tp_traverse*/ -: 3749: 0, /*tp_clear*/ -: 3750: 0, /*tp_richcompare*/ -: 3751: 0, /*tp_weaklistoffset*/ -: 3752: 0, /*tp_iter*/ -: 3753: 0, /*tp_iternext*/ -: 3754: _draw_methods, /*tp_methods*/ -: 3755: 0, /*tp_members*/ -: 3756: 0, /*tp_getset*/ -: 3757:}; -: 3758: -: 3759:#endif -: 3760: -: 3761:static PyMappingMethods pixel_access_as_mapping = { -: 3762: (lenfunc) NULL, /*mp_length*/ -: 3763: (binaryfunc) pixel_access_getitem, /*mp_subscript*/ -: 3764: (objobjargproc) pixel_access_setitem, /*mp_ass_subscript*/ -: 3765:}; -: 3766: -: 3767:/* type description */ -: 3768: -: 3769:static PyTypeObject PixelAccess_Type = { -: 3770: PyVarObject_HEAD_INIT(NULL, 0) -: 3771: "PixelAccess", sizeof(PixelAccessObject), 0, -: 3772: /* methods */ -: 3773: (destructor)pixel_access_dealloc, /*tp_dealloc*/ -: 3774: 0, /*tp_print*/ -: 3775: 0, /*tp_getattr*/ -: 3776: 0, /*tp_setattr*/ -: 3777: 0, /*tp_compare*/ -: 3778: 0, /*tp_repr*/ -: 3779: 0, /*tp_as_number */ -: 3780: 0, /*tp_as_sequence */ -: 3781: &pixel_access_as_mapping, /*tp_as_mapping */ -: 3782: 0 /*tp_hash*/ -: 3783:}; -: 3784: -: 3785:/* -------------------------------------------------------------------- */ -: 3786: -: 3787:static PyObject* function _get_stats called 20 returned 100% blocks executed 100% 20: 3788:_get_stats(PyObject* self, PyObject* args) -: 3789:{ -: 3790: PyObject* d; 20: 3791: ImagingMemoryArena arena = &ImagingDefaultArena; -: 3792: 20: 3793: if (!PyArg_ParseTuple(args, ":get_stats")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3794: return NULL; -: 3795: } -: 3796: 20: 3797: d = PyDict_New(); call 0 returned 100% 20: 3798: if ( ! d) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 3799: return NULL; -: 3800: } 20: 3801: PyDict_SetItemString(d, "new_count", call 0 returned 100% call 1 returned 100% 20: 3802: PyLong_FromLong(arena->stats_new_count)); 20: 3803: PyDict_SetItemString(d, "allocated_blocks", call 0 returned 100% call 1 returned 100% 20: 3804: PyLong_FromLong(arena->stats_allocated_blocks)); 20: 3805: PyDict_SetItemString(d, "reused_blocks", call 0 returned 100% call 1 returned 100% 20: 3806: PyLong_FromLong(arena->stats_reused_blocks)); 20: 3807: PyDict_SetItemString(d, "reallocated_blocks", call 0 returned 100% call 1 returned 100% 20: 3808: PyLong_FromLong(arena->stats_reallocated_blocks)); 20: 3809: PyDict_SetItemString(d, "freed_blocks", call 0 returned 100% call 1 returned 100% 20: 3810: PyLong_FromLong(arena->stats_freed_blocks)); 20: 3811: PyDict_SetItemString(d, "blocks_cached", call 0 returned 100% call 1 returned 100% 20: 3812: PyLong_FromLong(arena->blocks_cached)); 20: 3813: return d; -: 3814:} -: 3815: -: 3816:static PyObject* function _reset_stats called 5 returned 100% blocks executed 100% 5: 3817:_reset_stats(PyObject* self, PyObject* args) -: 3818:{ 5: 3819: ImagingMemoryArena arena = &ImagingDefaultArena; -: 3820: 5: 3821: if (!PyArg_ParseTuple(args, ":reset_stats")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3822: return NULL; -: 3823: } -: 3824: 5: 3825: arena->stats_new_count = 0; 5: 3826: arena->stats_allocated_blocks = 0; 5: 3827: arena->stats_reused_blocks = 0; 5: 3828: arena->stats_reallocated_blocks = 0; 5: 3829: arena->stats_freed_blocks = 0; -: 3830: 5: 3831: Py_INCREF(Py_None); 5: 3832: return Py_None; -: 3833:} -: 3834: -: 3835:static PyObject* function _get_alignment called 7 returned 100% blocks executed 100% 7: 3836:_get_alignment(PyObject* self, PyObject* args) -: 3837:{ 7: 3838: if (!PyArg_ParseTuple(args, ":get_alignment")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3839: return NULL; -: 3840: } -: 3841: 7: 3842: return PyLong_FromLong(ImagingDefaultArena.alignment); call 0 returned 100% -: 3843:} -: 3844: -: 3845:static PyObject* function _get_block_size called 5 returned 100% blocks executed 100% 5: 3846:_get_block_size(PyObject* self, PyObject* args) -: 3847:{ 5: 3848: if (!PyArg_ParseTuple(args, ":get_block_size")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3849: return NULL; -: 3850: } -: 3851: 5: 3852: return PyLong_FromLong(ImagingDefaultArena.block_size); call 0 returned 100% -: 3853:} -: 3854: -: 3855:static PyObject* function _get_blocks_max called 5 returned 100% blocks executed 100% 5: 3856:_get_blocks_max(PyObject* self, PyObject* args) -: 3857:{ 5: 3858: if (!PyArg_ParseTuple(args, ":get_blocks_max")) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3859: return NULL; -: 3860: } -: 3861: 5: 3862: return PyLong_FromLong(ImagingDefaultArena.blocks_max); call 0 returned 100% -: 3863:} -: 3864: -: 3865:static PyObject* function _set_alignment called 22 returned 100% blocks executed 100% 22: 3866:_set_alignment(PyObject* self, PyObject* args) -: 3867:{ -: 3868: int alignment; 22: 3869: if (!PyArg_ParseTuple(args, "i:set_alignment", &alignment)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3870: return NULL; -: 3871: } -: 3872: 22: 3873: if (alignment < 1 || alignment > 128) { branch 0 taken 9% (fallthrough) branch 1 taken 91% 2: 3874: PyErr_SetString(PyExc_ValueError, "alignment should be from 1 to 128"); call 0 returned 100% 2: 3875: return NULL; -: 3876: } -: 3877: /* Is power of two */ 20: 3878: if (alignment & (alignment - 1)) { branch 0 taken 10% (fallthrough) branch 1 taken 90% 2: 3879: PyErr_SetString(PyExc_ValueError, "alignment should be power of two"); call 0 returned 100% 2: 3880: return NULL; -: 3881: } -: 3882: 18: 3883: ImagingDefaultArena.alignment = alignment; -: 3884: 18: 3885: Py_INCREF(Py_None); 18: 3886: return Py_None; -: 3887:} -: 3888: -: 3889:static PyObject* function _set_block_size called 24 returned 100% blocks executed 100% 24: 3890:_set_block_size(PyObject* self, PyObject* args) -: 3891:{ -: 3892: int block_size; 24: 3893: if (!PyArg_ParseTuple(args, "i:set_block_size", &block_size)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3894: return NULL; -: 3895: } -: 3896: 24: 3897: if (block_size <= 0) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 2: 3898: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 3899: "block_size should be greater than 0"); 2: 3900: return NULL; -: 3901: } -: 3902: 22: 3903: if (block_size & 0xfff) { branch 0 taken 9% (fallthrough) branch 1 taken 91% 2: 3904: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 3905: "block_size should be multiple of 4096"); 2: 3906: return NULL; -: 3907: } -: 3908: 20: 3909: ImagingDefaultArena.block_size = block_size; -: 3910: 20: 3911: Py_INCREF(Py_None); 20: 3912: return Py_None; -: 3913:} -: 3914: -: 3915:static PyObject* function _set_blocks_max called 21 returned 100% blocks executed 71% 21: 3916:_set_blocks_max(PyObject* self, PyObject* args) -: 3917:{ -: 3918: int blocks_max; 21: 3919: if (!PyArg_ParseTuple(args, "i:set_blocks_max", &blocks_max)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3920: return NULL; -: 3921: } -: 3922: 21: 3923: if (blocks_max < 0) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 1: 3924: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 3925: "blocks_max should be greater than 0"); 1: 3926: return NULL; -: 3927: } 20: 3928: else if ( blocks_max > SIZE_MAX/sizeof(ImagingDefaultArena.blocks_pool[0])) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 3929: PyErr_SetString(PyExc_ValueError, call 0 never executed -: 3930: "blocks_max is too large"); #####: 3931: return NULL; -: 3932: } -: 3933: -: 3934: 20: 3935: if ( ! ImagingMemorySetBlocksMax(&ImagingDefaultArena, blocks_max)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 3936: ImagingError_MemoryError(); call 0 never executed #####: 3937: return NULL; -: 3938: } -: 3939: 20: 3940: Py_INCREF(Py_None); 20: 3941: return Py_None; -: 3942:} -: 3943: -: 3944:static PyObject* function _clear_cache called 18 returned 100% blocks executed 100% 18: 3945:_clear_cache(PyObject* self, PyObject* args) -: 3946:{ 18: 3947: int i = 0; -: 3948: 18: 3949: if (!PyArg_ParseTuple(args, "|i:clear_cache", &i)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 3950: return NULL; -: 3951: } -: 3952: 18: 3953: ImagingMemoryClearCache(&ImagingDefaultArena, i); call 0 returned 100% -: 3954: 18: 3955: Py_INCREF(Py_None); 18: 3956: return Py_None; -: 3957:} -: 3958: -: 3959:/* -------------------------------------------------------------------- */ -: 3960: -: 3961:/* FIXME: this is something of a mess. Should replace this with -: 3962: pluggable codecs, but not before PIL 1.2 */ -: 3963: -: 3964:/* Decoders (in decode.c) */ -: 3965:extern PyObject* PyImaging_BcnDecoderNew(PyObject* self, PyObject* args); -: 3966:extern PyObject* PyImaging_BitDecoderNew(PyObject* self, PyObject* args); -: 3967:extern PyObject* PyImaging_FliDecoderNew(PyObject* self, PyObject* args); -: 3968:extern PyObject* PyImaging_GifDecoderNew(PyObject* self, PyObject* args); -: 3969:extern PyObject* PyImaging_HexDecoderNew(PyObject* self, PyObject* args); -: 3970:extern PyObject* PyImaging_JpegDecoderNew(PyObject* self, PyObject* args); -: 3971:extern PyObject* PyImaging_Jpeg2KDecoderNew(PyObject* self, PyObject* args); -: 3972:extern PyObject* PyImaging_LibTiffDecoderNew(PyObject* self, PyObject* args); -: 3973:extern PyObject* PyImaging_PackbitsDecoderNew(PyObject* self, PyObject* args); -: 3974:extern PyObject* PyImaging_PcdDecoderNew(PyObject* self, PyObject* args); -: 3975:extern PyObject* PyImaging_PcxDecoderNew(PyObject* self, PyObject* args); -: 3976:extern PyObject* PyImaging_RawDecoderNew(PyObject* self, PyObject* args); -: 3977:extern PyObject* PyImaging_SgiRleDecoderNew(PyObject* self, PyObject* args); -: 3978:extern PyObject* PyImaging_SunRleDecoderNew(PyObject* self, PyObject* args); -: 3979:extern PyObject* PyImaging_TgaRleDecoderNew(PyObject* self, PyObject* args); -: 3980:extern PyObject* PyImaging_XbmDecoderNew(PyObject* self, PyObject* args); -: 3981:extern PyObject* PyImaging_ZipDecoderNew(PyObject* self, PyObject* args); -: 3982: -: 3983:/* Encoders (in encode.c) */ -: 3984:extern PyObject* PyImaging_EpsEncoderNew(PyObject* self, PyObject* args); -: 3985:extern PyObject* PyImaging_GifEncoderNew(PyObject* self, PyObject* args); -: 3986:extern PyObject* PyImaging_JpegEncoderNew(PyObject* self, PyObject* args); -: 3987:extern PyObject* PyImaging_Jpeg2KEncoderNew(PyObject* self, PyObject* args); -: 3988:extern PyObject* PyImaging_PcxEncoderNew(PyObject* self, PyObject* args); -: 3989:extern PyObject* PyImaging_RawEncoderNew(PyObject* self, PyObject* args); -: 3990:extern PyObject* PyImaging_TgaRleEncoderNew(PyObject* self, PyObject* args); -: 3991:extern PyObject* PyImaging_XbmEncoderNew(PyObject* self, PyObject* args); -: 3992:extern PyObject* PyImaging_ZipEncoderNew(PyObject* self, PyObject* args); -: 3993:extern PyObject* PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args); -: 3994: -: 3995:/* Display support etc (in display.c) */ -: 3996:#ifdef _WIN32 -: 3997:extern PyObject* PyImaging_CreateWindowWin32(PyObject* self, PyObject* args); -: 3998:extern PyObject* PyImaging_DisplayWin32(PyObject* self, PyObject* args); -: 3999:extern PyObject* PyImaging_DisplayModeWin32(PyObject* self, PyObject* args); -: 4000:extern PyObject* PyImaging_GrabScreenWin32(PyObject* self, PyObject* args); -: 4001:extern PyObject* PyImaging_GrabClipboardWin32(PyObject* self, PyObject* args); -: 4002:extern PyObject* PyImaging_ListWindowsWin32(PyObject* self, PyObject* args); -: 4003:extern PyObject* PyImaging_EventLoopWin32(PyObject* self, PyObject* args); -: 4004:extern PyObject* PyImaging_DrawWmf(PyObject* self, PyObject* args); -: 4005:#endif -: 4006:#ifdef HAVE_XCB -: 4007:extern PyObject* PyImaging_GrabScreenX11(PyObject* self, PyObject* args); -: 4008:#endif -: 4009: -: 4010:/* Experimental path stuff (in path.c) */ -: 4011:extern PyObject* PyPath_Create(ImagingObject* self, PyObject* args); -: 4012: -: 4013:/* Experimental outline stuff (in outline.c) */ -: 4014:extern PyObject* PyOutline_Create(ImagingObject* self, PyObject* args); -: 4015: -: 4016:extern PyObject* PyImaging_Mapper(PyObject* self, PyObject* args); -: 4017:extern PyObject* PyImaging_MapBuffer(PyObject* self, PyObject* args); -: 4018: -: 4019:static PyMethodDef functions[] = { -: 4020: -: 4021: /* Object factories */ -: 4022: {"alpha_composite", (PyCFunction)_alpha_composite, 1}, -: 4023: {"blend", (PyCFunction)_blend, 1}, -: 4024: {"fill", (PyCFunction)_fill, 1}, -: 4025: {"new", (PyCFunction)_new, 1}, -: 4026: {"merge", (PyCFunction)_merge, 1}, -: 4027: -: 4028: /* Functions */ -: 4029: {"convert", (PyCFunction)_convert2, 1}, -: 4030: -: 4031: /* Codecs */ -: 4032: {"bcn_decoder", (PyCFunction)PyImaging_BcnDecoderNew, 1}, -: 4033: {"bit_decoder", (PyCFunction)PyImaging_BitDecoderNew, 1}, -: 4034: {"eps_encoder", (PyCFunction)PyImaging_EpsEncoderNew, 1}, -: 4035: {"fli_decoder", (PyCFunction)PyImaging_FliDecoderNew, 1}, -: 4036: {"gif_decoder", (PyCFunction)PyImaging_GifDecoderNew, 1}, -: 4037: {"gif_encoder", (PyCFunction)PyImaging_GifEncoderNew, 1}, -: 4038: {"hex_decoder", (PyCFunction)PyImaging_HexDecoderNew, 1}, -: 4039: {"hex_encoder", (PyCFunction)PyImaging_EpsEncoderNew, 1}, /* EPS=HEX! */ -: 4040:#ifdef HAVE_LIBJPEG -: 4041: {"jpeg_decoder", (PyCFunction)PyImaging_JpegDecoderNew, 1}, -: 4042: {"jpeg_encoder", (PyCFunction)PyImaging_JpegEncoderNew, 1}, -: 4043:#endif -: 4044:#ifdef HAVE_OPENJPEG -: 4045: {"jpeg2k_decoder", (PyCFunction)PyImaging_Jpeg2KDecoderNew, 1}, -: 4046: {"jpeg2k_encoder", (PyCFunction)PyImaging_Jpeg2KEncoderNew, 1}, -: 4047:#endif -: 4048:#ifdef HAVE_LIBTIFF -: 4049: {"libtiff_decoder", (PyCFunction)PyImaging_LibTiffDecoderNew, 1}, -: 4050: {"libtiff_encoder", (PyCFunction)PyImaging_LibTiffEncoderNew, 1}, -: 4051:#endif -: 4052: {"packbits_decoder", (PyCFunction)PyImaging_PackbitsDecoderNew, 1}, -: 4053: {"pcd_decoder", (PyCFunction)PyImaging_PcdDecoderNew, 1}, -: 4054: {"pcx_decoder", (PyCFunction)PyImaging_PcxDecoderNew, 1}, -: 4055: {"pcx_encoder", (PyCFunction)PyImaging_PcxEncoderNew, 1}, -: 4056: {"raw_decoder", (PyCFunction)PyImaging_RawDecoderNew, 1}, -: 4057: {"raw_encoder", (PyCFunction)PyImaging_RawEncoderNew, 1}, -: 4058: {"sgi_rle_decoder", (PyCFunction)PyImaging_SgiRleDecoderNew, 1}, -: 4059: {"sun_rle_decoder", (PyCFunction)PyImaging_SunRleDecoderNew, 1}, -: 4060: {"tga_rle_decoder", (PyCFunction)PyImaging_TgaRleDecoderNew, 1}, -: 4061: {"tga_rle_encoder", (PyCFunction)PyImaging_TgaRleEncoderNew, 1}, -: 4062: {"xbm_decoder", (PyCFunction)PyImaging_XbmDecoderNew, 1}, -: 4063: {"xbm_encoder", (PyCFunction)PyImaging_XbmEncoderNew, 1}, -: 4064:#ifdef HAVE_LIBZ -: 4065: {"zip_decoder", (PyCFunction)PyImaging_ZipDecoderNew, 1}, -: 4066: {"zip_encoder", (PyCFunction)PyImaging_ZipEncoderNew, 1}, -: 4067:#endif -: 4068: -: 4069: /* Memory mapping */ -: 4070:#ifdef WITH_MAPPING -: 4071:#ifdef _WIN32 -: 4072: {"map", (PyCFunction)PyImaging_Mapper, 1}, -: 4073:#endif -: 4074: {"map_buffer", (PyCFunction)PyImaging_MapBuffer, 1}, -: 4075:#endif -: 4076: -: 4077: /* Display support */ -: 4078:#ifdef _WIN32 -: 4079: {"display", (PyCFunction)PyImaging_DisplayWin32, 1}, -: 4080: {"display_mode", (PyCFunction)PyImaging_DisplayModeWin32, 1}, -: 4081: {"grabscreen_win32", (PyCFunction)PyImaging_GrabScreenWin32, 1}, -: 4082: {"grabclipboard_win32", (PyCFunction)PyImaging_GrabClipboardWin32, 1}, -: 4083: {"createwindow", (PyCFunction)PyImaging_CreateWindowWin32, 1}, -: 4084: {"eventloop", (PyCFunction)PyImaging_EventLoopWin32, 1}, -: 4085: {"listwindows", (PyCFunction)PyImaging_ListWindowsWin32, 1}, -: 4086: {"drawwmf", (PyCFunction)PyImaging_DrawWmf, 1}, -: 4087:#endif -: 4088:#ifdef HAVE_XCB -: 4089: {"grabscreen_x11", (PyCFunction)PyImaging_GrabScreenX11, 1}, -: 4090:#endif -: 4091: -: 4092: /* Utilities */ -: 4093: {"getcodecstatus", (PyCFunction)_getcodecstatus, 1}, -: 4094: -: 4095: /* Special effects (experimental) */ -: 4096:#ifdef WITH_EFFECTS -: 4097: {"effect_mandelbrot", (PyCFunction)_effect_mandelbrot, 1}, -: 4098: {"effect_noise", (PyCFunction)_effect_noise, 1}, -: 4099: {"linear_gradient", (PyCFunction)_linear_gradient, 1}, -: 4100: {"radial_gradient", (PyCFunction)_radial_gradient, 1}, -: 4101: {"wedge", (PyCFunction)_linear_gradient, 1}, /* Compatibility */ -: 4102:#endif -: 4103: -: 4104: /* Drawing support stuff */ -: 4105:#ifdef WITH_IMAGEDRAW -: 4106: {"font", (PyCFunction)_font_new, 1}, -: 4107: {"draw", (PyCFunction)_draw_new, 1}, -: 4108:#endif -: 4109: -: 4110: /* Experimental path stuff */ -: 4111:#ifdef WITH_IMAGEPATH -: 4112: {"path", (PyCFunction)PyPath_Create, 1}, -: 4113:#endif -: 4114: -: 4115: /* Experimental arrow graphics stuff */ -: 4116:#ifdef WITH_ARROW -: 4117: {"outline", (PyCFunction)PyOutline_Create, 1}, -: 4118:#endif -: 4119: -: 4120: /* Resource management */ -: 4121: {"get_stats", (PyCFunction)_get_stats, 1}, -: 4122: {"reset_stats", (PyCFunction)_reset_stats, 1}, -: 4123: {"get_alignment", (PyCFunction)_get_alignment, 1}, -: 4124: {"get_block_size", (PyCFunction)_get_block_size, 1}, -: 4125: {"get_blocks_max", (PyCFunction)_get_blocks_max, 1}, -: 4126: {"set_alignment", (PyCFunction)_set_alignment, 1}, -: 4127: {"set_block_size", (PyCFunction)_set_block_size, 1}, -: 4128: {"set_blocks_max", (PyCFunction)_set_blocks_max, 1}, -: 4129: {"clear_cache", (PyCFunction)_clear_cache, 1}, -: 4130: -: 4131: {NULL, NULL} /* sentinel */ -: 4132:}; -: 4133: -: 4134:static int function setup_module called 3 returned 100% blocks executed 100% 3: 4135:setup_module(PyObject* m) { 3: 4136: PyObject* d = PyModule_GetDict(m); call 0 returned 100% 3: 4137: const char* version = (char*)PILLOW_VERSION; -: 4138: -: 4139: /* Ready object types */ 3: 4140: if (PyType_Ready(&Imaging_Type) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 4141: return -1; -: 4142: } -: 4143: -: 4144:#ifdef WITH_IMAGEDRAW 3: 4145: if (PyType_Ready(&ImagingFont_Type) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 4146: return -1; -: 4147: } -: 4148: 3: 4149: if (PyType_Ready(&ImagingDraw_Type) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 4150: return -1; -: 4151: } -: 4152:#endif 3: 4153: if (PyType_Ready(&PixelAccess_Type) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 4154: return -1; -: 4155: } -: 4156: 3: 4157: ImagingAccessInit(); call 0 returned 100% -: 4158: -: 4159:#ifdef HAVE_LIBJPEG -: 4160: { -: 4161: extern const char* ImagingJpegVersion(void); 3: 4162: PyDict_SetItemString(d, "jpeglib_version", PyUnicode_FromString(ImagingJpegVersion())); call 0 returned 100% call 1 returned 100% call 2 returned 100% -: 4163: } -: 4164:#endif -: 4165: -: 4166:#ifdef HAVE_OPENJPEG -: 4167: { -: 4168: extern const char *ImagingJpeg2KVersion(void); 3: 4169: PyDict_SetItemString(d, "jp2klib_version", PyUnicode_FromString(ImagingJpeg2KVersion())); call 0 returned 100% call 1 returned 100% call 2 returned 100% -: 4170: } -: 4171:#endif -: 4172: -: 4173:#ifdef LIBJPEG_TURBO_VERSION 3: 4174: PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", Py_True); call 0 returned 100% -: 4175: #define tostr1(a) #a -: 4176: #define tostr(a) tostr1(a) 3: 4177: PyDict_SetItemString(d, "libjpeg_turbo_version", PyUnicode_FromString(tostr(LIBJPEG_TURBO_VERSION))); call 0 returned 100% call 1 returned 100% -: 4178: #undef tostr -: 4179: #undef tostr1 -: 4180:#else -: 4181: PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", Py_False); -: 4182:#endif -: 4183: -: 4184:#ifdef HAVE_LIBIMAGEQUANT 3: 4185: PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", Py_True); call 0 returned 100% -: 4186: { -: 4187: extern const char* ImagingImageQuantVersion(void); 3: 4188: PyDict_SetItemString(d, "imagequant_version", PyUnicode_FromString(ImagingImageQuantVersion())); call 0 returned 100% call 1 returned 100% call 2 returned 100% -: 4189: } -: 4190:#else -: 4191: PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", Py_False); -: 4192:#endif -: 4193: -: 4194:#ifdef HAVE_LIBZ -: 4195: /* zip encoding strategies */ 3: 4196: PyModule_AddIntConstant(m, "DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY); call 0 returned 100% 3: 4197: PyModule_AddIntConstant(m, "FILTERED", Z_FILTERED); call 0 returned 100% 3: 4198: PyModule_AddIntConstant(m, "HUFFMAN_ONLY", Z_HUFFMAN_ONLY); call 0 returned 100% 3: 4199: PyModule_AddIntConstant(m, "RLE", Z_RLE); call 0 returned 100% 3: 4200: PyModule_AddIntConstant(m, "FIXED", Z_FIXED); call 0 returned 100% -: 4201: { -: 4202: extern const char* ImagingZipVersion(void); 3: 4203: PyDict_SetItemString(d, "zlib_version", PyUnicode_FromString(ImagingZipVersion())); call 0 returned 100% call 1 returned 100% call 2 returned 100% -: 4204: } -: 4205:#endif -: 4206: -: 4207:#ifdef HAVE_LIBTIFF -: 4208: { -: 4209: extern const char * ImagingTiffVersion(void); 3: 4210: PyDict_SetItemString(d, "libtiff_version", PyUnicode_FromString(ImagingTiffVersion())); call 0 returned 100% call 1 returned 100% call 2 returned 100% -: 4211: -: 4212: // Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7 -: 4213: PyObject* support_custom_tags; -: 4214:#if TIFFLIB_VERSION >= 20111221 && TIFFLIB_VERSION != 20120218 && TIFFLIB_VERSION != 20120922 3: 4215: support_custom_tags = Py_True; -: 4216:#else -: 4217: support_custom_tags = Py_False; -: 4218:#endif 3: 4219: PyDict_SetItemString(d, "libtiff_support_custom_tags", support_custom_tags); call 0 returned 100% -: 4220: } -: 4221:#endif -: 4222: -: 4223:#ifdef HAVE_XCB 3: 4224: PyModule_AddObject(m, "HAVE_XCB", Py_True); call 0 returned 100% -: 4225:#else -: 4226: PyModule_AddObject(m, "HAVE_XCB", Py_False); -: 4227:#endif -: 4228: 3: 4229: PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(version)); call 0 returned 100% call 1 returned 100% -: 4230: 3: 4231: return 0; -: 4232:} -: 4233: -: 4234:PyMODINIT_FUNC function PyInit__imaging called 3 returned 100% blocks executed 100% 3: 4235:PyInit__imaging(void) { -: 4236: PyObject* m; -: 4237: -: 4238: static PyModuleDef module_def = { -: 4239: PyModuleDef_HEAD_INIT, -: 4240: "_imaging", /* m_name */ -: 4241: NULL, /* m_doc */ -: 4242: -1, /* m_size */ -: 4243: functions, /* m_methods */ -: 4244: }; -: 4245: 3: 4246: m = PyModule_Create(&module_def); call 0 returned 100% -: 4247: 3: 4248: if (setup_module(m) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 4249: return NULL; -: 4250: } -: 4251: 3: 4252: return m; -: 4253:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Pack.c.gcov -: 0:Source:src/libImaging/Pack.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Pack.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/Pack.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1: /* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * code to pack raw data -: 6: * -: 7: * history: -: 8: * 1996-04-30 fl Created -: 9: * 1996-05-12 fl Published a few RGB packers -: 10: * 1996-11-01 fl More RGB packers (Tk booster stuff) -: 11: * 1996-12-30 fl Added P;1, P;2 and P;4 packers -: 12: * 1997-06-02 fl Added F (F;32NF) packer -: 13: * 1997-08-28 fl Added 1 as L packer -: 14: * 1998-02-08 fl Added I packer -: 15: * 1998-03-09 fl Added mode field, RGBA/RGBX as RGB packers -: 16: * 1998-07-01 fl Added YCbCr support -: 17: * 1998-07-12 fl Added I 16 packer -: 18: * 1999-02-03 fl Added BGR packers -: 19: * 2003-09-26 fl Added LA/PA packers -: 20: * 2006-06-22 fl Added CMYK;I packer -: 21: * -: 22: * Copyright (c) 1997-2006 by Secret Labs AB. -: 23: * Copyright (c) 1996-1997 by Fredrik Lundh. -: 24: * -: 25: * See the README file for information on usage and redistribution. -: 26: */ -: 27: -: 28: -: 29:#include "Imaging.h" -: 30: -: 31:#define R 0 -: 32:#define G 1 -: 33:#define B 2 -: 34:#define X 3 -: 35:#define A 3 -: 36: -: 37:#define C 0 -: 38:#define M 1 -: 39:#define Y 2 -: 40:#define K 3 -: 41: -: 42:/* byte swapping macros */ -: 43: -: 44:#define C16N\ -: 45: (out[0]=tmp[0], out[1]=tmp[1]); -: 46:#define C16S\ -: 47: (out[1]=tmp[0], out[0]=tmp[1]); -: 48:#define C32N\ -: 49: (out[0]=tmp[0], out[1]=tmp[1], out[2]=tmp[2], out[3]=tmp[3]); -: 50:#define C32S\ -: 51: (out[3]=tmp[0], out[2]=tmp[1], out[1]=tmp[2], out[0]=tmp[3]); -: 52:#define C64N\ -: 53: (out[0]=tmp[0], out[1]=tmp[1], out[2]=tmp[2], out[3]=tmp[3],\ -: 54: out[4]=tmp[4], out[5]=tmp[5], out[6]=tmp[6], out[7]=tmp[7]); -: 55:#define C64S\ -: 56: (out[7]=tmp[0], out[6]=tmp[1], out[5]=tmp[2], out[4]=tmp[3],\ -: 57: out[3]=tmp[4], out[2]=tmp[5], out[1]=tmp[6], out[0]=tmp[7]); -: 58: -: 59:#ifdef WORDS_BIGENDIAN -: 60:#define C16B C16N -: 61:#define C16L C16S -: 62:#define C32B C32N -: 63:#define C32L C32S -: 64:#define C64B C64N -: 65:#define C64L C64S -: 66:#else -: 67:#define C16B C16S -: 68:#define C16L C16N -: 69:#define C32B C32S -: 70:#define C32L C32N -: 71:#define C64B C64S -: 72:#define C64L C64N -: 73:#endif -: 74: -: 75: -: 76:static void function pack1 called 44769 returned 100% blocks executed 100% 44769: 77:pack1(UINT8* out, const UINT8* in, int pixels) -: 78:{ -: 79: int i, m, b; -: 80: /* bilevel (black is 0) */ 44769: 81: b = 0; m = 128; 41686077: 82: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 41641308: 83: if (in[i] != 0) { branch 0 taken 68% (fallthrough) branch 1 taken 32% 28342814: 84: b |= m; -: 85: } 41641308: 86: m >>= 1; 41641308: 87: if (m == 0) { branch 0 taken 12% (fallthrough) branch 1 taken 88% 5193992: 88: *out++ = b; 5193992: 89: b = 0; m = 128; -: 90: } -: 91: } 44769: 92: if (m != 128) { branch 0 taken 54% (fallthrough) branch 1 taken 46% 24228: 93: *out++ = b; -: 94: } 44769: 95:} -: 96: -: 97:static void function pack1I called 258 returned 100% blocks executed 90% 258: 98:pack1I(UINT8* out, const UINT8* in, int pixels) -: 99:{ -: 100: int i, m, b; -: 101: /* bilevel (black is 1) */ 258: 102: b = 0; m = 128; 33042: 103: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32784: 104: if (in[i] == 0) { branch 0 taken 67% (fallthrough) branch 1 taken 33% 21993: 105: b |= m; -: 106: } 32784: 107: m >>= 1; 32784: 108: if (m == 0) { branch 0 taken 13% (fallthrough) branch 1 taken 88% 4098: 109: *out++ = b; 4098: 110: b = 0; m = 128; -: 111: } -: 112: } 258: 113: if (m != 128) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 114: *out++ = b; -: 115: } 258: 116:} -: 117: -: 118:static void function pack1R called 1514 returned 100% blocks executed 90% 1514: 119:pack1R(UINT8* out, const UINT8* in, int pixels) -: 120:{ -: 121: int i, m, b; -: 122: /* bilevel, lsb first (black is 0) */ 1514: 123: b = 0; m = 1; 1067066: 124: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1065552: 125: if (in[i] != 0) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 353490: 126: b |= m; -: 127: } 1065552: 128: m <<= 1; 1065552: 129: if (m == 256){ branch 0 taken 13% (fallthrough) branch 1 taken 88% 133194: 130: *out++ = b; 133194: 131: b = 0; m = 1; -: 132: } -: 133: } 1514: 134: if (m != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 135: *out++ = b; -: 136: } 1514: 137:} -: 138: -: 139:static void function pack1IR called 2 returned 100% blocks executed 90% 2: 140:pack1IR(UINT8* out, const UINT8* in, int pixels) -: 141:{ -: 142: int i, m, b; -: 143: /* bilevel, lsb first (black is 1) */ 2: 144: b = 0; m = 1; 18: 145: for (i = 0; i < pixels; i++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 16: 146: if (in[i] == 0) { branch 0 taken 31% (fallthrough) branch 1 taken 69% 5: 147: b |= m; -: 148: } 16: 149: m <<= 1; 16: 150: if (m == 256){ branch 0 taken 13% (fallthrough) branch 1 taken 88% 2: 151: *out++ = b; 2: 152: b = 0; m = 1; -: 153: } -: 154: } 2: 155: if (m != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 156: *out++ = b; -: 157: } 2: 158:} -: 159: -: 160:static void function pack1L called 45 returned 100% blocks executed 100% 45: 161:pack1L(UINT8* out, const UINT8* in, int pixels) -: 162:{ -: 163: int i; -: 164: /* bilevel, stored as bytes */ 663: 165: for (i = 0; i < pixels; i++) { branch 0 taken 93% branch 1 taken 7% (fallthrough) 618: 166: out[i] = (in[i] != 0) ? 255 : 0; branch 0 taken 96% (fallthrough) branch 1 taken 4% -: 167: } 45: 168:} -: 169: -: 170:static void function packP4 called 1 returned 100% blocks executed 83% 1: 171:packP4(UINT8* out, const UINT8* in, int pixels) -: 172:{ 4: 173: while (pixels >= 2) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 4: 174: *out++ = (in[0] << 4) | 2: 175: (in[1] & 15); 2: 176: in += 2; pixels -= 2; -: 177: } -: 178: 1: 179: if (pixels) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 180: out[0] = (in[0] << 4); -: 181: } 1: 182:} -: 183: -: 184:static void function packP2 called 2 returned 100% blocks executed 75% 2: 185:packP2(UINT8* out, const UINT8* in, int pixels) -: 186:{ 6: 187: while (pixels >= 4) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 8: 188: *out++ = (in[0] << 6) | 2: 189: ((in[1] & 3) << 4) | 2: 190: ((in[2] & 3) << 2) | 2: 191: (in[3] & 3); 2: 192: in += 4; pixels -= 4; -: 193: } -: 194: 2: 195: switch (pixels) { branch 0 taken 0% branch 1 taken 50% branch 2 taken 0% branch 3 taken 50% -: 196: case 3: #####: 197: out[0] = (in[0] << 6) | #####: 198: ((in[1] & 3) << 4) | #####: 199: ((in[2] & 3) << 2); #####: 200: break; -: 201: case 2: 2: 202: out[0] = (in[0] << 6) | 1: 203: ((in[1] & 3) << 4); 1: 204: break; -: 205: case 1: #####: 206: out[0] = (in[0] << 6); -: 207: } 2: 208:} -: 209: -: 210:static void function packL16 called 1 returned 100% blocks executed 100% 1: 211:packL16(UINT8* out, const UINT8* in, int pixels) -: 212:{ -: 213: int i; -: 214: /* L -> L;16, e.g: \xff77 -> \x00\xff\x00\x77 */ 3: 215: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 216: out[0] = 0; 2: 217: out[1] = in[i]; 2: 218: out += 2; -: 219: } 1: 220:} -: 221: -: 222:static void function packL16B called 385 returned 100% blocks executed 100% 385: 223:packL16B(UINT8* out, const UINT8* in, int pixels) -: 224:{ -: 225: int i; -: 226: /* L -> L;16B, e.g: \xff77 -> \xff\x00\x77\x00 */ 49539: 227: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49154: 228: out[0] = in[i]; 49154: 229: out[1] = 0; 49154: 230: out += 2; -: 231: } 385: 232:} -: 233: -: 234: -: 235:static void function packLA called 14830 returned 100% blocks executed 100% 14830: 236:packLA(UINT8* out, const UINT8* in, int pixels) -: 237:{ -: 238: int i; -: 239: /* LA, pixel interleaved */ 1848858: 240: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1834028: 241: out[0] = in[R]; 1834028: 242: out[1] = in[A]; 1834028: 243: out += 2; in += 4; -: 244: } 14830: 245:} -: 246: -: 247:static void function packLAL called 130 returned 100% blocks executed 100% 130: 248:packLAL(UINT8* out, const UINT8* in, int pixels) -: 249:{ -: 250: int i; -: 251: /* LA, line interleaved */ 16520: 252: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16390: 253: out[i] = in[R]; 16390: 254: out[i+pixels] = in[A]; 16390: 255: in += 4; -: 256: } 130: 257:} -: 258: -: 259:void function ImagingPackRGB called 219200 returned 100% blocks executed 100% 219200: 260:ImagingPackRGB(UINT8* out, const UINT8* in, int pixels) -: 261:{ 219200: 262: int i = 0; -: 263: /* RGB triplets */ -: 264:#ifdef __sparc -: 265: /* SPARC CPUs cannot read integers from nonaligned addresses. */ -: 266: for (; i < pixels; i++) { -: 267: out[0] = in[R]; -: 268: out[1] = in[G]; -: 269: out[2] = in[B]; -: 270: out += 3; in += 4; -: 271: } -: 272:#else 235645210: 273: for (; i < pixels-1; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 470852020: 274: memcpy(out, in + i * 4, 4); 235426010: 275: out += 3; -: 276: } 219200: 277: for (; i < pixels; i++) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 219200: 278: out[0] = in[i*4+R]; 219200: 279: out[1] = in[i*4+G]; 219200: 280: out[2] = in[i*4+B]; 219200: 281: out += 3; -: 282: } -: 283:#endif 219200: 284:} -: 285: -: 286:void function ImagingPackXRGB called 1 returned 100% blocks executed 100% 1: 287:ImagingPackXRGB(UINT8* out, const UINT8* in, int pixels) -: 288:{ -: 289: int i; -: 290: /* XRGB, triplets with left padding */ 3: 291: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 292: out[0] = 0; 2: 293: out[1] = in[R]; 2: 294: out[2] = in[G]; 2: 295: out[3] = in[B]; 2: 296: out += 4; in += 4; -: 297: } 1: 298:} -: 299: -: 300:void function ImagingPackBGR called 1379 returned 100% blocks executed 100% 1379: 301:ImagingPackBGR(UINT8* out, const UINT8* in, int pixels) -: 302:{ -: 303: int i; -: 304: /* RGB, reversed bytes */ 208412: 305: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 207033: 306: out[0] = in[B]; 207033: 307: out[1] = in[G]; 207033: 308: out[2] = in[R]; 207033: 309: out += 3; in += 4; -: 310: } 1379: 311:} -: 312: -: 313:void function ImagingPackBGRX called 1550 returned 100% blocks executed 100% 1550: 314:ImagingPackBGRX(UINT8* out, const UINT8* in, int pixels) -: 315:{ -: 316: int i; -: 317: /* BGRX, reversed bytes with right padding */ 1081054: 318: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1079504: 319: out[0] = in[B]; 1079504: 320: out[1] = in[G]; 1079504: 321: out[2] = in[R]; 1079504: 322: out[3] = 0; 1079504: 323: out += 4; in += 4; -: 324: } 1550: 325:} -: 326: -: 327:void function ImagingPackXBGR called 2 returned 100% blocks executed 100% 2: 328:ImagingPackXBGR(UINT8* out, const UINT8* in, int pixels) -: 329:{ -: 330: int i; -: 331: /* XBGR, reversed bytes with left padding */ 7: 332: for (i = 0; i < pixels; i++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 5: 333: out[0] = 0; 5: 334: out[1] = in[B]; 5: 335: out[2] = in[G]; 5: 336: out[3] = in[R]; 5: 337: out += 4; in += 4; -: 338: } 2: 339:} -: 340: -: 341:void function ImagingPackBGRA called 2746 returned 100% blocks executed 100% 2746: 342:ImagingPackBGRA(UINT8* out, const UINT8* in, int pixels) -: 343:{ -: 344: int i; -: 345: /* BGRX, reversed bytes with right padding */ 468466: 346: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 465720: 347: out[0] = in[B]; 465720: 348: out[1] = in[G]; 465720: 349: out[2] = in[R]; 465720: 350: out[3] = in[A]; 465720: 351: out += 4; in += 4; -: 352: } 2746: 353:} -: 354: -: 355:void function ImagingPackABGR called 2 returned 100% blocks executed 100% 2: 356:ImagingPackABGR(UINT8* out, const UINT8* in, int pixels) -: 357:{ -: 358: int i; -: 359: /* XBGR, reversed bytes with left padding */ 8: 360: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 361: out[0] = in[A]; 6: 362: out[1] = in[B]; 6: 363: out[2] = in[G]; 6: 364: out[3] = in[R]; 6: 365: out += 4; in += 4; -: 366: } 2: 367:} -: 368: -: 369:void function ImagingPackBGRa called 1 returned 100% blocks executed 100% 1: 370:ImagingPackBGRa(UINT8* out, const UINT8* in, int pixels) -: 371:{ -: 372: int i; -: 373: /* BGRa, reversed bytes with premultiplied alpha */ 4: 374: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 375: int alpha = out[3] = in[A]; -: 376: int tmp; 3: 377: out[0] = MULDIV255(in[B], alpha, tmp); 3: 378: out[1] = MULDIV255(in[G], alpha, tmp); 3: 379: out[2] = MULDIV255(in[R], alpha, tmp); 3: 380: out += 4; in += 4; -: 381: } 1: 382:} -: 383: -: 384:static void function packRGBL called 1035 returned 100% blocks executed 100% 1035: 385:packRGBL(UINT8* out, const UINT8* in, int pixels) -: 386:{ -: 387: int i; -: 388: /* RGB, line interleaved */ 330258: 389: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 329223: 390: out[i] = in[R]; 329223: 391: out[i+pixels] = in[G]; 329223: 392: out[i+pixels+pixels] = in[B]; 329223: 393: in += 4; -: 394: } 1035: 395:} -: 396: -: 397:static void function packRGBXL called 3 returned 100% blocks executed 100% 3: 398:packRGBXL(UINT8* out, const UINT8* in, int pixels) -: 399:{ -: 400: int i; -: 401: /* RGBX, line interleaved */ 12: 402: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 9: 403: out[i] = in[R]; 9: 404: out[i+pixels] = in[G]; 9: 405: out[i+pixels+pixels] = in[B]; 9: 406: out[i+pixels+pixels+pixels] = in[X]; 9: 407: in += 4; -: 408: } 3: 409:} -: 410: -: 411:static void function packI16B called 293 returned 100% blocks executed 89% 293: 412:packI16B(UINT8* out, const UINT8* in_, int pixels) -: 413:{ -: 414: int i; -: 415: UINT16 tmp_; 293: 416: UINT8* tmp = (UINT8*) &tmp_; 22775: 417: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 418: INT32 in; 22482: 419: memcpy(&in, in_, sizeof(in)); 22482: 420: if (in <= 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 75: 421: tmp_ = 0; 22407: 422: } else if (in > 65535) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 423: tmp_ = 65535; -: 424: } else { 22407: 425: tmp_ = in; -: 426: } 22482: 427: C16B; 22482: 428: out += 2; in_ += sizeof(in); -: 429: } 293: 430:} -: 431: -: 432:static void function packI16N_I16B called 320 returned 100% blocks executed 100% 320: 433:packI16N_I16B(UINT8* out, const UINT8* in, int pixels){ -: 434: int i; 320: 435: UINT8* tmp = (UINT8*) in; 37184: 436: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 36864: 437: C16B; 36864: 438: out += 2; tmp += 2; -: 439: } -: 440: 320: 441:} -: 442:static void function packI16N_I16 called 64 returned 100% blocks executed 100% 64: 443:packI16N_I16(UINT8* out, const UINT8* in, int pixels){ -: 444: int i; 64: 445: UINT8* tmp = (UINT8*) in; 4160: 446: for (i = 0; i < pixels; i++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 4096: 447: C16L; 4096: 448: out += 2; tmp += 2; -: 449: } 64: 450:} -: 451: -: 452: -: 453:static void function packI32S called 290 returned 100% blocks executed 100% 290: 454:packI32S(UINT8* out, const UINT8* in, int pixels) -: 455:{ -: 456: int i; 290: 457: UINT8* tmp = (UINT8*) in; 34086: 458: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 33796: 459: C32L; 33796: 460: out += 4; tmp += 4; -: 461: } 290: 462:} -: 463: -: 464:void function ImagingPackLAB called 1025 returned 100% blocks executed 100% 1025: 465:ImagingPackLAB(UINT8* out, const UINT8* in, int pixels) -: 466:{ -: 467: int i; -: 468: /* LAB triplets */ 132100: 469: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 131075: 470: out[0] = in[0]; 131075: 471: out[1] = in[1] ^ 128; /* signed in outside world */ 131075: 472: out[2] = in[2] ^ 128; 131075: 473: out += 3; in += 4; -: 474: } 1025: 475:} -: 476: -: 477:static void function copy1 called 221941 returned 100% blocks executed 100% 221941: 478:copy1(UINT8* out, const UINT8* in, int pixels) -: 479:{ -: 480: /* L, P */ 443882: 481: memcpy(out, in, pixels); 221941: 482:} -: 483: -: 484:static void function copy2 called 8449 returned 100% blocks executed 100% 8449: 485:copy2(UINT8* out, const UINT8* in, int pixels) -: 486:{ -: 487: /* I;16, etc */ 16898: 488: memcpy(out, in, pixels*2); 8449: 489:} -: 490: -: 491:static void function copy3 called 0 returned 0% blocks executed 0% #####: 492:copy3(UINT8* out, const UINT8* in, int pixels) -: 493:{ -: 494: /* BGR;24, etc */ #####: 495: memcpy(out, in, pixels*3); #####: 496:} -: 497: -: 498:static void function copy4 called 77688 returned 100% blocks executed 100% 77688: 499:copy4(UINT8* out, const UINT8* in, int pixels) -: 500:{ -: 501: /* RGBA, CMYK quadruples */ 155376: 502: memcpy(out, in, 4*pixels); 77688: 503:} -: 504: -: 505:static void function copy4I called 2189 returned 100% blocks executed 100% 2189: 506:copy4I(UINT8* out, const UINT8* in, int pixels) -: 507:{ -: 508: /* RGBA, CMYK quadruples, inverted */ -: 509: int i; 1022553: 510: for (i = 0; i < pixels*4; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1020364: 511: out[i] = ~in[i]; -: 512: } 2189: 513:} -: 514: -: 515:static void function band0 called 6 returned 100% blocks executed 100% 6: 516:band0(UINT8* out, const UINT8* in, int pixels) -: 517:{ -: 518: int i; 24: 519: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 18: 520: out[i] = in[0]; -: 521: } 6: 522:} -: 523: -: 524:static void function band1 called 6 returned 100% blocks executed 100% 6: 525:band1(UINT8* out, const UINT8* in, int pixels) -: 526:{ -: 527: int i; 24: 528: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 18: 529: out[i] = in[1]; -: 530: } 6: 531:} -: 532: -: 533:static void function band2 called 6 returned 100% blocks executed 100% 6: 534:band2(UINT8* out, const UINT8* in, int pixels) -: 535:{ -: 536: int i; 24: 537: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 18: 538: out[i] = in[2]; -: 539: } 6: 540:} -: 541: -: 542:static void function band3 called 5 returned 100% blocks executed 100% 5: 543:band3(UINT8* out, const UINT8* in, int pixels) -: 544:{ -: 545: int i; 526: 546: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 521: 547: out[i] = in[3]; -: 548: } 5: 549:} -: 550: -: 551:static struct { -: 552: const char* mode; -: 553: const char* rawmode; -: 554: int bits; -: 555: ImagingShuffler pack; -: 556:} packers[] = { -: 557: -: 558: /* bilevel */ -: 559: {"1", "1", 1, pack1}, -: 560: {"1", "1;I", 1, pack1I}, -: 561: {"1", "1;R", 1, pack1R}, -: 562: {"1", "1;IR", 1, pack1IR}, -: 563: {"1", "L", 8, pack1L}, -: 564: -: 565: /* greyscale */ -: 566: {"L", "L", 8, copy1}, -: 567: {"L", "L;16", 16, packL16}, -: 568: {"L", "L;16B", 16, packL16B}, -: 569: -: 570: /* greyscale w. alpha */ -: 571: {"LA", "LA", 16, packLA}, -: 572: {"LA", "LA;L", 16, packLAL}, -: 573: -: 574: /* greyscale w. alpha premultiplied */ -: 575: {"La", "La", 16, packLA}, -: 576: -: 577: /* palette */ -: 578: {"P", "P;1", 1, pack1}, -: 579: {"P", "P;2", 2, packP2}, -: 580: {"P", "P;4", 4, packP4}, -: 581: {"P", "P", 8, copy1}, -: 582: -: 583: /* palette w. alpha */ -: 584: {"PA", "PA", 16, packLA}, -: 585: {"PA", "PA;L", 16, packLAL}, -: 586: -: 587: /* true colour */ -: 588: {"RGB", "RGB", 24, ImagingPackRGB}, -: 589: {"RGB", "RGBX", 32, copy4}, -: 590: {"RGB", "XRGB", 32, ImagingPackXRGB}, -: 591: {"RGB", "BGR", 24, ImagingPackBGR}, -: 592: {"RGB", "BGRX", 32, ImagingPackBGRX}, -: 593: {"RGB", "XBGR", 32, ImagingPackXBGR}, -: 594: {"RGB", "RGB;L", 24, packRGBL}, -: 595: {"RGB", "R", 8, band0}, -: 596: {"RGB", "G", 8, band1}, -: 597: {"RGB", "B", 8, band2}, -: 598: -: 599: /* true colour w. alpha */ -: 600: {"RGBA", "RGBA", 32, copy4}, -: 601: {"RGBA", "RGBA;L", 32, packRGBXL}, -: 602: {"RGBA", "RGB", 24, ImagingPackRGB}, -: 603: {"RGBA", "BGR", 24, ImagingPackBGR}, -: 604: {"RGBA", "BGRA", 32, ImagingPackBGRA}, -: 605: {"RGBA", "ABGR", 32, ImagingPackABGR}, -: 606: {"RGBA", "BGRa", 32, ImagingPackBGRa}, -: 607: {"RGBA", "R", 8, band0}, -: 608: {"RGBA", "G", 8, band1}, -: 609: {"RGBA", "B", 8, band2}, -: 610: {"RGBA", "A", 8, band3}, -: 611: -: 612: /* true colour w. alpha premultiplied */ -: 613: {"RGBa", "RGBa", 32, copy4}, -: 614: {"RGBa", "BGRa", 32, ImagingPackBGRA}, -: 615: {"RGBa", "aBGR", 32, ImagingPackABGR}, -: 616: -: 617: /* true colour w. padding */ -: 618: {"RGBX", "RGBX", 32, copy4}, -: 619: {"RGBX", "RGBX;L", 32, packRGBXL}, -: 620: {"RGBX", "RGB", 24, ImagingPackRGB}, -: 621: {"RGBX", "BGR", 24, ImagingPackBGR}, -: 622: {"RGBX", "BGRX", 32, ImagingPackBGRX}, -: 623: {"RGBX", "XBGR", 32, ImagingPackXBGR}, -: 624: {"RGBX", "R", 8, band0}, -: 625: {"RGBX", "G", 8, band1}, -: 626: {"RGBX", "B", 8, band2}, -: 627: {"RGBX", "X", 8, band3}, -: 628: -: 629: /* colour separation */ -: 630: {"CMYK", "CMYK", 32, copy4}, -: 631: {"CMYK", "CMYK;I", 32, copy4I}, -: 632: {"CMYK", "CMYK;L", 32, packRGBXL}, -: 633: {"CMYK", "C", 8, band0}, -: 634: {"CMYK", "M", 8, band1}, -: 635: {"CMYK", "Y", 8, band2}, -: 636: {"CMYK", "K", 8, band3}, -: 637: -: 638: /* video (YCbCr) */ -: 639: {"YCbCr", "YCbCr", 24, ImagingPackRGB}, -: 640: {"YCbCr", "YCbCr;L", 24, packRGBL}, -: 641: {"YCbCr", "YCbCrX", 32, copy4}, -: 642: {"YCbCr", "YCbCrK", 32, copy4}, -: 643: {"YCbCr", "Y", 8, band0}, -: 644: {"YCbCr", "Cb", 8, band1}, -: 645: {"YCbCr", "Cr", 8, band2}, -: 646: -: 647: /* LAB Color */ -: 648: {"LAB", "LAB", 24, ImagingPackLAB}, -: 649: {"LAB", "L", 8, band0}, -: 650: {"LAB", "A", 8, band1}, -: 651: {"LAB", "B", 8, band2}, -: 652: -: 653: /* HSV */ -: 654: {"HSV", "HSV", 24, ImagingPackRGB}, -: 655: {"HSV", "H", 8, band0}, -: 656: {"HSV", "S", 8, band1}, -: 657: {"HSV", "V", 8, band2}, -: 658: -: 659: /* integer */ -: 660: {"I", "I", 32, copy4}, -: 661: {"I", "I;16B", 16, packI16B}, -: 662: {"I", "I;32S", 32, packI32S}, -: 663: {"I", "I;32NS", 32, copy4}, -: 664: -: 665: /* floating point */ -: 666: {"F", "F", 32, copy4}, -: 667: {"F", "F;32F", 32, packI32S}, -: 668: {"F", "F;32NF", 32, copy4}, -: 669: -: 670: /* storage modes */ -: 671: {"I;16", "I;16", 16, copy2}, -: 672: {"I;16", "I;16B", 16, packI16N_I16B}, -: 673: {"I;16B", "I;16B", 16, copy2}, -: 674: {"I;16L", "I;16L", 16, copy2}, -: 675: {"I;16", "I;16N", 16, packI16N_I16}, // LibTiff native->image endian. -: 676: {"I;16L", "I;16N", 16, packI16N_I16}, -: 677: {"I;16B", "I;16N", 16, packI16N_I16B}, -: 678: {"BGR;15", "BGR;15", 16, copy2}, -: 679: {"BGR;16", "BGR;16", 16, copy2}, -: 680: {"BGR;24", "BGR;24", 24, copy3}, -: 681: -: 682: {NULL} /* sentinel */ -: 683:}; -: 684: -: 685: -: 686:ImagingShuffler function ImagingFindPacker called 4410 returned 100% blocks executed 100% 4410: 687:ImagingFindPacker(const char* mode, const char* rawmode, int* bits_out) -: 688:{ -: 689: int i; -: 690: -: 691: /* find a suitable pixel packer */ 79382: 692: for (i = 0; packers[i].rawmode; i++) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 86314: 693: if (strcmp(packers[i].mode, mode) == 0 && branch 0 taken 9% (fallthrough) branch 1 taken 91% branch 2 taken 64% (fallthrough) branch 3 taken 36% 6932: 694: strcmp(packers[i].rawmode, rawmode) == 0) { 4410: 695: if (bits_out) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 4410: 696: *bits_out = packers[i].bits; -: 697: } 4410: 698: return packers[i].pack; -: 699: } -: 700: } -: 701: return NULL; -: 702:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#QuantPngQuant.c.gcov -: 0:Source:src/libImaging/QuantPngQuant.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/QuantPngQuant.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-x86_64-3.9/src/libImaging/QuantPngQuant.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * quantization using libimagequant, a part of pngquant. -: 6: * -: 7: * Copyright (c) 2016 Marcin Kurczewski -: 8: * -: 9: */ -: 10: -: 11:#include -: 12:#include -: 13:#include -: 14: -: 15:#include "QuantPngQuant.h" -: 16: -: 17:#ifdef HAVE_LIBIMAGEQUANT -: 18:#include "libimagequant.h" -: 19: -: 20:int function quantize_pngquant called 1 returned 100% blocks executed 97% 1: 21:quantize_pngquant( -: 22: Pixel *pixelData, -: 23: unsigned int width, -: 24: unsigned int height, -: 25: uint32_t quantPixels, -: 26: Pixel **palette, -: 27: uint32_t *paletteLength, -: 28: uint32_t **quantizedPixels, -: 29: int withAlpha) -: 30:{ 1: 31: int result = 0; 1: 32: liq_image *image = NULL; 1: 33: liq_attr *attr = NULL; 1: 34: liq_result *remap = NULL; 1: 35: unsigned char *charMatrix = NULL; 1: 36: unsigned char **charMatrixRows = NULL; -: 37: unsigned int i, y; 1: 38: *palette = NULL; 1: 39: *paletteLength = 0; 1: 40: *quantizedPixels = NULL; -: 41: -: 42: /* configure pngquant */ 1: 43: attr = liq_attr_create(); call 0 returned 100% 1: 44: if (!attr) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 45: if (quantPixels) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 46: liq_set_max_colors(attr, quantPixels); call 0 returned 100% -: 47: } -: 48: -: 49: /* prepare input image */ 1: 50: image = liq_image_create_rgba( call 0 returned 100% -: 51: attr, -: 52: pixelData, -: 53: width, -: 54: height, -: 55: 0.45455 /* gamma */); 1: 56: if (!image) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 57: -: 58: /* quantize the image */ 1: 59: remap = liq_quantize_image(attr, image); call 0 returned 100% 1: 60: if (!remap) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 61: liq_set_output_gamma(remap, 0.45455); call 0 returned 100% 1: 62: liq_set_dithering_level(remap, 1); call 0 returned 100% -: 63: -: 64: /* write output palette */ 1: 65: const liq_palette *l_palette = liq_get_palette(remap); call 0 returned 100% 1: 66: *paletteLength = l_palette->count; 1: 67: *palette = malloc(sizeof(Pixel) * l_palette->count); 1: 68: if (!*palette) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 100: 69: for (i = 0; i < l_palette->count; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 100: 70: (*palette)[i].c.b = l_palette->entries[i].b; 100: 71: (*palette)[i].c.g = l_palette->entries[i].g; 100: 72: (*palette)[i].c.r = l_palette->entries[i].r; 100: 73: (*palette)[i].c.a = l_palette->entries[i].a; -: 74: } -: 75: -: 76: /* write output pixels (pngquant uses char array) */ 1: 77: charMatrix = malloc(width * height); 1: 78: if (!charMatrix) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 79: charMatrixRows = malloc(height * sizeof(unsigned char*)); 1: 80: if (!charMatrixRows) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 128: 81: for (y = 0; y < height; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 128: 82: charMatrixRows[y] = &charMatrix[y * width]; -: 83: } 1: 84: if (LIQ_OK != liq_write_remapped_image_rows(remap, image, charMatrixRows)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 85: goto err; -: 86: } -: 87: -: 88: /* transcribe output pixels (pillow uses uint32_t array) */ 1: 89: *quantizedPixels = malloc(sizeof(uint32_t) * width * height); 1: 90: if (!*quantizedPixels) { goto err; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 16384: 91: for (i = 0; i < width * height; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 92: (*quantizedPixels)[i] = charMatrix[i]; -: 93: } -: 94: -: 95: result = 1; -: 96: -: 97:err: 1: 98: if (attr) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 99: liq_attr_destroy(attr); call 0 returned 100% -: 100: } 1: 101: if (image) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 102: liq_image_destroy(image); call 0 returned 100% -: 103: } 1: 104: if (remap) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 105: liq_result_destroy(remap); call 0 returned 100% -: 106: } 1: 107: free(charMatrix); 1: 108: free(charMatrixRows); 1: 109: if (!result) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 110: free(*quantizedPixels); #####: 111: free(*palette); -: 112: } 1: 113: return result; -: 114:} -: 115: -: 116:const char* function ImagingImageQuantVersion called 3 returned 100% blocks executed 100% 3: 117:ImagingImageQuantVersion(void) -: 118:{ -: 119: static char version[20]; 3: 120: int number = liq_version(); call 0 returned 100% 6: 121: sprintf(version, "%d.%d.%d", number / 10000, (number / 100) % 100, number % 100); 3: 122: return version; -: 123:} -: 124: -: 125:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/coverage.xml /home/travis/build/python-pillow/Pillow