Skip to content

Add 12-bit profile (Main_4xx_12_IP2)#5112

Draft
xinzhao-apple wants to merge 2 commits into
AOMediaCodec:mainfrom
xinzhao-apple:contrib/avm-12bit-fix
Draft

Add 12-bit profile (Main_4xx_12_IP2)#5112
xinzhao-apple wants to merge 2 commits into
AOMediaCodec:mainfrom
xinzhao-apple:contrib/avm-12bit-fix

Conversation

@xinzhao-apple

Copy link
Copy Markdown
Contributor

This PR enables the 12-bit profile by default and brings its implementation into conformance with AV2 Spec Draft with 12-bit support: https://github.com/AOMediaCodec/av2-spec-internal/pull/776.

  1. Enable CONFIG_TESTONLY_12BIT_SUPPORT by default
  • Flips the 12-bit config default from 0 to 1 so 12-bit encode/decode is built in by default. (Superseded by the rename below; the flag is now CONFIG_12BIT_PROFILE.)
  1. Align MAIN_4xx_12_IP2 profile with AV2 spec Annex A
  • Renames CONFIG_TESTONLY_12BIT_SUPPORT to CONFIG_12BIT_PROFILE, and the profile enum TEST_ONLY_12BIT_PROFILE to MAIN_4xx_12_IP2 (spec Main_4xx_12_IP2, seq_profile_idc = 5).
  • Accepts 8/10/12-bit and all chroma formats (4:0:0/4:2:0/4:2:2/4:4:4) for profile 5, per Table A.1 (previously 8/10-bit were rejected).
  • Sets the max embedded-layer count for profile 5 to 3, matching its IOP2 limit (Table A.3).
  • Gives profile 5 its own PicSize/Bitrate factor row (36 / 3.0) per Table A.2.
  • Updates the in-code Annex A profile/config tables (A.1/A.2/A.5/A.6) and comments, including the bit_depth_idc mapping.

Flip the default for the 12-bit test-only profile from 0 to 1 so that
12-bit encode/decode is built in by default. Builds that explicitly
opt out can still pass -DCONFIG_TESTONLY_12BIT_SUPPORT=0.
@xinzhao-apple
xinzhao-apple marked this pull request as draft July 14, 2026 22:28

@wantehchang wantehchang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Xin: Thank you for writing this PR. I suggest some simple changes.

Comment thread av2/common/enums.h Outdated
Comment thread av2/common/annexA.c
*
* Notes:
* - seq_profile_idc: Allowed profile values
* - bit_depth_idc: 0=8-bit, 1=10-bit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Optional: It would be good to create a separate pull request to correct the comment error. The comment fix could then be cherry-picked to the normative branch.

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.

@urvangjoshi Any preference on this? I am good either way (include this change in a separate PR or keep it in this PR).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fine either way as well. Slight preference for a separate PR since this is a separate issue from this PR's intent.

Comment thread av2/common/annexA.c Outdated
if (profile == MAIN_4xx_12_IP2 && bit_depth == AVM_BITS_12) {
is_valid_bit_depth = 1;
}
#endif // CONFIG_12BIT_PROFILE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: I think it would be better to change check_bit_depth_8_10() to take the profile parameter as follows:

static int check_bit_depth_8_10(int bit_depth, BITSTREAM_PROFILE profile) {
  (void)profile;
  // All profiles support 8-bit and 10-bit. Profile MAIN_4xx_12_IP2
  // additionally supports 12-bit.
  if (bit_depth == AVM_BITS_8 || bit_depth == AVM_BITS_10) {
    return 1;
  }
#if CONFIG_12BIT_PROFILE
  if (profile == MAIN_4xx_12_IP2 && bit_depth == AVM_BITS_12) {
    return 1;
  }
#endif  // CONFIG_12BIT_PROFILE
  return 0;
}

Then here we can just say:

  int is_valid_bit_depth = check_bit_depth(bit_depth, profile);

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.

Thanks for the suggestion. Agreed this is better, updated this PR.

Comment thread av2/common/annexA.c
case MAIN_4xx_12_IP2:
// Supports all chroma formats (4:0:0/4:2:0/4:2:2/4:4:4) at 8/10/12-bit
break;
#endif // CONFIG_12BIT_PROFILE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: I suggest adding case MAIN_4xx_12_IP2 before case CONFIGURABLE

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.

Agreed and updated.

Comment thread av2/av2_cx_iface.c Outdated
@xinzhao-apple
xinzhao-apple force-pushed the contrib/avm-12bit-fix branch 4 times, most recently from 411bbea to 9527f14 Compare July 16, 2026 20:24
- Rename CONFIG_TESTONLY_12BIT_SUPPORT to CONFIG_12BIT_PROFILE and the
  profile enum to MAIN_4xx_12_IP2 (spec Main_4xx_12_IP2)
- Accept 8/10/12-bit and all chroma formats for profile 5
- Set max mlayer count for profile 5 to 3 (IOP2 limit)
- Give profile 5 its own PicSize/Bitrate factor row (36 / 3.0) per Table A.2
- Update Annex A profile/config tables and comments
@xinzhao-apple
xinzhao-apple force-pushed the contrib/avm-12bit-fix branch from 9527f14 to 7493fd0 Compare July 16, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants