TRAVIS_PYTHON_VERSION=3.8 TRAVIS_OS_NAME=linux <<<<<< 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#Offset.c.gcov -: 0:Source:src/libImaging/Offset.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Offset.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/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#XbmEncode.c.gcov -: 0:Source:src/libImaging/XbmEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/XbmEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/XbmEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * encoder for Xbm data -: 6: * -: 7: * history: -: 8: * 96-11-01 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: -: 20:int function ImagingXbmEncode called 13 returned 100% blocks executed 96% 13: 21:ImagingXbmEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 22:{ 13: 23: const char *hex = "0123456789abcdef"; -: 24: 13: 25: UINT8* ptr = buf; -: 26: int i, n; -: 27: 13: 28: if (!state->state) { branch 0 taken 31% (fallthrough) branch 1 taken 69% -: 29: -: 30: /* 8 pixels are stored in no more than 6 bytes */ 4: 31: state->bytes = 6*(state->xsize+7)/8; -: 32: 4: 33: state->state = 1; -: 34: -: 35: } -: 36: 13: 37: if (bytes < state->bytes) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 38: state->errcode = IMAGING_CODEC_MEMORY; #####: 39: return 0; -: 40: } -: 41: -: 42: ptr = buf; -: 43: 1393: 44: while (bytes >= state->bytes) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 45: 2768: 46: state->shuffle(state->buffer, call 0 returned 100% 1384: 47: (UINT8*) im->image[state->y + state->yoff] + 1384: 48: state->xoff * im->pixelsize, state->xsize); -: 49: 1384: 50: if (state->y < state->ysize-1) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 51: -: 52: /* any line but the last */ 130971: 53: for (n = 0; n < state->xsize; n += 8) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 54: 130971: 55: i = state->buffer[n/8]; -: 56: 130971: 57: *ptr++ = '0'; 130971: 58: *ptr++ = 'x'; 130971: 59: *ptr++ = hex[(i>>4)&15]; 130971: 60: *ptr++ = hex[i&15]; 130971: 61: *ptr++ = ','; 130971: 62: bytes -= 5; -: 63: 130971: 64: if (++state->count >= 79/5) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 8730: 65: *ptr++ = '\n'; 8730: 66: bytes--; 8730: 67: state->count = 0; -: 68: } -: 69: -: 70: } -: 71: 1380: 72: state->y++; -: 73: -: 74: } else { -: 75: -: 76: /* last line */ 173: 77: for (n = 0; n < state->xsize; n += 8) { branch 0 taken 98% branch 1 taken 2% (fallthrough) -: 78: 173: 79: i = state->buffer[n/8]; -: 80: 173: 81: *ptr++ = '0'; 173: 82: *ptr++ = 'x'; 173: 83: *ptr++ = hex[(i>>4)&15]; 173: 84: *ptr++ = hex[i&15]; -: 85: 173: 86: if (n < state->xsize-8) { branch 0 taken 98% (fallthrough) branch 1 taken 2% 169: 87: *ptr++ = ','; 169: 88: if (++state->count >= 79/5) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 11: 89: *ptr++ = '\n'; 11: 90: bytes--; 11: 91: state->count = 0; -: 92: } -: 93: } else { 4: 94: *ptr++ = '\n'; -: 95: } -: 96: 173: 97: bytes -= 5; -: 98: -: 99: } -: 100: 4: 101: state->errcode = IMAGING_CODEC_END; 4: 102: break; -: 103: } -: 104: } -: 105: 13: 106: return ptr - buf; -: 107:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ImagingUtils.h.gcov -: 0:Source:src/libImaging/ImagingUtils.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Filter.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Filter.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#ifdef WORDS_BIGENDIAN -: 2: #define MAKE_UINT32(u0, u1, u2, u3) ((UINT32)(u3) | ((UINT32)(u2)<<8) | ((UINT32)(u1)<<16) | ((UINT32)(u0)<<24)) -: 3: #define MASK_UINT32_CHANNEL_0 0xff000000 -: 4: #define MASK_UINT32_CHANNEL_1 0x00ff0000 -: 5: #define MASK_UINT32_CHANNEL_2 0x0000ff00 -: 6: #define MASK_UINT32_CHANNEL_3 0x000000ff -: 7:#else -: 8: #define MAKE_UINT32(u0, u1, u2, u3) ((UINT32)(u0) | ((UINT32)(u1)<<8) | ((UINT32)(u2)<<16) | ((UINT32)(u3)<<24)) -: 9: #define MASK_UINT32_CHANNEL_0 0x000000ff -: 10: #define MASK_UINT32_CHANNEL_1 0x0000ff00 -: 11: #define MASK_UINT32_CHANNEL_2 0x00ff0000 -: 12: #define MASK_UINT32_CHANNEL_3 0xff000000 -: 13:#endif -: 14: -: 15: -: 16:#define SHIFTFORDIV255(a)\ -: 17: ((((a) >> 8) + a) >> 8) -: 18: -: 19:/* like (a * b + 127) / 255), but much faster on most platforms */ -: 20:#define MULDIV255(a, b, tmp)\ -: 21: (tmp = (a) * (b) + 128, SHIFTFORDIV255(tmp)) -: 22: -: 23:#define DIV255(a, tmp)\ -: 24: (tmp = (a) + 128, SHIFTFORDIV255(tmp)) -: 25: -: 26:#define BLEND(mask, in1, in2, tmp1)\ -: 27: DIV255(in1 * (255 - mask) + in2 * mask, tmp1) -: 28: -: 29:#define PREBLEND(mask, in1, in2, tmp1)\ -: 30: (MULDIV255(in1, (255 - mask), tmp1) + in2) -: 31: -: 32: -: 33:#define CLIP8(v) ((v) <= 0 ? 0 : (v) < 256 ? (v) : 255) -: 34: -: 35:/* This is to work around a bug in GCC prior 4.9 in 64 bit mode. -: 36: GCC generates code with partial dependency which is 3 times slower. -: 37: See: http://stackoverflow.com/a/26588074/253146 */ -: 38:#if defined(__x86_64__) && defined(__SSE__) && ! defined(__NO_INLINE__) && \ -: 39: ! defined(__clang__) && defined(GCC_VERSION) && (GCC_VERSION < 40900) -: 40:static float __attribute__((always_inline)) inline _i2f(int v) { -: 41: float x; -: 42: __asm__("xorps %0, %0; cvtsi2ss %1, %0" : "=x"(x) : "r"(v) ); -: 43: return x; -: 44:} -: 45:#else 23864303: 46:static float inline _i2f(int v) { return (float) v; } -: 47:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Paste.c.gcov -: 0:Source:src/libImaging/Paste.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Paste.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Paste.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * paste image on another image -: 6: * -: 7: * history: -: 8: * 96-03-27 fl Created -: 9: * 96-07-16 fl Support "1", "L" and "RGBA" masks -: 10: * 96-08-16 fl Merged with opaque paste -: 11: * 97-01-17 fl Faster blending, added support for RGBa images -: 12: * 97-08-27 fl Faster masking for 32-bit images -: 13: * 98-02-02 fl Fixed MULDIV255 macro for gcc -: 14: * 99-02-02 fl Added "RGBa" mask support -: 15: * 99-02-06 fl Rewritten. Added support for masked fill operations. -: 16: * 99-12-08 fl Fixed matte fill. -: 17: * -: 18: * Copyright (c) Fredrik Lundh 1996-97. -: 19: * Copyright (c) Secret Labs AB 1997-99. -: 20: * -: 21: * See the README file for information on usage and redistribution. -: 22: */ -: 23: -: 24:#include "Imaging.h" -: 25: -: 26: -: 27:static inline void function paste.isra.0 called 2066665 returned 100% blocks executed 100% 2066665: 28:paste(Imaging imOut, Imaging imIn, int dx, int dy, int sx, int sy, -: 29: int xsize, int ysize, int pixelsize) -: 30:{ -: 31: /* paste opaque region */ -: 32: -: 33: int y; -: 34: 2066665: 35: dx *= pixelsize; 2066665: 36: sx *= pixelsize; -: 37: 2066665: 38: xsize *= pixelsize; -: 39: 11845416: 40: for (y = 0; y < ysize; y++) { branch 0 taken 83% branch 1 taken 17% (fallthrough) 19557502: 41: memcpy(imOut->image[y+dy]+dx, imIn->image[y+sy]+sx, xsize); -: 42: } 2066665: 43:} -: 44: -: 45:static inline void function paste_mask_1.isra.1 called 6 returned 100% blocks executed 100% 6: 46:paste_mask_1(Imaging imOut, Imaging imIn, Imaging imMask, -: 47: int dx, int dy, int sx, int sy, -: 48: int xsize, int ysize, int pixelsize) -: 49:{ -: 50: /* paste with mode "1" mask */ -: 51: -: 52: int x, y; -: 53: 6: 54: if (imOut->image8) { branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 55: 256: 56: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 256: 57: UINT8* out = imOut->image8[y+dy]+dx; 256: 58: UINT8* in = imIn->image8[y+sy]+sx; 256: 59: UINT8* mask = imMask->image8[y+sy]+sx; 33024: 60: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 61: if (*mask++) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 16384: 62: *out = *in; -: 63: } 32768: 64: out++, in++; -: 65: } -: 66: } -: 67: -: 68: } else { -: 69: 512: 70: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 512: 71: INT32* out = imOut->image32[y+dy]+dx; 512: 72: INT32* in = imIn->image32[y+sy]+sx; 512: 73: UINT8* mask = imMask->image8[y+sy]+sx; 66048: 74: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 65536: 75: if (*mask++) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 32768: 76: *out = *in; -: 77: } 65536: 78: out++, in++; -: 79: } -: 80: } -: 81: } 6: 82:} -: 83: -: 84:static inline void function paste_mask_L.isra.2 called 11 returned 100% blocks executed 100% 11: 85:paste_mask_L(Imaging imOut, Imaging imIn, Imaging imMask, -: 86: int dx, int dy, int sx, int sy, -: 87: int xsize, int ysize, int pixelsize) -: 88:{ -: 89: /* paste with mode "L" matte */ -: 90: -: 91: int x, y; -: 92: unsigned int tmp1; -: 93: 11: 94: if (imOut->image8) { branch 0 taken 73% (fallthrough) branch 1 taken 27% -: 95: 384: 96: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 384: 97: UINT8* out = imOut->image8[y+dy]+dx; 384: 98: UINT8* in = imIn->image8[y+sy]+sx; 384: 99: UINT8* mask = imMask->image8[y+sy]+sx; 49536: 100: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49152: 101: *out = BLEND(*mask, *out, *in, tmp1); 49152: 102: out++, in++, mask++; -: 103: } -: 104: } -: 105: -: 106: } else { -: 107: 818: 108: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 818: 109: UINT8* out = (UINT8*) (imOut->image32[y + dy] + dx); 818: 110: UINT8* in = (UINT8*) (imIn->image32[y + sy] + sx); 818: 111: UINT8* mask = (UINT8*) (imMask->image8[y+sy] + sx); 115570: 112: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 114752: 113: UINT8 a = mask[0]; 114752: 114: out[0] = BLEND(a, out[0], in[0], tmp1); 114752: 115: out[1] = BLEND(a, out[1], in[1], tmp1); 114752: 116: out[2] = BLEND(a, out[2], in[2], tmp1); 114752: 117: out[3] = BLEND(a, out[3], in[3], tmp1); 114752: 118: out += 4; in += 4; mask ++; -: 119: } -: 120: } -: 121: } 11: 122:} -: 123: -: 124:static inline void function paste_mask_RGBA.isra.3 called 506 returned 100% blocks executed 100% 506: 125:paste_mask_RGBA(Imaging imOut, Imaging imIn, Imaging imMask, -: 126: int dx, int dy, int sx, int sy, -: 127: int xsize, int ysize, int pixelsize) -: 128:{ -: 129: /* paste with mode "RGBA" matte */ -: 130: -: 131: int x, y; -: 132: unsigned int tmp1; -: 133: 506: 134: if (imOut->image8) { branch 0 taken 40% (fallthrough) branch 1 taken 60% -: 135: 62430: 136: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 62430: 137: UINT8* out = imOut->image8[y+dy]+dx; 62430: 138: UINT8* in = imIn->image8[y+sy]+sx; 62430: 139: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx*4+3; 15242356: 140: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 15179926: 141: *out = BLEND(*mask, *out, *in, tmp1); 15179926: 142: out++, in++, mask += 4; -: 143: } -: 144: } -: 145: -: 146: } else { -: 147: 12664: 148: for (y = 0; y < ysize; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 12664: 149: UINT8* out = (UINT8*) (imOut->image32[y + dy] + dx); 12664: 150: UINT8* in = (UINT8*) (imIn->image32[y + sy] + sx); 12664: 151: UINT8* mask = (UINT8*) (imMask->image32[y+sy] + sx); 1100956: 152: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1088292: 153: UINT8 a = mask[3]; 1088292: 154: out[0] = BLEND(a, out[0], in[0], tmp1); 1088292: 155: out[1] = BLEND(a, out[1], in[1], tmp1); 1088292: 156: out[2] = BLEND(a, out[2], in[2], tmp1); 1088292: 157: out[3] = BLEND(a, out[3], in[3], tmp1); 1088292: 158: out += 4; in += 4; mask += 4; -: 159: } -: 160: } -: 161: } 506: 162:} -: 163: -: 164: -: 165:static inline void function paste_mask_RGBa.isra.4 called 6 returned 100% blocks executed 100% 6: 166:paste_mask_RGBa(Imaging imOut, Imaging imIn, Imaging imMask, -: 167: int dx, int dy, int sx, int sy, -: 168: int xsize, int ysize, int pixelsize) -: 169:{ -: 170: /* paste with mode "RGBa" matte */ -: 171: -: 172: int x, y; -: 173: unsigned int tmp1; -: 174: 6: 175: if (imOut->image8) { branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 176: 256: 177: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 256: 178: UINT8* out = imOut->image8[y+dy]+dx; 256: 179: UINT8* in = imIn->image8[y+sy]+sx; 256: 180: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx*4+3; 33024: 181: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 182: *out = PREBLEND(*mask, *out, *in, tmp1); 32768: 183: out++, in++, mask += 4; -: 184: } -: 185: } -: 186: -: 187: } else { -: 188: 512: 189: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 512: 190: UINT8* out = (UINT8*) (imOut->image32[y + dy] + dx); 512: 191: UINT8* in = (UINT8*) (imIn->image32[y + sy] + sx); 512: 192: UINT8* mask = (UINT8*) (imMask->image32[y+sy] + sx); 66048: 193: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 65536: 194: UINT8 a = mask[3]; 65536: 195: out[0] = PREBLEND(a, out[0], in[0], tmp1); 65536: 196: out[1] = PREBLEND(a, out[1], in[1], tmp1); 65536: 197: out[2] = PREBLEND(a, out[2], in[2], tmp1); 65536: 198: out[3] = PREBLEND(a, out[3], in[3], tmp1); 65536: 199: out += 4; in += 4; mask += 4; -: 200: } -: 201: } -: 202: } 6: 203:} -: 204: -: 205:int function ImagingPaste called 2067369 returned 100% blocks executed 84% 2067369: 206:ImagingPaste(Imaging imOut, Imaging imIn, Imaging imMask, -: 207: int dx0, int dy0, int dx1, int dy1) -: 208:{ -: 209: int xsize, ysize; -: 210: int pixelsize; -: 211: int sx0, sy0; -: 212: ImagingSectionCookie cookie; -: 213: 2067369: 214: if (!imOut || !imIn) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 215: (void) ImagingError_ModeError(); call 0 never executed #####: 216: return -1; -: 217: } -: 218: 2067369: 219: pixelsize = imOut->pixelsize; -: 220: 2067369: 221: xsize = dx1 - dx0; 2067369: 222: ysize = dy1 - dy0; -: 223: 4134738: 224: if (xsize != imIn->xsize || ysize != imIn->ysize || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% 2067369: 225: pixelsize != imIn->pixelsize) { #####: 226: (void) ImagingError_Mismatch(); call 0 never executed #####: 227: return -1; -: 228: } -: 229: 2067369: 230: if (imMask && (xsize != imMask->xsize || ysize != imMask->ysize)) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 231: (void) ImagingError_Mismatch(); call 0 never executed #####: 232: return -1; -: 233: } -: 234: -: 235: /* Determine which region to copy */ 2067369: 236: sx0 = sy0 = 0; 2067369: 237: if (dx0 < 0) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 819888: 238: xsize += dx0, sx0 = -dx0, dx0 = 0; -: 239: } 2067369: 240: if (dx0 + xsize > imOut->xsize) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1024924: 241: xsize = imOut->xsize - dx0; -: 242: } 2067369: 243: if (dy0 < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 591: 244: ysize += dy0, sy0 = -dy0, dy0 = 0; -: 245: } 2067369: 246: if (dy0 + ysize > imOut->ysize) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1025015: 247: ysize = imOut->ysize - dy0; -: 248: } -: 249: 2067369: 250: if (xsize <= 0 || ysize <= 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% -: 251: return 0; -: 252: } -: 253: 2067194: 254: if (!imMask) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 2066665: 255: ImagingSectionEnter(&cookie); call 0 returned 100% 2066665: 256: paste(imOut, imIn, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); call 0 returned 100% 2066665: 257: ImagingSectionLeave(&cookie); call 0 returned 100% -: 258: 529: 259: } else if (strcmp(imMask->mode, "1") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 1% (fallthrough) branch 3 taken 99% 6: 260: ImagingSectionEnter(&cookie); call 0 returned 100% 6: 261: paste_mask_1(imOut, imIn, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 262: xsize, ysize, pixelsize); 6: 263: ImagingSectionLeave(&cookie); call 0 returned 100% -: 264: 523: 265: } else if (strcmp(imMask->mode, "L") == 0) { branch 0 taken 2% (fallthrough) branch 1 taken 98% branch 2 taken 2% (fallthrough) branch 3 taken 98% 11: 266: ImagingSectionEnter(&cookie); call 0 returned 100% 11: 267: paste_mask_L(imOut, imIn, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 268: xsize, ysize, pixelsize); 11: 269: ImagingSectionLeave(&cookie); call 0 returned 100% -: 270: 512: 271: } else if (strcmp(imMask->mode, "RGBA") == 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 506: 272: ImagingSectionEnter(&cookie); call 0 returned 100% 506: 273: paste_mask_RGBA(imOut, imIn, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 274: xsize, ysize, pixelsize); 506: 275: ImagingSectionLeave(&cookie); call 0 returned 100% -: 276: 6: 277: } else if (strcmp(imMask->mode, "RGBa") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 278: ImagingSectionEnter(&cookie); call 0 returned 100% 6: 279: paste_mask_RGBa(imOut, imIn, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 280: xsize, ysize, pixelsize); 6: 281: ImagingSectionLeave(&cookie); call 0 returned 100% -: 282: -: 283: } else { #####: 284: (void) ImagingError_ValueError("bad transparency mask"); call 0 never executed #####: 285: return -1; -: 286: } -: 287: -: 288: return 0; -: 289:} -: 290: -: 291:static inline void function fill called 58 returned 100% blocks executed 100% 58: 292:fill(Imaging imOut, const void* ink_, int dx, int dy, -: 293: int xsize, int ysize, int pixelsize) -: 294:{ -: 295: /* fill opaque region */ -: 296: -: 297: int x, y; 58: 298: UINT8 ink8 = 0; 58: 299: INT32 ink32 = 0L; -: 300: 116: 301: memcpy(&ink32, ink_, pixelsize); 58: 302: memcpy(&ink8, ink_, sizeof(ink8)); -: 303: 58: 304: if (imOut->image8 || ink32 == 0L) { branch 0 taken 90% (fallthrough) branch 1 taken 10% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 305: 6: 306: dx *= pixelsize; 6: 307: xsize *= pixelsize; 466: 308: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 920: 309: memset(imOut->image[y+dy]+dx, ink8, xsize); -: 310: } -: 311: -: 312: } else { -: 313: 4002: 314: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4002: 315: INT32* out = imOut->image32[y+dy]+dx; 328878: 316: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 324876: 317: out[x] = ink32; -: 318: } -: 319: } -: 320: -: 321: } 58: 322:} -: 323: -: 324:static inline void function fill_mask_1.isra.5 called 114 returned 100% blocks executed 100% 114: 325:fill_mask_1(Imaging imOut, const void* ink_, Imaging imMask, -: 326: int dx, int dy, int sx, int sy, -: 327: int xsize, int ysize, int pixelsize) -: 328:{ -: 329: /* fill with mode "1" mask */ -: 330: -: 331: int x, y; 114: 332: UINT8 ink8 = 0; 114: 333: INT32 ink32 = 0L; -: 334: 228: 335: memcpy(&ink32, ink_, pixelsize); 114: 336: memcpy(&ink8, ink_, sizeof(ink8)); -: 337: 114: 338: if (imOut->image8) { branch 0 taken 93% (fallthrough) branch 1 taken 7% -: 339: 376: 340: for (y = 0; y < ysize; y++) { branch 0 taken 98% branch 1 taken 2% 376: 341: UINT8* out = imOut->image8[y+dy]+dx; 376: 342: UINT8* mask = imMask->image8[y+sy]+sx; 72344: 343: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 71968: 344: if (*mask++) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 23781: 345: *out = ink8; -: 346: } 71968: 347: out++; -: 348: } -: 349: } -: 350: -: 351: } else { -: 352: 1634: 353: for (y = 0; y < ysize; y++) { branch 0 taken 94% branch 1 taken 6% (fallthrough) 1634: 354: INT32* out = imOut->image32[y+dy]+dx; 1634: 355: UINT8* mask = imMask->image8[y+sy]+sx; 353610: 356: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 351976: 357: if (*mask++) { branch 0 taken 28% (fallthrough) branch 1 taken 72% 100020: 358: *out = ink32; -: 359: } 351976: 360: out++; -: 361: } -: 362: } -: 363: } 114: 364:} -: 365: -: 366:static inline void function fill_mask_L.isra.8 called 245 returned 100% blocks executed 82% 245: 367:fill_mask_L(Imaging imOut, const UINT8* ink, Imaging imMask, -: 368: int dx, int dy, int sx, int sy, -: 369: int xsize, int ysize, int pixelsize) -: 370:{ -: 371: /* fill with mode "L" matte */ -: 372: -: 373: int x, y, i; -: 374: unsigned int tmp1; -: 375: 245: 376: if (imOut->image8) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 377: 266: 378: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 266: 379: UINT8* out = imOut->image8[y+dy]+dx; 266: 380: UINT8* mask = imMask->image8[y+sy]+sx; 33834: 381: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 33568: 382: *out = BLEND(*mask, *out, ink[0], tmp1); 33568: 383: out++, mask++; -: 384: } -: 385: } -: 386: -: 387: } else { -: 388: 10676: 389: for (y = 0; y < ysize; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 10676: 390: UINT8* out = (UINT8*) imOut->image[y+dy]+dx*pixelsize; 10676: 391: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx; 1025780: 392: for (x = 0; x < xsize; x++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 4060416: 393: for (i = 0; i < pixelsize; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 4060416: 394: UINT8 channel_mask = *mask; 4060416: 395: if (( branch 0 taken 100% (fallthrough) branch 1 taken 0% 8120832: 396: strcmp(imOut->mode, "RGBa") == 0 || branch 0 taken 96% (fallthrough) branch 1 taken 4% 7974784: 397: strcmp(imOut->mode, "RGBA") == 0 || branch 0 taken 100% (fallthrough) branch 1 taken 0% 7828736: 398: strcmp(imOut->mode, "La") == 0 || branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed branch 4 taken 100% (fallthrough) branch 5 taken 0% 7828736: 399: strcmp(imOut->mode, "LA") == 0 || branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed branch 4 taken 0% (fallthrough) branch 5 taken 100% 3914368: 400: strcmp(imOut->mode, "PA") == 0 branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed 146048: 401: ) && i != 3) { branch 0 taken 75% (fallthrough) branch 1 taken 25% 109536: 402: channel_mask = 255 - (255 - channel_mask) * (1 - (255 - out[3]) / 255); -: 403: } 4060416: 404: out[i] = BLEND(channel_mask, out[i], ink[i], tmp1); -: 405: } 1015104: 406: out += pixelsize; 1015104: 407: mask++; -: 408: } -: 409: } -: 410: } 245: 411:} -: 412: -: 413:static inline void function fill_mask_RGBA.isra.6 called 7 returned 100% blocks executed 100% 7: 414:fill_mask_RGBA(Imaging imOut, const UINT8* ink, Imaging imMask, -: 415: int dx, int dy, int sx, int sy, -: 416: int xsize, int ysize, int pixelsize) -: 417:{ -: 418: /* fill with mode "RGBA" matte */ -: 419: -: 420: int x, y, i; -: 421: unsigned int tmp1; -: 422: 7: 423: if (imOut->image8) { branch 0 taken 29% (fallthrough) branch 1 taken 71% -: 424: 2: 425: sx = sx*4+3; 258: 426: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 256: 427: UINT8* out = imOut->image8[y+dy]+dx; 256: 428: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx; 33024: 429: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 430: *out = BLEND(*mask, *out, ink[0], tmp1); 32768: 431: out++, mask += 4; -: 432: } -: 433: } -: 434: -: 435: } else { -: 436: 5: 437: dx *= pixelsize; 5: 438: sx = sx*4 + 3; 567: 439: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 562: 440: UINT8* out = (UINT8*) imOut->image[y+dy]+dx; 562: 441: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx; 68598: 442: for (x = 0; x < xsize; x++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 272144: 443: for (i = 0; i < pixelsize; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 272144: 444: *out = BLEND(*mask, *out, ink[i], tmp1); 272144: 445: out++; -: 446: } 68036: 447: mask += 4; -: 448: } -: 449: } -: 450: } 7: 451:} -: 452: -: 453:static inline void function fill_mask_RGBa.isra.7 called 6 returned 100% blocks executed 100% 6: 454:fill_mask_RGBa(Imaging imOut, const UINT8* ink, Imaging imMask, -: 455: int dx, int dy, int sx, int sy, -: 456: int xsize, int ysize, int pixelsize) -: 457:{ -: 458: /* fill with mode "RGBa" matte */ -: 459: -: 460: int x, y, i; -: 461: unsigned int tmp1; -: 462: 6: 463: if (imOut->image8) { branch 0 taken 33% (fallthrough) branch 1 taken 67% -: 464: 2: 465: sx = sx*4 + 3; 258: 466: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 256: 467: UINT8* out = imOut->image8[y+dy]+dx; 256: 468: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx; 33024: 469: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 470: *out = PREBLEND(*mask, *out, ink[0], tmp1); 32768: 471: out++, mask += 4; -: 472: } -: 473: } -: 474: -: 475: } else { -: 476: 4: 477: dx *= pixelsize; 4: 478: sx = sx*4 + 3; 516: 479: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 512: 480: UINT8* out = (UINT8*) imOut->image[y+dy]+dx; 512: 481: UINT8* mask = (UINT8*) imMask->image[y+sy]+sx; 66048: 482: for (x = 0; x < xsize; x++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 262144: 483: for (i = 0; i < pixelsize; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 262144: 484: *out = PREBLEND(*mask, *out, ink[i], tmp1); 262144: 485: out++; -: 486: } 65536: 487: mask += 4; -: 488: } -: 489: } -: 490: } 6: 491:} -: 492: -: 493:int function ImagingFill2 called 432 returned 100% blocks executed 87% 432: 494:ImagingFill2(Imaging imOut, const void* ink, Imaging imMask, -: 495: int dx0, int dy0, int dx1, int dy1) -: 496:{ -: 497: ImagingSectionCookie cookie; -: 498: int xsize, ysize; -: 499: int pixelsize; -: 500: int sx0, sy0; -: 501: 432: 502: if (!imOut || !ink) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 503: (void) ImagingError_ModeError(); call 0 never executed #####: 504: return -1; -: 505: } -: 506: 432: 507: pixelsize = imOut->pixelsize; -: 508: 432: 509: xsize = dx1 - dx0; 432: 510: ysize = dy1 - dy0; -: 511: 432: 512: if (imMask && (xsize != imMask->xsize || ysize != imMask->ysize)) { branch 0 taken 87% (fallthrough) branch 1 taken 13% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 513: (void) ImagingError_Mismatch(); call 0 never executed #####: 514: return -1; -: 515: } -: 516: -: 517: /* Determine which region to fill */ 432: 518: sx0 = sy0 = 0; 432: 519: if (dx0 < 0) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 20: 520: xsize += dx0, sx0 = -dx0, dx0 = 0; -: 521: } 432: 522: if (dx0 + xsize > imOut->xsize) { branch 0 taken 30% (fallthrough) branch 1 taken 70% 129: 523: xsize = imOut->xsize - dx0; -: 524: } 432: 525: if (dy0 < 0) { branch 0 taken 4% (fallthrough) branch 1 taken 96% 17: 526: ysize += dy0, sy0 = -dy0, dy0 = 0; -: 527: } 432: 528: if (dy0 + ysize > imOut->ysize) { branch 0 taken 4% (fallthrough) branch 1 taken 96% 17: 529: ysize = imOut->ysize - dy0; -: 530: } -: 531: 432: 532: if (xsize <= 0 || ysize <= 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 533: return 0; -: 534: } -: 535: 430: 536: if (!imMask) { branch 0 taken 13% (fallthrough) branch 1 taken 87% 58: 537: ImagingSectionEnter(&cookie); call 0 returned 100% 58: 538: fill(imOut, ink, dx0, dy0, xsize, ysize, pixelsize); call 0 returned 100% 58: 539: ImagingSectionLeave(&cookie); call 0 returned 100% -: 540: 372: 541: } else if (strcmp(imMask->mode, "1") == 0) { branch 0 taken 31% (fallthrough) branch 1 taken 69% branch 2 taken 31% (fallthrough) branch 3 taken 69% 114: 542: ImagingSectionEnter(&cookie); call 0 returned 100% 114: 543: fill_mask_1(imOut, ink, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 544: xsize, ysize, pixelsize); 114: 545: ImagingSectionLeave(&cookie); call 0 returned 100% -: 546: 258: 547: } else if (strcmp(imMask->mode, "L") == 0) { branch 0 taken 95% (fallthrough) branch 1 taken 5% branch 2 taken 95% (fallthrough) branch 3 taken 5% 245: 548: ImagingSectionEnter(&cookie); call 0 returned 100% 245: 549: fill_mask_L(imOut, ink, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 550: xsize, ysize, pixelsize); 245: 551: ImagingSectionLeave(&cookie); call 0 returned 100% -: 552: 13: 553: } else if (strcmp(imMask->mode, "RGBA") == 0) { branch 0 taken 54% (fallthrough) branch 1 taken 46% 7: 554: ImagingSectionEnter(&cookie); call 0 returned 100% 7: 555: fill_mask_RGBA(imOut, ink, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 556: xsize, ysize, pixelsize); 7: 557: ImagingSectionLeave(&cookie); call 0 returned 100% -: 558: 6: 559: } else if (strcmp(imMask->mode, "RGBa") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 560: ImagingSectionEnter(&cookie); call 0 returned 100% 6: 561: fill_mask_RGBa(imOut, ink, imMask, dx0, dy0, sx0, sy0, call 0 returned 100% -: 562: xsize, ysize, pixelsize); 6: 563: ImagingSectionLeave(&cookie); call 0 returned 100% -: 564: -: 565: } else { #####: 566: (void) ImagingError_ValueError("bad transparency mask"); call 0 never executed #####: 567: return -1; -: 568: } -: 569: -: 570: return 0; -: 571:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ZipEncode.c.gcov -: 0:Source:src/libImaging/ZipEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/ZipEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/ZipEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * coder for ZIP (deflated) image data -: 6: * -: 7: * History: -: 8: * 96-12-29 fl created -: 9: * 96-12-30 fl adaptive filter selection, encoder tuning -: 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:#ifdef HAVE_LIBZ -: 21: -: 22:#include "ZipCodecs.h" -: 23: -: 24:int function ImagingZipEncode called 186 returned 100% blocks executed 72% 186: 25:ImagingZipEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 26:{ 186: 27: ZIPSTATE* context = (ZIPSTATE*) state->context; -: 28: int err; -: 29: int compress_level, compress_type; -: 30: UINT8* ptr; -: 31: int i, bpp, s, sum; -: 32: ImagingSectionCookie cookie; -: 33: 186: 34: if (!state->state) { branch 0 taken 70% (fallthrough) branch 1 taken 30% -: 35: -: 36: /* Initialization */ -: 37: -: 38: /* Valid modes are ZIP_PNG, ZIP_PNG_PALETTE, and ZIP_TIFF */ -: 39: -: 40: /* overflow check for malloc */ 131: 41: if (state->bytes > INT_MAX - 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 42: state->errcode = IMAGING_CODEC_MEMORY; #####: 43: return -1; -: 44: } -: 45: -: 46: /* Expand standard buffer to make room for the filter selector, -: 47: and allocate filter buffers */ 131: 48: free(state->buffer); -: 49: /* malloc check ok, overflow checked above */ 131: 50: state->buffer = (UINT8*) malloc(state->bytes+1); 131: 51: context->previous = (UINT8*) malloc(state->bytes+1); 131: 52: context->prior = (UINT8*) malloc(state->bytes+1); 131: 53: context->up = (UINT8*) malloc(state->bytes+1); 131: 54: context->average = (UINT8*) malloc(state->bytes+1); 131: 55: context->paeth = (UINT8*) malloc(state->bytes+1); 131: 56: if (!state->buffer || !context->previous || !context->prior || 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 100% (fallthrough) branch 7 taken 0% 131: 57: !context->up || !context->average || !context->paeth) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 58: free(context->paeth); #####: 59: free(context->average); #####: 60: free(context->up); #####: 61: free(context->prior); #####: 62: free(context->previous); #####: 63: state->errcode = IMAGING_CODEC_MEMORY; #####: 64: return -1; -: 65: } -: 66: -: 67: /* Initialise filter buffers */ 131: 68: state->buffer[0] = 0; 131: 69: context->prior[0] = 1; 131: 70: context->up[0] = 2; 131: 71: context->average[0] = 3; 131: 72: context->paeth[0] = 4; -: 73: -: 74: /* Initialise previous buffer to black */ 262: 75: memset(context->previous, 0, state->bytes+1); -: 76: -: 77: /* Setup compression context */ 131: 78: context->z_stream.zalloc = (alloc_func)0; 131: 79: context->z_stream.zfree = (free_func)0; 131: 80: context->z_stream.opaque = (voidpf)0; 131: 81: context->z_stream.next_in = 0; 131: 82: context->z_stream.avail_in = 0; -: 83: 262: 84: compress_level = (context->optimize) ? Z_BEST_COMPRESSION 131: 85: : context->compress_level; branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 86: 131: 87: if (context->compress_type == -1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 262: 88: compress_type = (context->mode == ZIP_PNG) ? Z_FILTERED 131: 89: : Z_DEFAULT_STRATEGY; -: 90: } else { -: 91: compress_type = context->compress_type; -: 92: } -: 93: 131: 94: err = deflateInit2(&context->z_stream, call 0 returned 100% -: 95: /* compression level */ -: 96: compress_level, -: 97: /* compression method */ -: 98: Z_DEFLATED, -: 99: /* compression memory resources */ -: 100: 15, 9, -: 101: /* compression strategy (image data are filtered)*/ -: 102: compress_type); 131: 103: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 104: state->errcode = IMAGING_CODEC_CONFIG; #####: 105: return -1; -: 106: } -: 107: 131: 108: if (context->dictionary && context->dictionary_size > 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed #####: 109: err = deflateSetDictionary(&context->z_stream, (unsigned char *)context->dictionary, call 0 never executed -: 110: context->dictionary_size); #####: 111: if (err < 0) { branch 0 never executed branch 1 never executed #####: 112: state->errcode = IMAGING_CODEC_CONFIG; #####: 113: return -1; -: 114: } -: 115: } -: 116: -: 117: /* Ready to decode */ 131: 118: state->state = 1; -: 119: -: 120: } -: 121: -: 122: /* Setup the destination buffer */ 186: 123: context->z_stream.next_out = buf; 186: 124: context->z_stream.avail_out = bytes; 186: 125: if (context->z_stream.next_in && context->z_stream.avail_in > 0) { branch 0 taken 30% (fallthrough) branch 1 taken 70% branch 2 taken 15% (fallthrough) branch 3 taken 85% -: 126: /* We have some data from previous round, deflate it first */ 8: 127: err = deflate(&context->z_stream, Z_NO_FLUSH); call 0 returned 100% -: 128: 8: 129: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 130: /* Something went wrong inside the compression library */ #####: 131: if (err == Z_DATA_ERROR) { branch 0 never executed branch 1 never executed #####: 132: state->errcode = IMAGING_CODEC_BROKEN; #####: 133: } else if (err == Z_MEM_ERROR) { branch 0 never executed branch 1 never executed #####: 134: state->errcode = IMAGING_CODEC_MEMORY; -: 135: } else { #####: 136: state->errcode = IMAGING_CODEC_CONFIG; -: 137: } #####: 138: free(context->paeth); #####: 139: free(context->average); #####: 140: free(context->up); #####: 141: free(context->prior); #####: 142: free(context->previous); #####: 143: deflateEnd(&context->z_stream); call 0 never executed #####: 144: return -1; -: 145: } -: 146: } -: 147: 186: 148: ImagingSectionEnter(&cookie); call 0 returned 100% -: 149: for (;;) { -: 150: 186: 151: switch (state->state) { branch 0 taken 97% branch 1 taken 3% branch 2 taken 0% -: 152: -: 153: case 1: -: 154: -: 155: /* Compress image data */ 15877: 156: while (context->z_stream.avail_out > 0) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 157: 15827: 158: if (state->y >= state->ysize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 159: /* End of image; now flush compressor buffers */ 131: 160: state->state = 2; 131: 161: break; -: 162: -: 163: } -: 164: -: 165: /* Stuff image data into the compressor */ 31392: 166: state->shuffle(state->buffer+1, call 0 returned 100% 15696: 167: (UINT8*) im->image[state->y + state->yoff] + 15696: 168: state->xoff * im->pixelsize, -: 169: state->xsize); -: 170: 15696: 171: state->y++; -: 172: 15696: 173: context->output = state->buffer; -: 174: 15696: 175: if (context->mode == ZIP_PNG) { branch 0 taken 92% (fallthrough) branch 1 taken 8% -: 176: -: 177: /* Filter the image data. For each line, select -: 178: the filter that gives the least total distance -: 179: from zero for the filtered data (taken from -: 180: LIBPNG) */ -: 181: 14518: 182: bpp = (state->bits + 7) / 8; -: 183: -: 184: /* 0. No filter */ 39651398: 185: for (i = 1, sum = 0; i <= state->bytes; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 39636880: 186: UINT8 v = state->buffer[i]; 39636880: 187: sum += (v < 128) ? v : 256 - v; branch 0 taken 78% (fallthrough) branch 1 taken 22% -: 188: } -: 189: -: 190: /* 2. Up. We'll test this first to save time when -: 191: an image line is identical to the one above. */ 14518: 192: if (sum > 0) { branch 0 taken 95% (fallthrough) branch 1 taken 5% 39382872: 193: for (i = 1, s = 0; i <= state->bytes; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 39382872: 194: UINT8 v = state->buffer[i] - context->previous[i]; 39382872: 195: context->up[i] = v; 39382872: 196: s += (v < 128) ? v : 256 - v; branch 0 taken 85% (fallthrough) branch 1 taken 15% -: 197: } 13838: 198: if (s < sum) { branch 0 taken 96% (fallthrough) branch 1 taken 4% 13251: 199: context->output = context->up; 13251: 200: sum = s; /* 0 if line was duplicated */ -: 201: } -: 202: } -: 203: -: 204: /* 1. Prior */ 14518: 205: if (sum > 0) { branch 0 taken 71% (fallthrough) branch 1 taken 29% 27524: 206: for (i = 1, s = 0; i <= bpp; i++) { branch 0 taken 73% branch 1 taken 27% (fallthrough) 27524: 207: UINT8 v = state->buffer[i]; 27524: 208: context->prior[i] = v; 27524: 209: s += (v < 128) ? v : 256 - v; branch 0 taken 63% (fallthrough) branch 1 taken 37% -: 210: } 26618180: 211: for (; i <= state->bytes; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 26618180: 212: UINT8 v = state->buffer[i] - state->buffer[i-bpp]; 26618180: 213: context->prior[i] = v; 26618180: 214: s += (v < 128) ? v : 256 - v; branch 0 taken 79% (fallthrough) branch 1 taken 21% -: 215: } 10252: 216: if (s < sum) { branch 0 taken 27% (fallthrough) branch 1 taken 73% 2816: 217: context->output = context->prior; 2816: 218: sum = s; /* 0 if line is solid */ -: 219: } -: 220: } -: 221: -: 222: /* 3. Average (not very common in real-life images, -: 223: so its only used with the optimize option) */ 14518: 224: if (context->optimize && sum > 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed #####: 225: for (i = 1, s = 0; i <= bpp; i++) { branch 0 never executed branch 1 never executed #####: 226: UINT8 v = state->buffer[i] - context->previous[i]/2; #####: 227: context->average[i] = v; #####: 228: s += (v < 128) ? v : 256 - v; branch 0 never executed branch 1 never executed -: 229: } #####: 230: for (; i <= state->bytes; i++) { branch 0 never executed branch 1 never executed #####: 231: UINT8 v = state->buffer[i] - #####: 232: (state->buffer[i-bpp] + context->previous[i])/2; #####: 233: context->average[i] = v; #####: 234: s += (v < 128) ? v : 256 - v; branch 0 never executed branch 1 never executed -: 235: } #####: 236: if (s < sum) { branch 0 never executed branch 1 never executed #####: 237: context->output = context->average; #####: 238: sum = s; -: 239: } -: 240: } -: 241: -: 242: /* 4. Paeth */ 14518: 243: if (sum > 0) { branch 0 taken 71% (fallthrough) branch 1 taken 29% 27524: 244: for (i = 1, s = 0; i <= bpp; i++) { branch 0 taken 73% branch 1 taken 27% (fallthrough) 27524: 245: UINT8 v = state->buffer[i] - context->previous[i]; 27524: 246: context->paeth[i] = v; 27524: 247: s += (v < 128) ? v : 256 - v; branch 0 taken 77% (fallthrough) branch 1 taken 23% -: 248: } 26618180: 249: for (; i <= state->bytes; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 250: UINT8 v; -: 251: int a, b, c; -: 252: int pa, pb, pc; -: 253: -: 254: /* fetch pixels */ 26618180: 255: a = state->buffer[i-bpp]; 26618180: 256: b = context->previous[i]; 26618180: 257: c = context->previous[i-bpp]; -: 258: -: 259: /* distances to surrounding pixels */ 26618180: 260: pa = abs(b - c); 26618180: 261: pb = abs(a - c); 26618180: 262: pc = abs(a + b - 2*c); -: 263: -: 264: /* pick predictor with the shortest distance */ 33758371: 265: v = state->buffer[i] - branch 0 taken 78% (fallthrough) branch 1 taken 22% branch 2 taken 81% (fallthrough) branch 3 taken 19% 20705284: 266: ((pa <= pb && pa <= pc) ? a : branch 0 taken 6% (fallthrough) branch 1 taken 94% -: 267: (pb <= pc) ? b : c); 26618180: 268: context->paeth[i] = v; 26618180: 269: s += (v < 128) ? v : 256 - v; branch 0 taken 84% (fallthrough) branch 1 taken 16% -: 270: } 10252: 271: if (s < sum) { branch 0 taken 58% (fallthrough) branch 1 taken 42% 5971: 272: context->output = context->paeth; 5971: 273: sum = s; -: 274: } -: 275: } -: 276: } -: 277: -: 278: /* Compress this line */ 15696: 279: context->z_stream.next_in = context->output; 15696: 280: context->z_stream.avail_in = state->bytes+1; -: 281: 15696: 282: err = deflate(&context->z_stream, Z_NO_FLUSH); call 0 returned 100% -: 283: 15696: 284: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 285: /* Something went wrong inside the compression library */ #####: 286: if (err == Z_DATA_ERROR) { branch 0 never executed branch 1 never executed #####: 287: state->errcode = IMAGING_CODEC_BROKEN; #####: 288: } else if (err == Z_MEM_ERROR) { branch 0 never executed branch 1 never executed #####: 289: state->errcode = IMAGING_CODEC_MEMORY; -: 290: } else { #####: 291: state->errcode = IMAGING_CODEC_CONFIG; -: 292: } #####: 293: free(context->paeth); #####: 294: free(context->average); #####: 295: free(context->up); #####: 296: free(context->prior); #####: 297: free(context->previous); #####: 298: deflateEnd(&context->z_stream); call 0 never executed #####: 299: ImagingSectionLeave(&cookie); call 0 never executed #####: 300: return -1; -: 301: } -: 302: -: 303: /* Swap buffer pointers */ 15696: 304: ptr = state->buffer; 15696: 305: state->buffer = context->previous; 15696: 306: context->previous = ptr; -: 307: -: 308: } -: 309: 181: 310: if (context->z_stream.avail_out == 0) { branch 0 taken 72% branch 1 taken 28% -: 311: break; /* Buffer full */ -: 312: } -: 313: -: 314: case 2: -: 315: -: 316: /* End of image data; flush compressor buffers */ -: 317: 136: 318: while (context->z_stream.avail_out > 0) { branch 0 taken 100% branch 1 taken 0% (fallthrough) -: 319: 136: 320: err = deflate(&context->z_stream, Z_FINISH); call 0 returned 100% -: 321: 136: 322: if (err == Z_STREAM_END) { branch 0 taken 96% (fallthrough) branch 1 taken 4% -: 323: 131: 324: free(context->paeth); 131: 325: free(context->average); 131: 326: free(context->up); 131: 327: free(context->prior); 131: 328: free(context->previous); -: 329: 131: 330: deflateEnd(&context->z_stream); call 0 returned 100% -: 331: 131: 332: state->errcode = IMAGING_CODEC_END; -: 333: 131: 334: break; -: 335: } -: 336: 5: 337: if (context->z_stream.avail_out == 0) { branch 0 taken 0% branch 1 taken 100% -: 338: break; /* Buffer full */ -: 339: } -: 340: -: 341: } -: 342: -: 343: } 186: 344: ImagingSectionLeave(&cookie); call 0 returned 100% 186: 345: return bytes - context->z_stream.avail_out; -: 346: -: 347: } -: 348: -: 349: /* Should never ever arrive here... */ -: 350: state->errcode = IMAGING_CODEC_CONFIG; -: 351: ImagingSectionLeave(&cookie); -: 352: return -1; -: 353:} -: 354: -: 355:/* -------------------------------------------------------------------- */ -: 356:/* Cleanup */ -: 357:/* -------------------------------------------------------------------- */ -: 358: -: 359:int function ImagingZipEncodeCleanup called 262 returned 100% blocks executed 67% 262: 360:ImagingZipEncodeCleanup(ImagingCodecState state) { 262: 361: ZIPSTATE* context = (ZIPSTATE*) state->context; -: 362: 262: 363: if (context->dictionary) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 364: free (context->dictionary); #####: 365: context->dictionary = NULL; -: 366: } -: 367: 262: 368: return -1; -: 369:} -: 370: -: 371: -: 372: -: 373:const char* function ImagingZipVersion called 3 returned 100% blocks executed 100% 3: 374:ImagingZipVersion(void) -: 375:{ 3: 376: return zlibVersion(); call 0 returned 100% -: 377:} -: 378: -: 379:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Copy.c.gcov -: 0:Source:src/libImaging/Copy.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Copy.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Copy.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * copy image -: 6: * -: 7: * history: -: 8: * 95-11-26 fl Moved from Imaging.c -: 9: * 97-05-12 fl Added ImagingCopy2 -: 10: * 97-08-28 fl Allow imOut == NULL in ImagingCopy2 -: 11: * -: 12: * Copyright (c) Fredrik Lundh 1995-97. -: 13: * Copyright (c) Secret Labs AB 1997. -: 14: * -: 15: * See the README file for details on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21: -: 22:static Imaging function _copy called 2787 returned 100% blocks executed 80% 2787: 23:_copy(Imaging imOut, Imaging imIn) -: 24:{ -: 25: ImagingSectionCookie cookie; -: 26: int y; -: 27: 2787: 28: if (!imIn) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 29: return (Imaging) ImagingError_ValueError(NULL); call 0 never executed -: 30: } -: 31: 2787: 32: imOut = ImagingNew2Dirty(imIn->mode, imOut, imIn); call 0 returned 100% 2787: 33: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 34: return NULL; -: 35: } -: 36: 2787: 37: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 38: 2787: 39: ImagingSectionEnter(&cookie); call 0 returned 100% 2787: 40: if (imIn->block != NULL && imOut->block != NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed #####: 41: memcpy(imOut->block, imIn->block, imIn->ysize * imIn->linesize); -: 42: } else { 420462: 43: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 840924: 44: memcpy(imOut->image[y], imIn->image[y], imIn->linesize); -: 45: } -: 46: } 2787: 47: ImagingSectionLeave(&cookie); call 0 returned 100% -: 48: 2787: 49: return imOut; -: 50:} -: 51: -: 52:Imaging function ImagingCopy called 2575 returned 100% blocks executed 100% 2575: 53:ImagingCopy(Imaging imIn) -: 54:{ 2575: 55: return _copy(NULL, imIn); call 0 returned 100% -: 56:} -: 57: -: 58:Imaging function ImagingCopy2 called 212 returned 100% blocks executed 100% 212: 59:ImagingCopy2(Imaging imOut, Imaging imIn) -: 60:{ 212: 61: return _copy(imOut, imIn); call 0 returned 100% -: 62:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Convert.c.gcov -: 0:Source:src/libImaging/Convert.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Convert.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Convert.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * convert images -: 6: * -: 7: * history: -: 8: * 1995-06-15 fl created -: 9: * 1995-11-28 fl added some "RGBA" and "CMYK" conversions -: 10: * 1996-04-22 fl added "1" conversions (same as "L") -: 11: * 1996-05-05 fl added palette conversions (hack) -: 12: * 1996-07-23 fl fixed "1" conversions to zero/non-zero convention -: 13: * 1996-11-01 fl fixed "P" to "L" and "RGB" to "1" conversions -: 14: * 1996-12-29 fl set alpha byte in RGB converters -: 15: * 1997-05-12 fl added ImagingConvert2 -: 16: * 1997-05-30 fl added floating point support -: 17: * 1997-08-27 fl added "P" to "1" and "P" to "F" conversions -: 18: * 1998-01-11 fl added integer support -: 19: * 1998-07-01 fl added "YCbCr" support -: 20: * 1998-07-02 fl added "RGBX" conversions (sort of) -: 21: * 1998-07-04 fl added floyd-steinberg dithering -: 22: * 1998-07-12 fl changed "YCrCb" to "YCbCr" (!) -: 23: * 1998-12-29 fl added basic "I;16" and "I;16B" conversions -: 24: * 1999-02-03 fl added "RGBa", and "BGR" conversions (experimental) -: 25: * 2003-09-26 fl added "LA" and "PA" conversions (experimental) -: 26: * 2005-05-05 fl fixed "P" to "1" threshold -: 27: * 2005-12-08 fl fixed palette memory leak in topalette -: 28: * -: 29: * Copyright (c) 1997-2005 by Secret Labs AB. -: 30: * Copyright (c) 1995-1997 by Fredrik Lundh. -: 31: * -: 32: * See the README file for details on usage and redistribution. -: 33: */ -: 34: -: 35: -: 36:#include "Imaging.h" -: 37: -: 38:#define MAX(a, b) (a)>(b) ? (a) : (b) -: 39:#define MIN(a, b) (a)<(b) ? (a) : (b) -: 40: -: 41:#define CLIP16(v) ((v) <= -32768 ? -32768 : (v) >= 32767 ? 32767 : (v)) -: 42: -: 43:/* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */ -: 44:#define L(rgb)\ -: 45: ((INT32) (rgb)[0]*299 + (INT32) (rgb)[1]*587 + (INT32) (rgb)[2]*114) -: 46:#define L24(rgb)\ -: 47: ((rgb)[0]*19595 + (rgb)[1]*38470 + (rgb)[2]*7471 + 0x8000) -: 48: -: 49: -: 50:#ifndef round -: 51:double round(double x) { #####: 52: return floor(x+0.5); -: 53:} -: 54:#endif -: 55: -: 56:/* ------------------- */ -: 57:/* 1 (bit) conversions */ -: 58:/* ------------------- */ -: 59: -: 60:static void function bit2l called 833 returned 100% blocks executed 100% 833: 61:bit2l(UINT8* out, const UINT8* in, int xsize) -: 62:{ -: 63: int x; 132930: 64: for (x = 0; x < xsize; x++) branch 0 taken 99% branch 1 taken 1% (fallthrough) 132097: 65: *out++ = (*in++ != 0) ? 255 : 0; branch 0 taken 33% (fallthrough) branch 1 taken 67% 833: 66:} -: 67: -: 68:static void function bit2rgb called 512 returned 100% blocks executed 100% 512: 69:bit2rgb(UINT8* out, const UINT8* in, int xsize) -: 70:{ -: 71: int x; 57856: 72: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 57344: 73: UINT8 v = (*in++ != 0) ? 255 : 0; branch 0 taken 65% (fallthrough) branch 1 taken 35% 57344: 74: *out++ = v; 57344: 75: *out++ = v; 57344: 76: *out++ = v; 57344: 77: *out++ = 255; -: 78: } 512: 79:} -: 80: -: 81:static void function bit2cmyk called 128 returned 100% blocks executed 100% 128: 82:bit2cmyk(UINT8* out, const UINT8* in, int xsize) -: 83:{ -: 84: int x; 16512: 85: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 86: *out++ = 0; 16384: 87: *out++ = 0; 16384: 88: *out++ = 0; 16384: 89: *out++ = (*in++ != 0) ? 0 : 255; branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 90: } 128: 91:} -: 92: -: 93:static void function bit2ycbcr called 128 returned 100% blocks executed 100% 128: 94:bit2ycbcr(UINT8* out, const UINT8* in, int xsize) -: 95:{ -: 96: int x; 16512: 97: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 98: *out++ = (*in++ != 0) ? 255 : 0; branch 0 taken 67% (fallthrough) branch 1 taken 33% 16384: 99: *out++ = 128; 16384: 100: *out++ = 128; 16384: 101: *out++ = 255; -: 102: } 128: 103:} -: 104: -: 105:static void function bit2hsv called 128 returned 100% blocks executed 100% 128: 106:bit2hsv(UINT8* out, const UINT8* in, int xsize) -: 107:{ -: 108: int x; 16512: 109: for (x = 0; x < xsize; x++, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 110: UINT8 v = (*in++ != 0) ? 255 : 0; branch 0 taken 67% (fallthrough) branch 1 taken 33% 16384: 111: out[0] = 0; 16384: 112: out[1] = 0; 16384: 113: out[2] = v; 16384: 114: out[3] = 255; -: 115: } 128: 116:} -: 117: -: 118:/* ----------------- */ -: 119:/* RGB/L conversions */ -: 120:/* ----------------- */ -: 121: -: 122:static void function l2bit called 1 returned 100% blocks executed 83% 1: 123:l2bit(UINT8* out, const UINT8* in, int xsize) -: 124:{ -: 125: int x; 2: 126: for (x = 0; x < xsize; x++) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 1: 127: *out++ = (*in++ >= 128) ? 255 : 0; branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 128: } 1: 129:} -: 130: -: 131:static void function lA2la called 75106 returned 100% blocks executed 100% 75106: 132:lA2la(UINT8* out, const UINT8* in, int xsize) -: 133:{ -: 134: int x; -: 135: unsigned int alpha, pixel, tmp; 37132631: 136: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 37057525: 137: alpha = in[3]; 37057525: 138: pixel = MULDIV255(in[0], alpha, tmp); 37057525: 139: *out++ = (UINT8) pixel; 37057525: 140: *out++ = (UINT8) pixel; 37057525: 141: *out++ = (UINT8) pixel; 37057525: 142: *out++ = (UINT8) alpha; -: 143: } 75106: 144:} -: 145: -: 146:/* RGBa -> RGBA conversion to remove premultiplication -: 147: Needed for correct transforms/resizing on RGBA images */ -: 148:static void function la2lA called 20827 returned 100% blocks executed 100% 20827: 149:la2lA(UINT8* out, const UINT8* in, int xsize) -: 150:{ -: 151: int x; -: 152: unsigned int alpha, pixel; 3420108: 153: for (x = 0; x < xsize; x++, in+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3399281: 154: alpha = in[3]; 3399281: 155: if (alpha == 255 || alpha == 0) { branch 0 taken 48% (fallthrough) branch 1 taken 52% branch 2 taken 1% (fallthrough) branch 3 taken 99% 1779933: 156: pixel = in[0]; -: 157: } else { 1619348: 158: pixel = CLIP8((255 * in[0]) / alpha); branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 159: } 3399281: 160: *out++ = (UINT8) pixel; 3399281: 161: *out++ = (UINT8) pixel; 3399281: 162: *out++ = (UINT8) pixel; 3399281: 163: *out++ = (UINT8) alpha; -: 164: } 20827: 165:} -: 166: -: 167:static void function l2la called 523 returned 100% blocks executed 100% 523: 168:l2la(UINT8* out, const UINT8* in, int xsize) -: 169:{ -: 170: int x; 148690: 171: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% branch 2 taken 99% branch 3 taken 1% (fallthrough) 147527: 172: UINT8 v = *in++; 147527: 173: *out++ = v; 147527: 174: *out++ = v; 147527: 175: *out++ = v; 147527: 176: *out++ = 255; -: 177: } 523: 178:} -: 179: -: 180:static void function l2rgb called 5392 returned 100% blocks executed 100% 5392: 181:l2rgb(UINT8* out, const UINT8* in, int xsize) -: 182:{ -: 183: int x; 1866626: 184: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1861234: 185: UINT8 v = *in++; 1861234: 186: *out++ = v; 1861234: 187: *out++ = v; 1861234: 188: *out++ = v; 1861234: 189: *out++ = 255; -: 190: } 5392: 191:} -: 192: -: 193:static void function l2hsv called 256 returned 100% blocks executed 100% 256: 194:l2hsv(UINT8* out, const UINT8* in, int xsize) -: 195:{ -: 196: int x; 33024: 197: for (x = 0; x < xsize; x++, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 198: UINT8 v = *in++; 32768: 199: out[0] = 0; 32768: 200: out[1] = 0; 32768: 201: out[2] = v; 32768: 202: out[3] = 255; -: 203: } 256: 204:} -: 205: -: 206:static void function la2l called 1024 returned 100% blocks executed 100% 1024: 207:la2l(UINT8* out, const UINT8* in, int xsize) -: 208:{ -: 209: int x; 132096: 210: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 131072: 211: *out++ = in[0]; -: 212: } 1024: 213:} -: 214: -: 215:static void function la2rgb called 896 returned 100% blocks executed 100% 896: 216:la2rgb(UINT8* out, const UINT8* in, int xsize) -: 217:{ -: 218: int x; 115584: 219: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 114688: 220: UINT8 v = in[0]; 114688: 221: *out++ = v; 114688: 222: *out++ = v; 114688: 223: *out++ = v; 114688: 224: *out++ = in[3]; -: 225: } 896: 226:} -: 227: -: 228:static void function la2hsv called 128 returned 100% blocks executed 100% 128: 229:la2hsv(UINT8* out, const UINT8* in, int xsize) -: 230:{ -: 231: int x; 16512: 232: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 233: UINT8 v = in[0]; 16384: 234: out[0] = 0; 16384: 235: out[1] = 0; 16384: 236: out[2] = v; 16384: 237: out[3] = in[3]; -: 238: } 128: 239:} -: 240: -: 241:static void function rgb2bit called 0 returned 0% blocks executed 0% #####: 242:rgb2bit(UINT8* out, const UINT8* in, int xsize) -: 243:{ -: 244: int x; #####: 245: for (x = 0; x < xsize; x++, in += 4) { branch 0 never executed branch 1 never executed -: 246: /* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */ #####: 247: *out++ = (L(in) >= 128000) ? 255 : 0; branch 0 never executed branch 1 never executed -: 248: } #####: 249:} -: 250: -: 251:static void function rgb2l called 5305 returned 100% blocks executed 100% 5305: 252:rgb2l(UINT8* out, const UINT8* in, int xsize) -: 253:{ -: 254: int x; 1535614: 255: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 256: /* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */ 1530309: 257: *out++ = L24(in) >> 16; -: 258: } 5305: 259:} -: 260: -: 261:static void function rgb2la called 840 returned 100% blocks executed 100% 840: 262:rgb2la(UINT8* out, const UINT8* in, int xsize) -: 263:{ -: 264: int x; 108360: 265: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 266: /* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */ 107520: 267: out[0] = out[1] = out[2] = L24(in) >> 16; 107520: 268: out[3] = 255; -: 269: } 840: 270:} -: 271: -: 272:static void function rgb2i called 1512 returned 100% blocks executed 100% 1512: 273:rgb2i(UINT8* out_, const UINT8* in, int xsize) -: 274:{ -: 275: int x; 191976: 276: for (x = 0; x < xsize; x++, in += 4, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 190464: 277: INT32 v = L24(in) >> 16; 190464: 278: memcpy(out_, &v, sizeof(v)); -: 279: } 1512: 280:} -: 281: -: 282:static void function rgb2f called 1480 returned 100% blocks executed 100% 1480: 283:rgb2f(UINT8* out_, const UINT8* in, int xsize) -: 284:{ -: 285: int x; 190920: 286: for (x = 0; x < xsize; x++, in += 4, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 189440: 287: FLOAT32 v = (float) L(in) / 1000.0F; 189440: 288: memcpy(out_, &v, sizeof(v)); -: 289: } 1480: 290:} -: 291: -: 292:static void function rgb2bgr15 called 128 returned 100% blocks executed 100% 128: 293:rgb2bgr15(UINT8* out_, const UINT8* in, int xsize) -: 294:{ -: 295: int x; 16512: 296: for (x = 0; x < xsize; x++, in += 4, out_ += 2) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49152: 297: UINT16 v = 16384: 298: ((((UINT16)in[0])<<7)&0x7c00) + 16384: 299: ((((UINT16)in[1])<<2)&0x03e0) + 16384: 300: ((((UINT16)in[2])>>3)&0x001f); 16384: 301: memcpy(out_, &v, sizeof(v)); -: 302: } 128: 303:} -: 304: -: 305:static void function rgb2bgr16 called 0 returned 0% blocks executed 0% #####: 306:rgb2bgr16(UINT8* out_, const UINT8* in, int xsize) -: 307:{ -: 308: int x; #####: 309: for (x = 0; x < xsize; x++, in += 4, out_ += 2) { branch 0 never executed branch 1 never executed #####: 310: UINT16 v = #####: 311: ((((UINT16)in[0])<<8)&0xf800) + #####: 312: ((((UINT16)in[1])<<3)&0x07e0) + #####: 313: ((((UINT16)in[2])>>3)&0x001f); #####: 314: memcpy(out_, &v, sizeof(v)); -: 315: } #####: 316:} -: 317: -: 318:static void function rgb2bgr24 called 0 returned 0% blocks executed 0% #####: 319:rgb2bgr24(UINT8* out, const UINT8* in, int xsize) -: 320:{ -: 321: int x; #####: 322: for (x = 0; x < xsize; x++, in += 4) { branch 0 never executed branch 1 never executed #####: 323: *out++ = in[2]; #####: 324: *out++ = in[1]; #####: 325: *out++ = in[0]; -: 326: } #####: 327:} -: 328: -: 329:static void function rgb2hsv_row called 150528 returned 100% blocks executed 100% 150528: 330:rgb2hsv_row(UINT8* out, const UINT8* in) -: 331:{ // following colorsys.py -: 332: float h,s,rc,gc,bc,cr; -: 333: UINT8 maxc,minc; -: 334: UINT8 r, g, b; -: 335: UINT8 uh,us,uv; -: 336: 150528: 337: r = in[0]; 150528: 338: g = in[1]; 150528: 339: b = in[2]; 150528: 340: maxc = MAX(r,MAX(g,b)); branch 0 taken 27% (fallthrough) branch 1 taken 73% 150528: 341: minc = MIN(r,MIN(g,b)); branch 0 taken 64% (fallthrough) branch 1 taken 36% 150528: 342: uv = maxc; 150528: 343: if (minc == maxc){ branch 0 taken 97% (fallthrough) branch 1 taken 3% -: 344: uh = 0; -: 345: us = 0; -: 346: } else { 145485: 347: cr = (float)(maxc-minc); 145485: 348: s = cr/(float)maxc; 145485: 349: rc = ((float)(maxc-r))/cr; 145485: 350: gc = ((float)(maxc-g))/cr; 145485: 351: bc = ((float)(maxc-b))/cr; 145485: 352: if (r == maxc) { branch 0 taken 39% (fallthrough) branch 1 taken 61% 56561: 353: h = bc-gc; 88924: 354: } else if (g == maxc) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 6569: 355: h = 2.0 + rc-bc; -: 356: } else { 82355: 357: h = 4.0 + gc-rc; -: 358: } -: 359: // incorrect hue happens if h/6 is negative. 145485: 360: h = fmod((h/6.0 + 1.0), 1.0); -: 361: 145485: 362: uh = (UINT8)CLIP8((int)(h*255.0)); branch 0 taken 96% (fallthrough) branch 1 taken 4% branch 2 taken 100% (fallthrough) branch 3 taken 0% 145485: 363: us = (UINT8)CLIP8((int)(s*255.0)); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 364: } 150528: 365: out[0] = uh; 150528: 366: out[1] = us; 150528: 367: out[2] = uv; 150528: 368:} -: 369: -: 370:static void function rgb2hsv called 800 returned 100% blocks executed 100% 800: 371:rgb2hsv(UINT8* out, const UINT8* in, int xsize) -: 372:{ -: 373: int x; 102176: 374: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 101376: 375: rgb2hsv_row(out, in); call 0 returned 100% 101376: 376: out[3] = in[3]; -: 377: } 800: 378:} -: 379: -: 380: -: 381: -: 382:static void function hsv2rgb called 1696 returned 100% blocks executed 100% 1696: 383:hsv2rgb(UINT8* out, const UINT8* in, int xsize) -: 384:{ // following colorsys.py -: 385: -: 386: int p,q,t; -: 387: UINT8 up,uq,ut; -: 388: int i, x; -: 389: float f, fs; -: 390: UINT8 h,s,v; -: 391: 217760: 392: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 216064: 393: h = in[0]; 216064: 394: s = in[1]; 216064: 395: v = in[2]; -: 396: 216064: 397: if (s==0){ branch 0 taken 1% (fallthrough) branch 1 taken 99% 506: 398: *out++ = v; 506: 399: *out++ = v; 506: 400: *out++ = v; -: 401: } else { 215558: 402: i = floor((float)h * 6.0 / 255.0); // 0 - 6 215558: 403: f = (float)h * 6.0 / 255.0 - (float)i; // 0-1 : remainder. 215558: 404: fs = ((float)s)/255.0; -: 405: 215558: 406: p = round((float)v * (1.0-fs)); 215558: 407: q = round((float)v * (1.0-fs*f)); 215558: 408: t = round((float)v * (1.0-fs*(1.0-f))); 215558: 409: up = (UINT8)CLIP8(p); branch 0 taken 98% (fallthrough) branch 1 taken 2% branch 2 taken 100% (fallthrough) branch 3 taken 0% 215558: 410: uq = (UINT8)CLIP8(q); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 215558: 411: ut = (UINT8)CLIP8(t); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 412: 215558: 413: switch (i%6) { branch 0 taken 27% branch 1 taken 1% branch 2 taken 1% branch 3 taken 35% branch 4 taken 26% branch 5 taken 10% branch 6 taken 0% -: 414: case 0: 58630: 415: *out++ = v; 58630: 416: *out++ = ut; 58630: 417: *out++ = up; 58630: 418: break; -: 419: case 1: 1910: 420: *out++ = uq; 1910: 421: *out++ = v; 1910: 422: *out++ = up; 1910: 423: break; -: 424: case 2: 3014: 425: *out++ = up; 3014: 426: *out++ = v; 3014: 427: *out++ = ut; 3014: 428: break; -: 429: case 3: 75724: 430: *out++ = up; 75724: 431: *out++ = uq; 75724: 432: *out++ = v; 75724: 433: break; -: 434: case 4: 55608: 435: *out++ = ut; 55608: 436: *out++ = up; 55608: 437: *out++ = v; 55608: 438: break; -: 439: case 5: 20672: 440: *out++ = v; 20672: 441: *out++ = up; 20672: 442: *out++ = uq; 20672: 443: break; -: 444: -: 445: } -: 446: } 216064: 447: *out++ = in[3]; -: 448: } 1696: 449:} -: 450: -: 451: -: 452: -: 453:/* ---------------- */ -: 454:/* RGBA conversions */ -: 455:/* ---------------- */ -: 456: -: 457:static void function rgb2rgba called 3176 returned 100% blocks executed 100% 3176: 458:rgb2rgba(UINT8* out, const UINT8* in, int xsize) -: 459:{ -: 460: int x; 449280: 461: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 446104: 462: *out++ = *in++; 446104: 463: *out++ = *in++; 446104: 464: *out++ = *in++; 446104: 465: *out++ = 255; in++; -: 466: } 3176: 467:} -: 468: -: 469:static void function rgba2la called 512 returned 100% blocks executed 100% 512: 470:rgba2la(UINT8* out, const UINT8* in, int xsize) -: 471:{ -: 472: int x; 66048: 473: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 474: /* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */ 65536: 475: out[0] = out[1] = out[2] = L24(in) >> 16; 65536: 476: out[3] = in[3]; -: 477: } 512: 478:} -: 479: -: 480:static void function rgba2rgb called 5744 returned 100% blocks executed 100% 5744: 481:rgba2rgb(UINT8* out, const UINT8* in, int xsize) -: 482:{ -: 483: int x; 4247636: 484: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4241892: 485: *out++ = *in++; 4241892: 486: *out++ = *in++; 4241892: 487: *out++ = *in++; 4241892: 488: *out++ = 255; in++; -: 489: } 5744: 490:} -: 491: -: 492:static void function rgbA2rgba called 78896 returned 100% blocks executed 100% 78896: 493:rgbA2rgba(UINT8* out, const UINT8* in, int xsize) -: 494:{ -: 495: int x; -: 496: unsigned int alpha, tmp; 39281569: 497: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 39202673: 498: alpha = in[3]; 39202673: 499: *out++ = MULDIV255(*in++, alpha, tmp); 39202673: 500: *out++ = MULDIV255(*in++, alpha, tmp); 39202673: 501: *out++ = MULDIV255(*in++, alpha, tmp); 39202673: 502: *out++ = *in++; -: 503: } 78896: 504:} -: 505: -: 506:/* RGBa -> RGBA conversion to remove premultiplication -: 507: Needed for correct transforms/resizing on RGBA images */ -: 508:static void function rgba2rgbA called 21983 returned 100% blocks executed 100% 21983: 509:rgba2rgbA(UINT8* out, const UINT8* in, int xsize) -: 510:{ -: 511: int x; -: 512: unsigned int alpha; 3559028: 513: for (x = 0; x < xsize; x++, in+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3537045: 514: alpha = in[3]; 3537045: 515: if (alpha == 255 || alpha == 0) { branch 0 taken 46% (fallthrough) branch 1 taken 54% branch 2 taken 1% (fallthrough) branch 3 taken 99% 1916339: 516: *out++ = in[0]; 1916339: 517: *out++ = in[1]; 1916339: 518: *out++ = in[2]; -: 519: } else { 1620706: 520: *out++ = CLIP8((255 * in[0]) / alpha); branch 0 taken 99% (fallthrough) branch 1 taken 1% 1620706: 521: *out++ = CLIP8((255 * in[1]) / alpha); branch 0 taken 99% (fallthrough) branch 1 taken 1% 1620706: 522: *out++ = CLIP8((255 * in[2]) / alpha); branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 523: } 3537045: 524: *out++ = in[3]; -: 525: } 21983: 526:} -: 527: -: 528:/* -: 529: * Conversion of RGB + single transparent color to RGBA, -: 530: * where any pixel that matches the color will have the -: 531: * alpha channel set to 0 -: 532: */ -: 533: -: 534:static void function rgbT2rgba called 576 returned 100% blocks executed 100% 576: 535:rgbT2rgba(UINT8* out, int xsize, int r, int g, int b) -: 536:{ -: 537:#ifdef WORDS_BIGENDIAN 576: 538: UINT32 trns = ((r & 0xff)<<24) | ((g & 0xff)<<16) | ((b & 0xff)<<8) | 0xff; 576: 539: UINT32 repl = trns & 0xffffff00; -: 540:#else -: 541: UINT32 trns = (0xff <<24) | ((b & 0xff)<<16) | ((g & 0xff)<<8) | (r & 0xff); -: 542: UINT32 repl = trns & 0x00ffffff; -: 543:#endif -: 544: -: 545: int i; -: 546: 45632: 547: for (i=0; i < xsize; i++ ,out += sizeof(trns)) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 548: UINT32 v; 45056: 549: memcpy(&v, out, sizeof(v)); 45056: 550: if (v==trns) { branch 0 taken 16% (fallthrough) branch 1 taken 84% -: 551: memcpy(out, &repl, sizeof(repl)); -: 552: } -: 553: } 576: 554:} -: 555: -: 556: -: 557:/* ---------------- */ -: 558:/* CMYK conversions */ -: 559:/* ---------------- */ -: 560: -: 561:static void function l2cmyk called 389 returned 100% blocks executed 100% 389: 562:l2cmyk(UINT8* out, const UINT8* in, int xsize) -: 563:{ -: 564: int x; 49576: 565: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49187: 566: *out++ = 0; 49187: 567: *out++ = 0; 49187: 568: *out++ = 0; 49187: 569: *out++ = ~(*in++); -: 570: } 389: 571:} -: 572: -: 573:static void function la2cmyk called 128 returned 100% blocks executed 100% 128: 574:la2cmyk(UINT8* out, const UINT8* in, int xsize) -: 575:{ -: 576: int x; 16512: 577: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 578: *out++ = 0; 16384: 579: *out++ = 0; 16384: 580: *out++ = 0; 16384: 581: *out++ = ~(in[0]); -: 582: } 128: 583:} -: 584: -: 585:static void function rgb2cmyk called 1024 returned 100% blocks executed 100% 1024: 586:rgb2cmyk(UINT8* out, const UINT8* in, int xsize) -: 587:{ -: 588: int x; 164864: 589: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 99% branch 5 taken 1% (fallthrough) -: 590: /* Note: no undercolour removal */ 163840: 591: *out++ = ~(*in++); 163840: 592: *out++ = ~(*in++); 163840: 593: *out++ = ~(*in++); 163840: 594: *out++ = 0; in++; -: 595: } 1024: 596:} -: 597: -: 598:static void function cmyk2rgb called 1408 returned 100% blocks executed 100% 1408: 599:cmyk2rgb(UINT8* out, const UINT8* in, int xsize) -: 600:{ -: 601: int x, nk, tmp; 181632: 602: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 180224: 603: nk = 255 - in[3]; 180224: 604: out[0] = CLIP8(nk - MULDIV255(in[0], nk, tmp)); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 180224: 605: out[1] = CLIP8(nk - MULDIV255(in[1], nk, tmp)); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 180224: 606: out[2] = CLIP8(nk - MULDIV255(in[2], nk, tmp)); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 180224: 607: out[3] = 255; 180224: 608: out += 4; 180224: 609: in += 4; -: 610: } 1408: 611:} -: 612: -: 613:static void function cmyk2hsv called 128 returned 100% blocks executed 100% 128: 614:cmyk2hsv(UINT8* out, const UINT8* in, int xsize) -: 615:{ -: 616: int x, nk, tmp; 16512: 617: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 618: nk = 255 - in[3]; 16384: 619: out[0] = CLIP8(nk - MULDIV255(in[0], nk, tmp)); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 16384: 620: out[1] = CLIP8(nk - MULDIV255(in[1], nk, tmp)); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 16384: 621: out[2] = CLIP8(nk - MULDIV255(in[2], nk, tmp)); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% 16384: 622: rgb2hsv_row(out, out); call 0 returned 100% 16384: 623: out[3] = 255; 16384: 624: out += 4; 16384: 625: in += 4; -: 626: } 128: 627:} -: 628: -: 629:/* ------------- */ -: 630:/* I conversions */ -: 631:/* ------------- */ -: 632: -: 633:static void function bit2i called 256 returned 100% blocks executed 100% 256: 634:bit2i(UINT8* out_, const UINT8* in, int xsize) -: 635:{ -: 636: int x; 32896: 637: for (x = 0; x < xsize; x++, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32640: 638: INT32 v = (*in++ != 0) ? 255 : 0; branch 0 taken 69% (fallthrough) branch 1 taken 31% 32640: 639: memcpy(out_, &v, sizeof(v)); -: 640: } 256: 641:} -: 642: -: 643:static void function l2i called 617345 returned 100% blocks executed 100% 617345: 644:l2i(UINT8* out_, const UINT8* in, int xsize) -: 645:{ -: 646: int x; 191584602: 647: for (x = 0; x < xsize; x++, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 190967257: 648: INT32 v = *in++; 190967257: 649: memcpy(out_, &v, sizeof(v)); -: 650: } 617345: 651:} -: 652: -: 653:static void function i2l called 313825 returned 100% blocks executed 100% 313825: 654:i2l(UINT8* out, const UINT8* in_, int xsize) -: 655:{ -: 656: int x; 96871322: 657: for (x = 0; x < xsize; x++, out++, in_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 658: INT32 v; 96557497: 659: memcpy(&v, in_, sizeof(v)); 96557497: 660: if (v <= 0) { branch 0 taken 86% (fallthrough) branch 1 taken 14% 82843353: 661: *out = 0; 13714144: 662: } else if (v >= 255) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 27142: 663: *out = 255; -: 664: } else { 13687002: 665: *out = (UINT8) v; -: 666: } -: 667: } 313825: 668:} -: 669: -: 670:static void function i2f called 326 returned 100% blocks executed 100% 326: 671:i2f(UINT8* out_, const UINT8* in_, int xsize) -: 672:{ -: 673: int x; 37196: 674: for (x = 0; x < xsize; x++, in_ += 4, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 675: INT32 i; -: 676: FLOAT32 f; 36870: 677: memcpy(&i, in_, sizeof(i)); 36870: 678: f = i; 36870: 679: memcpy(out_, &f, sizeof(f)); -: 680: } 326: 681:} -: 682: -: 683:static void function i2rgb called 513 returned 100% blocks executed 100% 513: 684:i2rgb(UINT8* out, const UINT8* in_, int xsize) -: 685:{ -: 686: int x; 513: 687: INT32* in = (INT32*) in_; 57858: 688: for (x = 0; x < xsize; x++, in++, out+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 57345: 689: if (*in <= 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 110: 690: out[0] = out[1] = out[2] = 0; 57235: 691: } else if (*in >= 255) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 1121: 692: out[0] = out[1] = out[2] = 255; -: 693: } else { 56114: 694: out[0] = out[1] = out[2] = (UINT8) *in; -: 695: } 57345: 696: out[3] = 255; -: 697: } 513: 698:} -: 699: -: 700:static void function i2hsv called 128 returned 100% blocks executed 89% 128: 701:i2hsv(UINT8* out, const UINT8* in_, int xsize) -: 702:{ -: 703: int x; 128: 704: INT32* in = (INT32*) in_; 16512: 705: for (x = 0; x < xsize; x++, in++, out+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 706: out[0] = 0; 16384: 707: out[1] = 0; 16384: 708: if (*in <= 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 709: out[2] = 0; 16384: 710: } else if (*in >= 255) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 711: out[2] = 255; -: 712: } else { 16383: 713: out[2] = (UINT8) *in; -: 714: } 16384: 715: out[3] = 255; -: 716: } 128: 717:} -: 718: -: 719:/* ------------- */ -: 720:/* F conversions */ -: 721:/* ------------- */ -: 722: -: 723:static void function bit2f called 128 returned 100% blocks executed 100% 128: 724:bit2f(UINT8* out_, const UINT8* in, int xsize) -: 725:{ -: 726: int x; 16512: 727: for (x = 0; x < xsize; x++, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 728: FLOAT32 f = (*in++ != 0) ? 255.0F : 0.0F; branch 0 taken 67% (fallthrough) branch 1 taken 33% 16384: 729: memcpy(out_, &f, sizeof(f)); -: 730: } 128: 731:} -: 732: -: 733:static void function l2f called 1037 returned 100% blocks executed 100% 1037: 734:l2f(UINT8* out_, const UINT8* in, int xsize) -: 735:{ -: 736: int x; 328760: 737: for (x = 0; x < xsize; x++, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 327723: 738: FLOAT32 f = (FLOAT32) *in++; 327723: 739: memcpy(out_, &f, sizeof(f)); -: 740: } 1037: 741:} -: 742: -: 743:static void function f2l called 5905 returned 100% blocks executed 100% 5905: 744:f2l(UINT8* out, const UINT8* in_, int xsize) -: 745:{ -: 746: int x; 1281663: 747: for (x = 0; x < xsize; x++, out++, in_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 748: FLOAT32 v; 1275758: 749: memcpy(&v, in_, sizeof(v)); 1275758: 750: if (v <= 0.0) { branch 0 taken 83% (fallthrough) branch 1 taken 17% 1055550: 751: *out = 0; 220208: 752: } else if (v >= 255.0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 12: 753: *out = 255; -: 754: } else { 220196: 755: *out = (UINT8) v; -: 756: } -: 757: } 5905: 758:} -: 759: -: 760:static void function f2i called 129 returned 100% blocks executed 100% 129: 761:f2i(UINT8* out_, const UINT8* in_, int xsize) -: 762:{ -: 763: int x; 16514: 764: for (x = 0; x < xsize; x++, in_ += 4, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 765: FLOAT32 f; -: 766: INT32 i; 16385: 767: memcpy(&f, in_, sizeof(f)); 16385: 768: i = f; 16385: 769: memcpy(out_, &i, sizeof(i)); -: 770: } 129: 771:} -: 772: -: 773:/* ----------------- */ -: 774:/* YCbCr conversions */ -: 775:/* ----------------- */ -: 776: -: 777:/* See ConvertYCbCr.c for RGB/YCbCr tables */ -: 778: -: 779:static void function l2ycbcr called 389 returned 100% blocks executed 100% 389: 780:l2ycbcr(UINT8* out, const UINT8* in, int xsize) -: 781:{ -: 782: int x; 49576: 783: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49187: 784: *out++ = *in++; 49187: 785: *out++ = 128; 49187: 786: *out++ = 128; 49187: 787: *out++ = 255; -: 788: } 389: 789:} -: 790: -: 791:static void function la2ycbcr called 128 returned 100% blocks executed 100% 128: 792:la2ycbcr(UINT8* out, const UINT8* in, int xsize) -: 793:{ -: 794: int x; 16512: 795: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 796: *out++ = in[0]; 16384: 797: *out++ = 128; 16384: 798: *out++ = 128; 16384: 799: *out++ = 255; -: 800: } 128: 801:} -: 802: -: 803:static void function ycbcr2l called 128 returned 100% blocks executed 100% 128: 804:ycbcr2l(UINT8* out, const UINT8* in, int xsize) -: 805:{ -: 806: int x; 16512: 807: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 808: *out++ = in[0]; -: 809: } 128: 810:} -: 811: -: 812:static void function ycbcr2la called 128 returned 100% blocks executed 100% 128: 813:ycbcr2la(UINT8* out, const UINT8* in, int xsize) -: 814:{ -: 815: int x; 16512: 816: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 817: out[0] = out[1] = out[2] = in[0]; 16384: 818: out[3] = 255; -: 819: } 128: 820:} -: 821: -: 822:/* ------------------------- */ -: 823:/* I;16 (16-bit) conversions */ -: 824:/* ------------------------- */ -: 825: -: 826:static void function I_I16L called 544 returned 100% blocks executed 100% 544: 827:I_I16L(UINT8* out, const UINT8* in_, int xsize) -: 828:{ -: 829: int x, v; 54816: 830: for (x = 0; x < xsize; x++, in_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 831: INT32 i; 54272: 832: memcpy(&i, in_, sizeof(i)); 54272: 833: v = CLIP16(i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 54272: 834: *out++ = (UINT8) v; 54272: 835: *out++ = (UINT8) (v >> 8); -: 836: } 544: 837:} -: 838: -: 839:static void function I_I16B called 256 returned 100% blocks executed 100% 256: 840:I_I16B(UINT8* out, const UINT8* in_, int xsize) -: 841:{ -: 842: int x, v; 20736: 843: for (x = 0; x < xsize; x++, in_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 844: INT32 i; 20480: 845: memcpy(&i, in_, sizeof(i)); 20480: 846: v = CLIP16(i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 20480: 847: *out++ = (UINT8) (v >> 8); 20480: 848: *out++ = (UINT8) v; -: 849: } 256: 850:} -: 851: -: 852: -: 853:static void function I16L_I called 452 returned 100% blocks executed 100% 452: 854:I16L_I(UINT8* out_, const UINT8* in, int xsize) -: 855:{ -: 856: int x; 31956: 857: for (x = 0; x < xsize; x++, in += 2, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 31504: 858: INT32 v = in[0] + ((int) in[1] << 8); 31504: 859: memcpy(out_, &v, sizeof(v)); -: 860: } 452: 861:} -: 862: -: 863: -: 864:static void function I16B_I called 32 returned 100% blocks executed 100% 32: 865:I16B_I(UINT8* out_, const UINT8* in, int xsize) -: 866:{ -: 867: int x; 1056: 868: for (x = 0; x < xsize; x++, in += 2, out_ += 4) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 1024: 869: INT32 v = in[1] + ((int) in[0] << 8); 1024: 870: memcpy(out_, &v, sizeof(v)); -: 871: } 32: 872:} -: 873: -: 874:static void function I16L_F called 64 returned 100% blocks executed 100% 64: 875:I16L_F(UINT8* out_, const UINT8* in, int xsize) -: 876:{ -: 877: int x; 4160: 878: for (x = 0; x < xsize; x++, in += 2, out_ += 4) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 4096: 879: FLOAT32 v = in[0] + ((int) in[1] << 8); 4096: 880: memcpy(out_, &v, sizeof(v)); -: 881: } 64: 882:} -: 883: -: 884: -: 885:static void function I16B_F called 0 returned 0% blocks executed 0% #####: 886:I16B_F(UINT8* out_, const UINT8* in, int xsize) -: 887:{ -: 888: int x; #####: 889: for (x = 0; x < xsize; x++, in += 2, out_ += 4) { branch 0 never executed branch 1 never executed #####: 890: FLOAT32 v = in[1] + ((int) in[0] << 8); #####: 891: memcpy(out_, &v, sizeof(v)); -: 892: } #####: 893:} -: 894: -: 895:static void function L_I16L called 0 returned 0% blocks executed 0% #####: 896:L_I16L(UINT8* out, const UINT8* in, int xsize) -: 897:{ -: 898: int x; #####: 899: for (x = 0; x < xsize; x++, in++) { branch 0 never executed branch 1 never executed #####: 900: *out++ = *in; #####: 901: *out++ = 0; -: 902: } #####: 903:} -: 904: -: 905:static void function L_I16B called 0 returned 0% blocks executed 0% #####: 906:L_I16B(UINT8* out, const UINT8* in, int xsize) -: 907:{ -: 908: int x; #####: 909: for (x = 0; x < xsize; x++, in++) { branch 0 never executed branch 1 never executed #####: 910: *out++ = 0; #####: 911: *out++ = *in; -: 912: } #####: 913:} -: 914: -: 915:static void function I16L_L called 288 returned 100% blocks executed 86% 288: 916:I16L_L(UINT8* out, const UINT8* in, int xsize) -: 917:{ -: 918: int x; 34080: 919: for (x = 0; x < xsize; x++, in += 2) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 33792: 920: if (in[1] != 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 921: *out++ = 255; -: 922: } else { 33792: 923: *out++ = in[0]; -: 924: } -: 925: } 288: 926:} -: 927: -: 928:static void function I16B_L called 32 returned 100% blocks executed 86% 32: 929:I16B_L(UINT8* out, const UINT8* in, int xsize) -: 930:{ -: 931: int x; 1056: 932: for (x = 0; x < xsize; x++, in += 2) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 1024: 933: if (in[0] != 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 934: *out++ = 255; -: 935: } else { 1024: 936: *out++ = in[1]; -: 937: } -: 938: } 32: 939:} -: 940: -: 941:static struct { -: 942: const char* from; -: 943: const char* to; -: 944: ImagingShuffler convert; -: 945:} converters[] = { -: 946: -: 947: { "1", "L", bit2l }, -: 948: { "1", "I", bit2i }, -: 949: { "1", "F", bit2f }, -: 950: { "1", "RGB", bit2rgb }, -: 951: { "1", "RGBA", bit2rgb }, -: 952: { "1", "RGBX", bit2rgb }, -: 953: { "1", "CMYK", bit2cmyk }, -: 954: { "1", "YCbCr", bit2ycbcr }, -: 955: { "1", "HSV", bit2hsv }, -: 956: -: 957: { "L", "1", l2bit }, -: 958: { "L", "LA", l2la }, -: 959: { "L", "I", l2i }, -: 960: { "L", "F", l2f }, -: 961: { "L", "RGB", l2rgb }, -: 962: { "L", "RGBA", l2rgb }, -: 963: { "L", "RGBX", l2rgb }, -: 964: { "L", "CMYK", l2cmyk }, -: 965: { "L", "YCbCr", l2ycbcr }, -: 966: { "L", "HSV", l2hsv }, -: 967: -: 968: { "LA", "L", la2l }, -: 969: { "LA", "La", lA2la }, -: 970: { "LA", "RGB", la2rgb }, -: 971: { "LA", "RGBA", la2rgb }, -: 972: { "LA", "RGBX", la2rgb }, -: 973: { "LA", "CMYK", la2cmyk }, -: 974: { "LA", "YCbCr", la2ycbcr }, -: 975: { "LA", "HSV", la2hsv }, -: 976: -: 977: { "La", "LA", la2lA }, -: 978: -: 979: { "I", "L", i2l }, -: 980: { "I", "F", i2f }, -: 981: { "I", "RGB", i2rgb }, -: 982: { "I", "RGBA", i2rgb }, -: 983: { "I", "RGBX", i2rgb }, -: 984: { "I", "HSV", i2hsv }, -: 985: -: 986: { "F", "L", f2l }, -: 987: { "F", "I", f2i }, -: 988: -: 989: { "RGB", "1", rgb2bit }, -: 990: { "RGB", "L", rgb2l }, -: 991: { "RGB", "LA", rgb2la }, -: 992: { "RGB", "I", rgb2i }, -: 993: { "RGB", "F", rgb2f }, -: 994: { "RGB", "BGR;15", rgb2bgr15 }, -: 995: { "RGB", "BGR;16", rgb2bgr16 }, -: 996: { "RGB", "BGR;24", rgb2bgr24 }, -: 997: { "RGB", "RGBA", rgb2rgba }, -: 998: { "RGB", "RGBX", rgb2rgba }, -: 999: { "RGB", "CMYK", rgb2cmyk }, -: 1000: { "RGB", "YCbCr", ImagingConvertRGB2YCbCr }, -: 1001: { "RGB", "HSV", rgb2hsv }, -: 1002: -: 1003: { "RGBA", "1", rgb2bit }, -: 1004: { "RGBA", "L", rgb2l }, -: 1005: { "RGBA", "LA", rgba2la }, -: 1006: { "RGBA", "I", rgb2i }, -: 1007: { "RGBA", "F", rgb2f }, -: 1008: { "RGBA", "RGB", rgba2rgb }, -: 1009: { "RGBA", "RGBa", rgbA2rgba }, -: 1010: { "RGBA", "RGBX", rgb2rgba }, -: 1011: { "RGBA", "CMYK", rgb2cmyk }, -: 1012: { "RGBA", "YCbCr", ImagingConvertRGB2YCbCr }, -: 1013: { "RGBA", "HSV", rgb2hsv }, -: 1014: -: 1015: { "RGBa", "RGBA", rgba2rgbA }, -: 1016: -: 1017: { "RGBX", "1", rgb2bit }, -: 1018: { "RGBX", "L", rgb2l }, -: 1019: { "RGBX", "LA", rgb2la }, -: 1020: { "RGBX", "I", rgb2i }, -: 1021: { "RGBX", "F", rgb2f }, -: 1022: { "RGBX", "RGB", rgba2rgb }, -: 1023: { "RGBX", "CMYK", rgb2cmyk }, -: 1024: { "RGBX", "YCbCr", ImagingConvertRGB2YCbCr }, -: 1025: { "RGBX", "HSV", rgb2hsv }, -: 1026: -: 1027: { "CMYK", "RGB", cmyk2rgb }, -: 1028: { "CMYK", "RGBA", cmyk2rgb }, -: 1029: { "CMYK", "RGBX", cmyk2rgb }, -: 1030: { "CMYK", "HSV", cmyk2hsv }, -: 1031: -: 1032: { "YCbCr", "L", ycbcr2l }, -: 1033: { "YCbCr", "LA", ycbcr2la }, -: 1034: { "YCbCr", "RGB", ImagingConvertYCbCr2RGB }, -: 1035: -: 1036: { "HSV", "RGB", hsv2rgb }, -: 1037: -: 1038: { "I", "I;16", I_I16L }, -: 1039: { "I;16", "I", I16L_I }, -: 1040: { "L", "I;16", L_I16L }, -: 1041: { "I;16", "L", I16L_L }, -: 1042: -: 1043: { "I", "I;16L", I_I16L }, -: 1044: { "I;16L", "I", I16L_I }, -: 1045: { "I", "I;16B", I_I16B }, -: 1046: { "I;16B", "I", I16B_I }, -: 1047: -: 1048: { "L", "I;16L", L_I16L }, -: 1049: { "I;16L", "L", I16L_L }, -: 1050: { "L", "I;16B", L_I16B }, -: 1051: { "I;16B", "L", I16B_L }, -: 1052: -: 1053: { "I;16", "F", I16L_F }, -: 1054: { "I;16L", "F", I16L_F }, -: 1055: { "I;16B", "F", I16B_F }, -: 1056: -: 1057: { NULL } -: 1058:}; -: 1059: -: 1060:/* FIXME: translate indexed versions to pointer versions below this line */ -: 1061: -: 1062:/* ------------------- */ -: 1063:/* Palette conversions */ -: 1064:/* ------------------- */ -: 1065: -: 1066:static void function p2bit called 128 returned 100% blocks executed 100% 128: 1067:p2bit(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1068:{ -: 1069: int x; -: 1070: /* FIXME: precalculate greyscale palette? */ 16512: 1071: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1072: *out++ = (L(&palette[in[x]*4]) >= 128000) ? 255 : 0; branch 0 taken 69% (fallthrough) branch 1 taken 31% -: 1073: } 128: 1074:} -: 1075: -: 1076:static void function pa2bit called 128 returned 100% blocks executed 100% 128: 1077:pa2bit(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1078:{ -: 1079: int x; -: 1080: /* FIXME: precalculate greyscale palette? */ 16512: 1081: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1082: *out++ = (L(&palette[in[0]*4]) >= 128000) ? 255 : 0; branch 0 taken 69% (fallthrough) branch 1 taken 31% -: 1083: } 128: 1084:} -: 1085: -: 1086:static void function p2l called 9276 returned 100% blocks executed 100% 9276: 1087:p2l(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1088:{ -: 1089: int x; -: 1090: /* FIXME: precalculate greyscale palette? */ 2493970: 1091: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2484694: 1092: *out++ = L(&palette[in[x]*4]) / 1000; -: 1093: } 9276: 1094:} -: 1095: -: 1096:static void function pa2l called 128 returned 100% blocks executed 100% 128: 1097:pa2l(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1098:{ -: 1099: int x; -: 1100: /* FIXME: precalculate greyscale palette? */ 16512: 1101: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1102: *out++ = L(&palette[in[0]*4]) / 1000; -: 1103: } 128: 1104:} -: 1105: -: 1106:static void function p2pa called 129 returned 100% blocks executed 100% 129: 1107:p2pa(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1108:{ -: 1109: int x; 16514: 1110: for (x = 0; x < xsize; x++, in++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16385: 1111: const UINT8* rgba = &palette[in[0]]; 16385: 1112: *out++ = in[0]; 16385: 1113: *out++ = in[0]; 16385: 1114: *out++ = in[0]; 16385: 1115: *out++ = rgba[3]; -: 1116: } 129: 1117:} -: 1118: -: 1119:static void function p2la called 256 returned 100% blocks executed 100% 256: 1120:p2la(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1121:{ -: 1122: int x; -: 1123: /* FIXME: precalculate greyscale palette? */ 33024: 1124: for (x = 0; x < xsize; x++, out+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 1125: const UINT8* rgba = &palette[*in++ * 4]; 32768: 1126: out[0] = out[1] = out[2] = L(rgba) / 1000; 32768: 1127: out[3] = rgba[3]; -: 1128: } 256: 1129:} -: 1130: -: 1131:static void function pa2la called 128 returned 100% blocks executed 100% 128: 1132:pa2la(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1133:{ -: 1134: int x; -: 1135: /* FIXME: precalculate greyscale palette? */ 16512: 1136: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1137: out[0] = out[1] = out[2] = L(&palette[in[0]*4]) / 1000; 16384: 1138: out[3] = in[3]; -: 1139: } 128: 1140:} -: 1141: -: 1142:static void function p2i called 128 returned 100% blocks executed 100% 128: 1143:p2i(UINT8* out_, const UINT8* in, int xsize, const UINT8* palette) -: 1144:{ -: 1145: int x; 16512: 1146: for (x = 0; x < xsize; x++, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1147: INT32 v = L(&palette[in[x]*4]) / 1000; 16384: 1148: memcpy(out_, &v, sizeof(v)); -: 1149: } 128: 1150:} -: 1151: -: 1152:static void function pa2i called 128 returned 100% blocks executed 100% 128: 1153:pa2i(UINT8* out_, const UINT8* in, int xsize, const UINT8* palette) -: 1154:{ -: 1155: int x; 128: 1156: INT32* out = (INT32*) out_; 16512: 1157: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1158: *out++ = L(&palette[in[0]*4]) / 1000; -: 1159: } 128: 1160:} -: 1161: -: 1162:static void function p2f called 128 returned 100% blocks executed 100% 128: 1163:p2f(UINT8* out_, const UINT8* in, int xsize, const UINT8* palette) -: 1164:{ -: 1165: int x; 16512: 1166: for (x = 0; x < xsize; x++, out_ += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1167: FLOAT32 v = L(&palette[in[x]*4]) / 1000.0F; 16384: 1168: memcpy(out_, &v, sizeof(v)); -: 1169: } 128: 1170:} -: 1171: -: 1172:static void function pa2f called 128 returned 100% blocks executed 100% 128: 1173:pa2f(UINT8* out_, const UINT8* in, int xsize, const UINT8* palette) -: 1174:{ -: 1175: int x; 128: 1176: FLOAT32* out = (FLOAT32*) out_; 16512: 1177: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1178: *out++ = (float) L(&palette[in[0]*4]) / 1000.0F; -: 1179: } 128: 1180:} -: 1181: -: 1182:static void function p2rgb called 31696 returned 100% blocks executed 100% 31696: 1183:p2rgb(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1184:{ -: 1185: int x; 9528336: 1186: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 99% branch 5 taken 1% (fallthrough) 9496384: 1187: const UINT8* rgb = &palette[*in++ * 4]; 9496384: 1188: *out++ = rgb[0]; 9496384: 1189: *out++ = rgb[1]; 9496384: 1190: *out++ = rgb[2]; 9496384: 1191: *out++ = 255; -: 1192: } 31696: 1193:} -: 1194: -: 1195:static void function pa2rgb called 512 returned 100% blocks executed 100% 512: 1196:pa2rgb(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1197:{ -: 1198: int x; 99072: 1199: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 99% branch 5 taken 1% (fallthrough) 98304: 1200: const UINT8* rgb = &palette[in[0] * 4]; 98304: 1201: *out++ = rgb[0]; 98304: 1202: *out++ = rgb[1]; 98304: 1203: *out++ = rgb[2]; 98304: 1204: *out++ = 255; -: 1205: } 512: 1206:} -: 1207: -: 1208:static void function p2hsv called 128 returned 100% blocks executed 100% 128: 1209:p2hsv(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1210:{ -: 1211: int x; 16512: 1212: for (x = 0; x < xsize; x++, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1213: const UINT8* rgb = &palette[*in++ * 4]; 16384: 1214: rgb2hsv_row(out, rgb); call 0 returned 100% 16384: 1215: out[3] = 255; -: 1216: } 128: 1217:} -: 1218: -: 1219:static void function pa2hsv called 128 returned 100% blocks executed 100% 128: 1220:pa2hsv(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1221:{ -: 1222: int x; 16512: 1223: for (x = 0; x < xsize; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1224: const UINT8* rgb = &palette[in[0] * 4]; 16384: 1225: rgb2hsv_row(out, rgb); call 0 returned 100% 16384: 1226: out[3] = 255; -: 1227: } 128: 1228:} -: 1229: -: 1230:static void function p2rgba called 73064 returned 100% blocks executed 100% 73064: 1231:p2rgba(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1232:{ -: 1233: int x; 18106192: 1234: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 18033128: 1235: const UINT8* rgba = &palette[*in++ * 4]; 18033128: 1236: *out++ = rgba[0]; 18033128: 1237: *out++ = rgba[1]; 18033128: 1238: *out++ = rgba[2]; 18033128: 1239: *out++ = rgba[3]; -: 1240: } 73064: 1241:} -: 1242: -: 1243:static void function pa2rgba called 256 returned 100% blocks executed 100% 256: 1244:pa2rgba(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1245:{ -: 1246: int x; 33024: 1247: for (x = 0; x < xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 1248: const UINT8* rgb = &palette[in[0] * 4]; 32768: 1249: *out++ = rgb[0]; 32768: 1250: *out++ = rgb[1]; 32768: 1251: *out++ = rgb[2]; 32768: 1252: *out++ = in[3]; -: 1253: } 256: 1254:} -: 1255: -: 1256:static void function p2cmyk called 128 returned 100% blocks executed 100% 128: 1257:p2cmyk(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1258:{ -: 1259: p2rgb(out, in, xsize, palette); 128: 1260: rgb2cmyk(out, out, xsize); 128: 1261:} -: 1262: -: 1263:static void function pa2cmyk called 128 returned 100% blocks executed 100% 128: 1264:pa2cmyk(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1265:{ -: 1266: pa2rgb(out, in, xsize, palette); 128: 1267: rgb2cmyk(out, out, xsize); 128: 1268:} -: 1269: -: 1270:static void function p2ycbcr called 128 returned 100% blocks executed 100% 128: 1271:p2ycbcr(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1272:{ 128: 1273: p2rgb(out, in, xsize, palette); 128: 1274: ImagingConvertRGB2YCbCr(out, out, xsize); call 0 returned 100% 128: 1275:} -: 1276: -: 1277:static void function pa2ycbcr called 128 returned 100% blocks executed 100% 128: 1278:pa2ycbcr(UINT8* out, const UINT8* in, int xsize, const UINT8* palette) -: 1279:{ 128: 1280: pa2rgb(out, in, xsize, palette); 128: 1281: ImagingConvertRGB2YCbCr(out, out, xsize); call 0 returned 100% 128: 1282:} -: 1283: -: 1284:static Imaging function frompalette called 696 returned 100% blocks executed 99% 696: 1285:frompalette(Imaging imOut, Imaging imIn, const char *mode) -: 1286:{ -: 1287: ImagingSectionCookie cookie; -: 1288: int alpha; -: 1289: int y; -: 1290: void (*convert)(UINT8*, const UINT8*, int, const UINT8*); -: 1291: -: 1292: /* Map palette image to L, RGB, RGBA, or CMYK */ -: 1293: 696: 1294: if (!imIn->palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1295: return (Imaging) ImagingError_ValueError("no palette"); call 0 never executed -: 1296: } -: 1297: 696: 1298: alpha = !strcmp(imIn->mode, "PA"); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 2% (fallthrough) branch 3 taken 98% -: 1299: 696: 1300: if (strcmp(mode, "1") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1301: convert = alpha ? pa2bit : p2bit; branch 0 taken 50% (fallthrough) branch 1 taken 50% 694: 1302: } else if (strcmp(mode, "L") == 0) { branch 0 taken 11% (fallthrough) branch 1 taken 89% branch 2 taken 11% (fallthrough) branch 3 taken 89% 74: 1303: convert = alpha ? pa2l : p2l; branch 0 taken 99% (fallthrough) branch 1 taken 1% 620: 1304: } else if (strcmp(mode, "LA") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 1% (fallthrough) branch 5 taken 99% 3: 1305: convert = alpha ? pa2la : p2la; branch 0 taken 67% (fallthrough) branch 1 taken 33% 617: 1306: } else if (strcmp(mode, "PA") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 67% (fallthrough) branch 3 taken 33% branch 4 taken 99% (fallthrough) branch 5 taken 1% -: 1307: convert = p2pa; 615: 1308: } else if (strcmp(mode, "I") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1309: convert = alpha ? pa2i : p2i; branch 0 taken 50% (fallthrough) branch 1 taken 50% 613: 1310: } else if (strcmp(mode, "F") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 1% (fallthrough) branch 3 taken 99% 2: 1311: convert = alpha ? pa2f : p2f; branch 0 taken 50% (fallthrough) branch 1 taken 50% 611: 1312: } else if (strcmp(mode, "RGB") == 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 38% (fallthrough) branch 7 taken 62% 231: 1313: convert = alpha ? pa2rgb : p2rgb; branch 0 taken 98% (fallthrough) branch 1 taken 2% 380: 1314: } else if (strcmp(mode, "RGBA") == 0) { branch 0 taken 98% (fallthrough) branch 1 taken 2% 371: 1315: convert = alpha ? pa2rgba : p2rgba; branch 0 taken 99% (fallthrough) branch 1 taken 1% 9: 1316: } else if (strcmp(mode, "RGBX") == 0) { branch 0 taken 22% (fallthrough) branch 1 taken 78% 2: 1317: convert = alpha ? pa2rgba : p2rgba; branch 0 taken 50% (fallthrough) branch 1 taken 50% 7: 1318: } else if (strcmp(mode, "CMYK") == 0) { branch 0 taken 29% (fallthrough) branch 1 taken 71% 2: 1319: convert = alpha ? pa2cmyk : p2cmyk; branch 0 taken 50% (fallthrough) branch 1 taken 50% 5: 1320: } else if (strcmp(mode, "YCbCr") == 0) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 2: 1321: convert = alpha ? pa2ycbcr : p2ycbcr; branch 0 taken 50% (fallthrough) branch 1 taken 50% 3: 1322: } else if (strcmp(mode, "HSV") == 0) { branch 0 taken 67% (fallthrough) branch 1 taken 33% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 67% (fallthrough) branch 7 taken 33% 2: 1323: convert = alpha ? pa2hsv : p2hsv; branch 0 taken 50% (fallthrough) branch 1 taken 50% -: 1324: } else { 1: 1325: return (Imaging) ImagingError_ValueError("conversion not supported"); call 0 returned 100% -: 1326: } -: 1327: 695: 1328: imOut = ImagingNew2Dirty(mode, imOut, imIn); call 0 returned 100% 695: 1329: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1330: return NULL; -: 1331: } -: 1332: 695: 1333: ImagingSectionEnter(&cookie); 117676: 1334: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 233962: 1335: (*convert)((UINT8*) imOut->image[y], (UINT8*) imIn->image[y], call 0 returned 100% 116981: 1336: imIn->xsize, imIn->palette->palette); -: 1337: } 695: 1338: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1339: 695: 1340: return imOut; -: 1341:} -: 1342: -: 1343:#if defined(_MSC_VER) -: 1344:#pragma optimize("", off) -: 1345:#endif -: 1346:static Imaging function topalette called 132 returned 100% blocks executed 88% 132: 1347:topalette(Imaging imOut, Imaging imIn, const char *mode, ImagingPalette inpalette, int dither) -: 1348:{ -: 1349: ImagingSectionCookie cookie; -: 1350: int alpha; -: 1351: int x, y; 132: 1352: ImagingPalette palette = inpalette;; -: 1353: -: 1354: /* Map L or RGB/RGBX/RGBA to palette image */ 132: 1355: if (strcmp(imIn->mode, "L") != 0 && strncmp(imIn->mode, "RGB", 3) != 0) { branch 0 taken 13% (fallthrough) branch 1 taken 87% branch 2 taken 89% (fallthrough) branch 3 taken 11% branch 4 taken 34% (fallthrough) branch 5 taken 66% 40: 1356: return (Imaging) ImagingError_ValueError("conversion not supported"); call 0 returned 100% -: 1357: } -: 1358: 92: 1359: alpha = !strcmp(mode, "PA"); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 41% (fallthrough) branch 3 taken 59% -: 1360: 92: 1361: if (palette == NULL) { branch 0 taken 95% (fallthrough) branch 1 taken 5% -: 1362: /* FIXME: make user configurable */ 87: 1363: if (imIn->bands == 1) { branch 0 taken 17% (fallthrough) branch 1 taken 83% 15: 1364: palette = ImagingPaletteNew("RGB"); /* Initialised to grey ramp */ call 0 returned 100% -: 1365: } else { 72: 1366: palette = ImagingPaletteNewBrowser(); /* Standard colour cube */ call 0 returned 100% -: 1367: } -: 1368: } -: 1369: 92: 1370: if (!palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1371: return (Imaging) ImagingError_ValueError("no palette"); call 0 never executed -: 1372: } -: 1373: 92: 1374: imOut = ImagingNew2Dirty(mode, imOut, imIn); call 0 returned 100% 92: 1375: if (!imOut) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1376: if (palette != inpalette) { branch 0 never executed branch 1 never executed #####: 1377: ImagingPaletteDelete(palette); call 0 never executed -: 1378: } -: 1379: return NULL; -: 1380: } -: 1381: 92: 1382: ImagingPaletteDelete(imOut->palette); call 0 returned 100% 92: 1383: imOut->palette = ImagingPaletteDuplicate(palette); call 0 returned 100% -: 1384: 92: 1385: if (imIn->bands == 1) { branch 0 taken 16% (fallthrough) branch 1 taken 84% -: 1386: /* greyscale image */ -: 1387: -: 1388: /* Greyscale palette: copy data as is */ 15: 1389: ImagingSectionEnter(&cookie); 2940: 1390: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 2925: 1391: if (alpha) { branch 0 taken 22% (fallthrough) branch 1 taken 78% 640: 1392: l2la((UINT8*) imOut->image[y], (UINT8*) imIn->image[y], imIn->xsize); -: 1393: } else { 2285: 1394: memcpy(imOut->image[y], imIn->image[y], imIn->linesize); -: 1395: } -: 1396: } 15: 1397: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1398: -: 1399: } else { -: 1400: /* colour image */ -: 1401: -: 1402: /* Create mapping cache */ 77: 1403: if (ImagingPaletteCachePrepare(palette) < 0) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 1404: ImagingDelete(imOut); call 0 never executed #####: 1405: if (palette != inpalette) { branch 0 never executed branch 1 never executed #####: 1406: ImagingPaletteDelete(palette); call 0 never executed -: 1407: } -: 1408: return NULL; -: 1409: } -: 1410: 77: 1411: if (dither) { branch 0 taken 97% (fallthrough) branch 1 taken 3% -: 1412: /* floyd-steinberg dither */ -: 1413: -: 1414: int* errors; 75: 1415: errors = calloc(imIn->xsize + 1, sizeof(int) * 3); 75: 1416: if (!errors) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1417: ImagingDelete(imOut); call 0 never executed #####: 1418: return ImagingError_MemoryError(); call 0 never executed -: 1419: } -: 1420: -: 1421: /* Map each pixel to the nearest palette entry */ 75: 1422: ImagingSectionEnter(&cookie); 5901: 1423: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) -: 1424: int r, r0, r1, r2; -: 1425: int g, g0, g1, g2; -: 1426: int b, b0, b1, b2; 5826: 1427: UINT8* in = (UINT8*) imIn->image[y]; 5826: 1428: UINT8* out = alpha ? (UINT8*) imOut->image32[y] : imOut->image8[y]; branch 0 taken 44% (fallthrough) branch 1 taken 56% 5826: 1429: int* e = errors; -: 1430: 5826: 1431: r = r0 = r1 = 0; 5826: 1432: g = g0 = g1 = 0; 5826: 1433: b = b0 = b1 = b2 = 0; -: 1434: 781428: 1435: for (x = 0; x < imIn->xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 1436: int d2; -: 1437: INT16* cache; -: 1438: 775602: 1439: r = CLIP8(in[0] + (r + e[3+0])/16); branch 0 taken 92% (fallthrough) branch 1 taken 8% 775602: 1440: g = CLIP8(in[1] + (g + e[3+1])/16); branch 0 taken 87% (fallthrough) branch 1 taken 13% 775602: 1441: b = CLIP8(in[2] + (b + e[3+2])/16); branch 0 taken 87% (fallthrough) branch 1 taken 13% -: 1442: -: 1443: /* get closest colour */ 775602: 1444: cache = &ImagingPaletteCache(palette, r, g, b); 775602: 1445: if (cache[0] == 0x100) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 6373: 1446: ImagingPaletteCacheUpdate(palette, r, g, b); call 0 returned 100% -: 1447: } 775602: 1448: if (alpha) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 327680: 1449: out[x*4] = out[x*4+1] = out[x*4+2] = (UINT8) cache[0]; 327680: 1450: out[x*4+3] = 255; -: 1451: } else { 447922: 1452: out[x] = (UINT8) cache[0]; -: 1453: } -: 1454: 775602: 1455: r -= (int) palette->palette[cache[0]*4]; 775602: 1456: g -= (int) palette->palette[cache[0]*4+1]; 775602: 1457: b -= (int) palette->palette[cache[0]*4+2]; -: 1458: -: 1459: /* propagate errors (don't ask ;-) */ 775602: 1460: r2 = r; d2 = r + r; r += d2; e[0] = r + r0; 775602: 1461: r += d2; r0 = r + r1; r1 = r2; r += d2; 775602: 1462: g2 = g; d2 = g + g; g += d2; e[1] = g + g0; 775602: 1463: g += d2; g0 = g + g1; g1 = g2; g += d2; 775602: 1464: b2 = b; d2 = b + b; b += d2; e[2] = b + b0; 775602: 1465: b += d2; b0 = b + b1; b1 = b2; b += d2; -: 1466: 775602: 1467: e += 3; -: 1468: -: 1469: } -: 1470: 5826: 1471: e[0] = b0; 5826: 1472: e[1] = b1; 5826: 1473: e[2] = b2; -: 1474: -: 1475: } 75: 1476: ImagingSectionLeave(&cookie); call 0 returned 100% 75: 1477: free(errors); -: 1478: -: 1479: } else { -: 1480: -: 1481: /* closest colour */ 2: 1482: ImagingSectionEnter(&cookie); 258: 1483: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) -: 1484: int r, g, b; 256: 1485: UINT8* in = (UINT8*) imIn->image[y]; 256: 1486: UINT8* out = alpha ? (UINT8*) imOut->image32[y] : imOut->image8[y]; branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1487: 33024: 1488: for (x = 0; x < imIn->xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 1489: INT16* cache; -: 1490: 32768: 1491: r = in[0]; g = in[1]; b = in[2]; -: 1492: -: 1493: /* get closest colour */ 32768: 1494: cache = &ImagingPaletteCache(palette, r, g, b); 32768: 1495: if (cache[0] == 0x100) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 191: 1496: ImagingPaletteCacheUpdate(palette, r, g, b); call 0 returned 100% -: 1497: } 32768: 1498: if (alpha) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1499: out[x*4] = out[x*4+1] = out[x*4+2] = (UINT8) cache[0]; #####: 1500: out[x*4+3] = 255; -: 1501: } else { 32768: 1502: out[x] = (UINT8) cache[0]; -: 1503: } -: 1504: } -: 1505: } 2: 1506: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1507: -: 1508: } 77: 1509: if (inpalette != palette) { branch 0 taken 94% (fallthrough) branch 1 taken 6% 72: 1510: ImagingPaletteCacheDelete(palette); call 0 returned 100% -: 1511: } -: 1512: } -: 1513: 92: 1514: if (inpalette != palette) { branch 0 taken 95% (fallthrough) branch 1 taken 5% 87: 1515: ImagingPaletteDelete(palette); call 0 returned 100% -: 1516: } -: 1517: -: 1518: return imOut; -: 1519:} -: 1520: -: 1521:static Imaging function tobilevel.isra.0 called 55 returned 100% blocks executed 95% 55: 1522:tobilevel(Imaging imOut, Imaging imIn, int dither) -: 1523:{ -: 1524: ImagingSectionCookie cookie; -: 1525: int x, y; -: 1526: int* errors; -: 1527: -: 1528: /* Map L or RGB to dithered 1 image */ 55: 1529: if (strcmp(imIn->mode, "L") != 0 && strcmp(imIn->mode, "RGB") != 0) { branch 0 taken 18% (fallthrough) branch 1 taken 82% branch 2 taken 84% (fallthrough) branch 3 taken 16% branch 4 taken 57% (fallthrough) branch 5 taken 43% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 48% (fallthrough) branch 11 taken 52% 22: 1530: return (Imaging) ImagingError_ValueError("conversion not supported"); call 0 returned 100% -: 1531: } -: 1532: 33: 1533: imOut = ImagingNew2Dirty("1", imOut, imIn); call 0 returned 100% 33: 1534: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1535: return NULL; -: 1536: } -: 1537: 33: 1538: errors = calloc(imIn->xsize + 1, sizeof(int)); 33: 1539: if (!errors) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1540: ImagingDelete(imOut); call 0 never executed #####: 1541: return ImagingError_MemoryError(); call 0 never executed -: 1542: } -: 1543: 33: 1544: if (imIn->bands == 1) { branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 1545: -: 1546: /* map each pixel to black or white, using error diffusion */ 9: 1547: ImagingSectionEnter(&cookie); 2529: 1548: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) -: 1549: int l, l0, l1, l2, d2; 2520: 1550: UINT8* in = (UINT8*) imIn->image[y]; 2520: 1551: UINT8* out = imOut->image8[y]; -: 1552: 2520: 1553: l = l0 = l1 = 0; -: 1554: 2068102: 1555: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 1556: -: 1557: /* pick closest colour */ 2065582: 1558: l = CLIP8(in[x] + (l + errors[x+1])/16); branch 0 taken 99% (fallthrough) branch 1 taken 1% 2065582: 1559: out[x] = (l > 128) ? 255 : 0; branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 1560: -: 1561: /* propagate errors */ 2065582: 1562: l -= (int) out[x]; 2065582: 1563: l2 = l; d2 = l + l; l += d2; errors[x] = l + l0; 2065582: 1564: l += d2; l0 = l + l1; l1 = l2; l += d2; -: 1565: } -: 1566: 2520: 1567: errors[x] = l0; -: 1568: -: 1569: } 9: 1570: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1571: -: 1572: } else { -: 1573: -: 1574: /* map each pixel to black or white, using error diffusion */ 24: 1575: ImagingSectionEnter(&cookie); 1432: 1576: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 98% branch 2 taken 2% (fallthrough) -: 1577: int l, l0, l1, l2, d2; 1408: 1578: UINT8* in = (UINT8*) imIn->image[y]; 1408: 1579: UINT8* out = imOut->image8[y]; -: 1580: 1408: 1581: l = l0 = l1 = 0; -: 1582: 181632: 1583: for (x = 0; x < imIn->xsize; x++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 1584: -: 1585: /* pick closest colour */ 180224: 1586: l = CLIP8(L(in)/1000 + (l + errors[x+1])/16); branch 0 taken 99% (fallthrough) branch 1 taken 1% 180224: 1587: out[x] = (l > 128) ? 255 : 0; branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 1588: -: 1589: /* propagate errors */ 180224: 1590: l -= (int) out[x]; 180224: 1591: l2 = l; d2 = l + l; l += d2; errors[x] = l + l0; 180224: 1592: l += d2; l0 = l + l1; l1 = l2; l += d2; -: 1593: -: 1594: } -: 1595: 1408: 1596: errors[x] = l0; -: 1597: -: 1598: } 24: 1599: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1600: } -: 1601: 33: 1602: free(errors); -: 1603: -: 1604: return imOut; -: 1605:} -: 1606:#if defined(_MSC_VER) -: 1607:#pragma optimize("", on) -: 1608:#endif -: 1609: -: 1610:static Imaging function convert called 7904 returned 100% blocks executed 91% 7904: 1611:convert(Imaging imOut, Imaging imIn, const char *mode, -: 1612: ImagingPalette palette, int dither) -: 1613:{ -: 1614: ImagingSectionCookie cookie; -: 1615: ImagingShuffler convert; -: 1616: int y; -: 1617: 7904: 1618: if (!imIn) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1619: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 1620: } -: 1621: 7904: 1622: if (!mode) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1623: /* Map palette image to full depth */ #####: 1624: if (!imIn->palette) { branch 0 never executed branch 1 never executed #####: 1625: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 1626: } #####: 1627: mode = imIn->palette->mode; -: 1628: } else { -: 1629: /* Same mode? */ 7904: 1630: if (!strcmp(imIn->mode, mode)) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 192: 1631: return ImagingCopy2(imOut, imIn); call 0 returned 100% -: 1632: } -: 1633: } -: 1634: -: 1635: -: 1636: /* test for special conversions */ -: 1637: 7712: 1638: if (strcmp(imIn->mode, "P") == 0 || strcmp(imIn->mode, "PA") == 0) { branch 0 taken 9% (fallthrough) branch 1 taken 91% branch 2 taken 91% (fallthrough) branch 3 taken 9% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 1% (fallthrough) branch 9 taken 99% 696: 1639: return frompalette(imOut, imIn, mode); call 0 returned 100% -: 1640: } -: 1641: 7016: 1642: if (strcmp(mode, "P") == 0 || strcmp(mode, "PA") == 0) { branch 0 taken 2% (fallthrough) branch 1 taken 98% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 1% (fallthrough) branch 9 taken 99% 132: 1643: return topalette(imOut, imIn, mode, palette, dither); call 0 returned 100% -: 1644: } -: 1645: 6884: 1646: if (dither && strcmp(mode, "1") == 0) { branch 0 taken 97% (fallthrough) branch 1 taken 3% branch 2 taken 1% (fallthrough) branch 3 taken 99% branch 4 taken 99% (fallthrough) branch 5 taken 1% 55: 1647: return tobilevel(imOut, imIn, dither); call 0 returned 100% -: 1648: } -: 1649: -: 1650: -: 1651: /* standard conversion machinery */ -: 1652: -: 1653: convert = NULL; -: 1654: 166484: 1655: for (y = 0; converters[y].from; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 190512: 1656: if (!strcmp(imIn->mode, converters[y].from) && branch 0 taken 10% (fallthrough) branch 1 taken 90% branch 2 taken 39% (fallthrough) branch 3 taken 61% 17336: 1657: !strcmp(mode, converters[y].to)) { 6692: 1658: convert = converters[y].convert; 6692: 1659: break; -: 1660: } -: 1661: } -: 1662: 6829: 1663: if (!convert) { branch 0 taken 2% (fallthrough) branch 1 taken 98% -: 1664:#ifdef notdef -: 1665: return (Imaging) ImagingError_ValueError("conversion not supported"); -: 1666:#else -: 1667: static char buf[256]; -: 1668: /* FIXME: may overflow if mode is too large */ 274: 1669: sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode); 137: 1670: return (Imaging) ImagingError_ValueError(buf); call 0 returned 100% -: 1671:#endif -: 1672: } -: 1673: 6692: 1674: imOut = ImagingNew2Dirty(mode, imOut, imIn); call 0 returned 100% 6692: 1675: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1676: return NULL; -: 1677: } -: 1678: 6692: 1679: ImagingSectionEnter(&cookie); 1181482: 1680: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 1174790: 1681: (*convert)((UINT8*) imOut->image[y], (UINT8*) imIn->image[y], call 0 returned 100% -: 1682: imIn->xsize); -: 1683: } 6692: 1684: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1685: 6692: 1686: return imOut; -: 1687:} -: 1688: -: 1689:Imaging function ImagingConvert called 7904 returned 100% blocks executed 100% 7904: 1690:ImagingConvert(Imaging imIn, const char *mode, -: 1691: ImagingPalette palette, int dither) -: 1692:{ 7904: 1693: return convert(NULL, imIn, mode, palette, dither); call 0 returned 100% -: 1694:} -: 1695: -: 1696:Imaging function ImagingConvert2 called 0 returned 0% blocks executed 0% #####: 1697:ImagingConvert2(Imaging imOut, Imaging imIn) -: 1698:{ #####: 1699: return convert(imOut, imIn, imOut->mode, NULL, 0); call 0 never executed -: 1700:} -: 1701: -: 1702: -: 1703:Imaging function ImagingConvertTransparent called 8 returned 100% blocks executed 95% 8: 1704:ImagingConvertTransparent(Imaging imIn, const char *mode, -: 1705: int r, int g, int b) -: 1706:{ -: 1707: ImagingSectionCookie cookie; -: 1708: ImagingShuffler convert; 8: 1709: Imaging imOut = NULL; -: 1710: int y; -: 1711: 8: 1712: if (!imIn){ branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1713: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 1714: } -: 1715: 22: 1716: if (!((strcmp(imIn->mode, "RGB") == 0 || branch 0 taken 25% (fallthrough) branch 1 taken 75% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 75% (fallthrough) branch 7 taken 25% branch 8 taken 67% (fallthrough) branch 9 taken 33% branch 10 taken 0% (fallthrough) branch 11 taken 100% 10: 1717: strcmp(imIn->mode, "1") == 0 || branch 0 taken 33% (fallthrough) branch 1 taken 67% branch 2 taken 50% (fallthrough) branch 3 taken 50% 6: 1718: strcmp(imIn->mode, "I") == 0 || branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 100% (fallthrough) branch 3 taken 0% 2: 1719: strcmp(imIn->mode, "L") == 0) branch 0 taken 100% (fallthrough) branch 1 taken 0% 8: 1720: && strcmp(mode, "RGBA") == 0)) -: 1721:#ifdef notdef -: 1722: { -: 1723: return (Imaging) ImagingError_ValueError("conversion not supported"); -: 1724: } -: 1725:#else -: 1726: { -: 1727: static char buf[256]; -: 1728: /* FIXME: may overflow if mode is too large */ #####: 1729: sprintf(buf, "conversion from %s to %s not supported in convert_transparent", imIn->mode, mode); #####: 1730: return (Imaging) ImagingError_ValueError(buf); call 0 never executed -: 1731: } -: 1732:#endif -: 1733: 8: 1734: if (strcmp(imIn->mode, "RGB") == 0) { branch 0 taken 25% (fallthrough) branch 1 taken 75% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 75% (fallthrough) branch 7 taken 25% -: 1735: convert = rgb2rgba; -: 1736: } else { 6: 1737: if (strcmp(imIn->mode, "1") == 0) { branch 0 taken 33% (fallthrough) branch 1 taken 67% branch 2 taken 67% (fallthrough) branch 3 taken 33% -: 1738: convert = bit2rgb; 4: 1739: } else if (strcmp(imIn->mode, "I") == 0) { branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 50% (fallthrough) branch 3 taken 50% -: 1740: convert = i2rgb; -: 1741: } else { 2: 1742: convert = l2rgb; -: 1743: } -: 1744: g = b = r; -: 1745: } -: 1746: 8: 1747: imOut = ImagingNew2Dirty(mode, imOut, imIn); call 0 returned 100% 8: 1748: if (!imOut){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1749: return NULL; -: 1750: } -: 1751: 8: 1752: ImagingSectionEnter(&cookie); 584: 1753: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 576: 1754: (*convert)((UINT8*) imOut->image[y], (UINT8*) imIn->image[y], call 0 returned 100% -: 1755: imIn->xsize); 576: 1756: rgbT2rgba((UINT8*) imOut->image[y], imIn->xsize, r, g, b); call 0 returned 100% -: 1757: } 8: 1758: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1759: 8: 1760: return imOut; -: 1761: -: 1762:} -: 1763: -: 1764:Imaging function ImagingConvertInPlace called 6 returned 100% blocks executed 100% 6: 1765:ImagingConvertInPlace(Imaging imIn, const char* mode) -: 1766:{ -: 1767: ImagingSectionCookie cookie; -: 1768: ImagingShuffler convert; -: 1769: int y; -: 1770: -: 1771: /* limited support for inplace conversion */ 6: 1772: if (strcmp(imIn->mode, "L") == 0 && strcmp(mode, "1") == 0) { branch 0 taken 33% (fallthrough) branch 1 taken 67% branch 2 taken 33% (fallthrough) branch 3 taken 67% branch 4 taken 50% (fallthrough) branch 5 taken 50% branch 6 taken 50% (fallthrough) branch 7 taken 50% -: 1773: convert = l2bit; 5: 1774: } else if (strcmp(imIn->mode, "1") == 0 && strcmp(mode, "L") == 0) { branch 0 taken 20% (fallthrough) branch 1 taken 80% branch 2 taken 20% (fallthrough) branch 3 taken 80% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 0% (fallthrough) branch 7 taken 100% -: 1775: convert = bit2l; -: 1776: } else { 4: 1777: return ImagingError_ModeError(); call 0 returned 100% -: 1778: } -: 1779: 2: 1780: ImagingSectionEnter(&cookie); 4: 1781: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 50% branch 2 taken 50% (fallthrough) 2: 1782: (*convert)((UINT8*) imIn->image[y], (UINT8*) imIn->image[y], call 0 returned 100% -: 1783: imIn->xsize); -: 1784: } 2: 1785: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1786: 2: 1787: return imIn; -: 1788:} <<<<<< 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-s390x-3.8/src/libImaging/BitDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/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/#usr#include#webp#encode.h.gcov -: 0:Source:/usr/include/webp/encode.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:// Copyright 2011 Google Inc. All Rights Reserved. -: 2:// -: 3:// Use of this source code is governed by a BSD-style license -: 4:// that can be found in the COPYING file in the root of the source -: 5:// tree. An additional intellectual property rights grant can be found -: 6:// in the file PATENTS. All contributing project authors may -: 7:// be found in the AUTHORS file in the root of the source tree. -: 8:// ----------------------------------------------------------------------------- -: 9:// -: 10:// WebP encoder: main interface -: 11:// -: 12:// Author: Skal (pascal.massimino@gmail.com) -: 13: -: 14:#ifndef WEBP_WEBP_ENCODE_H_ -: 15:#define WEBP_WEBP_ENCODE_H_ -: 16: -: 17:#include "./types.h" -: 18: -: 19:#ifdef __cplusplus -: 20:extern "C" { -: 21:#endif -: 22: -: 23:#define WEBP_ENCODER_ABI_VERSION 0x020f // MAJOR(8b) + MINOR(8b) -: 24: -: 25:// Note: forward declaring enumerations is not allowed in (strict) C and C++, -: 26:// the types are left here for reference. -: 27:// typedef enum WebPImageHint WebPImageHint; -: 28:// typedef enum WebPEncCSP WebPEncCSP; -: 29:// typedef enum WebPPreset WebPPreset; -: 30:// typedef enum WebPEncodingError WebPEncodingError; -: 31:typedef struct WebPConfig WebPConfig; -: 32:typedef struct WebPPicture WebPPicture; // main structure for I/O -: 33:typedef struct WebPAuxStats WebPAuxStats; -: 34:typedef struct WebPMemoryWriter WebPMemoryWriter; -: 35: -: 36:// Return the encoder's version number, packed in hexadecimal using 8bits for -: 37:// each of major/minor/revision. E.g: v2.5.7 is 0x020507. -: 38:WEBP_EXTERN int WebPGetEncoderVersion(void); -: 39: -: 40://------------------------------------------------------------------------------ -: 41:// One-stop-shop call! No questions asked: -: 42: -: 43:// Returns the size of the compressed data (pointed to by *output), or 0 if -: 44:// an error occurred. The compressed data must be released by the caller -: 45:// using the call 'WebPFree(*output)'. -: 46:// These functions compress using the lossy format, and the quality_factor -: 47:// can go from 0 (smaller output, lower quality) to 100 (best quality, -: 48:// larger output). -: 49:WEBP_EXTERN size_t WebPEncodeRGB(const uint8_t* rgb, -: 50: int width, int height, int stride, -: 51: float quality_factor, uint8_t** output); -: 52:WEBP_EXTERN size_t WebPEncodeBGR(const uint8_t* bgr, -: 53: int width, int height, int stride, -: 54: float quality_factor, uint8_t** output); -: 55:WEBP_EXTERN size_t WebPEncodeRGBA(const uint8_t* rgba, -: 56: int width, int height, int stride, -: 57: float quality_factor, uint8_t** output); -: 58:WEBP_EXTERN size_t WebPEncodeBGRA(const uint8_t* bgra, -: 59: int width, int height, int stride, -: 60: float quality_factor, uint8_t** output); -: 61: -: 62:// These functions are the equivalent of the above, but compressing in a -: 63:// lossless manner. Files are usually larger than lossy format, but will -: 64:// not suffer any compression loss. -: 65:// Note these functions, like the lossy versions, use the library's default -: 66:// settings. For lossless this means 'exact' is disabled. RGB values in -: 67:// transparent areas will be modified to improve compression. To avoid this, -: 68:// use WebPEncode() and set WebPConfig::exact to 1. -: 69:WEBP_EXTERN size_t WebPEncodeLosslessRGB(const uint8_t* rgb, -: 70: int width, int height, int stride, -: 71: uint8_t** output); -: 72:WEBP_EXTERN size_t WebPEncodeLosslessBGR(const uint8_t* bgr, -: 73: int width, int height, int stride, -: 74: uint8_t** output); -: 75:WEBP_EXTERN size_t WebPEncodeLosslessRGBA(const uint8_t* rgba, -: 76: int width, int height, int stride, -: 77: uint8_t** output); -: 78:WEBP_EXTERN size_t WebPEncodeLosslessBGRA(const uint8_t* bgra, -: 79: int width, int height, int stride, -: 80: uint8_t** output); -: 81: -: 82://------------------------------------------------------------------------------ -: 83:// Coding parameters -: 84: -: 85:// Image characteristics hint for the underlying encoder. -: 86:typedef enum WebPImageHint { -: 87: WEBP_HINT_DEFAULT = 0, // default preset. -: 88: WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot -: 89: WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting -: 90: WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). -: 91: WEBP_HINT_LAST -: 92:} WebPImageHint; -: 93: -: 94:// Compression parameters. -: 95:struct WebPConfig { -: 96: int lossless; // Lossless encoding (0=lossy(default), 1=lossless). -: 97: float quality; // between 0 and 100. For lossy, 0 gives the smallest -: 98: // size and 100 the largest. For lossless, this -: 99: // parameter is the amount of effort put into the -: 100: // compression: 0 is the fastest but gives larger -: 101: // files compared to the slowest, but best, 100. -: 102: int method; // quality/speed trade-off (0=fast, 6=slower-better) -: 103: -: 104: WebPImageHint image_hint; // Hint for image type (lossless only for now). -: 105: -: 106: int target_size; // if non-zero, set the desired target size in bytes. -: 107: // Takes precedence over the 'compression' parameter. -: 108: float target_PSNR; // if non-zero, specifies the minimal distortion to -: 109: // try to achieve. Takes precedence over target_size. -: 110: int segments; // maximum number of segments to use, in [1..4] -: 111: int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. -: 112: int filter_strength; // range: [0 = off .. 100 = strongest] -: 113: int filter_sharpness; // range: [0 = off .. 7 = least sharp] -: 114: int filter_type; // filtering type: 0 = simple, 1 = strong (only used -: 115: // if filter_strength > 0 or autofilter > 0) -: 116: int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] -: 117: int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, -: 118: // 1 = compressed with WebP lossless). Default is 1. -: 119: int alpha_filtering; // Predictive filtering method for alpha plane. -: 120: // 0: none, 1: fast, 2: best. Default if 1. -: 121: int alpha_quality; // Between 0 (smallest size) and 100 (lossless). -: 122: // Default is 100. -: 123: int pass; // number of entropy-analysis passes (in [1..10]). -: 124: -: 125: int show_compressed; // if true, export the compressed picture back. -: 126: // In-loop filtering is not applied. -: 127: int preprocessing; // preprocessing filter: -: 128: // 0=none, 1=segment-smooth, 2=pseudo-random dithering -: 129: int partitions; // log2(number of token partitions) in [0..3]. Default -: 130: // is set to 0 for easier progressive decoding. -: 131: int partition_limit; // quality degradation allowed to fit the 512k limit -: 132: // on prediction modes coding (0: no degradation, -: 133: // 100: maximum possible degradation). -: 134: int emulate_jpeg_size; // If true, compression parameters will be remapped -: 135: // to better match the expected output size from -: 136: // JPEG compression. Generally, the output size will -: 137: // be similar but the degradation will be lower. -: 138: int thread_level; // If non-zero, try and use multi-threaded encoding. -: 139: int low_memory; // If set, reduce memory usage (but increase CPU use). -: 140: -: 141: int near_lossless; // Near lossless encoding [0 = max loss .. 100 = off -: 142: // (default)]. -: 143: int exact; // if non-zero, preserve the exact RGB values under -: 144: // transparent area. Otherwise, discard this invisible -: 145: // RGB information for better compression. The default -: 146: // value is 0. -: 147: -: 148: int use_delta_palette; // reserved for future lossless feature -: 149: int use_sharp_yuv; // if needed, use sharp (and slow) RGB->YUV conversion -: 150: -: 151: uint32_t pad[2]; // padding for later use -: 152:}; -: 153: -: 154:// Enumerate some predefined settings for WebPConfig, depending on the type -: 155:// of source picture. These presets are used when calling WebPConfigPreset(). -: 156:typedef enum WebPPreset { -: 157: WEBP_PRESET_DEFAULT = 0, // default preset. -: 158: WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot -: 159: WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting -: 160: WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details -: 161: WEBP_PRESET_ICON, // small-sized colorful images -: 162: WEBP_PRESET_TEXT // text-like -: 163:} WebPPreset; -: 164: -: 165:// Internal, version-checked, entry point -: 166:WEBP_EXTERN int WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); -: 167: -: 168:// Should always be called, to initialize a fresh WebPConfig structure before -: 169:// modification. Returns false in case of version mismatch. WebPConfigInit() -: 170:// must have succeeded before using the 'config' object. -: 171:// Note that the default values are lossless=0 and quality=75. -: 172:static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { 105: 173: return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, call 0 returned 100% call 1 returned 100% -: 174: WEBP_ENCODER_ABI_VERSION); -: 175:} -: 176: -: 177:// This function will initialize the configuration according to a predefined -: 178:// set of parameters (referred to by 'preset') and a given quality factor. -: 179:// This function can be called as a replacement to WebPConfigInit(). Will -: 180:// return false in case of error. -: 181:static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, -: 182: WebPPreset preset, float quality) { -: 183: return WebPConfigInitInternal(config, preset, quality, -: 184: WEBP_ENCODER_ABI_VERSION); -: 185:} -: 186: -: 187:// Activate the lossless compression mode with the desired efficiency level -: 188:// between 0 (fastest, lowest compression) and 9 (slower, best compression). -: 189:// A good default level is '6', providing a fair tradeoff between compression -: 190:// speed and final compressed size. -: 191:// This function will overwrite several fields from config: 'method', 'quality' -: 192:// and 'lossless'. Returns false in case of parameter error. -: 193:WEBP_EXTERN int WebPConfigLosslessPreset(WebPConfig* config, int level); -: 194: -: 195:// Returns true if 'config' is non-NULL and all configuration parameters are -: 196:// within their valid ranges. -: 197:WEBP_EXTERN int WebPValidateConfig(const WebPConfig* config); -: 198: -: 199://------------------------------------------------------------------------------ -: 200:// Input / Output -: 201:// Structure for storing auxiliary statistics. -: 202: -: 203:struct WebPAuxStats { -: 204: int coded_size; // final size -: 205: -: 206: float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha -: 207: int block_count[3]; // number of intra4/intra16/skipped macroblocks -: 208: int header_bytes[2]; // approximate number of bytes spent for header -: 209: // and mode-partition #0 -: 210: int residual_bytes[3][4]; // approximate number of bytes spent for -: 211: // DC/AC/uv coefficients for each (0..3) segments. -: 212: int segment_size[4]; // number of macroblocks in each segments -: 213: int segment_quant[4]; // quantizer values for each segments -: 214: int segment_level[4]; // filtering strength for each segments [0..63] -: 215: -: 216: int alpha_data_size; // size of the transparency data -: 217: int layer_data_size; // size of the enhancement layer data -: 218: -: 219: // lossless encoder statistics -: 220: uint32_t lossless_features; // bit0:predictor bit1:cross-color transform -: 221: // bit2:subtract-green bit3:color indexing -: 222: int histogram_bits; // number of precision bits of histogram -: 223: int transform_bits; // precision bits for transform -: 224: int cache_bits; // number of bits for color cache lookup -: 225: int palette_size; // number of color in palette, if used -: 226: int lossless_size; // final lossless size -: 227: int lossless_hdr_size; // lossless header (transform, huffman etc) size -: 228: int lossless_data_size; // lossless image data size -: 229: -: 230: uint32_t pad[2]; // padding for later use -: 231:}; -: 232: -: 233:// Signature for output function. Should return true if writing was successful. -: 234:// data/data_size is the segment of data to write, and 'picture' is for -: 235:// reference (and so one can make use of picture->custom_ptr). -: 236:typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, -: 237: const WebPPicture* picture); -: 238: -: 239:// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using -: 240:// the following WebPMemoryWriter object (to be set as a custom_ptr). -: 241:struct WebPMemoryWriter { -: 242: uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). -: 243: size_t size; // final size -: 244: size_t max_size; // total capacity -: 245: uint32_t pad[1]; // padding for later use -: 246:}; -: 247: -: 248:// The following must be called first before any use. -: 249:WEBP_EXTERN void WebPMemoryWriterInit(WebPMemoryWriter* writer); -: 250: -: 251:// The following must be called to deallocate writer->mem memory. The 'writer' -: 252:// object itself is not deallocated. -: 253:WEBP_EXTERN void WebPMemoryWriterClear(WebPMemoryWriter* writer); -: 254:// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon -: 255:// completion, writer.mem and writer.size will hold the coded data. -: 256:// writer.mem must be freed by calling WebPMemoryWriterClear. -: 257:WEBP_EXTERN int WebPMemoryWrite(const uint8_t* data, size_t data_size, -: 258: const WebPPicture* picture); -: 259: -: 260:// Progress hook, called from time to time to report progress. It can return -: 261:// false to request an abort of the encoding process, or true otherwise if -: 262:// everything is OK. -: 263:typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); -: 264: -: 265:// Color spaces. -: 266:typedef enum WebPEncCSP { -: 267: // chroma sampling -: 268: WEBP_YUV420 = 0, // 4:2:0 -: 269: WEBP_YUV420A = 4, // alpha channel variant -: 270: WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors -: 271: WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present -: 272:} WebPEncCSP; -: 273: -: 274:// Encoding error conditions. -: 275:typedef enum WebPEncodingError { -: 276: VP8_ENC_OK = 0, -: 277: VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects -: 278: VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits -: 279: VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL -: 280: VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid -: 281: VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height -: 282: VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k -: 283: VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M -: 284: VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes -: 285: VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G -: 286: VP8_ENC_ERROR_USER_ABORT, // abort request by user -: 287: VP8_ENC_ERROR_LAST // list terminator. always last. -: 288:} WebPEncodingError; -: 289: -: 290:// maximum width/height allowed (inclusive), in pixels -: 291:#define WEBP_MAX_DIMENSION 16383 -: 292: -: 293:// Main exchange structure (input samples, output bytes, statistics) -: 294:struct WebPPicture { -: 295: // INPUT -: 296: ////////////// -: 297: // Main flag for encoder selecting between ARGB or YUV input. -: 298: // It is recommended to use ARGB input (*argb, argb_stride) for lossless -: 299: // compression, and YUV input (*y, *u, *v, etc.) for lossy compression -: 300: // since these are the respective native colorspace for these formats. -: 301: int use_argb; -: 302: -: 303: // YUV input (mostly used for input to lossy compression) -: 304: WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). -: 305: int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) -: 306: uint8_t* y, *u, *v; // pointers to luma/chroma planes. -: 307: int y_stride, uv_stride; // luma/chroma strides. -: 308: uint8_t* a; // pointer to the alpha plane -: 309: int a_stride; // stride of the alpha plane -: 310: uint32_t pad1[2]; // padding for later use -: 311: -: 312: // ARGB input (mostly used for input to lossless compression) -: 313: uint32_t* argb; // Pointer to argb (32 bit) plane. -: 314: int argb_stride; // This is stride in pixels units, not bytes. -: 315: uint32_t pad2[3]; // padding for later use -: 316: -: 317: // OUTPUT -: 318: /////////////// -: 319: // Byte-emission hook, to store compressed bytes as they are ready. -: 320: WebPWriterFunction writer; // can be NULL -: 321: void* custom_ptr; // can be used by the writer. -: 322: -: 323: // map for extra information (only for lossy compression mode) -: 324: int extra_info_type; // 1: intra type, 2: segment, 3: quant -: 325: // 4: intra-16 prediction mode, -: 326: // 5: chroma prediction mode, -: 327: // 6: bit cost, 7: distortion -: 328: uint8_t* extra_info; // if not NULL, points to an array of size -: 329: // ((width + 15) / 16) * ((height + 15) / 16) that -: 330: // will be filled with a macroblock map, depending -: 331: // on extra_info_type. -: 332: -: 333: // STATS AND REPORTS -: 334: /////////////////////////// -: 335: // Pointer to side statistics (updated only if not NULL) -: 336: WebPAuxStats* stats; -: 337: -: 338: // Error code for the latest error encountered during encoding -: 339: WebPEncodingError error_code; -: 340: -: 341: // If not NULL, report progress during encoding. -: 342: WebPProgressHook progress_hook; -: 343: -: 344: void* user_data; // this field is free to be set to any value and -: 345: // used during callbacks (like progress-report e.g.). -: 346: -: 347: uint32_t pad3[3]; // padding for later use -: 348: -: 349: // Unused for now -: 350: uint8_t* pad4, *pad5; -: 351: uint32_t pad6[8]; // padding for later use -: 352: -: 353: // PRIVATE FIELDS -: 354: //////////////////// -: 355: void* memory_; // row chunk of memory for yuva planes -: 356: void* memory_argb_; // and for argb too. -: 357: void* pad7[2]; // padding for later use -: 358:}; -: 359: -: 360:// Internal, version-checked, entry point -: 361:WEBP_EXTERN int WebPPictureInitInternal(WebPPicture*, int); -: 362: -: 363:// Should always be called, to initialize the structure. Returns false in case -: 364:// of version mismatch. WebPPictureInit() must have succeeded before using the -: 365:// 'picture' object. -: 366:// Note that, by default, use_argb is false and colorspace is WEBP_YUV420. -: 367:static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { 22: 368: return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); call 0 returned 100% call 1 returned 100% -: 369:} -: 370: -: 371://------------------------------------------------------------------------------ -: 372:// WebPPicture utils -: 373: -: 374:// Convenience allocation / deallocation based on picture->width/height: -: 375:// Allocate y/u/v buffers as per colorspace/width/height specification. -: 376:// Note! This function will free the previous buffer if needed. -: 377:// Returns false in case of memory error. -: 378:WEBP_EXTERN int WebPPictureAlloc(WebPPicture* picture); -: 379: -: 380:// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). -: 381:// Note that this function does _not_ free the memory used by the 'picture' -: 382:// object itself. -: 383:// Besides memory (which is reclaimed) all other fields of 'picture' are -: 384:// preserved. -: 385:WEBP_EXTERN void WebPPictureFree(WebPPicture* picture); -: 386: -: 387:// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst -: 388:// will fully own the copied pixels (this is not a view). The 'dst' picture need -: 389:// not be initialized as its content is overwritten. -: 390:// Returns false in case of memory allocation error. -: 391:WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); -: 392: -: 393:// Compute the single distortion for packed planes of samples. -: 394:// 'src' will be compared to 'ref', and the raw distortion stored into -: 395:// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be -: 396:// stored in '*result'. -: 397:// 'x_step' is the horizontal stride (in bytes) between samples. -: 398:// 'src/ref_stride' is the byte distance between rows. -: 399:// Returns false in case of error (bad parameter, memory allocation error, ...). -: 400:WEBP_EXTERN int WebPPlaneDistortion(const uint8_t* src, size_t src_stride, -: 401: const uint8_t* ref, size_t ref_stride, -: 402: int width, int height, -: 403: size_t x_step, -: 404: int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM -: 405: float* distortion, float* result); -: 406: -: 407:// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results -: 408:// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is -: 409:// always performed using ARGB samples. Hence if the input is YUV(A), the -: 410:// picture will be internally converted to ARGB (just for the measurement). -: 411:// Warning: this function is rather CPU-intensive. -: 412:WEBP_EXTERN int WebPPictureDistortion( -: 413: const WebPPicture* src, const WebPPicture* ref, -: 414: int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM -: 415: float result[5]); -: 416: -: 417:// self-crops a picture to the rectangle defined by top/left/width/height. -: 418:// Returns false in case of memory allocation error, or if the rectangle is -: 419:// outside of the source picture. -: 420:// The rectangle for the view is defined by the top-left corner pixel -: 421:// coordinates (left, top) as well as its width and height. This rectangle -: 422:// must be fully be comprised inside the 'src' source picture. If the source -: 423:// picture uses the YUV420 colorspace, the top and left coordinates will be -: 424:// snapped to even values. -: 425:WEBP_EXTERN int WebPPictureCrop(WebPPicture* picture, -: 426: int left, int top, int width, int height); -: 427: -: 428:// Extracts a view from 'src' picture into 'dst'. The rectangle for the view -: 429:// is defined by the top-left corner pixel coordinates (left, top) as well -: 430:// as its width and height. This rectangle must be fully be comprised inside -: 431:// the 'src' source picture. If the source picture uses the YUV420 colorspace, -: 432:// the top and left coordinates will be snapped to even values. -: 433:// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed -: 434:// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, -: 435:// the original dimension will be lost). Picture 'dst' need not be initialized -: 436:// with WebPPictureInit() if it is different from 'src', since its content will -: 437:// be overwritten. -: 438:// Returns false in case of memory allocation error or invalid parameters. -: 439:WEBP_EXTERN int WebPPictureView(const WebPPicture* src, -: 440: int left, int top, int width, int height, -: 441: WebPPicture* dst); -: 442: -: 443:// Returns true if the 'picture' is actually a view and therefore does -: 444:// not own the memory for pixels. -: 445:WEBP_EXTERN int WebPPictureIsView(const WebPPicture* picture); -: 446: -: 447:// Rescale a picture to new dimension width x height. -: 448:// If either 'width' or 'height' (but not both) is 0 the corresponding -: 449:// dimension will be calculated preserving the aspect ratio. -: 450:// No gamma correction is applied. -: 451:// Returns false in case of error (invalid parameter or insufficient memory). -: 452:WEBP_EXTERN int WebPPictureRescale(WebPPicture* pic, int width, int height); -: 453: -: 454:// Colorspace conversion function to import RGB samples. -: 455:// Previous buffer will be free'd, if any. -: 456:// *rgb buffer should have a size of at least height * rgb_stride. -: 457:// Returns false in case of memory error. -: 458:WEBP_EXTERN int WebPPictureImportRGB( -: 459: WebPPicture* picture, const uint8_t* rgb, int rgb_stride); -: 460:// Same, but for RGBA buffer. -: 461:WEBP_EXTERN int WebPPictureImportRGBA( -: 462: WebPPicture* picture, const uint8_t* rgba, int rgba_stride); -: 463:// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format -: 464:// input buffer ignoring the alpha channel. Avoids needing to copy the data -: 465:// to a temporary 24-bit RGB buffer to import the RGB only. -: 466:WEBP_EXTERN int WebPPictureImportRGBX( -: 467: WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); -: 468: -: 469:// Variants of the above, but taking BGR(A|X) input. -: 470:WEBP_EXTERN int WebPPictureImportBGR( -: 471: WebPPicture* picture, const uint8_t* bgr, int bgr_stride); -: 472:WEBP_EXTERN int WebPPictureImportBGRA( -: 473: WebPPicture* picture, const uint8_t* bgra, int bgra_stride); -: 474:WEBP_EXTERN int WebPPictureImportBGRX( -: 475: WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); -: 476: -: 477:// Converts picture->argb data to the YUV420A format. The 'colorspace' -: 478:// parameter is deprecated and should be equal to WEBP_YUV420. -: 479:// Upon return, picture->use_argb is set to false. The presence of real -: 480:// non-opaque transparent values is detected, and 'colorspace' will be -: 481:// adjusted accordingly. Note that this method is lossy. -: 482:// Returns false in case of error. -: 483:WEBP_EXTERN int WebPPictureARGBToYUVA(WebPPicture* picture, -: 484: WebPEncCSP /*colorspace = WEBP_YUV420*/); -: 485: -: 486:// Same as WebPPictureARGBToYUVA(), but the conversion is done using -: 487:// pseudo-random dithering with a strength 'dithering' between -: 488:// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful -: 489:// for photographic picture. -: 490:WEBP_EXTERN int WebPPictureARGBToYUVADithered( -: 491: WebPPicture* picture, WebPEncCSP colorspace, float dithering); -: 492: -: 493:// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion. -: 494:// Downsampling is handled with extra care in case of color clipping. This -: 495:// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better -: 496:// and sharper YUV representation. -: 497:// Returns false in case of error. -: 498:WEBP_EXTERN int WebPPictureSharpARGBToYUVA(WebPPicture* picture); -: 499:// kept for backward compatibility: -: 500:WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture); -: 501: -: 502:// Converts picture->yuv to picture->argb and sets picture->use_argb to true. -: 503:// The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to -: 504:// ARGB incurs a small loss too. -: 505:// Note that the use of this colorspace is discouraged if one has access to the -: 506:// raw ARGB samples, since using YUV420 is comparatively lossy. -: 507:// Returns false in case of error. -: 508:WEBP_EXTERN int WebPPictureYUVAToARGB(WebPPicture* picture); -: 509: -: 510:// Helper function: given a width x height plane of RGBA or YUV(A) samples -: 511:// clean-up or smoothen the YUV or RGB samples under fully transparent area, -: 512:// to help compressibility (no guarantee, though). -: 513:WEBP_EXTERN void WebPCleanupTransparentArea(WebPPicture* picture); -: 514: -: 515:// Scan the picture 'picture' for the presence of non fully opaque alpha values. -: 516:// Returns true in such case. Otherwise returns false (indicating that the -: 517:// alpha plane can be ignored altogether e.g.). -: 518:WEBP_EXTERN int WebPPictureHasTransparency(const WebPPicture* picture); -: 519: -: 520:// Remove the transparency information (if present) by blending the color with -: 521:// the background color 'background_rgb' (specified as 24bit RGB triplet). -: 522:// After this call, all alpha values are reset to 0xff. -: 523:WEBP_EXTERN void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb); -: 524: -: 525://------------------------------------------------------------------------------ -: 526:// Main call -: 527: -: 528:// Main encoding call, after config and picture have been initialized. -: 529:// 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), -: 530:// and the 'config' object must be a valid one. -: 531:// Returns false in case of error, true otherwise. -: 532:// In case of error, picture->error_code is updated accordingly. -: 533:// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending -: 534:// on the value of 'picture->use_argb'. It is highly recommended to use -: 535:// the former for lossy encoding, and the latter for lossless encoding -: 536:// (when config.lossless is true). Automatic conversion from one format to -: 537:// another is provided but they both incur some loss. -: 538:WEBP_EXTERN int WebPEncode(const WebPConfig* config, WebPPicture* picture); -: 539: -: 540://------------------------------------------------------------------------------ -: 541: -: 542:#ifdef __cplusplus -: 543:} // extern "C" -: 544:#endif -: 545: -: 546:#endif // WEBP_WEBP_ENCODE_H_ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ColorLUT.c.gcov -: 0:Source:src/libImaging/ColorLUT.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/ColorLUT.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/ColorLUT.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Imaging.h" -: 2:#include -: 3: -: 4: -: 5:/* 8 bits for result. Table can overflow [0, 1.0] range, -: 6: so we need extra bits for overflow and negative values. -: 7: NOTE: This value should be the same as in _imaging/_prepare_lut_table() */ -: 8:#define PRECISION_BITS (16 - 8 - 2) -: 9:#define PRECISION_ROUNDING (1<<(PRECISION_BITS-1)) -: 10: -: 11:/* 8 — scales are multiplied on byte. -: 12: 6 — max index in the table -: 13: (max size is 65, but index 64 is not reachable) */ -: 14:#define SCALE_BITS (32 - 8 - 6) -: 15:#define SCALE_MASK ((1<> PRECISION_BITS]; -: 23:} -: 24: -: 25:static inline void -: 26:interpolate3(INT16 out[3], const INT16 a[3], const INT16 b[3], INT16 shift) -: 27:{ 8263136: 28: out[0] = (a[0] * ((1<> SHIFT_BITS; 8263136: 29: out[1] = (a[1] * ((1<> SHIFT_BITS; 8263136: 30: out[2] = (a[2] * ((1<> SHIFT_BITS; -: 31:} -: 32: -: 33:static inline void function interpolate4 called 460852 returned 100% blocks executed 100% 460852: 34:interpolate4(INT16 out[4], const INT16 a[4], const INT16 b[4], INT16 shift) -: 35:{ 460852: 36: out[0] = (a[0] * ((1<> SHIFT_BITS; 460852: 37: out[1] = (a[1] * ((1<> SHIFT_BITS; 460852: 38: out[2] = (a[2] * ((1<> SHIFT_BITS; 460852: 39: out[3] = (a[3] * ((1<> SHIFT_BITS; 460852: 40:} -: 41: -: 42:static inline int -: 43:table_index3D(int index1D, int index2D, int index3D, -: 44: int size1D, int size1D_2D) -: 45:{ 1246284: 46: return index1D + index2D * size1D + index3D * size1D_2D; -: 47:} -: 48: -: 49: -: 50:/* -: 51: Transforms colors of imIn using provided 3D lookup table -: 52: and puts the result in imOut. Returns imOut on success or 0 on error. -: 53: -: 54: imOut, imIn — images, should be the same size and may be the same image. -: 55: Should have 3 or 4 channels. -: 56: table_channels — number of channels in the lookup table, 3 or 4. -: 57: Should be less or equal than number of channels in imOut image; -: 58: size1D, size_2D and size3D — dimensions of provided table; -: 59: table — flat table, -: 60: array with table_channels × size1D × size2D × size3D elements, -: 61: where channels are changed first, then 1D, then​ 2D, then 3D. -: 62: Each element is signed 16-bit int where 0 is lowest output value -: 63: and 255 << PRECISION_BITS (16320) is highest value. -: 64:*/ -: 65:Imaging function ImagingColorLUT3D_linear called 37 returned 100% blocks executed 100% 37: 66:ImagingColorLUT3D_linear(Imaging imOut, Imaging imIn, int table_channels, -: 67: int size1D, int size2D, int size3D, -: 68: INT16* table) -: 69:{ -: 70: /* This float to int conversion doesn't have rounding -: 71: error compensation (+0.5) for two reasons: -: 72: 1. As we don't hit the highest value, -: 73: we can use one extra bit for precision. -: 74: 2. For every pixel, we interpolate 8 elements from the table: -: 75: current and +1 for every dimension and their combinations. -: 76: If we hit the upper cells from the table, -: 77: +1 cells will be outside of the table. -: 78: With this compensation we never hit the upper cells -: 79: but this also doesn't introduce any noticeable difference. */ 37: 80: UINT32 scale1D = (size1D - 1) / 255.0 * (1< 4) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 2: 88: PyErr_SetString(PyExc_ValueError, "table_channels could be 3 or 4"); call 0 returned 100% 2: 89: return NULL; -: 90: } -: 91: 70: 92: if (imIn->type != IMAGING_TYPE_UINT8 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 70: 93: imOut->type != IMAGING_TYPE_UINT8 || branch 0 taken 94% (fallthrough) branch 1 taken 6% 68: 94: imIn->bands < 3 || branch 0 taken 6% (fallthrough) branch 1 taken 94% 33: 95: imOut->bands < table_channels -: 96: ) { 4: 97: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 98: } -: 99: -: 100: /* In case we have one extra band in imOut and don't have in imIn.*/ 31: 101: if (imOut->bands > table_channels && imOut->bands > imIn->bands) { branch 0 taken 10% (fallthrough) branch 1 taken 90% branch 2 taken 33% (fallthrough) branch 3 taken 67% 1: 102: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 103: } -: 104: 30: 105: ImagingSectionEnter(&cookie); 5004: 106: for (y = 0; y < imOut->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 4974: 107: UINT8* rowIn = (UINT8 *)imIn->image[y]; 4974: 108: char* rowOut = (char *)imOut->image[y]; 1251258: 109: for (x = 0; x < imOut->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1246284: 110: UINT32 index1D = rowIn[x*4 + 0] * scale1D; 1246284: 111: UINT32 index2D = rowIn[x*4 + 1] * scale2D; 1246284: 112: UINT32 index3D = rowIn[x*4 + 2] * scale3D; 1246284: 113: INT16 shift1D = (SCALE_MASK & index1D) >> (SCALE_BITS - SHIFT_BITS); 1246284: 114: INT16 shift2D = (SCALE_MASK & index2D) >> (SCALE_BITS - SHIFT_BITS); 1246284: 115: INT16 shift3D = (SCALE_MASK & index3D) >> (SCALE_BITS - SHIFT_BITS); 4985136: 116: int idx = table_channels * table_index3D( 2492568: 117: index1D >> SCALE_BITS, index2D >> SCALE_BITS, 1246284: 118: index3D >> SCALE_BITS, size1D, size1D_2D); -: 119: INT16 result[4], left[4], right[4]; -: 120: INT16 leftleft[4], leftright[4], rightleft[4], rightright[4]; -: 121: 1246284: 122: if (table_channels == 3) { branch 0 taken 95% (fallthrough) branch 1 taken 5% -: 123: UINT32 v; 2360896: 124: interpolate3(leftleft, &table[idx + 0], &table[idx + 3], shift1D); 2360896: 125: interpolate3(leftright, &table[idx + size1D*3], 1180448: 126: &table[idx + size1D*3 + 3], shift1D); 1180448: 127: interpolate3(left, leftleft, leftright, shift2D); -: 128: 2360896: 129: interpolate3(rightleft, &table[idx + size1D_2D*3], 1180448: 130: &table[idx + size1D_2D*3 + 3], shift1D); 2360896: 131: interpolate3(rightright, &table[idx + size1D_2D*3 + size1D*3], 1180448: 132: &table[idx + size1D_2D*3 + size1D*3 + 3], shift1D); 1180448: 133: interpolate3(right, rightleft, rightright, shift2D); -: 134: 1180448: 135: interpolate3(result, left, right, shift3D); -: 136: 4721792: 137: v = MAKE_UINT32( -: 138: clip8(result[0]), clip8(result[1]), -: 139: clip8(result[2]), rowIn[x*4 + 3]); 2360896: 140: memcpy(rowOut + x * sizeof(v), &v, sizeof(v)); -: 141: } -: 142: 1246284: 143: if (table_channels == 4) { branch 0 taken 5% (fallthrough) branch 1 taken 95% -: 144: UINT32 v; 65836: 145: interpolate4(leftleft, &table[idx + 0], &table[idx + 4], shift1D); call 0 returned 100% 131672: 146: interpolate4(leftright, &table[idx + size1D*4], call 0 returned 100% 65836: 147: &table[idx + size1D*4 + 4], shift1D); 65836: 148: interpolate4(left, leftleft, leftright, shift2D); call 0 returned 100% -: 149: 131672: 150: interpolate4(rightleft, &table[idx + size1D_2D*4], call 0 returned 100% 65836: 151: &table[idx + size1D_2D*4 + 4], shift1D); 131672: 152: interpolate4(rightright, &table[idx + size1D_2D*4 + size1D*4], call 0 returned 100% 65836: 153: &table[idx + size1D_2D*4 + size1D*4 + 4], shift1D); 65836: 154: interpolate4(right, rightleft, rightright, shift2D); call 0 returned 100% -: 155: 65836: 156: interpolate4(result, left, right, shift3D); call 0 returned 100% -: 157: 329180: 158: v = MAKE_UINT32( -: 159: clip8(result[0]), clip8(result[1]), -: 160: clip8(result[2]), clip8(result[3])); 131672: 161: memcpy(rowOut + x * sizeof(v), &v, sizeof(v)); -: 162: } -: 163: } -: 164: } 30: 165: ImagingSectionLeave(&cookie); call 0 returned 100% -: 166: 30: 167: return imOut; -: 168:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#PcxDecode.c.gcov -: 0:Source:src/libImaging/PcxDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/PcxDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/PcxDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for PCX image data. -: 6: * -: 7: * history: -: 8: * 95-09-14 fl Created -: 9: * -: 10: * Copyright (c) Fredrik Lundh 1995. -: 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 ImagingPcxDecode called 45 returned 100% blocks executed 96% 45: 20:ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 21:{ -: 22: UINT8 n; -: 23: UINT8* ptr; -: 24: 45: 25: if ((state->xsize * state->bits + 7) / 8 > state->bytes) { branch 0 taken 93% (fallthrough) branch 1 taken 7% 3: 26: state->errcode = IMAGING_CODEC_OVERRUN; 3: 27: return -1; -: 28: } -: 29: -: 30: ptr = buf; -: 31: -: 32: for (;;) { -: 33: 1084658: 34: if (bytes < 1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 16: 35: return ptr - buf; -: 36: } -: 37: 1084642: 38: if ((*ptr & 0xC0) == 0xC0) { branch 0 taken 39% (fallthrough) branch 1 taken 61% -: 39: -: 40: /* Run */ 421242: 41: if (bytes < 2) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 4: 42: return ptr - buf; -: 43: } -: 44: 421238: 45: n = ptr[0] & 0x3F; -: 46: 2817038: 47: while (n > 0) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 1974562: 48: if (state->x >= state->bytes) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 49: state->errcode = IMAGING_CODEC_OVERRUN; #####: 50: break; -: 51: } 1974562: 52: state->buffer[state->x++] = ptr[1]; 1974562: 53: n--; -: 54: } -: 55: 421238: 56: ptr += 2; bytes -= 2; -: 57: -: 58: } else { -: 59: -: 60: /* Literal */ 663400: 61: state->buffer[state->x++] = ptr[0]; 663400: 62: ptr++; bytes--; -: 63: -: 64: } -: 65: 1084638: 66: if (state->x >= state->bytes) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4499: 67: if (state->bytes % state->xsize && state->bytes > state->xsize) { branch 0 taken 52% (fallthrough) branch 1 taken 48% branch 2 taken 66% (fallthrough) branch 3 taken 34% 1538: 68: int bands = state->bytes / state->xsize; 1538: 69: int stride = state->bytes / bands; -: 70: int i; 2560: 71: for (i=1; i< bands; i++) { // note -- skipping first band branch 0 taken 40% branch 1 taken 60% (fallthrough) 3066: 72: memmove(&state->buffer[i*state->xsize], 1022: 73: &state->buffer[i*stride], -: 74: state->xsize); -: 75: } -: 76: } -: 77: /* Got a full line, unpack it */ 13497: 78: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 8998: 79: state->xoff * im->pixelsize, state->buffer, -: 80: state->xsize); -: 81: 4499: 82: state->x = 0; -: 83: 4499: 84: if (++state->y >= state->ysize) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 85: /* End of file (errcode = 0) */ -: 86: return -1; -: 87: } -: 88: } -: 89: -: 90: } -: 91:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Negative.c.gcov -: 0:Source:src/libImaging/Negative.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Negative.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Negative.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * negate image -: 6: * -: 7: * to do: -: 8: * FIXME: Maybe this should be implemented using ImagingPoint() -: 9: * -: 10: * history: -: 11: * 95-11-27 fl: Created -: 12: * -: 13: * Copyright (c) Fredrik Lundh 1995. -: 14: * Copyright (c) Secret Labs AB 1997. -: 15: * -: 16: * See the README file for information on usage and redistribution. -: 17: */ -: 18: -: 19: -: 20:#include "Imaging.h" -: 21: -: 22: -: 23:Imaging function ImagingNegative called 2 returned 100% blocks executed 91% 2: 24:ImagingNegative(Imaging im) -: 25:{ -: 26: Imaging imOut; -: 27: int x, y; -: 28: 2: 29: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 30: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 31: } -: 32: 2: 33: imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize); call 0 returned 100% 2: 34: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 35: return NULL; -: 36: } -: 37: 228: 38: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 56384: 39: for (x = 0; x < im->linesize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 56384: 40: imOut->image[y][x] = ~im->image[y][x]; -: 41: } -: 42: } -: 43: -: 44: return imOut; -: 45:} -: 46: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#s390x-linux-gnu#bits#string3.h.gcov -: 0:Source:/usr/include/s390x-linux-gnu/bits/string3.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/codec_fd.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/codec_fd.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* Copyright (C) 2004-2016 Free Software Foundation, Inc. -: 2: This file is part of the GNU C Library. -: 3: -: 4: The GNU C Library is free software; you can redistribute it and/or -: 5: modify it under the terms of the GNU Lesser General Public -: 6: License as published by the Free Software Foundation; either -: 7: version 2.1 of the License, or (at your option) any later version. -: 8: -: 9: The GNU C Library is distributed in the hope that it will be useful, -: 10: but WITHOUT ANY WARRANTY; without even the implied warranty of -: 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -: 12: Lesser General Public License for more details. -: 13: -: 14: You should have received a copy of the GNU Lesser General Public -: 15: License along with the GNU C Library; if not, see -: 16: . */ -: 17: -: 18:#ifndef _STRING_H -: 19:# error "Never use directly; include instead." -: 20:#endif -: 21: -: 22:#if !__GNUC_PREREQ (5,0) -: 23:__warndecl (__warn_memset_zero_len, -: 24: "memset used with constant zero length parameter; this could be due to transposed parameters"); -: 25:#endif -: 26: -: 27:#ifndef __cplusplus -: 28:/* XXX This is temporarily. We should not redefine any of the symbols -: 29: and instead integrate the error checking into the original -: 30: definitions. */ -: 31:# undef memcpy -: 32:# undef memmove -: 33:# undef memset -: 34:# undef strcat -: 35:# undef strcpy -: 36:# undef strncat -: 37:# undef strncpy -: 38:# ifdef __USE_GNU -: 39:# undef mempcpy -: 40:# undef stpcpy -: 41:# endif -: 42:# ifdef __USE_MISC -: 43:# undef bcopy -: 44:# undef bzero -: 45:# endif -: 46:#endif -: 47: -: 48: -: 49:__fortify_function void * -: 50:__NTH (memcpy (void *__restrict __dest, const void *__restrict __src, -: 51: size_t __len)) -: 52:{ 69: 53: return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); -: 54:} -: 55: -: 56:__fortify_function void * -: 57:__NTH (memmove (void *__dest, const void *__src, size_t __len)) -: 58:{ -: 59: return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); -: 60:} -: 61: -: 62:#ifdef __USE_GNU -: 63:__fortify_function void * -: 64:__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src, -: 65: size_t __len)) -: 66:{ -: 67: return __builtin___mempcpy_chk (__dest, __src, __len, __bos0 (__dest)); -: 68:} -: 69:#endif -: 70: -: 71: -: 72:/* The first two tests here help to catch a somewhat common problem -: 73: where the second and third parameter are transposed. This is -: 74: especially problematic if the intended fill value is zero. In this -: 75: case no work is done at all. We detect these problems by referring -: 76: non-existing functions. */ -: 77:__fortify_function void * -: 78:__NTH (memset (void *__dest, int __ch, size_t __len)) -: 79:{ -: 80: /* GCC-5.0 and newer implements these checks in the compiler, so we don't -: 81: need them here. */ -: 82:#if !__GNUC_PREREQ (5,0) -: 83: if (__builtin_constant_p (__len) && __len == 0 -: 84: && (!__builtin_constant_p (__ch) || __ch != 0)) -: 85: { -: 86: __warn_memset_zero_len (); -: 87: return __dest; -: 88: } -: 89:#endif -: 90: return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest)); -: 91:} -: 92: -: 93:#ifdef __USE_MISC -: 94:__fortify_function void -: 95:__NTH (bcopy (const void *__src, void *__dest, size_t __len)) -: 96:{ -: 97: (void) __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); -: 98:} -: 99: -: 100:__fortify_function void -: 101:__NTH (bzero (void *__dest, size_t __len)) -: 102:{ -: 103: (void) __builtin___memset_chk (__dest, '\0', __len, __bos0 (__dest)); -: 104:} -: 105:#endif -: 106: -: 107:__fortify_function char * -: 108:__NTH (strcpy (char *__restrict __dest, const char *__restrict __src)) -: 109:{ -: 110: return __builtin___strcpy_chk (__dest, __src, __bos (__dest)); -: 111:} -: 112: -: 113:#ifdef __USE_GNU -: 114:__fortify_function char * -: 115:__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src)) -: 116:{ -: 117: return __builtin___stpcpy_chk (__dest, __src, __bos (__dest)); -: 118:} -: 119:#endif -: 120: -: 121: -: 122:__fortify_function char * -: 123:__NTH (strncpy (char *__restrict __dest, const char *__restrict __src, -: 124: size_t __len)) -: 125:{ -: 126: return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); -: 127:} -: 128: -: 129:// XXX We have no corresponding builtin yet. -: 130:extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, -: 131: size_t __destlen) __THROW; -: 132:extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src, -: 133: size_t __n), stpncpy); -: 134: -: 135:__fortify_function char * -: 136:__NTH (stpncpy (char *__dest, const char *__src, size_t __n)) -: 137:{ -: 138: if (__bos (__dest) != (size_t) -1 -: 139: && (!__builtin_constant_p (__n) || __n > __bos (__dest))) -: 140: return __stpncpy_chk (__dest, __src, __n, __bos (__dest)); -: 141: return __stpncpy_alias (__dest, __src, __n); -: 142:} -: 143: -: 144: -: 145:__fortify_function char * -: 146:__NTH (strcat (char *__restrict __dest, const char *__restrict __src)) -: 147:{ -: 148: return __builtin___strcat_chk (__dest, __src, __bos (__dest)); -: 149:} -: 150: -: 151: -: 152:__fortify_function char * -: 153:__NTH (strncat (char *__restrict __dest, const char *__restrict __src, -: 154: size_t __len)) -: 155:{ -: 156: return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); -: 157:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Crop.c.gcov -: 0:Source:src/libImaging/Crop.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Crop.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Crop.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * cut region from image -: 6: * -: 7: * history: -: 8: * 95-11-27 fl Created -: 9: * 98-07-10 fl Fixed "null result" error -: 10: * 99-02-05 fl Rewritten to use Paste primitive -: 11: * -: 12: * Copyright (c) Secret Labs AB 1997-99. -: 13: * Copyright (c) Fredrik Lundh 1995. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21: -: 22:Imaging function ImagingCrop called 1028538 returned 100% blocks executed 84% 1028538: 23:ImagingCrop(Imaging imIn, int sx0, int sy0, int sx1, int sy1) -: 24:{ -: 25: Imaging imOut; -: 26: int xsize, ysize; -: 27: int dx0, dy0, dx1, dy1; 1028538: 28: INT32 zero = 0; -: 29: 1028538: 30: if (!imIn) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 31: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 32: } -: 33: 1028538: 34: xsize = sx1 - sx0; 1028538: 35: if (xsize < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 2: 36: xsize = 0; -: 37: } 1028538: 38: ysize = sy1 - sy0; 1028538: 39: if (ysize < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 2: 40: ysize = 0; -: 41: } -: 42: 1028538: 43: imOut = ImagingNewDirty(imIn->mode, xsize, ysize); call 0 returned 100% 1028538: 44: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 45: return NULL; -: 46: } -: 47: 1028538: 48: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 49: 1028538: 50: if (sx0 < 0 || sy0 < 0 || sx1 > imIn->xsize || sy1 > imIn->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 99% (fallthrough) branch 5 taken 1% branch 6 taken 1% (fallthrough) branch 7 taken 99% 19: 51: (void) ImagingFill(imOut, &zero); call 0 returned 100% -: 52: } -: 53: 1028538: 54: dx0 = -sx0; 1028538: 55: dy0 = -sy0; 1028538: 56: dx1 = imIn->xsize - sx0; 1028538: 57: dy1 = imIn->ysize - sy0; -: 58: -: 59: /* paste the source image on top of the output image!!! */ 1028538: 60: if (ImagingPaste(imOut, imIn, NULL, dx0, dy0, dx1, dy1) < 0) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 61: ImagingDelete(imOut); call 0 never executed #####: 62: return NULL; -: 63: } -: 64: -: 65: return imOut; -: 66:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Quant.c.gcov -: 0:Source:src/libImaging/Quant.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Quant.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Quant.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * image quantizer -: 6: * -: 7: * history: -: 8: * 1998-09-10 tjs Contributed -: 9: * 1998-12-29 fl Added to PIL 1.0b1 -: 10: * 2004-02-21 fl Fixed bogus free() on quantization error -: 11: * 2005-02-07 fl Limit number of colors to 256 -: 12: * -: 13: * Written by Toby J Sargeant . -: 14: * -: 15: * Copyright (c) 1998 by Toby J Sargeant -: 16: * Copyright (c) 1998-2004 by Secret Labs AB. All rights reserved. -: 17: * -: 18: * See the README file for information on usage and redistribution. -: 19: */ -: 20: -: 21:#include "Imaging.h" -: 22: -: 23:#include -: 24:#include -: 25:#include -: 26:#include -: 27: -: 28:#include "QuantTypes.h" -: 29:#include "QuantOctree.h" -: 30:#include "QuantPngQuant.h" -: 31:#include "QuantHash.h" -: 32:#include "QuantHeap.h" -: 33: -: 34:/* MSVC9.0 */ -: 35:#ifndef UINT32_MAX -: 36:#define UINT32_MAX 0xffffffff -: 37:#endif -: 38: -: 39:#define NO_OUTPUT -: 40: -: 41:typedef struct { -: 42: uint32_t scale; -: 43:} PixelHashData; -: 44: -: 45:typedef struct _PixelList { -: 46: struct _PixelList *next[3],*prev[3]; -: 47: Pixel p; -: 48: unsigned int flag:1; -: 49: int count; -: 50:} PixelList; -: 51: -: 52:typedef struct _BoxNode { -: 53: struct _BoxNode *l,*r; -: 54: PixelList *head[3],*tail[3]; -: 55: int axis; -: 56: int volume; -: 57: uint32_t pixelCount; -: 58:} BoxNode; -: 59: -: 60:#define _SQR(x) ((x)*(x)) -: 61:#define _DISTSQR(p1,p2) \ -: 62: _SQR((int)((p1)->c.r)-(int)((p2)->c.r))+ \ -: 63: _SQR((int)((p1)->c.g)-(int)((p2)->c.g))+ \ -: 64: _SQR((int)((p1)->c.b)-(int)((p2)->c.b)) -: 65: -: 66:#define MAX_HASH_ENTRIES 65536 -: 67: -: 68:#define PIXEL_HASH(r,g,b) \ -: 69: (((unsigned int)(r) )*463 ^ \ -: 70: ((unsigned int)(g)<< 8)*10069 ^ \ -: 71: ((unsigned int)(b)<<16)*64997) -: 72: -: 73:#define PIXEL_UNSCALE(p,q,s) \ -: 74: ((q)->c.r=(p)->c.r<<(s)), \ -: 75: ((q)->c.g=(p)->c.g<<(s)), \ -: 76: ((q)->c.b=(p)->c.b<<(s)) -: 77: -: 78:#define PIXEL_SCALE(p,q,s)\ -: 79: ((q)->c.r=(p)->c.r>>(s)), \ -: 80: ((q)->c.g=(p)->c.g>>(s)), \ -: 81: ((q)->c.b=(p)->c.b>>(s)) -: 82: -: 83:static uint32_t function unshifted_pixel_hash called 865738 returned 100% blocks executed 100% 865738: 84:unshifted_pixel_hash(const HashTable *h, const Pixel pixel) -: 85:{ 865738: 86: return PIXEL_HASH(pixel.c.r, pixel.c.g, pixel.c.b); -: 87:} -: 88: -: 89:static int function unshifted_pixel_cmp called 1131632 returned 100% blocks executed 100% 1131632: 90:unshifted_pixel_cmp(const HashTable *h, const Pixel pixel1, const Pixel pixel2) -: 91:{ 1131632: 92: if (pixel1.c.r==pixel2.c.r) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 625746: 93: if (pixel1.c.g==pixel2.c.g) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 618838: 94: if (pixel1.c.b==pixel2.c.b) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 95: return 0; -: 96: } else { 8088: 97: return (int)(pixel1.c.b)-(int)(pixel2.c.b); -: 98: } -: 99: } else { 6908: 100: return (int)(pixel1.c.g)-(int)(pixel2.c.g); -: 101: } -: 102: } else { 505886: 103: return (int)(pixel1.c.r)-(int)(pixel2.c.r); -: 104: } -: 105:} -: 106: -: 107:static uint32_t function pixel_hash called 1613524 returned 100% blocks executed 100% 1613524: 108:pixel_hash(const HashTable *h,const Pixel pixel) -: 109:{ 1613524: 110: PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); call 0 returned 100% 1613524: 111: return PIXEL_HASH(pixel.c.r>>d->scale, pixel.c.g>>d->scale, pixel.c.b>>d->scale); -: 112:} -: 113: -: 114:static int function pixel_cmp called 2414222 returned 100% blocks executed 100% 2414222: 115:pixel_cmp(const HashTable *h,const Pixel pixel1, const Pixel pixel2) -: 116:{ 2414222: 117: PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); call 0 returned 100% -: 118: uint32_t A,B; 2414222: 119: A=PIXEL_HASH(pixel1.c.r>>d->scale, pixel1.c.g>>d->scale, pixel1.c.b>>d->scale); 2414222: 120: B=PIXEL_HASH(pixel2.c.r>>d->scale, pixel2.c.g>>d->scale, pixel2.c.b>>d->scale); 2414222: 121: return (A==B)?0:((Ascale=0; -: 166:#ifndef NO_OUTPUT -: 167: timer=timer3=clock(); -: 168:#endif 679280: 169: for (i=0;iMAX_HASH_ENTRIES) { call 0 returned 100% branch 1 taken 0% branch 2 taken 100% (fallthrough) #####: 176: d->scale++; -: 177:#ifndef NO_OUTPUT -: 178: printf ("rehashing - new scale: %d\n",(int)d->scale); -: 179: timer2=clock(); -: 180:#endif #####: 181: hashtable_rehash_compute(hash,rehash_collide); call 0 never executed -: 182:#ifndef NO_OUTPUT -: 183: timer2=clock()-timer2; -: 184: printf ("rehash took %f sec\n",timer2/(double)CLOCKS_PER_SEC); -: 185: timer+=timer2; -: 186:#endif -: 187: } -: 188: } -: 189:#ifndef NO_OUTPUT -: 190: printf ("inserts took %f sec\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 191:#endif -: 192:#ifndef NO_OUTPUT -: 193: printf ("total %f sec\n",(clock()-timer3)/(double)CLOCKS_PER_SEC); -: 194:#endif -: 195: return hash; -: 196:} -: 197: -: 198:static void function destroy_pixel_hash called 12 returned 100% blocks executed 100% 12: 199:destroy_pixel_hash(HashTable *hash) -: 200:{ 12: 201: PixelHashData *d=(PixelHashData *)hashtable_get_user_data(hash); call 0 returned 100% 12: 202: if (d) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 12: 203: free(d); -: 204: } 12: 205: hashtable_free(hash); call 0 returned 100% 12: 206:} -: 207: -: 208: -: 209:/* 1. hash quantized pixels. */ -: 210:/* 2. create R,G,B lists of sorted quantized pixels. */ -: 211:/* 3. median cut. */ -: 212:/* 4. build hash table from median cut boxes. */ -: 213:/* 5. for each pixel, compute entry in hash table, and hence median cut box. */ -: 214:/* 6. compute median cut box pixel averages. */ -: 215:/* 7. map each pixel to nearest average. */ -: 216: -: 217:static int function compute_box_volume called 2363 returned 100% blocks executed 83% 2363: 218:compute_box_volume(BoxNode *b) -: 219:{ -: 220: unsigned char rl,rh,gl,gh,bl,bh; 2363: 221: if (b->volume>=0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 222: return b->volume; -: 223: } 2363: 224: if (!b->head[0]) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 225: b->volume=0; -: 226: } else { 2363: 227: rh=b->head[0]->p.c.r; 2363: 228: rl=b->tail[0]->p.c.r; 2363: 229: gh=b->head[1]->p.c.g; 2363: 230: gl=b->tail[1]->p.c.g; 2363: 231: bh=b->head[2]->p.c.b; 2363: 232: bl=b->tail[2]->p.c.b; 2363: 233: b->volume=(rh-rl+1)*(gh-gl+1)*(bh-bl+1); -: 234: } 2363: 235: return b->volume; -: 236:} -: 237: -: 238:static void function hash_to_list called 68518 returned 100% blocks executed 90% 68518: 239:hash_to_list(const HashTable *h, const Pixel pixel, const uint32_t count, void *u) -: 240:{ 68518: 241: PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); call 0 returned 100% 68518: 242: PixelList **pl=(PixelList **)u; -: 243: PixelList *p; -: 244: int i; -: 245: Pixel q; -: 246: 68518: 247: PIXEL_SCALE(&pixel,&q,d->scale); -: 248: -: 249: /* malloc check ok, small constant allocation */ 68518: 250: p=malloc(sizeof(PixelList)); 68518: 251: if (!p) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 252: return; -: 253: } -: 254: 68518: 255: p->flag=0; 68518: 256: p->p=q; 68518: 257: p->count=count; 274072: 258: for (i=0;i<3;i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 205554: 259: p->next[i]=pl[i]; 205554: 260: p->prev[i]=NULL; 205554: 261: if (pl[i]) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 205518: 262: pl[i]->prev[i]=p; -: 263: } 205554: 264: pl[i]=p; -: 265: } -: 266:} -: 267: -: 268:static PixelList * function mergesort_pixels called 411072 returned 100% blocks executed 100% 411072: 269:mergesort_pixels(PixelList *head, int i) -: 270:{ -: 271: PixelList *c,*t,*a,*b,*p; 411072: 272: if (!head||!head->next[i]) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% (fallthrough) branch 3 taken 50% 205554: 273: if (head) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 205554: 274: head->next[i]=NULL; 205554: 275: head->prev[i]=NULL; -: 276: } -: 277: return head; -: 278: } 1394181: 279: for (c=t=head;c&&t;c=c->next[i],t=(t->next[i])?t->next[i]->next[i]:NULL); branch 0 taken 95% (fallthrough) branch 1 taken 5% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 87% branch 5 taken 13% (fallthrough) 205518: 280: if (c) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 205518: 281: if (c->prev[i]) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 205518: 282: c->prev[i]->next[i]=NULL; -: 283: } 205518: 284: c->prev[i]=NULL; -: 285: } 205518: 286: a=mergesort_pixels(head,i); call 0 returned 100% 205518: 287: b=mergesort_pixels(c,i); 205518: 288: head=NULL; 205518: 289: p=NULL; call 0 returned 100% 2857215: 290: while (a&&b) { branch 0 taken 97% (fallthrough) branch 1 taken 3% branch 2 taken 95% branch 3 taken 5% (fallthrough) 2446179: 291: if (a->p.a.v[i]>b->p.a.v[i]) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1234257: 292: c=a; 1234257: 293: a=a->next[i]; -: 294: } else { 1211922: 295: c=b; 1211922: 296: b=b->next[i]; -: 297: } 2446179: 298: c->prev[i]=p; 2446179: 299: c->next[i]=NULL; 2446179: 300: if (p) { branch 0 taken 92% (fallthrough) branch 1 taken 8% 2240661: 301: p->next[i]=c; -: 302: } 2446179: 303: p=c; 2446179: 304: if (!head) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 205518: 305: head=c; -: 306: } -: 307: } 205518: 308: if (a) { branch 0 taken 56% (fallthrough) branch 1 taken 44% 115455: 309: c->next[i]=a; 115455: 310: a->prev[i]=c; 90063: 311: } else if (b) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 90063: 312: c->next[i]=b; 90063: 313: b->prev[i]=c; -: 314: } -: 315: return head; -: 316:} -: 317: -: 318:#if defined(TEST_MERGESORT) || defined(TEST_SORTED) -: 319:static int -: 320:test_sorted(PixelList *pl[3]) -: 321:{ -: 322: int i,n,l; -: 323: PixelList *t; -: 324: -: 325: for(i=0;i<3;i++) { -: 326: n=0; -: 327: l=256; -: 328: for (t=pl[i];t;t=t->next[i]) { -: 329: if (lp.a.v[i]) return 0; -: 330: l=t->p.a.v[i]; -: 331: } -: 332: } -: 333: return 1; -: 334:} -: 335:#endif -: 336: -: 337:static int function box_heap_cmp called 31474 returned 100% blocks executed 100% 31474: 338:box_heap_cmp(const Heap *h, const void *A, const void *B) -: 339:{ 31474: 340: BoxNode *a=(BoxNode *)A; 31474: 341: BoxNode *b=(BoxNode *)B; 31474: 342: return (int)a->pixelCount-(int)b->pixelCount; -: 343:} -: 344: -: 345:#define LUMINANCE(p) (77*(p)->c.r+150*(p)->c.g+29*(p)->c.b) -: 346: -: 347:static int function splitlists called 2048 returned 100% blocks executed 100% 2048: 348:splitlists(PixelList *h[3], -: 349: PixelList *t[3], -: 350: PixelList *nh[2][3], -: 351: PixelList *nt[2][3], -: 352: uint32_t nCount[2], -: 353: int axis, -: 354: uint32_t pixelCount) -: 355:{ -: 356: uint32_t left; -: 357: -: 358: PixelList *l,*r,*c,*n; -: 359: int i; -: 360: int nRight,nLeft; -: 361: int splitColourVal; -: 362: -: 363:#ifdef TEST_SPLIT -: 364: { -: 365: PixelList *_prevTest,*_nextTest; -: 366: int _i,_nextCount[3],_prevCount[3]; -: 367: for (_i=0;_i<3;_i++) { -: 368: for (_nextCount[_i]=0,_nextTest=h[_i];_nextTest&&_nextTest->next[_i];_nextTest=_nextTest->next[_i],_nextCount[_i]++); -: 369: for (_prevCount[_i]=0,_prevTest=t[_i];_prevTest&&_prevTest->prev[_i];_prevTest=_prevTest->prev[_i],_prevCount[_i]++); -: 370: if (_nextTest!=t[_i]) { -: 371: printf ("next-list of axis %d does not end at tail\n",_i); -: 372: exit(1); -: 373: } -: 374: if (_prevTest!=h[_i]) { -: 375: printf ("prev-list of axis %d does not end at head\n",_i); -: 376: exit(1); -: 377: } -: 378: for (;_nextTest&&_nextTest->prev[_i];_nextTest=_nextTest->prev[_i]); -: 379: for (;_prevTest&&_prevTest->next[_i];_prevTest=_prevTest->next[_i]); -: 380: if (_nextTest!=h[_i]) { -: 381: printf ("next-list of axis %d does not loop back to head\n",_i); -: 382: exit(1); -: 383: } -: 384: if (_prevTest!=t[_i]) { -: 385: printf ("prev-list of axis %d does not loop back to tail\n",_i); -: 386: exit(1); -: 387: } -: 388: } -: 389: for (_i=1;_i<3;_i++) { -: 390: if (_prevCount[_i]!=_prevCount[_i-1] || -: 391: _nextCount[_i]!=_nextCount[_i-1] || -: 392: _prevCount[_i]!=_nextCount[_i]) { -: 393: printf ("{%d %d %d} {%d %d %d}\n", -: 394: _prevCount[0], -: 395: _prevCount[1], -: 396: _prevCount[2], -: 397: _nextCount[0], -: 398: _nextCount[1], -: 399: _nextCount[2]); -: 400: exit(1); -: 401: } -: 402: } -: 403: } -: 404:#endif 2048: 405: nCount[0]=nCount[1]=0; 2048: 406: nLeft=nRight=0; 266883: 407: for (left=0,c=h[axis];c;) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 264835: 408: left=left+c->count; 264835: 409: nCount[0]+=c->count; 264835: 410: c->flag=0; 264835: 411: nLeft++; 264835: 412: c=c->next[axis]; 264835: 413: if (left*2>pixelCount) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 414: break; -: 415: } -: 416: } 2048: 417: if (c) { branch 0 taken 96% (fallthrough) branch 1 taken 4% 1960: 418: splitColourVal=c->prev[axis]->p.a.v[axis]; 11346: 419: for (;c;c=c->next[axis]) { branch 0 taken 99% branch 1 taken 1% 11292: 420: if (splitColourVal!=c->p.a.v[axis]) { branch 0 taken 17% (fallthrough) branch 1 taken 83% -: 421: break; -: 422: } 9386: 423: c->flag=0; 9386: 424: nLeft++; 9386: 425: nCount[0]+=c->count; -: 426: } -: 427: } 211308: 428: for (;c;c=c->next[axis]) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 211308: 429: c->flag=1; 211308: 430: nRight++; 211308: 431: nCount[1]+=c->count; -: 432: } 2048: 433: if (!nRight) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 514: 434: for (c=t[axis],splitColourVal=t[axis]->p.a.v[axis];c;c=c->prev[axis]) { branch 0 taken 100% branch 1 taken 0% 514: 435: if (splitColourVal!=c->p.a.v[axis]) { branch 0 taken 28% (fallthrough) branch 1 taken 72% -: 436: break; -: 437: } 372: 438: c->flag=1; 372: 439: nRight++; 372: 440: nLeft--; 372: 441: nCount[0]-=c->count; 372: 442: nCount[1]+=c->count; -: 443: } -: 444: } -: 445:#ifndef NO_OUTPUT -: 446: if (!nLeft) { -: 447: for (c=h[axis];c;c=c->next[axis]) { -: 448: printf ("[%d %d %d]\n",c->p.c.r,c->p.c.g,c->p.c.b); -: 449: } -: 450: printf ("warning... trivial split\n"); -: 451: } -: 452:#endif -: 453: 6144: 454: for (i=0;i<3;i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6144: 455: l=r=NULL; 6144: 456: nh[0][i]=nt[0][i]=NULL; 6144: 457: nh[1][i]=nt[1][i]=NULL; 1468875: 458: for (c=h[i];c;c=n) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1456587: 459: n=c->next[i]; 1456587: 460: if (c->flag) { /* move pixel to right list*/ branch 0 taken 44% (fallthrough) branch 1 taken 56% 635040: 461: if (r) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 628896: 462: r->next[i]=c; -: 463: } else { 6144: 464: nh[1][i]=c; -: 465: } 635040: 466: c->prev[i]=r; 635040: 467: r=c; -: 468: } else { /* move pixel to left list */ 821547: 469: if (l) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 815403: 470: l->next[i]=c; -: 471: } else { 6144: 472: nh[0][i]=c; -: 473: } 821547: 474: c->prev[i]=l; 821547: 475: l=c; -: 476: } -: 477: } 6144: 478: if (l) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6144: 479: l->next[i]=NULL; -: 480: } 6144: 481: if (r) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6144: 482: r->next[i]=NULL; -: 483: } 6144: 484: nt[0][i]=l; 6144: 485: nt[1][i]=r; -: 486: } 2048: 487: return 1; -: 488:} -: 489: -: 490:static int function split called 2048 returned 100% blocks executed 93% 2048: 491:split(BoxNode *node) -: 492:{ -: 493: unsigned char rl,rh,gl,gh,bl,bh; -: 494: int f[3]; -: 495: int best,axis; -: 496: int i; -: 497: PixelList *heads[2][3]; -: 498: PixelList *tails[2][3]; -: 499: uint32_t newCounts[2]; -: 500: BoxNode *left,*right; -: 501: 2048: 502: rh=node->head[0]->p.c.r; 2048: 503: rl=node->tail[0]->p.c.r; 2048: 504: gh=node->head[1]->p.c.g; 2048: 505: gl=node->tail[1]->p.c.g; 2048: 506: bh=node->head[2]->p.c.b; 2048: 507: bl=node->tail[2]->p.c.b; -: 508:#ifdef TEST_SPLIT -: 509: printf ("splitting node [%d %d %d] [%d %d %d] ",rl,gl,bl,rh,gh,bh); -: 510:#endif 2048: 511: f[0]=(rh-rl)*77; 2048: 512: f[1]=(gh-gl)*150; 2048: 513: f[2]=(bh-bl)*29; -: 514: 2048: 515: best=f[0]; 2048: 516: axis=0; 6144: 517: for (i=1;i<3;i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 4096: 518: if (besttail[_i]->next[_i]) { -: 530: printf ("tail is not tail\n"); -: 531: printf ("node->tail[%d]->next[%d]=%p\n",_i,_i,node->tail[_i]->next[_i]); -: 532: } -: 533: if (node->head[_i]->prev[_i]) { -: 534: printf ("head is not head\n"); -: 535: printf ("node->head[%d]->prev[%d]=%p\n",_i,_i,node->head[_i]->prev[_i]); -: 536: } -: 537: } -: 538: -: 539: for (_i=0;_i<3;_i++) { -: 540: for (_nextCount[_i]=0,_nextTest=node->head[_i];_nextTest&&_nextTest->next[_i];_nextTest=_nextTest->next[_i],_nextCount[_i]++); -: 541: for (_prevCount[_i]=0,_prevTest=node->tail[_i];_prevTest&&_prevTest->prev[_i];_prevTest=_prevTest->prev[_i],_prevCount[_i]++); -: 542: if (_nextTest!=node->tail[_i]) { -: 543: printf ("next-list of axis %d does not end at tail\n",_i); -: 544: } -: 545: if (_prevTest!=node->head[_i]) { -: 546: printf ("prev-list of axis %d does not end at head\n",_i); -: 547: } -: 548: for (;_nextTest&&_nextTest->prev[_i];_nextTest=_nextTest->prev[_i]); -: 549: for (;_prevTest&&_prevTest->next[_i];_prevTest=_prevTest->next[_i]); -: 550: if (_nextTest!=node->head[_i]) { -: 551: printf ("next-list of axis %d does not loop back to head\n",_i); -: 552: } -: 553: if (_prevTest!=node->tail[_i]) { -: 554: printf ("prev-list of axis %d does not loop back to tail\n",_i); -: 555: } -: 556: } -: 557: for (_i=1;_i<3;_i++) { -: 558: if (_prevCount[_i]!=_prevCount[_i-1] || -: 559: _nextCount[_i]!=_nextCount[_i-1] || -: 560: _prevCount[_i]!=_nextCount[_i]) { -: 561: printf ("{%d %d %d} {%d %d %d}\n", -: 562: _prevCount[0], -: 563: _prevCount[1], -: 564: _prevCount[2], -: 565: _nextCount[0], -: 566: _nextCount[1], -: 567: _nextCount[2]); -: 568: } -: 569: } -: 570: } -: 571:#endif 2048: 572: node->axis=axis; 4096: 573: if (!splitlists(node->head, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 2048: 574: node->tail, -: 575: heads, -: 576: tails, -: 577: newCounts, -: 578: axis, -: 579: node->pixelCount)) { -: 580:#ifndef NO_OUTPUT -: 581: printf ("list split failed.\n"); -: 582:#endif -: 583: return 0; -: 584: } -: 585:#ifdef TEST_SPLIT -: 586: if (!test_sorted(heads[0])) { -: 587: printf ("bug in split"); -: 588: exit(1); -: 589: } -: 590: if (!test_sorted(heads[1])) { -: 591: printf ("bug in split"); -: 592: exit(1); -: 593: } -: 594:#endif -: 595: /* malloc check ok, small constant allocation */ 2048: 596: left=malloc(sizeof(BoxNode)); 2048: 597: right=malloc(sizeof(BoxNode)); 2048: 598: if (!left||!right) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% #####: 599: free(left); #####: 600: free(right); #####: 601: return 0; -: 602: } 6144: 603: for(i=0;i<3;i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6144: 604: left->head[i]=heads[0][i]; 6144: 605: left->tail[i]=tails[0][i]; 6144: 606: right->head[i]=heads[1][i]; 6144: 607: right->tail[i]=tails[1][i]; 6144: 608: node->head[i]=NULL; 6144: 609: node->tail[i]=NULL; -: 610: } -: 611:#ifdef TEST_SPLIT -: 612: if (left->head[0]) { -: 613: rh=left->head[0]->p.c.r; -: 614: rl=left->tail[0]->p.c.r; -: 615: gh=left->head[1]->p.c.g; -: 616: gl=left->tail[1]->p.c.g; -: 617: bh=left->head[2]->p.c.b; -: 618: bl=left->tail[2]->p.c.b; -: 619: printf (" left node [%3d %3d %3d] [%3d %3d %3d]\n",rl,gl,bl,rh,gh,bh); -: 620: } -: 621: if (right->head[0]) { -: 622: rh=right->head[0]->p.c.r; -: 623: rl=right->tail[0]->p.c.r; -: 624: gh=right->head[1]->p.c.g; -: 625: gl=right->tail[1]->p.c.g; -: 626: bh=right->head[2]->p.c.b; -: 627: bl=right->tail[2]->p.c.b; -: 628: printf (" right node [%3d %3d %3d] [%3d %3d %3d]\n",rl,gl,bl,rh,gh,bh); -: 629: } -: 630:#endif 2048: 631: left->l=left->r=NULL; 2048: 632: right->l=right->r=NULL; 2048: 633: left->axis=right->axis=-1; 2048: 634: left->volume=right->volume=-1; 2048: 635: left->pixelCount=newCounts[0]; 2048: 636: right->pixelCount=newCounts[1]; 2048: 637: node->l=left; 2048: 638: node->r=right; 2048: 639: return 1; -: 640:} -: 641: -: 642:static BoxNode * function median_cut called 12 returned 100% blocks executed 92% 12: 643:median_cut(PixelList *hl[3], -: 644: uint32_t imPixelCount, -: 645: int nPixels) -: 646:{ -: 647: PixelList *tl[3]; -: 648: int i; -: 649: BoxNode *root; -: 650: Heap* h; -: 651: BoxNode *thisNode; -: 652: 12: 653: h=ImagingQuantHeapNew(box_heap_cmp); call 0 returned 100% -: 654: /* malloc check ok, small constant allocation */ 12: 655: root=malloc(sizeof(BoxNode)); 12: 656: if (!root) { ImagingQuantHeapFree(h); return NULL; } branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 never executed 36: 657: for(i=0;i<3;i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 36: 658: for (tl[i]=hl[i];tl[i]&&tl[i]->next[i];tl[i]=tl[i]->next[i]); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 99% branch 3 taken 1% (fallthrough) 36: 659: root->head[i]=hl[i]; 36: 660: root->tail[i]=tl[i]; -: 661: } 12: 662: root->l=root->r=NULL; 12: 663: root->axis=-1; 12: 664: root->volume=-1; 12: 665: root->pixelCount=imPixelCount; -: 666: 12: 667: ImagingQuantHeapAdd(h,(void *)root); call 0 returned 100% 2072: 668: while (--nPixels) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 669: do { 2367: 670: if (!ImagingQuantHeapRemove(h,(void **)&thisNode)) { call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 671: goto done; -: 672: } 2363: 673: } while (compute_box_volume(thisNode)==1); call 0 returned 100% branch 1 taken 13% branch 2 taken 87% (fallthrough) 2048: 674: if (!split(thisNode)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 675:#ifndef NO_OUTPUT -: 676: printf ("Oops, split failed...\n"); -: 677:#endif #####: 678: exit (1); call 0 never executed -: 679: } 2048: 680: ImagingQuantHeapAdd(h,(void *)(thisNode->l)); call 0 returned 100% 2048: 681: ImagingQuantHeapAdd(h,(void *)(thisNode->r)); call 0 returned 100% -: 682: } -: 683:done: 12: 684: ImagingQuantHeapFree(h); call 0 returned 100% 12: 685: return root; -: 686:} -: 687: -: 688:static void function free_box_tree called 4108 returned 100% blocks executed 100% 4108: 689:free_box_tree(BoxNode *n) -: 690:{ -: 691: PixelList *p,*pp; 4108: 692: if (n->l) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 2048: 693: free_box_tree(n->l); call 0 returned 100% -: 694: } 4108: 695: if (n->r) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 2048: 696: free_box_tree(n->r); call 0 returned 100% -: 697: } 72626: 698: for (p=n->head[0];p;p=pp) { branch 0 taken 94% branch 1 taken 6% (fallthrough) 68518: 699: pp=p->next[0]; 68518: 700: free(p); -: 701: } 4108: 702: free(n); 4108: 703:} -: 704: -: 705:#ifdef TEST_SPLIT_INTEGRITY -: 706:static int -: 707:checkContained(BoxNode *n,Pixel *pp) -: 708:{ -: 709: if (n->l&&n->r) { -: 710: return checkContained(n->l,pp)+checkContained(n->r,pp); -: 711: } -: 712: if (n->l||n->r) { -: 713:#ifndef NO_OUTPUT -: 714: printf ("box tree is dead\n"); -: 715:#endif -: 716: return 0; -: 717: } -: 718: if ( -: 719: pp->c.r<=n->head[0]->p.c.r && -: 720: pp->c.r>=n->tail[0]->p.c.r && -: 721: pp->c.g<=n->head[1]->p.c.g && -: 722: pp->c.g>=n->tail[1]->p.c.g && -: 723: pp->c.b<=n->head[2]->p.c.b && -: 724: pp->c.b>=n->tail[2]->p.c.b) { -: 725: return 1; -: 726: } -: 727: return 0; -: 728:} -: 729:#endif -: 730: -: 731:static int function annotate_hash_table called 4108 returned 100% blocks executed 94% 4108: 732:annotate_hash_table(BoxNode *n,HashTable *h,uint32_t *box) -: 733:{ -: 734: PixelList *p; 4108: 735: PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); call 0 returned 100% -: 736: Pixel q; 4108: 737: if (n->l&&n->r) { branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 100% (fallthrough) branch 3 taken 0% 2048: 738: return annotate_hash_table(n->l,h,box) && annotate_hash_table(n->r,h,box); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% call 3 returned 100% branch 4 taken 0% (fallthrough) branch 5 taken 100% -: 739: } 2060: 740: if (n->l||n->r) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 741:#ifndef NO_OUTPUT -: 742: printf ("box tree is dead\n"); -: 743:#endif -: 744: return 0; -: 745: } 70578: 746: for (p=n->head[0];p;p=p->next[0]) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 68518: 747: PIXEL_UNSCALE(&(p->p),&q,d->scale); 68518: 748: if (!hashtable_insert(h,q,*box)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 749:#ifndef NO_OUTPUT -: 750: printf ("hashtable insert failed\n"); -: 751:#endif -: 752: return 0; -: 753: } -: 754: } 2060: 755: if (n->head[0]) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 2060: 756: (*box)++; -: 757: } -: 758: return 1; -: 759:} -: 760: -: 761:static int function _sort_ulong_ptr_keys called 2802385 returned 100% blocks executed 100% 2802385: 762:_sort_ulong_ptr_keys(const void *a, const void *b) -: 763:{ 2802385: 764: uint32_t A=**(uint32_t **)a; 2802385: 765: uint32_t B=**(uint32_t **)b; 2802385: 766: return (A==B)?0:((A*(skRow[k]));k--) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 791: skRow[k]=skRow[k-1]; -: 792: } #####: 793: if (k!=j) { branch 0 never executed branch 1 never executed #####: 794: skRow[k]=skElt; -: 795: } -: 796: } -: 797: } #####: 798: return 1; -: 799:} -: 800: -: 801:static int function build_distance_tables called 12 returned 100% blocks executed 100% 12: 802:build_distance_tables(uint32_t *avgDist, -: 803: uint32_t **avgDistSortKey, -: 804: Pixel *p, -: 805: uint32_t nEntries) -: 806:{ -: 807: uint32_t i,j; -: 808: 2072: 809: for (i=0;i1) { -: 1027: printf ("pixel in two boxes\n"); -: 1028: for(i=0;i<3;i++) { -: 1029: free (avg[i]); -: 1030: } -: 1031: free(count); -: 1032: return 0; -: 1033: } -: 1034:#endif 679268: 1035: if (!hashtable_lookup(medianBoxHash,pixelData[i],&paletteEntry)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 1036:#ifndef NO_OUTPUT -: 1037: printf ("pixel lookup failed\n"); -: 1038:#endif #####: 1039: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed #####: 1040: free (avg[i]); -: 1041: } #####: 1042: free(count); #####: 1043: return 0; -: 1044: } 679268: 1045: if (paletteEntry>=nPaletteEntries) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1046:#ifndef NO_OUTPUT -: 1047: printf ("panic - paletteEntry>=nPaletteEntries (%d>=%d)\n",(int)paletteEntry,(int)nPaletteEntries); -: 1048:#endif #####: 1049: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed #####: 1050: free (avg[i]); -: 1051: } #####: 1052: free(count); #####: 1053: return 0; -: 1054: } 679268: 1055: avg[0][paletteEntry]+=pixelData[i].c.r; 679268: 1056: avg[1][paletteEntry]+=pixelData[i].c.g; 679268: 1057: avg[2][paletteEntry]+=pixelData[i].c.b; 679268: 1058: count[paletteEntry]++; -: 1059: } -: 1060: /* malloc check ok, using calloc */ 12: 1061: p=calloc(nPaletteEntries, sizeof(Pixel)); 12: 1062: if (!p) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 1063: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed #####: 1064: free (avg[i]); -: 1065: } #####: 1066: free(count); #####: 1067: return 0; -: 1068: } 2060: 1069: for (i=0;i=nPaletteEntries) { branch 0 never executed branch 1 never executed -: 1117:#ifndef NO_OUTPUT -: 1118: printf ("scream\n"); -: 1119:#endif -: 1120: return 0; -: 1121: } #####: 1122: avg[0][qp[i]]+=pixelData[i].c.r; #####: 1123: avg[1][qp[i]]+=pixelData[i].c.g; #####: 1124: avg[2][qp[i]]+=pixelData[i].c.b; #####: 1125: count[qp[i]]++; -: 1126: } #####: 1127: for (i=0;i UINT32_MAX / (sizeof(uint32_t))) { branch 0 never executed branch 1 never executed -: 1152: return 0; -: 1153: } -: 1154: /* malloc check ok, using calloc */ #####: 1155: if (!(count=calloc(nPaletteEntries, sizeof(uint32_t)))) { branch 0 never executed branch 1 never executed -: 1156: return 0; -: 1157: } #####: 1158: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed #####: 1159: avg[i]=NULL; -: 1160: } #####: 1161: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed -: 1162: /* malloc check ok, using calloc */ #####: 1163: if (!(avg[i]=calloc(nPaletteEntries, sizeof(uint32_t)))) { branch 0 never executed branch 1 never executed -: 1164: goto error_1; -: 1165: } -: 1166: } -: 1167: -: 1168: /* this is enough of a check, since the multiplication n*size is done above */ #####: 1169: if (nPaletteEntries > UINT32_MAX / nPaletteEntries) { branch 0 never executed branch 1 never executed -: 1170: goto error_1; -: 1171: } -: 1172: /* malloc check ok, using calloc, checking n*n above */ #####: 1173: avgDist=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t)); #####: 1174: if (!avgDist) { goto error_1; } branch 0 never executed branch 1 never executed -: 1175: -: 1176: /* malloc check ok, using calloc, checking n*n above */ #####: 1177: avgDistSortKey=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t *)); #####: 1178: if (!avgDistSortKey) { goto error_2; } branch 0 never executed branch 1 never executed -: 1179: -: 1180:#ifndef NO_OUTPUT -: 1181: printf("[");fflush(stdout); -: 1182:#endif -: 1183: while (1) { #####: 1184: if (!built) { branch 0 never executed branch 1 never executed #####: 1185: compute_palette_from_quantized_pixels(pixelData,nPixels,paletteData,nPaletteEntries,avg,count,qp); call 0 never executed #####: 1186: build_distance_tables(avgDist,avgDistSortKey,paletteData,nPaletteEntries); #####: 1187: built=1; call 0 never executed -: 1188: } else { #####: 1189: recompute_palette_from_averages(paletteData,nPaletteEntries,avg,count); call 0 never executed #####: 1190: resort_distance_tables(avgDist,avgDistSortKey,paletteData,nPaletteEntries); call 0 never executed -: 1191: } #####: 1192: changes=map_image_pixels_from_quantized_pixels(pixelData, call 0 never executed -: 1193: nPixels, -: 1194: paletteData, -: 1195: nPaletteEntries, -: 1196: avgDist, -: 1197: avgDistSortKey, -: 1198: qp, -: 1199: avg, -: 1200: count); #####: 1201: if (changes<0) { branch 0 never executed branch 1 never executed -: 1202: goto error_3; -: 1203: } -: 1204:#ifndef NO_OUTPUT -: 1205: printf (".(%d)",changes);fflush(stdout); -: 1206:#endif #####: 1207: if (changes<=threshold) { branch 0 never executed branch 1 never executed -: 1208: break; -: 1209: } -: 1210: } -: 1211:#ifndef NO_OUTPUT -: 1212: printf("]\n"); -: 1213:#endif #####: 1214: if (avgDistSortKey) { branch 0 never executed branch 1 never executed #####: 1215: free(avgDistSortKey); -: 1216: } #####: 1217: if (avgDist) { branch 0 never executed branch 1 never executed #####: 1218: free(avgDist); -: 1219: } #####: 1220: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed #####: 1221: if (avg[i]) { branch 0 never executed branch 1 never executed #####: 1222: free (avg[i]); -: 1223: } -: 1224: } #####: 1225: if (count) { branch 0 never executed branch 1 never executed #####: 1226: free(count); -: 1227: } -: 1228: return 1; -: 1229: -: 1230:error_3: #####: 1231: if (avgDistSortKey) { branch 0 never executed branch 1 never executed #####: 1232: free(avgDistSortKey); -: 1233: } -: 1234:error_2: #####: 1235: if (avgDist) { branch 0 never executed branch 1 never executed #####: 1236: free(avgDist); -: 1237: } -: 1238:error_1: #####: 1239: for(i=0;i<3;i++) { branch 0 never executed branch 1 never executed #####: 1240: if (avg[i]) { branch 0 never executed branch 1 never executed #####: 1241: free (avg[i]); -: 1242: } -: 1243: } #####: 1244: if (count) { branch 0 never executed branch 1 never executed #####: 1245: free(count); -: 1246: } -: 1247: return 0; -: 1248:} -: 1249: -: 1250:int function quantize called 12 returned 100% blocks executed 70% 12: 1251:quantize(Pixel *pixelData, -: 1252: uint32_t nPixels, -: 1253: uint32_t nQuantPixels, -: 1254: Pixel **palette, -: 1255: uint32_t *paletteLength, -: 1256: uint32_t **quantizedPixels, -: 1257: int kmeans) -: 1258:{ -: 1259: PixelList *hl[3]; -: 1260: HashTable *h; -: 1261: BoxNode *root; -: 1262: uint32_t i; -: 1263: uint32_t *qp; -: 1264: uint32_t nPaletteEntries; -: 1265: -: 1266: uint32_t *avgDist; -: 1267: uint32_t **avgDistSortKey; -: 1268: Pixel *p; -: 1269: -: 1270:#ifndef NO_OUTPUT -: 1271: uint32_t timer,timer2; -: 1272:#endif -: 1273: -: 1274:#ifndef NO_OUTPUT -: 1275: timer2=clock(); -: 1276: printf ("create hash table..."); fflush(stdout); timer=clock(); -: 1277:#endif 12: 1278: h=create_pixel_hash(pixelData,nPixels); call 0 returned 100% -: 1279:#ifndef NO_OUTPUT -: 1280: printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 1281:#endif 12: 1282: if (!h) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1283: goto error_0; -: 1284: } -: 1285: -: 1286:#ifndef NO_OUTPUT -: 1287: printf ("create lists from hash table..."); fflush(stdout); timer=clock(); -: 1288:#endif 12: 1289: hl[0]=hl[1]=hl[2]=NULL; 12: 1290: hashtable_foreach(h,hash_to_list,hl); call 0 returned 100% -: 1291:#ifndef NO_OUTPUT -: 1292: printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 1293:#endif -: 1294: 12: 1295: if (!hl[0]) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1296: goto error_1; -: 1297: } -: 1298: -: 1299:#ifndef NO_OUTPUT -: 1300: printf ("mergesort lists..."); fflush(stdout); timer=clock(); -: 1301:#endif 36: 1302: for(i=0;i<3;i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 36: 1303: hl[i]=mergesort_pixels(hl[i],i); call 0 returned 100% -: 1304: } -: 1305:#ifdef TEST_MERGESORT -: 1306: if (!test_sorted(hl)) { -: 1307: printf ("bug in mergesort\n"); -: 1308: goto error_1; -: 1309: } -: 1310:#endif -: 1311:#ifndef NO_OUTPUT -: 1312: printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 1313:#endif -: 1314: -: 1315:#ifndef NO_OUTPUT -: 1316: printf ("median cut..."); fflush(stdout); timer=clock(); -: 1317:#endif 12: 1318: root=median_cut(hl,nPixels,nQuantPixels); call 0 returned 100% -: 1319:#ifndef NO_OUTPUT -: 1320: printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 1321:#endif 12: 1322: if (!root) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1323: goto error_1; -: 1324: } 12: 1325: nPaletteEntries=0; -: 1326:#ifndef NO_OUTPUT -: 1327: printf ("median cut tree to hash table..."); fflush(stdout); timer=clock(); -: 1328:#endif 12: 1329: annotate_hash_table(root,h,&nPaletteEntries); call 0 returned 100% -: 1330:#ifndef NO_OUTPUT -: 1331: printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 1332:#endif -: 1333:#ifndef NO_OUTPUT -: 1334: printf ("compute palette...\n"); fflush(stdout); timer=clock(); -: 1335:#endif 12: 1336: if (!compute_palette_from_median_cut(pixelData,nPixels,h,&p,nPaletteEntries)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1337: goto error_3; -: 1338: } -: 1339:#ifndef NO_OUTPUT -: 1340: printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); -: 1341:#endif -: 1342: 12: 1343: free_box_tree(root); call 0 returned 100% 12: 1344: root=NULL; -: 1345: -: 1346: /* malloc check ok, using calloc for overflow */ 12: 1347: qp=calloc(nPixels, sizeof(uint32_t)); 12: 1348: if (!qp) { goto error_4; } branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1349: 12: 1350: if (nPaletteEntries > UINT32_MAX / nPaletteEntries ) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1351: goto error_5; -: 1352: } -: 1353: /* malloc check ok, using calloc for overflow, check of n*n above */ 12: 1354: avgDist=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t)); 12: 1355: if (!avgDist) { goto error_5; } branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1356: -: 1357: /* malloc check ok, using calloc for overflow, check of n*n above */ 12: 1358: avgDistSortKey=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t *)); 12: 1359: if (!avgDistSortKey) { goto error_6; } branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1360: 12: 1361: if (!build_distance_tables(avgDist,avgDistSortKey,p,nPaletteEntries)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1362: goto error_7; -: 1363: } -: 1364: 12: 1365: if (!map_image_pixels_from_median_box(pixelData,nPixels,p,nPaletteEntries,h,avgDist,avgDistSortKey,qp)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1366: goto error_7; -: 1367: } -: 1368: -: 1369:#ifdef TEST_NEAREST_NEIGHBOUR -: 1370:#include -: 1371: { -: 1372: uint32_t bestmatch,bestdist,dist; -: 1373: HashTable *h2; -: 1374: printf ("nearest neighbour search (full search)..."); fflush(stdout); timer=clock(); -: 1375: h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); -: 1376: for (i=0;inew),&pixel); #####: 1488: if (data->secondPixel || newDistdata->furthestDistance) { branch 0 never executed branch 1 never executed #####: 1493: data->furthestDistance=oldDist; #####: 1494: data->furthest.v=pixel.v; -: 1495: } #####: 1496:} -: 1497: -: 1498:int function quantize2 called 0 returned 0% blocks executed 0% #####: 1499:quantize2(Pixel *pixelData, -: 1500: uint32_t nPixels, -: 1501: uint32_t nQuantPixels, -: 1502: Pixel **palette, -: 1503: uint32_t *paletteLength, -: 1504: uint32_t **quantizedPixels, -: 1505: int kmeans) -: 1506:{ -: 1507: HashTable *h; -: 1508: uint32_t i; -: 1509: uint32_t mean[3]; -: 1510: Pixel *p; -: 1511: DistanceData data; -: 1512: -: 1513: uint32_t *qp; -: 1514: uint32_t *avgDist; -: 1515: uint32_t **avgDistSortKey; -: 1516: -: 1517: /* malloc check ok, using calloc */ #####: 1518: p=calloc(nQuantPixels, sizeof(Pixel)); #####: 1519: if (!p) { branch 0 never executed branch 1 never executed -: 1520: return 0; -: 1521: } #####: 1522: mean[0]=mean[1]=mean[2]=0; #####: 1523: h=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); #####: 1524: for (i=0;i UINT32_MAX / nQuantPixels ) { branch 0 never executed branch 1 never executed -: 1547: goto error_2; -: 1548: } -: 1549: -: 1550: /* malloc check ok, using calloc for overflow, check of n*n above */ #####: 1551: avgDist=calloc(nQuantPixels*nQuantPixels, sizeof(uint32_t)); #####: 1552: if (!avgDist) { goto error_2; } branch 0 never executed branch 1 never executed -: 1553: -: 1554: /* malloc check ok, using calloc for overflow, check of n*n above */ #####: 1555: avgDistSortKey=calloc(nQuantPixels*nQuantPixels, sizeof(uint32_t *)); #####: 1556: if (!avgDistSortKey) { goto error_3; } branch 0 never executed branch 1 never executed -: 1557: #####: 1558: if (!build_distance_tables(avgDist,avgDistSortKey,p,nQuantPixels)) { call 0 never executed branch 1 never executed branch 2 never executed -: 1559: goto error_4; -: 1560: } -: 1561: #####: 1562: if (!map_image_pixels(pixelData,nPixels,p,nQuantPixels,avgDist,avgDistSortKey,qp)) { call 0 never executed branch 1 never executed branch 2 never executed -: 1563: goto error_4; -: 1564: } #####: 1565: if (kmeans) { branch 0 never executed branch 1 never executed #####: 1566: k_means(pixelData,nPixels,p,nQuantPixels,qp,kmeans-1); call 0 never executed -: 1567: } -: 1568: #####: 1569: *paletteLength=nQuantPixels; #####: 1570: *palette=p; #####: 1571: *quantizedPixels=qp; #####: 1572: free(avgDistSortKey); #####: 1573: free(avgDist); #####: 1574: return 1; -: 1575: -: 1576:error_4: #####: 1577: free(avgDistSortKey); -: 1578:error_3: #####: 1579: free(avgDist); -: 1580:error_2: #####: 1581: free(qp); -: 1582:error_1: #####: 1583: free(p); #####: 1584: return 0; -: 1585:} -: 1586: -: 1587:Imaging function ImagingQuantize called 25 returned 100% blocks executed 77% 25: 1588:ImagingQuantize(Imaging im, int colors, int mode, int kmeans) -: 1589:{ -: 1590: int i, j; -: 1591: int x, y, v; -: 1592: UINT8* pp; -: 1593: Pixel* p; -: 1594: Pixel* palette; -: 1595: uint32_t paletteLength; -: 1596: int result; -: 1597: uint32_t* newData; -: 1598: Imaging imOut; 25: 1599: int withAlpha = 0; -: 1600: ImagingSectionCookie cookie; -: 1601: 25: 1602: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1603: return ImagingError_ModeError(); call 0 never executed -: 1604: } 25: 1605: if (colors < 1 || colors > 256) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1606: /* FIXME: for colors > 256, consider returning an RGB image -: 1607: instead (see @PIL205) */ #####: 1608: return (Imaging) ImagingError_ValueError("bad number of colors"); call 0 never executed -: 1609: } -: 1610: 49: 1611: if (strcmp(im->mode, "L") != 0 && strcmp(im->mode, "P") != 0 && branch 0 taken 4% (fallthrough) branch 1 taken 96% branch 2 taken 96% (fallthrough) branch 3 taken 4% branch 4 taken 0% (fallthrough) branch 5 taken 100% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 46% (fallthrough) branch 9 taken 54% 35: 1612: strcmp(im->mode, "RGB") != 0 && strcmp(im->mode, "RGBA") !=0) { 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% #####: 1613: return ImagingError_ModeError(); call 0 never executed -: 1614: } -: 1615: -: 1616: /* only octree and imagequant supports RGBA */ 25: 1617: if (!strcmp(im->mode, "RGBA") && mode != 2 && mode != 3) { branch 0 taken 44% (fallthrough) branch 1 taken 56% branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 never executed branch 5 never executed #####: 1618: return ImagingError_ModeError(); call 0 never executed -: 1619: } -: 1620: 25: 1621: if (im->xsize > INT_MAX / im->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1622: return ImagingError_MemoryError(); call 0 never executed -: 1623: } -: 1624: /* malloc check ok, using calloc for final overflow, x*y above */ 25: 1625: p = calloc(im->xsize * im->ysize, sizeof(Pixel)); 25: 1626: if (!p) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1627: return ImagingError_MemoryError(); call 0 never executed -: 1628: } -: 1629: -: 1630: /* collect statistics */ -: 1631: -: 1632: /* FIXME: maybe we could load the hash tables directly from the -: 1633: image data? */ -: 1634: 25: 1635: if (!strcmp(im->mode, "L")) { branch 0 taken 4% (fallthrough) branch 1 taken 96% branch 2 taken 4% (fallthrough) branch 3 taken 96% -: 1636: /* greyscale */ -: 1637: -: 1638: /* FIXME: converting a "L" image to "P" with 256 colors -: 1639: should be done by a simple copy... */ -: 1640: 128: 1641: for (i = y = 0; y < im->ysize; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 16384: 1642: for (x = 0; x < im->xsize; x++, i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 1643: p[i].c.r = p[i].c.g = p[i].c.b = im->image8[y][x]; 16384: 1644: p[i].c.a = 255; -: 1645: } -: 1646: } -: 1647: 24: 1648: } else if (!strcmp(im->mode, "P")) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 1649: /* palette */ -: 1650: #####: 1651: pp = im->palette->palette; -: 1652: #####: 1653: for (i = y = 0; y < im->ysize; y++) { branch 0 never executed branch 1 never executed #####: 1654: for (x = 0; x < im->xsize; x++, i++) { branch 0 never executed branch 1 never executed #####: 1655: v = im->image8[y][x]; #####: 1656: p[i].c.r = pp[v*4+0]; #####: 1657: p[i].c.g = pp[v*4+1]; #####: 1658: p[i].c.b = pp[v*4+2]; #####: 1659: p[i].c.a = pp[v*4+3]; -: 1660: } -: 1661: } -: 1662: 24: 1663: } else if (!strcmp(im->mode, "RGB") || !strcmp(im->mode, "RGBA")) { 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 46% (fallthrough) branch 7 taken 54% branch 8 taken 100% (fallthrough) branch 9 taken 0% -: 1664: /* true colour */ -: 1665: 3207: 1666: for (i = y = 0; y < im->ysize; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 881337: 1667: for (x = 0; x < im->xsize; x++, i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 881337: 1668: p[i].v = im->image32[y][x]; -: 1669: } -: 1670: } -: 1671: -: 1672: } else { #####: 1673: free(p); #####: 1674: return (Imaging) ImagingError_ValueError("internal error"); call 0 never executed -: 1675: } -: 1676: 25: 1677: ImagingSectionEnter(&cookie); call 0 returned 100% -: 1678: 25: 1679: switch (mode) { branch 0 taken 48% branch 1 taken 0% branch 2 taken 48% branch 3 taken 4% branch 4 taken 0% -: 1680: case 0: -: 1681: /* median cut */ 12: 1682: result = quantize( call 0 returned 100% -: 1683: p, 12: 1684: im->xsize*im->ysize, -: 1685: colors, -: 1686: &palette, -: 1687: &paletteLength, -: 1688: &newData, -: 1689: kmeans -: 1690: ); 12: 1691: break; -: 1692: case 1: -: 1693: /* maximum coverage */ #####: 1694: result = quantize2( call 0 never executed -: 1695: p, #####: 1696: im->xsize*im->ysize, -: 1697: colors, -: 1698: &palette, -: 1699: &paletteLength, -: 1700: &newData, -: 1701: kmeans -: 1702: ); #####: 1703: break; -: 1704: case 2: 12: 1705: if (!strcmp(im->mode, "RGBA")) { branch 0 taken 92% (fallthrough) branch 1 taken 8% 11: 1706: withAlpha = 1; -: 1707: } 12: 1708: result = quantize_octree( call 0 returned 100% -: 1709: p, 12: 1710: im->xsize*im->ysize, -: 1711: colors, -: 1712: &palette, -: 1713: &paletteLength, -: 1714: &newData, -: 1715: withAlpha -: 1716: ); 12: 1717: break; -: 1718: case 3: -: 1719:#ifdef HAVE_LIBIMAGEQUANT 1: 1720: if (!strcmp(im->mode, "RGBA")) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1721: withAlpha = 1; -: 1722: } 2: 1723: result = quantize_pngquant( call 0 returned 100% -: 1724: p, 1: 1725: im->xsize, 1: 1726: im->ysize, -: 1727: colors, -: 1728: &palette, -: 1729: &paletteLength, -: 1730: &newData, -: 1731: withAlpha -: 1732: ); -: 1733:#else -: 1734: result = -1; -: 1735:#endif 1: 1736: break; -: 1737: default: -: 1738: result = 0; -: 1739: break; -: 1740: } -: 1741: 25: 1742: free(p); 25: 1743: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1744: 25: 1745: if (result > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 25: 1746: imOut = ImagingNewDirty("P", im->xsize, im->ysize); call 0 returned 100% 25: 1747: ImagingSectionEnter(&cookie); -: 1748: 3360: 1749: for (i = y = 0; y < im->ysize; y++) { call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% 897721: 1750: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 897721: 1751: imOut->image8[y][x] = (unsigned char) newData[i++]; -: 1752: } -: 1753: } -: 1754: 25: 1755: free(newData); -: 1756: 25: 1757: pp = imOut->palette->palette; -: 1758: 5101: 1759: for (i = j = 0; i < (int) paletteLength; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5076: 1760: *pp++ = palette[i].c.r; 5076: 1761: *pp++ = palette[i].c.g; 5076: 1762: *pp++ = palette[i].c.b; 5076: 1763: if (withAlpha) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 2816: 1764: *pp++ = palette[i].c.a; -: 1765: } else { 2260: 1766: *pp++ = 255; -: 1767: } -: 1768: } 1324: 1769: for (; i < 256; i++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 1324: 1770: *pp++ = 0; 1324: 1771: *pp++ = 0; 1324: 1772: *pp++ = 0; 1324: 1773: *pp++ = 255; -: 1774: } -: 1775: 25: 1776: if (withAlpha) { branch 0 taken 44% (fallthrough) branch 1 taken 56% 11: 1777: strcpy(imOut->palette->mode, "RGBA"); -: 1778: } -: 1779: 25: 1780: free(palette); 25: 1781: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1782: 25: 1783: return imOut; -: 1784: -: 1785: } else { -: 1786: #####: 1787: if (result == -1) { branch 0 never executed branch 1 never executed #####: 1788: return (Imaging) ImagingError_ValueError( call 0 never executed -: 1789: "dependency required by this method was not " -: 1790: "enabled at compile time"); -: 1791: } -: 1792: #####: 1793: return (Imaging) ImagingError_ValueError("quantization error"); call 0 never executed -: 1794: -: 1795: } -: 1796:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Point.c.gcov -: 0:Source:src/libImaging/Point.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Point.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Point.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * point (pixel) translation -: 6: * -: 7: * history: -: 8: * 1995-11-27 fl Created -: 9: * 1996-03-31 fl Fixed colour support -: 10: * 1996-08-13 fl Support 8-bit to "1" thresholding -: 11: * 1997-05-31 fl Added floating point transform -: 12: * 1998-07-02 fl Added integer point transform -: 13: * 1998-07-17 fl Support L to anything lookup -: 14: * 2004-12-18 fl Refactored; added I to L lookup -: 15: * -: 16: * Copyright (c) 1997-2004 by Secret Labs AB. -: 17: * Copyright (c) 1995-2004 by Fredrik Lundh. -: 18: * -: 19: * See the README file for information on usage and redistribution. -: 20: */ -: 21: -: 22: -: 23:#include "Imaging.h" -: 24: -: 25:typedef struct { -: 26: const void* table; -: 27:} im_point_context; -: 28: -: 29:static void function im_point_8_8 called 19 returned 100% blocks executed 100% 19: 30:im_point_8_8(Imaging imOut, Imaging imIn, im_point_context* context) -: 31:{ -: 32: int x, y; -: 33: /* 8-bit source, 8-bit destination */ 19: 34: UINT8* table = (UINT8*) context->table; 2399: 35: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2380: 36: UINT8* in = imIn->image8[y]; 2380: 37: UINT8* out = imOut->image8[y]; 706108: 38: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 703728: 39: out[x] = table[in[x]]; -: 40: } -: 41: } 19: 42:} -: 43: -: 44:static void function im_point_2x8_2x8 called 0 returned 0% blocks executed 0% #####: 45:im_point_2x8_2x8(Imaging imOut, Imaging imIn, im_point_context* context) -: 46:{ -: 47: int x, y; -: 48: /* 2x8-bit source, 2x8-bit destination */ #####: 49: UINT8* table = (UINT8*) context->table; #####: 50: for (y = 0; y < imIn->ysize; y++) { branch 0 never executed branch 1 never executed #####: 51: UINT8* in = (UINT8*) imIn->image[y]; #####: 52: UINT8* out = (UINT8*) imOut->image[y]; #####: 53: for (x = 0; x < imIn->xsize; x++) { branch 0 never executed branch 1 never executed #####: 54: out[0] = table[in[0]]; #####: 55: out[3] = table[in[3]+256]; #####: 56: in += 4; out += 4; -: 57: } -: 58: } #####: 59:} -: 60: -: 61:static void function im_point_3x8_3x8 called 18 returned 100% blocks executed 100% 18: 62:im_point_3x8_3x8(Imaging imOut, Imaging imIn, im_point_context* context) -: 63:{ -: 64: int x, y; -: 65: /* 3x8-bit source, 3x8-bit destination */ 18: 66: UINT8* table = (UINT8*) context->table; 2448: 67: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2430: 68: UINT8* in = (UINT8*) imIn->image[y]; 2430: 69: UINT8* out = (UINT8*) imOut->image[y]; 805214: 70: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 802784: 71: out[0] = table[in[0]]; 802784: 72: out[1] = table[in[1]+256]; 802784: 73: out[2] = table[in[2]+512]; 802784: 74: in += 4; out += 4; -: 75: } -: 76: } 18: 77:} -: 78: -: 79:static void function im_point_4x8_4x8 called 0 returned 0% blocks executed 0% #####: 80:im_point_4x8_4x8(Imaging imOut, Imaging imIn, im_point_context* context) -: 81:{ -: 82: int x, y; -: 83: /* 4x8-bit source, 4x8-bit destination */ #####: 84: UINT8* table = (UINT8*) context->table; #####: 85: for (y = 0; y < imIn->ysize; y++) { branch 0 never executed branch 1 never executed #####: 86: UINT8* in = (UINT8*) imIn->image[y]; #####: 87: UINT8* out = (UINT8*) imOut->image[y]; #####: 88: for (x = 0; x < imIn->xsize; x++) { branch 0 never executed branch 1 never executed #####: 89: out[0] = table[in[0]]; #####: 90: out[1] = table[in[1]+256]; #####: 91: out[2] = table[in[2]+512]; #####: 92: out[3] = table[in[3]+768]; #####: 93: in += 4; out += 4; -: 94: } -: 95: } #####: 96:} -: 97: -: 98:static void function im_point_8_32 called 1 returned 100% blocks executed 100% 1: 99:im_point_8_32(Imaging imOut, Imaging imIn, im_point_context* context) -: 100:{ -: 101: int x, y; -: 102: /* 8-bit source, 32-bit destination */ 1: 103: char* table = (char*) context->table; 129: 104: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 128: 105: UINT8* in = imIn->image8[y]; 128: 106: INT32* out = imOut->image32[y]; 16512: 107: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 108: memcpy(out + x, table + in[x] * sizeof(INT32), sizeof(INT32)); -: 109: } -: 110: } 1: 111:} -: 112: -: 113:static void function im_point_32_8 called 1 returned 100% blocks executed 90% 1: 114:im_point_32_8(Imaging imOut, Imaging imIn, im_point_context* context) -: 115:{ -: 116: int x, y; -: 117: /* 32-bit source, 8-bit destination */ 1: 118: UINT8* table = (UINT8*) context->table; 129: 119: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 128: 120: INT32* in = imIn->image32[y]; 128: 121: UINT8* out = imOut->image8[y]; 16512: 122: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 123: int v = in[x]; 16384: 124: if (v < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 125: v = 0; 16384: 126: } else if (v > 65535) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 127: v = 65535; -: 128: } 16384: 129: out[x] = table[v]; -: 130: } -: 131: } 1: 132:} -: 133: -: 134:Imaging function ImagingPoint called 40 returned 100% blocks executed 89% 40: 135:ImagingPoint(Imaging imIn, const char* mode, const void* table) -: 136:{ -: 137: /* lookup table transform */ -: 138: -: 139: ImagingSectionCookie cookie; -: 140: Imaging imOut; -: 141: im_point_context context; -: 142: void (*point)(Imaging imIn, Imaging imOut, im_point_context* context); -: 143: 40: 144: if (!imIn) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 145: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 146: } -: 147: 40: 148: if (!mode) { branch 0 taken 93% (fallthrough) branch 1 taken 8% 37: 149: mode = imIn->mode; -: 150: } -: 151: 40: 152: if (imIn->type != IMAGING_TYPE_UINT8) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 2: 153: if (imIn->type != IMAGING_TYPE_INT32 || strcmp(mode, "L") != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 50% branch 5 taken 50% -: 154: goto mode_mismatch; -: 155: } 38: 156: } else if (!imIn->image8 && strcmp(imIn->mode, mode) != 0) { branch 0 taken 47% (fallthrough) branch 1 taken 53% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 157: goto mode_mismatch; -: 158: } -: 159: 39: 160: imOut = ImagingNew(mode, imIn->xsize, imIn->ysize); call 0 returned 100% 39: 161: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 162: return NULL; -: 163: } -: 164: -: 165: /* find appropriate handler */ 39: 166: if (imIn->type == IMAGING_TYPE_UINT8) { branch 0 taken 97% (fallthrough) branch 1 taken 3% 38: 167: if (imIn->bands == imOut->bands && imIn->type == imOut->type) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 97% (fallthrough) branch 3 taken 3% 37: 168: switch (imIn->bands) { branch 0 taken 0% branch 1 taken 49% branch 2 taken 0% branch 3 taken 51% -: 169: case 1: -: 170: point = im_point_8_8; -: 171: break; -: 172: case 2: #####: 173: point = im_point_2x8_2x8; #####: 174: break; -: 175: case 3: 18: 176: point = im_point_3x8_3x8; 18: 177: break; -: 178: case 4: #####: 179: point = im_point_4x8_4x8; #####: 180: break; -: 181: default: -: 182: /* this cannot really happen */ -: 183: point = im_point_8_8; -: 184: break; -: 185: } -: 186: } else { -: 187: point = im_point_8_32; -: 188: } -: 189: } else { -: 190: point = im_point_32_8; -: 191: } -: 192: 39: 193: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 194: 39: 195: ImagingSectionEnter(&cookie); call 0 returned 100% -: 196: 39: 197: context.table = table; 39: 198: point(imOut, imIn, &context); call 0 returned 100% -: 199: 39: 200: ImagingSectionLeave(&cookie); call 0 returned 100% -: 201: 39: 202: return imOut; -: 203: -: 204: mode_mismatch: 1: 205: return (Imaging) ImagingError_ValueError( call 0 returned 100% -: 206: "point operation not supported for this mode" -: 207: ); -: 208:} -: 209: -: 210: -: 211:Imaging function ImagingPointTransform called 4 returned 100% blocks executed 70% 4: 212:ImagingPointTransform(Imaging imIn, double scale, double offset) -: 213:{ -: 214: /* scale/offset transform */ -: 215: -: 216: ImagingSectionCookie cookie; -: 217: Imaging imOut; -: 218: int x, y; -: 219: 5: 220: if (!imIn || (strcmp(imIn->mode, "I") != 0 && branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 75% (fallthrough) branch 3 taken 25% branch 4 taken 25% (fallthrough) branch 5 taken 75% branch 6 taken 100% (fallthrough) branch 7 taken 0% 2: 221: strcmp(imIn->mode, "I;16") != 0 && branch 0 taken 0% (fallthrough) branch 1 taken 100% 1: 222: strcmp(imIn->mode, "F") != 0)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 223: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 224: } -: 225: 4: 226: imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize); call 0 returned 100% 4: 227: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 228: return NULL; -: 229: } -: 230: 4: 231: switch (imIn->type) { branch 0 taken 75% branch 1 taken 25% branch 2 taken 0% branch 3 taken 0% -: 232: case IMAGING_TYPE_INT32: 3: 233: ImagingSectionEnter(&cookie); 387: 234: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 384: 235: INT32* in = imIn->image32[y]; 384: 236: INT32* out = imOut->image32[y]; -: 237: /* FIXME: add clipping? */ 49536: 238: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49152: 239: out[x] = in[x] * scale + offset; -: 240: } -: 241: } 3: 242: ImagingSectionLeave(&cookie); call 0 returned 100% 3: 243: break; -: 244: case IMAGING_TYPE_FLOAT32: 1: 245: ImagingSectionEnter(&cookie); 129: 246: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 128: 247: FLOAT32* in = (FLOAT32*) imIn->image32[y]; 128: 248: FLOAT32* out = (FLOAT32*) imOut->image32[y]; 16512: 249: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 250: out[x] = in[x] * scale + offset; -: 251: } -: 252: } 1: 253: ImagingSectionLeave(&cookie); call 0 returned 100% 1: 254: break; -: 255: case IMAGING_TYPE_SPECIAL: #####: 256: if (strcmp(imIn->mode,"I;16") == 0) { branch 0 never executed branch 1 never executed #####: 257: ImagingSectionEnter(&cookie); #####: 258: for (y = 0; y < imIn->ysize; y++) { call 0 never executed branch 1 never executed branch 2 never executed #####: 259: char* in = (char*)imIn->image[y]; #####: 260: char* out = (char*)imOut->image[y]; -: 261: /* FIXME: add clipping? */ #####: 262: for (x = 0; x < imIn->xsize; x++) { branch 0 never executed branch 1 never executed -: 263: UINT16 v; #####: 264: memcpy(&v, in + x * sizeof(v), sizeof(v)); #####: 265: v = v * scale + offset; #####: 266: memcpy(out + x * sizeof(UINT16), &v, sizeof(v)); -: 267: } -: 268: } #####: 269: ImagingSectionLeave(&cookie); call 0 never executed #####: 270: break; -: 271: } -: 272: /* FALL THROUGH */ -: 273: default: #####: 274: ImagingDelete(imOut); call 0 never executed #####: 275: return (Imaging) ImagingError_ValueError("internal error"); call 0 never executed -: 276: } -: 277: -: 278: return imOut; -: 279:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Matrix.c.gcov -: 0:Source:src/libImaging/Matrix.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Matrix.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Matrix.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * colour and luminance matrix transforms -: 6: * -: 7: * history: -: 8: * 1996-05-18 fl: created (brute force implementation) -: 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: -: 20:#define CLIPF(v) ((v <= 0.0) ? 0 : (v >= 255.0F) ? 255 : (UINT8) v) -: 21: -: 22: -: 23:Imaging function ImagingConvertMatrix called 4 returned 100% blocks executed 97% 4: 24:ImagingConvertMatrix(Imaging im, const char *mode, float m[]) -: 25:{ -: 26: Imaging imOut; -: 27: int x, y; -: 28: -: 29: /* Assume there's enough data in the buffer */ 4: 30: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 31: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 32: } -: 33: 4: 34: if (strcmp(mode, "L") == 0 && im->bands == 3) { branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 50% (fallthrough) branch 5 taken 50% -: 35: 1: 36: imOut = ImagingNewDirty("L", im->xsize, im->ysize); call 0 returned 100% 1: 37: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 38: return NULL; -: 39: } -: 40: 128: 41: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% 128: 42: UINT8* in = (UINT8*) im->image[y]; 128: 43: UINT8* out = (UINT8*) imOut->image[y]; -: 44: 16512: 45: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16384: 46: float v = m[0]*in[0] + m[1]*in[1] + m[2]*in[2] + m[3] + 0.5; 16384: 47: out[x] = CLIPF(v); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 16384: 48: in += 4; -: 49: } -: 50: } -: 51: 3: 52: } else if (strlen(mode) == 3 && im->bands == 3) { branch 0 taken 67% (fallthrough) branch 1 taken 33% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 53: 2: 54: imOut = ImagingNewDirty(mode, im->xsize, im->ysize); call 0 returned 100% 2: 55: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 56: return NULL; -: 57: } -: 58: 256: 59: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% 256: 60: UINT8* in = (UINT8*) im->image[y]; 256: 61: UINT8* out = (UINT8*) imOut->image[y]; -: 62: 33024: 63: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 64: float v0 = m[0]*in[0] + m[1]*in[1] + m[2]*in[2] + m[3] + 0.5; 32768: 65: float v1 = m[4]*in[0] + m[5]*in[1] + m[6]*in[2] + m[7] + 0.5; 32768: 66: float v2 = m[8]*in[0] + m[9]*in[1] + m[10]*in[2] + m[11] + 0.5; 32768: 67: out[0] = CLIPF(v0); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 99% (fallthrough) branch 3 taken 1% 32768: 68: out[1] = CLIPF(v1); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 99% (fallthrough) branch 3 taken 1% 32768: 69: out[2] = CLIPF(v2); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 99% (fallthrough) branch 3 taken 1% 32768: 70: in += 4; out += 4; -: 71: } -: 72: } -: 73: } else { 1: 74: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 75: } -: 76: -: 77: return imOut; -: 78:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#TgaRleDecode.c.gcov -: 0:Source:src/libImaging/TgaRleDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/TgaRleDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/TgaRleDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for Targa RLE data. -: 6: * -: 7: * history: -: 8: * 97-01-04 fl created -: 9: * 98-09-11 fl don't one byte per pixel; take orientation into account -: 10: * -: 11: * Copyright (c) Fredrik Lundh 1997. -: 12: * Copyright (c) Secret Labs AB 1997-98. -: 13: * -: 14: * See the README file for information on usage and redistribution. -: 15: */ -: 16: -: 17: -: 18:#include "Imaging.h" -: 19: -: 20: -: 21:int function ImagingTgaRleDecode called 33 returned 100% blocks executed 90% 33: 22:ImagingTgaRleDecode(Imaging im, ImagingCodecState state, -: 23: UINT8* buf, Py_ssize_t bytes) -: 24:{ -: 25: int n, depth; -: 26: UINT8* ptr; -: 27: 33: 28: ptr = buf; -: 29: 33: 30: if (state->state == 0) { branch 0 taken 91% (fallthrough) branch 1 taken 9% -: 31: -: 32: /* check image orientation */ 30: 33: if (state->ystep < 0) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 15: 34: state->y = state->ysize-1; 15: 35: state->ystep = -1; -: 36: } else { 15: 37: state->ystep = 1; -: 38: } -: 39: 30: 40: state->state = 1; -: 41: -: 42: } -: 43: 33: 44: depth = state->count; -: 45: -: 46: for (;;) { -: 47: 24577: 48: if (bytes < 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 49: return ptr - buf; -: 50: } -: 51: 24577: 52: if (ptr[0] & 0x80) { branch 0 taken 52% (fallthrough) branch 1 taken 48% -: 53: -: 54: /* Run (1 + pixelsize bytes) */ -: 55: 12885: 56: if (bytes < 1 + depth) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 57: break; -: 58: } -: 59: 12885: 60: n = depth * ((ptr[0] & 0x7f) + 1); -: 61: 12885: 62: if (state->x + n > state->bytes) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 63: state->errcode = IMAGING_CODEC_OVERRUN; #####: 64: return -1; -: 65: } -: 66: 12885: 67: if (depth == 1) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 4948: 68: memset(state->buffer + state->x, ptr[1], n); -: 69: } else { -: 70: int i; 35423: 71: for (i = 0; i < n; i += depth) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 70846: 72: memcpy(state->buffer + state->x + i, ptr+1, depth); -: 73: } -: 74: } -: 75: 12885: 76: ptr += 1 + depth; 12885: 77: bytes -= 1 + depth; -: 78: -: 79: } else { -: 80: -: 81: /* Literal (1+n+1 bytes block) */ 11692: 82: n = depth * (ptr[0] + 1); -: 83: 11692: 84: if (bytes < 1 + n) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 85: break; -: 86: } -: 87: 11689: 88: if (state->x + n > state->bytes) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 89: state->errcode = IMAGING_CODEC_OVERRUN; #####: 90: return -1; -: 91: } -: 92: 23378: 93: memcpy(state->buffer + state->x, ptr + 1, n); -: 94: 11689: 95: ptr += 1 + n; 11689: 96: bytes -= 1 + n; -: 97: -: 98: } -: 99: 24574: 100: state->x += n; -: 101: 24574: 102: if (state->x >= state->bytes) { branch 0 taken 94% branch 1 taken 6% (fallthrough) -: 103: -: 104: /* Got a full line, unpack it */ 4203: 105: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 2802: 106: state->xoff * im->pixelsize, state->buffer, -: 107: state->xsize); -: 108: 1401: 109: state->x = 0; -: 110: 1401: 111: state->y += state->ystep; -: 112: 1401: 113: if (state->y < 0 || state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% branch 3 taken 1% -: 114: /* End of file (errcode = 0) */ -: 115: return -1; -: 116: } -: 117: -: 118: } -: 119: -: 120: } -: 121: 3: 122: return ptr - buf; -: 123:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#JpegDecode.c.gcov -: 0:Source:src/libImaging/JpegDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/JpegDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/JpegDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for JPEG image data. -: 6: * -: 7: * history: -: 8: * 1996-05-02 fl Created -: 9: * 1996-05-05 fl Handle small JPEG files correctly -: 10: * 1996-05-28 fl Added "draft mode" support -: 11: * 1997-01-25 fl Added colour conversion override -: 12: * 1998-01-31 fl Adapted to libjpeg 6a -: 13: * 1998-07-12 fl Extended YCbCr support -: 14: * 1998-12-29 fl Added new state to handle suspension in multipass modes -: 15: * 2000-10-12 fl Suppress warnings -: 16: * 2000-12-04 fl Suppress errors beyond end of image data -: 17: * -: 18: * Copyright (c) 1998-2000 Secret Labs AB -: 19: * Copyright (c) 1996-2000 Fredrik Lundh -: 20: * -: 21: * See the README file for details on usage and redistribution. -: 22: */ -: 23: -: 24: -: 25:#include "Imaging.h" -: 26: -: 27:#ifdef HAVE_LIBJPEG -: 28: -: 29:#undef HAVE_PROTOTYPES -: 30:#undef HAVE_STDLIB_H -: 31:#undef HAVE_STDDEF_H -: 32:#undef UINT8 -: 33:#undef UINT16 -: 34:#undef UINT32 -: 35:#undef INT16 -: 36:#undef INT32 -: 37: -: 38:#include "Jpeg.h" -: 39: -: 40: -: 41:#define STRINGIFY(x) #x -: 42:#define TOSTRING(x) STRINGIFY(x) -: 43: -: 44:// There is no way to compare versions on compile time, -: 45:// so we have to do that in runtime. -: 46:#ifdef LIBJPEG_TURBO_VERSION -: 47:char *libjpeg_turbo_version = TOSTRING(LIBJPEG_TURBO_VERSION); -: 48:#else -: 49:char *libjpeg_turbo_version = NULL; -: 50:#endif -: 51: -: 52:int function ImagingJpegUseJCSExtensions called 354 returned 100% blocks executed 100% 354: 53:ImagingJpegUseJCSExtensions() -: 54:{ 354: 55: int use_jcs_extensions = 0; -: 56: #ifdef JCS_EXTENSIONS -: 57: #if defined(LIBJPEG_TURBO_VERSION_NUMBER) -: 58: #if LIBJPEG_TURBO_VERSION_NUMBER >= 1002010 -: 59: use_jcs_extensions = 1; -: 60: #endif -: 61: #else 354: 62: if (libjpeg_turbo_version) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 354: 63: use_jcs_extensions = strcmp(libjpeg_turbo_version, "1.2.1") >= 0; -: 64: } -: 65: #endif -: 66: #endif 354: 67: return use_jcs_extensions; -: 68:} -: 69: -: 70:/* -------------------------------------------------------------------- */ -: 71:/* Suspending input handler */ -: 72:/* -------------------------------------------------------------------- */ -: 73: -: 74:METHODDEF(void) function stub called 392 returned 100% blocks executed 100% 392: 75:stub(j_decompress_ptr cinfo) -: 76:{ -: 77: /* empty */ 392: 78:} -: 79: -: 80:METHODDEF(boolean) function fill_input_buffer called 26 returned 100% blocks executed 100% 26: 81:fill_input_buffer(j_decompress_ptr cinfo) -: 82:{ -: 83: /* Suspension */ 26: 84: return FALSE; -: 85:} -: 86: -: 87:METHODDEF(void) function skip_input_data called 185 returned 100% blocks executed 100% 185: 88:skip_input_data(j_decompress_ptr cinfo, long num_bytes) -: 89:{ 191: 90: JPEGSOURCE* source = (JPEGSOURCE*) cinfo->src; -: 91: 191: 92: if (num_bytes > (long) source->pub.bytes_in_buffer) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 3% (fallthrough) branch 3 taken 97% -: 93: /* We need to skip more data than we have in the buffer. -: 94: This will force the JPEG library to suspend decoding. */ 6: 95: source->skip = num_bytes - source->pub.bytes_in_buffer; 6: 96: source->pub.next_input_byte += source->pub.bytes_in_buffer; 6: 97: source->pub.bytes_in_buffer = 0; -: 98: } else { -: 99: /* Skip portion of the buffer */ 185: 100: source->pub.bytes_in_buffer -= num_bytes; 185: 101: source->pub.next_input_byte += num_bytes; 185: 102: source->skip = 0; -: 103: } 185: 104:} -: 105: -: 106: -: 107:GLOBAL(void) function jpeg_buffer_src called 197 returned 100% blocks executed 100% 197: 108:jpeg_buffer_src(j_decompress_ptr cinfo, JPEGSOURCE* source) -: 109:{ 197: 110: cinfo->src = (void*) source; -: 111: -: 112: /* Prepare for suspending reader */ 197: 113: source->pub.init_source = stub; 197: 114: source->pub.fill_input_buffer = fill_input_buffer; 197: 115: source->pub.skip_input_data = skip_input_data; 197: 116: source->pub.resync_to_restart = jpeg_resync_to_restart; 197: 117: source->pub.term_source = stub; 197: 118: source->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ -: 119: 197: 120: source->skip = 0; 197: 121:} -: 122: -: 123: -: 124:/* -------------------------------------------------------------------- */ -: 125:/* Error handler */ -: 126:/* -------------------------------------------------------------------- */ -: 127: -: 128:METHODDEF(void) function error called 0 returned 0% blocks executed 0% #####: 129:error(j_common_ptr cinfo) -: 130:{ -: 131: JPEGERROR* error; #####: 132: error = (JPEGERROR*) cinfo->err; #####: 133: longjmp(error->setjmp_buffer, 1); -: 134:} -: 135: -: 136:METHODDEF(void) function output called 1 returned 100% blocks executed 100% 1: 137:output(j_common_ptr cinfo) -: 138:{ -: 139: /* nothing */ 1: 140:} -: 141: -: 142:/* -------------------------------------------------------------------- */ -: 143:/* Decoder */ -: 144:/* -------------------------------------------------------------------- */ -: 145: -: 146:int function ImagingJpegDecode called 221 returned 100% blocks executed 75% 221: 147:ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 148:{ 221: 149: JPEGSTATE* context = (JPEGSTATE*) state->context; -: 150: int ok; -: 151: 221: 152: if (setjmp(context->error.setjmp_buffer)) { branch 0 taken 0% branch 1 taken 100% -: 153: /* JPEG error handler */ #####: 154: jpeg_destroy_decompress(&context->cinfo); call 0 never executed #####: 155: state->errcode = IMAGING_CODEC_BROKEN; #####: 156: return -1; -: 157: } -: 158: 221: 159: if (!state->state) { branch 0 taken 89% (fallthrough) branch 1 taken 11% -: 160: -: 161: /* Setup decompression context */ 197: 162: context->cinfo.err = jpeg_std_error(&context->error.pub); call 0 returned 100% 197: 163: context->error.pub.error_exit = error; 197: 164: context->error.pub.output_message = output; 197: 165: jpeg_create_decompress(&context->cinfo); call 0 returned 100% 197: 166: jpeg_buffer_src(&context->cinfo, &context->source); call 0 returned 100% -: 167: -: 168: /* Ready to decode */ 197: 169: state->state = 1; -: 170: -: 171: } -: 172: -: 173: /* Load the source buffer */ 221: 174: context->source.pub.next_input_byte = buf; 221: 175: context->source.pub.bytes_in_buffer = bytes; -: 176: 221: 177: if (context->source.skip > 0) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 12: 178: skip_input_data(&context->cinfo, context->source.skip); 6: 179: if (context->source.skip > 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 180: return context->source.pub.next_input_byte - buf; -: 181: } -: 182: } -: 183: 221: 184: switch (state->state) { branch 0 taken 92% branch 1 taken 1% branch 2 taken 7% branch 3 taken 0% branch 4 taken 0% -: 185: -: 186: case 1: -: 187: -: 188: /* Read JPEG header, until we find an image body. */ -: 189: do { -: 190: -: 191: /* Note that we cannot return unless we have decoded -: 192: as much data as possible. */ 203: 193: ok = jpeg_read_header(&context->cinfo, FALSE); call 0 returned 100% -: 194: 203: 195: } while (ok == JPEG_HEADER_TABLES_ONLY); branch 0 taken 0% branch 1 taken 100% (fallthrough) -: 196: 203: 197: if (ok == JPEG_SUSPENDED) { branch 0 taken 97% (fallthrough) branch 1 taken 3% -: 198: break; -: 199: } -: 200: -: 201: /* Decoder settings */ -: 202: -: 203: /* jpegmode indicates whats in the file; if not set, we'll -: 204: trust the decoder */ 197: 205: if (strcmp(context->jpegmode, "L") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 206: context->cinfo.jpeg_color_space = JCS_GRAYSCALE; 197: 207: } else if (strcmp(context->jpegmode, "RGB") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed branch 6 taken 0% (fallthrough) branch 7 taken 100% #####: 208: context->cinfo.jpeg_color_space = JCS_RGB; 197: 209: } else if (strcmp(context->jpegmode, "CMYK") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 210: context->cinfo.jpeg_color_space = JCS_CMYK; 197: 211: } else if (strcmp(context->jpegmode, "YCbCr") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 212: context->cinfo.jpeg_color_space = JCS_YCbCr; 197: 213: } else if (strcmp(context->jpegmode, "YCbCrK") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 214: context->cinfo.jpeg_color_space = JCS_YCCK; -: 215: } -: 216: -: 217: /* rawmode indicates what we want from the decoder. if not -: 218: set, conversions are disabled */ 197: 219: if (strcmp(context->rawmode, "L") == 0) { branch 0 taken 15% (fallthrough) branch 1 taken 85% branch 2 taken 15% (fallthrough) branch 3 taken 85% 29: 220: context->cinfo.out_color_space = JCS_GRAYSCALE; 168: 221: } else if (strcmp(context->rawmode, "RGB") == 0) { branch 0 taken 88% (fallthrough) branch 1 taken 12% 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% #####: 222: context->cinfo.out_color_space = JCS_RGB; -: 223: } -: 224: #ifdef JCS_EXTENSIONS 168: 225: else if (strcmp(context->rawmode, "RGBX") == 0) { branch 0 taken 88% (fallthrough) branch 1 taken 12% 148: 226: context->cinfo.out_color_space = JCS_EXT_RGBX; -: 227: } -: 228: #endif 40: 229: else if (strcmp(context->rawmode, "CMYK") == 0 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 95% (fallthrough) branch 3 taken 5% 20: 230: strcmp(context->rawmode, "CMYK;I") == 0) { 19: 231: context->cinfo.out_color_space = JCS_CMYK; 1: 232: } else if (strcmp(context->rawmode, "YCbCr") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 233: context->cinfo.out_color_space = JCS_YCbCr; #####: 234: } else if (strcmp(context->rawmode, "YCbCrK") == 0) { branch 0 never executed branch 1 never executed #####: 235: context->cinfo.out_color_space = JCS_YCCK; -: 236: } else { -: 237: /* Disable decoder conversions */ #####: 238: context->cinfo.jpeg_color_space = JCS_UNKNOWN; #####: 239: context->cinfo.out_color_space = JCS_UNKNOWN; -: 240: } -: 241: 197: 242: if (context->scale > 1) { branch 0 taken 10% (fallthrough) branch 1 taken 90% 19: 243: context->cinfo.scale_num = 1; 19: 244: context->cinfo.scale_denom = context->scale; -: 245: } 197: 246: if (context->draft) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 247: context->cinfo.do_fancy_upsampling = FALSE; #####: 248: context->cinfo.dct_method = JDCT_FASTEST; -: 249: } -: 250: 197: 251: state->state++; -: 252: /* fall through */ -: 253: -: 254: case 2: -: 255: -: 256: /* Set things up for decompression (this processes the entire -: 257: file if necessary to return data line by line) */ 199: 258: if (!jpeg_start_decompress(&context->cinfo)) { call 0 returned 100% branch 1 taken 98% (fallthrough) branch 2 taken 2% -: 259: break; -: 260: } -: 261: 195: 262: state->state++; -: 263: /* fall through */ -: 264: -: 265: case 3: -: 266: -: 267: /* Decompress a single line of data */ -: 268: ok = 1; 36379: 269: while (state->y < state->ysize) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 36184: 270: ok = jpeg_read_scanlines(&context->cinfo, &state->buffer, 1); call 0 returned 100% 36184: 271: if (ok != 1) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 272: break; -: 273: } 108504: 274: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 72336: 275: state->xoff * im->pixelsize, state->buffer, -: 276: state->xsize); 36168: 277: state->y++; -: 278: } 211: 279: if (ok != 1) { branch 0 taken 92% (fallthrough) branch 1 taken 8% -: 280: break; -: 281: } 195: 282: state->state++; -: 283: /* fall through */ -: 284: -: 285: case 4: -: 286: -: 287: /* Finish decompression */ 195: 288: if (!jpeg_finish_decompress(&context->cinfo)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 289: /* FIXME: add strictness mode test */ #####: 290: if (state->y < state->ysize) { branch 0 never executed branch 1 never executed -: 291: break; -: 292: } -: 293: } -: 294: -: 295: /* Clean up */ 195: 296: jpeg_destroy_decompress(&context->cinfo); call 0 returned 100% -: 297: /* if (jerr.pub.num_warnings) return BROKEN; */ -: 298: return -1; -: 299: -: 300: } -: 301: -: 302: /* Return number of bytes consumed */ 26: 303: return context->source.pub.next_input_byte - buf; -: 304: -: 305:} -: 306: -: 307:/* -------------------------------------------------------------------- */ -: 308:/* Cleanup */ -: 309:/* -------------------------------------------------------------------- */ -: 310: function ImagingJpegDecodeCleanup called 394 returned 100% blocks executed 100% 394: 311:int ImagingJpegDecodeCleanup(ImagingCodecState state){ -: 312: /* called to free the decompression engine when the decode terminates -: 313: due to a corrupt or truncated image -: 314: */ 394: 315: JPEGSTATE* context = (JPEGSTATE*) state->context; -: 316: -: 317: /* Clean up */ 394: 318: jpeg_destroy_decompress(&context->cinfo); call 0 returned 100% 394: 319: return -1; -: 320:} -: 321: -: 322:#endif -: 323: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#File.c.gcov -: 0:Source:src/libImaging/File.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/File.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/File.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * built-in image file handling -: 6: * -: 7: * history: -: 8: * 1995-11-26 fl Created, supports PGM/PPM -: 9: * 1996-08-07 fl Write "1" images as PGM -: 10: * 1999-02-21 fl Don't write non-standard modes -: 11: * -: 12: * Copyright (c) 1997-99 by Secret Labs AB. -: 13: * Copyright (c) 1995-96 by Fredrik Lundh. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21:#include -: 22: -: 23: -: 24:int function ImagingSaveRaw called 20 returned 100% blocks executed 94% 20: 25:ImagingSaveRaw(Imaging im, FILE* fp) -: 26:{ -: 27: int x, y, i; -: 28: 20: 29: if (strcmp(im->mode, "1") == 0 || strcmp(im->mode, "L") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 35% (fallthrough) branch 5 taken 65% branch 6 taken 65% (fallthrough) branch 7 taken 35% -: 30: -: 31: /* @PIL227: FIXME: for mode "1", map != 0 to 255 */ -: 32: -: 33: /* PGM "L" */ 778: 34: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% 778: 35: fwrite(im->image[y], 1, im->xsize, fp); call 0 returned 100% -: 36: } -: 37: -: 38: } else { -: 39: -: 40: /* PPM "RGB" or other internal format */ 1546: 41: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 196708: 42: for (x = i = 0; x < im->xsize; x++, i += im->pixelsize) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 196708: 43: fwrite(im->image[y]+i, 1, im->bands, fp); call 0 returned 100% -: 44: } -: 45: } -: 46: -: 47: } -: 48: 20: 49: return 1; -: 50:} -: 51: -: 52: -: 53:int function ImagingSavePPM called 21 returned 100% blocks executed 81% 21: 54:ImagingSavePPM(Imaging im, const char* outfile) -: 55:{ -: 56: FILE* fp; -: 57: 21: 58: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 59: (void) ImagingError_ValueError(NULL); call 0 never executed #####: 60: return 0; -: 61: } -: 62: 21: 63: fp = fopen(outfile, "wb"); call 0 returned 100% 21: 64: if (!fp) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 65: (void) ImagingError_OSError(); call 0 never executed #####: 66: return 0; -: 67: } -: 68: 21: 69: if (strcmp(im->mode, "1") == 0 || strcmp(im->mode, "L") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 33% (fallthrough) branch 5 taken 67% branch 6 taken 33% (fallthrough) branch 7 taken 67% -: 70: /* Write "PGM" */ 7: 71: fprintf(fp, "P5\n%d %d\n255\n", im->xsize, im->ysize); 14: 72: } else if (strcmp(im->mode, "RGB") == 0) { branch 0 taken 93% (fallthrough) branch 1 taken 7% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 93% (fallthrough) branch 7 taken 7% -: 73: /* Write "PPM" */ 13: 74: fprintf(fp, "P6\n%d %d\n255\n", im->xsize, im->ysize); -: 75: } else { 1: 76: fclose(fp); call 0 returned 100% 1: 77: (void) ImagingError_ModeError(); call 0 returned 100% 1: 78: return 0; -: 79: } -: 80: 20: 81: ImagingSaveRaw(im, fp); call 0 returned 100% -: 82: 20: 83: fclose(fp); call 0 returned 100% -: 84: 20: 85: return 1; -: 86:} -: 87: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Geometry.c.gcov -: 0:Source:src/libImaging/Geometry.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Geometry.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Geometry.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Imaging.h" -: 2: -: 3:/* For large images rotation is an inefficient operation in terms of CPU cache. -: 4: One row in the source image affects each column in destination. -: 5: Rotating in chunks that fit in the cache can speed up rotation -: 6: 8x on a modern CPU. A chunk size of 128 requires only 65k and is large enough -: 7: that the overhead from the extra loops are not apparent. */ -: 8:#define ROTATE_CHUNK 512 -: 9:#define ROTATE_SMALL_CHUNK 8 -: 10: -: 11:#define COORD(v) ((v) < 0.0 ? -1 : ((int)(v))) -: 12:#define FLOOR(v) ((v) < 0.0 ? ((int)floor(v)) : ((int)(v))) -: 13: -: 14:/* -------------------------------------------------------------------- */ -: 15:/* Transpose operations */ -: 16: -: 17:Imaging function ImagingFlipLeftRight called 33 returned 100% blocks executed 94% 33: 18:ImagingFlipLeftRight(Imaging imOut, Imaging imIn) -: 19:{ -: 20: ImagingSectionCookie cookie; -: 21: int x, y, xr; -: 22: 33: 23: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 24: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 25: } 33: 26: if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 27: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 28: } -: 29: 33: 30: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 31: -: 32:#define FLIP_LEFT_RIGHT(INT, image) \ -: 33: for (y = 0; y < imIn->ysize; y++) { \ -: 34: INT* in = (INT *)imIn->image[y]; \ -: 35: INT* out = (INT *)imOut->image[y]; \ -: 36: xr = imIn->xsize-1; \ -: 37: for (x = 0; x < imIn->xsize; x++, xr--) { \ -: 38: out[xr] = in[x]; \ -: 39: } \ -: 40: } -: 41: 33: 42: ImagingSectionEnter(&cookie); call 0 returned 100% -: 43: 33: 44: if (imIn->image8) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 21: 45: if (strncmp(imIn->mode, "I;16", 4) == 0) { branch 0 taken 29% (fallthrough) branch 1 taken 71% 1869: 46: FLIP_LEFT_RIGHT(UINT16, image8) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% -: 47: } else { 751: 48: FLIP_LEFT_RIGHT(UINT8, image8) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% -: 49: } -: 50: } else { 1463: 51: FLIP_LEFT_RIGHT(INT32, image32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) -: 52: } -: 53: 33: 54: ImagingSectionLeave(&cookie); call 0 returned 100% -: 55: -: 56:#undef FLIP_LEFT_RIGHT -: 57: 33: 58: return imOut; -: 59:} -: 60: -: 61: -: 62:Imaging function ImagingFlipTopBottom called 31 returned 100% blocks executed 87% 31: 63:ImagingFlipTopBottom(Imaging imOut, Imaging imIn) -: 64:{ -: 65: ImagingSectionCookie cookie; -: 66: int y, yr; -: 67: 31: 68: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 69: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 70: } 31: 71: if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 72: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 73: } -: 74: 31: 75: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 76: 31: 77: ImagingSectionEnter(&cookie); call 0 returned 100% -: 78: 31: 79: yr = imIn->ysize - 1; 3914: 80: for (y = 0; y < imIn->ysize; y++, yr--) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 7766: 81: memcpy(imOut->image[yr], imIn->image[y], imIn->linesize); -: 82: } -: 83: 31: 84: ImagingSectionLeave(&cookie); call 0 returned 100% -: 85: 31: 86: return imOut; -: 87:} -: 88: -: 89: -: 90:Imaging function ImagingRotate90 called 68 returned 100% blocks executed 97% 68: 91:ImagingRotate90(Imaging imOut, Imaging imIn) -: 92:{ -: 93: ImagingSectionCookie cookie; -: 94: int x, y, xx, yy, xr, xxsize, yysize; -: 95: int xxx, yyy, xxxsize, yyysize; -: 96: 68: 97: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 98: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 99: } 68: 100: if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 101: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 102: } -: 103: 68: 104: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 105: -: 106:#define ROTATE_90(INT, image) \ -: 107: for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ -: 108: for (x = 0; x < imIn->xsize; x += ROTATE_CHUNK) { \ -: 109: yysize = y + ROTATE_CHUNK < imIn->ysize ? y + ROTATE_CHUNK : imIn->ysize; \ -: 110: xxsize = x + ROTATE_CHUNK < imIn->xsize ? x + ROTATE_CHUNK : imIn->xsize; \ -: 111: for (yy = y; yy < yysize; yy += ROTATE_SMALL_CHUNK) { \ -: 112: for (xx = x; xx < xxsize; xx += ROTATE_SMALL_CHUNK) { \ -: 113: yyysize = yy + ROTATE_SMALL_CHUNK < imIn->ysize ? yy + ROTATE_SMALL_CHUNK : imIn->ysize; \ -: 114: xxxsize = xx + ROTATE_SMALL_CHUNK < imIn->xsize ? xx + ROTATE_SMALL_CHUNK : imIn->xsize; \ -: 115: for (yyy = yy; yyy < yyysize; yyy++) { \ -: 116: INT* in = (INT *)imIn->image[yyy]; \ -: 117: xr = imIn->xsize - 1 - xx; \ -: 118: for (xxx = xx; xxx < xxxsize; xxx++, xr--) { \ -: 119: INT* out = (INT *)imOut->image[xr]; \ -: 120: out[yyy] = in[xxx]; \ -: 121: } \ -: 122: } \ -: 123: } \ -: 124: } \ -: 125: } \ -: 126: } -: 127: 68: 128: ImagingSectionEnter(&cookie); call 0 returned 100% -: 129: 68: 130: if (imIn->image8) { branch 0 taken 18% (fallthrough) branch 1 taken 82% 56: 131: if (strncmp(imIn->mode, "I;16", 4) == 0) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 12: 132: ROTATE_90(UINT16, image8); branch 0 taken 88% branch 1 taken 12% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 133: } else { 44: 134: ROTATE_90(UINT8, image8); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 98% branch 5 taken 2% (fallthrough) branch 6 taken 97% branch 7 taken 3% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 135: } -: 136: } else { 12: 137: ROTATE_90(INT32, image32); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 96% branch 5 taken 4% (fallthrough) branch 6 taken 96% branch 7 taken 4% branch 8 taken 52% branch 9 taken 48% (fallthrough) branch 10 taken 48% branch 11 taken 52% (fallthrough) -: 138: } -: 139: 68: 140: ImagingSectionLeave(&cookie); call 0 returned 100% -: 141: -: 142:#undef ROTATE_90 -: 143: 68: 144: return imOut; -: 145:} -: 146: -: 147: -: 148:Imaging function ImagingTranspose called 140 returned 100% blocks executed 97% 140: 149:ImagingTranspose(Imaging imOut, Imaging imIn) -: 150:{ -: 151: ImagingSectionCookie cookie; -: 152: int x, y, xx, yy, xxsize, yysize; -: 153: int xxx, yyy, xxxsize, yyysize; -: 154: 140: 155: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 156: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 157: } 140: 158: if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 159: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 160: } -: 161: 140: 162: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 163: -: 164:#define TRANSPOSE(INT, image) \ -: 165: for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ -: 166: for (x = 0; x < imIn->xsize; x += ROTATE_CHUNK) { \ -: 167: yysize = y + ROTATE_CHUNK < imIn->ysize ? y + ROTATE_CHUNK : imIn->ysize; \ -: 168: xxsize = x + ROTATE_CHUNK < imIn->xsize ? x + ROTATE_CHUNK : imIn->xsize; \ -: 169: for (yy = y; yy < yysize; yy += ROTATE_SMALL_CHUNK) { \ -: 170: for (xx = x; xx < xxsize; xx += ROTATE_SMALL_CHUNK) { \ -: 171: yyysize = yy + ROTATE_SMALL_CHUNK < imIn->ysize ? yy + ROTATE_SMALL_CHUNK : imIn->ysize; \ -: 172: xxxsize = xx + ROTATE_SMALL_CHUNK < imIn->xsize ? xx + ROTATE_SMALL_CHUNK : imIn->xsize; \ -: 173: for (yyy = yy; yyy < yyysize; yyy++) { \ -: 174: INT* in = (INT *)imIn->image[yyy]; \ -: 175: for (xxx = xx; xxx < xxxsize; xxx++) { \ -: 176: INT* out = (INT *)imOut->image[xxx]; \ -: 177: out[yyy] = in[xxx]; \ -: 178: } \ -: 179: } \ -: 180: } \ -: 181: } \ -: 182: } \ -: 183: } -: 184: 140: 185: ImagingSectionEnter(&cookie); call 0 returned 100% -: 186: 140: 187: if (imIn->image8) { branch 0 taken 60% (fallthrough) branch 1 taken 40% 56: 188: if (strncmp(imIn->mode, "I;16", 4) == 0) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 12: 189: TRANSPOSE(UINT16, image8); branch 0 taken 88% branch 1 taken 12% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 190: } else { 44: 191: TRANSPOSE(UINT8, image8); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 87% branch 7 taken 13% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 192: } -: 193: } else { 84: 194: TRANSPOSE(INT32, image32); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 90% branch 7 taken 10% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% (fallthrough) -: 195: } -: 196: 140: 197: ImagingSectionLeave(&cookie); call 0 returned 100% -: 198: -: 199:#undef TRANSPOSE -: 200: 140: 201: return imOut; -: 202:} -: 203: -: 204: -: 205:Imaging function ImagingTransverse called 24 returned 100% blocks executed 97% 24: 206:ImagingTransverse(Imaging imOut, Imaging imIn) -: 207:{ -: 208: ImagingSectionCookie cookie; -: 209: int x, y, xr, yr, xx, yy, xxsize, yysize; -: 210: int xxx, yyy, xxxsize, yyysize; -: 211: 24: 212: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 213: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 214: } 24: 215: if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 216: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 217: } -: 218: 24: 219: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 220: -: 221:#define TRANSVERSE(INT, image) \ -: 222: for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ -: 223: for (x = 0; x < imIn->xsize; x += ROTATE_CHUNK) { \ -: 224: yysize = y + ROTATE_CHUNK < imIn->ysize ? y + ROTATE_CHUNK : imIn->ysize; \ -: 225: xxsize = x + ROTATE_CHUNK < imIn->xsize ? x + ROTATE_CHUNK : imIn->xsize; \ -: 226: for (yy = y; yy < yysize; yy += ROTATE_SMALL_CHUNK) { \ -: 227: for (xx = x; xx < xxsize; xx += ROTATE_SMALL_CHUNK) { \ -: 228: yyysize = yy + ROTATE_SMALL_CHUNK < imIn->ysize ? yy + ROTATE_SMALL_CHUNK : imIn->ysize; \ -: 229: xxxsize = xx + ROTATE_SMALL_CHUNK < imIn->xsize ? xx + ROTATE_SMALL_CHUNK : imIn->xsize; \ -: 230: yr = imIn->ysize - 1 - yy; \ -: 231: for (yyy = yy; yyy < yyysize; yyy++, yr--) { \ -: 232: INT* in = (INT *)imIn->image[yyy]; \ -: 233: xr = imIn->xsize - 1 - xx; \ -: 234: for (xxx = xx; xxx < xxxsize; xxx++, xr--) { \ -: 235: INT* out = (INT *)imOut->image[xr]; \ -: 236: out[yr] = in[xxx]; \ -: 237: } \ -: 238: } \ -: 239: } \ -: 240: } \ -: 241: } \ -: 242: } -: 243: 24: 244: ImagingSectionEnter(&cookie); call 0 returned 100% -: 245: 24: 246: if (imIn->image8) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 16: 247: if (strncmp(imIn->mode, "I;16", 4) == 0) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 12: 248: TRANSVERSE(UINT16, image8); branch 0 taken 88% branch 1 taken 12% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 249: } else { 4: 250: TRANSVERSE(UINT8, image8); branch 0 taken 88% branch 1 taken 12% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 251: } -: 252: } else { 8: 253: TRANSVERSE(INT32, image32); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% (fallthrough) -: 254: } -: 255: 24: 256: ImagingSectionLeave(&cookie); call 0 returned 100% -: 257: -: 258:#undef TRANSVERSE -: 259: 24: 260: return imOut; -: 261:} -: 262: -: 263: -: 264:Imaging function ImagingRotate180 called 58 returned 100% blocks executed 94% 58: 265:ImagingRotate180(Imaging imOut, Imaging imIn) -: 266:{ -: 267: ImagingSectionCookie cookie; -: 268: int x, y, xr, yr; -: 269: 58: 270: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 271: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 272: } 58: 273: if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 274: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 275: } -: 276: 58: 277: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 278: -: 279:#define ROTATE_180(INT, image) \ -: 280: for (y = 0; y < imIn->ysize; y++, yr--) { \ -: 281: INT* in = (INT *)imIn->image[y]; \ -: 282: INT* out = (INT *)imOut->image[yr]; \ -: 283: xr = imIn->xsize-1; \ -: 284: for (x = 0; x < imIn->xsize; x++, xr--) { \ -: 285: out[xr] = in[x]; \ -: 286: } \ -: 287: } -: 288: 58: 289: ImagingSectionEnter(&cookie); call 0 returned 100% -: 290: 58: 291: yr = imIn->ysize-1; 58: 292: if (imIn->image8) { branch 0 taken 24% (fallthrough) branch 1 taken 76% 44: 293: if (strncmp(imIn->mode, "I;16", 4) == 0) { branch 0 taken 73% (fallthrough) branch 1 taken 27% 1524: 294: ROTATE_180(UINT16, image8) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% -: 295: } else { 4988: 296: ROTATE_180(UINT8, image8) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% -: 297: } -: 298: } else { 2156: 299: ROTATE_180(INT32, image32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) -: 300: } -: 301: 58: 302: ImagingSectionLeave(&cookie); call 0 returned 100% -: 303: -: 304:#undef ROTATE_180 -: 305: 58: 306: return imOut; -: 307:} -: 308: -: 309: -: 310:Imaging function ImagingRotate270 called 45 returned 100% blocks executed 97% 45: 311:ImagingRotate270(Imaging imOut, Imaging imIn) -: 312:{ -: 313: ImagingSectionCookie cookie; -: 314: int x, y, xx, yy, yr, xxsize, yysize; -: 315: int xxx, yyy, xxxsize, yyysize; -: 316: 45: 317: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 318: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 319: } 45: 320: if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 321: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 322: } -: 323: 45: 324: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 325: -: 326:#define ROTATE_270(INT, image) \ -: 327: for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ -: 328: for (x = 0; x < imIn->xsize; x += ROTATE_CHUNK) { \ -: 329: yysize = y + ROTATE_CHUNK < imIn->ysize ? y + ROTATE_CHUNK : imIn->ysize; \ -: 330: xxsize = x + ROTATE_CHUNK < imIn->xsize ? x + ROTATE_CHUNK : imIn->xsize; \ -: 331: for (yy = y; yy < yysize; yy += ROTATE_SMALL_CHUNK) { \ -: 332: for (xx = x; xx < xxsize; xx += ROTATE_SMALL_CHUNK) { \ -: 333: yyysize = yy + ROTATE_SMALL_CHUNK < imIn->ysize ? yy + ROTATE_SMALL_CHUNK : imIn->ysize; \ -: 334: xxxsize = xx + ROTATE_SMALL_CHUNK < imIn->xsize ? xx + ROTATE_SMALL_CHUNK : imIn->xsize; \ -: 335: yr = imIn->ysize - 1 - yy; \ -: 336: for (yyy = yy; yyy < yyysize; yyy++, yr--) { \ -: 337: INT* in = (INT *)imIn->image[yyy]; \ -: 338: for (xxx = xx; xxx < xxxsize; xxx++) { \ -: 339: INT* out = (INT *)imOut->image[xxx]; \ -: 340: out[yr] = in[xxx]; \ -: 341: } \ -: 342: } \ -: 343: } \ -: 344: } \ -: 345: } \ -: 346: } -: 347: 45: 348: ImagingSectionEnter(&cookie); call 0 returned 100% -: 349: 45: 350: if (imIn->image8) { branch 0 taken 29% (fallthrough) branch 1 taken 71% 32: 351: if (strncmp(imIn->mode, "I;16", 4) == 0) { branch 0 taken 63% (fallthrough) branch 1 taken 38% 12: 352: ROTATE_270(UINT16, image8); branch 0 taken 88% branch 1 taken 12% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 94% branch 5 taken 6% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 353: } else { 20: 354: ROTATE_270(UINT8, image8); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 95% branch 5 taken 5% (fallthrough) branch 6 taken 94% branch 7 taken 6% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 50% branch 11 taken 50% -: 355: } -: 356: } else { 13: 357: ROTATE_270(INT32, image32); branch 0 taken 89% branch 1 taken 11% (fallthrough) branch 2 taken 89% branch 3 taken 11% branch 4 taken 96% branch 5 taken 4% (fallthrough) branch 6 taken 95% branch 7 taken 5% branch 8 taken 52% branch 9 taken 48% (fallthrough) branch 10 taken 48% branch 11 taken 52% (fallthrough) -: 358: } -: 359: 45: 360: ImagingSectionLeave(&cookie); call 0 returned 100% -: 361: -: 362:#undef ROTATE_270 -: 363: 45: 364: return imOut; -: 365:} -: 366: -: 367: -: 368:/* -------------------------------------------------------------------- */ -: 369:/* Transforms */ -: 370: -: 371:/* transform primitives (ImagingTransformMap) */ -: 372: -: 373:static int function affine_transform called 879938 returned 100% blocks executed 100% 879938: 374:affine_transform(double* xout, double* yout, int x, int y, void* data) -: 375:{ -: 376: /* full moon tonight. your compiler will generate bogus code -: 377: for simple expressions, unless you reorganize the code, or -: 378: install Service Pack 3 */ -: 379: 879938: 380: double* a = (double*) data; 879938: 381: double a0 = a[0]; double a1 = a[1]; double a2 = a[2]; 879938: 382: double a3 = a[3]; double a4 = a[4]; double a5 = a[5]; -: 383: 879938: 384: double xin = x + 0.5; 879938: 385: double yin = y + 0.5; -: 386: 879938: 387: xout[0] = a0*xin + a1*yin + a2; 879938: 388: yout[0] = a3*xin + a4*yin + a5; -: 389: 879938: 390: return 1; -: 391:} -: 392: -: 393:static int function perspective_transform called 1006161 returned 100% blocks executed 100% 1006161: 394:perspective_transform(double* xout, double* yout, int x, int y, void* data) -: 395:{ 1006161: 396: double* a = (double*) data; 1006161: 397: double a0 = a[0]; double a1 = a[1]; double a2 = a[2]; 1006161: 398: double a3 = a[3]; double a4 = a[4]; double a5 = a[5]; 1006161: 399: double a6 = a[6]; double a7 = a[7]; -: 400: 1006161: 401: double xin = x + 0.5; 1006161: 402: double yin = y + 0.5; -: 403: 1006161: 404: xout[0] = (a0*xin + a1*yin + a2) / (a6*xin + a7*yin + 1); 1006161: 405: yout[0] = (a3*xin + a4*yin + a5) / (a6*xin + a7*yin + 1); -: 406: 1006161: 407: return 1; -: 408:} -: 409: -: 410:static int function quad_transform called 75540 returned 100% blocks executed 100% 75540: 411:quad_transform(double* xout, double* yout, int x, int y, void* data) -: 412:{ -: 413: /* quad warp: map quadrilateral to rectangle */ -: 414: 75540: 415: double* a = (double*) data; 75540: 416: double a0 = a[0]; double a1 = a[1]; double a2 = a[2]; double a3 = a[3]; 75540: 417: double a4 = a[4]; double a5 = a[5]; double a6 = a[6]; double a7 = a[7]; -: 418: 75540: 419: double xin = x + 0.5; 75540: 420: double yin = y + 0.5; -: 421: 75540: 422: xout[0] = a0 + a1*xin + a2*yin + a3*xin*yin; 75540: 423: yout[0] = a4 + a5*xin + a6*yin + a7*xin*yin; -: 424: 75540: 425: return 1; -: 426:} -: 427: -: 428:/* transform filters (ImagingTransformFilter) */ -: 429: -: 430:static int function nearest_filter8 called 10004 returned 100% blocks executed 100% 10004: 431:nearest_filter8(void* out, Imaging im, double xin, double yin) -: 432:{ 10004: 433: int x = COORD(xin); branch 0 taken 100% (fallthrough) branch 1 taken 0% 10004: 434: int y = COORD(yin); branch 0 taken 100% (fallthrough) branch 1 taken 0% 10004: 435: 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 100% (fallthrough) branch 7 taken 0% -: 436: return 0; -: 437: } 10004: 438: ((UINT8*)out)[0] = im->image8[y][x]; 10004: 439: return 1; -: 440:} -: 441: -: 442:static int function nearest_filter16 called 3252 returned 100% blocks executed 100% 3252: 443:nearest_filter16(void* out, Imaging im, double xin, double yin) -: 444:{ 3252: 445: int x = COORD(xin); branch 0 taken 100% (fallthrough) branch 1 taken 0% 3252: 446: int y = COORD(yin); branch 0 taken 100% (fallthrough) branch 1 taken 0% 3252: 447: 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 100% (fallthrough) branch 7 taken 0% -: 448: return 0; -: 449: } 6504: 450: memcpy(out, im->image8[y] + x * sizeof(INT16), sizeof(INT16)); 3252: 451: return 1; -: 452:} -: 453: -: 454:static int function nearest_filter32 called 335387 returned 100% blocks executed 100% 335387: 455:nearest_filter32(void* out, Imaging im, double xin, double yin) -: 456:{ 335387: 457: int x = COORD(xin); branch 0 taken 98% (fallthrough) branch 1 taken 2% 335387: 458: int y = COORD(yin); branch 0 taken 98% (fallthrough) branch 1 taken 2% 335387: 459: if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) { branch 0 taken 98% (fallthrough) branch 1 taken 2% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 98% (fallthrough) branch 5 taken 2% branch 6 taken 100% (fallthrough) branch 7 taken 0% -: 460: return 0; -: 461: } 645998: 462: memcpy(out, &im->image32[y][x], sizeof(INT32)); 322999: 463: return 1; -: 464:} -: 465: -: 466:#define XCLIP(im, x) ( ((x) < 0) ? 0 : ((x) < im->xsize) ? (x) : im->xsize-1 ) -: 467:#define YCLIP(im, y) ( ((y) < 0) ? 0 : ((y) < im->ysize) ? (y) : im->ysize-1 ) -: 468: -: 469:#define BILINEAR(v, a, b, d)\ -: 470: (v = (a) + ( (b) - (a) ) * (d)) -: 471: -: 472:#define BILINEAR_HEAD(type)\ -: 473: int x, y;\ -: 474: int x0, x1;\ -: 475: double v1, v2;\ -: 476: double dx, dy;\ -: 477: type* in;\ -: 478: if (xin < 0.0 || xin >= im->xsize || yin < 0.0 || yin >= im->ysize) {\ -: 479: return 0;\ -: 480: }\ -: 481: xin -= 0.5;\ -: 482: yin -= 0.5;\ -: 483: x = FLOOR(xin);\ -: 484: y = FLOOR(yin);\ -: 485: dx = xin - x;\ -: 486: dy = yin - y; -: 487: -: 488:#define BILINEAR_BODY(type, image, step, offset) {\ -: 489: in = (type*) ((image)[YCLIP(im, y)] + offset);\ -: 490: x0 = XCLIP(im, x+0)*step;\ -: 491: x1 = XCLIP(im, x+1)*step;\ -: 492: BILINEAR(v1, in[x0], in[x1], dx);\ -: 493: if (y+1 >= 0 && y+1 < im->ysize) {\ -: 494: in = (type*) ((image)[y+1] + offset);\ -: 495: BILINEAR(v2, in[x0], in[x1], dx);\ -: 496: } else {\ -: 497: v2 = v1;\ -: 498: }\ -: 499: BILINEAR(v1, v1, v2, dy);\ -: 500:} -: 501: -: 502:static int function bilinear_filter8 called 16384 returned 100% blocks executed 88% 16384: 503:bilinear_filter8(void* out, Imaging im, double xin, double yin) -: 504:{ 16384: 505: BILINEAR_HEAD(UINT8); 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 100% (fallthrough) branch 7 taken 0% branch 8 taken 0% (fallthrough) branch 9 taken 100% branch 10 taken 3% (fallthrough) branch 11 taken 97% 16384: 506: BILINEAR_BODY(UINT8, im->image8, 1, 0); branch 0 taken 97% (fallthrough) branch 1 taken 3% 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% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 3% (fallthrough) branch 11 taken 97% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 100% (fallthrough) branch 15 taken 0% 16384: 507: ((UINT8*)out)[0] = (UINT8) v1; 16384: 508: return 1; -: 509:} -: 510: -: 511:static int function bilinear_filter32I called 0 returned 0% blocks executed 0% #####: 512:bilinear_filter32I(void* out, Imaging im, double xin, double yin) -: 513:{ -: 514: INT32 k; #####: 515: BILINEAR_HEAD(INT32); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed #####: 516: BILINEAR_BODY(INT32, im->image32, 1, 0); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed #####: 517: k = v1; #####: 518: memcpy(out, &k, sizeof(k)); #####: 519: return 1; -: 520:} -: 521: -: 522:static int function bilinear_filter32F called 0 returned 0% blocks executed 0% #####: 523:bilinear_filter32F(void* out, Imaging im, double xin, double yin) -: 524:{ -: 525: FLOAT32 k; #####: 526: BILINEAR_HEAD(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 branch 6 never executed branch 7 never executed branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed #####: 527: BILINEAR_BODY(FLOAT32, im->image32, 1, 0); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed #####: 528: k = v1; #####: 529: memcpy(out, &k, sizeof(k)); #####: 530: return 1; -: 531:} -: 532: -: 533:static int function bilinear_filter32LA called 16384 returned 100% blocks executed 81% 16384: 534:bilinear_filter32LA(void* out, Imaging im, double xin, double yin) -: 535:{ 16384: 536: BILINEAR_HEAD(UINT8); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 50% (fallthrough) branch 7 taken 50% branch 8 taken 0% (fallthrough) branch 9 taken 100% branch 10 taken 0% (fallthrough) branch 11 taken 100% 4096: 537: BILINEAR_BODY(UINT8, im->image, 4, 0); 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% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 100% (fallthrough) branch 11 taken 0% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 100% (fallthrough) branch 15 taken 0% 4096: 538: ((UINT8*)out)[0] = (UINT8) v1; 4096: 539: ((UINT8*)out)[1] = (UINT8) v1; 4096: 540: ((UINT8*)out)[2] = (UINT8) v1; 4096: 541: BILINEAR_BODY(UINT8, im->image, 4, 3); 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% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 100% (fallthrough) branch 11 taken 0% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 100% (fallthrough) branch 15 taken 0% 4096: 542: ((UINT8*)out)[3] = (UINT8) v1; 4096: 543: return 1; -: 544:} -: 545: -: 546:static int function bilinear_filter32RGB called 827178 returned 100% blocks executed 93% 827178: 547:bilinear_filter32RGB(void* out, Imaging im, double xin, double yin) -: 548:{ -: 549: int b; 827178: 550: BILINEAR_HEAD(UINT8); branch 0 taken 98% (fallthrough) branch 1 taken 2% branch 2 taken 97% (fallthrough) branch 3 taken 3% branch 4 taken 98% (fallthrough) branch 5 taken 2% branch 6 taken 98% (fallthrough) branch 7 taken 2% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) branch 11 taken 99% 3073400: 551: for (b = 0; b < im->bands; b++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 2312318: 552: BILINEAR_BODY(UINT8, im->image, 4, b); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 99% (fallthrough) branch 5 taken 1% branch 6 taken 0% (fallthrough) branch 7 taken 100% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 99% (fallthrough) branch 11 taken 1% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 99% (fallthrough) branch 15 taken 1% 2312318: 553: ((UINT8*)out)[b] = (UINT8) v1; -: 554: } -: 555: return 1; -: 556:} -: 557: -: 558:#undef BILINEAR -: 559:#undef BILINEAR_HEAD -: 560:#undef BILINEAR_BODY -: 561: -: 562:#define BICUBIC(v, v1, v2, v3, v4, d) {\ -: 563: double p1 = v2;\ -: 564: double p2 = -v1 + v3;\ -: 565: double p3 = 2*(v1 - v2) + v3 - v4;\ -: 566: double p4 = -v1 + v2 - v3 + v4;\ -: 567: v = p1 + (d)*(p2 + (d)*(p3 + (d)*p4));\ -: 568:} -: 569: -: 570:#define BICUBIC_HEAD(type)\ -: 571: int x = FLOOR(xin);\ -: 572: int y = FLOOR(yin);\ -: 573: int x0, x1, x2, x3;\ -: 574: double v1, v2, v3, v4;\ -: 575: double dx, dy;\ -: 576: type* in;\ -: 577: if (xin < 0.0 || xin >= im->xsize || yin < 0.0 || yin >= im->ysize) {\ -: 578: return 0;\ -: 579: }\ -: 580: xin -= 0.5;\ -: 581: yin -= 0.5;\ -: 582: x = FLOOR(xin);\ -: 583: y = FLOOR(yin);\ -: 584: dx = xin - x;\ -: 585: dy = yin - y;\ -: 586: x--; y--; -: 587: -: 588:#define BICUBIC_BODY(type, image, step, offset) {\ -: 589: in = (type*) ((image)[YCLIP(im, y)] + offset);\ -: 590: x0 = XCLIP(im, x+0)*step;\ -: 591: x1 = XCLIP(im, x+1)*step;\ -: 592: x2 = XCLIP(im, x+2)*step;\ -: 593: x3 = XCLIP(im, x+3)*step;\ -: 594: BICUBIC(v1, in[x0], in[x1], in[x2], in[x3], dx);\ -: 595: if (y+1 >= 0 && y+1 < im->ysize) {\ -: 596: in = (type*) ((image)[y+1] + offset);\ -: 597: BICUBIC(v2, in[x0], in[x1], in[x2], in[x3], dx);\ -: 598: } else {\ -: 599: v2 = v1;\ -: 600: }\ -: 601: if (y+2 >= 0 && y+2 < im->ysize) {\ -: 602: in = (type*) ((image)[y+2] + offset);\ -: 603: BICUBIC(v3, in[x0], in[x1], in[x2], in[x3], dx);\ -: 604: } else {\ -: 605: v3 = v2;\ -: 606: }\ -: 607: if (y+3 >= 0 && y+3 < im->ysize) {\ -: 608: in = (type*) ((image)[y+3] + offset);\ -: 609: BICUBIC(v4, in[x0], in[x1], in[x2], in[x3], dx);\ -: 610: } else {\ -: 611: v4 = v3;\ -: 612: }\ -: 613: BICUBIC(v1, v1, v2, v3, v4, dy);\ -: 614:} -: 615: -: 616: -: 617:static int function bicubic_filter8 called 0 returned 0% blocks executed 0% #####: 618:bicubic_filter8(void* out, Imaging im, double xin, double yin) -: 619:{ #####: 620: BICUBIC_HEAD(UINT8); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed #####: 621: BICUBIC_BODY(UINT8, im->image8, 1, 0); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed branch 20 never executed branch 21 never executed branch 22 never executed branch 23 never executed branch 24 never executed branch 25 never executed branch 26 never executed branch 27 never executed branch 28 never executed branch 29 never executed branch 30 never executed branch 31 never executed #####: 622: if (v1 <= 0.0) { branch 0 never executed branch 1 never executed #####: 623: ((UINT8*)out)[0] = 0; #####: 624: } else if (v1 >= 255.0) { branch 0 never executed branch 1 never executed #####: 625: ((UINT8*)out)[0] = 255; -: 626: } else { #####: 627: ((UINT8*)out)[0] = (UINT8) v1; -: 628: } -: 629: return 1; -: 630:} -: 631: -: 632:static int function bicubic_filter32I called 0 returned 0% blocks executed 0% #####: 633:bicubic_filter32I(void* out, Imaging im, double xin, double yin) -: 634:{ -: 635: INT32 k; #####: 636: BICUBIC_HEAD(INT32); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed #####: 637: BICUBIC_BODY(INT32, im->image32, 1, 0); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed branch 20 never executed branch 21 never executed branch 22 never executed branch 23 never executed branch 24 never executed branch 25 never executed branch 26 never executed branch 27 never executed branch 28 never executed branch 29 never executed branch 30 never executed branch 31 never executed #####: 638: k = v1; #####: 639: memcpy(out, &k, sizeof(k)); #####: 640: return 1; -: 641:} -: 642: -: 643:static int function bicubic_filter32F called 0 returned 0% blocks executed 0% #####: 644:bicubic_filter32F(void* out, Imaging im, double xin, double yin) -: 645:{ -: 646: FLOAT32 k; #####: 647: BICUBIC_HEAD(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 branch 6 never executed branch 7 never executed branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed #####: 648: BICUBIC_BODY(FLOAT32, im->image32, 1, 0); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed branch 20 never executed branch 21 never executed branch 22 never executed branch 23 never executed branch 24 never executed branch 25 never executed branch 26 never executed branch 27 never executed branch 28 never executed branch 29 never executed branch 30 never executed branch 31 never executed #####: 649: k = v1; #####: 650: memcpy(out, &k, sizeof(k)); #####: 651: return 1; -: 652:} -: 653: -: 654:static int function bicubic_filter32LA called 0 returned 0% blocks executed 0% #####: 655:bicubic_filter32LA(void* out, Imaging im, double xin, double yin) -: 656:{ #####: 657: BICUBIC_HEAD(UINT8); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed #####: 658: BICUBIC_BODY(UINT8, im->image, 4, 0); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed branch 20 never executed branch 21 never executed branch 22 never executed branch 23 never executed branch 24 never executed branch 25 never executed branch 26 never executed branch 27 never executed branch 28 never executed branch 29 never executed branch 30 never executed branch 31 never executed #####: 659: if (v1 <= 0.0) { branch 0 never executed branch 1 never executed #####: 660: ((UINT8*)out)[0] = 0; #####: 661: ((UINT8*)out)[1] = 0; #####: 662: ((UINT8*)out)[2] = 0; #####: 663: } else if (v1 >= 255.0) { branch 0 never executed branch 1 never executed #####: 664: ((UINT8*)out)[0] = 255; #####: 665: ((UINT8*)out)[1] = 255; #####: 666: ((UINT8*)out)[2] = 255; -: 667: } else { #####: 668: ((UINT8*)out)[0] = (UINT8) v1; #####: 669: ((UINT8*)out)[1] = (UINT8) v1; #####: 670: ((UINT8*)out)[2] = (UINT8) v1; -: 671: } #####: 672: BICUBIC_BODY(UINT8, im->image, 4, 3); 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed branch 20 never executed branch 21 never executed branch 22 never executed branch 23 never executed branch 24 never executed branch 25 never executed branch 26 never executed branch 27 never executed branch 28 never executed branch 29 never executed branch 30 never executed branch 31 never executed #####: 673: if (v1 <= 0.0) { branch 0 never executed branch 1 never executed #####: 674: ((UINT8*)out)[3] = 0; #####: 675: } else if (v1 >= 255.0) { branch 0 never executed branch 1 never executed #####: 676: ((UINT8*)out)[3] = 255; -: 677: } else { #####: 678: ((UINT8*)out)[3] = (UINT8) v1; -: 679: } -: 680: return 1; -: 681:} -: 682: -: 683:static int function bicubic_filter32RGB called 753050 returned 100% blocks executed 94% 753050: 684:bicubic_filter32RGB(void* out, Imaging im, double xin, double yin) -: 685:{ -: 686: int b; 753050: 687: BICUBIC_HEAD(UINT8); branch 0 taken 96% (fallthrough) branch 1 taken 4% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 98% (fallthrough) branch 5 taken 2% branch 6 taken 99% (fallthrough) branch 7 taken 1% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) branch 11 taken 99% 2766012: 688: for (b = 0; b < im->bands; b++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 2074509: 689: BICUBIC_BODY(UINT8, im->image, 4, b); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 99% (fallthrough) branch 5 taken 1% branch 6 taken 0% (fallthrough) branch 7 taken 100% branch 8 taken 99% (fallthrough) branch 9 taken 1% branch 10 taken 100% (fallthrough) branch 11 taken 0% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 99% (fallthrough) branch 15 taken 1% branch 16 taken 100% (fallthrough) branch 17 taken 0% branch 18 taken 99% (fallthrough) branch 19 taken 1% branch 20 taken 99% (fallthrough) branch 21 taken 1% branch 22 taken 100% (fallthrough) branch 23 taken 0% branch 24 taken 100% (fallthrough) branch 25 taken 0% branch 26 taken 99% (fallthrough) branch 27 taken 1% branch 28 taken 100% (fallthrough) branch 29 taken 0% branch 30 taken 98% (fallthrough) branch 31 taken 2% 2074509: 690: if (v1 <= 0.0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 9946: 691: ((UINT8*)out)[b] = 0; 2064563: 692: } else if (v1 >= 255.0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 15110: 693: ((UINT8*)out)[b] = 255; -: 694: } else { 2049453: 695: ((UINT8*)out)[b] = (UINT8) v1; -: 696: } -: 697: } -: 698: return 1; -: 699:} -: 700: -: 701:#undef BICUBIC -: 702:#undef BICUBIC_HEAD -: 703:#undef BICUBIC_BODY -: 704: -: 705:static ImagingTransformFilter function getfilter called 126 returned 100% blocks executed 80% 126: 706:getfilter(Imaging im, int filterid) -: 707:{ 126: 708: switch (filterid) { branch 0 taken 21% branch 1 taken 44% branch 2 taken 35% branch 3 taken 0% -: 709: case IMAGING_TRANSFORM_NEAREST: 26: 710: if (im->image8) { branch 0 taken 23% (fallthrough) branch 1 taken 77% 6: 711: switch (im->type) { branch 0 taken 67% branch 1 taken 0% branch 2 taken 33% -: 712: case IMAGING_TYPE_UINT8: -: 713: return nearest_filter8; -: 714: case IMAGING_TYPE_SPECIAL: 4: 715: switch (im->pixelsize) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% -: 716: case 1: -: 717: return nearest_filter8; -: 718: case 2: 4: 719: return nearest_filter16; -: 720: case 4: #####: 721: return nearest_filter32; -: 722: } -: 723: } -: 724: } else { -: 725: return nearest_filter32; -: 726: } -: 727: break; -: 728: case IMAGING_TRANSFORM_BILINEAR: 56: 729: if (im->image8) { branch 0 taken 98% (fallthrough) branch 1 taken 2% -: 730: return bilinear_filter8; 55: 731: } else if (im->image32) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 55: 732: switch (im->type) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% -: 733: case IMAGING_TYPE_UINT8: 55: 734: if (im->bands == 2) { branch 0 taken 98% (fallthrough) branch 1 taken 2% -: 735: return bilinear_filter32LA; -: 736: } else { 54: 737: return bilinear_filter32RGB; -: 738: } -: 739: case IMAGING_TYPE_INT32: -: 740: return bilinear_filter32I; -: 741: case IMAGING_TYPE_FLOAT32: #####: 742: return bilinear_filter32F; -: 743: } -: 744: } -: 745: break; -: 746: case IMAGING_TRANSFORM_BICUBIC: 44: 747: if (im->image8) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 748: return bicubic_filter8; 44: 749: } else if (im->image32) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 44: 750: switch (im->type) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% -: 751: case IMAGING_TYPE_UINT8: 44: 752: if (im->bands == 2) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 753: return bicubic_filter32LA; -: 754: } else { 44: 755: return bicubic_filter32RGB; -: 756: } -: 757: case IMAGING_TYPE_INT32: -: 758: return bicubic_filter32I; -: 759: case IMAGING_TYPE_FLOAT32: #####: 760: return bicubic_filter32F; -: 761: } -: 762: } -: 763: break; -: 764: } -: 765: /* no such filter */ #####: 766: return NULL; -: 767:} -: 768: -: 769:/* transformation engines */ -: 770: -: 771:Imaging function ImagingGenericTransform called 126 returned 100% blocks executed 81% 126: 772:ImagingGenericTransform( -: 773: Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1, -: 774: ImagingTransformMap transform, void* transform_data, -: 775: int filterid, int fill) -: 776:{ -: 777: /* slow generic transformation. use ImagingTransformAffine or -: 778: ImagingScaleAffine where possible. */ -: 779: -: 780: ImagingSectionCookie cookie; -: 781: int x, y; -: 782: char *out; -: 783: double xx, yy; -: 784: 126: 785: ImagingTransformFilter filter = getfilter(imIn, filterid); call 0 returned 100% 126: 786: if (!filter) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 787: return (Imaging) ImagingError_ValueError("bad filter number"); call 0 never executed -: 788: } -: 789: 126: 790: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 791: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 792: } -: 793: 126: 794: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 795: 126: 796: ImagingSectionEnter(&cookie); call 0 returned 100% -: 797: 126: 798: if (x0 < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 799: x0 = 0; -: 800: } 126: 801: if (y0 < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 802: y0 = 0; -: 803: } 126: 804: if (x1 > imOut->xsize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 805: x1 = imOut->xsize; -: 806: } 126: 807: if (y1 > imOut->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 808: y1 = imOut->ysize; -: 809: } -: 810: 13687: 811: for (y = y0; y < y1; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 13561: 812: out = imOut->image[y] + x0*imOut->pixelsize; 1975200: 813: for (x = x0; x < x1; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3923278: 814: if ( ! transform(&xx, &yy, x-x0, y-y0, transform_data) || call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 8% (fallthrough) branch 4 taken 92% 1961639: 815: ! filter(out, imIn, xx, yy)) { call 0 returned 100% 152319: 816: if (fill) { branch 0 taken 76% (fallthrough) branch 1 taken 24% 115455: 817: memset(out, 0, imOut->pixelsize); -: 818: } -: 819: } 1961639: 820: out += imOut->pixelsize; -: 821: } -: 822: } -: 823: 126: 824: ImagingSectionLeave(&cookie); call 0 returned 100% -: 825: 126: 826: return imOut; -: 827:} -: 828: -: 829:static Imaging function ImagingScaleAffine called 136 returned 100% blocks executed 88% 136: 830:ImagingScaleAffine(Imaging imOut, Imaging imIn, -: 831: int x0, int y0, int x1, int y1, -: 832: double a[6], int fill) -: 833:{ -: 834: /* scale, nearest neighbour resampling */ -: 835: -: 836: ImagingSectionCookie cookie; -: 837: int x, y; -: 838: int xin; -: 839: double xo, yo; -: 840: int xmin, xmax; -: 841: int *xintab; -: 842: 136: 843: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 844: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 845: } -: 846: 136: 847: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 848: 136: 849: if (x0 < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 850: x0 = 0; -: 851: } 136: 852: if (y0 < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 853: y0 = 0; -: 854: } 136: 855: if (x1 > imOut->xsize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 856: x1 = imOut->xsize; -: 857: } 136: 858: if (y1 > imOut->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 859: y1 = imOut->ysize; -: 860: } -: 861: -: 862: /* malloc check ok, uses calloc for overflow */ 136: 863: xintab = (int*) calloc(imOut->xsize, sizeof(int)); 136: 864: if (!xintab) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 865: ImagingDelete(imOut); call 0 never executed #####: 866: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 867: } -: 868: 136: 869: xo = a[2] + a[0] * 0.5; 136: 870: yo = a[5] + a[4] * 0.5; -: 871: 136: 872: xmin = x1; 136: 873: xmax = x0; -: 874: -: 875: /* Pretabulate horizontal pixel positions */ 25725: 876: for (x = x0; x < x1; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 25589: 877: xin = COORD(xo); branch 0 taken 99% (fallthrough) branch 1 taken 1% 25589: 878: if (xin >= 0 && xin < (int) imIn->xsize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 97% (fallthrough) branch 3 taken 3% 24558: 879: xmax = x+1; 24558: 880: if (x < xmin) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 132: 881: xmin = x; -: 882: } 24558: 883: xintab[x] = xin; -: 884: } 25589: 885: xo += a[0]; -: 886: } -: 887: -: 888:#define AFFINE_SCALE(pixel, image)\ -: 889: for (y = y0; y < y1; y++) {\ -: 890: int yi = COORD(yo);\ -: 891: pixel *in, *out;\ -: 892: out = imOut->image[y];\ -: 893: if (fill && x1 > x0) {\ -: 894: memset(out+x0, 0, (x1-x0)*sizeof(pixel));\ -: 895: }\ -: 896: if (yi >= 0 && yi < imIn->ysize) {\ -: 897: in = imIn->image[yi];\ -: 898: for (x = xmin; x < xmax; x++) {\ -: 899: out[x] = in[xintab[x]];\ -: 900: }\ -: 901: }\ -: 902: yo += a[4];\ -: 903: } -: 904: 136: 905: ImagingSectionEnter(&cookie); call 0 returned 100% -: 906: 136: 907: if (imIn->image8) { branch 0 taken 66% (fallthrough) branch 1 taken 34% 39522: 908: AFFINE_SCALE(UINT8, image8); 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 100% (fallthrough) branch 7 taken 0% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 99% branch 11 taken 1% (fallthrough) branch 12 taken 99% branch 13 taken 1% -: 909: } else { 10986: 910: AFFINE_SCALE(INT32, image32); branch 0 taken 94% (fallthrough) branch 1 taken 6% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 94% (fallthrough) branch 7 taken 6% branch 8 taken 86% (fallthrough) branch 9 taken 14% branch 10 taken 99% branch 11 taken 1% (fallthrough) branch 12 taken 98% branch 13 taken 2% (fallthrough) -: 911: } -: 912: 136: 913: ImagingSectionLeave(&cookie); call 0 returned 100% -: 914: -: 915:#undef AFFINE_SCALE -: 916: 136: 917: free(xintab); -: 918: 136: 919: return imOut; -: 920:} -: 921: -: 922:static inline int -: 923:check_fixed(double a[6], int x, int y) -: 924:{ 976: 925: return (fabs(x*a[0] + y*a[1] + a[2]) < 32768.0 && branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 0% (fallthrough) branch 7 taken 100% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 0% (fallthrough) branch 11 taken 100% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 0% (fallthrough) branch 15 taken 100% 488: 926: fabs(x*a[3] + y*a[4] + a[5]) < 32768.0); -: 927:} -: 928: -: 929:static inline Imaging function affine_fixed.isra.0 called 122 returned 100% blocks executed 96% 122: 930:affine_fixed(Imaging imOut, Imaging imIn, -: 931: int x0, int y0, int x1, int y1, -: 932: double a[6], int filterid, int fill) -: 933:{ -: 934: /* affine transform, nearest neighbour resampling, fixed point -: 935: arithmetics */ -: 936: -: 937: ImagingSectionCookie cookie; -: 938: int x, y; -: 939: int xin, yin; -: 940: int xsize, ysize; -: 941: int xx, yy; -: 942: int a0, a1, a2, a3, a4, a5; -: 943: 122: 944: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 945: 122: 946: xsize = (int) imIn->xsize; 122: 947: ysize = (int) imIn->ysize; -: 948: -: 949:/* use 16.16 fixed point arithmetics */ -: 950:#define FIX(v) FLOOR((v)*65536.0 + 0.5) -: 951: 122: 952: a0 = FIX(a[0]); a1 = FIX(a[1]); branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 95% (fallthrough) branch 3 taken 5% 122: 953: a3 = FIX(a[3]); a4 = FIX(a[4]); branch 0 taken 4% (fallthrough) branch 1 taken 96% branch 2 taken 0% (fallthrough) branch 3 taken 100% 122: 954: a2 = FIX(a[2] + a[0] * 0.5 + a[1] * 0.5); branch 0 taken 4% (fallthrough) branch 1 taken 96% 122: 955: a5 = FIX(a[5] + a[3] * 0.5 + a[4] * 0.5); branch 0 taken 22% (fallthrough) branch 1 taken 78% -: 956: -: 957:#undef FIX -: 958: -: 959:#define AFFINE_TRANSFORM_FIXED(pixel, image)\ -: 960: for (y = y0; y < y1; y++) {\ -: 961: pixel *out;\ -: 962: xx = a2;\ -: 963: yy = a5;\ -: 964: out = imOut->image[y];\ -: 965: if (fill && x1 > x0) {\ -: 966: memset(out+x0, 0, (x1-x0)*sizeof(pixel));\ -: 967: }\ -: 968: for (x = x0; x < x1; x++, out++) {\ -: 969: xin = xx >> 16;\ -: 970: if (xin >= 0 && xin < xsize) {\ -: 971: yin = yy >> 16;\ -: 972: if (yin >= 0 && yin < ysize) {\ -: 973: *out = imIn->image[yin][xin];\ -: 974: }\ -: 975: }\ -: 976: xx += a0;\ -: 977: yy += a3;\ -: 978: }\ -: 979: a2 += a1;\ -: 980: a5 += a4;\ -: 981: } -: 982: 122: 983: ImagingSectionEnter(&cookie); call 0 returned 100% -: 984: 122: 985: if (imIn->image8) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 5288026: 986: AFFINE_TRANSFORM_FIXED(UINT8, image8) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 99% (fallthrough) branch 5 taken 1% branch 6 taken 99% (fallthrough) branch 7 taken 1% branch 8 taken 99% (fallthrough) branch 9 taken 1% branch 10 taken 99% (fallthrough) branch 11 taken 1% branch 12 taken 99% branch 13 taken 1% (fallthrough) branch 14 taken 99% branch 15 taken 1% -: 987: } else { 1070102: 988: AFFINE_TRANSFORM_FIXED(INT32, image32) branch 0 taken 97% (fallthrough) branch 1 taken 3% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 87% (fallthrough) branch 5 taken 13% branch 6 taken 96% (fallthrough) branch 7 taken 4% branch 8 taken 86% (fallthrough) branch 9 taken 14% branch 10 taken 87% (fallthrough) branch 11 taken 13% branch 12 taken 99% branch 13 taken 1% (fallthrough) branch 14 taken 99% branch 15 taken 1% (fallthrough) -: 989: } -: 990: 122: 991: ImagingSectionLeave(&cookie); call 0 returned 100% -: 992: -: 993:#undef AFFINE_TRANSFORM_FIXED -: 994: 122: 995: return imOut; -: 996:} -: 997: -: 998:Imaging function ImagingTransformAffine called 315 returned 100% blocks executed 35% 315: 999:ImagingTransformAffine(Imaging imOut, Imaging imIn, -: 1000: int x0, int y0, int x1, int y1, -: 1001: double a[6], int filterid, int fill) -: 1002:{ -: 1003: /* affine transform, nearest neighbour resampling, floating point -: 1004: arithmetics*/ -: 1005: -: 1006: ImagingSectionCookie cookie; -: 1007: int x, y; -: 1008: int xin, yin; -: 1009: int xsize, ysize; -: 1010: double xx, yy; -: 1011: double xo, yo; -: 1012: 315: 1013: if (filterid || imIn->type == IMAGING_TYPE_SPECIAL) { branch 0 taken 83% (fallthrough) branch 1 taken 17% branch 2 taken 2% (fallthrough) branch 3 taken 98% 57: 1014: return ImagingGenericTransform( call 0 returned 100% -: 1015: imOut, imIn, -: 1016: x0, y0, x1, y1, -: 1017: affine_transform, a, -: 1018: filterid, fill); -: 1019: } -: 1020: 258: 1021: if (a[1] == 0 && a[3] == 0) { branch 0 taken 53% (fallthrough) branch 1 taken 47% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 1022: /* Scaling */ 136: 1023: return ImagingScaleAffine(imOut, imIn, x0, y0, x1, y1, a, fill); call 0 returned 100% -: 1024: } -: 1025: 122: 1026: if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 1027: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 1028: } -: 1029: 122: 1030: if (x0 < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1031: x0 = 0; -: 1032: } 122: 1033: if (y0 < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1034: y0 = 0; -: 1035: } 122: 1036: if (x1 > imOut->xsize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1037: x1 = imOut->xsize; -: 1038: } 122: 1039: if (y1 > imOut->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1040: y1 = imOut->ysize; -: 1041: } -: 1042: -: 1043: /* translate all four corners to check if they are within the -: 1044: range that can be represented by the fixed point arithmetics */ -: 1045: 366: 1046: if (check_fixed(a, 0, 0) && check_fixed(a, x1-x0, y1-y0) && 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% 488: 1047: check_fixed(a, 0, y1-y0) && check_fixed(a, x1-x0, 0)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 122: 1048: return affine_fixed(imOut, imIn, x0, y0, x1, y1, a, filterid, fill); call 0 returned 100% -: 1049: } -: 1050: -: 1051: /* FIXME: cannot really think of any reasonable case when the -: 1052: following code is used. maybe we should fall back on the slow -: 1053: generic transform engine in this case? */ -: 1054: #####: 1055: ImagingCopyPalette(imOut, imIn); call 0 never executed -: 1056: #####: 1057: xsize = (int) imIn->xsize; #####: 1058: ysize = (int) imIn->ysize; -: 1059: #####: 1060: xo = a[2] + a[1] * 0.5 + a[0] * 0.5; #####: 1061: yo = a[5] + a[4] * 0.5 + a[3] * 0.5; -: 1062: -: 1063:#define AFFINE_TRANSFORM(pixel, image)\ -: 1064: for (y = y0; y < y1; y++) {\ -: 1065: pixel *out;\ -: 1066: xx = xo;\ -: 1067: yy = yo;\ -: 1068: out = imOut->image[y];\ -: 1069: if (fill && x1 > x0) {\ -: 1070: memset(out+x0, 0, (x1-x0)*sizeof(pixel));\ -: 1071: }\ -: 1072: for (x = x0; x < x1; x++, out++) {\ -: 1073: xin = COORD(xx);\ -: 1074: if (xin >= 0 && xin < xsize) {\ -: 1075: yin = COORD(yy);\ -: 1076: if (yin >= 0 && yin < ysize) {\ -: 1077: *out = imIn->image[yin][xin];\ -: 1078: }\ -: 1079: }\ -: 1080: xx += a[0];\ -: 1081: yy += a[3];\ -: 1082: }\ -: 1083: xo += a[1];\ -: 1084: yo += a[4];\ -: 1085: } -: 1086: #####: 1087: ImagingSectionEnter(&cookie); call 0 never executed -: 1088: #####: 1089: if (imIn->image8) { branch 0 never executed branch 1 never executed #####: 1090: AFFINE_TRANSFORM(UINT8, image8) 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed -: 1091: } else { #####: 1092: AFFINE_TRANSFORM(INT32, image32) 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 branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed -: 1093: } -: 1094: #####: 1095: ImagingSectionLeave(&cookie); call 0 never executed -: 1096: -: 1097:#undef AFFINE_TRANSFORM -: 1098: #####: 1099: return imOut; -: 1100:} -: 1101: -: 1102:Imaging function ImagingTransform called 384 returned 100% blocks executed 83% 384: 1103:ImagingTransform(Imaging imOut, Imaging imIn, int method, -: 1104: int x0, int y0, int x1, int y1, -: 1105: double a[8], int filterid, int fill) -: 1106:{ -: 1107: ImagingTransformMap transform; -: 1108: 384: 1109: switch(method) { branch 0 taken 82% branch 1 taken 2% branch 2 taken 0% branch 3 taken 16% -: 1110: case IMAGING_TRANSFORM_AFFINE: 315: 1111: return ImagingTransformAffine( call 0 returned 100% -: 1112: imOut, imIn, x0, y0, x1, y1, a, filterid, fill); -: 1113: break; -: 1114: case IMAGING_TRANSFORM_PERSPECTIVE: -: 1115: transform = perspective_transform; -: 1116: break; -: 1117: case IMAGING_TRANSFORM_QUAD: 9: 1118: transform = quad_transform; 9: 1119: break; -: 1120: default: #####: 1121: return (Imaging) ImagingError_ValueError("bad transform method"); call 0 never executed -: 1122: } -: 1123: 69: 1124: return ImagingGenericTransform( call 0 returned 100% -: 1125: imOut, imIn, -: 1126: x0, y0, x1, y1, -: 1127: transform, a, filterid, fill); -: 1128:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#AlphaComposite.c.gcov -: 0:Source:src/libImaging/AlphaComposite.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/AlphaComposite.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/AlphaComposite.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * Alpha composite imSrc over imDst. -: 6: * https://en.wikipedia.org/wiki/Alpha_compositing -: 7: * -: 8: * See the README file for details on usage and redistribution. -: 9: */ -: 10: -: 11: -: 12:#include "Imaging.h" -: 13: -: 14:#define PRECISION_BITS 7 -: 15: -: 16:typedef struct -: 17:{ -: 18: UINT8 r; -: 19: UINT8 g; -: 20: UINT8 b; -: 21: UINT8 a; -: 22:} rgba8; -: 23: -: 24: -: 25: -: 26:Imaging function ImagingAlphaComposite called 6 returned 100% blocks executed 91% 6: 27:ImagingAlphaComposite(Imaging imDst, Imaging imSrc) -: 28:{ -: 29: Imaging imOut; -: 30: int x, y; -: 31: -: 32: /* Check arguments */ 12: 33: if (!imDst || !imSrc || 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% 12: 34: strcmp(imDst->mode, "RGBA") || branch 0 taken 100% (fallthrough) branch 1 taken 0% 12: 35: imDst->type != IMAGING_TYPE_UINT8 || branch 0 taken 0% (fallthrough) branch 1 taken 100% 6: 36: imDst->bands != 4) { #####: 37: return ImagingError_ModeError(); call 0 never executed -: 38: } -: 39: 12: 40: if (strcmp(imDst->mode, imSrc->mode) || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 6: 41: imDst->type != imSrc->type || 6: 42: imDst->bands != imSrc->bands || branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 43: imDst->xsize != imSrc->xsize || branch 0 taken 0% (fallthrough) branch 1 taken 100% 6: 44: imDst->ysize != imSrc->ysize) { #####: 45: return ImagingError_Mismatch(); call 0 never executed -: 46: } -: 47: 6: 48: imOut = ImagingNewDirty(imDst->mode, imDst->xsize, imDst->ysize); call 0 returned 100% 6: 49: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 50: return NULL; -: 51: } -: 52: 580: 53: for (y = 0; y < imDst->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 580: 54: rgba8* dst = (rgba8*) imDst->image[y]; 580: 55: rgba8* src = (rgba8*) imSrc->image[y]; 580: 56: rgba8* out = (rgba8*) imOut->image[y]; -: 57: 64852: 58: for (x = 0; x < imDst->xsize; x ++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 64272: 59: if (src->a == 0) { branch 0 taken 5% (fallthrough) branch 1 taken 95% -: 60: // Copy 4 bytes at once. 3300: 61: *out = *dst; -: 62: } else { -: 63: // Integer implementation with increased precision. -: 64: // Each variable has extra meaningful bits. -: 65: // Divisions are rounded. -: 66: -: 67: UINT32 tmpr, tmpg, tmpb; 60972: 68: UINT32 blend = dst->a * (255 - src->a); 60972: 69: UINT32 outa255 = src->a * 255 + blend; -: 70: // There we use 7 bits for precision. -: 71: // We could use more, but we go beyond 32 bits. 60972: 72: UINT32 coef1 = src->a * 255 * 255 * (1<r * coef1 + dst->r * coef2; 60972: 76: tmpg = src->g * coef1 + dst->g * coef2; 60972: 77: tmpb = src->b * coef1 + dst->b * coef2; 60972: 78: out->r = SHIFTFORDIV255(tmpr + (0x80<> PRECISION_BITS; 60972: 79: out->g = SHIFTFORDIV255(tmpg + (0x80<> PRECISION_BITS; 60972: 80: out->b = SHIFTFORDIV255(tmpb + (0x80<> PRECISION_BITS; 60972: 81: out->a = SHIFTFORDIV255(outa255 + 0x80); -: 82: } -: 83: 64272: 84: dst++; src++; out++; -: 85: } -: 86: -: 87: } -: 88: -: 89: return imOut; -: 90:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#webp#demux.h.gcov -: 0:Source:/usr/include/webp/demux.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:// Copyright 2012 Google Inc. All Rights Reserved. -: 2:// -: 3:// Use of this source code is governed by a BSD-style license -: 4:// that can be found in the COPYING file in the root of the source -: 5:// tree. An additional intellectual property rights grant can be found -: 6:// in the file PATENTS. All contributing project authors may -: 7:// be found in the AUTHORS file in the root of the source tree. -: 8:// ----------------------------------------------------------------------------- -: 9:// -: 10:// Demux API. -: 11:// Enables extraction of image and extended format data from WebP files. -: 12: -: 13:// Code Example: Demuxing WebP data to extract all the frames, ICC profile -: 14:// and EXIF/XMP metadata. -: 15:/* -: 16: WebPDemuxer* demux = WebPDemux(&webp_data); -: 17: -: 18: uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); -: 19: uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); -: 20: // ... (Get information about the features present in the WebP file). -: 21: uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS); -: 22: -: 23: // ... (Iterate over all frames). -: 24: WebPIterator iter; -: 25: if (WebPDemuxGetFrame(demux, 1, &iter)) { -: 26: do { -: 27: // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(), -: 28: // ... and get other frame properties like width, height, offsets etc. -: 29: // ... see 'struct WebPIterator' below for more info). -: 30: } while (WebPDemuxNextFrame(&iter)); -: 31: WebPDemuxReleaseIterator(&iter); -: 32: } -: 33: -: 34: // ... (Extract metadata). -: 35: WebPChunkIterator chunk_iter; -: 36: if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter); -: 37: // ... (Consume the ICC profile in 'chunk_iter.chunk'). -: 38: WebPDemuxReleaseChunkIterator(&chunk_iter); -: 39: if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter); -: 40: // ... (Consume the EXIF metadata in 'chunk_iter.chunk'). -: 41: WebPDemuxReleaseChunkIterator(&chunk_iter); -: 42: if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter); -: 43: // ... (Consume the XMP metadata in 'chunk_iter.chunk'). -: 44: WebPDemuxReleaseChunkIterator(&chunk_iter); -: 45: WebPDemuxDelete(demux); -: 46:*/ -: 47: -: 48:#ifndef WEBP_WEBP_DEMUX_H_ -: 49:#define WEBP_WEBP_DEMUX_H_ -: 50: -: 51:#include "./decode.h" // for WEBP_CSP_MODE -: 52:#include "./mux_types.h" -: 53: -: 54:#ifdef __cplusplus -: 55:extern "C" { -: 56:#endif -: 57: -: 58:#define WEBP_DEMUX_ABI_VERSION 0x0107 // MAJOR(8b) + MINOR(8b) -: 59: -: 60:// Note: forward declaring enumerations is not allowed in (strict) C and C++, -: 61:// the types are left here for reference. -: 62:// typedef enum WebPDemuxState WebPDemuxState; -: 63:// typedef enum WebPFormatFeature WebPFormatFeature; -: 64:typedef struct WebPDemuxer WebPDemuxer; -: 65:typedef struct WebPIterator WebPIterator; -: 66:typedef struct WebPChunkIterator WebPChunkIterator; -: 67:typedef struct WebPAnimInfo WebPAnimInfo; -: 68:typedef struct WebPAnimDecoderOptions WebPAnimDecoderOptions; -: 69: -: 70://------------------------------------------------------------------------------ -: 71: -: 72:// Returns the version number of the demux library, packed in hexadecimal using -: 73:// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507. -: 74:WEBP_EXTERN int WebPGetDemuxVersion(void); -: 75: -: 76://------------------------------------------------------------------------------ -: 77:// Life of a Demux object -: 78: -: 79:typedef enum WebPDemuxState { -: 80: WEBP_DEMUX_PARSE_ERROR = -1, // An error occurred while parsing. -: 81: WEBP_DEMUX_PARSING_HEADER = 0, // Not enough data to parse full header. -: 82: WEBP_DEMUX_PARSED_HEADER = 1, // Header parsing complete, -: 83: // data may be available. -: 84: WEBP_DEMUX_DONE = 2 // Entire file has been parsed. -: 85:} WebPDemuxState; -: 86: -: 87:// Internal, version-checked, entry point -: 88:WEBP_EXTERN WebPDemuxer* WebPDemuxInternal( -: 89: const WebPData*, int, WebPDemuxState*, int); -: 90: -: 91:// Parses the full WebP file given by 'data'. For single images the WebP file -: 92:// header alone or the file header and the chunk header may be absent. -: 93:// Returns a WebPDemuxer object on successful parse, NULL otherwise. -: 94:static WEBP_INLINE WebPDemuxer* WebPDemux(const WebPData* data) { -: 95: return WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION); -: 96:} -: 97: -: 98:// Parses the possibly incomplete WebP file given by 'data'. -: 99:// If 'state' is non-NULL it will be set to indicate the status of the demuxer. -: 100:// Returns NULL in case of error or if there isn't enough data to start parsing; -: 101:// and a WebPDemuxer object on successful parse. -: 102:// Note that WebPDemuxer keeps internal pointers to 'data' memory segment. -: 103:// If this data is volatile, the demuxer object should be deleted (by calling -: 104:// WebPDemuxDelete()) and WebPDemuxPartial() called again on the new data. -: 105:// This is usually an inexpensive operation. -: 106:static WEBP_INLINE WebPDemuxer* WebPDemuxPartial( -: 107: const WebPData* data, WebPDemuxState* state) { -: 108: return WebPDemuxInternal(data, 1, state, WEBP_DEMUX_ABI_VERSION); -: 109:} -: 110: -: 111:// Frees memory associated with 'dmux'. -: 112:WEBP_EXTERN void WebPDemuxDelete(WebPDemuxer* dmux); -: 113: -: 114://------------------------------------------------------------------------------ -: 115:// Data/information extraction. -: 116: -: 117:typedef enum WebPFormatFeature { -: 118: WEBP_FF_FORMAT_FLAGS, // bit-wise combination of WebPFeatureFlags -: 119: // corresponding to the 'VP8X' chunk (if present). -: 120: WEBP_FF_CANVAS_WIDTH, -: 121: WEBP_FF_CANVAS_HEIGHT, -: 122: WEBP_FF_LOOP_COUNT, // only relevant for animated file -: 123: WEBP_FF_BACKGROUND_COLOR, // idem. -: 124: WEBP_FF_FRAME_COUNT // Number of frames present in the demux object. -: 125: // In case of a partial demux, this is the number -: 126: // of frames seen so far, with the last frame -: 127: // possibly being partial. -: 128:} WebPFormatFeature; -: 129: -: 130:// Get the 'feature' value from the 'dmux'. -: 131:// NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial() -: 132:// returned a state > WEBP_DEMUX_PARSING_HEADER. -: 133:// If 'feature' is WEBP_FF_FORMAT_FLAGS, the returned value is a bit-wise -: 134:// combination of WebPFeatureFlags values. -: 135:// If 'feature' is WEBP_FF_LOOP_COUNT, WEBP_FF_BACKGROUND_COLOR, the returned -: 136:// value is only meaningful if the bitstream is animated. -: 137:WEBP_EXTERN uint32_t WebPDemuxGetI( -: 138: const WebPDemuxer* dmux, WebPFormatFeature feature); -: 139: -: 140://------------------------------------------------------------------------------ -: 141:// Frame iteration. -: 142: -: 143:struct WebPIterator { -: 144: int frame_num; -: 145: int num_frames; // equivalent to WEBP_FF_FRAME_COUNT. -: 146: int x_offset, y_offset; // offset relative to the canvas. -: 147: int width, height; // dimensions of this frame. -: 148: int duration; // display duration in milliseconds. -: 149: WebPMuxAnimDispose dispose_method; // dispose method for the frame. -: 150: int complete; // true if 'fragment' contains a full frame. partial images -: 151: // may still be decoded with the WebP incremental decoder. -: 152: WebPData fragment; // The frame given by 'frame_num'. Note for historical -: 153: // reasons this is called a fragment. -: 154: int has_alpha; // True if the frame contains transparency. -: 155: WebPMuxAnimBlend blend_method; // Blend operation for the frame. -: 156: -: 157: uint32_t pad[2]; // padding for later use. -: 158: void* private_; // for internal use only. -: 159:}; -: 160: -: 161:// Retrieves frame 'frame_number' from 'dmux'. -: 162:// 'iter->fragment' points to the frame on return from this function. -: 163:// Setting 'frame_number' equal to 0 will return the last frame of the image. -: 164:// Returns false if 'dmux' is NULL or frame 'frame_number' is not present. -: 165:// Call WebPDemuxReleaseIterator() when use of the iterator is complete. -: 166:// NOTE: 'dmux' must persist for the lifetime of 'iter'. -: 167:WEBP_EXTERN int WebPDemuxGetFrame( -: 168: const WebPDemuxer* dmux, int frame_number, WebPIterator* iter); -: 169: -: 170:// Sets 'iter->fragment' to point to the next ('iter->frame_num' + 1) or -: 171:// previous ('iter->frame_num' - 1) frame. These functions do not loop. -: 172:// Returns true on success, false otherwise. -: 173:WEBP_EXTERN int WebPDemuxNextFrame(WebPIterator* iter); -: 174:WEBP_EXTERN int WebPDemuxPrevFrame(WebPIterator* iter); -: 175: -: 176:// Releases any memory associated with 'iter'. -: 177:// Must be called before any subsequent calls to WebPDemuxGetChunk() on the same -: 178:// iter. Also, must be called before destroying the associated WebPDemuxer with -: 179:// WebPDemuxDelete(). -: 180:WEBP_EXTERN void WebPDemuxReleaseIterator(WebPIterator* iter); -: 181: -: 182://------------------------------------------------------------------------------ -: 183:// Chunk iteration. -: 184: -: 185:struct WebPChunkIterator { -: 186: // The current and total number of chunks with the fourcc given to -: 187: // WebPDemuxGetChunk(). -: 188: int chunk_num; -: 189: int num_chunks; -: 190: WebPData chunk; // The payload of the chunk. -: 191: -: 192: uint32_t pad[6]; // padding for later use -: 193: void* private_; -: 194:}; -: 195: -: 196:// Retrieves the 'chunk_number' instance of the chunk with id 'fourcc' from -: 197:// 'dmux'. -: 198:// 'fourcc' is a character array containing the fourcc of the chunk to return, -: 199:// e.g., "ICCP", "XMP ", "EXIF", etc. -: 200:// Setting 'chunk_number' equal to 0 will return the last chunk in a set. -: 201:// Returns true if the chunk is found, false otherwise. Image related chunk -: 202:// payloads are accessed through WebPDemuxGetFrame() and related functions. -: 203:// Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete. -: 204:// NOTE: 'dmux' must persist for the lifetime of the iterator. -: 205:WEBP_EXTERN int WebPDemuxGetChunk(const WebPDemuxer* dmux, -: 206: const char fourcc[4], int chunk_number, -: 207: WebPChunkIterator* iter); -: 208: -: 209:// Sets 'iter->chunk' to point to the next ('iter->chunk_num' + 1) or previous -: 210:// ('iter->chunk_num' - 1) chunk. These functions do not loop. -: 211:// Returns true on success, false otherwise. -: 212:WEBP_EXTERN int WebPDemuxNextChunk(WebPChunkIterator* iter); -: 213:WEBP_EXTERN int WebPDemuxPrevChunk(WebPChunkIterator* iter); -: 214: -: 215:// Releases any memory associated with 'iter'. -: 216:// Must be called before destroying the associated WebPDemuxer with -: 217:// WebPDemuxDelete(). -: 218:WEBP_EXTERN void WebPDemuxReleaseChunkIterator(WebPChunkIterator* iter); -: 219: -: 220://------------------------------------------------------------------------------ -: 221:// WebPAnimDecoder API -: 222:// -: 223:// This API allows decoding (possibly) animated WebP images. -: 224:// -: 225:// Code Example: -: 226:/* -: 227: WebPAnimDecoderOptions dec_options; -: 228: WebPAnimDecoderOptionsInit(&dec_options); -: 229: // Tune 'dec_options' as needed. -: 230: WebPAnimDecoder* dec = WebPAnimDecoderNew(webp_data, &dec_options); -: 231: WebPAnimInfo anim_info; -: 232: WebPAnimDecoderGetInfo(dec, &anim_info); -: 233: for (uint32_t i = 0; i < anim_info.loop_count; ++i) { -: 234: while (WebPAnimDecoderHasMoreFrames(dec)) { -: 235: uint8_t* buf; -: 236: int timestamp; -: 237: WebPAnimDecoderGetNext(dec, &buf, ×tamp); -: 238: // ... (Render 'buf' based on 'timestamp'). -: 239: // ... (Do NOT free 'buf', as it is owned by 'dec'). -: 240: } -: 241: WebPAnimDecoderReset(dec); -: 242: } -: 243: const WebPDemuxer* demuxer = WebPAnimDecoderGetDemuxer(dec); -: 244: // ... (Do something using 'demuxer'; e.g. get EXIF/XMP/ICC data). -: 245: WebPAnimDecoderDelete(dec); -: 246:*/ -: 247: -: 248:typedef struct WebPAnimDecoder WebPAnimDecoder; // Main opaque object. -: 249: -: 250:// Global options. -: 251:struct WebPAnimDecoderOptions { -: 252: // Output colorspace. Only the following modes are supported: -: 253: // MODE_RGBA, MODE_BGRA, MODE_rgbA and MODE_bgrA. -: 254: WEBP_CSP_MODE color_mode; -: 255: int use_threads; // If true, use multi-threaded decoding. -: 256: uint32_t padding[7]; // Padding for later use. -: 257:}; -: 258: -: 259:// Internal, version-checked, entry point. -: 260:WEBP_EXTERN int WebPAnimDecoderOptionsInitInternal( -: 261: WebPAnimDecoderOptions*, int); -: 262: -: 263:// Should always be called, to initialize a fresh WebPAnimDecoderOptions -: 264:// structure before modification. Returns false in case of version mismatch. -: 265:// WebPAnimDecoderOptionsInit() must have succeeded before using the -: 266:// 'dec_options' object. -: 267:static WEBP_INLINE int WebPAnimDecoderOptionsInit( -: 268: WebPAnimDecoderOptions* dec_options) { -: 269: return WebPAnimDecoderOptionsInitInternal(dec_options, -: 270: WEBP_DEMUX_ABI_VERSION); -: 271:} -: 272: -: 273:// Internal, version-checked, entry point. -: 274:WEBP_EXTERN WebPAnimDecoder* WebPAnimDecoderNewInternal( -: 275: const WebPData*, const WebPAnimDecoderOptions*, int); -: 276: -: 277:// Creates and initializes a WebPAnimDecoder object. -: 278:// Parameters: -: 279:// webp_data - (in) WebP bitstream. This should remain unchanged during the -: 280:// lifetime of the output WebPAnimDecoder object. -: 281:// dec_options - (in) decoding options. Can be passed NULL to choose -: 282:// reasonable defaults (in particular, color mode MODE_RGBA -: 283:// will be picked). -: 284:// Returns: -: 285:// A pointer to the newly created WebPAnimDecoder object, or NULL in case of -: 286:// parsing error, invalid option or memory error. -: 287:static WEBP_INLINE WebPAnimDecoder* WebPAnimDecoderNew( -: 288: const WebPData* webp_data, const WebPAnimDecoderOptions* dec_options) { 161: 289: return WebPAnimDecoderNewInternal(webp_data, dec_options, call 0 returned 100% -: 290: WEBP_DEMUX_ABI_VERSION); -: 291:} -: 292: -: 293:// Global information about the animation.. -: 294:struct WebPAnimInfo { -: 295: uint32_t canvas_width; -: 296: uint32_t canvas_height; -: 297: uint32_t loop_count; -: 298: uint32_t bgcolor; -: 299: uint32_t frame_count; -: 300: uint32_t pad[4]; // padding for later use -: 301:}; -: 302: -: 303:// Get global information about the animation. -: 304:// Parameters: -: 305:// dec - (in) decoder instance to get information from. -: 306:// info - (out) global information fetched from the animation. -: 307:// Returns: -: 308:// True on success. -: 309:WEBP_EXTERN int WebPAnimDecoderGetInfo(const WebPAnimDecoder* dec, -: 310: WebPAnimInfo* info); -: 311: -: 312:// Fetch the next frame from 'dec' based on options supplied to -: 313:// WebPAnimDecoderNew(). This will be a fully reconstructed canvas of size -: 314:// 'canvas_width * 4 * canvas_height', and not just the frame sub-rectangle. The -: 315:// returned buffer 'buf' is valid only until the next call to -: 316:// WebPAnimDecoderGetNext(), WebPAnimDecoderReset() or WebPAnimDecoderDelete(). -: 317:// Parameters: -: 318:// dec - (in/out) decoder instance from which the next frame is to be fetched. -: 319:// buf - (out) decoded frame. -: 320:// timestamp - (out) timestamp of the frame in milliseconds. -: 321:// Returns: -: 322:// False if any of the arguments are NULL, or if there is a parsing or -: 323:// decoding error, or if there are no more frames. Otherwise, returns true. -: 324:WEBP_EXTERN int WebPAnimDecoderGetNext(WebPAnimDecoder* dec, -: 325: uint8_t** buf, int* timestamp); -: 326: -: 327:// Check if there are more frames left to decode. -: 328:// Parameters: -: 329:// dec - (in) decoder instance to be checked. -: 330:// Returns: -: 331:// True if 'dec' is not NULL and some frames are yet to be decoded. -: 332:// Otherwise, returns false. -: 333:WEBP_EXTERN int WebPAnimDecoderHasMoreFrames(const WebPAnimDecoder* dec); -: 334: -: 335:// Resets the WebPAnimDecoder object, so that next call to -: 336:// WebPAnimDecoderGetNext() will restart decoding from 1st frame. This would be -: 337:// helpful when all frames need to be decoded multiple times (e.g. -: 338:// info.loop_count times) without destroying and recreating the 'dec' object. -: 339:// Parameters: -: 340:// dec - (in/out) decoder instance to be reset -: 341:WEBP_EXTERN void WebPAnimDecoderReset(WebPAnimDecoder* dec); -: 342: -: 343:// Grab the internal demuxer object. -: 344:// Getting the demuxer object can be useful if one wants to use operations only -: 345:// available through demuxer; e.g. to get XMP/EXIF/ICC metadata. The returned -: 346:// demuxer object is owned by 'dec' and is valid only until the next call to -: 347:// WebPAnimDecoderDelete(). -: 348:// -: 349:// Parameters: -: 350:// dec - (in) decoder instance from which the demuxer object is to be fetched. -: 351:WEBP_EXTERN const WebPDemuxer* WebPAnimDecoderGetDemuxer( -: 352: const WebPAnimDecoder* dec); -: 353: -: 354:// Deletes the WebPAnimDecoder object. -: 355:// Parameters: -: 356:// dec - (in/out) decoder instance to be deleted -: 357:WEBP_EXTERN void WebPAnimDecoderDelete(WebPAnimDecoder* dec); -: 358: -: 359:#ifdef __cplusplus -: 360:} // extern "C" -: 361:#endif -: 362: -: 363:#endif // WEBP_WEBP_DEMUX_H_ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#FliDecode.c.gcov -: 0:Source:src/libImaging/FliDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/FliDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/FliDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for Autodesk Animator FLI/FLC animations -: 6: * -: 7: * history: -: 8: * 97-01-03 fl Created -: 9: * 97-01-17 fl Added SS2 support (FLC) -: 10: * -: 11: * Copyright (c) Fredrik Lundh 1997. -: 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:#define I16(ptr)\ -: 22: ((ptr)[0] + ((ptr)[1] << 8)) -: 23: -: 24:#define I32(ptr)\ -: 25: ((ptr)[0] + ((ptr)[1] << 8) + ((ptr)[2] << 16) + ((ptr)[3] << 24)) -: 26: -: 27:#define ERR_IF_DATA_OOB(offset) \ -: 28: if ((data + (offset)) > ptr + bytes) {\ -: 29: state->errcode = IMAGING_CODEC_OVERRUN; \ -: 30: return -1; \ -: 31: } -: 32: -: 33:int function ImagingFliDecode called 444 returned 100% blocks executed 45% 444: 34:ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 35:{ -: 36: UINT8* ptr; -: 37: int framesize; -: 38: int c, chunks, advance; -: 39: int l, lines; 444: 40: int i, j, x = 0, y, ymax; -: 41: -: 42: /* If not even the chunk size is present, we'd better leave */ -: 43: 444: 44: if (bytes < 4) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 45: return 0; -: 46: } -: 47: -: 48: /* We don't decode anything unless we have a full chunk in the -: 49: input buffer */ -: 50: 443: 51: ptr = buf; -: 52: 443: 53: framesize = I32(ptr); -: 54: if (framesize < I32(ptr)) { -: 55: return 0; -: 56: } -: 57: -: 58: /* Make sure this is a frame chunk. The Python driver takes -: 59: case of other chunk types. */ -: 60: 443: 61: if (bytes < 8) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 62: state->errcode = IMAGING_CODEC_OVERRUN; 1: 63: return -1; -: 64: } 442: 65: if (I16(ptr+4) != 0xF1FA) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 66: state->errcode = IMAGING_CODEC_UNKNOWN; #####: 67: return -1; -: 68: } -: 69: 442: 70: chunks = I16(ptr+6); 442: 71: ptr += 16; 442: 72: bytes -= 16; -: 73: -: 74: /* Process subchunks */ 660: 75: for (c = 0; c < chunks; c++) { branch 0 taken 33% branch 1 taken 67% (fallthrough) -: 76: UINT8* data; 219: 77: if (bytes < 10) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 78: state->errcode = IMAGING_CODEC_OVERRUN; #####: 79: return -1; -: 80: } 219: 81: data = ptr + 6; 219: 82: switch (I16(ptr+4)) { branch 0 taken 4% branch 1 taken 0% branch 2 taken 0% branch 3 taken 91% branch 4 taken 0% branch 5 taken 0% branch 6 taken 5% -: 83: case 4: case 11: -: 84: /* FLI COLOR chunk */ -: 85: break; /* ignored; handled by Python code */ -: 86: case 7: -: 87: /* FLI SS2 chunk (word delta) */ -: 88: /* OOB ok, we've got 4 bytes min on entry */ #####: 89: lines = I16(data); data += 2; #####: 90: for (l = y = 0; l < lines && y < state->ysize; l++, y++) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 91: UINT8* local_buf = (UINT8*) im->image[y]; -: 92: int p, packets; #####: 93: ERR_IF_DATA_OOB(2) branch 0 never executed branch 1 never executed #####: 94: packets = I16(data); data += 2; #####: 95: while (packets & 0x8000) { branch 0 never executed branch 1 never executed -: 96: /* flag word */ #####: 97: if (packets & 0x4000) { branch 0 never executed branch 1 never executed #####: 98: y += 65536 - packets; /* skip lines */ #####: 99: if (y >= state->ysize) { branch 0 never executed branch 1 never executed #####: 100: state->errcode = IMAGING_CODEC_OVERRUN; #####: 101: return -1; -: 102: } #####: 103: local_buf = (UINT8*) im->image[y]; -: 104: } else { -: 105: /* store last byte (used if line width is odd) */ #####: 106: local_buf[state->xsize-1] = (UINT8) packets; -: 107: } #####: 108: ERR_IF_DATA_OOB(2) branch 0 never executed branch 1 never executed #####: 109: packets = I16(data); data += 2; -: 110: } #####: 111: for (p = x = 0; p < packets; p++) { branch 0 never executed branch 1 never executed #####: 112: ERR_IF_DATA_OOB(2) branch 0 never executed branch 1 never executed #####: 113: x += data[0]; /* pixel skip */ #####: 114: if (data[1] >= 128) { branch 0 never executed branch 1 never executed #####: 115: ERR_IF_DATA_OOB(4) branch 0 never executed branch 1 never executed #####: 116: i = 256-data[1]; /* run */ #####: 117: if (x + i + i > state->xsize) { branch 0 never executed branch 1 never executed -: 118: break; -: 119: } #####: 120: for (j = 0; j < i; j++) { branch 0 never executed branch 1 never executed #####: 121: local_buf[x++] = data[2]; #####: 122: local_buf[x++] = data[3]; -: 123: } -: 124: data += 2 + 2; -: 125: } else { #####: 126: i = 2 * (int) data[1]; /* chunk */ #####: 127: if (x + i > state->xsize) { branch 0 never executed branch 1 never executed -: 128: break; -: 129: } #####: 130: ERR_IF_DATA_OOB(2+i) branch 0 never executed branch 1 never executed #####: 131: memcpy(local_buf + x, data + 2, i); #####: 132: data += 2 + i; #####: 133: x += i; -: 134: } -: 135: } #####: 136: if (p < packets) { branch 0 never executed branch 1 never executed -: 137: break; /* didn't process all packets */ -: 138: } -: 139: } #####: 140: if (l < lines) { branch 0 never executed branch 1 never executed -: 141: /* didn't process all lines */ #####: 142: state->errcode = IMAGING_CODEC_OVERRUN; #####: 143: return -1; -: 144: } -: 145: break; -: 146: case 12: -: 147: /* FLI LC chunk (byte delta) */ -: 148: /* OOB Check ok, we have 4 bytes min here */ 200: 149: y = I16(data); ymax = y + I16(data+2); data += 4; 4518: 150: for (; y < ymax && y < state->ysize; y++) { branch 0 taken 96% (fallthrough) branch 1 taken 4% branch 2 taken 100% branch 3 taken 0% (fallthrough) 4318: 151: UINT8* out = (UINT8*) im->image[y]; 4318: 152: ERR_IF_DATA_OOB(1) branch 0 taken 0% (fallthrough) branch 1 taken 100% 4318: 153: int p, packets = *data++; 27803: 154: for (p = x = 0; p < packets; p++, x += i) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 23485: 155: ERR_IF_DATA_OOB(2) branch 0 taken 0% (fallthrough) branch 1 taken 100% 23485: 156: x += data[0]; /* skip pixels */ 23485: 157: if (data[1] & 0x80) { branch 0 taken 53% (fallthrough) branch 1 taken 47% 12556: 158: i = 256-data[1]; /* run */ 12556: 159: if (x + i > state->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 160: break; -: 161: } 12556: 162: ERR_IF_DATA_OOB(3) branch 0 taken 0% (fallthrough) branch 1 taken 100% 25112: 163: memset(out + x, data[2], i); 12556: 164: data += 3; -: 165: } else { 10929: 166: i = data[1]; /* chunk */ 10929: 167: if (x + i > state->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 168: break; -: 169: } 10929: 170: ERR_IF_DATA_OOB(2+i) branch 0 taken 0% (fallthrough) branch 1 taken 100% 21858: 171: memcpy(out + x, data + 2, i); 10929: 172: data += i + 2; -: 173: } -: 174: } 4318: 175: if (p < packets) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 176: break; /* didn't process all packets */ -: 177: } -: 178: } 200: 179: if (y < ymax) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 180: /* didn't process all lines */ #####: 181: state->errcode = IMAGING_CODEC_OVERRUN; #####: 182: return -1; -: 183: } -: 184: break; -: 185: case 13: -: 186: /* FLI BLACK chunk */ #####: 187: for (y = 0; y < state->ysize; y++) { branch 0 never executed branch 1 never executed #####: 188: memset(im->image[y], 0, state->xsize); -: 189: } -: 190: break; -: 191: case 15: -: 192: /* FLI BRUN chunk */ -: 193: /* OOB, ok, we've got 4 bytes min on entry */ 1312: 194: for (y = 0; y < state->ysize; y++) { branch 0 taken 99% branch 1 taken 1% 1312: 195: UINT8* out = (UINT8*) im->image[y]; 1312: 196: data += 1; /* ignore packetcount byte */ 15620: 197: for (x = 0; x < state->xsize; x += i) { branch 0 taken 92% branch 1 taken 8% (fallthrough) 14308: 198: ERR_IF_DATA_OOB(2) branch 0 taken 0% (fallthrough) branch 1 taken 100% 14308: 199: if (data[0] & 0x80) { branch 0 taken 39% (fallthrough) branch 1 taken 61% 5532: 200: i = 256 - data[0]; 5532: 201: if (x + i > state->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 202: break; /* safety first */ -: 203: } 5532: 204: ERR_IF_DATA_OOB(i+1) branch 0 taken 0% (fallthrough) branch 1 taken 100% 11064: 205: memcpy(out + x, data + 1, i); 5532: 206: data += i + 1; -: 207: } else { 8776: 208: i = data[0]; 8776: 209: if (x + i > state->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 210: break; /* safety first */ -: 211: } 17552: 212: memset(out + x, data[1], i); 8776: 213: data += 2; -: 214: } -: 215: } 1312: 216: if (x != state->xsize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 217: /* didn't unpack whole line */ #####: 218: state->errcode = IMAGING_CODEC_OVERRUN; #####: 219: return -1; -: 220: } -: 221: } -: 222: break; -: 223: case 16: -: 224: /* COPY chunk */ #####: 225: if (state->xsize > bytes/state->ysize) { branch 0 never executed branch 1 never executed -: 226: /* not enough data for frame */ #####: 227: return ptr - buf; /* bytes consumed */ -: 228: } #####: 229: for (y = 0; y < state->ysize; y++) { branch 0 never executed branch 1 never executed #####: 230: UINT8* local_buf = (UINT8*) im->image[y]; #####: 231: memcpy(local_buf, data, state->xsize); #####: 232: data += state->xsize; -: 233: } -: 234: break; -: 235: case 18: -: 236: /* PSTAMP chunk */ -: 237: break; /* ignored */ -: 238: default: -: 239: /* unknown chunk */ -: 240: /* printf("unknown FLI/FLC chunk: %d\n", I16(ptr+4)); */ #####: 241: state->errcode = IMAGING_CODEC_UNKNOWN; #####: 242: return -1; -: 243: } 219: 244: advance = I32(ptr); 219: 245: if (advance < 0 || advance > bytes) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 1% (fallthrough) branch 3 taken 99% 1: 246: state->errcode = IMAGING_CODEC_OVERRUN; 1: 247: return -1; -: 248: } 218: 249: ptr += advance; 218: 250: bytes -= advance; -: 251: } -: 252: -: 253: return -1; /* end of frame */ -: 254:} <<<<<< 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-s390x-3.8/src/libImaging/QuantPngQuant.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/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/#usr#include#webp#mux_types.h.gcov -: 0:Source:/usr/include/webp/mux_types.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:// Copyright 2012 Google Inc. All Rights Reserved. -: 2:// -: 3:// Use of this source code is governed by a BSD-style license -: 4:// that can be found in the COPYING file in the root of the source -: 5:// tree. An additional intellectual property rights grant can be found -: 6:// in the file PATENTS. All contributing project authors may -: 7:// be found in the AUTHORS file in the root of the source tree. -: 8:// ----------------------------------------------------------------------------- -: 9:// -: 10:// Data-types common to the mux and demux libraries. -: 11:// -: 12:// Author: Urvang (urvang@google.com) -: 13: -: 14:#ifndef WEBP_WEBP_MUX_TYPES_H_ -: 15:#define WEBP_WEBP_MUX_TYPES_H_ -: 16: -: 17:#include // memset() -: 18:#include "./types.h" -: 19: -: 20:#ifdef __cplusplus -: 21:extern "C" { -: 22:#endif -: 23: -: 24:// Note: forward declaring enumerations is not allowed in (strict) C and C++, -: 25:// the types are left here for reference. -: 26:// typedef enum WebPFeatureFlags WebPFeatureFlags; -: 27:// typedef enum WebPMuxAnimDispose WebPMuxAnimDispose; -: 28:// typedef enum WebPMuxAnimBlend WebPMuxAnimBlend; -: 29:typedef struct WebPData WebPData; -: 30: -: 31:// VP8X Feature Flags. -: 32:typedef enum WebPFeatureFlags { -: 33: ANIMATION_FLAG = 0x00000002, -: 34: XMP_FLAG = 0x00000004, -: 35: EXIF_FLAG = 0x00000008, -: 36: ALPHA_FLAG = 0x00000010, -: 37: ICCP_FLAG = 0x00000020, -: 38: -: 39: ALL_VALID_FLAGS = 0x0000003e -: 40:} WebPFeatureFlags; -: 41: -: 42:// Dispose method (animation only). Indicates how the area used by the current -: 43:// frame is to be treated before rendering the next frame on the canvas. -: 44:typedef enum WebPMuxAnimDispose { -: 45: WEBP_MUX_DISPOSE_NONE, // Do not dispose. -: 46: WEBP_MUX_DISPOSE_BACKGROUND // Dispose to background color. -: 47:} WebPMuxAnimDispose; -: 48: -: 49:// Blend operation (animation only). Indicates how transparent pixels of the -: 50:// current frame are blended with those of the previous canvas. -: 51:typedef enum WebPMuxAnimBlend { -: 52: WEBP_MUX_BLEND, // Blend. -: 53: WEBP_MUX_NO_BLEND // Do not blend. -: 54:} WebPMuxAnimBlend; -: 55: -: 56:// Data type used to describe 'raw' data, e.g., chunk data -: 57:// (ICC profile, metadata) and WebP compressed image data. -: 58:// 'bytes' memory must be allocated using WebPMalloc() and such. -: 59:struct WebPData { -: 60: const uint8_t* bytes; -: 61: size_t size; -: 62:}; -: 63: -: 64:// Initializes the contents of the 'webp_data' object with default values. -: 65:static WEBP_INLINE void WebPDataInit(WebPData* webp_data) { 345: 66: if (webp_data != NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 67: memset(webp_data, 0, sizeof(*webp_data)); -: 68: } -: 69:} -: 70: -: 71:// Clears the contents of the 'webp_data' object by calling WebPFree(). -: 72:// Does not deallocate the object itself. function WebPDataClear called 184 returned 100% blocks executed 100% 184: 73:static WEBP_INLINE void WebPDataClear(WebPData* webp_data) { 184: 74: if (webp_data != NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 184: 75: WebPFree((void*)webp_data->bytes); call 0 returned 100% -: 76: WebPDataInit(webp_data); -: 77: } 184: 78:} -: 79: -: 80:// Allocates necessary storage for 'dst' and copies the contents of 'src'. -: 81:// Returns true on success. function WebPDataCopy called 161 returned 100% blocks executed 100% 161: 82:static WEBP_INLINE int WebPDataCopy(const WebPData* src, WebPData* dst) { 161: 83: if (src == NULL || dst == NULL) return 0; branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 161: 84: WebPDataInit(dst); 161: 85: if (src->bytes != NULL && src->size != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 161: 86: dst->bytes = (uint8_t*)WebPMalloc(src->size); call 0 returned 100% 161: 87: if (dst->bytes == NULL) return 0; branch 0 taken 100% (fallthrough) branch 1 taken 0% 322: 88: memcpy((void*)dst->bytes, src->bytes, src->size); 161: 89: dst->size = src->size; -: 90: } -: 91: return 1; -: 92:} -: 93: -: 94:#ifdef __cplusplus -: 95:} // extern "C" -: 96:#endif -: 97: -: 98:#endif // WEBP_WEBP_MUX_TYPES_H_ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#GifEncode.c.gcov -: 0:Source:src/libImaging/GifEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/GifEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/GifEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * encoder for uncompressed GIF data -: 6: * -: 7: * history: -: 8: * 97-01-05 fl created (writes uncompressed data) -: 9: * 97-08-27 fl fixed off-by-one error in buffer size test -: 10: * 98-07-09 fl added interlace write support -: 11: * 99-02-07 fl rewritten, now uses a run-length encoding strategy -: 12: * 99-02-08 fl improved run-length encoding for long runs -: 13: * -: 14: * Copyright (c) Secret Labs AB 1997-99. -: 15: * Copyright (c) Fredrik Lundh 1997. -: 16: * -: 17: * See the README file for information on usage and redistribution. -: 18: */ -: 19: -: 20:#include "Imaging.h" -: 21: -: 22:#include "Gif.h" -: 23: -: 24:/* codes from 0 to 255 are literals */ -: 25:#define CLEAR_CODE 256 -: 26:#define EOF_CODE 257 -: 27:#define FIRST_CODE 258 -: 28:#define LAST_CODE 511 -: 29: -: 30:enum { INIT, ENCODE, ENCODE_EOF, FLUSH, EXIT }; -: 31: -: 32:/* to make things a little less complicated, we use a simple output -: 33: queue to hold completed blocks. the following inlined function -: 34: adds a byte to the current block. it allocates a new block if -: 35: necessary. */ -: 36: -: 37:static inline int function emit called 2920221 returned 100% blocks executed 100% 2920221: 38:emit(GIFENCODERSTATE *context, int byte) -: 39:{ -: 40: /* write a byte to the output buffer */ -: 41: 2920221: 42: if (!context->block || context->block->size == 255) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% -: 43: GIFENCODERBLOCK* block; -: 44: -: 45: /* no room in the current block (or no current block); -: 46: allocate a new one */ -: 47: -: 48: /* add current block to end of flush queue */ 11495: 49: if (context->block) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 11388: 50: block = context->flush; 11388: 51: while (block && block->next) { branch 0 taken 33% (fallthrough) branch 1 taken 67% branch 2 taken 8% (fallthrough) branch 3 taken 92% -: 52: block = block->next; -: 53: } 11388: 54: if (block) { branch 0 taken 31% (fallthrough) branch 1 taken 69% 3535: 55: block->next = context->block; -: 56: } else { 7853: 57: context->flush = context->block; -: 58: } -: 59: } -: 60: -: 61: /* get a new block */ 11495: 62: if (context->free) { branch 0 taken 68% (fallthrough) branch 1 taken 32% 7798: 63: block = context->free; 7798: 64: context->free = NULL; -: 65: } else { -: 66: /* malloc check ok, small constant allocation */ 3697: 67: block = malloc(sizeof(GIFENCODERBLOCK)); 3697: 68: if (!block) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 69: return 0; -: 70: } -: 71: } -: 72: 11495: 73: block->size = 0; 11495: 74: block->next = NULL; -: 75: 11495: 76: context->block = block; -: 77: -: 78: } -: 79: -: 80: /* write new byte to block */ 2920221: 81: context->block->data[context->block->size++] = byte; -: 82: 2920221: 83: return 1; -: 84:} -: 85: -: 86:/* write a code word to the current block. this is a macro to make -: 87: sure it's inlined on all platforms */ -: 88: -: 89:#define EMIT(code) {\ -: 90: context->bitbuffer |= ((INT32) (code)) << context->bitcount;\ -: 91: context->bitcount += 9;\ -: 92: while (context->bitcount >= 8) {\ -: 93: if (!emit(context, (UINT8) context->bitbuffer)) {\ -: 94: state->errcode = IMAGING_CODEC_MEMORY;\ -: 95: return 0;\ -: 96: }\ -: 97: context->bitbuffer >>= 8;\ -: 98: context->bitcount -= 8;\ -: 99: }\ -: 100:} -: 101: -: 102:/* write a run. we use a combination of literals and combinations of -: 103: literals. this can give quite decent compression for images with -: 104: long stretches of identical pixels. but remember: if you want -: 105: really good compression, use another file format. */ -: 106: -: 107:#define EMIT_RUN(label) {\ -: 108:label:\ -: 109: while (context->count > 0) {\ -: 110: int run = 2;\ -: 111: EMIT(context->last);\ -: 112: context->count--;\ -: 113: if (state->count++ == LAST_CODE) {\ -: 114: EMIT(CLEAR_CODE);\ -: 115: state->count = FIRST_CODE;\ -: 116: goto label;\ -: 117: }\ -: 118: while (context->count >= run) {\ -: 119: EMIT(state->count - 1);\ -: 120: context->count -= run;\ -: 121: run++;\ -: 122: if (state->count++ == LAST_CODE) {\ -: 123: EMIT(CLEAR_CODE);\ -: 124: state->count = FIRST_CODE;\ -: 125: goto label;\ -: 126: }\ -: 127: }\ -: 128: if (context->count > 1) {\ -: 129: EMIT(state->count - 1 - (run - context->count));\ -: 130: context->count = 0;\ -: 131: if (state->count++ == LAST_CODE) {\ -: 132: EMIT(CLEAR_CODE);\ -: 133: state->count = FIRST_CODE;\ -: 134: }\ -: 135: break;\ -: 136: }\ -: 137: }\ -: 138:} -: 139: -: 140:int function ImagingGifEncode called 140 returned 100% blocks executed 83% 140: 141:ImagingGifEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 142:{ -: 143: UINT8* ptr; -: 144: int this; -: 145: -: 146: GIFENCODERBLOCK* block; 140: 147: GIFENCODERSTATE *context = (GIFENCODERSTATE*) state->context; -: 148: 140: 149: if (!state->state) { branch 0 taken 76% (fallthrough) branch 1 taken 24% -: 150: -: 151: /* place a clear code in the output buffer */ 107: 152: context->bitbuffer = CLEAR_CODE; 107: 153: context->bitcount = 9; -: 154: 107: 155: state->count = FIRST_CODE; -: 156: 107: 157: if (context->interlace) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 38: 158: context->interlace = 1; 38: 159: context->step = 8; -: 160: } else { 69: 161: context->step = 1; -: 162: } -: 163: 107: 164: context->last = -1; -: 165: -: 166: /* sanity check */ 107: 167: if (state->xsize <= 0 || state->ysize <= 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 168: state->state = ENCODE_EOF; -: 169: } -: 170: -: 171: } -: 172: -: 173: ptr = buf; -: 174: -: 175: for (;;) -: 176: 6715955: 177: switch (state->state) { branch 0 taken 0% branch 1 taken 1% branch 2 taken 99% branch 3 taken 1% -: 178: -: 179: case INIT: -: 180: case ENCODE: -: 181: -: 182: /* identify and store a run of pixels */ -: 183: 6707978: 184: if (state->x == 0 || state->x >= state->xsize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% -: 185: 24878: 186: if (!context->interlace && state->y >= state->ysize) { branch 0 taken 62% (fallthrough) branch 1 taken 38% branch 2 taken 1% (fallthrough) branch 3 taken 99% 107: 187: state->state = ENCODE_EOF; 107: 188: break; -: 189: } -: 190: 24771: 191: if (context->flush) { branch 0 taken 32% (fallthrough) branch 1 taken 68% 7837: 192: state->state = FLUSH; 7837: 193: break; -: 194: } -: 195: -: 196: /* get another line of data */ 33868: 197: state->shuffle( call 0 returned 100% -: 198: state->buffer, 16934: 199: (UINT8*) im->image[state->y + state->yoff] + 16934: 200: state->xoff * im->pixelsize, state->xsize -: 201: ); -: 202: 16934: 203: state->x = 0; -: 204: 16934: 205: if (state->state == INIT) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 206: /* preload the run-length buffer and get going */ 107: 207: context->last = state->buffer[0]; 107: 208: context->count = state->x = 1; 107: 209: state->state = ENCODE; -: 210: } -: 211: -: 212: /* step forward, according to the interlace settings */ 16934: 213: state->y += context->step; 33982: 214: while (context->interlace && state->y >= state->ysize) branch 0 taken 33% (fallthrough) branch 1 taken 67% branch 2 taken 2% branch 3 taken 98% (fallthrough) 114: 215: switch (context->interlace) { branch 0 taken 33% branch 1 taken 33% branch 2 taken 33% branch 3 taken 0% -: 216: case 1: 38: 217: state->y = 4; 38: 218: context->interlace = 2; 38: 219: break; -: 220: case 2: 38: 221: context->step = 4; 38: 222: state->y = 2; 38: 223: context->interlace = 3; 38: 224: break; -: 225: case 3: 38: 226: context->step = 2; 38: 227: state->y = 1; 38: 228: context->interlace = 0; 38: 229: break; -: 230: default: -: 231: /* just make sure we don't loop forever */ #####: 232: context->interlace = 0; -: 233: } -: 234: -: 235: } -: 236: 6700034: 237: this = state->buffer[state->x++]; -: 238: 6700034: 239: if (this == context->last) { branch 0 taken 13% (fallthrough) branch 1 taken 87% 5838913: 240: context->count++; -: 241: } else { 1400279: 242: EMIT_RUN(label1); call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% branch 3 taken 53% branch 4 taken 47% (fallthrough) branch 5 taken 1% (fallthrough) branch 6 taken 99% call 7 returned 100% branch 8 taken 0% (fallthrough) branch 9 taken 100% branch 10 taken 53% branch 11 taken 47% (fallthrough) call 12 returned 100% branch 13 taken 0% (fallthrough) branch 14 taken 100% branch 15 taken 53% branch 16 taken 47% (fallthrough) branch 17 taken 1% (fallthrough) branch 18 taken 99% call 19 returned 100% branch 20 taken 0% (fallthrough) branch 21 taken 100% branch 22 taken 53% branch 23 taken 47% (fallthrough) branch 24 taken 42% branch 25 taken 58% (fallthrough) branch 26 taken 11% (fallthrough) branch 27 taken 89% call 28 returned 100% branch 29 taken 0% (fallthrough) branch 30 taken 100% branch 31 taken 53% branch 32 taken 47% (fallthrough) branch 33 taken 1% (fallthrough) branch 34 taken 99% call 35 returned 100% branch 36 taken 0% (fallthrough) branch 37 taken 100% branch 38 taken 53% branch 39 taken 47% (fallthrough) branch 40 taken 67% branch 41 taken 33% (fallthrough) 861121: 243: context->last = this; 861121: 244: context->count = 1; -: 245: } -: 246: break; -: 247: -: 248: -: 249: case ENCODE_EOF: -: 250: -: 251: /* write the final run */ 130: 252: EMIT_RUN(label2); call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% branch 3 taken 59% branch 4 taken 41% (fallthrough) branch 5 taken 0% (fallthrough) branch 6 taken 100% call 7 never executed branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed call 12 returned 100% branch 13 taken 0% (fallthrough) branch 14 taken 100% branch 15 taken 53% branch 16 taken 47% (fallthrough) branch 17 taken 1% (fallthrough) branch 18 taken 99% call 19 returned 100% branch 20 taken 0% (fallthrough) branch 21 taken 100% branch 22 taken 56% branch 23 taken 44% (fallthrough) branch 24 taken 98% branch 25 taken 2% (fallthrough) branch 26 taken 69% (fallthrough) branch 27 taken 31% call 28 returned 100% branch 29 taken 0% (fallthrough) branch 30 taken 100% branch 31 taken 51% branch 32 taken 49% (fallthrough) branch 33 taken 0% (fallthrough) branch 34 taken 100% call 35 never executed branch 36 never executed branch 37 never executed branch 38 never executed branch 39 never executed branch 40 taken 84% branch 41 taken 16% (fallthrough) -: 253: -: 254: /* write an end of image marker */ 107: 255: EMIT(EOF_CODE); call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% branch 3 taken 51% branch 4 taken 49% (fallthrough) -: 256: -: 257: /* empty the bit buffer */ 209: 258: while (context->bitcount > 0) { branch 0 taken 49% branch 1 taken 51% (fallthrough) 102: 259: if (!emit(context, (UINT8) context->bitbuffer)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 260: state->errcode = IMAGING_CODEC_MEMORY; #####: 261: return 0; -: 262: } 102: 263: context->bitbuffer >>= 8; 102: 264: context->bitcount -= 8; -: 265: } -: 266: -: 267: /* flush the last block, and exit */ 107: 268: if (context->block) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 269: GIFENCODERBLOCK* block; 107: 270: block = context->flush; 107: 271: while (block && block->next) { branch 0 taken 19% (fallthrough) branch 1 taken 81% branch 2 taken 24% branch 3 taken 76% (fallthrough) -: 272: block = block->next; -: 273: } 107: 274: if (block) { branch 0 taken 15% (fallthrough) branch 1 taken 85% 16: 275: block->next = context->block; -: 276: } else { 91: 277: context->flush = context->block; -: 278: } 107: 279: context->block = NULL; -: 280: } -: 281: 107: 282: state->state = EXIT; -: 283: -: 284: /* fall through... */ -: 285: -: 286: case EXIT: -: 287: case FLUSH: -: 288: 19472: 289: while (context->flush) { branch 0 taken 59% branch 1 taken 41% (fallthrough) -: 290: -: 291: /* get a block from the flush queue */ 11528: 292: block = context->flush; -: 293: 11528: 294: if (block->size > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 295: -: 296: /* make sure it fits into the output buffer */ 11528: 297: if (bytes < block->size+1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 33: 298: return ptr - buf; -: 299: } -: 300: 11495: 301: ptr[0] = block->size; 22990: 302: memcpy(ptr+1, block->data, block->size); -: 303: 11495: 304: ptr += block->size+1; 11495: 305: bytes -= block->size+1; -: 306: -: 307: } -: 308: 11495: 309: context->flush = block->next; -: 310: 11495: 311: if (context->free) { branch 0 taken 31% (fallthrough) branch 1 taken 69% 3590: 312: free(context->free); -: 313: } 11495: 314: context->free = block; -: 315: -: 316: } -: 317: 7944: 318: if (state->state == EXIT) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 319: /* this was the last block! */ 107: 320: if (context->free) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 107: 321: free(context->free); -: 322: } 107: 323: state->errcode = IMAGING_CODEC_END; 107: 324: return ptr - buf; -: 325: } -: 326: 7837: 327: state->state = ENCODE; 7837: 328: break; -: 329: } -: 330:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#codec_fd.c.gcov -: 0:Source:src/libImaging/codec_fd.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/codec_fd.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/codec_fd.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Python.h" -: 2:#include "Imaging.h" -: 3: -: 4: -: 5:Py_ssize_t function _imaging_read_pyFd called 69 returned 100% blocks executed 80% 69: 6:_imaging_read_pyFd(PyObject *fd, char* dest, Py_ssize_t bytes) -: 7:{ -: 8: /* dest should be a buffer bytes long, returns length of read -: 9: -1 on error */ -: 10: -: 11: PyObject *result; -: 12: char *buffer; -: 13: Py_ssize_t length; -: 14: int bytes_result; -: 15: 69: 16: result = PyObject_CallMethod(fd, "read", "n", bytes); call 0 returned 100% -: 17: 69: 18: bytes_result = PyBytes_AsStringAndSize(result, &buffer, &length); call 0 returned 100% 69: 19: if (bytes_result == -1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 20: goto err; -: 21: } -: 22: 69: 23: if (length > bytes) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 24: goto err; -: 25: } -: 26: 138: 27: memcpy(dest, buffer, length); -: 28: 138: 29: Py_DECREF(result); 69: 30: return length; -: 31: -: 32: err: #####: 33: Py_DECREF(result); -: 34: return -1; -: 35: -: 36:} -: 37: -: 38:Py_ssize_t function _imaging_write_pyFd called 54 returned 100% blocks executed 100% 54: 39:_imaging_write_pyFd(PyObject *fd, char* src, Py_ssize_t bytes) -: 40:{ -: 41: -: 42: PyObject *result; -: 43: PyObject *byteObj; -: 44: 54: 45: byteObj = PyBytes_FromStringAndSize(src, bytes); call 0 returned 100% 54: 46: result = PyObject_CallMethod(fd, "write", "O", byteObj); call 0 returned 100% -: 47: 108: 48: Py_DECREF(byteObj); 108: 49: Py_DECREF(result); -: 50: 54: 51: return bytes; -: 52: -: 53:} -: 54: -: 55:int function _imaging_seek_pyFd called 40 returned 100% blocks executed 100% 40: 56:_imaging_seek_pyFd(PyObject *fd, Py_ssize_t offset, int whence) -: 57:{ -: 58: PyObject *result; -: 59: 40: 60: result = PyObject_CallMethod(fd, "seek", "ni", offset, whence); call 0 returned 100% -: 61: 80: 62: Py_DECREF(result); 40: 63: return 0; -: 64: -: 65:} -: 66: -: 67:Py_ssize_t function _imaging_tell_pyFd called 33 returned 100% blocks executed 100% 33: 68:_imaging_tell_pyFd(PyObject *fd) -: 69:{ -: 70: PyObject *result; -: 71: Py_ssize_t location; -: 72: 33: 73: result = PyObject_CallMethod(fd, "tell", NULL); call 0 returned 100% 33: 74: location = PyLong_AsSsize_t(result); call 0 returned 100% -: 75: 66: 76: Py_DECREF(result); 33: 77: return location; -: 78:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Draw.c.gcov -: 0:Source:src/libImaging/Draw.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Draw.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Draw.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * a simple drawing package for the Imaging library -: 6: * -: 7: * history: -: 8: * 1996-04-13 fl Created. -: 9: * 1996-04-30 fl Added transforms and polygon support. -: 10: * 1996-08-12 fl Added filled polygons. -: 11: * 1996-11-05 fl Fixed float/int confusion in polygon filler -: 12: * 1997-07-04 fl Support 32-bit images (C++ would have been nice) -: 13: * 1998-09-09 fl Eliminated qsort casts; improved rectangle clipping -: 14: * 1998-09-10 fl Fixed fill rectangle to include lower edge (!) -: 15: * 1998-12-29 fl Added arc, chord, and pieslice primitives -: 16: * 1999-01-10 fl Added some level 2 ("arrow") stuff (experimental) -: 17: * 1999-02-06 fl Added bitmap primitive -: 18: * 1999-07-26 fl Eliminated a compiler warning -: 19: * 1999-07-31 fl Pass ink as void* instead of int -: 20: * 2002-12-10 fl Added experimental RGBA-on-RGB drawing -: 21: * 2004-09-04 fl Support simple wide lines (no joins) -: 22: * 2005-05-25 fl Fixed line width calculation -: 23: * -: 24: * Copyright (c) 1996-2006 by Fredrik Lundh -: 25: * Copyright (c) 1997-2006 by Secret Labs AB. -: 26: * -: 27: * See the README file for information on usage and redistribution. -: 28: */ -: 29: -: 30:/* FIXME: support fill/outline attribute for all filled shapes */ -: 31:/* FIXME: support zero-winding fill */ -: 32:/* FIXME: add drawing context, support affine transforms */ -: 33:/* FIXME: support clip window (and mask?) */ -: 34: -: 35:#include "Imaging.h" -: 36: -: 37:#include -: 38:#include -: 39: -: 40:#define CEIL(v) (int) ceil(v) -: 41:#define FLOOR(v) ((v) >= 0.0 ? (int) (v) : (int) floor(v)) -: 42: -: 43:#define INK8(ink) (*(UINT8*)ink) -: 44: -: 45:/* -: 46: * Rounds around zero (up=away from zero, down=towards zero) -: 47: * This guarantees that ROUND_UP|DOWN(f) == -ROUND_UP|DOWN(-f) -: 48: */ -: 49:#define ROUND_UP(f) ((int) ((f) >= 0.0 ? floor((f) + 0.5F) : -floor(fabs(f) + 0.5F))) -: 50:#define ROUND_DOWN(f) ((int) ((f) >= 0.0 ? ceil((f) - 0.5F) : -ceil(fabs(f) - 0.5F))) -: 51: -: 52:/* -------------------------------------------------------------------- */ -: 53:/* Primitives */ -: 54:/* -------------------------------------------------------------------- */ -: 55: -: 56:typedef struct { -: 57: /* edge descriptor for polygon engine */ -: 58: int d; -: 59: int x0, y0; -: 60: int xmin, ymin, xmax, ymax; -: 61: float dx; -: 62:} Edge; -: 63: -: 64:/* Type used in "polygon*" functions */ -: 65:typedef void (*hline_handler)(Imaging, int, int, int, int); -: 66: -: 67:static inline void function point8 called 658 returned 100% blocks executed 100% 658: 68:point8(Imaging im, int x, int y, int ink) -: 69:{ 658: 70: if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 99% (fallthrough) branch 7 taken 1% 655: 71: if (strncmp(im->mode, "I;16", 4) == 0) { branch 0 taken 15% (fallthrough) branch 1 taken 85% 100: 72: im->image8[y][x*2] = (UINT8) ink; 100: 73: im->image8[y][x*2+1] = (UINT8) ink; -: 74: } else { 555: 75: im->image8[y][x] = (UINT8) ink; -: 76: } -: 77: } 658: 78:} -: 79: -: 80:static inline void function point32 called 165 returned 100% blocks executed 100% 165: 81:point32(Imaging im, int x, int y, int ink) -: 82:{ 63249: 83: 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 100% (fallthrough) branch 7 taken 0% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 taken 100% (fallthrough) branch 11 taken 0% branch 12 taken 100% (fallthrough) branch 13 taken 0% branch 14 taken 100% (fallthrough) branch 15 taken 0% branch 16 taken 100% (fallthrough) branch 17 taken 0% branch 18 taken 100% (fallthrough) branch 19 taken 0% branch 20 taken 100% (fallthrough) branch 21 taken 0% branch 22 taken 100% (fallthrough) branch 23 taken 0% branch 24 taken 100% (fallthrough) branch 25 taken 0% branch 26 taken 100% (fallthrough) branch 27 taken 0% branch 28 taken 100% (fallthrough) branch 29 taken 0% branch 30 taken 100% (fallthrough) branch 31 taken 0% branch 32 taken 100% (fallthrough) branch 33 taken 0% branch 34 taken 53% (fallthrough) branch 35 taken 47% branch 36 taken 100% (fallthrough) branch 37 taken 0% branch 38 taken 11% (fallthrough) branch 39 taken 89% 63094: 84: im->image32[y][x] = ink; -: 85: } 165: 86:} -: 87: -: 88:static inline void function point32rgba called 0 returned 0% blocks executed 0% #####: 89:point32rgba(Imaging im, int x, int y, int ink) -: 90:{ -: 91: unsigned int tmp1; -: 92: #####: 93: if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize) { 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 #####: 94: UINT8* out = (UINT8*) im->image[y]+x*4; #####: 95: UINT8* in = (UINT8*) &ink; #####: 96: out[0] = BLEND(in[3], out[0], in[0], tmp1); #####: 97: out[1] = BLEND(in[3], out[1], in[1], tmp1); #####: 98: out[2] = BLEND(in[3], out[2], in[2], tmp1); -: 99: } #####: 100:} -: 101: -: 102:static inline void function hline8 called 2781 returned 100% blocks executed 93% 2781: 103:hline8(Imaging im, int x0, int y0, int x1, int ink) -: 104:{ -: 105: int tmp, pixelwidth; -: 106: 2781: 107: if (y0 >= 0 && y0 < im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 98% (fallthrough) branch 3 taken 2% 2737: 108: if (x0 > x1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 109: tmp = x0, x0 = x1, x1 = tmp; -: 110: } 2737: 111: if (x0 < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 112: x0 = 0; 2737: 113: } else if (x0 >= im->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 114: return; -: 115: } 2737: 116: if (x1 < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 117: return; 2737: 118: } else if (x1 >= im->xsize) { branch 0 taken 12% (fallthrough) branch 1 taken 88% 337: 119: x1 = im->xsize-1; -: 120: } 2737: 121: if (x0 <= x1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 2737: 122: pixelwidth = strncmp(im->mode, "I;16", 4) == 0 ? 2 : 1; branch 0 taken 98% (fallthrough) branch 1 taken 2% 5474: 123: memset(im->image8[y0] + x0 * pixelwidth, (UINT8) ink, 2737: 124: (x1 - x0 + 1) * pixelwidth); -: 125: } -: 126: } -: 127:} -: 128: -: 129:static inline void function hline32 called 77255 returned 100% blocks executed 100% 77255: 130:hline32(Imaging im, int x0, int y0, int x1, int ink) -: 131:{ -: 132: int tmp; -: 133: INT32* p; -: 134: 77255: 135: if (y0 >= 0 && y0 < im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 99% (fallthrough) branch 3 taken 1% 77243: 136: if (x0 > x1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 6: 137: tmp = x0, x0 = x1, x1 = tmp; -: 138: } 77243: 139: if (x0 < 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 140: x0 = 0; 77043: 141: } else if (x0 >= im->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 142: return; -: 143: } 77243: 144: if (x1 < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 145: return; 77243: 146: } else if (x1 >= im->xsize) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 1173: 147: x1 = im->xsize-1; -: 148: } 77243: 149: p = im->image32[y0]; 1020421: 150: while (x0 <= x1) { branch 0 taken 92% branch 1 taken 8% (fallthrough) 865935: 151: p[x0++] = ink; -: 152: } -: 153: } -: 154:} -: 155: -: 156:static inline void function hline32rgba called 102 returned 100% blocks executed 86% 102: 157:hline32rgba(Imaging im, int x0, int y0, int x1, int ink) -: 158:{ -: 159: int tmp; -: 160: unsigned int tmp1; -: 161: 102: 162: if (y0 >= 0 && y0 < im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 102: 163: if (x0 > x1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 164: tmp = x0, x0 = x1, x1 = tmp; -: 165: } 102: 166: if (x0 < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 167: x0 = 0; 102: 168: } else if (x0 >= im->xsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 169: return; -: 170: } 102: 171: if (x1 < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 172: return; 102: 173: } else if (x1 >= im->xsize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 174: x1 = im->xsize-1; -: 175: } 102: 176: if (x0 <= x1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 102: 177: UINT8* out = (UINT8*) im->image[y0]+x0*4; 102: 178: UINT8* in = (UINT8*) &ink; 2229: 179: while (x0 <= x1) { branch 0 taken 95% branch 1 taken 5% (fallthrough) 2025: 180: out[0] = BLEND(in[3], out[0], in[0], tmp1); 2025: 181: out[1] = BLEND(in[3], out[1], in[1], tmp1); 2025: 182: out[2] = BLEND(in[3], out[2], in[2], tmp1); 2025: 183: x0++; out += 4; -: 184: } -: 185: } -: 186: } -: 187:} -: 188: -: 189:static inline void function line8 called 11 returned 100% blocks executed 86% 11: 190:line8(Imaging im, int x0, int y0, int x1, int y1, int ink) -: 191:{ -: 192: int i, n, e; -: 193: int dx, dy; -: 194: int xs, ys; -: 195: -: 196: /* normalize coordinates */ 11: 197: dx = x1-x0; 11: 198: if (dx < 0) { branch 0 taken 18% (fallthrough) branch 1 taken 82% 2: 199: dx = -dx, xs = -1; -: 200: } else { -: 201: xs = 1; -: 202: } 11: 203: dy = y1-y0; 11: 204: if (dy < 0) { branch 0 taken 45% (fallthrough) branch 1 taken 55% 5: 205: dy = -dy, ys = -1; -: 206: } else { -: 207: ys = 1; -: 208: } -: 209: 11: 210: n = (dx > dy) ? dx : dy; -: 211: 11: 212: if (dx == 0) { branch 0 taken 45% (fallthrough) branch 1 taken 55% -: 213: -: 214: /* vertical */ 200: 215: for (i = 0; i < dy; i++) { branch 0 taken 98% branch 1 taken 2% 200: 216: point8(im, x0, y0, ink); call 0 returned 100% 200: 217: y0 += ys; -: 218: } -: 219: 6: 220: } else if (dy == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 221: -: 222: /* horizontal */ #####: 223: for (i = 0; i < dx; i++) { branch 0 never executed branch 1 never executed #####: 224: point8(im, x0, y0, ink); call 0 never executed #####: 225: x0 += xs; -: 226: } -: 227: 6: 228: } else if (dx > dy) { branch 0 taken 33% (fallthrough) branch 1 taken 67% -: 229: -: 230: /* bresenham, horizontal slope */ 2: 231: n = dx; 2: 232: dy += dy; 2: 233: e = dy - dx; 2: 234: dx += dx; -: 235: 122: 236: for (i = 0; i < n; i++) { branch 0 taken 98% branch 1 taken 2% 120: 237: point8(im, x0, y0, ink); call 0 returned 100% 120: 238: if (e >= 0) { branch 0 taken 67% (fallthrough) branch 1 taken 33% 80: 239: y0 += ys; 80: 240: e -= dx; -: 241: } 120: 242: e += dy; 120: 243: x0 += xs; -: 244: } -: 245: -: 246: } else { -: 247: -: 248: /* bresenham, vertical slope */ 4: 249: n = dy; 4: 250: dx += dx; 4: 251: e = dx - dy; 4: 252: dy += dy; -: 253: 340: 254: for (i = 0; i < n; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 336: 255: point8(im, x0, y0, ink); call 0 returned 100% 336: 256: if (e >= 0) { branch 0 taken 88% (fallthrough) branch 1 taken 12% 296: 257: x0 += xs; 296: 258: e -= dy; -: 259: } 336: 260: e += dx; 336: 261: y0 += ys; -: 262: } -: 263: -: 264: } 11: 265:} -: 266: -: 267:static inline void function line32 called 288 returned 100% blocks executed 100% 288: 268:line32(Imaging im, int x0, int y0, int x1, int y1, int ink) -: 269:{ -: 270: int i, n, e; -: 271: int dx, dy; -: 272: int xs, ys; -: 273: -: 274: /* normalize coordinates */ 288: 275: dx = x1-x0; 288: 276: if (dx < 0) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 7: 277: dx = -dx, xs = -1; -: 278: } else { -: 279: xs = 1; -: 280: } 288: 281: dy = y1-y0; 288: 282: if (dy < 0) { branch 0 taken 14% (fallthrough) branch 1 taken 86% 41: 283: dy = -dy, ys = -1; -: 284: } else { -: 285: ys = 1; -: 286: } -: 287: 288: 288: n = (dx > dy) ? dx : dy; -: 289: 288: 290: if (dx == 0) { branch 0 taken 48% (fallthrough) branch 1 taken 52% -: 291: -: 292: /* vertical */ 31174: 293: for (i = 0; i < dy; i++) { branch 0 taken 99% branch 1 taken 1% 31174: 294: point32(im, x0, y0, ink); 31174: 295: y0 += ys; -: 296: } -: 297: 149: 298: } else if (dy == 0) { branch 0 taken 52% (fallthrough) branch 1 taken 48% -: 299: -: 300: /* horizontal */ 31250: 301: for (i = 0; i < dx; i++) { branch 0 taken 99% branch 1 taken 1% 31250: 302: point32(im, x0, y0, ink); 31250: 303: x0 += xs; -: 304: } -: 305: 71: 306: } else if (dx > dy) { branch 0 taken 3% (fallthrough) branch 1 taken 97% -: 307: -: 308: /* bresenham, horizontal slope */ 2: 309: n = dx; 2: 310: dy += dy; 2: 311: e = dy - dx; 2: 312: dx += dx; -: 313: 122: 314: for (i = 0; i < n; i++) { branch 0 taken 98% branch 1 taken 2% 120: 315: point32(im, x0, y0, ink); 120: 316: if (e >= 0) { branch 0 taken 67% (fallthrough) branch 1 taken 33% 80: 317: y0 += ys; 80: 318: e -= dx; -: 319: } 120: 320: e += dy; 120: 321: x0 += xs; -: 322: } -: 323: -: 324: } else { -: 325: -: 326: /* bresenham, vertical slope */ 69: 327: n = dy; 69: 328: dx += dx; 69: 329: e = dx - dy; 69: 330: dy += dy; -: 331: 609: 332: for (i = 0; i < n; i++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 540: 333: point32(im, x0, y0, ink); 540: 334: if (e >= 0) { branch 0 taken 78% (fallthrough) branch 1 taken 22% 420: 335: x0 += xs; 420: 336: e -= dy; -: 337: } 540: 338: e += dx; 540: 339: y0 += ys; -: 340: } -: 341: -: 342: } 288: 343:} -: 344: -: 345:static inline void function line32rgba called 0 returned 0% blocks executed 0% #####: 346:line32rgba(Imaging im, int x0, int y0, int x1, int y1, int ink) -: 347:{ -: 348: int i, n, e; -: 349: int dx, dy; -: 350: int xs, ys; -: 351: -: 352: /* normalize coordinates */ #####: 353: dx = x1-x0; #####: 354: if (dx < 0) { branch 0 never executed branch 1 never executed #####: 355: dx = -dx, xs = -1; -: 356: } else { -: 357: xs = 1; -: 358: } #####: 359: dy = y1-y0; #####: 360: if (dy < 0) { branch 0 never executed branch 1 never executed #####: 361: dy = -dy, ys = -1; -: 362: } else { -: 363: ys = 1; -: 364: } -: 365: #####: 366: n = (dx > dy) ? dx : dy; -: 367: #####: 368: if (dx == 0) { branch 0 never executed branch 1 never executed -: 369: -: 370: /* vertical */ #####: 371: for (i = 0; i < dy; i++) { branch 0 never executed branch 1 never executed #####: 372: point32rgba(im, x0, y0, ink); call 0 never executed #####: 373: y0 += ys; -: 374: } -: 375: #####: 376: } else if (dy == 0) { branch 0 never executed branch 1 never executed -: 377: -: 378: /* horizontal */ #####: 379: for (i = 0; i < dx; i++) { branch 0 never executed branch 1 never executed #####: 380: point32rgba(im, x0, y0, ink); call 0 never executed #####: 381: x0 += xs; -: 382: } -: 383: #####: 384: } else if (dx > dy) { branch 0 never executed branch 1 never executed -: 385: -: 386: /* bresenham, horizontal slope */ #####: 387: n = dx; #####: 388: dy += dy; #####: 389: e = dy - dx; #####: 390: dx += dx; -: 391: #####: 392: for (i = 0; i < n; i++) { branch 0 never executed branch 1 never executed #####: 393: point32rgba(im, x0, y0, ink); call 0 never executed #####: 394: if (e >= 0) { branch 0 never executed branch 1 never executed #####: 395: y0 += ys; #####: 396: e -= dx; -: 397: } #####: 398: e += dy; #####: 399: x0 += xs; -: 400: } -: 401: -: 402: } else { -: 403: -: 404: /* bresenham, vertical slope */ #####: 405: n = dy; #####: 406: dx += dx; #####: 407: e = dx - dy; #####: 408: dy += dy; -: 409: #####: 410: for (i = 0; i < n; i++) { branch 0 never executed branch 1 never executed #####: 411: point32rgba(im, x0, y0, ink); call 0 never executed #####: 412: if (e >= 0) { branch 0 never executed branch 1 never executed #####: 413: x0 += xs; #####: 414: e -= dy; -: 415: } #####: 416: e += dx; #####: 417: y0 += ys; -: 418: } -: 419: -: 420: } #####: 421:} -: 422: -: 423:static int function x_cmp called 7448 returned 100% blocks executed 100% 7448: 424:x_cmp(const void *x0, const void *x1) -: 425:{ 7448: 426: float diff = *((float*)x0) - *((float*)x1); 7448: 427: if (diff < 0) { branch 0 taken 56% (fallthrough) branch 1 taken 44% -: 428: return -1; 4169: 429: } else if (diff > 0) { branch 0 taken 21% (fallthrough) branch 1 taken 79% -: 430: return 1; -: 431: } else { 890: 432: return 0; -: 433: } -: 434:} -: 435: -: 436: -: 437:static void function draw_horizontal_lines called 12757 returned 100% blocks executed 100% 12757: 438:draw_horizontal_lines(Imaging im, int n, Edge *e, int ink, int *x_pos, int y, hline_handler hline) -: 439:{ -: 440: int i; 82885: 441: for (i = 0; i < n; i++) { branch 0 taken 85% branch 1 taken 15% (fallthrough) 70128: 442: if (e[i].ymin == y && e[i].ymin == e[i].ymax) { branch 0 taken 3% (fallthrough) branch 1 taken 97% branch 2 taken 21% (fallthrough) branch 3 taken 79% -: 443: int xmax; 438: 444: int xmin = e[i].xmin; 438: 445: if (*x_pos < xmin) { branch 0 taken 48% (fallthrough) branch 1 taken 52% -: 446: // Line would be after the current position 209: 447: continue; -: 448: } -: 449: 229: 450: xmax = e[i].xmax; 229: 451: if (*x_pos > xmin) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 452: // Line would be partway through x_pos, so increase the starting point 228: 453: xmin = *x_pos; 228: 454: if (xmax < xmin) { branch 0 taken 93% (fallthrough) branch 1 taken 7% -: 455: // Line would now end before it started 212: 456: continue; -: 457: } -: 458: } -: 459: 17: 460: (*hline)(im, xmin, e[i].ymin, xmax, ink); call 0 returned 100% 17: 461: *x_pos = xmax+1; -: 462: } -: 463: } 12757: 464:} -: 465: -: 466:/* -: 467: * Filled polygon draw function using scan line algorithm. -: 468: */ -: 469:static inline int function polygon_generic.isra.0 called 166 returned 100% blocks executed 96% 166: 470:polygon_generic(Imaging im, int n, Edge *e, int ink, int eofill, -: 471: hline_handler hline) -: 472:{ -: 473: -: 474: Edge** edge_table; -: 475: float* xx; 166: 476: int edge_count = 0; 166: 477: int ymin = im->ysize - 1; 166: 478: int ymax = 0; -: 479: int i; -: 480: 166: 481: if (n <= 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 482: return 0; -: 483: } -: 484: -: 485: /* Initialize the edge table and find polygon boundaries */ -: 486: /* malloc check ok, using calloc */ 166: 487: edge_table = calloc(n, sizeof(Edge*)); 166: 488: if (!edge_table) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 489: return -1; -: 490: } -: 491: 889: 492: for (i = 0; i < n; i++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 889: 493: if (ymin > e[i].ymin) { branch 0 taken 26% (fallthrough) branch 1 taken 74% 232: 494: ymin = e[i].ymin; -: 495: } 889: 496: if (ymax < e[i].ymax) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 324: 497: ymax = e[i].ymax; -: 498: } 889: 499: if (e[i].ymin == e[i].ymax) { branch 0 taken 23% (fallthrough) branch 1 taken 77% 205: 500: continue; -: 501: } 684: 502: edge_table[edge_count++] = (e + i); -: 503: } 166: 504: if (ymin < 0) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 3: 505: ymin = 0; -: 506: } 166: 507: if (ymax > im->ysize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 508: ymax = im->ysize; -: 509: } -: 510: -: 511: /* Process the edge table with a scan line searching for intersections */ -: 512: /* malloc check ok, using calloc */ 166: 513: xx = calloc(edge_count * 2, sizeof(float)); 166: 514: if (!xx) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 515: free(edge_table); -: 516: return -1; -: 517: } 6289: 518: for (; ymin <= ymax; ymin++) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 6289: 519: int j = 0; 6289: 520: int x_pos = 0; 32885: 521: for (i = 0; i < edge_count; i++) { branch 0 taken 81% branch 1 taken 19% (fallthrough) 26596: 522: Edge* current = edge_table[i]; 26596: 523: if (ymin >= current->ymin && ymin <= current->ymax) { branch 0 taken 72% (fallthrough) branch 1 taken 28% branch 2 taken 68% (fallthrough) branch 3 taken 32% 12929: 524: xx[j++] = (ymin - current->y0) * current->dx + current->x0; -: 525: } -: 526: /* Needed to draw consistent polygons */ 26596: 527: if (ymin == current->ymax && ymin < ymax) { branch 0 taken 3% (fallthrough) branch 1 taken 97% branch 2 taken 52% (fallthrough) branch 3 taken 48% 353: 528: xx[j] = xx[j - 1]; 353: 529: j++; -: 530: } -: 531: } 6289: 532: qsort(xx, j, sizeof(float), x_cmp); 12930: 533: for (i = 1; i < j; i += 2) { call 0 returned 100% branch 1 taken 51% branch 2 taken 49% (fallthrough) 6641: 534: int x_end = ROUND_DOWN(xx[i]); branch 0 taken 99% (fallthrough) branch 1 taken 1% 6641: 535: if (x_end < x_pos) { branch 0 taken 3% (fallthrough) branch 1 taken 97% -: 536: // Line would be before the current position 173: 537: continue; -: 538: } 6468: 539: draw_horizontal_lines(im, n, e, ink, &x_pos, ymin, hline); call 0 returned 100% 6468: 540: if (x_end < x_pos) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 541: // Line would be before the current position 8: 542: continue; -: 543: } -: 544: 6460: 545: int x_start = ROUND_UP(xx[i-1]); branch 0 taken 99% (fallthrough) branch 1 taken 1% 6460: 546: if (x_pos > x_start) { branch 0 taken 3% (fallthrough) branch 1 taken 97% -: 547: // Line would be partway through x_pos, so increase the starting point 179: 548: x_start = x_pos; 179: 549: if (x_end < x_start) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 550: // Line would now end before it started #####: 551: continue; -: 552: } -: 553: } 6460: 554: (*hline)(im, x_start, ymin, x_end, ink); call 0 returned 100% 6460: 555: x_pos = x_end+1; -: 556: } 6289: 557: draw_horizontal_lines(im, n, e, ink, &x_pos, ymin, hline); call 0 returned 100% -: 558: } -: 559: 166: 560: free(xx); 166: 561: free(edge_table); -: 562: return 0; -: 563:} -: 564: -: 565:static inline int function polygon8 called 7 returned 100% blocks executed 100% 7: 566:polygon8(Imaging im, int n, Edge *e, int ink, int eofill) -: 567:{ 7: 568: return polygon_generic(im, n, e, ink, eofill, hline8); call 0 returned 100% -: 569:} -: 570: -: 571:static inline int function polygon32 called 159 returned 100% blocks executed 100% 159: 572:polygon32(Imaging im, int n, Edge *e, int ink, int eofill) -: 573:{ 159: 574: return polygon_generic(im, n, e, ink, eofill, hline32); call 0 returned 100% -: 575:} -: 576: -: 577:static inline int function polygon32rgba called 0 returned 0% blocks executed 0% #####: 578:polygon32rgba(Imaging im, int n, Edge *e, int ink, int eofill) -: 579:{ #####: 580: return polygon_generic(im, n, e, ink, eofill, hline32rgba); call 0 never executed -: 581:} -: 582: -: 583:static inline void function add_edge called 724 returned 100% blocks executed 100% 724: 584:add_edge(Edge *e, int x0, int y0, int x1, int y1) -: 585:{ -: 586: /* printf("edge %d %d %d %d\n", x0, y0, x1, y1); */ -: 587: 724: 588: if (x0 <= x1) { branch 0 taken 63% (fallthrough) branch 1 taken 37% 459: 589: e->xmin = x0, e->xmax = x1; -: 590: } else { 265: 591: e->xmin = x1, e->xmax = x0; -: 592: } -: 593: 724: 594: if (y0 <= y1) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 450: 595: e->ymin = y0, e->ymax = y1; -: 596: } else { 274: 597: e->ymin = y1, e->ymax = y0; -: 598: } -: 599: 724: 600: if (y0 == y1) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 180: 601: e->d = 0; 180: 602: e->dx = 0.0; -: 603: } else { 544: 604: e->dx = ((float)(x1-x0)) / (y1-y0); 544: 605: if (y0 == e->ymin) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 270: 606: e->d = 1; -: 607: } else { 274: 608: e->d = -1; -: 609: } -: 610: } -: 611: 724: 612: e->x0 = x0; 724: 613: e->y0 = y0; 724: 614:} -: 615: -: 616:typedef struct { -: 617: void (*point)(Imaging im, int x, int y, int ink); -: 618: void (*hline)(Imaging im, int x0, int y0, int x1, int ink); -: 619: void (*line)(Imaging im, int x0, int y0, int x1, int y1, int ink); -: 620: int (*polygon)(Imaging im, int n, Edge *e, int ink, int eofill); -: 621:} DRAW; -: 622: -: 623:DRAW draw8 = { point8, hline8, line8, polygon8 }; -: 624:DRAW draw32 = { point32, hline32, line32, polygon32 }; -: 625:DRAW draw32rgba = { point32rgba, hline32rgba, line32rgba, polygon32rgba }; -: 626: -: 627:/* -------------------------------------------------------------------- */ -: 628:/* Interface */ -: 629:/* -------------------------------------------------------------------- */ -: 630: -: 631:#define DRAWINIT()\ -: 632: if (im->image8) {\ -: 633: draw = &draw8;\ -: 634: ink = INK8(ink_);\ -: 635: } else {\ -: 636: draw = (op) ? &draw32rgba : &draw32; \ -: 637: memcpy(&ink, ink_, sizeof(ink)); \ -: 638: } -: 639: -: 640:int function ImagingDrawPoint called 166 returned 100% blocks executed 100% 166: 641:ImagingDrawPoint(Imaging im, int x0, int y0, const void* ink_, int op) -: 642:{ -: 643: DRAW* draw; -: 644: INT32 ink; -: 645: 166: 646: DRAWINIT(); branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 647: 166: 648: draw->point(im, x0, y0, ink); call 0 returned 100% -: 649: 166: 650: return 0; -: 651:} -: 652: -: 653:int function ImagingDrawLine called 163 returned 100% blocks executed 100% 163: 654:ImagingDrawLine(Imaging im, int x0, int y0, int x1, int y1, const void* ink_, -: 655: int op) -: 656:{ -: 657: DRAW* draw; -: 658: INT32 ink; -: 659: 163: 660: DRAWINIT(); branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 661: 163: 662: draw->line(im, x0, y0, x1, y1, ink); call 0 returned 100% -: 663: 163: 664: return 0; -: 665:} -: 666: -: 667:int function ImagingDrawWideLine called 140 returned 100% blocks executed 91% 140: 668:ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1, -: 669: const void* ink_, int width, int op) -: 670:{ -: 671: DRAW* draw; -: 672: INT32 ink; -: 673: int dx, dy; -: 674: double big_hypotenuse, small_hypotenuse, ratio_max, ratio_min; -: 675: int dxmin, dxmax, dymin, dymax; -: 676: Edge e[4]; -: 677: 140: 678: DRAWINIT(); branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 679: 140: 680: dx = x1-x0; 140: 681: dy = y1-y0; 140: 682: if (dx == 0 && dy == 0) { branch 0 taken 24% (fallthrough) branch 1 taken 76% branch 2 taken 3% (fallthrough) branch 3 taken 97% 1: 683: draw->point(im, x0, y0, ink); call 0 returned 100% 1: 684: return 0; -: 685: } -: 686: 139: 687: big_hypotenuse = hypot(dx, dy); 139: 688: small_hypotenuse = (width - 1) / 2.0; 139: 689: ratio_max = ROUND_UP(small_hypotenuse) / big_hypotenuse; branch 0 taken 100% (fallthrough) branch 1 taken 0% 139: 690: ratio_min = ROUND_DOWN(small_hypotenuse) / big_hypotenuse; branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 691: 139: 692: dxmin = ROUND_DOWN(ratio_min * dy); branch 0 taken 63% (fallthrough) branch 1 taken 37% 139: 693: dxmax = ROUND_DOWN(ratio_max * dy); branch 0 taken 59% (fallthrough) branch 1 taken 41% 139: 694: dymin = ROUND_DOWN(ratio_min * dx); branch 0 taken 59% (fallthrough) branch 1 taken 41% 139: 695: dymax = ROUND_DOWN(ratio_max * dx); branch 0 taken 58% (fallthrough) branch 1 taken 42% -: 696: { 1112: 697: int vertices[4][2] = { 278: 698: {x0 - dxmin, y0 + dymax}, 278: 699: {x1 - dxmin, y1 + dymax}, 278: 700: {x1 + dxmax, y1 - dymin}, 278: 701: {x0 + dxmax, y0 - dymin} -: 702: }; -: 703: 139: 704: add_edge(e+0, vertices[0][0], vertices[0][1], vertices[1][0], vertices[1][1]); call 0 returned 100% 139: 705: add_edge(e+1, vertices[1][0], vertices[1][1], vertices[2][0], vertices[2][1]); call 0 returned 100% 139: 706: add_edge(e+2, vertices[2][0], vertices[2][1], vertices[3][0], vertices[3][1]); call 0 returned 100% 139: 707: add_edge(e+3, vertices[3][0], vertices[3][1], vertices[0][0], vertices[0][1]); call 0 returned 100% -: 708: 139: 709: draw->polygon(im, 4, e, ink, 0); call 0 returned 100% -: 710: } 139: 711: return 0; -: 712:} -: 713: -: 714:int function ImagingDrawRectangle called 147 returned 100% blocks executed 96% 147: 715:ImagingDrawRectangle(Imaging im, int x0, int y0, int x1, int y1, -: 716: const void* ink_, int fill, int width, int op) -: 717:{ -: 718: int i; -: 719: int y; -: 720: int tmp; -: 721: DRAW* draw; -: 722: INT32 ink; -: 723: 147: 724: DRAWINIT(); branch 0 taken 67% (fallthrough) branch 1 taken 33% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 725: 147: 726: if (y0 > y1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 727: tmp = y0, y0 = y1, y1 = tmp; -: 728: } -: 729: 147: 730: if (fill) { branch 0 taken 84% (fallthrough) branch 1 taken 16% -: 731: 123: 732: if (y0 < 0) { branch 0 taken 98% (fallthrough) branch 1 taken 2% -: 733: y0 = 0; 121: 734: } else if (y0 >= im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 735: return 0; -: 736: } -: 737: 123: 738: if (y1 < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 739: return 0; 123: 740: } else if (y1 > im->ysize) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 2: 741: y1 = im->ysize; -: 742: } -: 743: 3167: 744: for (y = y0; y <= y1; y++) { branch 0 taken 96% branch 1 taken 4% 3044: 745: draw->hline(im, x0, y, x1, ink); call 0 returned 100% -: 746: } -: 747: -: 748: } else { -: 749: /* outline */ 24: 750: if (width == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 751: width = 1; -: 752: } 56: 753: for (i = 0; i < width; i++) { branch 0 taken 57% branch 1 taken 43% (fallthrough) 32: 754: draw->hline(im, x0, y0+i, x1, ink); call 0 returned 100% 32: 755: draw->hline(im, x0, y1-i, x1, ink); call 0 returned 100% 32: 756: draw->line(im, x1-i, y0, x1-i, y1, ink); call 0 returned 100% 32: 757: draw->line(im, x0+i, y1, x0+i, y0, ink); call 0 returned 100% -: 758: } -: 759: } -: 760: -: 761: return 0; -: 762:} -: 763: -: 764:int function ImagingDrawPolygon called 26 returned 100% blocks executed 92% 26: 765:ImagingDrawPolygon(Imaging im, int count, int* xy, const void* ink_, -: 766: int fill, int op) -: 767:{ -: 768: int i, n; -: 769: DRAW* draw; -: 770: INT32 ink; -: 771: 26: 772: if (count <= 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 773: return 0; -: 774: } -: 775: 26: 776: DRAWINIT(); branch 0 taken 19% (fallthrough) branch 1 taken 81% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 777: 26: 778: if (fill) { branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 779: -: 780: /* Build edge list */ -: 781: /* malloc check ok, using calloc */ 19: 782: Edge* e = calloc(count, sizeof(Edge)); 19: 783: if (!e) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 784: (void) ImagingError_MemoryError(); call 0 never executed #####: 785: return -1; -: 786: } 52: 787: for (i = n = 0; i < count-1; i++) { branch 0 taken 73% branch 1 taken 27% (fallthrough) 52: 788: add_edge(&e[n++], xy[i+i], xy[i+i+1], xy[i+i+2], xy[i+i+3]); call 0 returned 100% -: 789: } 19: 790: if (xy[i+i] != xy[0] || xy[i+i+1] != xy[1]) { branch 0 taken 16% (fallthrough) branch 1 taken 84% branch 2 taken 33% (fallthrough) branch 3 taken 67% 17: 791: add_edge(&e[n++], xy[i+i], xy[i+i+1], xy[0], xy[1]); call 0 returned 100% -: 792: } 19: 793: draw->polygon(im, n, e, ink, 0); call 0 returned 100% 19: 794: free(e); -: 795: -: 796: } else { -: 797: -: 798: /* Outline */ 65: 799: for (i = 0; i < count-1; i++) { branch 0 taken 90% branch 1 taken 10% (fallthrough) 65: 800: draw->line(im, xy[i+i], xy[i+i+1], xy[i+i+2], xy[i+i+3], ink); call 0 returned 100% -: 801: } 7: 802: draw->line(im, xy[i+i], xy[i+i+1], xy[0], xy[1], ink); call 0 returned 100% -: 803: -: 804: } -: 805: -: 806: return 0; -: 807:} -: 808: -: 809:int function ImagingDrawBitmap called 350 returned 100% blocks executed 100% 350: 810:ImagingDrawBitmap(Imaging im, int x0, int y0, Imaging bitmap, const void* ink, -: 811: int op) -: 812:{ 700: 813: return ImagingFill2( call 0 returned 100% -: 814: im, ink, bitmap, 700: 815: x0, y0, x0 + bitmap->xsize, y0 + bitmap->ysize -: 816: ); -: 817:} -: 818: -: 819:/* -------------------------------------------------------------------- */ -: 820:/* standard shapes */ -: 821: -: 822:// Imagine 2D plane and ellipse with center in (0, 0) and semi-major axes a and b. -: 823:// Then quarter_* stuff approximates its top right quarter (x, y >= 0) with integer -: 824:// points from set {(2x+x0, 2y+y0) | x,y in Z} where x0, y0 are from {0, 1} and -: 825:// are such that point (a, b) is in the set. -: 826: -: 827:typedef struct { -: 828: int32_t a, b, cx, cy, ex, ey; -: 829: int64_t a2, b2, a2b2; -: 830: int8_t finished; -: 831:} quarter_state; -: 832: function quarter_init called 4155 returned 100% blocks executed 100% 4155: 833:void quarter_init(quarter_state* s, int32_t a, int32_t b) { 4155: 834: if (a < 0 || b < 0) { branch 0 taken 74% (fallthrough) branch 1 taken 26% branch 2 taken 1% (fallthrough) branch 3 taken 99% 1073: 835: s->finished = 1; -: 836: } else { 3082: 837: s->a = a; 3082: 838: s->b = b; 3082: 839: s->cx = a; 3082: 840: s->cy = b % 2; 3082: 841: s->ex = a % 2; 3082: 842: s->ey = b; 3082: 843: s->a2 = a * a; 3082: 844: s->b2 = b * b; 3082: 845: s->a2b2 = s->a2 * s->b2; 3082: 846: s->finished = 0; -: 847: } 4155: 848:} -: 849: -: 850:// deviation of the point from ellipse curve, basically a substitution -: 851:// of the point into the ellipse equation function quarter_delta called 115722 returned 100% blocks executed 100% 115722: 852:int64_t quarter_delta(quarter_state* s, int64_t x, int64_t y) { 115722: 853: return llabs(s->a2 * y * y + s->b2 * x * x - s->a2b2); -: 854:} -: 855: function quarter_next called 57079 returned 100% blocks executed 100% 57079: 856:int8_t quarter_next(quarter_state* s, int32_t* ret_x, int32_t* ret_y) { 57079: 857: if (s->finished) { branch 0 taken 75% (fallthrough) branch 1 taken 25% -: 858: return -1; -: 859: } 42799: 860: *ret_x = s->cx; 42799: 861: *ret_y = s->cy; 42799: 862: if (s->cx == s->ex && s->cy == s->ey) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 3073: 863: s->finished = 1; -: 864: } else { -: 865: // Bresenham's algorithm, possible optimization: only consider 2 of 3 -: 866: // next points depending on current slope 39726: 867: int32_t nx = s->cx; 39726: 868: int32_t ny = s->cy + 2; 39726: 869: int64_t ndelta = quarter_delta(s, nx, ny); call 0 returned 100% 39726: 870: if (nx > 1) { branch 0 taken 96% (fallthrough) branch 1 taken 4% 37998: 871: int64_t newdelta = quarter_delta(s, s->cx - 2, s->cy + 2); call 0 returned 100% 37998: 872: if (ndelta > newdelta) { branch 0 taken 68% (fallthrough) branch 1 taken 32% 25831: 873: nx = s->cx - 2; 25831: 874: ny = s->cy + 2; 25831: 875: ndelta = newdelta; -: 876: } 37998: 877: newdelta = quarter_delta(s, s->cx - 2, s->cy); call 0 returned 100% 37998: 878: if (ndelta > newdelta) { branch 0 taken 35% (fallthrough) branch 1 taken 65% 13268: 879: nx = s->cx - 2; 13268: 880: ny = s->cy; -: 881: } -: 882: } 39726: 883: s->cx = nx; 39726: 884: s->cy = ny; -: 885: } -: 886: return 0; -: 887:} -: 888: -: 889:// quarter_* stuff can "draw" a quarter of an ellipse with thickness 1, great. -: 890:// Now we use ellipse_* stuff to join all four quarters of two different sized -: 891:// ellipses and receive horizontal segments of a complete ellipse with -: 892:// specified thickness. -: 893:// -: 894:// Still using integer grid with step 2 at this point (like in quarter_*) -: 895:// to ease angle clipping in future. -: 896: -: 897:typedef struct { -: 898: quarter_state st_o, st_i; -: 899: int32_t py, pl, pr; -: 900: int32_t cy[4], cl[4], cr[4]; -: 901: int8_t bufcnt; -: 902: int8_t finished; -: 903: int8_t leftmost; -: 904:} ellipse_state; -: 905: function ellipse_init called 2080 returned 100% blocks executed 100% 2080: 906:void ellipse_init(ellipse_state* s, int32_t a, int32_t b, int32_t w) { 2080: 907: s->bufcnt = 0; 2080: 908: s->leftmost = a % 2; 2080: 909: quarter_init(&s->st_o, a, b); call 0 returned 100% 2080: 910: if (w < 1 || quarter_next(&s->st_o, &s->pr, &s->py) == -1) { branch 0 taken 99% (fallthrough) branch 1 taken 1% call 2 returned 100% branch 3 taken 0% (fallthrough) branch 4 taken 100% 5: 911: s->finished = 1; -: 912: } else { 2075: 913: s->finished = 0; 2075: 914: quarter_init(&s->st_i, a - 2 * (w - 1), b - 2 * (w - 1)); call 0 returned 100% 2075: 915: s->pl = s->leftmost; -: 916: } 2080: 917:} -: 918: function ellipse_next called 79775 returned 100% blocks executed 100% 79775: 919:int8_t ellipse_next(ellipse_state* s, int32_t* ret_x0, int32_t* ret_y, int32_t* ret_x1) { 79775: 920: if (s->bufcnt == 0) { branch 0 taken 28% (fallthrough) branch 1 taken 72% 22446: 921: if (s->finished) { branch 0 taken 9% (fallthrough) branch 1 taken 91% 2078: 922: return -1; -: 923: } 20368: 924: int32_t y = s->py; 20368: 925: int32_t l = s->pl; 20368: 926: int32_t r = s->pr; 20368: 927: int32_t cx = 0, cy = 0; -: 928: int8_t next_ret; 20368: 929: while ((next_ret = quarter_next(&s->st_o, &cx, &cy)) != -1 && cy <= y) { call 0 returned 100% branch 1 taken 93% (fallthrough) branch 2 taken 7% branch 3 taken 33% (fallthrough) branch 4 taken 67% -: 930: } 20368: 931: if (next_ret == -1) { branch 0 taken 10% (fallthrough) branch 1 taken 90% 2073: 932: s->finished = 1; -: 933: } else { 18295: 934: s->pr = cx; 18295: 935: s->py = cy; -: 936: } 25483: 937: while ((next_ret = quarter_next(&s->st_i, &cx, &cy)) != -1 && cy <= y) { call 0 returned 100% branch 1 taken 52% (fallthrough) branch 2 taken 48% branch 3 taken 39% branch 4 taken 61% (fallthrough) 5115: 938: l = cx; -: 939: } 20368: 940: s->pl = next_ret == -1 ? s->leftmost : cx; branch 0 taken 60% (fallthrough) branch 1 taken 40% -: 941: 20368: 942: if ((l > 0 || l < r) && y > 0) { branch 0 taken 37% (fallthrough) branch 1 taken 63% branch 2 taken 90% (fallthrough) branch 3 taken 10% branch 4 taken 94% (fallthrough) branch 5 taken 6% 18496: 943: s->cl[s->bufcnt] = l == 0 ? 2 : l; branch 0 taken 65% (fallthrough) branch 1 taken 35% 18496: 944: s->cy[s->bufcnt] = y; 18496: 945: s->cr[s->bufcnt] = r; 18496: 946: ++s->bufcnt; -: 947: } 20368: 948: if (y > 0) { branch 0 taken 94% (fallthrough) branch 1 taken 6% 19239: 949: s->cl[s->bufcnt] = -r; 19239: 950: s->cy[s->bufcnt] = y; 19239: 951: s->cr[s->bufcnt] = -l; 19239: 952: ++s->bufcnt; -: 953: } 20368: 954: if (l > 0 || l < r) { branch 0 taken 37% (fallthrough) branch 1 taken 63% branch 2 taken 90% (fallthrough) branch 3 taken 10% 19594: 955: s->cl[s->bufcnt] = l == 0 ? 2 : l; branch 0 taken 65% (fallthrough) branch 1 taken 35% 19594: 956: s->cy[s->bufcnt] = -y; 19594: 957: s->cr[s->bufcnt] = r; 19594: 958: ++s->bufcnt; -: 959: } 20368: 960: s->cl[s->bufcnt] = -r; 20368: 961: s->cy[s->bufcnt] = -y; 20368: 962: s->cr[s->bufcnt] = -l; 20368: 963: ++s->bufcnt; -: 964: } 77697: 965: --s->bufcnt; 77697: 966: *ret_x0 = s->cl[s->bufcnt]; 77697: 967: *ret_y = s->cy[s->bufcnt]; 77697: 968: *ret_x1 = s->cr[s->bufcnt]; 77697: 969: return 0; -: 970:} -: 971: -: 972:// Clipping tree consists of half-plane clipping nodes and combining nodes. -: 973:// We can throw a horizontal segment in such a tree and collect an ordered set -: 974:// of resulting disjoint clipped segments organized into a sorted linked list -: 975:// of their end points. -: 976:typedef enum { -: 977: CT_AND, // intersection -: 978: CT_OR, // union -: 979: CT_CLIP // half-plane clipping -: 980:} clip_type; -: 981: -: 982:typedef struct clip_node { -: 983: clip_type type; -: 984: double a, b, c; // half-plane coeffs, only used in clipping nodes -: 985: struct clip_node* l; // child pointers, are only non-NULL in combining nodes -: 986: struct clip_node* r; -: 987:} clip_node; -: 988: -: 989:// Linked list for the ends of the clipped horizontal segments. -: 990:// Since the segment is always horizontal, we don't need to store Y coordinate. -: 991:typedef struct event_list { -: 992: int32_t x; -: 993: int8_t type; // used internally, 1 for the left end (smaller X), -1 for the -: 994: // right end; pointless in output since the output segments -: 995: // are disjoint, therefore the types would always come in pairs -: 996: // and interchange (1 -1 1 -1 ...) -: 997: struct event_list* next; -: 998:} event_list; -: 999: -: 1000:// Mirrors all the clipping nodes of the tree relative to the y = x line. function clip_tree_transpose called 14 returned 100% blocks executed 100% 14: 1001:void clip_tree_transpose(clip_node* root) { 26: 1002: if (root != NULL) { branch 0 taken 46% (fallthrough) branch 1 taken 54% 12: 1003: if (root->type == CT_CLIP) { branch 0 taken 58% (fallthrough) branch 1 taken 42% 7: 1004: double t = root->a; 7: 1005: root->a = root->b; 7: 1006: root->b = t; -: 1007: } 12: 1008: clip_tree_transpose(root->l); call 0 returned 100% 12: 1009: clip_tree_transpose(root->r); -: 1010: } 14: 1011:} -: 1012: -: 1013:// Outputs a sequence of open-close events (types -1 and 1) for -: 1014:// non-intersecting segments sorted by X coordinate. -: 1015:// Combining nodes (AND, OR) may also accept sequences for intersecting -: 1016:// segments, i.e. something like correct bracket sequences. function clip_tree_do_clip called 40224 returned 100% blocks executed 77% 40224: 1017:int clip_tree_do_clip(clip_node* root, int32_t x0, int32_t y, int32_t x1, event_list** ret) { 40224: 1018: if (root == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1019: event_list* start = malloc(sizeof(event_list)); #####: 1020: if (!start) { branch 0 never executed branch 1 never executed #####: 1021: ImagingError_MemoryError(); call 0 never executed #####: 1022: return -1; -: 1023: } #####: 1024: event_list* end = malloc(sizeof(event_list)); #####: 1025: if (!end) { branch 0 never executed branch 1 never executed #####: 1026: free(start); #####: 1027: ImagingError_MemoryError(); call 0 never executed #####: 1028: return -1; -: 1029: } #####: 1030: start->x = x0; #####: 1031: start->type = 1; #####: 1032: start->next = end; #####: 1033: end->x = x1; #####: 1034: end->type = -1; #####: 1035: end->next = NULL; #####: 1036: *ret = start; #####: 1037: return 0; -: 1038: } 40224: 1039: if (root->type == CT_CLIP) { branch 0 taken 66% (fallthrough) branch 1 taken 34% 26452: 1040: double eps = 1e-9; 26452: 1041: double A = root->a; 26452: 1042: double B = root->b; 26452: 1043: double C = root->c; 26452: 1044: if (fabs(A) < eps) { branch 0 taken 19% (fallthrough) branch 1 taken 81% 5154: 1045: if (B * y + C < -eps) { branch 0 taken 49% (fallthrough) branch 1 taken 51% 2518: 1046: x0 = 1; 2518: 1047: x1 = 0; -: 1048: } -: 1049: } else { -: 1050: // X of intersection 21298: 1051: double ix = - (B * y + C) / A; 21298: 1052: if (A * x0 + B * y + C < eps) { branch 0 taken 52% (fallthrough) branch 1 taken 48% 11086: 1053: x0 = lround(fmax(x0, ix)); -: 1054: } 21298: 1055: if (A * x1 + B * y + C < eps) { branch 0 taken 53% (fallthrough) branch 1 taken 47% 11318: 1056: x1 = lround(fmin(x1, ix)); -: 1057: } -: 1058: } 26452: 1059: if (x0 <= x1) { branch 0 taken 59% (fallthrough) branch 1 taken 41% 15530: 1060: event_list* start = malloc(sizeof(event_list)); 15530: 1061: if (!start) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1062: ImagingError_MemoryError(); call 0 never executed #####: 1063: return -1; -: 1064: } 15530: 1065: event_list* end = malloc(sizeof(event_list)); 15530: 1066: if (!end) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1067: free(start); #####: 1068: ImagingError_MemoryError(); call 0 never executed #####: 1069: return -1; -: 1070: } 15530: 1071: start->x = x0; 15530: 1072: start->type = 1; 15530: 1073: start->next = end; 15530: 1074: end->x = x1; 15530: 1075: end->type = -1; 15530: 1076: end->next = NULL; 15530: 1077: *ret = start; -: 1078: } else { 10922: 1079: *ret = NULL; -: 1080: } -: 1081: return 0; -: 1082: } 13772: 1083: if (root->type == CT_OR || root->type == CT_AND) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1084: event_list* l1; -: 1085: event_list* l2; 13772: 1086: if (clip_tree_do_clip(root->l, x0, y, x1, &l1) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1087: return -1; -: 1088: } 13772: 1089: if (clip_tree_do_clip(root->r, x0, y, x1, &l2) < 0) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 1090: while (l1) { branch 0 never executed branch 1 never executed #####: 1091: l2 = l1->next; #####: 1092: free(l1); #####: 1093: l1 = l2; -: 1094: } -: 1095: return -1; -: 1096: } 13772: 1097: *ret = NULL; 13772: 1098: event_list* tail = NULL; 13772: 1099: int32_t k1 = 0; 13772: 1100: int32_t k2 = 0; 59014: 1101: while (l1 != NULL || l2 != NULL) { branch 0 taken 53% branch 1 taken 47% (fallthrough) branch 2 taken 36% branch 3 taken 64% (fallthrough) -: 1102: event_list* t; 31470: 1103: if (l2 == NULL || (l1 != NULL && (l1->x < l2->x || (l1->x == l2->x && l1->type > l2->type)))) { branch 0 taken 66% (fallthrough) branch 1 taken 34% branch 2 taken 64% (fallthrough) branch 3 taken 36% branch 4 taken 69% (fallthrough) branch 5 taken 31% branch 6 taken 77% (fallthrough) branch 7 taken 23% branch 8 taken 11% (fallthrough) branch 9 taken 89% 15540: 1104: t = l1; 15540: 1105: k1 += t->type; -: 1106: assert(k1 >= 0); 15540: 1107: l1 = l1->next; -: 1108: } else { 15930: 1109: t = l2; 15930: 1110: k2 += t->type; -: 1111: assert(k2 >= 0); 15930: 1112: l2 = l2->next; -: 1113: } 31470: 1114: t->next = NULL; 36620: 1115: if ((root->type == CT_OR && ( branch 0 taken 16% (fallthrough) branch 1 taken 84% branch 2 taken 50% (fallthrough) branch 3 taken 50% 7725: 1116: (t->type == 1 && (tail == NULL || tail->type == -1)) || branch 0 taken 23% (fallthrough) branch 1 taken 77% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 81% (fallthrough) branch 5 taken 19% 2575: 1117: (t->type == -1 && k1 == 0 && k2 == 0) branch 0 taken 77% (fallthrough) branch 1 taken 23% branch 2 taken 1% (fallthrough) branch 3 taken 99% 27522: 1118: )) || branch 0 taken 96% (fallthrough) branch 1 taken 4% 26320: 1119: (root->type == CT_AND && ( branch 0 taken 50% (fallthrough) branch 1 taken 50% 39480: 1120: (t->type == 1 && (tail == NULL || tail->type == -1) && k1 > 0 && k2 > 0) || branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed branch 4 taken 53% (fallthrough) branch 5 taken 47% branch 6 taken 46% (fallthrough) branch 7 taken 54% branch 8 taken 58% (fallthrough) branch 9 taken 42% 13160: 1121: (t->type == -1 && tail != NULL && tail->type == 1 && (k1 == 0 || k2 == 0)) branch 0 taken 57% (fallthrough) branch 1 taken 43% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 87% (fallthrough) branch 5 taken 13% branch 6 taken 100% (fallthrough) branch 7 taken 0% -: 1122: ))) { 11482: 1123: if (tail == NULL) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 5741: 1124: *ret = t; -: 1125: } else { 5741: 1126: tail->next = t; -: 1127: } -: 1128: tail = t; -: 1129: } else { 19988: 1130: free(t); -: 1131: } -: 1132: } -: 1133: return 0; -: 1134: } #####: 1135: *ret = NULL; #####: 1136: return 0; -: 1137:} -: 1138: -: 1139:// One more layer of processing on top of the regular ellipse. -: 1140:// Uses the clipping tree. -: 1141:// Used for producing ellipse derivatives such as arc, chord, pie, etc. -: 1142:typedef struct { -: 1143: ellipse_state st; -: 1144: clip_node* root; -: 1145: clip_node nodes[7]; -: 1146: int32_t node_count; -: 1147: event_list* head; -: 1148: int32_t y; -: 1149:} clip_ellipse_state; -: 1150: -: 1151:typedef void (*clip_ellipse_init)(clip_ellipse_state*, int32_t, int32_t, int32_t, float, float); -: 1152: function debug_clip_tree called 0 returned 0% blocks executed 0% #####: 1153:void debug_clip_tree(clip_node* root, int space) { #####: 1154: if (root == NULL) { branch 0 never executed branch 1 never executed -: 1155: return; -: 1156: } #####: 1157: if (root->type == CT_CLIP) { branch 0 never executed branch 1 never executed -: 1158: int t = space; #####: 1159: while (t--) { branch 0 never executed branch 1 never executed #####: 1160: fputc(' ', stderr); call 0 never executed -: 1161: } #####: 1162: fprintf(stderr, "clip %+fx%+fy%+f > 0\n", root->a, root->b, root->c); -: 1163: } else { #####: 1164: debug_clip_tree(root->l, space + 2); #####: 1165: int t = space; call 0 never executed #####: 1166: while (t--) { branch 0 never executed branch 1 never executed #####: 1167: fputc(' ', stderr); call 0 never executed -: 1168: } #####: 1169: fprintf(stderr, "%s\n", root->type == CT_AND ? "and" : "or"); branch 0 never executed branch 1 never executed #####: 1170: debug_clip_tree(root->r, space + 2); call 0 never executed -: 1171: } #####: 1172: if (space == 0) { branch 0 never executed branch 1 never executed #####: 1173: fputc('\n', stderr); call 0 never executed -: 1174: } -: 1175:} -: 1176: -: 1177:// Resulting angles will satisfy 0 <= al < 360, al <= ar <= al + 360 function normalize_angles called 96 returned 100% blocks executed 100% 96: 1178:void normalize_angles(float* al, float* ar) { 96: 1179: if (*ar - *al >= 360) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 1180: *al = 0; 1: 1181: *ar = 360; -: 1182: } else { 95: 1183: *al = fmod(*al < 0 ? 360 - (fmod(-*al, 360)) : *al, 360); branch 0 taken 20% (fallthrough) branch 1 taken 80% 95: 1184: *ar = *al + fmod(*ar < *al ? 360 - fmod(*al - *ar, 360) : *ar - *al, 360); branch 0 taken 39% (fallthrough) branch 1 taken 61% -: 1185: } 96: 1186:} -: 1187: -: 1188:// An arc with caps orthogonal to the ellipse curve. function arc_init called 13 returned 100% blocks executed 95% 13: 1189:void arc_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al, float ar) { 13: 1190: if (a < b) { branch 0 taken 15% (fallthrough) branch 1 taken 85% -: 1191: // transpose the coordinate system 2: 1192: arc_init(s, b, a, w, 90 - ar, 90 - al); call 0 returned 100% 2: 1193: ellipse_init(&s->st, a, b, w); call 0 returned 100% 2: 1194: clip_tree_transpose(s->root); call 0 returned 100% -: 1195: } else { -: 1196: // a >= b, based on "wide" ellipse 11: 1197: ellipse_init(&s->st, a, b, w); call 0 returned 100% -: 1198: 11: 1199: s->head = NULL; 11: 1200: s->node_count = 0; 11: 1201: normalize_angles(&al, &ar); call 0 returned 100% -: 1202: -: 1203: // building clipping tree, a lot of different cases 11: 1204: if (ar == al + 360) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1205: s->root = NULL; -: 1206: } else { 11: 1207: clip_node* lc = s->nodes + s->node_count++; 11: 1208: clip_node* rc = s->nodes + s->node_count++; 11: 1209: lc->l = lc->r = rc->l = rc->r = NULL; 11: 1210: lc->type = rc->type = CT_CLIP; 11: 1211: lc->a = -a * sin(al * M_PI / 180.0); 11: 1212: lc->b = b * cos(al * M_PI / 180.0); 11: 1213: lc->c = (a * a - b * b) * sin(al * M_PI / 90.0) / 2.0; 11: 1214: rc->a = a * sin(ar * M_PI / 180.0); 11: 1215: rc->b = -b * cos(ar * M_PI / 180.0); 11: 1216: rc->c = (b * b - a * a) * sin(ar * M_PI / 90.0) / 2.0; 11: 1217: if (fmod(al, 180) == 0 || fmod(ar, 180) == 0) { branch 0 taken 82% (fallthrough) branch 1 taken 18% branch 2 taken 11% (fallthrough) branch 3 taken 89% 3: 1218: s->root = s->nodes + s->node_count++; 3: 1219: s->root->l = lc; 3: 1220: s->root->r = rc; 3: 1221: s->root->type = ar - al < 180 ? CT_AND : CT_OR; 8: 1222: } else if (((int)(al / 180) + (int)(ar / 180)) % 2 == 1) { branch 0 taken 88% (fallthrough) branch 1 taken 13% 7: 1223: s->root = s->nodes + s->node_count++; 7: 1224: s->root->l = s->nodes + s->node_count++; 7: 1225: s->root->l->l = s->nodes + s->node_count++; 7: 1226: s->root->l->r = lc; 7: 1227: s->root->r = s->nodes + s->node_count++; 7: 1228: s->root->r->l = s->nodes + s->node_count++; 7: 1229: s->root->r->r = rc; 7: 1230: s->root->type = CT_OR; 7: 1231: s->root->l->type = CT_AND; 7: 1232: s->root->r->type = CT_AND; 7: 1233: s->root->l->l->type = CT_CLIP; 7: 1234: s->root->r->l->type = CT_CLIP; 7: 1235: s->root->l->l->l = s->root->l->l->r = NULL; 7: 1236: s->root->r->l->l = s->root->r->l->r = NULL; 7: 1237: s->root->l->l->a = s->root->l->l->c = 0; 7: 1238: s->root->r->l->a = s->root->r->l->c = 0; 7: 1239: s->root->l->l->b = (int)(al / 180) % 2 == 0 ? 1 : -1; branch 0 taken 14% (fallthrough) branch 1 taken 86% 7: 1240: s->root->r->l->b = (int)(ar / 180) % 2 == 0 ? 1 : -1; branch 0 taken 86% (fallthrough) branch 1 taken 14% -: 1241: } else { 1: 1242: s->root = s->nodes + s->node_count++; 1: 1243: s->root->l = s->nodes + s->node_count++; 1: 1244: s->root->r = s->nodes + s->node_count++; 1: 1245: s->root->type = s->root->l->type = ar - al < 180 ? CT_AND : CT_OR; 1: 1246: s->root->l->l = lc; 1: 1247: s->root->l->r = rc; 1: 1248: s->root->r->type = CT_CLIP; 1: 1249: s->root->r->l = s->root->r->r = NULL; 1: 1250: s->root->r->a = s->root->r->c = 0; 1: 1251: s->root->r->b = ar < 180 || ar > 540 ? 1 : -1; branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 1252: } -: 1253: } -: 1254: } 13: 1255:} -: 1256: -: 1257:// A chord line. function chord_line_init called 7 returned 100% blocks executed 100% 7: 1258:void chord_line_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al, float ar) { 7: 1259: ellipse_init(&s->st, a, b, a + b + 1); call 0 returned 100% -: 1260: 7: 1261: s->head = NULL; 7: 1262: s->node_count = 0; -: 1263: -: 1264: // line equation for chord 7: 1265: double xl = a * cos(al * M_PI / 180.0), xr = a * cos(ar * M_PI / 180.0); 7: 1266: double yl = b * sin(al * M_PI / 180.0), yr = b * sin(ar * M_PI / 180.0); 7: 1267: s->root = s->nodes + s->node_count++; 7: 1268: s->root->l = s->nodes + s->node_count++; 7: 1269: s->root->r = s->nodes + s->node_count++; 7: 1270: s->root->type = CT_AND; 7: 1271: s->root->l->type = s->root->r->type = CT_CLIP; 7: 1272: s->root->l->l = s->root->l->r = s->root->r->l = s->root->r->r = NULL; 7: 1273: s->root->l->a = yr - yl; 7: 1274: s->root->l->b = xl - xr; 7: 1275: s->root->l->c = -(s->root->l->a * xl + s->root->l->b * yl); 7: 1276: s->root->r->a = -s->root->l->a; 7: 1277: s->root->r->b = -s->root->l->b; 7: 1278: s->root->r->c = 2 * w * sqrt(pow(s->root->l->a, 2.0) + pow(s->root->l->b, 2.0)) - s->root->l->c; 7: 1279:} -: 1280: -: 1281:// Pie side. function pie_side_init called 14 returned 100% blocks executed 100% 14: 1282:void pie_side_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al, float _) { 14: 1283: ellipse_init(&s->st, a, b, a + b + 1); call 0 returned 100% -: 1284: 14: 1285: s->head = NULL; 14: 1286: s->node_count = 0; -: 1287: 14: 1288: double xl = a * cos(al * M_PI / 180.0); 14: 1289: double yl = b * sin(al * M_PI / 180.0); 14: 1290: double a1 = -yl; 14: 1291: double b1 = xl; 14: 1292: double c1 = w * sqrt(a1 * a1 + b1 * b1); -: 1293: 14: 1294: s->root = s->nodes + s->node_count++; 14: 1295: s->root->type = CT_AND; 14: 1296: s->root->l = s->nodes + s->node_count++; 14: 1297: s->root->l->type = CT_AND; -: 1298: -: 1299: clip_node* cnode; 14: 1300: cnode = s->nodes + s->node_count++; 14: 1301: cnode->l = cnode->r = NULL; 14: 1302: cnode->type = CT_CLIP; 14: 1303: cnode->a = a1; 14: 1304: cnode->b = b1; 14: 1305: cnode->c = c1; 14: 1306: s->root->l->l = cnode; 14: 1307: cnode = s->nodes + s->node_count++; 14: 1308: cnode->l = cnode->r = NULL; 14: 1309: cnode->type = CT_CLIP; 14: 1310: cnode->a = -a1; 14: 1311: cnode->b = -b1; 14: 1312: cnode->c = c1; 14: 1313: s->root->l->r = cnode; 14: 1314: cnode = s->nodes + s->node_count++; 14: 1315: cnode->l = cnode->r = NULL; 14: 1316: cnode->type = CT_CLIP; 14: 1317: cnode->a = b1; 14: 1318: cnode->b = -a1; 14: 1319: cnode->c = 0; 14: 1320: s->root->r = cnode; 14: 1321:} -: 1322: -: 1323:// A chord. function chord_init called 20 returned 100% blocks executed 100% 20: 1324:void chord_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al, float ar) { 20: 1325: ellipse_init(&s->st, a, b, w); call 0 returned 100% -: 1326: 20: 1327: s->head = NULL; 20: 1328: s->node_count = 0; -: 1329: -: 1330: // line equation for chord 20: 1331: double xl = a * cos(al * M_PI / 180.0), xr = a * cos(ar * M_PI / 180.0); 20: 1332: double yl = b * sin(al * M_PI / 180.0), yr = b * sin(ar * M_PI / 180.0); 20: 1333: s->root = s->nodes + s->node_count++; 20: 1334: s->root->l = s->root->r = NULL; 20: 1335: s->root->type = CT_CLIP; 20: 1336: s->root->a = yr - yl; 20: 1337: s->root->b = xl - xr; 20: 1338: s->root->c = -(s->root->a * xl + s->root->b * yl); 20: 1339:} -: 1340: -: 1341:// A pie. Can also be used to draw an arc with ugly sharp caps. function pie_init called 53 returned 100% blocks executed 100% 53: 1342:void pie_init(clip_ellipse_state* s, int32_t a, int32_t b, int32_t w, float al, float ar) { 53: 1343: ellipse_init(&s->st, a, b, w); call 0 returned 100% -: 1344: 53: 1345: s->head = NULL; 53: 1346: s->node_count = 0; -: 1347: -: 1348: // line equations for pie sides 53: 1349: double xl = a * cos(al * M_PI / 180.0), xr = a * cos(ar * M_PI / 180.0); 53: 1350: double yl = b * sin(al * M_PI / 180.0), yr = b * sin(ar * M_PI / 180.0); -: 1351: 53: 1352: clip_node* lc = s->nodes + s->node_count++; 53: 1353: clip_node* rc = s->nodes + s->node_count++; 53: 1354: lc->l = lc->r = rc->l = rc->r = NULL; 53: 1355: lc->type = rc->type = CT_CLIP; 53: 1356: lc->a = -yl; 53: 1357: lc->b = xl; 53: 1358: lc->c = 0; 53: 1359: rc->a = yr; 53: 1360: rc->b = -xr; 53: 1361: rc->c = 0; -: 1362: 53: 1363: s->root = s->nodes + s->node_count++; 53: 1364: s->root->l = lc; 53: 1365: s->root->r = rc; 53: 1366: s->root->type = ar - al < 180 ? CT_AND : CT_OR; 53: 1367:} -: 1368: function clip_ellipse_free called 105 returned 100% blocks executed 75% 105: 1369:void clip_ellipse_free(clip_ellipse_state* s) { 210: 1370: while (s->head != NULL) { branch 0 taken 0% branch 1 taken 100% (fallthrough) #####: 1371: event_list* t = s->head; #####: 1372: s->head = s->head->next; #####: 1373: free(t); -: 1374: } 105: 1375:} -: 1376: function clip_ellipse_next called 5641 returned 100% blocks executed 100% 5641: 1377:int8_t clip_ellipse_next(clip_ellipse_state* s, int32_t* ret_x0, int32_t* ret_y, int32_t* ret_x1) { -: 1378: int32_t x0, y, x1; 23962: 1379: while (s->head == NULL && ellipse_next(&s->st, &x0, &y, &x1) >= 0) { branch 0 taken 70% (fallthrough) branch 1 taken 30% call 2 returned 100% branch 3 taken 99% branch 4 taken 1% (fallthrough) 12680: 1380: if (clip_tree_do_clip(s->root, x0, y, x1, &s->head) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1381: return -2; -: 1382: } 12680: 1383: s->y = y; -: 1384: } 5641: 1385: if (s->head != NULL) { branch 0 taken 98% (fallthrough) branch 1 taken 2% 5536: 1386: *ret_y = s->y; 5536: 1387: event_list* t = s->head; 5536: 1388: s->head = s->head->next; 5536: 1389: *ret_x0 = t->x; 5536: 1390: free(t); 5536: 1391: t = s->head; -: 1392: assert(t != NULL); 5536: 1393: s->head = s->head->next; 5536: 1394: *ret_x1 = t->x; 5536: 1395: free(t); 5536: 1396: return 0; -: 1397: } -: 1398: return -1; -: 1399:} -: 1400: -: 1401:static int function ellipseNew called 2099 returned 100% blocks executed 100% 2099: 1402:ellipseNew(Imaging im, int x0, int y0, int x1, int y1, -: 1403: const void* ink_, int fill, -: 1404: int width, int op) -: 1405:{ -: 1406: DRAW* draw; -: 1407: INT32 ink; 2099: 1408: DRAWINIT(); branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 99% (fallthrough) branch 3 taken 1% -: 1409: 2099: 1410: int a = x1 - x0; 2099: 1411: int b = y1 - y0; 2099: 1412: if (a < 0 || b < 0) { branch 0 taken 97% (fallthrough) branch 1 taken 3% branch 2 taken 97% (fallthrough) branch 3 taken 3% -: 1413: return 0; -: 1414: } 1973: 1415: if (fill) { branch 0 taken 51% (fallthrough) branch 1 taken 49% 999: 1416: width = a + b; -: 1417: } -: 1418: -: 1419: ellipse_state st; 1973: 1420: ellipse_init(&st, a, b, width); call 0 returned 100% -: 1421: int32_t X0, Y, X1; 68963: 1422: while (ellipse_next(&st, &X0, &Y, &X1) != -1) { call 0 returned 100% branch 1 taken 97% branch 2 taken 3% (fallthrough) 65017: 1423: draw->hline(im, x0 + (X0 + a) / 2, y0 + (Y + b) / 2, x0 + (X1 + a) / 2, ink); call 0 returned 100% -: 1424: } -: 1425: return 0; -: 1426:} -: 1427: -: 1428:static int function clipEllipseNew called 105 returned 100% blocks executed 94% 105: 1429:clipEllipseNew(Imaging im, int x0, int y0, int x1, int y1, -: 1430: float start, float end, -: 1431: const void* ink_, int width, int op, clip_ellipse_init init) -: 1432:{ -: 1433: DRAW* draw; -: 1434: INT32 ink; 105: 1435: DRAWINIT(); branch 0 taken 11% (fallthrough) branch 1 taken 89% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 1436: 105: 1437: int a = x1 - x0; 105: 1438: int b = y1 - y0; 105: 1439: if (a < 0 || b < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 1440: return 0; -: 1441: } -: 1442: -: 1443: clip_ellipse_state st; 105: 1444: init(&st, a, b, width, start, end); call 0 returned 100% -: 1445: // debug_clip_tree(st.root, 0); -: 1446: int32_t X0, Y, X1; -: 1447: int next_code; 5746: 1448: while ((next_code = clip_ellipse_next(&st, &X0, &Y, &X1)) >= 0) { call 0 returned 100% branch 1 taken 98% branch 2 taken 2% (fallthrough) 5536: 1449: draw->hline(im, x0 + (X0 + a) / 2, y0 + (Y + b) / 2, x0 + (X1 + a) / 2, ink); call 0 returned 100% -: 1450: } 105: 1451: clip_ellipse_free(&st); call 0 returned 100% 105: 1452: return next_code == -1 ? 0 : -1; branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1453:} -: 1454:static int -: 1455:arcNew(Imaging im, int x0, int y0, int x1, int y1, -: 1456: float start, float end, -: 1457: const void* ink_, int width, int op) -: 1458:{ 11: 1459: return clipEllipseNew(im, x0, y0, x1, y1, start, end, ink_, width, op, arc_init); -: 1460:} -: 1461: -: 1462:static int -: 1463:chordNew(Imaging im, int x0, int y0, int x1, int y1, -: 1464: float start, float end, -: 1465: const void* ink_, int width, int op) -: 1466:{ 20: 1467: return clipEllipseNew(im, x0, y0, x1, y1, start, end, ink_, width, op, chord_init); -: 1468:} -: 1469: -: 1470:static int -: 1471:chordLineNew(Imaging im, int x0, int y0, int x1, int y1, -: 1472: float start, float end, -: 1473: const void* ink_, int width, int op) -: 1474:{ 7: 1475: return clipEllipseNew(im, x0, y0, x1, y1, start, end, ink_, width, op, chord_line_init); call 0 returned 100% -: 1476:} -: 1477: -: 1478:static int -: 1479:pieNew(Imaging im, int x0, int y0, int x1, int y1, -: 1480: float start, float end, -: 1481: const void* ink_, int width, int op) -: 1482:{ 53: 1483: return clipEllipseNew(im, x0, y0, x1, y1, start, end, ink_, width, op, pie_init); -: 1484:} -: 1485: -: 1486:static int -: 1487:pieSideNew(Imaging im, int x0, int y0, int x1, int y1, -: 1488: float start, -: 1489: const void* ink_, int width, int op) -: 1490:{ 14: 1491: return clipEllipseNew(im, x0, y0, x1, y1, start, 0, ink_, width, op, pie_side_init); call 0 returned 100% call 1 returned 100% -: 1492:} -: 1493: -: 1494:int function ImagingDrawEllipse called 2092 returned 100% blocks executed 100% 2092: 1495:ImagingDrawEllipse(Imaging im, int x0, int y0, int x1, int y1, -: 1496: const void* ink, int fill, int width, int op) -: 1497:{ 2092: 1498: return ellipseNew(im, x0, y0, x1, y1, ink, fill, width, op); call 0 returned 100% -: 1499:} -: 1500: -: 1501:int function ImagingDrawArc called 12 returned 100% blocks executed 100% 12: 1502:ImagingDrawArc(Imaging im, int x0, int y0, int x1, int y1, -: 1503: float start, float end, const void* ink, int width, int op) -: 1504:{ 12: 1505: normalize_angles(&start, &end); call 0 returned 100% 12: 1506: if (start + 360 == end) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 1: 1507: return ImagingDrawEllipse(im, x0, y0, x1, y1, ink, 0, width, op); call 0 returned 100% -: 1508: } 11: 1509: if (start == end) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1510: return 0; -: 1511: } 22: 1512: return arcNew(im, x0, y0, x1, y1, start, end, ink, width, op); call 0 returned 100% -: 1513:} -: 1514: -: 1515: -: 1516:int function ImagingDrawChord called 20 returned 100% blocks executed 92% 20: 1517:ImagingDrawChord(Imaging im, int x0, int y0, int x1, int y1, -: 1518: float start, float end, const void* ink, int fill, -: 1519: int width, int op) -: 1520:{ 20: 1521: normalize_angles(&start, &end); call 0 returned 100% 20: 1522: if (start + 360 == end) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1523: return ImagingDrawEllipse(im, x0, y0, x1, y1, ink, fill, width, op); call 0 never executed -: 1524: } 20: 1525: if (start == end) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1526: return 0; -: 1527: } 20: 1528: if (fill) { branch 0 taken 65% (fallthrough) branch 1 taken 35% 26: 1529: return chordNew(im, x0, y0, x1, y1, start, end, ink, x1 - x0 + y1 - y0 + 1, op); call 0 returned 100% -: 1530: } else { 14: 1531: if (chordLineNew(im, x0, y0, x1, y1, start, end, ink, width, op)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1532: return -1; -: 1533: } 14: 1534: return chordNew(im, x0, y0, x1, y1, start, end, ink, width, op); call 0 returned 100% -: 1535: } -: 1536:} -: 1537: -: 1538: -: 1539:int function ImagingDrawPieslice called 53 returned 100% blocks executed 93% 53: 1540:ImagingDrawPieslice(Imaging im, int x0, int y0, int x1, int y1, -: 1541: float start, float end, const void* ink, int fill, -: 1542: int width, int op) -: 1543:{ 53: 1544: normalize_angles(&start, &end); call 0 returned 100% 53: 1545: if (start + 360 == end) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1546: return ellipseNew(im, x0, y0, x1, y1, ink, fill, width, op); call 0 never executed -: 1547: } 53: 1548: if (start == end) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1549: return 0; -: 1550: } 53: 1551: if (fill) { branch 0 taken 87% (fallthrough) branch 1 taken 13% 92: 1552: return pieNew(im, x0, y0, x1, y1, start, end, ink, x1 + y1 - x0 - y0, op); call 0 returned 100% -: 1553: } else { 14: 1554: if (pieSideNew(im, x0, y0, x1, y1, start, ink, width, op)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1555: return -1; -: 1556: } 14: 1557: if (pieSideNew(im, x0, y0, x1, y1, end, ink, width, op)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1558: return -1; -: 1559: } 7: 1560: int xc = lround((x0 + x1 - width) / 2.0), yc = lround((y0 + y1 - width) / 2.0); 7: 1561: ellipseNew(im, xc, yc, xc + width - 1, yc + width - 1, ink, 1, 0, op); call 0 returned 100% 14: 1562: return pieNew(im, x0, y0, x1, y1, start, end, ink, width, op); call 0 returned 100% -: 1563: } -: 1564:} -: 1565: -: 1566: -: 1567:/* -------------------------------------------------------------------- */ -: 1568: -: 1569:/* experimental level 2 ("arrow") graphics stuff. this implements -: 1570: portions of the arrow api on top of the Edge structure. the -: 1571: semantics are ok, except that "curve" flattens the bezier curves by -: 1572: itself */ -: 1573: -: 1574:struct ImagingOutlineInstance { -: 1575: -: 1576: float x0, y0; -: 1577: -: 1578: float x, y; -: 1579: -: 1580: int count; -: 1581: Edge *edges; -: 1582: -: 1583: int size; -: 1584: -: 1585:}; -: 1586: -: 1587: -: 1588:ImagingOutline function ImagingOutlineNew called 3 returned 100% blocks executed 80% 3: 1589:ImagingOutlineNew(void) -: 1590:{ -: 1591: ImagingOutline outline; -: 1592: 3: 1593: outline = calloc(1, sizeof(struct ImagingOutlineInstance)); 3: 1594: if (!outline) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1595: return (ImagingOutline) ImagingError_MemoryError(); call 0 never executed -: 1596: } -: 1597: 3: 1598: outline->edges = NULL; 3: 1599: outline->count = outline->size = 0; -: 1600: 3: 1601: ImagingOutlineMove(outline, 0, 0); call 0 returned 100% -: 1602: 3: 1603: return outline; -: 1604:} -: 1605: -: 1606:void function ImagingOutlineDelete called 3 returned 100% blocks executed 100% 3: 1607:ImagingOutlineDelete(ImagingOutline outline) -: 1608:{ 3: 1609: if (!outline) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1610: return; -: 1611: } -: 1612: 3: 1613: if (outline->edges) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 3: 1614: free(outline->edges); -: 1615: } -: 1616: 3: 1617: free(outline); -: 1618:} -: 1619: -: 1620: -: 1621:static Edge* function allocate called 6 returned 100% blocks executed 78% 6: 1622:allocate(ImagingOutline outline, int extra) -: 1623:{ -: 1624: Edge* e; -: 1625: 6: 1626: if (outline->count + extra > outline->size) { branch 0 taken 50% (fallthrough) branch 1 taken 50% -: 1627: /* expand outline buffer */ 3: 1628: outline->size += extra + 25; 3: 1629: if (!outline->edges) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1630: /* malloc check ok, uses calloc for overflow */ 3: 1631: e = calloc(outline->size, sizeof(Edge)); -: 1632: } else { #####: 1633: if (outline->size > INT_MAX / sizeof(Edge)) { branch 0 never executed branch 1 never executed -: 1634: return NULL; -: 1635: } -: 1636: /* malloc check ok, overflow checked above */ #####: 1637: e = realloc(outline->edges, outline->size * sizeof(Edge)); -: 1638: } 3: 1639: if (!e) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1640: return NULL; -: 1641: } 3: 1642: outline->edges = e; -: 1643: } -: 1644: 6: 1645: e = outline->edges + outline->count; -: 1646: 6: 1647: outline->count += extra; -: 1648: 6: 1649: return e; -: 1650:} -: 1651: -: 1652:int function ImagingOutlineMove called 6 returned 100% blocks executed 100% 6: 1653:ImagingOutlineMove(ImagingOutline outline, float x0, float y0) -: 1654:{ 6: 1655: outline->x = outline->x0 = x0; 6: 1656: outline->y = outline->y0 = y0; -: 1657: 6: 1658: return 0; -: 1659:} -: 1660: -: 1661:int function ImagingOutlineLine called 3 returned 100% blocks executed 100% 3: 1662:ImagingOutlineLine(ImagingOutline outline, float x1, float y1) -: 1663:{ -: 1664: Edge* e; -: 1665: 3: 1666: e = allocate(outline, 1); call 0 returned 100% 3: 1667: if (!e) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1668: return -1; /* out of memory */ -: 1669: } -: 1670: 3: 1671: add_edge(e, (int) outline->x, (int) outline->y, (int) x1, (int) y1); call 0 returned 100% -: 1672: 3: 1673: outline->x = x1; 3: 1674: outline->y = y1; -: 1675: 3: 1676: return 0; -: 1677:} -: 1678: -: 1679:int function ImagingOutlineCurve called 3 returned 100% blocks executed 100% 3: 1680:ImagingOutlineCurve(ImagingOutline outline, float x1, float y1, -: 1681: float x2, float y2, float x3, float y3) -: 1682:{ -: 1683: Edge* e; -: 1684: int i; -: 1685: float xo, yo; -: 1686: -: 1687:#define STEPS 32 -: 1688: 3: 1689: e = allocate(outline, STEPS); call 0 returned 100% 3: 1690: if (!e) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1691: return -1; /* out of memory */ -: 1692: } -: 1693: 3: 1694: xo = outline->x; 3: 1695: yo = outline->y; -: 1696: -: 1697: /* flatten the bezier segment */ -: 1698: 99: 1699: for (i = 1; i <= STEPS; i++) { branch 0 taken 97% branch 1 taken 3% (fallthrough) -: 1700: 96: 1701: float t = ((float) i) / STEPS; 96: 1702: float t2 = t*t; 96: 1703: float t3 = t2*t; -: 1704: 96: 1705: float u = 1.0F - t; 96: 1706: float u2 = u*u; 96: 1707: float u3 = u2*u; -: 1708: 96: 1709: float x = outline->x*u3 + 3*(x1*t*u2 + x2*t2*u) + x3*t3 + 0.5; 96: 1710: float y = outline->y*u3 + 3*(y1*t*u2 + y2*t2*u) + y3*t3 + 0.5; -: 1711: 96: 1712: add_edge(e++, xo, yo, (int) x, (int) y); call 0 returned 100% -: 1713: 96: 1714: xo = x, yo = y; -: 1715: -: 1716: } -: 1717: 3: 1718: outline->x = xo; 3: 1719: outline->y = yo; -: 1720: 3: 1721: return 0; -: 1722:} -: 1723: -: 1724:int function ImagingOutlineClose called 8 returned 100% blocks executed 75% 8: 1725:ImagingOutlineClose(ImagingOutline outline) -: 1726:{ 8: 1727: if (outline->x == outline->x0 && outline->y == outline->y0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 1728: return 0; -: 1729: } #####: 1730: return ImagingOutlineLine(outline, outline->x0, outline->y0); call 0 never executed -: 1731:} -: 1732: -: 1733:int function ImagingOutlineTransform called 0 returned 0% blocks executed 0% #####: 1734:ImagingOutlineTransform(ImagingOutline outline, double a[6]) -: 1735:{ -: 1736: Edge *eIn; -: 1737: Edge *eOut; -: 1738: int i, n; -: 1739: int x0, y0, x1, y1; -: 1740: int X0, Y0, X1, Y1; -: 1741: #####: 1742: double a0 = a[0]; double a1 = a[1]; double a2 = a[2]; #####: 1743: double a3 = a[3]; double a4 = a[4]; double a5 = a[5]; -: 1744: #####: 1745: eIn = outline->edges; #####: 1746: n = outline->count; -: 1747: -: 1748: /* FIXME: ugly! */ #####: 1749: outline->edges = NULL; #####: 1750: outline->count = outline->size = 0; -: 1751: #####: 1752: eOut = allocate(outline, n); call 0 never executed #####: 1753: if (!eOut) { branch 0 never executed branch 1 never executed #####: 1754: outline->edges = eIn; #####: 1755: outline->count = outline->size = n; #####: 1756: ImagingError_MemoryError(); call 0 never executed #####: 1757: return -1; -: 1758: } -: 1759: #####: 1760: for (i = 0; i < n; i++) { branch 0 never executed branch 1 never executed -: 1761: #####: 1762: x0 = eIn->x0; #####: 1763: y0 = eIn->y0; -: 1764: -: 1765: /* FIXME: ouch! */ #####: 1766: if (eIn->x0 == eIn->xmin) { branch 0 never executed branch 1 never executed #####: 1767: x1 = eIn->xmax; -: 1768: } else { -: 1769: x1 = eIn->xmin; -: 1770: } #####: 1771: if (eIn->y0 == eIn->ymin) { branch 0 never executed branch 1 never executed #####: 1772: y1 = eIn->ymax; -: 1773: } else { -: 1774: y1 = eIn->ymin; -: 1775: } -: 1776: -: 1777: /* full moon tonight! if this doesn't work, you may need to -: 1778: upgrade your compiler (make sure you have the right service -: 1779: pack) */ -: 1780: #####: 1781: X0 = (int) (a0*x0 + a1*y0 + a2); #####: 1782: Y0 = (int) (a3*x0 + a4*y0 + a5); #####: 1783: X1 = (int) (a0*x1 + a1*y1 + a2); #####: 1784: Y1 = (int) (a3*x1 + a4*y1 + a5); -: 1785: #####: 1786: add_edge(eOut, X0, Y0, X1, Y1); call 0 never executed -: 1787: #####: 1788: eIn++; #####: 1789: eOut++; -: 1790: -: 1791: } -: 1792: #####: 1793: free(eIn); -: 1794: #####: 1795: return 0; -: 1796:} -: 1797: -: 1798:int function ImagingDrawOutline called 8 returned 100% blocks executed 100% 8: 1799:ImagingDrawOutline(Imaging im, ImagingOutline outline, const void* ink_, -: 1800: int fill, int op) -: 1801:{ -: 1802: DRAW* draw; -: 1803: INT32 ink; -: 1804: 8: 1805: DRAWINIT(); branch 0 taken 38% (fallthrough) branch 1 taken 63% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 1806: 8: 1807: draw->polygon(im, outline->count, outline->edges, ink, 0); call 0 returned 100% -: 1808: 8: 1809: return 0; -: 1810:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#display.c.gcov -: 0:Source:src/display.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/display.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/display.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * display support (and other windows-related stuff) -: 5: * -: 6: * History: -: 7: * 1996-05-13 fl Windows DIB support -: 8: * 1996-05-21 fl Added palette stuff -: 9: * 1996-05-28 fl Added display_mode stuff -: 10: * 1997-09-21 fl Added draw primitive -: 11: * 2001-09-17 fl Added ImagingGrabScreen (from _grabscreen.c) -: 12: * 2002-05-12 fl Added ImagingListWindows -: 13: * 2002-11-19 fl Added clipboard support -: 14: * 2002-11-25 fl Added GetDC/ReleaseDC helpers -: 15: * 2003-05-21 fl Added create window support (including window callback) -: 16: * 2003-09-05 fl Added fromstring/tostring methods -: 17: * 2009-03-14 fl Added WMF support (from pilwmf) -: 18: * -: 19: * Copyright (c) 1997-2003 by Secret Labs AB. -: 20: * Copyright (c) 1996-1997 by Fredrik Lundh. -: 21: * -: 22: * See the README file for information on usage and redistribution. -: 23: */ -: 24: -: 25:#define PY_SSIZE_T_CLEAN -: 26:#include "Python.h" -: 27: -: 28:#include "libImaging/Imaging.h" -: 29: -: 30:/* -------------------------------------------------------------------- */ -: 31:/* Windows DIB support */ -: 32: -: 33:#ifdef _WIN32 -: 34: -: 35:#include "libImaging/ImDib.h" -: 36: -: 37:#if SIZEOF_VOID_P == 8 -: 38:#define F_HANDLE "K" -: 39:#else -: 40:#define F_HANDLE "k" -: 41:#endif -: 42: -: 43:typedef struct { -: 44: PyObject_HEAD -: 45: ImagingDIB dib; -: 46:} ImagingDisplayObject; -: 47: -: 48:static PyTypeObject ImagingDisplayType; -: 49: -: 50:static ImagingDisplayObject* -: 51:_new(const char* mode, int xsize, int ysize) -: 52:{ -: 53: ImagingDisplayObject *display; -: 54: -: 55: if (PyType_Ready(&ImagingDisplayType) < 0) { -: 56: return NULL; -: 57: } -: 58: -: 59: display = PyObject_New(ImagingDisplayObject, &ImagingDisplayType); -: 60: if (display == NULL) { -: 61: return NULL; -: 62: } -: 63: -: 64: display->dib = ImagingNewDIB(mode, xsize, ysize); -: 65: if (!display->dib) { -: 66: Py_DECREF(display); -: 67: return NULL; -: 68: } -: 69: -: 70: return display; -: 71:} -: 72: -: 73:static void -: 74:_delete(ImagingDisplayObject* display) -: 75:{ -: 76: if (display->dib) { -: 77: ImagingDeleteDIB(display->dib); -: 78: } -: 79: PyObject_Del(display); -: 80:} -: 81: -: 82:static PyObject* -: 83:_expose(ImagingDisplayObject* display, PyObject* args) -: 84:{ -: 85: HDC hdc; -: 86: if (!PyArg_ParseTuple(args, F_HANDLE, &hdc)) { -: 87: return NULL; -: 88: } -: 89: -: 90: ImagingExposeDIB(display->dib, hdc); -: 91: -: 92: Py_INCREF(Py_None); -: 93: return Py_None; -: 94:} -: 95: -: 96:static PyObject* -: 97:_draw(ImagingDisplayObject* display, PyObject* args) -: 98:{ -: 99: HDC hdc; -: 100: int dst[4]; -: 101: int src[4]; -: 102: if (!PyArg_ParseTuple(args, F_HANDLE "(iiii)(iiii)", &hdc, -: 103: dst+0, dst+1, dst+2, dst+3, -: 104: src+0, src+1, src+2, src+3)) { -: 105: return NULL; -: 106: } -: 107: -: 108: ImagingDrawDIB(display->dib, hdc, dst, src); -: 109: -: 110: Py_INCREF(Py_None); -: 111: return Py_None; -: 112:} -: 113: -: 114:extern Imaging PyImaging_AsImaging(PyObject *op); -: 115: -: 116:static PyObject* -: 117:_paste(ImagingDisplayObject* display, PyObject* args) -: 118:{ -: 119: Imaging im; -: 120: -: 121: PyObject* op; -: 122: int xy[4]; -: 123: xy[0] = xy[1] = xy[2] = xy[3] = 0; -: 124: if (!PyArg_ParseTuple(args, "O|(iiii)", &op, xy+0, xy+1, xy+2, xy+3)) { -: 125: return NULL; -: 126: } -: 127: im = PyImaging_AsImaging(op); -: 128: if (!im) { -: 129: return NULL; -: 130: } -: 131: -: 132: if (xy[2] <= xy[0]) { -: 133: xy[2] = xy[0] + im->xsize; -: 134: } -: 135: if (xy[3] <= xy[1]) { -: 136: xy[3] = xy[1] + im->ysize; -: 137: } -: 138: -: 139: ImagingPasteDIB(display->dib, im, xy); -: 140: -: 141: Py_INCREF(Py_None); -: 142: return Py_None; -: 143:} -: 144: -: 145:static PyObject* -: 146:_query_palette(ImagingDisplayObject* display, PyObject* args) -: 147:{ -: 148: HDC hdc; -: 149: int status; -: 150: -: 151: if (!PyArg_ParseTuple(args, F_HANDLE, &hdc)) { -: 152: return NULL; -: 153: } -: 154: -: 155: status = ImagingQueryPaletteDIB(display->dib, hdc); -: 156: -: 157: return Py_BuildValue("i", status); -: 158:} -: 159: -: 160:static PyObject* -: 161:_getdc(ImagingDisplayObject* display, PyObject* args) -: 162:{ -: 163: HWND window; -: 164: HDC dc; -: 165: -: 166: if (!PyArg_ParseTuple(args, F_HANDLE, &window)) { -: 167: return NULL; -: 168: } -: 169: -: 170: dc = GetDC(window); -: 171: if (!dc) { -: 172: PyErr_SetString(PyExc_OSError, "cannot create dc"); -: 173: return NULL; -: 174: } -: 175: -: 176: return Py_BuildValue(F_HANDLE, dc); -: 177:} -: 178: -: 179:static PyObject* -: 180:_releasedc(ImagingDisplayObject* display, PyObject* args) -: 181:{ -: 182: HWND window; -: 183: HDC dc; -: 184: -: 185: if (!PyArg_ParseTuple(args, F_HANDLE F_HANDLE, &window, &dc)) { -: 186: return NULL; -: 187: } -: 188: -: 189: ReleaseDC(window, dc); -: 190: -: 191: Py_INCREF(Py_None); -: 192: return Py_None; -: 193:} -: 194: -: 195:static PyObject* -: 196:_frombytes(ImagingDisplayObject* display, PyObject* args) -: 197:{ -: 198: char* ptr; -: 199: Py_ssize_t bytes; -: 200: -: 201: if (!PyArg_ParseTuple(args, "y#:frombytes", &ptr, &bytes)) { -: 202: return NULL; -: 203: } -: 204: -: 205: if (display->dib->ysize * display->dib->linesize != bytes) { -: 206: PyErr_SetString(PyExc_ValueError, "wrong size"); -: 207: return NULL; -: 208: } -: 209: -: 210: memcpy(display->dib->bits, ptr, bytes); -: 211: -: 212: Py_INCREF(Py_None); -: 213: return Py_None; -: 214:} -: 215: -: 216:static PyObject* -: 217:_tobytes(ImagingDisplayObject* display, PyObject* args) -: 218:{ -: 219: if (!PyArg_ParseTuple(args, ":tobytes")) { -: 220: return NULL; -: 221: } -: 222: -: 223: return PyBytes_FromStringAndSize( -: 224: display->dib->bits, display->dib->ysize * display->dib->linesize -: 225: ); -: 226:} -: 227: -: 228:static struct PyMethodDef methods[] = { -: 229: {"draw", (PyCFunction)_draw, 1}, -: 230: {"expose", (PyCFunction)_expose, 1}, -: 231: {"paste", (PyCFunction)_paste, 1}, -: 232: {"query_palette", (PyCFunction)_query_palette, 1}, -: 233: {"getdc", (PyCFunction)_getdc, 1}, -: 234: {"releasedc", (PyCFunction)_releasedc, 1}, -: 235: {"frombytes", (PyCFunction)_frombytes, 1}, -: 236: {"tobytes", (PyCFunction)_tobytes, 1}, -: 237: {NULL, NULL} /* sentinel */ -: 238:}; -: 239: -: 240:static PyObject* -: 241:_getattr_mode(ImagingDisplayObject* self, void* closure) -: 242:{ -: 243: return Py_BuildValue("s", self->dib->mode); -: 244:} -: 245: -: 246:static PyObject* -: 247:_getattr_size(ImagingDisplayObject* self, void* closure) -: 248:{ -: 249: return Py_BuildValue("ii", self->dib->xsize, self->dib->ysize); -: 250:} -: 251: -: 252:static struct PyGetSetDef getsetters[] = { -: 253: { "mode", (getter) _getattr_mode }, -: 254: { "size", (getter) _getattr_size }, -: 255: { NULL } -: 256:}; -: 257: -: 258:static PyTypeObject ImagingDisplayType = { -: 259: PyVarObject_HEAD_INIT(NULL, 0) -: 260: "ImagingDisplay", /*tp_name*/ -: 261: sizeof(ImagingDisplayObject),/*tp_size*/ -: 262: 0, /*tp_itemsize*/ -: 263: /* methods */ -: 264: (destructor)_delete, /*tp_dealloc*/ -: 265: 0, /*tp_print*/ -: 266: 0, /*tp_getattr*/ -: 267: 0, /*tp_setattr*/ -: 268: 0, /*tp_compare*/ -: 269: 0, /*tp_repr*/ -: 270: 0, /*tp_as_number */ -: 271: 0, /*tp_as_sequence */ -: 272: 0, /*tp_as_mapping */ -: 273: 0, /*tp_hash*/ -: 274: 0, /*tp_call*/ -: 275: 0, /*tp_str*/ -: 276: 0, /*tp_getattro*/ -: 277: 0, /*tp_setattro*/ -: 278: 0, /*tp_as_buffer*/ -: 279: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 280: 0, /*tp_doc*/ -: 281: 0, /*tp_traverse*/ -: 282: 0, /*tp_clear*/ -: 283: 0, /*tp_richcompare*/ -: 284: 0, /*tp_weaklistoffset*/ -: 285: 0, /*tp_iter*/ -: 286: 0, /*tp_iternext*/ -: 287: methods, /*tp_methods*/ -: 288: 0, /*tp_members*/ -: 289: getsetters, /*tp_getset*/ -: 290:}; -: 291: -: 292:PyObject* -: 293:PyImaging_DisplayWin32(PyObject* self, PyObject* args) -: 294:{ -: 295: ImagingDisplayObject* display; -: 296: char *mode; -: 297: int xsize, ysize; -: 298: -: 299: if (!PyArg_ParseTuple(args, "s(ii)", &mode, &xsize, &ysize)) { -: 300: return NULL; -: 301: } -: 302: -: 303: display = _new(mode, xsize, ysize); -: 304: if (display == NULL) { -: 305: return NULL; -: 306: } -: 307: -: 308: return (PyObject*) display; -: 309:} -: 310: -: 311:PyObject* -: 312:PyImaging_DisplayModeWin32(PyObject* self, PyObject* args) -: 313:{ -: 314: char *mode; -: 315: int size[2]; -: 316: -: 317: mode = ImagingGetModeDIB(size); -: 318: -: 319: return Py_BuildValue("s(ii)", mode, size[0], size[1]); -: 320:} -: 321: -: 322:/* -------------------------------------------------------------------- */ -: 323:/* Windows screen grabber */ -: 324: -: 325:typedef HANDLE(__stdcall* Func_SetThreadDpiAwarenessContext)(HANDLE); -: 326: -: 327:PyObject* -: 328:PyImaging_GrabScreenWin32(PyObject* self, PyObject* args) -: 329:{ -: 330: int x = 0, y = 0, width, height; -: 331: int includeLayeredWindows = 0, all_screens = 0; -: 332: HBITMAP bitmap; -: 333: BITMAPCOREHEADER core; -: 334: HDC screen, screen_copy; -: 335: DWORD rop; -: 336: PyObject* buffer; -: 337: HANDLE dpiAwareness; -: 338: HMODULE user32; -: 339: Func_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContext_function; -: 340: -: 341: if (!PyArg_ParseTuple(args, "|ii", &includeLayeredWindows, &all_screens)) { -: 342: return NULL; -: 343: } -: 344: -: 345: /* step 1: create a memory DC large enough to hold the -: 346: entire screen */ -: 347: -: 348: screen = CreateDC("DISPLAY", NULL, NULL, NULL); -: 349: screen_copy = CreateCompatibleDC(screen); -: 350: -: 351: // added in Windows 10 (1607) -: 352: // loaded dynamically to avoid link errors -: 353: user32 = LoadLibraryA("User32.dll"); -: 354: SetThreadDpiAwarenessContext_function = -: 355: (Func_SetThreadDpiAwarenessContext) -: 356: GetProcAddress(user32, "SetThreadDpiAwarenessContext"); -: 357: if (SetThreadDpiAwarenessContext_function != NULL) { -: 358: // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = ((DPI_CONTEXT_HANDLE)-3) -: 359: dpiAwareness = SetThreadDpiAwarenessContext_function((HANDLE) -3); -: 360: } -: 361: -: 362: if (all_screens) { -: 363: x = GetSystemMetrics(SM_XVIRTUALSCREEN); -: 364: y = GetSystemMetrics(SM_YVIRTUALSCREEN); -: 365: width = GetSystemMetrics(SM_CXVIRTUALSCREEN); -: 366: height = GetSystemMetrics(SM_CYVIRTUALSCREEN); -: 367: } else { -: 368: width = GetDeviceCaps(screen, HORZRES); -: 369: height = GetDeviceCaps(screen, VERTRES); -: 370: } -: 371: -: 372: if (SetThreadDpiAwarenessContext_function != NULL) { -: 373: SetThreadDpiAwarenessContext_function(dpiAwareness); -: 374: } -: 375: -: 376: FreeLibrary(user32); -: 377: -: 378: bitmap = CreateCompatibleBitmap(screen, width, height); -: 379: if (!bitmap) { -: 380: goto error; -: 381: } -: 382: -: 383: if (!SelectObject(screen_copy, bitmap)) { -: 384: goto error; -: 385: } -: 386: -: 387: /* step 2: copy bits into memory DC bitmap */ -: 388: -: 389: rop = SRCCOPY; -: 390: if (includeLayeredWindows) { -: 391: rop |= CAPTUREBLT; -: 392: } -: 393: if (!BitBlt(screen_copy, 0, 0, width, height, screen, x, y, rop)) { -: 394: goto error; -: 395: } -: 396: -: 397: /* step 3: extract bits from bitmap */ -: 398: -: 399: buffer = PyBytes_FromStringAndSize(NULL, height * ((width*3 + 3) & -4)); -: 400: if (!buffer) { -: 401: return NULL; -: 402: } -: 403: -: 404: core.bcSize = sizeof(core); -: 405: core.bcWidth = width; -: 406: core.bcHeight = height; -: 407: core.bcPlanes = 1; -: 408: core.bcBitCount = 24; -: 409: if (!GetDIBits(screen_copy, bitmap, 0, height, PyBytes_AS_STRING(buffer), -: 410: (BITMAPINFO*) &core, DIB_RGB_COLORS)) { -: 411: goto error; -: 412: } -: 413: -: 414: DeleteObject(bitmap); -: 415: DeleteDC(screen_copy); -: 416: DeleteDC(screen); -: 417: -: 418: return Py_BuildValue("(ii)(ii)N", x, y, width, height, buffer); -: 419: -: 420:error: -: 421: PyErr_SetString(PyExc_OSError, "screen grab failed"); -: 422: -: 423: DeleteDC(screen_copy); -: 424: DeleteDC(screen); -: 425: -: 426: return NULL; -: 427:} -: 428: -: 429:static BOOL CALLBACK list_windows_callback(HWND hwnd, LPARAM lParam) -: 430:{ -: 431: PyObject* window_list = (PyObject*) lParam; -: 432: PyObject* item; -: 433: PyObject* title; -: 434: RECT inner, outer; -: 435: int title_size; -: 436: int status; -: 437: -: 438: /* get window title */ -: 439: title_size = GetWindowTextLength(hwnd); -: 440: if (title_size > 0) { -: 441: title = PyUnicode_FromStringAndSize(NULL, title_size); -: 442: if (title) { -: 443: GetWindowTextW(hwnd, PyUnicode_AS_UNICODE(title), title_size+1); -: 444: } -: 445: } else { -: 446: title = PyUnicode_FromString(""); -: 447: } -: 448: if (!title) { -: 449: return 0; -: 450: } -: 451: -: 452: /* get bounding boxes */ -: 453: GetClientRect(hwnd, &inner); -: 454: GetWindowRect(hwnd, &outer); -: 455: -: 456: item = Py_BuildValue( -: 457: F_HANDLE "N(iiii)(iiii)", hwnd, title, -: 458: inner.left, inner.top, inner.right, inner.bottom, -: 459: outer.left, outer.top, outer.right, outer.bottom -: 460: ); -: 461: if (!item) { -: 462: return 0; -: 463: } -: 464: -: 465: status = PyList_Append(window_list, item); -: 466: -: 467: Py_DECREF(item); -: 468: -: 469: if (status < 0) { -: 470: return 0; -: 471: } -: 472: -: 473: return 1; -: 474:} -: 475: -: 476:PyObject* -: 477:PyImaging_ListWindowsWin32(PyObject* self, PyObject* args) -: 478:{ -: 479: PyObject* window_list; -: 480: -: 481: window_list = PyList_New(0); -: 482: if (!window_list) { -: 483: return NULL; -: 484: } -: 485: -: 486: EnumWindows(list_windows_callback, (LPARAM) window_list); -: 487: -: 488: if (PyErr_Occurred()) { -: 489: Py_DECREF(window_list); -: 490: return NULL; -: 491: } -: 492: -: 493: return window_list; -: 494:} -: 495: -: 496:/* -------------------------------------------------------------------- */ -: 497:/* Windows clipboard grabber */ -: 498: -: 499:PyObject* -: 500:PyImaging_GrabClipboardWin32(PyObject* self, PyObject* args) -: 501:{ -: 502: int clip; -: 503: HANDLE handle = NULL; -: 504: int size; -: 505: void* data; -: 506: PyObject* result; -: 507: UINT format; -: 508: UINT formats[] = { CF_DIB, CF_DIBV5, CF_HDROP, RegisterClipboardFormatA("PNG"), 0 }; -: 509: LPCSTR format_names[] = { "DIB", "DIB", "file", "png", NULL }; -: 510: -: 511: if (!OpenClipboard(NULL)) { -: 512: PyErr_SetString(PyExc_OSError, "failed to open clipboard"); -: 513: return NULL; -: 514: } -: 515: -: 516: // find best format as set by clipboard owner -: 517: format = 0; -: 518: while (!handle && (format = EnumClipboardFormats(format))) { -: 519: for (UINT i = 0; formats[i] != 0; i++) { -: 520: if (format == formats[i]) { -: 521: handle = GetClipboardData(format); -: 522: format = i; -: 523: break; -: 524: } -: 525: } -: 526: } -: 527: -: 528: if (!handle) { -: 529: CloseClipboard(); -: 530: return Py_BuildValue("zO", NULL, Py_None); -: 531: } -: 532: -: 533: data = GlobalLock(handle); -: 534: size = GlobalSize(handle); -: 535: -: 536: result = PyBytes_FromStringAndSize(data, size); -: 537: -: 538: GlobalUnlock(handle); -: 539: CloseClipboard(); -: 540: -: 541: return Py_BuildValue("zN", format_names[format], result); -: 542:} -: 543: -: 544:/* -------------------------------------------------------------------- */ -: 545:/* Windows class */ -: 546: -: 547:#ifndef WM_MOUSEWHEEL -: 548:#define WM_MOUSEWHEEL 522 -: 549:#endif -: 550: -: 551:static int mainloop = 0; -: 552: -: 553:static void -: 554:callback_error(const char* handler) -: 555:{ -: 556: PyObject* sys_stderr; -: 557: -: 558: sys_stderr = PySys_GetObject("stderr"); -: 559: -: 560: if (sys_stderr) { -: 561: PyFile_WriteString("*** ImageWin: error in ", sys_stderr); -: 562: PyFile_WriteString((char*) handler, sys_stderr); -: 563: PyFile_WriteString(":\n", sys_stderr); -: 564: } -: 565: -: 566: PyErr_Print(); -: 567: PyErr_Clear(); -: 568:} -: 569: -: 570:static LRESULT CALLBACK -: 571:windowCallback(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) -: 572:{ -: 573: PAINTSTRUCT ps; -: 574: PyObject* callback = NULL; -: 575: PyObject* result; -: 576: PyThreadState* threadstate; -: 577: PyThreadState* current_threadstate; -: 578: HDC dc; -: 579: RECT rect; -: 580: LRESULT status = 0; -: 581: -: 582: /* set up threadstate for messages that calls back into python */ -: 583: switch (message) { -: 584: case WM_CREATE: -: 585: mainloop++; -: 586: break; -: 587: case WM_DESTROY: -: 588: mainloop--; -: 589: /* fall through... */ -: 590: case WM_PAINT: -: 591: case WM_SIZE: -: 592: callback = (PyObject*) GetWindowLongPtr(wnd, 0); -: 593: if (callback) { -: 594: threadstate = (PyThreadState*) -: 595: GetWindowLongPtr(wnd, sizeof(PyObject*)); -: 596: current_threadstate = PyThreadState_Swap(NULL); -: 597: PyEval_RestoreThread(threadstate); -: 598: } else { -: 599: return DefWindowProc(wnd, message, wParam, lParam); -: 600: } -: 601: } -: 602: -: 603: /* process message */ -: 604: switch (message) { -: 605: -: 606: case WM_PAINT: -: 607: /* redraw (part of) window. this generates a WCK-style -: 608: damage/clear/repair cascade */ -: 609: BeginPaint(wnd, &ps); -: 610: dc = GetDC(wnd); -: 611: GetWindowRect(wnd, &rect); /* in screen coordinates */ -: 612: -: 613: result = PyObject_CallFunction( -: 614: callback, "siiii", "damage", -: 615: ps.rcPaint.left, ps.rcPaint.top, -: 616: ps.rcPaint.right, ps.rcPaint.bottom -: 617: ); -: 618: if (result) { -: 619: Py_DECREF(result); -: 620: } else { -: 621: callback_error("window damage callback"); -: 622: } -: 623: -: 624: result = PyObject_CallFunction( -: 625: callback, "s" F_HANDLE "iiii", "clear", dc, -: 626: 0, 0, rect.right-rect.left, rect.bottom-rect.top -: 627: ); -: 628: if (result) { -: 629: Py_DECREF(result); -: 630: } else { -: 631: callback_error("window clear callback"); -: 632: } -: 633: -: 634: result = PyObject_CallFunction( -: 635: callback, "s" F_HANDLE "iiii", "repair", dc, -: 636: 0, 0, rect.right-rect.left, rect.bottom-rect.top -: 637: ); -: 638: if (result) { -: 639: Py_DECREF(result); -: 640: } else { -: 641: callback_error("window repair callback"); -: 642: } -: 643: -: 644: ReleaseDC(wnd, dc); -: 645: EndPaint(wnd, &ps); -: 646: break; -: 647: -: 648: case WM_SIZE: -: 649: /* resize window */ -: 650: result = PyObject_CallFunction( -: 651: callback, "sii", "resize", LOWORD(lParam), HIWORD(lParam) -: 652: ); -: 653: if (result) { -: 654: InvalidateRect(wnd, NULL, 1); -: 655: Py_DECREF(result); -: 656: } else { -: 657: callback_error("window resize callback"); -: 658: } -: 659: break; -: 660: -: 661: case WM_DESTROY: -: 662: /* destroy window */ -: 663: result = PyObject_CallFunction(callback, "s", "destroy"); -: 664: if (result) { -: 665: Py_DECREF(result); -: 666: } else { -: 667: callback_error("window destroy callback"); -: 668: } -: 669: Py_DECREF(callback); -: 670: break; -: 671: -: 672: default: -: 673: status = DefWindowProc(wnd, message, wParam, lParam); -: 674: } -: 675: -: 676: if (callback) { -: 677: /* restore thread state */ -: 678: PyEval_SaveThread(); -: 679: PyThreadState_Swap(threadstate); -: 680: } -: 681: -: 682: return status; -: 683:} -: 684: -: 685:PyObject* -: 686:PyImaging_CreateWindowWin32(PyObject* self, PyObject* args) -: 687:{ -: 688: HWND wnd; -: 689: WNDCLASS windowClass; -: 690: -: 691: char* title; -: 692: PyObject* callback; -: 693: int width = 0, height = 0; -: 694: if (!PyArg_ParseTuple(args, "sO|ii", &title, &callback, &width, &height)) { -: 695: return NULL; -: 696: } -: 697: -: 698: if (width <= 0) { -: 699: width = CW_USEDEFAULT; -: 700: } -: 701: if (height <= 0) { -: 702: height = CW_USEDEFAULT; -: 703: } -: 704: -: 705: /* register toplevel window class */ -: 706: windowClass.style = CS_CLASSDC; -: 707: windowClass.cbClsExtra = 0; -: 708: windowClass.cbWndExtra = sizeof(PyObject*) + sizeof(PyThreadState*); -: 709: windowClass.hInstance = GetModuleHandle(NULL); -: 710: /* windowClass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); */ -: 711: windowClass.hbrBackground = NULL; -: 712: windowClass.lpszMenuName = NULL; -: 713: windowClass.lpszClassName = "pilWindow"; -: 714: windowClass.lpfnWndProc = windowCallback; -: 715: windowClass.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(1)); -: 716: windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); /* CROSS? */ -: 717: -: 718: RegisterClass(&windowClass); /* FIXME: check return status */ -: 719: -: 720: wnd = CreateWindowEx( -: 721: 0, windowClass.lpszClassName, title, -: 722: WS_OVERLAPPEDWINDOW, -: 723: CW_USEDEFAULT, CW_USEDEFAULT, width, height, -: 724: HWND_DESKTOP, NULL, NULL, NULL -: 725: ); -: 726: -: 727: if (!wnd) { -: 728: PyErr_SetString(PyExc_OSError, "failed to create window"); -: 729: return NULL; -: 730: } -: 731: -: 732: /* register window callback */ -: 733: Py_INCREF(callback); -: 734: SetWindowLongPtr(wnd, 0, (LONG_PTR) callback); -: 735: SetWindowLongPtr(wnd, sizeof(callback), (LONG_PTR) PyThreadState_Get()); -: 736: -: 737: Py_BEGIN_ALLOW_THREADS -: 738: ShowWindow(wnd, SW_SHOWNORMAL); -: 739: SetForegroundWindow(wnd); /* to make sure it's visible */ -: 740: Py_END_ALLOW_THREADS -: 741: -: 742: return Py_BuildValue(F_HANDLE, wnd); -: 743:} -: 744: -: 745:PyObject* -: 746:PyImaging_EventLoopWin32(PyObject* self, PyObject* args) -: 747:{ -: 748: MSG msg; -: 749: -: 750: Py_BEGIN_ALLOW_THREADS -: 751: while (mainloop && GetMessage(&msg, NULL, 0, 0)) { -: 752: TranslateMessage(&msg); -: 753: DispatchMessage(&msg); -: 754: } -: 755: Py_END_ALLOW_THREADS -: 756: -: 757: Py_INCREF(Py_None); -: 758: return Py_None; -: 759:} -: 760: -: 761:/* -------------------------------------------------------------------- */ -: 762:/* windows WMF renderer */ -: 763: -: 764:#define GET32(p,o) ((DWORD*)(p+o))[0] -: 765: -: 766:PyObject * -: 767:PyImaging_DrawWmf(PyObject* self, PyObject* args) -: 768:{ -: 769: HBITMAP bitmap; -: 770: HENHMETAFILE meta; -: 771: BITMAPCOREHEADER core; -: 772: HDC dc; -: 773: RECT rect; -: 774: PyObject* buffer = NULL; -: 775: char* ptr; -: 776: -: 777: char* data; -: 778: Py_ssize_t datasize; -: 779: int width, height; -: 780: int x0, y0, x1, y1; -: 781: if (!PyArg_ParseTuple(args, "y#(ii)(iiii):_load", &data, &datasize, -: 782: &width, &height, &x0, &x1, &y0, &y1)) { -: 783: return NULL; -: 784: } -: 785: -: 786: /* step 1: copy metafile contents into METAFILE object */ -: 787: -: 788: if (datasize > 22 && GET32(data, 0) == 0x9ac6cdd7) { -: 789: -: 790: /* placeable windows metafile (22-byte aldus header) */ -: 791: meta = SetWinMetaFileBits(datasize-22, data+22, NULL, NULL); -: 792: -: 793: } else if (datasize > 80 && GET32(data, 0) == 1 && -: 794: GET32(data, 40) == 0x464d4520) { -: 795: -: 796: /* enhanced metafile */ -: 797: meta = SetEnhMetaFileBits(datasize, data); -: 798: -: 799: } else { -: 800: -: 801: /* unknown meta format */ -: 802: meta = NULL; -: 803: -: 804: } -: 805: -: 806: if (!meta) { -: 807: PyErr_SetString(PyExc_OSError, "cannot load metafile"); -: 808: return NULL; -: 809: } -: 810: -: 811: /* step 2: create bitmap */ -: 812: -: 813: core.bcSize = sizeof(core); -: 814: core.bcWidth = width; -: 815: core.bcHeight = height; -: 816: core.bcPlanes = 1; -: 817: core.bcBitCount = 24; -: 818: -: 819: dc = CreateCompatibleDC(NULL); -: 820: -: 821: bitmap = CreateDIBSection( -: 822: dc, (BITMAPINFO*) &core, DIB_RGB_COLORS, &ptr, NULL, 0 -: 823: ); -: 824: -: 825: if (!bitmap) { -: 826: PyErr_SetString(PyExc_OSError, "cannot create bitmap"); -: 827: goto error; -: 828: } -: 829: -: 830: if (!SelectObject(dc, bitmap)) { -: 831: PyErr_SetString(PyExc_OSError, "cannot select bitmap"); -: 832: goto error; -: 833: } -: 834: -: 835: /* step 3: render metafile into bitmap */ -: 836: -: 837: rect.left = rect.top = 0; -: 838: rect.right = width; -: 839: rect.bottom = height; -: 840: -: 841: /* FIXME: make background transparent? configurable? */ -: 842: FillRect(dc, &rect, GetStockObject(WHITE_BRUSH)); -: 843: -: 844: if (!PlayEnhMetaFile(dc, meta, &rect)) { -: 845: PyErr_SetString(PyExc_OSError, "cannot render metafile"); -: 846: goto error; -: 847: } -: 848: -: 849: /* step 4: extract bits from bitmap */ -: 850: -: 851: GdiFlush(); -: 852: -: 853: buffer = PyBytes_FromStringAndSize(ptr, height * ((width*3 + 3) & -4)); -: 854: -: 855:error: -: 856: DeleteEnhMetaFile(meta); -: 857: -: 858: if (bitmap) { -: 859: DeleteObject(bitmap); -: 860: } -: 861: -: 862: DeleteDC(dc); -: 863: -: 864: return buffer; -: 865:} -: 866: -: 867:#endif /* _WIN32 */ -: 868: -: 869:/* -------------------------------------------------------------------- */ -: 870:/* X11 support */ -: 871: -: 872:#ifdef HAVE_XCB -: 873:#include -: 874: -: 875:/* -------------------------------------------------------------------- */ -: 876:/* X11 screen grabber */ -: 877: -: 878:PyObject* function PyImaging_GrabScreenX11 called 2 returned 100% blocks executed 28% 2: 879:PyImaging_GrabScreenX11(PyObject* self, PyObject* args) -: 880:{ -: 881: int width, height; -: 882: char* display_name; -: 883: xcb_connection_t* connection; -: 884: int screen_number; -: 885: xcb_screen_iterator_t iter; 2: 886: xcb_screen_t* screen = NULL; -: 887: xcb_get_image_reply_t* reply; -: 888: xcb_generic_error_t* error; 2: 889: PyObject* buffer = NULL; -: 890: 2: 891: if (!PyArg_ParseTuple(args, "|z", &display_name)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 892: return NULL; -: 893: } -: 894: -: 895: /* connect to X and get screen data */ -: 896: 2: 897: connection = xcb_connect(display_name, &screen_number); call 0 returned 100% 2: 898: if (xcb_connection_has_error(connection)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 2: 899: PyErr_Format(PyExc_OSError, "X connection failed: error %i", xcb_connection_has_error(connection)); call 0 returned 100% call 1 returned 100% 2: 900: xcb_disconnect(connection); call 0 returned 100% 2: 901: return NULL; -: 902: } -: 903: #####: 904: iter = xcb_setup_roots_iterator(xcb_get_setup(connection)); call 0 never executed call 1 never executed #####: 905: for (; iter.rem; --screen_number, xcb_screen_next(&iter)) { call 0 never executed branch 1 never executed branch 2 never executed #####: 906: if (screen_number == 0) { branch 0 never executed branch 1 never executed #####: 907: screen = iter.data; #####: 908: break; -: 909: } -: 910: } #####: 911: if (screen == NULL || screen->root == 0) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 912: // this case is usually caught with "X connection failed: error 6" above #####: 913: xcb_disconnect(connection); call 0 never executed #####: 914: PyErr_SetString(PyExc_OSError, "X screen not found"); call 0 never executed #####: 915: return NULL; -: 916: } -: 917: #####: 918: width = screen->width_in_pixels; #####: 919: height = screen->height_in_pixels; -: 920: -: 921: /* get image data */ -: 922: #####: 923: reply = xcb_get_image_reply(connection, call 0 never executed call 1 never executed -: 924: xcb_get_image(connection, XCB_IMAGE_FORMAT_Z_PIXMAP, screen->root, -: 925: 0, 0, width, height, 0x00ffffff), -: 926: &error); #####: 927: if (reply == NULL) { branch 0 never executed branch 1 never executed #####: 928: PyErr_Format(PyExc_OSError, "X get_image failed: error %i (%i, %i, %i)", call 0 never executed #####: 929: error->error_code, error->major_code, error->minor_code, error->resource_id); #####: 930: free(error); #####: 931: xcb_disconnect(connection); call 0 never executed #####: 932: return NULL; -: 933: } -: 934: -: 935: /* store data in Python buffer */ -: 936: #####: 937: if (reply->depth == 24) { branch 0 never executed branch 1 never executed #####: 938: buffer = PyBytes_FromStringAndSize((char*)xcb_get_image_data(reply), call 0 never executed call 1 never executed #####: 939: xcb_get_image_data_length(reply)); call 0 never executed -: 940: } else { #####: 941: PyErr_Format(PyExc_OSError, "unsupported bit depth: %i", reply->depth); call 0 never executed -: 942: } -: 943: #####: 944: free(reply); #####: 945: xcb_disconnect(connection); call 0 never executed -: 946: #####: 947: if (!buffer) { branch 0 never executed branch 1 never executed -: 948: return NULL; -: 949: } -: 950: #####: 951: return Py_BuildValue("(ii)N", width, height, buffer); call 0 never executed -: 952:} -: 953: -: 954:#endif /* HAVE_XCB */ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#_webp.c.gcov -: 0:Source:src/_webp.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#define PY_SSIZE_T_CLEAN -: 2:#include -: 3:#include "libImaging/Imaging.h" -: 4:#include -: 5:#include -: 6:#include -: 7: -: 8:#ifdef HAVE_WEBPMUX -: 9:#include -: 10:#include -: 11: -: 12:/* -: 13: * Check the versions from mux.h and demux.h, to ensure the WebPAnimEncoder and -: 14: * WebPAnimDecoder APIs are present (initial support was added in 0.5.0). The -: 15: * very early versions had some significant differences, so we require later -: 16: * versions, before enabling animation support. -: 17: */ -: 18:#if WEBP_MUX_ABI_VERSION >= 0x0104 && WEBP_DEMUX_ABI_VERSION >= 0x0105 -: 19:#define HAVE_WEBPANIM -: 20:#endif -: 21: -: 22:#endif -: 23: function ImagingSectionEnter called 16 returned 100% blocks executed 100% 16: 24:void ImagingSectionEnter(ImagingSectionCookie* cookie) { 16: 25: *cookie = (PyThreadState *) PyEval_SaveThread(); call 0 returned 100% 16: 26:} -: 27: function ImagingSectionLeave called 16 returned 100% blocks executed 100% 16: 28:void ImagingSectionLeave(ImagingSectionCookie* cookie) { 16: 29: PyEval_RestoreThread((PyThreadState*) *cookie); call 0 returned 100% 16: 30:} -: 31: -: 32:/* -------------------------------------------------------------------- */ -: 33:/* WebP Muxer Error Handling */ -: 34:/* -------------------------------------------------------------------- */ -: 35: -: 36:#ifdef HAVE_WEBPMUX -: 37: -: 38:static const char* const kErrorMessages[-WEBP_MUX_NOT_ENOUGH_DATA + 1] = { -: 39: "WEBP_MUX_NOT_FOUND", "WEBP_MUX_INVALID_ARGUMENT", "WEBP_MUX_BAD_DATA", -: 40: "WEBP_MUX_MEMORY_ERROR", "WEBP_MUX_NOT_ENOUGH_DATA" -: 41:}; -: 42: function HandleMuxError called 0 returned 0% blocks executed 0% #####: 43:PyObject* HandleMuxError(WebPMuxError err, char* chunk) { -: 44: char message[100]; -: 45: int message_len; -: 46: assert(err <= WEBP_MUX_NOT_FOUND && err >= WEBP_MUX_NOT_ENOUGH_DATA); -: 47: -: 48: // Check for a memory error first #####: 49: if (err == WEBP_MUX_MEMORY_ERROR) { branch 0 never executed branch 1 never executed #####: 50: return PyErr_NoMemory(); call 0 never executed -: 51: } -: 52: -: 53: // Create the error message #####: 54: if (chunk == NULL) { branch 0 never executed branch 1 never executed #####: 55: message_len = sprintf(message, "could not assemble chunks: %s", kErrorMessages[-err]); -: 56: } else { #####: 57: message_len = sprintf(message, "could not set %.4s chunk: %s", chunk, kErrorMessages[-err]); -: 58: } #####: 59: if (message_len < 0) { branch 0 never executed branch 1 never executed #####: 60: PyErr_SetString(PyExc_RuntimeError, "failed to construct error message"); call 0 never executed #####: 61: return NULL; -: 62: } -: 63: -: 64: // Set the proper error type #####: 65: switch (err) { branch 0 never executed branch 1 never executed branch 2 never executed -: 66: case WEBP_MUX_NOT_FOUND: -: 67: case WEBP_MUX_INVALID_ARGUMENT: #####: 68: PyErr_SetString(PyExc_ValueError, message); call 0 never executed #####: 69: break; -: 70: -: 71: case WEBP_MUX_BAD_DATA: -: 72: case WEBP_MUX_NOT_ENOUGH_DATA: #####: 73: PyErr_SetString(PyExc_OSError, message); call 0 never executed #####: 74: break; -: 75: -: 76: default: #####: 77: PyErr_SetString(PyExc_RuntimeError, message); call 0 never executed #####: 78: break; -: 79: } -: 80: return NULL; -: 81:} -: 82: -: 83:#endif -: 84: -: 85:/* -------------------------------------------------------------------- */ -: 86:/* WebP Animation Support */ -: 87:/* -------------------------------------------------------------------- */ -: 88: -: 89:#ifdef HAVE_WEBPANIM -: 90: -: 91:// Encoder type -: 92:typedef struct { -: 93: PyObject_HEAD -: 94: WebPAnimEncoder* enc; -: 95: WebPPicture frame; -: 96:} WebPAnimEncoderObject; -: 97: -: 98:static PyTypeObject WebPAnimEncoder_Type; -: 99: -: 100:// Decoder type -: 101:typedef struct { -: 102: PyObject_HEAD -: 103: WebPAnimDecoder* dec; -: 104: WebPAnimInfo info; -: 105: WebPData data; -: 106: char* mode; -: 107:} WebPAnimDecoderObject; -: 108: -: 109:static PyTypeObject WebPAnimDecoder_Type; -: 110: -: 111:// Encoder functions function _anim_encoder_new called 7 returned 100% blocks executed 64% 7: 112:PyObject* _anim_encoder_new(PyObject* self, PyObject* args) -: 113:{ -: 114: int width, height; -: 115: uint32_t bgcolor; -: 116: int loop_count; -: 117: int minimize_size; -: 118: int kmin, kmax; -: 119: int allow_mixed; -: 120: int verbose; -: 121: WebPAnimEncoderOptions enc_options; 7: 122: WebPAnimEncoderObject* encp = NULL; 7: 123: WebPAnimEncoder* enc = NULL; -: 124: 7: 125: if (!PyArg_ParseTuple(args, "iiIiiiiii", call 0 returned 100% branch 1 taken 86% (fallthrough) branch 2 taken 14% -: 126: &width, &height, &bgcolor, &loop_count, &minimize_size, -: 127: &kmin, &kmax, &allow_mixed, &verbose)) { -: 128: return NULL; -: 129: } -: 130: -: 131: // Setup and configure the encoder's options (these are animation-specific) 6: 132: if (!WebPAnimEncoderOptionsInit(&enc_options)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 133: PyErr_SetString(PyExc_RuntimeError, "failed to initialize encoder options"); call 0 never executed #####: 134: return NULL; -: 135: } 6: 136: enc_options.anim_params.bgcolor = bgcolor; 6: 137: enc_options.anim_params.loop_count = loop_count; 6: 138: enc_options.minimize_size = minimize_size; 6: 139: enc_options.kmin = kmin; 6: 140: enc_options.kmax = kmax; 6: 141: enc_options.allow_mixed = allow_mixed; 6: 142: enc_options.verbose = verbose; -: 143: -: 144: // Validate canvas dimensions 6: 145: if (width <= 0 || height <= 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 146: PyErr_SetString(PyExc_ValueError, "invalid canvas dimensions"); call 0 never executed #####: 147: return NULL; -: 148: } -: 149: -: 150: // Create a new animation encoder and picture frame 6: 151: encp = PyObject_New(WebPAnimEncoderObject, &WebPAnimEncoder_Type); call 0 returned 100% 6: 152: if (encp) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 12: 153: if (WebPPictureInit(&(encp->frame))) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 12: 154: enc = WebPAnimEncoderNew(width, height, &enc_options); 6: 155: if (enc) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 156: encp->enc = enc; 6: 157: return (PyObject*) encp; -: 158: } #####: 159: WebPPictureFree(&(encp->frame)); call 0 never executed -: 160: } #####: 161: PyObject_Del(encp); call 0 never executed -: 162: } #####: 163: PyErr_SetString(PyExc_RuntimeError, "could not create encoder object"); call 0 never executed #####: 164: return NULL; -: 165:} -: 166: function _anim_encoder_dealloc called 6 returned 100% blocks executed 100% 6: 167:PyObject* _anim_encoder_dealloc(PyObject* self) -: 168:{ 6: 169: WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self; 6: 170: WebPPictureFree(&(encp->frame)); call 0 returned 100% 6: 171: WebPAnimEncoderDelete(encp->enc); call 0 returned 100% 12: 172: Py_RETURN_NONE; -: 173:} -: 174: function _anim_encoder_add called 95 returned 100% blocks executed 68% 95: 175:PyObject* _anim_encoder_add(PyObject* self, PyObject* args) -: 176:{ -: 177: uint8_t* rgb; -: 178: Py_ssize_t size; -: 179: int timestamp; -: 180: int width; -: 181: int height; -: 182: char* mode; -: 183: int lossless; -: 184: float quality_factor; -: 185: int method; -: 186: WebPConfig config; 95: 187: WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self; 95: 188: WebPAnimEncoder* enc = encp->enc; 95: 189: WebPPicture* frame = &(encp->frame); -: 190: 95: 191: if (!PyArg_ParseTuple(args, "z#iiisifi", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 192: (char**)&rgb, &size, ×tamp, &width, &height, &mode, -: 193: &lossless, &quality_factor, &method)) { -: 194: return NULL; -: 195: } -: 196: -: 197: // Check for NULL frame, which sets duration of final frame 95: 198: if (!rgb) { branch 0 taken 6% (fallthrough) branch 1 taken 94% 6: 199: WebPAnimEncoderAdd(enc, NULL, timestamp, NULL); call 0 returned 100% 12: 200: Py_RETURN_NONE; -: 201: } -: 202: -: 203: // Setup config for this frame 89: 204: if (!WebPConfigInit(&config)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 205: PyErr_SetString(PyExc_RuntimeError, "failed to initialize config!"); call 0 never executed #####: 206: return NULL; -: 207: } 89: 208: config.lossless = lossless; 89: 209: config.quality = quality_factor; 89: 210: config.method = method; -: 211: -: 212: // Validate the config 89: 213: if (!WebPValidateConfig(&config)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 214: PyErr_SetString(PyExc_ValueError, "invalid configuration"); call 0 never executed #####: 215: return NULL; -: 216: } -: 217: -: 218: // Populate the frame with raw bytes passed to us 89: 219: frame->width = width; 89: 220: frame->height = height; 89: 221: frame->use_argb = 1; // Don't convert RGB pixels to YUV 89: 222: if (strcmp(mode, "RGBA")==0) { branch 0 taken 35% (fallthrough) branch 1 taken 65% 31: 223: WebPPictureImportRGBA(frame, rgb, 4 * width); call 0 returned 100% 58: 224: } else if (strcmp(mode, "RGBX")==0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 58: 225: WebPPictureImportRGBX(frame, rgb, 4 * width); call 0 returned 100% -: 226: } else { #####: 227: WebPPictureImportRGB(frame, rgb, 3 * width); call 0 never executed -: 228: } -: 229: -: 230: // Add the frame to the encoder 89: 231: if (!WebPAnimEncoderAdd(enc, frame, timestamp, &config)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 232: PyErr_SetString(PyExc_RuntimeError, WebPAnimEncoderGetError(enc)); call 0 never executed call 1 never executed #####: 233: return NULL; -: 234: } -: 235: 178: 236: Py_RETURN_NONE; -: 237:} -: 238: function _anim_encoder_assemble called 6 returned 100% blocks executed 73% 6: 239:PyObject* _anim_encoder_assemble(PyObject* self, PyObject* args) -: 240:{ -: 241: uint8_t* icc_bytes; -: 242: uint8_t* exif_bytes; -: 243: uint8_t* xmp_bytes; -: 244: Py_ssize_t icc_size; -: 245: Py_ssize_t exif_size; -: 246: Py_ssize_t xmp_size; -: 247: WebPData webp_data; 6: 248: WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self; 6: 249: WebPAnimEncoder* enc = encp->enc; 6: 250: WebPMux* mux = NULL; 6: 251: PyObject* ret = NULL; -: 252: 6: 253: if (!PyArg_ParseTuple(args, "s#s#s#", call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 254: &icc_bytes, &icc_size, &exif_bytes, &exif_size, &xmp_bytes, &xmp_size)) { -: 255: return NULL; -: 256: } -: 257: -: 258: // Init the output buffer 6: 259: WebPDataInit(&webp_data); -: 260: -: 261: // Assemble everything into the output buffer 6: 262: if (!WebPAnimEncoderAssemble(enc, &webp_data)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 263: PyErr_SetString(PyExc_RuntimeError, WebPAnimEncoderGetError(enc)); call 0 never executed call 1 never executed #####: 264: return NULL; -: 265: } -: 266: -: 267: // Re-mux to add metadata as needed 6: 268: if (icc_size > 0 || exif_size > 0 || xmp_size > 0) { branch 0 taken 83% (fallthrough) branch 1 taken 17% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% 1: 269: WebPMuxError err = WEBP_MUX_OK; 1: 270: int i_icc_size = (int)icc_size; 1: 271: int i_exif_size = (int)exif_size; 1: 272: int i_xmp_size = (int)xmp_size; 1: 273: WebPData icc_profile = { icc_bytes, i_icc_size }; 1: 274: WebPData exif = { exif_bytes, i_exif_size }; 1: 275: WebPData xmp = { xmp_bytes, i_xmp_size }; -: 276: 1: 277: mux = WebPMuxCreate(&webp_data, 1); 1: 278: if (mux == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 279: PyErr_SetString(PyExc_RuntimeError, "could not re-mux to add metadata"); call 0 never executed #####: 280: return NULL; -: 281: } 1: 282: WebPDataClear(&webp_data); call 0 returned 100% -: 283: -: 284: // Add ICCP chunk 1: 285: if (i_icc_size > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 286: err = WebPMuxSetChunk(mux, "ICCP", &icc_profile, 1); call 0 returned 100% 1: 287: if (err != WEBP_MUX_OK) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 288: return HandleMuxError(err, "ICCP"); call 0 never executed -: 289: } -: 290: } -: 291: -: 292: // Add EXIF chunk 1: 293: if (i_exif_size > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 294: err = WebPMuxSetChunk(mux, "EXIF", &exif, 1); call 0 returned 100% 1: 295: if (err != WEBP_MUX_OK) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 296: return HandleMuxError(err, "EXIF"); call 0 never executed -: 297: } -: 298: } -: 299: -: 300: // Add XMP chunk 1: 301: if (i_xmp_size > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 302: err = WebPMuxSetChunk(mux, "XMP ", &xmp, 1); call 0 returned 100% 1: 303: if (err != WEBP_MUX_OK) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 304: return HandleMuxError(err, "XMP"); call 0 never executed -: 305: } -: 306: } -: 307: 1: 308: err = WebPMuxAssemble(mux, &webp_data); call 0 returned 100% 1: 309: if (err != WEBP_MUX_OK) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 310: return HandleMuxError(err, NULL); call 0 never executed -: 311: } -: 312: } -: 313: -: 314: // Convert to Python bytes 6: 315: ret = PyBytes_FromStringAndSize((char*)webp_data.bytes, webp_data.size); call 0 returned 100% 6: 316: WebPDataClear(&webp_data); call 0 returned 100% -: 317: -: 318: // If we had to re-mux, we should free it now that we're done with it 6: 319: if (mux != NULL) { branch 0 taken 17% (fallthrough) branch 1 taken 83% 1: 320: WebPMuxDelete(mux); call 0 returned 100% -: 321: } -: 322: -: 323: return ret; -: 324:} -: 325: -: 326:// Decoder functions function _anim_decoder_new called 162 returned 100% blocks executed 85% 162: 327:PyObject* _anim_decoder_new(PyObject* self, PyObject* args) -: 328:{ -: 329: PyBytesObject *webp_string; -: 330: const uint8_t *webp; -: 331: Py_ssize_t size; -: 332: WebPData webp_src; -: 333: char* mode; -: 334: WebPDecoderConfig config; 162: 335: WebPAnimDecoderObject* decp = NULL; 162: 336: WebPAnimDecoder* dec = NULL; -: 337: 162: 338: if (!PyArg_ParseTuple(args, "S", &webp_string)) { call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 339: return NULL; -: 340: } 161: 341: PyBytes_AsStringAndSize((PyObject *)webp_string, (char**)&webp, &size); call 0 returned 100% 161: 342: webp_src.bytes = webp; 161: 343: webp_src.size = size; -: 344: -: 345: // Sniff the mode, since the decoder API doesn't tell us 161: 346: mode = "RGBA"; 322: 347: if (WebPGetFeatures(webp, size, &config.input) == VP8_STATUS_OK) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 161: 348: if (!config.input.has_alpha) { branch 0 taken 93% (fallthrough) branch 1 taken 7% 149: 349: mode = "RGBX"; -: 350: } -: 351: } -: 352: -: 353: // Create the decoder (default mode is RGBA, if no options passed) 161: 354: decp = PyObject_New(WebPAnimDecoderObject, &WebPAnimDecoder_Type); call 0 returned 100% 161: 355: if (decp) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 161: 356: decp->mode = mode; 161: 357: if (WebPDataCopy(&webp_src, &(decp->data))) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 322: 358: dec = WebPAnimDecoderNew(&(decp->data), NULL); 161: 359: if (dec) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 161: 360: if (WebPAnimDecoderGetInfo(dec, &(decp->info))) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% 161: 361: decp->dec = dec; 161: 362: return (PyObject*)decp; -: 363: } -: 364: } -: 365: } #####: 366: PyObject_Del(decp); call 0 never executed -: 367: } #####: 368: PyErr_SetString(PyExc_RuntimeError, "could not create decoder object"); call 0 never executed #####: 369: return NULL; -: 370:} -: 371: function _anim_decoder_dealloc called 161 returned 100% blocks executed 100% 161: 372:PyObject* _anim_decoder_dealloc(PyObject* self) -: 373:{ 161: 374: WebPAnimDecoderObject* decp = (WebPAnimDecoderObject *)self; 161: 375: WebPDataClear(&(decp->data)); call 0 returned 100% 161: 376: WebPAnimDecoderDelete(decp->dec); call 0 returned 100% 322: 377: Py_RETURN_NONE; -: 378:} -: 379: function _anim_decoder_get_info called 161 returned 100% blocks executed 100% 161: 380:PyObject* _anim_decoder_get_info(PyObject* self) -: 381:{ 161: 382: WebPAnimDecoderObject* decp = (WebPAnimDecoderObject *)self; 161: 383: WebPAnimInfo* info = &(decp->info); -: 384: 161: 385: return Py_BuildValue("IIIIIs", call 0 returned 100% -: 386: info->canvas_width, info->canvas_height, -: 387: info->loop_count, -: 388: info->bgcolor, -: 389: info->frame_count, -: 390: decp->mode -: 391: ); -: 392:} -: 393: function _anim_decoder_get_chunk called 483 returned 100% blocks executed 100% 483: 394:PyObject* _anim_decoder_get_chunk(PyObject* self, PyObject* args) -: 395:{ -: 396: char* mode; 483: 397: WebPAnimDecoderObject* decp = (WebPAnimDecoderObject *)self; -: 398: const WebPDemuxer* demux; -: 399: WebPChunkIterator iter; -: 400: PyObject *ret; -: 401: 483: 402: if (!PyArg_ParseTuple(args, "s", &mode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 403: return NULL; -: 404: } -: 405: 483: 406: demux = WebPAnimDecoderGetDemuxer(decp->dec); call 0 returned 100% 483: 407: if (!WebPDemuxGetChunk(demux, mode, 1, &iter)) { call 0 returned 100% branch 1 taken 96% (fallthrough) branch 2 taken 4% 924: 408: Py_RETURN_NONE; -: 409: } -: 410: 21: 411: ret = PyBytes_FromStringAndSize((const char*)iter.chunk.bytes, iter.chunk.size); call 0 returned 100% 21: 412: WebPDemuxReleaseChunkIterator(&iter); call 0 returned 100% -: 413: 21: 414: return ret; -: 415:} -: 416: function _anim_decoder_get_next called 209 returned 100% blocks executed 67% 209: 417:PyObject* _anim_decoder_get_next(PyObject* self) -: 418:{ -: 419: uint8_t* buf; -: 420: int timestamp; -: 421: PyObject* bytes; -: 422: PyObject* ret; 209: 423: WebPAnimDecoderObject* decp = (WebPAnimDecoderObject*)self; -: 424: 209: 425: if (!WebPAnimDecoderGetNext(decp->dec, &buf, ×tamp)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 426: PyErr_SetString(PyExc_OSError, "failed to read next frame"); call 0 never executed #####: 427: return NULL; -: 428: } -: 429: 418: 430: bytes = PyBytes_FromStringAndSize((char *)buf, call 0 returned 100% 209: 431: decp->info.canvas_width * 4 * decp->info.canvas_height); -: 432: 209: 433: ret = Py_BuildValue("Si", bytes, timestamp); call 0 returned 100% -: 434: 209: 435: Py_DECREF(bytes); -: 436: return ret; -: 437:} -: 438: function _anim_decoder_reset called 4 returned 100% blocks executed 100% 4: 439:PyObject* _anim_decoder_reset(PyObject* self) -: 440:{ 4: 441: WebPAnimDecoderObject* decp = (WebPAnimDecoderObject *)self; 4: 442: WebPAnimDecoderReset(decp->dec); call 0 returned 100% 8: 443: Py_RETURN_NONE; -: 444:} -: 445: -: 446:/* -------------------------------------------------------------------- */ -: 447:/* Type Definitions */ -: 448:/* -------------------------------------------------------------------- */ -: 449: -: 450:// WebPAnimEncoder methods -: 451:static struct PyMethodDef _anim_encoder_methods[] = { -: 452: {"add", (PyCFunction)_anim_encoder_add, METH_VARARGS, "add"}, -: 453: {"assemble", (PyCFunction)_anim_encoder_assemble, METH_VARARGS, "assemble"}, -: 454: {NULL, NULL} /* sentinel */ -: 455:}; -: 456: -: 457:// WebPAnimDecoder type definition -: 458:static PyTypeObject WebPAnimEncoder_Type = { -: 459: PyVarObject_HEAD_INIT(NULL, 0) -: 460: "WebPAnimEncoder", /*tp_name */ -: 461: sizeof(WebPAnimEncoderObject), /*tp_size */ -: 462: 0, /*tp_itemsize */ -: 463: /* methods */ -: 464: (destructor)_anim_encoder_dealloc, /*tp_dealloc*/ -: 465: 0, /*tp_print*/ -: 466: 0, /*tp_getattr*/ -: 467: 0, /*tp_setattr*/ -: 468: 0, /*tp_compare*/ -: 469: 0, /*tp_repr*/ -: 470: 0, /*tp_as_number */ -: 471: 0, /*tp_as_sequence */ -: 472: 0, /*tp_as_mapping */ -: 473: 0, /*tp_hash*/ -: 474: 0, /*tp_call*/ -: 475: 0, /*tp_str*/ -: 476: 0, /*tp_getattro*/ -: 477: 0, /*tp_setattro*/ -: 478: 0, /*tp_as_buffer*/ -: 479: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 480: 0, /*tp_doc*/ -: 481: 0, /*tp_traverse*/ -: 482: 0, /*tp_clear*/ -: 483: 0, /*tp_richcompare*/ -: 484: 0, /*tp_weaklistoffset*/ -: 485: 0, /*tp_iter*/ -: 486: 0, /*tp_iternext*/ -: 487: _anim_encoder_methods, /*tp_methods*/ -: 488: 0, /*tp_members*/ -: 489: 0, /*tp_getset*/ -: 490:}; -: 491: -: 492:// WebPAnimDecoder methods -: 493:static struct PyMethodDef _anim_decoder_methods[] = { -: 494: {"get_info", (PyCFunction)_anim_decoder_get_info, METH_NOARGS, "get_info"}, -: 495: {"get_chunk", (PyCFunction)_anim_decoder_get_chunk, METH_VARARGS, "get_chunk"}, -: 496: {"get_next", (PyCFunction)_anim_decoder_get_next, METH_NOARGS, "get_next"}, -: 497: {"reset", (PyCFunction)_anim_decoder_reset, METH_NOARGS, "reset"}, -: 498: {NULL, NULL} /* sentinel */ -: 499:}; -: 500: -: 501:// WebPAnimDecoder type definition -: 502:static PyTypeObject WebPAnimDecoder_Type = { -: 503: PyVarObject_HEAD_INIT(NULL, 0) -: 504: "WebPAnimDecoder", /*tp_name */ -: 505: sizeof(WebPAnimDecoderObject), /*tp_size */ -: 506: 0, /*tp_itemsize */ -: 507: /* methods */ -: 508: (destructor)_anim_decoder_dealloc, /*tp_dealloc*/ -: 509: 0, /*tp_print*/ -: 510: 0, /*tp_getattr*/ -: 511: 0, /*tp_setattr*/ -: 512: 0, /*tp_compare*/ -: 513: 0, /*tp_repr*/ -: 514: 0, /*tp_as_number */ -: 515: 0, /*tp_as_sequence */ -: 516: 0, /*tp_as_mapping */ -: 517: 0, /*tp_hash*/ -: 518: 0, /*tp_call*/ -: 519: 0, /*tp_str*/ -: 520: 0, /*tp_getattro*/ -: 521: 0, /*tp_setattro*/ -: 522: 0, /*tp_as_buffer*/ -: 523: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 524: 0, /*tp_doc*/ -: 525: 0, /*tp_traverse*/ -: 526: 0, /*tp_clear*/ -: 527: 0, /*tp_richcompare*/ -: 528: 0, /*tp_weaklistoffset*/ -: 529: 0, /*tp_iter*/ -: 530: 0, /*tp_iternext*/ -: 531: _anim_decoder_methods, /*tp_methods*/ -: 532: 0, /*tp_members*/ -: 533: 0, /*tp_getset*/ -: 534:}; -: 535: -: 536:#endif -: 537: -: 538:/* -------------------------------------------------------------------- */ -: 539:/* Legacy WebP Support */ -: 540:/* -------------------------------------------------------------------- */ -: 541: function WebPEncode_wrapper called 17 returned 100% blocks executed 73% 17: 542:PyObject* WebPEncode_wrapper(PyObject* self, PyObject* args) -: 543:{ -: 544: int width; -: 545: int height; -: 546: int lossless; -: 547: float quality_factor; -: 548: int method; -: 549: uint8_t* rgb; -: 550: uint8_t* icc_bytes; -: 551: uint8_t* exif_bytes; -: 552: uint8_t* xmp_bytes; -: 553: uint8_t* output; -: 554: char* mode; -: 555: Py_ssize_t size; -: 556: Py_ssize_t icc_size; -: 557: Py_ssize_t exif_size; -: 558: Py_ssize_t xmp_size; -: 559: size_t ret_size; -: 560: int rgba_mode; -: 561: int channels; -: 562: int ok; -: 563: ImagingSectionCookie cookie; -: 564: WebPConfig config; -: 565: WebPMemoryWriter writer; -: 566: WebPPicture pic; -: 567: 17: 568: if (!PyArg_ParseTuple(args, "y#iiifss#is#s#", call 0 returned 100% branch 1 taken 94% (fallthrough) branch 2 taken 6% -: 569: (char**)&rgb, &size, &width, &height, &lossless, &quality_factor, &mode, -: 570: &icc_bytes, &icc_size, &method, &exif_bytes, &exif_size, &xmp_bytes, &xmp_size)) { -: 571: return NULL; -: 572: } -: 573: 16: 574: rgba_mode = strcmp(mode, "RGBA") == 0; 16: 575: if (!rgba_mode && strcmp(mode, "RGB") != 0) { branch 0 taken 81% (fallthrough) branch 1 taken 19% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 100% (fallthrough) branch 7 taken 0% branch 8 taken 0% (fallthrough) branch 9 taken 100% #####: 576: Py_RETURN_NONE; -: 577: } -: 578: 16: 579: channels = rgba_mode ? 4 : 3; branch 0 taken 81% (fallthrough) branch 1 taken 19% 16: 580: if (size < width * height * channels) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 581: Py_RETURN_NONE; -: 582: } -: 583: -: 584: // Setup config for this frame 16: 585: if (!WebPConfigInit(&config)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 586: PyErr_SetString(PyExc_RuntimeError, "failed to initialize config!"); call 0 never executed #####: 587: return NULL; -: 588: } 16: 589: config.lossless = lossless; 16: 590: config.quality = quality_factor; 16: 591: config.method = method; -: 592: -: 593: // Validate the config 16: 594: if (!WebPValidateConfig(&config)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 595: PyErr_SetString(PyExc_ValueError, "invalid configuration"); call 0 never executed #####: 596: return NULL; -: 597: } -: 598: 16: 599: if (!WebPPictureInit(&pic)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 600: PyErr_SetString(PyExc_ValueError, "could not initialise picture"); call 0 never executed #####: 601: return NULL; -: 602: } 16: 603: pic.width = width; 16: 604: pic.height = height; 16: 605: pic.use_argb = 1; // Don't convert RGB pixels to YUV -: 606: 16: 607: if (rgba_mode) { branch 0 taken 19% (fallthrough) branch 1 taken 81% 3: 608: WebPPictureImportRGBA(&pic, rgb, channels * width); call 0 returned 100% -: 609: } else { 13: 610: WebPPictureImportRGB(&pic, rgb, channels * width); call 0 returned 100% -: 611: } -: 612: 16: 613: WebPMemoryWriterInit(&writer); call 0 returned 100% 16: 614: pic.writer = WebPMemoryWrite; 16: 615: pic.custom_ptr = &writer; -: 616: 16: 617: ImagingSectionEnter(&cookie); call 0 returned 100% 16: 618: ok = WebPEncode(&config, &pic); call 0 returned 100% 16: 619: ImagingSectionLeave(&cookie); call 0 returned 100% -: 620: 16: 621: WebPPictureFree(&pic); call 0 returned 100% 16: 622: if (!ok) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 623: PyErr_SetString(PyExc_ValueError, "encoding error"); call 0 never executed #####: 624: return NULL; -: 625: } 16: 626: output = writer.mem; 16: 627: ret_size = writer.size; -: 628: -: 629:#ifndef HAVE_WEBPMUX -: 630: if (ret_size > 0) { -: 631: PyObject *ret = PyBytes_FromStringAndSize((char*)output, ret_size); -: 632: free(output); -: 633: return ret; -: 634: } -: 635:#else -: 636: { -: 637: /* I want to truncate the *_size items that get passed into WebP -: 638: data. Pypy2.1.0 had some issues where the Py_ssize_t items had -: 639: data in the upper byte. (Not sure why, it shouldn't have been there) -: 640: */ 16: 641: int i_icc_size = (int)icc_size; 16: 642: int i_exif_size = (int)exif_size; 16: 643: int i_xmp_size = (int)xmp_size; 16: 644: WebPData output_data = {0}; 16: 645: WebPData image = { output, ret_size }; 16: 646: WebPData icc_profile = { icc_bytes, i_icc_size }; 16: 647: WebPData exif = { exif_bytes, i_exif_size }; 16: 648: WebPData xmp = { xmp_bytes, i_xmp_size }; -: 649: WebPMuxError err; 16: 650: int dbg = 0; -: 651: 16: 652: int copy_data = 0; // value 1 indicates given data WILL be copied to the mux -: 653: // and value 0 indicates data will NOT be copied. -: 654: 16: 655: WebPMux* mux = WebPMuxNew(); 16: 656: WebPMuxSetImage(mux, &image, copy_data); call 0 returned 100% -: 657: -: 658: if (dbg) { -: 659: /* was getting %ld icc_size == 0, icc_size>0 was true */ -: 660: fprintf(stderr, "icc size %d, %d \n", i_icc_size, i_icc_size > 0); -: 661: } -: 662: 16: 663: if (i_icc_size > 0) { branch 0 taken 6% (fallthrough) branch 1 taken 94% -: 664: if (dbg) { -: 665: fprintf(stderr, "Adding ICC Profile\n"); -: 666: } 1: 667: err = WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data); call 0 returned 100% 1: 668: if (err != WEBP_MUX_OK) { branch 0 taken 0% (fallthrough) branch 1 taken 100% 16: 669: return HandleMuxError(err, "ICCP"); call 0 never executed -: 670: } -: 671: } -: 672: -: 673: if (dbg) { -: 674: fprintf(stderr, "exif size %d \n", i_exif_size); -: 675: } 16: 676: if (i_exif_size > 0) { branch 0 taken 19% (fallthrough) branch 1 taken 81% -: 677: if (dbg) { -: 678: fprintf(stderr, "Adding Exif Data\n"); -: 679: } 3: 680: err = WebPMuxSetChunk(mux, "EXIF", &exif, copy_data); call 0 returned 100% 3: 681: if (err != WEBP_MUX_OK) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 682: return HandleMuxError(err, "EXIF"); call 0 never executed -: 683: } -: 684: } -: 685: -: 686: if (dbg) { -: 687: fprintf(stderr, "xmp size %d \n", i_xmp_size); -: 688: } 16: 689: if (i_xmp_size > 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 690: if (dbg){ -: 691: fprintf(stderr, "Adding XMP Data\n"); -: 692: } #####: 693: err = WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data); call 0 never executed #####: 694: if (err != WEBP_MUX_OK) { branch 0 never executed branch 1 never executed #####: 695: return HandleMuxError(err, "XMP "); call 0 never executed -: 696: } -: 697: } -: 698: 16: 699: WebPMuxAssemble(mux, &output_data); call 0 returned 100% 16: 700: WebPMuxDelete(mux); call 0 returned 100% 16: 701: free(output); -: 702: 16: 703: ret_size = output_data.size; 16: 704: if (ret_size > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 16: 705: PyObject *ret = PyBytes_FromStringAndSize((char*)output_data.bytes, ret_size); call 0 returned 100% 16: 706: WebPDataClear(&output_data); call 0 returned 100% 16: 707: return ret; -: 708: } -: 709: } -: 710:#endif #####: 711: Py_RETURN_NONE; -: 712:} -: 713: function WebPDecode_wrapper called 1 returned 100% blocks executed 6% 1: 714:PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args) -: 715:{ -: 716: PyBytesObject* webp_string; -: 717: const uint8_t* webp; -: 718: Py_ssize_t size; 1: 719: PyObject *ret = Py_None, *bytes = NULL, *pymode = NULL, *icc_profile = NULL, *exif = NULL; -: 720: WebPDecoderConfig config; 1: 721: VP8StatusCode vp8_status_code = VP8_STATUS_OK; 1: 722: char* mode = "RGB"; -: 723: 1: 724: if (!PyArg_ParseTuple(args, "S", &webp_string)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 725: return NULL; -: 726: } -: 727: #####: 728: if (!WebPInitDecoderConfig(&config)) { branch 0 never executed branch 1 never executed #####: 729: Py_RETURN_NONE; -: 730: } -: 731: #####: 732: PyBytes_AsStringAndSize((PyObject*) webp_string, (char**)&webp, &size); call 0 never executed -: 733: #####: 734: vp8_status_code = WebPGetFeatures(webp, size, &config.input); #####: 735: if (vp8_status_code == VP8_STATUS_OK) { branch 0 never executed branch 1 never executed -: 736: // If we don't set it, we don't get alpha. -: 737: // Initialized to MODE_RGB #####: 738: if (config.input.has_alpha) { branch 0 never executed branch 1 never executed #####: 739: config.output.colorspace = MODE_RGBA; #####: 740: mode = "RGBA"; -: 741: } -: 742: -: 743:#ifndef HAVE_WEBPMUX -: 744: vp8_status_code = WebPDecode(webp, size, &config); -: 745:#else -: 746: { #####: 747: int copy_data = 0; #####: 748: WebPData data = { webp, size }; -: 749: WebPMuxFrameInfo image; #####: 750: WebPData icc_profile_data = {0}; #####: 751: WebPData exif_data = {0}; -: 752: #####: 753: WebPMux* mux = WebPMuxCreate(&data, copy_data); #####: 754: if (NULL == mux) { branch 0 never executed branch 1 never executed -: 755: goto end; -: 756: } -: 757: #####: 758: if (WEBP_MUX_OK != WebPMuxGetFrame(mux, 1, &image)) call 0 never executed branch 1 never executed branch 2 never executed -: 759: { #####: 760: WebPMuxDelete(mux); call 0 never executed #####: 761: goto end; -: 762: } -: 763: #####: 764: webp = image.bitstream.bytes; #####: 765: size = image.bitstream.size; -: 766: #####: 767: vp8_status_code = WebPDecode(webp, size, &config); call 0 never executed -: 768: #####: 769: if (WEBP_MUX_OK == WebPMuxGetChunk(mux, "ICCP", &icc_profile_data)) { call 0 never executed branch 1 never executed branch 2 never executed #####: 770: icc_profile = PyBytes_FromStringAndSize((const char*)icc_profile_data.bytes, icc_profile_data.size); call 0 never executed -: 771: } -: 772: #####: 773: if (WEBP_MUX_OK == WebPMuxGetChunk(mux, "EXIF", &exif_data)) { call 0 never executed branch 1 never executed branch 2 never executed #####: 774: exif = PyBytes_FromStringAndSize((const char*)exif_data.bytes, exif_data.size); call 0 never executed -: 775: } -: 776: #####: 777: WebPDataClear(&image.bitstream); call 0 never executed #####: 778: WebPMuxDelete(mux); call 0 never executed -: 779: } -: 780:#endif -: 781: } -: 782: #####: 783: if (vp8_status_code != VP8_STATUS_OK) { branch 0 never executed branch 1 never executed -: 784: goto end; -: 785: } -: 786: #####: 787: if (config.output.colorspace < MODE_YUV) { branch 0 never executed branch 1 never executed #####: 788: bytes = PyBytes_FromStringAndSize((char*)config.output.u.RGBA.rgba, call 0 never executed #####: 789: config.output.u.RGBA.size); -: 790: } else { -: 791: // Skipping YUV for now. Need Test Images. -: 792: // UNDONE -- unclear if we'll ever get here if we set mode_rgb* #####: 793: bytes = PyBytes_FromStringAndSize((char*)config.output.u.YUVA.y, call 0 never executed #####: 794: config.output.u.YUVA.y_size); -: 795: } -: 796: #####: 797: pymode = PyUnicode_FromString(mode); call 0 never executed #####: 798: ret = Py_BuildValue("SiiSSS", bytes, config.output.width, branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed call 4 never executed -: 799: config.output.height, pymode, -: 800: NULL == icc_profile ? Py_None : icc_profile, -: 801: NULL == exif ? Py_None : exif); -: 802: -: 803:end: #####: 804: WebPFreeDecBuffer(&config.output); call 0 never executed -: 805: #####: 806: Py_XDECREF(bytes); #####: 807: Py_XDECREF(pymode); #####: 808: Py_XDECREF(icc_profile); #####: 809: Py_XDECREF(exif); -: 810: #####: 811: if (Py_None == ret) { branch 0 never executed branch 1 never executed #####: 812: Py_RETURN_NONE; -: 813: } -: 814: -: 815: return ret; -: 816:} -: 817: -: 818:// Return the decoder's version number, packed in hexadecimal using 8bits for -: 819:// each of major/minor/revision. E.g: v2.5.7 is 0x020507. function WebPDecoderVersion_wrapper called 3 returned 100% blocks executed 100% 3: 820:PyObject* WebPDecoderVersion_wrapper() { 3: 821: return Py_BuildValue("i", WebPGetDecoderVersion()); call 0 returned 100% call 1 returned 100% -: 822:} -: 823: -: 824:// Version as string -: 825:const char* function WebPDecoderVersion_str called 3 returned 100% blocks executed 100% 3: 826:WebPDecoderVersion_str(void) -: 827:{ -: 828: static char version[20]; 3: 829: int version_number = WebPGetDecoderVersion(); call 0 returned 100% 6: 830: sprintf(version, "%d.%d.%d", version_number >> 16, (version_number >> 8) % 0x100, version_number % 0x100); 3: 831: return version; -: 832:} -: 833: -: 834:/* -: 835: * The version of webp that ships with (0.1.3) Ubuntu 12.04 doesn't handle alpha well. -: 836: * Files that are valid with 0.3 are reported as being invalid. -: 837: */ function WebPDecoderBuggyAlpha called 7 returned 100% blocks executed 100% 7: 838:int WebPDecoderBuggyAlpha(void) { 7: 839: return WebPGetDecoderVersion()==0x0103; call 0 returned 100% -: 840:} -: 841: function WebPDecoderBuggyAlpha_wrapper called 4 returned 100% blocks executed 100% 4: 842:PyObject* WebPDecoderBuggyAlpha_wrapper() { 4: 843: return Py_BuildValue("i", WebPDecoderBuggyAlpha()); call 0 returned 100% call 1 returned 100% -: 844:} -: 845: -: 846:/* -------------------------------------------------------------------- */ -: 847:/* Module Setup */ -: 848:/* -------------------------------------------------------------------- */ -: 849: -: 850:static PyMethodDef webpMethods[] = -: 851:{ -: 852:#ifdef HAVE_WEBPANIM -: 853: {"WebPAnimDecoder", _anim_decoder_new, METH_VARARGS, "WebPAnimDecoder"}, -: 854: {"WebPAnimEncoder", _anim_encoder_new, METH_VARARGS, "WebPAnimEncoder"}, -: 855:#endif -: 856: {"WebPEncode", WebPEncode_wrapper, METH_VARARGS, "WebPEncode"}, -: 857: {"WebPDecode", WebPDecode_wrapper, METH_VARARGS, "WebPDecode"}, -: 858: {"WebPDecoderVersion", WebPDecoderVersion_wrapper, METH_NOARGS, "WebPVersion"}, -: 859: {"WebPDecoderBuggyAlpha", WebPDecoderBuggyAlpha_wrapper, METH_NOARGS, "WebPDecoderBuggyAlpha"}, -: 860: {NULL, NULL} -: 861:}; -: 862: function addMuxFlagToModule called 3 returned 100% blocks executed 100% 3: 863:void addMuxFlagToModule(PyObject* m) { -: 864:#ifdef HAVE_WEBPMUX 3: 865: PyModule_AddObject(m, "HAVE_WEBPMUX", Py_True); call 0 returned 100% -: 866:#else -: 867: PyModule_AddObject(m, "HAVE_WEBPMUX", Py_False); -: 868:#endif 3: 869:} -: 870: function addAnimFlagToModule called 3 returned 100% blocks executed 100% 3: 871:void addAnimFlagToModule(PyObject* m) { -: 872:#ifdef HAVE_WEBPANIM 3: 873: PyModule_AddObject(m, "HAVE_WEBPANIM", Py_True); call 0 returned 100% -: 874:#else -: 875: PyModule_AddObject(m, "HAVE_WEBPANIM", Py_False); -: 876:#endif 3: 877:} -: 878: function addTransparencyFlagToModule called 3 returned 100% blocks executed 100% 3: 879:void addTransparencyFlagToModule(PyObject* m) { 3: 880: PyModule_AddObject(m, "HAVE_TRANSPARENCY", call 0 returned 100% call 1 returned 100% 3: 881: PyBool_FromLong(!WebPDecoderBuggyAlpha())); call 0 returned 100% 3: 882:} -: 883: function setup_module called 3 returned 100% blocks executed 92% 3: 884:static int setup_module(PyObject* m) { 3: 885: PyObject* d = PyModule_GetDict(m); call 0 returned 100% 3: 886: addMuxFlagToModule(m); call 0 returned 100% 3: 887: addAnimFlagToModule(m); call 0 returned 100% 3: 888: addTransparencyFlagToModule(m); call 0 returned 100% -: 889: 3: 890: PyDict_SetItemString(d, "webpdecoder_version", PyUnicode_FromString(WebPDecoderVersion_str())); call 0 returned 100% call 1 returned 100% call 2 returned 100% -: 891: -: 892:#ifdef HAVE_WEBPANIM -: 893: /* Ready object types */ 6: 894: if (PyType_Ready(&WebPAnimDecoder_Type) < 0 || call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 0% (fallthrough) branch 4 taken 100% 3: 895: PyType_Ready(&WebPAnimEncoder_Type) < 0) { call 0 returned 100% -: 896: return -1; -: 897: } -: 898:#endif -: 899: return 0; -: 900:} -: 901: -: 902:PyMODINIT_FUNC function PyInit__webp called 3 returned 100% blocks executed 100% 3: 903:PyInit__webp(void) { -: 904: PyObject* m; -: 905: -: 906: static PyModuleDef module_def = { -: 907: PyModuleDef_HEAD_INIT, -: 908: "_webp", /* m_name */ -: 909: NULL, /* m_doc */ -: 910: -1, /* m_size */ -: 911: webpMethods, /* m_methods */ -: 912: }; -: 913: 3: 914: m = PyModule_Create(&module_def); call 0 returned 100% 3: 915: if (setup_module(m) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 916: return NULL; -: 917: } -: 918: 3: 919: return m; -: 920:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#encode.c.gcov -: 0:Source:src/encode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/encode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/encode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * standard encoder interfaces for the Imaging library -: 5: * -: 6: * History: -: 7: * 1996-04-19 fl Based on decoders.c -: 8: * 1996-05-12 fl Compile cleanly as C++ -: 9: * 1996-12-30 fl Plugged potential memory leak for tiled images -: 10: * 1997-01-03 fl Added GIF encoder -: 11: * 1997-01-05 fl Plugged encoder buffer leaks -: 12: * 1997-01-11 fl Added encode_to_file method -: 13: * 1998-03-09 fl Added mode/rawmode argument to encoders -: 14: * 1998-07-09 fl Added interlace argument to GIF encoder -: 15: * 1999-02-07 fl Added PCX encoder -: 16: * -: 17: * Copyright (c) 1997-2001 by Secret Labs AB -: 18: * Copyright (c) 1996-1997 by Fredrik Lundh -: 19: * -: 20: * See the README file for information on usage and redistribution. -: 21: */ -: 22: -: 23:/* FIXME: make these pluggable! */ -: 24: -: 25:#define PY_SSIZE_T_CLEAN -: 26:#include "Python.h" -: 27: -: 28:#include "libImaging/Imaging.h" -: 29:#include "libImaging/Gif.h" -: 30: -: 31:#ifdef HAVE_UNISTD_H -: 32:#include /* write */ -: 33:#endif -: 34: -: 35:/* -------------------------------------------------------------------- */ -: 36:/* Common */ -: 37:/* -------------------------------------------------------------------- */ -: 38: -: 39:typedef struct { -: 40: PyObject_HEAD -: 41: int (*encode)(Imaging im, ImagingCodecState state, -: 42: UINT8* buffer, int bytes); -: 43: int (*cleanup)(ImagingCodecState state); -: 44: struct ImagingCodecStateInstance state; -: 45: Imaging im; -: 46: PyObject* lock; -: 47: int pushes_fd; -: 48:} ImagingEncoderObject; -: 49: -: 50:static PyTypeObject ImagingEncoderType; -: 51: -: 52:static ImagingEncoderObject* function PyImaging_EncoderNew called 3780 returned 100% blocks executed 67% 3780: 53:PyImaging_EncoderNew(int contextsize) -: 54:{ -: 55: ImagingEncoderObject *encoder; -: 56: void *context; -: 57: 3780: 58: if(PyType_Ready(&ImagingEncoderType) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 59: return NULL; -: 60: } -: 61: 3780: 62: encoder = PyObject_New(ImagingEncoderObject, &ImagingEncoderType); call 0 returned 100% 3780: 63: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 64: return NULL; -: 65: } -: 66: -: 67: /* Clear the encoder state */ 7560: 68: memset(&encoder->state, 0, sizeof(encoder->state)); -: 69: -: 70: /* Allocate encoder context */ 3780: 71: if (contextsize > 0) { branch 0 taken 11% (fallthrough) branch 1 taken 89% 410: 72: context = (void*) calloc(1, contextsize); 410: 73: if (!context) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 74: Py_DECREF(encoder); #####: 75: (void) PyErr_NoMemory(); call 0 never executed #####: 76: return NULL; -: 77: } -: 78: } else { -: 79: context = 0; -: 80: } -: 81: -: 82: /* Initialize encoder context */ 3780: 83: encoder->state.context = context; -: 84: -: 85: /* Most encoders don't need this */ 3780: 86: encoder->cleanup = NULL; -: 87: -: 88: /* Target image */ 3780: 89: encoder->lock = NULL; 3780: 90: encoder->im = NULL; 3780: 91: encoder->pushes_fd = 0; -: 92: 3780: 93: return encoder; -: 94:} -: 95: -: 96:static void function _dealloc called 3780 returned 100% blocks executed 80% 3780: 97:_dealloc(ImagingEncoderObject* encoder) -: 98:{ 3780: 99: if (encoder->cleanup) { branch 0 taken 4% (fallthrough) branch 1 taken 96% 146: 100: encoder->cleanup(&encoder->state); call 0 returned 100% -: 101: } 3780: 102: free(encoder->state.buffer); 3780: 103: free(encoder->state.context); 7560: 104: Py_XDECREF(encoder->lock); 7560: 105: Py_XDECREF(encoder->state.fd); 3780: 106: PyObject_Del(encoder); call 0 returned 100% 3780: 107:} -: 108: -: 109:static PyObject* function _encode_cleanup called 560 returned 100% blocks executed 100% 560: 110:_encode_cleanup(ImagingEncoderObject* encoder, PyObject* args) -: 111:{ 560: 112: int status = 0; -: 113: 560: 114: if (encoder->cleanup){ branch 0 taken 26% (fallthrough) branch 1 taken 74% 144: 115: status = encoder->cleanup(&encoder->state); call 0 returned 100% -: 116: } -: 117: 560: 118: return Py_BuildValue("i", status); call 0 returned 100% -: 119:} -: 120: -: 121:static PyObject* function _encode called 14585 returned 100% blocks executed 92% 14585: 122:_encode(ImagingEncoderObject* encoder, PyObject* args) -: 123:{ -: 124: PyObject* buf; -: 125: PyObject* result; -: 126: int status; -: 127: -: 128: /* Encode to a Python string (allocated by this method) */ -: 129: 14585: 130: Py_ssize_t bufsize = 16384; -: 131: 14585: 132: if (!PyArg_ParseTuple(args, "|n", &bufsize)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 133: return NULL; -: 134: } -: 135: 14585: 136: buf = PyBytes_FromStringAndSize(NULL, bufsize); call 0 returned 100% 14585: 137: if (!buf) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 138: return NULL; -: 139: } -: 140: 29170: 141: status = encoder->encode(encoder->im, &encoder->state, call 0 returned 100% 14585: 142: (UINT8*) PyBytes_AsString(buf), bufsize); call 0 returned 100% -: 143: -: 144: /* adjust string length to avoid slicing in encoder */ 14585: 145: if (_PyBytes_Resize(&buf, (status > 0) ? status : 0) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 146: return NULL; -: 147: } -: 148: 14585: 149: result = Py_BuildValue("iiO", status, encoder->state.errcode, buf); call 0 returned 100% -: 150: 14585: 151: Py_DECREF(buf); /* must release buffer!!! */ -: 152: -: 153: return result; -: 154:} -: 155: -: 156:static PyObject* function _encode_to_pyfd called 14 returned 100% blocks executed 71% 14: 157:_encode_to_pyfd(ImagingEncoderObject* encoder, PyObject* args) -: 158:{ -: 159: -: 160: PyObject *result; -: 161: int status; -: 162: 14: 163: if (!encoder->pushes_fd) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 164: // UNDONE, appropriate errcode??? #####: 165: result = Py_BuildValue("ii", 0, IMAGING_CODEC_CONFIG);; call 0 never executed #####: 166: return result; -: 167: } -: 168: 14: 169: status = encoder->encode(encoder->im, &encoder->state, call 0 returned 100% -: 170: (UINT8*) NULL, 0); -: 171: 14: 172: result = Py_BuildValue("ii", status, encoder->state.errcode); call 0 returned 100% -: 173: 14: 174: return result; -: 175:} -: 176: -: 177:static PyObject* function _encode_to_file called 237 returned 100% blocks executed 81% 237: 178:_encode_to_file(ImagingEncoderObject* encoder, PyObject* args) -: 179:{ -: 180: UINT8* buf; -: 181: int status; -: 182: ImagingSectionCookie cookie; -: 183: -: 184: /* Encode to a file handle */ -: 185: -: 186: Py_ssize_t fh; 237: 187: Py_ssize_t bufsize = 16384; -: 188: 237: 189: if (!PyArg_ParseTuple(args, "n|n", &fh, &bufsize)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 190: return NULL; -: 191: } -: 192: -: 193: /* Allocate an encoder buffer */ -: 194: /* malloc check ok, either constant int, or checked by PyArg_ParseTuple */ 237: 195: buf = (UINT8*) malloc(bufsize); 237: 196: if (!buf) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 197: return PyErr_NoMemory(); call 0 never executed -: 198: } -: 199: 237: 200: ImagingSectionEnter(&cookie); call 0 returned 100% -: 201: -: 202: do { -: 203: -: 204: /* This replaces the inner loop in the ImageFile _save -: 205: function. */ -: 206: 324: 207: status = encoder->encode(encoder->im, &encoder->state, buf, bufsize); call 0 returned 100% -: 208: 324: 209: if (status > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 324: 210: if (write(fh, buf, status) < 0) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 211: ImagingSectionLeave(&cookie); call 0 never executed #####: 212: free(buf); #####: 213: return PyErr_SetFromErrno(PyExc_OSError); call 0 never executed -: 214: } -: 215: } -: 216: 324: 217: } while (encoder->state.errcode == 0); branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 218: 237: 219: ImagingSectionLeave(&cookie); call 0 returned 100% -: 220: 237: 221: free(buf); -: 222: 237: 223: return Py_BuildValue("i", encoder->state.errcode); call 0 returned 100% -: 224:} -: 225: -: 226:extern Imaging PyImaging_AsImaging(PyObject *op); -: 227: -: 228:static PyObject* function _setimage called 3779 returned 100% blocks executed 75% 3779: 229:_setimage(ImagingEncoderObject* encoder, PyObject* args) -: 230:{ -: 231: PyObject* op; -: 232: Imaging im; -: 233: ImagingCodecState state; -: 234: Py_ssize_t x0, y0, x1, y1; -: 235: -: 236: /* Define where image data should be stored */ -: 237: 3779: 238: x0 = y0 = x1 = y1 = 0; -: 239: -: 240: /* FIXME: should publish the ImagingType descriptor */ 3779: 241: if (!PyArg_ParseTuple(args, "O|(nnnn)", &op, &x0, &y0, &x1, &y1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 242: return NULL; -: 243: } 3779: 244: im = PyImaging_AsImaging(op); call 0 returned 100% 3779: 245: if (!im) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 246: return NULL; -: 247: } -: 248: 3779: 249: encoder->im = im; -: 250: 3779: 251: state = &encoder->state; -: 252: 3779: 253: if (x0 == 0 && x1 == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 85% (fallthrough) branch 3 taken 15% 3218: 254: state->xsize = im->xsize; 3218: 255: state->ysize = im->ysize; -: 256: } else { 561: 257: state->xoff = x0; 561: 258: state->yoff = y0; 561: 259: state->xsize = x1 - x0; 561: 260: state->ysize = y1 - y0; -: 261: } -: 262: 7558: 263: if (state->xsize <= 0 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 7558: 264: state->xsize + state->xoff > im->xsize || branch 0 taken 100% (fallthrough) branch 1 taken 0% 7558: 265: state->ysize <= 0 || branch 0 taken 0% (fallthrough) branch 1 taken 100% 3779: 266: state->ysize + state->yoff > im->ysize) { #####: 267: PyErr_SetString(PyExc_SystemError, "tile cannot extend outside image"); call 0 never executed #####: 268: return NULL; -: 269: } -: 270: -: 271: /* Allocate memory buffer (if bits field is set) */ 3779: 272: if (state->bits > 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 3745: 273: if (state->xsize > ((INT_MAX / state->bits)-7)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 274: return PyErr_NoMemory(); call 0 never executed -: 275: } 3745: 276: state->bytes = (state->bits * state->xsize+7)/8; -: 277: /* malloc check ok, overflow checked above */ 3745: 278: state->buffer = (UINT8*) malloc(state->bytes); 3745: 279: if (!state->buffer) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 280: return PyErr_NoMemory(); call 0 never executed -: 281: } -: 282: } -: 283: -: 284: /* Keep a reference to the image object, to make sure it doesn't -: 285: go away before we do */ 3779: 286: Py_INCREF(op); 7558: 287: Py_XDECREF(encoder->lock); 3779: 288: encoder->lock = op; -: 289: 3779: 290: Py_INCREF(Py_None); 3779: 291: return Py_None; -: 292:} -: 293: -: 294:static PyObject* function _setfd called 14 returned 100% blocks executed 100% 14: 295:_setfd(ImagingEncoderObject* encoder, PyObject* args) -: 296:{ -: 297: PyObject* fd; -: 298: ImagingCodecState state; -: 299: 14: 300: if (!PyArg_ParseTuple(args, "O", &fd)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 301: return NULL; -: 302: } -: 303: 14: 304: state = &encoder->state; -: 305: 28: 306: Py_XINCREF(fd); 14: 307: state->fd = fd; -: 308: 14: 309: Py_INCREF(Py_None); 14: 310: return Py_None; -: 311:} -: 312: -: 313:static PyObject * function _get_pushes_fd called 561 returned 100% blocks executed 100% 561: 314:_get_pushes_fd(ImagingEncoderObject *encoder) -: 315:{ 561: 316: return PyBool_FromLong(encoder->pushes_fd); call 0 returned 100% -: 317:} -: 318: -: 319:static struct PyMethodDef methods[] = { -: 320: {"encode", (PyCFunction)_encode, 1}, -: 321: {"cleanup", (PyCFunction)_encode_cleanup, 1}, -: 322: {"encode_to_file", (PyCFunction)_encode_to_file, 1}, -: 323: {"encode_to_pyfd", (PyCFunction)_encode_to_pyfd, 1}, -: 324: {"setimage", (PyCFunction)_setimage, 1}, -: 325: {"setfd", (PyCFunction)_setfd, 1}, -: 326: {NULL, NULL} /* sentinel */ -: 327:}; -: 328: -: 329:static struct PyGetSetDef getseters[] = { -: 330: {"pushes_fd", (getter)_get_pushes_fd, NULL, -: 331: "True if this decoder expects to push directly to self.fd", -: 332: NULL}, -: 333: {NULL, NULL, NULL, NULL, NULL} /* sentinel */ -: 334:}; -: 335: -: 336:static PyTypeObject ImagingEncoderType = { -: 337: PyVarObject_HEAD_INIT(NULL, 0) -: 338: "ImagingEncoder", /*tp_name*/ -: 339: sizeof(ImagingEncoderObject), /*tp_size*/ -: 340: 0, /*tp_itemsize*/ -: 341: /* methods */ -: 342: (destructor)_dealloc, /*tp_dealloc*/ -: 343: 0, /*tp_print*/ -: 344: 0, /*tp_getattr*/ -: 345: 0, /*tp_setattr*/ -: 346: 0, /*tp_compare*/ -: 347: 0, /*tp_repr*/ -: 348: 0, /*tp_as_number */ -: 349: 0, /*tp_as_sequence */ -: 350: 0, /*tp_as_mapping */ -: 351: 0, /*tp_hash*/ -: 352: 0, /*tp_call*/ -: 353: 0, /*tp_str*/ -: 354: 0, /*tp_getattro*/ -: 355: 0, /*tp_setattro*/ -: 356: 0, /*tp_as_buffer*/ -: 357: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 358: 0, /*tp_doc*/ -: 359: 0, /*tp_traverse*/ -: 360: 0, /*tp_clear*/ -: 361: 0, /*tp_richcompare*/ -: 362: 0, /*tp_weaklistoffset*/ -: 363: 0, /*tp_iter*/ -: 364: 0, /*tp_iternext*/ -: 365: methods, /*tp_methods*/ -: 366: 0, /*tp_members*/ -: 367: getseters, /*tp_getset*/ -: 368:}; -: 369: -: 370:/* -------------------------------------------------------------------- */ -: 371: -: 372:int function get_packer called 3745 returned 100% blocks executed 50% 3745: 373:get_packer(ImagingEncoderObject* encoder, const char* mode, -: 374: const char* rawmode) -: 375:{ -: 376: int bits; -: 377: ImagingShuffler pack; -: 378: 3745: 379: pack = ImagingFindPacker(mode, rawmode, &bits); call 0 returned 100% 3745: 380: if (!pack) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 381: Py_DECREF(encoder); #####: 382: PyErr_Format(PyExc_ValueError, "No packer found from %s to %s", mode, rawmode); call 0 never executed #####: 383: return -1; -: 384: } -: 385: 3745: 386: encoder->state.shuffle = pack; 3745: 387: encoder->state.bits = bits; -: 388: 3745: 389: return 0; -: 390:} -: 391: -: 392: -: 393:/* -------------------------------------------------------------------- */ -: 394:/* EPS */ -: 395:/* -------------------------------------------------------------------- */ -: 396: -: 397:PyObject* function PyImaging_EpsEncoderNew called 20 returned 100% blocks executed 100% 20: 398:PyImaging_EpsEncoderNew(PyObject* self, PyObject* args) -: 399:{ -: 400: ImagingEncoderObject* encoder; -: 401: 20: 402: encoder = PyImaging_EncoderNew(0); call 0 returned 100% 20: 403: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 404: return NULL; -: 405: } -: 406: 20: 407: encoder->encode = ImagingEpsEncode; -: 408: 20: 409: return (PyObject*) encoder; -: 410:} -: 411: -: 412: -: 413:/* -------------------------------------------------------------------- */ -: 414:/* GIF */ -: 415:/* -------------------------------------------------------------------- */ -: 416: -: 417:PyObject* function PyImaging_GifEncoderNew called 107 returned 100% blocks executed 100% 107: 418:PyImaging_GifEncoderNew(PyObject* self, PyObject* args) -: 419:{ -: 420: ImagingEncoderObject* encoder; -: 421: -: 422: char *mode; -: 423: char *rawmode; 107: 424: Py_ssize_t bits = 8; 107: 425: Py_ssize_t interlace = 0; 107: 426: if (!PyArg_ParseTuple(args, "ss|nn", &mode, &rawmode, &bits, &interlace)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 427: return NULL; -: 428: } -: 429: 107: 430: encoder = PyImaging_EncoderNew(sizeof(GIFENCODERSTATE)); call 0 returned 100% 107: 431: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 432: return NULL; -: 433: } -: 434: 107: 435: if (get_packer(encoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 436: return NULL; -: 437: } -: 438: 107: 439: encoder->encode = ImagingGifEncode; -: 440: 107: 441: ((GIFENCODERSTATE*)encoder->state.context)->bits = bits; 107: 442: ((GIFENCODERSTATE*)encoder->state.context)->interlace = interlace; -: 443: 107: 444: return (PyObject*) encoder; -: 445:} -: 446: -: 447: -: 448:/* -------------------------------------------------------------------- */ -: 449:/* PCX */ -: 450:/* -------------------------------------------------------------------- */ -: 451: -: 452:PyObject* function PyImaging_PcxEncoderNew called 17 returned 100% blocks executed 100% 17: 453:PyImaging_PcxEncoderNew(PyObject* self, PyObject* args) -: 454:{ -: 455: ImagingEncoderObject* encoder; -: 456: -: 457: char *mode; -: 458: char *rawmode; 17: 459: Py_ssize_t bits = 8; -: 460: 17: 461: if (!PyArg_ParseTuple(args, "ss|n", &mode, &rawmode, &bits)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 462: return NULL; -: 463: } -: 464: 17: 465: encoder = PyImaging_EncoderNew(0); call 0 returned 100% 17: 466: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 467: return NULL; -: 468: } -: 469: 17: 470: if (get_packer(encoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 471: return NULL; -: 472: } -: 473: 17: 474: encoder->encode = ImagingPcxEncode; -: 475: 17: 476: return (PyObject*) encoder; -: 477:} -: 478: -: 479: -: 480:/* -------------------------------------------------------------------- */ -: 481:/* RAW */ -: 482:/* -------------------------------------------------------------------- */ -: 483: -: 484:PyObject* function PyImaging_RawEncoderNew called 3309 returned 100% blocks executed 100% 3309: 485:PyImaging_RawEncoderNew(PyObject* self, PyObject* args) -: 486:{ -: 487: ImagingEncoderObject* encoder; -: 488: -: 489: char *mode; -: 490: char *rawmode; 3309: 491: Py_ssize_t stride = 0; 3309: 492: Py_ssize_t ystep = 1; -: 493: 3309: 494: if (!PyArg_ParseTuple(args, "ss|nn", &mode, &rawmode, &stride, &ystep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 495: return NULL; -: 496: } -: 497: 3309: 498: encoder = PyImaging_EncoderNew(0); call 0 returned 100% 3309: 499: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 500: return NULL; -: 501: } -: 502: 3309: 503: if (get_packer(encoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 504: return NULL; -: 505: } -: 506: 3309: 507: encoder->encode = ImagingRawEncode; -: 508: 3309: 509: encoder->state.ystep = ystep; 3309: 510: encoder->state.count = stride; -: 511: 3309: 512: return (PyObject*) encoder; -: 513:} -: 514: -: 515: -: 516:/* -------------------------------------------------------------------- */ -: 517:/* TGA */ -: 518:/* -------------------------------------------------------------------- */ -: 519: -: 520:PyObject* function PyImaging_TgaRleEncoderNew called 20 returned 100% blocks executed 100% 20: 521:PyImaging_TgaRleEncoderNew(PyObject* self, PyObject* args) -: 522:{ -: 523: ImagingEncoderObject* encoder; -: 524: -: 525: char *mode; -: 526: char *rawmode; 20: 527: Py_ssize_t ystep = 1; -: 528: 20: 529: if (!PyArg_ParseTuple(args, "ss|n", &mode, &rawmode, &ystep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 530: return NULL; -: 531: } -: 532: 20: 533: encoder = PyImaging_EncoderNew(0); call 0 returned 100% 20: 534: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 535: return NULL; -: 536: } -: 537: 20: 538: if (get_packer(encoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 539: return NULL; -: 540: } -: 541: 20: 542: encoder->encode = ImagingTgaRleEncode; -: 543: 20: 544: encoder->state.ystep = ystep; -: 545: 20: 546: return (PyObject*) encoder; -: 547:} -: 548: -: 549: -: 550: -: 551:/* -------------------------------------------------------------------- */ -: 552:/* XBM */ -: 553:/* -------------------------------------------------------------------- */ -: 554: -: 555:PyObject* function PyImaging_XbmEncoderNew called 4 returned 100% blocks executed 100% 4: 556:PyImaging_XbmEncoderNew(PyObject* self, PyObject* args) -: 557:{ -: 558: ImagingEncoderObject* encoder; -: 559: 4: 560: encoder = PyImaging_EncoderNew(0); call 0 returned 100% 4: 561: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 562: return NULL; -: 563: } -: 564: 4: 565: if (get_packer(encoder, "1", "1;R") < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 566: return NULL; -: 567: } -: 568: 4: 569: encoder->encode = ImagingXbmEncode; -: 570: 4: 571: return (PyObject*) encoder; -: 572:} -: 573: -: 574: -: 575:/* -------------------------------------------------------------------- */ -: 576:/* ZIP */ -: 577:/* -------------------------------------------------------------------- */ -: 578: -: 579:#ifdef HAVE_LIBZ -: 580: -: 581:#include "libImaging/ZipCodecs.h" -: 582: -: 583:PyObject* function PyImaging_ZipEncoderNew called 131 returned 100% blocks executed 72% 131: 584:PyImaging_ZipEncoderNew(PyObject* self, PyObject* args) -: 585:{ -: 586: ImagingEncoderObject* encoder; -: 587: -: 588: char* mode; -: 589: char* rawmode; 131: 590: Py_ssize_t optimize = 0; 131: 591: Py_ssize_t compress_level = -1; 131: 592: Py_ssize_t compress_type = -1; 131: 593: char* dictionary = NULL; 131: 594: Py_ssize_t dictionary_size = 0; 131: 595: if (!PyArg_ParseTuple(args, "ss|nnny#", &mode, &rawmode, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 596: &optimize, -: 597: &compress_level, &compress_type, -: 598: &dictionary, &dictionary_size)) { -: 599: return NULL; -: 600: } -: 601: -: 602: /* Copy to avoid referencing Python's memory */ 131: 603: if (dictionary && dictionary_size > 0) { branch 0 taken 76% (fallthrough) branch 1 taken 24% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 604: /* malloc check ok, size comes from PyArg_ParseTuple */ #####: 605: char* p = malloc(dictionary_size); #####: 606: if (!p) { branch 0 never executed branch 1 never executed #####: 607: return PyErr_NoMemory(); call 0 never executed -: 608: } #####: 609: memcpy(p, dictionary, dictionary_size); #####: 610: dictionary = p; -: 611: } else { 131: 612: dictionary = NULL; -: 613: } -: 614: 131: 615: encoder = PyImaging_EncoderNew(sizeof(ZIPSTATE)); call 0 returned 100% 131: 616: if (encoder == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 617: free(dictionary); #####: 618: return NULL; -: 619: } -: 620: 131: 621: if (get_packer(encoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 622: free(dictionary); #####: 623: return NULL; -: 624: } -: 625: 131: 626: encoder->encode = ImagingZipEncode; 131: 627: encoder->cleanup = ImagingZipEncodeCleanup; -: 628: 131: 629: if (rawmode[0] == 'P') { branch 0 taken 9% (fallthrough) branch 1 taken 91% -: 630: /* disable filtering */ 12: 631: ((ZIPSTATE*)encoder->state.context)->mode = ZIP_PNG_PALETTE; -: 632: } -: 633: 131: 634: ((ZIPSTATE*)encoder->state.context)->optimize = optimize; 131: 635: ((ZIPSTATE*)encoder->state.context)->compress_level = compress_level; 131: 636: ((ZIPSTATE*)encoder->state.context)->compress_type = compress_type; 131: 637: ((ZIPSTATE*)encoder->state.context)->dictionary = dictionary; 131: 638: ((ZIPSTATE*)encoder->state.context)->dictionary_size = dictionary_size; -: 639: 131: 640: return (PyObject*) encoder; -: 641:} -: 642:#endif -: 643: -: 644: -: 645:/* -------------------------------------------------------------------- */ -: 646:/* LibTiff */ -: 647:/* -------------------------------------------------------------------- */ -: 648: -: 649:#ifdef HAVE_LIBTIFF -: 650: -: 651:#include "libImaging/TiffDecode.h" -: 652: -: 653:#include -: 654: -: 655:PyObject* -: 656:PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args) -: 657:{ -: 658: ImagingEncoderObject* encoder; -: 659: -: 660: char* mode; -: 661: char* rawmode; -: 662: char* compname; -: 663: char* filename; -: 664: Py_ssize_t fp; -: 665: -: 666: PyObject *tags, *types; -: 667: PyObject *key, *value; -: 668: Py_ssize_t pos = 0; -: 669: int key_int, status, is_core_tag, is_var_length, num_core_tags, i; -: 670: TIFFDataType type = TIFF_NOTYPE; -: 671: // This list also exists in TiffTags.py -: 672: const int core_tags[] = { -: 673: 256, 257, 258, 259, 262, 263, 266, 269, 274, 277, 278, 280, 281, 340, -: 674: 341, 282, 283, 284, 286, 287, 296, 297, 320, 321, 338, 32995, 32998, 32996, -: 675: 339, 32997, 330, 531, 530, 65537 -: 676: }; -: 677: -: 678: Py_ssize_t tags_size; -: 679: PyObject *item; -: 680: -: 681: if (! PyArg_ParseTuple(args, "sssnsOO", &mode, &rawmode, &compname, &fp, &filename, &tags, &types)) { -: 682: return NULL; -: 683: } -: 684: -: 685: if (!PyList_Check(tags)) { -: 686: PyErr_SetString(PyExc_ValueError, "Invalid tags list"); -: 687: return NULL; -: 688: } else { -: 689: tags_size = PyList_Size(tags); -: 690: TRACE(("tags size: %d\n", (int)tags_size)); -: 691: for (pos=0;posstate, filename, fp)) { -: 717: Py_DECREF(encoder); -: 718: PyErr_SetString(PyExc_RuntimeError, "tiff codec initialization failed"); -: 719: return NULL; -: 720: } -: 721: -: 722: num_core_tags = sizeof(core_tags) / sizeof(int); -: 723: for (pos = 0; pos < tags_size; pos++) { -: 724: item = PyList_GetItem(tags, pos); -: 725: // We already checked that tags is a 2-tuple list. -: 726: key = PyTuple_GetItem(item, 0); -: 727: key_int = (int)PyLong_AsLong(key); -: 728: value = PyTuple_GetItem(item, 1); -: 729: status = 0; -: 730: is_core_tag = 0; -: 731: is_var_length = 0; -: 732: type = TIFF_NOTYPE; -: 733: -: 734: for (i=0; i= TIFF_BYTE && type_int <= TIFF_DOUBLE) { -: 746: type = (TIFFDataType)type_int; -: 747: } -: 748: } -: 749: } -: 750: -: 751: -: 752: if (type == TIFF_NOTYPE) { -: 753: // Autodetect type. Types should not be changed for backwards -: 754: // compatibility. -: 755: if (PyLong_Check(value)) { -: 756: type = TIFF_LONG; -: 757: } else if (PyFloat_Check(value)) { -: 758: type = TIFF_DOUBLE; -: 759: } else if (PyBytes_Check(value)) { -: 760: type = TIFF_ASCII; -: 761: } -: 762: } -: 763: -: 764: if (PyTuple_Check(value)) { -: 765: Py_ssize_t len; -: 766: len = PyTuple_Size(value); -: 767: -: 768: is_var_length = 1; -: 769: -: 770: if (!len) { -: 771: continue; -: 772: } -: 773: -: 774: if (type == TIFF_NOTYPE) { -: 775: // Autodetect type based on first item. Types should not be -: 776: // changed for backwards compatibility. -: 777: if (PyLong_Check(PyTuple_GetItem(value,0))) { -: 778: type = TIFF_LONG; -: 779: } else if (PyFloat_Check(PyTuple_GetItem(value,0))) { -: 780: type = TIFF_FLOAT; -: 781: } -: 782: } -: 783: } -: 784: -: 785: if (!is_core_tag) { -: 786: // Register field for non core tags. -: 787: if (type == TIFF_BYTE) { -: 788: is_var_length = 1; -: 789: } -: 790: if (ImagingLibTiffMergeFieldInfo(&encoder->state, type, key_int, is_var_length)) { -: 791: continue; -: 792: } -: 793: } -: 794: -: 795: if (type == TIFF_BYTE || type == TIFF_UNDEFINED) { -: 796: status = ImagingLibTiffSetField(&encoder->state, -: 797: (ttag_t) key_int, -: 798: PyBytes_Size(value), PyBytes_AsString(value)); -: 799: } else if (is_var_length) { -: 800: Py_ssize_t len,i; -: 801: TRACE(("Setting from Tuple: %d \n", key_int)); -: 802: len = PyTuple_Size(value); -: 803: -: 804: if (key_int == TIFFTAG_COLORMAP) { -: 805: int stride = 256; -: 806: if (len != 768) { -: 807: PyErr_SetString(PyExc_ValueError, "Requiring 768 items for for Colormap"); -: 808: return NULL; -: 809: } -: 810: UINT16 *av; -: 811: /* malloc check ok, calloc checks for overflow */ -: 812: av = calloc(len, sizeof(UINT16)); -: 813: if (av) { -: 814: for (i=0;istate, (ttag_t) key_int, -: 818: av, -: 819: av + stride, -: 820: av + stride * 2); -: 821: free(av); -: 822: } -: 823: } else if (type == TIFF_SHORT) { -: 824: UINT16 *av; -: 825: /* malloc check ok, calloc checks for overflow */ -: 826: av = calloc(len, sizeof(UINT16)); -: 827: if (av) { -: 828: for (i=0;istate, (ttag_t) key_int, len, av); -: 832: free(av); -: 833: } -: 834: } else if (type == TIFF_LONG) { -: 835: UINT32 *av; -: 836: /* malloc check ok, calloc checks for overflow */ -: 837: av = calloc(len, sizeof(UINT32)); -: 838: if (av) { -: 839: for (i=0;istate, (ttag_t) key_int, len, av); -: 843: free(av); -: 844: } -: 845: } else if (type == TIFF_SBYTE) { -: 846: INT8 *av; -: 847: /* malloc check ok, calloc checks for overflow */ -: 848: av = calloc(len, sizeof(INT8)); -: 849: if (av) { -: 850: for (i=0;istate, (ttag_t) key_int, len, av); -: 854: free(av); -: 855: } -: 856: } else if (type == TIFF_SSHORT) { -: 857: INT16 *av; -: 858: /* malloc check ok, calloc checks for overflow */ -: 859: av = calloc(len, sizeof(INT16)); -: 860: if (av) { -: 861: for (i=0;istate, (ttag_t) key_int, len, av); -: 865: free(av); -: 866: } -: 867: } else if (type == TIFF_SLONG) { -: 868: INT32 *av; -: 869: /* malloc check ok, calloc checks for overflow */ -: 870: av = calloc(len, sizeof(INT32)); -: 871: if (av) { -: 872: for (i=0;istate, (ttag_t) key_int, len, av); -: 876: free(av); -: 877: } -: 878: } else if (type == TIFF_FLOAT) { -: 879: FLOAT32 *av; -: 880: /* malloc check ok, calloc checks for overflow */ -: 881: av = calloc(len, sizeof(FLOAT32)); -: 882: if (av) { -: 883: for (i=0;istate, (ttag_t) key_int, len, av); -: 887: free(av); -: 888: } -: 889: } else if (type == TIFF_DOUBLE) { -: 890: FLOAT64 *av; -: 891: /* malloc check ok, calloc checks for overflow */ -: 892: av = calloc(len, sizeof(FLOAT64)); -: 893: if (av) { -: 894: for (i=0;istate, (ttag_t) key_int, len, av); -: 898: free(av); -: 899: } -: 900: } -: 901: } else { -: 902: if (type == TIFF_SHORT) { -: 903: status = ImagingLibTiffSetField(&encoder->state, -: 904: (ttag_t) key_int, -: 905: (UINT16)PyLong_AsLong(value)); -: 906: } else if (type == TIFF_LONG) { -: 907: status = ImagingLibTiffSetField(&encoder->state, -: 908: (ttag_t) key_int, -: 909: (UINT32)PyLong_AsLong(value)); -: 910: } else if (type == TIFF_SSHORT) { -: 911: status = ImagingLibTiffSetField(&encoder->state, -: 912: (ttag_t) key_int, -: 913: (INT16)PyLong_AsLong(value)); -: 914: } else if (type == TIFF_SLONG) { -: 915: status = ImagingLibTiffSetField(&encoder->state, -: 916: (ttag_t) key_int, -: 917: (INT32)PyLong_AsLong(value)); -: 918: } else if (type == TIFF_FLOAT) { -: 919: status = ImagingLibTiffSetField(&encoder->state, -: 920: (ttag_t) key_int, -: 921: (FLOAT32)PyFloat_AsDouble(value)); -: 922: } else if (type == TIFF_DOUBLE) { -: 923: status = ImagingLibTiffSetField(&encoder->state, -: 924: (ttag_t) key_int, -: 925: (FLOAT64)PyFloat_AsDouble(value)); -: 926: } else if (type == TIFF_SBYTE) { -: 927: status = ImagingLibTiffSetField(&encoder->state, -: 928: (ttag_t) key_int, -: 929: (INT8)PyLong_AsLong(value)); -: 930: } else if (type == TIFF_ASCII) { -: 931: status = ImagingLibTiffSetField(&encoder->state, -: 932: (ttag_t) key_int, -: 933: PyBytes_AsString(value)); -: 934: } else if (type == TIFF_RATIONAL) { -: 935: status = ImagingLibTiffSetField(&encoder->state, -: 936: (ttag_t) key_int, -: 937: (FLOAT64)PyFloat_AsDouble(value)); -: 938: } else { -: 939: TRACE(("Unhandled type for key %d : %s \n", -: 940: key_int, -: 941: PyBytes_AsString(PyObject_Str(value)))); -: 942: } -: 943: } -: 944: if (!status) { -: 945: TRACE(("Error setting Field\n")); -: 946: Py_DECREF(encoder); -: 947: PyErr_SetString(PyExc_RuntimeError, "Error setting from dictionary"); -: 948: return NULL; -: 949: } -: 950: } -: 951: -: 952: encoder->encode = ImagingLibTiffEncode; -: 953: -: 954: return (PyObject*) encoder; -: 955:} -: 956: -: 957:#endif -: 958: -: 959:/* -------------------------------------------------------------------- */ -: 960:/* JPEG */ -: 961:/* -------------------------------------------------------------------- */ -: 962: -: 963:#ifdef HAVE_LIBJPEG -: 964: -: 965:/* We better define this encoder last in this file, so the following -: 966: undef's won't mess things up for the Imaging library proper. */ -: 967: -: 968:#undef HAVE_PROTOTYPES -: 969:#undef HAVE_STDDEF_H -: 970:#undef HAVE_STDLIB_H -: 971:#undef UINT8 -: 972:#undef UINT16 -: 973:#undef UINT32 -: 974:#undef INT8 -: 975:#undef INT16 -: 976:#undef INT32 -: 977: -: 978:#include "libImaging/Jpeg.h" -: 979: function get_qtables_arrays called 157 returned 100% blocks executed 63% 157: 980:static unsigned int* get_qtables_arrays(PyObject* qtables, int* qtablesLen) { -: 981: PyObject* tables; -: 982: PyObject* table; -: 983: PyObject* table_data; -: 984: int i, j, num_tables; -: 985: unsigned int *qarrays; -: 986: 157: 987: if ((qtables == NULL) || (qtables == Py_None)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 20% (fallthrough) branch 3 taken 80% -: 988: return NULL; -: 989: } -: 990: 32: 991: if (!PySequence_Check(qtables)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 992: PyErr_SetString(PyExc_ValueError, "Invalid quantization tables"); call 0 never executed #####: 993: return NULL; -: 994: } -: 995: 32: 996: tables = PySequence_Fast(qtables, "expected a sequence"); call 0 returned 100% 32: 997: num_tables = PySequence_Size(qtables); call 0 returned 100% 32: 998: if (num_tables < 1 || num_tables > NUM_QUANT_TBLS) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 999: PyErr_SetString(PyExc_ValueError, call 0 never executed -: 1000: "Not a valid number of quantization tables. Should be between 1 and 4."); #####: 1001: Py_DECREF(tables); -: 1002: return NULL; -: 1003: } -: 1004: /* malloc check ok, num_tables <4, DCTSIZE2 == 64 from jpeglib.h */ 32: 1005: qarrays = (unsigned int*) malloc(num_tables * DCTSIZE2 * sizeof(unsigned int)); 32: 1006: if (!qarrays) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 1007: Py_DECREF(tables); #####: 1008: PyErr_NoMemory(); call 0 never executed #####: 1009: return NULL; -: 1010: } 63: 1011: for (i = 0; i < num_tables; i++) { branch 0 taken 66% branch 1 taken 34% (fallthrough) 63: 1012: table = PySequence_Fast_GET_ITEM(tables, i); branch 0 taken 100% (fallthrough) branch 1 taken 0% 63: 1013: if (!PySequence_Check(table)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 1014: PyErr_SetString(PyExc_ValueError, "Invalid quantization tables"); call 0 never executed #####: 1015: goto JPEG_QTABLES_ERR; -: 1016: } 63: 1017: if (PySequence_Size(table) != DCTSIZE2) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 1018: PyErr_SetString(PyExc_ValueError, "Invalid quantization table size"); call 0 never executed #####: 1019: goto JPEG_QTABLES_ERR; -: 1020: } 63: 1021: table_data = PySequence_Fast(table, "expected a sequence"); 4095: 1022: for (j = 0; j < DCTSIZE2; j++) { call 0 returned 100% branch 1 taken 98% branch 2 taken 2% (fallthrough) 4032: 1023: qarrays[i * DCTSIZE2 + j] = PyLong_AS_LONG(PySequence_Fast_GET_ITEM(table_data, j)); branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 returned 100% -: 1024: } 126: 1025: Py_DECREF(table_data); -: 1026: } -: 1027: 32: 1028: *qtablesLen = num_tables; -: 1029: -: 1030:JPEG_QTABLES_ERR: 64: 1031: Py_DECREF(tables); // Run on both error and not error 32: 1032: if (PyErr_Occurred()) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 1033: free(qarrays); #####: 1034: qarrays = NULL; #####: 1035: return NULL; -: 1036: } -: 1037: -: 1038: return qarrays; -: 1039:} -: 1040: -: 1041:PyObject* function PyImaging_JpegEncoderNew called 158 returned 100% blocks executed 87% 158: 1042:PyImaging_JpegEncoderNew(PyObject* self, PyObject* args) -: 1043:{ -: 1044: ImagingEncoderObject* encoder; -: 1045: -: 1046: char *mode; -: 1047: char *rawmode; 158: 1048: Py_ssize_t quality = 0; 158: 1049: Py_ssize_t progressive = 0; 158: 1050: Py_ssize_t smooth = 0; 158: 1051: Py_ssize_t optimize = 0; 158: 1052: Py_ssize_t streamtype = 0; /* 0=interchange, 1=tables only, 2=image only */ 158: 1053: Py_ssize_t xdpi = 0, ydpi = 0; 158: 1054: Py_ssize_t subsampling = -1; /* -1=default, 0=none, 1=medium, 2=high */ 158: 1055: PyObject* qtables=NULL; 158: 1056: unsigned int *qarrays = NULL; 158: 1057: int qtablesLen = 0; 158: 1058: char* extra = NULL; -: 1059: Py_ssize_t extra_size; 158: 1060: char* rawExif = NULL; 158: 1061: Py_ssize_t rawExifLen = 0; -: 1062: 158: 1063: if (!PyArg_ParseTuple(args, "ss|nnnnnnnnOy#y#", call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 1064: &mode, &rawmode, &quality, -: 1065: &progressive, &smooth, &optimize, &streamtype, -: 1066: &xdpi, &ydpi, &subsampling, &qtables, &extra, &extra_size, -: 1067: &rawExif, &rawExifLen)) { -: 1068: return NULL; -: 1069: } -: 1070: 157: 1071: encoder = PyImaging_EncoderNew(sizeof(JPEGENCODERSTATE)); call 0 returned 100% 157: 1072: if (encoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1073: return NULL; -: 1074: } -: 1075: -: 1076: // libjpeg-turbo supports different output formats. -: 1077: // We are choosing Pillow's native format (3 color bytes + 1 padding) -: 1078: // to avoid extra conversion in Pack.c. 157: 1079: if (ImagingJpegUseJCSExtensions() && strcmp(rawmode, "RGB") == 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 65% (fallthrough) branch 4 taken 35% branch 5 taken 100% (fallthrough) branch 6 taken 0% branch 7 taken 100% (fallthrough) branch 8 taken 0% branch 9 taken 65% (fallthrough) branch 10 taken 35% 102: 1080: rawmode = "RGBX"; -: 1081: } -: 1082: 157: 1083: if (get_packer(encoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1084: return NULL; -: 1085: } -: 1086: -: 1087: // Freed in JpegEncode, Case 5 157: 1088: qarrays = get_qtables_arrays(qtables, &qtablesLen); call 0 returned 100% -: 1089: 169: 1090: if (extra && extra_size > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 8% (fallthrough) branch 3 taken 92% -: 1091: /* malloc check ok, length is from python parsearg */ 12: 1092: char* p = malloc(extra_size); // Freed in JpegEncode, Case 5 12: 1093: if (!p) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1094: return PyErr_NoMemory(); call 0 never executed -: 1095: } 24: 1096: memcpy(p, extra, extra_size); 12: 1097: extra = p; -: 1098: } else { 145: 1099: extra = NULL; -: 1100: } -: 1101: 162: 1102: if (rawExif && rawExifLen > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 3% (fallthrough) branch 3 taken 97% -: 1103: /* malloc check ok, length is from python parsearg */ 5: 1104: char* pp = malloc(rawExifLen); // Freed in JpegEncode, Case 5 5: 1105: if (!pp) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1106: if (extra) { branch 0 never executed branch 1 never executed #####: 1107: free(extra); -: 1108: } #####: 1109: return PyErr_NoMemory(); call 0 never executed -: 1110: } 10: 1111: memcpy(pp, rawExif, rawExifLen); 5: 1112: rawExif = pp; -: 1113: } else { 152: 1114: rawExif = NULL; -: 1115: } -: 1116: 157: 1117: encoder->encode = ImagingJpegEncode; -: 1118: 314: 1119: strncpy(((JPEGENCODERSTATE*)encoder->state.context)->rawmode, rawmode, 8); -: 1120: 157: 1121: ((JPEGENCODERSTATE*)encoder->state.context)->quality = quality; 157: 1122: ((JPEGENCODERSTATE*)encoder->state.context)->qtables = qarrays; 157: 1123: ((JPEGENCODERSTATE*)encoder->state.context)->qtablesLen = qtablesLen; 157: 1124: ((JPEGENCODERSTATE*)encoder->state.context)->subsampling = subsampling; 157: 1125: ((JPEGENCODERSTATE*)encoder->state.context)->progressive = progressive; 157: 1126: ((JPEGENCODERSTATE*)encoder->state.context)->smooth = smooth; 157: 1127: ((JPEGENCODERSTATE*)encoder->state.context)->optimize = optimize; 157: 1128: ((JPEGENCODERSTATE*)encoder->state.context)->streamtype = streamtype; 157: 1129: ((JPEGENCODERSTATE*)encoder->state.context)->xdpi = xdpi; 157: 1130: ((JPEGENCODERSTATE*)encoder->state.context)->ydpi = ydpi; 157: 1131: ((JPEGENCODERSTATE*)encoder->state.context)->extra = extra; 157: 1132: ((JPEGENCODERSTATE*)encoder->state.context)->extra_size = extra_size; 157: 1133: ((JPEGENCODERSTATE*)encoder->state.context)->rawExif = rawExif; 157: 1134: ((JPEGENCODERSTATE*)encoder->state.context)->rawExifLen = rawExifLen; -: 1135: 157: 1136: return (PyObject*) encoder; -: 1137:} -: 1138: -: 1139:#endif -: 1140: -: 1141: -: 1142:/* -------------------------------------------------------------------- */ -: 1143:/* JPEG 2000 */ -: 1144:/* -------------------------------------------------------------------- */ -: 1145: -: 1146:#ifdef HAVE_OPENJPEG -: 1147: -: 1148:#include "libImaging/Jpeg2K.h" -: 1149: -: 1150:static void function j2k_decode_coord_tuple called 73 returned 100% blocks executed 80% 73: 1151:j2k_decode_coord_tuple(PyObject *tuple, int *x, int *y) -: 1152:{ 73: 1153: *x = *y = 0; -: 1154: 73: 1155: if (tuple && PyTuple_Check(tuple) && PyTuple_GET_SIZE(tuple) == 2) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 10% (fallthrough) branch 3 taken 90% branch 4 taken 100% (fallthrough) branch 5 taken 0% 7: 1156: *x = (int)PyLong_AsLong(PyTuple_GET_ITEM(tuple, 0)); call 0 returned 100% 7: 1157: *y = (int)PyLong_AsLong(PyTuple_GET_ITEM(tuple, 1)); call 0 returned 100% -: 1158: 7: 1159: if (*x < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1160: *x = 0; -: 1161: } 7: 1162: if (*y < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1163: *y = 0; -: 1164: } -: 1165: } 73: 1166:} -: 1167: -: 1168:PyObject* function PyImaging_Jpeg2KEncoderNew called 15 returned 100% blocks executed 76% 15: 1169:PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) -: 1170:{ -: 1171: ImagingEncoderObject *encoder; -: 1172: JPEG2KENCODESTATE *context; -: 1173: -: 1174: char *mode; -: 1175: char *format; -: 1176: OPJ_CODEC_FORMAT codec_format; 15: 1177: PyObject *offset = NULL, *tile_offset = NULL, *tile_size = NULL; 15: 1178: char *quality_mode = "rates"; 15: 1179: PyObject *quality_layers = NULL; 15: 1180: Py_ssize_t num_resolutions = 0; 15: 1181: PyObject *cblk_size = NULL, *precinct_size = NULL; 15: 1182: PyObject *irreversible = NULL; 15: 1183: char *progression = "LRCP"; -: 1184: OPJ_PROG_ORDER prog_order; 15: 1185: char *cinema_mode = "no"; -: 1186: OPJ_CINEMA_MODE cine_mode; 15: 1187: Py_ssize_t fd = -1; -: 1188: 15: 1189: if (!PyArg_ParseTuple(args, "ss|OOOsOnOOOssn", &mode, &format, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 1190: &offset, &tile_offset, &tile_size, -: 1191: &quality_mode, &quality_layers, &num_resolutions, -: 1192: &cblk_size, &precinct_size, -: 1193: &irreversible, &progression, &cinema_mode, -: 1194: &fd)) { -: 1195: return NULL; -: 1196: } -: 1197: 15: 1198: if (strcmp (format, "j2k") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 never executed branch 5 never executed branch 6 taken 100% (fallthrough) branch 7 taken 0% -: 1199: codec_format = OPJ_CODEC_J2K; 15: 1200: } else if (strcmp (format, "jpt") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% branch 6 taken 100% (fallthrough) branch 7 taken 0% -: 1201: codec_format = OPJ_CODEC_JPT; 15: 1202: } else if (strcmp (format, "jp2") == 0) { 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 100% (fallthrough) branch 7 taken 0% -: 1203: codec_format = OPJ_CODEC_JP2; -: 1204: } else { -: 1205: return NULL; -: 1206: } -: 1207: 15: 1208: if (strcmp(progression, "LRCP") == 0) { branch 0 taken 7% (fallthrough) branch 1 taken 93% -: 1209: prog_order = OPJ_LRCP; 1: 1210: } else if (strcmp(progression, "RLCP") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 1211: prog_order = OPJ_RLCP; #####: 1212: } else if (strcmp(progression, "RPCL") == 0) { branch 0 never executed branch 1 never executed -: 1213: prog_order = OPJ_RPCL; #####: 1214: } else if (strcmp(progression, "PCRL") == 0) { branch 0 never executed branch 1 never executed -: 1215: prog_order = OPJ_PCRL; #####: 1216: } else if (strcmp(progression, "CPRL") == 0) { branch 0 never executed branch 1 never executed -: 1217: prog_order = OPJ_CPRL; -: 1218: } else { -: 1219: return NULL; -: 1220: } -: 1221: 15: 1222: if (strcmp(cinema_mode, "no") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% -: 1223: cine_mode = OPJ_OFF; #####: 1224: } else if (strcmp(cinema_mode, "cinema2k-24") == 0) { branch 0 never executed branch 1 never executed -: 1225: cine_mode = OPJ_CINEMA2K_24; #####: 1226: } else if (strcmp(cinema_mode, "cinema2k-48") == 0) { branch 0 never executed branch 1 never executed -: 1227: cine_mode = OPJ_CINEMA2K_48; #####: 1228: } else if (strcmp(cinema_mode, "cinema4k-24") == 0) { branch 0 never executed branch 1 never executed -: 1229: cine_mode = OPJ_CINEMA4K_24; -: 1230: } else { -: 1231: return NULL; -: 1232: } -: 1233: 15: 1234: encoder = PyImaging_EncoderNew(sizeof(JPEG2KENCODESTATE)); call 0 returned 100% 15: 1235: if (!encoder) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1236: return NULL; -: 1237: } -: 1238: 15: 1239: encoder->encode = ImagingJpeg2KEncode; 15: 1240: encoder->cleanup = ImagingJpeg2KEncodeCleanup; 15: 1241: encoder->pushes_fd = 1; -: 1242: 15: 1243: context = (JPEG2KENCODESTATE *)encoder->state.context; -: 1244: 15: 1245: context->fd = fd; 15: 1246: context->format = codec_format; 15: 1247: context->offset_x = context->offset_y = 0; -: 1248: -: 1249: 15: 1250: j2k_decode_coord_tuple(offset, &context->offset_x, &context->offset_y); call 0 returned 100% 15: 1251: j2k_decode_coord_tuple(tile_offset, call 0 returned 100% -: 1252: &context->tile_offset_x, -: 1253: &context->tile_offset_y); 15: 1254: j2k_decode_coord_tuple(tile_size, call 0 returned 100% -: 1255: &context->tile_size_x, -: 1256: &context->tile_size_y); -: 1257: -: 1258: /* Error on illegal tile offsets */ 15: 1259: if (context->tile_size_x && context->tile_size_y) { branch 0 taken 20% (fallthrough) branch 1 taken 80% branch 2 taken 100% (fallthrough) branch 3 taken 0% 3: 1260: if (context->tile_offset_x <= context->offset_x - context->tile_size_x branch 0 taken 67% (fallthrough) branch 1 taken 33% 2: 1261: || context->tile_offset_y <= context->offset_y - context->tile_size_y) { branch 0 taken 0% (fallthrough) branch 1 taken 100% 1: 1262: PyErr_SetString(PyExc_ValueError, call 0 returned 100% -: 1263: "JPEG 2000 tile offset too small; top left tile must " -: 1264: "intersect image area"); 1: 1265: Py_DECREF(encoder); -: 1266: return NULL; -: 1267: } -: 1268: 2: 1269: if (context->tile_offset_x > context->offset_x branch 0 taken 100% (fallthrough) branch 1 taken 0% 2: 1270: || context->tile_offset_y > context->offset_y) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 1271: PyErr_SetString(PyExc_ValueError, call 0 never executed -: 1272: "JPEG 2000 tile offset too large to cover image area"); #####: 1273: Py_DECREF(encoder); -: 1274: return NULL; -: 1275: } -: 1276: } -: 1277: 14: 1278: if (quality_layers && PySequence_Check(quality_layers)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 returned 100% branch 3 taken 43% (fallthrough) branch 4 taken 57% 6: 1279: context->quality_is_in_db = strcmp (quality_mode, "dB") == 0; branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed 6: 1280: context->quality_layers = quality_layers; 6: 1281: Py_INCREF(quality_layers); -: 1282: } -: 1283: 14: 1284: context->num_resolutions = num_resolutions; -: 1285: 14: 1286: j2k_decode_coord_tuple(cblk_size, call 0 returned 100% -: 1287: &context->cblk_width, -: 1288: &context->cblk_height); 14: 1289: j2k_decode_coord_tuple(precinct_size, call 0 returned 100% -: 1290: &context->precinct_width, -: 1291: &context->precinct_height); -: 1292: 14: 1293: context->irreversible = PyObject_IsTrue(irreversible); call 0 returned 100% 14: 1294: context->progression = prog_order; 14: 1295: context->cinema_mode = cine_mode; -: 1296: 14: 1297: return (PyObject *)encoder; -: 1298:} -: 1299: -: 1300:#endif -: 1301: -: 1302:/* -: 1303: * Local Variables: -: 1304: * c-basic-offset: 4 -: 1305: * End: -: 1306: * -: 1307: */ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Storage.c.gcov -: 0:Source:src/libImaging/Storage.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Storage.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Storage.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * imaging storage object -: 6: * -: 7: * This baseline implementation is designed to efficiently handle -: 8: * large images, provided they fit into the available memory. -: 9: * -: 10: * history: -: 11: * 1995-06-15 fl Created -: 12: * 1995-09-12 fl Updated API, compiles silently under ANSI C++ -: 13: * 1995-11-26 fl Compiles silently under Borland 4.5 as well -: 14: * 1996-05-05 fl Correctly test status from Prologue -: 15: * 1997-05-12 fl Increased THRESHOLD (to speed up Tk interface) -: 16: * 1997-05-30 fl Added support for floating point images -: 17: * 1997-11-17 fl Added support for "RGBX" images -: 18: * 1998-01-11 fl Added support for integer images -: 19: * 1998-03-05 fl Exported Prologue/Epilogue functions -: 20: * 1998-07-01 fl Added basic "YCrCb" support -: 21: * 1998-07-03 fl Attach palette in prologue for "P" images -: 22: * 1998-07-09 hk Don't report MemoryError on zero-size images -: 23: * 1998-07-12 fl Change "YCrCb" to "YCbCr" (!) -: 24: * 1998-10-26 fl Added "I;16" and "I;16B" storage modes (experimental) -: 25: * 1998-12-29 fl Fixed allocation bug caused by previous fix -: 26: * 1999-02-03 fl Added "RGBa" and "BGR" modes (experimental) -: 27: * 2001-04-22 fl Fixed potential memory leak in ImagingCopyPalette -: 28: * 2003-09-26 fl Added "LA" and "PA" modes (experimental) -: 29: * 2005-10-02 fl Added image counter -: 30: * -: 31: * Copyright (c) 1998-2005 by Secret Labs AB -: 32: * Copyright (c) 1995-2005 by Fredrik Lundh -: 33: * -: 34: * See the README file for information on usage and redistribution. -: 35: */ -: 36: -: 37: -: 38:#include "Imaging.h" -: 39:#include -: 40: -: 41: -: 42:int ImagingNewCount = 0; -: 43: -: 44:/* -------------------------------------------------------------------- -: 45: * Standard image object. -: 46: */ -: 47: -: 48:Imaging function ImagingNewPrologueSubtype called 1088136 returned 100% blocks executed 97% 1088136: 49:ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int size) -: 50:{ -: 51: Imaging im; -: 52: -: 53: /* linesize overflow check, roughly the current largest space req'd */ 1088136: 54: if (xsize > (INT_MAX / 4) - 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 55: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 56: } -: 57: 1088136: 58: im = (Imaging) calloc(1, size); 1088136: 59: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 60: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 61: } -: 62: -: 63: /* Setup image descriptor */ 1088136: 64: im->xsize = xsize; 1088136: 65: im->ysize = ysize; -: 66: 1088136: 67: im->type = IMAGING_TYPE_UINT8; -: 68: 1088136: 69: if (strcmp(mode, "1") == 0) { branch 0 taken 96% (fallthrough) branch 1 taken 4% branch 2 taken 96% (fallthrough) branch 3 taken 4% -: 70: /* 1-bit images */ 1041541: 71: im->bands = im->pixelsize = 1; 1041541: 72: im->linesize = xsize; -: 73: 46595: 74: } else if (strcmp(mode, "P") == 0) { branch 0 taken 4% (fallthrough) branch 1 taken 96% branch 2 taken 4% (fallthrough) branch 3 taken 96% -: 75: /* 8-bit palette mapped images */ 1959: 76: im->bands = im->pixelsize = 1; 1959: 77: im->linesize = xsize; 1959: 78: im->palette = ImagingPaletteNew("RGB"); call 0 returned 100% -: 79: 44636: 80: } else if (strcmp(mode, "PA") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 1% (fallthrough) branch 5 taken 99% -: 81: /* 8-bit palette with alpha */ 78: 82: im->bands = 2; 78: 83: im->pixelsize = 4; /* store in image32 memory */ 78: 84: im->linesize = xsize * 4; 78: 85: im->palette = ImagingPaletteNew("RGB"); call 0 returned 100% -: 86: 44558: 87: } else if (strcmp(mode, "L") == 0) { branch 0 taken 21% (fallthrough) branch 1 taken 79% branch 2 taken 18% (fallthrough) branch 3 taken 82% -: 88: /* 8-bit greyscale (luminance) images */ 8106: 89: im->bands = im->pixelsize = 1; 8106: 90: im->linesize = xsize; -: 91: 36452: 92: } else if (strcmp(mode, "LA") == 0) { branch 0 taken 3% (fallthrough) branch 1 taken 97% branch 2 taken 40% (fallthrough) branch 3 taken 60% branch 4 taken 1% (fallthrough) branch 5 taken 99% -: 93: /* 8-bit greyscale (luminance) with alpha */ 376: 94: im->bands = 2; 376: 95: im->pixelsize = 4; /* store in image32 memory */ 376: 96: im->linesize = xsize * 4; -: 97: 36076: 98: } else if (strcmp(mode, "La") == 0) { branch 0 taken 2% (fallthrough) branch 1 taken 98% branch 2 taken 95% (fallthrough) branch 3 taken 5% branch 4 taken 2% (fallthrough) branch 5 taken 98% -: 99: /* 8-bit greyscale (luminance) with premultiplied alpha */ 619: 100: im->bands = 2; 619: 101: im->pixelsize = 4; /* store in image32 memory */ 619: 102: im->linesize = xsize * 4; -: 103: 35457: 104: } else if (strcmp(mode, "F") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 1% (fallthrough) branch 3 taken 99% -: 105: /* 32-bit floating point images */ 444: 106: im->bands = 1; 444: 107: im->pixelsize = 4; 444: 108: im->linesize = xsize * 4; 444: 109: im->type = IMAGING_TYPE_FLOAT32; -: 110: 35013: 111: } else if (strcmp(mode, "I") == 0) { branch 0 taken 22% (fallthrough) branch 1 taken 78% branch 2 taken 21% (fallthrough) branch 3 taken 79% -: 112: /* 32-bit integer images */ 7411: 113: im->bands = 1; 7411: 114: im->pixelsize = 4; 7411: 115: im->linesize = xsize * 4; 7411: 116: im->type = IMAGING_TYPE_INT32; -: 117: 27602: 118: } else if (strcmp(mode, "I;16") == 0 || strcmp(mode, "I;16L") == 0 \ branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% 27414: 119: || strcmp(mode, "I;16B") == 0 || strcmp(mode, "I;16N") == 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% -: 120: /* EXPERIMENTAL */ -: 121: /* 16-bit raw integer images */ 288: 122: im->bands = 1; 288: 123: im->pixelsize = 2; 288: 124: im->linesize = xsize * 2; 288: 125: im->type = IMAGING_TYPE_SPECIAL; -: 126: 27314: 127: } else if (strcmp(mode, "RGB") == 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 88% (fallthrough) branch 7 taken 12% -: 128: /* 24-bit true colour images */ 23994: 129: im->bands = 3; 23994: 130: im->pixelsize = 4; 23994: 131: im->linesize = xsize * 4; -: 132: 3320: 133: } else if (strcmp(mode, "BGR;15") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 134: /* EXPERIMENTAL */ -: 135: /* 15-bit reversed true colour */ 6: 136: im->bands = 1; 6: 137: im->pixelsize = 2; 6: 138: im->linesize = (xsize*2 + 3) & -4; 6: 139: im->type = IMAGING_TYPE_SPECIAL; -: 140: 3314: 141: } else if (strcmp(mode, "BGR;16") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 142: /* EXPERIMENTAL */ -: 143: /* 16-bit reversed true colour */ 1: 144: im->bands = 1; 1: 145: im->pixelsize = 2; 1: 146: im->linesize = (xsize*2 + 3) & -4; 1: 147: im->type = IMAGING_TYPE_SPECIAL; -: 148: 3313: 149: } else if (strcmp(mode, "BGR;24") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 150: /* EXPERIMENTAL */ -: 151: /* 24-bit reversed true colour */ 1: 152: im->bands = 1; 1: 153: im->pixelsize = 3; 1: 154: im->linesize = (xsize*3 + 3) & -4; 1: 155: im->type = IMAGING_TYPE_SPECIAL; -: 156: 3312: 157: } else if (strcmp(mode, "BGR;32") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 158: /* EXPERIMENTAL */ -: 159: /* 32-bit reversed true colour */ 1: 160: im->bands = 1; 1: 161: im->pixelsize = 4; 1: 162: im->linesize = (xsize*4 + 3) & -4; 1: 163: im->type = IMAGING_TYPE_SPECIAL; -: 164: 3311: 165: } else if (strcmp(mode, "RGBX") == 0) { branch 0 taken 3% (fallthrough) branch 1 taken 97% -: 166: /* 32-bit true colour images with padding */ 111: 167: im->bands = im->pixelsize = 4; 111: 168: im->linesize = xsize * 4; -: 169: 3200: 170: } else if (strcmp(mode, "RGBA") == 0) { branch 0 taken 69% (fallthrough) branch 1 taken 31% -: 171: /* 32-bit true colour images with alpha */ 2194: 172: im->bands = im->pixelsize = 4; 2194: 173: im->linesize = xsize * 4; -: 174: 1006: 175: } else if (strcmp(mode, "RGBa") == 0) { branch 0 taken 64% (fallthrough) branch 1 taken 36% -: 176: /* 32-bit true colour images with premultiplied alpha */ 647: 177: im->bands = im->pixelsize = 4; 647: 178: im->linesize = xsize * 4; -: 179: 359: 180: } else if (strcmp(mode, "CMYK") == 0) { branch 0 taken 50% (fallthrough) branch 1 taken 50% -: 181: /* 32-bit colour separation */ 178: 182: im->bands = im->pixelsize = 4; 178: 183: im->linesize = xsize * 4; -: 184: 181: 185: } else if (strcmp(mode, "YCbCr") == 0) { branch 0 taken 44% (fallthrough) branch 1 taken 56% -: 186: /* 24-bit video format */ 79: 187: im->bands = 3; 79: 188: im->pixelsize = 4; 79: 189: im->linesize = xsize * 4; -: 190: 102: 191: } else if (strcmp(mode, "LAB") == 0) { branch 0 taken 33% (fallthrough) branch 1 taken 67% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 33% (fallthrough) branch 7 taken 67% -: 192: /* 24-bit color, luminance, + 2 color channels */ -: 193: /* L is uint8, a,b are int8 */ 34: 194: im->bands = 3; 34: 195: im->pixelsize = 4; 34: 196: im->linesize = xsize * 4; -: 197: 68: 198: } else if (strcmp(mode, "HSV") == 0) { branch 0 taken 91% (fallthrough) branch 1 taken 9% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 91% (fallthrough) branch 7 taken 9% -: 199: /* 24-bit color, luminance, + 2 color channels */ -: 200: /* L is uint8, a,b are int8 */ 62: 201: im->bands = 3; 62: 202: im->pixelsize = 4; 62: 203: im->linesize = xsize * 4; -: 204: -: 205: } else { 6: 206: free(im); 6: 207: return (Imaging) ImagingError_ValueError("unrecognized image mode"); call 0 returned 100% -: 208: } -: 209: -: 210: /* Setup image descriptor */ 2176260: 211: strcpy(im->mode, mode); -: 212: -: 213: /* Pointer array (allocate at least one line, to avoid MemoryError -: 214: exceptions on platforms where calloc(0, x) returns NULL) */ 1088130: 215: im->image = (char **) calloc((ysize > 0) ? ysize : 1, sizeof(void *)); -: 216: 1088130: 217: if ( ! im->image) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 218: free(im); #####: 219: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 220: } -: 221: -: 222: /* Initialize alias pointers to pixel data. */ 1088130: 223: switch (im->pixelsize) { branch 0 taken 97% branch 1 taken 3% branch 2 taken 0% -: 224: case 1: case 2: case 3: 1051902: 225: im->image8 = (UINT8 **) im->image; 1051902: 226: break; -: 227: case 4: 36228: 228: im->image32 = (INT32 **) im->image; 36228: 229: break; -: 230: } -: 231: 1088130: 232: ImagingDefaultArena.stats_new_count += 1; -: 233: 1088130: 234: return im; -: 235:} -: 236: -: 237:Imaging function ImagingNewPrologue called 1088030 returned 100% blocks executed 100% 1088030: 238:ImagingNewPrologue(const char *mode, int xsize, int ysize) -: 239:{ 1088030: 240: return ImagingNewPrologueSubtype( call 0 returned 100% -: 241: mode, xsize, ysize, sizeof(struct ImagingMemoryInstance)); -: 242:} -: 243: -: 244:void function ImagingDelete called 1088158 returned 100% blocks executed 100% 1088158: 245:ImagingDelete(Imaging im) -: 246:{ 1088158: 247: if (!im) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 248: return; -: 249: } -: 250: 1088090: 251: if (im->palette) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 2165: 252: ImagingPaletteDelete(im->palette); call 0 returned 100% -: 253: } -: 254: 1088090: 255: if (im->destroy) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 1087600: 256: im->destroy(im); call 0 returned 100% -: 257: } -: 258: 1088090: 259: if (im->image) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1088090: 260: free(im->image); -: 261: } -: 262: 1088090: 263: free(im); -: 264:} -: 265: -: 266: -: 267:/* Array Storage Type */ -: 268:/* ------------------ */ -: 269:/* Allocate image as an array of line buffers. */ -: 270: -: 271:#define IMAGING_PAGE_SIZE (4096) -: 272: -: 273:struct ImagingMemoryArena ImagingDefaultArena = { -: 274: 1, // alignment -: 275: 16*1024*1024, // block_size -: 276: 0, // blocks_max -: 277: 0, // blocks_cached -: 278: NULL, // blocks_pool -: 279: 0, 0, 0, 0, 0 // Stats -: 280:}; -: 281: -: 282:int function ImagingMemorySetBlocksMax called 20 returned 100% blocks executed 100% 20: 283:ImagingMemorySetBlocksMax(ImagingMemoryArena arena, int blocks_max) -: 284:{ -: 285: void *p; -: 286: /* Free already cached blocks */ 20: 287: ImagingMemoryClearCache(arena, blocks_max); call 0 returned 100% -: 288: 20: 289: if (blocks_max == 0 && arena->blocks_pool != NULL) { branch 0 taken 75% (fallthrough) branch 1 taken 25% branch 2 taken 60% (fallthrough) branch 3 taken 40% 9: 290: free(arena->blocks_pool); 9: 291: arena->blocks_pool = NULL; 11: 292: } else if (arena->blocks_pool != NULL) { branch 0 taken 9% (fallthrough) branch 1 taken 91% 1: 293: p = realloc(arena->blocks_pool, sizeof(*arena->blocks_pool) * blocks_max); 1: 294: if ( ! p) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 295: // Leave previous blocks_max value -: 296: return 0; -: 297: } 1: 298: arena->blocks_pool = p; -: 299: } else { 10: 300: arena->blocks_pool = calloc(sizeof(*arena->blocks_pool), blocks_max); 10: 301: if ( ! arena->blocks_pool) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 302: return 0; -: 303: } -: 304: } 20: 305: arena->blocks_max = blocks_max; -: 306: 20: 307: return 1; -: 308:} -: 309: -: 310:void function ImagingMemoryClearCache called 38 returned 100% blocks executed 100% 38: 311:ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size) -: 312:{ 205: 313: while (arena->blocks_cached > new_size) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 129: 314: arena->blocks_cached -= 1; 129: 315: free(arena->blocks_pool[arena->blocks_cached].ptr); 129: 316: arena->stats_freed_blocks += 1; -: 317: } 38: 318:} -: 319: -: 320:ImagingMemoryBlock function memory_get_block called 1089213 returned 100% blocks executed 73% 1089213: 321:memory_get_block(ImagingMemoryArena arena, int requested_size, int dirty) -: 322:{ 1089213: 323: ImagingMemoryBlock block = {NULL, 0}; -: 324: 1089213: 325: if (arena->blocks_cached > 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 326: // Get block from cache 129: 327: arena->blocks_cached -= 1; 129: 328: block = arena->blocks_pool[arena->blocks_cached]; -: 329: // Reallocate if needed 129: 330: if (block.size != requested_size){ branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 331: block.ptr = realloc(block.ptr, requested_size); -: 332: } 129: 333: if ( ! block.ptr) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 334: // Can't allocate, free previous pointer (it is still valid) #####: 335: free(arena->blocks_pool[arena->blocks_cached].ptr); #####: 336: arena->stats_freed_blocks += 1; #####: 337: return block; -: 338: } 129: 339: if ( ! dirty) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 340: memset(block.ptr, 0, requested_size); -: 341: } 129: 342: arena->stats_reused_blocks += 1; 129: 343: if (block.ptr != arena->blocks_pool[arena->blocks_cached].ptr) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 344: arena->stats_reallocated_blocks += 1; -: 345: } -: 346: } else { 1089084: 347: if (dirty) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 1082251: 348: block.ptr = malloc(requested_size); -: 349: } else { 6833: 350: block.ptr = calloc(1, requested_size); -: 351: } 1089084: 352: arena->stats_allocated_blocks += 1; -: 353: } 1089213: 354: block.size = requested_size; 1089213: 355: return block; -: 356:} -: 357: -: 358:void function memory_return_block called 1089173 returned 100% blocks executed 83% 1089173: 359:memory_return_block(ImagingMemoryArena arena, ImagingMemoryBlock block) -: 360:{ 1089173: 361: if (arena->blocks_cached < arena->blocks_max) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 362: // Reduce block size 258: 363: if (block.size > arena->block_size) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 364: block.size = arena->block_size; #####: 365: block.ptr = realloc(block.ptr, arena->block_size); -: 366: } 258: 367: arena->blocks_pool[arena->blocks_cached] = block; 258: 368: arena->blocks_cached += 1; -: 369: } else { 1088915: 370: free(block.ptr); 1088915: 371: arena->stats_freed_blocks += 1; -: 372: } 1089173: 373:} -: 374: -: 375: -: 376:static void function ImagingDestroyArray called 1087494 returned 100% blocks executed 100% 1087494: 377:ImagingDestroyArray(Imaging im) -: 378:{ 1087494: 379: int y = 0; -: 380: 1087494: 381: if (im->blocks) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 2176667: 382: while (im->blocks[y].ptr) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 1089173: 383: memory_return_block(&ImagingDefaultArena, im->blocks[y]); call 0 returned 100% 1089173: 384: y += 1; -: 385: } 1087494: 386: free(im->blocks); -: 387: } 1087494: 388:} -: 389: -: 390:Imaging function ImagingAllocateArray called 1088024 returned 100% blocks executed 86% 1088024: 391:ImagingAllocateArray(Imaging im, int dirty, int block_size) -: 392:{ -: 393: int y, line_in_block, current_block; 1088024: 394: ImagingMemoryArena arena = &ImagingDefaultArena; 1088024: 395: ImagingMemoryBlock block = {NULL, 0}; -: 396: int aligned_linesize, lines_per_block, blocks_count; 1088024: 397: char *aligned_ptr = NULL; -: 398: -: 399: /* 0-width or 0-height image. No need to do anything */ 1088024: 400: if ( ! im->linesize || ! im->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% -: 401: return im; -: 402: } -: 403: 1087534: 404: aligned_linesize = (im->linesize + arena->alignment - 1) & -arena->alignment; 1087534: 405: lines_per_block = (block_size - (arena->alignment - 1)) / aligned_linesize; 1087534: 406: if (lines_per_block == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 407: lines_per_block = 1; -: 408: } 1087534: 409: blocks_count = (im->ysize + lines_per_block - 1) / lines_per_block; -: 410: // printf("NEW size: %dx%d, ls: %d, lpb: %d, blocks: %d\n", -: 411: // im->xsize, im->ysize, aligned_linesize, lines_per_block, blocks_count); -: 412: -: 413: /* One extra pointer is always NULL */ 1087534: 414: im->blocks = calloc(sizeof(*im->blocks), blocks_count + 1); 1087534: 415: if ( ! im->blocks) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 416: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 417: } -: 418: -: 419: /* Allocate image as an array of lines */ -: 420: line_in_block = 0; -: 421: current_block = 0; 9389173: 422: for (y = 0; y < im->ysize; y++) { branch 0 taken 90% branch 1 taken 10% (fallthrough) 9389173: 423: if (line_in_block == 0) { branch 0 taken 12% (fallthrough) branch 1 taken 88% -: 424: int required; 1089213: 425: int lines_remaining = lines_per_block; 1089213: 426: if (lines_remaining > im->ysize - y) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 1087426: 427: lines_remaining = im->ysize - y; -: 428: } 1089213: 429: required = lines_remaining * aligned_linesize + arena->alignment - 1; 1089213: 430: block = memory_get_block(arena, required, dirty); call 0 returned 100% 1089213: 431: if ( ! block.ptr) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 432: ImagingDestroyArray(im); call 0 never executed #####: 433: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 434: } 1089213: 435: im->blocks[current_block] = block; -: 436: /* Bulletproof code from libc _int_memalign */ 1089213: 437: aligned_ptr = (char *)( 2178426: 438: ((size_t) (block.ptr + arena->alignment - 1)) & 1089213: 439: -((Py_ssize_t) arena->alignment)); -: 440: } -: 441: 9389173: 442: im->image[y] = aligned_ptr + aligned_linesize * line_in_block; -: 443: 9389173: 444: line_in_block += 1; 9389173: 445: if (line_in_block >= lines_per_block) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 446: /* Reset counter and start new block */ 1787: 447: line_in_block = 0; 1787: 448: current_block += 1; -: 449: } -: 450: } -: 451: 1087534: 452: im->destroy = ImagingDestroyArray; -: 453: 1087534: 454: return im; -: 455:} -: 456: -: 457: -: 458:/* Block Storage Type */ -: 459:/* ------------------ */ -: 460:/* Allocate image as a single block. */ -: 461: -: 462:static void function ImagingDestroyBlock called 0 returned 0% blocks executed 0% #####: 463:ImagingDestroyBlock(Imaging im) -: 464:{ #####: 465: if (im->block) { branch 0 never executed branch 1 never executed #####: 466: free(im->block); -: 467: } #####: 468:} -: 469: -: 470:Imaging function ImagingAllocateBlock called 0 returned 0% blocks executed 0% #####: 471:ImagingAllocateBlock(Imaging im) -: 472:{ -: 473: Py_ssize_t y, i; -: 474: -: 475: /* overflow check for malloc */ #####: 476: if (im->linesize && branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 477: im->ysize > INT_MAX / im->linesize) { #####: 478: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 479: } -: 480: #####: 481: if (im->ysize * im->linesize <= 0) { branch 0 never executed branch 1 never executed -: 482: /* some platforms return NULL for malloc(0); this fix -: 483: prevents MemoryError on zero-sized images on such -: 484: platforms */ #####: 485: im->block = (char *) malloc(1); -: 486: } else { -: 487: /* malloc check ok, overflow check above */ #####: 488: im->block = (char *) calloc(im->ysize, im->linesize); -: 489: } -: 490: #####: 491: if ( ! im->block) { branch 0 never executed branch 1 never executed #####: 492: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 493: } -: 494: #####: 495: for (y = i = 0; y < im->ysize; y++) { branch 0 never executed branch 1 never executed #####: 496: im->image[y] = im->block + i; #####: 497: i += im->linesize; -: 498: } -: 499: #####: 500: im->destroy = ImagingDestroyBlock; -: 501: #####: 502: return im; -: 503:} -: 504: -: 505:/* -------------------------------------------------------------------- -: 506: * Create a new, internally allocated, image. -: 507: */ -: 508: -: 509:Imaging function ImagingNewInternal called 1088031 returned 100% blocks executed 62% 1088031: 510:ImagingNewInternal(const char* mode, int xsize, int ysize, int dirty) -: 511:{ -: 512: Imaging im; -: 513: 1088031: 514: if (xsize < 0 || ysize < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 1% (fallthrough) branch 3 taken 99% 1: 515: return (Imaging) ImagingError_ValueError("bad image size"); call 0 returned 100% -: 516: } -: 517: 1088030: 518: im = ImagingNewPrologue(mode, xsize, ysize); call 0 returned 100% 1088030: 519: if ( ! im) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 520: return NULL; -: 521: } -: 522: 1088024: 523: if (ImagingAllocateArray(im, dirty, ImagingDefaultArena.block_size)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 524: return im; -: 525: } -: 526: #####: 527: ImagingError_Clear(); call 0 never executed -: 528: -: 529: // Try to allocate the image once more with smallest possible block size #####: 530: if (ImagingAllocateArray(im, dirty, IMAGING_PAGE_SIZE)) { call 0 never executed branch 1 never executed branch 2 never executed -: 531: return im; -: 532: } -: 533: #####: 534: ImagingDelete(im); call 0 never executed #####: 535: return NULL; -: 536:} -: 537: -: 538:Imaging function ImagingNew called 6181 returned 100% blocks executed 100% 6181: 539:ImagingNew(const char* mode, int xsize, int ysize) -: 540:{ 6181: 541: return ImagingNewInternal(mode, xsize, ysize, 0); call 0 returned 100% -: 542:} -: 543: -: 544:Imaging function ImagingNewDirty called 1081850 returned 100% blocks executed 100% 1081850: 545:ImagingNewDirty(const char* mode, int xsize, int ysize) -: 546:{ 1081850: 547: return ImagingNewInternal(mode, xsize, ysize, 1); call 0 returned 100% -: 548:} -: 549: -: 550:Imaging function ImagingNewBlock called 0 returned 0% blocks executed 0% #####: 551:ImagingNewBlock(const char* mode, int xsize, int ysize) -: 552:{ -: 553: Imaging im; -: 554: #####: 555: if (xsize < 0 || ysize < 0) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 556: return (Imaging) ImagingError_ValueError("bad image size"); call 0 never executed -: 557: } -: 558: #####: 559: im = ImagingNewPrologue(mode, xsize, ysize); call 0 never executed #####: 560: if ( ! im) { branch 0 never executed branch 1 never executed -: 561: return NULL; -: 562: } -: 563: #####: 564: if (ImagingAllocateBlock(im)) { call 0 never executed branch 1 never executed branch 2 never executed -: 565: return im; -: 566: } -: 567: #####: 568: ImagingDelete(im); call 0 never executed #####: 569: return NULL; -: 570:} -: 571: -: 572:Imaging function ImagingNew2Dirty called 10307 returned 100% blocks executed 89% 10307: 573:ImagingNew2Dirty(const char* mode, Imaging imOut, Imaging imIn) -: 574:{ -: 575: /* allocate or validate output image */ -: 576: 10307: 577: if (imOut) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 578: /* make sure images match */ 20: 579: if (strcmp(imOut->mode, mode) != 0 branch 0 taken 100% (fallthrough) branch 1 taken 0% 20: 580: || imOut->xsize != imIn->xsize branch 0 taken 100% (fallthrough) branch 1 taken 0% 20: 581: || imOut->ysize != imIn->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 582: return ImagingError_Mismatch(); call 0 never executed -: 583: } -: 584: } else { -: 585: /* create new image */ 10287: 586: imOut = ImagingNewDirty(mode, imIn->xsize, imIn->ysize); call 0 returned 100% 10287: 587: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 588: return NULL; -: 589: } -: 590: } -: 591: -: 592: return imOut; -: 593:} -: 594: -: 595:void function ImagingCopyPalette called 1032266 returned 100% blocks executed 100% 1032266: 596:ImagingCopyPalette(Imaging destination, Imaging source) -: 597:{ 1032266: 598: if (source->palette) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1331: 599: if (destination->palette) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1331: 600: ImagingPaletteDelete(destination->palette); call 0 returned 100% -: 601: } 1331: 602: destination->palette = ImagingPaletteDuplicate(source->palette); call 0 returned 100% -: 603: } 1032266: 604:} <<<<<< EOF # 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-s390x-3.8/src/libImaging/RawDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/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 15341 returned 100% blocks executed 95% 15341: 23:ImagingRawDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 24:{ -: 25: enum { LINE = 1, SKIP }; 15341: 26: RAWSTATE* rawstate = state->context; -: 27: -: 28: UINT8* ptr; -: 29: 15341: 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 */ 14840: 35: state->bytes = (state->xsize * state->bits + 7) / 8; 14840: 36: if (rawstate->stride) { branch 0 taken 90% (fallthrough) branch 1 taken 10% 13424: 37: rawstate->skip = rawstate->stride - state->bytes; 13424: 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 { 1416: 43: rawstate->skip = 0; -: 44: } -: 45: -: 46: /* check image orientation */ 14839: 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 { 14741: 51: state->ystep = 1; -: 52: } -: 53: 14839: 54: state->state = LINE; -: 55: -: 56: } -: 57: -: 58: ptr = buf; -: 59: -: 60: for (;;) { -: 61: 436298: 62: if (state->state == SKIP) { branch 0 taken 96% (fallthrough) branch 1 taken 4% -: 63: -: 64: /* Skip padding between lines */ -: 65: 420958: 66: if (bytes < rawstate->skip) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 67: return ptr - buf; -: 68: } -: 69: 420958: 70: ptr += rawstate->skip; 420958: 71: bytes -= rawstate->skip; -: 72: 420958: 73: state->state = LINE; -: 74: -: 75: } -: 76: 436298: 77: if (bytes < state->bytes) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 506: 78: return ptr - buf; -: 79: } -: 80: -: 81: /* Unpack data */ 871584: 82: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 435792: 83: state->xoff * im->pixelsize, ptr, state->xsize); -: 84: 435792: 85: ptr += state->bytes; 435792: 86: bytes -= state->bytes; -: 87: 435792: 88: state->y += state->ystep; -: 89: 435792: 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: 420958: 95: state->state = SKIP; -: 96: 420958: 97: } -: 98: -: 99:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Fill.c.gcov -: 0:Source:src/libImaging/Fill.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Fill.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Fill.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * fill image with constant pixel value -: 6: * -: 7: * history: -: 8: * 95-11-26 fl moved from Imaging.c -: 9: * 96-05-17 fl added radial fill, renamed wedge to linear -: 10: * 98-06-23 fl changed ImageFill signature -: 11: * -: 12: * Copyright (c) Secret Labs AB 1997-98. All rights reserved. -: 13: * Copyright (c) Fredrik Lundh 1995-96. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21:#include "math.h" -: 22: -: 23:Imaging function ImagingFill called 15960 returned 100% blocks executed 100% 15960: 24:ImagingFill(Imaging im, const void* colour) -: 25:{ -: 26: int x, y; -: 27: ImagingSectionCookie cookie; -: 28: 15960: 29: if (im->type == IMAGING_TYPE_SPECIAL) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 30: /* use generic API */ 67: 31: ImagingAccess access = ImagingAccessNew(im); call 0 returned 100% 67: 32: if (access) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 208: 33: for (y = 0; y < im->ysize; y++) { branch 0 taken 76% (fallthrough) branch 1 taken 24% 10752: 34: for (x = 0; x < im->xsize; x++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 10752: 35: access->put_pixel(im, x, y, colour); call 0 returned 100% -: 36: } -: 37: } -: 38: ImagingAccessDelete(im, access); -: 39: } else { -: 40: /* wipe the image */ 1: 41: for (y = 0; y < im->ysize; y++) { branch 0 taken 50% branch 1 taken 50% 2: 42: memset(im->image[y], 0, im->linesize); -: 43: } -: 44: } -: 45: } else { 15893: 46: INT32 c = 0L; 15893: 47: ImagingSectionEnter(&cookie); call 0 returned 100% 31786: 48: memcpy(&c, colour, im->pixelsize); 15893: 49: if (im->image32 && c != 0L) { branch 0 taken 8% (fallthrough) branch 1 taken 92% branch 2 taken 40% (fallthrough) branch 3 taken 60% 118857: 50: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 120196328: 51: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 120196328: 52: im->image32[y][x] = c; -: 53: } -: 54: } -: 55: } else { 15370: 56: unsigned char cc = (unsigned char) *(UINT8*) colour; 411627: 57: for (y = 0; y < im->ysize; y++) { branch 0 taken 96% branch 1 taken 4% (fallthrough) 792514: 58: memset(im->image[y], cc, im->linesize); -: 59: } -: 60: } 15893: 61: ImagingSectionLeave(&cookie); call 0 returned 100% -: 62: } -: 63: 15960: 64: return im; -: 65:} -: 66: -: 67:Imaging function ImagingFillLinearGradient called 12 returned 100% blocks executed 100% 12: 68:ImagingFillLinearGradient(const char *mode) -: 69:{ -: 70: Imaging im; -: 71: int y; -: 72: 12: 73: if (strlen(mode) != 1) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 1: 74: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 75: } -: 76: 11: 77: im = ImagingNewDirty(mode, 256, 256); call 0 returned 100% 11: 78: if (!im) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 79: return NULL; -: 80: } -: 81: 2816: 82: for (y = 0; y < 256; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5632: 83: memset(im->image8[y], (unsigned char) y, 256); -: 84: } -: 85: -: 86: return im; -: 87:} -: 88: -: 89:Imaging function ImagingFillRadialGradient called 3 returned 100% blocks executed 100% 3: 90:ImagingFillRadialGradient(const char *mode) -: 91:{ -: 92: Imaging im; -: 93: int x, y; -: 94: int d; -: 95: 3: 96: if (strlen(mode) != 1) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 1: 97: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 98: } -: 99: 2: 100: im = ImagingNewDirty(mode, 256, 256); call 0 returned 100% 2: 101: if (!im) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 102: return NULL; -: 103: } -: 104: 512: 105: for (y = 0; y < 256; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 131072: 106: for (x = 0; x < 256; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 131072: 107: d = (int) sqrt((double) ((x-128)*(x-128) + (y-128)*(y-128)) * 2.0); 131072: 108: if (d >= 255) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 10: 109: im->image8[y][x] = 255; -: 110: } else { 131062: 111: im->image8[y][x] = d; -: 112: } -: 113: } -: 114: } -: 115: -: 116: return im; -: 117:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Chops.c.gcov -: 0:Source:src/libImaging/Chops.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Chops.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Chops.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * basic channel operations -: 6: * -: 7: * history: -: 8: * 1996-03-28 fl Created -: 9: * 1996-08-13 fl Added and/or/xor for "1" images -: 10: * 1996-12-14 fl Added add_modulo, sub_modulo -: 11: * 2005-09-10 fl Fixed output values from and/or/xor -: 12: * -: 13: * Copyright (c) 1996 by Fredrik Lundh. -: 14: * Copyright (c) 1997 by Secret Labs AB. -: 15: * -: 16: * See the README file for details on usage and redistribution. -: 17: */ -: 18: -: 19: -: 20:#include "Imaging.h" -: 21: -: 22:#define CHOP(operation)\ -: 23: int x, y;\ -: 24: Imaging imOut;\ -: 25: imOut = create(imIn1, imIn2, NULL);\ -: 26: if (!imOut) {\ -: 27: return NULL;\ -: 28: }\ -: 29: for (y = 0; y < imOut->ysize; y++) {\ -: 30: UINT8* out = (UINT8*) imOut->image[y];\ -: 31: UINT8* in1 = (UINT8*) imIn1->image[y];\ -: 32: UINT8* in2 = (UINT8*) imIn2->image[y];\ -: 33: for (x = 0; x < imOut->linesize; x++) {\ -: 34: int temp = operation;\ -: 35: if (temp <= 0) {\ -: 36: out[x] = 0;\ -: 37: } else if (temp >= 255) {\ -: 38: out[x] = 255;\ -: 39: } else {\ -: 40: out[x] = temp;\ -: 41: }\ -: 42: }\ -: 43: }\ -: 44: return imOut; -: 45: -: 46:#define CHOP2(operation, mode)\ -: 47: int x, y;\ -: 48: Imaging imOut;\ -: 49: imOut = create(imIn1, imIn2, mode);\ -: 50: if (!imOut) {\ -: 51: return NULL;\ -: 52: }\ -: 53: for (y = 0; y < imOut->ysize; y++) {\ -: 54: UINT8* out = (UINT8*) imOut->image[y];\ -: 55: UINT8* in1 = (UINT8*) imIn1->image[y];\ -: 56: UINT8* in2 = (UINT8*) imIn2->image[y];\ -: 57: for (x = 0; x < imOut->linesize; x++) {\ -: 58: out[x] = operation;\ -: 59: }\ -: 60: }\ -: 61: return imOut; -: 62: -: 63:static Imaging function create called 146 returned 100% blocks executed 88% 146: 64:create(Imaging im1, Imaging im2, char* mode) -: 65:{ -: 66: int xsize, ysize; -: 67: 146: 68: if (!im1 || !im2 || im1->type != IMAGING_TYPE_UINT8 || 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 25% (fallthrough) branch 7 taken 75% 36: 69: (mode != NULL && (strcmp(im1->mode, "1") || strcmp(im2->mode, "1")))) { 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% #####: 70: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 71: } 292: 72: if (im1->type != im2->type || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% 146: 73: im1->bands != im2->bands) { #####: 74: return (Imaging) ImagingError_Mismatch(); call 0 never executed -: 75: } -: 76: 146: 77: xsize = (im1->xsize < im2->xsize) ? im1->xsize : im2->xsize; 146: 78: ysize = (im1->ysize < im2->ysize) ? im1->ysize : im2->ysize; -: 79: 146: 80: return ImagingNewDirty(im1->mode, xsize, ysize); call 0 returned 100% -: 81:} -: 82: -: 83:Imaging function ImagingChopLighter called 3 returned 100% blocks executed 100% 3: 84:ImagingChopLighter(Imaging imIn1, Imaging imIn2) -: 85:{ 3: 86: CHOP((in1[x] > in2[x]) ? in1[x] : in2[x]); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 30% (fallthrough) branch 4 taken 70% branch 5 taken 30% (fallthrough) branch 6 taken 70% branch 7 taken 34% (fallthrough) branch 8 taken 66% branch 9 taken 99% branch 10 taken 1% (fallthrough) branch 11 taken 99% branch 12 taken 1% (fallthrough) -: 87:} -: 88: -: 89:Imaging function ImagingChopDarker called 3 returned 100% blocks executed 100% 3: 90:ImagingChopDarker(Imaging imIn1, Imaging imIn2) -: 91:{ 3: 92: CHOP((in1[x] < in2[x]) ? in1[x] : in2[x]); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 1% (fallthrough) branch 4 taken 99% branch 5 taken 60% (fallthrough) branch 6 taken 40% branch 7 taken 55% (fallthrough) branch 8 taken 45% branch 9 taken 99% branch 10 taken 1% (fallthrough) branch 11 taken 99% branch 12 taken 1% (fallthrough) -: 93:} -: 94: -: 95:Imaging function ImagingChopDifference called 3 returned 100% blocks executed 100% 3: 96:ImagingChopDifference(Imaging imIn1, Imaging imIn2) -: 97:{ 3: 98: CHOP(abs((int) in1[x] - (int) in2[x])); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 69% (fallthrough) branch 4 taken 31% branch 5 taken 2% (fallthrough) branch 6 taken 98% branch 7 taken 99% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) -: 99:} -: 100: -: 101:Imaging function ImagingChopMultiply called 4 returned 100% blocks executed 100% 4: 102:ImagingChopMultiply(Imaging imIn1, Imaging imIn2) -: 103:{ 4: 104: CHOP((int) in1[x] * (int) in2[x] / 255); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 44% (fallthrough) branch 4 taken 56% branch 5 taken 41% (fallthrough) branch 6 taken 59% branch 7 taken 99% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) -: 105:} -: 106: -: 107:Imaging function ImagingChopScreen called 2 returned 100% blocks executed 100% 2: 108:ImagingChopScreen(Imaging imIn1, Imaging imIn2) -: 109:{ 2: 110: CHOP(255 - ((int) (255 - in1[x]) * (int) (255 - in2[x])) / 255); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 45% (fallthrough) branch 4 taken 55% branch 5 taken 42% (fallthrough) branch 6 taken 58% branch 7 taken 99% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) -: 111:} -: 112: -: 113:Imaging function ImagingChopAdd called 6 returned 100% blocks executed 100% 6: 114:ImagingChopAdd(Imaging imIn1, Imaging imIn2, float scale, int offset) -: 115:{ 6: 116: CHOP(((int) in1[x] + (int) in2[x]) / scale + offset); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 13% (fallthrough) branch 4 taken 87% branch 5 taken 39% (fallthrough) branch 6 taken 61% branch 7 taken 99% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) -: 117:} -: 118: -: 119:Imaging function ImagingChopSubtract called 6 returned 100% blocks executed 100% 6: 120:ImagingChopSubtract(Imaging imIn1, Imaging imIn2, float scale, int offset) -: 121:{ 6: 122: CHOP(((int) in1[x] - (int) in2[x]) / scale + offset); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 1% (fallthrough) branch 6 taken 99% branch 7 taken 99% branch 8 taken 1% (fallthrough) branch 9 taken 99% branch 10 taken 1% (fallthrough) -: 123:} -: 124: -: 125:Imaging function ImagingChopAnd called 12 returned 100% blocks executed 100% 12: 126:ImagingChopAnd(Imaging imIn1, Imaging imIn2) -: 127:{ 12: 128: CHOP2((in1[x] && in2[x]) ? 255 : 0, "1"); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) branch 6 taken 50% branch 7 taken 50% branch 8 taken 50% (fallthrough) branch 9 taken 50% branch 10 taken 50% (fallthrough) -: 129:} -: 130: -: 131:Imaging function ImagingChopOr called 12 returned 100% blocks executed 100% 12: 132:ImagingChopOr(Imaging imIn1, Imaging imIn2) -: 133:{ 12: 134: CHOP2((in1[x] || in2[x]) ? 255 : 0, "1"); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) branch 6 taken 50% branch 7 taken 50% branch 8 taken 50% (fallthrough) branch 9 taken 50% branch 10 taken 50% (fallthrough) -: 135:} -: 136: -: 137:Imaging function ImagingChopXor called 12 returned 100% blocks executed 100% 12: 138:ImagingChopXor(Imaging imIn1, Imaging imIn2) -: 139:{ 12: 140: CHOP2(((in1[x] != 0) ^ (in2[x] != 0)) ? 255 : 0, "1"); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% branch 6 taken 50% (fallthrough) branch 7 taken 50% branch 8 taken 50% (fallthrough) -: 141:} -: 142: -: 143:Imaging function ImagingChopAddModulo called 3 returned 100% blocks executed 100% 3: 144:ImagingChopAddModulo(Imaging imIn1, Imaging imIn2) -: 145:{ 3: 146: CHOP2(in1[x] + in2[x], NULL); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 99% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 1% (fallthrough) -: 147:} -: 148: -: 149:Imaging function ImagingChopSubtractModulo called 74 returned 100% blocks executed 100% 74: 150:ImagingChopSubtractModulo(Imaging imIn1, Imaging imIn2) -: 151:{ 74: 152: CHOP2(in1[x] - in2[x], NULL); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 99% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 1% (fallthrough) -: 153:} -: 154: -: 155:Imaging function ImagingChopSoftLight called 2 returned 100% blocks executed 100% 2: 156:ImagingChopSoftLight(Imaging imIn1, Imaging imIn2) -: 157:{ 2: 158: CHOP2( (((255-in1[x]) * (in1[x]*in2[x]) ) / 65536) + call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 99% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 1% (fallthrough) -: 159: (in1[x] * ( 255 - ( (255 - in1[x]) * (255 - in2[x] ) / 255) )) / 255 -: 160: , NULL ); -: 161:} -: 162: -: 163:Imaging function ImagingChopHardLight called 2 returned 100% blocks executed 100% 2: 164:ImagingChopHardLight(Imaging imIn1, Imaging imIn2) -: 165:{ 2: 166: CHOP2( (in2[x]<128) ? ( (in1[x]*in2[x])/127) call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 53% (fallthrough) branch 4 taken 47% branch 5 taken 99% branch 6 taken 1% (fallthrough) branch 7 taken 99% branch 8 taken 1% (fallthrough) -: 167: : 255 - ( ((255-in2[x]) * (255-in1[x])) / 127) -: 168: , NULL); -: 169:} -: 170: -: 171:Imaging function ImagingOverlay called 2 returned 100% blocks executed 100% 2: 172:ImagingOverlay(Imaging imIn1, Imaging imIn2) -: 173:{ 2: 174: CHOP2( (in1[x]<128) ? ( (in1[x]*in2[x])/127) call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 55% (fallthrough) branch 4 taken 45% branch 5 taken 99% branch 6 taken 1% (fallthrough) branch 7 taken 99% branch 8 taken 1% (fallthrough) -: 175: : 255 - ( ((255-in1[x]) * (255-in2[x])) / 127) -: 176: , NULL); -: 177:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Jpeg2KEncode.c.gcov -: 0:Source:src/libImaging/Jpeg2KEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Jpeg2KEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Jpeg2KEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for JPEG2000 image data. -: 6: * -: 7: * history: -: 8: * 2014-03-12 ajh Created -: 9: * -: 10: * Copyright (c) 2014 Coriolis Systems Limited -: 11: * Copyright (c) 2014 Alastair Houghton -: 12: * -: 13: * See the README file for details on usage and redistribution. -: 14: */ -: 15: -: 16:#include "Imaging.h" -: 17: -: 18:#ifdef HAVE_OPENJPEG -: 19: -: 20:#include "Jpeg2K.h" -: 21: -: 22:#define CINEMA_24_CS_LENGTH 1302083 -: 23:#define CINEMA_48_CS_LENGTH 651041 -: 24:#define COMP_24_CS_MAX_LENGTH 1041666 -: 25:#define COMP_48_CS_MAX_LENGTH 520833 -: 26: -: 27:/* -------------------------------------------------------------------- */ -: 28:/* Error handler */ -: 29:/* -------------------------------------------------------------------- */ -: 30: -: 31:static void function j2k_error called 1 returned 100% blocks executed 100% 1: 32:j2k_error(const char *msg, void *client_data) -: 33:{ 1: 34: JPEG2KENCODESTATE *state = (JPEG2KENCODESTATE *) client_data; 1: 35: free((void *)state->error_msg); 1: 36: state->error_msg = strdup(msg); call 0 returned 100% 1: 37:} -: 38: -: 39:static void function j2k_warn called 55 returned 100% blocks executed 100% 55: 40:j2k_warn(const char *msg, void *client_data) -: 41:{ -: 42: // Null handler 55: 43:} -: 44: -: 45:/* -------------------------------------------------------------------- */ -: 46:/* Buffer output stream */ -: 47:/* -------------------------------------------------------------------- */ -: 48: -: 49:static OPJ_SIZE_T function j2k_write called 40 returned 100% blocks executed 100% 40: 50:j2k_write(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) -: 51:{ 40: 52: ImagingCodecState state = (ImagingCodecState)p_user_data; -: 53: unsigned int result; -: 54: 40: 55: result = _imaging_write_pyFd(state->fd, p_buffer, p_nb_bytes); call 0 returned 100% -: 56: 40: 57: return result ? result : (OPJ_SIZE_T)-1; branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 58:} -: 59: -: 60: -: 61:static OPJ_OFF_T function j2k_skip called 14 returned 100% blocks executed 100% 14: 62:j2k_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data) -: 63:{ 14: 64: ImagingCodecState state = (ImagingCodecState)p_user_data; -: 65: char *buffer; -: 66: int result; -: 67: -: 68: /* Explicitly write zeros */ 14: 69: buffer = calloc(p_nb_bytes,1); 14: 70: if (!buffer) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 71: return (OPJ_OFF_T)-1; -: 72: } -: 73: 14: 74: result = _imaging_write_pyFd(state->fd, buffer, p_nb_bytes); call 0 returned 100% -: 75: 14: 76: free(buffer); -: 77: 14: 78: return result ? result : p_nb_bytes; branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 79:} -: 80: -: 81:static OPJ_BOOL function j2k_seek called 26 returned 100% blocks executed 100% 26: 82:j2k_seek(OPJ_OFF_T p_nb_bytes, void *p_user_data) -: 83:{ 26: 84: ImagingCodecState state = (ImagingCodecState)p_user_data; 26: 85: off_t pos = 0; -: 86: 26: 87: _imaging_seek_pyFd(state->fd, p_nb_bytes, SEEK_SET); call 0 returned 100% 26: 88: pos = _imaging_tell_pyFd(state->fd); call 0 returned 100% -: 89: 26: 90: return pos == p_nb_bytes; -: 91:} -: 92: -: 93:/* -------------------------------------------------------------------- */ -: 94:/* Encoder */ -: 95:/* -------------------------------------------------------------------- */ -: 96: -: 97:typedef void (*j2k_pack_tile_t)(Imaging im, UINT8 *buf, -: 98: unsigned x0, unsigned y0, -: 99: unsigned w, unsigned h); -: 100: -: 101:static void function j2k_pack_l called 0 returned 0% blocks executed 0% #####: 102:j2k_pack_l(Imaging im, UINT8 *buf, -: 103: unsigned x0, unsigned y0, unsigned w, unsigned h) -: 104:{ #####: 105: UINT8 *ptr = buf; -: 106: unsigned x,y; #####: 107: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 108: UINT8 *data = (UINT8 *)(im->image[y + y0] + x0); #####: 109: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 110: *ptr++ = *data++; -: 111: } -: 112: } #####: 113:} -: 114: -: 115:static void function j2k_pack_i16 called 2 returned 100% blocks executed 100% 2: 116:j2k_pack_i16(Imaging im, UINT8 *buf, -: 117: unsigned x0, unsigned y0, unsigned w, unsigned h) -: 118:{ 2: 119: UINT8 *ptr = buf; -: 120: unsigned x,y; 130: 121: for (y = 0; y < h; ++y) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 128: 122: UINT8 *data = (UINT8 *)(im->image[y + y0] + x0); 8320: 123: for (x = 0; x < w; ++x) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 8192: 124: *ptr++ = *data++; 8192: 125: *ptr++ = *data++; -: 126: } -: 127: } 2: 128:} -: 129: -: 130: -: 131:static void function j2k_pack_la called 0 returned 0% blocks executed 0% #####: 132:j2k_pack_la(Imaging im, UINT8 *buf, -: 133: unsigned x0, unsigned y0, unsigned w, unsigned h) -: 134:{ #####: 135: UINT8 *ptr = buf; #####: 136: UINT8 *ptra = buf + w * h; -: 137: unsigned x,y; #####: 138: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 139: UINT8 *data = (UINT8 *)(im->image[y + y0] + 4 * x0); #####: 140: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 141: *ptr++ = data[0]; #####: 142: *ptra++ = data[3]; #####: 143: data += 4; -: 144: } -: 145: } #####: 146:} -: 147: -: 148:static void function j2k_pack_rgb called 53 returned 100% blocks executed 100% 53: 149:j2k_pack_rgb(Imaging im, UINT8 *buf, -: 150: unsigned x0, unsigned y0, unsigned w, unsigned h) -: 151:{ 53: 152: UINT8 *pr = buf; 53: 153: UINT8 *pg = pr + w * h; 53: 154: UINT8 *pb = pg + w * h; -: 155: unsigned x,y; 9653: 156: for (y = 0; y < h; ++y) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 9600: 157: UINT8 *data = (UINT8 *)(im->image[y + y0] + 4 * x0); 3388800: 158: for (x = 0; x < w; ++x) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3379200: 159: *pr++ = data[0]; 3379200: 160: *pg++ = data[1]; 3379200: 161: *pb++ = data[2]; 3379200: 162: data += 4; -: 163: } -: 164: } 53: 165:} -: 166: -: 167:static void function j2k_pack_rgba called 0 returned 0% blocks executed 0% #####: 168:j2k_pack_rgba(Imaging im, UINT8 *buf, -: 169: unsigned x0, unsigned y0, unsigned w, unsigned h) -: 170:{ #####: 171: UINT8 *pr = buf; #####: 172: UINT8 *pg = pr + w * h; #####: 173: UINT8 *pb = pg + w * h; #####: 174: UINT8 *pa = pb + w * h; -: 175: unsigned x,y; #####: 176: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 177: UINT8 *data = (UINT8 *)(im->image[y + y0] + 4 * x0); #####: 178: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 179: *pr++ = *data++; #####: 180: *pg++ = *data++; #####: 181: *pb++ = *data++; #####: 182: *pa++ = *data++; -: 183: } -: 184: } #####: 185:} -: 186: -: 187:enum { -: 188: J2K_STATE_START = 0, -: 189: J2K_STATE_ENCODING = 1, -: 190: J2K_STATE_DONE = 2, -: 191: J2K_STATE_FAILED = 3, -: 192:}; -: 193: -: 194:static void function j2k_set_cinema_params.isra.0 called 0 returned 0% blocks executed 0% #####: 195:j2k_set_cinema_params(Imaging im, int components, opj_cparameters_t *params) -: 196:{ -: 197: float rate; -: 198: int n; -: 199: -: 200: /* These settings have been copied from opj_compress in the OpenJPEG -: 201: sources. */ -: 202: #####: 203: params->tile_size_on = OPJ_FALSE; #####: 204: params->cp_tdx = params->cp_tdy = 1; #####: 205: params->tp_flag = 'C'; #####: 206: params->tp_on = 1; #####: 207: params->cp_tx0 = params->cp_ty0 = 0; #####: 208: params->image_offset_x0 = params->image_offset_y0 = 0; #####: 209: params->cblockw_init = 32; #####: 210: params->cblockh_init = 32; #####: 211: params->csty |= 0x01; #####: 212: params->prog_order = OPJ_CPRL; #####: 213: params->roi_compno = -1; #####: 214: params->subsampling_dx = params->subsampling_dy = 1; #####: 215: params->irreversible = 1; -: 216: #####: 217: if (params->cp_cinema == OPJ_CINEMA4K_24) { branch 0 never executed branch 1 never executed #####: 218: float max_rate = ((float)(components * im->xsize * im->ysize * 8) -: 219: / (CINEMA_24_CS_LENGTH * 8)); -: 220: #####: 221: params->POC[0].tile = 1; #####: 222: params->POC[0].resno0 = 0; #####: 223: params->POC[0].compno0 = 0; #####: 224: params->POC[0].layno1 = 1; #####: 225: params->POC[0].resno1 = params->numresolution - 1; #####: 226: params->POC[0].compno1 = 3; #####: 227: params->POC[0].prg1 = OPJ_CPRL; #####: 228: params->POC[1].tile = 1; #####: 229: params->POC[1].resno0 = 0; #####: 230: params->POC[1].compno0 = 0; #####: 231: params->POC[1].layno1 = 1; #####: 232: params->POC[1].resno1 = params->numresolution - 1; #####: 233: params->POC[1].compno1 = 3; #####: 234: params->POC[1].prg1 = OPJ_CPRL; #####: 235: params->numpocs = 2; -: 236: #####: 237: for (n = 0; n < params->tcp_numlayers; ++n) { branch 0 never executed branch 1 never executed #####: 238: rate = 0; #####: 239: if (params->tcp_rates[0] == 0) { branch 0 never executed branch 1 never executed #####: 240: params->tcp_rates[n] = max_rate; -: 241: } else { #####: 242: rate = ((float)(components * im->xsize * im->ysize * 8) #####: 243: / (params->tcp_rates[n] * 8)); #####: 244: if (rate > CINEMA_24_CS_LENGTH) { branch 0 never executed branch 1 never executed #####: 245: params->tcp_rates[n] = max_rate; -: 246: } -: 247: } -: 248: } -: 249: #####: 250: params->max_comp_size = COMP_24_CS_MAX_LENGTH; -: 251: } else { #####: 252: float max_rate = ((float)(components * im->xsize * im->ysize * 8) -: 253: / (CINEMA_48_CS_LENGTH * 8)); -: 254: #####: 255: for (n = 0; n < params->tcp_numlayers; ++n) { branch 0 never executed branch 1 never executed #####: 256: rate = 0; #####: 257: if (params->tcp_rates[0] == 0) { branch 0 never executed branch 1 never executed #####: 258: params->tcp_rates[n] = max_rate; -: 259: } else { #####: 260: rate = ((float)(components * im->xsize * im->ysize * 8) #####: 261: / (params->tcp_rates[n] * 8)); #####: 262: if (rate > CINEMA_48_CS_LENGTH) { branch 0 never executed branch 1 never executed #####: 263: params->tcp_rates[n] = max_rate; -: 264: } -: 265: } -: 266: } -: 267: #####: 268: params->max_comp_size = COMP_48_CS_MAX_LENGTH; -: 269: } #####: 270:} -: 271: -: 272:static int function j2k_encode_entry called 14 returned 100% blocks executed 76% 14: 273:j2k_encode_entry(Imaging im, ImagingCodecState state) -: 274:{ 14: 275: JPEG2KENCODESTATE *context = (JPEG2KENCODESTATE *)state->context; 14: 276: opj_stream_t *stream = NULL; 14: 277: opj_image_t *image = NULL; 14: 278: opj_codec_t *codec = NULL; -: 279: opj_cparameters_t params; -: 280: unsigned components; -: 281: OPJ_COLOR_SPACE color_space; -: 282: opj_image_cmptparm_t image_params[4]; -: 283: unsigned xsiz, ysiz; -: 284: unsigned tile_width, tile_height; -: 285: unsigned tiles_x, tiles_y; -: 286: unsigned x, y, tile_ndx; -: 287: unsigned n; -: 288: j2k_pack_tile_t pack; 14: 289: int ret = -1; -: 290: 14: 291: unsigned prec = 8; 14: 292: unsigned bpp = 8; -: 293: unsigned _overflow_scale_factor; -: 294: 14: 295: stream = opj_stream_create(BUFFER_SIZE, OPJ_FALSE); call 0 returned 100% -: 296: 14: 297: if (!stream) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 298: state->errcode = IMAGING_CODEC_BROKEN; #####: 299: state->state = J2K_STATE_FAILED; #####: 300: goto quick_exit; -: 301: } -: 302: 14: 303: opj_stream_set_write_function(stream, j2k_write); call 0 returned 100% 14: 304: opj_stream_set_skip_function(stream, j2k_skip); call 0 returned 100% 14: 305: opj_stream_set_seek_function(stream, j2k_seek); call 0 returned 100% -: 306: -: 307: /* OpenJPEG 2.0 doesn't have OPJ_VERSION_MAJOR */ -: 308:#ifndef OPJ_VERSION_MAJOR -: 309: opj_stream_set_user_data(stream, state); -: 310:#else 14: 311: opj_stream_set_user_data(stream, state, NULL); call 0 returned 100% -: 312:#endif -: 313: -: 314: /* Setup an opj_image */ 14: 315: if (strcmp (im->mode, "L") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 316: components = 1; -: 317: color_space = OPJ_CLRSPC_GRAY; -: 318: pack = j2k_pack_l; 14: 319: } else if (strcmp (im->mode, "I;16") == 0){ branch 0 taken 86% (fallthrough) branch 1 taken 14% -: 320: components = 1; -: 321: color_space = OPJ_CLRSPC_GRAY; -: 322: pack = j2k_pack_i16; -: 323: prec = 16; -: 324: bpp = 12; 12: 325: } else if (strcmp (im->mode, "I;16B") == 0){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 326: components = 1; -: 327: color_space = OPJ_CLRSPC_GRAY; -: 328: pack = j2k_pack_i16; -: 329: prec = 16; -: 330: bpp = 12; 12: 331: } else if (strcmp (im->mode, "LA") == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed branch 4 taken 100% (fallthrough) branch 5 taken 0% -: 332: components = 2; -: 333: color_space = OPJ_CLRSPC_GRAY; -: 334: pack = j2k_pack_la; 12: 335: } else if (strcmp (im->mode, "RGB") == 0) { 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% -: 336: components = 3; -: 337: color_space = OPJ_CLRSPC_SRGB; -: 338: pack = j2k_pack_rgb; #####: 339: } else if (strcmp (im->mode, "YCbCr") == 0) { branch 0 never executed branch 1 never executed -: 340: components = 3; -: 341: color_space = OPJ_CLRSPC_SYCC; -: 342: pack = j2k_pack_rgb; #####: 343: } else if (strcmp (im->mode, "RGBA") == 0) { branch 0 never executed branch 1 never executed -: 344: components = 4; -: 345: color_space = OPJ_CLRSPC_SRGB; -: 346: pack = j2k_pack_rgba; -: 347: } else { #####: 348: state->errcode = IMAGING_CODEC_BROKEN; #####: 349: state->state = J2K_STATE_FAILED; #####: 350: goto quick_exit; -: 351: } -: 352: 52: 353: for (n = 0; n < components; ++n) { branch 0 taken 73% branch 1 taken 27% (fallthrough) 38: 354: image_params[n].dx = image_params[n].dy = 1; 38: 355: image_params[n].w = im->xsize; 38: 356: image_params[n].h = im->ysize; 38: 357: image_params[n].x0 = image_params[n].y0 = 0; 38: 358: image_params[n].prec = prec; 38: 359: image_params[n].bpp = bpp; 38: 360: image_params[n].sgnd = 0; -: 361: } -: 362: 14: 363: image = opj_image_create(components, image_params, color_space); call 0 returned 100% 14: 364: if (!image) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 365: state->errcode = IMAGING_CODEC_BROKEN; #####: 366: state->state = J2K_STATE_FAILED; #####: 367: goto quick_exit; -: 368: } -: 369: -: 370: /* Setup compression context */ 14: 371: context->error_msg = NULL; -: 372: 14: 373: opj_set_default_encoder_parameters(¶ms); call 0 returned 100% -: 374: 14: 375: params.image_offset_x0 = context->offset_x; 14: 376: params.image_offset_y0 = context->offset_y; -: 377: 14: 378: if (context->tile_size_x && context->tile_size_y) { branch 0 taken 14% (fallthrough) branch 1 taken 86% branch 2 taken 100% (fallthrough) branch 3 taken 0% 2: 379: params.tile_size_on = OPJ_TRUE; 2: 380: params.cp_tx0 = context->tile_offset_x; 2: 381: params.cp_ty0 = context->tile_offset_y; 2: 382: params.cp_tdx = context->tile_size_x; 2: 383: params.cp_tdy = context->tile_size_y; -: 384: 2: 385: tile_width = params.cp_tdx; 2: 386: tile_height = params.cp_tdy; -: 387: } else { 12: 388: params.cp_tx0 = 0; 12: 389: params.cp_ty0 = 0; 12: 390: params.cp_tdx = 1; 12: 391: params.cp_tdy = 1; -: 392: 12: 393: tile_width = im->xsize; 12: 394: tile_height = im->ysize; -: 395: } -: 396: 14: 397: if (context->quality_layers && PySequence_Check(context->quality_layers)) { branch 0 taken 43% (fallthrough) branch 1 taken 57% call 2 returned 100% branch 3 taken 100% (fallthrough) branch 4 taken 0% 6: 398: Py_ssize_t len = PySequence_Length(context->quality_layers); call 0 returned 100% -: 399: Py_ssize_t n; -: 400: float *pq; -: 401: 6: 402: if (len > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 403: if ((unsigned)len > sizeof(params.tcp_rates) / sizeof(params.tcp_rates[0])) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 404: len = sizeof(params.tcp_rates)/sizeof(params.tcp_rates[0]); -: 405: } -: 406: 6: 407: params.tcp_numlayers = (int)len; -: 408: 6: 409: if (context->quality_is_in_db) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 410: params.cp_disto_alloc = params.cp_fixed_alloc = 0; #####: 411: params.cp_fixed_quality = 1; #####: 412: pq = params.tcp_distoratio; -: 413: } else { 6: 414: params.cp_disto_alloc = 1; 6: 415: params.cp_fixed_alloc = params.cp_fixed_quality = 0; 6: 416: pq = params.tcp_rates; -: 417: } -: 418: 20: 419: for (n = 0; n < len; ++n) { branch 0 taken 70% branch 1 taken 30% 14: 420: PyObject *obj = PySequence_ITEM(context->quality_layers, n); call 0 returned 100% 14: 421: pq[n] = PyFloat_AsDouble(obj); call 0 returned 100% -: 422: } -: 423: } -: 424: } else { 8: 425: params.tcp_numlayers = 1; 8: 426: params.tcp_rates[0] = 0; 8: 427: params.cp_disto_alloc = 1; -: 428: } -: 429: 14: 430: if (context->num_resolutions) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 1: 431: params.numresolution = context->num_resolutions; -: 432: } -: 433: 14: 434: if (context->cblk_width >= 4 && context->cblk_width <= 1024 branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 435: && context->cblk_height >= 4 && context->cblk_height <= 1024 branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 436: && context->cblk_width * context->cblk_height <= 4096) { branch 0 never executed branch 1 never executed #####: 437: params.cblockw_init = context->cblk_width; #####: 438: params.cblockh_init = context->cblk_height; -: 439: } -: 440: 14: 441: if (context->precinct_width >= 4 && context->precinct_height >= 4 branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed #####: 442: && context->precinct_width >= context->cblk_width branch 0 never executed branch 1 never executed #####: 443: && context->precinct_height > context->cblk_height) { branch 0 never executed branch 1 never executed #####: 444: params.prcw_init[0] = context->precinct_width; #####: 445: params.prch_init[0] = context->precinct_height; #####: 446: params.res_spec = 1; #####: 447: params.csty |= 0x01; -: 448: } -: 449: 14: 450: params.irreversible = context->irreversible; -: 451: 14: 452: params.prog_order = context->progression; -: 453: 14: 454: params.cp_cinema = context->cinema_mode; -: 455: 14: 456: switch (params.cp_cinema) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% -: 457: case OPJ_OFF: 14: 458: params.cp_rsiz = OPJ_STD_RSIZ; 14: 459: break; -: 460: case OPJ_CINEMA2K_24: -: 461: case OPJ_CINEMA2K_48: #####: 462: params.cp_rsiz = OPJ_CINEMA2K; #####: 463: if (params.numresolution > 6) { branch 0 never executed branch 1 never executed #####: 464: params.numresolution = 6; -: 465: } -: 466: break; -: 467: case OPJ_CINEMA4K_24: #####: 468: params.cp_rsiz = OPJ_CINEMA4K; #####: 469: if (params.numresolution > 7) { branch 0 never executed branch 1 never executed #####: 470: params.numresolution = 7; -: 471: } -: 472: break; -: 473: } -: 474: 14: 475: if (context->cinema_mode != OPJ_OFF) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 476: j2k_set_cinema_params(im, components, ¶ms); call 0 never executed -: 477: } -: 478: -: 479: /* Set up the reference grid in the image */ 14: 480: image->x0 = params.image_offset_x0; 14: 481: image->y0 = params.image_offset_y0; 14: 482: image->x1 = xsiz = im->xsize + params.image_offset_x0; 14: 483: image->y1 = ysiz = im->ysize + params.image_offset_y0; -: 484: -: 485: /* Create the compressor */ 14: 486: codec = opj_create_compress(context->format); call 0 returned 100% -: 487: 14: 488: if (!codec) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 489: state->errcode = IMAGING_CODEC_BROKEN; #####: 490: state->state = J2K_STATE_FAILED; #####: 491: goto quick_exit; -: 492: } -: 493: 14: 494: opj_set_error_handler(codec, j2k_error, context); call 0 returned 100% 14: 495: opj_set_info_handler(codec, j2k_warn, context); call 0 returned 100% 14: 496: opj_set_warning_handler(codec, j2k_warn, context); call 0 returned 100% 14: 497: opj_setup_encoder(codec, ¶ms, image); call 0 returned 100% -: 498: -: 499: /* Start encoding */ 14: 500: if (!opj_start_compress(codec, image, stream)) { call 0 returned 100% branch 1 taken 7% (fallthrough) branch 2 taken 93% 1: 501: state->errcode = IMAGING_CODEC_BROKEN; 1: 502: state->state = J2K_STATE_FAILED; 1: 503: goto quick_exit; -: 504: } -: 505: -: 506: /* Write each tile */ 26: 507: tiles_x = (im->xsize + (params.image_offset_x0 - params.cp_tx0) 13: 508: + tile_width - 1) / tile_width; 26: 509: tiles_y = (im->ysize + (params.image_offset_y0 - params.cp_ty0) 13: 510: + tile_height - 1) / tile_height; -: 511: -: 512: /* check for integer overflow for the malloc line, checking any expression -: 513: that may multiply either tile_width or tile_height */ 13: 514: _overflow_scale_factor = components * prec; 13: 515: if (( tile_width > UINT_MAX / _overflow_scale_factor ) || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 13: 516: ( tile_height > UINT_MAX / _overflow_scale_factor ) || branch 0 taken 100% (fallthrough) branch 1 taken 0% 26: 517: ( tile_width > UINT_MAX / (tile_height * _overflow_scale_factor )) || branch 0 taken 0% (fallthrough) branch 1 taken 100% 13: 518: ( tile_height > UINT_MAX / (tile_width * _overflow_scale_factor ))) { #####: 519: state->errcode = IMAGING_CODEC_BROKEN; #####: 520: state->state = J2K_STATE_FAILED; #####: 521: goto quick_exit; -: 522: } -: 523: /* malloc check ok, checked for overflow above */ 13: 524: state->buffer = malloc (tile_width * tile_height * components * prec / 8); 13: 525: if (!state->buffer) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 526: state->errcode = IMAGING_CODEC_BROKEN; #####: 527: state->state = J2K_STATE_FAILED; #####: 528: goto quick_exit; -: 529: } -: 530: -: 531: tile_ndx = 0; 19: 532: for (y = 0; y < tiles_y; ++y) { branch 0 taken 59% branch 1 taken 41% (fallthrough) 19: 533: int ty0 = params.cp_ty0 + y * tile_height; 19: 534: unsigned ty1 = ty0 + tile_height; -: 535: unsigned pixy, pixh; -: 536: 19: 537: if (ty0 < params.image_offset_y0) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 1: 538: ty0 = params.image_offset_y0; -: 539: } 19: 540: if (ty1 > ysiz) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 1: 541: ty1 = ysiz; -: 542: } -: 543: 19: 544: pixy = ty0 - params.image_offset_y0; 19: 545: pixh = ty1 - ty0; -: 546: 74: 547: for (x = 0; x < tiles_x; ++x) { branch 0 taken 74% branch 1 taken 26% (fallthrough) 55: 548: int tx0 = params.cp_tx0 + x * tile_width; 55: 549: unsigned tx1 = tx0 + tile_width; -: 550: unsigned pixx, pixw; -: 551: unsigned data_size; -: 552: 55: 553: if (tx0 < params.image_offset_x0) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 4: 554: tx0 = params.image_offset_x0; -: 555: } 55: 556: if (tx1 > xsiz) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 4: 557: tx1 = xsiz; -: 558: } -: 559: 55: 560: pixx = tx0 - params.image_offset_x0; 55: 561: pixw = tx1 - tx0; -: 562: 55: 563: pack(im, state->buffer, pixx, pixy, pixw, pixh); call 0 returned 100% -: 564: 55: 565: data_size = pixw * pixh * components * prec / 8; -: 566: 55: 567: if (!opj_write_tile(codec, tile_ndx++, state->buffer, call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 568: data_size, stream)) { #####: 569: state->errcode = IMAGING_CODEC_BROKEN; #####: 570: state->state = J2K_STATE_FAILED; #####: 571: goto quick_exit; -: 572: } -: 573: } -: 574: } -: 575: 13: 576: if (!opj_end_compress(codec, stream)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 577: state->errcode = IMAGING_CODEC_BROKEN; #####: 578: state->state = J2K_STATE_FAILED; #####: 579: goto quick_exit; -: 580: } -: 581: 13: 582: state->errcode = IMAGING_CODEC_END; 13: 583: state->state = J2K_STATE_DONE; 13: 584: ret = -1; -: 585: -: 586: quick_exit: 14: 587: if (codec) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 14: 588: opj_destroy_codec(codec); call 0 returned 100% -: 589: } 14: 590: if (image) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 14: 591: opj_image_destroy(image); call 0 returned 100% -: 592: } 14: 593: if (stream) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 14: 594: opj_stream_destroy(stream); call 0 returned 100% -: 595: } -: 596: 14: 597: return ret; -: 598:} -: 599: -: 600:int function ImagingJpeg2KEncode called 14 returned 100% blocks executed 100% 14: 601:ImagingJpeg2KEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) -: 602:{ 14: 603: if (state->state == J2K_STATE_FAILED) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 604: return -1; -: 605: } -: 606: 14: 607: if (state->state == J2K_STATE_START) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 608: 14: 609: state->state = J2K_STATE_ENCODING; -: 610: 14: 611: return j2k_encode_entry(im, state); call 0 returned 100% -: 612: } -: 613: -: 614: return -1; -: 615:} -: 616: -: 617:/* -------------------------------------------------------------------- */ -: 618:/* Cleanup */ -: 619:/* -------------------------------------------------------------------- */ -: 620: -: 621:int function ImagingJpeg2KEncodeCleanup called 28 returned 100% blocks executed 88% 28: 622:ImagingJpeg2KEncodeCleanup(ImagingCodecState state) { 28: 623: JPEG2KENCODESTATE *context = (JPEG2KENCODESTATE *)state->context; -: 624: 28: 625: if (context->quality_layers) { branch 0 taken 21% (fallthrough) branch 1 taken 79% 12: 626: Py_XDECREF(context->quality_layers); 6: 627: context->quality_layers = NULL; -: 628: } -: 629: 28: 630: if (context->error_msg) { branch 0 taken 4% (fallthrough) branch 1 taken 96% 1: 631: free ((void *)context->error_msg); -: 632: } -: 633: 28: 634: context->error_msg = NULL; -: 635: -: 636: 28: 637: return -1; -: 638:} -: 639: -: 640:#endif /* HAVE_OPENJPEG */ -: 641: -: 642:/* -: 643: * Local Variables: -: 644: * c-basic-offset: 4 -: 645: * End: -: 646: * -: 647: */ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ModeFilter.c.gcov -: 0:Source:src/libImaging/ModeFilter.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/ModeFilter.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/ModeFilter.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * mode filter -: 6: * -: 7: * history: -: 8: * 2002-06-08 fl Created (based on code from IFUNC95) -: 9: * 2004-10-05 fl Rewritten; use a simpler brute-force algorithm -: 10: * -: 11: * Copyright (c) Secret Labs AB 2002-2004. All rights reserved. -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16:#include "Imaging.h" -: 17: -: 18:Imaging function ImagingModeFilter called 20 returned 100% blocks executed 97% 20: 19:ImagingModeFilter(Imaging im, int size) -: 20:{ -: 21: Imaging imOut; -: 22: int x, y, i; -: 23: int xx, yy; -: 24: int maxcount; -: 25: UINT8 maxpixel; -: 26: int histogram[256]; -: 27: 20: 28: if (!im || im->bands != 1 || im->type != IMAGING_TYPE_UINT8) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 29: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 30: } -: 31: 20: 32: imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize); call 0 returned 100% 20: 33: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 34: return NULL; -: 35: } -: 36: 20: 37: size = size / 2; -: 38: 1080: 39: for (y = 0; y < imOut->ysize; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 1060: 40: UINT8* out = &IMAGING_PIXEL_L(imOut, 0, y); 132240: 41: for (x = 0; x < imOut->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 42: -: 43: /* calculate histogram over current area */ -: 44: -: 45: /* FIXME: brute force! to improve, update the histogram -: 46: incrementally. may also add a "frequent list", like in -: 47: the old implementation, but I'm not sure that's worth -: 48: the added complexity... */ -: 49: 131180: 50: memset(histogram, 0, sizeof(histogram)); 524720: 51: for (yy = y - size; yy <= y + size; yy++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 393540: 52: if (yy >= 0 && yy < imOut->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% 391420: 53: UINT8* in = &IMAGING_PIXEL_L(im, 0, yy); 1565680: 54: for (xx = x - size; xx <= x + size; xx++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 1174260: 55: if (xx >= 0 && xx < imOut->xsize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% (fallthrough) branch 3 taken 1% 1167980: 56: histogram[in[xx]]++; -: 57: } -: 58: } -: 59: } -: 60: } -: 61: -: 62: /* find most frequent pixel value in this region */ 131180: 63: maxpixel = 0; 131180: 64: maxcount = histogram[maxpixel]; 33582080: 65: for (i = 1; i < 256; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 33450900: 66: if (histogram[i] > maxcount) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 188823: 67: maxcount = histogram[i]; 188823: 68: maxpixel = (UINT8) i; -: 69: } -: 70: } -: 71: 131180: 72: if (maxcount > 2) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 61560: 73: out[x] = maxpixel; -: 74: } else { 69620: 75: out[x] = IMAGING_PIXEL_L(im, x, y); -: 76: } -: 77: -: 78: } -: 79: -: 80: } -: 81: 20: 82: ImagingCopyPalette(imOut, im); call 0 returned 100% -: 83: 20: 84: return imOut; -: 85:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#HexDecode.c.gcov -: 0:Source:src/libImaging/HexDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/HexDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/HexDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for hex encoded image data -: 6: * -: 7: * history: -: 8: * 96-05-16 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:#define HEX(v) ((v >= '0' && v <= '9') ? v - '0' :\ -: 20: (v >= 'a' && v <= 'f') ? v - 'a' + 10 :\ -: 21: (v >= 'A' && v <= 'F') ? v - 'A' + 10 : -1) -: 22: -: 23:int function ImagingHexDecode called 194 returned 100% blocks executed 83% 194: 24:ImagingHexDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 25:{ -: 26: UINT8* ptr; -: 27: int a, b; -: 28: 194: 29: ptr = buf; -: 30: -: 31: for (;;) { -: 32: 1254: 33: if (bytes < 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 34: return ptr - buf; -: 35: } -: 36: 1254: 37: a = HEX(ptr[0]); branch 0 taken 69% (fallthrough) branch 1 taken 31% branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 taken 100% (fallthrough) branch 5 taken 0% 1254: 38: b = HEX(ptr[1]); branch 0 taken 80% (fallthrough) branch 1 taken 20% branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 taken 100% (fallthrough) branch 5 taken 0% -: 39: 1254: 40: if (a < 0 || b < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 41: #####: 42: ptr++; #####: 43: bytes--; -: 44: -: 45: } else { -: 46: 1254: 47: ptr += 2; 1254: 48: bytes -= 2; -: 49: 1254: 50: state->buffer[state->x] = (a<<4) + b; -: 51: 1254: 52: if (++state->x >= state->bytes) { branch 0 taken 0% branch 1 taken 100% (fallthrough) -: 53: -: 54: /* Got a full line, unpack it */ 1254: 55: state->shuffle((UINT8*) im->image[state->y], state->buffer, call 0 returned 100% -: 56: state->xsize); -: 57: 1254: 58: state->x = 0; -: 59: 1254: 60: if (++state->y >= state->ysize) { branch 0 taken 85% branch 1 taken 15% (fallthrough) -: 61: /* End of file (errcode = 0) */ -: 62: return -1; -: 63: } -: 64: } -: 65: -: 66: } -: 67: } -: 68:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Palette.c.gcov -: 0:Source:src/libImaging/Palette.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Palette.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Palette.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * imaging palette object -: 6: * -: 7: * history: -: 8: * 1996-05-05 fl Added to library -: 9: * 1996-05-27 fl Added colour mapping stuff -: 10: * 1997-05-12 fl Support RGBA palettes -: 11: * 2005-02-09 fl Removed grayscale entries from web palette -: 12: * -: 13: * Copyright (c) Secret Labs AB 1997-2005. All rights reserved. -: 14: * Copyright (c) Fredrik Lundh 1995-1997. -: 15: * -: 16: * See the README file for information on usage and redistribution. -: 17: */ -: 18: -: 19: -: 20:#include "Imaging.h" -: 21: -: 22:#include -: 23: -: 24: -: 25:ImagingPalette function ImagingPaletteNew called 3105 returned 100% blocks executed 77% 3105: 26:ImagingPaletteNew(const char* mode) -: 27:{ -: 28: /* Create a palette object */ -: 29: -: 30: int i; -: 31: ImagingPalette palette; -: 32: 3105: 33: if (strcmp(mode, "RGB") && strcmp(mode, "RGBA")) { 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% branch 8 never executed branch 9 never executed #####: 34: return (ImagingPalette) ImagingError_ModeError(); call 0 never executed -: 35: } -: 36: 3105: 37: palette = calloc(1, sizeof(struct ImagingPaletteInstance)); 3105: 38: if (!palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 39: return (ImagingPalette) ImagingError_MemoryError(); call 0 never executed -: 40: } -: 41: 6210: 42: strncpy(palette->mode, mode, IMAGING_MODE_LENGTH-1); 3105: 43: palette->mode[IMAGING_MODE_LENGTH-1] = 0; -: 44: -: 45: /* Initialize to ramp */ 797985: 46: for (i = 0; i < 256; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 794880: 47: palette->palette[i*4+0] = 1589760: 48: palette->palette[i*4+1] = 794880: 49: palette->palette[i*4+2] = (UINT8) i; 794880: 50: palette->palette[i*4+3] = 255; /* opaque */ -: 51: } -: 52: -: 53: return palette; -: 54:} -: 55: -: 56:ImagingPalette function ImagingPaletteNewBrowser called 72 returned 100% blocks executed 100% 72: 57:ImagingPaletteNewBrowser(void) -: 58:{ -: 59: /* Create a standard "browser" palette object */ -: 60: -: 61: int i, r, g, b; -: 62: ImagingPalette palette; -: 63: 72: 64: palette = ImagingPaletteNew("RGB"); call 0 returned 100% 72: 65: if (!palette) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 66: return NULL; -: 67: } -: 68: -: 69: /* Blank out unused entries */ -: 70: /* FIXME: Add 10-level windows palette here? */ -: 71: 720: 72: for (i = 0; i < 10; i++) { branch 0 taken 91% branch 1 taken 9% (fallthrough) 720: 73: palette->palette[i*4+0] = 1440: 74: palette->palette[i*4+1] = 720: 75: palette->palette[i*4+2] = 0; -: 76: } -: 77: -: 78: /* Simple 6x6x6 colour cube */ -: 79: 432: 80: for (b = 0; b < 256; b += 51) { branch 0 taken 86% (fallthrough) branch 1 taken 14% 2592: 81: for (g = 0; g < 256; g += 51) { branch 0 taken 86% (fallthrough) branch 1 taken 14% 15552: 82: for (r = 0; r < 256; r += 51) { branch 0 taken 86% branch 1 taken 14% (fallthrough) 15552: 83: palette->palette[i*4+0] = r; 15552: 84: palette->palette[i*4+1] = g; 15552: 85: palette->palette[i*4+2] = b; 15552: 86: i++; -: 87: } -: 88: } -: 89: } -: 90: -: 91: /* Blank out unused entries */ -: 92: /* FIXME: add 30-level greyscale wedge here? */ -: 93: 2160: 94: for (; i < 256; i++) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 2160: 95: palette->palette[i*4+0] = 4320: 96: palette->palette[i*4+1] = 2160: 97: palette->palette[i*4+2] = 0; -: 98: } -: 99: -: 100: return palette; -: 101:} -: 102: -: 103:ImagingPalette function ImagingPaletteDuplicate called 1423 returned 100% blocks executed 80% 1423: 104:ImagingPaletteDuplicate(ImagingPalette palette) -: 105:{ -: 106: /* Duplicate palette descriptor */ -: 107: -: 108: ImagingPalette new_palette; -: 109: 1423: 110: if (!palette) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 111: return NULL; -: 112: } -: 113: /* malloc check ok, small constant allocation */ 1423: 114: new_palette = malloc(sizeof(struct ImagingPaletteInstance)); 1423: 115: if (!new_palette) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 116: return (ImagingPalette) ImagingError_MemoryError(); call 0 never executed -: 117: } -: 118: 1423: 119: memcpy(new_palette, palette, sizeof(struct ImagingPaletteInstance)); -: 120: -: 121: /* Don't share the cache */ 1423: 122: new_palette->cache = NULL; -: 123: 1423: 124: return new_palette; -: 125:} -: 126: -: 127:void function ImagingPaletteDelete called 4656 returned 100% blocks executed 100% 4656: 128:ImagingPaletteDelete(ImagingPalette palette) -: 129:{ -: 130: /* Destroy palette object */ -: 131: 4656: 132: if (palette) { branch 0 taken 97% (fallthrough) branch 1 taken 3% 4528: 133: if (palette->cache) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 4: 134: free(palette->cache); -: 135: } 4528: 136: free(palette); -: 137: } 4656: 138:} -: 139: -: 140: -: 141:/* -------------------------------------------------------------------- */ -: 142:/* Colour mapping */ -: 143:/* -------------------------------------------------------------------- */ -: 144: -: 145:/* This code is used to map RGB triplets to palette indices, using -: 146: a palette index cache. */ -: 147: -: 148:/* -: 149: * This implementation is loosely based on the corresponding code in -: 150: * the IJG JPEG library by Thomas G. Lane. Original algorithms by -: 151: * Paul Heckbert and Spencer W. Thomas. -: 152: * -: 153: * The IJG JPEG library is copyright (C) 1991-1995, Thomas G. Lane. */ -: 154: -: 155:#define DIST(a, b, s) (a - b) * (a - b) * s -: 156: -: 157:/* Colour weights (no scaling, for now) */ -: 158:#define RSCALE 1 -: 159:#define GSCALE 1 -: 160:#define BSCALE 1 -: 161: -: 162:/* Calculated scaled distances */ -: 163:#define RDIST(a, b) DIST(a, b, RSCALE*RSCALE) -: 164:#define GDIST(a, b) DIST(a, b, GSCALE*GSCALE) -: 165:#define BDIST(a, b) DIST(a, b, BSCALE*BSCALE) -: 166: -: 167:/* Incremental steps */ -: 168:#define RSTEP (4 * RSCALE) -: 169:#define GSTEP (4 * GSCALE) -: 170:#define BSTEP (4 * BSCALE) -: 171: -: 172:#define BOX 8 -: 173: -: 174:#define BOXVOLUME BOX*BOX*BOX -: 175: -: 176:void function ImagingPaletteCacheUpdate called 6564 returned 100% blocks executed 100% 6564: 177:ImagingPaletteCacheUpdate(ImagingPalette palette, int r, int g, int b) -: 178:{ -: 179: int i, j; -: 180: unsigned int dmin[256], dmax; -: 181: int r0, g0, b0; -: 182: int r1, g1, b1; -: 183: int rc, gc, bc; -: 184: unsigned int d[BOXVOLUME]; -: 185: UINT8 c[BOXVOLUME]; -: 186: -: 187: /* Get box boundaries for the given (r,g,b)-triplet. Each box -: 188: covers eight cache slots (32 colour values, that is). */ -: 189: 6564: 190: r0 = r & 0xe0; r1 = r0 + 0x1f; rc = (r0 + r1) / 2; 6564: 191: g0 = g & 0xe0; g1 = g0 + 0x1f; gc = (g0 + g1) / 2; 6564: 192: b0 = b & 0xe0; b1 = b0 + 0x1f; bc = (b0 + b1) / 2; -: 193: -: 194: /* Step 1 -- Select relevant palette entries (after Heckbert) */ -: 195: -: 196: /* For each palette entry, calculate the min and max distances to -: 197: * any position in the box given by the colour we're looking for. */ -: 198: 6564: 199: dmax = (unsigned int) ~0; -: 200: 1686948: 201: for (i = 0; i < 256; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 202: -: 203: int r, g, b; -: 204: unsigned int tmin, tmax; -: 205: -: 206: /* Find min and max distances to any point in the box */ 1680384: 207: r = palette->palette[i*4+0]; 1680384: 208: tmin = (r < r0) ? RDIST(r, r1) : (r > r1) ? RDIST(r, r0) : 0; branch 0 taken 58% (fallthrough) branch 1 taken 42% branch 2 taken 73% (fallthrough) branch 3 taken 27% 1680384: 209: tmax = (r <= rc) ? RDIST(r, r1) : RDIST(r, r0); branch 0 taken 64% (fallthrough) branch 1 taken 36% -: 210: 1680384: 211: g = palette->palette[i*4+1]; 1680384: 212: tmin += (g < g0) ? GDIST(g, g1) : (g > g1) ? GDIST(g, g0) : 0; branch 0 taken 45% (fallthrough) branch 1 taken 55% branch 2 taken 78% (fallthrough) branch 3 taken 22% 1680384: 213: tmax += (g <= gc) ? GDIST(g, g1) : GDIST(g, g0); branch 0 taken 52% (fallthrough) branch 1 taken 48% -: 214: 1680384: 215: b = palette->palette[i*4+2]; 1680384: 216: tmin += (b < b0) ? BDIST(b, b1) : (b > b1) ? BDIST(b, b0) : 0; branch 0 taken 46% (fallthrough) branch 1 taken 54% branch 2 taken 78% (fallthrough) branch 3 taken 22% 1680384: 217: tmax += (b <= bc) ? BDIST(b, b1) : BDIST(b, b0); branch 0 taken 53% (fallthrough) branch 1 taken 47% -: 218: 1680384: 219: dmin[i] = tmin; 1680384: 220: if (tmax < dmax) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 131228: 221: dmax = tmax; /* keep the smallest max distance only */ -: 222: } -: 223: -: 224: } -: 225: -: 226: /* Step 2 -- Incrementally update cache slot (after Thomas) */ -: 227: -: 228: /* Find the box containing the nearest palette entry, and update -: 229: * all slots in that box. We only check boxes for which the min -: 230: * distance is less than or equal the smallest max distance */ -: 231: 3360768: 232: for (i = 0; i < BOXVOLUME; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3360768: 233: d[i] = (unsigned int) ~0; -: 234: } -: 235: 1680384: 236: for (i = 0; i < 256; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 237: 1680384: 238: if (dmin[i] <= dmax) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 239: -: 240: int rd, gd, bd; -: 241: int ri, gi, bi; -: 242: int rx, gx, bx; -: 243: 19183: 244: ri = (r0 - palette->palette[i*4+0]) * RSCALE; 19183: 245: gi = (g0 - palette->palette[i*4+1]) * GSCALE; 19183: 246: bi = (b0 - palette->palette[i*4+2]) * BSCALE; -: 247: 19183: 248: rd = ri*ri + gi*gi + bi*bi; -: 249: 19183: 250: ri = ri * (2 * RSTEP) + RSTEP * RSTEP; 19183: 251: gi = gi * (2 * GSTEP) + GSTEP * GSTEP; 19183: 252: bi = bi * (2 * BSTEP) + BSTEP * BSTEP; -: 253: 19183: 254: rx = ri; 172647: 255: for (r = j = 0; r < BOX; r++) { branch 0 taken 89% (fallthrough) branch 1 taken 11% -: 256: gd = rd; gx = gi; 1227712: 257: for (g = 0; g < BOX; g++) { branch 0 taken 89% (fallthrough) branch 1 taken 11% -: 258: bd = gd; bx = bi; 9821696: 259: for (b = 0; b < BOX; b++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 9821696: 260: if ((unsigned int) bd < d[j]) { branch 0 taken 60% (fallthrough) branch 1 taken 40% 5899708: 261: d[j] = bd; 5899708: 262: c[j] = (UINT8) i; -: 263: } 9821696: 264: bd += bx; 9821696: 265: bx += 2 * BSTEP * BSTEP; 9821696: 266: j++; -: 267: } 1227712: 268: gd += gx; 1227712: 269: gx += 2 * GSTEP * GSTEP; -: 270: } 153464: 271: rd += rx; 153464: 272: rx += 2 * RSTEP * RSTEP; -: 273: } -: 274: } -: 275: } -: 276: -: 277: /* Step 3 -- Update cache */ -: 278: -: 279: /* The c array now contains the closest match for each -: 280: * cache slot in the box. Update the cache. */ -: 281: -: 282: j = 0; 52512: 283: for (r = r0; r < r1; r+=4) { branch 0 taken 89% (fallthrough) branch 1 taken 11% 420096: 284: for (g = g0; g < g1; g+=4) { branch 0 taken 89% (fallthrough) branch 1 taken 11% 3360768: 285: for (b = b0; b < b1; b+=4) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 3360768: 286: ImagingPaletteCache(palette, r, g, b) = c[j++]; -: 287: } -: 288: } -: 289: } 6564: 290:} -: 291: -: 292: -: 293:int function ImagingPaletteCachePrepare called 77 returned 100% blocks executed 75% 77: 294:ImagingPaletteCachePrepare(ImagingPalette palette) -: 295:{ -: 296: /* Add a colour cache to a palette */ -: 297: -: 298: int i; 77: 299: int entries = 64*64*64; -: 300: 77: 301: if (palette->cache == NULL) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 302: -: 303: /* The cache is 512k. It might be a good idea to break it -: 304: up into a pointer array (e.g. an 8-bit image?) */ -: 305: -: 306: /* malloc check ok, small constant allocation */ 76: 307: palette->cache = (INT16*) malloc(entries * sizeof(INT16)); 76: 308: if (!palette->cache) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 309: (void) ImagingError_MemoryError(); call 0 never executed #####: 310: return -1; -: 311: } -: 312: -: 313: /* Mark all entries as empty */ 19922944: 314: for (i = 0; i < entries; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 19922944: 315: palette->cache[i] = 0x100; -: 316: } -: 317: -: 318: } -: 319: -: 320: return 0; -: 321:} -: 322: -: 323: -: 324:void function ImagingPaletteCacheDelete called 72 returned 100% blocks executed 100% 72: 325:ImagingPaletteCacheDelete(ImagingPalette palette) -: 326:{ -: 327: /* Release the colour cache, if any */ -: 328: 72: 329: if (palette && palette->cache) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 72: 330: free(palette->cache); 72: 331: palette->cache = NULL; -: 332: } 72: 333:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#s390x-linux-gnu#bits#stdio2.h.gcov -: 0:Source:/usr/include/s390x-linux-gnu/bits/stdio2.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/QuantPngQuant.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/QuantPngQuant.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* Checking macros for stdio functions. -: 2: Copyright (C) 2004-2016 Free Software Foundation, Inc. -: 3: This file is part of the GNU C Library. -: 4: -: 5: The GNU C Library is free software; you can redistribute it and/or -: 6: modify it under the terms of the GNU Lesser General Public -: 7: License as published by the Free Software Foundation; either -: 8: version 2.1 of the License, or (at your option) any later version. -: 9: -: 10: The GNU C Library is distributed in the hope that it will be useful, -: 11: but WITHOUT ANY WARRANTY; without even the implied warranty of -: 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -: 13: Lesser General Public License for more details. -: 14: -: 15: You should have received a copy of the GNU Lesser General Public -: 16: License along with the GNU C Library; if not, see -: 17: . */ -: 18: -: 19:#ifndef _STDIO_H -: 20:# error "Never include directly; use instead." -: 21:#endif -: 22: -: 23:extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen, -: 24: const char *__restrict __format, ...) __THROW; -: 25:extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen, -: 26: const char *__restrict __format, -: 27: _G_va_list __ap) __THROW; -: 28: -: 29:#ifdef __va_arg_pack -: 30:__fortify_function int -: 31:__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...)) -: 32:{ 3: 33: return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, -: 34: __bos (__s), __fmt, __va_arg_pack ()); -: 35:} -: 36:#elif !defined __cplusplus -: 37:# define sprintf(str, ...) \ -: 38: __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, __bos (str), \ -: 39: __VA_ARGS__) -: 40:#endif -: 41: -: 42:__fortify_function int -: 43:__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt, -: 44: _G_va_list __ap)) -: 45:{ -: 46: return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, -: 47: __bos (__s), __fmt, __ap); -: 48:} -: 49: -: 50:#if defined __USE_ISOC99 || defined __USE_UNIX98 -: 51: -: 52:extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag, -: 53: size_t __slen, const char *__restrict __format, -: 54: ...) __THROW; -: 55:extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, -: 56: size_t __slen, const char *__restrict __format, -: 57: _G_va_list __ap) __THROW; -: 58: -: 59:# ifdef __va_arg_pack -: 60:__fortify_function int -: 61:__NTH (snprintf (char *__restrict __s, size_t __n, -: 62: const char *__restrict __fmt, ...)) -: 63:{ -: 64: return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, -: 65: __bos (__s), __fmt, __va_arg_pack ()); -: 66:} -: 67:# elif !defined __cplusplus -: 68:# define snprintf(str, len, ...) \ -: 69: __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \ -: 70: __VA_ARGS__) -: 71:# endif -: 72: -: 73:__fortify_function int -: 74:__NTH (vsnprintf (char *__restrict __s, size_t __n, -: 75: const char *__restrict __fmt, _G_va_list __ap)) -: 76:{ -: 77: return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, -: 78: __bos (__s), __fmt, __ap); -: 79:} -: 80: -: 81:#endif -: 82: -: 83:#if __USE_FORTIFY_LEVEL > 1 -: 84: -: 85:extern int __fprintf_chk (FILE *__restrict __stream, int __flag, -: 86: const char *__restrict __format, ...); -: 87:extern int __printf_chk (int __flag, const char *__restrict __format, ...); -: 88:extern int __vfprintf_chk (FILE *__restrict __stream, int __flag, -: 89: const char *__restrict __format, _G_va_list __ap); -: 90:extern int __vprintf_chk (int __flag, const char *__restrict __format, -: 91: _G_va_list __ap); -: 92: -: 93:# ifdef __va_arg_pack -: 94:__fortify_function int -: 95:fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...) -: 96:{ -: 97: return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, -: 98: __va_arg_pack ()); -: 99:} -: 100: -: 101:__fortify_function int -: 102:printf (const char *__restrict __fmt, ...) -: 103:{ -: 104: return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); -: 105:} -: 106:# elif !defined __cplusplus -: 107:# define printf(...) \ -: 108: __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -: 109:# define fprintf(stream, ...) \ -: 110: __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -: 111:# endif -: 112: -: 113:__fortify_function int -: 114:vprintf (const char *__restrict __fmt, _G_va_list __ap) -: 115:{ -: 116:#ifdef __USE_EXTERN_INLINES -: 117: return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); -: 118:#else -: 119: return __vprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap); -: 120:#endif -: 121:} -: 122: -: 123:__fortify_function int -: 124:vfprintf (FILE *__restrict __stream, -: 125: const char *__restrict __fmt, _G_va_list __ap) -: 126:{ -: 127: return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); -: 128:} -: 129: -: 130:# ifdef __USE_XOPEN2K8 -: 131:extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt, -: 132: ...) __attribute__ ((__format__ (__printf__, 3, 4))); -: 133:extern int __vdprintf_chk (int __fd, int __flag, -: 134: const char *__restrict __fmt, _G_va_list __arg) -: 135: __attribute__ ((__format__ (__printf__, 3, 0))); -: 136: -: 137:# ifdef __va_arg_pack -: 138:__fortify_function int -: 139:dprintf (int __fd, const char *__restrict __fmt, ...) -: 140:{ -: 141: return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, -: 142: __va_arg_pack ()); -: 143:} -: 144:# elif !defined __cplusplus -: 145:# define dprintf(fd, ...) \ -: 146: __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -: 147:# endif -: 148: -: 149:__fortify_function int -: 150:vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap) -: 151:{ -: 152: return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); -: 153:} -: 154:# endif -: 155: -: 156:# ifdef __USE_GNU -: 157: -: 158:extern int __asprintf_chk (char **__restrict __ptr, int __flag, -: 159: const char *__restrict __fmt, ...) -: 160: __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur; -: 161:extern int __vasprintf_chk (char **__restrict __ptr, int __flag, -: 162: const char *__restrict __fmt, _G_va_list __arg) -: 163: __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur; -: 164:extern int __obstack_printf_chk (struct obstack *__restrict __obstack, -: 165: int __flag, const char *__restrict __format, -: 166: ...) -: 167: __THROW __attribute__ ((__format__ (__printf__, 3, 4))); -: 168:extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack, -: 169: int __flag, -: 170: const char *__restrict __format, -: 171: _G_va_list __args) -: 172: __THROW __attribute__ ((__format__ (__printf__, 3, 0))); -: 173: -: 174:# ifdef __va_arg_pack -: 175:__fortify_function int -: 176:__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...)) -: 177:{ -: 178: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, -: 179: __va_arg_pack ()); -: 180:} -: 181: -: 182:__fortify_function int -: 183:__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt, -: 184: ...)) -: 185:{ -: 186: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, -: 187: __va_arg_pack ()); -: 188:} -: 189: -: 190:__fortify_function int -: 191:__NTH (obstack_printf (struct obstack *__restrict __obstack, -: 192: const char *__restrict __fmt, ...)) -: 193:{ -: 194: return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, -: 195: __va_arg_pack ()); -: 196:} -: 197:# elif !defined __cplusplus -: 198:# define asprintf(ptr, ...) \ -: 199: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -: 200:# define __asprintf(ptr, ...) \ -: 201: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -: 202:# define obstack_printf(obstack, ...) \ -: 203: __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -: 204:# endif -: 205: -: 206:__fortify_function int -: 207:__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt, -: 208: _G_va_list __ap)) -: 209:{ -: 210: return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); -: 211:} -: 212: -: 213:__fortify_function int -: 214:__NTH (obstack_vprintf (struct obstack *__restrict __obstack, -: 215: const char *__restrict __fmt, _G_va_list __ap)) -: 216:{ -: 217: return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, -: 218: __ap); -: 219:} -: 220: -: 221:# endif -: 222: -: 223:#endif -: 224: -: 225:#if !defined __USE_ISOC11 \ -: 226: || (defined __cplusplus && __cplusplus <= 201103L && !defined __USE_GNU) -: 227:extern char *__gets_chk (char *__str, size_t) __wur; -: 228:extern char *__REDIRECT (__gets_warn, (char *__str), gets) -: 229: __wur __warnattr ("please use fgets or getline instead, gets can't " -: 230: "specify buffer size"); -: 231: -: 232:__fortify_function __wur char * -: 233:gets (char *__str) -: 234:{ -: 235: if (__bos (__str) != (size_t) -1) -: 236: return __gets_chk (__str, __bos (__str)); -: 237: return __gets_warn (__str); -: 238:} -: 239:#endif -: 240: -: 241:extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, -: 242: FILE *__restrict __stream) __wur; -: 243:extern char *__REDIRECT (__fgets_alias, -: 244: (char *__restrict __s, int __n, -: 245: FILE *__restrict __stream), fgets) __wur; -: 246:extern char *__REDIRECT (__fgets_chk_warn, -: 247: (char *__restrict __s, size_t __size, int __n, -: 248: FILE *__restrict __stream), __fgets_chk) -: 249: __wur __warnattr ("fgets called with bigger size than length " -: 250: "of destination buffer"); -: 251: -: 252:__fortify_function __wur char * -: 253:fgets (char *__restrict __s, int __n, FILE *__restrict __stream) -: 254:{ -: 255: if (__bos (__s) != (size_t) -1) -: 256: { -: 257: if (!__builtin_constant_p (__n) || __n <= 0) -: 258: return __fgets_chk (__s, __bos (__s), __n, __stream); -: 259: -: 260: if ((size_t) __n > __bos (__s)) -: 261: return __fgets_chk_warn (__s, __bos (__s), __n, __stream); -: 262: } -: 263: return __fgets_alias (__s, __n, __stream); -: 264:} -: 265: -: 266:extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, -: 267: size_t __size, size_t __n, -: 268: FILE *__restrict __stream) __wur; -: 269:extern size_t __REDIRECT (__fread_alias, -: 270: (void *__restrict __ptr, size_t __size, -: 271: size_t __n, FILE *__restrict __stream), -: 272: fread) __wur; -: 273:extern size_t __REDIRECT (__fread_chk_warn, -: 274: (void *__restrict __ptr, size_t __ptrlen, -: 275: size_t __size, size_t __n, -: 276: FILE *__restrict __stream), -: 277: __fread_chk) -: 278: __wur __warnattr ("fread called with bigger size * nmemb than length " -: 279: "of destination buffer"); -: 280: -: 281:__fortify_function __wur size_t -: 282:fread (void *__restrict __ptr, size_t __size, size_t __n, -: 283: FILE *__restrict __stream) -: 284:{ -: 285: if (__bos0 (__ptr) != (size_t) -1) -: 286: { -: 287: if (!__builtin_constant_p (__size) -: 288: || !__builtin_constant_p (__n) -: 289: || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2))) -: 290: return __fread_chk (__ptr, __bos0 (__ptr), __size, __n, __stream); -: 291: -: 292: if (__size * __n > __bos0 (__ptr)) -: 293: return __fread_chk_warn (__ptr, __bos0 (__ptr), __size, __n, __stream); -: 294: } -: 295: return __fread_alias (__ptr, __size, __n, __stream); -: 296:} -: 297: -: 298:#ifdef __USE_GNU -: 299:extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, -: 300: int __n, FILE *__restrict __stream) __wur; -: 301:extern char *__REDIRECT (__fgets_unlocked_alias, -: 302: (char *__restrict __s, int __n, -: 303: FILE *__restrict __stream), fgets_unlocked) __wur; -: 304:extern char *__REDIRECT (__fgets_unlocked_chk_warn, -: 305: (char *__restrict __s, size_t __size, int __n, -: 306: FILE *__restrict __stream), __fgets_unlocked_chk) -: 307: __wur __warnattr ("fgets_unlocked called with bigger size than length " -: 308: "of destination buffer"); -: 309: -: 310:__fortify_function __wur char * -: 311:fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) -: 312:{ -: 313: if (__bos (__s) != (size_t) -1) -: 314: { -: 315: if (!__builtin_constant_p (__n) || __n <= 0) -: 316: return __fgets_unlocked_chk (__s, __bos (__s), __n, __stream); -: 317: -: 318: if ((size_t) __n > __bos (__s)) -: 319: return __fgets_unlocked_chk_warn (__s, __bos (__s), __n, __stream); -: 320: } -: 321: return __fgets_unlocked_alias (__s, __n, __stream); -: 322:} -: 323:#endif -: 324: -: 325:#ifdef __USE_MISC -: 326:# undef fread_unlocked -: 327:extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen, -: 328: size_t __size, size_t __n, -: 329: FILE *__restrict __stream) __wur; -: 330:extern size_t __REDIRECT (__fread_unlocked_alias, -: 331: (void *__restrict __ptr, size_t __size, -: 332: size_t __n, FILE *__restrict __stream), -: 333: fread_unlocked) __wur; -: 334:extern size_t __REDIRECT (__fread_unlocked_chk_warn, -: 335: (void *__restrict __ptr, size_t __ptrlen, -: 336: size_t __size, size_t __n, -: 337: FILE *__restrict __stream), -: 338: __fread_unlocked_chk) -: 339: __wur __warnattr ("fread_unlocked called with bigger size * nmemb than " -: 340: "length of destination buffer"); -: 341: -: 342:__fortify_function __wur size_t -: 343:fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, -: 344: FILE *__restrict __stream) -: 345:{ -: 346: if (__bos0 (__ptr) != (size_t) -1) -: 347: { -: 348: if (!__builtin_constant_p (__size) -: 349: || !__builtin_constant_p (__n) -: 350: || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2))) -: 351: return __fread_unlocked_chk (__ptr, __bos0 (__ptr), __size, __n, -: 352: __stream); -: 353: -: 354: if (__size * __n > __bos0 (__ptr)) -: 355: return __fread_unlocked_chk_warn (__ptr, __bos0 (__ptr), __size, __n, -: 356: __stream); -: 357: } -: 358: -: 359:# ifdef __USE_EXTERN_INLINES -: 360: if (__builtin_constant_p (__size) -: 361: && __builtin_constant_p (__n) -: 362: && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2)) -: 363: && __size * __n <= 8) -: 364: { -: 365: size_t __cnt = __size * __n; -: 366: char *__cptr = (char *) __ptr; -: 367: if (__cnt == 0) -: 368: return 0; -: 369: -: 370: for (; __cnt > 0; --__cnt) -: 371: { -: 372: int __c = _IO_getc_unlocked (__stream); -: 373: if (__c == EOF) -: 374: break; -: 375: *__cptr++ = __c; -: 376: } -: 377: return (__cptr - (char *) __ptr) / __size; -: 378: } -: 379:# endif -: 380: return __fread_unlocked_alias (__ptr, __size, __n, __stream); -: 381:} -: 382:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Effects.c.gcov -: 0:Source:src/libImaging/Effects.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Effects.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Effects.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * various special effects and image generators -: 6: * -: 7: * history: -: 8: * 1997-05-21 fl Just for fun -: 9: * 1997-06-05 fl Added mandelbrot generator -: 10: * 2003-05-24 fl Added perlin_turbulence generator (in progress) -: 11: * -: 12: * Copyright (c) 1997-2003 by Fredrik Lundh. -: 13: * Copyright (c) 1997 by Secret Labs AB. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21:#include -: 22: -: 23:Imaging function ImagingEffectMandelbrot called 2 returned 100% blocks executed 100% 2: 24:ImagingEffectMandelbrot(int xsize, int ysize, double extent[4], int quality) -: 25:{ -: 26: /* Generate a Mandelbrot set covering the given extent */ -: 27: -: 28: Imaging im; -: 29: int x, y, k; -: 30: double width, height; -: 31: double x1, y1, xi2, yi2, cr, ci, radius; -: 32: double dr, di; -: 33: -: 34: /* Check arguments */ 2: 35: width = extent[2] - extent[0]; 2: 36: height = extent[3] - extent[1]; 2: 37: if (width < 0.0 || height < 0.0 || quality < 2) { branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% 1: 38: return (Imaging) ImagingError_ValueError(NULL); call 0 returned 100% -: 39: } -: 40: 1: 41: im = ImagingNewDirty("L", xsize, ysize); call 0 returned 100% 1: 42: if (!im) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 43: return NULL; -: 44: } -: 45: 1: 46: dr = width/(xsize-1); 1: 47: di = height/(ysize-1); -: 48: 1: 49: radius = 100.0; -: 50: 513: 51: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 512: 52: UINT8* buf = im->image8[y]; 262656: 53: for (x = 0; x < xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 262144: 54: x1 = y1 = xi2 = yi2 = 0.0; 262144: 55: cr = x*dr + extent[0]; 262144: 56: ci = y*di + extent[1]; 2641150: 57: for (k = 1;; k++) { 2641150: 58: y1 = 2*x1*y1 + ci; 2641150: 59: x1 = xi2 - yi2 + cr; 2641150: 60: xi2 = x1*x1; 2641150: 61: yi2 = y1*y1; 2641150: 62: if ((xi2 + yi2) > radius) { branch 0 taken 9% (fallthrough) branch 1 taken 91% 245974: 63: buf[x] = k*255/quality; 245974: 64: break; -: 65: } 2395176: 66: if (k > quality) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 16170: 67: buf[x] = 0; 16170: 68: break; -: 69: } 2379006: 70: } -: 71: } -: 72: } -: 73: return im; -: 74:} -: 75: -: 76:Imaging function ImagingEffectNoise called 1 returned 100% blocks executed 100% 1: 77:ImagingEffectNoise(int xsize, int ysize, float sigma) -: 78:{ -: 79: /* Generate Gaussian noise centered around 128 */ -: 80: -: 81: Imaging imOut; -: 82: int x, y; -: 83: int nextok; -: 84: double this, next; -: 85: 1: 86: imOut = ImagingNewDirty("L", xsize, ysize); call 0 returned 100% 1: 87: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 88: return NULL; -: 89: } -: 90: -: 91: next = 0.0; -: 92: nextok = 0; -: 93: 100: 94: for (y = 0; y < imOut->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 100: 95: UINT8* out = imOut->image8[y]; 10100: 96: for (x = 0; x < imOut->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 97: if (nextok) { -: 98: this = next; -: 99: nextok = 0; -: 100: } else { -: 101: /* after numerical recipes */ -: 102: double v1, v2, radius, factor; -: 103: do { 12782: 104: v1 = rand()*(2.0/RAND_MAX) - 1.0; call 0 returned 100% 12782: 105: v2 = rand()*(2.0/RAND_MAX) - 1.0; call 0 returned 100% 12782: 106: radius= v1*v1 + v2*v2; 12782: 107: } while (radius >= 1.0); branch 0 taken 22% (fallthrough) branch 1 taken 78% 10000: 108: factor = sqrt(-2.0*log(radius)/radius); 10000: 109: this = factor * v1; 10000: 110: next = factor * v2; -: 111: } 10000: 112: out[x] = CLIP8(128 + sigma * this); branch 0 taken 83% (fallthrough) branch 1 taken 17% branch 2 taken 81% (fallthrough) branch 3 taken 19% -: 113: } -: 114: } -: 115: -: 116: return imOut; -: 117:} -: 118: -: 119:Imaging function ImagingEffectSpread called 2 returned 100% blocks executed 56% 2: 120:ImagingEffectSpread(Imaging imIn, int distance) -: 121:{ -: 122: /* Randomly spread pixels in an image */ -: 123: -: 124: Imaging imOut; -: 125: int x, y; -: 126: 2: 127: imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize); call 0 returned 100% -: 128: 2: 129: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 130: return NULL; -: 131: } -: 132: -: 133:#define SPREAD(type, image)\ -: 134: if (distance == 0) {\ -: 135: for (y = 0; y < imOut->ysize; y++) {\ -: 136: for (x = 0; x < imOut->xsize; x++) {\ -: 137: imOut->image[y][x] = imIn->image[y][x];\ -: 138: }\ -: 139: }\ -: 140: } else {\ -: 141: for (y = 0; y < imOut->ysize; y++) {\ -: 142: for (x = 0; x < imOut->xsize; x++) {\ -: 143: int xx = x + (rand() % distance) - distance/2;\ -: 144: int yy = y + (rand() % distance) - distance/2;\ -: 145: if (xx >= 0 && xx < imIn->xsize && yy >= 0 && yy < imIn->ysize) {\ -: 146: imOut->image[yy][xx] = imIn->image[y][x];\ -: 147: imOut->image[y][x] = imIn->image[yy][xx];\ -: 148: } else {\ -: 149: imOut->image[y][x] = imIn->image[y][x];\ -: 150: }\ -: 151: }\ -: 152: }\ -: 153: } -: 154: 2: 155: if (imIn->image8) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 156: SPREAD(UINT8, image8); branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed call 6 never executed call 7 never executed branch 8 never executed branch 9 never executed branch 10 never executed branch 11 never executed branch 12 never executed branch 13 never executed branch 14 never executed branch 15 never executed branch 16 never executed branch 17 never executed branch 18 never executed branch 19 never executed -: 157: } else { 2: 158: SPREAD(INT32, image32); branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 99% (fallthrough) branch 5 taken 1% call 6 returned 100% call 7 returned 100% branch 8 taken 99% (fallthrough) branch 9 taken 1% branch 10 taken 99% (fallthrough) branch 11 taken 1% branch 12 taken 99% (fallthrough) branch 13 taken 1% branch 14 taken 99% (fallthrough) branch 15 taken 1% branch 16 taken 99% branch 17 taken 1% (fallthrough) branch 18 taken 99% (fallthrough) branch 19 taken 1% -: 159: } -: 160: 2: 161: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 162: 2: 163: return imOut; -: 164:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#s390x-linux-gnu#bits#mathcalls.h.gcov -: 0:Source:/usr/include/s390x-linux-gnu/bits/mathcalls.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Convert.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/Convert.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* Prototype declarations for math functions; helper file for . -: 2: Copyright (C) 1996-2016 Free Software Foundation, Inc. -: 3: This file is part of the GNU C Library. -: 4: -: 5: The GNU C Library is free software; you can redistribute it and/or -: 6: modify it under the terms of the GNU Lesser General Public -: 7: License as published by the Free Software Foundation; either -: 8: version 2.1 of the License, or (at your option) any later version. -: 9: -: 10: The GNU C Library is distributed in the hope that it will be useful, -: 11: but WITHOUT ANY WARRANTY; without even the implied warranty of -: 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -: 13: Lesser General Public License for more details. -: 14: -: 15: You should have received a copy of the GNU Lesser General Public -: 16: License along with the GNU C Library; if not, see -: 17: . */ -: 18: -: 19:/* NOTE: Because of the special way this file is used by , this -: 20: file must NOT be protected from multiple inclusion as header files -: 21: usually are. -: 22: -: 23: This file provides prototype declarations for the math functions. -: 24: Most functions are declared using the macro: -: 25: -: 26: __MATHCALL (NAME,[_r], (ARGS...)); -: 27: -: 28: This means there is a function `NAME' returning `double' and a function -: 29: `NAMEf' returning `float'. Each place `_Mdouble_' appears in the -: 30: prototype, that is actually `double' in the prototype for `NAME' and -: 31: `float' in the prototype for `NAMEf'. Reentrant variant functions are -: 32: called `NAME_r' and `NAMEf_r'. -: 33: -: 34: Functions returning other types like `int' are declared using the macro: -: 35: -: 36: __MATHDECL (TYPE, NAME,[_r], (ARGS...)); -: 37: -: 38: This is just like __MATHCALL but for a function returning `TYPE' -: 39: instead of `_Mdouble_'. In all of these cases, there is still -: 40: both a `NAME' and a `NAMEf' that takes `float' arguments. -: 41: -: 42: Note that there must be no whitespace before the argument passed for -: 43: NAME, to make token pasting work with -traditional. */ -: 44: -: 45:#ifndef _MATH_H -: 46:# error "Never include directly; include instead." -: 47:#endif -: 48: -: 49: -: 50:/* Trigonometric functions. */ -: 51: -: 52:_Mdouble_BEGIN_NAMESPACE -: 53:/* Arc cosine of X. */ -: 54:__MATHCALL (acos,, (_Mdouble_ __x)); -: 55:/* Arc sine of X. */ -: 56:__MATHCALL (asin,, (_Mdouble_ __x)); -: 57:/* Arc tangent of X. */ -: 58:__MATHCALL (atan,, (_Mdouble_ __x)); -: 59:/* Arc tangent of Y/X. */ -: 60:__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); -: 61: -: 62:/* Cosine of X. */ -: 63:__MATHCALL_VEC (cos,, (_Mdouble_ __x)); -: 64:/* Sine of X. */ -: 65:__MATHCALL_VEC (sin,, (_Mdouble_ __x)); -: 66:/* Tangent of X. */ -: 67:__MATHCALL (tan,, (_Mdouble_ __x)); -: 68: -: 69:/* Hyperbolic functions. */ -: 70: -: 71:/* Hyperbolic cosine of X. */ -: 72:__MATHCALL (cosh,, (_Mdouble_ __x)); -: 73:/* Hyperbolic sine of X. */ -: 74:__MATHCALL (sinh,, (_Mdouble_ __x)); -: 75:/* Hyperbolic tangent of X. */ -: 76:__MATHCALL (tanh,, (_Mdouble_ __x)); -: 77:_Mdouble_END_NAMESPACE -: 78: -: 79:#ifdef __USE_GNU -: 80:/* Cosine and sine of X. */ -: 81:__MATHDECL_VEC (void,sincos,, -: 82: (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx)); -: 83:#endif -: 84: -: 85:#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 -: 86:__BEGIN_NAMESPACE_C99 -: 87:/* Hyperbolic arc cosine of X. */ -: 88:__MATHCALL (acosh,, (_Mdouble_ __x)); -: 89:/* Hyperbolic arc sine of X. */ -: 90:__MATHCALL (asinh,, (_Mdouble_ __x)); -: 91:/* Hyperbolic arc tangent of X. */ -: 92:__MATHCALL (atanh,, (_Mdouble_ __x)); -: 93:__END_NAMESPACE_C99 -: 94:#endif -: 95: -: 96:/* Exponential and logarithmic functions. */ -: 97: -: 98:_Mdouble_BEGIN_NAMESPACE -: 99:/* Exponential function of X. */ -: 100:__MATHCALL_VEC (exp,, (_Mdouble_ __x)); -: 101: -: 102:/* Break VALUE into a normalized fraction and an integral power of 2. */ -: 103:__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent)); -: 104: -: 105:/* X times (two to the EXP power). */ -: 106:__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent)); -: 107: -: 108:/* Natural logarithm of X. */ -: 109:__MATHCALL_VEC (log,, (_Mdouble_ __x)); -: 110: -: 111:/* Base-ten logarithm of X. */ -: 112:__MATHCALL (log10,, (_Mdouble_ __x)); -: 113: -: 114:/* Break VALUE into integral and fractional parts. */ -: 115:__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)) __nonnull ((2)); -: 116:_Mdouble_END_NAMESPACE -: 117: -: 118:#ifdef __USE_GNU -: 119:/* A function missing in all standards: compute exponent to base ten. */ -: 120:__MATHCALL (exp10,, (_Mdouble_ __x)); -: 121:/* Another name occasionally used. */ -: 122:__MATHCALL (pow10,, (_Mdouble_ __x)); -: 123:#endif -: 124: -: 125:#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 -: 126:__BEGIN_NAMESPACE_C99 -: 127:/* Return exp(X) - 1. */ -: 128:__MATHCALL (expm1,, (_Mdouble_ __x)); -: 129: -: 130:/* Return log(1 + X). */ -: 131:__MATHCALL (log1p,, (_Mdouble_ __x)); -: 132: -: 133:/* Return the base 2 signed integral exponent of X. */ -: 134:__MATHCALL (logb,, (_Mdouble_ __x)); -: 135:__END_NAMESPACE_C99 -: 136:#endif -: 137: -: 138:#ifdef __USE_ISOC99 -: 139:__BEGIN_NAMESPACE_C99 -: 140:/* Compute base-2 exponential of X. */ -: 141:__MATHCALL (exp2,, (_Mdouble_ __x)); -: 142: -: 143:/* Compute base-2 logarithm of X. */ -: 144:__MATHCALL (log2,, (_Mdouble_ __x)); -: 145:__END_NAMESPACE_C99 -: 146:#endif -: 147: -: 148: -: 149:/* Power functions. */ -: 150: -: 151:_Mdouble_BEGIN_NAMESPACE -: 152:/* Return X to the Y power. */ -: 153:__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y)); -: 154: -: 155:/* Return the square root of X. */ -: 156:__MATHCALL (sqrt,, (_Mdouble_ __x)); -: 157:_Mdouble_END_NAMESPACE -: 158: -: 159:#if defined __USE_XOPEN || defined __USE_ISOC99 -: 160:__BEGIN_NAMESPACE_C99 -: 161:/* Return `sqrt(X*X + Y*Y)'. */ -: 162:__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y)); -: 163:__END_NAMESPACE_C99 -: 164:#endif -: 165: -: 166:#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 -: 167:__BEGIN_NAMESPACE_C99 -: 168:/* Return the cube root of X. */ -: 169:__MATHCALL (cbrt,, (_Mdouble_ __x)); -: 170:__END_NAMESPACE_C99 -: 171:#endif -: 172: -: 173: -: 174:/* Nearest integer, absolute value, and remainder functions. */ -: 175: -: 176:_Mdouble_BEGIN_NAMESPACE -: 177:/* Smallest integral value not less than X. */ -: 178:__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__)); -: 179: -: 180:/* Absolute value of X. */ -: 181:__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__)); -: 182: -: 183:/* Largest integer not greater than X. */ -: 184:__MATHCALLX (floor,, (_Mdouble_ __x), (__const__)); -: 185: -: 186:/* Floating-point modulo remainder of X/Y. */ -: 187:__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y)); -: 188: -: 189: -: 190:/* Return 0 if VALUE is finite or NaN, +1 if it -: 191: is +Infinity, -1 if it is -Infinity. */ -: 192:__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); -: 193: -: 194:/* Return nonzero if VALUE is finite and not NaN. */ -: 195:__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); -: 196:_Mdouble_END_NAMESPACE -: 197: -: 198:#ifdef __USE_MISC -: 199:# if (!defined __cplusplus \ -: 200: || __cplusplus < 201103L /* isinf conflicts with C++11. */ \ -: 201: || __MATH_DECLARING_DOUBLE == 0) /* isinff or isinfl don't. */ -: 202:/* Return 0 if VALUE is finite or NaN, +1 if it -: 203: is +Infinity, -1 if it is -Infinity. */ -: 204:__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); -: 205:# endif -: 206: -: 207:/* Return nonzero if VALUE is finite and not NaN. */ -: 208:__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); -: 209: -: 210:/* Return the remainder of X/Y. */ -: 211:__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); -: 212: -: 213: -: 214:/* Return the fractional part of X after dividing out `ilogb (X)'. */ -: 215:__MATHCALL (significand,, (_Mdouble_ __x)); -: 216:#endif /* Use misc. */ -: 217: -: 218:#ifdef __USE_ISOC99 -: 219:__BEGIN_NAMESPACE_C99 -: 220:/* Return X with its signed changed to Y's. */ -: 221:__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); -: 222:__END_NAMESPACE_C99 -: 223:#endif -: 224: -: 225:#ifdef __USE_ISOC99 -: 226:__BEGIN_NAMESPACE_C99 -: 227:/* Return representation of qNaN for double type. */ -: 228:__MATHCALLX (nan,, (const char *__tagb), (__const__)); -: 229:__END_NAMESPACE_C99 -: 230:#endif -: 231: -: 232: -: 233:/* Return nonzero if VALUE is not a number. */ -: 234:__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); -: 235: -: 236:#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) -: 237:# if (!defined __cplusplus \ -: 238: || __cplusplus < 201103L /* isnan conflicts with C++11. */ \ -: 239: || __MATH_DECLARING_DOUBLE == 0) /* isnanf or isnanl don't. */ -: 240:/* Return nonzero if VALUE is not a number. */ -: 241:__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); -: 242:# endif -: 243:#endif -: 244: -: 245:#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE) -: 246:/* Bessel functions. */ -: 247:__MATHCALL (j0,, (_Mdouble_)); -: 248:__MATHCALL (j1,, (_Mdouble_)); -: 249:__MATHCALL (jn,, (int, _Mdouble_)); -: 250:__MATHCALL (y0,, (_Mdouble_)); -: 251:__MATHCALL (y1,, (_Mdouble_)); -: 252:__MATHCALL (yn,, (int, _Mdouble_)); -: 253:#endif -: 254: -: 255: -: 256:#if defined __USE_XOPEN || defined __USE_ISOC99 -: 257:__BEGIN_NAMESPACE_C99 -: 258:/* Error and gamma functions. */ -: 259:__MATHCALL (erf,, (_Mdouble_)); -: 260:__MATHCALL (erfc,, (_Mdouble_)); -: 261:__MATHCALL (lgamma,, (_Mdouble_)); -: 262:__END_NAMESPACE_C99 -: 263:#endif -: 264: -: 265:#ifdef __USE_ISOC99 -: 266:__BEGIN_NAMESPACE_C99 -: 267:/* True gamma function. */ -: 268:__MATHCALL (tgamma,, (_Mdouble_)); -: 269:__END_NAMESPACE_C99 -: 270:#endif -: 271: -: 272:#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) -: 273:/* Obsolete alias for `lgamma'. */ -: 274:__MATHCALL (gamma,, (_Mdouble_)); -: 275:#endif -: 276: -: 277:#ifdef __USE_MISC -: 278:/* Reentrant version of lgamma. This function uses the global variable -: 279: `signgam'. The reentrant version instead takes a pointer and stores -: 280: the value through it. */ -: 281:__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp)); -: 282:#endif -: 283: -: 284: -: 285:#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 -: 286:__BEGIN_NAMESPACE_C99 -: 287:/* Return the integer nearest X in the direction of the -: 288: prevailing rounding mode. */ -: 289:__MATHCALL (rint,, (_Mdouble_ __x)); -: 290: -: 291:/* Return X + epsilon if X < Y, X - epsilon if X > Y. */ -: 292:__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); -: 293:# if defined __USE_ISOC99 && !defined __LDBL_COMPAT -: 294:__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__)); -: 295:# endif -: 296: -: 297:/* Return the remainder of integer divison X / Y with infinite precision. */ -: 298:__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y)); -: 299: -: 300:# ifdef __USE_ISOC99 -: 301:/* Return X times (2 to the Nth power). */ -: 302:__MATHCALL (scalbn,, (_Mdouble_ __x, int __n)); -: 303:# endif -: 304: -: 305:/* Return the binary exponent of X, which must be nonzero. */ -: 306:__MATHDECL (int,ilogb,, (_Mdouble_ __x)); -: 307:#endif -: 308: -: 309:#ifdef __USE_ISOC99 -: 310:/* Return X times (2 to the Nth power). */ -: 311:__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n)); -: 312: -: 313:/* Round X to integral value in floating-point format using current -: 314: rounding direction, but do not raise inexact exception. */ -: 315:__MATHCALL (nearbyint,, (_Mdouble_ __x)); -: 316: -: 317:/* Round X to nearest integral value, rounding halfway cases away from -: 318: zero. */ function round called 0 returned 0% blocks executed 0% #####: 319:__MATHCALLX (round,, (_Mdouble_ __x), (__const__)); -: 320: -: 321:/* Round X to the integral value in floating-point format nearest but -: 322: not larger in magnitude. */ -: 323:__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__)); -: 324: -: 325:/* Compute remainder of X and Y and put in *QUO a value with sign of x/y -: 326: and magnitude congruent `mod 2^n' to the magnitude of the integral -: 327: quotient x/y, with n >= 3. */ -: 328:__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo)); -: 329: -: 330: -: 331:/* Conversion functions. */ -: 332: -: 333:/* Round X to nearest integral value according to current rounding -: 334: direction. */ -: 335:__MATHDECL (long int,lrint,, (_Mdouble_ __x)); -: 336:__extension__ -: 337:__MATHDECL (long long int,llrint,, (_Mdouble_ __x)); -: 338: -: 339:/* Round X to nearest integral value, rounding halfway cases away from -: 340: zero. */ -: 341:__MATHDECL (long int,lround,, (_Mdouble_ __x)); -: 342:__extension__ -: 343:__MATHDECL (long long int,llround,, (_Mdouble_ __x)); -: 344: -: 345: -: 346:/* Return positive difference between X and Y. */ -: 347:__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y)); -: 348: -: 349:/* Return maximum numeric value from X and Y. */ -: 350:__MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); -: 351: -: 352:/* Return minimum numeric value from X and Y. */ -: 353:__MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); -: 354: -: 355: -: 356:/* Classify given number. */ -: 357:__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value)) -: 358: __attribute__ ((__const__)); -: 359: -: 360:/* Test for negative number. */ -: 361:__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value)) -: 362: __attribute__ ((__const__)); -: 363: -: 364: -: 365:/* Multiply-add function computed as a ternary operation. */ -: 366:__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z)); -: 367:#endif /* Use ISO C99. */ -: 368: -: 369:#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 -: 370:__END_NAMESPACE_C99 -: 371:#endif -: 372: -: 373:#ifdef __USE_GNU -: 374:/* Test for signaling NaN. */ -: 375:__MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value)) -: 376: __attribute__ ((__const__)); -: 377:#endif -: 378: -: 379:#if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \ -: 380: && __MATH_DECLARING_DOUBLE \ -: 381: && !defined __USE_XOPEN2K8) -: 382:/* Return X times (2 to the Nth power). */ -: 383:__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n)); -: 384:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#webp#mux.h.gcov -: 0:Source:/usr/include/webp/mux.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_webp.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:// Copyright 2011 Google Inc. All Rights Reserved. -: 2:// -: 3:// Use of this source code is governed by a BSD-style license -: 4:// that can be found in the COPYING file in the root of the source -: 5:// tree. An additional intellectual property rights grant can be found -: 6:// in the file PATENTS. All contributing project authors may -: 7:// be found in the AUTHORS file in the root of the source tree. -: 8:// ----------------------------------------------------------------------------- -: 9:// -: 10:// RIFF container manipulation and encoding for WebP images. -: 11:// -: 12:// Authors: Urvang (urvang@google.com) -: 13:// Vikas (vikasa@google.com) -: 14: -: 15:#ifndef WEBP_WEBP_MUX_H_ -: 16:#define WEBP_WEBP_MUX_H_ -: 17: -: 18:#include "./mux_types.h" -: 19: -: 20:#ifdef __cplusplus -: 21:extern "C" { -: 22:#endif -: 23: -: 24:#define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b) -: 25: -: 26://------------------------------------------------------------------------------ -: 27:// Mux API -: 28:// -: 29:// This API allows manipulation of WebP container images containing features -: 30:// like color profile, metadata, animation. -: 31:// -: 32:// Code Example#1: Create a WebPMux object with image data, color profile and -: 33:// XMP metadata. -: 34:/* -: 35: int copy_data = 0; -: 36: WebPMux* mux = WebPMuxNew(); -: 37: // ... (Prepare image data). -: 38: WebPMuxSetImage(mux, &image, copy_data); -: 39: // ... (Prepare ICCP color profile data). -: 40: WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data); -: 41: // ... (Prepare XMP metadata). -: 42: WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data); -: 43: // Get data from mux in WebP RIFF format. -: 44: WebPMuxAssemble(mux, &output_data); -: 45: WebPMuxDelete(mux); -: 46: // ... (Consume output_data; e.g. write output_data.bytes to file). -: 47: WebPDataClear(&output_data); -: 48:*/ -: 49: -: 50:// Code Example#2: Get image and color profile data from a WebP file. -: 51:/* -: 52: int copy_data = 0; -: 53: // ... (Read data from file). -: 54: WebPMux* mux = WebPMuxCreate(&data, copy_data); -: 55: WebPMuxGetFrame(mux, 1, &image); -: 56: // ... (Consume image; e.g. call WebPDecode() to decode the data). -: 57: WebPMuxGetChunk(mux, "ICCP", &icc_profile); -: 58: // ... (Consume icc_data). -: 59: WebPMuxDelete(mux); -: 60: WebPFree(data); -: 61:*/ -: 62: -: 63:// Note: forward declaring enumerations is not allowed in (strict) C and C++, -: 64:// the types are left here for reference. -: 65:// typedef enum WebPMuxError WebPMuxError; -: 66:// typedef enum WebPChunkId WebPChunkId; -: 67:typedef struct WebPMux WebPMux; // main opaque object. -: 68:typedef struct WebPMuxFrameInfo WebPMuxFrameInfo; -: 69:typedef struct WebPMuxAnimParams WebPMuxAnimParams; -: 70:typedef struct WebPAnimEncoderOptions WebPAnimEncoderOptions; -: 71: -: 72:// Error codes -: 73:typedef enum WebPMuxError { -: 74: WEBP_MUX_OK = 1, -: 75: WEBP_MUX_NOT_FOUND = 0, -: 76: WEBP_MUX_INVALID_ARGUMENT = -1, -: 77: WEBP_MUX_BAD_DATA = -2, -: 78: WEBP_MUX_MEMORY_ERROR = -3, -: 79: WEBP_MUX_NOT_ENOUGH_DATA = -4 -: 80:} WebPMuxError; -: 81: -: 82:// IDs for different types of chunks. -: 83:typedef enum WebPChunkId { -: 84: WEBP_CHUNK_VP8X, // VP8X -: 85: WEBP_CHUNK_ICCP, // ICCP -: 86: WEBP_CHUNK_ANIM, // ANIM -: 87: WEBP_CHUNK_ANMF, // ANMF -: 88: WEBP_CHUNK_DEPRECATED, // (deprecated from FRGM) -: 89: WEBP_CHUNK_ALPHA, // ALPH -: 90: WEBP_CHUNK_IMAGE, // VP8/VP8L -: 91: WEBP_CHUNK_EXIF, // EXIF -: 92: WEBP_CHUNK_XMP, // XMP -: 93: WEBP_CHUNK_UNKNOWN, // Other chunks. -: 94: WEBP_CHUNK_NIL -: 95:} WebPChunkId; -: 96: -: 97://------------------------------------------------------------------------------ -: 98: -: 99:// Returns the version number of the mux library, packed in hexadecimal using -: 100:// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507. -: 101:WEBP_EXTERN int WebPGetMuxVersion(void); -: 102: -: 103://------------------------------------------------------------------------------ -: 104:// Life of a Mux object -: 105: -: 106:// Internal, version-checked, entry point -: 107:WEBP_EXTERN WebPMux* WebPNewInternal(int); -: 108: -: 109:// Creates an empty mux object. -: 110:// Returns: -: 111:// A pointer to the newly created empty mux object. -: 112:// Or NULL in case of memory error. -: 113:static WEBP_INLINE WebPMux* WebPMuxNew(void) { 16: 114: return WebPNewInternal(WEBP_MUX_ABI_VERSION); call 0 returned 100% -: 115:} -: 116: -: 117:// Deletes the mux object. -: 118:// Parameters: -: 119:// mux - (in/out) object to be deleted -: 120:WEBP_EXTERN void WebPMuxDelete(WebPMux* mux); -: 121: -: 122://------------------------------------------------------------------------------ -: 123:// Mux creation. -: 124: -: 125:// Internal, version-checked, entry point -: 126:WEBP_EXTERN WebPMux* WebPMuxCreateInternal(const WebPData*, int, int); -: 127: -: 128:// Creates a mux object from raw data given in WebP RIFF format. -: 129:// Parameters: -: 130:// bitstream - (in) the bitstream data in WebP RIFF format -: 131:// copy_data - (in) value 1 indicates given data WILL be copied to the mux -: 132:// object and value 0 indicates data will NOT be copied. -: 133:// Returns: -: 134:// A pointer to the mux object created from given data - on success. -: 135:// NULL - In case of invalid data or memory error. -: 136:static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream, -: 137: int copy_data) { 1: 138: return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION); call 0 never executed call 1 returned 100% -: 139:} -: 140: -: 141://------------------------------------------------------------------------------ -: 142:// Non-image chunks. -: 143: -: 144:// Note: Only non-image related chunks should be managed through chunk APIs. -: 145:// (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH"). -: 146:// To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(), -: 147:// WebPMuxGetFrame() and WebPMuxDeleteFrame(). -: 148: -: 149:// Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object. -: 150:// Any existing chunk(s) with the same id will be removed. -: 151:// Parameters: -: 152:// mux - (in/out) object to which the chunk is to be added -: 153:// fourcc - (in) a character array containing the fourcc of the given chunk; -: 154:// e.g., "ICCP", "XMP ", "EXIF" etc. -: 155:// chunk_data - (in) the chunk data to be added -: 156:// copy_data - (in) value 1 indicates given data WILL be copied to the mux -: 157:// object and value 0 indicates data will NOT be copied. -: 158:// Returns: -: 159:// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL -: 160:// or if fourcc corresponds to an image chunk. -: 161:// WEBP_MUX_MEMORY_ERROR - on memory allocation error. -: 162:// WEBP_MUX_OK - on success. -: 163:WEBP_EXTERN WebPMuxError WebPMuxSetChunk( -: 164: WebPMux* mux, const char fourcc[4], const WebPData* chunk_data, -: 165: int copy_data); -: 166: -: 167:// Gets a reference to the data of the chunk with id 'fourcc' in the mux object. -: 168:// The caller should NOT free the returned data. -: 169:// Parameters: -: 170:// mux - (in) object from which the chunk data is to be fetched -: 171:// fourcc - (in) a character array containing the fourcc of the chunk; -: 172:// e.g., "ICCP", "XMP ", "EXIF" etc. -: 173:// chunk_data - (out) returned chunk data -: 174:// Returns: -: 175:// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL -: 176:// or if fourcc corresponds to an image chunk. -: 177:// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given id. -: 178:// WEBP_MUX_OK - on success. -: 179:WEBP_EXTERN WebPMuxError WebPMuxGetChunk( -: 180: const WebPMux* mux, const char fourcc[4], WebPData* chunk_data); -: 181: -: 182:// Deletes the chunk with the given 'fourcc' from the mux object. -: 183:// Parameters: -: 184:// mux - (in/out) object from which the chunk is to be deleted -: 185:// fourcc - (in) a character array containing the fourcc of the chunk; -: 186:// e.g., "ICCP", "XMP ", "EXIF" etc. -: 187:// Returns: -: 188:// WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL -: 189:// or if fourcc corresponds to an image chunk. -: 190:// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc. -: 191:// WEBP_MUX_OK - on success. -: 192:WEBP_EXTERN WebPMuxError WebPMuxDeleteChunk( -: 193: WebPMux* mux, const char fourcc[4]); -: 194: -: 195://------------------------------------------------------------------------------ -: 196:// Images. -: 197: -: 198:// Encapsulates data about a single frame. -: 199:struct WebPMuxFrameInfo { -: 200: WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream -: 201: // or a single-image WebP file. -: 202: int x_offset; // x-offset of the frame. -: 203: int y_offset; // y-offset of the frame. -: 204: int duration; // duration of the frame (in milliseconds). -: 205: -: 206: WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF -: 207: // or WEBP_CHUNK_IMAGE -: 208: WebPMuxAnimDispose dispose_method; // Disposal method for the frame. -: 209: WebPMuxAnimBlend blend_method; // Blend operation for the frame. -: 210: uint32_t pad[1]; // padding for later use -: 211:}; -: 212: -: 213:// Sets the (non-animated) image in the mux object. -: 214:// Note: Any existing images (including frames) will be removed. -: 215:// Parameters: -: 216:// mux - (in/out) object in which the image is to be set -: 217:// bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image -: 218:// WebP file (non-animated) -: 219:// copy_data - (in) value 1 indicates given data WILL be copied to the mux -: 220:// object and value 0 indicates data will NOT be copied. -: 221:// Returns: -: 222:// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL. -: 223:// WEBP_MUX_MEMORY_ERROR - on memory allocation error. -: 224:// WEBP_MUX_OK - on success. -: 225:WEBP_EXTERN WebPMuxError WebPMuxSetImage( -: 226: WebPMux* mux, const WebPData* bitstream, int copy_data); -: 227: -: 228:// Adds a frame at the end of the mux object. -: 229:// Notes: (1) frame.id should be WEBP_CHUNK_ANMF -: 230:// (2) For setting a non-animated image, use WebPMuxSetImage() instead. -: 231:// (3) Type of frame being pushed must be same as the frames in mux. -: 232:// (4) As WebP only supports even offsets, any odd offset will be snapped -: 233:// to an even location using: offset &= ~1 -: 234:// Parameters: -: 235:// mux - (in/out) object to which the frame is to be added -: 236:// frame - (in) frame data. -: 237:// copy_data - (in) value 1 indicates given data WILL be copied to the mux -: 238:// object and value 0 indicates data will NOT be copied. -: 239:// Returns: -: 240:// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL -: 241:// or if content of 'frame' is invalid. -: 242:// WEBP_MUX_MEMORY_ERROR - on memory allocation error. -: 243:// WEBP_MUX_OK - on success. -: 244:WEBP_EXTERN WebPMuxError WebPMuxPushFrame( -: 245: WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data); -: 246: -: 247:// Gets the nth frame from the mux object. -: 248:// The content of 'frame->bitstream' is allocated using WebPMalloc(), and NOT -: 249:// owned by the 'mux' object. It MUST be deallocated by the caller by calling -: 250:// WebPDataClear(). -: 251:// nth=0 has a special meaning - last position. -: 252:// Parameters: -: 253:// mux - (in) object from which the info is to be fetched -: 254:// nth - (in) index of the frame in the mux object -: 255:// frame - (out) data of the returned frame -: 256:// Returns: -: 257:// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL. -: 258:// WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object. -: 259:// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid. -: 260:// WEBP_MUX_MEMORY_ERROR - on memory allocation error. -: 261:// WEBP_MUX_OK - on success. -: 262:WEBP_EXTERN WebPMuxError WebPMuxGetFrame( -: 263: const WebPMux* mux, uint32_t nth, WebPMuxFrameInfo* frame); -: 264: -: 265:// Deletes a frame from the mux object. -: 266:// nth=0 has a special meaning - last position. -: 267:// Parameters: -: 268:// mux - (in/out) object from which a frame is to be deleted -: 269:// nth - (in) The position from which the frame is to be deleted -: 270:// Returns: -: 271:// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL. -: 272:// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object -: 273:// before deletion. -: 274:// WEBP_MUX_OK - on success. -: 275:WEBP_EXTERN WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth); -: 276: -: 277://------------------------------------------------------------------------------ -: 278:// Animation. -: 279: -: 280:// Animation parameters. -: 281:struct WebPMuxAnimParams { -: 282: uint32_t bgcolor; // Background color of the canvas stored (in MSB order) as: -: 283: // Bits 00 to 07: Alpha. -: 284: // Bits 08 to 15: Red. -: 285: // Bits 16 to 23: Green. -: 286: // Bits 24 to 31: Blue. -: 287: int loop_count; // Number of times to repeat the animation [0 = infinite]. -: 288:}; -: 289: -: 290:// Sets the animation parameters in the mux object. Any existing ANIM chunks -: 291:// will be removed. -: 292:// Parameters: -: 293:// mux - (in/out) object in which ANIM chunk is to be set/added -: 294:// params - (in) animation parameters. -: 295:// Returns: -: 296:// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL. -: 297:// WEBP_MUX_MEMORY_ERROR - on memory allocation error. -: 298:// WEBP_MUX_OK - on success. -: 299:WEBP_EXTERN WebPMuxError WebPMuxSetAnimationParams( -: 300: WebPMux* mux, const WebPMuxAnimParams* params); -: 301: -: 302:// Gets the animation parameters from the mux object. -: 303:// Parameters: -: 304:// mux - (in) object from which the animation parameters to be fetched -: 305:// params - (out) animation parameters extracted from the ANIM chunk -: 306:// Returns: -: 307:// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL. -: 308:// WEBP_MUX_NOT_FOUND - if ANIM chunk is not present in mux object. -: 309:// WEBP_MUX_OK - on success. -: 310:WEBP_EXTERN WebPMuxError WebPMuxGetAnimationParams( -: 311: const WebPMux* mux, WebPMuxAnimParams* params); -: 312: -: 313://------------------------------------------------------------------------------ -: 314:// Misc Utilities. -: 315: -: 316:// Sets the canvas size for the mux object. The width and height can be -: 317:// specified explicitly or left as zero (0, 0). -: 318:// * When width and height are specified explicitly, then this frame bound is -: 319:// enforced during subsequent calls to WebPMuxAssemble() and an error is -: 320:// reported if any animated frame does not completely fit within the canvas. -: 321:// * When unspecified (0, 0), the constructed canvas will get the frame bounds -: 322:// from the bounding-box over all frames after calling WebPMuxAssemble(). -: 323:// Parameters: -: 324:// mux - (in) object to which the canvas size is to be set -: 325:// width - (in) canvas width -: 326:// height - (in) canvas height -: 327:// Returns: -: 328:// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL; or -: 329:// width or height are invalid or out of bounds -: 330:// WEBP_MUX_OK - on success. -: 331:WEBP_EXTERN WebPMuxError WebPMuxSetCanvasSize(WebPMux* mux, -: 332: int width, int height); -: 333: -: 334:// Gets the canvas size from the mux object. -: 335:// Note: This method assumes that the VP8X chunk, if present, is up-to-date. -: 336:// That is, the mux object hasn't been modified since the last call to -: 337:// WebPMuxAssemble() or WebPMuxCreate(). -: 338:// Parameters: -: 339:// mux - (in) object from which the canvas size is to be fetched -: 340:// width - (out) canvas width -: 341:// height - (out) canvas height -: 342:// Returns: -: 343:// WEBP_MUX_INVALID_ARGUMENT - if mux, width or height is NULL. -: 344:// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid. -: 345:// WEBP_MUX_OK - on success. -: 346:WEBP_EXTERN WebPMuxError WebPMuxGetCanvasSize(const WebPMux* mux, -: 347: int* width, int* height); -: 348: -: 349:// Gets the feature flags from the mux object. -: 350:// Note: This method assumes that the VP8X chunk, if present, is up-to-date. -: 351:// That is, the mux object hasn't been modified since the last call to -: 352:// WebPMuxAssemble() or WebPMuxCreate(). -: 353:// Parameters: -: 354:// mux - (in) object from which the features are to be fetched -: 355:// flags - (out) the flags specifying which features are present in the -: 356:// mux object. This will be an OR of various flag values. -: 357:// Enum 'WebPFeatureFlags' can be used to test individual flag values. -: 358:// Returns: -: 359:// WEBP_MUX_INVALID_ARGUMENT - if mux or flags is NULL. -: 360:// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid. -: 361:// WEBP_MUX_OK - on success. -: 362:WEBP_EXTERN WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, -: 363: uint32_t* flags); -: 364: -: 365:// Gets number of chunks with the given 'id' in the mux object. -: 366:// Parameters: -: 367:// mux - (in) object from which the info is to be fetched -: 368:// id - (in) chunk id specifying the type of chunk -: 369:// num_elements - (out) number of chunks with the given chunk id -: 370:// Returns: -: 371:// WEBP_MUX_INVALID_ARGUMENT - if mux, or num_elements is NULL. -: 372:// WEBP_MUX_OK - on success. -: 373:WEBP_EXTERN WebPMuxError WebPMuxNumChunks(const WebPMux* mux, -: 374: WebPChunkId id, int* num_elements); -: 375: -: 376:// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'. -: 377:// This function also validates the mux object. -: 378:// Note: The content of 'assembled_data' will be ignored and overwritten. -: 379:// Also, the content of 'assembled_data' is allocated using WebPMalloc(), and -: 380:// NOT owned by the 'mux' object. It MUST be deallocated by the caller by -: 381:// calling WebPDataClear(). It's always safe to call WebPDataClear() upon -: 382:// return, even in case of error. -: 383:// Parameters: -: 384:// mux - (in/out) object whose chunks are to be assembled -: 385:// assembled_data - (out) assembled WebP data -: 386:// Returns: -: 387:// WEBP_MUX_BAD_DATA - if mux object is invalid. -: 388:// WEBP_MUX_INVALID_ARGUMENT - if mux or assembled_data is NULL. -: 389:// WEBP_MUX_MEMORY_ERROR - on memory allocation error. -: 390:// WEBP_MUX_OK - on success. -: 391:WEBP_EXTERN WebPMuxError WebPMuxAssemble(WebPMux* mux, -: 392: WebPData* assembled_data); -: 393: -: 394://------------------------------------------------------------------------------ -: 395:// WebPAnimEncoder API -: 396:// -: 397:// This API allows encoding (possibly) animated WebP images. -: 398:// -: 399:// Code Example: -: 400:/* -: 401: WebPAnimEncoderOptions enc_options; -: 402: WebPAnimEncoderOptionsInit(&enc_options); -: 403: // Tune 'enc_options' as needed. -: 404: WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options); -: 405: while() { -: 406: WebPConfig config; -: 407: WebPConfigInit(&config); -: 408: // Tune 'config' as needed. -: 409: WebPAnimEncoderAdd(enc, frame, timestamp_ms, &config); -: 410: } -: 411: WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL); -: 412: WebPAnimEncoderAssemble(enc, webp_data); -: 413: WebPAnimEncoderDelete(enc); -: 414: // Write the 'webp_data' to a file, or re-mux it further. -: 415:*/ -: 416: -: 417:typedef struct WebPAnimEncoder WebPAnimEncoder; // Main opaque object. -: 418: -: 419:// Forward declarations. Defined in encode.h. -: 420:struct WebPPicture; -: 421:struct WebPConfig; -: 422: -: 423:// Global options. -: 424:struct WebPAnimEncoderOptions { -: 425: WebPMuxAnimParams anim_params; // Animation parameters. -: 426: int minimize_size; // If true, minimize the output size (slow). Implicitly -: 427: // disables key-frame insertion. -: 428: int kmin; -: 429: int kmax; // Minimum and maximum distance between consecutive key -: 430: // frames in the output. The library may insert some key -: 431: // frames as needed to satisfy this criteria. -: 432: // Note that these conditions should hold: kmax > kmin -: 433: // and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then -: 434: // key-frame insertion is disabled; and if kmax == 1, -: 435: // then all frames will be key-frames (kmin value does -: 436: // not matter for these special cases). -: 437: int allow_mixed; // If true, use mixed compression mode; may choose -: 438: // either lossy and lossless for each frame. -: 439: int verbose; // If true, print info and warning messages to stderr. -: 440: -: 441: uint32_t padding[4]; // Padding for later use. -: 442:}; -: 443: -: 444:// Internal, version-checked, entry point. -: 445:WEBP_EXTERN int WebPAnimEncoderOptionsInitInternal( -: 446: WebPAnimEncoderOptions*, int); -: 447: -: 448:// Should always be called, to initialize a fresh WebPAnimEncoderOptions -: 449:// structure before modification. Returns false in case of version mismatch. -: 450:// WebPAnimEncoderOptionsInit() must have succeeded before using the -: 451:// 'enc_options' object. -: 452:static WEBP_INLINE int WebPAnimEncoderOptionsInit( -: 453: WebPAnimEncoderOptions* enc_options) { 6: 454: return WebPAnimEncoderOptionsInitInternal(enc_options, WEBP_MUX_ABI_VERSION); call 0 returned 100% -: 455:} -: 456: -: 457:// Internal, version-checked, entry point. -: 458:WEBP_EXTERN WebPAnimEncoder* WebPAnimEncoderNewInternal( -: 459: int, int, const WebPAnimEncoderOptions*, int); -: 460: -: 461:// Creates and initializes a WebPAnimEncoder object. -: 462:// Parameters: -: 463:// width/height - (in) canvas width and height of the animation. -: 464:// enc_options - (in) encoding options; can be passed NULL to pick -: 465:// reasonable defaults. -: 466:// Returns: -: 467:// A pointer to the newly created WebPAnimEncoder object. -: 468:// Or NULL in case of memory error. -: 469:static WEBP_INLINE WebPAnimEncoder* WebPAnimEncoderNew( -: 470: int width, int height, const WebPAnimEncoderOptions* enc_options) { 6: 471: return WebPAnimEncoderNewInternal(width, height, enc_options, call 0 returned 100% -: 472: WEBP_MUX_ABI_VERSION); -: 473:} -: 474: -: 475:// Optimize the given frame for WebP, encode it and add it to the -: 476:// WebPAnimEncoder object. -: 477:// The last call to 'WebPAnimEncoderAdd' should be with frame = NULL, which -: 478:// indicates that no more frames are to be added. This call is also used to -: 479:// determine the duration of the last frame. -: 480:// Parameters: -: 481:// enc - (in/out) object to which the frame is to be added. -: 482:// frame - (in/out) frame data in ARGB or YUV(A) format. If it is in YUV(A) -: 483:// format, it will be converted to ARGB, which incurs a small loss. -: 484:// timestamp_ms - (in) timestamp of this frame in milliseconds. -: 485:// Duration of a frame would be calculated as -: 486:// "timestamp of next frame - timestamp of this frame". -: 487:// Hence, timestamps should be in non-decreasing order. -: 488:// config - (in) encoding options; can be passed NULL to pick -: 489:// reasonable defaults. -: 490:// Returns: -: 491:// On error, returns false and frame->error_code is set appropriately. -: 492:// Otherwise, returns true. -: 493:WEBP_EXTERN int WebPAnimEncoderAdd( -: 494: WebPAnimEncoder* enc, struct WebPPicture* frame, int timestamp_ms, -: 495: const struct WebPConfig* config); -: 496: -: 497:// Assemble all frames added so far into a WebP bitstream. -: 498:// This call should be preceded by a call to 'WebPAnimEncoderAdd' with -: 499:// frame = NULL; if not, the duration of the last frame will be internally -: 500:// estimated. -: 501:// Parameters: -: 502:// enc - (in/out) object from which the frames are to be assembled. -: 503:// webp_data - (out) generated WebP bitstream. -: 504:// Returns: -: 505:// True on success. -: 506:WEBP_EXTERN int WebPAnimEncoderAssemble(WebPAnimEncoder* enc, -: 507: WebPData* webp_data); -: 508: -: 509:// Get error string corresponding to the most recent call using 'enc'. The -: 510:// returned string is owned by 'enc' and is valid only until the next call to -: 511:// WebPAnimEncoderAdd() or WebPAnimEncoderAssemble() or WebPAnimEncoderDelete(). -: 512:// Parameters: -: 513:// enc - (in/out) object from which the error string is to be fetched. -: 514:// Returns: -: 515:// NULL if 'enc' is NULL. Otherwise, returns the error string if the last call -: 516:// to 'enc' had an error, or an empty string if the last call was a success. -: 517:WEBP_EXTERN const char* WebPAnimEncoderGetError(WebPAnimEncoder* enc); -: 518: -: 519:// Deletes the WebPAnimEncoder object. -: 520:// Parameters: -: 521:// enc - (in/out) object to be deleted -: 522:WEBP_EXTERN void WebPAnimEncoderDelete(WebPAnimEncoder* enc); -: 523: -: 524://------------------------------------------------------------------------------ -: 525: -: 526:#ifdef __cplusplus -: 527:} // extern "C" -: 528:#endif -: 529: -: 530:#endif // WEBP_WEBP_MUX_H_ <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#RankFilter.c.gcov -: 0:Source:src/libImaging/RankFilter.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/RankFilter.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/libImaging/RankFilter.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * min, max, median filters -: 6: * -: 7: * history: -: 8: * 2002-06-08 fl Created -: 9: * -: 10: * Copyright (c) Secret Labs AB 2002. All rights reserved. -: 11: * -: 12: * See the README file for information on usage and redistribution. -: 13: */ -: 14: -: 15:#include "Imaging.h" -: 16: -: 17:/* Fast rank algorithm (due to Wirth), based on public domain code -: 18: by Nicolas Devillard, available at http://ndevilla.free.fr */ -: 19: -: 20:#define SWAP(type,a,b) { register type t=(a);(a)=(b);(b)=t; } -: 21: -: 22:#define MakeRankFunction(type)\ -: 23:static type Rank##type(type a[], int n, int k)\ -: 24:{\ -: 25: register int i, j, l, m;\ -: 26: register type x;\ -: 27: l = 0; m = n-1;\ -: 28: while (l < m) {\ -: 29: x = a[k];\ -: 30: i = l;\ -: 31: j = m;\ -: 32: do {\ -: 33: while (a[i] < x) {\ -: 34: i++;\ -: 35: }\ -: 36: while (x < a[j]) {\ -: 37: j--;\ -: 38: }\ -: 39: if (i <= j) {\ -: 40: SWAP(type, a[i], a[j]);\ -: 41: i++; j--;\ -: 42: }\ -: 43: } while (i <= j);\ -: 44: if (j < k) {\ -: 45: l = i;\ -: 46: }\ -: 47: if (k < i) {\ -: 48: m = j;\ -: 49: }\ -: 50: }\ -: 51: return a[k];\ -: 52:} -: 53: function RankUINT8 called 393351 returned 100% blocks executed 100% 393351: 54:MakeRankFunction(UINT8) branch 0 taken 38% branch 1 taken 62% (fallthrough) branch 2 taken 38% branch 3 taken 62% (fallthrough) branch 4 taken 83% (fallthrough) branch 5 taken 17% branch 6 taken 55% branch 7 taken 45% (fallthrough) branch 8 taken 59% (fallthrough) branch 9 taken 41% branch 10 taken 59% (fallthrough) branch 11 taken 41% branch 12 taken 71% branch 13 taken 29% (fallthrough) function RankINT32 called 27 returned 100% blocks executed 100% 27: 55:MakeRankFunction(INT32) branch 0 taken 65% branch 1 taken 35% (fallthrough) branch 2 taken 65% branch 3 taken 35% (fallthrough) branch 4 taken 84% (fallthrough) branch 5 taken 16% branch 6 taken 33% branch 7 taken 67% (fallthrough) branch 8 taken 63% (fallthrough) branch 9 taken 37% branch 10 taken 63% (fallthrough) branch 11 taken 37% branch 12 taken 60% branch 13 taken 40% (fallthrough) function RankFLOAT32 called 27 returned 100% blocks executed 100% 27: 56:MakeRankFunction(FLOAT32) branch 0 taken 65% branch 1 taken 35% (fallthrough) branch 2 taken 65% branch 3 taken 35% (fallthrough) branch 4 taken 84% (fallthrough) branch 5 taken 16% branch 6 taken 33% branch 7 taken 67% (fallthrough) branch 8 taken 63% (fallthrough) branch 9 taken 37% branch 10 taken 63% (fallthrough) branch 11 taken 37% branch 12 taken 60% branch 13 taken 40% (fallthrough) -: 57: -: 58:Imaging function ImagingRankFilter called 45 returned 100% blocks executed 87% 45: 59:ImagingRankFilter(Imaging im, int size, int rank) -: 60:{ 45: 61: Imaging imOut = NULL; -: 62: int x, y; -: 63: int i, margin, size2; -: 64: 45: 65: if (!im || im->bands != 1 || im->type == IMAGING_TYPE_SPECIAL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 0% (fallthrough) branch 5 taken 100% #####: 66: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 67: } -: 68: 45: 69: if (!(size & 1)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 70: return (Imaging) ImagingError_ValueError("bad filter size"); call 0 never executed -: 71: } -: 72: -: 73: /* malloc check ok, for overflow in the define below */ 90: 74: if (size > INT_MAX / size || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% 45: 75: size > INT_MAX / (size * sizeof(FLOAT32))) { #####: 76: return (Imaging) ImagingError_ValueError("filter size too large"); call 0 never executed -: 77: } -: 78: 45: 79: size2 = size * size; 45: 80: margin = (size-1) / 2; -: 81: 45: 82: if (rank < 0 || rank >= size2) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 83: return (Imaging) ImagingError_ValueError("bad rank value"); call 0 never executed -: 84: } -: 85: 45: 86: imOut = ImagingNew(im->mode, im->xsize - 2*margin, im->ysize - 2*margin); call 0 returned 100% 45: 87: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 88: return NULL; -: 89: } -: 90: -: 91: /* malloc check ok, checked above */ -: 92:#define RANK_BODY(type) do {\ -: 93: type* buf = malloc(size2 * sizeof(type));\ -: 94: if (!buf) {\ -: 95: goto nomemory;\ -: 96: }\ -: 97: for (y = 0; y < imOut->ysize; y++) {\ -: 98: for (x = 0; x < imOut->xsize; x++) {\ -: 99: for (i = 0; i < size; i++) {\ -: 100: memcpy(buf + i*size, &IMAGING_PIXEL_##type(im, x, y+i),\ -: 101: size * sizeof(type));\ -: 102: }\ -: 103: IMAGING_PIXEL_##type(imOut, x, y) = Rank##type(buf, size2, rank);\ -: 104: }\ -: 105: }\ -: 106: free(buf); \ -: 107:} while (0) -: 108: 45: 109: if (im->image8) { branch 0 taken 87% (fallthrough) branch 1 taken 13% 1180092: 110: RANK_BODY(UINT8); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 75% branch 3 taken 25% (fallthrough) call 4 returned 100% branch 5 taken 99% (fallthrough) branch 6 taken 1% branch 7 taken 99% (fallthrough) branch 8 taken 1% 6: 111: } else if (im->type == IMAGING_TYPE_INT32) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 84: 112: RANK_BODY(INT32); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 75% branch 3 taken 25% (fallthrough) call 4 returned 100% branch 5 taken 75% (fallthrough) branch 6 taken 25% branch 7 taken 75% (fallthrough) branch 8 taken 25% 3: 113: } else if (im->type == IMAGING_TYPE_FLOAT32) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 84: 114: RANK_BODY(FLOAT32); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 75% branch 3 taken 25% (fallthrough) call 4 returned 100% branch 5 taken 75% (fallthrough) branch 6 taken 25% branch 7 taken 75% (fallthrough) branch 8 taken 25% -: 115: } else { -: 116: /* safety net (we shouldn't end up here) */ #####: 117: ImagingDelete(imOut); call 0 never executed #####: 118: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 119: } -: 120: 45: 121: ImagingCopyPalette(imOut, im); call 0 returned 100% -: 122: 45: 123: return imOut; -: 124: -: 125:nomemory: #####: 126: ImagingDelete(imOut); call 0 never executed #####: 127: return (Imaging) ImagingError_MemoryError(); call 0 never executed -: 128:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#_imagingcms.c.gcov -: 0:Source:src/_imagingcms.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_imagingcms.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-s390x-3.8/src/_imagingcms.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * pyCMS -: 3: * a Python / PIL interface to the littleCMS ICC Color Management System -: 4: * Copyright (C) 2002-2003 Kevin Cazabon -: 5: * kevin@cazabon.com -: 6: * http://www.cazabon.com -: 7: * Adapted/reworked for PIL by Fredrik Lundh -: 8: * Copyright (c) 2009 Fredrik Lundh -: 9: * Updated to LCMS2 -: 10: * Copyright (c) 2013 Eric Soroos -: 11: * -: 12: * pyCMS home page: http://www.cazabon.com/pyCMS -: 13: * littleCMS home page: http://www.littlecms.com -: 14: * (littleCMS is Copyright (C) 1998-2001 Marti Maria) -: 15: * -: 16: * Originally released under LGPL. Graciously donated to PIL in -: 17: * March 2009, for distribution under the standard PIL license -: 18: */ -: 19: -: 20:#define COPYRIGHTINFO "\ -: 21:pyCMS\n\ -: 22:a Python / PIL interface to the littleCMS ICC Color Management System\n\ -: 23:Copyright (C) 2002-2003 Kevin Cazabon\n\ -: 24:kevin@cazabon.com\n\ -: 25:http://www.cazabon.com\n\ -: 26:" -: 27: -: 28:#define PY_SSIZE_T_CLEAN -: 29:#include "Python.h" // Include before wchar.h so _GNU_SOURCE is set -: 30:#include "wchar.h" -: 31:#include "datetime.h" -: 32: -: 33:#include "lcms2.h" -: 34:#include "libImaging/Imaging.h" -: 35: -: 36:#define PYCMSVERSION "1.0.0 pil" -: 37: -: 38:/* version history */ -: 39: -: 40:/* -: 41: 1.0.0 pil Integrating littleCMS2 -: 42: 0.1.0 pil integration & refactoring -: 43: 0.0.2 alpha: Minor updates, added interfaces to littleCMS features, Jan 6, 2003 -: 44: - fixed some memory holes in how transforms/profiles were created and passed back to Python -: 45: due to improper destructor setup for PyCObjects -: 46: - added buildProofTransformFromOpenProfiles() function -: 47: - eliminated some code redundancy, centralizing several common tasks with internal functions -: 48: -: 49: 0.0.1 alpha: First public release Dec 26, 2002 -: 50: -: 51:*/ -: 52: -: 53:/* known to-do list with current version: -: 54: -: 55: Verify that PILmode->littleCMStype conversion in findLCMStype is correct for all -: 56: PIL modes (it probably isn't for the more obscure ones) -: 57: -: 58: Add support for creating custom RGB profiles on the fly -: 59: Add support for checking presence of a specific tag in a profile -: 60: Add support for other littleCMS features as required -: 61: -: 62:*/ -: 63: -: 64:/* -: 65: INTENT_PERCEPTUAL 0 -: 66: INTENT_RELATIVE_COLORIMETRIC 1 -: 67: INTENT_SATURATION 2 -: 68: INTENT_ABSOLUTE_COLORIMETRIC 3 -: 69:*/