TUT HEVC Encoder
Loading...
Searching...
No Matches
Macros | Functions
search_intra.c File Reference
#include "search_intra.h"
#include <limits.h>
#include "cabac.h"
#include "encoder.h"
#include "encoderstate.h"
#include "image.h"
#include "intra.h"
#include "kvazaar.h"
#include "rdo.h"
#include "search.h"
#include "strategies/strategies-picture.h"
#include "videoframe.h"
Include dependency graph for search_intra.c:

Macros

#define TRSKIP_RATIO   1.7
 
#define PARALLEL_BLKS   2
 
#define PARALLEL_BLKS   2
 

Functions

static uint8_t select_best_mode_index (const int8_t *modes, const double *costs, uint8_t length)
 Select mode with the smallest cost.
 
static double get_cost (encoder_state_t *const state, kvz_pixel *pred, kvz_pixel *orig_block, cost_pixel_nxn_func *satd_func, cost_pixel_nxn_func *sad_func, int width)
 Calculate quality of the reconstruction.
 
static void get_cost_dual (encoder_state_t *const state, const pred_buffer preds, const kvz_pixel *orig_block, cost_pixel_nxn_multi_func *satd_twin_func, cost_pixel_nxn_multi_func *sad_twin_func, int width, double *costs_out)
 Calculate quality of the reconstruction.
 
static double search_intra_trdepth (encoder_state_t *const state, int x_px, int y_px, int depth, int max_depth, int intra_mode, int cost_treshold, cu_info_t *const pred_cu, lcu_t *const lcu)
 Perform search for best intra transform split configuration.
 
static void search_intra_chroma_rough (encoder_state_t *const state, int x_px, int y_px, int depth, const kvz_pixel *orig_u, const kvz_pixel *orig_v, int16_t origstride, kvz_intra_references *refs_u, kvz_intra_references *refs_v, int8_t luma_mode, int8_t modes[5], double costs[5])
 
static int8_t search_intra_rough (encoder_state_t *const state, kvz_pixel *orig, int32_t origstride, kvz_intra_references *refs, int log2_width, int8_t *intra_preds, int8_t modes[35], double costs[35])
 Order the intra prediction modes according to a fast criteria.
 
static int8_t search_intra_rdo (encoder_state_t *const state, int x_px, int y_px, int depth, kvz_pixel *orig, int32_t origstride, int8_t *intra_preds, int modes_to_check, int8_t modes[35], double costs[35], lcu_t *lcu)
 Find best intra mode out of the ones listed in parameter modes.
 
double kvz_luma_mode_bits (const encoder_state_t *state, int8_t luma_mode, const int8_t *intra_preds)
 
double kvz_chroma_mode_bits (const encoder_state_t *state, int8_t chroma_mode, int8_t luma_mode)
 
int8_t kvz_search_intra_chroma_rdo (encoder_state_t *const state, int x_px, int y_px, int depth, int8_t intra_mode, int8_t modes[5], int8_t num_modes, lcu_t *const lcu)
 
int8_t kvz_search_cu_intra_chroma (encoder_state_t *const state, const int x_px, const int y_px, const int depth, lcu_t *lcu)
 
void kvz_search_cu_intra (encoder_state_t *const state, const int x_px, const int y_px, const int depth, lcu_t *lcu, int8_t *mode_out, double *cost_out)
 Update lcu to have best modes at this depth.
 

Macro Definition Documentation

◆ PARALLEL_BLKS [1/2]

#define PARALLEL_BLKS   2

◆ PARALLEL_BLKS [2/2]

#define PARALLEL_BLKS   2

◆ TRSKIP_RATIO

#define TRSKIP_RATIO   1.7

Function Documentation

◆ get_cost()

static double get_cost ( encoder_state_t *const  state,
kvz_pixel pred,
kvz_pixel orig_block,
cost_pixel_nxn_func satd_func,
cost_pixel_nxn_func sad_func,
int  width 
)
static
Parameters
predPredicted pixels in continous memory.
orig_blockOrignal (target) pixels in continous memory.
satd_funcSATD function for this block size.
sad_funcSAD function this block size.
widthPixel width of the block.
Returns
Estimated RD cost of the reconstruction and signaling the coefficients of the residual.
Here is the caller graph for this function:

◆ get_cost_dual()

static void get_cost_dual ( encoder_state_t *const  state,
const pred_buffer  preds,
const kvz_pixel orig_block,
cost_pixel_nxn_multi_func satd_twin_func,
cost_pixel_nxn_multi_func sad_twin_func,
int  width,
double costs_out 
)
static
Parameters
abc
Returns

Here is the caller graph for this function:

◆ kvz_chroma_mode_bits()

double kvz_chroma_mode_bits ( const encoder_state_t state,
int8_t  chroma_mode,
int8_t  luma_mode 
)
Here is the caller graph for this function:

◆ kvz_luma_mode_bits()

double kvz_luma_mode_bits ( const encoder_state_t state,
int8_t  luma_mode,
const int8_t intra_preds 
)
Here is the caller graph for this function:

◆ kvz_search_cu_intra()

void kvz_search_cu_intra ( encoder_state_t *const  state,
const int  x_px,
const int  y_px,
const int  depth,
lcu_t lcu,
int8_t mode_out,
double cost_out 
)
Returns
Cost of best mode.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_search_cu_intra_chroma()

int8_t kvz_search_cu_intra_chroma ( encoder_state_t *const  state,
const int  x_px,
const int  y_px,
const int  depth,
lcu_t lcu 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_search_intra_chroma_rdo()

int8_t kvz_search_intra_chroma_rdo ( encoder_state_t *const  state,
int  x_px,
int  y_px,
int  depth,
int8_t  intra_mode,
int8_t  modes[5],
int8_t  num_modes,
lcu_t *const  lcu 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_intra_chroma_rough()

static void search_intra_chroma_rough ( encoder_state_t *const  state,
int  x_px,
int  y_px,
int  depth,
const kvz_pixel orig_u,
const kvz_pixel orig_v,
int16_t  origstride,
kvz_intra_references refs_u,
kvz_intra_references refs_v,
int8_t  luma_mode,
int8_t  modes[5],
double  costs[5] 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_intra_rdo()

static int8_t search_intra_rdo ( encoder_state_t *const  state,
int  x_px,
int  y_px,
int  depth,
kvz_pixel orig,
int32_t  origstride,
int8_t intra_preds,
int  modes_to_check,
int8_t  modes[35],
double  costs[35],
lcu_t lcu 
)
static

This function perform intra search by doing full quantization, reconstruction and CABAC coding of coefficients. It is very slow but results in better RD quality than using just the rough search.

Parameters
x_pxLuma picture coordinate.
y_pxLuma picture coordinate.
origPointer to the top-left corner of current CU in the picture being encoded.
orig_strideStride of param orig.
recPointer to the top-left corner of current CU in the picture being encoded.
rec_strideStride of param rec.
intra_predsArray of the 3 predicted intra modes.
modes_to_checkHow many of the modes in param modes are checked.
[in]modesThe intra prediction modes that are to be checked.
[out]modesThe modes ordered according to their RD costs, from best to worst. The number of modes and costs output is given by parameter modes_to_check.
[out]costsThe RD costs of corresponding modes in param modes.
[out]lcuIf transform split searching is used, the transform split information for the best mode is saved in lcu.cu structure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_intra_rough()

static int8_t search_intra_rough ( encoder_state_t *const  state,
kvz_pixel orig,
int32_t  origstride,
kvz_intra_references refs,
int  log2_width,
int8_t intra_preds,
int8_t  modes[35],
double  costs[35] 
)
static

This function uses SATD to order the intra prediction modes. For 4x4 modes SAD might be used instead, if the cost given by SAD is much better than the one given by SATD, to take into account that 4x4 modes can be coded with transform skip. This version of the function calculates two costs simultaneously to better utilize large SIMD registers with AVX and newer extensions.

The modes are searched using halving search and the total number of modes that are tried is dependent on size of the predicted block. More modes are tried for smaller blocks.

Parameters
origPointer to the top-left corner of current CU in the picture being encoded.
orig_strideStride of param orig..
recPointer to the top-left corner of current CU in the picture being encoded.
rec_strideStride of param rec.
widthWidth of the prediction block.
intra_predsArray of the 3 predicted intra modes.
[out]modesThe modes ordered according to their RD costs, from best to worst. The number of modes and costs output is given by parameter modes_to_check.
[out]costsThe RD costs of corresponding modes in param modes.
Returns
Number of prediction modes in param modes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_intra_trdepth()

static double search_intra_trdepth ( encoder_state_t *const  state,
int  x_px,
int  y_px,
int  depth,
int  max_depth,
int  intra_mode,
int  cost_treshold,
cu_info_t *const  pred_cu,
lcu_t *const  lcu 
)
static

This function does a recursive search for the best intra transform split configuration for a given intra prediction mode.

Returns
RD cost of best transform split configuration. Splits in lcu->cu.
Parameters
depthCurrent transform depth.
max_depthDepth to which TR split will be tried.
intra_modeIntra prediction mode.
cost_tresholdRD cost at which search can be stopped.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_best_mode_index()

static uint8_t select_best_mode_index ( const int8_t modes,
const double costs,
uint8_t  length 
)
inlinestatic
Here is the caller graph for this function: