TUT HEVC Encoder
Loading...
Searching...
No Matches
rate_control.c File Reference
#include "rate_control.h"
#include <math.h>
#include "encoder.h"
#include "kvazaar.h"
#include "pthread.h"
Include dependency graph for rate_control.c:

Macros

#define BETA1   1.2517
 

Functions

static double clip_lambda (double lambda)
 Clip lambda value to a valid range.
 
kvz_rc_datakvz_get_rc_data (const encoder_control_t *const encoder)
 
void kvz_free_rc_data ()
 
static void update_parameters (uint32_t bits, uint32_t pixels, double lambda_real, double *alpha, double *beta)
 Update alpha and beta parameters.
 
static double gop_allocate_bits (encoder_state_t *const state)
 Allocate bits for the current GOP.
 
static int xCalcHADs8x8_ISlice (kvz_pixel *piOrg, int y, int iStrideOrg)
 
static uint64_t pic_header_bits (encoder_state_t *const state)
 Estimate number of bits used for headers of the current picture.
 
static double pic_allocate_bits (encoder_state_t *const state)
 Allocate bits for the current picture.
 
static int8_t lambda_to_qp (const double lambda)
 
static double solve_cubic_equation (const encoder_state_config_frame_t *const state, int ctu_index, int last_ctu, double est_lambda, double target_bits)
 
static double calculate_weights (encoder_state_t *const state, const int ctu_count, double est_lambda)
 
void kvz_estimate_pic_lambda (encoder_state_t *const state)
 
static double get_ctu_bits (encoder_state_t *const state, vector2d_t pos)
 
static double qp_to_lambda (encoder_state_t *const state, int qp)
 
void kvz_set_ctu_qp_lambda (encoder_state_t *const state, vector2d_t pos)
 
static void update_pic_ck (encoder_state_t *const state, double bpp, double distortion, double lambda, int layer)
 
static void update_ck (encoder_state_t *const state, int ctu_index, int layer)
 
static int calc_poc (encoder_state_t *const state)
 
void kvz_update_after_picture (encoder_state_t *const state)
 
void kvz_set_picture_lambda_and_qp (encoder_state_t *const state)
 Allocate bits and set lambda and QP for the current picture.
 
static double lcu_allocate_bits (encoder_state_t *const state, vector2d_t pos)
 Allocate bits for a LCU.
 
void kvz_set_lcu_lambda_and_qp (encoder_state_t *const state, vector2d_t pos)
 

Variables

static const int MIN_SMOOTHING_WINDOW = 40
 
static int smoothing_window = 40
 
static const double MIN_LAMBDA = 0.1
 
static const double MAX_LAMBDA = 10000
 
static kvz_rc_datadata
 
static FILE * dist_file
 
static FILE * bits_file
 
static FILE * qp_file
 
static FILE * lambda_file
 

Macro Definition Documentation

◆ BETA1

#define BETA1   1.2517

Function Documentation

◆ calc_poc()

static int calc_poc ( encoder_state_t *const state)
static
Here is the caller graph for this function:

◆ calculate_weights()

static double calculate_weights ( encoder_state_t *const state,
const int ctu_count,
double est_lambda )
inlinestatic
Here is the caller graph for this function:

◆ clip_lambda()

static double clip_lambda ( double lambda)
static
Here is the caller graph for this function:

◆ get_ctu_bits()

static double get_ctu_bits ( encoder_state_t *const state,
vector2d_t pos )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gop_allocate_bits()

static double gop_allocate_bits ( encoder_state_t *const state)
static
Parameters
statethe main encoder state
Returns
target number of bits
Here is the caller graph for this function:

◆ kvz_estimate_pic_lambda()

void kvz_estimate_pic_lambda ( encoder_state_t *const state)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_free_rc_data()

void kvz_free_rc_data ( )
Here is the caller graph for this function:

◆ kvz_get_rc_data()

kvz_rc_data * kvz_get_rc_data ( const encoder_control_t *const encoder)
Here is the caller graph for this function:

◆ kvz_set_ctu_qp_lambda()

void kvz_set_ctu_qp_lambda ( encoder_state_t *const state,
vector2d_t pos )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_set_lcu_lambda_and_qp()

void kvz_set_lcu_lambda_and_qp ( encoder_state_t *const state,
vector2d_t pos )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_set_picture_lambda_and_qp()

void kvz_set_picture_lambda_and_qp ( encoder_state_t *const state)
Parameters
statethe main encoder state
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_update_after_picture()

void kvz_update_after_picture ( encoder_state_t *const state)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lambda_to_qp()

static int8_t lambda_to_qp ( const double lambda)
static
Here is the caller graph for this function:

◆ lcu_allocate_bits()

static double lcu_allocate_bits ( encoder_state_t *const state,
vector2d_t pos )
static
Parameters
statethe main encoder state
poslocation of the LCU as number of LCUs from top left
Returns
number of bits allocated for the LCU
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pic_allocate_bits()

static double pic_allocate_bits ( encoder_state_t *const state)
static
Parameters
statethe main encoder state
Returns
target number of bits, excluding headers
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pic_header_bits()

static uint64_t pic_header_bits ( encoder_state_t *const state)
static
Parameters
statethe main encoder state
Returns
number of header bits
Here is the call graph for this function:
Here is the caller graph for this function:

◆ qp_to_lambda()

static double qp_to_lambda ( encoder_state_t *const state,
int qp )
static
Here is the caller graph for this function:

◆ solve_cubic_equation()

static double solve_cubic_equation ( const encoder_state_config_frame_t *const state,
int ctu_index,
int last_ctu,
double est_lambda,
double target_bits )
static
Here is the caller graph for this function:

◆ update_ck()

static void update_ck ( encoder_state_t *const state,
int ctu_index,
int layer )
static
Here is the caller graph for this function:

◆ update_parameters()

static void update_parameters ( uint32_t bits,
uint32_t pixels,
double lambda_real,
double * alpha,
double * beta )
static
Parameters
bitsnumber of bits spent for coding the area
pixelssize of the area in pixels
lambda_reallambda used for coding the area
[in,out]alphaalpha parameter to update
[in,out]betabeta parameter to update
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_pic_ck()

static void update_pic_ck ( encoder_state_t *const state,
double bpp,
double distortion,
double lambda,
int layer )
static
Here is the caller graph for this function:

◆ xCalcHADs8x8_ISlice()

static int xCalcHADs8x8_ISlice ( kvz_pixel * piOrg,
int y,
int iStrideOrg )
static
Here is the caller graph for this function:

Variable Documentation

◆ bits_file

FILE* bits_file
static

◆ data

kvz_rc_data* data
static

◆ dist_file

FILE* dist_file
static

◆ lambda_file

FILE* lambda_file
static

◆ MAX_LAMBDA

const double MAX_LAMBDA = 10000
static

◆ MIN_LAMBDA

const double MIN_LAMBDA = 0.1
static

◆ MIN_SMOOTHING_WINDOW

const int MIN_SMOOTHING_WINDOW = 40
static

◆ qp_file

FILE* qp_file
static

◆ smoothing_window

int smoothing_window = 40
static