TUT HEVC Encoder
Loading...
Searching...
No Matches
Functions | Variables
filter.c File Reference
#include "filter.h"
#include <stdlib.h>
#include "cu.h"
#include "encoder.h"
#include "kvazaar.h"
#include "transform.h"
#include "videoframe.h"
Include dependency graph for filter.c:

Functions

static int kvz_filter_deblock_luma_strong (kvz_pixel *line, int32_t tc)
 Perform in strong luma filtering in place.
 
static int kvz_filter_deblock_luma_weak (const encoder_control_t *const encoder, kvz_pixel *line, int32_t tc, bool p_2nd, bool q_2nd)
 Perform in weak luma filtering in place.
 
static void kvz_filter_deblock_chroma (const encoder_control_t *const encoder, kvz_pixel *src, int32_t offset, int32_t tc, int8_t part_P_nofilter, int8_t part_Q_nofilter)
 
static bool is_tu_boundary (const encoder_state_t *const state, int32_t x, int32_t y, edge_dir dir)
 Check whether an edge is a TU boundary.
 
static bool is_pu_boundary (const encoder_state_t *const state, int32_t x, int32_t y, edge_dir dir)
 Check whether an edge is a PU boundary.
 
static bool is_on_8x8_grid (int x, int y, edge_dir dir)
 Check whether an edge is aligned on a 8x8 grid.
 
static int8_t get_qp_y_pred (const encoder_state_t *state, int x, int y, edge_dir dir)
 
static void gather_deblock_pixels (const kvz_pixel *src, int step, int stride, int reach, kvz_pixel *dst)
 Gather pixels needed for deblocking.
 
static void scatter_deblock_pixels (const kvz_pixel *src, int step, int stride, int reach, kvz_pixel *dst)
 Scatter pixels.
 
static void filter_deblock_edge_luma (encoder_state_t *const state, int32_t x, int32_t y, int32_t length, edge_dir dir, bool tu_boundary)
 Apply the deblocking filter to luma pixels on a single edge.
 
static void filter_deblock_edge_chroma (encoder_state_t *const state, int32_t x, int32_t y, int32_t length, edge_dir dir, bool tu_boundary)
 Apply the deblocking filter to chroma pixels on a single edge.
 
static void filter_deblock_unit (encoder_state_t *const state, int x, int y, int width, int height, edge_dir dir, bool tu_boundary)
 Filter edge of a single PU or TU.
 
static void filter_deblock_lcu_inside (encoder_state_t *const state, int32_t x, int32_t y, edge_dir dir)
 Deblock PU and TU boundaries inside an LCU.
 
static void filter_deblock_lcu_rightmost (encoder_state_t *const state, int32_t x_px, int32_t y_px)
 Filter rightmost 4 pixels of the horizontal egdes of an LCU.
 
void kvz_filter_deblock_lcu (encoder_state_t *const state, int x_px, int y_px)
 Deblock a single LCU without using data from right or down.
 

Variables

const uint8_t kvz_g_tc_table_8x8 [54]
 
const uint8_t kvz_g_beta_table_8x8 [52]
 
const int8_t kvz_g_luma_filter [4][8]
 
const int8_t kvz_g_chroma_filter [8][4]
 

Function Documentation

◆ filter_deblock_edge_chroma()

static void filter_deblock_edge_chroma ( encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  length,
edge_dir  dir,
bool  tu_boundary 
)
static

The caller should check that the edge is a TU boundary or a PU boundary.

        .-- filter this edge if dir == EDGE_HOR
        v
    +--------+
    |o <-- pixel at (x, y)
    |        |
    |<-- filter this edge if dir == EDGE_VER
    |        |
    +--------+
Parameters
stateencoder state
xx-coordinate in chroma pixels (see above)
yy-coordinate in chroma pixels (see above)
lengthlength of the edge in chroma pixels
dirdirection of the edge to filter
tu_boundarywhether the edge is a TU boundary
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_deblock_edge_luma()

static void filter_deblock_edge_luma ( encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  length,
edge_dir  dir,
bool  tu_boundary 
)
static

The caller should check that the edge is a TU boundary or a PU boundary.

        .-- filter this edge if dir == EDGE_HOR
        v
    +--------+
    |o <-- pixel at (x, y)
    |        |
    |<-- filter this edge if dir == EDGE_VER
    |        |
    +--------+
Parameters
stateencoder state
xx-coordinate in pixels (see above)
yy-coordinate in pixels (see above)
lengthlength of the edge in pixels
dirdirection of the edge to filter
tu_boundarywhether the edge is a TU boundary
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_deblock_lcu_inside()

static void filter_deblock_lcu_inside ( encoder_state_t *const  state,
int32_t  x,
int32_t  y,
edge_dir  dir 
)
static
Parameters
stateencoder state
x_pxblock x-position in pixels
y_pxblock y-position in pixels
dirdirection of the edges to filter

Recursively traverse the CU/TU quadtree. At the lowest level, apply the deblocking filter to the left edge (when dir == EDGE_VER) or the top edge (when dir == EDGE_HOR) as needed. Both luma and chroma are filtered.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_deblock_lcu_rightmost()

static void filter_deblock_lcu_rightmost ( encoder_state_t *const  state,
int32_t  x_px,
int32_t  y_px 
)
static
Parameters
stateencoder state
x_pxx-coordinate of the right edge of the LCU in pixels
y_pxy-coordinate of the top edge of the LCU in pixels
Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_deblock_unit()

static void filter_deblock_unit ( encoder_state_t *const  state,
int  x,
int  y,
int  width,
int  height,
edge_dir  dir,
bool  tu_boundary 
)
static
Parameters
stateencoder state
xblock x-position in pixels
yblock y-position in pixels
widthblock width in pixels
heightblock height in pixels
dirdirection of the edges to filter
tu_boundarywhether the edge is a TU boundary
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gather_deblock_pixels()

static void gather_deblock_pixels ( const kvz_pixel src,
int  step,
int  stride,
int  reach,
kvz_pixel dst 
)
inlinestatic
Here is the caller graph for this function:

◆ get_qp_y_pred()

static int8_t get_qp_y_pred ( const encoder_state_t state,
int  x,
int  y,
edge_dir  dir 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_on_8x8_grid()

static bool is_on_8x8_grid ( int  x,
int  y,
edge_dir  dir 
)
static
Parameters
xx-coordinate of the edge
yy-coordinate of the edge
dirdirection of the edge
Returns
true, if the edge is aligned on a 8x8 grid, otherwise false
Here is the caller graph for this function:

◆ is_pu_boundary()

static bool is_pu_boundary ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
edge_dir  dir 
)
static
Parameters
stateencoder state
xx-coordinate of the scu in pixels
yy-coordinate of the scu in pixels
dirdirection of the edge to check
Returns
true, if the edge is a TU boundary, otherwise false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_tu_boundary()

static bool is_tu_boundary ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
edge_dir  dir 
)
static
Parameters
stateencoder state
xx-coordinate of the scu in pixels
yy-coordinate of the scu in pixels
dirdirection of the edge to check
Returns
true, if the edge is a TU boundary, otherwise false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_filter_deblock_chroma()

static void kvz_filter_deblock_chroma ( const encoder_control_t *const  encoder,
kvz_pixel src,
int32_t  offset,
int32_t  tc,
int8_t  part_P_nofilter,
int8_t  part_Q_nofilter 
)
inlinestatic
Here is the caller graph for this function:

◆ kvz_filter_deblock_lcu()

void kvz_filter_deblock_lcu ( encoder_state_t *const  state,
int  x_px,
int  y_px 
)

Filter the following vertical edges (horizontal filtering):

  1. The left edge of the LCU.
  2. All vertical edges within the LCU.

Filter the following horizontal edges (vertical filtering):

  1. The rightmost 4 pixels of the top edge of the LCU to the left.
  2. The rightmost 4 pixels of all horizontal edges within the LCU to the left.
  3. The top edge and all horizontal edges within the LCU, excluding the rightmost 4 pixels. If the LCU is the rightmost LCU of the frame, the last 4 pixels are also filtered.

What is not filtered:

  • The rightmost 4 pixels of the top edge and all horizontal edges within the LCU, unless the LCU is the rightmost LCU of the frame.
  • The bottom edge of the LCU.
  • The right edge of the LCU.
Parameters
stateencoder state
x_pxx-coordinate of the left edge of the LCU in pixels
y_pxy-coordinate of the top edge of the LCU in pixels
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_filter_deblock_luma_strong()

static int kvz_filter_deblock_luma_strong ( kvz_pixel line,
int32_t  tc 
)
inlinestatic
Parameters
lineline of 8 pixels, with center at index 4
tctc treshold
Returns
Reach of the filter starting from center.
Here is the caller graph for this function:

◆ kvz_filter_deblock_luma_weak()

static int kvz_filter_deblock_luma_weak ( const encoder_control_t *const  encoder,
kvz_pixel line,
int32_t  tc,
bool  p_2nd,
bool  q_2nd 
)
inlinestatic
Parameters
encoderEncoder
lineLine of 8 pixels, with center at index 4
tcThe tc treshold
p_2ndWhether to filter the 2nd line of P
q_2ndWhether to filter the 2nd line of Q
Here is the caller graph for this function:

◆ scatter_deblock_pixels()

static void scatter_deblock_pixels ( const kvz_pixel src,
int  step,
int  stride,
int  reach,
kvz_pixel dst 
)
inlinestatic
Here is the caller graph for this function:

Variable Documentation

◆ kvz_g_beta_table_8x8

const uint8_t kvz_g_beta_table_8x8[52]
Initial value:
=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 20,
22, 24, 26, 28, 30, 32, 34, 36, 38, 40,
42, 44, 46, 48, 50, 52, 54, 56, 58, 60,
62, 64
}

◆ kvz_g_chroma_filter

const int8_t kvz_g_chroma_filter[8][4]
Initial value:
=
{
{ 0, 64, 0, 0 },
{ -2, 58, 10, -2 },
{ -4, 54, 16, -2 },
{ -6, 46, 28, -4 },
{ -4, 36, 36, -4 },
{ -4, 28, 46, -6 },
{ -2, 16, 54, -4 },
{ -2, 10, 58, -2 }
}

◆ kvz_g_luma_filter

const int8_t kvz_g_luma_filter[4][8]
Initial value:
=
{
{ 0, 0, 0, 64, 0, 0, 0, 0 },
{ -1, 4, -10, 58, 17, -5, 1, 0 },
{ -1, 4, -11, 40, 40, -11, 4, -1 },
{ 0, 1, -5, 17, 58, -10, 4, -1 }
}

◆ kvz_g_tc_table_8x8

const uint8_t kvz_g_tc_table_8x8[54]
Initial value:
=
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 3, 3, 3, 3, 4, 4, 4, 5, 5,
6, 6, 7, 8, 9, 10, 11, 13, 14, 16,
18, 20, 22, 24
}