public void TestJpegLibraryEncode444()
        {
            var encoder = new JpegEncoder();

            encoder.SetQuantizationTable(JpegStandardQuantizationTable.ScaleByQuality(JpegStandardQuantizationTable.GetLuminanceTable(JpegElementPrecision.Precision8Bit, 0), 75));
            encoder.SetQuantizationTable(JpegStandardQuantizationTable.ScaleByQuality(JpegStandardQuantizationTable.GetChrominanceTable(JpegElementPrecision.Precision8Bit, 1), 75));
            encoder.SetHuffmanTable(true, 0, JpegStandardHuffmanEncodingTable.GetLuminanceDCTable());
            encoder.SetHuffmanTable(false, 0, JpegStandardHuffmanEncodingTable.GetLuminanceACTable());
            encoder.SetHuffmanTable(true, 1, JpegStandardHuffmanEncodingTable.GetChrominanceDCTable());
            encoder.SetHuffmanTable(false, 1, JpegStandardHuffmanEncodingTable.GetChrominanceACTable());
            encoder.AddComponent(1, 0, 0, 0, 1, 1); // Y component
            encoder.AddComponent(2, 1, 1, 1, 1, 1); // Cb component
            encoder.AddComponent(3, 1, 1, 1, 1, 1); // Cr component

            byte[] ycbcr = ArrayPool <byte> .Shared.Rent(3 *_width *_height);

            try
            {
                JpegRgbToYCbCrConverter.Shared.ConvertRgba32ToYCbCr8(MemoryMarshal.AsBytes(_rgba.AsSpan()), ycbcr, _width * _height);
                encoder.SetInputReader(new JpegBufferInputReader(_width, _height, 3, ycbcr));

                using var bufferWriter = new NullBufferWriter();
                encoder.SetOutput(bufferWriter);

                encoder.Encode();
            }
            finally
            {
                ArrayPool <byte> .Shared.Return(ycbcr);
            }
        }
        public void TestJpegLibraryEncode420_NoBuffer()
        {
            var encoder = new JpegEncoder();

            encoder.SetQuantizationTable(JpegStandardQuantizationTable.ScaleByQuality(JpegStandardQuantizationTable.GetLuminanceTable(JpegElementPrecision.Precision8Bit, 0), 75));
            encoder.SetQuantizationTable(JpegStandardQuantizationTable.ScaleByQuality(JpegStandardQuantizationTable.GetChrominanceTable(JpegElementPrecision.Precision8Bit, 1), 75));
            encoder.SetHuffmanTable(true, 0, JpegStandardHuffmanEncodingTable.GetLuminanceDCTable());
            encoder.SetHuffmanTable(false, 0, JpegStandardHuffmanEncodingTable.GetLuminanceACTable());
            encoder.SetHuffmanTable(true, 1, JpegStandardHuffmanEncodingTable.GetChrominanceDCTable());
            encoder.SetHuffmanTable(false, 1, JpegStandardHuffmanEncodingTable.GetChrominanceACTable());
            encoder.AddComponent(1, 0, 0, 0, 1, 1); // Y component
            encoder.AddComponent(2, 1, 1, 1, 2, 2); // Cb component
            encoder.AddComponent(3, 1, 1, 1, 2, 2); // Cr component

            encoder.SetInputReader(new JpegRgbaInputReader(_width, _height, _rgba));

            using var bufferWriter = new NullBufferWriter();
            encoder.SetOutput(bufferWriter);

            encoder.Encode();
        }