#include <math.h>
#include <limits.h>
#include "global.h"
#include "ratectl.h"
Go to the source code of this file.
Functions | |
void | rc_alloc_quadratic (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic **p_quad) |
void | rc_copy_quadratic (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *dst, RCQuadratic *src) |
void | rc_free_quadratic (RCQuadratic **p_quad) |
void | rc_init_seq (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen) |
void | rc_init_GOP (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int np, int nb) |
void | rc_init_pict (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int fieldpic, int topfield, int targetcomputation, float mult) |
void | rc_update_pict (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int nbits) |
void | rc_update_picture (ImageParameters *p_Img, InputParameters *p_Inp, int bits) |
int | updateComplexity (ImageParameters *p_Img, RCQuadratic *p_quad, RCGeneric *p_gen, Boolean is_updated, int nbits) |
void | updatePparams (RCQuadratic *p_quad, RCGeneric *p_gen, int complexity) |
void | updateBparams (RCQuadratic *p_quad, RCGeneric *p_gen, int complexity) |
void | rc_update_pict_frame (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int nbits) |
void | updateRCModel (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen) |
void | RCModelEstimator (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, int n_windowSize, Boolean *m_rgRejected) |
void | updateMADModel (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen) |
void | MADModelEstimator (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, int n_windowSize, Boolean *PictureRejected) |
int | updateQPRC0 (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
int | updateQPRC1 (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
int | updateQPRC2 (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
int | updateQPRC3 (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
void | updateQPInterlace (RCQuadratic *p_quad, RCGeneric *p_gen) |
void | updateQPNonPicAFF (seq_parameter_set_rbsp_t *active_sps, RCQuadratic *p_quad) |
void | updateBottomField (InputParameters *p_Inp, RCQuadratic *p_quad) |
int | updateFirstP (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
int | updateNegativeTarget (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield, int m_Qp) |
int | updateFirstBU (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
void | updateLastBU (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen, int topfield) |
void | predictCurrPicMAD (InputParameters *p_Inp, RCQuadratic *p_quad, RCGeneric *p_gen) |
void | updateModelQPBU (ImageParameters *p_Img, InputParameters *p_Inp, RCQuadratic *p_quad, int m_Qp) |
void | updateQPInterlaceBU (RCQuadratic *p_quad, RCGeneric *p_gen) |
void | updateModelQPFrame (RCQuadratic *p_quad, int m_Bits) |
int | rc_handle_mb (Macroblock *currMB, int prev_mb) |
void | rc_init_top_field (ImageParameters *p_Img, InputParameters *p_Inp) |
void | rc_init_bottom_field (ImageParameters *p_Img, InputParameters *p_Inp, int TopFieldBits) |
void | rc_init_frame_rdpic (ImageParameters *p_Img, InputParameters *p_Inp, float rateRatio) |
void | rc_allocate_memory (ImageParameters *p_Img, InputParameters *p_Inp) |
void | rc_free_memory (ImageParameters *p_Img, InputParameters *p_Inp) |
void | rc_update_mb_stats (Macroblock *currMB) |
void | rc_save_state (ImageParameters *p_Img, InputParameters *p_Inp) |
void | rc_restore_state (ImageParameters *p_Img, InputParameters *p_Inp) |
Variables | |
static const float | THETA = 1.3636F |
static const float | OMEGA = 0.9F |
static const float | MINVALUE = 4.0F |
Definition in file rc_quadratic.c.
void MADModelEstimator | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
int | n_windowSize, | |||
Boolean * | PictureRejected | |||
) |
MAD mode estimator.
Definition at line 1219 of file rc_quadratic.c.
References img_par::number.
Referenced by updateMADModel().
void predictCurrPicMAD | ( | InputParameters * | p_Inp, | |
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen | |||
) |
update current picture MAD
Definition at line 2378 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, and inp_par_enc::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
void rc_alloc_quadratic | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic ** | p_quad | |||
) |
Dynamically allocate memory needed for rate control.
Definition at line 37 of file rc_quadratic.c.
References no_mem_exit(), and inp_par_enc::qp.
Referenced by rc_allocate_memory().
void rc_allocate_memory | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
allocate rate control memory
Definition at line 2633 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, rc_alloc_generic(), rc_alloc_quadratic(), and inp_par_enc::RDPictureDecision.
Referenced by init_global_buffers().
void rc_copy_quadratic | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | dst, | |||
RCQuadratic * | src | |||
) |
Copy JVT rate control objects.
Definition at line 101 of file rc_quadratic.c.
Referenced by encode_one_slice_MBAFF(), rc_init_frame(), rc_init_frame_rdpic(), rc_restore_state(), and rc_save_state().
void rc_free_memory | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
free rate control memory
Definition at line 2660 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, rc_free_generic(), rc_free_quadratic(), and inp_par_enc::RDPictureDecision.
Referenced by free_global_buffers().
void rc_free_quadratic | ( | RCQuadratic ** | p_quad | ) |
Free memory needed for rate control.
Definition at line 133 of file rc_quadratic.c.
Referenced by rc_free_memory().
int rc_handle_mb | ( | Macroblock * | currMB, | |
int | prev_mb | |||
) |
rate control at the MB level
Definition at line 2492 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, img_par::number, macroblock::p_Img, inp_par_enc::PicInterlace, macroblock::qp, img_par::qp, and updateRCModel().
Referenced by start_macroblock().
void rc_init_bottom_field | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | TopFieldBits | |||
) |
initialize rate control model for the bottom field
Definition at line 2589 of file rc_quadratic.c.
References img_par::qp.
Referenced by field_picture().
void rc_init_frame_rdpic | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
float | rateRatio | |||
) |
initialize rate control for RDPictureDecision
Definition at line 2606 of file rc_quadratic.c.
References img_par::qp, rc_copy_generic(), and rc_copy_quadratic().
Referenced by rd_picture_coding().
void rc_init_GOP | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | np, | |||
int | nb | |||
) |
Initialize one GOP.
Definition at line 312 of file rc_quadratic.c.
References inp_par_enc::intra_period, inp_par_enc::MbInterlace, inp_par_enc::no_frm_base, inp_par_enc::NumberBFrames, inp_par_enc::PicInterlace, and inp_par_enc::source.
Referenced by rc_init_gop_params().
void rc_init_pict | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | fieldpic, | |||
int | topfield, | |||
int | targetcomputation, | |||
float | mult | |||
) |
Initialize one picture.
Definition at line 508 of file rc_quadratic.c.
References GOP_DATA::hierarchy_layer, inp_par_enc::MbInterlace, img_par::number, inp_par_enc::NumberBFrames, and inp_par_enc::PicInterlace.
Referenced by rc_init_seq().
void rc_init_seq | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen | |||
) |
Initialize rate control parameters.
Definition at line 170 of file rc_quadratic.c.
References inp_par_enc::NumberBFrames, rc_init_pict(), rc_update_pict_frame(), rc_update_picture(), img_par::size, updateQPRC0(), updateQPRC1(), updateQPRC2(), updateQPRC3(), and img_par::width.
Referenced by rc_init_sequence().
void rc_init_top_field | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
initialize rate control model for the top field
Definition at line 2572 of file rc_quadratic.c.
References inp_par_enc::PicInterlace, and img_par::qp.
Referenced by field_picture().
void rc_restore_state | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
restore state of rate control model
Definition at line 2741 of file rc_quadratic.c.
References rc_copy_generic(), and rc_copy_quadratic().
void rc_save_state | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
save state of rate control model
Definition at line 2722 of file rc_quadratic.c.
References rc_copy_generic(), and rc_copy_quadratic().
Referenced by rd_picture_coding().
void rc_update_mb_stats | ( | Macroblock * | currMB | ) |
update coding statistics after MB coding
Definition at line 2687 of file rc_quadratic.c.
References macroblock::p_Img.
Referenced by write_macroblock().
void rc_update_pict | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | nbits | |||
) |
update one picture after frame/field encoding
p_Img | Image encoding parameters for picture | |
p_Inp | Input configuration parameters | |
p_quad | quadratic model | |
p_gen | generic rate control parameters | |
nbits | number of bits used for picture |
Definition at line 757 of file rc_quadratic.c.
References ComputeFrameMAD(), and updateRCModel().
Referenced by rc_update_picture().
void rc_update_pict_frame | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | nbits | |||
) |
update after frame encoding
p_Img | Image encoding parameters for picture | |
p_Inp | Input configuration parameters | |
p_quad | quadratic model | |
p_gen | generic rate control parameters | |
nbits | number of bits used for frame |
Definition at line 858 of file rc_quadratic.c.
References GOP_DATA::hierarchy_layer, and img_par::number.
Referenced by rc_init_seq().
void rc_update_picture | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | bits | |||
) |
update one picture after coding
p_Img | image parameters for current picture | |
p_Inp | input parameters from configuration | |
bits | number of bits used for picture |
Definition at line 793 of file rc_quadratic.c.
References rc_update_pict().
Referenced by rc_init_seq().
void RCModelEstimator | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
int | n_windowSize, | |||
Boolean * | m_rgRejected | |||
) |
Model Estimator.
Definition at line 1056 of file rc_quadratic.c.
References img_par::number.
Referenced by updateRCModel().
void updateBottomField | ( | InputParameters * | p_Inp, | |
RCQuadratic * | p_quad | |||
) |
Update QP values for bottom filed in field coding.
Definition at line 2137 of file rc_quadratic.c.
References inp_par_enc::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
int updateFirstBU | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
update QP for the first Basic Unit in the picture
Definition at line 2286 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, and inp_par_enc::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
int updateFirstP | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
update QP variables for P frames
Definition at line 2158 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, and inp_par_enc::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
void updateLastBU | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
update QP for the last Basic Unit in the picture
Definition at line 2335 of file rc_quadratic.c.
References inp_par_enc::intra_period, inp_par_enc::MbInterlace, and inp_par_enc::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
void updateMADModel | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen | |||
) |
update the parameters of linear prediction model
Definition at line 1129 of file rc_quadratic.c.
References error(), MADModelEstimator(), inp_par_enc::MbInterlace, img_par::number, and inp_par_enc::PicInterlace.
Referenced by updateRCModel().
void updateModelQPBU | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
int | m_Qp | |||
) |
update QP using the quadratic model for basic unit coding
Definition at line 2409 of file rc_quadratic.c.
References Qstep2QP().
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
void updateModelQPFrame | ( | RCQuadratic * | p_quad, | |
int | m_Bits | |||
) |
update QP with quadratic model
Definition at line 2472 of file rc_quadratic.c.
References Qstep2QP().
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
int updateNegativeTarget | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield, | |||
int | m_Qp | |||
) |
update QP when bit target is negative
Definition at line 2204 of file rc_quadratic.c.
References inp_par_enc::intra_period, inp_par_enc::MbInterlace, and inp_par_enc::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
void updateQPInterlace | ( | RCQuadratic * | p_quad, | |
RCGeneric * | p_gen | |||
) |
Save previous QP values for interlaced coding.
Definition at line 2091 of file rc_quadratic.c.
Referenced by updateQPRC0(), updateQPRC2(), and updateQPRC3().
void updateQPInterlaceBU | ( | RCQuadratic * | p_quad, | |
RCGeneric * | p_gen | |||
) |
update QP variables for interlaced pictures and basic unit coding
Definition at line 2450 of file rc_quadratic.c.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
void updateQPNonPicAFF | ( | seq_parameter_set_rbsp_t * | active_sps, | |
RCQuadratic * | p_quad | |||
) |
Save previous QP values for the case of non-PicAFF.
Definition at line 2117 of file rc_quadratic.c.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
int updateQPRC0 | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
compute a quantization parameter for each frame (RC_MODE_0)
Definition at line 1293 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, inp_par_enc::NumberBFrames, inp_par_enc::PicInterlace, predictCurrPicMAD(), updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlace(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().
int updateQPRC1 | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
compute a quantization parameter for each frame
Definition at line 1544 of file rc_quadratic.c.
References inp_par_enc::MbInterlace, img_par::number, inp_par_enc::PicInterlace, predictCurrPicMAD(), updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().
int updateQPRC2 | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
compute a quantization parameter for each frame
Definition at line 1693 of file rc_quadratic.c.
References GOP_DATA::hierarchy_layer, inp_par_enc::MbInterlace, img_par::number, inp_par_enc::PicInterlace, predictCurrPicMAD(), updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlace(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().
int updateQPRC3 | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen, | |||
int | topfield | |||
) |
compute a quantization parameter for each frame
Definition at line 1905 of file rc_quadratic.c.
References GOP_DATA::hierarchy_layer, inp_par_enc::MbInterlace, img_par::number, inp_par_enc::PicInterlace, predictCurrPicMAD(), updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlace(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().
void updateRCModel | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
RCQuadratic * | p_quad, | |||
RCGeneric * | p_gen | |||
) |
update the parameters of quadratic R-D model
Definition at line 921 of file rc_quadratic.c.
References ComputeFrameMAD(), error(), img_par::framepoc, inp_par_enc::MbInterlace, img_par::number, inp_par_enc::PicInterlace, QP2Qstep(), RCModelEstimator(), and updateMADModel().
Referenced by rc_handle_mb(), and rc_update_pict().