Skip to content

Instantly share code, notes, and snippets.

View LukeNewNew's full-sized avatar

Luke New LukeNewNew

View GitHub Profile
ffmpeg.exe -nostdin -hide_banner -loglevel error -i "%~1" -vf format=yuv420p10le -strict -1 -f yuv4mpegpipe - | SvtAv1EncApp.exe -i - --crf 36 --keyint 15s --preset 4 --enable-dlf 2 --enable-cdef 1 --enable-restoration 0 --enable-tf 0 --scd 1 --scm 0 --tune 3 --enable-variance-boost 1 --variance-octile 5 --film-grain 0 --film-grain-denoise 0 --enable-qm 1 --qm-min 3 --sharpness 2 --max-32-tx-size 1 --noise-norm-strength 1 --qp-scale-compress-strength 0 --progress 2 -b "%~dpn1_av1.ivf"
cmd

x264 Adaptive Quantization (AQ mode)

In x264, the --aq-mode option controls macroblock-level adaptive quantization. In mode 0 (disabled), all blocks use the frame’s base QP. In mode 1 (variance AQ) and mode 2 (auto-variance AQ), x264 measures each block’s activity (roughly its AC variance) to adjust its QP: complex blocks get higher QP (fewer bits) while flat/dark blocks get lower QP (more bits). The goal is to maintain overall bitrate while improving perceptual quality (less banding in flat areas). x264’s code was tuned so that AQ modes use roughly the same total bits as no-AQ (see comment in code). Below we detail each mode’s formula, code logic, and effects.

Mode 0: Disabled

AQ mode 0 turns off adaptive quantization. In this case x264 simply sets all MB-level offsets to zero. In code, if i_aq_mode==X264_AQ_NONE or strength=0, x264 does:

memset(frame->f_qp_offset, 0, mb_count*sizeof(float));

Of course. Here is a comprehensive summary of the packJPG v2.5k source code in English, detailing all the essential steps of its compression and decompression processes.

Introduction: The Core Value of packJPG

packJPG is a highly specialized, lossless re-compression utility designed exclusively for JPEG files. The term "lossless" here is critical: it does not mean converting the JPEG to a pixel-based format and then compressing it (like PNG). Instead, it means the program can take a JPEG file, compress it into a .pjg file, and then decompress it back into a JPEG file that is bitwise identical to the original. On average, it achieves a file size reduction of around 20%.

The program's effectiveness stems from its deep understanding and exploitation of the inherent inefficiencies within the standard JPEG compression scheme. While JPEG is excellent for lossy image compression, its final entropy coding stage (using Huffman coding) is not optimally efficient. packJPG replaces this with more advanced pr

.prose-slate, .prose-slate :not(.katex, .katex *) {
font-size: revert !important;
line-height: unset !important;
}
.whitespace-pre-wrap {
white-space: normal;
}
html body :not(.katex, .katex *) {
img[style][src^="data:"] {
margin: auto;
width: revert !important;
height: revert !important;
max-width: 100% !important;
max-height: 100% !important;
}
[data-message-author-role="user"] .bg-token-message-surface {
outline: 2px #d00000 solid
}
button.absolute.cursor-pointer:has(svg.icon-md.text-token-text-primary) {
display: none;
}
.text-token-text-secondary:has(.tabular-nums) {
background: #0f6c
}
.group\/conversation-turn [class*="turn-messages:opacity-100"] {

How to transcode Dolby Vision with correct color on non-Dolby device?

Below is a step‑by‑step workflow to “flatten” Dolby Vision into a single‑layer HDR10 (or SDR) encode that preserves the correct color on devices without Dolby Vision support.

At a high level, Dolby Vision streams consist of a backward‑compatible HDR10 base layer plus one or two enhancement layers (dynamic metadata) that non‑Dolby decoders ignore; our goal is to merge and tone‑map these into a single output the target device can render accurately.

1. Understand Dolby Vision’s Dual‑Layer Architecture

Dolby Vision encodes a mandatory HDR10 base layer plus one (Profile 8.1) or two (Profile 7.6) enhancement layers (RPU and optional MEL/FEL) carrying dynamic metadata.

/*
Y Combinator: From Factorial to Fixed-point Combinator
Modern JS Implementation
https://picasso250.github.io/2015/03/31/reinvent-y.html
https://gist.github.com/igstan/388351
*/
/* STEP 1: Basic recursive factorial */
const fact1 = n => n < 2 ? 1 : n * fact1(n - 1);
message-content.model-response-text .markdown h1,
message-content.model-response-text .markdown h2,
message-content.model-response-text .markdown h3,
message-content.model-response-text .markdown h4,
message-content.model-response-text .markdown h5,
message-content.model-response-text .markdown h6 {
font-size: revert !important;
line-height: 1.5em !important;
}
main:has(div.h-full.max-h-screen.min-h-screen.w-full div.flex.flex-col.items-start a[href^="/explore"].bg-token-bg-active) div[class^="absolute bottom-2 left-1/2 hidden w-full max-w-[800px] -translate-x-1/2 px-3 tablet:block tablet:left-[calc(var(--sidebar-width)+2*var(--sidebar-gap)+(100%-(var(--sidebar-width)+2*var(--sidebar-gap)))/2)] tablet:w-[calc(100%-(var(--sidebar-width)+2*var(--sidebar-gap)))]"]:has(textarea[placeholder^="Describe your"]) {
display: none !important
}
div[role="dialog"].dialog-content:has([style*="scrollbar-gutter"]) {
height: 100vh !important;
max-width: 100vw !important;
img, video {
object-fit: contain !important;
}