Skip to content

Commit

Permalink
decoder: Compute AV1 tile offsets and sizes correctly
Browse files Browse the repository at this point in the history
The previous implementation was obviously wrong, as it could only handle
the single tile case (i.e. tileCount would always be 1 at the end of the
parsing).
  • Loading branch information
lolzballs authored and dabrain34 committed Sep 17, 2024
1 parent 7b7bc7c commit 8034cb6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions vk_video_decoder/libs/NvVideoParser/src/VulkanAV1Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2245,29 +2245,34 @@ bool VulkanAV1Decoder::ParseObuTileGroup(const AV1ObuHeader& hdr)
// Tile payload
int consumedBytes = (consumed_bits() + 7) / 8;
// offset of obu number of bytes read getting the tile data
m_PicData.tileOffsets[m_PicData.khr_info.tileCount] = m_nalu.start_offset + consumedBytes;

// Compute the tile group size
uint32_t totalTileSize = 0;
for (int TileNum = tg_start; TileNum <= tg_end; TileNum++)
{
int lastTile = TileNum == tg_end;
size_t tileSize = 0;

if (lastTile)
{
tileSize = hdr.payload_size - consumedBytes;
m_PicData.tileOffsets[m_PicData.khr_info.tileCount] = m_nalu.start_offset + consumedBytes;
}
else
{
uint64_t tile_size_minus_1 = le(tile_size_bytes_minus_1 + 1);

consumedBytes += tile_size_bytes_minus_1 + 1;
m_PicData.tileOffsets[m_PicData.khr_info.tileCount] = m_nalu.start_offset + consumedBytes;

tileSize = tile_size_minus_1 + 1;
consumedBytes += tileSize;

skip_bits(tileSize * 8);
}

totalTileSize += tileSize;
m_PicData.tileSizes[m_PicData.khr_info.tileCount] = tileSize;
m_PicData.khr_info.tileCount++;
}

m_PicData.tileSizes[m_PicData.khr_info.tileCount] = totalTileSize;
m_PicData.khr_info.tileCount++;
return (tg_end == num_tiles - 1);
}

Expand Down

0 comments on commit 8034cb6

Please sign in to comment.