Skip to content

Count the AMVD flag cost for same-ref compound and TIP modes - #5490

Merged
leolzhao merged 1 commit into
AOMediaCodec:av2-encfrom
yeqing-wu:fix/amvd-flag-cost
Oct 14, 2026
Merged

leolzhao merged 1 commit into
AOMediaCodec:av2-encfrom
yeqing-wu:fix/amvd-flag-cost

Conversation

@yeqing-wu

Copy link
Copy Markdown
Contributor

cost_prediction_mode() left out the adaptive MVD flag cost for same-ref compound modes and for TIP NEWMV, even though the flag is coded for every mode that allow_amvd_mode() accepts. The mode search tries both use_amvd values for these modes, so both were priced the same and the choice ignored the flag's rate.

Add the cost to those two returns, and only count it when enable_adaptive_mvd is on, which is when the flag is actually coded.

Anchor: commit 6169621
Speed 0 (cpu-used=0): VCWG CTC (130 frames, RA and LD)

1) RA
  +------------+-------+-------+-------+-------+------+------+
  | Class      |     Y |    Cb |    Cr |  wAvg | Enc% | Dec% |
  +------------+-------+-------+-------+-------+------+------+
  | A1         | -0.10 | -0.23 | -0.27 | -0.11 |  100 |  100 |
  | A2         | -0.14 |  0.03 | -0.19 | -0.13 |  100 |   99 |
  | A3         | -0.11 | -0.10 | -0.33 | -0.12 |  101 |   99 |
  | A4         |  0.04 |  0.02 |  0.47 |  0.05 |   99 |   99 |
  | A5         | -0.05 | -0.32 |  0.15 | -0.05 |  100 |   99 |
  | B1         | -0.06 | -0.15 |  0.02 | -0.06 |  100 |   99 |
  | B2         | -0.08 | -0.52 |  0.25 | -0.08 |  100 |  100 |
  | Avg w/o B2 | -0.09 | -0.09 | -0.09 | -0.09 |  100 |   99 |
  +------------+-------+-------+-------+-------+------+------+

2) LD
  +------------+-------+-------+-------+-------+------+------+
  | Class      |     Y |    Cb |    Cr |  wAvg | Enc% | Dec% |
  +------------+-------+-------+-------+-------+------+------+
  | A2         | -0.18 | -0.37 | -0.18 | -0.19 |  100 |  100 |
  | A3         | -0.28 | -0.52 | -0.28 | -0.29 |  100 |  100 |
  | A4         | -0.28 | -0.01 |  0.15 | -0.25 |  102 |  101 |
  | A5         | -0.50 | -0.08 | -0.96 | -0.50 |  101 |  101 |
  | B1         | -0.12 |  0.18 |  0.34 | -0.09 |  100 |  100 |
  | B2         |  0.05 |  0.02 |  0.52 |  0.07 |  101 |  100 |
  | Avg w/o B2 | -0.23 | -0.21 | -0.11 | -0.22 |  100 |  100 |
  +------------+-------+-------+-------+-------+------+------+

STATS_CHANGED

@yeqing-wu yeqing-wu changed the title Count the AMVD flag cost for same-ref compound and TIP modes DRAFT: Count the AMVD flag cost for same-ref compound and TIP modes Oct 5, 2026
@yeqing-wu

yeqing-wu commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello all, this PR is ready for review, could you please help review the code?

@urvangjoshi
urvangjoshi marked this pull request as draft October 13, 2026 18:24
@yeqing-wu yeqing-wu changed the title DRAFT: Count the AMVD flag cost for same-ref compound and TIP modes Count the AMVD flag cost for same-ref compound and TIP modes Oct 13, 2026
@urvangjoshi
urvangjoshi marked this pull request as ready for review October 13, 2026 22:52
@urvangjoshi

Copy link
Copy Markdown
Contributor

@leolzhao : could you review this one, as it's related to AMVD?

@urvangjoshi
urvangjoshi removed their request for review October 13, 2026 23:03
@yeqing-wu

Copy link
Copy Markdown
Contributor Author

@leolzhao and @yunqingwang1 , could you please help review this PR?

cost_prediction_mode() left out the adaptive MVD flag cost for
same-ref compound modes and for TIP NEWMV, even though the flag is coded
for every mode that allow_amvd_mode() accepts. The mode search tries
both use_amvd values for these modes, so both were priced the same and
the choice ignored the flag's rate.

Add the cost to those two returns, and only count it when
enable_adaptive_mvd is on, which is when the flag is actually coded.

Anchor: commit 6169621
Speed 0 (cpu-used=0): VCWG CTC (130 frames, RA and LD)

```
1) RA
  +------------+-------+-------+-------+-------+------+------+
  | Class      |     Y |    Cb |    Cr |  wAvg | Enc% | Dec% |
  +------------+-------+-------+-------+-------+------+------+
  | A1         | -0.10 | -0.23 | -0.27 | -0.11 |  100 |  100 |
  | A2         | -0.14 |  0.03 | -0.19 | -0.13 |  100 |   99 |
  | A3         | -0.11 | -0.10 | -0.33 | -0.12 |  101 |   99 |
  | A4         |  0.04 |  0.02 |  0.47 |  0.05 |   99 |   99 |
  | A5         | -0.05 | -0.32 |  0.15 | -0.05 |  100 |   99 |
  | B1         | -0.06 | -0.15 |  0.02 | -0.06 |  100 |   99 |
  | B2         | -0.08 | -0.52 |  0.25 | -0.08 |  100 |  100 |
  | Avg w/o B2 | -0.09 | -0.09 | -0.09 | -0.09 |  100 |   99 |
  +------------+-------+-------+-------+-------+------+------+

2) LD
  +------------+-------+-------+-------+-------+------+------+
  | Class      |     Y |    Cb |    Cr |  wAvg | Enc% | Dec% |
  +------------+-------+-------+-------+-------+------+------+
  | A2         | -0.18 | -0.37 | -0.18 | -0.19 |  100 |  100 |
  | A3         | -0.28 | -0.52 | -0.28 | -0.29 |  100 |  100 |
  | A4         | -0.28 | -0.01 |  0.15 | -0.25 |  102 |  101 |
  | A5         | -0.50 | -0.08 | -0.96 | -0.50 |  101 |  101 |
  | B1         | -0.12 |  0.18 |  0.34 | -0.09 |  100 |  100 |
  | B2         |  0.05 |  0.02 |  0.52 |  0.07 |  101 |  100 |
  | Avg w/o B2 | -0.23 | -0.21 | -0.11 | -0.22 |  100 |  100 |
  +------------+-------+-------+-------+-------+------+------+
```

STATS_CHANGED
@leolzhao
leolzhao merged commit 89eae12 into AOMediaCodec:av2-enc Oct 14, 2026
8 checks passed
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