Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Wrong value of max_sub_layers_minus1 in HEVC SPS Parser #270

Open
Nomidia opened this issue Jan 7, 2025 · 2 comments
Open

[BUG] Wrong value of max_sub_layers_minus1 in HEVC SPS Parser #270

Nomidia opened this issue Jan 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@Nomidia
Copy link
Contributor

Nomidia commented Jan 7, 2025

Logging
sps: 42 01 01 01 60 00 00 00 00 00 00 00 00 00 96 a0 03 c0 80 10 e5 8d ae 49 32 6b 96 70 08 00 00 1f 48 00 03 0e 08 40 b1 b6 30 00
pos: 4, sps_video_parameter_set_id = 4
pos: 7, sps_max_sub_layers_minus1 = 1

Describe the bug
When I refer to the code parseH265Sps, I found the extracted value of max_sub_layers_minus1 should be 0 instead of 1. But the later parameters of width and height are correct.

The parameter was incorrectly read from NAL header which is "0x42 0x01".

image
image

Compare to the the parser of H264, I think it's missing to read the nalu header like CHK_STATUS(bitReaderReadBits(&bitReader, 16, &read));

// Create a bit reader on top of the SPS
CHK_STATUS(bitReaderReset(&bitReader, pSps, spsSize * 8));
// Read the SPS Nalu
CHK_STATUS(bitReaderReadBits(&bitReader, 8, &read));
CHK(((read & 0x80) == 0) && ((read & 0x60) != 0) && ((read & 0x1f) == SPS_NALU_TYPE), STATUS_MKV_INVALID_H264_H265_SPS_NALU);

Since the wrong value of sps_max_sub_layers_minus1, it read more 2 bytes of the nalu, leading to getting parameters width and height in the correct position.

for (i = 0; i < pSpsInfo->max_sub_layers_minus1; i++) {
// Read the sub_layer_profile_present_flag[i]
CHK_STATUS(bitReaderReadBits(pBitReader, 1, &read));
subLayerProfilePresentFlags[i] = (read != 0);
// Read the sub_layer_level_present_flag[i]
CHK_STATUS(bitReaderReadBits(pBitReader, 1, &read));
subLayerLevelPresentFlags[i] = (read != 0);
}
if (pSpsInfo->max_sub_layers_minus1 > 0) {
for (i = pSpsInfo->max_sub_layers_minus1; i < 8; i++) {
// Read the reserved_zero_2bits[i]
CHK_STATUS(bitReaderReadBits(pBitReader, 2, &read));
// CHK(0 == read, STATUS_MKV_INVALID_HEVC_SPS_RESERVED);
}
}

SDK version number
1.2.0

@Nomidia Nomidia added the bug Something isn't working label Jan 7, 2025
@stefankiesz
Copy link
Contributor

Hi, can you please explain how this potential bug is affecting your use-case, and any errors if you are getting them, and are you using this library with KVS C or C++ Producer SDKs?

@Nomidia
Copy link
Contributor Author

Nomidia commented Jan 8, 2025

Since only the width and height of the video need to be obtained, there is no impact for the time being. I just want to remind you that the parsing process is wrong, although the width and height values ​​obtained are correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants