Skip to content

Commit

Permalink
formats: Add support for very small NAL units
Browse files Browse the repository at this point in the history
With this commit, every NAL unit size should be supported.
  • Loading branch information
jrsnen committed Nov 23, 2022
1 parent e223402 commit 5ca3c13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/formats/h266.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace uvgrtp {
enum H266_NAL_TYPES {
H266_TRAIL_NUT = 0,
H266_IDR_W_RADL = 7,
H266_PKT_AGGR = 28, // not implemented yet
H266_PKT_AGGR = 28,
H266_PKT_FRAG = 29
};

Expand Down
10 changes: 3 additions & 7 deletions src/formats/h26x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ssize_t uvgrtp::formats::h26x::find_h26x_start_code(

uint64_t prefetch64 = UINT64_MAX;

while (pos + 8 <= len) {
while (pos + 4 <= len) {

if (!prev_had_zero)
{
Expand All @@ -172,21 +172,17 @@ ssize_t uvgrtp::formats::h26x::find_h26x_start_code(
}
}

if (pos + 8 <= len)
if (pos + 4 <= len)
{
cur_value32 = *(uint32_t*)(data + pos);
}

if (cur_has_zero)
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
cur_has_zero = haszero32_le(cur_value32);
#else
cur_has_zero = haszero32_be(cur_value32);
#endif
}

if (prev_had_zero || cur_has_zero)
if ((prev_had_zero || cur_has_zero) && pos + 4 <= len)
{
/* Previous dword had zeros but this doesn't. The only way there might be a start code
* is if the most significant byte of current dword is 0x01 */
Expand Down

0 comments on commit 5ca3c13

Please sign in to comment.