Skip to content

Instantly share code, notes, and snippets.

View cynthia2006's full-sized avatar

Cynthia cynthia2006

  • India
View GitHub Profile
@cynthia2006
cynthia2006 / VMAF.md
Last active September 21, 2026 04:13

VMAF: Measuring Encoder Performance

VMAF is a ML (machine learning) model[^0] that computes several traditional metrics across frames, aggregates results, and computes a single score between 0 and 100. Developed by Netflix, it explicitly targets human perception of video quality degradation when viewed at a nominal distance on TV, mobiles or 4K displays.

A encoded video and a reference video is required for comparison. In all practical scenarios, the reference video is the source video that was encoded. The reference video is often the highest quality (e.g. archival grade/master) version of the video in question.

Important Notes

  • Choosing a right model:[^5] Using the wrong model will inflate or deflate the true results. Such as a Mobile/4K model used for HD comparison inflates results. By default, HD model is chosen.
  • Frame alignment and resolution sensitivity: Encode and the reference must have the same resolution, frame rate[^1], pixel format, and the frames must h
@cynthia2006
cynthia2006 / vhs.cpp
Last active September 3, 2026 14:33
Cheap emulation of a VHS tape
// clang++ -Wall -O2 -pedantic -shared -o vhs.so vhs.cxx -Wl,-z,relro,-z,now -fvisibility=hidden -fvisibility-inlines-hidden -fno-plt -fPIC -fno-rtti -fno-exceptions -fuse-ld=lld -flto=thin
#include <algorithm>
#include <array>
#include <random>
#include <cstdint>
#include "frei0r.hpp"
@cynthia2006
cynthia2006 / line-draw.cc
Created July 24, 2026 15:23
Anti-aliased line-drawing toy program
#include <vector>
#include <SDL3/SDL.h>
#include "SDL3_gfxPrimitives.h"
struct PointPair {
SDL_Point begin, end;
// Constructor required for emplace_back(); not POD.
PointPair(SDL_Point a, SDL_Point b): begin(a), end(b) {}
@cynthia2006
cynthia2006 / lolicon.go
Created July 24, 2026 12:12
HTTP/3 accelarated fastest Lolicon downloader
package main
import (
"crypto/tls"
"encoding/json"
"io"
"log"
"net/http"
"net/url"
"os"

I don’t enjoy coding Python. I think its:

  • Syntax is awkward. The strife between tabs and spaces is real, and sometimes annoying too, if you’re making quick edits without using a sophisticated code editor.
  • Lambda functions are limited to a single line. Let’s be real—naming things is hard, and I wouldn’t want to name every multi-line anonymous function some awkward name.
  • API is inconsistent.
    • len(v) is a function (procedural), but v.append() is a method (object-oriented). And, more interestingly, len(v) calls v.__len__() under the hood.
    • One argument could be raised that it’s procedural to distinguish its polymorphic nature, but that argument is inevitably weak, because duck typing—a method often pursued—could be used (e.g. v.length) to determine its length.
    • Another argument could be raised that it enforces a certain protocol of determining length, but that argument is also weak, because the protocol could just be defined differently.
  • Features like namedtuples are somewhat
@cynthia2006
cynthia2006 / fd.md
Created April 27, 2026 09:28
A complete summary of the fd(1) tool.

fd

  • GNU find(1) is bloated and slow; fd(1) is the fast, modern and less-cluttered option.
  • Regular expressions by default, globbing when advanced options not needed.
  • Adheres to global/local ignore files (.gitignore, .ignore or .fdignore files), also excluding hidden files/folders.
  • Has several convenience functions included for ease of use.
  • Syntax for the command line. Similar to find, path defaults to the current directory if left empty or . is used; difference however is that instead of -name or -path options, pattern becomes a positional argument, which indeed covers most usecases.
      fd [options] [pattern [path]]
    
  • Search patterns

@cynthia2006
cynthia2006 / Summary of Format Specification.md
Last active March 22, 2026 06:18
A complete summary of format-specifiers in Python

Format strings (str.format() or format(), extended to f-strings and t-strings) are based off of format specification mini-language which is made up of replacement fields where values are substituted in.

  • Replacement fields are surrounded with {} ({} itself is escaped with {{}}), and begin with a field name, optionally followed by a conversion field (preceded by !), and a format specification (preceded by :).
  • A field name consists of an argument name, which is a number or an identifier (specifying the kwarg), and infinitely nested attribute accesses (e.g. .a.b.c), indexing ([0][1][2]), or a combination of the two (e.g. [0].a[1].b[2].c).
    • If a format string consists only of numbers in sequence (excluding attribute access and indexing), they could be omitted.
  • A conversion field is used if the str() value (!s), or a repr() value (!r) is needed.
  • A format specification is used to format the value in a specific manner; its syntax is s
# /// script
# requires-python = ">=3.14"
# dependencies = [
# "aiofiles>=25.1.0",
# "httpx[http2]>=0.28.1",
# ]
# ///
import asyncio
import sys

Criticism of Rust

Rust is all about grand narratives—fearless concurrency, memory safety, zero-cost abstractions, and all that jazz. But does it hold up altogether or crumble under its own weight of deceptive marketing?

Myth of Zero-Cost Abstractions

There's nothing such as zero-cost abstractions. Any abstraction, no matter how transparent, brings both a performance and cognitive penalty. It applies not only to Rust, but also to carcinogens like C++.

Cognitive penalty is especially applicable to bindings that dramatically change the original paradigm of the underlying library without (properly) documenting it; in that case, source code must be read to ascertain correct behaviour. This needless effort makes abstractions not zero-cost, but sometimes more cost than if you had just used the library without the binding.

AV1 (AOMedia Video 1) is a next-generation video codec to facilitate VOD (video on demand), storage and live-streaming, as you might already know. It is usually stored in the WebM container, accompanied by Opus as the audio codec. Both are royalty-free codecs; i.e. you need not pay to use them unlike H.264 or H.265; latter of which was the reason AV1 was made, for it was encumbered in a complex web of patents. There are several AV1 encoders to choose from, such as—aomenc, rav1e, SVT-AV1. Although all provide a more-or-less same level of functionality, SVT-AV1 is notable for its speed and scalability.

This is largely a primer meant to familiarise you with some rudimentary aspects of AV1 encoding, which avoids some of the more advanced topics such as—film grain synthesis, variance boost, hierarchical levels, temporal filtering, etc. There's a dedicated community around the codec that document best practises for high-quality encodes.

Presets

Presets are a set of preconfigured encoder options deciding