// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Formats.Jpg { using System.Buffers; /// /// A structure to store unprocessed instances and their coordinates while scanning the image. /// internal struct DecodedBlockMemento { /// /// A value indicating whether the instance is initialized. /// public bool Initialized; /// /// X coordinate of the current block, in units of 8x8. (The third block in the first row has (bx, by) = (2, 0)) /// public int Bx; /// /// Y coordinate of the current block, in units of 8x8. (The third block in the first row has (bx, by) = (2, 0)) /// public int By; /// /// The /// public Block8x8F Block; /// /// The used to pool data in . /// Should always clean arrays when returning! /// private static readonly ArrayPool ArrayPool = ArrayPool.Create(); /// /// Rent an array of -s from the pool. /// /// The requested array size /// An array of -s public static DecodedBlockMemento[] RentArray(int size) { return ArrayPool.Rent(size); } /// /// Returns the array to the pool. /// /// The array public static void ReturnArray(DecodedBlockMemento[] blockArray) { ArrayPool.Return(blockArray, true); } /// /// Store the block data into a at the given index. /// /// The array of /// The index in the array /// X coordinate of the block /// Y coordinate of the block /// The public static void Store(DecodedBlockMemento[] blockArray, int index, int bx, int by, ref Block8x8F block) { blockArray[index].Initialized = true; blockArray[index].Bx = bx; blockArray[index].By = by; blockArray[index].Block = block; } } }