From 4c019f5056eca26eb70af70a165bb158e00aef51 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Sun, 21 Jul 2024 21:44:28 +0200 Subject: [PATCH] Bug fixes in TileDecoder, inspired by libgav1 --- .../Formats/Heif/Av1/Tiling/Av1TileDecoder.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Heif/Av1/Tiling/Av1TileDecoder.cs b/src/ImageSharp/Formats/Heif/Av1/Tiling/Av1TileDecoder.cs index 278eb4dbb..830f3c645 100644 --- a/src/ImageSharp/Formats/Heif/Av1/Tiling/Av1TileDecoder.cs +++ b/src/ImageSharp/Formats/Heif/Av1/Tiling/Av1TileDecoder.cs @@ -99,15 +99,15 @@ internal class Av1TileDecoder : IAv1TileDecoder } Av1TileInfo tileInfo = new(tileRowIndex, tileColumnIndex, this.FrameInfo); - Av1BlockSize superBlockSize = this.SequenceHeader.Use128x128Superblock ? Av1BlockSize.Block128x128 : Av1BlockSize.Block64x64; - int superBlock4x4Size = superBlockSize.Get4x4WideCount(); - for (int row = modeInfoRowStart; row < modeInfoRowEnd; row += this.SequenceHeader.SuperblockModeInfoSize) + Av1BlockSize superBlockSize = this.SequenceHeader.SuperblockSize; + int superBlock4x4Size = this.SequenceHeader.SuperblockSizeLog2; + for (int row = modeInfoRowStart; row < modeInfoRowEnd; row += superBlock4x4Size) { - int superBlockRow = row << Av1Constants.ModeInfoSizeLog2 >> this.SequenceHeader.SuperblockSizeLog2; + int superBlockRow = (row << Av1Constants.ModeInfoSizeLog2) >> superBlock4x4Size; this.leftNeighborContext.Clear(this.SequenceHeader); - for (int column = modeInfoColumnStart; column < modeInfoColumnEnd; column += this.SequenceHeader.SuperblockModeInfoSize) + for (int column = modeInfoColumnStart; column < modeInfoColumnEnd; column += superBlock4x4Size) { - int superBlockColumn = column << Av1Constants.ModeInfoSizeLog2 >> this.SequenceHeader.SuperblockSizeLog2; + int superBlockColumn = (column << Av1Constants.ModeInfoSizeLog2) >> superBlock4x4Size; Point superblockPosition = new(superBlockColumn, superBlockRow); Av1SuperblockInfo superblockInfo = this.FrameBuffer.GetSuperblock(superblockPosition);