<commit_before>﻿using System;
using System.IO;
using System.Threading.Tasks;
using FFImageLoading.Work;
using FFImageLoading.Config;
using FFImageLoading.Helpers;
using FFImageLoading.Extensions;

#if __MACOS__
using AppKit;
using PImage = AppKit.NSImage;
using WebPCodec = WebP.Mac.WebPCodec;
#elif __IOS__
using UIKit;
using PImage = UIKit.UIImage;
using WebPCodec = WebP.Touch.WebPCodec;
#endif

namespace FFImageLoading.Decoders
{
    public class WebPDecoder : IDecoder<PImage>
    {
        WebPCodec _decoder = new WebPCodec();

        public Task<IDecodedImage<PImage>> DecodeAsync(Stream stream, string path, ImageSource source, ImageInformation imageInformation, TaskParameter parameters)
        {
            var result = new DecodedImage<PImage>();
            result.Image = _decoder.Decode(stream);

            int downsampleWidth = parameters.DownSampleSize?.Item1 ?? 0;
            int downsampleHeight = parameters.DownSampleSize?.Item2 ?? 0;
            bool allowUpscale = parameters.AllowUpscale ?? Configuration.AllowUpscale;

            if (parameters.DownSampleUseDipUnits)
            {
                downsampleWidth = downsampleWidth.DpToPixels();<commit_msg>WebpP - don't instantiate right away<commit_after>﻿using System;
using System.IO;
using System.Threading.Tasks;
using FFImageLoading.Work;
using FFImageLoading.Config;
using FFImageLoading.Helpers;
using FFImageLoading.Extensions;

#if __MACOS__
using AppKit;
using PImage = AppKit.NSImage;
using WebPCodec = WebP.Mac.WebPCodec;
#elif __IOS__
using UIKit;
using PImage = UIKit.UIImage;
using WebPCodec = WebP.Touch.WebPCodec;
#endif

namespace FFImageLoading.Decoders
{
    public class WebPDecoder : IDecoder<PImage>
    {
        WebPCodec _decoder;

        public Task<IDecodedImage<PImage>> DecodeAsync(Stream stream, string path, ImageSource source, ImageInformation imageInformation, TaskParameter parameters)
        {
            if (_decoder == null)
                _decoder = new WebPCodec();

            var result = new DecodedImage<PImage>();
            result.Image = _decoder.Decode(stream);

            int downsampleWidth = parameters.DownSampleSize?.Item1 ?? 0;
            int downsampleHeight = parameters.DownSampleSize?.Item2 ?? 0;
            bool allowUpscale = parameters.AllowUpscale ?? Configuration.AllowUpscale;

            if (parameters.DownSampleUseDipUnits)
            {
                downsampleWidth = downsampleWidth.DpToPixels();
{'fraction_non_alphanumeric': 0.08319805194805195, 'fraction_numerical': 0.003246753246753247, 'mean_word_length': 3.4254937163375225, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '415105', 'n_tokens_mistral': 733, 'n_tokens_neox': 714, 'n_words': 165}