TUT HEVC Encoder
Loading...
Searching...
No Matches
search.c File Reference
#include "search.h"
#include <limits.h>
#include <string.h>
#include "cabac.h"
#include "encoder.h"
#include "encode_coding_tree.h"
#include "imagelist.h"
#include "inter.h"
#include "intra.h"
#include "kvazaar.h"
#include "rdo.h"
#include "search_inter.h"
#include "search_intra.h"
#include "threadqueue.h"
#include "transform.h"
#include "videoframe.h"
#include "strategies/strategies-picture.h"
#include "strategies/strategies-quant.h"
Include dependency graph for search.c:

Macros

#define IN_FRAME(x, y, width, height, block_width, block_height)
 

Functions

static void copy_cu_info (int x_local, int y_local, int width, lcu_t *from, lcu_t *to)
 
static void copy_cu_pixels (int x_local, int y_local, int width, lcu_t *from, lcu_t *to)
 
static void copy_cu_coeffs (int x_local, int y_local, int width, lcu_t *from, lcu_t *to)
 
static void work_tree_copy_up (int x_local, int y_local, int depth, lcu_t *work_tree)
 Copy all non-reference CU data from next level to current level.
 
static void work_tree_copy_down (int x_local, int y_local, int depth, lcu_t *work_tree)
 Copy all non-reference CU data from current level to all lower levels.
 
void kvz_lcu_fill_trdepth (lcu_t *lcu, int x_px, int y_px, int depth, int tr_depth)
 
static void lcu_fill_cu_info (lcu_t *lcu, int x_local, int y_local, int width, int height, cu_info_t *cu)
 
static void lcu_fill_inter (lcu_t *lcu, int x_local, int y_local, int cu_width)
 
static void lcu_fill_cbf (lcu_t *lcu, int x_local, int y_local, int width, cu_info_t *cur_cu)
 
static double cu_zero_coeff_cost (const encoder_state_t *state, lcu_t *work_tree, const int x, const int y, const int depth)
 
double kvz_cu_rd_cost_luma (const encoder_state_t *const state, const int x_px, const int y_px, const int depth, const cu_info_t *const pred_cu, lcu_t *const lcu)
 Calculate RD cost for a Coding Unit.
 
double kvz_cu_rd_cost_chroma (const encoder_state_t *const state, const int x_px, const int y_px, const int depth, const cu_info_t *const pred_cu, lcu_t *const lcu)
 
static double cu_rd_cost_tr_split_accurate (const encoder_state_t *const state, const int x_px, const int y_px, const int depth, const cu_info_t *const pred_cu, lcu_t *const lcu)
 
static double calc_mode_bits (const encoder_state_t *state, const lcu_t *lcu, const cu_info_t *cur_cu, int x, int y)
 
void kvz_sort_modes (int8_t *__restrict modes, double *__restrict costs, uint8_t length)
 Sort modes and costs to ascending order according to costs.
 
void kvz_sort_keys_by_cost (unit_stats_map_t *__restrict map)
 Sort keys (indices) to ascending order according to costs.
 
static uint8_t get_ctx_cu_split_model (const lcu_t *lcu, int x, int y, int depth)
 
static double search_cu (encoder_state_t *const state, int x, int y, int depth, lcu_t *work_tree)
 Search every mode from 0 to MAX_PU_DEPTH and return cost of best mode.
 
static void init_lcu_t (const encoder_state_t *const state, const int x, const int y, lcu_t *lcu, const yuv_t *hor_buf, const yuv_t *ver_buf)
 Initialize lcu_t for search.
 
static void copy_lcu_to_cu_data (const encoder_state_t *const state, int x_px, int y_px, const lcu_t *lcu)
 Copy CU and pixel data to it's place in picture datastructure.
 
void kvz_search_lcu (encoder_state_t *const state, const int x, const int y, const yuv_t *const hor_buf, const yuv_t *const ver_buf)
 Search LCU for modes.
 

Variables

static const int INTRA_THRESHOLD = 8
 

Macro Definition Documentation

◆ IN_FRAME

#define IN_FRAME ( x,
y,
width,
height,
block_width,
block_height )
Value:
((x) >= 0 && (y) >= 0 \
&& (x) + (block_width) <= (width) \
&& (y) + (block_height) <= (height))

Function Documentation

◆ calc_mode_bits()

static double calc_mode_bits ( const encoder_state_t * state,
const lcu_t * lcu,
const cu_info_t * cur_cu,
int x,
int y )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_cu_coeffs()

static void copy_cu_coeffs ( int x_local,
int y_local,
int width,
lcu_t * from,
lcu_t * to )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_cu_info()

static void copy_cu_info ( int x_local,
int y_local,
int width,
lcu_t * from,
lcu_t * to )
inlinestatic
Here is the caller graph for this function:

◆ copy_cu_pixels()

static void copy_cu_pixels ( int x_local,
int y_local,
int width,
lcu_t * from,
lcu_t * to )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_lcu_to_cu_data()

static void copy_lcu_to_cu_data ( const encoder_state_t *const state,
int x_px,
int y_px,
const lcu_t * lcu )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cu_rd_cost_tr_split_accurate()

static double cu_rd_cost_tr_split_accurate ( const encoder_state_t *const state,
const int x_px,
const int y_px,
const int depth,
const cu_info_t *const pred_cu,
lcu_t *const lcu )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cu_zero_coeff_cost()

static double cu_zero_coeff_cost ( const encoder_state_t * state,
lcu_t * work_tree,
const int x,
const int y,
const int depth )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ctx_cu_split_model()

static uint8_t get_ctx_cu_split_model ( const lcu_t * lcu,
int x,
int y,
int depth )
static
Here is the caller graph for this function:

◆ init_lcu_t()

static void init_lcu_t ( const encoder_state_t *const state,
const int x,
const int y,
lcu_t * lcu,
const yuv_t * hor_buf,
const yuv_t * ver_buf )
static
  • Copy reference CUs.
  • Copy reference pixels from neighbouring LCUs.
  • Copy reference pixels from this LCU.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_cu_rd_cost_chroma()

double kvz_cu_rd_cost_chroma ( const encoder_state_t *const state,
const int x_px,
const int y_px,
const int depth,
const cu_info_t *const pred_cu,
lcu_t *const lcu )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_cu_rd_cost_luma()

double kvz_cu_rd_cost_luma ( const encoder_state_t *const state,
const int x_px,
const int y_px,
const int depth,
const cu_info_t *const pred_cu,
lcu_t *const lcu )
Returns
Cost of block
Parameters
ref_cuCU used for prediction parameters.

Calculates the RDO cost of a single CU that will not be split further. Takes into account SSD of reconstruction and the cost of encoding whatever prediction unit data needs to be coded.

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

◆ kvz_lcu_fill_trdepth()

void kvz_lcu_fill_trdepth ( lcu_t * lcu,
int x_px,
int y_px,
int depth,
int tr_depth )
Here is the caller graph for this function:

◆ kvz_search_lcu()

void kvz_search_lcu ( encoder_state_t *const state,
const int x,
const int y,
const yuv_t *const hor_buf,
const yuv_t *const ver_buf )
  • Best mode gets copied to current picture.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_sort_keys_by_cost()

void kvz_sort_keys_by_cost ( unit_stats_map_t *__restrict map)
Here is the caller graph for this function:

◆ kvz_sort_modes()

void kvz_sort_modes ( int8_t *__restrict modes,
double *__restrict costs,
uint8_t length )
Here is the caller graph for this function:

◆ lcu_fill_cbf()

static void lcu_fill_cbf ( lcu_t * lcu,
int x_local,
int y_local,
int width,
cu_info_t * cur_cu )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lcu_fill_cu_info()

static void lcu_fill_cu_info ( lcu_t * lcu,
int x_local,
int y_local,
int width,
int height,
cu_info_t * cu )
static
Here is the caller graph for this function:

◆ lcu_fill_inter()

static void lcu_fill_inter ( lcu_t * lcu,
int x_local,
int y_local,
int cu_width )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_cu()

static double search_cu ( encoder_state_t *const state,
int x,
int y,
int depth,
lcu_t * work_tree )
static
  • The recursion is started at depth 0 and goes in Z-order to MAX_PU_DEPTH.
  • Data structure work_tree is maintained such that the neighbouring SCUs and pixels to the left and up of current CU are the final CUs decided via the search. This is done by copying the relevant data to all relevant levels whenever a decision is made whether to split or not.
  • All the final data for the LCU gets eventually copied to depth 0, which will be the final output of the recursion.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ work_tree_copy_down()

static void work_tree_copy_down ( int x_local,
int y_local,
int depth,
lcu_t * work_tree )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ work_tree_copy_up()

static void work_tree_copy_up ( int x_local,
int y_local,
int depth,
lcu_t * work_tree )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ INTRA_THRESHOLD

const int INTRA_THRESHOLD = 8
static