#include "contributors.h"
#include <math.h>
#include <time.h>
#include "global.h"
#include "filehandle.h"
#include "mbuffer.h"
#include "img_luma.h"
#include "img_chroma.h"
#include "img_distortion.h"
#include "intrarefresh.h"
#include "slice.h"
#include "fmo.h"
#include "sei.h"
#include "memalloc.h"
#include "nalu.h"
#include "ratectl.h"
#include "mb_access.h"
#include "context_ini.h"
#include "biariencode.h"
#include "enc_statistics.h"
#include "conformance.h"
#include "report.h"
#include "q_matrix.h"
#include "q_offsets.h"
#include "wp.h"
#include "input.h"
#include "image.h"
#include "errdo.h"
#include "img_process.h"
#include "rdopt.h"
Go to the source code of this file.
Functions | |
void | DeblockFrame (ImageParameters *p_Img, imgpel **, imgpel ***) |
static void | code_a_picture (ImageParameters *p_Img, InputParameters *p_Inp, Picture *pic) |
static void | field_picture (ImageParameters *p_Img, InputParameters *p_Inp, Picture *top, Picture *bottom) |
static void | prepare_enc_frame_picture (ImageParameters *p_Img, InputParameters *p_Inp, StorablePicture **stored_pic) |
static void | writeout_picture (ImageParameters *p_Img, Picture *pic) |
static byte | picture_structure_decision (ImageParameters *p_Img, Picture *frame, Picture *top, Picture *bot) |
static void | distortion_fld (ImageParameters *p_Img, InputParameters *p_Inp, Picture *field_pic, ImageData *imgData) |
static void | field_mode_buffer (ImageParameters *p_Img) |
static void | frame_mode_buffer (ImageParameters *p_Img, InputParameters *p_Inp) |
static void | init_frame (ImageParameters *p_Img, InputParameters *p_Inp) |
static void | init_field (ImageParameters *p_Img, InputParameters *p_Inp) |
static void | put_buffer_frame (ImageParameters *p_Img) |
static void | put_buffer_top (ImageParameters *p_Img) |
static void | put_buffer_bot (ImageParameters *p_Img) |
static void | ReportFirstframe (ImageParameters *p_Img, InputParameters *p_Inp, StatParameters *p_Stats, int64 tmp_time) |
static void | ReportI (ImageParameters *p_Img, InputParameters *p_Inp, StatParameters *p_Stats, int64 tmp_time) |
static void | ReportP (ImageParameters *p_Img, InputParameters *p_Inp, StatParameters *p_Stats, int64 tmp_time) |
static void | ReportB (ImageParameters *p_Img, InputParameters *p_Inp, StatParameters *p_Stats, int64 tmp_time) |
static void | ReportNALNonVLCBits (ImageParameters *p_Img, InputParameters *p_Inp, StatParameters *p_Stats, int64 tmp_time) |
void | rd_picture_coding (ImageParameters *p_Img, InputParameters *p_Inp) |
void | MbAffPostProc (ImageParameters *p_Img) |
void | set_slice_type (ImageParameters *p_Img, InputParameters *p_Inp, int slice_type) |
static void | code_a_plane (ImageParameters *p_Img, InputParameters *p_Inp) |
byte | get_idr_flag (ImageParameters *p_Img, InputParameters *p_Inp) |
void | update_global_stats (InputParameters *p_Inp, StatParameters *gl_stats, StatParameters *cur_stats) |
static void | storeRedundantFrame (ImageParameters *p_Img) |
void | free_pictures (ImageParameters *p_Img, InputParameters *p_Inp, int stored_pic) |
int | encode_one_frame (ImageParameters *p_Img, InputParameters *p_Inp) |
void | copy_params (ImageParameters *p_Img, StorablePicture *enc_picture, seq_parameter_set_rbsp_t *active_sps) |
static void | calc_picture_bits (Picture *frame) |
void | frame_picture (ImageParameters *p_Img, InputParameters *p_Inp, Picture *frame, ImageData *imgData, int rd_pass) |
static void | combine_field (ImageParameters *p_Img) |
static byte | decide_fld_frame (float snr_frame_Y, float snr_field_Y, int bit_field, int bit_frame, double lambda_picture) |
static void | init_dec_ref_pic_marking_buffer (ImageParameters *p_Img) |
void | UnifiedOneForthPix (ImageParameters *p_Img, InputParameters *p_Inp, StorablePicture *s) |
void | UnifiedOneForthPix_JV (ImageParameters *p_Img, InputParameters *p_Inp, int nplane, StorablePicture *s) |
Boolean | dummy_slice_too_big (int bits_slice) |
static void | ReportSimple (ImageParameters *p_Img, char *pic_type, int cur_bits, DistMetric *metric, int tmp_time) |
static void | ReportVerbose (ImageParameters *p_Img, char *pic_type, int cur_bits, int wp_method, int lambda, DistMetric *mPSNR, int tmp_time, int direct_mode) |
static void | ReportVerboseNVB (ImageParameters *p_Img, char *pic_type, int cur_bits, int nvb_bits, int wp_method, int lambda, DistMetric *mPSNR, int tmp_time, int direct_mode) |
static void | ReportVerboseFDN (ImageParameters *p_Img, char *pic_type, int cur_bits, int fdn_bits, int nvb_bits, int wp_method, int lambda, DistMetric *mPSNR, int tmp_time, int direct_mode) |
static void | ReportVerboseSSIM (ImageParameters *p_Img, char *pic_type, int cur_bits, int wp_method, int lambda, DistMetric *mPSNR, DistMetric *mSSIM, int tmp_time, int direct_mode) |
static void | ReportVerboseNVBSSIM (ImageParameters *p_Img, char *pic_type, int cur_bits, int nvb_bits, int wp_method, int lambda, DistMetric *mPSNR, DistMetric *mSSIM, int tmp_time, int direct_mode) |
static void | ReportVerboseFDNSSIM (ImageParameters *p_Img, char *pic_type, int cur_bits, int fdn_bits, int nvb_bits, int wp_method, int lambda, DistMetric *mPSNR, DistMetric *mSSIM, int tmp_time, int direct_mode) |
int | CalculateFrameNumber (ImageParameters *p_Img, InputParameters *p_Inp) |
void | output_SP_coefficients (ImageParameters *p_Img, InputParameters *p_Inp) |
void | read_SP_coefficients (ImageParameters *p_Img, InputParameters *p_Inp) |
void | select_plane (ImageParameters *p_Img, ColorPlane color_plane) |
static int | is_gop_first_unit (ImageParameters *p_Img, InputParameters *p_Inp) |
void | write_non_vcl_nalu (ImageParameters *p_Img, InputParameters *p_Inp) |
Definition in file image.c.
int CalculateFrameNumber | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Calculates the absolute frame number in the source file out of various variables in p_Img-> and p_Inp->.
Definition at line 1911 of file image.c.
References GOP_DATA::display_no, inp_par_enc::EnableIDRGOP, img_par::frame_interval, inp_par_enc::frame_skip, img_par::gop_number, inp_par_enc::idr_period, inp_par_enc::intra_delay, inp_par_enc::no_frames, img_par::number, inp_par_enc::NumberBFrames, img_par::rewind_frame, img_par::start_frame_no, and img_par::start_tr_gop.
Referenced by prepare_first_layer(), and prepare_second_layer().
static void code_a_picture | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
Picture * | pic | |||
) | [static] |
Encodes a picture.
This is the main picture coding loop.. It is called by all this frame and field coding stuff after the p_Img-> elements have been set up. Not sure whether it is useful for MB-adaptive frame/field coding
Allocates forced INTRA MBs (even for fields!)
Definition at line 222 of file image.c.
References code_a_plane(), img_par::colour_plane_id, img_par::currentPicture, inp_par_enc::EnableIDRGOP, get_idr_flag(), img_par::MbaffFrameFlag, and RandomIntraNewPicture().
Referenced by field_picture(), and frame_picture().
static void code_a_plane | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
picture level initialization of FMO
Definition at line 165 of file image.c.
References CalculateOffset4x4Param(), CalculateOffset8x8Param(), CalculateQuant4x4Param(), CalculateQuant8x8Param(), DeblockFrame(), encode_one_slice(), encode_one_slice_MBAFF(), FmoEndPicture(), FmoInit(), FmoStartPicture(), storable_picture::imgUV, storable_picture::imgY, and img_par::MbaffFrameFlag.
Referenced by code_a_picture().
static void combine_field | ( | ImageParameters * | p_Img | ) | [static] |
form frame picture from two field pictures
Definition at line 1096 of file image.c.
References img_par::height, img_par::height_cr, storable_picture::imgUV, img_par::imgUV_com, storable_picture::imgY, img_par::imgY_com, img_par::width, img_par::width_cr, and YUV400.
Referenced by distortion_fld().
void DeblockFrame | ( | ImageParameters * | p_Img, | |
imgpel ** | , | |||
imgpel *** | ||||
) |
Filter all macroblocks in order of increasing macroblock address.
Definition at line 81 of file loopFilter.c.
References DeblockMb(), EdgeLoopChromaMBAff(), EdgeLoopChromaNormal(), EdgeLoopLumaMBAff(), EdgeLoopLumaNormal(), GetStrengthMBAff(), GetStrengthNormal(), img_par::mb_data, macroblock::mb_type, img_par::MbaffFrameFlag, macroblock::qp, and macroblock::qpc.
static byte decide_fld_frame | ( | float | snr_frame_Y, | |
float | snr_field_Y, | |||
int | bit_field, | |||
int | bit_frame, | |||
double | lambda_picture | |||
) | [static] |
RD decision of frame and field coding.
Definition at line 1156 of file image.c.
Referenced by picture_structure_decision().
static void distortion_fld | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
Picture * | field_pic, | |||
ImageData * | imgData | |||
) | [static] |
Distortion Field.
Definition at line 1125 of file image.c.
References combine_field(), find_distortion(), img_par::gop_number, img_par::height, img_par::height_cr, img_par::height_cr_frame, img_par::number, inp_par_enc::output, img_par::pCurImg, img_par::start_frame_no, and YUV400.
Referenced by field_picture().
Boolean dummy_slice_too_big | ( | int | bits_slice | ) |
int encode_one_frame | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Encodes one frame.
Definition at line 394 of file image.c.
References img_par::currentPicture, img_par::enc_frame_picture_JV, error(), field_mode_buffer(), field_picture(), frame_mode_buffer(), frame_picture(), free_pictures(), free_slice_list(), free_storable_picture(), img_par::frm_iter, img_par::gop_number, img_par::height, img_par::height_cr, img_par::imgData, img_par::imgData0, inp_par_enc::infile_header, init_frame(), inp_par_enc::input_file1, inp_par_enc::MbInterlace, inp_par_enc::output, output_SP_coefficients(), PaddAutoCropBorders(), inp_par_enc::PicInterlace, picture_structure_decision(), put_buffer_frame(), rc_init_frame(), inp_par_enc::RCEnable, rd_picture_coding(), inp_par_enc::RDPictureDecision, inp_par_enc::RDPictureIntra, read_SP_coefficients(), ReadOneFrame(), replace_top_pic_with_frame(), ReportNALNonVLCBits(), inp_par_enc::si_frame_indicator, inp_par_enc::source, inp_par_enc::sp2_frame_indicator, inp_par_enc::sp_output_indicator, store_picture_in_dpb(), update_global_stats(), UpdateDecoders(), UpdatePixelMap(), img_par::width, img_par::width_cr, inp_par_enc::WPIterMC, wpxInitWPXPasses(), write_non_vcl_nalu(), and writeout_picture().
Referenced by encode_one_redundant_frame(), and encode_sequence().
static void field_mode_buffer | ( | ImageParameters * | p_Img | ) | [static] |
Field Mode Buffer.
Definition at line 1199 of file image.c.
References put_buffer_frame().
Referenced by encode_one_frame().
static void field_picture | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
Picture * | top, | |||
Picture * | bottom | |||
) | [static] |
Encodes a field picture, consisting of top and bottom field.
Definition at line 992 of file image.c.
References alloc_storable_picture(), img_par::bottompoc, inp_par_enc::BRefPictures, code_a_picture(), distortion_fld(), img_par::frame_num, get_mb_block_pos_normal(), getNonAffNeighbour(), img_par::gop_number, img_par::height, img_par::height_cr, img_par::height_cr_frame, img_par::imgData, init_field(), inp_par_enc::IntraBottom, img_par::MbaffFrameFlag, img_par::number, inp_par_enc::output, put_buffer_bot(), put_buffer_top(), rc_init_bottom_field(), rc_init_top_field(), inp_par_enc::RCEnable, set_slice_type(), img_par::start_frame_no, store_picture_in_dpb(), img_par::structure, img_par::ThisPOC, img_par::toppoc, update_mv_limits(), img_par::width, and img_par::width_cr.
Referenced by encode_one_frame().
static void frame_mode_buffer | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Frame Mode Buffer.
Definition at line 1211 of file image.c.
References img_par::gop_number, img_par::height, img_par::height_cr, img_par::height_cr_frame, inp_par_enc::MbInterlace, img_par::number, inp_par_enc::output, inp_par_enc::PicInterlace, put_buffer_bot(), put_buffer_frame(), put_buffer_top(), and img_par::start_frame_no.
Referenced by encode_one_frame().
void frame_picture | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
Picture * | frame, | |||
ImageData * | imgData, | |||
int | rd_pass | |||
) |
Encodes a frame picture.
Definition at line 943 of file image.c.
References code_a_picture(), img_par::enc_frame_picture_JV, find_distortion(), make_frame_picture_JV(), prepare_enc_frame_picture(), img_par::structure, and update_mv_limits().
Referenced by encode_one_frame(), and rd_picture_coding().
void free_pictures | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | stored_pic | |||
) |
Free storable pictures.
Definition at line 378 of file image.c.
References free_storable_picture().
Referenced by encode_one_frame().
byte get_idr_flag | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Determine whether picture is coded as IDR.
Definition at line 268 of file image.c.
References img_par::gop_number, inp_par_enc::idr_period, and img_par::structure.
Referenced by code_a_picture(), is_gop_first_unit(), and write_non_vcl_nalu().
static void init_dec_ref_pic_marking_buffer | ( | ImageParameters * | p_Img | ) | [static] |
mmco initializations should go here
Definition at line 1244 of file image.c.
Referenced by init_frame().
static void init_field | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Initializes the parameters for a new field.
Definition at line 1394 of file image.c.
References img_par::fld_type, img_par::gop_number, inp_par_enc::intra_upd, inp_par_enc::jumpd, img_par::mb_y_intra, img_par::number, inp_par_enc::NumberBFrames, inp_par_enc::qp, img_par::qp, inp_par_enc::qpBRSOffset, inp_par_enc::qpsp, img_par::qpsp, inp_par_enc::RCEnable, GOP_DATA::slice_qp, inp_par_enc::sp2_frame_indicator, img_par::start_frame_no, and img_par::width.
Referenced by field_picture().
static void init_frame | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Initializes the parameters for a new frame.
KS: hard code qp increment
Definition at line 1256 of file image.c.
References inp_par_enc::AdaptiveRounding, img_par::AdaptiveRounding, inp_par_enc::direct_spatial_mv_pred_flag, img_par::direct_spatial_mv_pred_flag, img_par::height, init_dec_ref_pic_marking_buffer(), inp_par_enc::intra_upd, img_par::mb_data, img_par::mb_data_JV, img_par::mb_y_intra, inp_par_enc::qp, img_par::qp, inp_par_enc::qpBRSOffset, inp_par_enc::qpsp, img_par::qpsp, inp_par_enc::RCEnable, macroblock::slice_nr, GOP_DATA::slice_qp, inp_par_enc::sp2_frame_indicator, and inp_par_enc::WPIterMC.
Referenced by encode_one_frame().
static int is_gop_first_unit | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) | [static] |
Brief Is this picture the first access unit in this GOP?
Definition at line 2151 of file image.c.
References inp_par_enc::EnableOpenGOP, and get_idr_flag().
Referenced by write_non_vcl_nalu().
void output_SP_coefficients | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Brief Output SP frames coefficients
Definition at line 2025 of file image.c.
References error(), img_par::height, img_par::height_cr, inp_par_enc::sp_output_filename, img_par::width, and img_par::width_cr.
Referenced by encode_one_frame().
static byte picture_structure_decision | ( | ImageParameters * | p_Img, | |
Picture * | frame, | |||
Picture * | top, | |||
Picture * | bot | |||
) | [static] |
Picture Structure Decision.
all distrortions of a field picture are accumulated in the top field
Definition at line 1175 of file image.c.
References decide_fld_frame(), and img_par::qp.
Referenced by encode_one_frame().
static void prepare_enc_frame_picture | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
StorablePicture ** | stored_pic | |||
) | [static] |
Prepare and allocate an encoded frame picture structure.
Definition at line 901 of file image.c.
References alloc_storable_picture(), img_par::bottompoc, img_par::frame_num, img_par::framepoc, get_mb_block_pos_mbaff(), get_mb_block_pos_normal(), getAffNeighbour(), getNonAffNeighbour(), img_par::height, img_par::height_cr, img_par::MbaffFrameFlag, inp_par_enc::MbInterlace, img_par::structure, img_par::ThisPOC, img_par::toppoc, img_par::width, and img_par::width_cr.
Referenced by frame_picture().
static void put_buffer_bot | ( | ImageParameters * | p_Img | ) | [static] |
point to bottom field coding variables
Definition at line 2005 of file image.c.
References img_par::fld_type, img_par::imgData, img_par::pCurImg, and YUV400.
Referenced by field_picture(), and frame_mode_buffer().
static void put_buffer_frame | ( | ImageParameters * | p_Img | ) | [static] |
point to frame coding variables
Definition at line 1967 of file image.c.
References img_par::imgData, img_par::pCurImg, and YUV400.
Referenced by encode_one_frame(), field_mode_buffer(), and frame_mode_buffer().
static void put_buffer_top | ( | ImageParameters * | p_Img | ) | [static] |
point to top field coding variables
Definition at line 1985 of file image.c.
References img_par::fld_type, img_par::imgData, img_par::pCurImg, and YUV400.
Referenced by field_picture(), and frame_mode_buffer().
void rd_picture_coding | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
performs multi-pass encoding of same picture using different coding conditions
Definition at line 29 of file rd_pic_coding.c.
References img_par::AdaptiveRounding, BASELINE, frame_picture(), img_par::imgData, img_par::intras, picture_coding_decision(), img_par::qp, rc_init_frame_rdpic(), rc_save_state(), inp_par_enc::RCEnable, inp_par_enc::RDBSliceWeightOnly, inp_par_enc::RDPSliceBTest, inp_par_enc::RDPSliceWeightOnly, and set_slice_type().
Referenced by encode_one_frame().
void read_SP_coefficients | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Brief Read SP frames coefficients
Definition at line 2077 of file image.c.
References img_par::height, img_par::height_cr, img_par::size, inp_par_enc::sp2_input_filename1, inp_par_enc::sp2_input_filename2, img_par::width, and img_par::width_cr.
Referenced by encode_one_frame().
static void ReportNALNonVLCBits | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
StatParameters * | p_Stats, | |||
int64 | tmp_time | |||
) | [static] |
Need to add type (i.e. SPS, PPS, SEI etc).
Definition at line 1719 of file image.c.
Referenced by encode_one_frame().
void select_plane | ( | ImageParameters * | p_Img, | |
ColorPlane | color_plane | |||
) |
Brief Select appropriate image plane (for 444 coding)
Definition at line 2136 of file image.c.
References img_par::dc_pred_value, img_par::dc_pred_value_comp, img_par::max_imgpel_value, img_par::max_pel_value_comp, storable_picture::p_curr_img, storable_picture::p_curr_img_sub, storable_picture::p_img, storable_picture::p_img_sub, and img_par::pCurImg.
Referenced by encode_one_macroblock_low(), Intra16x16_Mode_Decision444(), luma_residual_coding_p444_16x16(), luma_residual_coding_p444_8x8(), Mode_Decision_for_4x4IntraBlocks_JM_High444(), Mode_Decision_for_4x4IntraBlocks_JM_Low444(), Mode_Decision_for_8x8IntraBlocks_JM_High444(), Mode_Decision_for_8x8IntraBlocks_JM_Low444(), rdcost_for_4x4_intra_blocks_444(), rdcost_for_8x8_intra_blocks_444(), and UnifiedOneForthPix().
void set_slice_type | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | slice_type | |||
) |
Sets slice type.
Definition at line 158 of file image.c.
Referenced by encode_one_redundant_frame(), ExplicitUpdateImgParams(), field_picture(), rd_picture_coding(), and SetImgType().
void UnifiedOneForthPix | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
StorablePicture * | s | |||
) |
Upsample 4 times, store them in out4x. Color is simply copied.
Definition at line 1502 of file image.c.
References get_mem4Dpel(), get_mem5Dpel(), getSubImagesChroma(), getSubImagesLuma(), storable_picture::imgUV_sub, storable_picture::imgY, storable_picture::imgY_sub, no_mem_exit(), storable_picture::p_curr_img, storable_picture::p_curr_img_sub, storable_picture::p_img_sub, select_plane(), YUV400, YUV420, and YUV422.
Referenced by dpb_combine_field(), dpb_split_field(), insert_picture_in_dpb(), and replace_top_pic_with_frame().
void UnifiedOneForthPix_JV | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp, | |||
int | nplane, | |||
StorablePicture * | s | |||
) |
Upsample 4 times, store them in out4x. Color is simply copied for 4:4:4 Independent mode.
Definition at line 1586 of file image.c.
References storable_picture::colour_plane_id, get_mem4Dpel(), get_mem5Dpel(), getSubImagesLuma(), storable_picture::imgUV, storable_picture::imgUV_sub, storable_picture::imgY, storable_picture::imgY_sub, no_mem_exit(), storable_picture::p_curr_img, storable_picture::p_curr_img_sub, storable_picture::p_img, and storable_picture::p_img_sub.
Referenced by dpb_combine_field(), dpb_split_field(), insert_picture_in_dpb(), and replace_top_pic_with_frame().
void update_global_stats | ( | InputParameters * | p_Inp, | |
StatParameters * | gl_stats, | |||
StatParameters * | cur_stats | |||
) |
void write_non_vcl_nalu | ( | ImageParameters * | p_Img, | |
InputParameters * | p_Inp | |||
) |
Brief AUD, SPS, PPS, and SEI messages
Commented out by StW, needs fixing in SEI.h to keep the trace file clean
Definition at line 2162 of file image.c.
References get_idr_flag(), is_gop_first_unit(), img_par::layer, img_par::number, PrepareAggregationSEIMessage(), rewrite_paramsets(), inp_par_enc::SendAUD, UpdateSubseqInfo(), Write_AUD_NALU(), and write_PPS().
Referenced by encode_one_frame().
static void writeout_picture | ( | ImageParameters * | p_Img, | |
Picture * | pic | |||
) | [static] |
This function write out a picture.
Definition at line 843 of file image.c.
References img_par::currentPicture, slice::max_part_nr, slice::partArr, and Bitstream::write_flag.
Referenced by encode_one_frame().