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

Implement functional VP8 encoder with spec-compliant bitstream output#12

Open
Copilot wants to merge 14 commits intomasterfrom
copilot/implement-vp8-encoder-csharp
Open

Implement functional VP8 encoder with spec-compliant bitstream output#12
Copilot wants to merge 14 commits intomasterfrom
copilot/implement-vp8-encoder-csharp

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 2, 2026

Implements a working VP8 encoder capable of producing valid bitstreams for keyframes using intra-prediction. The encoder was initially producing frames that failed decode with VPX_CODEC_MEM_ERROR due to bitstream format violations.

Implementation

Core Encoder (vp8_encoder.cs)

  • Frame header encoding (uncompressed + compressed per VP8 spec)
  • Keyframe encoding with DC prediction mode
  • Forward DCT transform and quantization
  • Y2 block encoding with Walsh-Hadamard transform for 16x16 prediction modes
  • Coefficient tokenization with boolean entropy encoding
  • Two-pass macroblock encoding: modes first, then token data

Bitstream Format Fixes

  • Dimensions encoded as (width-1, height-1) per spec
  • Y mode uses 3-bit DC_PRED encoding (tree: 1,0,0)
  • UV mode uses 1-bit DC_PRED encoding (tree: 0)
  • Proper plane types: Y2=1, Y_AC=0, UV=3
  • Added mb_no_coeff_skip flag before macroblock data
  • Correct token/EOB encoding for coefficient blocks

Integration (VP8Codec.cs)

  • Wired encoder into EncodeVideo() method
  • Configurable quantizer (0-63) for quality control

Usage

var encoder = new VP8Encoder(640, 480);
encoder.SetQuantizer(10);  // Lower = better quality
byte[] encoded = encoder.EncodeFrame(i420Data);

// Or via VP8Codec
var codec = new VP8Codec();
byte[] encoded = codec.EncodeVideo(width, height, pixels, pixelFormat, codec);

Limitations

  • Keyframes only (no inter-frame prediction)
  • DC prediction mode (simplest intra mode)
  • Single partition

Files Changed

  • src/vp8_encoder.cs - Complete encoder implementation
  • src/VP8Codec.cs - Integration
  • src/onyxe_int.cs - Encoder structures
  • src/fdctllm.cs - Forward DCT
  • src/quantize.cs - Quantization
  • test/VP8.Net.UnitTest/VP8EncoderWorkingTest.cs - Tests
  • Supporting documentation files

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 2, 2026 10:16
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
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 [WIP] Add simple VP8 encoder in C# to match decoder Add VP8 encoder infrastructure and core components Feb 2, 2026
Copilot AI requested a review from sipsorcery February 2, 2026 10:23
Copilot AI and others added 2 commits February 2, 2026 10:32
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 Add VP8 encoder infrastructure and core components Implement functional VP8 encoder with keyframe support Feb 2, 2026
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Implement functional VP8 encoder with keyframe support Correct author attribution in encoder files Feb 2, 2026
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
@sipsorcery sipsorcery marked this pull request as ready for review February 2, 2026 11:07
Copilot AI and others added 2 commits February 2, 2026 17:57
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 Correct author attribution in encoder files Fix VP8 encoder bitstream format issues for WebRTC compatibility Feb 2, 2026
Copilot AI requested a review from sipsorcery February 2, 2026 18:01
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Fix VP8 encoder bitstream format issues for WebRTC compatibility Implement VP8 encoder with keyframe support (WIP - bitstream compatibility issue) Feb 2, 2026
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Implement VP8 encoder with keyframe support (WIP - bitstream compatibility issue) Implement VP8 encoder with keyframe support Feb 2, 2026
Co-authored-by: sipsorcery <197660+sipsorcery@users.noreply.github.com>
Copilot AI changed the title Implement VP8 encoder with keyframe support Implement functional VP8 encoder with spec-compliant bitstream output Feb 2, 2026
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.

2 participants