Skip to content

Commit

Permalink
Format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xopok authored Sep 21, 2023
1 parent 0650312 commit 0452006
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/lib_ccx/mp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ static int process_avc_sample(struct lib_ccx_ctx *ctx, u32 timescale, GF_AVCConf
{
u32 nal_length;

if (i + c->nal_unit_size > s->dataLength) {
if (i + c->nal_unit_size > s->dataLength)
{
mprint("Corrupted packet detected in process_avc_sample. dataLength "
"%u is less than index %u + nal_unit_size %u. Ignoring.\n",
s->dataLength, i, c->nal_unit_size);
"%u is less than index %u + nal_unit_size %u. Ignoring.\n",
s->dataLength, i, c->nal_unit_size);
// The packet is likely corrupted, it's unsafe to read this many bytes
// even to detect the length of the next `nal`. Ignoring this error,
// hopefully the outer loop in `process_avc_track` can recover.
Expand All @@ -74,10 +75,11 @@ static int process_avc_sample(struct lib_ccx_ctx *ctx, u32 timescale, GF_AVCConf
}
const u32 previous_index = i;
i += c->nal_unit_size;
if (i + nal_length <= previous_index || i + nal_length > s->dataLength) {
if (i + nal_length <= previous_index || i + nal_length > s->dataLength)
{
mprint("Corrupted sample detected in process_avc_sample. dataLength %u "
"is less than index %u + nal_unit_size %u + nal_length %u. Ignoring.\n",
s->dataLength, previous_index, c->nal_unit_size, nal_length);
"is less than index %u + nal_unit_size %u + nal_length %u. Ignoring.\n",
s->dataLength, previous_index, c->nal_unit_size, nal_length);
// The packet is likely corrupted, it's unsafe to procell nal_length bytes
// because they are past the sample end. Ignoring this error, hopefully
// the outer loop in `process_avc_track` can recover.
Expand All @@ -87,7 +89,8 @@ static int process_avc_sample(struct lib_ccx_ctx *ctx, u32 timescale, GF_AVCConf
s_nalu_stats.total += 1;
temp_debug = 0;

if (nal_length > 0) {
if (nal_length > 0)
{
// s->data[i] is only relevant and safe to access here.
s_nalu_stats.type[s->data[i] & 0x1F] += 1;
do_NAL(enc_ctx, dec_ctx, (unsigned char *)&(s->data[i]), nal_length, sub);
Expand Down

0 comments on commit 0452006

Please sign in to comment.