lencod.c File Reference

H.264/AVC reference encoder project main(). More...

#include "contributors.h"
#include <time.h>
#include <math.h>
#include <sys/timeb.h>
#include "global.h"
#include "cconv_yuv2rgb.h"
#include "configfile.h"
#include "context_ini.h"
#include "explicit_gop.h"
#include "explicit_seq.h"
#include "filehandle.h"
#include "image.h"
#include "input.h"
#include "img_io.h"
#include "slice.h"
#include "intrarefresh.h"
#include "leaky_bucket.h"
#include "memalloc.h"
#include "me_epzs.h"
#include "me_umhex.h"
#include "me_umhexsmp.h"
#include "output.h"
#include "parset.h"
#include "q_matrix.h"
#include "q_offsets.h"
#include "ratectl.h"
#include "report.h"
#include "rdoq.h"
#include "errdo.h"
#include "rdopt.h"
#include "wp_mcprec.h"
#include "mv-search.h"

Include dependency graph for lencod.c:

Go to the source code of this file.

Functions

int allocate_block_mem (void)
void free_block_mem (void)
int allocate_mb_mem (void)
void free_mb_mem (void)
static void SetLevelIndices (void)
static void chroma_mc_setup (void)
static int get_mem_mv (short *******mv)
static int get_mem_bipred_mv (short ********bipred_mv)
static void free_mem_bipred_mv (short *******bipred_mv)
static void free_mem_mv (short ******mv)
static void init_img (ImageParameters *img, InputParameters *params)
static void init_poc ()
static void init_encoder (ImageParameters *img)
static void encode_sequence (ImageParameters *img)
void init_stats (StatParameters *stats)
void init_dstats (DistortionParams *dist)
static void init_frame_params (ImageParameters *p_img)
static void alloc_img (ImageParameters **p_img)
int main (int argc, char **argv)
static int determine_coding_level (ImageParameters *p_img, InputParameters *pparams, int curr_frame)
static void SetImgType (ImageParameters *img, int gop_frame_num)
static void set_poc (ImageParameters *img, double frame_to_code)
static void prepare_first_layer (ImageParameters *p_img, int curr_frame_to_code)
static void prepare_second_layer (ImageParameters *p_img, int enh_frame_to_code)
void free_encoder_memory (ImageParameters *img)
static int alloc_rddata (ImageParameters *img, RD_DATA *rd_data)
static void free_rddata (RD_DATA *rd_data)
void CAVLC_init (void)
void free_img ()
Picture * malloc_picture ()
void free_picture (Picture *pic)
int init_orig_buffers (ImageData *imgData)
int init_global_buffers (void)
void free_orig_planes (ImageData *imgData)
void free_global_buffers (void)
int get_mem_ACcoeff (int *****cofAC)
int get_mem_ACcoeff_new (int ******cofAC, int chroma)
int get_mem_DCcoeff (int ****cofDC)
void free_mem_ACcoeff (int ****cofAC)
void free_mem_ACcoeff_new (int *****cofAC)
void free_mem_DCcoeff (int ***cofDC)
void Init_redundant_frame ()
void Set_redundant_frame ()
void encode_one_redundant_frame ()

Variables

InputParameters * params = NULL
ImageParameters * img = NULL
int initial_Bframes
int cabac_encoding
int frame_statistic_start
ColocatedParams * Co_located
ColocatedParams * Co_located_JV [MAX_PLANE]
double * mb16x16_cost_frame


Detailed Description

H.264/AVC reference encoder project main().

lencod.c

Author:
Main contributors (see contributors.h for copyright, address and affiliation details)

Definition in file lencod.c.


Function Documentation

static void alloc_img ( ImageParameters **  p_img  )  [static]

Allocate the Image structure.

Output:
Image Parameters ImageParameters *img

Definition at line 211 of file lencod.c.

References get_mem3Dint(), get_mem3Dpel(), get_mem4Dpel(), and no_mem_exit().

Referenced by main().

Here is the call graph for this function:

void CAVLC_init ( void   ) 

Initializes the img->nz_coeff.

Input:
none
Output:
none \ side effects sets omg->nz_coef[][][][] to -1

Definition at line 793 of file lencod.c.

References ImageParameters::num_blk8x8_uv, ImageParameters::nz_coeff, and ImageParameters::PicSizeInMbs.

Referenced by start_slice().

static void chroma_mc_setup ( void   )  [static]

Setup Chroma MC Variables.

Definition at line 2036 of file lencod.c.

References IMG_PAD_SIZE, YUV420, YUV422, and ImageParameters::yuv_format.

Referenced by init_global_buffers().

static int determine_coding_level ( ImageParameters *  p_img,
InputParameters *  pparams,
int  curr_frame 
) [static]

Determine coding level a frame belongs to.

Definition at line 371 of file lencod.c.

References ImageParameters::last_idr_number, and InputParameters::NumberBFrames.

Referenced by encode_sequence().

void encode_one_redundant_frame ( void   ) 

encode on redundant frame.

Definition at line 2013 of file lencod.c.

References ImageParameters::currentPicture, encode_one_frame(), ImageParameters::redundant_pic_cnt, set_slice_type(), and ImageParameters::type.

Referenced by encode_sequence().

Here is the call graph for this function:

static void encode_sequence ( ImageParameters *  img  )  [static]

void free_encoder_memory ( ImageParameters *  img  ) 

void free_global_buffers ( void   ) 

Free allocated memory of frame size related global buffers buffers are defined in global.h, allocated memory is allocated in int get_mem4global_buffers().

Input:
Input Parameters struct inp_par *inp,
Image Parameters ImageParameters *img
Output:
none

Definition at line 1521 of file lencod.c.

References ImageParameters::b8x8info, ImageParameters::bitdepth_luma_qp_scale, InputParameters::BRefPictures, InputParameters::CtxAdptLagrangeMult, direct_pdir, direct_ref_idx, InputParameters::DistortionYUVtoRGB, EPZSDelete(), free_errdo_mem(), free_mem2D(), free_mem2Dint(), free_mem2Dodouble(), free_mem2Dolm(), free_mem2Dpel(), free_mem3D(), free_mem3Dint(), free_mem3Dodouble(), free_mem3Doint(), free_mem3Dpel(), free_mem4Dint(), free_orig_planes(), free_picture(), free_QMatrix(), free_QOffsets(), ImageParameters::frm_iter, InputParameters::GenerateMultiplePPS, imgUV_com, imgY_com, imgY_sub_tmp, ImageParameters::intra_block, InputParameters::IntraProfile, ImageParameters::ipredmode, ImageParameters::ipredmode8x8, ImageParameters::lambda, ImageParameters::lambda_md, ImageParameters::lambda_me, ImageParameters::lambda_mf, ImageParameters::lambda_mf_factor, ImageParameters::mb_data, ImageParameters::mb_data_JV, ImageParameters::nz_coeff, pixel_map, InputParameters::ProfileIDC, rc_free_memory(), InputParameters::RCEnable, InputParameters::rdopt, InputParameters::redundant_pic_flag, refresh_map, InputParameters::RestrictRef, InputParameters::SearchMode, InputParameters::si_frame_indicator, smpUMHEX_free_mem(), InputParameters::sp_periodicity, UMHEX_free_mem(), InputParameters::UseConstrainedIntraPred, InputParameters::WeightedBiprediction, InputParameters::WeightedPrediction, InputParameters::WPMCPrecision, wpxFreeWPXObject(), YUV400, and ImageParameters::yuv_format.

Referenced by free_encoder_memory().

Here is the call graph for this function:

void free_img ( void   ) 

void free_mem_ACcoeff ( int ****  cofAC  ) 

Free memory of AC coefficients.

Definition at line 1795 of file lencod.c.

References free_mem4Dint().

Referenced by clear_rdopt(), and free_img().

Here is the call graph for this function:

void free_mem_ACcoeff_new ( int *****  cofAC  ) 

Free memory of AC coefficients.

Definition at line 1806 of file lencod.c.

References free_mem5Dint().

Referenced by clear_rdopt().

Here is the call graph for this function:

static void free_mem_bipred_mv ( short *******  bipred_mv  )  [static]

Free memory from mv.

Input:
int****** mv

Definition at line 1745 of file lencod.c.

References free_mem7Dshort().

Referenced by free_img().

Here is the call graph for this function:

void free_mem_DCcoeff ( int ***  cofDC  ) 

Free memory of DC coefficients.

Definition at line 1817 of file lencod.c.

References free_mem3Dint().

Referenced by clear_rdopt(), and free_img().

Here is the call graph for this function:

static void free_mem_mv ( short ******  mv  )  [static]

Free memory from mv.

Input:
int****** mv

Definition at line 1731 of file lencod.c.

References free_mem6Dshort().

Referenced by free_img().

Here is the call graph for this function:

void free_orig_planes ( ImageData *  imgData  ) 

Free allocated memory of original picture buffers.

Definition at line 1474 of file lencod.c.

References free_mem2Dpel(), free_top_bot_planes(), YUV400, and ImageParameters::yuv_format.

Referenced by free_global_buffers().

Here is the call graph for this function:

void free_picture ( Picture *  pic  ) 

Frees a picture.

Parameters:
pic,: POinter to a Picture to be freed

Definition at line 1221 of file lencod.c.

References free_slice_list().

Referenced by free_global_buffers().

Here is the call graph for this function:

int get_mem_ACcoeff ( int *****  cofAC  ) 

Allocate memory for AC coefficients.

Definition at line 1756 of file lencod.c.

References get_mem4Dint(), and ImageParameters::num_blk8x8_uv.

Referenced by init_img(), and init_rdopt().

Here is the call graph for this function:

int get_mem_ACcoeff_new ( int ******  cofAC,
int  chroma 
)

Allocate memory for AC coefficients.

Definition at line 1770 of file lencod.c.

References get_mem5Dint().

Referenced by init_rdopt().

Here is the call graph for this function:

static int get_mem_bipred_mv ( short ********  bipred_mv  )  [static]

Allocate memory for bipredictive mv.

Input:
Image Parameters ImageParameters *img
int****** mv
Returns:
memory size in bytes

Definition at line 1716 of file lencod.c.

References get_mem7Dshort(), and ImageParameters::max_num_references.

Referenced by init_img().

Here is the call graph for this function:

int get_mem_DCcoeff ( int ****  cofDC  ) 

Allocate memory for DC coefficients.

Definition at line 1782 of file lencod.c.

References get_mem3Dint().

Referenced by init_img(), and init_rdopt().

Here is the call graph for this function:

static int get_mem_mv ( short *******  mv  )  [static]

Allocate memory for mv.

Input:
Image Parameters ImageParameters *img
int****** mv
Returns:
memory size in bytes

Definition at line 1698 of file lencod.c.

References get_mem6Dshort(), and ImageParameters::max_num_references.

Referenced by init_img().

Here is the call graph for this function:

static void init_encoder ( ImageParameters *  img  )  [static]

static void init_frame_params ( ImageParameters *  p_img  )  [static]

int init_global_buffers ( void   ) 

Dynamic memory allocation of frame size related global buffers buffers are defined in global.h, allocated memory must be freed in void free_global_buffers().

Input:
Input Parameters struct inp_par *inp,
Image Parameters ImageParameters *img
Returns:
Number of allocated bytes

Definition at line 1315 of file lencod.c.

References allocate_errdo_mem(), InputParameters::BRefPictures, chroma_mc_setup(), InputParameters::ChromaMCBuffer, direct_pdir, direct_ref_idx, InputParameters::DistortionYUVtoRGB, EPZSInit(), ImageParameters::FrameSizeInMbs, ImageParameters::frm_iter, InputParameters::GenerateMultiplePPS, get_mem2D(), get_mem2Dint(), get_mem2Dpel(), get_mem3D(), get_mem3Dint(), get_mem3Dpel(), get_mem4Dint(), ImageParameters::height, ImageParameters::height_blk, ImageParameters::height_cr, ImageParameters::height_padded, IMG_PAD_SIZE, imgUV_com, imgY_com, imgY_sub_tmp, init_orig_buffers(), InputParameters::IntraProfile, malloc_picture(), no_mem_exit(), InputParameters::NumberBFrames, InputParameters::PicInterlace, ImageParameters::PicWidthInMbs, pixel_map, InputParameters::ProfileIDC, rc_allocate_memory(), InputParameters::RCEnable, InputParameters::rdopt, InputParameters::redundant_pic_flag, refresh_map, InputParameters::RestrictRef, InputParameters::SearchMode, InputParameters::si_frame_indicator, smpUMHEX_get_mem(), smpUMHEX_init(), InputParameters::sp_periodicity, UMHEX_get_mem(), InputParameters::WeightedBiprediction, InputParameters::WeightedPrediction, ImageParameters::width, ImageParameters::width_blk, ImageParameters::width_cr, ImageParameters::width_padded, InputParameters::WPMCPrecision, wpxInitWPXObject(), YUV400, and ImageParameters::yuv_format.

Referenced by init_encoder().

Here is the call graph for this function:

static void init_img ( ImageParameters *  img,
InputParameters *  params 
) [static]

Initializes the Image structure with appropriate parameters.

Input:
Input Parameters struct inp_par *inp
Output:
Image Parameters ImageParameters *img

Definition at line 809 of file lencod.c.

References InputParameters::AdaptiveRounding, ImageParameters::all_mv, AllocateFrameMemory(), ImageParameters::ARCofAdj4x4, ImageParameters::ARCofAdj8x8, ImageParameters::auto_crop_bottom, ImageParameters::auto_crop_right, ImageParameters::b8x8info, ImageParameters::b_frame_to_code, ImageParameters::base_dist, ImageParameters::bipred_mv, InputParameters::BiPredMotionEstimation, ImageParameters::bitdepth_chroma, ImageParameters::bitdepth_chroma_qp_scale, ImageParameters::bitdepth_lambda_scale, ImageParameters::bitdepth_luma, ImageParameters::bitdepth_luma_qp_scale, ImageParameters::bitdepth_scale, ImageParameters::buf_cycle, ImageParameters::chroma_qp_offset, ImageParameters::ChromaArrayType, ImageParameters::cofAC, ImageParameters::cofDC, ImageParameters::colour_plane_id, InputParameters::CtxAdptLagrangeMult, ImageParameters::curr_prd, ImageParameters::curr_res, ImageParameters::dc_pred_value, ImageParameters::dc_pred_value_comp, ImageParameters::DeblockCall, InputParameters::DFAlpha, InputParameters::DFBeta, InputParameters::DFDisableIdc, InputParameters::DFSendParameters, ImageParameters::frame_interval, InputParameters::frame_skip, ImageParameters::FrameHeightInMbs, ImageParameters::framerate, ImageParameters::FrameSizeInMbs, ImageParameters::frm_iter, get_mem2D(), get_mem2Dodouble(), get_mem2Dolm(), get_mem3Dint(), get_mem3Dodouble(), get_mem3Doint(), get_mem4Dint(), get_mem5Dshort(), get_mem_ACcoeff(), get_mem_bipred_mv(), get_mem_DCcoeff(), get_mem_mv(), ImageParameters::gop_number, ImageParameters::GopLevels, ImageParameters::height, ImageParameters::height_blk, ImageParameters::height_cr, ImageParameters::height_cr_frame, ImageParameters::height_padded, ImageParameters::idr_gop_number, ImageParameters::idr_refresh, IMG_PAD_SIZE, initInput(), ImageParameters::intra_block, InputParameters::IntraProfile, RD_DATA::ipredmode, ImageParameters::ipredmode, ImageParameters::ipredmode8x8, InputParameters::jumpd, ImageParameters::lambda, ImageParameters::lambda_md, ImageParameters::lambda_me, ImageParameters::lambda_mf, ImageParameters::lambda_mf_factor, ImageParameters::last_idr_number, ImageParameters::last_ref_idc, ImageParameters::lastIDRnumber, ImageParameters::lastINTRA, ImageParameters::lastIntraNumber, ImageParameters::max_bitCount, ImageParameters::max_imgpel_value, ImageParameters::max_imgpel_value_comp, ImageParameters::max_imgpel_value_comp_sq, ImageParameters::max_num_references, ImageParameters::max_qp_delta, ImageParameters::mb_cr_size_x, ImageParameters::mb_cr_size_y, ImageParameters::mb_data, ImageParameters::mb_data_JV, ImageParameters::mb_pred, ImageParameters::mb_rres, ImageParameters::mb_size, ImageParameters::mb_y_upd, InputParameters::MbInterlace, ImageParameters::min_IPCM_value, ImageParameters::min_qp_delta, no_mem_exit(), ImageParameters::num_blk8x8_uv, ImageParameters::num_cdc_coeff, InputParameters::num_ref_frames, ImageParameters::num_ref_frames, ImageParameters::number, InputParameters::NumberBFrames, ImageParameters::nz_coeff, ImageParameters::out_unit_size_on_disk, InputParameters::output, ImageParameters::P444_joined, ImageParameters::pic_unit_size_on_disk, ImageParameters::PicHeightInMapUnits, ImageParameters::PicWidthInMbs, ImageParameters::quad, RandomIntraInit(), InputParameters::RandomIntraMBRefresh, InputParameters::RCMaxQP, ImageParameters::RCMaxQP, InputParameters::RCMinQP, ImageParameters::RCMinQP, rddata_bot_field_mb, rddata_bot_frame_mb, InputParameters::RDOQ_CP_MV, InputParameters::RDOQ_QP_Num, InputParameters::RDPictureDecision, ImageParameters::rewind_frame, InputParameters::separate_colour_plane_flag, ImageParameters::size, ImageParameters::size_cr, InputParameters::source, ImageParameters::start_frame_no, ImageParameters::start_tr_gop, InputParameters::Transform8x8Mode, InputParameters::UseConstrainedIntraPred, InputParameters::UseRDOQuant, ImageParameters::width, ImageParameters::width_blk, ImageParameters::width_cr, ImageParameters::width_padded, YUV400, YUV420, YUV422, YUV444, and ImageParameters::yuv_format.

Referenced by init_encoder().

Here is the call graph for this function:

int init_orig_buffers ( ImageData *  imgData  ) 

memory allocation for original picture buffers

Definition at line 1237 of file lencod.c.

References get_mem2Dpel(), ImageParameters::height, ImageParameters::height_cr, init_top_bot_planes(), InputParameters::output, ImageParameters::width, ImageParameters::width_cr, YUV400, and ImageParameters::yuv_format.

Referenced by init_global_buffers().

Here is the call graph for this function:

void init_poc ( void   )  [static]

void Init_redundant_frame ( void   ) 

int main ( int  argc,
char **  argv 
)

Main function for encoder.

Parameters:
argc number of command line arguments
argv command line arguments
Returns:
exit code

Definition at line 237 of file lencod.c.

References alloc_img(), Configure(), encode_sequence(), free_encoder_memory(), init_encoder(), and p_dec.

Here is the call graph for this function:

Picture* malloc_picture (  ) 

Allocates the picture structure along with its dependent data structures.

Returns:
Pointer to a Picture

Note: slice structures are allocated as needed in code_a_picture

Definition at line 1205 of file lencod.c.

References no_mem_exit().

Referenced by init_global_buffers().

Here is the call graph for this function:

static void prepare_first_layer ( ImageParameters *  p_img,
int  curr_frame_to_code 
) [static]

static void prepare_second_layer ( ImageParameters *  p_img,
int  enh_frame_to_code 
) [static]

void Set_redundant_frame ( void   ) 

allocate redundant frames in a primary GOP.

Definition at line 1946 of file lencod.c.

References InputParameters::NumRedundantHierarchy, and InputParameters::PrimaryGOPLength.

Referenced by encode_sequence().

static void SetImgType ( ImageParameters *  img,
int  gop_frame_num 
) [static]

static void SetLevelIndices ( void   )  [static]

Sets indices to appropriate level constraints, depending on current level_idc.

Definition at line 1829 of file lencod.c.

References ImageParameters::LevelIndex.

Referenced by init_encoder().


Variable Documentation

Co_located to be used during 4:4:4 independent mode encoding.

Definition at line 42 of file mbuffer.c.


Documentation generated with DoxyGen