virinext / hevcesbrowser

HEVCESBrowser is a tool for analyzing hevc(h265) bitstreams
GNU General Public License v2.0
338 stars 98 forks source link

bugfix when skipbits #20

Closed leeyeel closed 10 months ago

leeyeel commented 10 months ago

BitstreamReader.cpp

if(m_posInBase > num % 8)
    m_posInBase -= num % 8;
  else
  {
    m_posBase++;
    m_posInBase = m_posInBase - num % 8 + 8;
  }

Here if(m_posInBase > num % 8) should be if(m_posInBase >= num % 8). Fortunately, this minor bug has not caused any issues so far, because the function is only used in one place, where it skips an integer number of bytes.

virinext commented 10 months ago

Hi! Thank you! Your changes looks well. But I'm bit confused why this wasn't found before. I am using this analyzer on large database and doesn't found incorrect values. I will test this changes on my files database. Have you found this issue during analyzing HEVC files? If so, could you please share this file and incorrectly parsed fields with me?

leeyeel commented 10 months ago

Hi, I am parsing a file in Apple HEVC with alpha format, and since I am unable to parse this payloadType (165), I hope to skip the SEI payload and directly reach the end of NALU. However, even taking into account 'emulation prevention,' I am unable to correctly skip to the specified position, which is why I discovered this issue.

Here is the file I am using, although it does not trigger the bug, and I hope it will be helpful to you(The uploaded file is a HEVC bitstream file, regardless of its file extension). By the way, the hevcesbrowser tool is fantastic.

input.zip

virinext commented 10 months ago

I have tested and all works well. Thank you for your contribution!