TRAVIS_PYTHON_VERSION=3.6 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#Paste.c.gcov -: 0:Source:src/libImaging/Paste.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Paste.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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 0% (fallthrough) branch 1 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% -: 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 86% 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 0% (fallthrough) branch 1 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% -: 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#SgiRleDecode.c.gcov -: 0:Source:src/libImaging/SgiRleDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/SgiRleDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/SgiRleDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for Sgi RLE data. -: 6: * -: 7: * history: -: 8: * 2017-07-28 mb fixed for images larger than 64KB -: 9: * 2017-07-20 mb created -: 10: * -: 11: * Copyright (c) Mickael Bonfill 2017. -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16:#include "Imaging.h" -: 17:#include "Sgi.h" -: 18: -: 19:#define SGI_HEADER_SIZE 512 -: 20:#define RLE_COPY_FLAG 0x80 -: 21:#define RLE_MAX_RUN 0x7f -: 22: -: 23:static void read4B(UINT32* dest, UINT8* buf) -: 24:{ 7310: 25: *dest = (UINT32)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); -: 26:} -: 27: function expandrow called 390 returned 100% blocks executed 100% 390: 28:static int expandrow(UINT8* dest, UINT8* src, int n, int z, int xsize) -: 29:{ -: 30: UINT8 pixel, count; 390: 31: int x = 0; -: 32: 4029: 33: for (;n > 0; n--) branch 0 taken 100% branch 1 taken 0% (fallthrough) -: 34: { 4029: 35: pixel = *src++; 4029: 36: if (n == 1 && pixel != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 37: return n; -: 38: } 4029: 39: count = pixel & RLE_MAX_RUN; 4029: 40: if (!count) { branch 0 taken 10% (fallthrough) branch 1 taken 90% 389: 41: return count; -: 42: } 3640: 43: if (x + count > xsize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 44: return -1; -: 45: } 3639: 46: x += count; 3639: 47: if (pixel & RLE_COPY_FLAG) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 44413: 48: while(count--) { branch 0 taken 97% branch 1 taken 3% 42875: 49: *dest = *src++; 42875: 50: dest += z; -: 51: } -: 52: -: 53: } -: 54: else { 2101: 55: pixel = *src++; 10993: 56: while (count--) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 6791: 57: *dest = pixel; 6791: 58: dest += z; -: 59: } -: 60: } -: 61: -: 62: } -: 63: return 0; -: 64:} -: 65: function expandrow2 called 2289 returned 100% blocks executed 100% 2289: 66:static int expandrow2(UINT8* dest, const UINT8* src, int n, int z, int xsize) -: 67:{ -: 68: UINT8 pixel, count; -: 69: 2289: 70: int x = 0; -: 71: 27832: 72: for (;n > 0; n--) branch 0 taken 100% branch 1 taken 0% (fallthrough) -: 73: { 27832: 74: pixel = src[1]; 27832: 75: src+=2; 27832: 76: if (n == 1 && pixel != 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 77: return n; -: 78: } 27832: 79: count = pixel & RLE_MAX_RUN; 27832: 80: if (!count) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 2286: 81: return count; -: 82: } 25546: 83: if (x + count > xsize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 84: return -1; -: 85: } 25543: 86: x += count; 25543: 87: if (pixel & RLE_COPY_FLAG) { branch 0 taken 57% (fallthrough) branch 1 taken 43% 790014: 88: while(count--) { branch 0 taken 99% branch 1 taken 1% 778949: 89: memcpy(dest, src, 2); 778949: 90: src += 2; 778949: 91: dest += z * 2; -: 92: } -: 93: } -: 94: else { 699326: 95: while (count--) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 684848: 96: memcpy(dest, src, 2); 684848: 97: dest += z * 2; -: 98: } 14478: 99: src+=2; -: 100: } -: 101: } -: 102: return 0; -: 103:} -: 104: -: 105: -: 106:int function ImagingSgiRleDecode called 7 returned 100% blocks executed 97% 7: 107:ImagingSgiRleDecode(Imaging im, ImagingCodecState state, -: 108: UINT8* buf, Py_ssize_t bytes) -: 109:{ -: 110: UINT8 *ptr; -: 111: SGISTATE *c; 7: 112: int err = 0; -: 113: int status; -: 114: -: 115: /* Get all data from File descriptor */ 7: 116: c = (SGISTATE*)state->context; 7: 117: _imaging_seek_pyFd(state->fd, 0L, SEEK_END); call 0 returned 100% 7: 118: c->bufsize = _imaging_tell_pyFd(state->fd); call 0 returned 100% 7: 119: c->bufsize -= SGI_HEADER_SIZE; 7: 120: ptr = malloc(sizeof(UINT8) * c->bufsize); 7: 121: if (!ptr) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 122: return IMAGING_CODEC_MEMORY; -: 123: } 7: 124: _imaging_seek_pyFd(state->fd, SGI_HEADER_SIZE, SEEK_SET); call 0 returned 100% 7: 125: _imaging_read_pyFd(state->fd, (char*)ptr, c->bufsize); call 0 returned 100% -: 126: -: 127: -: 128: /* decoder initialization */ 7: 129: state->count = 0; 7: 130: state->y = 0; 7: 131: if (state->ystep < 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 7: 132: state->y = im->ysize - 1; -: 133: } else { #####: 134: state->ystep = 1; -: 135: } -: 136: 14: 137: if (im->xsize > INT_MAX / im->bands || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 7: 138: im->ysize > INT_MAX / im->bands) { -: 139: err = IMAGING_CODEC_MEMORY; -: 140: goto sgi_finish_decode; -: 141: } -: 142: -: 143: /* Allocate memory for RLE tables and rows */ 7: 144: free(state->buffer); 7: 145: state->buffer = NULL; -: 146: /* malloc overflow check above */ 7: 147: state->buffer = calloc(im->xsize * im->bands, sizeof(UINT8) * 2); 7: 148: c->tablen = im->bands * im->ysize; 7: 149: c->starttab = calloc(c->tablen, sizeof(UINT32)); 7: 150: c->lengthtab = calloc(c->tablen, sizeof(UINT32)); 7: 151: if (!state->buffer || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 7: 152: !c->starttab || branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 153: !c->lengthtab) { -: 154: err = IMAGING_CODEC_MEMORY; -: 155: goto sgi_finish_decode; -: 156: } -: 157: /* populate offsets table */ 3662: 158: for (c->tabindex = 0, c->bufindex = 0; c->tabindex < c->tablen; c->tabindex++, c->bufindex+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 7310: 159: read4B(&c->starttab[c->tabindex], &ptr[c->bufindex]); -: 160: } -: 161: /* populate lengths table */ 3662: 162: for (c->tabindex = 0, c->bufindex = c->tablen * sizeof(UINT32); c->tabindex < c->tablen; c->tabindex++, c->bufindex+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 7310: 163: read4B(&c->lengthtab[c->tabindex], &ptr[c->bufindex]); -: 164: } -: 165: 7: 166: state->count += c->tablen * sizeof(UINT32) * 2; -: 167: -: 168: /* read compressed rows */ 898: 169: for (c->rowno = 0; c->rowno < im->ysize; c->rowno++, state->y += state->ystep) branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 170: { 3571: 171: for (c->channo = 0; c->channo < im->bands; c->channo++) branch 0 taken 75% branch 1 taken 25% (fallthrough) -: 172: { 2680: 173: c->rleoffset = c->starttab[c->rowno + c->channo * im->ysize]; 2680: 174: c->rlelength = c->lengthtab[c->rowno + c->channo * im->ysize]; 2680: 175: c->rleoffset -= SGI_HEADER_SIZE; -: 176: 2680: 177: if (c->rleoffset + c->rlelength > c->bufsize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 178: state->errcode = IMAGING_CODEC_OVERRUN; 1: 179: return -1; -: 180: } -: 181: -: 182: /* row decompression */ 2679: 183: if (c->bpc ==1) { branch 0 taken 15% (fallthrough) branch 1 taken 85% 390: 184: status = expandrow(&state->buffer[c->channo], &ptr[c->rleoffset], c->rlelength, im->bands, im->xsize); call 0 returned 100% -: 185: } -: 186: else { 2289: 187: status = expandrow2(&state->buffer[c->channo * 2], &ptr[c->rleoffset], c->rlelength, im->bands, im->xsize); call 0 returned 100% -: 188: } 2679: 189: if (status == -1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 4: 190: state->errcode = IMAGING_CODEC_OVERRUN; 4: 191: return -1; 2675: 192: } else if (status == 1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 193: goto sgi_finish_decode; -: 194: } -: 195: 2675: 196: state->count += c->rlelength; -: 197: } -: 198: -: 199: /* store decompressed data in image */ 891: 200: state->shuffle((UINT8*)im->image[state->y], state->buffer, im->xsize); call 0 returned 100% -: 201: -: 202: } -: 203: 2: 204: c->bufsize++; -: 205: -: 206:sgi_finish_decode: ; -: 207: 2: 208: free(c->starttab); 2: 209: free(c->lengthtab); 2: 210: free(ptr); 2: 211: if (err != 0){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 212: return err; -: 213: } 2: 214: return state->count - c->bufsize; -: 215:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Access.c.gcov -: 0:Source:src/libImaging/Access.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Access.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Access.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * imaging access objects -: 6: * -: 7: * Copyright (c) Fredrik Lundh 2009. -: 8: * -: 9: * See the README file for information on usage and redistribution. -: 10: */ -: 11: -: 12: -: 13:#include "Imaging.h" -: 14: -: 15:/* use Tests/make_hash.py to calculate these values */ -: 16:#define ACCESS_TABLE_SIZE 27 -: 17:#define ACCESS_TABLE_HASH 3078 -: 18: -: 19:static struct ImagingAccessInstance access_table[ACCESS_TABLE_SIZE]; -: 20: -: 21:static inline UINT32 -: 22:hash(const char* mode) -: 23:{ 53080: 24: UINT32 i = ACCESS_TABLE_HASH; 145245: 25: while (*mode) { branch 0 taken 63% branch 1 taken 37% (fallthrough) branch 2 taken 76% branch 3 taken 24% (fallthrough) 92165: 26: i = ((i<<5) + i) ^ (UINT8) *mode++; -: 27: } 53080: 28: return i % ACCESS_TABLE_SIZE; -: 29:} -: 30: -: 31:static ImagingAccess function add_item called 63 returned 100% blocks executed 63% 63: 32:add_item(const char* mode) -: 33:{ 63: 34: UINT32 i = hash(mode); -: 35: /* printf("hash %s => %d\n", mode, i); */ 63: 36: if (access_table[i].mode && strcmp(access_table[i].mode, mode) != 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed #####: 37: fprintf(stderr, "AccessInit: hash collision: %d for both %s and %s\n", -: 38: i, mode, access_table[i].mode); #####: 39: exit(1); call 0 never executed -: 40: } 63: 41: access_table[i].mode = mode; 63: 42: return &access_table[i]; -: 43:} -: 44: -: 45:/* fetch pointer to pixel line */ -: 46: -: 47:static void* function line_8 called 0 returned 0% blocks executed 0% #####: 48:line_8(Imaging im, int x, int y) -: 49:{ #####: 50: return &im->image8[y][x]; -: 51:} -: 52: -: 53:static void* function line_16 called 0 returned 0% blocks executed 0% #####: 54:line_16(Imaging im, int x, int y) -: 55:{ #####: 56: return &im->image8[y][x+x]; -: 57:} -: 58: -: 59:static void* function line_32 called 0 returned 0% blocks executed 0% #####: 60:line_32(Imaging im, int x, int y) -: 61:{ #####: 62: return &im->image32[y][x]; -: 63:} -: 64: -: 65:/* fetch individual pixel */ -: 66: -: 67:static void function get_pixel called 30335 returned 100% blocks executed 71% 30335: 68:get_pixel(Imaging im, int x, int y, void* color) -: 69:{ 30335: 70: char* out = color; -: 71: -: 72: /* generic pixel access*/ -: 73: 30335: 74: if (im->image8) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 75: out[0] = im->image8[y][x]; -: 76: } else { 30335: 77: UINT8* p = (UINT8*) &im->image32[y][x]; 30335: 78: if (im->type == IMAGING_TYPE_UINT8 && im->bands == 2) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 30335: 79: out[0] = p[0]; 30335: 80: out[1] = p[3]; 30335: 81: return; -: 82: } #####: 83: memcpy(out, p, im->pixelsize); -: 84: } -: 85:} -: 86: -: 87:static void function get_pixel_8 called 4120100 returned 100% blocks executed 100% 4120100: 88:get_pixel_8(Imaging im, int x, int y, void* color) -: 89:{ 4120100: 90: char* out = color; 4120100: 91: out[0] = im->image8[y][x]; 4120100: 92:} -: 93: -: 94:static void function get_pixel_16L called 18034 returned 100% blocks executed 100% 18034: 95:get_pixel_16L(Imaging im, int x, int y, void* color) -: 96:{ 18034: 97: UINT8* in = (UINT8*) &im->image[y][x+x]; -: 98:#ifdef WORDS_BIGENDIAN -: 99: UINT16 out = in[0] + (in[1]<<8); -: 100: memcpy(color, &out, sizeof(out)); -: 101:#else 18034: 102: memcpy(color, in, sizeof(UINT16)); -: 103:#endif 18034: 104:} -: 105: -: 106:static void function get_pixel_16B called 9426 returned 100% blocks executed 100% 9426: 107:get_pixel_16B(Imaging im, int x, int y, void* color) -: 108:{ 9426: 109: UINT8* in = (UINT8*) &im->image[y][x+x]; -: 110:#ifdef WORDS_BIGENDIAN -: 111: memcpy(color, in, sizeof(UINT16)); -: 112:#else 9426: 113: UINT16 out = in[1] + (in[0]<<8); 9426: 114: memcpy(color, &out, sizeof(out)); -: 115:#endif 9426: 116:} -: 117: -: 118:static void function get_pixel_32 called 463561 returned 100% blocks executed 100% 463561: 119:get_pixel_32(Imaging im, int x, int y, void* color) -: 120:{ 927122: 121: memcpy(color, &im->image32[y][x], sizeof(INT32)); 463561: 122:} -: 123: -: 124:static void function get_pixel_32L called 0 returned 0% blocks executed 0% #####: 125:get_pixel_32L(Imaging im, int x, int y, void* color) -: 126:{ #####: 127: UINT8* in = (UINT8*) &im->image[y][x*4]; -: 128:#ifdef WORDS_BIGENDIAN -: 129: INT32 out = in[0] + (in[1]<<8) + (in[2]<<16) + (in[3]<<24); -: 130: memcpy(color, &out, sizeof(out)); -: 131:#else #####: 132: memcpy(color, in, sizeof(INT32)); -: 133:#endif #####: 134:} -: 135: -: 136:static void function get_pixel_32B called 0 returned 0% blocks executed 0% #####: 137:get_pixel_32B(Imaging im, int x, int y, void* color) -: 138:{ #####: 139: UINT8* in = (UINT8*) &im->image[y][x*4]; -: 140:#ifdef WORDS_BIGENDIAN -: 141: memcpy(color, in, sizeof(INT32)); -: 142:#else #####: 143: INT32 out = in[3] + (in[2]<<8) + (in[1]<<16) + (in[0]<<24); #####: 144: memcpy(color, &out, sizeof(out)); -: 145:#endif #####: 146:} -: 147: -: 148:/* store individual pixel */ -: 149: -: 150:static void function put_pixel called 5139 returned 100% blocks executed 75% 5139: 151:put_pixel(Imaging im, int x, int y, const void* color) -: 152:{ 5139: 153: if (im->image8) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 154: im->image8[y][x] = *((UINT8*) color); -: 155: } else { 5139: 156: memcpy(&im->image32[y][x], color, sizeof(INT32)); -: 157: } 5139: 158:} -: 159: -: 160:static void function put_pixel_8 called 211306 returned 100% blocks executed 100% 211306: 161:put_pixel_8(Imaging im, int x, int y, const void* color) -: 162:{ 211306: 163: im->image8[y][x] = *((UINT8*) color); 211306: 164:} -: 165: -: 166:static void function put_pixel_16L called 10546 returned 100% blocks executed 100% 10546: 167:put_pixel_16L(Imaging im, int x, int y, const void* color) -: 168:{ 21092: 169: memcpy(&im->image8[y][x+x], color, 2); 10546: 170:} -: 171: -: 172:static void function put_pixel_16B called 232 returned 100% blocks executed 100% 232: 173:put_pixel_16B(Imaging im, int x, int y, const void* color) -: 174:{ 232: 175: const char* in = color; 232: 176: UINT8* out = (UINT8*) &im->image8[y][x+x]; 232: 177: out[0] = in[1]; 232: 178: out[1] = in[0]; 232: 179:} -: 180: -: 181:static void function put_pixel_32L called 0 returned 0% blocks executed 0% #####: 182:put_pixel_32L(Imaging im, int x, int y, const void* color) -: 183:{ #####: 184: memcpy(&im->image8[y][x*4], color, 4); #####: 185:} -: 186: -: 187:static void function put_pixel_32B called 0 returned 0% blocks executed 0% #####: 188:put_pixel_32B(Imaging im, int x, int y, const void* color) -: 189:{ #####: 190: const char* in = color; #####: 191: UINT8* out = (UINT8*) &im->image8[y][x*4]; #####: 192: out[0] = in[3]; #####: 193: out[1] = in[2]; #####: 194: out[2] = in[1]; #####: 195: out[3] = in[0]; #####: 196:} -: 197: -: 198:static void function put_pixel_32 called 141120 returned 100% blocks executed 100% 141120: 199:put_pixel_32(Imaging im, int x, int y, const void* color) -: 200:{ 282240: 201: memcpy(&im->image32[y][x], color, sizeof(INT32)); 141120: 202:} -: 203: -: 204:void function ImagingAccessInit called 3 returned 100% blocks executed 100% 3: 205:ImagingAccessInit() -: 206:{ -: 207:#define ADD(mode_, line_, get_pixel_, put_pixel_) \ -: 208: { ImagingAccess access = add_item(mode_); \ -: 209: access->line = line_; \ -: 210: access->get_pixel = get_pixel_; \ -: 211: access->put_pixel = put_pixel_; \ -: 212: } -: 213: -: 214: /* populate access table */ 3: 215: ADD("1", line_8, get_pixel_8, put_pixel_8); call 0 returned 100% 3: 216: ADD("L", line_8, get_pixel_8, put_pixel_8); call 0 returned 100% 3: 217: ADD("LA", line_32, get_pixel, put_pixel); call 0 returned 100% 3: 218: ADD("La", line_32, get_pixel, put_pixel); call 0 returned 100% 3: 219: ADD("I", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 220: ADD("I;16", line_16, get_pixel_16L, put_pixel_16L); call 0 returned 100% 3: 221: ADD("I;16L", line_16, get_pixel_16L, put_pixel_16L); call 0 returned 100% 3: 222: ADD("I;16B", line_16, get_pixel_16B, put_pixel_16B); call 0 returned 100% 3: 223: ADD("I;32L", line_32, get_pixel_32L, put_pixel_32L); call 0 returned 100% 3: 224: ADD("I;32B", line_32, get_pixel_32B, put_pixel_32B); call 0 returned 100% 3: 225: ADD("F", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 226: ADD("P", line_8, get_pixel_8, put_pixel_8); call 0 returned 100% 3: 227: ADD("PA", line_32, get_pixel, put_pixel); call 0 returned 100% 3: 228: ADD("RGB", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 229: ADD("RGBA", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 230: ADD("RGBa", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 231: ADD("RGBX", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 232: ADD("CMYK", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 233: ADD("YCbCr", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 234: ADD("LAB", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 235: ADD("HSV", line_32, get_pixel_32, put_pixel_32); call 0 returned 100% 3: 236:} -: 237: -: 238:ImagingAccess function ImagingAccessNew called 53017 returned 100% blocks executed 100% 53017: 239:ImagingAccessNew(Imaging im) -: 240:{ 106034: 241: ImagingAccess access = &access_table[hash(im->mode)]; 53017: 242: if (im->mode[0] != access->mode[0] || strcmp(im->mode, access->mode) != 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 243: return NULL; -: 244: } 53010: 245: return access; -: 246:} -: 247: -: 248:void function _ImagingAccessDelete called 0 returned 0% blocks executed 0% #####: 249:_ImagingAccessDelete(Imaging im, ImagingAccess access) -: 250:{ -: 251: #####: 252:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Jpeg2KDecode.c.gcov -: 0:Source:src/libImaging/Jpeg2KDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Jpeg2KDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Jpeg2KDecode.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 -: 21:#include "Jpeg2K.h" -: 22: -: 23:typedef struct { -: 24: OPJ_UINT32 tile_index; -: 25: OPJ_UINT32 data_size; -: 26: OPJ_INT32 x0, y0, x1, y1; -: 27: OPJ_UINT32 nb_comps; -: 28:} JPEG2KTILEINFO; -: 29: -: 30:/* -------------------------------------------------------------------- */ -: 31:/* Error handler */ -: 32:/* -------------------------------------------------------------------- */ -: 33: -: 34:static void function j2k_error called 0 returned 0% blocks executed 0% #####: 35:j2k_error(const char *msg, void *client_data) -: 36:{ #####: 37: JPEG2KDECODESTATE *state = (JPEG2KDECODESTATE *) client_data; #####: 38: free((void *)state->error_msg); #####: 39: state->error_msg = strdup(msg); call 0 never executed #####: 40:} -: 41: -: 42:/* -------------------------------------------------------------------- */ -: 43:/* Buffer input stream */ -: 44:/* -------------------------------------------------------------------- */ -: 45: -: 46:static OPJ_SIZE_T function j2k_read called 62 returned 100% blocks executed 100% 62: 47:j2k_read(void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data) -: 48:{ 62: 49: ImagingCodecState state = (ImagingCodecState)p_user_data; -: 50: 62: 51: size_t len = _imaging_read_pyFd(state->fd, p_buffer, p_nb_bytes); call 0 returned 100% -: 52: 62: 53: return len ? len : (OPJ_SIZE_T)-1; branch 0 taken 53% (fallthrough) branch 1 taken 47% -: 54:} -: 55: -: 56:static OPJ_OFF_T function j2k_skip called 0 returned 0% blocks executed 0% #####: 57:j2k_skip(OPJ_OFF_T p_nb_bytes, void *p_user_data) -: 58:{ -: 59: off_t pos; #####: 60: ImagingCodecState state = (ImagingCodecState)p_user_data; -: 61: #####: 62: _imaging_seek_pyFd(state->fd, p_nb_bytes, SEEK_CUR); call 0 never executed #####: 63: pos = _imaging_tell_pyFd(state->fd); call 0 never executed -: 64: #####: 65: return pos ? pos : (OPJ_OFF_T)-1; branch 0 never executed branch 1 never executed -: 66:} -: 67: -: 68:/* -------------------------------------------------------------------- */ -: 69:/* Unpackers */ -: 70:/* -------------------------------------------------------------------- */ -: 71: -: 72:typedef void (*j2k_unpacker_t)(opj_image_t *in, -: 73: const JPEG2KTILEINFO *tileInfo, -: 74: const UINT8 *data, -: 75: Imaging im); -: 76: -: 77:struct j2k_decode_unpacker { -: 78: const char *mode; -: 79: OPJ_COLOR_SPACE color_space; -: 80: unsigned components; -: 81: j2k_unpacker_t unpacker; -: 82:}; -: 83: -: 84:static inline -: 85:unsigned j2ku_shift(unsigned x, int n) -: 86:{ 19927296: 87: if (n < 0) { branch 0 never executed branch 1 never executed branch 2 taken 0% (fallthrough) branch 3 taken 100% branch 4 never executed branch 5 never executed branch 6 taken 0% (fallthrough) branch 7 taken 100% 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 taken 0% (fallthrough) branch 21 taken 100% 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 #####: 88: return x >> -n; -: 89: } else { 19927296: 90: return x << n; -: 91: } -: 92:} -: 93: -: 94:static void function j2ku_gray_l called 0 returned 0% blocks executed 0% #####: 95:j2ku_gray_l(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 96: const UINT8 *tiledata, Imaging im) -: 97:{ #####: 98: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; #####: 99: unsigned w = tileinfo->x1 - tileinfo->x0; #####: 100: unsigned h = tileinfo->y1 - tileinfo->y0; -: 101: #####: 102: int shift = 8 - in->comps[0].prec; #####: 103: int offset = in->comps[0].sgnd ? 1 << (in->comps[0].prec - 1) : 0; branch 0 never executed branch 1 never executed #####: 104: int csiz = (in->comps[0].prec + 7) >> 3; -: 105: -: 106: unsigned x, y; -: 107: #####: 108: if (csiz == 3) { branch 0 never executed branch 1 never executed #####: 109: csiz = 4; -: 110: } -: 111: #####: 112: if (shift < 0) { branch 0 never executed branch 1 never executed #####: 113: offset += 1 << (-shift - 1); -: 114: } -: 115: -: 116: /* csiz*h*w + offset = tileinfo.datasize */ #####: 117: switch (csiz) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 118: case 1: #####: 119: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 120: const UINT8 *data = &tiledata[y * w]; #####: 121: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; #####: 122: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 123: *row++ = j2ku_shift(offset + *data++, shift); -: 124: } -: 125: } -: 126: break; -: 127: case 2: #####: 128: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 129: const UINT16 *data = (const UINT16 *)&tiledata[2 * y * w]; #####: 130: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; #####: 131: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 132: *row++ = j2ku_shift(offset + *data++, shift); -: 133: } -: 134: } -: 135: break; -: 136: case 4: #####: 137: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 138: const UINT32 *data = (const UINT32 *)&tiledata[4 * y * w]; #####: 139: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; #####: 140: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 141: *row++ = j2ku_shift(offset + *data++, shift); -: 142: } -: 143: } -: 144: break; -: 145: } #####: 146:} -: 147: -: 148: -: 149:static void function j2ku_gray_i called 8 returned 100% blocks executed 37% 8: 150:j2ku_gray_i(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 151: const UINT8 *tiledata, Imaging im) -: 152:{ 8: 153: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; 8: 154: unsigned w = tileinfo->x1 - tileinfo->x0; 8: 155: unsigned h = tileinfo->y1 - tileinfo->y0; -: 156: 8: 157: int shift = 16 - in->comps[0].prec; 8: 158: int offset = in->comps[0].sgnd ? 1 << (in->comps[0].prec - 1) : 0; branch 0 taken 0% (fallthrough) branch 1 taken 100% 8: 159: int csiz = (in->comps[0].prec + 7) >> 3; -: 160: -: 161: unsigned x, y; -: 162: 8: 163: if (csiz == 3) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 164: csiz = 4; -: 165: } -: 166: 8: 167: if (shift < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 168: offset += 1 << (-shift - 1); -: 169: } -: 170: 8: 171: switch (csiz) { branch 0 taken 0% branch 1 taken 100% branch 2 taken 0% branch 3 taken 0% -: 172: case 1: #####: 173: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 174: const UINT8 *data = &tiledata[y * w]; #####: 175: UINT16 *row = (UINT16 *)im->image[y0 + y] + x0; #####: 176: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 177: *row++ = j2ku_shift(offset + *data++, shift); -: 178: } -: 179: } -: 180: break; -: 181: case 2: 512: 182: for (y = 0; y < h; ++y) { branch 0 taken 98% branch 1 taken 2% 512: 183: const UINT16 *data = (const UINT16 *)&tiledata[2 * y * w]; 512: 184: UINT16 *row = (UINT16 *)im->image[y0 + y] + x0; 33280: 185: for (x = 0; x < w; ++x) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 65536: 186: *row++ = j2ku_shift(offset + *data++, shift); -: 187: } -: 188: } -: 189: break; -: 190: case 4: #####: 191: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 192: const UINT32 *data = (const UINT32 *)&tiledata[4 * y * w]; #####: 193: UINT16 *row = (UINT16 *)im->image[y0 + y] + x0; #####: 194: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 195: *row++ = j2ku_shift(offset + *data++, shift); -: 196: } -: 197: } -: 198: break; -: 199: } 8: 200:} -: 201: -: 202: -: 203:static void function j2ku_gray_rgb called 0 returned 0% blocks executed 0% #####: 204:j2ku_gray_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 205: const UINT8 *tiledata, Imaging im) -: 206:{ #####: 207: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; #####: 208: unsigned w = tileinfo->x1 - tileinfo->x0; #####: 209: unsigned h = tileinfo->y1 - tileinfo->y0; -: 210: #####: 211: int shift = 8 - in->comps[0].prec; #####: 212: int offset = in->comps[0].sgnd ? 1 << (in->comps[0].prec - 1) : 0; branch 0 never executed branch 1 never executed #####: 213: int csiz = (in->comps[0].prec + 7) >> 3; -: 214: -: 215: unsigned x, y; -: 216: #####: 217: if (shift < 0) { branch 0 never executed branch 1 never executed #####: 218: offset += 1 << (-shift - 1); -: 219: } -: 220: #####: 221: if (csiz == 3) { branch 0 never executed branch 1 never executed #####: 222: csiz = 4; -: 223: } -: 224: #####: 225: switch (csiz) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 226: case 1: #####: 227: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 228: const UINT8 *data = &tiledata[y * w]; #####: 229: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; #####: 230: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 231: UINT8 byte = j2ku_shift(offset + *data++, shift); #####: 232: row[0] = row[1] = row[2] = byte; #####: 233: row[3] = 0xff; #####: 234: row += 4; -: 235: } -: 236: } -: 237: break; -: 238: case 2: #####: 239: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 240: const UINT16 *data = (UINT16 *)&tiledata[2 * y * w]; #####: 241: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; #####: 242: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 243: UINT8 byte = j2ku_shift(offset + *data++, shift); #####: 244: row[0] = row[1] = row[2] = byte; #####: 245: row[3] = 0xff; #####: 246: row += 4; -: 247: } -: 248: } -: 249: break; -: 250: case 4: #####: 251: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 252: const UINT32 *data = (UINT32 *)&tiledata[4 * y * w]; #####: 253: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0; #####: 254: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 255: UINT8 byte = j2ku_shift(offset + *data++, shift); #####: 256: row[0] = row[1] = row[2] = byte; #####: 257: row[3] = 0xff; #####: 258: row += 4; -: 259: } -: 260: } -: 261: break; -: 262: } #####: 263:} -: 264: -: 265:static void function j2ku_graya_la called 0 returned 0% blocks executed 0% #####: 266:j2ku_graya_la(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 267: const UINT8 *tiledata, Imaging im) -: 268:{ #####: 269: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; #####: 270: unsigned w = tileinfo->x1 - tileinfo->x0; #####: 271: unsigned h = tileinfo->y1 - tileinfo->y0; -: 272: #####: 273: int shift = 8 - in->comps[0].prec; #####: 274: int offset = in->comps[0].sgnd ? 1 << (in->comps[0].prec - 1) : 0; branch 0 never executed branch 1 never executed #####: 275: int csiz = (in->comps[0].prec + 7) >> 3; #####: 276: int ashift = 8 - in->comps[1].prec; #####: 277: int aoffset = in->comps[1].sgnd ? 1 << (in->comps[1].prec - 1) : 0; branch 0 never executed branch 1 never executed #####: 278: int acsiz = (in->comps[1].prec + 7) >> 3; -: 279: const UINT8 *atiledata; -: 280: -: 281: unsigned x, y; -: 282: #####: 283: if (csiz == 3) { branch 0 never executed branch 1 never executed #####: 284: csiz = 4; -: 285: } #####: 286: if (acsiz == 3) { branch 0 never executed branch 1 never executed #####: 287: acsiz = 4; -: 288: } -: 289: #####: 290: if (shift < 0) { branch 0 never executed branch 1 never executed #####: 291: offset += 1 << (-shift - 1); -: 292: } #####: 293: if (ashift < 0) { branch 0 never executed branch 1 never executed #####: 294: aoffset += 1 << (-ashift - 1); -: 295: } -: 296: #####: 297: atiledata = tiledata + csiz * w * h; -: 298: #####: 299: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed #####: 300: const UINT8 *data = &tiledata[csiz * y * w]; #####: 301: const UINT8 *adata = &atiledata[acsiz * y * w]; #####: 302: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4; #####: 303: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 304: UINT32 word = 0, aword = 0, byte; -: 305: #####: 306: switch (csiz) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 307: case 1: word = *data++; break; #####: 308: case 2: word = *(const UINT16 *)data; data += 2; break; #####: 309: case 4: word = *(const UINT32 *)data; data += 4; break; -: 310: } -: 311: #####: 312: switch (acsiz) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 313: case 1: aword = *adata++; break; #####: 314: case 2: aword = *(const UINT16 *)adata; adata += 2; break; #####: 315: case 4: aword = *(const UINT32 *)adata; adata += 4; break; -: 316: } -: 317: #####: 318: byte = j2ku_shift(offset + word, shift); #####: 319: row[0] = row[1] = row[2] = byte; #####: 320: row[3] = j2ku_shift(aoffset + aword, ashift); #####: 321: row += 4; -: 322: } -: 323: } #####: 324:} -: 325: -: 326:static void function j2ku_srgb_rgb called 76 returned 100% blocks executed 79% 76: 327:j2ku_srgb_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 328: const UINT8 *tiledata, Imaging im) -: 329:{ 76: 330: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; 76: 331: unsigned w = tileinfo->x1 - tileinfo->x0; 76: 332: unsigned h = tileinfo->y1 - tileinfo->y0; -: 333: -: 334: int shifts[3], offsets[3], csiz[3]; -: 335: const UINT8 *cdata[3]; 76: 336: const UINT8 *cptr = tiledata; -: 337: unsigned n, x, y; -: 338: 304: 339: for (n = 0; n < 3; ++n) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 228: 340: cdata[n] = cptr; 228: 341: shifts[n] = 8 - in->comps[n].prec; 228: 342: offsets[n] = in->comps[n].sgnd ? 1 << (in->comps[n].prec - 1) : 0; branch 0 taken 0% (fallthrough) branch 1 taken 100% 228: 343: csiz[n] = (in->comps[n].prec + 7) >> 3; -: 344: 228: 345: if (csiz[n] == 3) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 346: csiz[n] = 4; -: 347: } -: 348: 228: 349: if (shifts[n] < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 350: offsets[n] += 1 << (-shifts[n] - 1); -: 351: } -: 352: 228: 353: cptr += csiz[n] * w * h; -: 354: } -: 355: 13080: 356: for (y = 0; y < h; ++y) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 357: const UINT8 *data[3]; 13080: 358: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4; 52320: 359: for (n = 0; n < 3; ++n) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 39240: 360: data[n] = &cdata[n][csiz[n] * y * w]; -: 361: } -: 362: 4320000: 363: for (x = 0; x < w; ++x) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 12960000: 364: for (n = 0; n < 3; ++n) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 12960000: 365: UINT32 word = 0; -: 366: 12960000: 367: switch (csiz[n]) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% 12960000: 368: case 1: word = *data[n]++; break; #####: 369: case 2: word = *(const UINT16 *)data[n]; data[n] += 2; break; #####: 370: case 4: word = *(const UINT32 *)data[n]; data[n] += 4; break; -: 371: } -: 372: 25920000: 373: row[n] = j2ku_shift(offsets[n] + word, shifts[n]); -: 374: } 4320000: 375: row[3] = 0xff; 4320000: 376: row += 4; -: 377: } -: 378: } 76: 379:} -: 380: -: 381:static void function j2ku_sycc_rgb called 0 returned 0% blocks executed 0% #####: 382:j2ku_sycc_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 383: const UINT8 *tiledata, Imaging im) -: 384:{ #####: 385: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; #####: 386: unsigned w = tileinfo->x1 - tileinfo->x0; #####: 387: unsigned h = tileinfo->y1 - tileinfo->y0; -: 388: -: 389: int shifts[3], offsets[3], csiz[3]; -: 390: const UINT8 *cdata[3]; #####: 391: const UINT8 *cptr = tiledata; -: 392: unsigned n, x, y; -: 393: #####: 394: for (n = 0; n < 3; ++n) { branch 0 never executed branch 1 never executed #####: 395: cdata[n] = cptr; #####: 396: shifts[n] = 8 - in->comps[n].prec; #####: 397: offsets[n] = in->comps[n].sgnd ? 1 << (in->comps[n].prec - 1) : 0; branch 0 never executed branch 1 never executed #####: 398: csiz[n] = (in->comps[n].prec + 7) >> 3; -: 399: #####: 400: if (csiz[n] == 3) { branch 0 never executed branch 1 never executed #####: 401: csiz[n] = 4; -: 402: } -: 403: #####: 404: if (shifts[n] < 0) { branch 0 never executed branch 1 never executed #####: 405: offsets[n] += 1 << (-shifts[n] - 1); -: 406: } -: 407: #####: 408: cptr += csiz[n] * w * h; -: 409: } -: 410: #####: 411: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed -: 412: const UINT8 *data[3]; #####: 413: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4; #####: 414: UINT8 *row_start = row; #####: 415: for (n = 0; n < 3; ++n) { branch 0 never executed branch 1 never executed #####: 416: data[n] = &cdata[n][csiz[n] * y * w]; -: 417: } -: 418: #####: 419: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 420: for (n = 0; n < 3; ++n) { branch 0 never executed branch 1 never executed #####: 421: UINT32 word = 0; -: 422: #####: 423: switch (csiz[n]) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 424: case 1: word = *data[n]++; break; #####: 425: case 2: word = *(const UINT16 *)data[n]; data[n] += 2; break; #####: 426: case 4: word = *(const UINT32 *)data[n]; data[n] += 4; break; -: 427: } -: 428: #####: 429: row[n] = j2ku_shift(offsets[n] + word, shifts[n]); -: 430: } #####: 431: row[3] = 0xff; #####: 432: row += 4; -: 433: } -: 434: #####: 435: ImagingConvertYCbCr2RGB(row_start, row_start, w); call 0 never executed -: 436: } #####: 437:} -: 438: -: 439:static void function j2ku_srgba_rgba called 10 returned 100% blocks executed 79% 10: 440:j2ku_srgba_rgba(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 441: const UINT8 *tiledata, Imaging im) -: 442:{ 10: 443: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; 10: 444: unsigned w = tileinfo->x1 - tileinfo->x0; 10: 445: unsigned h = tileinfo->y1 - tileinfo->y0; -: 446: -: 447: int shifts[4], offsets[4], csiz[4]; -: 448: const UINT8 *cdata[4]; 10: 449: const UINT8 *cptr = tiledata; -: 450: unsigned n, x, y; -: 451: 50: 452: for (n = 0; n < 4; ++n) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 40: 453: cdata[n] = cptr; 40: 454: shifts[n] = 8 - in->comps[n].prec; 40: 455: offsets[n] = in->comps[n].sgnd ? 1 << (in->comps[n].prec - 1) : 0; branch 0 taken 0% (fallthrough) branch 1 taken 100% 40: 456: csiz[n] = (in->comps[n].prec + 7) >> 3; -: 457: 40: 458: if (csiz[n] == 3) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 459: csiz[n] = 4; -: 460: } -: 461: 40: 462: if (shifts[n] < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 463: offsets[n] += 1 << (-shifts[n] - 1); -: 464: } -: 465: 40: 466: cptr += csiz[n] * w * h; -: 467: } -: 468: 2912: 469: for (y = 0; y < h; ++y) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 470: const UINT8 *data[4]; 2912: 471: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4; 14560: 472: for (n = 0; n < 4; ++n) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 11648: 473: data[n] = &cdata[n][csiz[n] * y * w]; -: 474: } -: 475: 1733632: 476: for (x = 0; x < w; ++x) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 6934528: 477: for (n = 0; n < 4; ++n) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 6934528: 478: UINT32 word = 0; -: 479: 6934528: 480: switch (csiz[n]) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% 6934528: 481: case 1: word = *data[n]++; break; #####: 482: case 2: word = *(const UINT16 *)data[n]; data[n] += 2; break; #####: 483: case 4: word = *(const UINT32 *)data[n]; data[n] += 4; break; -: 484: } -: 485: 13869056: 486: row[n] = j2ku_shift(offsets[n] + word, shifts[n]); -: 487: } 1733632: 488: row += 4; -: 489: } -: 490: } 10: 491:} -: 492: -: 493:static void function j2ku_sycca_rgba called 0 returned 0% blocks executed 0% #####: 494:j2ku_sycca_rgba(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, -: 495: const UINT8 *tiledata, Imaging im) -: 496:{ #####: 497: unsigned x0 = tileinfo->x0 - in->x0, y0 = tileinfo->y0 - in->y0; #####: 498: unsigned w = tileinfo->x1 - tileinfo->x0; #####: 499: unsigned h = tileinfo->y1 - tileinfo->y0; -: 500: -: 501: int shifts[4], offsets[4], csiz[4]; -: 502: const UINT8 *cdata[4]; #####: 503: const UINT8 *cptr = tiledata; -: 504: unsigned n, x, y; -: 505: #####: 506: for (n = 0; n < 4; ++n) { branch 0 never executed branch 1 never executed #####: 507: cdata[n] = cptr; #####: 508: shifts[n] = 8 - in->comps[n].prec; #####: 509: offsets[n] = in->comps[n].sgnd ? 1 << (in->comps[n].prec - 1) : 0; branch 0 never executed branch 1 never executed #####: 510: csiz[n] = (in->comps[n].prec + 7) >> 3; -: 511: #####: 512: if (csiz[n] == 3) { branch 0 never executed branch 1 never executed #####: 513: csiz[n] = 4; -: 514: } -: 515: #####: 516: if (shifts[n] < 0) { branch 0 never executed branch 1 never executed #####: 517: offsets[n] += 1 << (-shifts[n] - 1); -: 518: } -: 519: #####: 520: cptr += csiz[n] * w * h; -: 521: } -: 522: #####: 523: for (y = 0; y < h; ++y) { branch 0 never executed branch 1 never executed -: 524: const UINT8 *data[4]; #####: 525: UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4; #####: 526: UINT8 *row_start = row; #####: 527: for (n = 0; n < 4; ++n) { branch 0 never executed branch 1 never executed #####: 528: data[n] = &cdata[n][csiz[n] * y * w]; -: 529: } -: 530: #####: 531: for (x = 0; x < w; ++x) { branch 0 never executed branch 1 never executed #####: 532: for (n = 0; n < 4; ++n) { branch 0 never executed branch 1 never executed #####: 533: UINT32 word = 0; -: 534: #####: 535: switch (csiz[n]) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 536: case 1: word = *data[n]++; break; #####: 537: case 2: word = *(const UINT16 *)data[n]; data[n] += 2; break; #####: 538: case 4: word = *(const UINT32 *)data[n]; data[n] += 4; break; -: 539: } -: 540: #####: 541: row[n] = j2ku_shift(offsets[n] + word, shifts[n]); -: 542: } #####: 543: row += 4; -: 544: } -: 545: #####: 546: ImagingConvertYCbCr2RGB(row_start, row_start, w); call 0 never executed -: 547: } #####: 548:} -: 549: -: 550:static const struct j2k_decode_unpacker j2k_unpackers[] = { -: 551: { "L", OPJ_CLRSPC_GRAY, 1, j2ku_gray_l }, -: 552: { "I;16", OPJ_CLRSPC_GRAY, 1, j2ku_gray_i }, -: 553: { "I;16B", OPJ_CLRSPC_GRAY, 1, j2ku_gray_i }, -: 554: { "LA", OPJ_CLRSPC_GRAY, 2, j2ku_graya_la }, -: 555: { "RGB", OPJ_CLRSPC_GRAY, 1, j2ku_gray_rgb }, -: 556: { "RGB", OPJ_CLRSPC_GRAY, 2, j2ku_gray_rgb }, -: 557: { "RGB", OPJ_CLRSPC_SRGB, 3, j2ku_srgb_rgb }, -: 558: { "RGB", OPJ_CLRSPC_SYCC, 3, j2ku_sycc_rgb }, -: 559: { "RGB", OPJ_CLRSPC_SRGB, 4, j2ku_srgb_rgb }, -: 560: { "RGB", OPJ_CLRSPC_SYCC, 4, j2ku_sycc_rgb }, -: 561: { "RGBA", OPJ_CLRSPC_GRAY, 1, j2ku_gray_rgb }, -: 562: { "RGBA", OPJ_CLRSPC_GRAY, 2, j2ku_graya_la }, -: 563: { "RGBA", OPJ_CLRSPC_SRGB, 3, j2ku_srgb_rgb }, -: 564: { "RGBA", OPJ_CLRSPC_SYCC, 3, j2ku_sycc_rgb }, -: 565: { "RGBA", OPJ_CLRSPC_SRGB, 4, j2ku_srgba_rgba }, -: 566: { "RGBA", OPJ_CLRSPC_SYCC, 4, j2ku_sycca_rgba }, -: 567:}; -: 568: -: 569:/* -------------------------------------------------------------------- */ -: 570:/* Decoder */ -: 571:/* -------------------------------------------------------------------- */ -: 572: -: 573:enum { -: 574: J2K_STATE_START = 0, -: 575: J2K_STATE_DECODING = 1, -: 576: J2K_STATE_DONE = 2, -: 577: J2K_STATE_FAILED = 3, -: 578:}; -: 579: -: 580:static int function j2k_decode_entry called 33 returned 100% blocks executed 80% 33: 581:j2k_decode_entry(Imaging im, ImagingCodecState state) -: 582:{ 33: 583: JPEG2KDECODESTATE *context = (JPEG2KDECODESTATE *) state->context; 33: 584: opj_stream_t *stream = NULL; 33: 585: opj_image_t *image = NULL; 33: 586: opj_codec_t *codec = NULL; -: 587: opj_dparameters_t params; -: 588: OPJ_COLOR_SPACE color_space; 33: 589: j2k_unpacker_t unpack = NULL; 33: 590: size_t buffer_size = 0, tile_bytes = 0; -: 591: unsigned n, tile_height, tile_width; -: 592: int components; -: 593: -: 594: 33: 595: stream = opj_stream_create(BUFFER_SIZE, OPJ_TRUE); call 0 returned 100% -: 596: 33: 597: if (!stream) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 598: state->errcode = IMAGING_CODEC_BROKEN; #####: 599: state->state = J2K_STATE_FAILED; #####: 600: goto quick_exit; -: 601: } -: 602: 33: 603: opj_stream_set_read_function(stream, j2k_read); call 0 returned 100% 33: 604: opj_stream_set_skip_function(stream, j2k_skip); call 0 returned 100% -: 605: -: 606: /* OpenJPEG 2.0 doesn't have OPJ_VERSION_MAJOR */ -: 607:#ifndef OPJ_VERSION_MAJOR -: 608: opj_stream_set_user_data(stream, state); -: 609:#else 33: 610: opj_stream_set_user_data(stream, state, NULL); call 0 returned 100% -: 611: -: 612: /* Hack: if we don't know the length, the largest file we can -: 613: possibly support is 4GB. We can't go larger than this, because -: 614: OpenJPEG truncates this value for the final box in the file, and -: 615: the box lengths in OpenJPEG are currently 32 bit. */ 33: 616: if (context->length < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 617: opj_stream_set_user_data_length(stream, 0xffffffff); call 0 never executed -: 618: } else { 33: 619: opj_stream_set_user_data_length(stream, context->length); call 0 returned 100% -: 620: } -: 621:#endif -: 622: -: 623: /* Setup decompression context */ 33: 624: context->error_msg = NULL; -: 625: 33: 626: opj_set_default_decoder_parameters(¶ms); call 0 returned 100% 33: 627: params.cp_reduce = context->reduce; 33: 628: params.cp_layer = context->layers; -: 629: 33: 630: codec = opj_create_decompress(context->format); call 0 returned 100% -: 631: 33: 632: if (!codec) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 633: state->errcode = IMAGING_CODEC_BROKEN; #####: 634: state->state = J2K_STATE_FAILED; #####: 635: goto quick_exit; -: 636: } -: 637: 33: 638: opj_set_error_handler(codec, j2k_error, context); call 0 returned 100% 33: 639: opj_setup_decoder(codec, ¶ms); call 0 returned 100% -: 640: 33: 641: if (!opj_read_header(stream, codec, &image)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 642: state->errcode = IMAGING_CODEC_BROKEN; #####: 643: state->state = J2K_STATE_FAILED; #####: 644: goto quick_exit; -: 645: } -: 646: -: 647: /* Check that this image is something we can handle */ 33: 648: if (image->numcomps < 1 || image->numcomps > 4 branch 0 taken 100% (fallthrough) branch 1 taken 0% 33: 649: || image->color_space == OPJ_CLRSPC_UNKNOWN) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 650: state->errcode = IMAGING_CODEC_BROKEN; #####: 651: state->state = J2K_STATE_FAILED; #####: 652: goto quick_exit; -: 653: } -: 654: 60: 655: for (n = 1; n < image->numcomps; ++n) { branch 0 taken 65% branch 1 taken 35% (fallthrough) 60: 656: if (image->comps[n].dx != 1 || image->comps[n].dy != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 657: state->errcode = IMAGING_CODEC_BROKEN; #####: 658: state->state = J2K_STATE_FAILED; #####: 659: goto quick_exit; -: 660: } -: 661: } -: 662: -: 663: /* -: 664: Colorspace Number of components PIL mode -: 665: ------------------------------------------------------ -: 666: sRGB 3 RGB -: 667: sRGB 4 RGBA -: 668: gray 1 L or I -: 669: gray 2 LA -: 670: YCC 3 YCbCr -: 671: -: 672: -: 673: If colorspace is unspecified, we assume: -: 674: -: 675: Number of components Colorspace -: 676: ----------------------------------------- -: 677: 1 gray -: 678: 2 gray (+ alpha) -: 679: 3 sRGB -: 680: 4 sRGB (+ alpha) -: 681: -: 682: */ -: 683: -: 684: /* Find the correct unpacker */ 33: 685: color_space = image->color_space; -: 686: 33: 687: if (color_space == OPJ_CLRSPC_UNSPECIFIED) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 33: 688: switch (image->numcomps) { branch 0 taken 24% branch 1 taken 76% branch 2 taken 0% 8: 689: case 1: case 2: color_space = OPJ_CLRSPC_GRAY; break; 25: 690: case 3: case 4: color_space = OPJ_CLRSPC_SRGB; break; -: 691: } -: 692: } -: 693: 271: 694: for (n = 0; n < sizeof(j2k_unpackers) / sizeof (j2k_unpackers[0]); ++n) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 271: 695: if (color_space == j2k_unpackers[n].color_space branch 0 taken 26% (fallthrough) branch 1 taken 74% 71: 696: && image->numcomps == j2k_unpackers[n].components branch 0 taken 72% (fallthrough) branch 1 taken 28% 51: 697: && strcmp (im->mode, j2k_unpackers[n].mode) == 0) { branch 0 taken 65% (fallthrough) branch 1 taken 35% 33: 698: unpack = j2k_unpackers[n].unpacker; 33: 699: break; -: 700: } -: 701: } -: 702: 33: 703: if (!unpack) { branch 0 taken 100% (fallthrough) branch 1 taken 0% #####: 704: state->errcode = IMAGING_CODEC_BROKEN; #####: 705: state->state = J2K_STATE_FAILED; #####: 706: goto quick_exit; -: 707: } -: 708: -: 709: /* Decode the image tile-by-tile; this means we only need use as much -: 710: memory as is required for one tile's worth of components. */ -: 711: for (;;) { -: 712: JPEG2KTILEINFO tile_info; -: 713: OPJ_BOOL should_continue; 127: 714: unsigned correction = (1 << params.cp_reduce) - 1; -: 715: 127: 716: if (!opj_read_tile_header(codec, call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 717: stream, -: 718: &tile_info.tile_index, -: 719: &tile_info.data_size, -: 720: &tile_info.x0, &tile_info.y0, -: 721: &tile_info.x1, &tile_info.y1, -: 722: &tile_info.nb_comps, -: 723: &should_continue)) { #####: 724: state->errcode = IMAGING_CODEC_BROKEN; #####: 725: state->state = J2K_STATE_FAILED; #####: 726: goto quick_exit; -: 727: } -: 728: 127: 729: if (!should_continue) { branch 0 taken 74% (fallthrough) branch 1 taken 26% -: 730: break; -: 731: } -: 732: -: 733: /* Adjust the tile co-ordinates based on the reduction (OpenJPEG -: 734: doesn't do this for us) */ 94: 735: tile_info.x0 = (tile_info.x0 + correction) >> context->reduce; 94: 736: tile_info.y0 = (tile_info.y0 + correction) >> context->reduce; 94: 737: tile_info.x1 = (tile_info.x1 + correction) >> context->reduce; 94: 738: tile_info.y1 = (tile_info.y1 + correction) >> context->reduce; -: 739: -: 740: /* Check the tile bounds; if the tile is outside the image area, -: 741: or if it has a negative width or height (i.e. the coordinates are -: 742: swapped), bail. */ 94: 743: if (tile_info.x0 >= tile_info.x1 branch 0 taken 100% (fallthrough) branch 1 taken 0% 94: 744: || tile_info.y0 >= tile_info.y1 branch 0 taken 100% (fallthrough) branch 1 taken 0% 94: 745: || tile_info.x0 < (OPJ_INT32)image->x0 branch 0 taken 100% (fallthrough) branch 1 taken 0% 94: 746: || tile_info.y0 < (OPJ_INT32)image->y0 branch 0 taken 100% (fallthrough) branch 1 taken 0% 94: 747: || tile_info.x1 - image->x0 > im->xsize branch 0 taken 100% (fallthrough) branch 1 taken 0% 94: 748: || tile_info.y1 - image->y0 > im->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 749: state->errcode = IMAGING_CODEC_BROKEN; #####: 750: state->state = J2K_STATE_FAILED; #####: 751: goto quick_exit; -: 752: } -: 753: -: 754: /* Sometimes the tile_info.datasize we get back from openjpeg -: 755: is less than numcomps*w*h, and we overflow in the -: 756: shuffle stage */ -: 757: 94: 758: tile_width = tile_info.x1 - tile_info.x0; 94: 759: tile_height = tile_info.y1 - tile_info.y0; 94: 760: components = tile_info.nb_comps == 3 ? 4 : tile_info.nb_comps; branch 0 taken 19% (fallthrough) branch 1 taken 81% 94: 761: if (( tile_width > UINT_MAX / components ) || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 94: 762: ( tile_height > UINT_MAX / components ) || branch 0 taken 100% (fallthrough) branch 1 taken 0% 188: 763: ( tile_width > UINT_MAX / (tile_height * components )) || branch 0 taken 0% (fallthrough) branch 1 taken 100% 94: 764: ( tile_height > UINT_MAX / (tile_width * components ))) { #####: 765: state->errcode = IMAGING_CODEC_BROKEN; #####: 766: state->state = J2K_STATE_FAILED; #####: 767: goto quick_exit; -: 768: } -: 769: 94: 770: tile_bytes = tile_width * tile_height * components; -: 771: 94: 772: if (tile_bytes > tile_info.data_size) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 76: 773: tile_info.data_size = tile_bytes; -: 774: } -: 775: 94: 776: if (buffer_size < tile_info.data_size) { branch 0 taken 37% (fallthrough) branch 1 taken 63% -: 777: /* malloc check ok, overflow and tile size sanity check above */ 35: 778: UINT8 *new = realloc (state->buffer, tile_info.data_size); 35: 779: if (!new) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 780: state->errcode = IMAGING_CODEC_MEMORY; #####: 781: state->state = J2K_STATE_FAILED; #####: 782: goto quick_exit; -: 783: } 35: 784: state->buffer = new; 35: 785: buffer_size = tile_info.data_size; -: 786: } -: 787: -: 788: 188: 789: if (!opj_decode_tile_data(codec, call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% -: 790: tile_info.tile_index, 94: 791: (OPJ_BYTE *)state->buffer, -: 792: tile_info.data_size, -: 793: stream)) { #####: 794: state->errcode = IMAGING_CODEC_BROKEN; #####: 795: state->state = J2K_STATE_FAILED; #####: 796: goto quick_exit; -: 797: } -: 798: 94: 799: unpack(image, &tile_info, state->buffer, im); call 0 returned 100% 94: 800: } -: 801: 33: 802: if (!opj_end_decompress(codec, stream)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 803: state->errcode = IMAGING_CODEC_BROKEN; #####: 804: state->state = J2K_STATE_FAILED; #####: 805: goto quick_exit; -: 806: } -: 807: 33: 808: state->state = J2K_STATE_DONE; 33: 809: state->errcode = IMAGING_CODEC_END; -: 810: 33: 811: if (context->pfile) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 812: if(fclose(context->pfile)){ call 0 never executed branch 1 never executed branch 2 never executed #####: 813: context->pfile = NULL; -: 814: } -: 815: } -: 816: -: 817: quick_exit: 33: 818: if (codec) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 33: 819: opj_destroy_codec(codec); call 0 returned 100% -: 820: } 33: 821: if (image) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 33: 822: opj_image_destroy(image); call 0 returned 100% -: 823: } 33: 824: if (stream) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 33: 825: opj_stream_destroy(stream); call 0 returned 100% -: 826: } -: 827: 33: 828: return -1; -: 829:} -: 830: -: 831:int function ImagingJpeg2KDecode called 33 returned 100% blocks executed 63% 33: 832:ImagingJpeg2KDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 833:{ -: 834: 33: 835: if (bytes){ branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 836: state->errcode = IMAGING_CODEC_BROKEN; #####: 837: state->state = J2K_STATE_FAILED; #####: 838: return -1; -: 839: } -: 840: 33: 841: if (state->state == J2K_STATE_DONE || state->state == J2K_STATE_FAILED) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 842: return -1; -: 843: } -: 844: 33: 845: if (state->state == J2K_STATE_START) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 33: 846: state->state = J2K_STATE_DECODING; -: 847: 33: 848: return j2k_decode_entry(im, state); call 0 returned 100% -: 849: } -: 850: #####: 851: if (state->state == J2K_STATE_DECODING) { branch 0 never executed branch 1 never executed #####: 852: state->errcode = IMAGING_CODEC_BROKEN; #####: 853: state->state = J2K_STATE_FAILED; #####: 854: return -1; -: 855: } -: 856: return -1; -: 857:} -: 858: -: 859:/* -------------------------------------------------------------------- */ -: 860:/* Cleanup */ -: 861:/* -------------------------------------------------------------------- */ -: 862: -: 863:int function ImagingJpeg2KDecodeCleanup called 67 returned 100% blocks executed 67% 67: 864:ImagingJpeg2KDecodeCleanup(ImagingCodecState state) { 67: 865: JPEG2KDECODESTATE *context = (JPEG2KDECODESTATE *)state->context; -: 866: 67: 867: if (context->error_msg) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 868: free ((void *)context->error_msg); -: 869: } -: 870: 67: 871: context->error_msg = NULL; -: 872: 67: 873: return -1; -: 874:} -: 875: -: 876:const char * function ImagingJpeg2KVersion called 3 returned 100% blocks executed 100% 3: 877:ImagingJpeg2KVersion(void) -: 878:{ 3: 879: return opj_version(); call 0 returned 100% -: 880:} -: 881: -: 882:#endif /* HAVE_OPENJPEG */ -: 883: -: 884:/* -: 885: * Local Variables: -: 886: * c-basic-offset: 4 -: 887: * End: -: 888: * -: 889: */ <<<<<< 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-aarch64-3.6/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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) { 160: 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#Quant.c.gcov -: 0:Source:src/libImaging/Quant.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Quant.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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 87% branch 3 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 92% branch 1 taken 8% (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% #####: 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 78% 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% #####: 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-aarch64-3.6/src/libImaging/Point.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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#Geometry.c.gcov -: 0:Source:src/libImaging/Geometry.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Geometry.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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 0% (fallthrough) branch 3 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 86% 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 0% (fallthrough) branch 3 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 0% (fallthrough) branch 3 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 0% (fallthrough) branch 3 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 0% (fallthrough) branch 3 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 0% (fallthrough) branch 3 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 0% (fallthrough) branch 3 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 0% (fallthrough) branch 3 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 87% 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 0% (fallthrough) branch 3 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 99% branch 9 taken 1% (fallthrough) branch 10 taken 99% branch 11 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 94% (fallthrough) branch 5 taken 6% branch 6 taken 86% (fallthrough) branch 7 taken 14% branch 8 taken 99% branch 9 taken 1% (fallthrough) branch 10 taken 98% branch 11 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 99% (fallthrough) branch 3 taken 1% branch 4 taken 99% (fallthrough) branch 5 taken 1% branch 6 taken 99% branch 7 taken 1% (fallthrough) branch 8 taken 99% branch 9 taken 1% -: 987: } else { 1070102: 988: AFFINE_TRANSFORM_FIXED(INT32, image32) branch 0 taken 97% (fallthrough) branch 1 taken 3% branch 2 taken 84% (fallthrough) branch 3 taken 16% branch 4 taken 74% (fallthrough) branch 5 taken 26% branch 6 taken 99% branch 7 taken 1% (fallthrough) branch 8 taken 99% branch 9 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 37% 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 0% (fallthrough) branch 3 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 -: 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 -: 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#_imagingmath.c.gcov -: 0:Source:src/_imagingmath.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/_imagingmath.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/_imagingmath.gcda -: 0:Runs:2 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * -: 4: * a simple math add-on for the Python Imaging Library -: 5: * -: 6: * history: -: 7: * 1999-02-15 fl Created -: 8: * 2005-05-05 fl Simplified and cleaned up for PIL 1.1.6 -: 9: * -: 10: * Copyright (c) 1999-2005 by Secret Labs AB -: 11: * Copyright (c) 2005 by Fredrik Lundh -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16:#include "Python.h" -: 17: -: 18:#include "libImaging/Imaging.h" -: 19: -: 20:#include "math.h" -: 21:#include "float.h" -: 22: -: 23:#define MAX_INT32 2147483647.0 -: 24:#define MIN_INT32 -2147483648.0 -: 25: -: 26:#define UNOP(name, op, type)\ -: 27:void name(Imaging out, Imaging im1)\ -: 28:{\ -: 29: int x, y;\ -: 30: for (y = 0; y < out->ysize; y++) {\ -: 31: type* p0 = (type*) out->image[y];\ -: 32: type* p1 = (type*) im1->image[y];\ -: 33: for (x = 0; x < out->xsize; x++) {\ -: 34: *p0 = op(type, *p1);\ -: 35: p0++; p1++;\ -: 36: }\ -: 37: }\ -: 38:} -: 39: -: 40:#define BINOP(name, op, type)\ -: 41:void name(Imaging out, Imaging im1, Imaging im2)\ -: 42:{\ -: 43: int x, y;\ -: 44: for (y = 0; y < out->ysize; y++) {\ -: 45: type* p0 = (type*) out->image[y];\ -: 46: type* p1 = (type*) im1->image[y];\ -: 47: type* p2 = (type*) im2->image[y];\ -: 48: for (x = 0; x < out->xsize; x++) {\ -: 49: *p0 = op(type, *p1, *p2);\ -: 50: p0++; p1++; p2++;\ -: 51: }\ -: 52: }\ -: 53:} -: 54: -: 55:#define NEG(type, v1) -(v1) -: 56:#define INVERT(type, v1) ~(v1) -: 57: -: 58:#define ADD(type, v1, v2) (v1)+(v2) -: 59:#define SUB(type, v1, v2) (v1)-(v2) -: 60:#define MUL(type, v1, v2) (v1)*(v2) -: 61: -: 62:#define MIN(type, v1, v2) ((v1)<(v2))?(v1):(v2) -: 63:#define MAX(type, v1, v2) ((v1)>(v2))?(v1):(v2) -: 64: -: 65:#define AND(type, v1, v2) (v1)&(v2) -: 66:#define OR(type, v1, v2) (v1)|(v2) -: 67:#define XOR(type, v1, v2) (v1)^(v2) -: 68:#define LSHIFT(type, v1, v2) (v1)<<(v2) -: 69:#define RSHIFT(type, v1, v2) (v1)>>(v2) -: 70: -: 71:#define ABS_I(type, v1) abs((v1)) -: 72:#define ABS_F(type, v1) fabs((v1)) -: 73: -: 74:/* -------------------------------------------------------------------- -: 75: * some day, we should add FPE protection mechanisms. see pyfpe.h for -: 76: * details. -: 77: * -: 78: * PyFPE_START_PROTECT("Error in foobar", return 0) -: 79: * PyFPE_END_PROTECT(result) -: 80: */ -: 81: -: 82:#define DIV_I(type, v1, v2) ((v2)!=0)?(v1)/(v2):0 -: 83:#define DIV_F(type, v1, v2) ((v2)!=0.0F)?(v1)/(v2):0.0F -: 84: -: 85:#define MOD_I(type, v1, v2) ((v2)!=0)?(v1)%(v2):0 -: 86:#define MOD_F(type, v1, v2) ((v2)!=0.0F)?fmod((v1),(v2)):0.0F -: 87: function powi called 2 returned 100% blocks executed 100% 2: 88:static int powi(int x, int y) -: 89:{ 2: 90: double v = pow(x, y) + 0.5; 2: 91: if (errno == EDOM) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 92: return 0; -: 93: } 2: 94: if (v < MIN_INT32) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 95: v = MIN_INT32; 2: 96: } else if (v > MAX_INT32) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1: 97: v = MAX_INT32; -: 98: } 2: 99: return (int) v; -: 100:} -: 101: -: 102:#define POW_I(type, v1, v2) powi(v1, v2) -: 103:#define POW_F(type, v1, v2) powf(v1, v2) /* FIXME: EDOM handling */ -: 104: -: 105:#define DIFF_I(type, v1, v2) abs((v1)-(v2)) -: 106:#define DIFF_F(type, v1, v2) fabs((v1)-(v2)) -: 107: -: 108:#define EQ(type, v1, v2) (v1)==(v2) -: 109:#define NE(type, v1, v2) (v1)!=(v2) -: 110:#define LT(type, v1, v2) (v1)<(v2) -: 111:#define LE(type, v1, v2) (v1)<=(v2) -: 112:#define GT(type, v1, v2) (v1)>(v2) -: 113:#define GE(type, v1, v2) (v1)>=(v2) -: 114: function abs_I called 1683 returned 100% blocks executed 100% 1683: 115:UNOP(abs_I, ABS_I, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function neg_I called 1 returned 100% blocks executed 100% 1: 116:UNOP(neg_I, NEG, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 117: function add_I called 9 returned 100% blocks executed 100% 9: 118:BINOP(add_I, ADD, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 94% branch 3 taken 6% (fallthrough) function sub_I called 1682 returned 100% blocks executed 100% 1682: 119:BINOP(sub_I, SUB, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function mul_I called 1 returned 100% blocks executed 100% 1: 120:BINOP(mul_I, MUL, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function div_I called 1 returned 100% blocks executed 100% 1: 121:BINOP(div_I, DIV_I, INT32) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) function mod_I called 6 returned 100% blocks executed 100% 6: 122:BINOP(mod_I, MOD_I, INT32) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) function pow_I called 2 returned 100% blocks executed 100% 2: 123:BINOP(pow_I, POW_I, INT32) call 0 returned 100% branch 1 taken 50% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 50% (fallthrough) function diff_I called 0 returned 0% blocks executed 0% #####: 124:BINOP(diff_I, DIFF_I, INT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 125: function invert_I called 3 returned 100% blocks executed 100% 3: 126:UNOP(invert_I, INVERT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function and_I called 4 returned 100% blocks executed 100% 4: 127:BINOP(and_I, AND, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function or_I called 4 returned 100% blocks executed 100% 4: 128:BINOP(or_I, OR, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function xor_I called 4 returned 100% blocks executed 100% 4: 129:BINOP(xor_I, XOR, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function lshift_I called 4 returned 100% blocks executed 100% 4: 130:BINOP(lshift_I, LSHIFT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function rshift_I called 4 returned 100% blocks executed 100% 4: 131:BINOP(rshift_I, RSHIFT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 132: function min_I called 1 returned 100% blocks executed 100% 1: 133:BINOP(min_I, MIN, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function max_I called 1 returned 100% blocks executed 100% 1: 134:BINOP(max_I, MAX, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 135: function eq_I called 12 returned 100% blocks executed 100% 12: 136:BINOP(eq_I, EQ, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function ne_I called 10 returned 100% blocks executed 100% 10: 137:BINOP(ne_I, NE, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function lt_I called 4 returned 100% blocks executed 100% 4: 138:BINOP(lt_I, LT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function le_I called 4 returned 100% blocks executed 100% 4: 139:BINOP(le_I, LE, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function gt_I called 4 returned 100% blocks executed 100% 4: 140:BINOP(gt_I, GT, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function ge_I called 4 returned 100% blocks executed 100% 4: 141:BINOP(ge_I, GE, INT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) -: 142: function abs_F called 19 returned 100% blocks executed 100% 19: 143:UNOP(abs_F, ABS_F, FLOAT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function neg_F called 0 returned 0% blocks executed 0% #####: 144:UNOP(neg_F, NEG, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 145: function add_F called 3 returned 100% blocks executed 100% 3: 146:BINOP(add_F, ADD, FLOAT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function sub_F called 20 returned 100% blocks executed 100% 20: 147:BINOP(sub_F, SUB, FLOAT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) function mul_F called 1 returned 100% blocks executed 100% 1: 148:BINOP(mul_F, MUL, FLOAT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function div_F called 1 returned 100% blocks executed 100% 1: 149:BINOP(div_F, DIV_F, FLOAT32) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 50% branch 3 taken 50% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) function mod_F called 0 returned 0% blocks executed 0% #####: 150:BINOP(mod_F, MOD_F, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function pow_F called 2 returned 100% blocks executed 100% 2: 151:BINOP(pow_F, POW_F, FLOAT32) branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 50% branch 3 taken 50% (fallthrough) function diff_F called 0 returned 0% blocks executed 0% #####: 152:BINOP(diff_F, DIFF_F, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 153: function min_F called 0 returned 0% blocks executed 0% #####: 154:BINOP(min_F, MIN, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function max_F called 0 returned 0% blocks executed 0% #####: 155:BINOP(max_F, MAX, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed -: 156: function eq_F called 0 returned 0% blocks executed 0% #####: 157:BINOP(eq_F, EQ, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function ne_F called 0 returned 0% blocks executed 0% #####: 158:BINOP(ne_F, NE, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function lt_F called 0 returned 0% blocks executed 0% #####: 159:BINOP(lt_F, LT, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function le_F called 0 returned 0% blocks executed 0% #####: 160:BINOP(le_F, LE, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function gt_F called 0 returned 0% blocks executed 0% #####: 161:BINOP(gt_F, GT, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed function ge_F called 0 returned 0% blocks executed 0% #####: 162:BINOP(ge_F, GE, FLOAT32) branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed -: 163: -: 164:static PyObject * function _unop called 1706 returned 100% blocks executed 100% 1706: 165:_unop(PyObject* self, PyObject* args) -: 166:{ -: 167: Imaging out; -: 168: Imaging im1; -: 169: void (*unop)(Imaging, Imaging); -: 170: -: 171: Py_ssize_t op, i0, i1; 1706: 172: if (!PyArg_ParseTuple(args, "nnn", &op, &i0, &i1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 173: return NULL; -: 174: } -: 175: 1706: 176: out = (Imaging) i0; 1706: 177: im1 = (Imaging) i1; -: 178: 1706: 179: unop = (void*) op; -: 180: 1706: 181: unop(out, im1); call 0 returned 100% -: 182: 1706: 183: Py_INCREF(Py_None); 1706: 184: return Py_None; -: 185:} -: 186: -: 187:static PyObject * function _binop called 1788 returned 100% blocks executed 100% 1788: 188:_binop(PyObject* self, PyObject* args) -: 189:{ -: 190: Imaging out; -: 191: Imaging im1; -: 192: Imaging im2; -: 193: void (*binop)(Imaging, Imaging, Imaging); -: 194: -: 195: Py_ssize_t op, i0, i1, i2; 1788: 196: if (!PyArg_ParseTuple(args, "nnnn", &op, &i0, &i1, &i2)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 197: return NULL; -: 198: } -: 199: 1788: 200: out = (Imaging) i0; 1788: 201: im1 = (Imaging) i1; 1788: 202: im2 = (Imaging) i2; -: 203: 1788: 204: binop = (void*) op; -: 205: 1788: 206: binop(out, im1, im2); call 0 returned 100% -: 207: 1788: 208: Py_INCREF(Py_None); 1788: 209: return Py_None; -: 210:} -: 211: -: 212:static PyMethodDef _functions[] = { -: 213: {"unop", _unop, 1}, -: 214: {"binop", _binop, 1}, -: 215: {NULL, NULL} -: 216:}; -: 217: -: 218:static void function install called 80 returned 100% blocks executed 78% 80: 219:install(PyObject *d, char* name, void* value) -: 220:{ 80: 221: PyObject *v = PyLong_FromSsize_t((Py_ssize_t) value); call 0 returned 100% 80: 222: if (!v || PyDict_SetItemString(d, name, v)) { branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 returned 100% branch 3 taken 0% (fallthrough) branch 4 taken 100% #####: 223: PyErr_Clear(); call 0 never executed -: 224: } 80: 225: Py_XDECREF(v); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% call 4 never executed 80: 226:} -: 227: -: 228:static int function setup_module called 2 returned 100% blocks executed 100% 2: 229:setup_module(PyObject* m) { 2: 230: PyObject* d = PyModule_GetDict(m); call 0 returned 100% -: 231: 2: 232: install(d, "abs_I", abs_I); call 0 returned 100% 2: 233: install(d, "neg_I", neg_I); call 0 returned 100% 2: 234: install(d, "add_I", add_I); call 0 returned 100% 2: 235: install(d, "sub_I", sub_I); call 0 returned 100% 2: 236: install(d, "diff_I", diff_I); call 0 returned 100% 2: 237: install(d, "mul_I", mul_I); call 0 returned 100% 2: 238: install(d, "div_I", div_I); call 0 returned 100% 2: 239: install(d, "mod_I", mod_I); call 0 returned 100% 2: 240: install(d, "min_I", min_I); call 0 returned 100% 2: 241: install(d, "max_I", max_I); call 0 returned 100% 2: 242: install(d, "pow_I", pow_I); call 0 returned 100% -: 243: 2: 244: install(d, "invert_I", invert_I); call 0 returned 100% 2: 245: install(d, "and_I", and_I); call 0 returned 100% 2: 246: install(d, "or_I", or_I); call 0 returned 100% 2: 247: install(d, "xor_I", xor_I); call 0 returned 100% 2: 248: install(d, "lshift_I", lshift_I); call 0 returned 100% 2: 249: install(d, "rshift_I", rshift_I); call 0 returned 100% -: 250: 2: 251: install(d, "eq_I", eq_I); call 0 returned 100% 2: 252: install(d, "ne_I", ne_I); call 0 returned 100% 2: 253: install(d, "lt_I", lt_I); call 0 returned 100% 2: 254: install(d, "le_I", le_I); call 0 returned 100% 2: 255: install(d, "gt_I", gt_I); call 0 returned 100% 2: 256: install(d, "ge_I", ge_I); call 0 returned 100% -: 257: 2: 258: install(d, "abs_F", abs_F); call 0 returned 100% 2: 259: install(d, "neg_F", neg_F); call 0 returned 100% 2: 260: install(d, "add_F", add_F); call 0 returned 100% 2: 261: install(d, "sub_F", sub_F); call 0 returned 100% 2: 262: install(d, "diff_F", diff_F); call 0 returned 100% 2: 263: install(d, "mul_F", mul_F); call 0 returned 100% 2: 264: install(d, "div_F", div_F); call 0 returned 100% 2: 265: install(d, "mod_F", mod_F); call 0 returned 100% 2: 266: install(d, "min_F", min_F); call 0 returned 100% 2: 267: install(d, "max_F", max_F); call 0 returned 100% 2: 268: install(d, "pow_F", pow_F); call 0 returned 100% -: 269: 2: 270: install(d, "eq_F", eq_F); call 0 returned 100% 2: 271: install(d, "ne_F", ne_F); call 0 returned 100% 2: 272: install(d, "lt_F", lt_F); call 0 returned 100% 2: 273: install(d, "le_F", le_F); call 0 returned 100% 2: 274: install(d, "gt_F", gt_F); call 0 returned 100% 2: 275: install(d, "ge_F", ge_F); call 0 returned 100% -: 276: 2: 277: return 0; -: 278:} -: 279: -: 280:PyMODINIT_FUNC function PyInit__imagingmath called 2 returned 100% blocks executed 100% 2: 281:PyInit__imagingmath(void) { -: 282: PyObject* m; -: 283: -: 284: static PyModuleDef module_def = { -: 285: PyModuleDef_HEAD_INIT, -: 286: "_imagingmath", /* m_name */ -: 287: NULL, /* m_doc */ -: 288: -1, /* m_size */ -: 289: _functions, /* m_methods */ -: 290: }; -: 291: 2: 292: m = PyModule_Create(&module_def); call 0 returned 100% -: 293: 2: 294: if (setup_module(m) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 295: return NULL; -: 296: } -: 297: 2: 298: return m; -: 299:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#GifDecode.c.gcov -: 0:Source:src/libImaging/GifDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/GifDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/GifDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * a fast, suspendable GIF decoder -: 6: * -: 7: * history: -: 8: * 95-09-03 fl Created -: 9: * 95-09-05 fl Fixed sign problem on 16-bit platforms -: 10: * 95-09-13 fl Added some storage shortcuts -: 11: * 96-03-28 fl Revised API, integrated with PIL -: 12: * 96-12-10 fl Added interlace support -: 13: * 96-12-16 fl Fixed premature termination bug introduced by last fix -: 14: * 97-01-05 fl Don't mess up on bogus configuration -: 15: * 97-01-17 fl Don't mess up on very small, interlaced files -: 16: * 99-02-07 fl Minor speedups -: 17: * -: 18: * Copyright (c) Secret Labs AB 1997-99. -: 19: * Copyright (c) Fredrik Lundh 1995-97. -: 20: * -: 21: * See the README file for information on usage and redistribution. -: 22: */ -: 23: -: 24: -: 25:#include "Imaging.h" -: 26: -: 27:#include -: 28:#include /* memcpy() */ -: 29: -: 30:#include "Gif.h" -: 31: -: 32: -: 33:#define NEWLINE(state, context) {\ -: 34: state->x = 0;\ -: 35: state->y += context->step;\ -: 36: while (state->y >= state->ysize)\ -: 37: switch (context->interlace) {\ -: 38: case 1:\ -: 39: context->repeat = state->y = 4;\ -: 40: context->interlace = 2;\ -: 41: break;\ -: 42: case 2:\ -: 43: context->step = 4;\ -: 44: context->repeat = state->y = 2;\ -: 45: context->interlace = 3;\ -: 46: break;\ -: 47: case 3:\ -: 48: context->step = 2;\ -: 49: context->repeat = state->y = 1;\ -: 50: context->interlace = 0;\ -: 51: break;\ -: 52: default:\ -: 53: return -1;\ -: 54: }\ -: 55: if (state->y < state->ysize) {\ -: 56: out = im->image8[state->y + state->yoff] + state->xoff;\ -: 57: }\ -: 58:} -: 59: -: 60: -: 61:int function ImagingGifDecode called 510 returned 100% blocks executed 90% 510: 62:ImagingGifDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_ssize_t bytes) -: 63:{ -: 64: UINT8* p; -: 65: UINT8* out; -: 66: int c, i; -: 67: int thiscode; 510: 68: GIFDECODERSTATE *context = (GIFDECODERSTATE*) state->context; -: 69: 510: 70: UINT8 *ptr = buffer; -: 71: 510: 72: if (!state->state) { branch 0 taken 95% (fallthrough) branch 1 taken 5% -: 73: -: 74: /* Initialise state */ 486: 75: if (context->bits < 0 || context->bits > 12) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 76: state->errcode = IMAGING_CODEC_CONFIG; #####: 77: return -1; -: 78: } -: 79: -: 80: /* Clear code */ 486: 81: context->clear = 1 << context->bits; -: 82: -: 83: /* End code */ 486: 84: context->end = context->clear + 1; -: 85: -: 86: /* Interlace */ 486: 87: if (context->interlace) { branch 0 taken 6% (fallthrough) branch 1 taken 94% 27: 88: context->interlace = 1; 27: 89: context->step = context->repeat = 8; -: 90: } else { 459: 91: context->step = 1; -: 92: } -: 93: 486: 94: state->state = 1; -: 95: } -: 96: 510: 97: out = im->image8[state->y + state->yoff] + state->xoff + state->x; -: 98: -: 99: for (;;) { -: 100: 6809997: 101: if (state->state == 1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 102: -: 103: /* First free entry in table */ 9783: 104: context->next = context->clear + 2; -: 105: -: 106: /* Initial code size */ 9783: 107: context->codesize = context->bits + 1; 9783: 108: context->codemask = (1 << context->codesize) - 1; -: 109: -: 110: /* Buffer pointer. We fill the buffer from right, which -: 111: allows us to return all of it in one operation. */ 9783: 112: context->bufferindex = GIFBUFFER; -: 113: 9783: 114: state->state = 2; -: 115: } -: 116: 6809997: 117: if (context->bufferindex < GIFBUFFER) { branch 0 taken 68% (fallthrough) branch 1 taken 32% -: 118: -: 119: /* Return whole buffer in one chunk */ 2205813: 120: i = GIFBUFFER - context->bufferindex; 2205813: 121: p = &context->buffer[context->bufferindex]; -: 122: 2205813: 123: context->bufferindex = GIFBUFFER; -: 124: -: 125: } else { -: 126: -: 127: /* Get current symbol */ -: 128: 10483769: 129: while (context->bitcount < context->codesize) { branch 0 taken 56% branch 1 taken 44% (fallthrough) -: 130: 5879609: 131: if (context->blocksize > 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 132: -: 133: /* Read next byte */ 5856384: 134: c = *ptr++; bytes--; -: 135: 5856384: 136: context->blocksize--; -: 137: -: 138: /* New bits are shifted in from from the left. */ 5856384: 139: context->bitbuffer |= (INT32) c << context->bitcount; 5856384: 140: context->bitcount += 8; -: 141: -: 142: } else { -: 143: -: 144: /* New GIF block */ -: 145: -: 146: /* We don't start decoding unless we have a full block */ 23225: 147: if (bytes < 1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 24: 148: return ptr - buffer; -: 149: } 23201: 150: c = *ptr; 23201: 151: if (bytes < c+1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 152: return ptr - buffer; -: 153: } -: 154: 23201: 155: context->blocksize = c; -: 156: 23201: 157: ptr++; bytes--; -: 158: -: 159: } -: 160: } -: 161: -: 162: /* Extract current symbol from bit buffer. */ 4604160: 163: c = (int) context->bitbuffer & context->codemask; -: 164: -: 165: /* Adjust buffer */ 4604160: 166: context->bitbuffer >>= context->codesize; 4604160: 167: context->bitcount -= context->codesize; -: 168: -: 169: /* If c is less than "clear", it's a data byte. Otherwise, -: 170: it's either clear/end or a code symbol which should be -: 171: expanded. */ -: 172: 4604160: 173: if (c == context->clear) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 9783: 174: if (state->state != 2) { branch 0 taken 95% (fallthrough) branch 1 taken 5% 9297: 175: state->state = 1; -: 176: } 9783: 177: continue; -: 178: } -: 179: 4594377: 180: if (c == context->end) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 181: break; -: 182: } -: 183: 4594377: 184: i = 1; 4594377: 185: p = &context->lastdata; -: 186: 4594377: 187: if (state->state == 2) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 188: -: 189: /* First valid symbol after clear; use as is */ 9783: 190: if (c > context->clear) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 191: state->errcode = IMAGING_CODEC_BROKEN; #####: 192: return -1; -: 193: } -: 194: 9783: 195: context->lastdata = context->lastcode = c; 9783: 196: state->state = 3; -: 197: -: 198: } else { -: 199: 4584594: 200: thiscode = c; -: 201: 4584594: 202: if (c > context->next) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 203: state->errcode = IMAGING_CODEC_BROKEN; #####: 204: return -1; -: 205: } -: 206: 4584594: 207: if (c == context->next) { branch 0 taken 20% (fallthrough) branch 1 taken 80% -: 208: -: 209: /* c == next is allowed. not sure why. */ -: 210: 911296: 211: if (context->bufferindex <= 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 212: state->errcode = IMAGING_CODEC_BROKEN; #####: 213: return -1; -: 214: } -: 215: 1822592: 216: context->buffer[--context->bufferindex] = 911296: 217: context->lastdata; -: 218: 911296: 219: c = context->lastcode; -: 220: -: 221: } -: 222: 25251852: 223: while (c >= context->clear) { branch 0 taken 82% branch 1 taken 18% (fallthrough) -: 224: -: 225: /* Copy data string to buffer (beginning from right) */ -: 226: 20667258: 227: if (context->bufferindex <= 0 || c >= GIFTABLE) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 228: state->errcode = IMAGING_CODEC_BROKEN; #####: 229: return -1; -: 230: } -: 231: 41334516: 232: context->buffer[--context->bufferindex] = 20667258: 233: context->data[c]; -: 234: 20667258: 235: c = context->link[c]; -: 236: } -: 237: 4584594: 238: context->lastdata = c; -: 239: 4584594: 240: if (context->next < GIFTABLE) { branch 0 taken 82% (fallthrough) branch 1 taken 18% -: 241: -: 242: /* We'll only add this symbol if we have room -: 243: for it (take advise, Netscape!) */ 3741932: 244: context->data[context->next] = c; 3741932: 245: context->link[context->next] = context->lastcode; -: 246: 3741932: 247: if (context->next == context->codemask && branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 92% (fallthrough) branch 3 taken 8% -: 248: context->codesize < GIFBITS) { -: 249: -: 250: /* Expand code size */ 1566: 251: context->codesize++; 1566: 252: context->codemask = (1 << context->codesize) - 1; -: 253: } -: 254: 3741932: 255: context->next++; -: 256: -: 257: } -: 258: 4584594: 259: context->lastcode = thiscode; -: 260: -: 261: } -: 262: } -: 263: -: 264: /* Copy the bytes into the image */ 6800190: 265: if (state->y >= state->ysize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 266: state->errcode = IMAGING_CODEC_OVERRUN; #####: 267: return -1; -: 268: } -: 269: -: 270: /* To squeeze some extra pixels out of this loop, we test for -: 271: some common cases and handle them separately. */ -: 272: -: 273: /* FIXME: should we handle the transparency index in here??? */ -: 274: 6800190: 275: if (i == 1) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 5486134: 276: if (state->x < state->xsize-1) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 277: /* Single pixel, not at the end of the line. */ 5467095: 278: *out++ = p[0]; 5467095: 279: state->x++; 5467095: 280: continue; -: 281: } 1314056: 282: } else if (state->x + i <= state->xsize) { branch 0 taken 5% (fallthrough) branch 1 taken 95% -: 283: /* This string fits into current line. */ 2485966: 284: memcpy(out, p, i); 1242983: 285: out += i; 1242983: 286: state->x += i; 1242983: 287: if (state->x == state->xsize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 5334: 288: NEWLINE(state, context); branch 0 taken 1% branch 1 taken 1% branch 2 taken 1% branch 3 taken 99% branch 4 taken 7% branch 5 taken 93% (fallthrough) branch 6 taken 100% (fallthrough) branch 7 taken 0% -: 289: } 1242589: 290: continue; -: 291: } -: 292: -: 293: /* No shortcut, copy pixel by pixel */ 8347184: 294: for (c = 0; c < i; c++) { branch 0 taken 1% branch 1 taken 99% 8347276: 295: *out++ = p[c]; 8347276: 296: if (++state->x >= state->xsize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 90310: 297: NEWLINE(state, context); branch 0 taken 15% branch 1 taken 15% branch 2 taken 15% branch 3 taken 55% branch 4 taken 1% branch 5 taken 99% (fallthrough) branch 6 taken 100% (fallthrough) branch 7 taken 0% -: 298: } -: 299: } -: 300: } -: 301: #####: 302: return ptr - buffer; -: 303:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#PcdDecode.c.gcov -: 0:Source:src/libImaging/PcdDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/PcdDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/PcdDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for uncompressed PCD image data. -: 6: * -: 7: * history: -: 8: * 96-05-10 fl Created -: 9: * 96-05-18 fl New tables -: 10: * 97-01-25 fl Use PhotoYCC unpacker -: 11: * -: 12: * notes: -: 13: * This driver supports uncompressed PCD modes only -: 14: * (resolutions up to 768x512). -: 15: * -: 16: * Copyright (c) Fredrik Lundh 1996-97. -: 17: * Copyright (c) Secret Labs AB 1997. -: 18: * -: 19: * See the README file for information on usage and redistribution. -: 20: */ -: 21: -: 22: -: 23:#include "Imaging.h" -: 24: -: 25: -: 26:int function ImagingPcdDecode called 9 returned 100% blocks executed 100% 9: 27:ImagingPcdDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 28:{ -: 29: int x; -: 30: int chunk; -: 31: UINT8* out; -: 32: UINT8* ptr; -: 33: 9: 34: ptr = buf; -: 35: 9: 36: chunk = 3 * state->xsize; -: 37: -: 38: for (;;) { -: 39: -: 40: /* We need data for two full lines before we can do anything */ 264: 41: if (bytes < chunk) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 8: 42: return ptr - buf; -: 43: } -: 44: -: 45: /* Unpack first line */ 256: 46: out = state->buffer; 196864: 47: for (x = 0; x < state->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 196608: 48: out[0] = ptr[x]; 196608: 49: out[1] = ptr[(x+4*state->xsize)/2]; 196608: 50: out[2] = ptr[(x+5*state->xsize)/2]; 196608: 51: out += 3; -: 52: } -: 53: 512: 54: state->shuffle((UINT8*) im->image[state->y], call 0 returned 100% 256: 55: state->buffer, state->xsize); -: 56: 256: 57: if (++state->y >= state->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 58: return -1; /* This can hardly happen */ -: 59: } -: 60: -: 61: /* Unpack second line */ 256: 62: out = state->buffer; 196864: 63: for (x = 0; x < state->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 196608: 64: out[0] = ptr[x+state->xsize]; 196608: 65: out[1] = ptr[(x+4*state->xsize)/2]; 196608: 66: out[2] = ptr[(x+5*state->xsize)/2]; 196608: 67: out += 3; -: 68: } -: 69: 512: 70: state->shuffle((UINT8*) im->image[state->y], call 0 returned 100% 256: 71: state->buffer, state->xsize); -: 72: 256: 73: if (++state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 74: return -1; -: 75: } -: 76: 255: 77: ptr += chunk; 255: 78: bytes -= chunk; -: 79: 255: 80: } -: 81:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#BcnDecode.c.gcov -: 0:Source:src/libImaging/BcnDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/BcnDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/BcnDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * -: 4: * decoder for DXTn-compressed data -: 5: * -: 6: * Format documentation: -: 7: * https://web.archive.org/web/20170802060935/http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_s3tc.txt -: 8: * -: 9: * The contents of this file are in the public domain (CC0) -: 10: * Full text of the CC0 license: -: 11: * https://creativecommons.org/publicdomain/zero/1.0/ -: 12: */ -: 13: -: 14: -: 15:#include "Imaging.h" -: 16: -: 17: -: 18:typedef struct { -: 19: UINT8 r, g, b, a; -: 20:} rgba; -: 21: -: 22:typedef struct { -: 23: UINT8 l; -: 24:} lum; -: 25: -: 26:typedef struct { -: 27: FLOAT32 r, g, b; -: 28:} rgb32f; -: 29: -: 30:typedef struct { -: 31: UINT16 c0, c1; -: 32: UINT32 lut; -: 33:} bc1_color; -: 34: -: 35:typedef struct { -: 36: UINT8 a0, a1; -: 37: UINT8 lut[6]; -: 38:} bc3_alpha; -: 39: -: 40:#define LOAD16(p) \ -: 41: (p)[0] | ((p)[1] << 8) -: 42: -: 43:#define LOAD32(p) \ -: 44: (p)[0] | ((p)[1] << 8) | ((p)[2] << 16) | ((p)[3] << 24) -: 45: -: 46:static void bc1_color_load(bc1_color *dst, const UINT8 *src) { 17401: 47: dst->c0 = LOAD16(src); 17401: 48: dst->c1 = LOAD16(src + 2); 17401: 49: dst->lut = LOAD32(src + 4); -: 50:} -: 51: -: 52:static void bc3_alpha_load(bc3_alpha *dst, const UINT8 *src) { -: 53: memcpy(dst, src, sizeof(bc3_alpha)); -: 54:} -: 55: -: 56:static rgba decode_565(UINT16 x) { -: 57: rgba c; -: 58: int r, g, b; 34802: 59: r = (x & 0xf800) >> 8; 34802: 60: r |= r >> 5; 34802: 61: c.r = r; 34802: 62: g = (x & 0x7e0) >> 3; 34802: 63: g |= g >> 6; 34802: 64: c.g = g; 34802: 65: b = (x & 0x1f) << 3; 34802: 66: b |= b >> 5; 34802: 67: c.b = b; 34802: 68: c.a = 0xff; -: 69: return c; -: 70:} -: 71: function decode_bc1_color called 17401 returned 100% blocks executed 100% 17401: 72:static void decode_bc1_color(rgba *dst, const UINT8 *src) { -: 73: bc1_color col; -: 74: rgba p[4]; -: 75: int n, cw; -: 76: UINT16 r0, g0, b0, r1, g1, b1; 17401: 77: bc1_color_load(&col, src); -: 78: 34802: 79: p[0] = decode_565(col.c0); 17401: 80: r0 = p[0].r; 17401: 81: g0 = p[0].g; 17401: 82: b0 = p[0].b; 34802: 83: p[1] = decode_565(col.c1); 17401: 84: r1 = p[1].r; 17401: 85: g1 = p[1].g; 17401: 86: b1 = p[1].b; 17401: 87: if (col.c0 > col.c1) { branch 0 taken 89% (fallthrough) branch 1 taken 11% 15466: 88: p[2].r = (2*r0 + 1*r1) / 3; 15466: 89: p[2].g = (2*g0 + 1*g1) / 3; 15466: 90: p[2].b = (2*b0 + 1*b1) / 3; 15466: 91: p[2].a = 0xff; 15466: 92: p[3].r = (1*r0 + 2*r1) / 3; 15466: 93: p[3].g = (1*g0 + 2*g1) / 3; 15466: 94: p[3].b = (1*b0 + 2*b1) / 3; 15466: 95: p[3].a = 0xff; -: 96: } else { 1935: 97: p[2].r = (r0 + r1) / 2; 1935: 98: p[2].g = (g0 + g1) / 2; 1935: 99: p[2].b = (b0 + b1) / 2; 1935: 100: p[2].a = 0xff; 1935: 101: p[3].r = 0; 1935: 102: p[3].g = 0; 1935: 103: p[3].b = 0; 1935: 104: p[3].a = 0; -: 105: } 278416: 106: for (n = 0; n < 16; n++) { branch 0 taken 94% branch 1 taken 6% (fallthrough) 278416: 107: cw = 3 & (col.lut >> (2 * n)); 278416: 108: dst[n] = p[cw]; -: 109: } 17401: 110:} -: 111: function decode_bc3_alpha called 8185 returned 100% blocks executed 100% 8185: 112:static void decode_bc3_alpha(char *dst, const UINT8 *src, int stride, int o) { -: 113: bc3_alpha b; -: 114: UINT16 a0, a1; -: 115: UINT8 a[8]; -: 116: int n, lut, aw; 8185: 117: bc3_alpha_load(&b, src); -: 118: 8185: 119: a0 = b.a0; 8185: 120: a1 = b.a1; 8185: 121: a[0] = (UINT8)a0; 8185: 122: a[1] = (UINT8)a1; 8185: 123: if (a0 > a1) { branch 0 taken 87% (fallthrough) branch 1 taken 13% 7087: 124: a[2] = (6*a0 + 1*a1) / 7; 7087: 125: a[3] = (5*a0 + 2*a1) / 7; 7087: 126: a[4] = (4*a0 + 3*a1) / 7; 7087: 127: a[5] = (3*a0 + 4*a1) / 7; 7087: 128: a[6] = (2*a0 + 5*a1) / 7; 7087: 129: a[7] = (1*a0 + 6*a1) / 7; -: 130: } else { 1098: 131: a[2] = (4*a0 + 1*a1) / 5; 1098: 132: a[3] = (3*a0 + 2*a1) / 5; 1098: 133: a[4] = (2*a0 + 3*a1) / 5; 1098: 134: a[5] = (1*a0 + 4*a1) / 5; 1098: 135: a[6] = 0; 1098: 136: a[7] = 0xff; -: 137: } 8185: 138: lut = b.lut[0] | (b.lut[1] << 8) | (b.lut[2] << 16); 73665: 139: for (n = 0; n < 8; n++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 65480: 140: aw = 7 & (lut >> (3 * n)); 65480: 141: dst[stride * n + o] = a[aw]; -: 142: } 8185: 143: lut = b.lut[3] | (b.lut[4] << 8) | (b.lut[5] << 16); 73665: 144: for (n = 0; n < 8; n++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 65480: 145: aw = 7 & (lut >> (3 * n)); 65480: 146: dst[stride * (8+n) + o] = a[aw]; -: 147: } 8185: 148:} -: 149: -: 150:static void decode_bc1_block(rgba *col, const UINT8* src) { 5120: 151: decode_bc1_color(col, src); call 0 returned 100% -: 152:} -: 153: function decode_bc2_block called 4096 returned 100% blocks executed 100% 4096: 154:static void decode_bc2_block(rgba *col, const UINT8* src) { -: 155: int n, bitI, byI, av; 4096: 156: decode_bc1_color(col, src + 8); 69632: 157: for (n = 0; n < 16; n++) { call 0 returned 100% branch 1 taken 94% branch 2 taken 6% (fallthrough) 65536: 158: bitI = n * 4; 65536: 159: byI = bitI >> 3; 65536: 160: av = 0xf & (src[byI] >> (bitI & 7)); 65536: 161: av = (av << 4) | av; 65536: 162: col[n].a = av; -: 163: } 4096: 164:} -: 165: function decode_bc3_block called 8185 returned 100% blocks executed 100% 8185: 166:static void decode_bc3_block(rgba *col, const UINT8* src) { 8185: 167: decode_bc1_color(col, src + 8); call 0 returned 100% 8185: 168: decode_bc3_alpha((char *)col, src, sizeof(col[0]), 3); call 0 returned 100% 8185: 169:} -: 170: -: 171:static void decode_bc4_block(lum *col, const UINT8* src) { #####: 172: decode_bc3_alpha((char *)col, src, sizeof(col[0]), 0); call 0 never executed -: 173:} -: 174: function decode_bc5_block called 0 returned 0% blocks executed 0% #####: 175:static void decode_bc5_block(rgba *col, const UINT8* src) { #####: 176: decode_bc3_alpha((char *)col, src, sizeof(col[0]), 0); call 0 never executed #####: 177: decode_bc3_alpha((char *)col, src + 8, sizeof(col[0]), 1); call 0 never executed #####: 178:} -: 179: -: 180:/* BC6 and BC7 are described here: -: 181: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_texture_compression_bptc.txt */ -: 182: -: 183:static UINT8 get_bit(const UINT8* src, int bit) { #####: 184: int by = bit >> 3; #####: 185: bit &= 7; #####: 186: return (src[by] >> bit) & 1; -: 187:} -: 188: function get_bits called 134464 returned 100% blocks executed 100% 134464: 189:static UINT8 get_bits(const UINT8* src, int bit, int count) { -: 190: UINT8 v; -: 191: int x; 142900: 192: int by = bit >> 3; 142900: 193: bit &= 7; 134464: 194: if (!count) { branch 0 taken 94% (fallthrough) branch 1 taken 6% -: 195: return 0; -: 196: } 134353: 197: if (bit + count <= 8) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 69% (fallthrough) branch 5 taken 31% 95205: 198: v = (src[by] >> bit) & ((1 << count) - 1); -: 199: } else { 39148: 200: x = src[by] | (src[by+1] << 8); 39148: 201: v = (x >> bit) & ((1 << count) - 1); -: 202: } -: 203: return v; -: 204:} -: 205: -: 206:/* BC7 */ -: 207:typedef struct { -: 208: char ns; -: 209: char pb; -: 210: char rb; -: 211: char isb; -: 212: char cb; -: 213: char ab; -: 214: char epb; -: 215: char spb; -: 216: char ib; -: 217: char ib2; -: 218:} bc7_mode_info; -: 219: -: 220:static const bc7_mode_info bc7_modes[] = { -: 221: {3, 4, 0, 0, 4, 0, 1, 0, 3, 0}, -: 222: {2, 6, 0, 0, 6, 0, 0, 1, 3, 0}, -: 223: {3, 6, 0, 0, 5, 0, 0, 0, 2, 0}, -: 224: {2, 6, 0, 0, 7, 0, 1, 0, 2, 0}, -: 225: {1, 0, 2, 1, 5, 6, 0, 0, 2, 3}, -: 226: {1, 0, 2, 0, 7, 8, 0, 0, 2, 2}, -: 227: {1, 0, 0, 0, 7, 7, 1, 0, 4, 0}, -: 228: {2, 6, 0, 0, 5, 5, 1, 0, 2, 0} -: 229:}; -: 230: -: 231:/* Subset indices: -: 232: Table.P2, 1 bit per index */ -: 233:static const UINT16 bc7_si2[] = { -: 234: 0xcccc, 0x8888, 0xeeee, 0xecc8, 0xc880, 0xfeec, 0xfec8, 0xec80, -: 235: 0xc800, 0xffec, 0xfe80, 0xe800, 0xffe8, 0xff00, 0xfff0, 0xf000, -: 236: 0xf710, 0x008e, 0x7100, 0x08ce, 0x008c, 0x7310, 0x3100, 0x8cce, -: 237: 0x088c, 0x3110, 0x6666, 0x366c, 0x17e8, 0x0ff0, 0x718e, 0x399c, -: 238: 0xaaaa, 0xf0f0, 0x5a5a, 0x33cc, 0x3c3c, 0x55aa, 0x9696, 0xa55a, -: 239: 0x73ce, 0x13c8, 0x324c, 0x3bdc, 0x6996, 0xc33c, 0x9966, 0x0660, -: 240: 0x0272, 0x04e4, 0x4e40, 0x2720, 0xc936, 0x936c, 0x39c6, 0x639c, -: 241: 0x9336, 0x9cc6, 0x817e, 0xe718, 0xccf0, 0x0fcc, 0x7744, 0xee22}; -: 242: -: 243:/* Table.P3, 2 bits per index */ -: 244:static const UINT32 bc7_si3[] = { -: 245: 0xaa685050, 0x6a5a5040, 0x5a5a4200, 0x5450a0a8, -: 246: 0xa5a50000, 0xa0a05050, 0x5555a0a0, 0x5a5a5050, -: 247: 0xaa550000, 0xaa555500, 0xaaaa5500, 0x90909090, -: 248: 0x94949494, 0xa4a4a4a4, 0xa9a59450, 0x2a0a4250, -: 249: 0xa5945040, 0x0a425054, 0xa5a5a500, 0x55a0a0a0, -: 250: 0xa8a85454, 0x6a6a4040, 0xa4a45000, 0x1a1a0500, -: 251: 0x0050a4a4, 0xaaa59090, 0x14696914, 0x69691400, -: 252: 0xa08585a0, 0xaa821414, 0x50a4a450, 0x6a5a0200, -: 253: 0xa9a58000, 0x5090a0a8, 0xa8a09050, 0x24242424, -: 254: 0x00aa5500, 0x24924924, 0x24499224, 0x50a50a50, -: 255: 0x500aa550, 0xaaaa4444, 0x66660000, 0xa5a0a5a0, -: 256: 0x50a050a0, 0x69286928, 0x44aaaa44, 0x66666600, -: 257: 0xaa444444, 0x54a854a8, 0x95809580, 0x96969600, -: 258: 0xa85454a8, 0x80959580, 0xaa141414, 0x96960000, -: 259: 0xaaaa1414, 0xa05050a0, 0xa0a5a5a0, 0x96000000, -: 260: 0x40804080, 0xa9a8a9a8, 0xaaaaaa44, 0x2a4a5254}; -: 261: -: 262:/* Anchor indices: -: 263: Table.A2 */ -: 264:static const char bc7_ai0[] = { -: 265: 15,15,15,15,15,15,15,15, -: 266: 15,15,15,15,15,15,15,15, -: 267: 15, 2, 8, 2, 2, 8, 8,15, -: 268: 2, 8, 2, 2, 8, 8, 2, 2, -: 269: 15,15, 6, 8, 2, 8,15,15, -: 270: 2, 8, 2, 2, 2,15,15, 6, -: 271: 6, 2, 6, 8,15,15, 2, 2, -: 272: 15,15,15,15,15, 2, 2,15}; -: 273: -: 274:/* Table.A3a */ -: 275:static const char bc7_ai1[] = { -: 276: 3, 3,15,15, 8, 3,15,15, -: 277: 8, 8, 6, 6, 6, 5, 3, 3, -: 278: 3, 3, 8,15, 3, 3, 6,10, -: 279: 5, 8, 8, 6, 8, 5,15,15, -: 280: 8,15, 3, 5, 6,10, 8,15, -: 281: 15, 3,15, 5,15,15,15,15, -: 282: 3,15, 5, 5, 5, 8, 5,10, -: 283: 5,10, 8,13,15,12, 3, 3}; -: 284: -: 285:/* Table.A3b */ -: 286:static const char bc7_ai2[] = { -: 287: 15, 8, 8, 3,15,15, 3, 8, -: 288: 15,15,15,15,15,15,15, 8, -: 289: 15, 8,15, 3,15, 8,15, 8, -: 290: 3,15, 6,10,15,15,10, 8, -: 291: 15, 3,15,10,10, 8, 9,10, -: 292: 6,15, 8,15, 3, 6, 6, 8, -: 293: 15, 3,15,15,15,15,15,15, -: 294: 15,15,15,15, 3,15,15, 8}; -: 295: -: 296:/* Interpolation weights */ -: 297:static const char bc7_weights2[] = {0, 21, 43, 64}; -: 298:static const char bc7_weights3[] = {0, 9, 18, 27, 37, 46, 55, 64}; -: 299:static const char bc7_weights4[] = { -: 300: 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64}; -: 301: -: 302:static const char *bc7_get_weights(int n) { 8224: 303: if (n == 2) { branch 0 never executed branch 1 never executed branch 2 taken 72% (fallthrough) branch 3 taken 28% branch 4 taken 87% (fallthrough) branch 5 taken 13% -: 304: return bc7_weights2; -: 305: } 6562: 306: if (n == 3) { branch 0 never executed branch 1 never executed branch 2 taken 32% (fallthrough) branch 3 taken 68% branch 4 taken 26% (fallthrough) branch 5 taken 74% -: 307: return bc7_weights3; -: 308: } -: 309: return bc7_weights4; -: 310:} -: 311: -: 312:static int bc7_get_subset(int ns, int partition, int n) { 65792: 313: if (ns == 2) { branch 0 never executed branch 1 never executed branch 2 taken 52% (fallthrough) branch 3 taken 48% 34528: 314: return 1 & (bc7_si2[partition] >> n); -: 315: } 31264: 316: if (ns == 3) { branch 0 never executed branch 1 never executed branch 2 taken 13% (fallthrough) branch 3 taken 87% 3968: 317: return 3 & (bc7_si3[partition] >> (2 * n)); -: 318: } -: 319: return 0; -: 320:} -: 321: -: 322:static UINT8 expand_quantized(UINT8 v, int bits) { 44096: 323: v = v << (8 - bits); 44096: 324: return v | (v >> bits); -: 325:} -: 326: function bc7_lerp called 65792 returned 100% blocks executed 100% 65792: 327:static void bc7_lerp(rgba *dst, const rgba *e, int s0, int s1) { 65792: 328: int t0 = 64 - s0; 65792: 329: int t1 = 64 - s1; 65792: 330: dst->r = (UINT8)((t0 * e[0].r + s0 * e[1].r + 32) >> 6); 65792: 331: dst->g = (UINT8)((t0 * e[0].g + s0 * e[1].g + 32) >> 6); 65792: 332: dst->b = (UINT8)((t0 * e[0].b + s0 * e[1].b + 32) >> 6); 65792: 333: dst->a = (UINT8)((t1 * e[0].a + s1 * e[1].a + 32) >> 6); 65792: 334:} -: 335: function decode_bc7_block called 4112 returned 100% blocks executed 92% 4112: 336:static void decode_bc7_block(rgba *col, const UINT8* src) { -: 337: rgba endpoints[6]; 4112: 338: int bit = 0, cibit, aibit; 4112: 339: int mode = src[0]; -: 340: int i, j; -: 341: int numep, cb, ab, ib, ib2, i0, i1, s; -: 342: UINT8 index_sel, partition, rotation, val; -: 343: const char *cw, *aw; -: 344: const bc7_mode_info *info; -: 345: -: 346: /* mode is the number of unset bits before the first set bit: */ 4112: 347: if (!mode) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 348: /* degenerate case when no bits set */ #####: 349: for (i = 0; i < 16; i++) { branch 0 never executed branch 1 never executed #####: 350: col[i].r = col[i].g = col[i].b = 0; #####: 351: col[i].a = 255; -: 352: } #####: 353: return; -: 354: } 15961: 355: while (!(mode & (1 << bit++))) ; branch 0 taken 74% branch 1 taken 26% (fallthrough) 4112: 356: mode = bit - 1; 4112: 357: info = &bc7_modes[mode]; -: 358: /* color selection bits: {subset}{endpoint} */ 4112: 359: cb = info->cb; 4112: 360: ab = info->ab; 8224: 361: cw = bc7_get_weights(info->ib); 8224: 362: aw = bc7_get_weights((ab && info->ib2) ? info->ib2 : info->ib); branch 0 taken 42% (fallthrough) branch 1 taken 58% branch 2 taken 44% (fallthrough) branch 3 taken 56% -: 363: -: 364:#define LOAD(DST, N) \ -: 365: DST = get_bits(src, bit, N); \ -: 366: bit += N; 4112: 367: LOAD(partition, info->pb); call 0 returned 100% 4112: 368: LOAD(rotation, info->rb); call 0 returned 100% 4112: 369: LOAD(index_sel, info->isb); call 0 returned 100% 4112: 370: numep = info->ns << 1; -: 371: -: 372: /* red */ 17644: 373: for (i = 0; i < numep; i++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 13532: 374: LOAD(val, cb); call 0 returned 100% 13532: 375: endpoints[i].r = val; -: 376: } -: 377: -: 378: /* green */ 13532: 379: for (i = 0; i < numep; i++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 13532: 380: LOAD(val, cb); call 0 returned 100% 13532: 381: endpoints[i].g = val; -: 382: } -: 383: -: 384: /* blue */ 13532: 385: for (i = 0; i < numep; i++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 13532: 386: LOAD(val, cb); call 0 returned 100% 13532: 387: endpoints[i].b = val; -: 388: } -: 389: -: 390: /* alpha */ 13532: 391: for (i = 0; i < numep; i++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 13532: 392: if (ab) { branch 0 taken 26% (fallthrough) branch 1 taken 74% 3500: 393: LOAD(val, ab); call 0 returned 100% -: 394: } else { -: 395: val = 255; -: 396: } 13532: 397: endpoints[i].a = val; -: 398: } -: 399: -: 400: /* p-bits */ -: 401:#define ASSIGN_P(x) x = (x << 1) | val 4112: 402: if (info->epb) { branch 0 taken 38% (fallthrough) branch 1 taken 62% -: 403: /* per endpoint */ 1564: 404: cb++; 1564: 405: if (ab) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 963: 406: ab++; -: 407: } 6434: 408: for (i = 0; i < numep; i++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 4870: 409: LOAD(val, 1); 4870: 410: ASSIGN_P(endpoints[i].r); 4870: 411: ASSIGN_P(endpoints[i].g); 4870: 412: ASSIGN_P(endpoints[i].b); 4870: 413: if (ab) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 1970: 414: ASSIGN_P(endpoints[i].a); -: 415: } -: 416: } -: 417: } 4112: 418: if (info->spb) { branch 0 taken 43% (fallthrough) branch 1 taken 57% -: 419: /* per subset */ 1783: 420: cb++; 1783: 421: if (ab) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 422: ab++; -: 423: } 5349: 424: for (i = 0; i < numep; i+=2) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 3566: 425: LOAD(val, 1); 10698: 426: for (j = 0; j < 2; j++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 7132: 427: ASSIGN_P(endpoints[i+j].r); 7132: 428: ASSIGN_P(endpoints[i+j].g); 7132: 429: ASSIGN_P(endpoints[i+j].b); 7132: 430: if (ab) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 431: ASSIGN_P(endpoints[i+j].a); -: 432: } -: 433: } -: 434: } -: 435: } -: 436:#undef ASSIGN_P -: 437:#define EXPAND(x, b) x = expand_quantized(x, b) 17644: 438: for (i = 0; i < numep; i++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 27064: 439: EXPAND(endpoints[i].r, cb); 27064: 440: EXPAND(endpoints[i].g, cb); 27064: 441: EXPAND(endpoints[i].b, cb); 13532: 442: if (ab) { branch 0 taken 26% (fallthrough) branch 1 taken 74% 7000: 443: EXPAND(endpoints[i].a, ab); -: 444: } -: 445: } -: 446:#undef EXPAND -: 447:#undef LOAD 4112: 448: cibit = bit; 4112: 449: aibit = cibit + 16 * info->ib - info->ns; 69904: 450: for (i = 0; i < 16; i++) { branch 0 taken 94% branch 1 taken 6% (fallthrough) 131584: 451: s = bc7_get_subset(info->ns, partition, i) << 1; 65792: 452: ib = info->ib; 65792: 453: if (i == 0) { branch 0 taken 6% (fallthrough) branch 1 taken 94% 4112: 454: ib--; 61680: 455: } else if (info->ns == 2) { branch 0 taken 52% (fallthrough) branch 1 taken 48% 32370: 456: if (i == bc7_ai0[partition]) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 2158: 457: ib--; -: 458: } 29310: 459: } else if (info->ns == 3) { branch 0 taken 13% (fallthrough) branch 1 taken 87% 3720: 460: if (i == bc7_ai1[partition]) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 248: 461: ib--; 3472: 462: } else if (i == bc7_ai2[partition]) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 248: 463: ib--; -: 464: } -: 465: } 65792: 466: i0 = get_bits(src, cibit, ib); call 0 returned 100% 65792: 467: cibit += ib; -: 468: 65792: 469: if (ab && info->ib2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% branch 2 taken 44% (fallthrough) branch 3 taken 56% 12240: 470: ib2 = info->ib2; 12240: 471: if (ib2 && i == 0) { branch 0 taken 6% (fallthrough) branch 1 taken 94% 765: 472: ib2--; -: 473: } 12240: 474: i1 = get_bits(src, aibit, ib2); call 0 returned 100% 12240: 475: aibit += ib2; 12240: 476: if (index_sel) { branch 0 taken 11% (fallthrough) branch 1 taken 89% 1360: 477: bc7_lerp(&col[i], &endpoints[s], aw[i1], cw[i0]); call 0 returned 100% -: 478: } else { 10880: 479: bc7_lerp(&col[i], &endpoints[s], cw[i0], aw[i1]); call 0 returned 100% -: 480: } -: 481: } else { 53552: 482: bc7_lerp(&col[i], &endpoints[s], cw[i0], cw[i0]); call 0 returned 100% -: 483: } -: 484:#define ROTATE(x, y) \ -: 485: val = x; \ -: 486: x = y; \ -: 487: y = val 65792: 488: if (rotation == 1) { branch 0 taken 14% (fallthrough) branch 1 taken 86% 9120: 489: ROTATE(col[i].r, col[i].a); 56672: 490: } else if (rotation == 2) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 912: 491: ROTATE(col[i].g, col[i].a); 55760: 492: } else if (rotation == 3) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 672: 493: ROTATE(col[i].b, col[i].a); -: 494: } -: 495:#undef ROTATE -: 496: } -: 497:} -: 498: -: 499:/* BC6 */ -: 500:typedef struct { -: 501: char ns; /* number of subsets (also called regions) */ -: 502: char tr; /* whether endpoints are delta-compressed */ -: 503: char pb; /* partition bits */ -: 504: char epb; /* endpoint bits */ -: 505: char rb; /* red bits (delta) */ -: 506: char gb; /* green bits (delta) */ -: 507: char bb; /* blue bits (delta) */ -: 508:} bc6_mode_info; -: 509: -: 510:static const bc6_mode_info bc6_modes[] = { -: 511: // 00 -: 512: {2, 1, 5, 10, 5, 5, 5}, -: 513: // 01 -: 514: {2, 1, 5, 7, 6, 6, 6}, -: 515: // 10 -: 516: {2, 1, 5, 11, 5, 4, 4}, -: 517: {2, 1, 5, 11, 4, 5, 4}, -: 518: {2, 1, 5, 11, 4, 4, 5}, -: 519: {2, 1, 5, 9, 5, 5, 5}, -: 520: {2, 1, 5, 8, 6, 5, 5}, -: 521: {2, 1, 5, 8, 5, 6, 5}, -: 522: {2, 1, 5, 8, 5, 5, 6}, -: 523: {2, 0, 5, 6, 6, 6, 6}, -: 524: // 11 -: 525: {1, 0, 0, 10, 10, 10, 10}, -: 526: {1, 1, 0, 11, 9, 9, 9}, -: 527: {1, 1, 0, 12, 8, 8, 8}, -: 528: {1, 1, 0, 16, 4, 4, 4} -: 529:}; -: 530: -: 531:/* Table.F, encoded as a sequence of bit indices */ -: 532:static const UINT8 bc6_bit_packings[][75] = { -: 533: {116, 132, 176, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, -: 534: 23, 24, 25, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, -: 535: 164, 112, 113, 114, 115, 64, 65, 66, 67, 68, 172, 160, 161, 162, 163, 80, -: 536: 81, 82, 83, 84, 173, 128, 129, 130, 131, 96, 97, 98, 99, 100, 174, 144, -: 537: 145, 146, 147, 148, 175}, -: 538: {117, 164, 165, 0, 1, 2, 3, 4, 5, 6, 172, 173, 132, 16, 17, 18, 19, 20, 21, -: 539: 22, 133, 174, 116, 32, 33, 34, 35, 36, 37, 38, 175, 177, 176, 48, 49, 50, -: 540: 51, 52, 53, 112, 113, 114, 115, 64, 65, 66, 67, 68, 69, 160, 161, 162, 163, -: 541: 80, 81, 82, 83, 84, 85, 128, 129, 130, 131, 96, 97, 98, 99, 100, 101, 144, -: 542: 145, 146, 147, 148, 149}, -: 543: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 544: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, 10, 112, 113, 114, -: 545: 115, 64, 65, 66, 67, 26, 172, 160, 161, 162, 163, 80, 81, 82, 83, 42, 173, -: 546: 128, 129, 130, 131, 96, 97, 98, 99, 100, 174, 144, 145, 146, 147, 148, -: 547: 175}, -: 548: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 549: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 10, 164, 112, 113, 114, -: 550: 115, 64, 65, 66, 67, 68, 26, 160, 161, 162, 163, 80, 81, 82, 83, 42, 173, -: 551: 128, 129, 130, 131, 96, 97, 98, 99, 172, 174, 144, 145, 146, 147, 116, -: 552: 175}, -: 553: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 554: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 10, 132, 112, 113, 114, -: 555: 115, 64, 65, 66, 67, 26, 172, 160, 161, 162, 163, 80, 81, 82, 83, 84, 42, -: 556: 128, 129, 130, 131, 96, 97, 98, 99, 173, 174, 144, 145, 146, 147, 176, -: 557: 175}, -: 558: {0, 1, 2, 3, 4, 5, 6, 7, 8, 132, 16, 17, 18, 19, 20, 21, 22, 23, 24, 116, -: 559: 32, 33, 34, 35, 36, 37, 38, 39, 40, 176, 48, 49, 50, 51, 52, 164, 112, 113, -: 560: 114, 115, 64, 65, 66, 67, 68, 172, 160, 161, 162, 163, 80, 81, 82, 83, 84, -: 561: 173, 128, 129, 130, 131, 96, 97, 98, 99, 100, 174, 144, 145, 146, 147, 148, -: 562: 175}, -: 563: {0, 1, 2, 3, 4, 5, 6, 7, 164, 132, 16, 17, 18, 19, 20, 21, 22, 23, 174, 116, -: 564: 32, 33, 34, 35, 36, 37, 38, 39, 175, 176, 48, 49, 50, 51, 52, 53, 112, 113, -: 565: 114, 115, 64, 65, 66, 67, 68, 172, 160, 161, 162, 163, 80, 81, 82, 83, 84, -: 566: 173, 128, 129, 130, 131, 96, 97, 98, 99, 100, 101, 144, 145, 146, 147, 148, -: 567: 149}, -: 568: {0, 1, 2, 3, 4, 5, 6, 7, 172, 132, 16, 17, 18, 19, 20, 21, 22, 23, 117, 116, -: 569: 32, 33, 34, 35, 36, 37, 38, 39, 165, 176, 48, 49, 50, 51, 52, 164, 112, -: 570: 113, 114, 115, 64, 65, 66, 67, 68, 69, 160, 161, 162, 163, 80, 81, 82, 83, -: 571: 84, 173, 128, 129, 130, 131, 96, 97, 98, 99, 100, 174, 144, 145, 146, 147, -: 572: 148, 175}, -: 573: {0, 1, 2, 3, 4, 5, 6, 7, 173, 132, 16, 17, 18, 19, 20, 21, 22, 23, 133, 116, -: 574: 32, 33, 34, 35, 36, 37, 38, 39, 177, 176, 48, 49, 50, 51, 52, 164, 112, -: 575: 113, 114, 115, 64, 65, 66, 67, 68, 172, 160, 161, 162, 163, 80, 81, 82, 83, -: 576: 84, 85, 128, 129, 130, 131, 96, 97, 98, 99, 100, 174, 144, 145, 146, 147, -: 577: 148, 175}, -: 578: {0, 1, 2, 3, 4, 5, 164, 172, 173, 132, 16, 17, 18, 19, 20, 21, 117, 133, -: 579: 174, 116, 32, 33, 34, 35, 36, 37, 165, 175, 177, 176, 48, 49, 50, 51, 52, -: 580: 53, 112, 113, 114, 115, 64, 65, 66, 67, 68, 69, 160, 161, 162, 163, 80, 81, -: 581: 82, 83, 84, 85, 128, 129, 130, 131, 96, 97, 98, 99, 100, 101, 144, 145, -: 582: 146, 147, 148, 149}, -: 583: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 584: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -: 585: 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 80, 81, 82, 83, 84, 85, 86, 87, 88, -: 586: 89}, -: 587: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 588: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 10, -: 589: 64, 65, 66, 67, 68, 69, 70, 71, 72, 26, 80, 81, 82, 83, 84, 85, 86, 87, 88, -: 590: 42}, -: 591: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 592: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 11, 10, -: 593: 64, 65, 66, 67, 68, 69, 70, 71, 27, 26, 80, 81, 82, 83, 84, 85, 86, 87, 43, -: 594: 42}, -: 595: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, -: 596: 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 15, 14, 13, 12, 11, 10, -: 597: 64, 65, 66, 67, 31, 30, 29, 28, 27, 26, 80, 81, 82, 83, 47, 46, 45, 44, 43, -: 598: 42}}; -: 599: -: 600:static void bc6_sign_extend(UINT16 *v, int prec) { #####: 601: int x = *v; #####: 602: if (x & (1 << (prec - 1))) { 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 #####: 603: x |= -1 << prec; -: 604: } #####: 605: *v = (UINT16)x; -: 606:} -: 607: function bc6_unquantize called 0 returned 0% blocks executed 0% #####: 608:static int bc6_unquantize(UINT16 v, int prec, int sign) { #####: 609: int s = 0; -: 610: int x; #####: 611: if (!sign) { branch 0 never executed branch 1 never executed #####: 612: x = v; #####: 613: if (prec >= 15) { branch 0 never executed branch 1 never executed -: 614: return x; -: 615: } #####: 616: if (x == 0) { branch 0 never executed branch 1 never executed -: 617: return 0; -: 618: } #####: 619: if (x == ((1 << prec) - 1)) { branch 0 never executed branch 1 never executed -: 620: return 0xffff; -: 621: } #####: 622: return ((x << 15) + 0x4000) >> (prec - 1); -: 623: } else { #####: 624: x = (INT16)v; #####: 625: if (prec >= 16) { branch 0 never executed branch 1 never executed -: 626: return x; -: 627: } #####: 628: if (x < 0) { branch 0 never executed branch 1 never executed #####: 629: s = 1; #####: 630: x = -x; -: 631: } -: 632: #####: 633: if (x != 0) { branch 0 never executed branch 1 never executed #####: 634: if (x >= ((1 << (prec - 1)) - 1)) { branch 0 never executed branch 1 never executed -: 635: x = 0x7fff; -: 636: } else { #####: 637: x = ((x << 15) + 0x4000) >> (prec - 1); -: 638: } -: 639: } -: 640: #####: 641: if (s) { branch 0 never executed branch 1 never executed #####: 642: return -x; -: 643: } -: 644: return x; -: 645: } -: 646:} -: 647: -: 648:static float half_to_float(UINT16 h) { -: 649: /* https://gist.github.com/rygorous/2144712 */ -: 650: union { -: 651: UINT32 u; -: 652: float f; -: 653: } o, m; #####: 654: m.u = 0x77800000; #####: 655: o.u = (h & 0x7fff) << 13; #####: 656: o.f *= m.f; #####: 657: m.u = 0x47800000; #####: 658: if (o.f >= m.f) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed #####: 659: o.u |= 255 << 23; -: 660: } #####: 661: o.u |= (h & 0x8000) << 16; #####: 662: return o.f; -: 663:} -: 664: function bc6_finalize called 0 returned 0% blocks executed 0% #####: 665:static float bc6_finalize(int v, int sign) { #####: 666: if (sign) { branch 0 never executed branch 1 never executed #####: 667: if (v < 0) { branch 0 never executed branch 1 never executed #####: 668: v = ((-v) * 31) / 32; #####: 669: return half_to_float((UINT16)(0x8000 | v)); -: 670: } else { #####: 671: return half_to_float((UINT16)((v * 31) / 32)); -: 672: } -: 673: } else { #####: 674: return half_to_float((UINT16)((v * 31) / 64)); -: 675: } -: 676:} -: 677: function bc6_lerp called 0 returned 0% blocks executed 0% #####: 678:static void bc6_lerp(rgb32f *col, int *e0, int *e1, int s, int sign) { -: 679: int r, g, b; #####: 680: int t = 64 - s; #####: 681: r = (e0[0] * t + e1[0] * s) >> 6; #####: 682: g = (e0[1] * t + e1[1] * s) >> 6; #####: 683: b = (e0[2] * t + e1[2] * s) >> 6; #####: 684: col->r = bc6_finalize(r, sign); call 0 never executed #####: 685: col->g = bc6_finalize(g, sign); call 0 never executed #####: 686: col->b = bc6_finalize(b, sign); call 0 never executed #####: 687:} -: 688: function decode_bc6_block called 0 returned 0% blocks executed 0% #####: 689:static void decode_bc6_block(rgb32f *col, const UINT8* src, int sign) { -: 690: UINT16 endpoints[12]; /* storage for r0, g0, b0, r1, ... */ -: 691: int ueps[12]; -: 692: int i, i0, ib2, di, dw, mask, numep, s; -: 693: UINT8 partition; -: 694: const bc6_mode_info *info; -: 695: const char *cw; #####: 696: int bit = 5; #####: 697: int epbits = 75; #####: 698: int ib = 3; #####: 699: int mode = src[0] & 0x1f; #####: 700: if ((mode & 3) == 0 || (mode & 3) == 1) { branch 0 never executed branch 1 never executed #####: 701: mode &= 3; #####: 702: bit = 2; #####: 703: } else if ((mode & 3) == 2) { branch 0 never executed branch 1 never executed #####: 704: mode = 2 + (mode >> 2); #####: 705: epbits = 72; -: 706: } else { #####: 707: mode = 10 + (mode >> 2); #####: 708: epbits = 60; #####: 709: ib = 4; -: 710: } #####: 711: if (mode >= 14) { branch 0 never executed branch 1 never executed -: 712: /* invalid block */ #####: 713: memset(col, 0, 16 * sizeof(col[0])); #####: 714: return; -: 715: } #####: 716: info = &bc6_modes[mode]; #####: 717: cw = bc7_get_weights(ib); #####: 718: numep = info->ns == 2 ? 12 : 6; branch 0 never executed branch 1 never executed #####: 719: for (i = 0; i < 12; i++) { branch 0 never executed branch 1 never executed #####: 720: endpoints[i] = 0; -: 721: } #####: 722: for (i = 0; i < epbits; i++) { branch 0 never executed branch 1 never executed #####: 723: di = bc6_bit_packings[mode][i]; #####: 724: dw = di >> 4; #####: 725: di &= 15; #####: 726: endpoints[dw] |= (UINT16)get_bit(src, bit + i) << di; -: 727: } #####: 728: bit += epbits; #####: 729: partition = get_bits(src, bit, info->pb); call 0 never executed #####: 730: bit += info->pb; #####: 731: mask = (1 << info->epb) - 1; #####: 732: if (sign) { /* sign-extend e0 if signed */ branch 0 never executed branch 1 never executed #####: 733: bc6_sign_extend(&endpoints[0], info->epb); #####: 734: bc6_sign_extend(&endpoints[1], info->epb); #####: 735: bc6_sign_extend(&endpoints[2], info->epb); -: 736: } #####: 737: if (sign || info->tr) { /* sign-extend e1,2,3 if signed or deltas */ branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 738: for (i = 3; i < numep; i += 3) { branch 0 never executed branch 1 never executed #####: 739: bc6_sign_extend(&endpoints[i+0], info->rb); #####: 740: bc6_sign_extend(&endpoints[i+1], info->gb); #####: 741: bc6_sign_extend(&endpoints[i+2], info->bb); -: 742: } -: 743: } #####: 744: if (info->tr) { /* apply deltas */ branch 0 never executed branch 1 never executed #####: 745: for (i = 3; i < numep; i++) { branch 0 never executed branch 1 never executed #####: 746: endpoints[i] = (endpoints[i] + endpoints[0]) & mask; -: 747: } #####: 748: if (sign) { branch 0 never executed branch 1 never executed #####: 749: for (i = 3; i < numep; i += 3) { branch 0 never executed branch 1 never executed #####: 750: bc6_sign_extend(&endpoints[i+0], info->rb); #####: 751: bc6_sign_extend(&endpoints[i+1], info->gb); #####: 752: bc6_sign_extend(&endpoints[i+2], info->bb); -: 753: } -: 754: } -: 755: } #####: 756: for (i = 0; i < numep; i++) { branch 0 never executed branch 1 never executed #####: 757: ueps[i] = bc6_unquantize(endpoints[i], info->epb, sign); call 0 never executed -: 758: } #####: 759: for (i = 0; i < 16; i++) { branch 0 never executed branch 1 never executed #####: 760: s = bc7_get_subset(info->ns, partition, i) * 6; #####: 761: ib2 = ib; #####: 762: if (i == 0) { branch 0 never executed branch 1 never executed #####: 763: ib2--; #####: 764: } else if (info->ns == 2) { branch 0 never executed branch 1 never executed #####: 765: if (i == bc7_ai0[partition]) { branch 0 never executed branch 1 never executed #####: 766: ib2--; -: 767: } -: 768: } #####: 769: i0 = get_bits(src, bit, ib2); call 0 never executed #####: 770: bit += ib2; -: 771: #####: 772: bc6_lerp(&col[i], &ueps[s], &ueps[s+3], cw[i0], sign); call 0 never executed -: 773: } -: 774:} -: 775: function put_block.isra.0 called 21513 returned 100% blocks executed 45% 21513: 776:static void put_block(Imaging im, ImagingCodecState state, const char *col, int sz, int C) { 21513: 777: int width = state->xsize; 21513: 778: int height = state->ysize; 21513: 779: int xmax = width + state->xoff; 21513: 780: int ymax = height + state->yoff; -: 781: int j, i, y, x; -: 782: char *dst; 107565: 783: for (j = 0; j < 4; j++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 86052: 784: y = state->y + j; 86052: 785: if (C) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 786: if (y >= height) { branch 0 never executed branch 1 never executed #####: 787: continue; -: 788: } #####: 789: if (state->ystep < 0) { branch 0 never executed branch 1 never executed #####: 790: y = state->yoff + ymax - y - 1; -: 791: } #####: 792: dst = im->image[y]; #####: 793: for (i = 0; i < 4; i++) { branch 0 never executed branch 1 never executed #####: 794: x = state->x + i; #####: 795: if (x >= width) { branch 0 never executed branch 1 never executed #####: 796: continue; -: 797: } #####: 798: memcpy(dst + sz*x, col + sz*(j*4 + i), sz); -: 799: } -: 800: } else { 86052: 801: if (state->ystep < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 802: y = state->yoff + ymax - y - 1; -: 803: } 86052: 804: x = state->x; 86052: 805: dst = im->image[y] + sz*x; 86052: 806: memcpy(dst, col + sz*(j*4), 4 * sz); -: 807: } -: 808: } 21513: 809: state->x += 4; 21513: 810: if (state->x >= xmax) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 355: 811: state->y += 4; 355: 812: state->x = state->xoff; -: 813: } 21513: 814:} -: 815: function decode_bcn called 7 returned 100% blocks executed 60% 7: 816:static int decode_bcn(Imaging im, ImagingCodecState state, const UINT8* src, int bytes, int N, int C) { 7: 817: int ymax = state->ysize + state->yoff; 7: 818: const UINT8 *ptr = src; 7: 819: switch (N) { branch 0 taken 29% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% branch 4 taken 29% branch 5 taken 14% branch 6 taken 29% branch 7 taken 0% -: 820:#define DECODE_LOOP(NN, SZ, TY, ...) \ -: 821: case NN: \ -: 822: while (bytes >= SZ) { \ -: 823: TY col[16]; \ -: 824: memset(col, 0, 16 * sizeof(col[0])); \ -: 825: decode_bc##NN##_block(col, ptr); \ -: 826: put_block(im, state, (const char *)col, sizeof(col[0]), C); \ -: 827: ptr += SZ; \ -: 828: bytes -= SZ; \ -: 829: if (state->y >= ymax) {\ -: 830: return -1; \ -: 831: }\ -: 832: } \ -: 833: break -: 834: 10240: 835: DECODE_LOOP(1, 8, rgba); call 0 returned 100% branch 1 taken 1% (fallthrough) branch 2 taken 99% branch 3 taken 100% branch 4 taken 0% 4096: 836: DECODE_LOOP(2, 16, rgba); call 0 returned 100% call 1 returned 100% branch 2 taken 1% (fallthrough) branch 3 taken 99% branch 4 taken 100% branch 5 taken 0% 8185: 837: DECODE_LOOP(3, 16, rgba); call 0 returned 100% call 1 returned 100% branch 2 taken 1% (fallthrough) branch 3 taken 99% branch 4 taken 99% branch 5 taken 1% #####: 838: DECODE_LOOP(4, 8, lum); call 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed #####: 839: DECODE_LOOP(5, 16, rgba); call 0 never executed call 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed -: 840: case 6: #####: 841: while (bytes >= 16) { branch 0 never executed branch 1 never executed -: 842: rgb32f col[16]; #####: 843: decode_bc6_block(col, ptr, (state->state >> 4) & 1); call 0 never executed #####: 844: put_block(im, state, (const char *)col, sizeof(col[0]), C); call 0 never executed #####: 845: ptr += 16; #####: 846: bytes -= 16; #####: 847: if (state->y >= ymax) {\ branch 0 never executed branch 1 never executed #####: 848: return -1; \ -: 849: }\ -: 850: } -: 851: break; 4112: 852: DECODE_LOOP(7, 16, rgba); call 0 returned 100% call 1 returned 100% branch 2 taken 1% (fallthrough) branch 3 taken 99% branch 4 taken 100% branch 5 taken 0% (fallthrough) -: 853:#undef DECODE_LOOP -: 854: } 1: 855: return (int)(ptr - src); -: 856:} -: 857: function ImagingBcnDecode called 7 returned 100% blocks executed 75% 7: 858:int ImagingBcnDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) { 7: 859: int N = state->state & 0xf; 7: 860: int width = state->xsize; 7: 861: int height = state->ysize; 7: 862: if ((width & 3) | (height & 3)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 863: return decode_bcn(im, state, buf, bytes, N, 1); call 0 never executed -: 864: } else { 7: 865: return decode_bcn(im, state, buf, bytes, N, 0); call 0 returned 100% -: 866: } -: 867:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#SunRleDecode.c.gcov -: 0:Source:src/libImaging/SunRleDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/SunRleDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/SunRleDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * THIS IS WORK IN PROGRESS -: 3: * -: 4: * The Python Imaging Library. -: 5: * $Id$ -: 6: * -: 7: * decoder for SUN RLE data. -: 8: * -: 9: * history: -: 10: * 97-01-04 fl Created -: 11: * -: 12: * Copyright (c) Fredrik Lundh 1997. -: 13: * Copyright (c) Secret Labs AB 1997. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21: -: 22:int function ImagingSunRleDecode called 19 returned 100% blocks executed 100% 19: 23:ImagingSunRleDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 24:{ -: 25: int n; -: 26: UINT8* ptr; 19: 27: UINT8 extra_data = 0; 19: 28: UINT8 extra_bytes = 0; -: 29: 19: 30: ptr = buf; -: 31: -: 32: for (;;) { -: 33: 1043968: 34: if (bytes < 1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 14: 35: return ptr - buf; -: 36: } -: 37: 1043954: 38: if (ptr[0] == 0x80) { branch 0 taken 2% (fallthrough) branch 1 taken 98% -: 39: 18634: 40: if (bytes < 2) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 41: break; -: 42: } -: 43: 18633: 44: n = ptr[1]; -: 45: -: 46: 18633: 47: if (n == 0) { branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 48: -: 49: /* Literal 0x80 (2 bytes) */ 5101: 50: n = 1; -: 51: 5101: 52: state->buffer[state->x] = 0x80; -: 53: 5101: 54: ptr += 2; 5101: 55: bytes -= 2; -: 56: -: 57: } else { -: 58: -: 59: /* Run (3 bytes) */ 13532: 60: if (bytes < 3) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 61: break; -: 62: } -: 63: -: 64: /* from (https://www.fileformat.info/format/sunraster/egff.htm) -: 65: -: 66: For example, a run of 100 pixels with the value of -: 67: 0Ah would encode as the values 80h 64h 0Ah. A -: 68: single pixel value of 80h would encode as the -: 69: values 80h 00h. The four unencoded bytes 12345678h -: 70: would be stored in the RLE stream as 12h 34h 56h -: 71: 78h. 100 pixels, n=100, not 100 pixels, n=99. -: 72: -: 73: But Wait! There's More! -: 74: (https://www.fileformat.info/format/sunraster/spec/598a59c4fac64c52897585d390d86360/view.htm) -: 75: -: 76: If the first byte is 0x80, and the second byte is -: 77: not zero, the record is three bytes long. The -: 78: second byte is a count and the third byte is a -: 79: value. Output (count+1) pixels of that value. -: 80: -: 81: 2 specs, same site, but Imagemagick and GIMP seem -: 82: to agree on the second one. -: 83: */ 13532: 84: n += 1; -: 85: 13532: 86: if (state->x + n > state->bytes) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 325: 87: extra_bytes = n; /* full value */ 325: 88: n = state->bytes - state->x; 325: 89: extra_bytes -= n; 325: 90: extra_data = ptr[2]; -: 91: } -: 92: 27064: 93: memset(state->buffer + state->x, ptr[2], n); -: 94: 13532: 95: ptr += 3; 13532: 96: bytes -= 3; -: 97: -: 98: } -: 99: -: 100: } else { -: 101: -: 102: /* Literal byte */ 1025320: 103: n = 1; -: 104: 1025320: 105: state->buffer[state->x] = ptr[0]; -: 106: 1025320: 107: ptr += 1; 1025320: 108: bytes -= 1; -: 109: -: 110: } -: 111: -: 112: for (;;) { 1044359: 113: state->x += n; -: 114: 1044359: 115: if (state->x >= state->bytes) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 116: -: 117: /* Got a full line, unpack it */ 5808: 118: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 3872: 119: state->xoff * im->pixelsize, state->buffer, -: 120: state->xsize); -: 121: 1936: 122: state->x = 0; -: 123: 1936: 124: if (++state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 125: /* End of file (errcode = 0) */ -: 126: return -1; -: 127: } -: 128: } -: 129: 1044355: 130: if (extra_bytes == 0) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 131: break; -: 132: } -: 133: 406: 134: if (state->x > 0) { branch 0 taken 0% branch 1 taken 100% (fallthrough) -: 135: break; // assert -: 136: } -: 137: 406: 138: if (extra_bytes >= state->bytes) { branch 0 taken 80% (fallthrough) branch 1 taken 20% -: 139: n = state->bytes; -: 140: } else { 324: 141: n = extra_bytes; -: 142: } 812: 143: memset(state->buffer + state->x, extra_data, n); 406: 144: extra_bytes -= n; 406: 145: } -: 146: } -: 147: 1: 148: return ptr - buf; -: 149:} <<<<<< 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-aarch64-3.6/src/libImaging/AlphaComposite.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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% 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#aarch64-linux-gnu#bits#mathcalls.h.gcov -: 0:Source:/usr/include/aarch64-linux-gnu/bits/mathcalls.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Convert.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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/src#_imagingmorph.c.gcov -: 0:Source:src/_imagingmorph.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/_imagingmorph.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/_imagingmorph.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * -: 4: * A binary morphology add-on for the Python Imaging Library -: 5: * -: 6: * History: -: 7: * 2014-06-04 Initial version. -: 8: * -: 9: * Copyright (c) 2014 Dov Grobgeld -: 10: * -: 11: * See the README file for information on usage and redistribution. -: 12: */ -: 13: -: 14:#include "Python.h" -: 15:#include "libImaging/Imaging.h" -: 16: -: 17:#define LUT_SIZE (1<<9) -: 18: -: 19:/* Apply a morphologic LUT to a binary image. Outputs a -: 20: a new binary image. -: 21: -: 22: Expected parameters: -: 23: -: 24: 1. a LUT - a 512 byte size lookup table. -: 25: 2. an input Imaging image id. -: 26: 3. an output Imaging image id -: 27: -: 28: Returns number of changed pixels. -: 29:*/ -: 30:static PyObject* function apply called 9 returned 100% blocks executed 82% 9: 31:apply(PyObject *self, PyObject* args) -: 32:{ -: 33: const char *lut; -: 34: PyObject *py_lut; -: 35: Py_ssize_t lut_len, i0, i1; -: 36: Imaging imgin, imgout; -: 37: int width, height; -: 38: int row_idx, col_idx; -: 39: UINT8 **inrows, **outrows; 9: 40: int num_changed_pixels = 0; -: 41: 9: 42: if (!PyArg_ParseTuple(args, "Onn", &py_lut, &i0, &i1)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 43: PyErr_SetString(PyExc_RuntimeError, "Argument parsing problem"); call 0 never executed #####: 44: return NULL; -: 45: } -: 46: 9: 47: if (!PyBytes_Check(py_lut)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 48: PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a bytes object"); call 0 never executed #####: 49: return NULL; -: 50: } -: 51: 9: 52: lut_len = PyBytes_Size(py_lut); call 0 returned 100% -: 53: 9: 54: if (lut_len < LUT_SIZE) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 55: PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size"); call 0 never executed #####: 56: return NULL; -: 57: } -: 58: 9: 59: lut = PyBytes_AsString(py_lut); call 0 returned 100% -: 60: 9: 61: imgin = (Imaging) i0; 9: 62: imgout = (Imaging) i1; 9: 63: width = imgin->xsize; 9: 64: height = imgin->ysize; -: 65: 18: 66: if (imgin->type != IMAGING_TYPE_UINT8 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 11% (fallthrough) branch 3 taken 89% 9: 67: imgin->bands != 1) { 1: 68: PyErr_SetString(PyExc_RuntimeError, "Unsupported image type"); call 0 returned 100% 1: 69: return NULL; -: 70: } 16: 71: if (imgout->type != IMAGING_TYPE_UINT8 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 13% (fallthrough) branch 3 taken 88% 8: 72: imgout->bands != 1) { 1: 73: PyErr_SetString(PyExc_RuntimeError, "Unsupported image type"); call 0 returned 100% 1: 74: return NULL; -: 75: } -: 76: 7: 77: inrows = imgin->image8; 7: 78: outrows = imgout->image8; -: 79: 56: 80: for (row_idx=0; row_idx < height; row_idx++) { branch 0 taken 88% branch 1 taken 13% (fallthrough) 49: 81: UINT8 *outrow = outrows[row_idx]; 49: 82: UINT8 *inrow = inrows[row_idx]; -: 83: UINT8 *prow, *nrow; /* Previous and next row */ -: 84: -: 85: /* zero boundary conditions. TBD support other modes */ 49: 86: outrow[0] = outrow[width-1] = 0; 49: 87: if (row_idx==0 || row_idx == height-1) { branch 0 taken 86% (fallthrough) branch 1 taken 14% branch 2 taken 17% (fallthrough) branch 3 taken 83% 98: 88: for(col_idx=0; col_idxtype != IMAGING_TYPE_UINT8 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 33% (fallthrough) branch 3 taken 67% 3: 171: imgin->bands != 1) { 1: 172: PyErr_SetString(PyExc_RuntimeError, "Unsupported image type"); call 0 returned 100% 1: 173: return NULL; -: 174: } -: 175: 2: 176: inrows = imgin->image8; 2: 177: width = imgin->xsize; 2: 178: height = imgin->ysize; -: 179: 15: 180: for (row_idx=1; row_idx < height-1; row_idx++) { branch 0 taken 87% branch 1 taken 13% (fallthrough) 13: 181: UINT8 *inrow = inrows[row_idx]; -: 182: UINT8 *prow, *nrow; -: 183: 13: 184: prow = inrows[row_idx-1]; 13: 185: nrow = inrows[row_idx+1]; -: 186: 115: 187: for (col_idx=1; col_idximage8; 1: 242: width = img->xsize; 1: 243: height = img->ysize; -: 244: 8: 245: for (row_idx=0; row_idx < height; row_idx++) { branch 0 taken 88% branch 1 taken 13% (fallthrough) 7: 246: UINT8 *row = rows[row_idx]; 56: 247: for (col_idx=0; col_idxRGB unpackers -: 26: * -: 27: * Copyright (c) 1997-2003 by Secret Labs AB. -: 28: * Copyright (c) 1996-1997 by Fredrik Lundh. -: 29: * -: 30: * See the README file for information on usage and redistribution. -: 31: */ -: 32: -: 33:#include "Imaging.h" -: 34: -: 35:#define R 0 -: 36:#define G 1 -: 37:#define B 2 -: 38:#define X 3 -: 39: -: 40:#define A 3 -: 41: -: 42:#define C 0 -: 43:#define M 1 -: 44:#define Y 2 -: 45:#define K 3 -: 46: -: 47:/* byte-swapping macros */ -: 48: -: 49:#define C16N\ -: 50: (tmp[0]=in[0], tmp[1]=in[1]); -: 51:#define C16S\ -: 52: (tmp[1]=in[0], tmp[0]=in[1]); -: 53:#define C32N\ -: 54: (tmp[0]=in[0], tmp[1]=in[1], tmp[2]=in[2], tmp[3]=in[3]); -: 55:#define C32S\ -: 56: (tmp[3]=in[0], tmp[2]=in[1], tmp[1]=in[2], tmp[0]=in[3]); -: 57:#define C64N\ -: 58: (tmp[0]=in[0], tmp[1]=in[1], tmp[2]=in[2], tmp[3]=in[3],\ -: 59: tmp[4]=in[4], tmp[5]=in[5], tmp[6]=in[6], tmp[7]=in[7]); -: 60:#define C64S\ -: 61: (tmp[7]=in[0], tmp[6]=in[1], tmp[5]=in[2], tmp[4]=in[3],\ -: 62: tmp[3]=in[4], tmp[2]=in[5], tmp[1]=in[6], tmp[0]=in[7]); -: 63: -: 64:#ifdef WORDS_BIGENDIAN -: 65:#define C16B C16N -: 66:#define C16L C16S -: 67:#define C32B C32N -: 68:#define C32L C32S -: 69:#define C64B C64N -: 70:#define C64L C64S -: 71:#else -: 72:#define C16B C16S -: 73:#define C16L C16N -: 74:#define C32B C32S -: 75:#define C32L C32N -: 76:#define C64B C64S -: 77:#define C64L C64N -: 78:#endif -: 79: -: 80:/* bit-swapping */ -: 81: -: 82:static UINT8 BITFLIP[] = { -: 83: 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, -: 84: 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, -: 85: 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, -: 86: 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, -: 87: 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, -: 88: 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, -: 89: 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, -: 90: 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, -: 91: 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, -: 92: 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, -: 93: 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, -: 94: 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, -: 95: 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, -: 96: 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, -: 97: 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, -: 98: 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, -: 99: 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, -: 100: 255 -: 101:}; -: 102: -: 103:/* Unpack to "1" image */ -: 104: -: 105:static void function unpack1 called 282690 returned 100% blocks executed 100% 282690: 106:unpack1(UINT8* out, const UINT8* in, int pixels) -: 107:{ -: 108: /* bits (msb first, white is non-zero) */ 2319258: 109: while (pixels > 0) { branch 0 taken 86% branch 1 taken 14% (fallthrough) 1753878: 110: UINT8 byte = *in++; 1753878: 111: switch (pixels) { branch 0 taken 84% branch 1 taken 1% branch 2 taken 1% branch 3 taken 1% branch 4 taken 1% branch 5 taken 1% branch 6 taken 15% branch 7 taken 1% 1479482: 112: default: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 58% (fallthrough) branch 1 taken 42% 1480978: 113: case 7: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 55% (fallthrough) branch 1 taken 45% 1481466: 114: case 6: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 54% (fallthrough) branch 1 taken 46% 1481819: 115: case 5: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 57% (fallthrough) branch 1 taken 43% 1481932: 116: case 4: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 55% (fallthrough) branch 1 taken 45% 1484000: 117: case 3: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 55% (fallthrough) branch 1 taken 45% 1750581: 118: case 2: *out++ = (byte & 128) ? 255 : 0; byte <<= 1; branch 0 taken 60% (fallthrough) branch 1 taken 40% 1753878: 119: case 1: *out++ = (byte & 128) ? 255 : 0; branch 0 taken 61% (fallthrough) branch 1 taken 39% -: 120: } 1753878: 121: pixels -= 8; -: 122: } 282690: 123:} -: 124: -: 125:static void function unpack1I called 2226 returned 100% blocks executed 100% 2226: 126:unpack1I(UINT8* out, const UINT8* in, int pixels) -: 127:{ -: 128: /* bits (msb first, white is zero) */ 148710: 129: while (pixels > 0) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 144258: 130: UINT8 byte = *in++; 144258: 131: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% branch 4 taken 0% branch 5 taken 0% branch 6 taken 0% branch 7 taken 0% 144258: 132: default: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 133: case 7: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 134: case 6: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 135: case 5: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 136: case 4: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 137: case 3: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 138: case 2: *out++ = (byte & 128) ? 0 : 255; byte <<= 1; branch 0 taken 75% (fallthrough) branch 1 taken 25% 144258: 139: case 1: *out++ = (byte & 128) ? 0 : 255; branch 0 taken 75% (fallthrough) branch 1 taken 25% -: 140: } 144258: 141: pixels -= 8; -: 142: } 2226: 143:} -: 144: -: 145:static void function unpack1R called 1162 returned 100% blocks executed 100% 1162: 146:unpack1R(UINT8* out, const UINT8* in, int pixels) -: 147:{ -: 148: /* bits (lsb first, white is non-zero) */ 129502: 149: while (pixels > 0) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 127178: 150: UINT8 byte = *in++; 127178: 151: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% branch 4 taken 0% branch 5 taken 0% branch 6 taken 0% branch 7 taken 0% 127178: 152: default: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 153: case 7: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 154: case 6: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 155: case 5: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 156: case 4: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 157: case 3: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 158: case 2: *out++ = (byte & 1) ? 255 : 0; byte >>= 1; branch 0 taken 67% (fallthrough) branch 1 taken 33% 127178: 159: case 1: *out++ = (byte & 1) ? 255 : 0; branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 160: } 127178: 161: pixels -= 8; -: 162: } 1162: 163:} -: 164: -: 165:static void function unpack1IR called 2 returned 100% blocks executed 100% 2: 166:unpack1IR(UINT8* out, const UINT8* in, int pixels) -: 167:{ -: 168: /* bits (lsb first, white is zero) */ 6: 169: while (pixels > 0) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 2: 170: UINT8 byte = *in++; 2: 171: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% branch 4 taken 0% branch 5 taken 0% branch 6 taken 0% branch 7 taken 0% 2: 172: default: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 50% (fallthrough) branch 1 taken 50% 2: 173: case 7: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 50% (fallthrough) branch 1 taken 50% 2: 174: case 6: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 100% (fallthrough) branch 1 taken 0% 2: 175: case 5: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 50% (fallthrough) branch 1 taken 50% 2: 176: case 4: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 100% (fallthrough) branch 1 taken 0% 2: 177: case 3: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 50% (fallthrough) branch 1 taken 50% 2: 178: case 2: *out++ = (byte & 1) ? 0 : 255; byte >>= 1; branch 0 taken 100% (fallthrough) branch 1 taken 0% 2: 179: case 1: *out++ = (byte & 1) ? 0 : 255; branch 0 taken 50% (fallthrough) branch 1 taken 50% -: 180: } 2: 181: pixels -= 8; -: 182: } 2: 183:} -: 184: -: 185:static void function unpack18 called 51 returned 100% blocks executed 100% 51: 186:unpack18(UINT8* out, const UINT8* in, int pixels) -: 187:{ -: 188: /* Unpack a '|b1' image, which is a numpy boolean. -: 189: 1 == true, 0==false, in bytes */ -: 190: -: 191: int i; 475: 192: for (i = 0; i < pixels; i++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 424: 193: out[i] = in[i] > 0 ? 255 : 0; branch 0 taken 71% (fallthrough) branch 1 taken 29% -: 194: } 51: 195:} -: 196: -: 197: -: 198: -: 199:/* Unpack to "L" image */ -: 200: -: 201:static void function unpackL2 called 129 returned 100% blocks executed 100% 129: 202:unpackL2(UINT8* out, const UINT8* in, int pixels) -: 203:{ -: 204: /* nibbles (msb first, white is non-zero) */ 4355: 205: while (pixels > 0) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 4097: 206: UINT8 byte = *in++; 4097: 207: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% 4097: 208: default: *out++ = ((byte >> 6) & 0x03U) * 0x55U; byte <<= 2; 4097: 209: case 3: *out++ = ((byte >> 6) & 0x03U) * 0x55U; byte <<= 2; 4097: 210: case 2: *out++ = ((byte >> 6) & 0x03U) * 0x55U; byte <<= 2; 4097: 211: case 1: *out++ = ((byte >> 6) & 0x03U) * 0x55U; -: 212: } 4097: 213: pixels -= 4; -: 214: } 129: 215:} -: 216: -: 217:static void function unpackL2I called 129 returned 100% blocks executed 100% 129: 218:unpackL2I(UINT8* out, const UINT8* in, int pixels) -: 219:{ -: 220: /* nibbles (msb first, white is zero) */ 4355: 221: while (pixels > 0) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 4097: 222: UINT8 byte = *in++; 4097: 223: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% 4097: 224: default: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); byte <<= 2; 4097: 225: case 3: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); byte <<= 2; 4097: 226: case 2: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); byte <<= 2; 4097: 227: case 1: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); -: 228: } 4097: 229: pixels -= 4; -: 230: } 129: 231:} -: 232: -: 233:static void function unpackL2R called 129 returned 100% blocks executed 100% 129: 234:unpackL2R(UINT8* out, const UINT8* in, int pixels) -: 235:{ -: 236: /* nibbles (bit order reversed, white is non-zero) */ 4355: 237: while (pixels > 0) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 4097: 238: UINT8 byte = *in++; 4097: 239: byte = BITFLIP[byte]; 4097: 240: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% 4097: 241: default: *out++ = ((byte >> 6) & 0x03U) * 0x55U; byte <<= 2; 4097: 242: case 3: *out++ = ((byte >> 6) & 0x03U) * 0x55U; byte <<= 2; 4097: 243: case 2: *out++ = ((byte >> 6) & 0x03U) * 0x55U; byte <<= 2; 4097: 244: case 1: *out++ = ((byte >> 6) & 0x03U) * 0x55U; -: 245: } 4097: 246: pixels -= 4; -: 247: } 129: 248:} -: 249: -: 250:static void function unpackL2IR called 129 returned 100% blocks executed 100% 129: 251:unpackL2IR(UINT8* out, const UINT8* in, int pixels) -: 252:{ -: 253: /* nibbles (bit order reversed, white is zero) */ 4355: 254: while (pixels > 0) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 4097: 255: UINT8 byte = *in++; 4097: 256: byte = BITFLIP[byte]; 4097: 257: switch (pixels) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% branch 3 taken 0% 4097: 258: default: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); byte <<= 2; 4097: 259: case 3: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); byte <<= 2; 4097: 260: case 2: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); byte <<= 2; 4097: 261: case 1: *out++ = 0xFFU - (UINT8)(((byte >> 6) & 0x03U) * 0x55U); -: 262: } 4097: 263: pixels -= 4; -: 264: } 129: 265:} -: 266: -: 267:static void function unpackL4 called 257 returned 100% blocks executed 100% 257: 268:unpackL4(UINT8* out, const UINT8* in, int pixels) -: 269:{ -: 270: /* nibbles (msb first, white is non-zero) */ 16900: 271: while (pixels > 0) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 16386: 272: UINT8 byte = *in++; 16386: 273: switch (pixels) { branch 0 taken 100% branch 1 taken 0% 16386: 274: default: *out++ = ((byte >> 4) & 0x0FU) * 0x11U; byte <<= 4; 16386: 275: case 1: *out++ = ((byte >> 4) & 0x0FU) * 0x11U; -: 276: } 16386: 277: pixels -= 2; -: 278: } 257: 279:} -: 280: -: 281:static void function unpackL4I called 129 returned 100% blocks executed 100% 129: 282:unpackL4I(UINT8* out, const UINT8* in, int pixels) -: 283:{ -: 284: /* nibbles (msb first, white is zero) */ 8452: 285: while (pixels > 0) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 8194: 286: UINT8 byte = *in++; 8194: 287: switch (pixels) { branch 0 taken 100% branch 1 taken 0% 8194: 288: default: *out++ = 0xFFU - (UINT8)(((byte >> 4) & 0x0FU) * 0x11U); byte <<= 4; 8194: 289: case 1: *out++ = 0xFFU - (UINT8)(((byte >> 4) & 0x0FU) * 0x11U); -: 290: } 8194: 291: pixels -= 2; -: 292: } 129: 293:} -: 294: -: 295:static void function unpackL4R called 129 returned 100% blocks executed 100% 129: 296:unpackL4R(UINT8* out, const UINT8* in, int pixels) -: 297:{ -: 298: /* nibbles (bit order reversed, white is non-zero) */ 8452: 299: while (pixels > 0) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 8194: 300: UINT8 byte = *in++; 8194: 301: byte = BITFLIP[byte]; 8194: 302: switch (pixels) { branch 0 taken 100% branch 1 taken 0% 8194: 303: default: *out++ = ((byte >> 4) & 0x0FU) * 0x11U; byte <<= 4; 8194: 304: case 1: *out++ = ((byte >> 4) & 0x0FU) * 0x11U; -: 305: } 8194: 306: pixels -= 2; -: 307: } 129: 308:} -: 309: -: 310:static void function unpackL4IR called 129 returned 100% blocks executed 100% 129: 311:unpackL4IR(UINT8* out, const UINT8* in, int pixels) -: 312:{ -: 313: /* nibbles (bit order reversed, white is zero) */ 8452: 314: while (pixels > 0) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 8194: 315: UINT8 byte = *in++; 8194: 316: byte = BITFLIP[byte]; 8194: 317: switch (pixels) { branch 0 taken 100% branch 1 taken 0% 8194: 318: default: *out++ = 0xFFU - (UINT8)(((byte >> 4) & 0x0FU) * 0x11U); byte <<= 4; 8194: 319: case 1: *out++ = 0xFFU - (UINT8)(((byte >> 4) & 0x0FU) * 0x11U); -: 320: } 8194: 321: pixels -= 2; -: 322: } 129: 323:} -: 324: -: 325:static void function unpackLA called 2769 returned 100% blocks executed 100% 2769: 326:unpackLA(UINT8* _out, const UINT8* in, int pixels) -: 327:{ -: 328: int i; -: 329: /* LA, pixel interleaved */ 368190: 330: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 365421: 331: UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[1]); 365421: 332: memcpy(_out, &iv, sizeof(iv)); 365421: 333: in += 2; _out += 4; -: 334: } 2769: 335:} -: 336: -: 337:static void function unpackLAL called 130 returned 100% blocks executed 100% 130: 338:unpackLAL(UINT8* _out, const UINT8* in, int pixels) -: 339:{ -: 340: int i; -: 341: /* LA, line interleaved */ 16520: 342: for (i = 0; i < pixels; i++, _out+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16390: 343: UINT32 iv = MAKE_UINT32(in[i], in[i], in[i], in[i+pixels]); 16390: 344: memcpy(_out, &iv, sizeof(iv)); -: 345: } 130: 346:} -: 347: -: 348:static void function unpackLI called 1 returned 100% blocks executed 100% 1: 349:unpackLI(UINT8* out, const UINT8* in, int pixels) -: 350:{ -: 351: /* negative */ -: 352: int i; 5: 353: for (i = 0; i < pixels; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 4: 354: out[i] = ~in[i]; -: 355: } 1: 356:} -: 357: -: 358:static void function unpackLR called 2 returned 100% blocks executed 100% 2: 359:unpackLR(UINT8* out, const UINT8* in, int pixels) -: 360:{ -: 361: int i; -: 362: /* RGB, bit reversed */ 10: 363: for (i = 0; i < pixels; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) 8: 364: out[i] = BITFLIP[in[i]]; -: 365: } 2: 366:} -: 367: -: 368:static void function unpackL16 called 2 returned 100% blocks executed 100% 2: 369:unpackL16(UINT8* out, const UINT8* in, int pixels) -: 370:{ -: 371: /* int16 (upper byte, little endian) */ -: 372: int i; 8: 373: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 374: out[i] = in[1]; 6: 375: in += 2; -: 376: } 2: 377:} -: 378: -: 379:static void function unpackL16B called 1154 returned 100% blocks executed 100% 1154: 380:unpackL16B(UINT8* out, const UINT8* in, int pixels) -: 381:{ -: 382: int i; -: 383: /* int16 (upper byte, big endian) */ 148616: 384: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 147462: 385: out[i] = in[0]; 147462: 386: in += 2; -: 387: } 1154: 388:} -: 389: -: 390: -: 391:/* Unpack to "P" image */ -: 392: -: 393:static void function unpackP1 called 891 returned 100% blocks executed 100% 891: 394:unpackP1(UINT8* out, const UINT8* in, int pixels) -: 395:{ -: 396: /* bits */ 12623: 397: while (pixels > 0) { branch 0 taken 92% branch 1 taken 8% (fallthrough) 10841: 398: UINT8 byte = *in++; 10841: 399: switch (pixels) { branch 0 taken 95% branch 1 taken 2% branch 2 taken 0% branch 3 taken 0% branch 4 taken 1% branch 5 taken 0% branch 6 taken 1% branch 7 taken 0% 10335: 400: default: *out++ = (byte >> 7) & 1; byte <<= 1; 10591: 401: case 7: *out++ = (byte >> 7) & 1; byte <<= 1; 10591: 402: case 6: *out++ = (byte >> 7) & 1; byte <<= 1; 10591: 403: case 5: *out++ = (byte >> 7) & 1; byte <<= 1; 10691: 404: case 4: *out++ = (byte >> 7) & 1; byte <<= 1; 10691: 405: case 3: *out++ = (byte >> 7) & 1; byte <<= 1; 10841: 406: case 2: *out++ = (byte >> 7) & 1; byte <<= 1; 10841: 407: case 1: *out++ = (byte >> 7) & 1; -: 408: } 10841: 409: pixels -= 8; -: 410: } 891: 411:} -: 412: -: 413:static void function unpackP2 called 194 returned 100% blocks executed 100% 194: 414:unpackP2(UINT8* out, const UINT8* in, int pixels) -: 415:{ -: 416: /* bit pairs */ 6535: 417: while (pixels > 0) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 6147: 418: UINT8 byte = *in++; 6147: 419: switch (pixels) { branch 0 taken 99% branch 1 taken 0% branch 2 taken 1% branch 3 taken 0% 6146: 420: default: *out++ = (byte >> 6) & 3; byte <<= 2; 6146: 421: case 3: *out++ = (byte >> 6) & 3; byte <<= 2; 6147: 422: case 2: *out++ = (byte >> 6) & 3; byte <<= 2; 6147: 423: case 1: *out++ = (byte >> 6) & 3; -: 424: } 6147: 425: pixels -= 4; -: 426: } 194: 427:} -: 428: -: 429:static void function unpackP4 called 21949 returned 100% blocks executed 100% 21949: 430:unpackP4(UINT8* out, const UINT8* in, int pixels) -: 431:{ -: 432: /* nibbles */ 7867084: 433: while (pixels > 0) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 7823186: 434: UINT8 byte = *in++; 7823186: 435: switch (pixels) { branch 0 taken 99% branch 1 taken 1% 7823058: 436: default: *out++ = (byte >> 4) & 15; byte <<= 4; 7823186: 437: case 1: *out++ = (byte >> 4) & 15; -: 438: } 7823186: 439: pixels -= 2; -: 440: } 21949: 441:} -: 442: -: 443:static void function unpackP2L called 0 returned 0% blocks executed 0% #####: 444:unpackP2L(UINT8* out, const UINT8* in, int pixels) -: 445:{ -: 446: int i, j, m, s; -: 447: /* bit layers */ #####: 448: m = 128; #####: 449: s = (pixels+7)/8; #####: 450: for (i = j = 0; i < pixels; i++) { branch 0 never executed branch 1 never executed #####: 451: out[i] = ((in[j] & m) ? 1 : 0) + ((in[j + s] & m) ? 2 : 0); branch 0 never executed branch 1 never executed #####: 452: if ((m >>= 1) == 0) { branch 0 never executed branch 1 never executed #####: 453: m = 128; #####: 454: j++; -: 455: } -: 456: } #####: 457:} -: 458: -: 459:static void function unpackP4L called 0 returned 0% blocks executed 0% #####: 460:unpackP4L(UINT8* out, const UINT8* in, int pixels) -: 461:{ -: 462: int i, j, m, s; -: 463: /* bit layers (trust the optimizer ;-) */ #####: 464: m = 128; #####: 465: s = (pixels+7)/8; #####: 466: for (i = j = 0; i < pixels; i++) { branch 0 never executed branch 1 never executed #####: 467: out[i] = ((in[j] & m) ? 1 : 0) + ((in[j + s] & m) ? 2 : 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 #####: 468: ((in[j + 2*s] & m) ? 4 : 0) + ((in[j + 3*s] & m) ? 8 : 0); #####: 469: if ((m >>= 1) == 0) { branch 0 never executed branch 1 never executed #####: 470: m = 128; #####: 471: j++; -: 472: } -: 473: } #####: 474:} -: 475: -: 476: -: 477:/* Unpack to "RGB" image */ -: 478: -: 479:void function ImagingUnpackRGB called 172112 returned 100% blocks executed 100% 172112: 480:ImagingUnpackRGB(UINT8* _out, const UINT8* in, int pixels) -: 481:{ 172112: 482: int i = 0; -: 483: /* RGB triplets */ 152564539: 484: for (; i < pixels-1; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 485: UINT32 iv; 152392427: 486: memcpy(&iv, in, sizeof(iv)); 152392427: 487: iv |= MASK_UINT32_CHANNEL_3; 152392427: 488: memcpy(_out, &iv, sizeof(iv)); 152392427: 489: in += 3; _out += 4; -: 490: } 172112: 491: for (; i < pixels; i++) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 172112: 492: UINT32 iv = MAKE_UINT32(in[0], in[1], in[2], 255); 172112: 493: memcpy(_out, &iv, sizeof(iv)); 172112: 494: in += 3; _out += 4; -: 495: } 172112: 496:} -: 497: -: 498:void function unpackRGB16L called 1 returned 100% blocks executed 100% 1: 499:unpackRGB16L(UINT8* _out, const UINT8* in, int pixels) -: 500:{ -: 501: int i; -: 502: /* 16-bit RGB triplets, little-endian order */ 3: 503: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 504: UINT32 iv = MAKE_UINT32(in[1], in[3], in[5], 255); 2: 505: memcpy(_out, &iv, sizeof(iv)); 2: 506: in += 6; _out += 4; -: 507: } 1: 508:} -: 509: -: 510:void function unpackRGB16B called 764 returned 100% blocks executed 100% 764: 511:unpackRGB16B(UINT8* _out, const UINT8* in, int pixels) -: 512:{ -: 513: int i; -: 514: /* 16-bit RGB triplets, big-endian order */ 488448: 515: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 487684: 516: UINT32 iv = MAKE_UINT32(in[0], in[2], in[4], 255); 487684: 517: memcpy(_out, &iv, sizeof(iv)); 487684: 518: in += 6; _out += 4; -: 519: } 764: 520:} -: 521: -: 522:static void function unpackRGBL called 2092 returned 100% blocks executed 100% 2092: 523:unpackRGBL(UINT8* _out, const UINT8* in, int pixels) -: 524:{ -: 525: int i; -: 526: /* RGB, line interleaved */ 480882: 527: for (i = 0; i < pixels; i++, _out+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 478790: 528: UINT32 iv = MAKE_UINT32(in[i], in[i+pixels], in[i+pixels+pixels], 255); 478790: 529: memcpy(_out, &iv, sizeof(iv)); -: 530: } 2092: 531:} -: 532: -: 533:static void function unpackRGBR called 1 returned 100% blocks executed 100% 1: 534:unpackRGBR(UINT8* _out, const UINT8* in, int pixels) -: 535:{ -: 536: int i; -: 537: /* RGB, bit reversed */ 3: 538: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 539: UINT32 iv = MAKE_UINT32(BITFLIP[in[0]], BITFLIP[in[1]], -: 540: BITFLIP[in[2]], 255); 2: 541: memcpy(_out, &iv, sizeof(iv)); 2: 542: in += 3; _out += 4; -: 543: } 1: 544:} -: 545: -: 546:void function ImagingUnpackBGR called 4369 returned 100% blocks executed 100% 4369: 547:ImagingUnpackBGR(UINT8* _out, const UINT8* in, int pixels) -: 548:{ -: 549: int i; -: 550: /* RGB, reversed bytes */ 2322186: 551: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2317817: 552: UINT32 iv = MAKE_UINT32(in[2], in[1], in[0], 255); 2317817: 553: memcpy(_out, &iv, sizeof(iv)); 2317817: 554: in += 3; _out += 4; -: 555: } 4369: 556:} -: 557: -: 558:void function ImagingUnpackRGB15 called 2 returned 100% blocks executed 100% 2: 559:ImagingUnpackRGB15(UINT8* out, const UINT8* in, int pixels) -: 560:{ -: 561: int i, pixel; -: 562: /* RGB, 5 bits per pixel */ 6: 563: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 4: 564: pixel = in[0] + (in[1] << 8); 4: 565: out[R] = (pixel & 31) * 255 / 31; 4: 566: out[G] = ((pixel>>5) & 31) * 255 / 31; 4: 567: out[B] = ((pixel>>10) & 31) * 255 / 31; 4: 568: out[A] = 255; 4: 569: out += 4; in += 2; -: 570: } 2: 571:} -: 572: -: 573:void function ImagingUnpackRGBA15 called 1 returned 100% blocks executed 100% 1: 574:ImagingUnpackRGBA15(UINT8* out, const UINT8* in, int pixels) -: 575:{ -: 576: int i, pixel; -: 577: /* RGB, 5/5/5/1 bits per pixel */ 3: 578: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 579: pixel = in[0] + (in[1] << 8); 2: 580: out[R] = (pixel & 31) * 255 / 31; 2: 581: out[G] = ((pixel>>5) & 31) * 255 / 31; 2: 582: out[B] = ((pixel>>10) & 31) * 255 / 31; 2: 583: out[A] = (pixel>>15) * 255; 2: 584: out += 4; in += 2; -: 585: } 1: 586:} -: 587: -: 588:void function ImagingUnpackBGR15 called 66 returned 100% blocks executed 100% 66: 589:ImagingUnpackBGR15(UINT8* out, const UINT8* in, int pixels) -: 590:{ -: 591: int i, pixel; -: 592: /* RGB, reversed bytes, 5 bits per pixel */ 8198: 593: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 8132: 594: pixel = in[0] + (in[1] << 8); 8132: 595: out[B] = (pixel & 31) * 255 / 31; 8132: 596: out[G] = ((pixel>>5) & 31) * 255 / 31; 8132: 597: out[R] = ((pixel>>10) & 31) * 255 / 31; 8132: 598: out[A] = 255; 8132: 599: out += 4; in += 2; -: 600: } 66: 601:} -: 602: -: 603:void function ImagingUnpackBGRA15 called 1 returned 100% blocks executed 100% 1: 604:ImagingUnpackBGRA15(UINT8* out, const UINT8* in, int pixels) -: 605:{ -: 606: int i, pixel; -: 607: /* RGB, reversed bytes, 5/5/5/1 bits per pixel */ 3: 608: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 609: pixel = in[0] + (in[1] << 8); 2: 610: out[B] = (pixel & 31) * 255 / 31; 2: 611: out[G] = ((pixel>>5) & 31) * 255 / 31; 2: 612: out[R] = ((pixel>>10) & 31) * 255 / 31; 2: 613: out[A] = (pixel>>15) * 255; 2: 614: out += 4; in += 2; -: 615: } 1: 616:} -: 617: -: 618:void function ImagingUnpackRGB16 called 1 returned 100% blocks executed 100% 1: 619:ImagingUnpackRGB16(UINT8* out, const UINT8* in, int pixels) -: 620:{ -: 621: int i, pixel; -: 622: /* RGB, 5/6/5 bits per pixel */ 3: 623: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 624: pixel = in[0] + (in[1] << 8); 2: 625: out[R] = (pixel & 31) * 255 / 31; 2: 626: out[G] = ((pixel>>5) & 63) * 255 / 63; 2: 627: out[B] = ((pixel>>11) & 31) * 255 / 31; 2: 628: out[A] = 255; 2: 629: out += 4; in += 2; -: 630: } 1: 631:} -: 632: -: 633:void function ImagingUnpackBGR16 called 129 returned 100% blocks executed 100% 129: 634:ImagingUnpackBGR16(UINT8* out, const UINT8* in, int pixels) -: 635:{ -: 636: int i, pixel; -: 637: /* RGB, reversed bytes, 5/6/5 bits per pixel */ 16387: 638: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16258: 639: pixel = in[0] + (in[1] << 8); 16258: 640: out[B] = (pixel & 31) * 255 / 31; 16258: 641: out[G] = ((pixel>>5) & 63) * 255 / 63; 16258: 642: out[R] = ((pixel>>11) & 31) * 255 / 31; 16258: 643: out[A] = 255; 16258: 644: out += 4; in += 2; -: 645: } 129: 646:} -: 647: -: 648:void function ImagingUnpackRGB4B called 2 returned 100% blocks executed 100% 2: 649:ImagingUnpackRGB4B(UINT8* out, const UINT8* in, int pixels) -: 650:{ -: 651: int i, pixel; -: 652: /* RGB, 4 bits per pixel */ 6: 653: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 4: 654: pixel = in[0] + (in[1] << 8); 4: 655: out[R] = (pixel & 15) * 17; 4: 656: out[G] = ((pixel>>4) & 15) * 17; 4: 657: out[B] = ((pixel>>8) & 15) * 17; 4: 658: out[A] = 255; 4: 659: out += 4; in += 2; -: 660: } 2: 661:} -: 662: -: 663:void function ImagingUnpackRGBA4B called 1 returned 100% blocks executed 100% 1: 664:ImagingUnpackRGBA4B(UINT8* out, const UINT8* in, int pixels) -: 665:{ -: 666: int i, pixel; -: 667: /* RGBA, 4 bits per pixel */ 3: 668: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 669: pixel = in[0] + (in[1] << 8); 2: 670: out[R] = (pixel & 15) * 17; 2: 671: out[G] = ((pixel>>4) & 15) * 17; 2: 672: out[B] = ((pixel>>8) & 15) * 17; 2: 673: out[A] = ((pixel>>12) & 15) * 17; 2: 674: out += 4; in += 2; -: 675: } 1: 676:} -: 677: -: 678:static void function ImagingUnpackBGRX called 1417 returned 100% blocks executed 100% 1417: 679:ImagingUnpackBGRX(UINT8* _out, const UINT8* in, int pixels) -: 680:{ -: 681: int i; -: 682: /* RGB, reversed bytes with padding */ 919901: 683: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 918484: 684: UINT32 iv = MAKE_UINT32(in[2], in[1], in[0], 255); 918484: 685: memcpy(_out, &iv, sizeof(iv)); 918484: 686: in += 4; _out += 4; -: 687: } 1417: 688:} -: 689: -: 690:static void function ImagingUnpackXRGB called 2 returned 100% blocks executed 100% 2: 691:ImagingUnpackXRGB(UINT8* _out, const UINT8* in, int pixels) -: 692:{ -: 693: int i; -: 694: /* RGB, leading pad */ 8: 695: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 696: UINT32 iv = MAKE_UINT32(in[1], in[2], in[3], 255); 6: 697: memcpy(_out, &iv, sizeof(iv)); 6: 698: in += 4; _out += 4; -: 699: } 2: 700:} -: 701: -: 702:static void function ImagingUnpackXBGR called 130 returned 100% blocks executed 100% 130: 703:ImagingUnpackXBGR(UINT8* _out, const UINT8* in, int pixels) -: 704:{ -: 705: int i; -: 706: /* RGB, reversed bytes, leading pad */ 16392: 707: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16262: 708: UINT32 iv = MAKE_UINT32(in[3], in[2], in[1], 255); 16262: 709: memcpy(_out, &iv, sizeof(iv)); 16262: 710: in += 4; _out += 4; -: 711: } 130: 712:} -: 713: -: 714:/* Unpack to "RGBA" image */ -: 715: -: 716:static void function unpackRGBALA called 1 returned 100% blocks executed 100% 1: 717:unpackRGBALA(UINT8* _out, const UINT8* in, int pixels) -: 718:{ -: 719: int i; -: 720: /* greyscale with alpha */ 4: 721: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 722: UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[1]); 3: 723: memcpy(_out, &iv, sizeof(iv)); 3: 724: in += 2; _out += 4; -: 725: } 1: 726:} -: 727: -: 728:static void function unpackRGBALA16B called 1 returned 100% blocks executed 100% 1: 729:unpackRGBALA16B(UINT8* _out, const UINT8* in, int pixels) -: 730:{ -: 731: int i; -: 732: /* 16-bit greyscale with alpha, big-endian */ 4: 733: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 734: UINT32 iv = MAKE_UINT32(in[0], in[0], in[0], in[2]); 3: 735: memcpy(_out, &iv, sizeof(iv)); 3: 736: in += 4; _out += 4; -: 737: } 1: 738:} -: 739: -: 740:static void function unpackRGBa16L called 2 returned 100% blocks executed 100% 2: 741:unpackRGBa16L(UINT8* _out, const UINT8* in, int pixels) -: 742:{ -: 743: int i; -: 744: /* premultiplied 16-bit RGBA, little-endian */ 7: 745: for (i = 0; i < pixels; i++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 5: 746: int a = in[7]; -: 747: UINT32 iv; 5: 748: if ( ! a) { branch 0 taken 20% (fallthrough) branch 1 taken 80% 1: 749: iv = 0; 4: 750: } else if (a == 255) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 1: 751: iv = MAKE_UINT32(in[1], in[3], in[5], a); -: 752: } else { 3: 753: iv = MAKE_UINT32(CLIP8(in[1] * 255 / a), 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% -: 754: CLIP8(in[3] * 255 / a), -: 755: CLIP8(in[5] * 255 / a), a); -: 756: } 5: 757: memcpy(_out, &iv, sizeof(iv)); 5: 758: in += 8; _out += 4; -: 759: } 2: 760:} -: 761: -: 762:static void function unpackRGBa16B called 2 returned 100% blocks executed 100% 2: 763:unpackRGBa16B(UINT8* _out, const UINT8* in, int pixels) -: 764:{ -: 765: int i; -: 766: /* premultiplied 16-bit RGBA, big-endian */ 7: 767: for (i = 0; i < pixels; i++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 5: 768: int a = in[6]; -: 769: UINT32 iv; 5: 770: if ( ! a) { branch 0 taken 20% (fallthrough) branch 1 taken 80% 1: 771: iv = 0; 4: 772: } else if (a == 255) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 1: 773: iv = MAKE_UINT32(in[0], in[2], in[4], a); -: 774: } else { 3: 775: iv = MAKE_UINT32(CLIP8(in[0] * 255 / a), 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% -: 776: CLIP8(in[2] * 255 / a), -: 777: CLIP8(in[4] * 255 / a), a); -: 778: } 5: 779: memcpy(_out, &iv, sizeof(iv)); 5: 780: in += 8; _out += 4; -: 781: } 2: 782:} -: 783: -: 784:static void function unpackRGBa called 45 returned 100% blocks executed 100% 45: 785:unpackRGBa(UINT8* _out, const UINT8* in, int pixels) -: 786:{ -: 787: int i; -: 788: /* premultiplied RGBA */ 2416: 789: for (i = 0; i < pixels; i++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 2371: 790: int a = in[3]; -: 791: UINT32 iv; 2371: 792: if ( ! a) { branch 0 taken 16% (fallthrough) branch 1 taken 84% 377: 793: iv = 0; 1994: 794: } else if (a == 255) { branch 0 taken 91% (fallthrough) branch 1 taken 9% 1814: 795: iv = MAKE_UINT32(in[0], in[1], in[2], a); -: 796: } else { 180: 797: iv = MAKE_UINT32(CLIP8(in[0] * 255 / a), branch 0 taken 23% (fallthrough) branch 1 taken 77% branch 2 taken 2% (fallthrough) branch 3 taken 98% branch 4 taken 28% (fallthrough) branch 5 taken 72% -: 798: CLIP8(in[1] * 255 / a), -: 799: CLIP8(in[2] * 255 / a), a); -: 800: } 2371: 801: memcpy(_out, &iv, sizeof(iv)); 2371: 802: in += 4; _out += 4; -: 803: } 45: 804:} -: 805: -: 806:static void function unpackRGBaskip1 called 1 returned 100% blocks executed 100% 1: 807:unpackRGBaskip1(UINT8* _out, const UINT8* in, int pixels) -: 808:{ -: 809: int i; 1: 810: UINT32* out = (UINT32*) _out; -: 811: /* premultiplied RGBA */ 4: 812: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 813: int a = in[3]; 3: 814: if ( ! a) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 1: 815: out[i] = 0; 2: 816: } else if (a == 255) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1: 817: out[i] = MAKE_UINT32(in[0], in[1], in[2], a); -: 818: } else { 1: 819: out[i] = MAKE_UINT32(CLIP8(in[0] * 255 / a), 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% -: 820: CLIP8(in[1] * 255 / a), -: 821: CLIP8(in[2] * 255 / a), a); -: 822: } 3: 823: in += 5; -: 824: } 1: 825:} -: 826: -: 827:static void function unpackRGBaskip2 called 1 returned 100% blocks executed 100% 1: 828:unpackRGBaskip2(UINT8* _out, const UINT8* in, int pixels) -: 829:{ -: 830: int i; 1: 831: UINT32* out = (UINT32*) _out; -: 832: /* premultiplied RGBA */ 4: 833: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 834: int a = in[3]; 3: 835: if ( ! a) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 1: 836: out[i] = 0; 2: 837: } else if (a == 255) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 1: 838: out[i] = MAKE_UINT32(in[0], in[1], in[2], a); -: 839: } else { 1: 840: out[i] = MAKE_UINT32(CLIP8(in[0] * 255 / a), 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% -: 841: CLIP8(in[1] * 255 / a), -: 842: CLIP8(in[2] * 255 / a), a); -: 843: } 3: 844: in += 6; -: 845: } 1: 846:} -: 847: -: 848:static void function unpackBGRa called 2 returned 100% blocks executed 100% 2: 849:unpackBGRa(UINT8* _out, const UINT8* in, int pixels) -: 850:{ -: 851: int i; -: 852: /* premultiplied BGRA */ 7: 853: for (i = 0; i < pixels; i++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 5: 854: int a = in[3]; -: 855: UINT32 iv; 5: 856: if ( ! a) { branch 0 taken 20% (fallthrough) branch 1 taken 80% 1: 857: iv = 0; 4: 858: } else if (a == 255) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 1: 859: iv = MAKE_UINT32(in[2], in[1], in[0], a); -: 860: } else { 3: 861: iv = MAKE_UINT32(CLIP8(in[2] * 255 / a), 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% -: 862: CLIP8(in[1] * 255 / a), -: 863: CLIP8(in[0] * 255 / a), a); -: 864: } 5: 865: memcpy(_out, &iv, sizeof(iv)); 5: 866: in += 4; _out += 4; -: 867: } 2: 868:} -: 869: -: 870:static void function unpackRGBAI called 1 returned 100% blocks executed 100% 1: 871:unpackRGBAI(UINT8* out, const UINT8* in, int pixels) -: 872:{ -: 873: int i; -: 874: /* RGBA, inverted RGB bytes (FlashPix) */ 4: 875: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 876: out[R] = ~in[0]; 3: 877: out[G] = ~in[1]; 3: 878: out[B] = ~in[2]; 3: 879: out[A] = in[3]; 3: 880: out += 4; in += 4; -: 881: } 1: 882:} -: 883: -: 884:static void function unpackRGBAL called 5 returned 100% blocks executed 100% 5: 885:unpackRGBAL(UINT8* _out, const UINT8* in, int pixels) -: 886:{ -: 887: int i; -: 888: /* RGBA, line interleaved */ 209: 889: for (i = 0; i < pixels; i++, _out+=4) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 204: 890: UINT32 iv = MAKE_UINT32(in[i], in[i+pixels], in[i+pixels+pixels], -: 891: in[i+pixels+pixels+pixels]); 204: 892: memcpy(_out, &iv, sizeof(iv)); -: 893: } 5: 894:} -: 895: -: 896:void function unpackRGBA16L called 4 returned 100% blocks executed 100% 4: 897:unpackRGBA16L(UINT8* _out, const UINT8* in, int pixels) -: 898:{ -: 899: int i; -: 900: /* 16-bit RGBA, little-endian order */ 12: 901: for (i = 0; i < pixels; i++, _out+=4) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 8: 902: UINT32 iv = MAKE_UINT32(in[1], in[3], in[5], in[7]); 8: 903: memcpy(_out, &iv, sizeof(iv)); 8: 904: in += 8; -: 905: } 4: 906:} -: 907: -: 908:void function unpackRGBA16B called 195 returned 100% blocks executed 100% 195: 909:unpackRGBA16B(UINT8* _out, const UINT8* in, int pixels) -: 910:{ -: 911: int i; -: 912: /* 16-bit RGBA, big-endian order */ 24777: 913: for (i = 0; i < pixels; i++, _out+=4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 24582: 914: UINT32 iv = MAKE_UINT32(in[0], in[2], in[4], in[6]); 24582: 915: memcpy(_out, &iv, sizeof(iv)); 24582: 916: in += 8; -: 917: } 195: 918:} -: 919: -: 920:static void function unpackARGB called 602 returned 100% blocks executed 100% 602: 921:unpackARGB(UINT8* _out, const UINT8* in, int pixels) -: 922:{ -: 923: int i; -: 924: /* RGBA, leading pad */ 480608: 925: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 480006: 926: UINT32 iv = MAKE_UINT32(in[1], in[2], in[3], in[0]); 480006: 927: memcpy(_out, &iv, sizeof(iv)); 480006: 928: in += 4; _out += 4; -: 929: } 602: 930:} -: 931: -: 932:static void function unpackABGR called 2 returned 100% blocks executed 100% 2: 933:unpackABGR(UINT8* _out, const UINT8* in, int pixels) -: 934:{ -: 935: int i; -: 936: /* RGBA, reversed bytes */ 8: 937: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 938: UINT32 iv = MAKE_UINT32(in[3], in[2], in[1], in[0]); 6: 939: memcpy(_out, &iv, sizeof(iv)); 6: 940: in += 4; _out += 4; -: 941: } 2: 942:} -: 943: -: 944:static void function unpackBGRA called 887 returned 100% blocks executed 100% 887: 945:unpackBGRA(UINT8* _out, const UINT8* in, int pixels) -: 946:{ -: 947: int i; -: 948: /* RGBA, reversed bytes */ 171920: 949: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 171033: 950: UINT32 iv = MAKE_UINT32(in[2], in[1], in[0], in[3]); 171033: 951: memcpy(_out, &iv, sizeof(iv)); 171033: 952: in += 4; _out += 4; -: 953: } 887: 954:} -: 955: -: 956: -: 957:/* Unpack to "CMYK" image */ -: 958: -: 959:static void function unpackCMYKI called 1757 returned 100% blocks executed 100% 1757: 960:unpackCMYKI(UINT8* _out, const UINT8* in, int pixels) -: 961:{ -: 962: int i; -: 963: /* CMYK, inverted bytes (Photoshop 2.5) */ 168144: 964: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 166387: 965: UINT32 iv = ~MAKE_UINT32(in[0], in[1], in[2], in[3]); 166387: 966: memcpy(_out, &iv, sizeof(iv)); 166387: 967: in += 4; _out += 4; -: 968: } 1757: 969:} -: 970: -: 971:/* Unpack to "LAB" image */ -: 972:/* There are two representations of LAB images for whatever precision: -: 973: L: Uint (in PS, it's 0-100) -: 974: A: Int (in ps, -128 .. 128, or elsewhere 0..255, with 128 as middle. -: 975: Channels in PS display a 0 value as middle grey, -: 976: LCMS appears to use 128 as the 0 value for these channels) -: 977: B: Int (as above) -: 978: -: 979: Since we don't have any signed ints, we're going with the shifted versions -: 980: internally, and we'll unshift for saving and whatnot. -: 981:*/ -: 982:void function ImagingUnpackLAB called 415 returned 100% blocks executed 100% 415: 983:ImagingUnpackLAB(UINT8* out, const UINT8* in, int pixels) -: 984:{ -: 985: int i; -: 986: /* LAB triplets */ 49870: 987: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49455: 988: out[0] = in[0]; 49455: 989: out[1] = in[1] ^ 128; /* signed in outside world */ 49455: 990: out[2] = in[2] ^ 128; 49455: 991: out[3] = 255; 49455: 992: out += 4; in += 3; -: 993: } 415: 994:} -: 995: -: 996:static void function unpackI16N_I16B called 1 returned 100% blocks executed 100% 1: 997:unpackI16N_I16B(UINT8* out, const UINT8* in, int pixels){ -: 998: int i; 1: 999: UINT8* tmp = (UINT8*) out; 4: 1000: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 1001: C16B; 3: 1002: in += 2; tmp += 2; -: 1003: } -: 1004: 1: 1005:} -: 1006:static void function unpackI16N_I16 called 2 returned 100% blocks executed 100% 2: 1007:unpackI16N_I16(UINT8* out, const UINT8* in, int pixels){ -: 1008: int i; 2: 1009: UINT8* tmp = (UINT8*) out; 8: 1010: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 1011: C16L; 6: 1012: in += 2; tmp += 2; -: 1013: } 2: 1014:} -: 1015: -: 1016:static void function unpackI12_I16 called 101 returned 100% blocks executed 100% 101: 1017:unpackI12_I16(UINT8* out, const UINT8* in, int pixels){ -: 1018: /* Fillorder 1/MSB -> LittleEndian, for 12bit integer greyscale tiffs. -: 1019: -: 1020: According to the TIFF spec: -: 1021: -: 1022: FillOrder = 2 should be used only when BitsPerSample = 1 and -: 1023: the data is either uncompressed or compressed using CCITT 1D -: 1024: or 2D compression, to avoid potentially ambiguous situations. -: 1025: -: 1026: Yeah. I thought so. We'll see how well people read the spec. -: 1027: We've got several fillorder=2 modes in TiffImagePlugin.py -: 1028: -: 1029: There's no spec I can find. It appears that the in storage -: 1030: layout is: 00 80 00 ... -> (128 , 0 ...). The samples are -: 1031: stored in a single big bitian 12bit block, but need to be -: 1032: pulled out to little endian format to be stored in a 2 byte -: 1033: int. -: 1034: */ -: 1035: -: 1036: int i; -: 1037: UINT16 pixel; -: 1038:#ifdef WORDS_BIGENDIAN -: 1039: UINT8* tmp = (UINT8 *)&pixel; -: 1040:#endif 5102: 1041: for (i = 0; i < pixels-1; i+=2) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 5001: 1042: pixel = (((UINT16) in[0]) << 4 ) + (in[1] >>4); -: 1043:#ifdef WORDS_BIGENDIAN -: 1044: out[0] = tmp[1]; out[1] = tmp[0]; -: 1045:#else 5001: 1046: memcpy(out, &pixel, sizeof(pixel)); -: 1047:#endif -: 1048: 5001: 1049: out+=2; 5001: 1050: pixel = (((UINT16) (in[1] & 0x0F)) << 8) + in[2]; -: 1051:#ifdef WORDS_BIGENDIAN -: 1052: out[0] = tmp[1]; out[1] = tmp[0]; -: 1053:#else 5001: 1054: memcpy(out, &pixel, sizeof(pixel)); -: 1055:#endif -: 1056: 5001: 1057: in += 3; out+=2; -: 1058: } 101: 1059: if (i == pixels-1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 1060: pixel = (((UINT16) in[0]) << 4 ) + (in[1] >>4); -: 1061:#ifdef WORDS_BIGENDIAN -: 1062: out[0] = tmp[1]; out[1] = tmp[0]; -: 1063:#else -: 1064: memcpy(out, &pixel, sizeof(pixel)); -: 1065:#endif -: 1066: } 101: 1067:} -: 1068: -: 1069: -: 1070:static void function copy1 called 366649 returned 100% blocks executed 100% 366649: 1071:copy1(UINT8* out, const UINT8* in, int pixels) -: 1072:{ -: 1073: /* L, P */ 733298: 1074: memcpy(out, in, pixels); 366649: 1075:} -: 1076: -: 1077:static void function copy2 called 145 returned 100% blocks executed 100% 145: 1078:copy2(UINT8* out, const UINT8* in, int pixels) -: 1079:{ -: 1080: /* I;16 */ 290: 1081: memcpy(out, in, pixels*2); 145: 1082:} -: 1083: -: 1084:static void function copy4 called 121933 returned 100% blocks executed 100% 121933: 1085:copy4(UINT8* out, const UINT8* in, int pixels) -: 1086:{ -: 1087: /* RGBA, CMYK quadruples */ 243866: 1088: memcpy(out, in, 4 * pixels); 121933: 1089:} -: 1090: -: 1091:static void function copy4skip1 called 3 returned 100% blocks executed 100% 3: 1092:copy4skip1(UINT8* _out, const UINT8* in, int pixels) -: 1093:{ -: 1094: int i; 12: 1095: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 9: 1096: memcpy(_out, in, 4); 9: 1097: in += 5; _out += 4; -: 1098: } 3: 1099:} -: 1100: -: 1101:static void function copy4skip2 called 3 returned 100% blocks executed 100% 3: 1102:copy4skip2(UINT8* _out, const UINT8* in, int pixels) -: 1103:{ -: 1104: int i; 12: 1105: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 9: 1106: memcpy(_out, in, 4); 9: 1107: in += 6; _out += 4; -: 1108: } 3: 1109:} -: 1110: -: 1111: -: 1112:/* Unpack to "I" and "F" images */ -: 1113: -: 1114:#define UNPACK_RAW(NAME, GET, INTYPE, OUTTYPE)\ -: 1115:static void NAME(UINT8* out_, const UINT8* in, int pixels)\ -: 1116:{\ -: 1117: int i;\ -: 1118: OUTTYPE* out = (OUTTYPE*) out_;\ -: 1119: for (i = 0; i < pixels; i++, in += sizeof(INTYPE)) {\ -: 1120: out[i] = (OUTTYPE) ((INTYPE) GET);\ -: 1121: }\ -: 1122:} -: 1123: -: 1124:#define UNPACK(NAME, COPY, INTYPE, OUTTYPE)\ -: 1125:static void NAME(UINT8* out_, const UINT8* in, int pixels)\ -: 1126:{\ -: 1127: int i;\ -: 1128: OUTTYPE* out = (OUTTYPE*) out_;\ -: 1129: INTYPE tmp_;\ -: 1130: UINT8* tmp = (UINT8*) &tmp_;\ -: 1131: for (i = 0; i < pixels; i++, in += sizeof(INTYPE)) {\ -: 1132: COPY;\ -: 1133: out[i] = (OUTTYPE) tmp_;\ -: 1134: }\ -: 1135:} -: 1136: function unpackI8 called 21 returned 100% blocks executed 100% 21: 1137:UNPACK_RAW(unpackI8, in[0], UINT8, INT32) branch 0 taken 91% branch 1 taken 9% (fallthrough) function unpackI8S called 1 returned 100% blocks executed 100% 1: 1138:UNPACK_RAW(unpackI8S, in[0], INT8, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI16 called 1 returned 100% blocks executed 100% 1: 1139:UNPACK(unpackI16, C16L, UINT16, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI16S called 31 returned 100% blocks executed 100% 31: 1140:UNPACK(unpackI16S, C16L, INT16, INT32) branch 0 taken 91% branch 1 taken 9% (fallthrough) function unpackI16B called 1685 returned 100% blocks executed 100% 1685: 1141:UNPACK(unpackI16B, C16B, UINT16, INT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) function unpackI16BS called 1 returned 100% blocks executed 100% 1: 1142:UNPACK(unpackI16BS, C16B, INT16, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI16N called 1 returned 100% blocks executed 100% 1: 1143:UNPACK(unpackI16N, C16N, UINT16, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI16NS called 1 returned 100% blocks executed 100% 1: 1144:UNPACK(unpackI16NS, C16N, INT16, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI32 called 21 returned 100% blocks executed 100% 21: 1145:UNPACK(unpackI32, C32L, UINT32, INT32) branch 0 taken 91% branch 1 taken 9% (fallthrough) function unpackI32S called 33 returned 100% blocks executed 100% 33: 1146:UNPACK(unpackI32S, C32L, INT32, INT32) branch 0 taken 97% branch 1 taken 3% (fallthrough) function unpackI32B called 1 returned 100% blocks executed 100% 1: 1147:UNPACK(unpackI32B, C32B, UINT32, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI32BS called 1 returned 100% blocks executed 100% 1: 1148:UNPACK(unpackI32BS, C32B, INT32, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI32N called 1 returned 100% blocks executed 100% 1: 1149:UNPACK(unpackI32N, C32N, UINT32, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackI32NS called 1 returned 100% blocks executed 100% 1: 1150:UNPACK(unpackI32NS, C32N, INT32, INT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) -: 1151: function unpackF8 called 1 returned 100% blocks executed 100% 1: 1152:UNPACK_RAW(unpackF8, in[0], UINT8, FLOAT32) branch 0 taken 80% branch 1 taken 20% (fallthrough) function unpackF8S called 1 returned 100% blocks executed 100% 1: 1153:UNPACK_RAW(unpackF8S, in[0], INT8, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF16 called 1 returned 100% blocks executed 100% 1: 1154:UNPACK(unpackF16, C16L, UINT16, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF16S called 1 returned 100% blocks executed 100% 1: 1155:UNPACK(unpackF16S, C16L, INT16, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF16B called 1 returned 100% blocks executed 100% 1: 1156:UNPACK(unpackF16B, C16B, UINT16, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF16BS called 1 returned 100% blocks executed 100% 1: 1157:UNPACK(unpackF16BS, C16B, INT16, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF16N called 1 returned 100% blocks executed 100% 1: 1158:UNPACK(unpackF16N, C16N, UINT16, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF16NS called 1 returned 100% blocks executed 100% 1: 1159:UNPACK(unpackF16NS, C16N, INT16, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32 called 1 returned 100% blocks executed 100% 1: 1160:UNPACK(unpackF32, C32L, UINT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32S called 1 returned 100% blocks executed 100% 1: 1161:UNPACK(unpackF32S, C32L, INT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32B called 1 returned 100% blocks executed 100% 1: 1162:UNPACK(unpackF32B, C32B, UINT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32BS called 1 returned 100% blocks executed 100% 1: 1163:UNPACK(unpackF32BS, C32B, INT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32N called 1 returned 100% blocks executed 100% 1: 1164:UNPACK(unpackF32N, C32N, UINT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32NS called 1 returned 100% blocks executed 100% 1: 1165:UNPACK(unpackF32NS, C32N, INT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32F called 961 returned 100% blocks executed 100% 961: 1166:UNPACK(unpackF32F, C32L, FLOAT32, FLOAT32) branch 0 taken 99% branch 1 taken 1% (fallthrough) function unpackF32BF called 1 returned 100% blocks executed 100% 1: 1167:UNPACK(unpackF32BF, C32B, FLOAT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF32NF called 1 returned 100% blocks executed 100% 1: 1168:UNPACK(unpackF32NF, C32N, FLOAT32, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) -: 1169:#ifdef FLOAT64 function unpackF64F called 41 returned 100% blocks executed 100% 41: 1170:UNPACK(unpackF64F, C64L, FLOAT64, FLOAT32) branch 0 taken 91% branch 1 taken 9% (fallthrough) function unpackF64BF called 1 returned 100% blocks executed 100% 1: 1171:UNPACK(unpackF64BF, C64B, FLOAT64, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) function unpackF64NF called 1 returned 100% blocks executed 100% 1: 1172:UNPACK(unpackF64NF, C64N, FLOAT64, FLOAT32) branch 0 taken 67% branch 1 taken 33% (fallthrough) -: 1173:#endif -: 1174: -: 1175: -: 1176:/* Misc. unpackers */ -: 1177: -: 1178:static void function band0 called 6158 returned 100% blocks executed 100% 6158: 1179:band0(UINT8* out, const UINT8* in, int pixels) -: 1180:{ -: 1181: int i; -: 1182: /* band 0 only */ 835516: 1183: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 829358: 1184: out[0] = in[i]; 829358: 1185: out += 4; -: 1186: } 6158: 1187:} -: 1188: -: 1189:static void function band1 called 6158 returned 100% blocks executed 100% 6158: 1190:band1(UINT8* out, const UINT8* in, int pixels) -: 1191:{ -: 1192: int i; -: 1193: /* band 1 only */ 835516: 1194: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 829358: 1195: out[1] = in[i]; 829358: 1196: out += 4; -: 1197: } 6158: 1198:} -: 1199: -: 1200:static void function band2 called 6158 returned 100% blocks executed 100% 6158: 1201:band2(UINT8* out, const UINT8* in, int pixels) -: 1202:{ -: 1203: int i; -: 1204: /* band 2 only */ 835516: 1205: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 829358: 1206: out[2] = in[i]; 829358: 1207: out += 4; -: 1208: } 6158: 1209:} -: 1210: -: 1211:static void function band3 called 409 returned 100% blocks executed 100% 409: 1212:band3(UINT8* out, const UINT8* in, int pixels) -: 1213:{ -: 1214: /* band 3 only */ -: 1215: int i; 63186: 1216: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 62777: 1217: out[3] = in[i]; 62777: 1218: out += 4; -: 1219: } 409: 1220:} -: 1221: -: 1222:static void function band0I called 1 returned 100% blocks executed 100% 1: 1223:band0I(UINT8* out, const UINT8* in, int pixels) -: 1224:{ -: 1225: int i; -: 1226: /* band 0 only */ 4: 1227: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 1228: out[0] = ~in[i]; 3: 1229: out += 4; -: 1230: } 1: 1231:} -: 1232: -: 1233:static void function band1I called 1 returned 100% blocks executed 100% 1: 1234:band1I(UINT8* out, const UINT8* in, int pixels) -: 1235:{ -: 1236: int i; -: 1237: /* band 1 only */ 4: 1238: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 1239: out[1] = ~in[i]; 3: 1240: out += 4; -: 1241: } 1: 1242:} -: 1243: -: 1244:static void function band2I called 1 returned 100% blocks executed 100% 1: 1245:band2I(UINT8* out, const UINT8* in, int pixels) -: 1246:{ -: 1247: int i; -: 1248: /* band 2 only */ 4: 1249: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 1250: out[2] = ~in[i]; 3: 1251: out += 4; -: 1252: } 1: 1253:} -: 1254: -: 1255:static void function band3I called 1 returned 100% blocks executed 100% 1: 1256:band3I(UINT8* out, const UINT8* in, int pixels) -: 1257:{ -: 1258: /* band 3 only */ -: 1259: int i; 4: 1260: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 1261: out[3] = ~in[i]; 3: 1262: out += 4; -: 1263: } 1: 1264:} -: 1265: -: 1266:static struct { -: 1267: const char* mode; -: 1268: const char* rawmode; -: 1269: int bits; -: 1270: ImagingShuffler unpack; -: 1271:} unpackers[] = { -: 1272: -: 1273: /* raw mode syntax is ";" where "bits" defaults -: 1274: depending on mode (1 for "1", 8 for "P" and "L", etc), and -: 1275: "flags" should be given in alphabetical order. if both bits -: 1276: and flags have their default values, the ; should be left out */ -: 1277: -: 1278: /* flags: "I" inverted data; "R" reversed bit order; "B" big -: 1279: endian byte order (default is little endian); "L" line -: 1280: interleave, "S" signed, "F" floating point */ -: 1281: -: 1282: /* exception: rawmodes "I" and "F" are always native endian byte order */ -: 1283: -: 1284: /* bilevel */ -: 1285: {"1", "1", 1, unpack1}, -: 1286: {"1", "1;I", 1, unpack1I}, -: 1287: {"1", "1;R", 1, unpack1R}, -: 1288: {"1", "1;IR", 1, unpack1IR}, -: 1289: {"1", "1;8", 8, unpack18}, -: 1290: -: 1291: /* greyscale */ -: 1292: {"L", "L;2", 2, unpackL2}, -: 1293: {"L", "L;2I", 2, unpackL2I}, -: 1294: {"L", "L;2R", 2, unpackL2R}, -: 1295: {"L", "L;2IR", 2, unpackL2IR}, -: 1296: -: 1297: {"L", "L;4", 4, unpackL4}, -: 1298: {"L", "L;4I", 4, unpackL4I}, -: 1299: {"L", "L;4R", 4, unpackL4R}, -: 1300: {"L", "L;4IR", 4, unpackL4IR}, -: 1301: -: 1302: {"L", "L", 8, copy1}, -: 1303: {"L", "L;I", 8, unpackLI}, -: 1304: {"L", "L;R", 8, unpackLR}, -: 1305: {"L", "L;16", 16, unpackL16}, -: 1306: {"L", "L;16B", 16, unpackL16B}, -: 1307: -: 1308: /* greyscale w. alpha */ -: 1309: {"LA", "LA", 16, unpackLA}, -: 1310: {"LA", "LA;L", 16, unpackLAL}, -: 1311: -: 1312: /* greyscale w. alpha premultiplied */ -: 1313: {"La", "La", 16, unpackLA}, -: 1314: -: 1315: /* palette */ -: 1316: {"P", "P;1", 1, unpackP1}, -: 1317: {"P", "P;2", 2, unpackP2}, -: 1318: {"P", "P;2L", 2, unpackP2L}, -: 1319: {"P", "P;4", 4, unpackP4}, -: 1320: {"P", "P;4L", 4, unpackP4L}, -: 1321: {"P", "P", 8, copy1}, -: 1322: {"P", "P;R", 8, unpackLR}, -: 1323: -: 1324: /* palette w. alpha */ -: 1325: {"PA", "PA", 16, unpackLA}, -: 1326: {"PA", "PA;L", 16, unpackLAL}, -: 1327: -: 1328: /* true colour */ -: 1329: {"RGB", "RGB", 24, ImagingUnpackRGB}, -: 1330: {"RGB", "RGB;L", 24, unpackRGBL}, -: 1331: {"RGB", "RGB;R", 24, unpackRGBR}, -: 1332: {"RGB", "RGB;16L", 48, unpackRGB16L}, -: 1333: {"RGB", "RGB;16B", 48, unpackRGB16B}, -: 1334: {"RGB", "BGR", 24, ImagingUnpackBGR}, -: 1335: {"RGB", "RGB;15", 16, ImagingUnpackRGB15}, -: 1336: {"RGB", "BGR;15", 16, ImagingUnpackBGR15}, -: 1337: {"RGB", "RGB;16", 16, ImagingUnpackRGB16}, -: 1338: {"RGB", "BGR;16", 16, ImagingUnpackBGR16}, -: 1339: {"RGB", "RGB;4B", 16, ImagingUnpackRGB4B}, -: 1340: {"RGB", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */ -: 1341: {"RGB", "RGBX", 32, copy4}, -: 1342: {"RGB", "RGBX;L", 32, unpackRGBAL}, -: 1343: {"RGB", "RGBA;L", 32, unpackRGBAL}, -: 1344: {"RGB", "BGRX", 32, ImagingUnpackBGRX}, -: 1345: {"RGB", "XRGB", 32, ImagingUnpackXRGB}, -: 1346: {"RGB", "XBGR", 32, ImagingUnpackXBGR}, -: 1347: {"RGB", "YCC;P", 24, ImagingUnpackYCC}, -: 1348: {"RGB", "R", 8, band0}, -: 1349: {"RGB", "G", 8, band1}, -: 1350: {"RGB", "B", 8, band2}, -: 1351: -: 1352: /* true colour w. alpha */ -: 1353: {"RGBA", "LA", 16, unpackRGBALA}, -: 1354: {"RGBA", "LA;16B", 32, unpackRGBALA16B}, -: 1355: {"RGBA", "RGBA", 32, copy4}, -: 1356: {"RGBA", "RGBAX", 40, copy4skip1}, -: 1357: {"RGBA", "RGBAXX", 48, copy4skip2}, -: 1358: {"RGBA", "RGBa", 32, unpackRGBa}, -: 1359: {"RGBA", "RGBaX", 40, unpackRGBaskip1}, -: 1360: {"RGBA", "RGBaXX", 48, unpackRGBaskip2}, -: 1361: {"RGBA", "RGBa;16L", 64, unpackRGBa16L}, -: 1362: {"RGBA", "RGBa;16B", 64, unpackRGBa16B}, -: 1363: {"RGBA", "BGRa", 32, unpackBGRa}, -: 1364: {"RGBA", "RGBA;I", 32, unpackRGBAI}, -: 1365: {"RGBA", "RGBA;L", 32, unpackRGBAL}, -: 1366: {"RGBA", "RGBA;15", 16, ImagingUnpackRGBA15}, -: 1367: {"RGBA", "BGRA;15", 16, ImagingUnpackBGRA15}, -: 1368: {"RGBA", "RGBA;4B", 16, ImagingUnpackRGBA4B}, -: 1369: {"RGBA", "RGBA;16L", 64, unpackRGBA16L}, -: 1370: {"RGBA", "RGBA;16B", 64, unpackRGBA16B}, -: 1371: {"RGBA", "BGRA", 32, unpackBGRA}, -: 1372: {"RGBA", "ARGB", 32, unpackARGB}, -: 1373: {"RGBA", "ABGR", 32, unpackABGR}, -: 1374: {"RGBA", "YCCA;P", 32, ImagingUnpackYCCA}, -: 1375: {"RGBA", "R", 8, band0}, -: 1376: {"RGBA", "G", 8, band1}, -: 1377: {"RGBA", "B", 8, band2}, -: 1378: {"RGBA", "A", 8, band3}, -: 1379: -: 1380:#ifdef WORDS_BIGENDIAN -: 1381: {"RGB", "RGB;16N", 48, unpackRGB16B}, -: 1382: {"RGBA", "RGBa;16N", 64, unpackRGBa16B}, -: 1383: {"RGBA", "RGBA;16N", 64, unpackRGBA16B}, -: 1384: {"RGBX", "RGBX;16N", 64, unpackRGBA16B}, -: 1385:#else -: 1386: {"RGB", "RGB;16N", 48, unpackRGB16L}, -: 1387: {"RGBA", "RGBa;16N", 64, unpackRGBa16L}, -: 1388: {"RGBA", "RGBA;16N", 64, unpackRGBA16L}, -: 1389: {"RGBX", "RGBX;16N", 64, unpackRGBA16B}, -: 1390:#endif -: 1391: -: 1392: /* true colour w. alpha premultiplied */ -: 1393: {"RGBa", "RGBa", 32, copy4}, -: 1394: {"RGBa", "BGRa", 32, unpackBGRA}, -: 1395: {"RGBa", "aRGB", 32, unpackARGB}, -: 1396: {"RGBa", "aBGR", 32, unpackABGR}, -: 1397: -: 1398: /* true colour w. padding */ -: 1399: {"RGBX", "RGB", 24, ImagingUnpackRGB}, -: 1400: {"RGBX", "RGB;L", 24, unpackRGBL}, -: 1401: {"RGBX", "RGB;16B", 48, unpackRGB16B}, -: 1402: {"RGBX", "BGR", 24, ImagingUnpackBGR}, -: 1403: {"RGBX", "RGB;15", 16, ImagingUnpackRGB15}, -: 1404: {"RGBX", "BGR;15", 16, ImagingUnpackBGR15}, -: 1405: {"RGBX", "RGB;4B", 16, ImagingUnpackRGB4B}, -: 1406: {"RGBX", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */ -: 1407: {"RGBX", "RGBX", 32, copy4}, -: 1408: {"RGBX", "RGBXX", 40, copy4skip1}, -: 1409: {"RGBX", "RGBXXX", 48, copy4skip2}, -: 1410: {"RGBX", "RGBX;L", 32, unpackRGBAL}, -: 1411: {"RGBX", "RGBX;16L", 64, unpackRGBA16L}, -: 1412: {"RGBX", "RGBX;16B", 64, unpackRGBA16B}, -: 1413: {"RGBX", "BGRX", 32, ImagingUnpackBGRX}, -: 1414: {"RGBX", "XRGB", 32, ImagingUnpackXRGB}, -: 1415: {"RGBX", "XBGR", 32, ImagingUnpackXBGR}, -: 1416: {"RGBX", "YCC;P", 24, ImagingUnpackYCC}, -: 1417: {"RGBX", "R", 8, band0}, -: 1418: {"RGBX", "G", 8, band1}, -: 1419: {"RGBX", "B", 8, band2}, -: 1420: {"RGBX", "X", 8, band3}, -: 1421: -: 1422: /* colour separation */ -: 1423: {"CMYK", "CMYK", 32, copy4}, -: 1424: {"CMYK", "CMYKX", 40, copy4skip1}, -: 1425: {"CMYK", "CMYKXX", 48, copy4skip2}, -: 1426: {"CMYK", "CMYK;I", 32, unpackCMYKI}, -: 1427: {"CMYK", "CMYK;L", 32, unpackRGBAL}, -: 1428: {"CMYK", "CMYK;16L", 64, unpackRGBA16L}, -: 1429: {"CMYK", "CMYK;16B", 64, unpackRGBA16B}, -: 1430: {"CMYK", "C", 8, band0}, -: 1431: {"CMYK", "M", 8, band1}, -: 1432: {"CMYK", "Y", 8, band2}, -: 1433: {"CMYK", "K", 8, band3}, -: 1434: {"CMYK", "C;I", 8, band0I}, -: 1435: {"CMYK", "M;I", 8, band1I}, -: 1436: {"CMYK", "Y;I", 8, band2I}, -: 1437: {"CMYK", "K;I", 8, band3I}, -: 1438: -: 1439:#ifdef WORDS_BIGENDIAN -: 1440: {"CMYK", "CMYK;16N", 64, unpackRGBA16B}, -: 1441:#else -: 1442: {"CMYK", "CMYK;16N", 64, unpackRGBA16L}, -: 1443:#endif -: 1444: -: 1445: /* video (YCbCr) */ -: 1446: {"YCbCr", "YCbCr", 24, ImagingUnpackRGB}, -: 1447: {"YCbCr", "YCbCr;L", 24, unpackRGBL}, -: 1448: {"YCbCr", "YCbCrX", 32, copy4}, -: 1449: {"YCbCr", "YCbCrK", 32, copy4}, -: 1450: -: 1451: /* LAB Color */ -: 1452: {"LAB", "LAB", 24, ImagingUnpackLAB}, -: 1453: {"LAB", "L", 8, band0}, -: 1454: {"LAB", "A", 8, band1}, -: 1455: {"LAB", "B", 8, band2}, -: 1456: -: 1457: /* HSV Color */ -: 1458: {"HSV", "HSV", 24, ImagingUnpackRGB}, -: 1459: {"HSV", "H", 8, band0}, -: 1460: {"HSV", "S", 8, band1}, -: 1461: {"HSV", "V", 8, band2}, -: 1462: -: 1463: /* integer variations */ -: 1464: {"I", "I", 32, copy4}, -: 1465: {"I", "I;8", 8, unpackI8}, -: 1466: {"I", "I;8S", 8, unpackI8S}, -: 1467: {"I", "I;16", 16, unpackI16}, -: 1468: {"I", "I;16S", 16, unpackI16S}, -: 1469: {"I", "I;16B", 16, unpackI16B}, -: 1470: {"I", "I;16BS", 16, unpackI16BS}, -: 1471: {"I", "I;16N", 16, unpackI16N}, -: 1472: {"I", "I;16NS", 16, unpackI16NS}, -: 1473: {"I", "I;32", 32, unpackI32}, -: 1474: {"I", "I;32S", 32, unpackI32S}, -: 1475: {"I", "I;32B", 32, unpackI32B}, -: 1476: {"I", "I;32BS", 32, unpackI32BS}, -: 1477: {"I", "I;32N", 32, unpackI32N}, -: 1478: {"I", "I;32NS", 32, unpackI32NS}, -: 1479: -: 1480: /* floating point variations */ -: 1481: {"F", "F", 32, copy4}, -: 1482: {"F", "F;8", 8, unpackF8}, -: 1483: {"F", "F;8S", 8, unpackF8S}, -: 1484: {"F", "F;16", 16, unpackF16}, -: 1485: {"F", "F;16S", 16, unpackF16S}, -: 1486: {"F", "F;16B", 16, unpackF16B}, -: 1487: {"F", "F;16BS", 16, unpackF16BS}, -: 1488: {"F", "F;16N", 16, unpackF16N}, -: 1489: {"F", "F;16NS", 16, unpackF16NS}, -: 1490: {"F", "F;32", 32, unpackF32}, -: 1491: {"F", "F;32S", 32, unpackF32S}, -: 1492: {"F", "F;32B", 32, unpackF32B}, -: 1493: {"F", "F;32BS", 32, unpackF32BS}, -: 1494: {"F", "F;32N", 32, unpackF32N}, -: 1495: {"F", "F;32NS", 32, unpackF32NS}, -: 1496: {"F", "F;32F", 32, unpackF32F}, -: 1497: {"F", "F;32BF", 32, unpackF32BF}, -: 1498: {"F", "F;32NF", 32, unpackF32NF}, -: 1499:#ifdef FLOAT64 -: 1500: {"F", "F;64F", 64, unpackF64F}, -: 1501: {"F", "F;64BF", 64, unpackF64BF}, -: 1502: {"F", "F;64NF", 64, unpackF64NF}, -: 1503:#endif -: 1504: -: 1505: /* storage modes */ -: 1506: {"I;16", "I;16", 16, copy2}, -: 1507: {"I;16B", "I;16B", 16, copy2}, -: 1508: {"I;16L", "I;16L", 16, copy2}, -: 1509: -: 1510: {"I;16", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian. -: 1511: {"I;16L", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian. -: 1512: {"I;16B", "I;16N", 16, unpackI16N_I16B}, -: 1513: -: 1514: {"I;16", "I;12", 12, unpackI12_I16}, // 12 bit Tiffs stored in 16bits. -: 1515: -: 1516: {NULL} /* sentinel */ -: 1517:}; -: 1518: -: 1519: -: 1520:ImagingShuffler function ImagingFindUnpacker called 17246 returned 100% blocks executed 100% 17246: 1521:ImagingFindUnpacker(const char* mode, const char* rawmode, int* bits_out) -: 1522:{ -: 1523: int i; -: 1524: -: 1525: /* find a suitable pixel unpacker */ 164517: 1526: for (i = 0; unpackers[i].rawmode; i++) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 199732: 1527: if (strcmp(unpackers[i].mode, mode) == 0 && branch 0 taken 21% (fallthrough) branch 1 taken 79% branch 2 taken 49% (fallthrough) branch 3 taken 51% 35215: 1528: strcmp(unpackers[i].rawmode, rawmode) == 0) { 17246: 1529: if (bits_out) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 17246: 1530: *bits_out = unpackers[i].bits; -: 1531: } 17246: 1532: return unpackers[i].unpack; -: 1533: } -: 1534: } -: 1535: -: 1536: /* FIXME: configure a general unpacker based on the type codes... */ -: 1537: -: 1538: return NULL; -: 1539:} <<<<<< 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-aarch64-3.6/src/libImaging/Negative.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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/src#libImaging#ColorLUT.c.gcov -: 0:Source:src/libImaging/ColorLUT.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/ColorLUT.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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#RawEncode.c.gcov -: 0:Source:src/libImaging/RawEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/RawEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/RawEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * coder for raw data -: 6: * -: 7: * FIXME: This encoder will fail if the buffer is not large enough to -: 8: * hold one full line of data. There's a workaround for this problem -: 9: * in ImageFile.py, but it should be solved here instead. -: 10: * -: 11: * history: -: 12: * 96-04-30 fl created -: 13: * 97-01-03 fl fixed padding -: 14: * -: 15: * Copyright (c) Fredrik Lundh 1996-97. -: 16: * Copyright (c) Secret Labs AB 1997. -: 17: * -: 18: * See the README file for information on usage and redistribution. */ -: 19: -: 20: -: 21:#include "Imaging.h" -: 22: -: 23:int function ImagingRawEncode called 12656 returned 100% blocks executed 86% 12656: 24:ImagingRawEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 25:{ -: 26: UINT8* ptr; -: 27: 12656: 28: if (!state->state) { branch 0 taken 26% (fallthrough) branch 1 taken 74% -: 29: -: 30: /* The "count" field holds the stride, if specified. Fix -: 31: things up so "bytes" is the full size, and "count" the -: 32: packed size */ -: 33: 3234: 34: if (state->count > 0) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 57: 35: int bytes = state->count; -: 36: -: 37: /* stride must not be less than real size */ 57: 38: if (state->count < state->bytes) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 39: state->errcode = IMAGING_CODEC_CONFIG; #####: 40: return -1; -: 41: } 57: 42: state->count = state->bytes; 57: 43: state->bytes = bytes; -: 44: } else { 3177: 45: state->count = state->bytes; -: 46: } -: 47: -: 48: /* The "ystep" field specifies the orientation */ -: 49: 3234: 50: if (state->ystep < 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 46: 51: state->y = state->ysize-1; 46: 52: state->ystep = -1; -: 53: } else { 3188: 54: state->ystep = 1; -: 55: } -: 56: 3234: 57: state->state = 1; -: 58: -: 59: } -: 60: 12656: 61: if (bytes < state->bytes) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 62: state->errcode = IMAGING_CODEC_CONFIG; #####: 63: return 0; -: 64: } -: 65: -: 66: ptr = buf; -: 67: 447494: 68: while (bytes >= state->bytes) { branch 0 taken 98% branch 1 taken 2% (fallthrough) -: 69: 876144: 70: state->shuffle(ptr, (UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 438072: 71: state->xoff * im->pixelsize, state->xsize); -: 72: 438072: 73: if (state->bytes > state->count) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 74: /* zero-pad the buffer, if necessary */ #####: 75: memset(ptr + state->count, 0, state->bytes - state->count); -: 76: } -: 77: 438072: 78: ptr += state->bytes; 438072: 79: bytes -= state->bytes; -: 80: 438072: 81: state->y += state->ystep; -: 82: 438072: 83: if (state->y < 0 || state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 3234: 84: state->errcode = IMAGING_CODEC_END; 3234: 85: break; -: 86: } -: 87: -: 88: } -: 89: 12656: 90: return ptr - buf; -: 91: -: 92:} <<<<<< 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-aarch64-3.6/src/libImaging/QuantPngQuant.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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/src#libImaging#Filter.c.gcov -: 0:Source:src/libImaging/Filter.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Filter.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Filter.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * apply convolution kernel to image -: 6: * -: 7: * history: -: 8: * 1995-11-26 fl Created, supports 3x3 kernels -: 9: * 1995-11-27 fl Added 5x5 kernels, copy border -: 10: * 1999-07-26 fl Eliminated a few compiler warnings -: 11: * 2002-06-09 fl Moved kernel definitions to Python -: 12: * 2002-06-11 fl Support floating point kernels -: 13: * 2003-09-15 fl Added ImagingExpand helper -: 14: * -: 15: * Copyright (c) Secret Labs AB 1997-2002. All rights reserved. -: 16: * Copyright (c) Fredrik Lundh 1995. -: 17: * -: 18: * See the README file for information on usage and redistribution. -: 19: */ -: 20: -: 21:/* -: 22: * FIXME: Support RGB and RGBA/CMYK modes as well -: 23: * FIXME: Expand image border (current version leaves border as is) -: 24: * FIXME: Implement image processing gradient filters -: 25: */ -: 26: -: 27:#include "Imaging.h" -: 28: -: 29: -: 30:static inline UINT8 clip8(float in) -: 31:{ 1858871: 32: if (in <= 0.0) { branch 0 taken 82% (fallthrough) branch 1 taken 18% branch 2 taken 46% (fallthrough) branch 3 taken 54% branch 4 taken 48% (fallthrough) branch 5 taken 52% branch 6 taken 86% (fallthrough) branch 7 taken 14% branch 8 taken 87% (fallthrough) branch 9 taken 13% branch 10 taken 88% (fallthrough) branch 11 taken 12% branch 12 taken 82% (fallthrough) branch 13 taken 18% branch 14 taken 83% (fallthrough) branch 15 taken 17% branch 16 taken 84% (fallthrough) branch 17 taken 16% branch 18 taken 82% (fallthrough) branch 19 taken 18% branch 20 taken 84% (fallthrough) branch 21 taken 16% branch 22 taken 48% (fallthrough) branch 23 taken 52% branch 24 taken 50% (fallthrough) branch 25 taken 50% branch 26 taken 85% (fallthrough) branch 27 taken 15% branch 28 taken 85% (fallthrough) branch 29 taken 15% branch 30 taken 86% (fallthrough) branch 31 taken 14% branch 32 taken 88% (fallthrough) branch 33 taken 12% branch 34 taken 89% (fallthrough) branch 35 taken 11% branch 36 taken 90% (fallthrough) branch 37 taken 10% branch 38 taken 96% (fallthrough) branch 39 taken 4% -: 33: return 0; -: 34: } 1596832: 35: if (in >= 255.0) { branch 0 taken 90% (fallthrough) branch 1 taken 10% branch 2 taken 48% (fallthrough) branch 3 taken 52% branch 4 taken 53% (fallthrough) branch 5 taken 47% branch 6 taken 93% (fallthrough) branch 7 taken 7% branch 8 taken 94% (fallthrough) branch 9 taken 6% branch 10 taken 93% (fallthrough) branch 11 taken 7% branch 12 taken 90% (fallthrough) branch 13 taken 10% branch 14 taken 91% (fallthrough) branch 15 taken 9% branch 16 taken 90% (fallthrough) branch 17 taken 10% branch 18 taken 90% (fallthrough) branch 19 taken 10% branch 20 taken 88% (fallthrough) branch 21 taken 12% branch 22 taken 75% (fallthrough) branch 23 taken 25% branch 24 taken 77% (fallthrough) branch 25 taken 23% branch 26 taken 88% (fallthrough) branch 27 taken 12% branch 28 taken 89% (fallthrough) branch 29 taken 11% branch 30 taken 89% (fallthrough) branch 31 taken 11% branch 32 taken 89% (fallthrough) branch 33 taken 11% branch 34 taken 89% (fallthrough) branch 35 taken 11% branch 36 taken 89% (fallthrough) branch 37 taken 11% branch 38 taken 77% (fallthrough) branch 39 taken 23% -: 36: return 255; -: 37: } 1399714: 38: return (UINT8) in; -: 39:} -: 40: -: 41:Imaging function ImagingExpand called 47 returned 100% blocks executed 99% 47: 42:ImagingExpand(Imaging imIn, int xmargin, int ymargin, int mode) -: 43:{ -: 44: Imaging imOut; -: 45: int x, y; -: 46: ImagingSectionCookie cookie; -: 47: 47: 48: if (xmargin < 0 && ymargin < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 49: return (Imaging) ImagingError_ValueError("bad kernel size"); call 0 never executed -: 50: } -: 51: 94: 52: imOut = ImagingNewDirty( call 0 returned 100% 94: 53: imIn->mode, imIn->xsize+2*xmargin, imIn->ysize+2*ymargin); 47: 54: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 55: return NULL; -: 56: } -: 57: -: 58:#define EXPAND_LINE(type, image, yin, yout) {\ -: 59: for (x = 0; x < xmargin; x++) {\ -: 60: imOut->image[yout][x] = imIn->image[yin][0];\ -: 61: }\ -: 62: for (x = 0; x < imIn->xsize; x++) {\ -: 63: imOut->image[yout][x+xmargin] = imIn->image[yin][x];\ -: 64: }\ -: 65: for (x = 0; x < xmargin; x++) {\ -: 66: imOut->image[yout][xmargin+imIn->xsize+x] =\ -: 67: imIn->image[yin][imIn->xsize-1];\ -: 68: }\ -: 69:} -: 70: -: 71:#define EXPAND(type, image) {\ -: 72: for (y = 0; y < ymargin; y++) {\ -: 73: EXPAND_LINE(type, image, 0, y);\ -: 74: }\ -: 75: for (y = 0; y < imIn->ysize; y++) {\ -: 76: EXPAND_LINE(type, image, y, y+ymargin);\ -: 77: }\ -: 78: for (y = 0; y < ymargin; y++) {\ -: 79: EXPAND_LINE(type, image, imIn->ysize-1, ymargin+imIn->ysize+y);\ -: 80: }\ -: 81:} -: 82: 47: 83: ImagingSectionEnter(&cookie); call 0 returned 100% 47: 84: if (imIn->image8) { branch 0 taken 17% (fallthrough) branch 1 taken 83% 39: 85: EXPAND(UINT8, image8); branch 0 taken 50% branch 1 taken 50% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 50% branch 5 taken 50% (fallthrough) branch 6 taken 50% (fallthrough) branch 7 taken 50% branch 8 taken 50% branch 9 taken 50% (fallthrough) branch 10 taken 99% branch 11 taken 1% (fallthrough) branch 12 taken 50% branch 13 taken 50% (fallthrough) branch 14 taken 99% (fallthrough) branch 15 taken 1% branch 16 taken 50% branch 17 taken 50% (fallthrough) branch 18 taken 99% branch 19 taken 1% (fallthrough) branch 20 taken 50% branch 21 taken 50% (fallthrough) branch 22 taken 50% (fallthrough) branch 23 taken 50% -: 86: } else { 46: 87: EXPAND(INT32, image32); branch 0 taken 77% branch 1 taken 23% (fallthrough) branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 77% branch 5 taken 23% (fallthrough) branch 6 taken 64% (fallthrough) branch 7 taken 36% branch 8 taken 83% branch 9 taken 17% (fallthrough) branch 10 taken 99% branch 11 taken 1% (fallthrough) branch 12 taken 83% branch 13 taken 17% (fallthrough) branch 14 taken 97% (fallthrough) branch 15 taken 3% branch 16 taken 77% branch 17 taken 23% (fallthrough) branch 18 taken 99% branch 19 taken 1% (fallthrough) branch 20 taken 77% branch 21 taken 23% (fallthrough) branch 22 taken 64% (fallthrough) branch 23 taken 36% -: 88: } 47: 89: ImagingSectionLeave(&cookie); call 0 returned 100% -: 90: 47: 91: ImagingCopyPalette(imOut, imIn); call 0 returned 100% -: 92: 47: 93: return imOut; -: 94:} -: 95: -: 96: -: 97:void function ImagingFilter3x3 called 33 returned 100% blocks executed 100% 33: 98:ImagingFilter3x3(Imaging imOut, Imaging im, const float* kernel, -: 99: float offset) -: 100:{ -: 101:#define KERNEL1x3(in0, x, kernel, d) ( \ -: 102: _i2f((UINT8) in0[x-d]) * (kernel)[0] + \ -: 103: _i2f((UINT8) in0[x]) * (kernel)[1] + \ -: 104: _i2f((UINT8) in0[x+d]) * (kernel)[2]) -: 105: 33: 106: int x = 0, y = 0; -: 107: 66: 108: memcpy(imOut->image[0], im->image[0], im->linesize); 33: 109: if (im->bands == 1) { branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 110: // Add one time for rounding 9: 111: offset += 0.5; 1143: 112: for (y = 1; y < im->ysize-1; y++) { branch 0 taken 99% branch 1 taken 1% 1134: 113: UINT8* in_1 = (UINT8*) im->image[y-1]; 1134: 114: UINT8* in0 = (UINT8*) im->image[y]; 1134: 115: UINT8* in1 = (UINT8*) im->image[y+1]; 1134: 116: UINT8* out = (UINT8*) imOut->image[y]; -: 117: 1134: 118: out[0] = in0[0]; 144018: 119: for (x = 1; x < im->xsize-1; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 142884: 120: float ss = offset; 571536: 121: ss += KERNEL1x3(in1, x, &kernel[0], 1); 571536: 122: ss += KERNEL1x3(in0, x, &kernel[3], 1); 571536: 123: ss += KERNEL1x3(in_1, x, &kernel[6], 1); 285768: 124: out[x] = clip8(ss); -: 125: } 1134: 126: out[x] = in0[x]; -: 127: } -: 128: } else { -: 129: // Add one time for rounding 24: 130: offset += 0.5; 2923: 131: for (y = 1; y < im->ysize-1; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2899: 132: UINT8* in_1 = (UINT8*) im->image[y-1]; 2899: 133: UINT8* in0 = (UINT8*) im->image[y]; 2899: 134: UINT8* in1 = (UINT8*) im->image[y+1]; 2899: 135: UINT8* out = (UINT8*) imOut->image[y]; -: 136: 2899: 137: memcpy(out, in0, sizeof(UINT32)); 2899: 138: if (im->bands == 2) { branch 0 taken 4% (fallthrough) branch 1 taken 96% 15876: 139: for (x = 1; x < im->xsize-1; x++) { branch 0 taken 99% branch 1 taken 1% 15876: 140: float ss0 = offset; 15876: 141: float ss3 = offset; -: 142: UINT32 v; 63504: 143: ss0 += KERNEL1x3(in1, x*4+0, &kernel[0], 4); 63504: 144: ss3 += KERNEL1x3(in1, x*4+3, &kernel[0], 4); 63504: 145: ss0 += KERNEL1x3(in0, x*4+0, &kernel[3], 4); 63504: 146: ss3 += KERNEL1x3(in0, x*4+3, &kernel[3], 4); 63504: 147: ss0 += KERNEL1x3(in_1, x*4+0, &kernel[6], 4); 63504: 148: ss3 += KERNEL1x3(in_1, x*4+3, &kernel[6], 4); 31752: 149: v = MAKE_UINT32(clip8(ss0), 0, 0, clip8(ss3)); 31752: 150: memcpy(out + x * sizeof(v), &v, sizeof(v)); -: 151: } 2773: 152: } else if (im->bands == 3) { branch 0 taken 45% (fallthrough) branch 1 taken 55% 158761: 153: for (x = 1; x < im->xsize-1; x++) { branch 0 taken 99% branch 1 taken 1% 158761: 154: float ss0 = offset; 158761: 155: float ss1 = offset; 158761: 156: float ss2 = offset; -: 157: UINT32 v; 635044: 158: ss0 += KERNEL1x3(in1, x*4+0, &kernel[0], 4); 635044: 159: ss1 += KERNEL1x3(in1, x*4+1, &kernel[0], 4); 635044: 160: ss2 += KERNEL1x3(in1, x*4+2, &kernel[0], 4); 635044: 161: ss0 += KERNEL1x3(in0, x*4+0, &kernel[3], 4); 635044: 162: ss1 += KERNEL1x3(in0, x*4+1, &kernel[3], 4); 635044: 163: ss2 += KERNEL1x3(in0, x*4+2, &kernel[3], 4); 635044: 164: ss0 += KERNEL1x3(in_1, x*4+0, &kernel[6], 4); 635044: 165: ss1 += KERNEL1x3(in_1, x*4+1, &kernel[6], 4); 635044: 166: ss2 += KERNEL1x3(in_1, x*4+2, &kernel[6], 4); 476283: 167: v = MAKE_UINT32( -: 168: clip8(ss0), clip8(ss1), clip8(ss2), 0); 317522: 169: memcpy(out + x * sizeof(v), &v, sizeof(v)); -: 170: } 1512: 171: } else if (im->bands == 4) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 190512: 172: for (x = 1; x < im->xsize-1; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 190512: 173: float ss0 = offset; 190512: 174: float ss1 = offset; 190512: 175: float ss2 = offset; 190512: 176: float ss3 = offset; -: 177: UINT32 v; 762048: 178: ss0 += KERNEL1x3(in1, x*4+0, &kernel[0], 4); 762048: 179: ss1 += KERNEL1x3(in1, x*4+1, &kernel[0], 4); 762048: 180: ss2 += KERNEL1x3(in1, x*4+2, &kernel[0], 4); 762048: 181: ss3 += KERNEL1x3(in1, x*4+3, &kernel[0], 4); 762048: 182: ss0 += KERNEL1x3(in0, x*4+0, &kernel[3], 4); 762048: 183: ss1 += KERNEL1x3(in0, x*4+1, &kernel[3], 4); 762048: 184: ss2 += KERNEL1x3(in0, x*4+2, &kernel[3], 4); 762048: 185: ss3 += KERNEL1x3(in0, x*4+3, &kernel[3], 4); 762048: 186: ss0 += KERNEL1x3(in_1, x*4+0, &kernel[6], 4); 762048: 187: ss1 += KERNEL1x3(in_1, x*4+1, &kernel[6], 4); 762048: 188: ss2 += KERNEL1x3(in_1, x*4+2, &kernel[6], 4); 762048: 189: ss3 += KERNEL1x3(in_1, x*4+3, &kernel[6], 4); 762048: 190: v = MAKE_UINT32( -: 191: clip8(ss0), clip8(ss1), clip8(ss2), clip8(ss3)); 381024: 192: memcpy(out + x * sizeof(v), &v, sizeof(v)); -: 193: } -: 194: } 5798: 195: memcpy(out + x * sizeof(UINT32), in0 + x * sizeof(UINT32), sizeof(UINT32)); -: 196: } -: 197: } 66: 198: memcpy(imOut->image[y], im->image[y], im->linesize); 33: 199:} -: 200: -: 201: -: 202:void function ImagingFilter5x5 called 11 returned 100% blocks executed 100% 11: 203:ImagingFilter5x5(Imaging imOut, Imaging im, const float* kernel, -: 204: float offset) -: 205:{ -: 206:#define KERNEL1x5(in0, x, kernel, d) ( \ -: 207: _i2f((UINT8) in0[x-d-d]) * (kernel)[0] + \ -: 208: _i2f((UINT8) in0[x-d]) * (kernel)[1] + \ -: 209: _i2f((UINT8) in0[x]) * (kernel)[2] + \ -: 210: _i2f((UINT8) in0[x+d]) * (kernel)[3] + \ -: 211: _i2f((UINT8) in0[x+d+d]) * (kernel)[4]) -: 212: 11: 213: int x = 0, y = 0; -: 214: 22: 215: memcpy(imOut->image[0], im->image[0], im->linesize); 22: 216: memcpy(imOut->image[1], im->image[1], im->linesize); 11: 217: if (im->bands == 1) { branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 218: // Add one time for rounding 3: 219: offset += 0.5; 375: 220: for (y = 2; y < im->ysize-2; y++) { branch 0 taken 99% branch 1 taken 1% 372: 221: UINT8* in_2 = (UINT8*) im->image[y-2]; 372: 222: UINT8* in_1 = (UINT8*) im->image[y-1]; 372: 223: UINT8* in0 = (UINT8*) im->image[y]; 372: 224: UINT8* in1 = (UINT8*) im->image[y+1]; 372: 225: UINT8* in2 = (UINT8*) im->image[y+2]; 372: 226: UINT8* out = (UINT8*) imOut->image[y]; -: 227: 372: 228: out[0] = in0[0]; 372: 229: out[1] = in0[1]; 46500: 230: for (x = 2; x < im->xsize-2; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 46128: 231: float ss = offset; 276768: 232: ss += KERNEL1x5(in2, x, &kernel[0], 1); 276768: 233: ss += KERNEL1x5(in1, x, &kernel[5], 1); 276768: 234: ss += KERNEL1x5(in0, x, &kernel[10], 1); 276768: 235: ss += KERNEL1x5(in_1, x, &kernel[15], 1); 276768: 236: ss += KERNEL1x5(in_2, x, &kernel[20], 1); 92256: 237: out[x] = clip8(ss); -: 238: } 372: 239: out[x+0] = in0[x+0]; 372: 240: out[x+1] = in0[x+1]; -: 241: } -: 242: } else { -: 243: // Add one time for rounding 8: 244: offset += 0.5; 1000: 245: for (y = 2; y < im->ysize-2; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 992: 246: UINT8* in_2 = (UINT8*) im->image[y-2]; 992: 247: UINT8* in_1 = (UINT8*) im->image[y-1]; 992: 248: UINT8* in0 = (UINT8*) im->image[y]; 992: 249: UINT8* in1 = (UINT8*) im->image[y+1]; 992: 250: UINT8* in2 = (UINT8*) im->image[y+2]; 992: 251: UINT8* out = (UINT8*) imOut->image[y]; -: 252: 992: 253: memcpy(out, in0, sizeof(UINT32) * 2); 992: 254: if (im->bands == 2) { branch 0 taken 13% (fallthrough) branch 1 taken 88% 15376: 255: for (x = 2; x < im->xsize-2; x++) { branch 0 taken 99% branch 1 taken 1% 15376: 256: float ss0 = offset; 15376: 257: float ss3 = offset; -: 258: UINT32 v; 92256: 259: ss0 += KERNEL1x5(in2, x*4+0, &kernel[0], 4); 92256: 260: ss3 += KERNEL1x5(in2, x*4+3, &kernel[0], 4); 92256: 261: ss0 += KERNEL1x5(in1, x*4+0, &kernel[5], 4); 92256: 262: ss3 += KERNEL1x5(in1, x*4+3, &kernel[5], 4); 92256: 263: ss0 += KERNEL1x5(in0, x*4+0, &kernel[10], 4); 92256: 264: ss3 += KERNEL1x5(in0, x*4+3, &kernel[10], 4); 92256: 265: ss0 += KERNEL1x5(in_1, x*4+0, &kernel[15], 4); 92256: 266: ss3 += KERNEL1x5(in_1, x*4+3, &kernel[15], 4); 92256: 267: ss0 += KERNEL1x5(in_2, x*4+0, &kernel[20], 4); 92256: 268: ss3 += KERNEL1x5(in_2, x*4+3, &kernel[20], 4); 30752: 269: v = MAKE_UINT32(clip8(ss0), 0, 0, clip8(ss3)); 30752: 270: memcpy(out + x * sizeof(v), &v, sizeof(v)); -: 271: } 868: 272: } else if (im->bands == 3) { branch 0 taken 57% (fallthrough) branch 1 taken 43% 61504: 273: for (x = 2; x < im->xsize-2; x++) { branch 0 taken 99% branch 1 taken 1% 61504: 274: float ss0 = offset; 61504: 275: float ss1 = offset; 61504: 276: float ss2 = offset; -: 277: UINT32 v; 369024: 278: ss0 += KERNEL1x5(in2, x*4+0, &kernel[0], 4); 369024: 279: ss1 += KERNEL1x5(in2, x*4+1, &kernel[0], 4); 369024: 280: ss2 += KERNEL1x5(in2, x*4+2, &kernel[0], 4); 369024: 281: ss0 += KERNEL1x5(in1, x*4+0, &kernel[5], 4); 369024: 282: ss1 += KERNEL1x5(in1, x*4+1, &kernel[5], 4); 369024: 283: ss2 += KERNEL1x5(in1, x*4+2, &kernel[5], 4); 369024: 284: ss0 += KERNEL1x5(in0, x*4+0, &kernel[10], 4); 369024: 285: ss1 += KERNEL1x5(in0, x*4+1, &kernel[10], 4); 369024: 286: ss2 += KERNEL1x5(in0, x*4+2, &kernel[10], 4); 369024: 287: ss0 += KERNEL1x5(in_1, x*4+0, &kernel[15], 4); 369024: 288: ss1 += KERNEL1x5(in_1, x*4+1, &kernel[15], 4); 369024: 289: ss2 += KERNEL1x5(in_1, x*4+2, &kernel[15], 4); 369024: 290: ss0 += KERNEL1x5(in_2, x*4+0, &kernel[20], 4); 369024: 291: ss1 += KERNEL1x5(in_2, x*4+1, &kernel[20], 4); 369024: 292: ss2 += KERNEL1x5(in_2, x*4+2, &kernel[20], 4); 184512: 293: v = MAKE_UINT32( -: 294: clip8(ss0), clip8(ss1), clip8(ss2), 0); 123008: 295: memcpy(out + x * sizeof(v), &v, sizeof(v)); -: 296: } 372: 297: } else if (im->bands == 4) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 46128: 298: for (x = 2; x < im->xsize-2; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 46128: 299: float ss0 = offset; 46128: 300: float ss1 = offset; 46128: 301: float ss2 = offset; 46128: 302: float ss3 = offset; -: 303: UINT32 v; 276768: 304: ss0 += KERNEL1x5(in2, x*4+0, &kernel[0], 4); 276768: 305: ss1 += KERNEL1x5(in2, x*4+1, &kernel[0], 4); 276768: 306: ss2 += KERNEL1x5(in2, x*4+2, &kernel[0], 4); 276768: 307: ss3 += KERNEL1x5(in2, x*4+3, &kernel[0], 4); 276768: 308: ss0 += KERNEL1x5(in1, x*4+0, &kernel[5], 4); 276768: 309: ss1 += KERNEL1x5(in1, x*4+1, &kernel[5], 4); 276768: 310: ss2 += KERNEL1x5(in1, x*4+2, &kernel[5], 4); 276768: 311: ss3 += KERNEL1x5(in1, x*4+3, &kernel[5], 4); 276768: 312: ss0 += KERNEL1x5(in0, x*4+0, &kernel[10], 4); 276768: 313: ss1 += KERNEL1x5(in0, x*4+1, &kernel[10], 4); 276768: 314: ss2 += KERNEL1x5(in0, x*4+2, &kernel[10], 4); 276768: 315: ss3 += KERNEL1x5(in0, x*4+3, &kernel[10], 4); 276768: 316: ss0 += KERNEL1x5(in_1, x*4+0, &kernel[15], 4); 276768: 317: ss1 += KERNEL1x5(in_1, x*4+1, &kernel[15], 4); 276768: 318: ss2 += KERNEL1x5(in_1, x*4+2, &kernel[15], 4); 276768: 319: ss3 += KERNEL1x5(in_1, x*4+3, &kernel[15], 4); 276768: 320: ss0 += KERNEL1x5(in_2, x*4+0, &kernel[20], 4); 276768: 321: ss1 += KERNEL1x5(in_2, x*4+1, &kernel[20], 4); 276768: 322: ss2 += KERNEL1x5(in_2, x*4+2, &kernel[20], 4); 276768: 323: ss3 += KERNEL1x5(in_2, x*4+3, &kernel[20], 4); 184512: 324: v = MAKE_UINT32( -: 325: clip8(ss0), clip8(ss1), clip8(ss2), clip8(ss3)); 92256: 326: memcpy(out + x * sizeof(v), &v, sizeof(v)); -: 327: } -: 328: } 1984: 329: memcpy(out + x * sizeof(UINT32), in0 + x * sizeof(UINT32), sizeof(UINT32) * 2); -: 330: } -: 331: } 22: 332: memcpy(imOut->image[y], im->image[y], im->linesize); 22: 333: memcpy(imOut->image[y+1], im->image[y+1], im->linesize); 11: 334:} -: 335: -: 336:Imaging function ImagingFilter called 47 returned 100% blocks executed 89% 47: 337:ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32* kernel, -: 338: FLOAT32 offset) -: 339:{ -: 340: Imaging imOut; -: 341: ImagingSectionCookie cookie; -: 342: 47: 343: if ( ! im || im->type != IMAGING_TYPE_UINT8) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 344: return (Imaging) ImagingError_ModeError(); call 0 never executed -: 345: } -: 346: 47: 347: if (im->xsize < xsize || im->ysize < ysize) { branch 0 taken 94% (fallthrough) branch 1 taken 6% branch 2 taken 0% (fallthrough) branch 3 taken 100% 3: 348: return ImagingCopy(im); call 0 returned 100% -: 349: } -: 350: 44: 351: if ((xsize != 3 && xsize != 5) || xsize != ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 352: return (Imaging) ImagingError_ValueError("bad kernel size"); call 0 never executed -: 353: } -: 354: 44: 355: imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize); call 0 returned 100% 44: 356: if (!imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 357: return NULL; -: 358: } -: 359: 44: 360: ImagingSectionEnter(&cookie); call 0 returned 100% 44: 361: if (xsize == 3) { branch 0 taken 75% (fallthrough) branch 1 taken 25% -: 362: /* 3x3 kernel. */ 33: 363: ImagingFilter3x3(imOut, im, kernel, offset); call 0 returned 100% -: 364: } else { -: 365: /* 5x5 kernel. */ 11: 366: ImagingFilter5x5(imOut, im, kernel, offset); call 0 returned 100% -: 367: } 44: 368: ImagingSectionLeave(&cookie); call 0 returned 100% 44: 369: return imOut; -: 370:} -: 371: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ConvertYCbCr.c.gcov -: 0:Source:src/libImaging/ConvertYCbCr.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/ConvertYCbCr.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/ConvertYCbCr.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * code to convert YCbCr data -: 6: * -: 7: * history: -: 8: * 98-07-01 hk Created -: 9: * -: 10: * Copyright (c) Secret Labs AB 1998 -: 11: * -: 12: * See the README file for information on usage and redistribution. -: 13: */ -: 14: -: 15:#include "Imaging.h" -: 16: -: 17:/* JPEG/JFIF YCbCr conversions -: 18: -: 19: Y = R * 0.29900 + G * 0.58700 + B * 0.11400 -: 20: Cb = R * -0.16874 + G * -0.33126 + B * 0.50000 + 128 -: 21: Cr = R * 0.50000 + G * -0.41869 + B * -0.08131 + 128 -: 22: -: 23: R = Y + + (Cr - 128) * 1.40200 -: 24: G = Y + (Cb - 128) * -0.34414 + (Cr - 128) * -0.71414 -: 25: B = Y + (Cb - 128) * 1.77200 -: 26: -: 27:*/ -: 28: -: 29:#define SCALE 6 /* bits */ -: 30: -: 31:static INT16 Y_R[] = { 0, 19, 38, 57, 77, 96, 115, 134, 153, 172, 191, -: 32:210, 230, 249, 268, 287, 306, 325, 344, 364, 383, 402, 421, 440, 459, -: 33:478, 498, 517, 536, 555, 574, 593, 612, 631, 651, 670, 689, 708, 727, -: 34:746, 765, 785, 804, 823, 842, 861, 880, 899, 919, 938, 957, 976, 995, -: 35:1014, 1033, 1052, 1072, 1091, 1110, 1129, 1148, 1167, 1186, 1206, -: 36:1225, 1244, 1263, 1282, 1301, 1320, 1340, 1359, 1378, 1397, 1416, -: 37:1435, 1454, 1473, 1493, 1512, 1531, 1550, 1569, 1588, 1607, 1627, -: 38:1646, 1665, 1684, 1703, 1722, 1741, 1761, 1780, 1799, 1818, 1837, -: 39:1856, 1875, 1894, 1914, 1933, 1952, 1971, 1990, 2009, 2028, 2048, -: 40:2067, 2086, 2105, 2124, 2143, 2162, 2182, 2201, 2220, 2239, 2258, -: 41:2277, 2296, 2315, 2335, 2354, 2373, 2392, 2411, 2430, 2449, 2469, -: 42:2488, 2507, 2526, 2545, 2564, 2583, 2602, 2622, 2641, 2660, 2679, -: 43:2698, 2717, 2736, 2756, 2775, 2794, 2813, 2832, 2851, 2870, 2890, -: 44:2909, 2928, 2947, 2966, 2985, 3004, 3023, 3043, 3062, 3081, 3100, -: 45:3119, 3138, 3157, 3177, 3196, 3215, 3234, 3253, 3272, 3291, 3311, -: 46:3330, 3349, 3368, 3387, 3406, 3425, 3444, 3464, 3483, 3502, 3521, -: 47:3540, 3559, 3578, 3598, 3617, 3636, 3655, 3674, 3693, 3712, 3732, -: 48:3751, 3770, 3789, 3808, 3827, 3846, 3865, 3885, 3904, 3923, 3942, -: 49:3961, 3980, 3999, 4019, 4038, 4057, 4076, 4095, 4114, 4133, 4153, -: 50:4172, 4191, 4210, 4229, 4248, 4267, 4286, 4306, 4325, 4344, 4363, -: 51:4382, 4401, 4420, 4440, 4459, 4478, 4497, 4516, 4535, 4554, 4574, -: 52:4593, 4612, 4631, 4650, 4669, 4688, 4707, 4727, 4746, 4765, 4784, -: 53:4803, 4822, 4841, 4861, 4880 }; -: 54: -: 55:static INT16 Y_G[] = { 0, 38, 75, 113, 150, 188, 225, 263, 301, 338, -: 56:376, 413, 451, 488, 526, 564, 601, 639, 676, 714, 751, 789, 826, 864, -: 57:902, 939, 977, 1014, 1052, 1089, 1127, 1165, 1202, 1240, 1277, 1315, -: 58:1352, 1390, 1428, 1465, 1503, 1540, 1578, 1615, 1653, 1691, 1728, -: 59:1766, 1803, 1841, 1878, 1916, 1954, 1991, 2029, 2066, 2104, 2141, -: 60:2179, 2217, 2254, 2292, 2329, 2367, 2404, 2442, 2479, 2517, 2555, -: 61:2592, 2630, 2667, 2705, 2742, 2780, 2818, 2855, 2893, 2930, 2968, -: 62:3005, 3043, 3081, 3118, 3156, 3193, 3231, 3268, 3306, 3344, 3381, -: 63:3419, 3456, 3494, 3531, 3569, 3607, 3644, 3682, 3719, 3757, 3794, -: 64:3832, 3870, 3907, 3945, 3982, 4020, 4057, 4095, 4132, 4170, 4208, -: 65:4245, 4283, 4320, 4358, 4395, 4433, 4471, 4508, 4546, 4583, 4621, -: 66:4658, 4696, 4734, 4771, 4809, 4846, 4884, 4921, 4959, 4997, 5034, -: 67:5072, 5109, 5147, 5184, 5222, 5260, 5297, 5335, 5372, 5410, 5447, -: 68:5485, 5522, 5560, 5598, 5635, 5673, 5710, 5748, 5785, 5823, 5861, -: 69:5898, 5936, 5973, 6011, 6048, 6086, 6124, 6161, 6199, 6236, 6274, -: 70:6311, 6349, 6387, 6424, 6462, 6499, 6537, 6574, 6612, 6650, 6687, -: 71:6725, 6762, 6800, 6837, 6875, 6913, 6950, 6988, 7025, 7063, 7100, -: 72:7138, 7175, 7213, 7251, 7288, 7326, 7363, 7401, 7438, 7476, 7514, -: 73:7551, 7589, 7626, 7664, 7701, 7739, 7777, 7814, 7852, 7889, 7927, -: 74:7964, 8002, 8040, 8077, 8115, 8152, 8190, 8227, 8265, 8303, 8340, -: 75:8378, 8415, 8453, 8490, 8528, 8566, 8603, 8641, 8678, 8716, 8753, -: 76:8791, 8828, 8866, 8904, 8941, 8979, 9016, 9054, 9091, 9129, 9167, -: 77:9204, 9242, 9279, 9317, 9354, 9392, 9430, 9467, 9505, 9542, 9580 }; -: 78: -: 79:static INT16 Y_B[] = { 0, 7, 15, 22, 29, 36, 44, 51, 58, 66, 73, 80, -: 80:88, 95, 102, 109, 117, 124, 131, 139, 146, 153, 161, 168, 175, 182, -: 81:190, 197, 204, 212, 219, 226, 233, 241, 248, 255, 263, 270, 277, 285, -: 82:292, 299, 306, 314, 321, 328, 336, 343, 350, 358, 365, 372, 379, 387, -: 83:394, 401, 409, 416, 423, 430, 438, 445, 452, 460, 467, 474, 482, 489, -: 84:496, 503, 511, 518, 525, 533, 540, 547, 554, 562, 569, 576, 584, 591, -: 85:598, 606, 613, 620, 627, 635, 642, 649, 657, 664, 671, 679, 686, 693, -: 86:700, 708, 715, 722, 730, 737, 744, 751, 759, 766, 773, 781, 788, 795, -: 87:803, 810, 817, 824, 832, 839, 846, 854, 861, 868, 876, 883, 890, 897, -: 88:905, 912, 919, 927, 934, 941, 948, 956, 963, 970, 978, 985, 992, 1000, -: 89:1007, 1014, 1021, 1029, 1036, 1043, 1051, 1058, 1065, 1073, 1080, -: 90:1087, 1094, 1102, 1109, 1116, 1124, 1131, 1138, 1145, 1153, 1160, -: 91:1167, 1175, 1182, 1189, 1197, 1204, 1211, 1218, 1226, 1233, 1240, -: 92:1248, 1255, 1262, 1270, 1277, 1284, 1291, 1299, 1306, 1313, 1321, -: 93:1328, 1335, 1342, 1350, 1357, 1364, 1372, 1379, 1386, 1394, 1401, -: 94:1408, 1415, 1423, 1430, 1437, 1445, 1452, 1459, 1466, 1474, 1481, -: 95:1488, 1496, 1503, 1510, 1518, 1525, 1532, 1539, 1547, 1554, 1561, -: 96:1569, 1576, 1583, 1591, 1598, 1605, 1612, 1620, 1627, 1634, 1642, -: 97:1649, 1656, 1663, 1671, 1678, 1685, 1693, 1700, 1707, 1715, 1722, -: 98:1729, 1736, 1744, 1751, 1758, 1766, 1773, 1780, 1788, 1795, 1802, -: 99:1809, 1817, 1824, 1831, 1839, 1846, 1853, 1860 }; -: 100: -: 101:static INT16 Cb_R[] = { 0, -10, -21, -31, -42, -53, -64, -75, -85, -: 102:-96, -107, -118, -129, -139, -150, -161, -172, -183, -193, -204, -215, -: 103:-226, -237, -247, -258, -269, -280, -291, -301, -312, -323, -334, -: 104:-345, -355, -366, -377, -388, -399, -409, -420, -431, -442, -453, -: 105:-463, -474, -485, -496, -507, -517, -528, -539, -550, -561, -571, -: 106:-582, -593, -604, -615, -625, -636, -647, -658, -669, -679, -690, -: 107:-701, -712, -723, -733, -744, -755, -766, -777, -787, -798, -809, -: 108:-820, -831, -841, -852, -863, -874, -885, -895, -906, -917, -928, -: 109:-939, -949, -960, -971, -982, -993, -1003, -1014, -1025, -1036, -1047, -: 110:-1057, -1068, -1079, -1090, -1101, -1111, -1122, -1133, -1144, -1155, -: 111:-1165, -1176, -1187, -1198, -1209, -1219, -1230, -1241, -1252, -1263, -: 112:-1273, -1284, -1295, -1306, -1317, -1327, -1338, -1349, -1360, -1371, -: 113:-1381, -1392, -1403, -1414, -1425, -1435, -1446, -1457, -1468, -1479, -: 114:-1489, -1500, -1511, -1522, -1533, -1543, -1554, -1565, -1576, -1587, -: 115:-1597, -1608, -1619, -1630, -1641, -1651, -1662, -1673, -1684, -1694, -: 116:-1705, -1716, -1727, -1738, -1748, -1759, -1770, -1781, -1792, -1802, -: 117:-1813, -1824, -1835, -1846, -1856, -1867, -1878, -1889, -1900, -1910, -: 118:-1921, -1932, -1943, -1954, -1964, -1975, -1986, -1997, -2008, -2018, -: 119:-2029, -2040, -2051, -2062, -2072, -2083, -2094, -2105, -2116, -2126, -: 120:-2137, -2148, -2159, -2170, -2180, -2191, -2202, -2213, -2224, -2234, -: 121:-2245, -2256, -2267, -2278, -2288, -2299, -2310, -2321, -2332, -2342, -: 122:-2353, -2364, -2375, -2386, -2396, -2407, -2418, -2429, -2440, -2450, -: 123:-2461, -2472, -2483, -2494, -2504, -2515, -2526, -2537, -2548, -2558, -: 124:-2569, -2580, -2591, -2602, -2612, -2623, -2634, -2645, -2656, -2666, -: 125:-2677, -2688, -2699, -2710, -2720, -2731, -2742, -2753 }; -: 126: -: 127:static INT16 Cb_G[] = { 0, -20, -41, -63, -84, -105, -126, -147, -169, -: 128:-190, -211, -232, -253, -275, -296, -317, -338, -359, -381, -402, -: 129:-423, -444, -465, -487, -508, -529, -550, -571, -593, -614, -635, -: 130:-656, -677, -699, -720, -741, -762, -783, -805, -826, -847, -868, -: 131:-889, -911, -932, -953, -974, -995, -1017, -1038, -1059, -1080, -1101, -: 132:-1123, -1144, -1165, -1186, -1207, -1229, -1250, -1271, -1292, -1313, -: 133:-1335, -1356, -1377, -1398, -1419, -1441, -1462, -1483, -1504, -1525, -: 134:-1547, -1568, -1589, -1610, -1631, -1653, -1674, -1695, -1716, -1737, -: 135:-1759, -1780, -1801, -1822, -1843, -1865, -1886, -1907, -1928, -1949, -: 136:-1971, -1992, -2013, -2034, -2055, -2077, -2098, -2119, -2140, -2161, -: 137:-2183, -2204, -2225, -2246, -2267, -2289, -2310, -2331, -2352, -2373, -: 138:-2395, -2416, -2437, -2458, -2479, -2501, -2522, -2543, -2564, -2585, -: 139:-2607, -2628, -2649, -2670, -2691, -2713, -2734, -2755, -2776, -2797, -: 140:-2819, -2840, -2861, -2882, -2903, -2925, -2946, -2967, -2988, -3009, -: 141:-3031, -3052, -3073, -3094, -3115, -3137, -3158, -3179, -3200, -3221, -: 142:-3243, -3264, -3285, -3306, -3328, -3349, -3370, -3391, -3412, -3434, -: 143:-3455, -3476, -3497, -3518, -3540, -3561, -3582, -3603, -3624, -3646, -: 144:-3667, -3688, -3709, -3730, -3752, -3773, -3794, -3815, -3836, -3858, -: 145:-3879, -3900, -3921, -3942, -3964, -3985, -4006, -4027, -4048, -4070, -: 146:-4091, -4112, -4133, -4154, -4176, -4197, -4218, -4239, -4260, -4282, -: 147:-4303, -4324, -4345, -4366, -4388, -4409, -4430, -4451, -4472, -4494, -: 148:-4515, -4536, -4557, -4578, -4600, -4621, -4642, -4663, -4684, -4706, -: 149:-4727, -4748, -4769, -4790, -4812, -4833, -4854, -4875, -4896, -4918, -: 150:-4939, -4960, -4981, -5002, -5024, -5045, -5066, -5087, -5108, -5130, -: 151:-5151, -5172, -5193, -5214, -5236, -5257, -5278, -5299, -5320, -5342, -: 152:-5363, -5384, -5405 }; -: 153: -: 154:static INT16 Cb_B[] = { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, -: 155:320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, -: 156:768, 800, 832, 864, 896, 928, 960, 992, 1024, 1056, 1088, 1120, 1152, -: 157:1184, 1216, 1248, 1280, 1312, 1344, 1376, 1408, 1440, 1472, 1504, -: 158:1536, 1568, 1600, 1632, 1664, 1696, 1728, 1760, 1792, 1824, 1856, -: 159:1888, 1920, 1952, 1984, 2016, 2048, 2080, 2112, 2144, 2176, 2208, -: 160:2240, 2272, 2304, 2336, 2368, 2400, 2432, 2464, 2496, 2528, 2560, -: 161:2592, 2624, 2656, 2688, 2720, 2752, 2784, 2816, 2848, 2880, 2912, -: 162:2944, 2976, 3008, 3040, 3072, 3104, 3136, 3168, 3200, 3232, 3264, -: 163:3296, 3328, 3360, 3392, 3424, 3456, 3488, 3520, 3552, 3584, 3616, -: 164:3648, 3680, 3712, 3744, 3776, 3808, 3840, 3872, 3904, 3936, 3968, -: 165:4000, 4032, 4064, 4096, 4128, 4160, 4192, 4224, 4256, 4288, 4320, -: 166:4352, 4384, 4416, 4448, 4480, 4512, 4544, 4576, 4608, 4640, 4672, -: 167:4704, 4736, 4768, 4800, 4832, 4864, 4896, 4928, 4960, 4992, 5024, -: 168:5056, 5088, 5120, 5152, 5184, 5216, 5248, 5280, 5312, 5344, 5376, -: 169:5408, 5440, 5472, 5504, 5536, 5568, 5600, 5632, 5664, 5696, 5728, -: 170:5760, 5792, 5824, 5856, 5888, 5920, 5952, 5984, 6016, 6048, 6080, -: 171:6112, 6144, 6176, 6208, 6240, 6272, 6304, 6336, 6368, 6400, 6432, -: 172:6464, 6496, 6528, 6560, 6592, 6624, 6656, 6688, 6720, 6752, 6784, -: 173:6816, 6848, 6880, 6912, 6944, 6976, 7008, 7040, 7072, 7104, 7136, -: 174:7168, 7200, 7232, 7264, 7296, 7328, 7360, 7392, 7424, 7456, 7488, -: 175:7520, 7552, 7584, 7616, 7648, 7680, 7712, 7744, 7776, 7808, 7840, -: 176:7872, 7904, 7936, 7968, 8000, 8032, 8064, 8096, 8128, 8160 }; -: 177: -: 178:#define Cr_R Cb_B -: 179: -: 180:static INT16 Cr_G[] = { 0, -26, -53, -79, -106, -133, -160, -187, -: 181:-213, -240, -267, -294, -321, -347, -374, -401, -428, -455, -481, -: 182:-508, -535, -562, -589, -615, -642, -669, -696, -722, -749, -776, -: 183:-803, -830, -856, -883, -910, -937, -964, -990, -1017, -1044, -1071, -: 184:-1098, -1124, -1151, -1178, -1205, -1232, -1258, -1285, -1312, -1339, -: 185:-1366, -1392, -1419, -1446, -1473, -1500, -1526, -1553, -1580, -1607, -: 186:-1634, -1660, -1687, -1714, -1741, -1768, -1794, -1821, -1848, -1875, -: 187:-1902, -1928, -1955, -1982, -2009, -2036, -2062, -2089, -2116, -2143, -: 188:-2169, -2196, -2223, -2250, -2277, -2303, -2330, -2357, -2384, -2411, -: 189:-2437, -2464, -2491, -2518, -2545, -2571, -2598, -2625, -2652, -2679, -: 190:-2705, -2732, -2759, -2786, -2813, -2839, -2866, -2893, -2920, -2947, -: 191:-2973, -3000, -3027, -3054, -3081, -3107, -3134, -3161, -3188, -3215, -: 192:-3241, -3268, -3295, -3322, -3349, -3375, -3402, -3429, -3456, -3483, -: 193:-3509, -3536, -3563, -3590, -3616, -3643, -3670, -3697, -3724, -3750, -: 194:-3777, -3804, -3831, -3858, -3884, -3911, -3938, -3965, -3992, -4018, -: 195:-4045, -4072, -4099, -4126, -4152, -4179, -4206, -4233, -4260, -4286, -: 196:-4313, -4340, -4367, -4394, -4420, -4447, -4474, -4501, -4528, -4554, -: 197:-4581, -4608, -4635, -4662, -4688, -4715, -4742, -4769, -4796, -4822, -: 198:-4849, -4876, -4903, -4929, -4956, -4983, -5010, -5037, -5063, -5090, -: 199:-5117, -5144, -5171, -5197, -5224, -5251, -5278, -5305, -5331, -5358, -: 200:-5385, -5412, -5439, -5465, -5492, -5519, -5546, -5573, -5599, -5626, -: 201:-5653, -5680, -5707, -5733, -5760, -5787, -5814, -5841, -5867, -5894, -: 202:-5921, -5948, -5975, -6001, -6028, -6055, -6082, -6109, -6135, -6162, -: 203:-6189, -6216, -6243, -6269, -6296, -6323, -6350, -6376, -6403, -6430, -: 204:-6457, -6484, -6510, -6537, -6564, -6591, -6618, -6644, -6671, -6698, -: 205:-6725, -6752, -6778, -6805, -6832 }; -: 206: -: 207:static INT16 Cr_B[] = { 0, -4, -9, -15, -20, -25, -30, -35, -41, -46, -: 208:-51, -56, -61, -67, -72, -77, -82, -87, -93, -98, -103, -108, -113, -: 209:-119, -124, -129, -134, -140, -145, -150, -155, -160, -166, -171, -: 210:-176, -181, -186, -192, -197, -202, -207, -212, -218, -223, -228, -: 211:-233, -238, -244, -249, -254, -259, -264, -270, -275, -280, -285, -: 212:-290, -296, -301, -306, -311, -316, -322, -327, -332, -337, -342, -: 213:-348, -353, -358, -363, -368, -374, -379, -384, -389, -394, -400, -: 214:-405, -410, -415, -421, -426, -431, -436, -441, -447, -452, -457, -: 215:-462, -467, -473, -478, -483, -488, -493, -499, -504, -509, -514, -: 216:-519, -525, -530, -535, -540, -545, -551, -556, -561, -566, -571, -: 217:-577, -582, -587, -592, -597, -603, -608, -613, -618, -623, -629, -: 218:-634, -639, -644, -649, -655, -660, -665, -670, -675, -681, -686, -: 219:-691, -696, -702, -707, -712, -717, -722, -728, -733, -738, -743, -: 220:-748, -754, -759, -764, -769, -774, -780, -785, -790, -795, -800, -: 221:-806, -811, -816, -821, -826, -832, -837, -842, -847, -852, -858, -: 222:-863, -868, -873, -878, -884, -889, -894, -899, -904, -910, -915, -: 223:-920, -925, -930, -936, -941, -946, -951, -957, -962, -967, -972, -: 224:-977, -983, -988, -993, -998, -1003, -1009, -1014, -1019, -1024, -: 225:-1029, -1035, -1040, -1045, -1050, -1055, -1061, -1066, -1071, -1076, -: 226:-1081, -1087, -1092, -1097, -1102, -1107, -1113, -1118, -1123, -1128, -: 227:-1133, -1139, -1144, -1149, -1154, -1159, -1165, -1170, -1175, -1180, -: 228:-1185, -1191, -1196, -1201, -1206, -1211, -1217, -1222, -1227, -1232, -: 229:-1238, -1243, -1248, -1253, -1258, -1264, -1269, -1274, -1279, -1284, -: 230:-1290, -1295, -1300, -1305, -1310, -1316, -1321, -1326 }; -: 231: -: 232:static INT16 R_Cr[] = { -11484, -11394, -11305, -11215, -11125, -: 233:-11036, -10946, -10856, -10766, -10677, -10587, -10497, -10407, -: 234:-10318, -10228, -10138, -10049, -9959, -9869, -9779, -9690, -9600, -: 235:-9510, -9420, -9331, -9241, -9151, -9062, -8972, -8882, -8792, -8703, -: 236:-8613, -8523, -8433, -8344, -8254, -8164, -8075, -7985, -7895, -7805, -: 237:-7716, -7626, -7536, -7446, -7357, -7267, -7177, -7088, -6998, -6908, -: 238:-6818, -6729, -6639, -6549, -6459, -6370, -6280, -6190, -6101, -6011, -: 239:-5921, -5831, -5742, -5652, -5562, -5472, -5383, -5293, -5203, -5113, -: 240:-5024, -4934, -4844, -4755, -4665, -4575, -4485, -4396, -4306, -4216, -: 241:-4126, -4037, -3947, -3857, -3768, -3678, -3588, -3498, -3409, -3319, -: 242:-3229, -3139, -3050, -2960, -2870, -2781, -2691, -2601, -2511, -2422, -: 243:-2332, -2242, -2152, -2063, -1973, -1883, -1794, -1704, -1614, -1524, -: 244:-1435, -1345, -1255, -1165, -1076, -986, -896, -807, -717, -627, -537, -: 245:-448, -358, -268, -178, -89, 0, 90, 179, 269, 359, 449, 538, 628, 718, -: 246:808, 897, 987, 1077, 1166, 1256, 1346, 1436, 1525, 1615, 1705, 1795, -: 247:1884, 1974, 2064, 2153, 2243, 2333, 2423, 2512, 2602, 2692, 2782, -: 248:2871, 2961, 3051, 3140, 3230, 3320, 3410, 3499, 3589, 3679, 3769, -: 249:3858, 3948, 4038, 4127, 4217, 4307, 4397, 4486, 4576, 4666, 4756, -: 250:4845, 4935, 5025, 5114, 5204, 5294, 5384, 5473, 5563, 5653, 5743, -: 251:5832, 5922, 6012, 6102, 6191, 6281, 6371, 6460, 6550, 6640, 6730, -: 252:6819, 6909, 6999, 7089, 7178, 7268, 7358, 7447, 7537, 7627, 7717, -: 253:7806, 7896, 7986, 8076, 8165, 8255, 8345, 8434, 8524, 8614, 8704, -: 254:8793, 8883, 8973, 9063, 9152, 9242, 9332, 9421, 9511, 9601, 9691, -: 255:9780, 9870, 9960, 10050, 10139, 10229, 10319, 10408, 10498, 10588, -: 256:10678, 10767, 10857, 10947, 11037, 11126, 11216, 11306, 11395 }; -: 257: -: 258:static INT16 G_Cb[] = { 2819, 2797, 2775, 2753, 2731, 2709, 2687, -: 259:2665, 2643, 2621, 2599, 2577, 2555, 2533, 2511, 2489, 2467, 2445, -: 260:2423, 2401, 2379, 2357, 2335, 2313, 2291, 2269, 2247, 2225, 2202, -: 261:2180, 2158, 2136, 2114, 2092, 2070, 2048, 2026, 2004, 1982, 1960, -: 262:1938, 1916, 1894, 1872, 1850, 1828, 1806, 1784, 1762, 1740, 1718, -: 263:1696, 1674, 1652, 1630, 1608, 1586, 1564, 1542, 1520, 1498, 1476, -: 264:1454, 1432, 1410, 1388, 1366, 1344, 1321, 1299, 1277, 1255, 1233, -: 265:1211, 1189, 1167, 1145, 1123, 1101, 1079, 1057, 1035, 1013, 991, 969, -: 266:947, 925, 903, 881, 859, 837, 815, 793, 771, 749, 727, 705, 683, 661, -: 267:639, 617, 595, 573, 551, 529, 507, 485, 463, 440, 418, 396, 374, 352, -: 268:330, 308, 286, 264, 242, 220, 198, 176, 154, 132, 110, 88, 66, 44, 22, -: 269:0, -21, -43, -65, -87, -109, -131, -153, -175, -197, -219, -241, -263, -: 270:-285, -307, -329, -351, -373, -395, -417, -439, -462, -484, -506, -: 271:-528, -550, -572, -594, -616, -638, -660, -682, -704, -726, -748, -: 272:-770, -792, -814, -836, -858, -880, -902, -924, -946, -968, -990, -: 273:-1012, -1034, -1056, -1078, -1100, -1122, -1144, -1166, -1188, -1210, -: 274:-1232, -1254, -1276, -1298, -1320, -1343, -1365, -1387, -1409, -1431, -: 275:-1453, -1475, -1497, -1519, -1541, -1563, -1585, -1607, -1629, -1651, -: 276:-1673, -1695, -1717, -1739, -1761, -1783, -1805, -1827, -1849, -1871, -: 277:-1893, -1915, -1937, -1959, -1981, -2003, -2025, -2047, -2069, -2091, -: 278:-2113, -2135, -2157, -2179, -2201, -2224, -2246, -2268, -2290, -2312, -: 279:-2334, -2356, -2378, -2400, -2422, -2444, -2466, -2488, -2510, -2532, -: 280:-2554, -2576, -2598, -2620, -2642, -2664, -2686, -2708, -2730, -2752, -: 281:-2774, -2796 }; -: 282: -: 283:static INT16 G_Cr[] = { 5850, 5805, 5759, 5713, 5667, 5622, 5576, -: 284:5530, 5485, 5439, 5393, 5347, 5302, 5256, 5210, 5165, 5119, 5073, -: 285:5028, 4982, 4936, 4890, 4845, 4799, 4753, 4708, 4662, 4616, 4570, -: 286:4525, 4479, 4433, 4388, 4342, 4296, 4251, 4205, 4159, 4113, 4068, -: 287:4022, 3976, 3931, 3885, 3839, 3794, 3748, 3702, 3656, 3611, 3565, -: 288:3519, 3474, 3428, 3382, 3336, 3291, 3245, 3199, 3154, 3108, 3062, -: 289:3017, 2971, 2925, 2879, 2834, 2788, 2742, 2697, 2651, 2605, 2559, -: 290:2514, 2468, 2422, 2377, 2331, 2285, 2240, 2194, 2148, 2102, 2057, -: 291:2011, 1965, 1920, 1874, 1828, 1782, 1737, 1691, 1645, 1600, 1554, -: 292:1508, 1463, 1417, 1371, 1325, 1280, 1234, 1188, 1143, 1097, 1051, -: 293:1006, 960, 914, 868, 823, 777, 731, 686, 640, 594, 548, 503, 457, 411, -: 294:366, 320, 274, 229, 183, 137, 91, 46, 0, -45, -90, -136, -182, -228, -: 295:-273, -319, -365, -410, -456, -502, -547, -593, -639, -685, -730, -: 296:-776, -822, -867, -913, -959, -1005, -1050, -1096, -1142, -1187, -: 297:-1233, -1279, -1324, -1370, -1416, -1462, -1507, -1553, -1599, -1644, -: 298:-1690, -1736, -1781, -1827, -1873, -1919, -1964, -2010, -2056, -2101, -: 299:-2147, -2193, -2239, -2284, -2330, -2376, -2421, -2467, -2513, -2558, -: 300:-2604, -2650, -2696, -2741, -2787, -2833, -2878, -2924, -2970, -3016, -: 301:-3061, -3107, -3153, -3198, -3244, -3290, -3335, -3381, -3427, -3473, -: 302:-3518, -3564, -3610, -3655, -3701, -3747, -3793, -3838, -3884, -3930, -: 303:-3975, -4021, -4067, -4112, -4158, -4204, -4250, -4295, -4341, -4387, -: 304:-4432, -4478, -4524, -4569, -4615, -4661, -4707, -4752, -4798, -4844, -: 305:-4889, -4935, -4981, -5027, -5072, -5118, -5164, -5209, -5255, -5301, -: 306:-5346, -5392, -5438, -5484, -5529, -5575, -5621, -5666, -5712, -5758, -: 307:-5804 }; -: 308: -: 309:static INT16 B_Cb[] = { -14515, -14402, -14288, -14175, -14062, -: 310:-13948, -13835, -13721, -13608, -13495, -13381, -13268, -13154, -: 311:-13041, -12928, -12814, -12701, -12587, -12474, -12360, -12247, -: 312:-12134, -12020, -11907, -11793, -11680, -11567, -11453, -11340, -: 313:-11226, -11113, -11000, -10886, -10773, -10659, -10546, -10433, -: 314:-10319, -10206, -10092, -9979, -9865, -9752, -9639, -9525, -9412, -: 315:-9298, -9185, -9072, -8958, -8845, -8731, -8618, -8505, -8391, -8278, -: 316:-8164, -8051, -7938, -7824, -7711, -7597, -7484, -7371, -7257, -7144, -: 317:-7030, -6917, -6803, -6690, -6577, -6463, -6350, -6236, -6123, -6010, -: 318:-5896, -5783, -5669, -5556, -5443, -5329, -5216, -5102, -4989, -4876, -: 319:-4762, -4649, -4535, -4422, -4309, -4195, -4082, -3968, -3855, -3741, -: 320:-3628, -3515, -3401, -3288, -3174, -3061, -2948, -2834, -2721, -2607, -: 321:-2494, -2381, -2267, -2154, -2040, -1927, -1814, -1700, -1587, -1473, -: 322:-1360, -1246, -1133, -1020, -906, -793, -679, -566, -453, -339, -226, -: 323:-112, 0, 113, 227, 340, 454, 567, 680, 794, 907, 1021, 1134, 1247, -: 324:1361, 1474, 1588, 1701, 1815, 1928, 2041, 2155, 2268, 2382, 2495, -: 325:2608, 2722, 2835, 2949, 3062, 3175, 3289, 3402, 3516, 3629, 3742, -: 326:3856, 3969, 4083, 4196, 4310, 4423, 4536, 4650, 4763, 4877, 4990, -: 327:5103, 5217, 5330, 5444, 5557, 5670, 5784, 5897, 6011, 6124, 6237, -: 328:6351, 6464, 6578, 6691, 6804, 6918, 7031, 7145, 7258, 7372, 7485, -: 329:7598, 7712, 7825, 7939, 8052, 8165, 8279, 8392, 8506, 8619, 8732, -: 330:8846, 8959, 9073, 9186, 9299, 9413, 9526, 9640, 9753, 9866, 9980, -: 331:10093, 10207, 10320, 10434, 10547, 10660, 10774, 10887, 11001, 11114, -: 332:11227, 11341, 11454, 11568, 11681, 11794, 11908, 12021, 12135, 12248, -: 333:12361, 12475, 12588, 12702, 12815, 12929, 13042, 13155, 13269, 13382, -: 334:13496, 13609, 13722, 13836, 13949, 14063, 14176, 14289, 14403 }; -: 335: -: 336: -: 337:void function ImagingConvertRGB2YCbCr called 1280 returned 100% blocks executed 100% 1280: 338:ImagingConvertRGB2YCbCr(UINT8* out, const UINT8* in, int pixels) -: 339:{ -: 340: int x; -: 341: UINT8 a; -: 342: int r, g, b; -: 343: int y, cr, cb; -: 344: 165120: 345: for (x = 0; x < pixels; x++, in +=4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 346: 163840: 347: r = in[0]; 163840: 348: g = in[1]; 163840: 349: b = in[2]; 163840: 350: a = in[3]; -: 351: 163840: 352: y = (Y_R[r] + Y_G[g] + Y_B[b]) >> SCALE; 163840: 353: cb = ((Cb_R[r] + Cb_G[g] + Cb_B[b]) >> SCALE) + 128; 163840: 354: cr = ((Cr_R[r] + Cr_G[g] + Cr_B[b]) >> SCALE) + 128; -: 355: 163840: 356: out[0] = (UINT8) y; 163840: 357: out[1] = (UINT8) cb; 163840: 358: out[2] = (UINT8) cr; 163840: 359: out[3] = a; -: 360: } 1280: 361:} -: 362: -: 363:void function ImagingConvertYCbCr2RGB called 1280 returned 100% blocks executed 100% 1280: 364:ImagingConvertYCbCr2RGB(UINT8* out, const UINT8* in, int pixels) -: 365:{ -: 366: int x; -: 367: UINT8 a; -: 368: int r, g, b; -: 369: int y, cr, cb; -: 370: 165120: 371: for (x = 0; x < pixels; x++, in += 4, out += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 372: 163840: 373: y = in[0]; 163840: 374: cb = in[1]; 163840: 375: cr = in[2]; 163840: 376: a = in[3]; -: 377: 163840: 378: r = y + (( R_Cr[cr]) >> SCALE); 163840: 379: g = y + ((G_Cb[cb] + G_Cr[cr]) >> SCALE); 163840: 380: b = y + ((B_Cb[cb] ) >> SCALE); -: 381: 163840: 382: out[0] = (r <= 0) ? 0 : (r >= 255) ? 255 : r; branch 0 taken 99% (fallthrough) branch 1 taken 1% 163840: 383: out[1] = (g <= 0) ? 0 : (g >= 255) ? 255 : g; branch 0 taken 99% (fallthrough) branch 1 taken 1% 163840: 384: out[2] = (b <= 0) ? 0 : (b >= 255) ? 255 : b; branch 0 taken 99% (fallthrough) branch 1 taken 1% 163840: 385: out[3] = a; -: 386: } 1280: 387:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#QuantHash.c.gcov -: 0:Source:src/libImaging/QuantHash.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/QuantHash.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/QuantHash.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * hash tables used by the image quantizer -: 6: * -: 7: * history: -: 8: * 98-09-10 tjs Contributed -: 9: * 98-12-29 fl Added to PIL 1.0b1 -: 10: * -: 11: * Written by Toby J Sargeant . -: 12: * -: 13: * Copyright (c) 1998 by Toby J Sargeant -: 14: * Copyright (c) 1998 by Secret Labs AB -: 15: * -: 16: * See the README file for information on usage and redistribution. -: 17: */ -: 18: -: 19:#include -: 20:#include -: 21:#include -: 22:#include -: 23: -: 24:#include "QuantHash.h" -: 25: -: 26:typedef struct _HashNode { -: 27: struct _HashNode *next; -: 28: HashKey_t key; -: 29: HashVal_t value; -: 30:} HashNode; -: 31: -: 32:struct _HashTable { -: 33: HashNode **table; -: 34: uint32_t length; -: 35: uint32_t count; -: 36: HashFunc hashFunc; -: 37: HashCmpFunc cmpFunc; -: 38: void *userData; -: 39:}; -: 40: -: 41:#define MIN_LENGTH 11 -: 42:#define RESIZE_FACTOR 3 -: 43: -: 44:static int _hashtable_insert_node(HashTable *,HashNode *,int,int,CollisionFunc); -: 45: function hashtable_new called 24 returned 100% blocks executed 80% 24: 46:HashTable *hashtable_new(HashFunc hf,HashCmpFunc cf) { -: 47: HashTable *h; 24: 48: h=malloc(sizeof(HashTable)); 24: 49: if (!h) { return NULL; } branch 0 taken 100% (fallthrough) branch 1 taken 0% 24: 50: h->hashFunc=hf; 24: 51: h->cmpFunc=cf; 24: 52: h->length=MIN_LENGTH; 24: 53: h->count=0; 24: 54: h->userData=NULL; 24: 55: h->table=malloc(sizeof(HashNode *)*h->length); 24: 56: if (!h->table) { free(h); return NULL; } branch 0 taken 0% (fallthrough) branch 1 taken 100% 48: 57: memset (h->table,0,sizeof(HashNode *)*h->length); 24: 58: return h; -: 59:} -: 60: function _findPrime called 204 returned 100% blocks executed 92% 204: 61:static uint32_t _findPrime(uint32_t start,int dir) { -: 62: static int unit[]={0,1,0,1,0,0,0,1,0,1,0,1,0,1,0,0}; -: 63: uint32_t t; 568: 64: while (start>1) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 364: 65: if (!unit[start&0x0f]) { branch 0 taken 56% (fallthrough) branch 1 taken 44% 160: 66: start+=dir; 160: 67: continue; -: 68: } 3338: 69: for (t=2;t=sqrt((double)start)) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 75: break; -: 76: } #####: 77: start+=dir; -: 78: } 204: 79: return start; -: 80:} -: 81: function _hashtable_rehash called 140 returned 100% blocks executed 90% 140: 82:static void _hashtable_rehash(HashTable *h,CollisionFunc cf,uint32_t newSize) { 140: 83: HashNode **oldTable=h->table; -: 84: uint32_t i; -: 85: HashNode *n,*nn; -: 86: uint32_t oldSize; 140: 87: oldSize=h->length; 140: 88: h->table=malloc(sizeof(HashNode *)*newSize); 140: 89: if (!h->table) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 90: h->table=oldTable; #####: 91: return; -: 92: } 140: 93: h->length=newSize; 140: 94: h->count=0; 280: 95: memset (h->table,0,sizeof(HashNode *)*h->length); 78728: 96: for (i=0;inext; 235904: 99: _hashtable_insert_node(h,n,0,0,cf); -: 100: } -: 101: } 140: 102: free(oldTable); -: 103:} -: 104: function _hashtable_resize called 137036 returned 100% blocks executed 100% 137036: 105:static void _hashtable_resize(HashTable *h) { -: 106: uint32_t newSize; -: 107: uint32_t oldSize; 137036: 108: oldSize=h->length; 137036: 109: newSize=oldSize; 137036: 110: if (h->count*RESIZE_FACTORlength) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 64: 111: newSize=_findPrime(h->length/2-1,-1); call 0 returned 100% 136972: 112: } else if (h->length*RESIZE_FACTORcount) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 140: 113: newSize=_findPrime(h->length*2+1,+1); call 0 returned 100% -: 114: } 137036: 115: if (newSizehashFunc(h,node->key)%h->length; call 0 returned 100% -: 123: HashNode **n,*nv; -: 124: int i; -: 125: 324142: 126: for (n=&(h->table[hash]);*n;n=&((*n)->next)) { branch 0 taken 47% branch 1 taken 53% (fallthrough) 153268: 127: nv=*n; 153268: 128: i=h->cmpFunc(h,nv->key,node->key); call 0 returned 100% 153268: 129: if (!i) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 130: if (cf) { branch 0 never executed branch 1 never executed #####: 131: nv->key=node->key; #####: 132: cf(h,&(nv->key),&(nv->value),node->key,node->value); call 0 never executed #####: 133: free(node); #####: 134: return 1; -: 135: } else { #####: 136: nv->key=node->key; #####: 137: nv->value=node->value; #####: 138: free(node); #####: 139: return 1; -: 140: } 153268: 141: } else if (i>0) { branch 0 taken 58% (fallthrough) branch 1 taken 42% -: 142: break; -: 143: } -: 144: } 235904: 145: if (!update) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 235904: 146: node->next=*n; 235904: 147: *n=node; 235904: 148: h->count++; 235904: 149: if (resize) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 150: _hashtable_resize(h); call 0 never executed -: 151: } -: 152: return 1; -: 153: } else { -: 154: return 0; -: 155: } -: 156:} -: 157: function _hashtable_insert called 137036 returned 100% blocks executed 100% 137036: 158:static int _hashtable_insert(HashTable *h,HashKey_t key,HashVal_t val,int resize,int update) { -: 159: HashNode **n,*nv; -: 160: HashNode *t; -: 161: int i; 137036: 162: uint32_t hash=h->hashFunc(h,key)%h->length; call 0 returned 100% -: 163: 278356: 164: for (n=&(h->table[hash]);*n;n=&((*n)->next)) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 248150: 165: nv=*n; 248150: 166: i=h->cmpFunc(h,nv->key,key); call 0 returned 100% 248150: 167: if (!i) { branch 0 taken 28% (fallthrough) branch 1 taken 72% 68518: 168: nv->value=val; 68518: 169: return 1; 179632: 170: } else if (i>0) { branch 0 taken 79% (fallthrough) branch 1 taken 21% -: 171: break; -: 172: } -: 173: } 68518: 174: if (!update) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 68518: 175: t=malloc(sizeof(HashNode)); 68518: 176: if (!t) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 177: return 0; -: 178: } 68518: 179: t->next=*n; 68518: 180: *n=t; 68518: 181: t->key=key; 68518: 182: t->value=val; 68518: 183: h->count++; 68518: 184: if (resize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 68518: 185: _hashtable_resize(h); call 0 returned 100% -: 186: } -: 187: return 1; -: 188: } else { -: 189: return 0; -: 190: } -: 191:} -: 192: function hashtable_insert_or_update_computed called 679268 returned 100% blocks executed 94% 679268: 193:int hashtable_insert_or_update_computed(HashTable *h, -: 194: HashKey_t key, -: 195: ComputeFunc newFunc, -: 196: ComputeFunc existsFunc) { -: 197: HashNode **n,*nv; -: 198: HashNode *t; -: 199: int i; 679268: 200: uint32_t hash=h->hashFunc(h,key)%h->length; call 0 returned 100% -: 201: 1100518: 202: for (n=&(h->table[hash]);*n;n=&((*n)->next)) { branch 0 taken 97% branch 1 taken 3% (fallthrough) 1069889: 203: nv=*n; 1069889: 204: i=h->cmpFunc(h,nv->key,key); call 0 returned 100% 1069889: 205: if (!i) { branch 0 taken 57% (fallthrough) branch 1 taken 43% 610750: 206: if (existsFunc) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 610750: 207: existsFunc(h,nv->key,&(nv->value)); call 0 returned 100% -: 208: } else { -: 209: return 0; -: 210: } 610750: 211: return 1; 459139: 212: } else if (i>0) { branch 0 taken 92% (fallthrough) branch 1 taken 8% -: 213: break; -: 214: } -: 215: } 68518: 216: t=malloc(sizeof(HashNode)); 68518: 217: if (!t) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 218: return 0; -: 219: } 68518: 220: t->key=key; 68518: 221: t->next=*n; 68518: 222: *n=t; 68518: 223: if (newFunc) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 68518: 224: newFunc(h,t->key,&(t->value)); call 0 returned 100% -: 225: } else { #####: 226: free(t); #####: 227: return 0; -: 228: } 68518: 229: h->count++; 68518: 230: _hashtable_resize(h); call 0 returned 100% 68518: 231: return 1; -: 232:} -: 233: function hashtable_insert called 137036 returned 100% blocks executed 100% 137036: 234:int hashtable_insert(HashTable *h,HashKey_t key,HashVal_t val) { 137036: 235: return _hashtable_insert(h,key,val,1,0); call 0 returned 100% -: 236:} -: 237: function hashtable_foreach_update called 0 returned 0% blocks executed 0% #####: 238:void hashtable_foreach_update(HashTable *h,IteratorUpdateFunc i,void *u) { -: 239: HashNode *n; -: 240: uint32_t x; -: 241: #####: 242: if (h->table) { branch 0 never executed branch 1 never executed #####: 243: for (x=0;xlength;x++) { branch 0 never executed branch 1 never executed #####: 244: for (n=h->table[x];n;n=n->next) { branch 0 never executed branch 1 never executed #####: 245: i(h,n->key,&(n->value),u); call 0 never executed -: 246: } -: 247: } -: 248: } #####: 249:} -: 250: function hashtable_foreach called 12 returned 100% blocks executed 100% 12: 251:void hashtable_foreach(HashTable *h,IteratorFunc i,void *u) { -: 252: HashNode *n; -: 253: uint32_t x; -: 254: 12: 255: if (h->table) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 39544: 256: for (x=0;xlength;x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 108062: 257: for (n=h->table[x];n;n=n->next) { branch 0 taken 63% branch 1 taken 37% (fallthrough) 68518: 258: i(h,n->key,n->value,u); call 0 returned 100% -: 259: } -: 260: } -: 261: } 12: 262:} -: 263: function hashtable_free called 24 returned 100% blocks executed 100% 24: 264:void hashtable_free(HashTable *h) { -: 265: HashNode *n,*nn; -: 266: uint32_t i; -: 267: 24: 268: if (h->table) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 79088: 269: for (i=0;ilength;i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 216124: 270: for (n=h->table[i];n;n=nn) { branch 0 taken 63% branch 1 taken 37% (fallthrough) 137036: 271: nn=n->next; 137036: 272: free(n); -: 273: } -: 274: } 24: 275: free(h->table); -: 276: } 24: 277: free(h); 24: 278:} -: 279: function hashtable_rehash_compute called 0 returned 0% blocks executed 0% #####: 280:void hashtable_rehash_compute(HashTable *h,CollisionFunc cf) { #####: 281: _hashtable_rehash(h,cf,h->length); call 0 never executed #####: 282:} -: 283: function hashtable_lookup called 1427054 returned 100% blocks executed 100% 1427054: 284:int hashtable_lookup(const HashTable *h,const HashKey_t key,HashVal_t *valp) { 1427054: 285: uint32_t hash=h->hashFunc(h,key)%h->length; call 0 returned 100% -: 286: HashNode *n; -: 287: int i; -: 288: 2104753: 289: for (n=h->table[hash];n;n=n->next) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2074547: 290: i=h->cmpFunc(h,n->key,key); call 0 returned 100% 2074547: 291: if (!i) { branch 0 taken 65% (fallthrough) branch 1 taken 35% 1358536: 292: *valp=n->value; 1358536: 293: return 1; 716011: 294: } else if (i>0) { branch 0 taken 95% (fallthrough) branch 1 taken 5% -: 295: break; -: 296: } -: 297: } -: 298: return 0; -: 299:} -: 300: function hashtable_get_count called 679268 returned 100% blocks executed 100% 679268: 301:uint32_t hashtable_get_count(const HashTable *h) { 679268: 302: return h->count; -: 303:} -: 304: function hashtable_get_user_data called 4100384 returned 100% blocks executed 100% 4100384: 305:void *hashtable_get_user_data(const HashTable *h) { 4100384: 306: return h->userData; -: 307:} -: 308: function hashtable_set_user_data called 12 returned 100% blocks executed 100% 12: 309:void *hashtable_set_user_data(HashTable *h,void *data) { 12: 310: void *r=h->userData; 12: 311: h->userData=data; 12: 312: return r; -: 313:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#map.c.gcov -: 0:Source:src/map.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/map.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/map.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * standard memory mapping interface for the Imaging library -: 5: * -: 6: * history: -: 7: * 1998-03-05 fl added Win32 read mapping -: 8: * 1999-02-06 fl added "I;16" support -: 9: * 2003-04-21 fl added PyImaging_MapBuffer primitive -: 10: * -: 11: * Copyright (c) 1998-2003 by Secret Labs AB. -: 12: * Copyright (c) 2003 by Fredrik Lundh. -: 13: * -: 14: * See the README file for information on usage and redistribution. -: 15: */ -: 16: -: 17:/* -: 18: * FIXME: should move the memory mapping primitives into libImaging! -: 19: */ -: 20: -: 21:#include "Python.h" -: 22: -: 23:#include "libImaging/Imaging.h" -: 24: -: 25:/* compatibility wrappers (defined in _imaging.c) */ -: 26:extern int PyImaging_CheckBuffer(PyObject* buffer); -: 27:extern int PyImaging_GetBuffer(PyObject* buffer, Py_buffer *view); -: 28: -: 29:/* -------------------------------------------------------------------- */ -: 30:/* Standard mapper */ -: 31: -: 32:typedef struct { -: 33: PyObject_HEAD -: 34: char* base; -: 35: int size; -: 36: int offset; -: 37:#ifdef _WIN32 -: 38: HANDLE hFile; -: 39: HANDLE hMap; -: 40:#endif -: 41:} ImagingMapperObject; -: 42: -: 43:static PyTypeObject ImagingMapperType; -: 44: -: 45:ImagingMapperObject* function PyImaging_MapperNew called 0 returned 0% blocks executed 0% #####: 46:PyImaging_MapperNew(const char* filename, int readonly) -: 47:{ -: 48: ImagingMapperObject *mapper; -: 49: #####: 50: if (PyType_Ready(&ImagingMapperType) < 0) { call 0 never executed branch 1 never executed branch 2 never executed -: 51: return NULL; -: 52: } -: 53: #####: 54: mapper = PyObject_New(ImagingMapperObject, &ImagingMapperType); call 0 never executed #####: 55: if (mapper == NULL) { branch 0 never executed branch 1 never executed -: 56: return NULL; -: 57: } -: 58: #####: 59: mapper->base = NULL; #####: 60: mapper->size = mapper->offset = 0; -: 61: -: 62:#ifdef _WIN32 -: 63: mapper->hFile = (HANDLE)-1; -: 64: mapper->hMap = (HANDLE)-1; -: 65: -: 66: /* FIXME: currently supports readonly mappings only */ -: 67: mapper->hFile = CreateFile( -: 68: filename, -: 69: GENERIC_READ, -: 70: FILE_SHARE_READ, -: 71: NULL, OPEN_EXISTING, -: 72: FILE_ATTRIBUTE_NORMAL, -: 73: NULL); -: 74: if (mapper->hFile == (HANDLE)-1) { -: 75: PyErr_SetString(PyExc_OSError, "cannot open file"); -: 76: Py_DECREF(mapper); -: 77: return NULL; -: 78: } -: 79: -: 80: mapper->hMap = CreateFileMapping( -: 81: mapper->hFile, NULL, -: 82: PAGE_READONLY, -: 83: 0, 0, NULL); -: 84: if (mapper->hMap == (HANDLE)-1) { -: 85: CloseHandle(mapper->hFile); -: 86: PyErr_SetString(PyExc_OSError, "cannot map file"); -: 87: Py_DECREF(mapper); -: 88: return NULL; -: 89: } -: 90: -: 91: mapper->base = (char*) MapViewOfFile( -: 92: mapper->hMap, -: 93: FILE_MAP_READ, -: 94: 0, 0, 0); -: 95: -: 96: mapper->size = GetFileSize(mapper->hFile, 0); -: 97:#endif -: 98: #####: 99: return mapper; -: 100:} -: 101: -: 102:static void function mapping_dealloc called 0 returned 0% blocks executed 0% #####: 103:mapping_dealloc(ImagingMapperObject* mapper) -: 104:{ -: 105:#ifdef _WIN32 -: 106: if (mapper->base != 0) { -: 107: UnmapViewOfFile(mapper->base); -: 108: } -: 109: if (mapper->hMap != (HANDLE)-1) { -: 110: CloseHandle(mapper->hMap); -: 111: } -: 112: if (mapper->hFile != (HANDLE)-1) { -: 113: CloseHandle(mapper->hFile); -: 114: } -: 115: mapper->base = 0; -: 116: mapper->hMap = mapper->hFile = (HANDLE)-1; -: 117:#endif #####: 118: PyObject_Del(mapper); call 0 never executed #####: 119:} -: 120: -: 121:/* -------------------------------------------------------------------- */ -: 122:/* standard file operations */ -: 123: -: 124:static PyObject* function mapping_read called 0 returned 0% blocks executed 0% #####: 125:mapping_read(ImagingMapperObject* mapper, PyObject* args) -: 126:{ -: 127: PyObject* buf; -: 128: #####: 129: int size = -1; #####: 130: if (!PyArg_ParseTuple(args, "|i", &size)) { call 0 never executed branch 1 never executed branch 2 never executed -: 131: return NULL; -: 132: } -: 133: -: 134: /* check size */ #####: 135: if (size < 0 || mapper->offset + size > mapper->size) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 136: size = mapper->size - mapper->offset; -: 137: } #####: 138: if (size < 0) { branch 0 never executed branch 1 never executed #####: 139: size = 0; -: 140: } -: 141: #####: 142: buf = PyBytes_FromStringAndSize(NULL, size); call 0 never executed #####: 143: if (!buf) { branch 0 never executed branch 1 never executed -: 144: return NULL; -: 145: } -: 146: #####: 147: if (size > 0) { branch 0 never executed branch 1 never executed #####: 148: memcpy(PyBytes_AsString(buf), mapper->base + mapper->offset, size); call 0 never executed #####: 149: mapper->offset += size; -: 150: } -: 151: -: 152: return buf; -: 153:} -: 154: -: 155:static PyObject* function mapping_seek called 0 returned 0% blocks executed 0% #####: 156:mapping_seek(ImagingMapperObject* mapper, PyObject* args) -: 157:{ -: 158: int offset; #####: 159: int whence = 0; #####: 160: if (!PyArg_ParseTuple(args, "i|i", &offset, &whence)) { call 0 never executed branch 1 never executed branch 2 never executed -: 161: return NULL; -: 162: } -: 163: #####: 164: switch (whence) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed -: 165: case 0: /* SEEK_SET */ #####: 166: mapper->offset = offset; #####: 167: break; -: 168: case 1: /* SEEK_CUR */ #####: 169: mapper->offset += offset; #####: 170: break; -: 171: case 2: /* SEEK_END */ #####: 172: mapper->offset = mapper->size + offset; #####: 173: break; -: 174: default: -: 175: /* FIXME: raise ValueError? */ -: 176: break; -: 177: } -: 178: #####: 179: Py_INCREF(Py_None); #####: 180: return Py_None; -: 181:} -: 182: -: 183:/* -------------------------------------------------------------------- */ -: 184:/* map entire image */ -: 185: -: 186:extern PyObject*PyImagingNew(Imaging im); -: 187: -: 188:static void function ImagingDestroyMap called 0 returned 0% blocks executed 0% #####: 189:ImagingDestroyMap(Imaging im) -: 190:{ #####: 191: return; /* nothing to do! */ -: 192:} -: 193: -: 194:static PyObject* function mapping_readimage called 0 returned 0% blocks executed 0% #####: 195:mapping_readimage(ImagingMapperObject* mapper, PyObject* args) -: 196:{ -: 197: int y, size; -: 198: Imaging im; -: 199: -: 200: char* mode; -: 201: int xsize; -: 202: int ysize; -: 203: int stride; -: 204: int orientation; #####: 205: if (!PyArg_ParseTuple(args, "s(ii)ii", &mode, &xsize, &ysize, call 0 never executed branch 1 never executed branch 2 never executed -: 206: &stride, &orientation)) { -: 207: return NULL; -: 208: } -: 209: #####: 210: if (stride <= 0) { branch 0 never executed branch 1 never executed -: 211: /* FIXME: maybe we should call ImagingNewPrologue instead */ #####: 212: if (!strcmp(mode, "L") || !strcmp(mode, "P")) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed branch 4 never executed branch 5 never executed branch 6 never executed branch 7 never executed #####: 213: stride = xsize; #####: 214: } else if (!strcmp(mode, "I;16") || !strcmp(mode, "I;16B")) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 215: stride = xsize * 2; -: 216: } else { #####: 217: stride = xsize * 4; -: 218: } -: 219: } -: 220: #####: 221: size = ysize * stride; -: 222: #####: 223: if (mapper->offset + size > mapper->size) { branch 0 never executed branch 1 never executed #####: 224: PyErr_SetString(PyExc_OSError, "image file truncated"); call 0 never executed #####: 225: return NULL; -: 226: } -: 227: #####: 228: im = ImagingNewPrologue(mode, xsize, ysize); call 0 never executed #####: 229: if (!im) { branch 0 never executed branch 1 never executed -: 230: return NULL; -: 231: } -: 232: -: 233: /* setup file pointers */ #####: 234: if (orientation > 0) { branch 0 never executed branch 1 never executed #####: 235: for (y = 0; y < ysize; y++) { branch 0 never executed branch 1 never executed #####: 236: im->image[y] = mapper->base + mapper->offset + y * stride; -: 237: } -: 238: } else { #####: 239: for (y = 0; y < ysize; y++) { branch 0 never executed branch 1 never executed #####: 240: im->image[ysize-y-1] = mapper->base + mapper->offset + y * stride; -: 241: } -: 242: } -: 243: #####: 244: im->destroy = ImagingDestroyMap; -: 245: #####: 246: mapper->offset += size; -: 247: #####: 248: return PyImagingNew(im); call 0 never executed -: 249:} -: 250: -: 251:static struct PyMethodDef methods[] = { -: 252: /* standard file interface */ -: 253: {"read", (PyCFunction)mapping_read, 1}, -: 254: {"seek", (PyCFunction)mapping_seek, 1}, -: 255: /* extensions */ -: 256: {"readimage", (PyCFunction)mapping_readimage, 1}, -: 257: {NULL, NULL} /* sentinel */ -: 258:}; -: 259: -: 260:static PyTypeObject ImagingMapperType = { -: 261: PyVarObject_HEAD_INIT(NULL, 0) -: 262: "ImagingMapper", /*tp_name*/ -: 263: sizeof(ImagingMapperObject), /*tp_size*/ -: 264: 0, /*tp_itemsize*/ -: 265: /* methods */ -: 266: (destructor)mapping_dealloc, /*tp_dealloc*/ -: 267: 0, /*tp_print*/ -: 268: 0, /*tp_getattr*/ -: 269: 0, /*tp_setattr*/ -: 270: 0, /*tp_compare*/ -: 271: 0, /*tp_repr*/ -: 272: 0, /*tp_as_number */ -: 273: 0, /*tp_as_sequence */ -: 274: 0, /*tp_as_mapping */ -: 275: 0, /*tp_hash*/ -: 276: 0, /*tp_call*/ -: 277: 0, /*tp_str*/ -: 278: 0, /*tp_getattro*/ -: 279: 0, /*tp_setattro*/ -: 280: 0, /*tp_as_buffer*/ -: 281: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 282: 0, /*tp_doc*/ -: 283: 0, /*tp_traverse*/ -: 284: 0, /*tp_clear*/ -: 285: 0, /*tp_richcompare*/ -: 286: 0, /*tp_weaklistoffset*/ -: 287: 0, /*tp_iter*/ -: 288: 0, /*tp_iternext*/ -: 289: methods, /*tp_methods*/ -: 290: 0, /*tp_members*/ -: 291: 0, /*tp_getset*/ -: 292:}; -: 293: -: 294:PyObject* function PyImaging_Mapper called 0 returned 0% blocks executed 0% #####: 295:PyImaging_Mapper(PyObject* self, PyObject* args) -: 296:{ -: 297: char* filename; #####: 298: if (!PyArg_ParseTuple(args, "s", &filename)) { call 0 never executed branch 1 never executed branch 2 never executed -: 299: return NULL; -: 300: } -: 301: #####: 302: return (PyObject*) PyImaging_MapperNew(filename, 1); call 0 never executed -: 303:} -: 304: -: 305:/* -------------------------------------------------------------------- */ -: 306:/* Buffer mapper */ -: 307: -: 308:typedef struct ImagingBufferInstance { -: 309: struct ImagingMemoryInstance im; -: 310: PyObject* target; -: 311: Py_buffer view; -: 312:} ImagingBufferInstance; -: 313: -: 314:static void function mapping_destroy_buffer called 106 returned 100% blocks executed 100% 106: 315:mapping_destroy_buffer(Imaging im) -: 316:{ 106: 317: ImagingBufferInstance* buffer = (ImagingBufferInstance*) im; -: 318: 106: 319: PyBuffer_Release(&buffer->view); call 0 returned 100% 106: 320: Py_XDECREF(buffer->target); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 42% (fallthrough) branch 3 taken 58% call 4 returned 100% 106: 321:} -: 322: -: 323:PyObject* function PyImaging_MapBuffer called 107 returned 100% blocks executed 77% 107: 324:PyImaging_MapBuffer(PyObject* self, PyObject* args) -: 325:{ -: 326: Py_ssize_t y, size; -: 327: Imaging im; -: 328: -: 329: PyObject* target; -: 330: Py_buffer view; -: 331: char* mode; -: 332: char* codec; -: 333: Py_ssize_t offset; -: 334: int xsize, ysize; -: 335: int stride; -: 336: int ystep; -: 337: 107: 338: if (!PyArg_ParseTuple(args, "O(ii)sn(sii)", &target, &xsize, &ysize, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 339: &codec, &offset, &mode, &stride, &ystep)) { -: 340: return NULL; -: 341: } -: 342: 107: 343: if (!PyImaging_CheckBuffer(target)) { call 0 returned 100% branch 1 taken 0% (fallthrough) branch 2 taken 100% #####: 344: PyErr_SetString(PyExc_TypeError, "expected string or buffer"); call 0 never executed #####: 345: return NULL; -: 346: } -: 347: 107: 348: if (stride <= 0) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 85: 349: if (!strcmp(mode, "L") || !strcmp(mode, "P")) { branch 0 taken 64% (fallthrough) branch 1 taken 36% branch 2 taken 36% (fallthrough) branch 3 taken 64% branch 4 taken 26% (fallthrough) branch 5 taken 74% branch 6 taken 26% (fallthrough) branch 7 taken 74% 62: 350: stride = xsize; 23: 351: } else if (!strncmp(mode, "I;16", 4)) { branch 0 taken 78% (fallthrough) branch 1 taken 22% 18: 352: stride = xsize * 2; -: 353: } else { 5: 354: stride = xsize * 4; -: 355: } -: 356: } -: 357: 107: 358: if (stride > 0 && ysize > PY_SSIZE_T_MAX / stride) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 359: PyErr_SetString(PyExc_MemoryError, "Integer overflow in ysize"); call 0 never executed #####: 360: return NULL; -: 361: } -: 362: 107: 363: size = (Py_ssize_t) ysize * stride; -: 364: 107: 365: if (offset > PY_SSIZE_T_MAX - size) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 366: PyErr_SetString(PyExc_MemoryError, "Integer overflow in offset"); call 0 never executed #####: 367: return NULL; -: 368: } -: 369: -: 370: /* check buffer size */ 107: 371: if (PyImaging_GetBuffer(target, &view) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 372: return NULL; -: 373: } -: 374: 107: 375: if (view.len < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 376: PyErr_SetString(PyExc_ValueError, "buffer has negative size"); call 0 never executed #####: 377: PyBuffer_Release(&view); call 0 never executed #####: 378: return NULL; -: 379: } 107: 380: if (offset + size > view.len) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 381: PyErr_SetString(PyExc_ValueError, "buffer is not large enough"); call 0 returned 100% 1: 382: PyBuffer_Release(&view); call 0 returned 100% 1: 383: return NULL; -: 384: } -: 385: 106: 386: im = ImagingNewPrologueSubtype( call 0 returned 100% -: 387: mode, xsize, ysize, sizeof(ImagingBufferInstance)); 106: 388: if (!im) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 389: PyBuffer_Release(&view); call 0 never executed #####: 390: return NULL; -: 391: } -: 392: -: 393: /* setup file pointers */ 106: 394: if (ystep > 0) { branch 0 taken 35% (fallthrough) branch 1 taken 65% 48947: 395: for (y = 0; y < ysize; y++) { branch 0 taken 99% branch 1 taken 1% 48947: 396: im->image[y] = (char*)view.buf + offset + y * stride; -: 397: } -: 398: } else { 2157: 399: for (y = 0; y < ysize; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 2157: 400: im->image[ysize-y-1] = (char*)view.buf + offset + y * stride; -: 401: } -: 402: } -: 403: 106: 404: im->destroy = mapping_destroy_buffer; -: 405: 106: 406: Py_INCREF(target); 106: 407: ((ImagingBufferInstance*) im)->target = target; 106: 408: ((ImagingBufferInstance*) im)->view = view; -: 409: 106: 410: return PyImagingNew(im); call 0 returned 100% -: 411:} -: 412: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Pack.c.gcov -: 0:Source:src/libImaging/Pack.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Pack.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Pack.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1: /* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * code to pack raw data -: 6: * -: 7: * history: -: 8: * 1996-04-30 fl Created -: 9: * 1996-05-12 fl Published a few RGB packers -: 10: * 1996-11-01 fl More RGB packers (Tk booster stuff) -: 11: * 1996-12-30 fl Added P;1, P;2 and P;4 packers -: 12: * 1997-06-02 fl Added F (F;32NF) packer -: 13: * 1997-08-28 fl Added 1 as L packer -: 14: * 1998-02-08 fl Added I packer -: 15: * 1998-03-09 fl Added mode field, RGBA/RGBX as RGB packers -: 16: * 1998-07-01 fl Added YCbCr support -: 17: * 1998-07-12 fl Added I 16 packer -: 18: * 1999-02-03 fl Added BGR packers -: 19: * 2003-09-26 fl Added LA/PA packers -: 20: * 2006-06-22 fl Added CMYK;I packer -: 21: * -: 22: * Copyright (c) 1997-2006 by Secret Labs AB. -: 23: * Copyright (c) 1996-1997 by Fredrik Lundh. -: 24: * -: 25: * See the README file for information on usage and redistribution. -: 26: */ -: 27: -: 28: -: 29:#include "Imaging.h" -: 30: -: 31:#define R 0 -: 32:#define G 1 -: 33:#define B 2 -: 34:#define X 3 -: 35:#define A 3 -: 36: -: 37:#define C 0 -: 38:#define M 1 -: 39:#define Y 2 -: 40:#define K 3 -: 41: -: 42:/* byte swapping macros */ -: 43: -: 44:#define C16N\ -: 45: (out[0]=tmp[0], out[1]=tmp[1]); -: 46:#define C16S\ -: 47: (out[1]=tmp[0], out[0]=tmp[1]); -: 48:#define C32N\ -: 49: (out[0]=tmp[0], out[1]=tmp[1], out[2]=tmp[2], out[3]=tmp[3]); -: 50:#define C32S\ -: 51: (out[3]=tmp[0], out[2]=tmp[1], out[1]=tmp[2], out[0]=tmp[3]); -: 52:#define C64N\ -: 53: (out[0]=tmp[0], out[1]=tmp[1], out[2]=tmp[2], out[3]=tmp[3],\ -: 54: out[4]=tmp[4], out[5]=tmp[5], out[6]=tmp[6], out[7]=tmp[7]); -: 55:#define C64S\ -: 56: (out[7]=tmp[0], out[6]=tmp[1], out[5]=tmp[2], out[4]=tmp[3],\ -: 57: out[3]=tmp[4], out[2]=tmp[5], out[1]=tmp[6], out[0]=tmp[7]); -: 58: -: 59:#ifdef WORDS_BIGENDIAN -: 60:#define C16B C16N -: 61:#define C16L C16S -: 62:#define C32B C32N -: 63:#define C32L C32S -: 64:#define C64B C64N -: 65:#define C64L C64S -: 66:#else -: 67:#define C16B C16S -: 68:#define C16L C16N -: 69:#define C32B C32S -: 70:#define C32L C32N -: 71:#define C64B C64S -: 72:#define C64L C64N -: 73:#endif -: 74: -: 75: -: 76:static void function pack1 called 23398 returned 100% blocks executed 100% 23398: 77:pack1(UINT8* out, const UINT8* in, int pixels) -: 78:{ -: 79: int i, m, b; -: 80: /* bilevel (black is 0) */ 23398: 81: b = 0; m = 128; 15596631: 82: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 15573233: 83: if (in[i] != 0) { branch 0 taken 46% (fallthrough) branch 1 taken 54% 7136230: 84: b |= m; -: 85: } 15573233: 86: m >>= 1; 15573233: 87: if (m == 0) { branch 0 taken 12% (fallthrough) branch 1 taken 88% 1944082: 88: *out++ = b; 1944082: 89: b = 0; m = 128; -: 90: } -: 91: } 23398: 92: if (m != 128) { branch 0 taken 30% (fallthrough) branch 1 taken 70% 6955: 93: *out++ = b; -: 94: } 23398: 95:} -: 96: -: 97:static void function pack1I called 258 returned 100% blocks executed 90% 258: 98:pack1I(UINT8* out, const UINT8* in, int pixels) -: 99:{ -: 100: int i, m, b; -: 101: /* bilevel (black is 1) */ 258: 102: b = 0; m = 128; 33042: 103: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32784: 104: if (in[i] == 0) { branch 0 taken 67% (fallthrough) branch 1 taken 33% 21993: 105: b |= m; -: 106: } 32784: 107: m >>= 1; 32784: 108: if (m == 0) { branch 0 taken 13% (fallthrough) branch 1 taken 88% 4098: 109: *out++ = b; 4098: 110: b = 0; m = 128; -: 111: } -: 112: } 258: 113: if (m != 128) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 114: *out++ = b; -: 115: } 258: 116:} -: 117: -: 118:static void function pack1R called 1386 returned 100% blocks executed 90% 1386: 119:pack1R(UINT8* out, const UINT8* in, int pixels) -: 120:{ -: 121: int i, m, b; -: 122: /* bilevel, lsb first (black is 0) */ 1386: 123: b = 0; m = 1; 1050554: 124: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1049168: 125: if (in[i] != 0) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 348100: 126: b |= m; -: 127: } 1049168: 128: m <<= 1; 1049168: 129: if (m == 256){ branch 0 taken 13% (fallthrough) branch 1 taken 88% 131146: 130: *out++ = b; 131146: 131: b = 0; m = 1; -: 132: } -: 133: } 1386: 134: if (m != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 135: *out++ = b; -: 136: } 1386: 137:} -: 138: -: 139:static void function pack1IR called 2 returned 100% blocks executed 90% 2: 140:pack1IR(UINT8* out, const UINT8* in, int pixels) -: 141:{ -: 142: int i, m, b; -: 143: /* bilevel, lsb first (black is 1) */ 2: 144: b = 0; m = 1; 18: 145: for (i = 0; i < pixels; i++) { branch 0 taken 89% branch 1 taken 11% (fallthrough) 16: 146: if (in[i] == 0) { branch 0 taken 31% (fallthrough) branch 1 taken 69% 5: 147: b |= m; -: 148: } 16: 149: m <<= 1; 16: 150: if (m == 256){ branch 0 taken 13% (fallthrough) branch 1 taken 88% 2: 151: *out++ = b; 2: 152: b = 0; m = 1; -: 153: } -: 154: } 2: 155: if (m != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 156: *out++ = b; -: 157: } 2: 158:} -: 159: -: 160:static void function pack1L called 45 returned 100% blocks executed 100% 45: 161:pack1L(UINT8* out, const UINT8* in, int pixels) -: 162:{ -: 163: int i; -: 164: /* bilevel, stored as bytes */ 663: 165: for (i = 0; i < pixels; i++) { branch 0 taken 93% branch 1 taken 7% (fallthrough) 618: 166: out[i] = (in[i] != 0) ? 255 : 0; branch 0 taken 96% (fallthrough) branch 1 taken 4% -: 167: } 45: 168:} -: 169: -: 170:static void function packP4 called 1 returned 100% blocks executed 83% 1: 171:packP4(UINT8* out, const UINT8* in, int pixels) -: 172:{ 4: 173: while (pixels >= 2) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 4: 174: *out++ = (in[0] << 4) | 2: 175: (in[1] & 15); 2: 176: in += 2; pixels -= 2; -: 177: } -: 178: 1: 179: if (pixels) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 180: out[0] = (in[0] << 4); -: 181: } 1: 182:} -: 183: -: 184:static void function packP2 called 2 returned 100% blocks executed 75% 2: 185:packP2(UINT8* out, const UINT8* in, int pixels) -: 186:{ 6: 187: while (pixels >= 4) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 8: 188: *out++ = (in[0] << 6) | 2: 189: ((in[1] & 3) << 4) | 2: 190: ((in[2] & 3) << 2) | 2: 191: (in[3] & 3); 2: 192: in += 4; pixels -= 4; -: 193: } -: 194: 2: 195: switch (pixels) { branch 0 taken 0% branch 1 taken 50% branch 2 taken 0% branch 3 taken 50% -: 196: case 3: #####: 197: out[0] = (in[0] << 6) | #####: 198: ((in[1] & 3) << 4) | #####: 199: ((in[2] & 3) << 2); #####: 200: break; -: 201: case 2: 2: 202: out[0] = (in[0] << 6) | 1: 203: ((in[1] & 3) << 4); 1: 204: break; -: 205: case 1: #####: 206: out[0] = (in[0] << 6); -: 207: } 2: 208:} -: 209: -: 210:static void function packL16 called 1 returned 100% blocks executed 100% 1: 211:packL16(UINT8* out, const UINT8* in, int pixels) -: 212:{ -: 213: int i; -: 214: /* L -> L;16, e.g: \xff77 -> \x00\xff\x00\x77 */ 3: 215: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 216: out[0] = 0; 2: 217: out[1] = in[i]; 2: 218: out += 2; -: 219: } 1: 220:} -: 221: -: 222:static void function packL16B called 385 returned 100% blocks executed 100% 385: 223:packL16B(UINT8* out, const UINT8* in, int pixels) -: 224:{ -: 225: int i; -: 226: /* L -> L;16B, e.g: \xff77 -> \xff\x00\x77\x00 */ 49539: 227: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 49154: 228: out[0] = in[i]; 49154: 229: out[1] = 0; 49154: 230: out += 2; -: 231: } 385: 232:} -: 233: -: 234: -: 235:static void function packLA called 13122 returned 100% blocks executed 100% 13122: 236:packLA(UINT8* out, const UINT8* in, int pixels) -: 237:{ -: 238: int i; -: 239: /* LA, pixel interleaved */ 1411686: 240: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1398564: 241: out[0] = in[R]; 1398564: 242: out[1] = in[A]; 1398564: 243: out += 2; in += 4; -: 244: } 13122: 245:} -: 246: -: 247:static void function packLAL called 130 returned 100% blocks executed 100% 130: 248:packLAL(UINT8* out, const UINT8* in, int pixels) -: 249:{ -: 250: int i; -: 251: /* LA, line interleaved */ 16520: 252: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 16390: 253: out[i] = in[R]; 16390: 254: out[i+pixels] = in[A]; 16390: 255: in += 4; -: 256: } 130: 257:} -: 258: -: 259:void function ImagingPackRGB called 188815 returned 100% blocks executed 100% 188815: 260:ImagingPackRGB(UINT8* out, const UINT8* in, int pixels) -: 261:{ 188815: 262: int i = 0; -: 263: /* RGB triplets */ -: 264:#ifdef __sparc -: 265: /* SPARC CPUs cannot read integers from nonaligned addresses. */ -: 266: for (; i < pixels; i++) { -: 267: out[0] = in[R]; -: 268: out[1] = in[G]; -: 269: out[2] = in[B]; -: 270: out += 3; in += 4; -: 271: } -: 272:#else 195550569: 273: for (; i < pixels-1; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 390723508: 274: memcpy(out, in + i * 4, 4); 195361754: 275: out += 3; -: 276: } 188815: 277: for (; i < pixels; i++) { branch 0 taken 50% branch 1 taken 50% (fallthrough) 188815: 278: out[0] = in[i*4+R]; 188815: 279: out[1] = in[i*4+G]; 188815: 280: out[2] = in[i*4+B]; 188815: 281: out += 3; -: 282: } -: 283:#endif 188815: 284:} -: 285: -: 286:void function ImagingPackXRGB called 1 returned 100% blocks executed 100% 1: 287:ImagingPackXRGB(UINT8* out, const UINT8* in, int pixels) -: 288:{ -: 289: int i; -: 290: /* XRGB, triplets with left padding */ 3: 291: for (i = 0; i < pixels; i++) { branch 0 taken 67% branch 1 taken 33% (fallthrough) 2: 292: out[0] = 0; 2: 293: out[1] = in[R]; 2: 294: out[2] = in[G]; 2: 295: out[3] = in[B]; 2: 296: out += 4; in += 4; -: 297: } 1: 298:} -: 299: -: 300:void function ImagingPackBGR called 1379 returned 100% blocks executed 100% 1379: 301:ImagingPackBGR(UINT8* out, const UINT8* in, int pixels) -: 302:{ -: 303: int i; -: 304: /* RGB, reversed bytes */ 208412: 305: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 207033: 306: out[0] = in[B]; 207033: 307: out[1] = in[G]; 207033: 308: out[2] = in[R]; 207033: 309: out += 3; in += 4; -: 310: } 1379: 311:} -: 312: -: 313:void function ImagingPackBGRX called 3 returned 100% blocks executed 100% 3: 314:ImagingPackBGRX(UINT8* out, const UINT8* in, int pixels) -: 315:{ -: 316: int i; -: 317: /* BGRX, reversed bytes with right padding */ 264: 318: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 261: 319: out[0] = in[B]; 261: 320: out[1] = in[G]; 261: 321: out[2] = in[R]; 261: 322: out[3] = 0; 261: 323: out += 4; in += 4; -: 324: } 3: 325:} -: 326: -: 327:void function ImagingPackXBGR called 2 returned 100% blocks executed 100% 2: 328:ImagingPackXBGR(UINT8* out, const UINT8* in, int pixels) -: 329:{ -: 330: int i; -: 331: /* XBGR, reversed bytes with left padding */ 7: 332: for (i = 0; i < pixels; i++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 5: 333: out[0] = 0; 5: 334: out[1] = in[B]; 5: 335: out[2] = in[G]; 5: 336: out[3] = in[R]; 5: 337: out += 4; in += 4; -: 338: } 2: 339:} -: 340: -: 341:void function ImagingPackBGRA called 1687 returned 100% blocks executed 100% 1687: 342:ImagingPackBGRA(UINT8* out, const UINT8* in, int pixels) -: 343:{ -: 344: int i; -: 345: /* BGRX, reversed bytes with right padding */ 322628: 346: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 320941: 347: out[0] = in[B]; 320941: 348: out[1] = in[G]; 320941: 349: out[2] = in[R]; 320941: 350: out[3] = in[A]; 320941: 351: out += 4; in += 4; -: 352: } 1687: 353:} -: 354: -: 355:void function ImagingPackABGR called 2 returned 100% blocks executed 100% 2: 356:ImagingPackABGR(UINT8* out, const UINT8* in, int pixels) -: 357:{ -: 358: int i; -: 359: /* XBGR, reversed bytes with left padding */ 8: 360: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 6: 361: out[0] = in[A]; 6: 362: out[1] = in[B]; 6: 363: out[2] = in[G]; 6: 364: out[3] = in[R]; 6: 365: out += 4; in += 4; -: 366: } 2: 367:} -: 368: -: 369:void function ImagingPackBGRa called 1 returned 100% blocks executed 100% 1: 370:ImagingPackBGRa(UINT8* out, const UINT8* in, int pixels) -: 371:{ -: 372: int i; -: 373: /* BGRa, reversed bytes with premultiplied alpha */ 4: 374: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 3: 375: int alpha = out[3] = in[A]; -: 376: int tmp; 3: 377: out[0] = MULDIV255(in[B], alpha, tmp); 3: 378: out[1] = MULDIV255(in[G], alpha, tmp); 3: 379: out[2] = MULDIV255(in[R], alpha, tmp); 3: 380: out += 4; in += 4; -: 381: } 1: 382:} -: 383: -: 384:static void function packRGBL called 1033 returned 100% blocks executed 100% 1033: 385:packRGBL(UINT8* out, const UINT8* in, int pixels) -: 386:{ -: 387: int i; -: 388: /* RGB, line interleaved */ 329744: 389: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 328711: 390: out[i] = in[R]; 328711: 391: out[i+pixels] = in[G]; 328711: 392: out[i+pixels+pixels] = in[B]; 328711: 393: in += 4; -: 394: } 1033: 395:} -: 396: -: 397:static void function packRGBXL called 3 returned 100% blocks executed 100% 3: 398:packRGBXL(UINT8* out, const UINT8* in, int pixels) -: 399:{ -: 400: int i; -: 401: /* RGBX, line interleaved */ 12: 402: for (i = 0; i < pixels; i++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 9: 403: out[i] = in[R]; 9: 404: out[i+pixels] = in[G]; 9: 405: out[i+pixels+pixels] = in[B]; 9: 406: out[i+pixels+pixels+pixels] = in[X]; 9: 407: in += 4; -: 408: } 3: 409:} -: 410: -: 411:static void function packI16B called 293 returned 100% blocks executed 89% 293: 412:packI16B(UINT8* out, const UINT8* in_, int pixels) -: 413:{ -: 414: int i; -: 415: UINT16 tmp_; 293: 416: UINT8* tmp = (UINT8*) &tmp_; 22775: 417: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 418: INT32 in; 22482: 419: memcpy(&in, in_, sizeof(in)); 22482: 420: if (in <= 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 75: 421: tmp_ = 0; 22407: 422: } else if (in > 65535) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 423: tmp_ = 65535; -: 424: } else { 22407: 425: tmp_ = in; -: 426: } 22482: 427: C16B; 22482: 428: out += 2; in_ += sizeof(in); -: 429: } 293: 430:} -: 431: -: 432:static void function packI16N_I16B called 256 returned 100% blocks executed 100% 256: 433:packI16N_I16B(UINT8* out, const UINT8* in, int pixels){ -: 434: int i; 256: 435: UINT8* tmp = (UINT8*) in; 33024: 436: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 32768: 437: C16B; 32768: 438: out += 2; tmp += 2; -: 439: } -: 440: 256: 441:} -: 442:static void function packI16N_I16 called 0 returned 0% blocks executed 0% #####: 443:packI16N_I16(UINT8* out, const UINT8* in, int pixels){ -: 444: int i; #####: 445: UINT8* tmp = (UINT8*) in; #####: 446: for (i = 0; i < pixels; i++) { branch 0 never executed branch 1 never executed #####: 447: C16L; #####: 448: out += 2; tmp += 2; -: 449: } #####: 450:} -: 451: -: 452: -: 453:static void function packI32S called 290 returned 100% blocks executed 100% 290: 454:packI32S(UINT8* out, const UINT8* in, int pixels) -: 455:{ -: 456: int i; 290: 457: UINT8* tmp = (UINT8*) in; 34086: 458: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 33796: 459: C32L; 33796: 460: out += 4; tmp += 4; -: 461: } 290: 462:} -: 463: -: 464:void function ImagingPackLAB called 1025 returned 100% blocks executed 100% 1025: 465:ImagingPackLAB(UINT8* out, const UINT8* in, int pixels) -: 466:{ -: 467: int i; -: 468: /* LAB triplets */ 132100: 469: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 131075: 470: out[0] = in[0]; 131075: 471: out[1] = in[1] ^ 128; /* signed in outside world */ 131075: 472: out[2] = in[2] ^ 128; 131075: 473: out += 3; in += 4; -: 474: } 1025: 475:} -: 476: -: 477:static void function copy1 called 195347 returned 100% blocks executed 100% 195347: 478:copy1(UINT8* out, const UINT8* in, int pixels) -: 479:{ -: 480: /* L, P */ 390694: 481: memcpy(out, in, pixels); 195347: 482:} -: 483: -: 484:static void function copy2 called 8121 returned 100% blocks executed 100% 8121: 485:copy2(UINT8* out, const UINT8* in, int pixels) -: 486:{ -: 487: /* I;16, etc */ 16242: 488: memcpy(out, in, pixels*2); 8121: 489:} -: 490: -: 491:static void function copy3 called 0 returned 0% blocks executed 0% #####: 492:copy3(UINT8* out, const UINT8* in, int pixels) -: 493:{ -: 494: /* BGR;24, etc */ #####: 495: memcpy(out, in, pixels*3); #####: 496:} -: 497: -: 498:static void function copy4 called 74849 returned 100% blocks executed 100% 74849: 499:copy4(UINT8* out, const UINT8* in, int pixels) -: 500:{ -: 501: /* RGBA, CMYK quadruples */ 149698: 502: memcpy(out, in, 4*pixels); 74849: 503:} -: 504: -: 505:static void function copy4I called 2189 returned 100% blocks executed 100% 2189: 506:copy4I(UINT8* out, const UINT8* in, int pixels) -: 507:{ -: 508: /* RGBA, CMYK quadruples, inverted */ -: 509: int i; 1022553: 510: for (i = 0; i < pixels*4; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1020364: 511: out[i] = ~in[i]; -: 512: } 2189: 513:} -: 514: -: 515:static void function band0 called 6 returned 100% blocks executed 100% 6: 516:band0(UINT8* out, const UINT8* in, int pixels) -: 517:{ -: 518: int i; 24: 519: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 18: 520: out[i] = in[0]; -: 521: } 6: 522:} -: 523: -: 524:static void function band1 called 6 returned 100% blocks executed 100% 6: 525:band1(UINT8* out, const UINT8* in, int pixels) -: 526:{ -: 527: int i; 24: 528: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 18: 529: out[i] = in[1]; -: 530: } 6: 531:} -: 532: -: 533:static void function band2 called 6 returned 100% blocks executed 100% 6: 534:band2(UINT8* out, const UINT8* in, int pixels) -: 535:{ -: 536: int i; 24: 537: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 18: 538: out[i] = in[2]; -: 539: } 6: 540:} -: 541: -: 542:static void function band3 called 5 returned 100% blocks executed 100% 5: 543:band3(UINT8* out, const UINT8* in, int pixels) -: 544:{ -: 545: int i; 526: 546: for (i = 0; i < pixels; i++, in += 4) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 521: 547: out[i] = in[3]; -: 548: } 5: 549:} -: 550: -: 551:static struct { -: 552: const char* mode; -: 553: const char* rawmode; -: 554: int bits; -: 555: ImagingShuffler pack; -: 556:} packers[] = { -: 557: -: 558: /* bilevel */ -: 559: {"1", "1", 1, pack1}, -: 560: {"1", "1;I", 1, pack1I}, -: 561: {"1", "1;R", 1, pack1R}, -: 562: {"1", "1;IR", 1, pack1IR}, -: 563: {"1", "L", 8, pack1L}, -: 564: -: 565: /* greyscale */ -: 566: {"L", "L", 8, copy1}, -: 567: {"L", "L;16", 16, packL16}, -: 568: {"L", "L;16B", 16, packL16B}, -: 569: -: 570: /* greyscale w. alpha */ -: 571: {"LA", "LA", 16, packLA}, -: 572: {"LA", "LA;L", 16, packLAL}, -: 573: -: 574: /* greyscale w. alpha premultiplied */ -: 575: {"La", "La", 16, packLA}, -: 576: -: 577: /* palette */ -: 578: {"P", "P;1", 1, pack1}, -: 579: {"P", "P;2", 2, packP2}, -: 580: {"P", "P;4", 4, packP4}, -: 581: {"P", "P", 8, copy1}, -: 582: -: 583: /* palette w. alpha */ -: 584: {"PA", "PA", 16, packLA}, -: 585: {"PA", "PA;L", 16, packLAL}, -: 586: -: 587: /* true colour */ -: 588: {"RGB", "RGB", 24, ImagingPackRGB}, -: 589: {"RGB", "RGBX", 32, copy4}, -: 590: {"RGB", "XRGB", 32, ImagingPackXRGB}, -: 591: {"RGB", "BGR", 24, ImagingPackBGR}, -: 592: {"RGB", "BGRX", 32, ImagingPackBGRX}, -: 593: {"RGB", "XBGR", 32, ImagingPackXBGR}, -: 594: {"RGB", "RGB;L", 24, packRGBL}, -: 595: {"RGB", "R", 8, band0}, -: 596: {"RGB", "G", 8, band1}, -: 597: {"RGB", "B", 8, band2}, -: 598: -: 599: /* true colour w. alpha */ -: 600: {"RGBA", "RGBA", 32, copy4}, -: 601: {"RGBA", "RGBA;L", 32, packRGBXL}, -: 602: {"RGBA", "RGB", 24, ImagingPackRGB}, -: 603: {"RGBA", "BGR", 24, ImagingPackBGR}, -: 604: {"RGBA", "BGRA", 32, ImagingPackBGRA}, -: 605: {"RGBA", "ABGR", 32, ImagingPackABGR}, -: 606: {"RGBA", "BGRa", 32, ImagingPackBGRa}, -: 607: {"RGBA", "R", 8, band0}, -: 608: {"RGBA", "G", 8, band1}, -: 609: {"RGBA", "B", 8, band2}, -: 610: {"RGBA", "A", 8, band3}, -: 611: -: 612: /* true colour w. alpha premultiplied */ -: 613: {"RGBa", "RGBa", 32, copy4}, -: 614: {"RGBa", "BGRa", 32, ImagingPackBGRA}, -: 615: {"RGBa", "aBGR", 32, ImagingPackABGR}, -: 616: -: 617: /* true colour w. padding */ -: 618: {"RGBX", "RGBX", 32, copy4}, -: 619: {"RGBX", "RGBX;L", 32, packRGBXL}, -: 620: {"RGBX", "RGB", 24, ImagingPackRGB}, -: 621: {"RGBX", "BGR", 24, ImagingPackBGR}, -: 622: {"RGBX", "BGRX", 32, ImagingPackBGRX}, -: 623: {"RGBX", "XBGR", 32, ImagingPackXBGR}, -: 624: {"RGBX", "R", 8, band0}, -: 625: {"RGBX", "G", 8, band1}, -: 626: {"RGBX", "B", 8, band2}, -: 627: {"RGBX", "X", 8, band3}, -: 628: -: 629: /* colour separation */ -: 630: {"CMYK", "CMYK", 32, copy4}, -: 631: {"CMYK", "CMYK;I", 32, copy4I}, -: 632: {"CMYK", "CMYK;L", 32, packRGBXL}, -: 633: {"CMYK", "C", 8, band0}, -: 634: {"CMYK", "M", 8, band1}, -: 635: {"CMYK", "Y", 8, band2}, -: 636: {"CMYK", "K", 8, band3}, -: 637: -: 638: /* video (YCbCr) */ -: 639: {"YCbCr", "YCbCr", 24, ImagingPackRGB}, -: 640: {"YCbCr", "YCbCr;L", 24, packRGBL}, -: 641: {"YCbCr", "YCbCrX", 32, copy4}, -: 642: {"YCbCr", "YCbCrK", 32, copy4}, -: 643: {"YCbCr", "Y", 8, band0}, -: 644: {"YCbCr", "Cb", 8, band1}, -: 645: {"YCbCr", "Cr", 8, band2}, -: 646: -: 647: /* LAB Color */ -: 648: {"LAB", "LAB", 24, ImagingPackLAB}, -: 649: {"LAB", "L", 8, band0}, -: 650: {"LAB", "A", 8, band1}, -: 651: {"LAB", "B", 8, band2}, -: 652: -: 653: /* HSV */ -: 654: {"HSV", "HSV", 24, ImagingPackRGB}, -: 655: {"HSV", "H", 8, band0}, -: 656: {"HSV", "S", 8, band1}, -: 657: {"HSV", "V", 8, band2}, -: 658: -: 659: /* integer */ -: 660: {"I", "I", 32, copy4}, -: 661: {"I", "I;16B", 16, packI16B}, -: 662: {"I", "I;32S", 32, packI32S}, -: 663: {"I", "I;32NS", 32, copy4}, -: 664: -: 665: /* floating point */ -: 666: {"F", "F", 32, copy4}, -: 667: {"F", "F;32F", 32, packI32S}, -: 668: {"F", "F;32NF", 32, copy4}, -: 669: -: 670: /* storage modes */ -: 671: {"I;16", "I;16", 16, copy2}, -: 672: {"I;16", "I;16B", 16, packI16N_I16B}, -: 673: {"I;16B", "I;16B", 16, copy2}, -: 674: {"I;16L", "I;16L", 16, copy2}, -: 675: {"I;16", "I;16N", 16, packI16N_I16}, // LibTiff native->image endian. -: 676: {"I;16L", "I;16N", 16, packI16N_I16}, -: 677: {"I;16B", "I;16N", 16, packI16N_I16B}, -: 678: {"BGR;15", "BGR;15", 16, copy2}, -: 679: {"BGR;16", "BGR;16", 16, copy2}, -: 680: {"BGR;24", "BGR;24", 24, copy3}, -: 681: -: 682: {NULL} /* sentinel */ -: 683:}; -: 684: -: 685: -: 686:ImagingShuffler function ImagingFindPacker called 4061 returned 100% blocks executed 100% 4061: 687:ImagingFindPacker(const char* mode, const char* rawmode, int* bits_out) -: 688:{ -: 689: int i; -: 690: -: 691: /* find a suitable pixel packer */ 73470: 692: for (i = 0; packers[i].rawmode; i++) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 79838: 693: if (strcmp(packers[i].mode, mode) == 0 && branch 0 taken 9% (fallthrough) branch 1 taken 91% branch 2 taken 64% (fallthrough) branch 3 taken 36% 6368: 694: strcmp(packers[i].rawmode, rawmode) == 0) { 4061: 695: if (bits_out) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 4061: 696: *bits_out = packers[i].bits; -: 697: } 4061: 698: return packers[i].pack; -: 699: } -: 700: } -: 701: return NULL; -: 702:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#UnsharpMask.c.gcov -: 0:Source:src/libImaging/UnsharpMask.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/UnsharpMask.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/UnsharpMask.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* PILusm, a gaussian blur and unsharp masking library for PIL -: 2: By Kevin Cazabon, copyright 2003 -: 3: kevin_cazabon@hotmail.com -: 4: kevin@cazabon.com */ -: 5: -: 6:/* Originally released under LGPL. Graciously donated to PIL -: 7: for distribution under the standard PIL license in 2009." */ -: 8: -: 9:#include "Imaging.h" -: 10: -: 11: -: 12:typedef UINT8 pixel[4]; -: 13: -: 14: -: 15:static inline UINT8 clip8(int in) -: 16:{ 286515: 17: if (in >= 255) { branch 0 taken 88% (fallthrough) branch 1 taken 12% branch 2 taken 74% (fallthrough) branch 3 taken 26% branch 4 taken 78% (fallthrough) branch 5 taken 22% branch 6 taken 81% (fallthrough) branch 7 taken 19% branch 8 never executed branch 9 never executed -: 18: return 255; -: 19: } 225782: 20: if (in <= 0) { branch 0 taken 57% (fallthrough) branch 1 taken 43% branch 2 taken 62% (fallthrough) branch 3 taken 38% branch 4 taken 65% (fallthrough) branch 5 taken 35% branch 6 taken 73% (fallthrough) branch 7 taken 27% branch 8 never executed branch 9 never executed -: 21: return 0; -: 22: } 148379: 23: return (UINT8) in; -: 24:} -: 25: -: 26: -: 27:Imaging function ImagingUnsharpMask called 16 returned 100% blocks executed 90% 16: 28:ImagingUnsharpMask(Imaging imOut, Imaging imIn, float radius, int percent, -: 29: int threshold) -: 30:{ -: 31: ImagingSectionCookie cookie; -: 32: Imaging result; -: 33: -: 34: int x, y, diff; -: 35: 16: 36: pixel *lineIn = NULL; 16: 37: pixel *lineOut = NULL; 16: 38: UINT8 *lineIn8 = NULL; 16: 39: UINT8 *lineOut8 = NULL; -: 40: -: 41: /* First, do a gaussian blur on the image, putting results in imOut -: 42: temporarily. All format checks are in gaussian blur. */ 16: 43: result = ImagingGaussianBlur(imOut, imIn, radius, 3); call 0 returned 100% 16: 44: if (!result) { branch 0 taken 75% (fallthrough) branch 1 taken 25% -: 45: return NULL; -: 46: } -: 47: -: 48: /* Now, go through each pixel, compare "normal" pixel to blurred -: 49: pixel. If the difference is more than threshold values, apply -: 50: the OPPOSITE correction to the amount of blur, multiplied by -: 51: percent. */ -: 52: 12: 53: ImagingSectionEnter(&cookie); -: 54: 1430: 55: for (y = 0; y < imIn->ysize; y++) { call 0 returned 100% branch 1 taken 99% branch 2 taken 1% (fallthrough) 1418: 56: if (imIn->image8) branch 0 taken 27% (fallthrough) branch 1 taken 73% -: 57: { 384: 58: lineIn8 = imIn->image8[y]; 384: 59: lineOut8 = imOut->image8[y]; 49536: 60: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% -: 61: /* compare in/out pixels, apply sharpening */ 49152: 62: diff = lineIn8[x] - lineOut8[x]; 49152: 63: if (abs(diff) > threshold) { branch 0 taken 66% (fallthrough) branch 1 taken 34% -: 64: /* add the diff*percent to the original pixel */ 65182: 65: lineOut8[x] = clip8(lineIn8[x] + diff * percent / 100); -: 66: } else { -: 67: /* new pixel is the same as imIn */ 16561: 68: lineOut8[x] = lineIn8[x]; -: 69: } -: 70: } -: 71: } else { 1034: 72: lineIn = (pixel *)imIn->image32[y]; 1034: 73: lineOut = (pixel *)imOut->image32[y]; 132206: 74: for (x = 0; x < imIn->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 75: /* compare in/out pixels, apply sharpening */ 131172: 76: diff = lineIn[x][0] - lineOut[x][0]; 216833: 77: lineOut[x][0] = abs(diff) > threshold ? branch 0 taken 65% (fallthrough) branch 1 taken 35% 85661: 78: clip8(lineIn[x][0] + diff * percent / 100) : lineIn[x][0]; -: 79: 131172: 80: diff = lineIn[x][1] - lineOut[x][1]; 213432: 81: lineOut[x][1] = abs(diff) > threshold ? branch 0 taken 63% (fallthrough) branch 1 taken 37% 82260: 82: clip8(lineIn[x][1] + diff * percent / 100) : lineIn[x][1]; -: 83: 131172: 84: diff = lineIn[x][2] - lineOut[x][2]; 217175: 85: lineOut[x][2] = abs(diff) > threshold ? branch 0 taken 66% (fallthrough) branch 1 taken 34% 86003: 86: clip8(lineIn[x][2] + diff * percent / 100) : lineIn[x][2]; -: 87: 131172: 88: diff = lineIn[x][3] - lineOut[x][3]; 131172: 89: lineOut[x][3] = abs(diff) > threshold ? branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 90: clip8(lineIn[x][3] + diff * percent / 100) : lineIn[x][3]; -: 91: } -: 92: } -: 93: } -: 94: 12: 95: ImagingSectionLeave(&cookie); call 0 returned 100% -: 96: 12: 97: return imOut; -: 98:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#BoxBlur.c.gcov -: 0:Source:src/libImaging/BoxBlur.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/BoxBlur.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/BoxBlur.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Imaging.h" -: 2: -: 3: -: 4:#define MAX(x, y) (((x) > (y)) ? (x) : (y)) -: 5:#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -: 6: -: 7: -: 8:typedef UINT8 pixel[4]; -: 9: -: 10:void static inline function ImagingLineBoxBlur32 called 13172 returned 100% blocks executed 100% 13172: 11:ImagingLineBoxBlur32(pixel *lineOut, pixel *lineIn, int lastx, int radius, int edgeA, -: 12: int edgeB, UINT32 ww, UINT32 fw) -: 13:{ -: 14: int x; -: 15: UINT32 acc[4]; -: 16: UINT32 bulk[4]; -: 17: -: 18: #define MOVE_ACC(acc, subtract, add) \ -: 19: acc[0] += lineIn[add][0] - lineIn[subtract][0]; \ -: 20: acc[1] += lineIn[add][1] - lineIn[subtract][1]; \ -: 21: acc[2] += lineIn[add][2] - lineIn[subtract][2]; \ -: 22: acc[3] += lineIn[add][3] - lineIn[subtract][3]; -: 23: -: 24: #define ADD_FAR(bulk, acc, left, right) \ -: 25: bulk[0] = (acc[0] * ww) + (lineIn[left][0] + lineIn[right][0]) * fw; \ -: 26: bulk[1] = (acc[1] * ww) + (lineIn[left][1] + lineIn[right][1]) * fw; \ -: 27: bulk[2] = (acc[2] * ww) + (lineIn[left][2] + lineIn[right][2]) * fw; \ -: 28: bulk[3] = (acc[3] * ww) + (lineIn[left][3] + lineIn[right][3]) * fw; -: 29: -: 30: #define SAVE(x, bulk) \ -: 31: lineOut[x][0] = (UINT8)((bulk[0] + (1 << 23)) >> 24); \ -: 32: lineOut[x][1] = (UINT8)((bulk[1] + (1 << 23)) >> 24); \ -: 33: lineOut[x][2] = (UINT8)((bulk[2] + (1 << 23)) >> 24); \ -: 34: lineOut[x][3] = (UINT8)((bulk[3] + (1 << 23)) >> 24); -: 35: -: 36: /* Compute acc for -1 pixel (outside of image): -: 37: From "-radius-1" to "-1" get first pixel, -: 38: then from "0" to "radius-1". */ 13172: 39: acc[0] = lineIn[0][0] * (radius + 1); 13172: 40: acc[1] = lineIn[0][1] * (radius + 1); 13172: 41: acc[2] = lineIn[0][2] * (radius + 1); 13172: 42: acc[3] = lineIn[0][3] * (radius + 1); -: 43: /* As radius can be bigger than xsize, iterate to edgeA -1. */ 45464: 44: for (x = 0; x < edgeA - 1; x++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 32292: 45: acc[0] += lineIn[x][0]; 32292: 46: acc[1] += lineIn[x][1]; 32292: 47: acc[2] += lineIn[x][2]; 32292: 48: acc[3] += lineIn[x][3]; -: 49: } -: 50: /* Then multiply remainder to last x. */ 13172: 51: acc[0] += lineIn[lastx][0] * (radius - edgeA + 1); 13172: 52: acc[1] += lineIn[lastx][1] * (radius - edgeA + 1); 13172: 53: acc[2] += lineIn[lastx][2] * (radius - edgeA + 1); 13172: 54: acc[3] += lineIn[lastx][3] * (radius - edgeA + 1); -: 55: 13172: 56: if (edgeA <= edgeB) branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 57: { -: 58: /* Subtract pixel from left ("0"). -: 59: Add pixels from radius. */ 45276: 60: for (x = 0; x < edgeA; x++) { branch 0 taken 78% branch 1 taken 22% (fallthrough) 45276: 61: MOVE_ACC(acc, 0, x + radius); 45276: 62: ADD_FAR(bulk, acc, 0, x + radius + 1); 45276: 63: SAVE(x, bulk); -: 64: } -: 65: /* Subtract previous pixel from "-radius". -: 66: Add pixels from radius. */ 1550308: 67: for (x = edgeA; x < edgeB; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1550308: 68: MOVE_ACC(acc, x - radius - 1, x + radius); 1550308: 69: ADD_FAR(bulk, acc, x - radius - 1, x + radius + 1); 1550308: 70: SAVE(x, bulk); -: 71: } -: 72: /* Subtract previous pixel from "-radius". -: 73: Add last pixel. */ 45276: 74: for (x = edgeB; x <= lastx; x++) { branch 0 taken 78% branch 1 taken 22% 45276: 75: MOVE_ACC(acc, x - radius - 1, lastx); 45276: 76: ADD_FAR(bulk, acc, x - radius - 1, lastx); 45276: 77: SAVE(x, bulk); -: 78: } -: 79: } -: 80: else -: 81: { 22: 82: for (x = 0; x < edgeB; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 83: MOVE_ACC(acc, 0, x + radius); 22: 84: ADD_FAR(bulk, acc, 0, x + radius + 1); 22: 85: SAVE(x, bulk); -: 86: } 166: 87: for (x = edgeB; x < edgeA; x++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 166: 88: MOVE_ACC(acc, 0, lastx); 166: 89: ADD_FAR(bulk, acc, 0, lastx); 166: 90: SAVE(x, bulk); -: 91: } 22: 92: for (x = edgeA; x <= lastx; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 93: MOVE_ACC(acc, x - radius - 1, lastx); 22: 94: ADD_FAR(bulk, acc, x - radius - 1, lastx); 22: 95: SAVE(x, bulk); -: 96: } -: 97: } -: 98: -: 99: #undef MOVE_ACC -: 100: #undef ADD_FAR -: 101: #undef SAVE 13172: 102:} -: 103: -: 104: -: 105:void static inline function ImagingLineBoxBlur8 called 4300 returned 100% blocks executed 100% 4300: 106:ImagingLineBoxBlur8(UINT8 *lineOut, UINT8 *lineIn, int lastx, int radius, int edgeA, -: 107: int edgeB, UINT32 ww, UINT32 fw) -: 108:{ -: 109: int x; -: 110: UINT32 acc; -: 111: UINT32 bulk; -: 112: -: 113: #define MOVE_ACC(acc, subtract, add) \ -: 114: acc += lineIn[add] - lineIn[subtract]; -: 115: -: 116: #define ADD_FAR(bulk, acc, left, right) \ -: 117: bulk = (acc * ww) + (lineIn[left] + lineIn[right]) * fw; -: 118: -: 119: #define SAVE(x, bulk) \ -: 120: lineOut[x] = (UINT8)((bulk + (1 << 23)) >> 24) -: 121: 4300: 122: acc = lineIn[0] * (radius + 1); 18128: 123: for (x = 0; x < edgeA - 1; x++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 13828: 124: acc += lineIn[x]; -: 125: } 4300: 126: acc += lineIn[lastx] * (radius - edgeA + 1); -: 127: 4300: 128: if (edgeA <= edgeB) branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 129: { 17940: 130: for (x = 0; x < edgeA; x++) { branch 0 taken 81% branch 1 taken 19% (fallthrough) 17940: 131: MOVE_ACC(acc, 0, x + radius); 17940: 132: ADD_FAR(bulk, acc, 0, x + radius + 1); 17940: 133: SAVE(x, bulk); -: 134: } 489388: 135: for (x = edgeA; x < edgeB; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 489388: 136: MOVE_ACC(acc, x - radius - 1, x + radius); 489388: 137: ADD_FAR(bulk, acc, x - radius - 1, x + radius + 1); 489388: 138: SAVE(x, bulk); -: 139: } 17940: 140: for (x = edgeB; x <= lastx; x++) { branch 0 taken 81% branch 1 taken 19% 17940: 141: MOVE_ACC(acc, x - radius - 1, lastx); 17940: 142: ADD_FAR(bulk, acc, x - radius - 1, lastx); 17940: 143: SAVE(x, bulk); -: 144: } -: 145: } -: 146: else -: 147: { 22: 148: for (x = 0; x < edgeB; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 149: MOVE_ACC(acc, 0, x + radius); 22: 150: ADD_FAR(bulk, acc, 0, x + radius + 1); 22: 151: SAVE(x, bulk); -: 152: } 166: 153: for (x = edgeB; x < edgeA; x++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 166: 154: MOVE_ACC(acc, 0, lastx); 166: 155: ADD_FAR(bulk, acc, 0, lastx); 166: 156: SAVE(x, bulk); -: 157: } 22: 158: for (x = edgeA; x <= lastx; x++) { branch 0 taken 38% branch 1 taken 62% (fallthrough) 22: 159: MOVE_ACC(acc, x - radius - 1, lastx); 22: 160: ADD_FAR(bulk, acc, x - radius - 1, lastx); 22: 161: SAVE(x, bulk); -: 162: } -: 163: } -: 164: -: 165: #undef MOVE_ACC -: 166: #undef ADD_FAR -: 167: #undef SAVE 4300: 168:} -: 169: -: 170: -: 171: -: 172:Imaging function ImagingHorizontalBoxBlur called 220 returned 100% blocks executed 96% 220: 173:ImagingHorizontalBoxBlur(Imaging imOut, Imaging imIn, float floatRadius) -: 174:{ -: 175: ImagingSectionCookie cookie; -: 176: -: 177: int y; -: 178: 220: 179: int radius = (int) floatRadius; 220: 180: UINT32 ww = (UINT32) (1 << 24) / (floatRadius * 2 + 1); 220: 181: UINT32 fw = ((1 << 24) - (radius * 2 + 1) * ww) / 2; -: 182: 220: 183: int edgeA = MIN(radius + 1, imIn->xsize); 220: 184: int edgeB = MAX(imIn->xsize - radius - 1, 0); -: 185: 220: 186: UINT32 *lineOut = calloc(imIn->xsize, sizeof(UINT32)); 220: 187: if (lineOut == NULL) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 188: return ImagingError_MemoryError(); call 0 never executed -: 189: } -: 190: -: 191: // printf(">>> %d %d %d\n", radius, ww, fw); -: 192: 220: 193: ImagingSectionEnter(&cookie); call 0 returned 100% -: 194: 220: 195: if (imIn->image8) branch 0 taken 70% (fallthrough) branch 1 taken 30% -: 196: { 4300: 197: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 98% branch 1 taken 2% 13738: 198: ImagingLineBoxBlur8( branch 0 taken 19% (fallthrough) branch 1 taken 81% call 2 returned 100% 838: 199: (imIn == imOut ? (UINT8 *) lineOut : imOut->image8[y]), 4300: 200: imIn->image8[y], 4300: 201: imIn->xsize - 1, -: 202: radius, edgeA, edgeB, -: 203: ww, fw -: 204: ); 4300: 205: if (imIn == imOut) { branch 0 taken 81% (fallthrough) branch 1 taken 19% -: 206: // Commit. 3462: 207: memcpy(imOut->image8[y], lineOut, imIn->xsize); -: 208: } -: 209: } -: 210: } -: 211: else -: 212: { 13172: 213: for (y = 0; y < imIn->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 41930: 214: ImagingLineBoxBlur32( branch 0 taken 18% (fallthrough) branch 1 taken 82% call 2 returned 100% 2414: 215: imIn == imOut ? (pixel *) lineOut : (pixel *) imOut->image32[y], 13172: 216: (pixel *) imIn->image32[y], 13172: 217: imIn->xsize - 1, -: 218: radius, edgeA, edgeB, -: 219: ww, fw -: 220: ); 13172: 221: if (imIn == imOut) { branch 0 taken 82% (fallthrough) branch 1 taken 18% -: 222: // Commit. 10758: 223: memcpy(imOut->image32[y], lineOut, imIn->xsize * 4); -: 224: } -: 225: } -: 226: } -: 227: 220: 228: ImagingSectionLeave(&cookie); call 0 returned 100% -: 229: 220: 230: free(lineOut); -: 231: 220: 232: return imOut; -: 233:} -: 234: -: 235: -: 236:Imaging function ImagingBoxBlur called 71 returned 100% blocks executed 96% 71: 237:ImagingBoxBlur(Imaging imOut, Imaging imIn, float radius, int n) -: 238:{ -: 239: int i; -: 240: Imaging imTransposed; -: 241: 71: 242: if (n < 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 243: return ImagingError_ValueError( call 0 never executed -: 244: "number of passes must be greater than zero" -: 245: ); -: 246: } -: 247: 142: 248: if (strcmp(imIn->mode, imOut->mode) || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 71: 249: imIn->type != imOut->type || 71: 250: imIn->bands != imOut->bands || branch 0 taken 100% (fallthrough) branch 1 taken 0% 71: 251: imIn->xsize != imOut->xsize || branch 0 taken 0% (fallthrough) branch 1 taken 100% 71: 252: imIn->ysize != imOut->ysize) { #####: 253: return ImagingError_Mismatch(); call 0 never executed -: 254: } -: 255: 71: 256: if (imIn->type != IMAGING_TYPE_UINT8) { branch 0 taken 8% (fallthrough) branch 1 taken 92% 6: 257: return ImagingError_ModeError(); call 0 returned 100% -: 258: } -: 259: 127: 260: if (!(strcmp(imIn->mode, "RGB") == 0 || branch 0 taken 43% (fallthrough) branch 1 taken 57% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 83% (fallthrough) branch 7 taken 17% branch 8 taken 70% (fallthrough) branch 9 taken 30% branch 10 taken 88% (fallthrough) branch 11 taken 13% 92: 261: strcmp(imIn->mode, "RGBA") == 0 || branch 0 taken 97% (fallthrough) branch 1 taken 3% 75: 262: strcmp(imIn->mode, "RGBa") == 0 || branch 0 taken 100% (fallthrough) branch 1 taken 0% 74: 263: strcmp(imIn->mode, "RGBX") == 0 || branch 0 taken 78% (fallthrough) branch 1 taken 22% 66: 264: strcmp(imIn->mode, "CMYK") == 0 || branch 0 taken 31% (fallthrough) branch 1 taken 69% 38: 265: strcmp(imIn->mode, "L") == 0 || branch 0 taken 76% (fallthrough) branch 1 taken 24% branch 2 taken 89% (fallthrough) branch 3 taken 11% 9: 266: strcmp(imIn->mode, "LA") == 0 || branch 0 taken 22% (fallthrough) branch 1 taken 78% branch 2 taken 50% (fallthrough) branch 3 taken 50% 8: 267: strcmp(imIn->mode, "La") == 0)) { branch 0 taken 13% (fallthrough) branch 1 taken 88% branch 2 taken 100% (fallthrough) branch 3 taken 0% 7: 268: return ImagingError_ModeError(); call 0 returned 100% -: 269: } -: 270: 58: 271: imTransposed = ImagingNewDirty(imIn->mode, imIn->ysize, imIn->xsize); call 0 returned 100% 58: 272: if (!imTransposed) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 273: return NULL; -: 274: } -: 275: -: 276: /* Apply blur in one dimension. -: 277: Use imOut as a destination at first pass, -: 278: then use imOut as a source too. */ 58: 279: ImagingHorizontalBoxBlur(imOut, imIn, radius); 110: 280: for (i = 1; i < n; i ++) { call 0 returned 100% branch 1 taken 47% branch 2 taken 53% (fallthrough) 52: 281: ImagingHorizontalBoxBlur(imOut, imOut, radius); call 0 returned 100% -: 282: } -: 283: /* Transpose result for blur in another direction. */ 58: 284: ImagingTranspose(imTransposed, imOut); -: 285: -: 286: /* Reuse imTransposed as a source and destination there. */ 168: 287: for (i = 0; i < n; i ++) { call 0 returned 100% branch 1 taken 65% branch 2 taken 35% (fallthrough) 110: 288: ImagingHorizontalBoxBlur(imTransposed, imTransposed, radius); call 0 returned 100% -: 289: } -: 290: /* Restore original orientation. */ 58: 291: ImagingTranspose(imOut, imTransposed); call 0 returned 100% -: 292: 58: 293: ImagingDelete(imTransposed); call 0 returned 100% -: 294: 58: 295: return imOut; -: 296:} -: 297: -: 298: function ImagingGaussianBlur called 31 returned 100% blocks executed 100% 31: 299:Imaging ImagingGaussianBlur(Imaging imOut, Imaging imIn, float radius, -: 300: int passes) -: 301:{ -: 302: float sigma2, L, l, a; -: 303: 31: 304: sigma2 = radius * radius / passes; -: 305: // from http://www.mia.uni-saarland.de/Publications/gwosdek-ssvm11.pdf -: 306: // [7] Box length. 31: 307: L = sqrt(12.0 * sigma2 + 1.0); -: 308: // [11] Integer part of box radius. 31: 309: l = floor((L - 1.0) / 2.0); -: 310: // [14], [Fig. 2] Fractional part of box radius. 31: 311: a = (2 * l + 1) * (l * (l + 1) - 3 * sigma2); 31: 312: a /= 6 * (sigma2 - (l + 1) * (l + 1)); -: 313: 31: 314: return ImagingBoxBlur(imOut, imIn, l + a, passes); call 0 returned 100% -: 315:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#aarch64-linux-gnu#bits#string3.h.gcov -: 0:Source:/usr/include/aarch64-linux-gnu/bits/string3.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/BcnDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/BcnDecode.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:{ 94237: 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 21513: 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#TgaRleEncode.c.gcov -: 0:Source:src/libImaging/TgaRleEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/TgaRleEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/TgaRleEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1: -: 2:#include "Imaging.h" -: 3: -: 4:#include -: 5:#include -: 6: -: 7: -: 8:static int comparePixels(const UINT8* buf, int x, int bytesPerPixel) -: 9:{ 329175: 10: buf += x * bytesPerPixel; 329175: 11: return memcmp(buf, buf + bytesPerPixel, bytesPerPixel) == 0; -: 12:} -: 13: -: 14: -: 15:int function ImagingTgaRleEncode called 26 returned 100% blocks executed 100% 26: 16:ImagingTgaRleEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 17:{ -: 18: UINT8* dst; -: 19: int bytesPerPixel; -: 20: 26: 21: if (state->state == 0) { branch 0 taken 77% (fallthrough) branch 1 taken 23% 20: 22: if (state->ystep < 0) { branch 0 taken 60% (fallthrough) branch 1 taken 40% 12: 23: state->ystep = -1; 12: 24: state->y = state->ysize - 1; -: 25: } else { 8: 26: state->ystep = 1; -: 27: } -: 28: 20: 29: state->state = 1; -: 30: } -: 31: 26: 32: dst = buf; 26: 33: bytesPerPixel = (state->bits + 7) / 8; -: 34: -: 35: while (1) { -: 36: int flushCount; -: 37: -: 38: /* -: 39: * state->count is the numbers of bytes in the packet, -: 40: * excluding the 1-byte descriptor. -: 41: */ 35468: 42: if (state->count == 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 43: UINT8* row; -: 44: UINT8 descriptor; -: 45: int startX; -: 46: -: 47: assert(state->x <= state->xsize); -: 48: -: 49: /* Make sure we have space for the descriptor. */ 35456: 50: if (bytes < 1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 51: break; -: 52: } -: 53: 35456: 54: if (state->x == state->xsize) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 1680: 55: state->x = 0; -: 56: 1680: 57: state->y += state->ystep; 1680: 58: if (state->y < 0 || state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 1% (fallthrough) branch 3 taken 99% 20: 59: state->errcode = IMAGING_CODEC_END; 20: 60: break; -: 61: } -: 62: } -: 63: 35436: 64: if (state->x == 0) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 3360: 65: state->shuffle( call 0 returned 100% -: 66: state->buffer, 1680: 67: (UINT8*)im->image[state->y + state->yoff] 1680: 68: + state->xoff * im->pixelsize, -: 69: state->xsize); -: 70: } -: 71: 35436: 72: row = state->buffer; -: 73: -: 74: /* Start with a raw packet for 1 px. */ 35436: 75: descriptor = 0; 35436: 76: startX = state->x; 35436: 77: state->count = bytesPerPixel; -: 78: 35436: 79: if (state->x + 1 < state->xsize) { branch 0 taken 98% (fallthrough) branch 1 taken 2% -: 80: int maxLookup; -: 81: int isRaw; -: 82: 69796: 83: isRaw = !comparePixels(row, state->x, bytesPerPixel); 34898: 84: ++state->x; -: 85: -: 86: /* -: 87: * A packet can contain up to 128 pixels; -: 88: * 2 are already behind (state->x points to -: 89: * the second one). -: 90: */ 34898: 91: maxLookup = state->x + 126; -: 92: /* A packet must not span multiple rows. */ 34898: 93: if (maxLookup > state->xsize - 1) { branch 0 taken 57% (fallthrough) branch 1 taken 43% 19998: 94: maxLookup = state->xsize - 1; -: 95: } -: 96: 34898: 97: if (isRaw) { branch 0 taken 52% (fallthrough) branch 1 taken 48% 222311: 98: while (state->x < maxLookup) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 442218: 99: if (!comparePixels(row, state->x, bytesPerPixel)) { branch 0 taken 93% (fallthrough) branch 1 taken 7% 205726: 100: ++state->x; -: 101: } else { -: 102: /* Two identical pixels will go to RLE packet. */ 15383: 103: --state->x; 15383: 104: break; -: 105: } -: 106: } -: 107: 16585: 108: state->count += (state->x - startX) * bytesPerPixel; -: 109: } else { -: 110: descriptor |= 0x80; -: 111: 73340: 112: while (state->x < maxLookup) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 146336: 113: if (comparePixels(row, state->x, bytesPerPixel)) { branch 0 taken 75% (fallthrough) branch 1 taken 25% 55027: 114: ++state->x; -: 115: } else { -: 116: break; -: 117: } -: 118: } -: 119: } -: 120: } -: 121: -: 122: /* -: 123: * state->x currently points to the last pixel to be -: 124: * included in the packet. The pixel count in the -: 125: * descriptor is 1 less than actual number of pixels in -: 126: * the packet, that is, state->x == startX if we encode -: 127: * only 1 pixel. -: 128: */ 35436: 129: descriptor += state->x - startX; 35436: 130: *dst++ = descriptor; 35436: 131: --bytes; -: 132: -: 133: /* Advance to past-the-last encoded pixel. */ 35436: 134: ++state->x; -: 135: } -: 136: -: 137: assert(bytes >= 0); -: 138: assert(state->count > 0); -: 139: assert(state->x > 0); -: 140: assert(state->count <= state->x * bytesPerPixel); -: 141: 35448: 142: if (bytes == 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 143: break; -: 144: } -: 145: 35442: 146: flushCount = state->count; 35442: 147: if (flushCount > bytes) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 6: 148: flushCount = bytes; -: 149: } -: 150: 106326: 151: memcpy( -: 152: dst, 70884: 153: state->buffer + (state->x * bytesPerPixel - state->count), -: 154: flushCount); 35442: 155: dst += flushCount; 35442: 156: bytes -= flushCount; -: 157: 35442: 158: state->count -= flushCount; 35442: 159: } -: 160: 26: 161: return dst - buf; -: 162:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#decode.c.gcov -: 0:Source:src/decode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/decode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/decode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * -: 4: * standard decoder interfaces for the Imaging library -: 5: * -: 6: * history: -: 7: * 1996-03-28 fl Moved from _imagingmodule.c -: 8: * 1996-04-15 fl Support subregions in setimage -: 9: * 1996-04-19 fl Allocate decoder buffer (where appropriate) -: 10: * 1996-05-02 fl Added jpeg decoder -: 11: * 1996-05-12 fl Compile cleanly as C++ -: 12: * 1996-05-16 fl Added hex decoder -: 13: * 1996-05-26 fl Added jpeg configuration parameters -: 14: * 1996-12-14 fl Added zip decoder -: 15: * 1996-12-30 fl Plugged potential memory leak for tiled images -: 16: * 1997-01-03 fl Added fli and msp decoders -: 17: * 1997-01-04 fl Added sun_rle and tga_rle decoders -: 18: * 1997-05-31 fl Added bitfield decoder -: 19: * 1998-09-11 fl Added orientation and pixelsize fields to tga_rle decoder -: 20: * 1998-12-29 fl Added mode/rawmode argument to decoders -: 21: * 1998-12-30 fl Added mode argument to *all* decoders -: 22: * 2002-06-09 fl Added stride argument to pcx decoder -: 23: * -: 24: * Copyright (c) 1997-2002 by Secret Labs AB. -: 25: * Copyright (c) 1995-2002 by Fredrik Lundh. -: 26: * -: 27: * See the README file for information on usage and redistribution. -: 28: */ -: 29: -: 30:/* FIXME: make these pluggable! */ -: 31: -: 32:#define PY_SSIZE_T_CLEAN -: 33:#include "Python.h" -: 34: -: 35:#include "libImaging/Imaging.h" -: 36: -: 37:#include "libImaging/Gif.h" -: 38:#include "libImaging/Raw.h" -: 39:#include "libImaging/Bit.h" -: 40:#include "libImaging/Sgi.h" -: 41: -: 42: -: 43:/* -------------------------------------------------------------------- */ -: 44:/* Common */ -: 45:/* -------------------------------------------------------------------- */ -: 46: -: 47:typedef struct { -: 48: PyObject_HEAD -: 49: int (*decode)(Imaging im, ImagingCodecState state, -: 50: UINT8* buffer, Py_ssize_t bytes); -: 51: int (*cleanup)(ImagingCodecState state); -: 52: struct ImagingCodecStateInstance state; -: 53: Imaging im; -: 54: PyObject* lock; -: 55: int pulls_fd; -: 56:} ImagingDecoderObject; -: 57: -: 58:static PyTypeObject ImagingDecoderType; -: 59: -: 60:static ImagingDecoderObject* function PyImaging_DecoderNew called 17261 returned 100% blocks executed 67% 17261: 61:PyImaging_DecoderNew(int contextsize) -: 62:{ -: 63: ImagingDecoderObject *decoder; -: 64: void *context; -: 65: 17261: 66: if(PyType_Ready(&ImagingDecoderType) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 67: return NULL; -: 68: } -: 69: 17261: 70: decoder = PyObject_New(ImagingDecoderObject, &ImagingDecoderType); call 0 returned 100% 17261: 71: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 72: return NULL; -: 73: } -: 74: -: 75: /* Clear the decoder state */ 34522: 76: memset(&decoder->state, 0, sizeof(decoder->state)); -: 77: -: 78: /* Allocate decoder context */ 17261: 79: if (contextsize > 0) { branch 0 taken 96% (fallthrough) branch 1 taken 4% 16533: 80: context = (void*) calloc(1, contextsize); 16533: 81: if (!context) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 82: Py_DECREF(decoder); branch 0 never executed branch 1 never executed call 2 never executed #####: 83: (void) PyErr_NoMemory(); call 0 never executed #####: 84: return NULL; -: 85: } -: 86: } else { -: 87: context = 0; -: 88: } -: 89: -: 90: /* Initialize decoder context */ 17261: 91: decoder->state.context = context; -: 92: -: 93: /* Target image */ 17261: 94: decoder->lock = NULL; 17261: 95: decoder->im = NULL; -: 96: -: 97: /* Initialize the cleanup function pointer */ 17261: 98: decoder->cleanup = NULL; -: 99: -: 100: /* set if the decoder needs to pull data from the fd, instead of -: 101: having it pushed */ 17261: 102: decoder->pulls_fd = 0; -: 103: 17261: 104: return decoder; -: 105:} -: 106: -: 107:static void function _dealloc called 17261 returned 100% blocks executed 100% 17261: 108:_dealloc(ImagingDecoderObject* decoder) -: 109:{ 17261: 110: if (decoder->cleanup) { branch 0 taken 7% (fallthrough) branch 1 taken 93% 1241: 111: decoder->cleanup(&decoder->state); call 0 returned 100% -: 112: } 17261: 113: free(decoder->state.buffer); 17261: 114: free(decoder->state.context); 17261: 115: Py_XDECREF(decoder->lock); branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 3% (fallthrough) branch 3 taken 97% call 4 returned 100% 17261: 116: Py_XDECREF(decoder->state.fd); branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 65% (fallthrough) branch 3 taken 35% call 4 returned 100% 17261: 117: PyObject_Del(decoder); call 0 returned 100% 17261: 118:} -: 119: -: 120:static PyObject* function _decode called 18341 returned 100% blocks executed 100% 18341: 121:_decode(ImagingDecoderObject* decoder, PyObject* args) -: 122:{ -: 123: UINT8* buffer; -: 124: Py_ssize_t bufsize; -: 125: int status; -: 126: ImagingSectionCookie cookie; -: 127: 18341: 128: if (!PyArg_ParseTuple(args, "y#", &buffer, &bufsize)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 129: return NULL; -: 130: } -: 131: 18341: 132: if (!decoder->pulls_fd) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 18301: 133: ImagingSectionEnter(&cookie); call 0 returned 100% -: 134: } -: 135: 18341: 136: status = decoder->decode(decoder->im, &decoder->state, buffer, bufsize); call 0 returned 100% -: 137: 18341: 138: if (!decoder->pulls_fd) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 18301: 139: ImagingSectionLeave(&cookie); call 0 returned 100% -: 140: } -: 141: 18341: 142: return Py_BuildValue("ii", status, decoder->state.errcode); call 0 returned 100% -: 143:} -: 144: -: 145:static PyObject* function _decode_cleanup called 3329 returned 100% blocks executed 100% 3329: 146:_decode_cleanup(ImagingDecoderObject* decoder, PyObject* args) -: 147:{ 3329: 148: int status = 0; -: 149: 3329: 150: if (decoder->cleanup){ branch 0 taken 37% (fallthrough) branch 1 taken 63% 1240: 151: status = decoder->cleanup(&decoder->state); call 0 returned 100% -: 152: } -: 153: 3329: 154: return Py_BuildValue("i", status); call 0 returned 100% -: 155:} -: 156: -: 157: -: 158: -: 159:extern Imaging PyImaging_AsImaging(PyObject *op); -: 160: -: 161:static PyObject* function _setimage called 17261 returned 100% blocks executed 77% 17261: 162:_setimage(ImagingDecoderObject* decoder, PyObject* args) -: 163:{ -: 164: PyObject* op; -: 165: Imaging im; -: 166: ImagingCodecState state; -: 167: int x0, y0, x1, y1; -: 168: 17261: 169: x0 = y0 = x1 = y1 = 0; -: 170: -: 171: /* FIXME: should publish the ImagingType descriptor */ 17261: 172: if (!PyArg_ParseTuple(args, "O|(iiii)", &op, &x0, &y0, &x1, &y1)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 173: return NULL; -: 174: } 17261: 175: im = PyImaging_AsImaging(op); call 0 returned 100% 17261: 176: if (!im) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 177: return NULL; -: 178: } -: 179: 17261: 180: decoder->im = im; -: 181: 17261: 182: state = &decoder->state; -: 183: -: 184: /* Setup decoding tile extent */ 17261: 185: if (x0 == 0 && x1 == 0) { branch 0 taken 98% (fallthrough) branch 1 taken 2% branch 2 taken 82% (fallthrough) branch 3 taken 18% 13905: 186: state->xsize = im->xsize; 13905: 187: state->ysize = im->ysize; -: 188: } else { 3356: 189: state->xoff = x0; 3356: 190: state->yoff = y0; 3356: 191: state->xsize = x1 - x0; 3356: 192: state->ysize = y1 - y0; -: 193: } -: 194: 34522: 195: if (state->xsize <= 0 || branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 34522: 196: state->xsize + state->xoff > (int) im->xsize || branch 0 taken 100% (fallthrough) branch 1 taken 0% 34522: 197: state->ysize <= 0 || branch 0 taken 0% (fallthrough) branch 1 taken 100% 17261: 198: state->ysize + state->yoff > (int) im->ysize) { #####: 199: PyErr_SetString(PyExc_ValueError, "tile cannot extend outside image"); call 0 never executed #####: 200: return NULL; -: 201: } -: 202: -: 203: /* Allocate memory buffer (if bits field is set) */ 17261: 204: if (state->bits > 0) { branch 0 taken 94% (fallthrough) branch 1 taken 6% 16291: 205: if (!state->bytes) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 16266: 206: if (state->xsize > ((INT_MAX / state->bits)-7)){ branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 207: return PyErr_NoMemory(); call 0 never executed -: 208: } 16266: 209: state->bytes = (state->bits * state->xsize+7)/8; -: 210: } -: 211: /* malloc check ok, overflow checked above */ 16291: 212: state->buffer = (UINT8*) malloc(state->bytes); 16291: 213: if (!state->buffer) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 214: return PyErr_NoMemory(); call 0 never executed -: 215: } -: 216: } -: 217: -: 218: /* Keep a reference to the image object, to make sure it doesn't -: 219: go away before we do */ 17261: 220: Py_INCREF(op); 17261: 221: Py_XDECREF(decoder->lock); branch 0 taken 0% (fallthrough) branch 1 taken 100% branch 2 never executed branch 3 never executed call 4 never executed 17261: 222: decoder->lock = op; -: 223: 17261: 224: Py_INCREF(Py_None); 17261: 225: return Py_None; -: 226:} -: 227: -: 228:static PyObject* function _setfd called 40 returned 100% blocks executed 100% 40: 229:_setfd(ImagingDecoderObject* decoder, PyObject* args) -: 230:{ -: 231: PyObject* fd; -: 232: ImagingCodecState state; -: 233: 40: 234: if (!PyArg_ParseTuple(args, "O", &fd)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 235: return NULL; -: 236: } -: 237: 40: 238: state = &decoder->state; -: 239: 40: 240: Py_XINCREF(fd); branch 0 taken 100% (fallthrough) branch 1 taken 0% 40: 241: state->fd = fd; -: 242: 40: 243: Py_INCREF(Py_None); 40: 244: return Py_None; -: 245:} -: 246: -: 247: -: 248:static PyObject * function _get_pulls_fd called 3329 returned 100% blocks executed 100% 3329: 249:_get_pulls_fd(ImagingDecoderObject *decoder) -: 250:{ 3329: 251: return PyBool_FromLong(decoder->pulls_fd); call 0 returned 100% -: 252:} -: 253: -: 254:static struct PyMethodDef methods[] = { -: 255: {"decode", (PyCFunction)_decode, 1}, -: 256: {"cleanup", (PyCFunction)_decode_cleanup, 1}, -: 257: {"setimage", (PyCFunction)_setimage, 1}, -: 258: {"setfd", (PyCFunction)_setfd, 1}, -: 259: {NULL, NULL} /* sentinel */ -: 260:}; -: 261: -: 262:static struct PyGetSetDef getseters[] = { -: 263: {"pulls_fd", (getter)_get_pulls_fd, NULL, -: 264: "True if this decoder expects to pull from self.fd itself.", -: 265: NULL}, -: 266: {NULL, NULL, NULL, NULL, NULL} /* sentinel */ -: 267:}; -: 268: -: 269:static PyTypeObject ImagingDecoderType = { -: 270: PyVarObject_HEAD_INIT(NULL, 0) -: 271: "ImagingDecoder", /*tp_name*/ -: 272: sizeof(ImagingDecoderObject), /*tp_size*/ -: 273: 0, /*tp_itemsize*/ -: 274: /* methods */ -: 275: (destructor)_dealloc, /*tp_dealloc*/ -: 276: 0, /*tp_print*/ -: 277: 0, /*tp_getattr*/ -: 278: 0, /*tp_setattr*/ -: 279: 0, /*tp_compare*/ -: 280: 0, /*tp_repr*/ -: 281: 0, /*tp_as_number */ -: 282: 0, /*tp_as_sequence */ -: 283: 0, /*tp_as_mapping */ -: 284: 0, /*tp_hash*/ -: 285: 0, /*tp_call*/ -: 286: 0, /*tp_str*/ -: 287: 0, /*tp_getattro*/ -: 288: 0, /*tp_setattro*/ -: 289: 0, /*tp_as_buffer*/ -: 290: Py_TPFLAGS_DEFAULT, /*tp_flags*/ -: 291: 0, /*tp_doc*/ -: 292: 0, /*tp_traverse*/ -: 293: 0, /*tp_clear*/ -: 294: 0, /*tp_richcompare*/ -: 295: 0, /*tp_weaklistoffset*/ -: 296: 0, /*tp_iter*/ -: 297: 0, /*tp_iternext*/ -: 298: methods, /*tp_methods*/ -: 299: 0, /*tp_members*/ -: 300: getseters, /*tp_getset*/ -: 301:}; -: 302: -: 303:/* -------------------------------------------------------------------- */ -: 304: -: 305:int function get_unpacker called 16291 returned 100% blocks executed 50% 16291: 306:get_unpacker(ImagingDecoderObject* decoder, const char* mode, -: 307: const char* rawmode) -: 308:{ -: 309: int bits; -: 310: ImagingShuffler unpack; -: 311: 16291: 312: unpack = ImagingFindUnpacker(mode, rawmode, &bits); call 0 returned 100% 16291: 313: if (!unpack) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 314: Py_DECREF(decoder); branch 0 never executed branch 1 never executed call 2 never executed #####: 315: PyErr_SetString(PyExc_ValueError, "unknown raw mode"); call 0 never executed #####: 316: return -1; -: 317: } -: 318: 16291: 319: decoder->state.shuffle = unpack; 16291: 320: decoder->state.bits = bits; -: 321: 16291: 322: return 0; -: 323:} -: 324: -: 325: -: 326:/* -------------------------------------------------------------------- */ -: 327:/* BIT (packed fields) */ -: 328:/* -------------------------------------------------------------------- */ -: 329: -: 330:PyObject* function PyImaging_BitDecoderNew called 0 returned 0% blocks executed 0% #####: 331:PyImaging_BitDecoderNew(PyObject* self, PyObject* args) -: 332:{ -: 333: ImagingDecoderObject* decoder; -: 334: -: 335: char* mode; #####: 336: int bits = 8; #####: 337: int pad = 8; #####: 338: int fill = 0; #####: 339: int sign = 0; #####: 340: int ystep = 1; #####: 341: if (!PyArg_ParseTuple(args, "s|iiiii", &mode, &bits, &pad, &fill, call 0 never executed branch 1 never executed branch 2 never executed -: 342: &sign, &ystep)) { -: 343: return NULL; -: 344: } -: 345: #####: 346: if (strcmp(mode, "F") != 0) { branch 0 never executed branch 1 never executed branch 2 never executed branch 3 never executed #####: 347: PyErr_SetString(PyExc_ValueError, "bad image mode"); call 0 never executed #####: 348: return NULL; -: 349: } -: 350: #####: 351: decoder = PyImaging_DecoderNew(sizeof(BITSTATE)); call 0 never executed #####: 352: if (decoder == NULL) { branch 0 never executed branch 1 never executed -: 353: return NULL; -: 354: } -: 355: #####: 356: decoder->decode = ImagingBitDecode; -: 357: #####: 358: decoder->state.ystep = ystep; -: 359: #####: 360: ((BITSTATE*)decoder->state.context)->bits = bits; #####: 361: ((BITSTATE*)decoder->state.context)->pad = pad; #####: 362: ((BITSTATE*)decoder->state.context)->fill = fill; #####: 363: ((BITSTATE*)decoder->state.context)->sign = sign; -: 364: #####: 365: return (PyObject*) decoder; -: 366:} -: 367: -: 368: -: 369:/* -------------------------------------------------------------------- */ -: 370:/* BCn: GPU block-compressed texture formats */ -: 371:/* -------------------------------------------------------------------- */ -: 372: -: 373:PyObject* function PyImaging_BcnDecoderNew called 7 returned 100% blocks executed 57% 7: 374:PyImaging_BcnDecoderNew(PyObject* self, PyObject* args) -: 375:{ -: 376: ImagingDecoderObject* decoder; -: 377: -: 378: char* mode; -: 379: char* actual; 7: 380: int n = 0; 7: 381: int ystep = 1; 7: 382: if (!PyArg_ParseTuple(args, "s|ii", &mode, &n, &ystep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 383: return NULL; -: 384: } -: 385: 7: 386: switch (n) { branch 0 taken 0% branch 1 taken 0% branch 2 taken 0% branch 3 taken 100% -: 387: case 1: /* BC1: 565 color, 1-bit alpha */ -: 388: case 2: /* BC2: 565 color, 4-bit alpha */ -: 389: case 3: /* BC3: 565 color, 2-endpoint 8-bit interpolated alpha */ -: 390: case 5: /* BC5: 2-channel 8-bit via 2 BC3 alpha blocks */ -: 391: case 7: /* BC7: 4-channel 8-bit via everything */ -: 392: actual = "RGBA"; break; -: 393: case 4: /* BC4: 1-channel 8-bit via 1 BC3 alpha block */ #####: 394: actual = "L"; break; -: 395: case 6: /* BC6: 3-channel 16-bit float */ -: 396: /* TODO: support 4-channel floating point images */ #####: 397: actual = "RGBAF"; break; -: 398: default: #####: 399: PyErr_SetString(PyExc_ValueError, "block compression type unknown"); call 0 never executed #####: 400: return NULL; -: 401: } -: 402: 7: 403: if (strcmp(mode, actual) != 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 404: PyErr_SetString(PyExc_ValueError, "bad image mode"); call 0 never executed #####: 405: return NULL; -: 406: } -: 407: 7: 408: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 7: 409: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 410: return NULL; -: 411: } -: 412: 7: 413: decoder->decode = ImagingBcnDecode; 7: 414: decoder->state.state = n; 7: 415: decoder->state.ystep = ystep; -: 416: 7: 417: return (PyObject*) decoder; -: 418:} -: 419: -: 420: -: 421:/* -------------------------------------------------------------------- */ -: 422:/* FLI */ -: 423:/* -------------------------------------------------------------------- */ -: 424: -: 425:PyObject* function PyImaging_FliDecoderNew called 443 returned 100% blocks executed 100% 443: 426:PyImaging_FliDecoderNew(PyObject* self, PyObject* args) -: 427:{ -: 428: ImagingDecoderObject* decoder; -: 429: 443: 430: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 443: 431: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 432: return NULL; -: 433: } -: 434: 443: 435: decoder->decode = ImagingFliDecode; -: 436: 443: 437: return (PyObject*) decoder; -: 438:} -: 439: -: 440: -: 441:/* -------------------------------------------------------------------- */ -: 442:/* GIF */ -: 443:/* -------------------------------------------------------------------- */ -: 444: -: 445:PyObject* function PyImaging_GifDecoderNew called 486 returned 100% blocks executed 86% 486: 446:PyImaging_GifDecoderNew(PyObject* self, PyObject* args) -: 447:{ -: 448: ImagingDecoderObject* decoder; -: 449: -: 450: char* mode; 486: 451: int bits = 8; 486: 452: int interlace = 0; 486: 453: if (!PyArg_ParseTuple(args, "s|ii", &mode, &bits, &interlace)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 454: return NULL; -: 455: } -: 456: 486: 457: if (strcmp(mode, "L") != 0 && strcmp(mode, "P") != 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 0% (fallthrough) branch 7 taken 100% #####: 458: PyErr_SetString(PyExc_ValueError, "bad image mode"); call 0 never executed #####: 459: return NULL; -: 460: } -: 461: 486: 462: decoder = PyImaging_DecoderNew(sizeof(GIFDECODERSTATE)); call 0 returned 100% 486: 463: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 464: return NULL; -: 465: } -: 466: 486: 467: decoder->decode = ImagingGifDecode; -: 468: 486: 469: ((GIFDECODERSTATE*)decoder->state.context)->bits = bits; 486: 470: ((GIFDECODERSTATE*)decoder->state.context)->interlace = interlace; -: 471: 486: 472: return (PyObject*) decoder; -: 473:} -: 474: -: 475: -: 476:/* -------------------------------------------------------------------- */ -: 477:/* HEX */ -: 478:/* -------------------------------------------------------------------- */ -: 479: -: 480:PyObject* function PyImaging_HexDecoderNew called 194 returned 100% blocks executed 100% 194: 481:PyImaging_HexDecoderNew(PyObject* self, PyObject* args) -: 482:{ -: 483: ImagingDecoderObject* decoder; -: 484: -: 485: char* mode; -: 486: char* rawmode; 194: 487: if (!PyArg_ParseTuple(args, "ss", &mode, &rawmode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 488: return NULL; -: 489: } -: 490: 194: 491: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 194: 492: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 493: return NULL; -: 494: } -: 495: 194: 496: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 497: return NULL; -: 498: } -: 499: 194: 500: decoder->decode = ImagingHexDecode; -: 501: 194: 502: return (PyObject*) decoder; -: 503:} -: 504: -: 505: -: 506:/* -------------------------------------------------------------------- */ -: 507:/* LibTiff */ -: 508:/* -------------------------------------------------------------------- */ -: 509: -: 510:#ifdef HAVE_LIBTIFF -: 511: -: 512:#include "libImaging/TiffDecode.h" -: 513: -: 514:#include -: 515: -: 516:PyObject* -: 517:PyImaging_LibTiffDecoderNew(PyObject* self, PyObject* args) -: 518:{ -: 519: ImagingDecoderObject* decoder; -: 520: char* mode; -: 521: char* rawmode; -: 522: char* compname; -: 523: int fp; -: 524: uint32 ifdoffset; -: 525: -: 526: if (! PyArg_ParseTuple(args, "sssiI", &mode, &rawmode, &compname, &fp, &ifdoffset)) { -: 527: return NULL; -: 528: } -: 529: -: 530: TRACE(("new tiff decoder %s\n", compname)); -: 531: -: 532: decoder = PyImaging_DecoderNew(sizeof(TIFFSTATE)); -: 533: if (decoder == NULL) { -: 534: return NULL; -: 535: } -: 536: -: 537: if (get_unpacker(decoder, mode, rawmode) < 0) { -: 538: return NULL; -: 539: } -: 540: -: 541: if (! ImagingLibTiffInit(&decoder->state, fp, ifdoffset)) { -: 542: Py_DECREF(decoder); -: 543: PyErr_SetString(PyExc_RuntimeError, "tiff codec initialization failed"); -: 544: return NULL; -: 545: } -: 546: -: 547: decoder->decode = ImagingLibTiffDecode; -: 548: -: 549: return (PyObject*) decoder; -: 550:} -: 551: -: 552:#endif -: 553: -: 554: -: 555:/* -------------------------------------------------------------------- */ -: 556:/* PackBits */ -: 557:/* -------------------------------------------------------------------- */ -: 558: -: 559:PyObject* function PyImaging_PackbitsDecoderNew called 21 returned 100% blocks executed 100% 21: 560:PyImaging_PackbitsDecoderNew(PyObject* self, PyObject* args) -: 561:{ -: 562: ImagingDecoderObject* decoder; -: 563: -: 564: char* mode; -: 565: char* rawmode; 21: 566: if (!PyArg_ParseTuple(args, "ss", &mode, &rawmode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 567: return NULL; -: 568: } -: 569: 21: 570: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 21: 571: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 572: return NULL; -: 573: } -: 574: 21: 575: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 576: return NULL; -: 577: } -: 578: 21: 579: decoder->decode = ImagingPackbitsDecode; -: 580: 21: 581: return (PyObject*) decoder; -: 582:} -: 583: -: 584: -: 585:/* -------------------------------------------------------------------- */ -: 586:/* PCD */ -: 587:/* -------------------------------------------------------------------- */ -: 588: -: 589:PyObject* function PyImaging_PcdDecoderNew called 1 returned 100% blocks executed 100% 1: 590:PyImaging_PcdDecoderNew(PyObject* self, PyObject* args) -: 591:{ -: 592: ImagingDecoderObject* decoder; -: 593: 1: 594: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 1: 595: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 596: return NULL; -: 597: } -: 598: -: 599: /* Unpack from PhotoYCC to RGB */ 1: 600: if (get_unpacker(decoder, "RGB", "YCC;P") < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 601: return NULL; -: 602: } -: 603: 1: 604: decoder->decode = ImagingPcdDecode; -: 605: 1: 606: return (PyObject*) decoder; -: 607:} -: 608: -: 609: -: 610:/* -------------------------------------------------------------------- */ -: 611:/* PCX */ -: 612:/* -------------------------------------------------------------------- */ -: 613: -: 614:PyObject* function PyImaging_PcxDecoderNew called 25 returned 100% blocks executed 100% 25: 615:PyImaging_PcxDecoderNew(PyObject* self, PyObject* args) -: 616:{ -: 617: ImagingDecoderObject* decoder; -: 618: -: 619: char* mode; -: 620: char* rawmode; -: 621: int stride; 25: 622: if (!PyArg_ParseTuple(args, "ssi", &mode, &rawmode, &stride)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 623: return NULL; -: 624: } -: 625: 25: 626: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 25: 627: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 628: return NULL; -: 629: } -: 630: 25: 631: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 632: return NULL; -: 633: } -: 634: 25: 635: decoder->state.bytes = stride; -: 636: 25: 637: decoder->decode = ImagingPcxDecode; -: 638: 25: 639: return (PyObject*) decoder; -: 640:} -: 641: -: 642: -: 643:/* -------------------------------------------------------------------- */ -: 644:/* RAW */ -: 645:/* -------------------------------------------------------------------- */ -: 646: -: 647:PyObject* function PyImaging_RawDecoderNew called 14799 returned 100% blocks executed 100% 14799: 648:PyImaging_RawDecoderNew(PyObject* self, PyObject* args) -: 649:{ -: 650: ImagingDecoderObject* decoder; -: 651: -: 652: char* mode; -: 653: char* rawmode; 14799: 654: int stride = 0; 14799: 655: int ystep = 1; 14799: 656: if (!PyArg_ParseTuple(args, "ss|ii", &mode, &rawmode, &stride, &ystep)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 657: return NULL; -: 658: } -: 659: 14799: 660: decoder = PyImaging_DecoderNew(sizeof(RAWSTATE)); call 0 returned 100% 14799: 661: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 662: return NULL; -: 663: } -: 664: 14799: 665: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 666: return NULL; -: 667: } -: 668: 14799: 669: decoder->decode = ImagingRawDecode; -: 670: 14799: 671: decoder->state.ystep = ystep; -: 672: 14799: 673: ((RAWSTATE*)decoder->state.context)->stride = stride; -: 674: 14799: 675: return (PyObject*) decoder; -: 676:} -: 677: -: 678: -: 679:/* -------------------------------------------------------------------- */ -: 680:/* SGI RLE */ -: 681:/* -------------------------------------------------------------------- */ -: 682: -: 683:PyObject* function PyImaging_SgiRleDecoderNew called 7 returned 100% blocks executed 100% 7: 684:PyImaging_SgiRleDecoderNew(PyObject* self, PyObject* args) -: 685:{ -: 686: ImagingDecoderObject* decoder; -: 687: -: 688: char* mode; -: 689: char* rawmode; 7: 690: int ystep = 1; 7: 691: int bpc = 1; 7: 692: if (!PyArg_ParseTuple(args, "ss|ii", &mode, &rawmode, &ystep, &bpc)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 693: return NULL; -: 694: } -: 695: 7: 696: decoder = PyImaging_DecoderNew(sizeof(SGISTATE)); call 0 returned 100% 7: 697: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 698: return NULL; -: 699: } -: 700: 7: 701: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 702: return NULL; -: 703: } -: 704: 7: 705: decoder->pulls_fd = 1; 7: 706: decoder->decode = ImagingSgiRleDecode; 7: 707: decoder->state.ystep = ystep; -: 708: 7: 709: ((SGISTATE*)decoder->state.context)->bpc = bpc; -: 710: 7: 711: return (PyObject*) decoder; -: 712:} -: 713: -: 714: -: 715:/* -------------------------------------------------------------------- */ -: 716:/* SUN RLE */ -: 717:/* -------------------------------------------------------------------- */ -: 718: -: 719:PyObject* function PyImaging_SunRleDecoderNew called 4 returned 100% blocks executed 100% 4: 720:PyImaging_SunRleDecoderNew(PyObject* self, PyObject* args) -: 721:{ -: 722: ImagingDecoderObject* decoder; -: 723: -: 724: char* mode; -: 725: char* rawmode; 4: 726: if (!PyArg_ParseTuple(args, "ss", &mode, &rawmode)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 727: return NULL; -: 728: } -: 729: 4: 730: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 4: 731: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 732: return NULL; -: 733: } -: 734: 4: 735: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 736: return NULL; -: 737: } -: 738: 4: 739: decoder->decode = ImagingSunRleDecode; -: 740: 4: 741: return (PyObject*) decoder; -: 742:} -: 743: -: 744: -: 745:/* -------------------------------------------------------------------- */ -: 746:/* TGA RLE */ -: 747:/* -------------------------------------------------------------------- */ -: 748: -: 749:PyObject* function PyImaging_TgaRleDecoderNew called 30 returned 100% blocks executed 100% 30: 750:PyImaging_TgaRleDecoderNew(PyObject* self, PyObject* args) -: 751:{ -: 752: ImagingDecoderObject* decoder; -: 753: -: 754: char* mode; -: 755: char* rawmode; 30: 756: int ystep = 1; 30: 757: int depth = 8; 30: 758: if (!PyArg_ParseTuple(args, "ss|ii", &mode, &rawmode, &ystep, &depth)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 759: return NULL; -: 760: } -: 761: 30: 762: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 30: 763: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 764: return NULL; -: 765: } -: 766: 30: 767: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 768: return NULL; -: 769: } -: 770: 30: 771: decoder->decode = ImagingTgaRleDecode; -: 772: 30: 773: decoder->state.ystep = ystep; 30: 774: decoder->state.count = depth / 8; -: 775: 30: 776: return (PyObject*) decoder; -: 777:} -: 778: -: 779: -: 780:/* -------------------------------------------------------------------- */ -: 781:/* XBM */ -: 782:/* -------------------------------------------------------------------- */ -: 783: -: 784:PyObject* function PyImaging_XbmDecoderNew called 3 returned 100% blocks executed 100% 3: 785:PyImaging_XbmDecoderNew(PyObject* self, PyObject* args) -: 786:{ -: 787: ImagingDecoderObject* decoder; -: 788: 3: 789: decoder = PyImaging_DecoderNew(0); call 0 returned 100% 3: 790: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 791: return NULL; -: 792: } -: 793: 3: 794: if (get_unpacker(decoder, "1", "1;R") < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 795: return NULL; -: 796: } -: 797: 3: 798: decoder->decode = ImagingXbmDecode; -: 799: 3: 800: return (PyObject*) decoder; -: 801:} -: 802: -: 803: -: 804:/* -------------------------------------------------------------------- */ -: 805:/* ZIP */ -: 806:/* -------------------------------------------------------------------- */ -: 807: -: 808:#ifdef HAVE_LIBZ -: 809: -: 810:#include "libImaging/ZipCodecs.h" -: 811: -: 812:PyObject* function PyImaging_ZipDecoderNew called 1016 returned 100% blocks executed 100% 1016: 813:PyImaging_ZipDecoderNew(PyObject* self, PyObject* args) -: 814:{ -: 815: ImagingDecoderObject* decoder; -: 816: -: 817: char* mode; -: 818: char* rawmode; 1016: 819: int interlaced = 0; 1016: 820: if (!PyArg_ParseTuple(args, "ss|i", &mode, &rawmode, &interlaced)) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 821: return NULL; -: 822: } -: 823: 1016: 824: decoder = PyImaging_DecoderNew(sizeof(ZIPSTATE)); call 0 returned 100% 1016: 825: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 826: return NULL; -: 827: } -: 828: 1016: 829: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 830: return NULL; -: 831: } -: 832: 1016: 833: decoder->decode = ImagingZipDecode; 1016: 834: decoder->cleanup = ImagingZipDecodeCleanup; -: 835: 1016: 836: ((ZIPSTATE*)decoder->state.context)->interlaced = interlaced; -: 837: 1016: 838: return (PyObject*) decoder; -: 839:} -: 840:#endif -: 841: -: 842: -: 843:/* -------------------------------------------------------------------- */ -: 844:/* JPEG */ -: 845:/* -------------------------------------------------------------------- */ -: 846: -: 847:#ifdef HAVE_LIBJPEG -: 848: -: 849:/* We better define this decoder last in this file, so the following -: 850: undef's won't mess things up for the Imaging library proper. */ -: 851: -: 852:#undef HAVE_PROTOTYPES -: 853:#undef HAVE_STDDEF_H -: 854:#undef HAVE_STDLIB_H -: 855:#undef UINT8 -: 856:#undef UINT16 -: 857:#undef UINT32 -: 858:#undef INT8 -: 859:#undef INT16 -: 860:#undef INT32 -: 861: -: 862:#include "libImaging/Jpeg.h" -: 863: -: 864:PyObject* function PyImaging_JpegDecoderNew called 191 returned 100% blocks executed 94% 191: 865:PyImaging_JpegDecoderNew(PyObject* self, PyObject* args) -: 866:{ -: 867: ImagingDecoderObject* decoder; -: 868: -: 869: char* mode; -: 870: char* rawmode; /* what we want from the decoder */ -: 871: char* jpegmode; /* what's in the file */ 191: 872: int scale = 1; 191: 873: int draft = 0; -: 874: 191: 875: if (!PyArg_ParseTuple(args, "ssz|ii", &mode, &rawmode, &jpegmode, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 876: &scale, &draft)) { -: 877: return NULL; -: 878: } -: 879: 191: 880: if (!jpegmode) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 881: jpegmode = ""; -: 882: } -: 883: 191: 884: decoder = PyImaging_DecoderNew(sizeof(JPEGSTATE)); call 0 returned 100% 191: 885: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 886: return NULL; -: 887: } -: 888: -: 889: // libjpeg-turbo supports different output formats. -: 890: // We are choosing Pillow's native format (3 color bytes + 1 padding) -: 891: // to avoid extra conversion in Unpack.c. 191: 892: if (ImagingJpegUseJCSExtensions() && strcmp(rawmode, "RGB") == 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% branch 3 taken 74% (fallthrough) branch 4 taken 26% branch 5 taken 100% (fallthrough) branch 6 taken 0% branch 7 taken 100% (fallthrough) branch 8 taken 0% branch 9 taken 74% (fallthrough) branch 10 taken 26% 142: 893: rawmode = "RGBX"; -: 894: } -: 895: 191: 896: if (get_unpacker(decoder, mode, rawmode) < 0) { call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 897: return NULL; -: 898: } -: 899: 191: 900: decoder->decode = ImagingJpegDecode; 191: 901: decoder->cleanup = ImagingJpegDecodeCleanup; -: 902: 382: 903: strncpy(((JPEGSTATE*)decoder->state.context)->rawmode, rawmode, 8); 382: 904: strncpy(((JPEGSTATE*)decoder->state.context)->jpegmode, jpegmode, 8); -: 905: 191: 906: ((JPEGSTATE*)decoder->state.context)->scale = scale; 191: 907: ((JPEGSTATE*)decoder->state.context)->draft = draft; -: 908: 191: 909: return (PyObject*) decoder; -: 910:} -: 911:#endif -: 912: -: 913:/* -------------------------------------------------------------------- */ -: 914:/* JPEG 2000 */ -: 915:/* -------------------------------------------------------------------- */ -: 916: -: 917:#ifdef HAVE_OPENJPEG -: 918: -: 919:#include "libImaging/Jpeg2K.h" -: 920: -: 921:PyObject* function PyImaging_Jpeg2KDecoderNew called 34 returned 100% blocks executed 95% 34: 922:PyImaging_Jpeg2KDecoderNew(PyObject* self, PyObject* args) -: 923:{ -: 924: ImagingDecoderObject* decoder; -: 925: JPEG2KDECODESTATE *context; -: 926: -: 927: char* mode; -: 928: char* format; -: 929: OPJ_CODEC_FORMAT codec_format; 34: 930: int reduce = 0; 34: 931: int layers = 0; 34: 932: int fd = -1; 34: 933: PY_LONG_LONG length = -1; -: 934: 34: 935: if (!PyArg_ParseTuple(args, "ss|iiiL", &mode, &format, call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% -: 936: &reduce, &layers, &fd, &length)) { -: 937: return NULL; -: 938: } -: 939: 34: 940: if (strcmp(format, "j2k") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 12% (fallthrough) branch 3 taken 88% branch 4 taken 100% (fallthrough) branch 5 taken 0% branch 6 taken 88% (fallthrough) branch 7 taken 12% -: 941: codec_format = OPJ_CODEC_J2K; 30: 942: } 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% -: 943: codec_format = OPJ_CODEC_JPT; 30: 944: } 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% -: 945: codec_format = OPJ_CODEC_JP2; -: 946: } else { -: 947: return NULL; -: 948: } -: 949: 34: 950: decoder = PyImaging_DecoderNew(sizeof(JPEG2KDECODESTATE)); call 0 returned 100% 34: 951: if (decoder == NULL) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 952: return NULL; -: 953: } -: 954: 34: 955: decoder->pulls_fd = 1; 34: 956: decoder->decode = ImagingJpeg2KDecode; 34: 957: decoder->cleanup = ImagingJpeg2KDecodeCleanup; -: 958: 34: 959: context = (JPEG2KDECODESTATE *)decoder->state.context; -: 960: 34: 961: context->fd = fd; 34: 962: context->length = (off_t)length; 34: 963: context->format = codec_format; 34: 964: context->reduce = reduce; 34: 965: context->layers = layers; -: 966: 34: 967: return (PyObject*) decoder; -: 968:} -: 969:#endif /* HAVE_OPENJPEG */ -: 970: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#UnpackYCC.c.gcov -: 0:Source:src/libImaging/UnpackYCC.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/UnpackYCC.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/UnpackYCC.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * code to convert and unpack PhotoYCC data -: 6: * -: 7: * history: -: 8: * 97-01-25 fl Moved from PcdDecode.c -: 9: * -: 10: * Copyright (c) Fredrik Lundh 1996-97. -: 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:/* Tables generated by pcdtables.py, based on transforms taken from -: 21: the "Colour Space Conversions FAQ" by Roberts/Ford. */ -: 22: -: 23:static INT16 L[] = { 0, 1, 3, 4, 5, 7, 8, 10, 11, 12, 14, 15, 16, 18, -: 24:19, 20, 22, 23, 24, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, -: 25:42, 43, 45, 46, 48, 49, 50, 52, 53, 54, 56, 57, 58, 60, 61, 62, 64, -: 26:65, 67, 68, 69, 71, 72, 73, 75, 76, 77, 79, 80, 82, 83, 84, 86, 87, -: 27:88, 90, 91, 92, 94, 95, 96, 98, 99, 101, 102, 103, 105, 106, 107, 109, -: 28:110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 124, 125, 126, 128, -: 29:129, 130, 132, 133, 134, 136, 137, 139, 140, 141, 143, 144, 145, 147, -: 30:148, 149, 151, 152, 153, 155, 156, 158, 159, 160, 162, 163, 164, 166, -: 31:167, 168, 170, 171, 173, 174, 175, 177, 178, 179, 181, 182, 183, 185, -: 32:186, 187, 189, 190, 192, 193, 194, 196, 197, 198, 200, 201, 202, 204, -: 33:205, 206, 208, 209, 211, 212, 213, 215, 216, 217, 219, 220, 221, 223, -: 34:224, 225, 227, 228, 230, 231, 232, 234, 235, 236, 238, 239, 240, 242, -: 35:243, 245, 246, 247, 249, 250, 251, 253, 254, 255, 257, 258, 259, 261, -: 36:262, 264, 265, 266, 268, 269, 270, 272, 273, 274, 276, 277, 278, 280, -: 37:281, 283, 284, 285, 287, 288, 289, 291, 292, 293, 295, 296, 297, 299, -: 38:300, 302, 303, 304, 306, 307, 308, 310, 311, 312, 314, 315, 317, 318, -: 39:319, 321, 322, 323, 325, 326, 327, 329, 330, 331, 333, 334, 336, 337, -: 40:338, 340, 341, 342, 344, 345, 346 }; -: 41: -: 42:static INT16 CB[] = { -345, -343, -341, -338, -336, -334, -332, -329, -: 43:-327, -325, -323, -321, -318, -316, -314, -312, -310, -307, -305, -: 44:-303, -301, -298, -296, -294, -292, -290, -287, -285, -283, -281, -: 45:-278, -276, -274, -272, -270, -267, -265, -263, -261, -258, -256, -: 46:-254, -252, -250, -247, -245, -243, -241, -239, -236, -234, -232, -: 47:-230, -227, -225, -223, -221, -219, -216, -214, -212, -210, -207, -: 48:-205, -203, -201, -199, -196, -194, -192, -190, -188, -185, -183, -: 49:-181, -179, -176, -174, -172, -170, -168, -165, -163, -161, -159, -: 50:-156, -154, -152, -150, -148, -145, -143, -141, -139, -137, -134, -: 51:-132, -130, -128, -125, -123, -121, -119, -117, -114, -112, -110, -: 52:-108, -105, -103, -101, -99, -97, -94, -92, -90, -88, -85, -83, -81, -: 53:-79, -77, -74, -72, -70, -68, -66, -63, -61, -59, -57, -54, -52, -50, -: 54:-48, -46, -43, -41, -39, -37, -34, -32, -30, -28, -26, -23, -21, -19, -: 55:-17, -15, -12, -10, -8, -6, -3, -1, 0, 2, 4, 7, 9, 11, 13, 16, 18, 20, -: 56:22, 24, 27, 29, 31, 33, 35, 38, 40, 42, 44, 47, 49, 51, 53, 55, 58, -: 57:60, 62, 64, 67, 69, 71, 73, 75, 78, 80, 82, 84, 86, 89, 91, 93, 95, -: 58:98, 100, 102, 104, 106, 109, 111, 113, 115, 118, 120, 122, 124, 126, -: 59:129, 131, 133, 135, 138, 140, 142, 144, 146, 149, 151, 153, 155, 157, -: 60:160, 162, 164, 166, 169, 171, 173, 175, 177, 180, 182, 184, 186, 189, -: 61:191, 193, 195, 197, 200, 202, 204, 206, 208, 211, 213, 215, 217, 220 }; -: 62: -: 63:static INT16 GB[] = { 67, 67, 66, 66, 65, 65, 65, 64, 64, 63, 63, 62, -: 64:62, 62, 61, 61, 60, 60, 59, 59, 59, 58, 58, 57, 57, 56, 56, 56, 55, -: 65:55, 54, 54, 53, 53, 52, 52, 52, 51, 51, 50, 50, 49, 49, 49, 48, 48, -: 66:47, 47, 46, 46, 46, 45, 45, 44, 44, 43, 43, 43, 42, 42, 41, 41, 40, -: 67:40, 40, 39, 39, 38, 38, 37, 37, 37, 36, 36, 35, 35, 34, 34, 34, 33, -: 68:33, 32, 32, 31, 31, 31, 30, 30, 29, 29, 28, 28, 28, 27, 27, 26, 26, -: 69:25, 25, 25, 24, 24, 23, 23, 22, 22, 22, 21, 21, 20, 20, 19, 19, 19, -: 70:18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, -: 71:11, 10, 10, 9, 9, 9, 8, 8, 7, 7, 6, 6, 6, 5, 5, 4, 4, 3, 3, 3, 2, 2, -: 72:1, 1, 0, 0, 0, 0, 0, -1, -1, -2, -2, -2, -3, -3, -4, -4, -5, -5, -5, -: 73:-6, -6, -7, -7, -8, -8, -8, -9, -9, -10, -10, -11, -11, -11, -12, -12, -: 74:-13, -13, -14, -14, -14, -15, -15, -16, -16, -17, -17, -18, -18, -18, -: 75:-19, -19, -20, -20, -21, -21, -21, -22, -22, -23, -23, -24, -24, -24, -: 76:-25, -25, -26, -26, -27, -27, -27, -28, -28, -29, -29, -30, -30, -30, -: 77:-31, -31, -32, -32, -33, -33, -33, -34, -34, -35, -35, -36, -36, -36, -: 78:-37, -37, -38, -38, -39, -39, -39, -40, -40, -41, -41, -42 }; -: 79: -: 80:static INT16 CR[] = { -249, -247, -245, -243, -241, -239, -238, -236, -: 81:-234, -232, -230, -229, -227, -225, -223, -221, -219, -218, -216, -: 82:-214, -212, -210, -208, -207, -205, -203, -201, -199, -198, -196, -: 83:-194, -192, -190, -188, -187, -185, -183, -181, -179, -178, -176, -: 84:-174, -172, -170, -168, -167, -165, -163, -161, -159, -157, -156, -: 85:-154, -152, -150, -148, -147, -145, -143, -141, -139, -137, -136, -: 86:-134, -132, -130, -128, -127, -125, -123, -121, -119, -117, -116, -: 87:-114, -112, -110, -108, -106, -105, -103, -101, -99, -97, -96, -94, -: 88:-92, -90, -88, -86, -85, -83, -81, -79, -77, -76, -74, -72, -70, -68, -: 89:-66, -65, -63, -61, -59, -57, -55, -54, -52, -50, -48, -46, -45, -43, -: 90:-41, -39, -37, -35, -34, -32, -30, -28, -26, -25, -23, -21, -19, -17, -: 91:-15, -14, -12, -10, -8, -6, -4, -3, -1, 0, 2, 4, 5, 7, 9, 11, 13, 15, -: 92:16, 18, 20, 22, 24, 26, 27, 29, 31, 33, 35, 36, 38, 40, 42, 44, 46, -: 93:47, 49, 51, 53, 55, 56, 58, 60, 62, 64, 66, 67, 69, 71, 73, 75, 77, -: 94:78, 80, 82, 84, 86, 87, 89, 91, 93, 95, 97, 98, 100, 102, 104, 106, -: 95:107, 109, 111, 113, 115, 117, 118, 120, 122, 124, 126, 128, 129, 131, -: 96:133, 135, 137, 138, 140, 142, 144, 146, 148, 149, 151, 153, 155, 157, -: 97:158, 160, 162, 164, 166, 168, 169, 171, 173, 175, 177, 179, 180, 182, -: 98:184, 186, 188, 189, 191, 193, 195, 197, 199, 200, 202, 204, 206, 208, -: 99:209, 211, 213, 215 }; -: 100: -: 101:static INT16 GR[] = { 127, 126, 125, 124, 123, 122, 121, 121, 120, 119, -: 102:118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 108, 107, 106, -: 103:105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 95, 94, 93, 92, 91, -: 104:90, 89, 88, 87, 86, 85, 84, 83, 83, 82, 81, 80, 79, 78, 77, 76, 75, -: 105:74, 73, 72, 71, 70, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, -: 106:58, 57, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 45, 44, -: 107:43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 32, 31, 30, 29, 28, -: 108:27, 26, 25, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, -: 109:11, 10, 9, 8, 7, 6, 6, 5, 4, 3, 2, 1, 0, 0, -1, -2, -3, -4, -5, -5, -: 110:-6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -18, -19, -: 111:-20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -31, -32, -: 112:-33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -44, -45, -: 113:-46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -56, -57, -58, -: 114:-59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -69, -70, -71, -: 115:-72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -82, -83, -84, -: 116:-85, -86, -87, -88, -89, -90, -91, -92, -93, -94, -94, -95, -96, -97, -: 117:-98, -99, -100, -101, -102, -103, -104, -105, -106, -107, -107, -108 }; -: 118: -: 119:#define R 0 -: 120:#define G 1 -: 121:#define B 2 -: 122:#define A 3 -: 123: -: 124:#define YCC2RGB(rgb, y, cb, cr) {\ -: 125: int l = L[y];\ -: 126: int r = l + CR[cr];\ -: 127: int g = l + GR[cr] + GB[cb];\ -: 128: int b = l + CB[cb];\ -: 129: rgb[0] = (r <= 0) ? 0 : (r >= 255) ? 255 : r;\ -: 130: rgb[1] = (g <= 0) ? 0 : (g >= 255) ? 255 : g;\ -: 131: rgb[2] = (b <= 0) ? 0 : (b >= 255) ? 255 : b;\ -: 132:} -: 133: -: 134:void function ImagingUnpackYCC called 514 returned 100% blocks executed 100% 514: 135:ImagingUnpackYCC(UINT8* out, const UINT8* in, int pixels) -: 136:{ -: 137: int i; -: 138: /* PhotoYCC triplets */ 393738: 139: for (i = 0; i < pixels; i++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 393224: 140: YCC2RGB(out, in[0], in[1], in[2]); branch 0 taken 52% (fallthrough) branch 1 taken 48% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 44% (fallthrough) branch 5 taken 56% 393224: 141: out[A] = 255; 393224: 142: out += 4; in += 3; -: 143: } 514: 144:} -: 145: -: 146:void function ImagingUnpackYCCA called 1 returned 100% blocks executed 100% 1: 147:ImagingUnpackYCCA(UINT8* out, const UINT8* in, int pixels) -: 148:{ -: 149: int i; -: 150: /* PhotoYCC triplets plus premultiplied alpha */ 5: 151: for (i = 0; i < pixels; i++) { branch 0 taken 80% branch 1 taken 20% (fallthrough) -: 152: /* Divide by alpha */ -: 153: UINT8 rgb[3]; 4: 154: rgb[0] = (in[3] == 0) ? 0 : (((int) in[0] * 255) / in[3]); branch 0 taken 100% (fallthrough) branch 1 taken 0% 4: 155: rgb[1] = (in[3] == 0) ? 0 : (((int) in[1] * 255) / in[3]); branch 0 taken 100% (fallthrough) branch 1 taken 0% 4: 156: rgb[2] = (in[3] == 0) ? 0 : (((int) in[2] * 255) / in[3]); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 157: /* Convert non-multiplied data to RGB */ 4: 158: YCC2RGB(out, rgb[0], rgb[1], rgb[2]); branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 25% (fallthrough) branch 5 taken 75% 4: 159: out[A] = in[3]; 4: 160: out += 4; in += 4; -: 161: } 1: 162:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#XbmDecode.c.gcov -: 0:Source:src/libImaging/XbmDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/XbmDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/XbmDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for XBM hex image data -: 6: * -: 7: * history: -: 8: * 96-04-13 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 : 0) -: 22: -: 23:int function ImagingXbmDecode called 3 returned 100% blocks executed 80% 3: 24:ImagingXbmDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 25:{ -: 26: enum { BYTE = 1, SKIP }; -: 27: -: 28: UINT8* ptr; -: 29: 3: 30: if (!state->state) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 3: 31: state->state = SKIP; -: 32: } -: 33: -: 34: ptr = buf; -: 35: -: 36: for (;;) { -: 37: 127176: 38: if (state->state == SKIP) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 39: -: 40: /* Skip forward until next 'x' */ -: 41: 390136: 42: while (bytes > 0) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 390136: 43: if (*ptr == 'x') { branch 0 taken 67% (fallthrough) branch 1 taken 33% -: 44: break; -: 45: } 262960: 46: ptr++; 262960: 47: bytes--; -: 48: } -: 49: 127176: 50: if (bytes == 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 51: return ptr - buf; -: 52: } -: 53: 127176: 54: state->state = BYTE; -: 55: -: 56: } -: 57: 127176: 58: if (bytes < 3) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 59: return ptr - buf; -: 60: } -: 61: 127176: 62: state->buffer[state->x] = (HEX(ptr[1])<<4) + HEX(ptr[2]); branch 0 taken 74% (fallthrough) branch 1 taken 26% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 never executed branch 5 never executed branch 6 taken 74% (fallthrough) branch 7 taken 26% branch 8 taken 100% (fallthrough) branch 9 taken 0% branch 10 never executed branch 11 never executed -: 63: 127176: 64: if (++state->x >= state->bytes) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 65: -: 66: /* Got a full line, unpack it */ 1160: 67: state->shuffle((UINT8*) im->image[state->y], state->buffer, call 0 returned 100% -: 68: state->xsize); -: 69: 1160: 70: state->x = 0; -: 71: 1160: 72: if (++state->y >= state->ysize) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 73: /* End of file (errcode = 0) */ -: 74: return -1; -: 75: } -: 76: } -: 77: 127173: 78: ptr += 3; 127173: 79: bytes -= 3; -: 80: 127173: 81: state->state = SKIP; -: 82: 127173: 83: } -: 84: -: 85:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#ZipDecode.c.gcov -: 0:Source:src/libImaging/ZipDecode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/ZipDecode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/ZipDecode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * decoder for ZIP (deflated) image data. -: 6: * -: 7: * history: -: 8: * 1996-12-14 fl Created (for PNG) -: 9: * 1997-01-15 fl Prepared to read TIFF/ZIP -: 10: * 2001-11-19 fl PNG incomplete read patch (from Bernhard Herzog) -: 11: * -: 12: * Copyright (c) Fredrik Lundh 1996. -: 13: * Copyright (c) Secret Labs AB 1997-2001. -: 14: * -: 15: * See the README file for information on usage and redistribution. -: 16: */ -: 17: -: 18: -: 19:#include "Imaging.h" -: 20: -: 21:#ifdef HAVE_LIBZ -: 22: -: 23:#include "ZipCodecs.h" -: 24: -: 25:static const int OFFSET[] = { 7, 3, 3, 1, 1, 0, 0 }; -: 26:static const int STARTING_COL[] = { 0, 4, 0, 2, 0, 1, 0 }; -: 27:static const int STARTING_ROW[] = { 0, 0, 4, 0, 2, 0, 1 }; -: 28:static const int COL_INCREMENT[] = { 8, 8, 4, 4, 2, 2, 1 }; -: 29:static const int ROW_INCREMENT[] = { 8, 8, 8, 4, 4, 2, 2 }; -: 30: -: 31:/* Get the length in bytes of a scanline in the pass specified, -: 32: * for interlaced images */ -: 33:static int get_row_len(ImagingCodecState state, int pass) -: 34:{ 124: 35: int row_len = (state->xsize + OFFSET[pass]) / COL_INCREMENT[pass]; 124: 36: return ((row_len * state->bits) + 7) / 8; -: 37:} -: 38: -: 39:/* -------------------------------------------------------------------- */ -: 40:/* Decoder */ -: 41:/* -------------------------------------------------------------------- */ -: 42: -: 43:int function ImagingZipDecode called 1501 returned 100% blocks executed 80% 1501: 44:ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8* buf, Py_ssize_t bytes) -: 45:{ 1501: 46: ZIPSTATE* context = (ZIPSTATE*) state->context; -: 47: int err; -: 48: int n; -: 49: UINT8* ptr; -: 50: int i, bpp; -: 51: int row_len; -: 52: 1501: 53: if (!state->state) { branch 0 taken 68% (fallthrough) branch 1 taken 32% -: 54: -: 55: /* Initialization */ 1015: 56: if (context->mode == ZIP_PNG || context->mode == ZIP_PNG_PALETTE) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1015: 57: context->prefix = 1; /* PNG */ -: 58: } -: 59: -: 60: /* overflow check for malloc */ 1015: 61: if (state->bytes > INT_MAX - 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 62: state->errcode = IMAGING_CODEC_MEMORY; #####: 63: return -1; -: 64: } -: 65: /* Expand standard buffer to make room for the (optional) filter -: 66: prefix, and allocate a buffer to hold the previous line */ 1015: 67: free(state->buffer); -: 68: /* malloc check ok, overflow checked above */ 1015: 69: state->buffer = (UINT8*) malloc(state->bytes+1); 1015: 70: context->previous = (UINT8*) malloc(state->bytes+1); 1015: 71: if (!state->buffer || !context->previous) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 0% (fallthrough) branch 3 taken 100% #####: 72: state->errcode = IMAGING_CODEC_MEMORY; #####: 73: return -1; -: 74: } -: 75: 1015: 76: context->last_output = 0; -: 77: -: 78: /* Initialize to black */ 2030: 79: memset(context->previous, 0, state->bytes+1); -: 80: -: 81: /* Setup decompression context */ 1015: 82: context->z_stream.zalloc = (alloc_func) NULL; 1015: 83: context->z_stream.zfree = (free_func) NULL; 1015: 84: context->z_stream.opaque = (voidpf) NULL; -: 85: 1015: 86: err = inflateInit(&context->z_stream); call 0 returned 100% 1015: 87: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 88: state->errcode = IMAGING_CODEC_CONFIG; #####: 89: free(context->previous); #####: 90: context->previous = NULL; #####: 91: return -1; -: 92: } -: 93: 1015: 94: if (context->interlaced) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 15: 95: context->pass = 0; 15: 96: state->y = STARTING_ROW[context->pass]; -: 97: } -: 98: -: 99: /* Ready to decode */ 1015: 100: state->state = 1; -: 101: -: 102: } -: 103: 1501: 104: if (context->interlaced) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 68: 105: row_len = get_row_len(state, context->pass); -: 106: } else { 1467: 107: row_len = state->bytes; -: 108: } -: 109: -: 110: /* Setup the source buffer */ 1501: 111: context->z_stream.next_in = buf; 1501: 112: context->z_stream.avail_in = bytes; -: 113: -: 114: /* Decompress what we've got this far */ 176563: 115: while (context->z_stream.avail_in > 0) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 116: 175050: 117: context->z_stream.next_out = state->buffer + context->last_output; 175050: 118: context->z_stream.avail_out = 175050: 119: row_len + context->prefix - context->last_output; -: 120: 175050: 121: err = inflate(&context->z_stream, Z_NO_FLUSH); call 0 returned 100% -: 122: 175050: 123: if (err < 0) { branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 124: /* Something went wrong inside the compression library */ #####: 125: if (err == Z_DATA_ERROR) { branch 0 never executed branch 1 never executed #####: 126: state->errcode = IMAGING_CODEC_BROKEN; #####: 127: } else if (err == Z_MEM_ERROR) { branch 0 never executed branch 1 never executed #####: 128: state->errcode = IMAGING_CODEC_MEMORY; -: 129: } else { #####: 130: state->errcode = IMAGING_CODEC_CONFIG; -: 131: } #####: 132: free(context->previous); #####: 133: context->previous = NULL; #####: 134: inflateEnd(&context->z_stream); call 0 never executed #####: 135: return -1; -: 136: } -: 137: 175050: 138: n = row_len + context->prefix - context->z_stream.avail_out; -: 139: 175050: 140: if (n < row_len + context->prefix) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 580: 141: context->last_output = n; 580: 142: break; /* need more input data */ -: 143: } -: 144: -: 145: /* Apply predictor */ 174470: 146: switch (context->mode) { branch 0 taken 100% branch 1 taken 0% branch 2 taken 0% -: 147: case ZIP_PNG: 174470: 148: switch (state->buffer[0]) { branch 0 taken 41% branch 1 taken 5% branch 2 taken 2% branch 3 taken 16% branch 4 taken 1% branch 5 taken 36% -: 149: case 0: -: 150: break; -: 151: case 1: -: 152: /* prior */ 8668: 153: bpp = (state->bits + 7) / 8; 11359273: 154: for (i = bpp+1; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% 11350605: 155: state->buffer[i] += state->buffer[i-bpp]; -: 156: } -: 157: break; -: 158: case 2: -: 159: /* up */ 209240594: 160: for (i = 1; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% 209240594: 161: state->buffer[i] += context->previous[i]; -: 162: } -: 163: break; -: 164: case 3: -: 165: /* average */ 2624: 166: bpp = (state->bits + 7) / 8; 10757: 167: for (i = 1; i <= bpp; i++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 8133: 168: state->buffer[i] += context->previous[i]/2; -: 169: } 2705611: 170: for (; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% 5411222: 171: state->buffer[i] += 2705611: 172: (state->buffer[i-bpp] + context->previous[i])/2; -: 173: } -: 174: break; -: 175: case 4: -: 176: /* paeth filtering */ 27894: 177: bpp = (state->bits + 7) / 8; 106501: 178: for (i = 1; i <= bpp; i++) { branch 0 taken 74% branch 1 taken 26% (fallthrough) 78607: 179: state->buffer[i] += context->previous[i]; -: 180: } 61557676: 181: for (; i <= row_len; i++) { branch 0 taken 99% branch 1 taken 1% -: 182: int a, b, c; -: 183: int pa, pb, pc; -: 184: -: 185: /* fetch pixels */ 61557676: 186: a = state->buffer[i-bpp]; 61557676: 187: b = context->previous[i]; 61557676: 188: c = context->previous[i-bpp]; -: 189: -: 190: /* distances to surrounding pixels */ 61557676: 191: pa = abs(b - c); 61557676: 192: pb = abs(a - c); 61557676: 193: pc = abs(a + b - 2*c); -: 194: -: 195: /* pick predictor with the shortest distance */ 123115352: 196: state->buffer[i] += branch 0 taken 28% (fallthrough) branch 1 taken 72% branch 2 taken 80% (fallthrough) branch 3 taken 20% 61557676: 197: (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; -: 198: -: 199: } -: 200: break; -: 201: default: 3: 202: state->errcode = IMAGING_CODEC_UNKNOWN; 3: 203: free(context->previous); 3: 204: context->previous = NULL; 3: 205: inflateEnd(&context->z_stream); call 0 returned 100% 3: 206: return -1; -: 207: } -: 208: break; -: 209: case ZIP_TIFF_PREDICTOR: #####: 210: bpp = (state->bits + 7) / 8; #####: 211: for (i = bpp+1; i <= row_len; i++) { branch 0 never executed branch 1 never executed #####: 212: state->buffer[i] += state->buffer[i-bpp]; -: 213: } -: 214: break; -: 215: } -: 216: -: 217: /* Stuff data into the image */ 174467: 218: if (context->interlaced) { branch 0 taken 2% (fallthrough) branch 1 taken 98% 4230: 219: int col = STARTING_COL[context->pass]; 4230: 220: if (state->bits >= 8) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 221: /* Stuff pixels in their correct location, one by one */ 364500: 222: for (i = 0; i < row_len; i += ((state->bits + 7) / 8)) { branch 0 taken 99% branch 1 taken 1% 1093500: 223: state->shuffle((UINT8*) im->image[state->y] + call 0 returned 100% 364500: 224: col * im->pixelsize, 364500: 225: state->buffer + context->prefix + i, 1); 364500: 226: col += COL_INCREMENT[context->pass]; -: 227: } -: 228: } else { -: 229: /* Handle case with more than a pixel in each byte */ #####: 230: int row_bits = ((state->xsize + OFFSET[context->pass]) #####: 231: / COL_INCREMENT[context->pass]) * state->bits; #####: 232: for (i = 0; i < row_bits; i += state->bits) { branch 0 never executed branch 1 never executed #####: 233: UINT8 byte = *(state->buffer + context->prefix + (i / 8)); #####: 234: byte <<= (i % 8); #####: 235: state->shuffle((UINT8*) im->image[state->y] + call 0 never executed #####: 236: col * im->pixelsize, &byte, 1); #####: 237: col += COL_INCREMENT[context->pass]; -: 238: } -: 239: } -: 240: /* Find next valid scanline */ 4230: 241: state->y += ROW_INCREMENT[context->pass]; 8550: 242: while (state->y >= state->ysize || row_len <= 0) { branch 0 taken 2% branch 1 taken 98% (fallthrough) branch 2 taken 0% branch 3 taken 100% 105: 243: context->pass++; 105: 244: if (context->pass == 7) { branch 0 taken 14% (fallthrough) branch 1 taken 86% -: 245: /* Force exit below */ 15: 246: state->y = state->ysize; 15: 247: break; -: 248: } 90: 249: state->y = STARTING_ROW[context->pass]; 180: 250: row_len = get_row_len(state, context->pass); -: 251: /* Since we're moving to the "first" line, the previous line -: 252: * should be black to make filters work correctly */ 90: 253: memset(state->buffer, 0, state->bytes+1); -: 254: } -: 255: } else { 510711: 256: state->shuffle((UINT8*) im->image[state->y + state->yoff] + call 0 returned 100% 170237: 257: state->xoff * im->pixelsize, 170237: 258: state->buffer + context->prefix, -: 259: state->xsize); 170237: 260: state->y++; -: 261: } -: 262: -: 263: /* all inflate output has been consumed */ 174467: 264: context->last_output = 0; -: 265: 174467: 266: if (state->y >= state->ysize || err == Z_STREAM_END) { branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 0% (fallthrough) branch 3 taken 100% -: 267: -: 268: /* The image and the data should end simultaneously */ -: 269: /* if (state->y < state->ysize || err != Z_STREAM_END) -: 270: state->errcode = IMAGING_CODEC_BROKEN; */ -: 271: 906: 272: free(context->previous); 906: 273: context->previous = NULL; 906: 274: inflateEnd(&context->z_stream); call 0 returned 100% 906: 275: return -1; /* end of file (errcode=0) */ -: 276: -: 277: } -: 278: -: 279: /* Swap buffer pointers */ 173561: 280: ptr = state->buffer; 173561: 281: state->buffer = context->previous; 173561: 282: context->previous = ptr; -: 283: -: 284: } -: 285: 592: 286: return bytes; /* consumed all of it */ -: 287: -: 288:} -: 289: -: 290: function ImagingZipDecodeCleanup called 2032 returned 100% blocks executed 100% 2032: 291:int ImagingZipDecodeCleanup(ImagingCodecState state){ -: 292: /* called to free the decompression engine when the decode terminates -: 293: due to a corrupt or truncated image -: 294: */ 2032: 295: ZIPSTATE* context = (ZIPSTATE*) state->context; -: 296: -: 297: /* Clean up */ 2032: 298: if (context->previous) { branch 0 taken 5% (fallthrough) branch 1 taken 95% 106: 299: inflateEnd(&context->z_stream); call 0 returned 100% 106: 300: free(context->previous); 106: 301: context->previous = NULL; -: 302: } 2032: 303: return -1; -: 304:} -: 305: -: 306:#endif <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#Reduce.c.gcov -: 0:Source:src/libImaging/Reduce.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Reduce.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/Reduce.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:#include "Imaging.h" -: 2: -: 3:#include -: 4: -: 5:#define ROUND_UP(f) ((int) ((f) >= 0.0 ? (f) + 0.5F : (f) - 0.5F)) -: 6: -: 7: -: 8:UINT32 function division_UINT32 called 882 returned 100% blocks executed 100% 882: 9:division_UINT32(int divider, int result_bits) -: 10:{ 882: 11: UINT32 max_dividend = (1 << result_bits) * divider; 882: 12: float max_int = (1 << 30) * 4.0; 882: 13: return (UINT32) (max_int / max_dividend); -: 14:} -: 15: -: 16: -: 17:void function ImagingReduceNxN called 129 returned 100% blocks executed 100% 129: 18:ImagingReduceNxN(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 19:{ -: 20: /* The most general implementation for any xscale and yscale -: 21: */ -: 22: int x, y, xx, yy; 129: 23: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 129: 24: UINT32 amend = yscale * xscale / 2; -: 25: 129: 26: if (imIn->image8) { branch 0 taken 79% (fallthrough) branch 1 taken 21% 1235: 27: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% 1235: 28: int yy_from = box[1] + y*yscale; 120321: 29: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 119086: 30: int xx_from = box[0] + x*xscale; 119086: 31: UINT32 ss = amend; 459494: 32: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 74% branch 1 taken 26% (fallthrough) 340408: 33: UINT8 *line0 = (UINT8 *)imIn->image8[yy]; 340408: 34: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 1101928: 35: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 69% branch 1 taken 31% (fallthrough) 2284560: 36: ss += line0[xx + 0] + line0[xx + 1] + 1523040: 37: line1[xx + 0] + line1[xx + 1]; -: 38: } 340408: 39: if (xscale & 0x01) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 187924: 40: ss += line0[xx + 0] + line1[xx + 0]; -: 41: } -: 42: } 119086: 43: if (yscale & 0x01) { branch 0 taken 54% (fallthrough) branch 1 taken 46% 64750: 44: UINT8 *line = (UINT8 *)imIn->image8[yy]; 190180: 45: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 66% branch 1 taken 34% (fallthrough) 125430: 46: ss += line[xx + 0] + line[xx + 1]; -: 47: } 64750: 48: if (xscale & 0x01) { branch 0 taken 51% (fallthrough) branch 1 taken 49% 32772: 49: ss += line[xx + 0]; -: 50: } -: 51: } 119086: 52: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 53: } -: 54: } -: 55: } else { 4225: 56: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 4225: 57: int yy_from = box[1] + y*yscale; 4225: 58: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 144786: 59: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 144786: 60: int xx_from = box[0] + x*xscale; -: 61: UINT32 v; 144786: 62: UINT32 ss0 = amend, ss3 = amend; 591574: 63: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 446788: 64: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 446788: 65: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1550440: 66: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 3310956: 67: ss0 += line0[xx*4 + 0] + line0[xx*4 + 4] + 2207304: 68: line1[xx*4 + 0] + line1[xx*4 + 4]; 3310956: 69: ss3 += line0[xx*4 + 3] + line0[xx*4 + 7] + 2207304: 70: line1[xx*4 + 3] + line1[xx*4 + 7]; -: 71: } 446788: 72: if (xscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 178000: 73: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 178000: 74: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 75: } -: 76: } 144786: 77: if (yscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 57206: 78: UINT8 *line = (UINT8 *)imIn->image[yy]; 189020: 79: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 131814: 80: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 131814: 81: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 82: } 57206: 83: if (xscale & 0x01) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 26786: 84: ss0 += line[xx*4 + 0]; 26786: 85: ss3 += line[xx*4 + 3]; -: 86: } -: 87: } 144786: 88: v = MAKE_UINT32( -: 89: (ss0 * multiplier) >> 24, 0, -: 90: 0, (ss3 * multiplier) >> 24); 289572: 91: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 92: } 2450: 93: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 50506: 94: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 50506: 95: int xx_from = box[0] + x*xscale; -: 96: UINT32 v; 50506: 97: UINT32 ss0 = amend, ss1 = amend, ss2 = amend; 206354: 98: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 155848: 99: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 155848: 100: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 540760: 101: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 1154736: 102: ss0 += line0[xx*4 + 0] + line0[xx*4 + 4] + 769824: 103: line1[xx*4 + 0] + line1[xx*4 + 4]; 1154736: 104: ss1 += line0[xx*4 + 1] + line0[xx*4 + 5] + 769824: 105: line1[xx*4 + 1] + line1[xx*4 + 5]; 1154736: 106: ss2 += line0[xx*4 + 2] + line0[xx*4 + 6] + 769824: 107: line1[xx*4 + 2] + line1[xx*4 + 6]; -: 108: } 155848: 109: if (xscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 62116: 110: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 62116: 111: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 62116: 112: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; -: 113: } -: 114: } 50506: 115: if (yscale & 0x01) { branch 0 taken 39% (fallthrough) branch 1 taken 61% 19946: 116: UINT8 *line = (UINT8 *)imIn->image[yy]; 65900: 117: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 45954: 118: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 45954: 119: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 45954: 120: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; -: 121: } 19946: 122: if (xscale & 0x01) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 9344: 123: ss0 += line[xx*4 + 0]; 9344: 124: ss1 += line[xx*4 + 1]; 9344: 125: ss2 += line[xx*4 + 2]; -: 126: } -: 127: } 50506: 128: v = MAKE_UINT32( -: 129: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 130: (ss2 * multiplier) >> 24, 0); 101012: 131: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 132: } -: 133: } else { // bands == 4 144786: 134: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 144786: 135: int xx_from = box[0] + x*xscale; -: 136: UINT32 v; 144786: 137: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 591574: 138: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 446788: 139: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 446788: 140: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1550440: 141: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 3310956: 142: ss0 += line0[xx*4 + 0] + line0[xx*4 + 4] + 2207304: 143: line1[xx*4 + 0] + line1[xx*4 + 4]; 3310956: 144: ss1 += line0[xx*4 + 1] + line0[xx*4 + 5] + 2207304: 145: line1[xx*4 + 1] + line1[xx*4 + 5]; 3310956: 146: ss2 += line0[xx*4 + 2] + line0[xx*4 + 6] + 2207304: 147: line1[xx*4 + 2] + line1[xx*4 + 6]; 3310956: 148: ss3 += line0[xx*4 + 3] + line0[xx*4 + 7] + 2207304: 149: line1[xx*4 + 3] + line1[xx*4 + 7]; -: 150: } 446788: 151: if (xscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 178000: 152: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 178000: 153: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 178000: 154: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; 178000: 155: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 156: } -: 157: } 144786: 158: if (yscale & 0x01) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 57206: 159: UINT8 *line = (UINT8 *)imIn->image[yy]; 189020: 160: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 131814: 161: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 131814: 162: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 131814: 163: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; 131814: 164: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 165: } 57206: 166: if (xscale & 0x01) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 26786: 167: ss0 += line[xx*4 + 0]; 26786: 168: ss1 += line[xx*4 + 1]; 26786: 169: ss2 += line[xx*4 + 2]; 26786: 170: ss3 += line[xx*4 + 3]; -: 171: } -: 172: } 144786: 173: v = MAKE_UINT32( -: 174: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 175: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 289572: 176: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 177: } -: 178: } -: 179: } -: 180: } 129: 181:} -: 182: -: 183: -: 184:void function ImagingReduce1xN called 40 returned 100% blocks executed 100% 40: 185:ImagingReduce1xN(Imaging imOut, Imaging imIn, int box[4], int yscale) -: 186:{ -: 187: /* Optimized implementation for xscale = 1. -: 188: */ -: 189: int x, y, yy; 40: 190: int xscale = 1; 40: 191: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 40: 192: UINT32 amend = yscale * xscale / 2; -: 193: 40: 194: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 314: 195: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% 314: 196: int yy_from = box[1] + y*yscale; 117350: 197: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 117036: 198: int xx = box[0] + x*xscale; 117036: 199: UINT32 ss = amend; 393642: 200: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 276606: 201: UINT8 *line0 = (UINT8 *)imIn->image8[yy]; 276606: 202: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 276606: 203: ss += line0[xx + 0] + line1[xx + 0]; -: 204: } 117036: 205: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42534: 206: UINT8 *line = (UINT8 *)imIn->image8[yy]; 42534: 207: ss += line[xx + 0]; -: 208: } 117036: 209: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 210: } -: 211: } -: 212: } else { 1966: 213: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 1966: 214: int yy_from = box[1] + y*yscale; 1966: 215: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 335448: 216: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 335448: 217: int xx = box[0] + x*xscale; -: 218: UINT32 v; 335448: 219: UINT32 ss0 = amend, ss3 = amend; 1128276: 220: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 792828: 221: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 792828: 222: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 792828: 223: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 792828: 224: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 225: } 335448: 226: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 121932: 227: UINT8 *line = (UINT8 *)imIn->image[yy]; 121932: 228: ss0 += line[xx*4 + 0]; 121932: 229: ss3 += line[xx*4 + 3]; -: 230: } 335448: 231: v = MAKE_UINT32( -: 232: (ss0 * multiplier) >> 24, 0, -: 233: 0, (ss3 * multiplier) >> 24); 670896: 234: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 235: } 1140: 236: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 117036: 237: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 117036: 238: int xx = box[0] + x*xscale; -: 239: UINT32 v; 117036: 240: UINT32 ss0 = amend, ss1 = amend, ss2 = amend; 393642: 241: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 276606: 242: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 276606: 243: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 276606: 244: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 276606: 245: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 276606: 246: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; -: 247: } 117036: 248: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42534: 249: UINT8 *line = (UINT8 *)imIn->image[yy]; 42534: 250: ss0 += line[xx*4 + 0]; 42534: 251: ss1 += line[xx*4 + 1]; 42534: 252: ss2 += line[xx*4 + 2]; -: 253: } 117036: 254: v = MAKE_UINT32( -: 255: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 256: (ss2 * multiplier) >> 24, 0); 234072: 257: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 258: } -: 259: } else { // bands == 4 335448: 260: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 335448: 261: int xx = box[0] + x*xscale; -: 262: UINT32 v; 335448: 263: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 1128276: 264: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 792828: 265: UINT8 *line0 = (UINT8 *)imIn->image[yy]; 792828: 266: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 792828: 267: ss0 += line0[xx*4 + 0] + line1[xx*4 + 0]; 792828: 268: ss1 += line0[xx*4 + 1] + line1[xx*4 + 1]; 792828: 269: ss2 += line0[xx*4 + 2] + line1[xx*4 + 2]; 792828: 270: ss3 += line0[xx*4 + 3] + line1[xx*4 + 3]; -: 271: } 335448: 272: if (yscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 121932: 273: UINT8 *line = (UINT8 *)imIn->image[yy]; 121932: 274: ss0 += line[xx*4 + 0]; 121932: 275: ss1 += line[xx*4 + 1]; 121932: 276: ss2 += line[xx*4 + 2]; 121932: 277: ss3 += line[xx*4 + 3]; -: 278: } 335448: 279: v = MAKE_UINT32( -: 280: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 281: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 670896: 282: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 283: } -: 284: } -: 285: } -: 286: } 40: 287:} -: 288: -: 289: -: 290:void function ImagingReduceNx1 called 40 returned 100% blocks executed 100% 40: 291:ImagingReduceNx1(Imaging imOut, Imaging imIn, int box[4], int xscale) -: 292:{ -: 293: /* Optimized implementation for yscale = 1. -: 294: */ -: 295: int x, y, xx; 40: 296: int yscale = 1; 40: 297: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 40: 298: UINT32 amend = yscale * xscale / 2; -: 299: 40: 300: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 1618: 301: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 1618: 302: int yy = box[1] + y*yscale; 1618: 303: UINT8 *line = (UINT8 *)imIn->image8[yy]; 119229: 304: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 117611: 305: int xx_from = box[0] + x*xscale; 117611: 306: UINT32 ss = amend; 395582: 307: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 277971: 308: ss += line[xx + 0] + line[xx + 1]; -: 309: } 117611: 310: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42749: 311: ss += line[xx + 0]; -: 312: } 117611: 313: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 314: } -: 315: } -: 316: } else { 10118: 317: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 10118: 318: int yy = box[1] + y*yscale; 10118: 319: UINT8 *line = (UINT8 *)imIn->image[yy]; 10118: 320: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 337129: 321: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 337129: 322: int xx_from = box[0] + x*xscale; -: 323: UINT32 v; 337129: 324: UINT32 ss0 = amend, ss3 = amend; 1133896: 325: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 796767: 326: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 796767: 327: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 328: } 337129: 329: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 122509: 330: ss0 += line[xx*4 + 0]; 122509: 331: ss3 += line[xx*4 + 3]; -: 332: } 337129: 333: v = MAKE_UINT32( -: 334: (ss0 * multiplier) >> 24, 0, -: 335: 0, (ss3 * multiplier) >> 24); 674258: 336: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 337: } 5868: 338: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 117611: 339: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 117611: 340: int xx_from = box[0] + x*xscale; -: 341: UINT32 v; 117611: 342: UINT32 ss0 = amend, ss1 = amend, ss2 = amend; 395582: 343: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 277971: 344: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 277971: 345: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 277971: 346: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; -: 347: } 117611: 348: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 42749: 349: ss0 += line[xx*4 + 0]; 42749: 350: ss1 += line[xx*4 + 1]; 42749: 351: ss2 += line[xx*4 + 2]; -: 352: } 117611: 353: v = MAKE_UINT32( -: 354: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 355: (ss2 * multiplier) >> 24, 0); 235222: 356: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 357: } -: 358: } else { // bands == 4 337129: 359: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 337129: 360: int xx_from = box[0] + x*xscale; -: 361: UINT32 v; 337129: 362: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 1133896: 363: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 796767: 364: ss0 += line[xx*4 + 0] + line[xx*4 + 4]; 796767: 365: ss1 += line[xx*4 + 1] + line[xx*4 + 5]; 796767: 366: ss2 += line[xx*4 + 2] + line[xx*4 + 6]; 796767: 367: ss3 += line[xx*4 + 3] + line[xx*4 + 7]; -: 368: } 337129: 369: if (xscale & 0x01) { branch 0 taken 36% (fallthrough) branch 1 taken 64% 122509: 370: ss0 += line[xx*4 + 0]; 122509: 371: ss1 += line[xx*4 + 1]; 122509: 372: ss2 += line[xx*4 + 2]; 122509: 373: ss3 += line[xx*4 + 3]; -: 374: } 337129: 375: v = MAKE_UINT32( -: 376: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 377: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 674258: 378: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 379: } -: 380: } -: 381: } -: 382: } 40: 383:} -: 384: -: 385:void function ImagingReduce1x2 called 20 returned 100% blocks executed 100% 20: 386:ImagingReduce1x2(Imaging imOut, Imaging imIn, int box[4]) -: 387:{ -: 388: /* Optimized implementation for xscale = 1 and yscale = 2. -: 389: */ 20: 390: int xscale = 1, yscale = 2; -: 391: int x, y; -: 392: UINT32 ss0, ss1, ss2, ss3; 20: 393: UINT32 amend = yscale * xscale / 2; -: 394: 20: 395: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 403: 396: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 403: 397: int yy = box[1] + y*yscale; 403: 398: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 403: 399: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 150189: 400: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 149786: 401: int xx = box[0] + x*xscale; 299572: 402: ss0 = line0[xx + 0] + 149786: 403: line1[xx + 0]; 149786: 404: imOut->image8[y][x] = (ss0 + amend) >> 1; -: 405: } -: 406: } -: 407: } else { 2521: 408: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2521: 409: int yy = box[1] + y*yscale; 2521: 410: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 2521: 411: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 2521: 412: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 429108: 413: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 429108: 414: int xx = box[0] + x*xscale; -: 415: UINT32 v; 858216: 416: ss0 = line0[xx*4 + 0] + 429108: 417: line1[xx*4 + 0]; 858216: 418: ss3 = line0[xx*4 + 3] + 429108: 419: line1[xx*4 + 3]; 429108: 420: v = MAKE_UINT32((ss0 + amend) >> 1, 0, -: 421: 0, (ss3 + amend) >> 1); 858216: 422: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 423: } 1462: 424: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 149786: 425: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 149786: 426: int xx = box[0] + x*xscale; -: 427: UINT32 v; 299572: 428: ss0 = line0[xx*4 + 0] + 149786: 429: line1[xx*4 + 0]; 299572: 430: ss1 = line0[xx*4 + 1] + 149786: 431: line1[xx*4 + 1]; 299572: 432: ss2 = line0[xx*4 + 2] + 149786: 433: line1[xx*4 + 2]; 149786: 434: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 435: (ss2 + amend) >> 1, 0); 299572: 436: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 437: } -: 438: } else { // bands == 4 429108: 439: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 429108: 440: int xx = box[0] + x*xscale; -: 441: UINT32 v; 858216: 442: ss0 = line0[xx*4 + 0] + 429108: 443: line1[xx*4 + 0]; 858216: 444: ss1 = line0[xx*4 + 1] + 429108: 445: line1[xx*4 + 1]; 858216: 446: ss2 = line0[xx*4 + 2] + 429108: 447: line1[xx*4 + 2]; 858216: 448: ss3 = line0[xx*4 + 3] + 429108: 449: line1[xx*4 + 3]; 429108: 450: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 451: (ss2 + amend) >> 1, (ss3 + amend) >> 1); 858216: 452: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 453: } -: 454: } -: 455: } -: 456: } 20: 457:} -: 458: -: 459: -: 460:void function ImagingReduce2x1 called 20 returned 100% blocks executed 100% 20: 461:ImagingReduce2x1(Imaging imOut, Imaging imIn, int box[4]) -: 462:{ -: 463: /* Optimized implementation for xscale = 2 and yscale = 1. -: 464: */ 20: 465: int xscale = 2, yscale = 1; -: 466: int x, y; -: 467: UINT32 ss0, ss1, ss2, ss3; 20: 468: UINT32 amend = yscale * xscale / 2; -: 469: 20: 470: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 809: 471: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 809: 472: int yy = box[1] + y*yscale; 809: 473: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 150835: 474: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 150026: 475: int xx = box[0] + x*xscale; 150026: 476: ss0 = line0[xx + 0] + line0[xx + 1]; 150026: 477: imOut->image8[y][x] = (ss0 + amend) >> 1; -: 478: } -: 479: } -: 480: } else { 5059: 481: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5059: 482: int yy = box[1] + y*yscale; 5059: 483: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 5059: 484: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 429844: 485: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 429844: 486: int xx = box[0] + x*xscale; -: 487: UINT32 v; 429844: 488: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4]; 429844: 489: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7]; 429844: 490: v = MAKE_UINT32((ss0 + amend) >> 1, 0, -: 491: 0, (ss3 + amend) >> 1); 859688: 492: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 493: } 2934: 494: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 150026: 495: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 150026: 496: int xx = box[0] + x*xscale; -: 497: UINT32 v; 150026: 498: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4]; 150026: 499: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5]; 150026: 500: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6]; 150026: 501: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 502: (ss2 + amend) >> 1, 0); 300052: 503: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 504: } -: 505: } else { // bands == 4 429844: 506: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 429844: 507: int xx = box[0] + x*xscale; -: 508: UINT32 v; 429844: 509: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4]; 429844: 510: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5]; 429844: 511: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6]; 429844: 512: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7]; 429844: 513: v = MAKE_UINT32((ss0 + amend) >> 1, (ss1 + amend) >> 1, -: 514: (ss2 + amend) >> 1, (ss3 + amend) >> 1); 859688: 515: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 516: } -: 517: } -: 518: } -: 519: } 20: 520:} -: 521: -: 522: -: 523:void function ImagingReduce2x2 called 27 returned 100% blocks executed 100% 27: 524:ImagingReduce2x2(Imaging imOut, Imaging imIn, int box[4]) -: 525:{ -: 526: /* Optimized implementation for xscale = 2 and yscale = 2. -: 527: */ 27: 528: int xscale = 2, yscale = 2; -: 529: int x, y; -: 530: UINT32 ss0, ss1, ss2, ss3; 27: 531: UINT32 amend = yscale * xscale / 2; -: 532: 27: 533: if (imIn->image8) { branch 0 taken 78% (fallthrough) branch 1 taken 22% 541: 534: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 541: 535: int yy = box[1] + y*yscale; 541: 536: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 541: 537: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 103447: 538: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 102906: 539: int xx = box[0] + x*xscale; 308718: 540: ss0 = line0[xx + 0] + line0[xx + 1] + 205812: 541: line1[xx + 0] + line1[xx + 1]; 102906: 542: imOut->image8[y][x] = (ss0 + amend) >> 2; -: 543: } -: 544: } -: 545: } else { 3173: 546: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3173: 547: int yy = box[1] + y*yscale; 3173: 548: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 3173: 549: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 3173: 550: if (imIn->bands == 2) { branch 0 taken 33% (fallthrough) branch 1 taken 67% 214404: 551: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 214404: 552: int xx = box[0] + x*xscale; -: 553: UINT32 v; 643212: 554: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + 428808: 555: line1[xx*4 + 0] + line1[xx*4 + 4]; 643212: 556: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + 428808: 557: line1[xx*4 + 3] + line1[xx*4 + 7]; 214404: 558: v = MAKE_UINT32((ss0 + amend) >> 2, 0, -: 559: 0, (ss3 + amend) >> 2); 428808: 560: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 561: } 2114: 562: } else if (imIn->bands == 3) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 237378: 563: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 237378: 564: int xx = box[0] + x*xscale; -: 565: UINT32 v; 712134: 566: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + 474756: 567: line1[xx*4 + 0] + line1[xx*4 + 4]; 712134: 568: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + 474756: 569: line1[xx*4 + 1] + line1[xx*4 + 5]; 712134: 570: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + 474756: 571: line1[xx*4 + 2] + line1[xx*4 + 6]; 237378: 572: v = MAKE_UINT32((ss0 + amend) >> 2, (ss1 + amend) >> 2, -: 573: (ss2 + amend) >> 2, 0); 474756: 574: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 575: } -: 576: } else { // bands == 4 214404: 577: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 214404: 578: int xx = box[0] + x*xscale; -: 579: UINT32 v; 643212: 580: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + 428808: 581: line1[xx*4 + 0] + line1[xx*4 + 4]; 643212: 582: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + 428808: 583: line1[xx*4 + 1] + line1[xx*4 + 5]; 643212: 584: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + 428808: 585: line1[xx*4 + 2] + line1[xx*4 + 6]; 643212: 586: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + 428808: 587: line1[xx*4 + 3] + line1[xx*4 + 7]; 214404: 588: v = MAKE_UINT32((ss0 + amend) >> 2, (ss1 + amend) >> 2, -: 589: (ss2 + amend) >> 2, (ss3 + amend) >> 2); 428808: 590: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 591: } -: 592: } -: 593: } -: 594: } 27: 595:} -: 596: -: 597: -: 598:void function ImagingReduce1x3 called 21 returned 100% blocks executed 100% 21: 599:ImagingReduce1x3(Imaging imOut, Imaging imIn, int box[4]) -: 600:{ -: 601: /* Optimized implementation for xscale = 1 and yscale = 3. -: 602: */ 21: 603: int xscale = 1, yscale = 3; -: 604: int x, y; -: 605: UINT32 ss0, ss1, ss2, ss3; 21: 606: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 21: 607: UINT32 amend = yscale * xscale / 2; -: 608: 21: 609: if (imIn->image8) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 272: 610: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 272: 611: int yy = box[1] + y*yscale; 272: 612: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 272: 613: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 272: 614: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 100330: 615: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 100058: 616: int xx = box[0] + x*xscale; 300174: 617: ss0 = line0[xx + 0] + 200116: 618: line1[xx + 0] + 100058: 619: line2[xx + 0]; 100058: 620: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 621: } -: 622: } -: 623: } else { 1683: 624: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1683: 625: int yy = box[1] + y*yscale; 1683: 626: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1683: 627: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1683: 628: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1683: 629: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 286584: 630: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 286584: 631: int xx = box[0] + x*xscale; -: 632: UINT32 v; 859752: 633: ss0 = line0[xx*4 + 0] + 573168: 634: line1[xx*4 + 0] + 286584: 635: line2[xx*4 + 0]; 859752: 636: ss3 = line0[xx*4 + 3] + 573168: 637: line1[xx*4 + 3] + 286584: 638: line2[xx*4 + 3]; 286584: 639: v = MAKE_UINT32( -: 640: ((ss0 + amend) * multiplier) >> 24, 0, -: 641: 0, ((ss3 + amend) * multiplier) >> 24); 573168: 642: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 643: } 976: 644: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 100028: 645: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 100028: 646: int xx = box[0] + x*xscale; -: 647: UINT32 v; 300084: 648: ss0 = line0[xx*4 + 0] + 200056: 649: line1[xx*4 + 0] + 100028: 650: line2[xx*4 + 0]; 300084: 651: ss1 = line0[xx*4 + 1] + 200056: 652: line1[xx*4 + 1] + 100028: 653: line2[xx*4 + 1]; 300084: 654: ss2 = line0[xx*4 + 2] + 200056: 655: line1[xx*4 + 2] + 100028: 656: line2[xx*4 + 2]; 100028: 657: v = MAKE_UINT32( -: 658: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 659: ((ss2 + amend) * multiplier) >> 24, 0); 200056: 660: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 661: } -: 662: } else { // bands == 4 286584: 663: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 286584: 664: int xx = box[0] + x*xscale; -: 665: UINT32 v; 859752: 666: ss0 = line0[xx*4 + 0] + 573168: 667: line1[xx*4 + 0] + 286584: 668: line2[xx*4 + 0]; 859752: 669: ss1 = line0[xx*4 + 1] + 573168: 670: line1[xx*4 + 1] + 286584: 671: line2[xx*4 + 1]; 859752: 672: ss2 = line0[xx*4 + 2] + 573168: 673: line1[xx*4 + 2] + 286584: 674: line2[xx*4 + 2]; 859752: 675: ss3 = line0[xx*4 + 3] + 573168: 676: line1[xx*4 + 3] + 286584: 677: line2[xx*4 + 3]; 286584: 678: v = MAKE_UINT32( -: 679: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 680: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 573168: 681: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 682: } -: 683: } -: 684: } -: 685: } 21: 686:} -: 687: -: 688: -: 689:void function ImagingReduce3x1 called 21 returned 100% blocks executed 100% 21: 690:ImagingReduce3x1(Imaging imOut, Imaging imIn, int box[4]) -: 691:{ -: 692: /* Optimized implementation for xscale = 3 and yscale = 1. -: 693: */ 21: 694: int xscale = 3, yscale = 1; -: 695: int x, y; -: 696: UINT32 ss0, ss1, ss2, ss3; 21: 697: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 21: 698: UINT32 amend = yscale * xscale / 2; -: 699: 21: 700: if (imIn->image8) { branch 0 taken 81% (fallthrough) branch 1 taken 19% 819: 701: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 819: 702: int yy = box[1] + y*yscale; 819: 703: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 100629: 704: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 99810: 705: int xx = box[0] + x*xscale; 99810: 706: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2]; 99810: 707: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 708: } -: 709: } -: 710: } else { 5059: 711: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5059: 712: int yy = box[1] + y*yscale; 5059: 713: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 5059: 714: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 285750: 715: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 285750: 716: int xx = box[0] + x*xscale; -: 717: UINT32 v; 285750: 718: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8]; 285750: 719: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11]; 285750: 720: v = MAKE_UINT32( -: 721: ((ss0 + amend) * multiplier) >> 24, 0, -: 722: 0, ((ss3 + amend) * multiplier) >> 24); 571500: 723: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 724: } 2934: 725: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 99780: 726: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 99780: 727: int xx = box[0] + x*xscale; -: 728: UINT32 v; 99780: 729: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8]; 99780: 730: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9]; 99780: 731: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10]; 99780: 732: v = MAKE_UINT32( -: 733: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 734: ((ss2 + amend) * multiplier) >> 24, 0); 199560: 735: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 736: } -: 737: } else { // bands == 4 285750: 738: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 285750: 739: int xx = box[0] + x*xscale; -: 740: UINT32 v; 285750: 741: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8]; 285750: 742: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9]; 285750: 743: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10]; 285750: 744: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11]; 285750: 745: v = MAKE_UINT32( -: 746: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 747: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 571500: 748: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 749: } -: 750: } -: 751: } -: 752: } 21: 753:} -: 754: -: 755: -: 756:void function ImagingReduce3x3 called 26 returned 100% blocks executed 100% 26: 757:ImagingReduce3x3(Imaging imOut, Imaging imIn, int box[4]) -: 758:{ -: 759: /* Optimized implementation for xscale = 3 and yscale = 3. -: 760: */ 26: 761: int xscale = 3, yscale = 3; -: 762: int x, y; -: 763: UINT32 ss0, ss1, ss2, ss3; 26: 764: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 26: 765: UINT32 amend = yscale * xscale / 2; -: 766: 26: 767: if (imIn->image8) { branch 0 taken 73% (fallthrough) branch 1 taken 27% 500: 768: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 500: 769: int yy = box[1] + y*yscale; 500: 770: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 500: 771: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 500: 772: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 55379: 773: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 54879: 774: int xx = box[0] + x*xscale; 164637: 775: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2] + 164637: 776: line1[xx + 0] + line1[xx + 1] + line1[xx + 2] + 109758: 777: line2[xx + 0] + line2[xx + 1] + line2[xx + 2]; 54879: 778: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 779: } -: 780: } -: 781: } else { 1767: 782: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1767: 783: int yy = box[1] + y*yscale; 1767: 784: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1767: 785: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1767: 786: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1767: 787: if (imIn->bands == 2) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 95190: 788: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 95190: 789: int xx = box[0] + x*xscale; -: 790: UINT32 v; 285570: 791: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + 285570: 792: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + 190380: 793: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8]; 285570: 794: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + 285570: 795: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + 190380: 796: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11]; 95190: 797: v = MAKE_UINT32( -: 798: ((ss0 + amend) * multiplier) >> 24, 0, -: 799: 0, ((ss3 + amend) * multiplier) >> 24); 190380: 800: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 801: } 1060: 802: } else if (imIn->bands == 3) { branch 0 taken 67% (fallthrough) branch 1 taken 33% 36758: 803: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 36758: 804: int xx = box[0] + x*xscale; -: 805: UINT32 v; 110274: 806: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + 110274: 807: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + 73516: 808: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8]; 110274: 809: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + 110274: 810: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + 73516: 811: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9]; 110274: 812: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + 110274: 813: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + 73516: 814: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10]; 36758: 815: v = MAKE_UINT32( -: 816: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 817: ((ss2 + amend) * multiplier) >> 24, 0); 73516: 818: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 819: } -: 820: } else { // bands == 4 95190: 821: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 95190: 822: int xx = box[0] + x*xscale; -: 823: UINT32 v; 285570: 824: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + 285570: 825: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + 190380: 826: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8]; 285570: 827: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + 285570: 828: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + 190380: 829: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9]; 285570: 830: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + 285570: 831: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + 190380: 832: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10]; 285570: 833: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + 285570: 834: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + 190380: 835: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11]; 95190: 836: v = MAKE_UINT32( -: 837: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 838: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 190380: 839: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 840: } -: 841: } -: 842: } -: 843: } 26: 844:} -: 845: -: 846:void function ImagingReduce4x4 called 20 returned 100% blocks executed 100% 20: 847:ImagingReduce4x4(Imaging imOut, Imaging imIn, int box[4]) -: 848:{ -: 849: /* Optimized implementation for xscale = 4 and yscale = 4. -: 850: */ 20: 851: int xscale = 4, yscale = 4; -: 852: int x, y; -: 853: UINT32 ss0, ss1, ss2, ss3; 20: 854: UINT32 amend = yscale * xscale / 2; -: 855: 20: 856: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 200: 857: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 200: 858: int yy = box[1] + y*yscale; 200: 859: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 200: 860: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 200: 861: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 200: 862: UINT8 *line3 = (UINT8 *)imIn->image8[yy + 3]; 18770: 863: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 18570: 864: int xx = box[0] + x*xscale; 55710: 865: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2] + line0[xx + 3] + 55710: 866: line1[xx + 0] + line1[xx + 1] + line1[xx + 2] + line1[xx + 3] + 55710: 867: line2[xx + 0] + line2[xx + 1] + line2[xx + 2] + line2[xx + 3] + 37140: 868: line3[xx + 0] + line3[xx + 1] + line3[xx + 2] + line3[xx + 3]; 18570: 869: imOut->image8[y][x] = (ss0 + amend) >> 4; -: 870: } -: 871: } -: 872: } else { 1252: 873: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1252: 874: int yy = box[1] + y*yscale; 1252: 875: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1252: 876: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1252: 877: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1252: 878: UINT8 *line3 = (UINT8 *)imIn->image[yy + 3]; 1252: 879: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 53268: 880: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 53268: 881: int xx = box[0] + x*xscale; -: 882: UINT32 v; 159804: 883: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + 159804: 884: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + 159804: 885: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + 106536: 886: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12]; 159804: 887: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + 159804: 888: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + 159804: 889: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + 106536: 890: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15]; 53268: 891: v = MAKE_UINT32((ss0 + amend) >> 4, 0, -: 892: 0, (ss3 + amend) >> 4); 106536: 893: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 894: } 726: 895: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 18570: 896: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 18570: 897: int xx = box[0] + x*xscale; -: 898: UINT32 v; 55710: 899: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + 55710: 900: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + 55710: 901: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + 37140: 902: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12]; 55710: 903: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + 55710: 904: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + 55710: 905: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + 37140: 906: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13]; 55710: 907: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + 55710: 908: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + 55710: 909: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + 37140: 910: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14]; 18570: 911: v = MAKE_UINT32((ss0 + amend) >> 4, (ss1 + amend) >> 4, -: 912: (ss2 + amend) >> 4, 0); 37140: 913: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 914: } -: 915: } else { // bands == 4 53268: 916: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 53268: 917: int xx = box[0] + x*xscale; -: 918: UINT32 v; 159804: 919: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + 159804: 920: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + 159804: 921: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + 106536: 922: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12]; 159804: 923: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + 159804: 924: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + 159804: 925: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + 106536: 926: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13]; 159804: 927: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + 159804: 928: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + 159804: 929: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + 106536: 930: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14]; 159804: 931: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + 159804: 932: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + 159804: 933: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + 106536: 934: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15]; 53268: 935: v = MAKE_UINT32((ss0 + amend) >> 4, (ss1 + amend) >> 4, -: 936: (ss2 + amend) >> 4, (ss3 + amend) >> 4); 106536: 937: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 938: } -: 939: } -: 940: } -: 941: } 20: 942:} -: 943: -: 944: -: 945:void function ImagingReduce5x5 called 20 returned 100% blocks executed 100% 20: 946:ImagingReduce5x5(Imaging imOut, Imaging imIn, int box[4]) -: 947:{ -: 948: /* Fast special case for xscale = 5 and yscale = 5. -: 949: */ 20: 950: int xscale = 5, yscale = 5; -: 951: int x, y; -: 952: UINT32 ss0, ss1, ss2, ss3; 20: 953: UINT32 multiplier = division_UINT32(yscale * xscale, 8); call 0 returned 100% 20: 954: UINT32 amend = yscale * xscale / 2; -: 955: 20: 956: if (imIn->image8) { branch 0 taken 85% (fallthrough) branch 1 taken 15% 161: 957: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% 161: 958: int yy = box[1] + y*yscale; 161: 959: UINT8 *line0 = (UINT8 *)imIn->image8[yy + 0]; 161: 960: UINT8 *line1 = (UINT8 *)imIn->image8[yy + 1]; 161: 961: UINT8 *line2 = (UINT8 *)imIn->image8[yy + 2]; 161: 962: UINT8 *line3 = (UINT8 *)imIn->image8[yy + 3]; 161: 963: UINT8 *line4 = (UINT8 *)imIn->image8[yy + 4]; 12083: 964: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 11922: 965: int xx = box[0] + x*xscale; 35766: 966: ss0 = line0[xx + 0] + line0[xx + 1] + line0[xx + 2] + line0[xx + 3] + line0[xx + 4] + 35766: 967: line1[xx + 0] + line1[xx + 1] + line1[xx + 2] + line1[xx + 3] + line1[xx + 4] + 35766: 968: line2[xx + 0] + line2[xx + 1] + line2[xx + 2] + line2[xx + 3] + line2[xx + 4] + 35766: 969: line3[xx + 0] + line3[xx + 1] + line3[xx + 2] + line3[xx + 3] + line3[xx + 4] + 23844: 970: line4[xx + 0] + line4[xx + 1] + line4[xx + 2] + line4[xx + 3] + line4[xx + 4]; 11922: 971: imOut->image8[y][x] = ((ss0 + amend) * multiplier) >> 24; -: 972: } -: 973: } -: 974: } else { 1007: 975: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 98% branch 1 taken 2% (fallthrough) 1007: 976: int yy = box[1] + y*yscale; 1007: 977: UINT8 *line0 = (UINT8 *)imIn->image[yy + 0]; 1007: 978: UINT8 *line1 = (UINT8 *)imIn->image[yy + 1]; 1007: 979: UINT8 *line2 = (UINT8 *)imIn->image[yy + 2]; 1007: 980: UINT8 *line3 = (UINT8 *)imIn->image[yy + 3]; 1007: 981: UINT8 *line4 = (UINT8 *)imIn->image[yy + 4]; 1007: 982: if (imIn->bands == 2) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 34146: 983: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 34146: 984: int xx = box[0] + x*xscale; -: 985: UINT32 v; 102438: 986: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + line0[xx*4 + 16] + 102438: 987: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + line1[xx*4 + 16] + 102438: 988: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + line2[xx*4 + 16] + 102438: 989: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12] + line3[xx*4 + 16] + 68292: 990: line4[xx*4 + 0] + line4[xx*4 + 4] + line4[xx*4 + 8] + line4[xx*4 + 12] + line4[xx*4 + 16]; 102438: 991: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + line0[xx*4 + 19] + 102438: 992: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + line1[xx*4 + 19] + 102438: 993: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + line2[xx*4 + 19] + 102438: 994: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15] + line3[xx*4 + 19] + 68292: 995: line4[xx*4 + 3] + line4[xx*4 + 7] + line4[xx*4 + 11] + line4[xx*4 + 15] + line4[xx*4 + 19]; 34146: 996: v = MAKE_UINT32( -: 997: ((ss0 + amend) * multiplier) >> 24, 0, -: 998: 0, ((ss3 + amend) * multiplier) >> 24); 68292: 999: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1000: } 584: 1001: } else if (imIn->bands == 3) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 11922: 1002: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% 11922: 1003: int xx = box[0] + x*xscale; -: 1004: UINT32 v; 35766: 1005: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + line0[xx*4 + 16] + 35766: 1006: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + line1[xx*4 + 16] + 35766: 1007: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + line2[xx*4 + 16] + 35766: 1008: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12] + line3[xx*4 + 16] + 23844: 1009: line4[xx*4 + 0] + line4[xx*4 + 4] + line4[xx*4 + 8] + line4[xx*4 + 12] + line4[xx*4 + 16]; 35766: 1010: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + line0[xx*4 + 17] + 35766: 1011: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + line1[xx*4 + 17] + 35766: 1012: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + line2[xx*4 + 17] + 35766: 1013: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13] + line3[xx*4 + 17] + 23844: 1014: line4[xx*4 + 1] + line4[xx*4 + 5] + line4[xx*4 + 9] + line4[xx*4 + 13] + line4[xx*4 + 17]; 35766: 1015: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + line0[xx*4 + 18] + 35766: 1016: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + line1[xx*4 + 18] + 35766: 1017: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + line2[xx*4 + 18] + 35766: 1018: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14] + line3[xx*4 + 18] + 23844: 1019: line4[xx*4 + 2] + line4[xx*4 + 6] + line4[xx*4 + 10] + line4[xx*4 + 14] + line4[xx*4 + 18]; 11922: 1020: v = MAKE_UINT32( -: 1021: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 1022: ((ss2 + amend) * multiplier) >> 24, 0); 23844: 1023: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1024: } -: 1025: } else { // bands == 4 34146: 1026: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 34146: 1027: int xx = box[0] + x*xscale; -: 1028: UINT32 v; 102438: 1029: ss0 = line0[xx*4 + 0] + line0[xx*4 + 4] + line0[xx*4 + 8] + line0[xx*4 + 12] + line0[xx*4 + 16] + 102438: 1030: line1[xx*4 + 0] + line1[xx*4 + 4] + line1[xx*4 + 8] + line1[xx*4 + 12] + line1[xx*4 + 16] + 102438: 1031: line2[xx*4 + 0] + line2[xx*4 + 4] + line2[xx*4 + 8] + line2[xx*4 + 12] + line2[xx*4 + 16] + 102438: 1032: line3[xx*4 + 0] + line3[xx*4 + 4] + line3[xx*4 + 8] + line3[xx*4 + 12] + line3[xx*4 + 16] + 68292: 1033: line4[xx*4 + 0] + line4[xx*4 + 4] + line4[xx*4 + 8] + line4[xx*4 + 12] + line4[xx*4 + 16]; 102438: 1034: ss1 = line0[xx*4 + 1] + line0[xx*4 + 5] + line0[xx*4 + 9] + line0[xx*4 + 13] + line0[xx*4 + 17] + 102438: 1035: line1[xx*4 + 1] + line1[xx*4 + 5] + line1[xx*4 + 9] + line1[xx*4 + 13] + line1[xx*4 + 17] + 102438: 1036: line2[xx*4 + 1] + line2[xx*4 + 5] + line2[xx*4 + 9] + line2[xx*4 + 13] + line2[xx*4 + 17] + 102438: 1037: line3[xx*4 + 1] + line3[xx*4 + 5] + line3[xx*4 + 9] + line3[xx*4 + 13] + line3[xx*4 + 17] + 68292: 1038: line4[xx*4 + 1] + line4[xx*4 + 5] + line4[xx*4 + 9] + line4[xx*4 + 13] + line4[xx*4 + 17]; 102438: 1039: ss2 = line0[xx*4 + 2] + line0[xx*4 + 6] + line0[xx*4 + 10] + line0[xx*4 + 14] + line0[xx*4 + 18] + 102438: 1040: line1[xx*4 + 2] + line1[xx*4 + 6] + line1[xx*4 + 10] + line1[xx*4 + 14] + line1[xx*4 + 18] + 102438: 1041: line2[xx*4 + 2] + line2[xx*4 + 6] + line2[xx*4 + 10] + line2[xx*4 + 14] + line2[xx*4 + 18] + 102438: 1042: line3[xx*4 + 2] + line3[xx*4 + 6] + line3[xx*4 + 10] + line3[xx*4 + 14] + line3[xx*4 + 18] + 68292: 1043: line4[xx*4 + 2] + line4[xx*4 + 6] + line4[xx*4 + 10] + line4[xx*4 + 14] + line4[xx*4 + 18]; 102438: 1044: ss3 = line0[xx*4 + 3] + line0[xx*4 + 7] + line0[xx*4 + 11] + line0[xx*4 + 15] + line0[xx*4 + 19] + 102438: 1045: line1[xx*4 + 3] + line1[xx*4 + 7] + line1[xx*4 + 11] + line1[xx*4 + 15] + line1[xx*4 + 19] + 102438: 1046: line2[xx*4 + 3] + line2[xx*4 + 7] + line2[xx*4 + 11] + line2[xx*4 + 15] + line2[xx*4 + 19] + 102438: 1047: line3[xx*4 + 3] + line3[xx*4 + 7] + line3[xx*4 + 11] + line3[xx*4 + 15] + line3[xx*4 + 19] + 68292: 1048: line4[xx*4 + 3] + line4[xx*4 + 7] + line4[xx*4 + 11] + line4[xx*4 + 15] + line4[xx*4 + 19]; 34146: 1049: v = MAKE_UINT32( -: 1050: ((ss0 + amend) * multiplier) >> 24, ((ss1 + amend) * multiplier) >> 24, -: 1051: ((ss2 + amend) * multiplier) >> 24, ((ss3 + amend) * multiplier) >> 24); 68292: 1052: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1053: } -: 1054: } -: 1055: } -: 1056: } 20: 1057:} -: 1058: -: 1059: -: 1060:void function ImagingReduceCorners called 384 returned 100% blocks executed 100% 384: 1061:ImagingReduceCorners(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 1062:{ -: 1063: /* Fill the last row and the last column for any xscale and yscale. -: 1064: */ -: 1065: int x, y, xx, yy; -: 1066: 384: 1067: if (imIn->image8) { branch 0 taken 19% (fallthrough) branch 1 taken 81% 72: 1068: if (box[2] % xscale) { branch 0 taken 51% (fallthrough) branch 1 taken 49% 37: 1069: int scale = (box[2] % xscale) * yscale; 37: 1070: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 37: 1071: UINT32 amend = scale / 2; 3406: 1072: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3369: 1073: int yy_from = box[1] + y*yscale; 3369: 1074: UINT32 ss = amend; 3369: 1075: x = box[2] / xscale; -: 1076: 13328: 1077: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 75% branch 1 taken 25% (fallthrough) 9959: 1078: UINT8 *line = (UINT8 *)imIn->image8[yy]; 47111: 1079: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 79% branch 1 taken 21% (fallthrough) 37152: 1080: ss += line[xx + 0]; -: 1081: } -: 1082: } 3369: 1083: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 1084: } -: 1085: } 72: 1086: if (box[3] % yscale) { branch 0 taken 74% (fallthrough) branch 1 taken 26% 53: 1087: int scale = xscale * (box[3] % yscale); 53: 1088: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 53: 1089: UINT32 amend = scale / 2; 53: 1090: y = box[3] / yscale; 5364: 1091: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5311: 1092: int xx_from = box[0] + x*xscale; 5311: 1093: UINT32 ss = amend; 17168: 1094: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 69% branch 1 taken 31% (fallthrough) 11857: 1095: UINT8 *line = (UINT8 *)imIn->image8[yy]; 53284: 1096: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 78% branch 1 taken 22% (fallthrough) 41427: 1097: ss += line[xx + 0]; -: 1098: } -: 1099: } 5311: 1100: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 1101: } -: 1102: } 72: 1103: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 51% (fallthrough) branch 1 taken 49% branch 2 taken 65% (fallthrough) branch 3 taken 35% 24: 1104: int scale = (box[2] % xscale) * (box[3] % yscale); 24: 1105: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 24: 1106: UINT32 amend = scale / 2; 24: 1107: UINT32 ss = amend; 24: 1108: x = box[2] / xscale; 24: 1109: y = box[3] / yscale; 116: 1110: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 79% branch 1 taken 21% (fallthrough) 92: 1111: UINT8 *line = (UINT8 *)imIn->image8[yy]; 586: 1112: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 494: 1113: ss += line[xx + 0]; -: 1114: } -: 1115: } 24: 1116: imOut->image8[y][x] = (ss * multiplier) >> 24; -: 1117: } -: 1118: } else { 312: 1119: if (box[2] % xscale) { branch 0 taken 47% (fallthrough) branch 1 taken 53% 148: 1120: int scale = (box[2] % xscale) * yscale; 148: 1121: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 148: 1122: UINT32 amend = scale / 2; 17543: 1123: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 17395: 1124: int yy_from = box[1] + y*yscale; -: 1125: UINT32 v; 17395: 1126: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 17395: 1127: x = box[2] / xscale; -: 1128: 59204: 1129: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 71% branch 1 taken 29% (fallthrough) 41809: 1130: UINT8 *line = (UINT8 *)imIn->image[yy]; 181544: 1131: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 77% branch 1 taken 23% (fallthrough) 139735: 1132: ss0 += line[xx*4 + 0]; 139735: 1133: ss1 += line[xx*4 + 1]; 139735: 1134: ss2 += line[xx*4 + 2]; 139735: 1135: ss3 += line[xx*4 + 3]; -: 1136: } -: 1137: } 17395: 1138: v = MAKE_UINT32( -: 1139: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 1140: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 34790: 1141: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1142: } -: 1143: } 312: 1144: if (box[3] % yscale) { branch 0 taken 72% (fallthrough) branch 1 taken 28% 226: 1145: int scale = xscale * (box[3] % yscale); 226: 1146: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 226: 1147: UINT32 amend = scale / 2; 226: 1148: y = box[3] / yscale; 27071: 1149: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 26845: 1150: int xx_from = box[0] + x*xscale; -: 1151: UINT32 v; 26845: 1152: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 90802: 1153: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 63957: 1154: UINT8 *line = (UINT8 *)imIn->image[yy]; 267841: 1155: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 203884: 1156: ss0 += line[xx*4 + 0]; 203884: 1157: ss1 += line[xx*4 + 1]; 203884: 1158: ss2 += line[xx*4 + 2]; 203884: 1159: ss3 += line[xx*4 + 3]; -: 1160: } -: 1161: } 26845: 1162: v = MAKE_UINT32( -: 1163: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 1164: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 53690: 1165: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1166: } -: 1167: } 312: 1168: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 47% (fallthrough) branch 1 taken 53% branch 2 taken 66% (fallthrough) branch 3 taken 34% 97: 1169: int scale = (box[2] % xscale) * (box[3] % yscale); 97: 1170: UINT32 multiplier = division_UINT32(scale, 8); call 0 returned 100% 97: 1171: UINT32 amend = scale / 2; -: 1172: UINT32 v; 97: 1173: UINT32 ss0 = amend, ss1 = amend, ss2 = amend, ss3 = amend; 97: 1174: x = box[2] / xscale; 97: 1175: y = box[3] / yscale; 526: 1176: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 429: 1177: UINT8 *line = (UINT8 *)imIn->image[yy]; 2935: 1178: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 85% branch 1 taken 15% (fallthrough) 2506: 1179: ss0 += line[xx*4 + 0]; 2506: 1180: ss1 += line[xx*4 + 1]; 2506: 1181: ss2 += line[xx*4 + 2]; 2506: 1182: ss3 += line[xx*4 + 3]; -: 1183: } -: 1184: } 97: 1185: v = MAKE_UINT32( -: 1186: (ss0 * multiplier) >> 24, (ss1 * multiplier) >> 24, -: 1187: (ss2 * multiplier) >> 24, (ss3 * multiplier) >> 24); 194: 1188: memcpy(imOut->image[y] + x * sizeof(v), &v, sizeof(v)); -: 1189: } -: 1190: } 384: 1191:} -: 1192: -: 1193: -: 1194:void function ImagingReduceNxN_32bpc called 108 returned 100% blocks executed 98% 108: 1195:ImagingReduceNxN_32bpc(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 1196:{ -: 1197: /* The most general implementation for any xscale and yscale -: 1198: */ -: 1199: int x, y, xx, yy; 108: 1200: double multiplier = 1.0 / (yscale * xscale); -: 1201: 108: 1202: switch(imIn->type) { branch 0 taken 50% branch 1 taken 50% branch 2 taken 0% -: 1203: case IMAGING_TYPE_INT32: 5930: 1204: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% 5930: 1205: int yy_from = box[1] + y*yscale; 929243: 1206: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 923313: 1207: int xx_from = box[0] + x*xscale; 923313: 1208: double ss = 0; 1774613: 1209: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 48% branch 1 taken 52% (fallthrough) 851300: 1210: INT32 *line0 = (INT32 *)imIn->image32[yy]; 851300: 1211: INT32 *line1 = (INT32 *)imIn->image32[yy + 1]; 1466228: 1212: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 42% branch 1 taken 58% (fallthrough) 1844784: 1213: ss += line0[xx + 0] + line0[xx + 1] + 1229856: 1214: line1[xx + 0] + line1[xx + 1]; -: 1215: } 851300: 1216: if (xscale & 0x01) { branch 0 taken 76% (fallthrough) branch 1 taken 24% 645610: 1217: ss += line0[xx + 0] + line1[xx + 0]; -: 1218: } -: 1219: } 923313: 1220: if (yscale & 0x01) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 575077: 1221: INT32 *line = (INT32 *)imIn->image32[yy]; 1205882: 1222: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 52% branch 1 taken 48% (fallthrough) 630805: 1223: ss += line[xx + 0] + line[xx + 1]; -: 1224: } 575077: 1225: if (xscale & 0x01) { branch 0 taken 59% (fallthrough) branch 1 taken 41% 339587: 1226: ss += line[xx + 0]; -: 1227: } -: 1228: } 923313: 1229: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1230: } -: 1231: } -: 1232: break; -: 1233: -: 1234: case IMAGING_TYPE_FLOAT32: 5930: 1235: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 5930: 1236: int yy_from = box[1] + y*yscale; 929243: 1237: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 923313: 1238: int xx_from = box[0] + x*xscale; 923313: 1239: double ss = 0; 1774613: 1240: for (yy = yy_from; yy < yy_from + yscale - 1; yy += 2) { branch 0 taken 48% branch 1 taken 52% (fallthrough) 851300: 1241: FLOAT32 *line0 = (FLOAT32 *)imIn->image32[yy]; 851300: 1242: FLOAT32 *line1 = (FLOAT32 *)imIn->image32[yy + 1]; 1466228: 1243: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 42% branch 1 taken 58% (fallthrough) 1844784: 1244: ss += line0[xx + 0] + line0[xx + 1] + 1229856: 1245: line1[xx + 0] + line1[xx + 1]; -: 1246: } 851300: 1247: if (xscale & 0x01) { branch 0 taken 76% (fallthrough) branch 1 taken 24% 645610: 1248: ss += line0[xx + 0] + line1[xx + 0]; -: 1249: } -: 1250: } 923313: 1251: if (yscale & 0x01) { branch 0 taken 62% (fallthrough) branch 1 taken 38% 575077: 1252: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 1205882: 1253: for (xx = xx_from; xx < xx_from + xscale - 1; xx += 2) { branch 0 taken 52% branch 1 taken 48% (fallthrough) 630805: 1254: ss += line[xx + 0] + line[xx + 1]; -: 1255: } 575077: 1256: if (xscale & 0x01) { branch 0 taken 59% (fallthrough) branch 1 taken 41% 339587: 1257: ss += line[xx + 0]; -: 1258: } -: 1259: } 923313: 1260: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1261: } -: 1262: } -: 1263: break; -: 1264: } 108: 1265:} -: 1266: -: 1267: -: 1268:void function ImagingReduceCorners_32bpc called 108 returned 100% blocks executed 96% 108: 1269:ImagingReduceCorners_32bpc(Imaging imOut, Imaging imIn, int box[4], int xscale, int yscale) -: 1270:{ -: 1271: /* Fill the last row and the last column for any xscale and yscale. -: 1272: */ -: 1273: int x, y, xx, yy; -: 1274: 108: 1275: switch(imIn->type) { branch 0 taken 50% branch 1 taken 50% branch 2 taken 0% -: 1276: case IMAGING_TYPE_INT32: 54: 1277: if (box[2] % xscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% 26: 1278: double multiplier = 1.0 / ((box[2] % xscale) * yscale); 2867: 1279: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2841: 1280: int yy_from = box[1] + y*yscale; 2841: 1281: double ss = 0; 2841: 1282: x = box[2] / xscale; 9540: 1283: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 6699: 1284: INT32 *line = (INT32 *)imIn->image32[yy]; 28368: 1285: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 21669: 1286: ss += line[xx + 0]; -: 1287: } -: 1288: } 2841: 1289: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1290: } -: 1291: } 54: 1292: if (box[3] % yscale) { branch 0 taken 74% (fallthrough) branch 1 taken 26% 40: 1293: double multiplier = 1.0 / (xscale * (box[3] % yscale)); 40: 1294: y = box[3] / yscale; 4355: 1295: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4315: 1296: int xx_from = box[0] + x*xscale; 4315: 1297: double ss = 0; 14502: 1298: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 10187: 1299: INT32 *line = (INT32 *)imIn->image32[yy]; 42371: 1300: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 32184: 1301: ss += line[xx + 0]; -: 1302: } -: 1303: } 4315: 1304: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1305: } -: 1306: } 54: 1307: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% branch 2 taken 65% (fallthrough) branch 3 taken 35% 17: 1308: double multiplier = 1.0 / ((box[2] % xscale) * (box[3] % yscale)); 17: 1309: double ss = 0; 17: 1310: x = box[2] / xscale; 17: 1311: y = box[3] / yscale; 92: 1312: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 75: 1313: INT32 *line = (INT32 *)imIn->image32[yy]; 465: 1314: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 390: 1315: ss += line[xx + 0]; -: 1316: } -: 1317: } 17: 1318: IMAGING_PIXEL_I(imOut, x, y) = ROUND_UP(ss * multiplier); branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1319: } -: 1320: break; -: 1321: -: 1322: case IMAGING_TYPE_FLOAT32: 54: 1323: if (box[2] % xscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% 26: 1324: double multiplier = 1.0 / ((box[2] % xscale) * yscale); 2867: 1325: for (y = 0; y < box[3] / yscale; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2841: 1326: int yy_from = box[1] + y*yscale; 2841: 1327: double ss = 0; 2841: 1328: x = box[2] / xscale; 9540: 1329: for (yy = yy_from; yy < yy_from + yscale; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 6699: 1330: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 28368: 1331: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 21669: 1332: ss += line[xx + 0]; -: 1333: } -: 1334: } 2841: 1335: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1336: } -: 1337: } 54: 1338: if (box[3] % yscale) { branch 0 taken 74% (fallthrough) branch 1 taken 26% 40: 1339: double multiplier = 1.0 / (xscale * (box[3] % yscale)); 40: 1340: y = box[3] / yscale; 4355: 1341: for (x = 0; x < box[2] / xscale; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 4315: 1342: int xx_from = box[0] + x*xscale; 4315: 1343: double ss = 0; 14502: 1344: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 70% branch 1 taken 30% (fallthrough) 10187: 1345: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 42371: 1346: for (xx = xx_from; xx < xx_from + xscale; xx++) { branch 0 taken 76% branch 1 taken 24% (fallthrough) 32184: 1347: ss += line[xx + 0]; -: 1348: } -: 1349: } 4315: 1350: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1351: } -: 1352: } 54: 1353: if (box[2] % xscale && box[3] % yscale) { branch 0 taken 48% (fallthrough) branch 1 taken 52% branch 2 taken 65% (fallthrough) branch 3 taken 35% 17: 1354: double multiplier = 1.0 / ((box[2] % xscale) * (box[3] % yscale)); 17: 1355: double ss = 0; 17: 1356: x = box[2] / xscale; 17: 1357: y = box[3] / yscale; 92: 1358: for (yy = box[1] + y*yscale; yy < box[1] + box[3]; yy++) { branch 0 taken 82% branch 1 taken 18% (fallthrough) 75: 1359: FLOAT32 *line = (FLOAT32 *)imIn->image32[yy]; 465: 1360: for (xx = box[0] + x*xscale; xx < box[0] + box[2]; xx++) { branch 0 taken 84% branch 1 taken 16% (fallthrough) 390: 1361: ss += line[xx + 0]; -: 1362: } -: 1363: } 17: 1364: IMAGING_PIXEL_F(imOut, x, y) = ss * multiplier; -: 1365: } -: 1366: break; -: 1367: } 108: 1368:} -: 1369: -: 1370: -: 1371:Imaging function ImagingReduce called 495 returned 100% blocks executed 100% 495: 1372:ImagingReduce(Imaging imIn, int xscale, int yscale, int box[4]) -: 1373:{ -: 1374: ImagingSectionCookie cookie; 495: 1375: Imaging imOut = NULL; -: 1376: 495: 1377: if (strcmp(imIn->mode, "P") == 0 || strcmp(imIn->mode, "1") == 0) { branch 0 taken 1% (fallthrough) branch 1 taken 99% branch 2 taken 99% (fallthrough) branch 3 taken 1% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 1% (fallthrough) branch 7 taken 99% 2: 1378: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 1379: } -: 1380: 493: 1381: if (imIn->type == IMAGING_TYPE_SPECIAL) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 1382: return (Imaging) ImagingError_ModeError(); call 0 returned 100% -: 1383: } -: 1384: 1476: 1385: imOut = ImagingNewDirty(imIn->mode, call 0 returned 100% 492: 1386: (box[2] + xscale - 1) / xscale, 492: 1387: (box[3] + yscale - 1) / yscale); 492: 1388: if ( ! imOut) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 1389: return NULL; -: 1390: } -: 1391: 492: 1392: ImagingSectionEnter(&cookie); call 0 returned 100% -: 1393: 492: 1394: switch(imIn->type) { branch 0 taken 78% branch 1 taken 22% branch 2 taken 0% -: 1395: case IMAGING_TYPE_UINT8: 384: 1396: if (xscale == 1) { branch 0 taken 21% (fallthrough) branch 1 taken 79% 81: 1397: if (yscale == 2) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 20: 1398: ImagingReduce1x2(imOut, imIn, box); call 0 returned 100% 61: 1399: } else if (yscale == 3) { branch 0 taken 34% (fallthrough) branch 1 taken 66% 21: 1400: ImagingReduce1x3(imOut, imIn, box); call 0 returned 100% -: 1401: } else { 40: 1402: ImagingReduce1xN(imOut, imIn, box, yscale); call 0 returned 100% -: 1403: } 303: 1404: } else if (yscale == 1) { branch 0 taken 27% (fallthrough) branch 1 taken 73% 81: 1405: if (xscale == 2) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 20: 1406: ImagingReduce2x1(imOut, imIn, box); call 0 returned 100% 61: 1407: } else if (xscale == 3) { branch 0 taken 34% (fallthrough) branch 1 taken 66% 21: 1408: ImagingReduce3x1(imOut, imIn, box); call 0 returned 100% -: 1409: } else { 40: 1410: ImagingReduceNx1(imOut, imIn, box, xscale); call 0 returned 100% -: 1411: } 222: 1412: } else if (xscale == yscale && xscale <= 5) { branch 0 taken 42% (fallthrough) branch 1 taken 58% 93: 1413: if (xscale == 2) { branch 0 taken 29% (fallthrough) branch 1 taken 71% 27: 1414: ImagingReduce2x2(imOut, imIn, box); call 0 returned 100% 66: 1415: } else if (xscale == 3) { branch 0 taken 39% (fallthrough) branch 1 taken 61% 26: 1416: ImagingReduce3x3(imOut, imIn, box); call 0 returned 100% 40: 1417: } else if (xscale == 4) { branch 0 taken 50% (fallthrough) branch 1 taken 50% 20: 1418: ImagingReduce4x4(imOut, imIn, box); call 0 returned 100% -: 1419: } else { 20: 1420: ImagingReduce5x5(imOut, imIn, box); call 0 returned 100% -: 1421: } -: 1422: } else { 129: 1423: ImagingReduceNxN(imOut, imIn, box, xscale, yscale); call 0 returned 100% -: 1424: } -: 1425: 384: 1426: ImagingReduceCorners(imOut, imIn, box, xscale, yscale); call 0 returned 100% 384: 1427: break; -: 1428: -: 1429: case IMAGING_TYPE_INT32: -: 1430: case IMAGING_TYPE_FLOAT32: 108: 1431: ImagingReduceNxN_32bpc(imOut, imIn, box, xscale, yscale); call 0 returned 100% -: 1432: 108: 1433: ImagingReduceCorners_32bpc(imOut, imIn, box, xscale, yscale); call 0 returned 100% 108: 1434: break; -: 1435: } -: 1436: 492: 1437: ImagingSectionLeave(&cookie); call 0 returned 100% -: 1438: 492: 1439: return imOut; -: 1440:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#GetBBox.c.gcov -: 0:Source:src/libImaging/GetBBox.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/GetBBox.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/GetBBox.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * helpers to bounding boxes, min/max values, number of colors, etc. -: 6: * -: 7: * history: -: 8: * 1996-07-22 fl Created -: 9: * 1996-12-30 fl Added projection stuff -: 10: * 1998-07-12 fl Added extrema stuff -: 11: * 2004-09-17 fl Added colors stuff -: 12: * -: 13: * Copyright (c) 1997-2004 by Secret Labs AB. -: 14: * Copyright (c) 1996-2004 by Fredrik Lundh. -: 15: * -: 16: * See the README file for details on usage and redistribution. -: 17: */ -: 18: -: 19: -: 20:#include "Imaging.h" -: 21: -: 22: -: 23:int function ImagingGetBBox called 158 returned 100% blocks executed 100% 158: 24:ImagingGetBBox(Imaging im, int bbox[4]) -: 25:{ -: 26: /* Get the bounding box for any non-zero data in the image.*/ -: 27: -: 28: int x, y; -: 29: int has_data; -: 30: -: 31: /* Initialize bounding box to max values */ 158: 32: bbox[0] = im->xsize; 158: 33: bbox[1] = -1; 158: 34: bbox[2] = bbox[3] = 0; -: 35: -: 36:#define GETBBOX(image, mask)\ -: 37: for (y = 0; y < im->ysize; y++) {\ -: 38: has_data = 0;\ -: 39: for (x = 0; x < im->xsize; x++) {\ -: 40: if (im->image[y][x] & mask) {\ -: 41: has_data = 1;\ -: 42: if (x < bbox[0]) {\ -: 43: bbox[0] = x;\ -: 44: }\ -: 45: if (x >= bbox[2]) {\ -: 46: bbox[2] = x+1;\ -: 47: }\ -: 48: }\ -: 49: }\ -: 50: if (has_data) {\ -: 51: if (bbox[1] < 0) {\ -: 52: bbox[1] = y;\ -: 53: }\ -: 54: bbox[3] = y+1;\ -: 55: }\ -: 56: } -: 57: 158: 58: if (im->image8) { branch 0 taken 15% (fallthrough) branch 1 taken 85% 190004: 59: GETBBOX(image8, 0xff); branch 0 taken 18% (fallthrough) branch 1 taken 82% branch 2 taken 1% (fallthrough) branch 3 taken 99% branch 4 taken 2% (fallthrough) branch 5 taken 98% branch 6 taken 99% branch 7 taken 1% (fallthrough) branch 8 taken 28% (fallthrough) branch 9 taken 72% branch 10 taken 2% (fallthrough) branch 11 taken 98% branch 12 taken 99% (fallthrough) branch 13 taken 1% -: 60: } else { 135: 61: INT32 mask = 0xffffffff; 135: 62: if (im->bands == 3) { branch 0 taken 56% (fallthrough) branch 1 taken 44% 75: 63: ((UINT8*) &mask)[3] = 0; 108: 64: } else if (strcmp(im->mode, "RGBa") == 0 || branch 0 taken 80% (fallthrough) branch 1 taken 20% branch 2 taken 75% (fallthrough) branch 3 taken 25% 84: 65: strcmp(im->mode, "RGBA") == 0 || branch 0 taken 67% (fallthrough) branch 1 taken 33% 60: 66: strcmp(im->mode, "La") == 0 || branch 0 taken 67% (fallthrough) branch 1 taken 33% branch 2 taken 50% (fallthrough) branch 3 taken 50% branch 4 taken 50% (fallthrough) branch 5 taken 50% 36: 67: strcmp(im->mode, "LA") == 0 || branch 0 taken 50% (fallthrough) branch 1 taken 50% branch 2 taken 100% (fallthrough) branch 3 taken 0% branch 4 taken 100% (fallthrough) branch 5 taken 0% 12: 68: strcmp(im->mode, "PA") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 69:#ifdef WORDS_BIGENDIAN -: 70: mask = 0x000000ff; -: 71:#else 60: 72: mask = 0xff000000; -: 73:#endif -: 74: } 4947616: 75: GETBBOX(image32, mask); branch 0 taken 91% (fallthrough) branch 1 taken 9% branch 2 taken 1% (fallthrough) branch 3 taken 99% branch 4 taken 1% (fallthrough) branch 5 taken 99% branch 6 taken 99% branch 7 taken 1% (fallthrough) branch 8 taken 75% (fallthrough) branch 9 taken 25% branch 10 taken 1% (fallthrough) branch 11 taken 99% branch 12 taken 99% (fallthrough) branch 13 taken 1% -: 76: } -: 77: -: 78: /* Check that we got a box */ 158: 79: if (bbox[1] < 0) { branch 0 taken 82% (fallthrough) branch 1 taken 18% -: 80: return 0; /* no data */ -: 81: } -: 82: 129: 83: return 1; /* ok */ -: 84:} -: 85: -: 86: -: 87:int function ImagingGetProjection called 10 returned 100% blocks executed 100% 10: 88:ImagingGetProjection(Imaging im, UINT8* xproj, UINT8* yproj) -: 89:{ -: 90: /* Get projection arrays for non-zero data in the image.*/ -: 91: -: 92: int x, y; -: 93: int has_data; -: 94: -: 95: /* Initialize projection arrays */ 20: 96: memset(xproj, 0, im->xsize); 20: 97: memset(yproj, 0, im->ysize); -: 98: -: 99: #define GETPROJ(image, mask)\ -: 100: for (y = 0; y < im->ysize; y++) {\ -: 101: has_data = 0;\ -: 102: for (x = 0; x < im->xsize; x++) {\ -: 103: if (im->image[y][x] & mask) {\ -: 104: has_data = 1;\ -: 105: xproj[x] = 1;\ -: 106: }\ -: 107: }\ -: 108: if (has_data) {\ -: 109: yproj[y] = 1;\ -: 110: }\ -: 111: } -: 112: 10: 113: if (im->image8) { branch 0 taken 40% (fallthrough) branch 1 taken 60% 400: 114: GETPROJ(image8, 0xff); branch 0 taken 6% (fallthrough) branch 1 taken 94% branch 2 taken 91% branch 3 taken 9% (fallthrough) branch 4 taken 10% (fallthrough) branch 5 taken 90% branch 6 taken 91% (fallthrough) branch 7 taken 9% -: 115: } else { 6: 116: INT32 mask = 0xffffffff; 6: 117: if (im->bands == 3) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 6: 118: ((UINT8*) &mask)[3] = 0; -: 119: } 33168: 120: GETPROJ(image32, mask); branch 0 taken 99% (fallthrough) branch 1 taken 1% branch 2 taken 99% branch 3 taken 1% (fallthrough) branch 4 taken 88% (fallthrough) branch 5 taken 12% branch 6 taken 98% (fallthrough) branch 7 taken 2% -: 121: } -: 122: 10: 123: return 1; /* ok */ -: 124:} -: 125: -: 126: -: 127:int function ImagingGetExtrema called 29 returned 100% blocks executed 93% 29: 128:ImagingGetExtrema(Imaging im, void *extrema) -: 129:{ -: 130: int x, y; -: 131: INT32 imin, imax; -: 132: FLOAT32 fmin, fmax; -: 133: 29: 134: if (im->bands != 1) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 135: (void) ImagingError_ModeError(); call 0 never executed #####: 136: return -1; /* mismatch */ -: 137: } -: 138: 29: 139: if (!im->xsize || !im->ysize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% -: 140: return 0; /* zero size */ -: 141: } -: 142: 29: 143: switch (im->type) { branch 0 taken 62% branch 1 taken 14% branch 2 taken 17% branch 3 taken 7% branch 4 taken 0% -: 144: case IMAGING_TYPE_UINT8: 18: 145: imin = imax = im->image8[0][0]; 2322: 146: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 2304: 147: UINT8* in = im->image8[y]; 297216: 148: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 294912: 149: if (imin > in[x]) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 97: 150: imin = in[x]; 294815: 151: } else if (imax < in[x]) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 119: 152: imax = in[x]; -: 153: } -: 154: } -: 155: } 18: 156: ((UINT8*) extrema)[0] = (UINT8) imin; 18: 157: ((UINT8*) extrema)[1] = (UINT8) imax; 18: 158: break; -: 159: case IMAGING_TYPE_INT32: 4: 160: imin = imax = im->image32[0][0]; 488: 161: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 484: 162: INT32* in = im->image32[y]; 51636: 163: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 51152: 164: if (imin > in[x]) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 129: 165: imin = in[x]; 51023: 166: } else if (imax < in[x]) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 39: 167: imax = in[x]; -: 168: } -: 169: } -: 170: } 4: 171: memcpy(extrema, &imin, sizeof(imin)); 4: 172: memcpy(((char*)extrema) + sizeof(imin), &imax, sizeof(imax)); -: 173: break; -: 174: case IMAGING_TYPE_FLOAT32: 5: 175: fmin = fmax = ((FLOAT32*) im->image32[0])[0]; 645: 176: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 640: 177: FLOAT32* in = (FLOAT32*) im->image32[y]; 82560: 178: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 81920: 179: if (fmin > in[x]) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 52: 180: fmin = in[x]; 81868: 181: } else if (fmax < in[x]) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 64: 182: fmax = in[x]; -: 183: } -: 184: } -: 185: } 5: 186: memcpy(extrema, &fmin, sizeof(fmin)); 5: 187: memcpy(((char*)extrema) + sizeof(fmin), &fmax, sizeof(fmax)); -: 188: break; -: 189: case IMAGING_TYPE_SPECIAL: 2: 190: if (strcmp(im->mode, "I;16") == 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 191: UINT16 v; 2: 192: UINT8* pixel = *im->image8; -: 193:#ifdef WORDS_BIGENDIAN -: 194: v = pixel[0] + (pixel[1] << 8); -: 195:#else 2: 196: memcpy(&v, pixel, sizeof(v)); -: 197:#endif 2: 198: imin = imax = v; 162: 199: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 17408: 200: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 17408: 201: pixel = im->image[y] + x * sizeof(v); -: 202:#ifdef WORDS_BIGENDIAN -: 203: v = pixel[0] + (pixel[1] << 8); -: 204:#else 17408: 205: memcpy(&v, pixel, sizeof(v)); -: 206:#endif 17408: 207: if (imin > v) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 23: 208: imin = v; 17385: 209: } else if (imax < v) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 18: 210: imax = v; -: 211: } -: 212: } -: 213: } 2: 214: v = (UINT16) imin; 2: 215: memcpy(extrema, &v, sizeof(v)); 2: 216: v = (UINT16) imax; 4: 217: memcpy(((char*)extrema) + sizeof(v), &v, sizeof(v)); -: 218: break; -: 219: } -: 220: /* FALL THROUGH */ -: 221: default: #####: 222: (void) ImagingError_ModeError(); call 0 never executed #####: 223: return -1; -: 224: } -: 225: return 1; /* ok */ -: 226:} -: 227: -: 228: -: 229:/* static ImagingColorItem* getcolors8(Imaging im, int maxcolors, int* size);*/ -: 230:static ImagingColorItem* getcolors32(Imaging im, int maxcolors, int* size); -: 231: -: 232:ImagingColorItem* function ImagingGetColors called 20 returned 100% blocks executed 100% 20: 233:ImagingGetColors(Imaging im, int maxcolors, int* size) -: 234:{ -: 235: /* FIXME: add support for 8-bit images */ 20: 236: return getcolors32(im, maxcolors, size); call 0 returned 100% -: 237:} -: 238: -: 239:static ImagingColorItem* function getcolors32 called 20 returned 100% blocks executed 93% 20: 240:getcolors32(Imaging im, int maxcolors, int* size) -: 241:{ -: 242: unsigned int h; -: 243: unsigned int i, incr; -: 244: int colors; -: 245: INT32 pixel_mask; -: 246: int x, y; -: 247: ImagingColorItem* table; -: 248: ImagingColorItem* v; -: 249: -: 250: unsigned int code_size; -: 251: unsigned int code_poly; -: 252: unsigned int code_mask; -: 253: -: 254: /* note: the hash algorithm used here is based on the dictionary -: 255: code in Python 2.1.3; the exact implementation is borrowed from -: 256: Python's Unicode property database (written by yours truly) /F */ -: 257: -: 258: static int SIZES[] = { -: 259: 4,3, 8,3, 16,3, 32,5, 64,3, 128,3, 256,29, 512,17, 1024,9, 2048,5, -: 260: 4096,83, 8192,27, 16384,43, 32768,3, 65536,45, 131072,9, 262144,39, -: 261: 524288,39, 1048576,9, 2097152,5, 4194304,3, 8388608,33, 16777216,27, -: 262: 33554432,9, 67108864,71, 134217728,39, 268435456,9, 536870912,5, -: 263: 1073741824,83, 0 -: 264: }; -: 265: 20: 266: code_size = code_poly = code_mask = 0; -: 267: 168: 268: for (i = 0; SIZES[i]; i += 2) { branch 0 taken 100% branch 1 taken 0% (fallthrough) 168: 269: if (SIZES[i] > maxcolors) { branch 0 taken 12% (fallthrough) branch 1 taken 88% 20: 270: code_size = SIZES[i]; 20: 271: code_poly = SIZES[i+1]; 20: 272: code_mask = code_size - 1; 20: 273: break; -: 274: } -: 275: } -: 276: -: 277: /* printf("code_size=%d\n", code_size); */ -: 278: /* printf("code_poly=%d\n", code_poly); */ -: 279: 20: 280: if (!code_size) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 281: return ImagingError_MemoryError(); /* just give up */ call 0 never executed -: 282: } -: 283: 20: 284: if (!im->image32) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 285: return ImagingError_ModeError(); call 0 never executed -: 286: } -: 287: 20: 288: table = calloc(code_size + 1, sizeof(ImagingColorItem)); 20: 289: if (!table) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 290: return ImagingError_MemoryError(); call 0 never executed -: 291: } -: 292: 20: 293: pixel_mask = 0xffffffff; 20: 294: if (im->bands == 3) { branch 0 taken 55% (fallthrough) branch 1 taken 45% 11: 295: ((UINT8*) &pixel_mask)[3] = 0; -: 296: } -: 297: -: 298: colors = 0; -: 299: 1625: 300: for (y = 0; y < im->ysize; y++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 1631: 301: INT32* p = im->image32[y]; 204775: 302: for (x = 0; x < im->xsize; x++) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 203150: 303: INT32 pixel = p[x] & pixel_mask; 203150: 304: h = (pixel); /* null hashing */ 203150: 305: i = (~h) & code_mask; 203150: 306: v = &table[i]; 203150: 307: if (!v->count) { branch 0 taken 17% (fallthrough) branch 1 taken 83% -: 308: /* add to table */ 34844: 309: if (colors++ == maxcolors) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 310: goto overflow; -: 311: } 34842: 312: v->x = x; v->y = y; 34842: 313: v->pixel = pixel; 34842: 314: v->count = 1; 34842: 315: continue; 168306: 316: } else if (v->pixel == pixel) { branch 0 taken 52% (fallthrough) branch 1 taken 48% 87972: 317: v->count++; 87972: 318: continue; -: 319: } 80334: 320: incr = (h ^ (h >> 3)) & code_mask; 80334: 321: if (!incr) { branch 0 taken 20% (fallthrough) branch 1 taken 80% 16245: 322: incr = code_mask; -: 323: } -: 324: for (;;) { 1945441: 325: i = (i + incr) & code_mask; 1945441: 326: v = &table[i]; 1945441: 327: if (!v->count) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 328: /* add to table */ 24640: 329: if (colors++ == maxcolors) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 330: goto overflow; -: 331: } 24636: 332: v->x = x; v->y = y; 24636: 333: v->pixel = pixel; 24636: 334: v->count = 1; 24636: 335: break; 1920801: 336: } else if (v->pixel == pixel) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 55694: 337: v->count++; 55694: 338: break; -: 339: } 1865107: 340: incr = incr << 1; 1865107: 341: if (incr > code_mask) { branch 0 taken 13% branch 1 taken 87% (fallthrough) 1619858: 342: incr = incr ^ code_poly; -: 343: } -: 344: } -: 345: } -: 346: } -: 347: -: 348:overflow: -: 349: -: 350: /* pack the table */ 283220: 351: for (x = y = 0; x < (int) code_size; x++) branch 0 taken 99% branch 1 taken 1% (fallthrough) 283200: 352: if (table[x].count) { branch 0 taken 21% (fallthrough) branch 1 taken 79% 59478: 353: if (x != y) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 59443: 354: table[y] = table[x]; -: 355: } 59478: 356: y++; -: 357: } 20: 358: table[y].count = 0; /* mark end of table */ -: 359: 20: 360: *size = colors; -: 361: 20: 362: return table; -: 363:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#PcxEncode.c.gcov -: 0:Source:src/libImaging/PcxEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/PcxEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/PcxEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * encoder for PCX data -: 6: * -: 7: * history: -: 8: * 99-02-07 fl created -: 9: * -: 10: * Copyright (c) Fredrik Lundh 1999. -: 11: * Copyright (c) Secret Labs AB 1999. -: 12: * -: 13: * See the README file for information on usage and redistribution. -: 14: */ -: 15: -: 16: -: 17:#include "Imaging.h" -: 18: -: 19:enum { INIT, FETCH, ENCODE }; -: 20: -: 21:/* we're reusing "ystep" to store the last value */ -: 22:#define LAST ystep -: 23: -: 24:int function ImagingPcxEncode called 40 returned 100% blocks executed 96% 40: 25:ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 26:{ -: 27: UINT8* ptr; -: 28: int this; 40: 29: int bytes_per_line = 0; 40: 30: int padding = 0; 40: 31: int stride = 0; 40: 32: int bpp = 0; 40: 33: int planes = 1; -: 34: int i; -: 35: 40: 36: ptr = buf; -: 37: 40: 38: if (!state->state) { branch 0 taken 43% (fallthrough) branch 1 taken 58% -: 39: /* sanity check */ 17: 40: 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% #####: 41: state->errcode = IMAGING_CODEC_END; #####: 42: return 0; -: 43: } 17: 44: state->state = FETCH; -: 45: } -: 46: 40: 47: bpp = state->bits; 40: 48: if (state->bits == 24){ branch 0 taken 30% (fallthrough) branch 1 taken 70% 12: 49: planes = 3; 12: 50: bpp = 8; -: 51: } -: 52: 40: 53: bytes_per_line = (state->xsize*bpp + 7) / 8; -: 54: /* The stride here needs to be kept in sync with the version in -: 55: PcxImagePlugin.py. If it's not, the header and the body of the -: 56: image will be out of sync and bad things will happen on decode. -: 57: */ 40: 58: stride = bytes_per_line + (bytes_per_line % 2); -: 59: 40: 60: padding = stride - bytes_per_line; -: 61: -: 62: -: 63: for (;;) { -: 64: 3883: 65: switch (state->state) { branch 0 taken 0% branch 1 taken 99% branch 2 taken 1% -: 66: case FETCH: -: 67: -: 68: /* get a line of data */ 3860: 69: if (state->y >= state->ysize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 17: 70: state->errcode = IMAGING_CODEC_END; 17: 71: return ptr - buf; -: 72: } -: 73: 7686: 74: state->shuffle(state->buffer, call 0 returned 100% 3843: 75: (UINT8*) im->image[state->y + state->yoff] + 3843: 76: state->xoff * im->pixelsize, state->xsize); -: 77: 3843: 78: state->y += 1; -: 79: 3843: 80: state->count = 1; 3843: 81: state->LAST = state->buffer[0]; -: 82: 3843: 83: state->x = 1; -: 84: 3843: 85: state->state = ENCODE; -: 86: /* fall through */ -: 87: -: 88: case ENCODE: -: 89: /* compress this line */ -: 90: -: 91: /* when we arrive here, "count" contains the number of -: 92: bytes having the value of "LAST" that we've already -: 93: seen */ -: 94: do { -: 95: /* If we're encoding an odd width file, and we've -: 96: got more than one plane, we need to pad each -: 97: color row with padding bytes at the end. Since -: 98: The pixels are stored RRRRRGGGGGBBBBB, so we need -: 99: to have the padding be RRRRRPGGGGGPBBBBBP. Hence -: 100: the double loop -: 101: */ 2430497: 102: while (state->x % bytes_per_line) { branch 0 taken 99% branch 1 taken 1% (fallthrough) -: 103: 2425372: 104: if (state->count == 63) { branch 0 taken 1% (fallthrough) branch 1 taken 99% -: 105: /* this run is full; flush it */ 239: 106: if (bytes < 2) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 107: return ptr - buf; -: 108: } 238: 109: ptr[0] = 0xff; 238: 110: ptr[1] = state->LAST; 238: 111: ptr += 2; 238: 112: bytes -= 2; -: 113: 238: 114: state->count = 0; -: 115: } -: 116: 2425371: 117: this = state->buffer[state->x]; -: 118: 2425371: 119: if (this == state->LAST) { branch 0 taken 63% (fallthrough) branch 1 taken 37% -: 120: /* extend the current run */ 1517079: 121: state->x += 1; 1517079: 122: state->count += 1; -: 123: -: 124: } else { -: 125: /* start a new run */ 908292: 126: if (state->count == 1 && (state->LAST < 0xc0)) { branch 0 taken 67% (fallthrough) branch 1 taken 33% branch 2 taken 87% (fallthrough) branch 3 taken 13% 531522: 127: if (bytes < 1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 5: 128: return ptr - buf; -: 129: } 531517: 130: ptr[0] = state->LAST; 531517: 131: ptr += 1; 531517: 132: bytes -= 1; -: 133: } else { 376770: 134: if (state->count > 0) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 376668: 135: if (bytes < 2) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 13: 136: return ptr - buf; -: 137: } 376655: 138: ptr[0] = 0xc0 | state->count; 376655: 139: ptr[1] = state->LAST; 376655: 140: ptr += 2; 376655: 141: bytes -= 2; -: 142: } -: 143: } -: 144: 908274: 145: state->LAST = this; 908274: 146: state->count = 1; -: 147: 908274: 148: state->x += 1; -: 149: } -: 150: } -: 151: -: 152: /* end of line; flush the current run */ 5125: 153: if (state->count == 1 && (state->LAST < 0xc0)) { branch 0 taken 26% (fallthrough) branch 1 taken 74% branch 2 taken 67% (fallthrough) branch 3 taken 33% 907: 154: if (bytes < 1 + padding) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 2: 155: return ptr - buf; -: 156: } 905: 157: ptr[0] = state->LAST; 905: 158: ptr += 1; 905: 159: bytes -= 1; -: 160: } else { 4218: 161: if (state->count > 0) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 4218: 162: if (bytes < 2 + padding) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 2: 163: return ptr - buf; -: 164: } 4216: 165: ptr[0] = 0xc0 | state->count; 4216: 166: ptr[1] = state->LAST; 4216: 167: ptr += 2; 4216: 168: bytes -= 2; -: 169: } -: 170: } -: 171: /* add the padding */ 2816: 172: for (i = 0; i < padding; i++) { branch 0 taken 35% branch 1 taken 65% (fallthrough) 2816: 173: ptr[0] = 0; 2816: 174: ptr += 1; 2816: 175: bytes -= 1; -: 176: } -: 177: /* reset for the next color plane. */ 5121: 178: if (state->x < planes * bytes_per_line) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 1278: 179: state->count = 1; 1278: 180: state->LAST = state->buffer[state->x]; 1278: 181: state->x += 1; -: 182: } 5121: 183: } while (state->x < planes * bytes_per_line); branch 0 taken 25% branch 1 taken 75% (fallthrough) -: 184: -: 185: /* read next line */ 3843: 186: state->state = FETCH; 3843: 187: break; -: 188: } -: 189: } -: 190:} -: 191: <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/#usr#include#webp#decode.h.gcov -: 0:Source:/usr/include/webp/decode.h -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/_webp.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/_webp.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:// Copyright 2010 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:// Main decoding functions for WebP images. -: 11:// -: 12:// Author: Skal (pascal.massimino@gmail.com) -: 13: -: 14:#ifndef WEBP_WEBP_DECODE_H_ -: 15:#define WEBP_WEBP_DECODE_H_ -: 16: -: 17:#include "./types.h" -: 18: -: 19:#ifdef __cplusplus -: 20:extern "C" { -: 21:#endif -: 22: -: 23:#define WEBP_DECODER_ABI_VERSION 0x0209 // 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 VP8StatusCode VP8StatusCode; -: 28:// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE; -: 29:typedef struct WebPRGBABuffer WebPRGBABuffer; -: 30:typedef struct WebPYUVABuffer WebPYUVABuffer; -: 31:typedef struct WebPDecBuffer WebPDecBuffer; -: 32:typedef struct WebPIDecoder WebPIDecoder; -: 33:typedef struct WebPBitstreamFeatures WebPBitstreamFeatures; -: 34:typedef struct WebPDecoderOptions WebPDecoderOptions; -: 35:typedef struct WebPDecoderConfig WebPDecoderConfig; -: 36: -: 37:// Return the decoder's version number, packed in hexadecimal using 8bits for -: 38:// each of major/minor/revision. E.g: v2.5.7 is 0x020507. -: 39:WEBP_EXTERN int WebPGetDecoderVersion(void); -: 40: -: 41:// Retrieve basic header information: width, height. -: 42:// This function will also validate the header, returning true on success, -: 43:// false otherwise. '*width' and '*height' are only valid on successful return. -: 44:// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. -: 45:// Note: The following chunk sequences (before the raw VP8/VP8L data) are -: 46:// considered valid by this function: -: 47:// RIFF + VP8(L) -: 48:// RIFF + VP8X + (optional chunks) + VP8(L) -: 49:// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose. -: 50:// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose. -: 51:WEBP_EXTERN int WebPGetInfo(const uint8_t* data, size_t data_size, -: 52: int* width, int* height); -: 53: -: 54:// Decodes WebP images pointed to by 'data' and returns RGBA samples, along -: 55:// with the dimensions in *width and *height. The ordering of samples in -: 56:// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). -: 57:// The returned pointer should be deleted calling WebPFree(). -: 58:// Returns NULL in case of error. -: 59:WEBP_EXTERN uint8_t* WebPDecodeRGBA(const uint8_t* data, size_t data_size, -: 60: int* width, int* height); -: 61: -: 62:// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. -: 63:WEBP_EXTERN uint8_t* WebPDecodeARGB(const uint8_t* data, size_t data_size, -: 64: int* width, int* height); -: 65: -: 66:// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. -: 67:WEBP_EXTERN uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size, -: 68: int* width, int* height); -: 69: -: 70:// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. -: 71:// If the bitstream contains transparency, it is ignored. -: 72:WEBP_EXTERN uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size, -: 73: int* width, int* height); -: 74: -: 75:// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. -: 76:WEBP_EXTERN uint8_t* WebPDecodeBGR(const uint8_t* data, size_t data_size, -: 77: int* width, int* height); -: 78: -: 79: -: 80:// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer -: 81:// returned is the Y samples buffer. Upon return, *u and *v will point to -: 82:// the U and V chroma data. These U and V buffers need NOT be passed to -: 83:// WebPFree(), unlike the returned Y luma one. The dimension of the U and V -: 84:// planes are both (*width + 1) / 2 and (*height + 1)/ 2. -: 85:// Upon return, the Y buffer has a stride returned as '*stride', while U and V -: 86:// have a common stride returned as '*uv_stride'. -: 87:// Return NULL in case of error. -: 88:// (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr -: 89:WEBP_EXTERN uint8_t* WebPDecodeYUV(const uint8_t* data, size_t data_size, -: 90: int* width, int* height, -: 91: uint8_t** u, uint8_t** v, -: 92: int* stride, int* uv_stride); -: 93: -: 94:// These five functions are variants of the above ones, that decode the image -: 95:// directly into a pre-allocated buffer 'output_buffer'. The maximum storage -: 96:// available in this buffer is indicated by 'output_buffer_size'. If this -: 97:// storage is not sufficient (or an error occurred), NULL is returned. -: 98:// Otherwise, output_buffer is returned, for convenience. -: 99:// The parameter 'output_stride' specifies the distance (in bytes) -: 100:// between scanlines. Hence, output_buffer_size is expected to be at least -: 101:// output_stride x picture-height. -: 102:WEBP_EXTERN uint8_t* WebPDecodeRGBAInto( -: 103: const uint8_t* data, size_t data_size, -: 104: uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -: 105:WEBP_EXTERN uint8_t* WebPDecodeARGBInto( -: 106: const uint8_t* data, size_t data_size, -: 107: uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -: 108:WEBP_EXTERN uint8_t* WebPDecodeBGRAInto( -: 109: const uint8_t* data, size_t data_size, -: 110: uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -: 111: -: 112:// RGB and BGR variants. Here too the transparency information, if present, -: 113:// will be dropped and ignored. -: 114:WEBP_EXTERN uint8_t* WebPDecodeRGBInto( -: 115: const uint8_t* data, size_t data_size, -: 116: uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -: 117:WEBP_EXTERN uint8_t* WebPDecodeBGRInto( -: 118: const uint8_t* data, size_t data_size, -: 119: uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -: 120: -: 121:// WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly -: 122:// into pre-allocated luma/chroma plane buffers. This function requires the -: 123:// strides to be passed: one for the luma plane and one for each of the -: 124:// chroma ones. The size of each plane buffer is passed as 'luma_size', -: 125:// 'u_size' and 'v_size' respectively. -: 126:// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred -: 127:// during decoding (or because some buffers were found to be too small). -: 128:WEBP_EXTERN uint8_t* WebPDecodeYUVInto( -: 129: const uint8_t* data, size_t data_size, -: 130: uint8_t* luma, size_t luma_size, int luma_stride, -: 131: uint8_t* u, size_t u_size, int u_stride, -: 132: uint8_t* v, size_t v_size, int v_stride); -: 133: -: 134://------------------------------------------------------------------------------ -: 135:// Output colorspaces and buffer -: 136: -: 137:// Colorspaces -: 138:// Note: the naming describes the byte-ordering of packed samples in memory. -: 139:// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... -: 140:// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. -: 141:// RGBA-4444 and RGB-565 colorspaces are represented by following byte-order: -: 142:// RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ... -: 143:// RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ... -: 144:// In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for -: 145:// these two modes: -: 146:// RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ... -: 147:// RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ... -: 148: -: 149:typedef enum WEBP_CSP_MODE { -: 150: MODE_RGB = 0, MODE_RGBA = 1, -: 151: MODE_BGR = 2, MODE_BGRA = 3, -: 152: MODE_ARGB = 4, MODE_RGBA_4444 = 5, -: 153: MODE_RGB_565 = 6, -: 154: // RGB-premultiplied transparent modes (alpha value is preserved) -: 155: MODE_rgbA = 7, -: 156: MODE_bgrA = 8, -: 157: MODE_Argb = 9, -: 158: MODE_rgbA_4444 = 10, -: 159: // YUV modes must come after RGB ones. -: 160: MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 -: 161: MODE_LAST = 13 -: 162:} WEBP_CSP_MODE; -: 163: -: 164:// Some useful macros: -: 165:static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { -: 166: return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || -: 167: mode == MODE_rgbA_4444); -: 168:} -: 169: -: 170:static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { -: 171: return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || -: 172: mode == MODE_RGBA_4444 || mode == MODE_YUVA || -: 173: WebPIsPremultipliedMode(mode)); -: 174:} -: 175: -: 176:static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { -: 177: return (mode < MODE_YUV); -: 178:} -: 179: -: 180://------------------------------------------------------------------------------ -: 181:// WebPDecBuffer: Generic structure for describing the output sample buffer. -: 182: -: 183:struct WebPRGBABuffer { // view as RGBA -: 184: uint8_t* rgba; // pointer to RGBA samples -: 185: int stride; // stride in bytes from one scanline to the next. -: 186: size_t size; // total size of the *rgba buffer. -: 187:}; -: 188: -: 189:struct WebPYUVABuffer { // view as YUVA -: 190: uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples -: 191: int y_stride; // luma stride -: 192: int u_stride, v_stride; // chroma strides -: 193: int a_stride; // alpha stride -: 194: size_t y_size; // luma plane size -: 195: size_t u_size, v_size; // chroma planes size -: 196: size_t a_size; // alpha-plane size -: 197:}; -: 198: -: 199:// Output buffer -: 200:struct WebPDecBuffer { -: 201: WEBP_CSP_MODE colorspace; // Colorspace. -: 202: int width, height; // Dimensions. -: 203: int is_external_memory; // If non-zero, 'internal_memory' pointer is not -: 204: // used. If value is '2' or more, the external -: 205: // memory is considered 'slow' and multiple -: 206: // read/write will be avoided. -: 207: union { -: 208: WebPRGBABuffer RGBA; -: 209: WebPYUVABuffer YUVA; -: 210: } u; // Nameless union of buffer parameters. -: 211: uint32_t pad[4]; // padding for later use -: 212: -: 213: uint8_t* private_memory; // Internally allocated memory (only when -: 214: // is_external_memory is 0). Should not be used -: 215: // externally, but accessed via the buffer union. -: 216:}; -: 217: -: 218:// Internal, version-checked, entry point -: 219:WEBP_EXTERN int WebPInitDecBufferInternal(WebPDecBuffer*, int); -: 220: -: 221:// Initialize the structure as empty. Must be called before any other use. -: 222:// Returns false in case of version mismatch -: 223:static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { -: 224: return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); -: 225:} -: 226: -: 227:// Free any memory associated with the buffer. Must always be called last. -: 228:// Note: doesn't free the 'buffer' structure itself. -: 229:WEBP_EXTERN void WebPFreeDecBuffer(WebPDecBuffer* buffer); -: 230: -: 231://------------------------------------------------------------------------------ -: 232:// Enumeration of the status codes -: 233: -: 234:typedef enum VP8StatusCode { -: 235: VP8_STATUS_OK = 0, -: 236: VP8_STATUS_OUT_OF_MEMORY, -: 237: VP8_STATUS_INVALID_PARAM, -: 238: VP8_STATUS_BITSTREAM_ERROR, -: 239: VP8_STATUS_UNSUPPORTED_FEATURE, -: 240: VP8_STATUS_SUSPENDED, -: 241: VP8_STATUS_USER_ABORT, -: 242: VP8_STATUS_NOT_ENOUGH_DATA -: 243:} VP8StatusCode; -: 244: -: 245://------------------------------------------------------------------------------ -: 246:// Incremental decoding -: 247:// -: 248:// This API allows streamlined decoding of partial data. -: 249:// Picture can be incrementally decoded as data become available thanks to the -: 250:// WebPIDecoder object. This object can be left in a SUSPENDED state if the -: 251:// picture is only partially decoded, pending additional input. -: 252:// Code example: -: 253:// -: 254:// WebPInitDecBuffer(&output_buffer); -: 255:// output_buffer.colorspace = mode; -: 256:// ... -: 257:// WebPIDecoder* idec = WebPINewDecoder(&output_buffer); -: 258:// while (additional_data_is_available) { -: 259:// // ... (get additional data in some new_data[] buffer) -: 260:// status = WebPIAppend(idec, new_data, new_data_size); -: 261:// if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) { -: 262:// break; // an error occurred. -: 263:// } -: 264:// -: 265:// // The above call decodes the current available buffer. -: 266:// // Part of the image can now be refreshed by calling -: 267:// // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. -: 268:// } -: 269:// WebPIDelete(idec); -: 270: -: 271:// Creates a new incremental decoder with the supplied buffer parameter. -: 272:// This output_buffer can be passed NULL, in which case a default output buffer -: 273:// is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' -: 274:// is kept, which means that the lifespan of 'output_buffer' must be larger than -: 275:// that of the returned WebPIDecoder object. -: 276:// The supplied 'output_buffer' content MUST NOT be changed between calls to -: 277:// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is -: 278:// not set to 0. In such a case, it is allowed to modify the pointers, size and -: 279:// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain -: 280:// within valid bounds. -: 281:// All other fields of WebPDecBuffer MUST remain constant between calls. -: 282:// Returns NULL if the allocation failed. -: 283:WEBP_EXTERN WebPIDecoder* WebPINewDecoder(WebPDecBuffer* output_buffer); -: 284: -: 285:// This function allocates and initializes an incremental-decoder object, which -: 286:// will output the RGB/A samples specified by 'csp' into a preallocated -: 287:// buffer 'output_buffer'. The size of this buffer is at least -: 288:// 'output_buffer_size' and the stride (distance in bytes between two scanlines) -: 289:// is specified by 'output_stride'. -: 290:// Additionally, output_buffer can be passed NULL in which case the output -: 291:// buffer will be allocated automatically when the decoding starts. The -: 292:// colorspace 'csp' is taken into account for allocating this buffer. All other -: 293:// parameters are ignored. -: 294:// Returns NULL if the allocation failed, or if some parameters are invalid. -: 295:WEBP_EXTERN WebPIDecoder* WebPINewRGB( -: 296: WEBP_CSP_MODE csp, -: 297: uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -: 298: -: 299:// This function allocates and initializes an incremental-decoder object, which -: 300:// will output the raw luma/chroma samples into a preallocated planes if -: 301:// supplied. The luma plane is specified by its pointer 'luma', its size -: 302:// 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane -: 303:// is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v -: 304:// plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer -: 305:// can be pass NULL in case one is not interested in the transparency plane. -: 306:// Conversely, 'luma' can be passed NULL if no preallocated planes are supplied. -: 307:// In this case, the output buffer will be automatically allocated (using -: 308:// MODE_YUVA) when decoding starts. All parameters are then ignored. -: 309:// Returns NULL if the allocation failed or if a parameter is invalid. -: 310:WEBP_EXTERN WebPIDecoder* WebPINewYUVA( -: 311: uint8_t* luma, size_t luma_size, int luma_stride, -: 312: uint8_t* u, size_t u_size, int u_stride, -: 313: uint8_t* v, size_t v_size, int v_stride, -: 314: uint8_t* a, size_t a_size, int a_stride); -: 315: -: 316:// Deprecated version of the above, without the alpha plane. -: 317:// Kept for backward compatibility. -: 318:WEBP_EXTERN WebPIDecoder* WebPINewYUV( -: 319: uint8_t* luma, size_t luma_size, int luma_stride, -: 320: uint8_t* u, size_t u_size, int u_stride, -: 321: uint8_t* v, size_t v_size, int v_stride); -: 322: -: 323:// Deletes the WebPIDecoder object and associated memory. Must always be called -: 324:// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. -: 325:WEBP_EXTERN void WebPIDelete(WebPIDecoder* idec); -: 326: -: 327:// Copies and decodes the next available data. Returns VP8_STATUS_OK when -: 328:// the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more -: 329:// data is expected. Returns error in other cases. -: 330:WEBP_EXTERN VP8StatusCode WebPIAppend( -: 331: WebPIDecoder* idec, const uint8_t* data, size_t data_size); -: 332: -: 333:// A variant of the above function to be used when data buffer contains -: 334:// partial data from the beginning. In this case data buffer is not copied -: 335:// to the internal memory. -: 336:// Note that the value of the 'data' pointer can change between calls to -: 337:// WebPIUpdate, for instance when the data buffer is resized to fit larger data. -: 338:WEBP_EXTERN VP8StatusCode WebPIUpdate( -: 339: WebPIDecoder* idec, const uint8_t* data, size_t data_size); -: 340: -: 341:// Returns the RGB/A image decoded so far. Returns NULL if output params -: 342:// are not initialized yet. The RGB/A output type corresponds to the colorspace -: 343:// specified during call to WebPINewDecoder() or WebPINewRGB(). -: 344:// *last_y is the index of last decoded row in raster scan order. Some pointers -: 345:// (*last_y, *width etc.) can be NULL if corresponding information is not -: 346:// needed. The values in these pointers are only valid on successful (non-NULL) -: 347:// return. -: 348:WEBP_EXTERN uint8_t* WebPIDecGetRGB( -: 349: const WebPIDecoder* idec, int* last_y, -: 350: int* width, int* height, int* stride); -: 351: -: 352:// Same as above function to get a YUVA image. Returns pointer to the luma -: 353:// plane or NULL in case of error. If there is no alpha information -: 354:// the alpha pointer '*a' will be returned NULL. -: 355:WEBP_EXTERN uint8_t* WebPIDecGetYUVA( -: 356: const WebPIDecoder* idec, int* last_y, -: 357: uint8_t** u, uint8_t** v, uint8_t** a, -: 358: int* width, int* height, int* stride, int* uv_stride, int* a_stride); -: 359: -: 360:// Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the -: 361:// alpha information (if present). Kept for backward compatibility. -: 362:static WEBP_INLINE uint8_t* WebPIDecGetYUV( -: 363: const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, -: 364: int* width, int* height, int* stride, int* uv_stride) { -: 365: return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, -: 366: stride, uv_stride, NULL); -: 367:} -: 368: -: 369:// Generic call to retrieve information about the displayable area. -: 370:// If non NULL, the left/right/width/height pointers are filled with the visible -: 371:// rectangular area so far. -: 372:// Returns NULL in case the incremental decoder object is in an invalid state. -: 373:// Otherwise returns the pointer to the internal representation. This structure -: 374:// is read-only, tied to WebPIDecoder's lifespan and should not be modified. -: 375:WEBP_EXTERN const WebPDecBuffer* WebPIDecodedArea( -: 376: const WebPIDecoder* idec, int* left, int* top, int* width, int* height); -: 377: -: 378://------------------------------------------------------------------------------ -: 379:// Advanced decoding parametrization -: 380:// -: 381:// Code sample for using the advanced decoding API -: 382:/* -: 383: // A) Init a configuration object -: 384: WebPDecoderConfig config; -: 385: CHECK(WebPInitDecoderConfig(&config)); -: 386: -: 387: // B) optional: retrieve the bitstream's features. -: 388: CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); -: 389: -: 390: // C) Adjust 'config', if needed -: 391: config.no_fancy_upsampling = 1; -: 392: config.output.colorspace = MODE_BGRA; -: 393: // etc. -: 394: -: 395: // Note that you can also make config.output point to an externally -: 396: // supplied memory buffer, provided it's big enough to store the decoded -: 397: // picture. Otherwise, config.output will just be used to allocate memory -: 398: // and store the decoded picture. -: 399: -: 400: // D) Decode! -: 401: CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); -: 402: -: 403: // E) Decoded image is now in config.output (and config.output.u.RGBA) -: 404: -: 405: // F) Reclaim memory allocated in config's object. It's safe to call -: 406: // this function even if the memory is external and wasn't allocated -: 407: // by WebPDecode(). -: 408: WebPFreeDecBuffer(&config.output); -: 409:*/ -: 410: -: 411:// Features gathered from the bitstream -: 412:struct WebPBitstreamFeatures { -: 413: int width; // Width in pixels, as read from the bitstream. -: 414: int height; // Height in pixels, as read from the bitstream. -: 415: int has_alpha; // True if the bitstream contains an alpha channel. -: 416: int has_animation; // True if the bitstream is an animation. -: 417: int format; // 0 = undefined (/mixed), 1 = lossy, 2 = lossless -: 418: -: 419: uint32_t pad[5]; // padding for later use -: 420:}; -: 421: -: 422:// Internal, version-checked, entry point -: 423:WEBP_EXTERN VP8StatusCode WebPGetFeaturesInternal( -: 424: const uint8_t*, size_t, WebPBitstreamFeatures*, int); -: 425: -: 426:// Retrieve features from the bitstream. The *features structure is filled -: 427:// with information gathered from the bitstream. -: 428:// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns -: 429:// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the -: 430:// features from headers. Returns error in other cases. -: 431:// Note: The following chunk sequences (before the raw VP8/VP8L data) are -: 432:// considered valid by this function: -: 433:// RIFF + VP8(L) -: 434:// RIFF + VP8X + (optional chunks) + VP8(L) -: 435:// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose. -: 436:// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose. -: 437:static WEBP_INLINE VP8StatusCode WebPGetFeatures( -: 438: const uint8_t* data, size_t data_size, -: 439: WebPBitstreamFeatures* features) { 160: 440: return WebPGetFeaturesInternal(data, data_size, features, call 0 never executed call 1 returned 100% -: 441: WEBP_DECODER_ABI_VERSION); -: 442:} -: 443: -: 444:// Decoding options -: 445:struct WebPDecoderOptions { -: 446: int bypass_filtering; // if true, skip the in-loop filtering -: 447: int no_fancy_upsampling; // if true, use faster pointwise upsampler -: 448: int use_cropping; // if true, cropping is applied _first_ -: 449: int crop_left, crop_top; // top-left position for cropping. -: 450: // Will be snapped to even values. -: 451: int crop_width, crop_height; // dimension of the cropping area -: 452: int use_scaling; // if true, scaling is applied _afterward_ -: 453: int scaled_width, scaled_height; // final resolution -: 454: int use_threads; // if true, use multi-threaded decoding -: 455: int dithering_strength; // dithering strength (0=Off, 100=full) -: 456: int flip; // flip output vertically -: 457: int alpha_dithering_strength; // alpha dithering strength in [0..100] -: 458: -: 459: uint32_t pad[5]; // padding for later use -: 460:}; -: 461: -: 462:// Main object storing the configuration for advanced decoding. -: 463:struct WebPDecoderConfig { -: 464: WebPBitstreamFeatures input; // Immutable bitstream features (optional) -: 465: WebPDecBuffer output; // Output buffer (can point to external mem) -: 466: WebPDecoderOptions options; // Decoding options -: 467:}; -: 468: -: 469:// Internal, version-checked, entry point -: 470:WEBP_EXTERN int WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); -: 471: -: 472:// Initialize the configuration as empty. This function must always be -: 473:// called first, unless WebPGetFeatures() is to be called. -: 474:// Returns false in case of mismatched version. -: 475:static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { #####: 476: return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); call 0 never executed -: 477:} -: 478: -: 479:// Instantiate a new incremental decoder object with the requested -: 480:// configuration. The bitstream can be passed using 'data' and 'data_size' -: 481:// parameter, in which case the features will be parsed and stored into -: 482:// config->input. Otherwise, 'data' can be NULL and no parsing will occur. -: 483:// Note that 'config' can be NULL too, in which case a default configuration -: 484:// is used. If 'config' is not NULL, it must outlive the WebPIDecoder object -: 485:// as some references to its fields will be used. No internal copy of 'config' -: 486:// is made. -: 487:// The return WebPIDecoder object must always be deleted calling WebPIDelete(). -: 488:// Returns NULL in case of error (and config->status will then reflect -: 489:// the error condition, if available). -: 490:WEBP_EXTERN WebPIDecoder* WebPIDecode(const uint8_t* data, size_t data_size, -: 491: WebPDecoderConfig* config); -: 492: -: 493:// Non-incremental version. This version decodes the full data at once, taking -: 494:// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK -: 495:// if the decoding was successful). Note that 'config' cannot be NULL. -: 496:WEBP_EXTERN VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size, -: 497: WebPDecoderConfig* config); -: 498: -: 499:#ifdef __cplusplus -: 500:} // extern "C" -: 501:#endif -: 502: -: 503:#endif // WEBP_WEBP_DECODE_H_ <<<<<< 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-aarch64-3.6/src/libImaging/Chops.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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 87% 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 25% (fallthrough) branch 5 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#QuantHeap.c.gcov -: 0:Source:src/libImaging/QuantHeap.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/QuantHeap.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/QuantHeap.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library -: 3: * $Id$ -: 4: * -: 5: * heap data type used by the image quantizer -: 6: * -: 7: * history: -: 8: * 98-09-10 tjs Contributed -: 9: * 98-12-29 fl Added to PIL 1.0b1 -: 10: * -: 11: * Written by Toby J Sargeant . -: 12: * -: 13: * Copyright (c) 1998 by Toby J Sargeant -: 14: * Copyright (c) 1998 by Secret Labs AB -: 15: * -: 16: * See the README file for information on usage and redistribution. -: 17: */ -: 18: -: 19:#include -: 20:#include -: 21:#include -: 22:#include -: 23:#include -: 24: -: 25:#include "QuantHeap.h" -: 26: -: 27:struct _Heap { -: 28: void **heap; -: 29: unsigned int heapsize; -: 30: unsigned int heapcount; -: 31: HeapCmpFunc cf; -: 32:}; -: 33: -: 34:#define INITIAL_SIZE 256 -: 35: -: 36:// #define DEBUG -: 37: -: 38:#ifdef DEBUG -: 39:static int _heap_test(Heap *); -: 40:#endif -: 41: function ImagingQuantHeapFree called 12 returned 100% blocks executed 100% 12: 42:void ImagingQuantHeapFree(Heap *h) { 12: 43: free(h->heap); 12: 44: free(h); 12: 45:} -: 46: function _heap_grow.isra.0 called 1 returned 100% blocks executed 100% 1: 47:static int _heap_grow(Heap *h,unsigned int newsize) { -: 48: void *newheap; 1: 49: if (!newsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% 1: 50: newsize=h->heapsize<<1; -: 51: } 1: 52: if (newsizeheapsize) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 53: return 0; -: 54: } 1: 55: if (newsize > INT_MAX / sizeof(void *)){ branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 56: return 0; -: 57: } -: 58: /* malloc check ok, using calloc for overflow, also checking -: 59: above due to memcpy below*/ 1: 60: newheap=calloc(newsize, sizeof(void *)); 1: 61: if (!newheap) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 62: return 0; -: 63: } 2: 64: memcpy(newheap,h->heap,sizeof(void *)*h->heapsize); 1: 65: free(h->heap); 1: 66: h->heap=newheap; 1: 67: h->heapsize=newsize; -: 68: return 1; -: 69:} -: 70: -: 71:#ifdef DEBUG -: 72:static int _heap_test(Heap *h) { -: 73: unsigned int k; -: 74: for (k=1;k*2<=h->heapcount;k++) { -: 75: if (h->cf(h,h->heap[k],h->heap[k*2])<0) { -: 76: printf ("heap is bad\n"); -: 77: return 0; -: 78: } -: 79: if (k*2+1<=h->heapcount && h->cf(h,h->heap[k],h->heap[k*2+1])<0) { -: 80: printf ("heap is bad\n"); -: 81: return 0; -: 82: } -: 83: } -: 84: return 1; -: 85:} -: 86:#endif -: 87: function ImagingQuantHeapRemove called 2367 returned 100% blocks executed 100% 2367: 88:int ImagingQuantHeapRemove(Heap* h,void **r) { -: 89: unsigned int k,l; -: 90: void *v; -: 91: 2367: 92: if (!h->heapcount) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 93: return 0; -: 94: } 2363: 95: *r=h->heap[1]; 2363: 96: v=h->heap[h->heapcount--]; 14863: 97: for (k=1;k*2<=h->heapcount;k=l) { branch 0 taken 85% branch 1 taken 15% (fallthrough) 12623: 98: l=k*2; 12623: 99: if (lheapcount) { branch 0 taken 99% (fallthrough) branch 1 taken 1% 12533: 100: if (h->cf(h,h->heap[l],h->heap[l+1])<0) { call 0 returned 100% branch 1 taken 48% (fallthrough) branch 2 taken 52% 6005: 101: l++; -: 102: } -: 103: } 12623: 104: if (h->cf(h,v,h->heap[l])>0) { call 0 returned 100% branch 1 taken 99% (fallthrough) branch 2 taken 1% -: 105: break; -: 106: } 12500: 107: h->heap[k]=h->heap[l]; -: 108: } 2363: 109: h->heap[k]=v; -: 110:#ifdef DEBUG -: 111: if (!_heap_test(h)) { printf ("oops - heap_remove messed up the heap\n"); exit(1); } -: 112:#endif 2363: 113: return 1; -: 114:} -: 115: function ImagingQuantHeapAdd called 4108 returned 100% blocks executed 100% 4108: 116:int ImagingQuantHeapAdd(Heap *h,void *val) { -: 117: int k; 4108: 118: if (h->heapcount==h->heapsize-1) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 1: 119: _heap_grow(h,0); call 0 returned 100% -: 120: } 4108: 121: k=++h->heapcount; 10466: 122: while (k!=1) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 6318: 123: if (h->cf(h,val,h->heap[k/2])<=0) { call 0 returned 100% branch 1 taken 36% (fallthrough) branch 2 taken 64% -: 124: break; -: 125: } 2250: 126: h->heap[k]=h->heap[k/2]; 2250: 127: k>>=1; -: 128: } 4108: 129: h->heap[k]=val; -: 130:#ifdef DEBUG -: 131: if (!_heap_test(h)) { printf ("oops - heap_add messed up the heap\n"); exit(1); } -: 132:#endif 4108: 133: return 1; -: 134:} -: 135: function ImagingQuantHeapTop called 0 returned 0% blocks executed 0% #####: 136:int ImagingQuantHeapTop(Heap *h,void **r) { #####: 137: if (!h->heapcount) { branch 0 never executed branch 1 never executed -: 138: return 0; -: 139: } #####: 140: *r=h->heap[1]; #####: 141: return 1; -: 142:} -: 143: function ImagingQuantHeapNew called 12 returned 100% blocks executed 80% 12: 144:Heap *ImagingQuantHeapNew(HeapCmpFunc cf) { -: 145: Heap *h; -: 146: -: 147: /* malloc check ok, small constant allocation */ 12: 148: h=malloc(sizeof(Heap)); 12: 149: if (!h) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 150: return NULL; -: 151: } 12: 152: h->heapsize=INITIAL_SIZE; -: 153: /* malloc check ok, using calloc for overflow */ 12: 154: h->heap=calloc(h->heapsize, sizeof(void *)); 12: 155: if (!h->heap) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 156: free(h); #####: 157: return NULL; -: 158: } 12: 159: h->heapcount=0; 12: 160: h->cf=cf; 12: 161: return h; -: 162:} <<<<<< EOF # path=/home/travis/build/python-pillow/Pillow/src#libImaging#EpsEncode.c.gcov -: 0:Source:src/libImaging/EpsEncode.c -: 0:Graph:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/EpsEncode.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/src/libImaging/EpsEncode.gcda -: 0:Runs:3 -: 0:Programs:1 -: 1:/* -: 2: * The Python Imaging Library. -: 3: * $Id$ -: 4: * -: 5: * encoder for EPS hex data -: 6: * -: 7: * history: -: 8: * 96-04-19 fl created -: 9: * 96-06-27 fl don't drop last block of encoded data -: 10: * -: 11: * notes: -: 12: * FIXME: rename to HexEncode.c ?? -: 13: * -: 14: * Copyright (c) Fredrik Lundh 1996. -: 15: * Copyright (c) Secret Labs AB 1997. -: 16: * -: 17: * See the README file for information on usage and redistribution. -: 18: */ -: 19: -: 20: -: 21:#include "Imaging.h" -: 22: -: 23: -: 24:int function ImagingEpsEncode called 81 returned 100% blocks executed 100% 81: 25:ImagingEpsEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) -: 26:{ -: 27: enum { HEXBYTE=1, NEWLINE }; 81: 28: const char *hex = "0123456789abcdef"; -: 29: 81: 30: UINT8* ptr = buf; -: 31: UINT8* in, i; -: 32: 81: 33: if (!state->state) { branch 0 taken 25% (fallthrough) branch 1 taken 75% 20: 34: state->state = HEXBYTE; 20: 35: state->xsize *= im->pixelsize; /* Hack! */ -: 36: } -: 37: 81: 38: in = (UINT8*) im->image[state->y]; -: 39: -: 40: for (;;) { -: 41: 2206269: 42: if (state->state == NEWLINE) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 56563: 43: if (bytes < 1) { branch 0 taken 100% (fallthrough) branch 1 taken 0% -: 44: break; -: 45: } 56563: 46: *ptr++ = '\n'; 56563: 47: bytes--; 56563: 48: state->state = HEXBYTE; -: 49: } -: 50: 2206269: 51: if (bytes < 2) { branch 0 taken 99% (fallthrough) branch 1 taken 1% -: 52: break; -: 53: } -: 54: 2206208: 55: i = in[state->x++]; 2206208: 56: *ptr++ = hex[(i>>4)&15]; 2206208: 57: *ptr++ = hex[i&15]; 2206208: 58: bytes -= 2; -: 59: -: 60: /* Skip junk bytes */ 2206208: 61: if (im->bands == 3 && (state->x & 3) == 3) { branch 0 taken 46% (fallthrough) branch 1 taken 54% branch 2 taken 33% (fallthrough) branch 3 taken 67% 340224: 62: state->x++; -: 63: } -: 64: 2206208: 65: if (++state->count >= 79/2) { branch 0 taken 3% (fallthrough) branch 1 taken 97% 56563: 66: state->state = NEWLINE; 56563: 67: state->count = 0; -: 68: } -: 69: 2206208: 70: if (state->x >= state->xsize) { branch 0 taken 99% branch 1 taken 1% (fallthrough) 3544: 71: state->x = 0; 3544: 72: if (++state->y >= state->ysize) { branch 0 taken 1% (fallthrough) branch 1 taken 99% 20: 73: state->errcode = IMAGING_CODEC_END; 20: 74: break; -: 75: } 3524: 76: in = (UINT8*) im->image[state->y]; -: 77: } -: 78: -: 79: } -: 80: 81: 81: return ptr - buf; -: 82: -: 83:} <<<<<< 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-aarch64-3.6/src/libImaging/codec_fd.gcno -: 0:Data:/home/travis/build/python-pillow/Pillow/build/temp.linux-aarch64-3.6/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: 69: 29: Py_DECREF(result); branch 0 taken 58% (fallthrough) branch 1 taken 42% call 2 returned 100% 69: 30: return length; -: 31: -: 32: err: #####: 33: Py_DECREF(result); branch 0 never executed branch 1 never executed call 2 never executed -: 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: 54: 48: Py_DECREF(byteObj); branch 0 taken 100% (fallthrough) branch 1 taken 0% call 2 returned 100% 54: 49: Py_DECREF(result); branch 0 taken 24% (fallthrough) branch 1 taken 76% call 2 returned 100% -: 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: 40: 62: Py_DECREF(result); branch 0 taken 68% (fallthrough) branch 1 taken 33% call 2 returned 100% 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: 33: 76: Py_DECREF(result); branch 0 taken 61% (fallthrough) branch 1 taken 39% call 2 returned 100% 33: 77: return location; -: 78:} <<<<<< EOF # pa