encoding.info
You are hereSourcePredictionTransformEntropy codingFiltersFramesDecisionsRate controlPerceptionQualityBitstreamSettingsEncoder map
Page 1 of 4 in In-loop filters

Deblocking and boundary strength

In-loop filters · concept · added 2026-11-15

In Brief:
Blocks are quantized separately, so their errors can meet as a small step along the block grid. A deblocking filter uses the reconstructed pixels and how the two blocks were coded to decide where to smooth such a step. It can also smooth real low-contrast detail.

Each block is transformed and quantized on its own, so two neighboring blocks can come back with different errors. Where they meet, the difference shows as a small step along the block grid. A deblocking filter smooths across a block edge when the step there looks like such an artifact, and leaves it alone when it looks like part of the picture.

Artifact or edge?

The filter never sees the source, so it has to judge from what the decoder has too. First, how the two blocks were coded gives the edge a boundary strength (bS): whether it may be filtered at all, and with which filter. Then the reconstructed pixels decide, line by line. One line of pixels crosses the edge: p0 and q0 touch the edge, p1 and q1 are the next ones out. In H.264's filter, as x264 implements it, a line is changed only if it passes three tests:

|p0 - q0| < alpha
|p1 - p0| < beta
|q1 - q0| < beta

A small step between two smooth sides passes: quantization could have made it. A large step fails the first test, and a busy side fails one of the others. Both thresholds come from tables indexed by the quantization parameter (QP), and they rise with it, because a coarser quantizer leaves larger steps.

Step of 8
100p3100p2100p1100p0108q0108q1108q2108q3
passes all three tests
Filtered
100p3100p2102p1103p0105q0106q1108q2108q3
teal: changed pixels
Step of 60
100p3100p2100p1100p0160q0160q1160q2160q3
fails the first test
Left alone
100p3100p2100p1100p0160q0160q1160q2160q3
no pixel changed
Worked example with x264's normal filter at alpha 40 and beta 10, the thresholds for QP 34. The dashed line is the block edge. The step of 8 is spread over four pixels; the step of 60 is at least alpha, so the filter does not touch it.

Try it on the cat

The cat is coded in 4×4 blocks at the quantizer step that QP nominally stands for, then filtered. Boundary strength is fixed, not on a slider: the picture is four intra macroblocks, so the 16-pixel edges between them have strength 4 and the 4×4 edges inside them strength 3. QP sets the quantizer and, through the tables, the thresholds. Both offsets sets the two offsets of x264's --deblock option to one value: each unit moves both table indexes by 2, and the alpha index also selects the normal filter's clipping limit. Error is the mean squared error against the source, in squared 8-bit levels: the average of the squared pixel differences, zero when the pictures are identical. The Changed panel marks in teal every pixel the filter altered.

34
← finer quantizercoarser quantizer →
0
← −6: filters less+6: filters more →
Source
Reconstructed
Deblocked
Changed
Alpha, beta
Changed, of 1,024
Error before
Error after
Simplified demo: the cat is invented, the transform is a floating-point 4×4 cosine transform, and every block is predicted as flat mid-gray. That isolates the filtering; it does not reproduce a real encoder's prediction choices. The filter arithmetic and its three tables are x264's, copied from common/deblock.c at the commit under Sources, for luma only. The picture is treated as four intra macroblocks: the 16-pixel macroblock edges get the strong filter and the 4×4 edges inside them get the normal filter at strength 3. Block edges are drawn only on the Changed panel (macroblock edges heavier), so any grid in the other panels is in the pixels. Mean squared error does not measure how visible the grid is.

For this cat:

Boundary strength in x264

The demo held fixed how the two blocks were coded, which says how likely an edge is to hold an artifact. x264 gives each 4-pixel piece of an edge a boundary strength from 0 to 4. For progressive video and the luma filters, the first row that applies is the one used; the demo reaches only the top two:

bSWhenFilter
4Macroblock edge, either side intraStrong
3Edge inside an intra macroblockNormal
2Either block has nonzero levelsNormal
1Different reference frames or motionNormal
0None of theseNone

"Different motion" means the two motion vectors differ by a full pixel or more horizontally (the vertical limit is a parameter). Strengths 1 to 3 share the normal filter and differ in a clipping limit, read from a third table by strength and index: p0 and q0 may move by at most that limit, plus one for each side that is itself smooth. The strong filter has no such limit and can rewrite three pixels on each side.

The settings

Trade-offs

Sources

Read 2026-11-15, at the commits linked.