TUT HEVC Encoder
|
#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"
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. | |
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. | |
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. | |
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. | |
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. | |
static void | inter_clear_cu_unused (cu_info_t *cu) |
Clear unused L0/L1 motion vectors and reference. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
#define NUM_PRIORITY_LIST 12; |
|
static |
|
inlinestatic |
|
static |
state | encoder state | |
current_ref | index of the picture referenced by the current CU | |
colocated | colocated CU | |
reflist | either 0 (for L0) or 1 (for L1) | |
[out] | mv_out | Returns the motion vector |
|
inlinestatic |
|
static |
|
static |
|
inlinestatic |
|
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.
x | block x position in pixels |
y | block y position in pixels |
width | block width in pixels |
height | block height in pixels |
picture_width | tile width in pixels |
picture_height | tile height in pixels |
lcu | current LCU |
cand_out | will be filled with A and B candidates |
< coordinates from top-left of this LCU
|
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.
cua | cu information |
x | block x position in pixels |
y | block y position in pixels |
width | block width in pixels |
height | block height in pixels |
picture_width | tile width in pixels |
picture_height | tile height in pixels |
cand_out | will be filled with A and B candidates |
< coordinates from top-left of this LCU
|
static |
state | encoder control state to use |
x | block x position in SCU |
y | block y position in SCU |
width | current block width |
height | current block height |
ref_list | which reference list, L0 is 1 and L1 is 2 |
ref_idx | index in the reference list |
cand_out | will be filled with C3 and H candidates |
|
static |
cu | coding unit to clear |
|
static |
ref_buf | pointer to the start of ref buffer |
ref_stride | stride of ref buffer |
ref_width | width of frame |
ref_height | height of frame |
rec_buf | pointer to the start of pu in rec buffer |
rec_stride | stride of rec buffer |
width | width of copied block |
height | height of copied block |
mv_in_frame | coordinates of copied block in frame coordinates |
|
static |
|
static |
|
static |
|
static |
|
static |
state | encoder state |
ref | picture to copy the data from |
pu_x | PU x position |
pu_y | PU y position |
width | PU width |
height | PU height |
mv_param | motion vector |
yuv_px | destination buffer for pixel precision |
yuv_im | destination buffer for high-precision, or NULL if not needed |
predict_luma | Enable or disable luma prediction for this call. |
predict_chroma | Enable or disable chroma prediction for this call. |
|
static |
x | x-coordinate of the current block (in pixels) |
y | y-coordinate of the current block (in pixels) |
width | width of the current block (in pixels) |
height | height of the current block (in pixels) |
|
static |
x | x-coordinate of the current block (in pixels) |
y | y-coordinate of the current block (in pixels) |
width | width of the current block (in pixels) |
height | height of the current block (in pixels) |
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 ) |
state | the encoder state |
x | block x position in SCU |
y | block y position in SCU |
width | block width |
height | block height |
use_a1 | true, if candidate a1 can be used |
use_b1 | true, if candidate b1 can be used |
mv_cand | Returns the merge candidates. |
lcu | lcu containing the block |
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 ) |
state | encoder state |
x | block x position in pixels |
y | block y position in pixels |
width | block width in pixels |
height | block height in pixels |
mv_cand | Return the motion vector candidates. |
cur_cu | current CU |
lcu | current LCU |
reflist | reflist index (either 0 or 1) |
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 ) |
state | encoder state |
x | block x position in pixels |
y | block y position in pixels |
width | block width in pixels |
height | block height in pixels |
mv_cand | Return the motion vector candidates. |
cur_cu | current CU |
reflist | reflist index (either 0 or 1) |
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.
state | encoder state |
lcu | containing LCU |
x | x-coordinate of the CU in pixels |
y | y-coordinate of the CU in pixels |
width | CU width |
predict_luma | Enable or disable luma prediction for this call. |
predict_chroma | Enable or disable chroma prediction for this call. |
i_pu | Index of the PU. Always zero for 2Nx2N. Used for SMP+AMP. |
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 ) |
state | encoder state |
ref1 | reference picture to copy the data from |
ref2 | other reference picture to copy the data from |
pu_x | PU x position |
pu_y | PU y position |
width | PU width |
height | PU height |
mv_param | motion vectors |
lcu | destination lcu |
predict_luma | Enable or disable luma prediction for this call. |
predict_chroma | Enable or disable chroma prediction for this call. |
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.
state | encoder state |
lcu | containing LCU |
x | x-coordinate of the CU in pixels |
y | y-coordinate of the CU in pixels |
width | CU width |
predict_luma | Enable or disable luma prediction for this call. |
predict_chroma | Enable or disable chroma prediction for this call. |