Browse Source

Decode every AV1 tile superblock row

pull/2633/head
James Jackson-South 1 week ago
parent
commit
ed751cb3cc
  1. 37
      src/ImageSharp/Formats/Heif/Av1/Pipeline/Av1FrameDecoder.cs

37
src/ImageSharp/Formats/Heif/Av1/Pipeline/Av1FrameDecoder.cs

@ -111,40 +111,33 @@ internal class Av1FrameDecoder : IAv1FrameDecoder
/// <remarks>SVT-AV1: <c>decode_tile</c>.</remarks> /// <remarks>SVT-AV1: <c>decode_tile</c>.</remarks>
private void DecodeFrameTiles(int tileColumn) private void DecodeFrameTiles(int tileColumn)
{ {
int tileRowCount = this.frameHeader.TilesInfo.TileRowCount; ObuTileGroupHeader tileInfo = this.frameHeader.TilesInfo;
int tileCount = tileRowCount * this.frameHeader.TilesInfo.TileColumnCount; for (int tileRow = 0; tileRow < tileInfo.TileRowCount; tileRow++)
for (int row = 0; row < tileRowCount; row++)
{ {
// Tile row starts are signaled in 4x4 mode-info units. Convert to pixels and then to superblock rows // Tile boundaries are expressed in 4x4 mode-info units. Walk every superblock row between consecutive
// so the frame-level superblock store and the tile-local syntax address the same region. // boundaries; using only the tile-row index would reconstruct one row and leave taller tiles incomplete.
int superblockRowTileStart = this.frameHeader.TilesInfo.TileRowStartModeInfo[row] << Av1Constants.ModeInfoSizeLog2 >> int modeInfoRowStart = tileInfo.TileRowStartModeInfo[tileRow];
this.sequenceHeader.SuperblockSizeLog2; int modeInfoRowEnd = tileInfo.TileRowStartModeInfo[tileRow + 1];
int superblockRow = row + superblockRowTileStart; for (int modeInfoRow = modeInfoRowStart;
modeInfoRow < modeInfoRowEnd;
int modeInfoRow = superblockRow << this.sequenceHeader.SuperblockSizeLog2 >> Av1Constants.ModeInfoSizeLog2; modeInfoRow += this.sequenceHeader.SuperblockModeInfoSize)
{
// EbColorConfig* color_config = &dec_mod_ctxt->seq_header->color_config; int superblockRow = modeInfoRow / this.sequenceHeader.SuperblockModeInfoSize;
// svt_cfl_init(&dec_mod_ctxt->cfl_ctx, color_config); this.DecodeTileSuperblockRow(tileRow, tileColumn, modeInfoRow, superblockRow);
this.DecodeTileRow(row, tileColumn, modeInfoRow, superblockRow); }
} }
} }
/// <summary> /// <summary>
/// Reconstructs the superblocks in one tile row from left to right. /// Reconstructs one superblock row within a tile from left to right.
/// </summary> /// </summary>
/// <param name="tileRow">The zero-based tile-row index.</param> /// <param name="tileRow">The zero-based tile-row index.</param>
/// <param name="tileColumn">The zero-based tile-column index.</param> /// <param name="tileColumn">The zero-based tile-column index.</param>
/// <param name="modeInfoRow">The frame-relative row in 4x4 mode-info units.</param> /// <param name="modeInfoRow">The frame-relative row in 4x4 mode-info units.</param>
/// <param name="superblockRow">The frame-relative superblock row.</param> /// <param name="superblockRow">The frame-relative superblock row.</param>
/// <remarks>SVT-AV1: <c>decode_tile_row</c>.</remarks> /// <remarks>SVT-AV1: <c>decode_tile_row</c>.</remarks>
private void DecodeTileRow(int tileRow, int tileColumn, int modeInfoRow, int superblockRow) private void DecodeTileSuperblockRow(int tileRow, int tileColumn, int modeInfoRow, int superblockRow)
{ {
int superblockModeInfoSizeLog2 = this.sequenceHeader.SuperblockSizeLog2 - Av1Constants.ModeInfoSizeLog2;
int superblockRowTileStart = this.frameHeader.TilesInfo.TileRowStartModeInfo[tileRow] << Av1Constants.ModeInfoSizeLog2 >>
this.sequenceHeader.SuperblockSizeLog2;
int superblockRowInTile = superblockRow - superblockRowTileStart;
ObuTileGroupHeader tileInfo = this.frameHeader.TilesInfo; ObuTileGroupHeader tileInfo = this.frameHeader.TilesInfo;
for (int modeInfoColumn = tileInfo.TileColumnStartModeInfo[tileColumn]; modeInfoColumn < tileInfo.TileColumnStartModeInfo[tileColumn + 1]; for (int modeInfoColumn = tileInfo.TileColumnStartModeInfo[tileColumn]; modeInfoColumn < tileInfo.TileColumnStartModeInfo[tileColumn + 1];
modeInfoColumn += this.sequenceHeader.SuperblockModeInfoSize) modeInfoColumn += this.sequenceHeader.SuperblockModeInfoSize)

Loading…
Cancel
Save