Skip to content

fix AC coefficient range check - #289

Merged
kpchoi merged 1 commit into
AcademySoftwareFoundation:mainfrom
gn-ahn:fix_ac_coeff_range
Sep 28, 2026
Merged

kpchoi merged 1 commit into
AcademySoftwareFoundation:mainfrom
gn-ahn:fix_ac_coeff_range

Conversation

@gn-ahn

@gn-ahn gn-ahn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

According to the specification (RFC 9924):

  • The reconstructed transform coefficients must be in the range of [-32768, 32767] ([MIN_TX_VAL, MAX_TX_VAL]).

Problem

Previously, the range check was performed on level before applying the sign bit (if (level > 32767)).
This caused a valid reconstructed AC coefficient of -32768 (level == 32768 with flag == 1) to be incorrectly rejected as OAPV_ERR_MALFORMED_BITSTREAM.

Solution

  • Moved the range check after sign parsing (oapv_set_sign16).
  • Validated the reconstructed signed AC coefficient (val) against [MIN_TX_VAL, MAX_TX_VAL] ([-32768, 32767]).

Check reconstructed AC coefficient against [-32768, 32767]

Signed-off-by: gn-ahn <earbuds@naver.com>

@kpchoi kpchoi left a comment

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.

Good point.
LGTM

@kpchoi
kpchoi merged commit 3ccfe23 into AcademySoftwareFoundation:main Sep 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants