lencod.c File Reference

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

#include "contributors.h"
#include <time.h>
#include <math.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 "mc_prediction.h"
#include "memalloc.h"
#include "me_epzs_common.h"
#include "me_epzs_int.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 "img_process.h"

Include dependency graph for lencod.c:

Go to the source code of this file.

Functions

static void SetLevelIndices (ImageParameters *p_Img)
static void chroma_mc_setup (ImageParameters *p_Img)
static int init_global_buffers (ImageParameters *p_Img, InputParameters *p_Inp)
static void free_global_buffers (ImageParameters *p_Img, InputParameters *p_Inp)
static void free_img (ImageParameters *p_Img, InputParameters *p_Inp)
static void free_params (InputParameters *p_Inp)
static void init_img (ImageParameters *p_Img, InputParameters *p_Inp)
static void init_poc (ImageParameters *p_Img, InputParameters *p_Inp)
static void init_encoder (ImageParameters *p_Img, InputParameters *p_Inp)
static void encode_sequence (ImageParameters *p_Img, InputParameters *p_Inp)
void init_stats (InputParameters *p_Inp, StatParameters *p_Stats)
void init_dstats (DistortionParams *p_Dist)
static void init_frame_params (ImageParameters *p_Img, InputParameters *p_Inp)
static void alloc_img (ImageParameters **p_Img)
static void alloc_params (InputParameters **p_Inp)
static void alloc_encoder (EncoderParams **p_Enc)
static void free_encoder (EncoderParams *p_Enc)
int main (int argc, char **argv)
static int determine_coding_level (ImageParameters *p_Img, InputParameters *p_Inp, int curr_frame)
static void SetImgType (ImageParameters *p_Img, InputParameters *p_Inp, int gop_frame_num)
static void set_poc (ImageParameters *p_Img, InputParameters *p_Inp, double frame_to_code)
static void prepare_first_layer (ImageParameters *p_Img, InputParameters *p_Inp, int curr_frame_to_code)
static void prepare_second_layer (ImageParameters *p_Img, InputParameters *p_Inp, int enh_frame_to_code)
void free_encoder_memory (ImageParameters *p_Img, InputParameters *p_Inp)
Picture * malloc_picture ()
void free_picture (Picture *pic)
int init_orig_buffers (ImageParameters *p_Img, InputParameters *p_Inp, ImageData *imgData)
void free_orig_planes (ImageParameters *p_Img, InputParameters *p_Inp, ImageData *imgData)
int get_mem_ACcoeff (ImageParameters *p_Img, 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 (ImageParameters *p_Img, InputParameters *p_Inp)
void Set_redundant_frame (ImageParameters *p_Img, InputParameters *p_Inp)
void encode_one_redundant_frame (ImageParameters *p_Img, InputParameters *p_Inp)

Variables

static const int mb_width_cr [4] = {0,8, 8,16}
static const int mb_height_cr [4] = {0,8,16,16}
EncoderParams * p_Enc = NULL


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_encoder ( EncoderParams **  p_Enc  )  [static]

Allocate the Encoder Structure.

Output:
Encoder Parameters

Definition at line 258 of file lencod.c.

References alloc_img(), alloc_params(), and no_mem_exit().

Referenced by main().

Here is the call graph for this function:

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

Allocate the Image structure.

Output:
Image Parameters ImageParameters *p_Img

Definition at line 203 of file lencod.c.

References no_mem_exit().

Referenced by alloc_encoder().

Here is the call graph for this function:

static void alloc_params ( InputParameters **  p_Inp  )  [static]

Allocate the Input structure.

Output:
Input Parameters InputParameters *p_Img

Definition at line 238 of file lencod.c.

References no_mem_exit().

Referenced by alloc_encoder().

Here is the call graph for this function:

static void chroma_mc_setup ( ImageParameters p_Img  )  [static]

Setup Chroma MC Variables.

Definition at line 1882 of file lencod.c.

References IMG_PAD_SIZE, YUV420, and YUV422.

Referenced by init_global_buffers().

static int determine_coding_level ( ImageParameters p_Img,
InputParameters p_Inp,
int  curr_frame 
) [static]

Determine coding level a frame belongs to.

Definition at line 434 of file lencod.c.

References inp_par_enc::NumberBFrames.

Referenced by encode_sequence().

void encode_one_redundant_frame ( ImageParameters p_Img,
InputParameters p_Inp 
)

encode one redundant frame.

Definition at line 1859 of file lencod.c.

References img_par::currentPicture, encode_one_frame(), and set_slice_type().

Referenced by encode_sequence().

Here is the call graph for this function:

static void encode_sequence ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

static void free_encoder ( EncoderParams *  p_Enc  )  [static]

Free the Encoder Structure.

Definition at line 275 of file lencod.c.

Referenced by main().

void free_encoder_memory ( ImageParameters p_Img,
InputParameters p_Inp 
)

static void free_global_buffers ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

static void free_img ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

Free the Image structures.

Input:
Image Parameters ImageParameters *p_Img

Definition at line 1069 of file lencod.c.

References inp_par_enc::AdaptiveRounding, img_par::ARCofAdj4x4, img_par::ARCofAdj8x8, DeleteFrameMemory(), and free_mem4Dint().

Referenced by free_encoder_memory().

Here is the call graph for this function:

void free_mem_ACcoeff ( int ****  cofAC  ) 

Free memory of AC coefficients.

Definition at line 1641 of file lencod.c.

References free_mem4Dint().

Referenced by clear_rdopt(), and free_slice().

Here is the call graph for this function:

void free_mem_ACcoeff_new ( int *****  cofAC  ) 

Free memory of AC coefficients.

Definition at line 1652 of file lencod.c.

References free_mem5Dint().

Referenced by clear_rdopt().

Here is the call graph for this function:

void free_mem_DCcoeff ( int ***  cofDC  ) 

Free memory of DC coefficients.

Definition at line 1663 of file lencod.c.

References free_mem3Dint().

Referenced by clear_rdopt(), and free_slice().

Here is the call graph for this function:

void free_orig_planes ( ImageParameters p_Img,
InputParameters p_Inp,
ImageData *  imgData 
)

Free allocated memory of original picture buffers.

Definition at line 1392 of file lencod.c.

References free_mem2Dpel(), free_top_bot_planes(), and YUV400.

Referenced by free_global_buffers().

Here is the call graph for this function:

static void free_params ( InputParameters p_Inp  )  [static]

Free the Input structures.

Input:
Input Parameters InputParameters *p_Inp

Definition at line 1103 of file lencod.c.

References inp_par_enc::run_length_minus1, inp_par_enc::slice_group_id, and inp_par_enc::top_left.

Referenced by main().

void free_picture ( Picture *  pic  ) 

Frees a picture.

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

Definition at line 1145 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 ( ImageParameters p_Img,
int *****  cofAC 
)

Allocate memory for AC coefficients.

Definition at line 1601 of file lencod.c.

References get_mem4Dint().

Referenced by init_rdopt(), and init_slice().

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 1616 of file lencod.c.

References get_mem5Dint().

Referenced by init_rdopt().

Here is the call graph for this function:

int get_mem_DCcoeff ( int ****  cofDC  ) 

Allocate memory for DC coefficients.

Definition at line 1628 of file lencod.c.

References get_mem3Dint().

Referenced by init_rdopt(), and init_slice().

Here is the call graph for this function:

static void init_encoder ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

static void init_frame_params ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

static int init_global_buffers ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

static void init_img ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

Initializes the Image structure with appropriate parameters.

Input:
Input Parameters InputParameters *inp
Output:
Image Parameters ImageParameters *p_Img

Definition at line 803 of file lencod.c.

References inp_par_enc::AdaptiveRounding, AllocateFrameMemory(), img_par::ARCofAdj4x4, img_par::ARCofAdj8x8, img_par::b8x8info, BASELINE, img_par::chroma_qp_offset, img_par::colour_plane_id, inp_par_enc::CtxAdptLagrangeMult, img_par::dc_pred_value, img_par::dc_pred_value_comp, EXTENDED, img_par::frame_interval, inp_par_enc::frame_skip, img_par::frm_iter, get_mem2D(), get_mem2Dodouble(), get_mem2Dolm(), get_mem3Dint(), get_mem3Dodouble(), get_mem3Doint(), get_mem4Dint(), img_par::gop_number, img_par::height, img_par::height_blk, img_par::height_cr, img_par::height_cr_frame, img_par::height_padded, img_par::idr_gop_number, IMG_PAD_SIZE, initInput(), img_par::ipredmode, img_par::ipredmode8x8, inp_par_enc::jumpd, img_par::lambda_md, img_par::lambda_me, img_par::lambda_mf, img_par::lambda_mf_factor, MAIN, img_par::max_imgpel_value, img_par::max_imgpel_value_comp_sq, img_par::max_num_references, img_par::max_pel_value_comp, img_par::mb_data, img_par::mb_data_JV, no_mem_exit(), inp_par_enc::num_ref_frames, img_par::num_ref_frames, img_par::number, inp_par_enc::NumberBFrames, img_par::nz_coeff, inp_par_enc::output, RandomIntraInit(), inp_par_enc::RandomIntraMBRefresh, inp_par_enc::RDPictureDecision, img_par::rewind_frame, img_par::size, img_par::size_cr, inp_par_enc::source, img_par::start_frame_no, img_par::start_tr_gop, inp_par_enc::UseConstrainedIntraPred, img_par::width, img_par::width_blk, img_par::width_cr, img_par::width_padded, YUV400, YUV420, YUV422, and YUV444.

Referenced by init_encoder().

Here is the call graph for this function:

int init_orig_buffers ( ImageParameters p_Img,
InputParameters p_Inp,
ImageData *  imgData 
)

memory allocation for original picture buffers

Definition at line 1161 of file lencod.c.

References get_mem2Dpel(), img_par::height, img_par::height_cr, init_top_bot_planes(), inp_par_enc::output, img_par::width, img_par::width_cr, and YUV400.

Referenced by init_global_buffers().

Here is the call graph for this function:

static void init_poc ( ImageParameters p_Img,
InputParameters p_Inp 
) [static]

Initializes the POC structure with appropriate parameters.

Definition at line 757 of file lencod.c.

References inp_par_enc::BRefPictures, inp_par_enc::MbInterlace, inp_par_enc::NumberBFrames, inp_par_enc::pic_order_cnt_type, and inp_par_enc::PicInterlace.

Referenced by init_encoder().

void Init_redundant_frame ( ImageParameters p_Img,
InputParameters p_Inp 
)

initialize key frames and corresponding redundant frames.

Definition at line 1746 of file lencod.c.

References error(), inp_par_enc::num_ref_frames, inp_par_enc::NumberBFrames, inp_par_enc::NumRedundantHierarchy, inp_par_enc::PicInterlace, and inp_par_enc::PrimaryGOPLength.

Referenced by encode_sequence().

Here is the call graph for this function:

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 295 of file lencod.c.

References alloc_encoder(), Configure(), encode_sequence(), free_encoder(), free_encoder_memory(), free_params(), and init_encoder().

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 1129 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,
InputParameters p_Inp,
int  curr_frame_to_code 
) [static]

static void prepare_second_layer ( ImageParameters p_Img,
InputParameters p_Inp,
int  enh_frame_to_code 
) [static]

void Set_redundant_frame ( ImageParameters p_Img,
InputParameters p_Inp 
)

allocate redundant frames in a primary GOP.

Definition at line 1792 of file lencod.c.

References inp_par_enc::NumRedundantHierarchy, and inp_par_enc::PrimaryGOPLength.

Referenced by encode_sequence().

static void SetImgType ( ImageParameters p_Img,
InputParameters p_Inp,
int  gop_frame_num 
) [static]

Set the image type for I,P and SP pictures (not B!).

Definition at line 452 of file lencod.c.

References inp_par_enc::BRefPictures, img_par::gop_number, inp_par_enc::idr_period, inp_par_enc::intra_period, set_slice_type(), and inp_par_enc::sp_periodicity.

Referenced by prepare_first_layer(), and prepare_second_layer().

Here is the call graph for this function:

static void SetLevelIndices ( ImageParameters p_Img  )  [static]

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

Definition at line 1675 of file lencod.c.

References img_par::LevelIndex.

Referenced by init_encoder().


Documentation generated with DoxyGen