image.c File Reference

Code one image/slice. More...

#include "contributors.h"
#include <math.h>
#include <time.h>
#include <sys/timeb.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 dependency graph for image.c:

Go to the source code of this file.

Functions

void DeblockFrame (ImageParameters *img, imgpel **, imgpel ***)
static void code_a_picture (Picture *pic)
static void field_picture (Picture *top, Picture *bottom)
static void prepare_enc_frame_picture (StorablePicture **stored_pic)
static void writeout_picture (Picture *pic)
static byte picture_structure_decision (Picture *frame, Picture *top, Picture *bot)
static void distortion_fld (Picture *field_pic, ImageData *imgData)
static void field_mode_buffer (ImageParameters *img, InputParameters *params)
static void frame_mode_buffer (ImageParameters *img, InputParameters *params)
static void init_frame (ImageParameters *img)
static void init_field (ImageParameters *img)
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 PaddAutoCropBorders (FrameFormat output, int img_size_x, int img_size_y, int img_size_x_cr, int img_size_y_cr, imgpel **pImage[3])
static void rdPictureCoding (void)
static void ReportFirstframe (int64 tmp_time, int64 me_time)
static void ReportIntra (int64 tmp_time, int64 me_time)
static void ReportP (int64 tmp_time, int64 me_time)
static void ReportB (int64 tmp_time, int64 me_time)
static void ReportNALNonVLCBits (int64 tmp_time, int64 me_time)
void MbAffPostProc (void)
void set_slice_type (ImageParameters *p_img, int slice_type)
void code_a_plane (ImageParameters *img, Picture *pic)
int get_idr_flag (void)
void update_global_stats (StatParameters *gl_stats, StatParameters *cur_stats)
void free_pictures (int stored_pic)
int encode_one_frame (ImageParameters *img)
void copy_params (StorablePicture *enc_picture, seq_parameter_set_rbsp_t *active_sps)
static void calc_picture_bits (Picture *frame)
void frame_picture (Picture *frame, ImageData *imgData, int rd_pass)
static void combine_field (void)
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 (void)
void UnifiedOneForthPix (StorablePicture *s)
void UnifiedOneForthPix_JV (int nplane, StorablePicture *s)
Boolean dummy_slice_too_big (int bits_slice)
static void copy_motion_vectors_MB (ImageParameters *img, RD_DATA *rdopt)
void copy_rdopt_data (Macroblock *currMB, int bot_block)
static void ReportSimple (ImageParameters *cur_img, char *pic_type, int cur_bits, DistMetric *metric, int tmp_time, int me_time)
static void ReportVerbose (ImageParameters *cur_img, char *pic_type, int cur_bits, int wp_method, int lambda, DistMetric *mPSNR, int tmp_time, int me_time, int direct_mode)
static void ReportVerboseNVB (ImageParameters *cur_img, char *pic_type, int cur_bits, int nvb_bits, int wp_method, int lambda, DistMetric *mPSNR, int tmp_time, int me_time, int direct_mode)
static void ReportVerboseSSIM (ImageParameters *cur_img, char *pic_type, int cur_bits, int wp_method, int lambda, DistMetric *mPSNR, DistMetric *mSSIM, int tmp_time, int me_time, int direct_mode)
static void ReportVerboseNVBSSIM (ImageParameters *cur_img, char *pic_type, int cur_bits, int nvb_bits, int wp_method, int lambda, DistMetric *mPSNR, DistMetric *mSSIM, int tmp_time, int me_time, int direct_mode)
int CalculateFrameNumber (ImageParameters *p_img)
void output_SP_coefficients ()
void read_SP_coefficients ()
void select_plane (ColorPlane color_plane)
static int is_gop_first_unit (void)
void write_non_vcl_nalu (void)

Variables

pic_parameter_set_rbsp_t * PicParSet [MAXPPS]
StorablePicture * enc_picture
StorablePicture ** enc_frame_picture
StorablePicture ** enc_field_picture
StorablePicture * enc_frame_picture_JV [MAX_PLANE]


Detailed Description

Code one image/slice.

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

Definition in file image.c.


Function Documentation

int CalculateFrameNumber ( ImageParameters *  p_img  ) 

static void code_a_picture ( 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 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 226 of file image.c.

References code_a_plane(), ImageParameters::colour_plane_id, ImageParameters::current_mb_nr, ImageParameters::current_slice_nr, ImageParameters::currentPicture, InputParameters::EnableIDRGOP, ImageParameters::frm_no_in_file, ImageParameters::frm_number, get_idr_flag(), ImageParameters::last_idr_number, ImageParameters::MbaffFrameFlag, RandomIntraNewPicture(), and ImageParameters::SumFrameQP.

Referenced by field_picture(), and frame_picture().

Here is the call graph for this function:

void code_a_plane ( ImageParameters *  img,
Picture *  pic 
)

static void combine_field ( void   )  [static]

form frame picture from two field pictures

Definition at line 1078 of file image.c.

References ImageParameters::height, ImageParameters::height_cr, imgUV_com, imgY_com, ImageParameters::width, ImageParameters::width_cr, YUV400, and ImageParameters::yuv_format.

Referenced by distortion_fld().

void copy_rdopt_data ( Macroblock *  currMB,
int  bot_block 
)

For MB level field/frame coding

Definition at line 1633 of file image.c.

References RD_DATA::all_mv, RD_DATA::b8mode, macroblock::b8mode, RD_DATA::b8pdir, macroblock::b8pdir, macroblock::bipred_me, ImageParameters::block_x, ImageParameters::block_y, RD_DATA::c_ipred_mode, macroblock::c_ipred_mode, RD_DATA::cbp, macroblock::cbp, RD_DATA::cbp_blk, macroblock::cbp_blk, RD_DATA::cofAC, ImageParameters::cofAC, RD_DATA::cofDC, ImageParameters::cofDC, RD_DATA::delta_qp, macroblock::delta_qp, RD_DATA::i16offset, ImageParameters::i16offset, storable_picture::imgUV, storable_picture::imgY, RD_DATA::intra_pred_modes, macroblock::intra_pred_modes, RD_DATA::intra_pred_modes8x8, macroblock::intra_pred_modes8x8, RD_DATA::ipredmode, ImageParameters::ipredmode, macroblock::list_offset, RD_DATA::luma_transform_size_8x8_flag, macroblock::luma_transform_size_8x8_flag, ImageParameters::mb_cr_size_x, ImageParameters::mb_cr_size_y, RD_DATA::mb_type, macroblock::mb_type, ImageParameters::MbaffFrameFlag, RD_DATA::mode, storable_picture::motion, pic_motion_params::mv, ImageParameters::num_blk8x8_uv, ImageParameters::pix_c_x, ImageParameters::pix_c_y, ImageParameters::pix_x, ImageParameters::pix_y, RD_DATA::prev_cbp, macroblock::prev_cbp, RD_DATA::prev_dqp, macroblock::prev_dqp, RD_DATA::prev_qp, macroblock::prev_qp, RD_DATA::qp, macroblock::qp, InputParameters::RDOQ_QP_Num, RD_DATA::rec_mb_cr, RD_DATA::rec_mbY, pic_motion_params::ref_idx, pic_motion_params::ref_pic_id, storable_picture::ref_pic_num, RD_DATA::refar, ImageParameters::type, update_qp(), InputParameters::UseRDOQuant, YUV400, and ImageParameters::yuv_format.

Referenced by encode_one_slice_MBAFF().

Here is the call graph for this function:

void DeblockFrame ( ImageParameters *  img,
imgpel **  ,
imgpel ***   
)

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 1138 of file image.c.

Referenced by picture_structure_decision().

static void distortion_fld ( Picture *  field_pic,
ImageData *  imgData 
) [static]

Boolean dummy_slice_too_big ( int  bits_slice  ) 

Just a placebo.

Definition at line 1616 of file image.c.

Referenced by init_slice().

int encode_one_frame ( ImageParameters *  img  ) 

Encodes one frame.

Definition at line 361 of file image.c.

References InputParameters::AdaptiveRounding, ImageParameters::AdaptiveRounding, ImageParameters::AverageFrameQP, ImageParameters::b_frame_to_code, InputParameters::basicunit, ImageParameters::bot_MB, ImageParameters::currentPicture, InputParameters::DFAlpha, ImageParameters::DFAlphaC0Offset, InputParameters::DFBeta, ImageParameters::DFBetaOffset, InputParameters::DFDisableIdc, ImageParameters::DFDisableIdc, InputParameters::direct_spatial_mv_pred_flag, ImageParameters::direct_spatial_mv_pred_flag, error(), field_mode_buffer(), field_picture(), ImageParameters::field_picture, ImageParameters::fld_flag, frame_mode_buffer(), ImageParameters::frame_no, frame_picture(), ImageParameters::frameOffsetAvail, ImageParameters::FrameSizeInMbs, free_pictures(), free_slice_list(), free_storable_picture(), ImageParameters::frm_iter, ImageParameters::frm_no_in_file, ImageParameters::frm_number, InputParameters::GenerateMultiplePPS, ImageParameters::gop_number, ImageParameters::height, ImageParameters::height_cr, InputParameters::infile_header, init_frame(), InputParameters::input_file1, ImageParameters::lastIDRnumber, ImageParameters::lastINTRA, ImageParameters::lastIntraNumber, InputParameters::MbInterlace, ImageParameters::nal_reference_idc, InputParameters::output, output_SP_coefficients(), PaddAutoCropBorders(), ImageParameters::pic_order_cnt_type, InputParameters::PicInterlace, picture_structure_decision(), put_buffer_frame(), rc_init_frame(), InputParameters::RCEnable, InputParameters::RCUpdateMode, ImageParameters::rd_pass, InputParameters::rdopt, rdPictureCoding(), InputParameters::RDPictureDecision, InputParameters::RDPictureIntra, read_SP_coefficients(), ReadOneFrame(), InputParameters::redundant_pic_flag, replace_top_pic_with_frame(), ReportNALNonVLCBits(), InputParameters::RestrictRef, InputParameters::si_frame_indicator, InputParameters::source, InputParameters::sp2_frame_indicator, InputParameters::sp_output_indicator, storable_picture::stats, store_picture_in_dpb(), ImageParameters::SumFrameQP, ImageParameters::type, update_global_stats(), UpdateDecoders(), UpdatePixelMap(), InputParameters::Verbose, ImageParameters::width, ImageParameters::width_cr, InputParameters::WPIterMC, InputParameters::WPMCPrecision, wpxInitWPXPasses(), ImageParameters::write_macroblock, write_non_vcl_nalu(), and writeout_picture().

Referenced by encode_one_redundant_frame(), and encode_sequence().

Here is the call graph for this function:

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

Field Mode Buffer.

Definition at line 1182 of file image.c.

References put_buffer_frame().

Referenced by encode_one_frame().

Here is the call graph for this function:

static void field_picture ( Picture *  top,
Picture *  bottom 
) [static]

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

void frame_picture ( Picture *  frame,
ImageData *  imgData,
int  rd_pass 
)

void free_pictures ( int  stored_pic  ) 

Free storable pictures.

Definition at line 345 of file image.c.

References free_storable_picture().

Referenced by encode_one_frame().

Here is the call graph for this function:

int get_idr_flag ( void   ) 

static void init_dec_ref_pic_marking_buffer ( void   )  [static]

mmco initializations should go here

Definition at line 1227 of file image.c.

References ImageParameters::dec_ref_pic_marking_buffer.

Referenced by init_frame().

static void init_field ( ImageParameters *  img  )  [static]

static void init_frame ( ImageParameters *  img  )  [static]

static int is_gop_first_unit ( void   )  [static]

Brief Is this picture the first access unit in this GOP?

Definition at line 2517 of file image.c.

References InputParameters::EnableOpenGOP, get_idr_flag(), and ImageParameters::type.

Referenced by write_non_vcl_nalu().

Here is the call graph for this function:

void output_SP_coefficients ( void   ) 

Brief Output SP frames coefficients

Definition at line 2389 of file image.c.

References error(), ImageParameters::height, ImageParameters::height_cr, InputParameters::sp_output_filename, ImageParameters::width, and ImageParameters::width_cr.

Referenced by encode_one_frame().

Here is the call graph for this function:

static void PaddAutoCropBorders ( FrameFormat  output,
int  img_size_x,
int  img_size_y,
int  img_size_x_cr,
int  img_size_y_cr,
imgpel **  pImage[3] 
) [static]

Padding of automatically added border for picture sizes that are not multiples of macroblock/macroblock pair size.

Parameters:
output Image dimensions
img_size_x coded image horizontal size (luma)
img_size_y code image vertical size (luma)
img_size_x_cr coded image horizontal size (chroma)
img_size_y_cr code image vertical size (chroma)
pImage image planes

Definition at line 1991 of file image.c.

References YUV400, and ImageParameters::yuv_format.

Referenced by encode_one_frame().

static byte picture_structure_decision ( 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 1157 of file image.c.

References ImageParameters::bitdepth_lambda_scale, decide_fld_frame(), ImageParameters::qp, and ImageParameters::type.

Referenced by encode_one_frame().

Here is the call graph for this function:

static void prepare_enc_frame_picture ( StorablePicture **  stored_pic  )  [static]

static void put_buffer_bot ( ImageParameters *  img  )  [static]

point to bottom field coding variables

Definition at line 2135 of file image.c.

References ImageParameters::fld_type, pCurImg, YUV400, and ImageParameters::yuv_format.

Referenced by field_picture(), and frame_mode_buffer().

static void put_buffer_frame ( ImageParameters *  img  )  [static]

point to frame coding variables

Definition at line 2097 of file image.c.

References pCurImg, YUV400, and ImageParameters::yuv_format.

Referenced by encode_one_frame(), field_mode_buffer(), and frame_mode_buffer().

static void put_buffer_top ( ImageParameters *  img  )  [static]

point to top field coding variables

Definition at line 2115 of file image.c.

References ImageParameters::fld_type, pCurImg, YUV400, and ImageParameters::yuv_format.

Referenced by field_picture(), and frame_mode_buffer().

static void rdPictureCoding ( void   )  [static]

void read_SP_coefficients ( void   ) 

static void ReportNALNonVLCBits ( int64  tmp_time,
int64  me_time 
) [static]

Need to add type (i.e. SPS, PPS, SEI etc).

Definition at line 1778 of file image.c.

References ImageParameters::frame_no, and InputParameters::Verbose.

Referenced by encode_one_frame().

void select_plane ( ColorPlane  color_plane  ) 

void set_slice_type ( ImageParameters *  p_img,
int  slice_type 
)

void UnifiedOneForthPix ( StorablePicture *  s  ) 

void UnifiedOneForthPix_JV ( int  nplane,
StorablePicture *  s 
)

void update_global_stats ( StatParameters *  gl_stats,
StatParameters *  cur_stats 
)

Update global stats.

Definition at line 300 of file image.c.

References InputParameters::skip_gl_stats.

Referenced by encode_one_frame().

void write_non_vcl_nalu ( void   ) 

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 2528 of file image.c.

References ImageParameters::frm_number, get_idr_flag(), is_gop_first_unit(), ImageParameters::layer, ImageParameters::number, PrepareAggregationSEIMessage(), InputParameters::ResendPPS, InputParameters::ResendSPS, rewrite_paramsets(), InputParameters::SendAUD, InputParameters::ToneMappingSEIPresentFlag, ImageParameters::type, UpdateSubseqInfo(), Write_AUD_NALU(), and write_PPS().

Referenced by encode_one_frame().

Here is the call graph for this function:

static void writeout_picture ( Picture *  pic  )  [static]

This function write out a picture.

Returns:
0 if OK,
1 in case of error

Definition at line 835 of file image.c.

References datapartition::bitstream, ImageParameters::currentPicture, Slice::max_part_nr, datapartition::nal_unit, Slice::partArr, and Bitstream::write_flag.

Referenced by encode_one_frame().


Variable Documentation

enc_frame_picture to be used during 4:4:4 independent mode encoding

enc_frame to be used during 4:4:4 independent mode encoding

Definition at line 93 of file image.c.

Referenced by change_plane_JV(), and make_frame_picture_JV().


Documentation generated with DoxyGen