TUT HEVC Encoder
Data Structures | Macros | Functions
inter.c File Reference
#include "inter.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "encoder.h"
#include "imagelist.h"
#include "strategies/generic/picture-generic.h"
#include "strategies/strategies-ipol.h"
#include "videoframe.h"
#include "strategies/strategies-picture.h"
Include dependency graph for inter.c:

Data Structures

struct  merge_candidates_t
 

Macros

#define NUM_PRIORITY_LIST   12;
 

Functions

static void inter_recon_frac_luma (const encoder_state_t *const state, const kvz_picture *const ref, int32_t xpos, int32_t ypos, int32_t block_width, int32_t block_height, const int16_t mv_param[2], yuv_t *out, unsigned out_stride)
 
static void inter_recon_frac_luma_hi (const encoder_state_t *const state, const kvz_picture *const ref, int32_t xpos, int32_t ypos, int32_t block_width, int32_t block_height, const int16_t mv_param[2], yuv_im_t *out, const unsigned out_stride)
 
static void inter_recon_frac_chroma (const encoder_state_t *const state, const kvz_picture *const ref, int32_t pu_x, int32_t pu_y, int32_t pu_w, int32_t pu_h, const int16_t mv_param[2], yuv_t *out, const unsigned out_stride)
 
static void inter_recon_frac_chroma_hi (const encoder_state_t *const state, const kvz_picture *const ref, int32_t pu_x, int32_t pu_y, int32_t pu_w, int32_t pu_h, const int16_t mv_param[2], yuv_im_t *out, const unsigned out_stride)
 
static void inter_cp_with_ext_border (const kvz_pixel *ref_buf, int ref_stride, int ref_width, int ref_height, kvz_pixel *rec_buf, int rec_stride, int width, int height, const vector2d_t *mv_in_frame)
 Copy from frame with extended border. More...
 
static unsigned inter_recon_unipred (const encoder_state_t *const state, const kvz_picture *const ref, int32_t pu_x, int32_t pu_y, int32_t pu_w, int32_t pu_h, int32_t out_stride_luma, const int16_t mv_param[2], yuv_t *yuv_px, yuv_im_t *yuv_im, bool predict_luma, bool predict_chroma)
 Reconstruct an inter PU using uniprediction. More...
 
void kvz_inter_recon_bipred (const encoder_state_t *const state, const kvz_picture *ref1, const kvz_picture *ref2, int32_t pu_x, int32_t pu_y, int32_t pu_w, int32_t pu_h, int16_t mv_param[2][2], lcu_t *lcu, bool predict_luma, bool predict_chroma)
 Reconstruct bi-pred inter PU. More...
 
void kvz_inter_recon_cu (const encoder_state_t *const state, lcu_t *lcu, int32_t x, int32_t y, int32_t width, bool predict_luma, bool predict_chroma)
 Reconstruct a single CU. More...
 
void kvz_inter_pred_pu (const encoder_state_t *const state, lcu_t *lcu, int32_t x, int32_t y, int32_t width, bool predict_luma, bool predict_chroma, int i_pu)
 Predict a single PU. More...
 
static void inter_clear_cu_unused (cu_info_t *cu)
 Clear unused L0/L1 motion vectors and reference. More...
 
static bool is_a0_cand_coded (int x, int y, int width, int height)
 Check whether a0 mv cand block is coded before the current block. More...
 
static bool is_b0_cand_coded (int x, int y, int width, int height)
 Check whether b0 mv cand block is coded before the current block. More...
 
static void get_temporal_merge_candidates (const encoder_state_t *const state, int32_t x, int32_t y, int32_t width, int32_t height, uint8_t ref_list, uint8_t ref_idx, merge_candidates_t *cand_out)
 Get merge candidates for current block. More...
 
static void get_spatial_merge_candidates (int32_t x, int32_t y, int32_t width, int32_t height, int32_t picture_width, int32_t picture_height, lcu_t *lcu, merge_candidates_t *cand_out)
 Get merge candidates for current block. More...
 
static void get_spatial_merge_candidates_cua (const cu_array_t *cua, int32_t x, int32_t y, int32_t width, int32_t height, int32_t picture_width, int32_t picture_height, merge_candidates_t *cand_out)
 Get merge candidates for current block. More...
 
static int16_t get_scaled_mv (int16_t mv, int scale)
 
static void apply_mv_scaling_pocs (int32_t current_poc, int32_t current_ref_poc, int32_t neighbor_poc, int32_t neighbor_ref_poc, int16_t mv_cand[2])
 
static void apply_mv_scaling (const encoder_state_t *state, const cu_info_t *current_cu, const cu_info_t *neighbor_cu, int8_t current_reflist, int8_t neighbor_reflist, int16_t mv_cand[2])
 
static bool add_temporal_candidate (const encoder_state_t *state, uint8_t current_ref, const cu_info_t *colocated, int32_t reflist, int16_t mv_out[2])
 Try to add a temporal MVP or merge candidate. More...
 
static bool add_mvp_candidate (const encoder_state_t *state, const cu_info_t *cur_cu, const cu_info_t *cand, int8_t reflist, bool scaling, int16_t mv_cand_out[2])
 
static void get_mv_cand_from_candidates (const encoder_state_t *const state, int32_t x, int32_t y, int32_t width, int32_t height, const merge_candidates_t *merge_cand, const cu_info_t *const cur_cu, int8_t reflist, int16_t mv_cand[2][2])
 Pick two mv candidates from the spatial and temporal candidates. More...
 
void kvz_inter_get_mv_cand (const encoder_state_t *const state, int32_t x, int32_t y, int32_t width, int32_t height, int16_t mv_cand[2][2], const cu_info_t *const cur_cu, lcu_t *lcu, int8_t reflist)
 Get MV prediction for current block. More...
 
void kvz_inter_get_mv_cand_cua (const encoder_state_t *const state, int32_t x, int32_t y, int32_t width, int32_t height, int16_t mv_cand[2][2], const cu_info_t *cur_cu, int8_t reflist)
 Get MV prediction for current block using state->tile->frame->cu_array. More...
 
static bool is_duplicate_candidate (const cu_info_t *cu1, const cu_info_t *cu2)
 
static bool add_merge_candidate (const cu_info_t *cand, const cu_info_t *possible_duplicate1, const cu_info_t *possible_duplicate2, inter_merge_cand_t *merge_cand_out, uint8_t candidates, uint8_t max_num_cands)
 
uint8_t kvz_inter_get_merge_cand (const encoder_state_t *const state, int32_t x, int32_t y, int32_t width, int32_t height, bool use_a1, bool use_b1, inter_merge_cand_t mv_cand[5], lcu_t *lcu)
 Get merge predictions for current block. More...
 

Macro Definition Documentation

◆ NUM_PRIORITY_LIST

#define NUM_PRIORITY_LIST   12;

Function Documentation

◆ add_merge_candidate()

static bool add_merge_candidate ( const cu_info_t cand,
const cu_info_t possible_duplicate1,
const cu_info_t possible_duplicate2,
inter_merge_cand_t merge_cand_out,
uint8_t  candidates,
uint8_t  max_num_cands 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_mvp_candidate()

static bool add_mvp_candidate ( const encoder_state_t state,
const cu_info_t cur_cu,
const cu_info_t cand,
int8_t  reflist,
bool  scaling,
int16_t  mv_cand_out[2] 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_temporal_candidate()

static bool add_temporal_candidate ( const encoder_state_t state,
uint8_t  current_ref,
const cu_info_t colocated,
int32_t  reflist,
int16_t  mv_out[2] 
)
static
Parameters
stateencoder state
current_refindex of the picture referenced by the current CU
colocatedcolocated CU
reflisteither 0 (for L0) or 1 (for L1)
[out]mv_outReturns the motion vector
Returns
Whether a temporal candidate was added or not.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_mv_scaling()

static void apply_mv_scaling ( const encoder_state_t state,
const cu_info_t current_cu,
const cu_info_t neighbor_cu,
int8_t  current_reflist,
int8_t  neighbor_reflist,
int16_t  mv_cand[2] 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_mv_scaling_pocs()

static void apply_mv_scaling_pocs ( int32_t  current_poc,
int32_t  current_ref_poc,
int32_t  neighbor_poc,
int32_t  neighbor_ref_poc,
int16_t  mv_cand[2] 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_mv_cand_from_candidates()

static void get_mv_cand_from_candidates ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
const merge_candidates_t merge_cand,
const cu_info_t *const  cur_cu,
int8_t  reflist,
int16_t  mv_cand[2][2] 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_scaled_mv()

static int16_t get_scaled_mv ( int16_t  mv,
int  scale 
)
inlinestatic
Here is the caller graph for this function:

◆ get_spatial_merge_candidates()

static void get_spatial_merge_candidates ( int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
int32_t  picture_width,
int32_t  picture_height,
lcu_t lcu,
merge_candidates_t cand_out 
)
static

The output parameters b0, b1, b2, a0, a1 are pointed to the corresponding cu_info_t struct in lcu->cu, or set to NULL, if the candidate is not available.

Parameters
xblock x position in pixels
yblock y position in pixels
widthblock width in pixels
heightblock height in pixels
picture_widthtile width in pixels
picture_heighttile height in pixels
lcucurrent LCU
cand_outwill be filled with A and B candidates

< coordinates from top-left of this LCU

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

◆ get_spatial_merge_candidates_cua()

static void get_spatial_merge_candidates_cua ( const cu_array_t cua,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
int32_t  picture_width,
int32_t  picture_height,
merge_candidates_t cand_out 
)
static

The output parameters b0, b1, b2, a0, a1 are pointed to the corresponding cu_info_t struct in lcu->cu, or set to NULL, if the candidate is not available.

Parameters
cuacu information
xblock x position in pixels
yblock y position in pixels
widthblock width in pixels
heightblock height in pixels
picture_widthtile width in pixels
picture_heighttile height in pixels
cand_outwill be filled with A and B candidates

< coordinates from top-left of this LCU

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

◆ get_temporal_merge_candidates()

static void get_temporal_merge_candidates ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
uint8_t  ref_list,
uint8_t  ref_idx,
merge_candidates_t cand_out 
)
static
Parameters
stateencoder control state to use
xblock x position in SCU
yblock y position in SCU
widthcurrent block width
heightcurrent block height
ref_listwhich reference list, L0 is 1 and L1 is 2
ref_idxindex in the reference list
cand_outwill be filled with C3 and H candidates
Here is the caller graph for this function:

◆ inter_clear_cu_unused()

static void inter_clear_cu_unused ( cu_info_t cu)
static
Parameters
cucoding unit to clear
Here is the caller graph for this function:

◆ inter_cp_with_ext_border()

static void inter_cp_with_ext_border ( const kvz_pixel ref_buf,
int  ref_stride,
int  ref_width,
int  ref_height,
kvz_pixel rec_buf,
int  rec_stride,
int  width,
int  height,
const vector2d_t mv_in_frame 
)
static
Parameters
ref_bufpointer to the start of ref buffer
ref_stridestride of ref buffer
ref_widthwidth of frame
ref_heightheight of frame
rec_bufpointer to the start of pu in rec buffer
rec_stridestride of rec buffer
widthwidth of copied block
heightheight of copied block
mv_in_framecoordinates of copied block in frame coordinates
Here is the caller graph for this function:

◆ inter_recon_frac_chroma()

static void inter_recon_frac_chroma ( const encoder_state_t *const  state,
const kvz_picture *const  ref,
int32_t  pu_x,
int32_t  pu_y,
int32_t  pu_w,
int32_t  pu_h,
const int16_t  mv_param[2],
yuv_t out,
const unsigned  out_stride 
)
static
Here is the caller graph for this function:

◆ inter_recon_frac_chroma_hi()

static void inter_recon_frac_chroma_hi ( const encoder_state_t *const  state,
const kvz_picture *const  ref,
int32_t  pu_x,
int32_t  pu_y,
int32_t  pu_w,
int32_t  pu_h,
const int16_t  mv_param[2],
yuv_im_t out,
const unsigned  out_stride 
)
static
Here is the caller graph for this function:

◆ inter_recon_frac_luma()

static void inter_recon_frac_luma ( const encoder_state_t *const  state,
const kvz_picture *const  ref,
int32_t  xpos,
int32_t  ypos,
int32_t  block_width,
int32_t  block_height,
const int16_t  mv_param[2],
yuv_t out,
unsigned  out_stride 
)
static
Here is the caller graph for this function:

◆ inter_recon_frac_luma_hi()

static void inter_recon_frac_luma_hi ( const encoder_state_t *const  state,
const kvz_picture *const  ref,
int32_t  xpos,
int32_t  ypos,
int32_t  block_width,
int32_t  block_height,
const int16_t  mv_param[2],
yuv_im_t out,
const unsigned  out_stride 
)
static
Here is the caller graph for this function:

◆ inter_recon_unipred()

static unsigned inter_recon_unipred ( const encoder_state_t *const  state,
const kvz_picture *const  ref,
int32_t  pu_x,
int32_t  pu_y,
int32_t  pu_w,
int32_t  pu_h,
int32_t  out_stride_luma,
const int16_t  mv_param[2],
yuv_t yuv_px,
yuv_im_t yuv_im,
bool  predict_luma,
bool  predict_chroma 
)
static
Parameters
stateencoder state
refpicture to copy the data from
pu_xPU x position
pu_yPU y position
widthPU width
heightPU height
mv_parammotion vector
yuv_pxdestination buffer for pixel precision
yuv_imdestination buffer for high-precision, or NULL if not needed
predict_lumaEnable or disable luma prediction for this call.
predict_chromaEnable or disable chroma prediction for this call.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_a0_cand_coded()

static bool is_a0_cand_coded ( int  x,
int  y,
int  width,
int  height 
)
static
Parameters
xx-coordinate of the current block (in pixels)
yy-coordinate of the current block (in pixels)
widthwidth of the current block (in pixels)
heightheight of the current block (in pixels)
Returns
True, if the a0 mv candidate block is coded before the current block. Otherwise false.
Here is the caller graph for this function:

◆ is_b0_cand_coded()

static bool is_b0_cand_coded ( int  x,
int  y,
int  width,
int  height 
)
static
Parameters
xx-coordinate of the current block (in pixels)
yy-coordinate of the current block (in pixels)
widthwidth of the current block (in pixels)
heightheight of the current block (in pixels)
Returns
True, if the b0 mv candidate block is coded before the current block. Otherwise false.
Here is the caller graph for this function:

◆ is_duplicate_candidate()

static bool is_duplicate_candidate ( const cu_info_t cu1,
const cu_info_t cu2 
)
static
Here is the caller graph for this function:

◆ kvz_inter_get_merge_cand()

uint8_t kvz_inter_get_merge_cand ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
bool  use_a1,
bool  use_b1,
inter_merge_cand_t  mv_cand[5],
lcu_t lcu 
)
Parameters
statethe encoder state
xblock x position in SCU
yblock y position in SCU
widthblock width
heightblock height
use_a1true, if candidate a1 can be used
use_b1true, if candidate b1 can be used
mv_candReturns the merge candidates.
lculcu containing the block
Returns
number of merge candidates
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_inter_get_mv_cand()

void kvz_inter_get_mv_cand ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
int16_t  mv_cand[2][2],
const cu_info_t *const  cur_cu,
lcu_t lcu,
int8_t  reflist 
)
Parameters
stateencoder state
xblock x position in pixels
yblock y position in pixels
widthblock width in pixels
heightblock height in pixels
mv_candReturn the motion vector candidates.
cur_cucurrent CU
lcucurrent LCU
reflistreflist index (either 0 or 1)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_inter_get_mv_cand_cua()

void kvz_inter_get_mv_cand_cua ( const encoder_state_t *const  state,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
int16_t  mv_cand[2][2],
const cu_info_t cur_cu,
int8_t  reflist 
)
Parameters
stateencoder state
xblock x position in pixels
yblock y position in pixels
widthblock width in pixels
heightblock height in pixels
mv_candReturn the motion vector candidates.
cur_cucurrent CU
reflistreflist index (either 0 or 1)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_inter_pred_pu()

void kvz_inter_pred_pu ( const encoder_state_t *const  state,
lcu_t lcu,
int32_t  x,
int32_t  y,
int32_t  width,
bool  predict_luma,
bool  predict_chroma,
int  i_pu 
)

The PU may use either uniprediction or biprediction.

Parameters
stateencoder state
lcucontaining LCU
xx-coordinate of the CU in pixels
yy-coordinate of the CU in pixels
widthCU width
predict_lumaEnable or disable luma prediction for this call.
predict_chromaEnable or disable chroma prediction for this call.
i_puIndex of the PU. Always zero for 2Nx2N. Used for SMP+AMP.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_inter_recon_bipred()

void kvz_inter_recon_bipred ( const encoder_state_t *const  state,
const kvz_picture ref1,
const kvz_picture ref2,
int32_t  pu_x,
int32_t  pu_y,
int32_t  pu_w,
int32_t  pu_h,
int16_t  mv_param[2][2],
lcu_t lcu,
bool  predict_luma,
bool  predict_chroma 
)
Parameters
stateencoder state
ref1reference picture to copy the data from
ref2other reference picture to copy the data from
pu_xPU x position
pu_yPU y position
widthPU width
heightPU height
mv_parammotion vectors
lcudestination lcu
predict_lumaEnable or disable luma prediction for this call.
predict_chromaEnable or disable chroma prediction for this call.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_inter_recon_cu()

void kvz_inter_recon_cu ( const encoder_state_t *const  state,
lcu_t lcu,
int32_t  x,
int32_t  y,
int32_t  width,
bool  predict_luma,
bool  predict_chroma 
)

The CU may consist of multiple PUs, each of which can use either uniprediction or biprediction.

Parameters
stateencoder state
lcucontaining LCU
xx-coordinate of the CU in pixels
yy-coordinate of the CU in pixels
widthCU width
predict_lumaEnable or disable luma prediction for this call.
predict_chromaEnable or disable chroma prediction for this call.
Here is the call graph for this function:
Here is the caller graph for this function: