{"id":50722610,"url":"https://github.com/rafaelcaricio/av2_demo","last_synced_at":"2026-06-10T01:30:37.621Z","repository":{"id":362461667,"uuid":"1176871005","full_name":"rafaelcaricio/av2_demo","owner":"rafaelcaricio","description":"Demo of AV2 av2codec is a from-scratch implementation of the AV2 video codec encoder in pure, safe Rust.","archived":false,"fork":false,"pushed_at":"2026-03-09T13:24:42.000Z","size":4118,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T11:05:43.164Z","etag":null,"topics":["av2","avm","codec","video"],"latest_commit_sha":null,"homepage":"https://rafaelcaricio.github.io/av2_demo/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafaelcaricio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-09T13:15:16.000Z","updated_at":"2026-05-15T10:39:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rafaelcaricio/av2_demo","commit_stats":null,"previous_names":["rafaelcaricio/av2_demo"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/rafaelcaricio/av2_demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelcaricio%2Fav2_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelcaricio%2Fav2_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelcaricio%2Fav2_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelcaricio%2Fav2_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafaelcaricio","download_url":"https://codeload.github.com/rafaelcaricio/av2_demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafaelcaricio%2Fav2_demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34133404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["av2","avm","codec","video"],"created_at":"2026-06-10T01:30:30.795Z","updated_at":"2026-06-10T01:30:37.616Z","avatar_url":"https://github.com/rafaelcaricio.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# av2codec — AV2 Video Codec Written in Rust\n\n**av2codec** is a from-scratch implementation of the AV2 video codec encoder in pure, safe Rust — zero `unsafe` code, zero C dependencies. This demo showcases the encoder running in the browser via WebAssembly.\n\nTo prove spec compliance, the encoded bitstream is decoded by the official **AVM reference decoder** (also compiled to WASM). Both encoding and decoding happen entirely in the browser — select a sample image or upload your own, adjust the quantization settings, and see the results instantly.\n\n## Architecture\n\n```\nBrowser\n  |\n  |-- av2codec encoder (Rust -\u003e WASM, ~154 KB)\n  |     RGB image -\u003e YUV 4:2:0 -\u003e AV2 bitstream\n  |\n  |-- AVM reference decoder (C -\u003e WASM, ~1.7 MB)\n  |     AV2 bitstream -\u003e YUV 4:2:0 -\u003e RGB -\u003e Canvas\n  |\n  |-- index.html\n        UI controls, sample images, canvas rendering\n```\n\n## Features\n\n- Select from 9 sample images or upload your own (max 2 MB, max 1024px)\n- Choose 8-bit or 10-bit quantization\n- Adjustable quantization index (QIndex 1-255)\n- Side-by-side original vs. encoded/decoded comparison\n- Encode/decode timing and compression statistics\n\n## Prerequisites\n\n- **Rust** (with `wasm32-unknown-unknown` target): `rustup target add wasm32-unknown-unknown`\n- **wasm-pack**: `cargo install wasm-pack` (or see https://rustwasm.github.io/wasm-pack/installer/)\n- **Emscripten SDK** (`emcc`, `emcmake`, `emmake`): https://emscripten.org/docs/getting_started/downloads.html\n- **CMake** (3.16+)\n- **AV2 reference source code** (the `av2/` AVM repository): https://gitlab.com/AOMediaCodec/avm\n\n## Directory Layout\n\n```\nav2codec_demo/\n  Cargo.toml              # Rust crate (encoder WASM bindings)\n  src/lib.rs              # Encoder: RGB-\u003eYUV + av2codec encode, exposed via wasm-bindgen\n  decoder_wasm/\n    avmdec_wasm.c          # Thin C wrapper around AVM reference decoder API\n    build.sh               # Emscripten build script for the reference decoder\n  web/\n    index.html             # Demo page (single-file HTML + JS)\n    samples/               # Sample PNG images\n    pkg/                   # [generated] Rust encoder WASM output (wasm-pack)\n    avmdec.js              # [generated] Emscripten JS glue for reference decoder\n    avmdec.wasm            # [generated] Reference decoder WASM binary\n```\n\n## Building\n\n### 1. Clone dependencies\n\nEnsure the following sibling directories exist relative to this project:\n\n```\nparent/\n  av2/          # AVM reference codec source (git clone from gitlab.com/AOMediaCodec/avm)\n  wav2c/        # av2codec encoder (Rust library)\n  av2codec_demo/  # This project\n```\n\n### 2. Build the encoder (Rust -\u003e WASM)\n\n```bash\ncd av2codec_demo\nwasm-pack build --target web --out-dir web/pkg --release\n```\n\nThis compiles the av2codec encoder to WebAssembly and outputs the JS bindings + `.wasm` file into `web/pkg/`.\n\n### 3. Build the reference decoder (C -\u003e WASM)\n\n```bash\ncd decoder_wasm\nbash build.sh\n```\n\nThis does two things:\n1. Cross-compiles the AVM reference decoder library (`libavm.a`) using Emscripten with decoder-only configuration (no encoder, no threads, no SIMD, no tests)\n2. Compiles `avmdec_wasm.c` (our thin wrapper) and links it with `libavm.a` to produce `web/avmdec.js` + `web/avmdec.wasm`\n\nThe AV2 source location defaults to `../av2/` relative to this project. Override it with the `AV2_SRC` environment variable:\n\n```bash\nAV2_SRC=/path/to/av2 bash build.sh\n```\n\nThe `libavm.a` build is cached in `decoder_wasm/build/`. Delete that directory to force a full rebuild.\n\n### 4. Add sample images\n\nCopy sample PNG images into `web/samples/`. The demo expects these files:\n\n```\nflowers.png  city.png  dog.png  sunset.png  waves.png\nbulb.png  house.png  night.png  guitar.png\n```\n\nThe sample images are from the [GB82 Image Set](https://github.com/gianni-rosato/gb82-image-set) by Gianni Rosato.\n\n### 5. Serve and open\n\nAny static HTTP server works. For example:\n\n```bash\ncd web\npython3 -m http.server 8080\n```\n\nThen open http://localhost:8080 in a browser.\n\n## How It Works\n\n1. The user selects or uploads an image\n2. The image is drawn to a canvas and its RGBA pixel data is extracted\n3. **Encoding** (Rust WASM): RGBA pixels are converted to YUV 4:2:0 and encoded into an AV2 bitstream using `av2codec::Encoder`\n4. **Decoding** (C WASM): The bitstream is passed to the AVM reference decoder (`avmdec`), which decodes it back to YUV and converts to RGBA\n5. The decoded RGBA data is rendered on a second canvas for side-by-side comparison\n6. Statistics (encode/decode time, bitstream size, compression ratio) are displayed\n\n## Rebuilding After Changes\n\n| What changed | Rebuild command |\n|---|---|\n| Rust encoder code (`src/lib.rs`) | `wasm-pack build --target web --out-dir web/pkg --release` |\n| C decoder wrapper (`decoder_wasm/avmdec_wasm.c`) | `cd decoder_wasm \u0026\u0026 bash build.sh` |\n| AVM reference source (`../av2/`) | `rm -rf decoder_wasm/build \u0026\u0026 cd decoder_wasm \u0026\u0026 bash build.sh` |\n| HTML/JS (`web/index.html`) | Just reload the browser |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelcaricio%2Fav2_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafaelcaricio%2Fav2_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafaelcaricio%2Fav2_demo/lists"}