Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

Fix VP8 encoder mode/coefficient ordering to match decoder expectations#13

Draft
Copilot wants to merge 11 commits intomasterfrom
copilot/na
Draft

Fix VP8 encoder mode/coefficient ordering to match decoder expectations#13
Copilot wants to merge 11 commits intomasterfrom
copilot/na

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 14, 2026

VP8 decoder reads all macroblock modes via vp8_decode_mode_mvs() before reading any coefficients via decode_mb_rows(). The encoder was interleaving mode and coefficient writes per macroblock, causing decoder rejection.

Changes

Restructured keyframe encoding into two phases:

  • Phase 1: Write Y-mode and UV-mode for all macroblocks using vp8_treed_write() with proper probability trees
  • Phase 2: Write coefficient data (16 Y + 4 U + 4 V blocks) for all macroblocks

Created vp8e_encode_macroblock_coeffs() to separate coefficient encoding from mode encoding logic.

// Before: interleaved per macroblock
for (mb_row...) {
  for (mb_col...) {
    encode_mode_and_coeffs(mb);  // Wrong order
  }
}

// After: two-phase encoding
for (mb_row...) {
  for (mb_col...) {
    write_ymode(); write_uvmode();  // Phase 1: all modes
  }
}
for (mb_row...) {
  for (mb_col...) {
    write_all_coeffs();  // Phase 2: all coefficients
  }
}

Frame structure verified: partition size correctly calculated, boolean encoder writing to proper buffer offset, tree-based mode encoding producing correct bit sequences.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] n/a No changes required - problem statement is a question about AI model Feb 14, 2026
Copilot AI requested a review from sipsorcery February 14, 2026 15:55
Copilot AI and others added 4 commits February 14, 2026 16:01
…and tokenization

Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
…g encoding

Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title No changes required - problem statement is a question about AI model Implement VP8 encoder with keyframe support Feb 14, 2026
Copilot AI and others added 2 commits February 14, 2026 19:13
…dual computation

Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
…bits

Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Implement VP8 encoder with keyframe support Implement VP8 encoder macroblock processing with DCT, quantization, and frame headers Feb 14, 2026
Copilot AI and others added 2 commits February 14, 2026 19:27
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Implement VP8 encoder macroblock processing with DCT, quantization, and frame headers Implement VP8 encoder token encoding and frame structure Feb 14, 2026
Copilot AI and others added 2 commits February 14, 2026 19:43
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Implement VP8 encoder token encoding and frame structure Fix VP8 encoder mode/coefficient ordering to match decoder expectations Feb 14, 2026
@paulomorgado
Copy link
Copy Markdown

Do not use byte[] or byte*. Use Span<byte> or ReadOnlySpan<byte> instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants