Skip to content

Instantly share code, notes, and snippets.

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;
}
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;
}
/*
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);

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.

[data-turn-id] .user-message-bubble-color {
outline: 2px #d00000 solid
}
button.cursor-pointer.rounded-full[class*="bottom-[calc(var(--composer-overlap-px)+--spacing(6))]"]:has(svg) {
display: none;
}
.text-token-text-secondary:has(.tabular-nums) {
background: #0f6c
}
[class*="turn-messages"] {
img[style][src^="data:"] {
margin: auto;
width: revert !important;
height: revert !important;
max-width: 100% !important;
max-height: 100% !important;
}
.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 *) {

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

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-&gt;f_qp_offset, 0, mb_count*sizeof(float));

AVX2与AVX-512性能综合分析:增益、衰减与架构细微差异

第1节:矢量化的原理:从标量到SIMD的演进

1.1 标量处理的局限与SIMD的诞生

在现代计算体系中,性能提升是永恒的追求。传统上,处理器遵循一种被称为“标量处理”的模式,即一条指令在单个时钟周期内仅对一个或一对数据进行操作 。这种模式虽然直观且易于编程,但其性能存在一个固有的天花板。随着处理器时钟频率的增长逐渐放缓,单纯依靠提高频率来提升性能的路径变得难以为继。为了突破这一瓶颈,计算机体系结构引入了一种革命性的并行计算范式:单指令多数据流(Single Instruction, Multiple Data,简称SIMD)。

SIMD的核心思想是通过单条指令同时对多个数据元素执行相同的操作 。想象一下,需要将两个包含八个浮点数的数组逐元素相加。在标量模型下,这需要执行八次独立的加法指令。而在SIMD模型下,处理器可以使用一条矢量加法指令,在一个或少数几个时钟周期内完成所有八对元素的相加。这种数据级并行性(Data-Level Parallelism)极大地提高了计算密集型任务的吞吐量,尤其是在图形处理、科学计算和多媒体编解码等领域。