#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 (rc_quadratic **prc) |
| void | rc_copy_quadratic (rc_quadratic *dst, rc_quadratic *src) |
| void | rc_free_quadratic (rc_quadratic **prc) |
| void | rc_init_seq (rc_quadratic *prc) |
| void | rc_init_GOP (rc_quadratic *prc, int np, int nb) |
| void | rc_init_pict (rc_quadratic *prc, int fieldpic, int topfield, int targetcomputation, float mult) |
| void | rc_update_pict (rc_quadratic *prc, int nbits) |
| void | rc_update_picture (int bits) |
| int | updateComplexity (rc_quadratic *prc, Boolean is_updated, int nbits) |
| void | updatePparams (rc_quadratic *prc, int complexity) |
| void | updateBparams (rc_quadratic *prc, int complexity) |
| void | rc_update_pict_frame (rc_quadratic *prc, int nbits) |
| void | updateRCModel (rc_quadratic *prc) |
| void | RCModelEstimator (rc_quadratic *prc, int n_windowSize, Boolean *m_rgRejected) |
| void | updateMADModel (rc_quadratic *prc) |
| void | MADModelEstimator (rc_quadratic *prc, int n_windowSize, Boolean *PictureRejected) |
| int | updateQPRC0 (rc_quadratic *prc, int topfield) |
| int | updateQPRC1 (rc_quadratic *prc, int topfield) |
| int | updateQPRC2 (rc_quadratic *prc, int topfield) |
| int | updateQPRC3 (rc_quadratic *prc, int topfield) |
| void | updateQPInterlace (rc_quadratic *prc) |
| void | updateQPNonPicAFF (rc_quadratic *prc) |
| void | updateBottomField (rc_quadratic *prc) |
| int | updateFirstP (rc_quadratic *prc, int topfield) |
| int | updateNegativeTarget (rc_quadratic *prc, int topfield, int m_Qp) |
| int | updateFirstBU (rc_quadratic *prc, int topfield) |
| void | updateLastBU (rc_quadratic *prc, int topfield) |
| void | predictCurrPicMAD (rc_quadratic *prc) |
| void | updateModelQPBU (rc_quadratic *prc, int topfield, int m_Qp) |
| void | updateQPInterlaceBU (rc_quadratic *prc) |
| void | updateModelQPFrame (rc_quadratic *prc, int m_Bits) |
| int | rc_handle_mb (int prev_mb, Macroblock *currMB, Slice *currSlice) |
| void | rc_init_top_field (void) |
| void | rc_init_bottom_field (int TopFieldBits) |
| void | rc_init_frame_rdpic (float rateRatio) |
| void | rc_allocate_memory (void) |
| void | rc_free_memory (void) |
| void | rc_update_mb_stats (Macroblock *currMB, int *bitCount) |
| void | rc_save_state (void) |
| void | rc_restore_state (void) |
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 | ( | rc_quadratic * | prc, | |
| int | n_windowSize, | |||
| Boolean * | PictureRejected | |||
| ) |
MAD mode estimator.
Definition at line 1196 of file rc_quadratic.c.
References ImageParameters::number, InputParameters::RCUpdateMode, and ImageParameters::type.
Referenced by updateMADModel().
| void predictCurrPicMAD | ( | rc_quadratic * | prc | ) |
update current picture MAD
Definition at line 2354 of file rc_quadratic.c.
References InputParameters::MbInterlace, and InputParameters::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| void rc_alloc_quadratic | ( | rc_quadratic ** | prc | ) |
Dynamically allocate memory needed for rate control.
Definition at line 37 of file rc_quadratic.c.
References InputParameters::basicunit, ImageParameters::FrameSizeInMbs, no_mem_exit(), and InputParameters::qp.
Referenced by rc_allocate_memory().

| void rc_allocate_memory | ( | void | ) |
allocate rate control memory
Definition at line 2594 of file rc_quadratic.c.
References InputParameters::MbInterlace, rc_alloc_generic(), rc_alloc_quadratic(), InputParameters::RCUpdateMode, and InputParameters::RDPictureDecision.
Referenced by init_global_buffers().

| void rc_copy_quadratic | ( | rc_quadratic * | dst, | |
| rc_quadratic * | src | |||
| ) |
Copy JVT rate control objects.
Definition at line 100 of file rc_quadratic.c.
References InputParameters::basicunit, and ImageParameters::FrameSizeInMbs.
Referenced by encode_one_slice_MBAFF(), rc_init_frame(), rc_init_frame_rdpic(), rc_restore_state(), and rc_save_state().
| void rc_free_memory | ( | void | ) |
free rate control memory
Definition at line 2620 of file rc_quadratic.c.
References InputParameters::MbInterlace, rc_free_generic(), rc_free_quadratic(), InputParameters::RCUpdateMode, and InputParameters::RDPictureDecision.
Referenced by free_global_buffers().

| void rc_free_quadratic | ( | rc_quadratic ** | prc | ) |
Free memory needed for rate control.
Definition at line 132 of file rc_quadratic.c.
Referenced by rc_free_memory().
| int rc_handle_mb | ( | int | prev_mb, | |
| Macroblock * | currMB, | |||
| Slice * | currSlice | |||
| ) |
rate control at the MB level
Definition at line 2468 of file rc_quadratic.c.
References ImageParameters::BasicUnit, InputParameters::basicunit, ImageParameters::BasicUnitQP, ImageParameters::bitdepth_luma_qp_scale, ImageParameters::bot_MB, ImageParameters::current_mb_nr, ImageParameters::FrameSizeInMbs, macroblock::mb_field, InputParameters::MbInterlace, ImageParameters::number, ImageParameters::NumberofCodedMacroBlocks, InputParameters::PicInterlace, macroblock::prev_cbp, macroblock::prev_qp, macroblock::PrevMB, macroblock::qp, ImageParameters::qp, InputParameters::RCUpdateMode, ImageParameters::type, updateRCModel(), and ImageParameters::write_macroblock.
Referenced by start_macroblock().

| void rc_init_bottom_field | ( | int | TopFieldBits | ) |
initialize rate control model for the bottom field
Definition at line 2558 of file rc_quadratic.c.
References ImageParameters::qp.
Referenced by field_picture().
| void rc_init_frame_rdpic | ( | float | rateRatio | ) |
initialize rate control for RDPictureDecision
Definition at line 2572 of file rc_quadratic.c.
References ImageParameters::qp, rc_copy_generic(), rc_copy_quadratic(), and InputParameters::RCUpdateMode.
Referenced by rdPictureCoding().

| void rc_init_GOP | ( | rc_quadratic * | prc, | |
| int | np, | |||
| int | nb | |||
| ) |
Initialize one GOP.
Definition at line 308 of file rc_quadratic.c.
References InputParameters::basicunit, InputParameters::bit_rate, ImageParameters::FrameSizeInMbs, InputParameters::HierarchicalCoding, InputParameters::intra_period, InputParameters::MbInterlace, InputParameters::no_frm_base, InputParameters::NumberBFrames, InputParameters::PicInterlace, InputParameters::RCBSliceBitRatio, InputParameters::RCISliceBitRatio, ImageParameters::RCMaxQP, ImageParameters::RCMinQP, InputParameters::RCUpdateMode, InputParameters::SeinitialQP, and InputParameters::source.
Referenced by rc_init_gop_params().
| void rc_init_pict | ( | rc_quadratic * | prc, | |
| int | fieldpic, | |||
| int | topfield, | |||
| int | targetcomputation, | |||
| float | mult | |||
| ) |
Initialize one picture.
Definition at line 504 of file rc_quadratic.c.
References ImageParameters::b_frame_to_code, InputParameters::basicunit, ImageParameters::BasicUnit, InputParameters::channel_type, ImageParameters::FrameSizeInMbs, InputParameters::HierarchicalCoding, GOP_DATA::hierarchy_layer, InputParameters::MbInterlace, ImageParameters::number, InputParameters::NumberBFrames, ImageParameters::NumberofCodedMacroBlocks, InputParameters::PicInterlace, InputParameters::RCBoverPRatio, InputParameters::RCIoverPRatio, InputParameters::RCUpdateMode, and ImageParameters::type.
Referenced by rc_init_seq().
| void rc_init_seq | ( | rc_quadratic * | prc | ) |
Initialize rate control parameters.
Definition at line 169 of file rc_quadratic.c.
References InputParameters::basicunit, InputParameters::bit_rate, ImageParameters::framerate, ImageParameters::FrameSizeInMbs, InputParameters::NumberBFrames, ImageParameters::PicWidthInMbs, rc_init_pict(), rc_update_pict_frame(), rc_update_picture(), InputParameters::RCMaxQPChange, InputParameters::RCUpdateMode, InputParameters::SeinitialQP, ImageParameters::size, updateQPRC0(), updateQPRC1(), updateQPRC2(), updateQPRC3(), and ImageParameters::width.
Referenced by rc_init_sequence().

| void rc_init_top_field | ( | void | ) |
initialize rate control model for the top field
Definition at line 2544 of file rc_quadratic.c.
References InputParameters::basicunit, ImageParameters::BasicUnit, InputParameters::PicInterlace, and ImageParameters::qp.
Referenced by field_picture().
| void rc_restore_state | ( | void | ) |
restore state of rate control model
Definition at line 2696 of file rc_quadratic.c.
References rc_copy_generic(), rc_copy_quadratic(), and InputParameters::RCUpdateMode.
Referenced by rdPictureCoding().

| void rc_save_state | ( | void | ) |
save state of rate control model
Definition at line 2677 of file rc_quadratic.c.
References rc_copy_generic(), rc_copy_quadratic(), and InputParameters::RCUpdateMode.
Referenced by rdPictureCoding().

| void rc_update_mb_stats | ( | Macroblock * | currMB, | |
| int * | bitCount | |||
| ) |
update coding statistics after MB coding
Definition at line 2647 of file rc_quadratic.c.
References ImageParameters::BasicUnit, ImageParameters::FrameSizeInMbs, ImageParameters::NumberofMBHeaderBits, ImageParameters::NumberofMBTextureBits, and InputParameters::RCUpdateMode.
Referenced by write_macroblock().
| void rc_update_pict | ( | rc_quadratic * | prc, | |
| int | nbits | |||
| ) |
update one picture after frame/field encoding
| nbits | number of bits used for picture |
Definition at line 745 of file rc_quadratic.c.
References ComputeFrameMAD(), ImageParameters::frm_number, InputParameters::RCUpdateMode, ImageParameters::type, and updateRCModel().
Referenced by rc_update_picture().

| void rc_update_pict_frame | ( | rc_quadratic * | prc, | |
| int | nbits | |||
| ) |
update after frame encoding
| nbits | number of bits used for frame |
Definition at line 835 of file rc_quadratic.c.
References ImageParameters::b_frame_to_code, InputParameters::HierarchicalCoding, GOP_DATA::hierarchy_layer, ImageParameters::number, InputParameters::RCUpdateMode, and ImageParameters::type.
Referenced by rc_init_seq().
| void rc_update_picture | ( | int | bits | ) |
update one picture after coding
| bits | number of bits used for picture |
Definition at line 777 of file rc_quadratic.c.
References rc_update_pict().
Referenced by rc_init_seq().

| void RCModelEstimator | ( | rc_quadratic * | prc, | |
| int | n_windowSize, | |||
| Boolean * | m_rgRejected | |||
| ) |
Model Estimator.
Definition at line 1033 of file rc_quadratic.c.
References ImageParameters::number, InputParameters::RCUpdateMode, and ImageParameters::type.
Referenced by updateRCModel().
| void updateBottomField | ( | rc_quadratic * | prc | ) |
Update QP values for bottom filed in field coding.
Definition at line 2114 of file rc_quadratic.c.
References InputParameters::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| int updateFirstBU | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
update QP for the first Basic Unit in the picture
Definition at line 2262 of file rc_quadratic.c.
References InputParameters::MbInterlace, InputParameters::PicInterlace, and ImageParameters::RCMaxQP.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| int updateFirstP | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
update QP variables for P frames
Definition at line 2135 of file rc_quadratic.c.
References InputParameters::MbInterlace, and InputParameters::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| void updateLastBU | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
update QP for the last Basic Unit in the picture
Definition at line 2311 of file rc_quadratic.c.
References InputParameters::intra_period, InputParameters::MbInterlace, and InputParameters::PicInterlace.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| void updateMADModel | ( | rc_quadratic * | prc | ) |
update the parameters of linear prediction model
Definition at line 1106 of file rc_quadratic.c.
References ImageParameters::BasicUnit, error(), ImageParameters::FrameSizeInMbs, MADModelEstimator(), InputParameters::MbInterlace, ImageParameters::number, InputParameters::PicInterlace, InputParameters::RCUpdateMode, and ImageParameters::type.
Referenced by updateRCModel().

| void updateModelQPBU | ( | rc_quadratic * | prc, | |
| int | topfield, | |||
| int | m_Qp | |||
| ) |
update QP using the quadratic model for basic unit coding
Definition at line 2385 of file rc_quadratic.c.
References InputParameters::basicunit, Qstep2QP(), ImageParameters::RCMaxQP, and ImageParameters::RCMinQP.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().

| void updateModelQPFrame | ( | rc_quadratic * | prc, | |
| int | m_Bits | |||
| ) |
update QP with quadratic model
Definition at line 2448 of file rc_quadratic.c.
References Qstep2QP().
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().

| int updateNegativeTarget | ( | rc_quadratic * | prc, | |
| int | topfield, | |||
| int | m_Qp | |||
| ) |
update QP when bit target is negative
Definition at line 2180 of file rc_quadratic.c.
References InputParameters::basicunit, InputParameters::intra_period, InputParameters::MbInterlace, InputParameters::PicInterlace, and ImageParameters::RCMaxQP.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| void updateQPInterlace | ( | rc_quadratic * | prc | ) |
Save previous QP values for interlaced coding.
Definition at line 2068 of file rc_quadratic.c.
Referenced by updateQPRC0(), updateQPRC2(), and updateQPRC3().
| void updateQPInterlaceBU | ( | rc_quadratic * | prc | ) |
update QP variables for interlaced pictures and basic unit coding
Definition at line 2426 of file rc_quadratic.c.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| void updateQPNonPicAFF | ( | rc_quadratic * | prc | ) |
Save previous QP values for the case of non-PicAFF.
Definition at line 2094 of file rc_quadratic.c.
Referenced by updateQPRC0(), updateQPRC1(), updateQPRC2(), and updateQPRC3().
| int updateQPRC0 | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
compute a quantization parameter for each frame (RC_MODE_0)
Definition at line 1270 of file rc_quadratic.c.
References ImageParameters::BasicUnit, ImageParameters::FrameSizeInMbs, InputParameters::MbInterlace, InputParameters::NumberBFrames, InputParameters::PicInterlace, predictCurrPicMAD(), ImageParameters::RCMaxQP, ImageParameters::RCMinQP, ImageParameters::type, updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlace(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().

| int updateQPRC1 | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
compute a quantization parameter for each frame
Definition at line 1521 of file rc_quadratic.c.
References ImageParameters::BasicUnit, ImageParameters::FrameSizeInMbs, InputParameters::MbInterlace, ImageParameters::number, InputParameters::PicInterlace, predictCurrPicMAD(), ImageParameters::RCMaxQP, ImageParameters::RCMinQP, updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().

| int updateQPRC2 | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
compute a quantization parameter for each frame
Definition at line 1670 of file rc_quadratic.c.
References ImageParameters::b_frame_to_code, ImageParameters::BasicUnit, ImageParameters::FrameSizeInMbs, ImageParameters::GopLevels, InputParameters::HierarchicalCoding, GOP_DATA::hierarchy_layer, InputParameters::MbInterlace, ImageParameters::nal_reference_idc, ImageParameters::number, InputParameters::PicInterlace, predictCurrPicMAD(), ImageParameters::RCMaxQP, ImageParameters::RCMinQP, ImageParameters::type, updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlace(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().

| int updateQPRC3 | ( | rc_quadratic * | prc, | |
| int | topfield | |||
| ) |
compute a quantization parameter for each frame
Definition at line 1882 of file rc_quadratic.c.
References ImageParameters::b_frame_to_code, ImageParameters::BasicUnit, ImageParameters::FrameSizeInMbs, InputParameters::HierarchicalCoding, GOP_DATA::hierarchy_layer, InputParameters::MbInterlace, ImageParameters::number, InputParameters::PicInterlace, predictCurrPicMAD(), ImageParameters::RCMaxQP, ImageParameters::RCMinQP, ImageParameters::type, updateBottomField(), updateFirstBU(), updateFirstP(), updateLastBU(), updateModelQPBU(), updateModelQPFrame(), updateNegativeTarget(), updateQPInterlace(), updateQPInterlaceBU(), and updateQPNonPicAFF().
Referenced by rc_init_seq().

| void updateRCModel | ( | rc_quadratic * | prc | ) |
update the parameters of quadratic R-D model
Definition at line 898 of file rc_quadratic.c.
References ImageParameters::BasicUnit, ComputeFrameMAD(), error(), ImageParameters::framepoc, ImageParameters::FrameSizeInMbs, InputParameters::MbInterlace, ImageParameters::number, InputParameters::PicInterlace, QP2Qstep(), RCModelEstimator(), InputParameters::RCUpdateMode, ImageParameters::type, and updateMADModel().
Referenced by rc_handle_mb(), and rc_update_pict().
