#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"
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 |
Definition in file lencod.c.
static void alloc_encoder | ( | EncoderParams ** | p_Enc | ) | [static] |
Allocate the Encoder Structure.
Definition at line 258 of file lencod.c.
References alloc_img(), alloc_params(), and no_mem_exit().
Referenced by main().
static void alloc_img | ( | ImageParameters ** | p_Img | ) | [static] |
Allocate the Image structure.
Definition at line 203 of file lencod.c.
References no_mem_exit().
Referenced by alloc_encoder().
static void alloc_params | ( | InputParameters ** | p_Inp | ) | [static] |
Allocate the Input structure.
Definition at line 238 of file lencod.c.
References no_mem_exit().
Referenced by alloc_encoder().
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().
static void encode_sequence | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Encode a sequence.
Definition at line 616 of file lencod.c.
References img_par::currentPicture, determine_coding_level(), inp_par_enc::EnableOpenGOP, encode_one_frame(), encode_one_redundant_frame(), ExplicitUpdateImgParams(), img_par::frame_num, img_par::idr_gop_number, Init_redundant_frame(), inp_par_enc::jumpd, inp_par_enc::no_frames, inp_par_enc::NumberBFrames, prepare_first_layer(), prepare_second_layer(), ReadExplicitSeqFile(), report_frame_statistic(), Set_redundant_frame(), and img_par::ThisPOC.
Referenced by main().
static void free_encoder | ( | EncoderParams * | p_Enc | ) | [static] |
void free_encoder_memory | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Free memory allocated for the encoder.
Definition at line 699 of file lencod.c.
References clear_gop_structure(), Clear_Motion_Search_Module(), CloseExplicitSeqFile(), CloseFiles(), flush_dpb(), FmoUninit(), free_dpb(), free_global_buffers(), free_img(), FreeParameterSets(), inp_par_enc::input_file1, inp_par_enc::output, img_par::p_dec, report(), terminate_sequence(), and uninit_out_buffer().
Referenced by main(), and report_stats_on_error().
static void free_global_buffers | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Free allocated memory of frame size related global buffers buffers are defined in global.h, allocated memory is allocated in int get_mem4global_buffers().
Definition at line 1439 of file lencod.c.
References img_par::b8x8info, inp_par_enc::CtxAdptLagrangeMult, EPZSDelete(), free_errdo_mem(), free_mem2D(), free_mem2Dint(), free_mem2Dodouble(), free_mem2Dolm(), free_mem2Dpel(), free_mem2Dshort(), free_mem3Dint(), free_mem3Dodouble(), free_mem3Doint(), free_mem3Dpel(), free_orig_planes(), free_picture(), free_QMatrix(), free_QOffsets(), img_par::frm_iter, img_par::imgData, img_par::imgData0, img_par::imgUV_com, img_par::imgY_com, img_par::imgY_sub_tmp, inp_par_enc::IntraProfile, img_par::ipredmode, img_par::ipredmode8x8, img_par::lambda_md, img_par::lambda_me, img_par::lambda_mf, img_par::lambda_mf_factor, img_par::mb_data, img_par::mb_data_JV, img_par::nz_coeff, img_par::pixel_map, rc_free_memory(), inp_par_enc::RCEnable, img_par::refresh_map, inp_par_enc::si_frame_indicator, smpUMHEX_free_mem(), inp_par_enc::sp_periodicity, UMHEX_free_mem(), inp_par_enc::UseConstrainedIntraPred, wpxFreeWPXObject(), and YUV400.
Referenced by free_encoder_memory().
static void free_img | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Free the Image structures.
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().
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().
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().
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().
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().
static void free_params | ( | InputParameters * | p_Inp | ) | [static] |
Free the Input structures.
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.
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().
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().
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().
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().
static void init_encoder | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Initialize encoder.
Definition at line 325 of file lencod.c.
References create_hierarchy(), inp_par_enc::ErrorConcealment, GenerateParameterSets(), information_init(), init_dpb(), init_error_conceal(), init_global_buffers(), init_gop_structure(), init_img(), Init_Motion_Search_Module(), init_out_buffer(), init_poc(), Init_QMatrix(), Init_QOffsetMatrix(), inp_par_enc::input_file1, interpret_gop_structure(), inp_par_enc::no_frames, inp_par_enc::NumberBFrames, OneComponentChromaPrediction4x4_regenerate(), OneComponentChromaPrediction4x4_retrieve(), OpenExplicitSeqFile(), OpenFiles(), img_par::p_log, rc_init_sequence(), inp_par_enc::RCEnable, inp_par_enc::search_range, SetLevelIndices(), start_sequence(), and wpxInitWPXPasses().
Referenced by main().
static void init_frame_params | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Initialize encoding parameters.
Definition at line 119 of file lencod.c.
References img_par::bottompoc, inp_par_enc::BRefPictures, img_par::frame_num, img_par::framepoc, img_par::gop_number, inp_par_enc::idr_period, inp_par_enc::intra_delay, inp_par_enc::MbInterlace, inp_par_enc::no_frm_base, inp_par_enc::NumberBFrames, inp_par_enc::PicInterlace, and img_par::toppoc.
Referenced by prepare_first_layer().
static int init_global_buffers | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
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().
Definition at line 1242 of file lencod.c.
References allocate_errdo_mem(), chroma_mc_setup(), EPZSInit(), img_par::frm_iter, get_mem2D(), get_mem2Dint(), get_mem2Dpel(), get_mem2Dshort(), get_mem3Dint(), get_mem3Dpel(), img_par::height, img_par::height_cr, img_par::height_padded, IMG_PAD_SIZE, img_par::imgData, img_par::imgData0, img_par::imgUV_com, img_par::imgY_com, img_par::imgY_sub_tmp, init_orig_buffers(), inp_par_enc::IntraProfile, malloc_picture(), no_mem_exit(), inp_par_enc::PicInterlace, img_par::pixel_map, rc_allocate_memory(), inp_par_enc::RCEnable, img_par::refresh_map, inp_par_enc::si_frame_indicator, smpUMHEX_get_mem(), smpUMHEX_init(), inp_par_enc::sp_periodicity, UMHEX_get_mem(), img_par::width, img_par::width_cr, img_par::width_padded, wpxInitWPXObject(), and YUV400.
Referenced by init_encoder().
static void init_img | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Initializes the Image structure with appropriate parameters.
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().
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().
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().
int main | ( | int | argc, | |
char ** | argv | |||
) |
Main function for encoder.
argc | number of command line arguments | |
argv | command line arguments |
Definition at line 295 of file lencod.c.
References alloc_encoder(), Configure(), encode_sequence(), free_encoder(), free_encoder_memory(), free_params(), and init_encoder().
Picture* malloc_picture | ( | ) |
Allocates the picture structure along with its dependent data structures.
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().
static void prepare_first_layer | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | curr_frame_to_code | |||
) | [static] |
Prepare first coding layer.
Definition at line 515 of file lencod.c.
References CalculateFrameNumber(), clear_gop_structure(), create_hierarchy(), img_par::gop_number, init_frame_params(), init_gop_structure(), img_par::layer, inp_par_enc::no_frames, img_par::number, inp_par_enc::NumberBFrames, rc_init_gop_params(), inp_par_enc::RCEnable, SetImgType(), and img_par::start_frame_no.
Referenced by encode_sequence().
static void prepare_second_layer | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | enh_frame_to_code | |||
) | [static] |
Prepare second coding layer.
Definition at line 553 of file lencod.c.
References img_par::bottompoc, inp_par_enc::BRefPictures, CalculateFrameNumber(), GOP_DATA::display_no, inp_par_enc::EnableIDRGOP, img_par::frame_interval, img_par::framepoc, img_par::gop_number, img_par::idr_gop_number, inp_par_enc::intra_delay, img_par::layer, inp_par_enc::MbInterlace, inp_par_enc::PicInterlace, GOP_DATA::reference_idc, SetImgType(), img_par::start_tr_gop, and img_par::toppoc.
Referenced by encode_sequence().
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().
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().