image.c File Reference

Code one image/slice. More...

#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"

Include dependency graph for image.c:

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)


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,
InputParameters p_Inp 
)

Calculates the absolute frame number in the source file out of various variables in p_Img-> and p_Inp->.

Returns:
frame number in the file to be read
side effects
global variable frame_no updated -- dunno, for what this one is necessary

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().

Here is the call graph for this function:

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

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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Boolean dummy_slice_too_big ( int  bits_slice  ) 

Just a placebo.

Definition at line 1632 of file image.c.

Referenced by init_slice().

int encode_one_frame ( ImageParameters p_Img,
InputParameters p_Inp 
)

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().

Here is the call graph for this function:

static void field_picture ( ImageParameters p_Img,
InputParameters p_Inp,
Picture *  top,
Picture *  bottom 
) [static]

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

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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]

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

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

static void prepare_enc_frame_picture ( ImageParameters p_Img,
InputParameters p_Inp,
StorablePicture **  stored_pic 
) [static]

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().

Here is the call graph for this function:

void read_SP_coefficients ( ImageParameters p_Img,
InputParameters p_Inp 
)

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 
)

void set_slice_type ( ImageParameters p_Img,
InputParameters p_Inp,
int  slice_type 
)

void UnifiedOneForthPix ( ImageParameters p_Img,
InputParameters p_Inp,
StorablePicture s 
)

Upsample 4 times, store them in out4x. Color is simply copied.

Input:
srcy, srcu, srcv, out4y, out4u, out4v
Side Effects_
Uses (writes) img4Y_tmp. This should be moved to a static variable in this module

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().

Here is the call graph for this function:

void UnifiedOneForthPix_JV ( ImageParameters p_Img,
InputParameters p_Inp,
int  nplane,
StorablePicture s 
)

void update_global_stats ( InputParameters p_Inp,
StatParameters *  gl_stats,
StatParameters *  cur_stats 
)

Update global stats.

Definition at line 299 of file image.c.

Referenced by encode_one_frame().

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().

Here is the call graph for this function:

static void writeout_picture ( ImageParameters p_Img,
Picture *  pic 
) [static]

This function write out a picture.

Returns:
0 if OK,
1 in case of error

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().


Documentation generated with DoxyGen