Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/oapv_vlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ static int dec_vlc_read_1bit_read(oapv_bs_t *bs)
}
else {
k++;
oapv_assert_rv(k < 30, -1);
}
}
}
Expand Down Expand Up @@ -733,6 +734,7 @@ static int dec_vlc_read(oapv_bs_t *bs, int k)
break;
}
else {
oapv_assert_rv(k < 31, -1);
symbol += (1 << k);
k++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/oapv_vlc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "oapv_metadata.h"

#define KPARAM_DC(level) oapv_min((level)>>1, OAPV_KPARAM_DC_MAX)
#define KPARAM_AC(level) oapv_min((level)>>2, OAPV_KPARAM_AC_MAX)
#define KPARAM_AC(level) oapv_clip3(OAPV_KPARAM_AC_MIN, OAPV_KPARAM_AC_MAX, (level)>>2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Level is always positive and monotonically increasing. Camparing with min value is not required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it overflows. This code prevents crash (because of MIN_INT) in case of (unintended overflow)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is difficult to understand why it can prevent crash. as I mentioned, level is always positive. and it is limited to some value.

#define KPARAM_RUN(run) oapv_min((run)>>2, OAPV_KPARAM_RUN_MAX)

void oapve_set_frame_header(oapve_ctx_t * ctx, oapv_fh_t * fh);
Expand Down