/// <inheritdoc/>
        protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span <byte> buffer)
        {
            if (this.jpegTables != null)
            {
                using var jpegDecoder = new JpegDecoderCore(this.configuration, new JpegDecoder());

                // TODO: Should we pass through the CancellationToken from the tiff decoder?
                // If the PhotometricInterpretation is YCbCr we explicitly assume the JPEG data is in RGB color space.
                // There seems no other way to determine that the JPEG data is RGB colorspace (no APP14 marker, componentId's are not RGB).
                using SpectralConverter <Rgb24> spectralConverter = this.photometricInterpretation == TiffPhotometricInterpretation.YCbCr ?
                                                                    new RgbJpegSpectralConverter <Rgb24>(this.configuration, CancellationToken.None) : new SpectralConverter <Rgb24>(this.configuration, CancellationToken.None);
                var scanDecoder = new HuffmanScanDecoder(stream, spectralConverter, CancellationToken.None);
                jpegDecoder.LoadTables(this.jpegTables, scanDecoder);
                scanDecoder.ResetInterval = 0;
                jpegDecoder.ParseStream(stream, scanDecoder, CancellationToken.None);

                using var image = new Image <Rgb24>(this.configuration, spectralConverter.PixelBuffer, new ImageMetadata());
                CopyImageBytesToBuffer(buffer, image);
            }
            else
            {
                using var image = Image.Load <Rgb24>(stream);
                CopyImageBytesToBuffer(buffer, image);
            }
        }