configfile.c File Reference

Configuration handling. More...

#include <sys/stat.h>
#include "global.h"
#include "configfile.h"
#include "fmo.h"
#include "conformance.h"
#include "mc_prediction.h"
#include "mv_search.h"
#include "img_io.h"
#include "ratectl.h"

Include dependency graph for configfile.c:

Go to the source code of this file.

Defines

#define INCLUDED_BY_CONFIGFILE_C
#define MAX_ITEMS_TO_PARSE   10000

Functions

char * GetConfigFileContent (char *Filename)
static void ParseContent (InputParameters *p_Inp, Mapping *Map, char *buf, int bufsize)
static void PatchInp (ImageParameters *p_Img, InputParameters *p_Inp)
static int ParameterNameToMapIndex (Mapping *Map, char *s)
static int InitEncoderParams (Mapping *Map)
static int TestEncoderParams (Mapping *Map, int bitdepth_qp_scale[3])
static int DisplayEncoderParams (Mapping *Map)
void JMHelpExit (void)
int64 getVideoFileSize (int video_file)
static void getNumberOfFrames (InputParameters *p_Inp, VideoDataFile *input_file)
static void updateMaxValue (FrameFormat *format)
static void updateOutFormat (InputParameters *p_Inp)
void Configure (ImageParameters *p_Img, InputParameters *p_Inp, int ac, char *av[])
unsigned CeilLog2 (unsigned uiVal)
void read_slice_group_info (ImageParameters *p_Img, InputParameters *p_Inp)
static void compute_frameno_params (InputParameters *p_Inp)
void PatchInputNoFrames (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}


Detailed Description

Configuration handling.

configfile.c

Author:
Main contributors (see contributors.h for copyright, address and affiliation details)
Note:
In the future this module should hide the Parameters and offer only Functions for their access. Modules which make frequent use of some parameters (e.g. picture size in macroblocks) are free to buffer them on local variables. This will not only avoid global variable and make the code more readable, but also speed it up. It will also greatly facilitate future enhancements such as the handling of different picture sizes in the same sequence.

For now, everything is just copied to the inp_par structure (gulp)
Configuration File Format
Format is line oriented, maximum of one parameter per line

Lines have the following format:
<ParameterName> = <ParameterValue> # Comments \n
Whitespace is space and \t
<ParameterName> are the predefined names for Parameters and are case sensitive. See configfile.h for the definition of those names and their mapping to cfgparams->values.
<ParameterValue> are either integers [0..9]* or strings. Integers must fit into the wordlengths, signed values are generally assumed. Strings containing no whitespace characters can be used directly. Strings containing whitespace characters are to be inclosed in double quotes ("string with whitespace") The double quote character is forbidden (may want to implement something smarter here).
Any Parameters whose ParameterName is undefined lead to the termination of the program with an error message.
Known bug/Shortcoming:
zero-length strings (i.e. to signal an non-existing file have to be coded as "".
Rules for using command files

All Parameters are initially taken from DEFAULTCONFIGFILENAME, defined in configfile.h. If an -f <config> parameter is present in the command line then this file is used to update the defaults of DEFAULTCONFIGFILENAME. There can be more than one -f parameters present. If -p <ParameterName = ParameterValue> parameters are present then these override the default and the additional config file's settings, and are themselves overridden by future -p parameters. There must be whitespace between -f and -p commands and their respective parameters

Definition in file configfile.c.


Function Documentation

unsigned CeilLog2 ( unsigned  uiVal  ) 

calculate Ceil(Log2(uiVal))

Definition at line 748 of file configfile.c.

Referenced by PatchInp().

static void compute_frameno_params ( InputParameters p_Inp  )  [static]

Compute frame numbering related parameters.

Note:
The set variables seem to now be primarily useful only for RC purposes. Can we ommit them completely? The use of lastframe can also be modified as to ommit this parameter. To be done at a future date.

Definition at line 919 of file configfile.c.

References inp_par_enc::EnableIDRGOP, inp_par_enc::frame_skip, inp_par_enc::idr_period, inp_par_enc::no_frames, inp_par_enc::no_frm_base, and inp_par_enc::NumberBFrames.

Referenced by PatchInp().

void Configure ( ImageParameters p_Img,
InputParameters p_Inp,
int  ac,
char *  av[] 
)

Parse the command line parameters and read the config files.

Parameters:
p_Img ImageParameters structure for encoding
p_Inp InputParameters structure as input configuration
ac number of command line parameters
av command line parameters

Definition at line 266 of file configfile.c.

References DisplayEncoderParams(), error(), errortext, ET_SIZE, GetConfigFileContent(), InitEncoderParams(), JMHelpExit(), no_mem_exit(), ParseContent(), and PatchInp().

Referenced by main().

Here is the call graph for this function:

static int DisplayEncoderParams ( Mapping *  Map  )  [static]

Outputs encoding parameters.

Returns:
-1 for error

Definition at line 721 of file configfile.c.

Referenced by Configure().

char * GetConfigFileContent ( char *  Filename  ) 

allocates memory buf, opens file Filename in f, reads contents into buf and returns buf

Parameters:
Filename name of config file
Returns:
if successfull, content of config file NULL in case of error. Error message will be set in errortext

Definition at line 407 of file configfile.c.

References errortext, ET_SIZE, and no_mem_exit().

Referenced by Configure(), Init_QMatrix(), and Init_QOffsetMatrix().

Here is the call graph for this function:

static void getNumberOfFrames ( InputParameters p_Inp,
VideoDataFile *  input_file 
) [static]

Updates the number of frames to encode based on the file size.

Definition at line 146 of file configfile.c.

References getVideoFileSize(), inp_par_enc::infile_header, inp_par_enc::no_frames, inp_par_enc::source, and inp_par_enc::start_frame.

Referenced by PatchInp().

Here is the call graph for this function:

int64 getVideoFileSize ( int  video_file  ) 

Reads Input File Size.

Definition at line 128 of file configfile.c.

Referenced by getNumberOfFrames().

static int InitEncoderParams ( Mapping *  Map  )  [static]

Sets initial values for encoding parameters.

Returns:
-1 for error

Definition at line 621 of file configfile.c.

Referenced by Configure().

void JMHelpExit ( void   ) 

print help message and exit

Definition at line 92 of file configfile.c.

Referenced by Configure().

static int ParameterNameToMapIndex ( Mapping *  Map,
char *  s 
) [static]

Returns the index number from Map[] for a given parameter name.

Parameters:
Map Mapping structure
s parameter name string
Returns:
the index number if the string is a valid parameter name,
-1 for error

Definition at line 601 of file configfile.c.

Referenced by ParseContent().

void ParseContent ( InputParameters p_Inp,
Mapping *  Map,
char *  buf,
int  bufsize 
) [static]

Parses the character array buf and writes global variable input, which is defined in configfile.h. This hack will continue to be necessary to facilitate the addition of new parameters through the Map[] mechanism (Need compiler-generated addresses in map[]).

Parameters:
p_Inp InputParameters of configuration
Map Mapping structure to specify the name and value mapping relation
buf buffer to be parsed
bufsize buffer size of buffer

Definition at line 468 of file configfile.c.

References error(), errortext, ET_SIZE, and ParameterNameToMapIndex().

Referenced by Configure().

Here is the call graph for this function:

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

Checks the input parameters for consistency.

the number of slice groups is forced to be 1 for slice group type 3-5

Definition at line 959 of file configfile.c.

References inp_par_enc::AdaptiveRounding, inp_par_enc::B_List0_refs, inp_par_enc::B_List1_refs, inp_par_enc::BiPredMESearchRange, inp_par_enc::BiPredMotionEstimation, inp_par_enc::BiPredSearch, inp_par_enc::BRefPictures, CeilLog2(), CloseFiles(), compute_frameno_params(), DIR_SPATIAL, DIR_TEMPORAL, inp_par_enc::direct_spatial_mv_pred_flag, inp_par_enc::directInferenceFlag, inp_par_enc::DisableSubpelME, inp_par_enc::EnableIDRGOP, inp_par_enc::EnableOpenGOP, error(), errortext, ET_SIZE, F_PEL, inp_par_enc::frame_skip, FREXT_CAVLC444, FREXT_Hi422, FREXT_Hi444, FREXT_HP, getNumberOfFrames(), inp_par_enc::idr_period, inp_par_enc::input_file1, inp_par_enc::intra_delay, inp_par_enc::intra_period, inp_par_enc::jumpd, LevelCheck(), inp_par_enc::Log2MaxFNumMinus4, inp_par_enc::Log2MaxPOCLsbMinus4, inp_par_enc::MbInterlace, inp_par_enc::no_frames, inp_par_enc::no_frm_base, inp_par_enc::num_ref_frames, inp_par_enc::num_slice_groups_minus1, inp_par_enc::NumberBFrames, inp_par_enc::NumRedundantHierarchy, inp_par_enc::of_mode, OpenFiles(), inp_par_enc::output, img_par::p_dec, inp_par_enc::P_List0_refs, PAR_OF_ANNEXB, PAR_OF_RTP, ParseFrameNoFormatFromString(), ParseSizeFromString(), inp_par_enc::pic_order_cnt_type, inp_par_enc::PicInterlace, inp_par_enc::PocMemoryManagement, inp_par_enc::PrimaryGOPLength, ProfileCheck(), inp_par_enc::ProfileIDC, Q_PEL, inp_par_enc::RCEnable, inp_par_enc::RDPictureDecision, read_slice_group_info(), inp_par_enc::ReconFile, inp_par_enc::ReferenceReorder, inp_par_enc::search_range, inp_par_enc::SetFirstAsLongTerm, inp_par_enc::slice_argument, inp_par_enc::slice_mode, inp_par_enc::source, inp_par_enc::sp_periodicity, inp_par_enc::src_BitDepthRescale, inp_par_enc::symbol_mode, TestEncoderParams(), inp_par_enc::TraceFile, updateOutFormat(), inp_par_enc::WeightedBiprediction, inp_par_enc::WeightedPrediction, YUV400, YUV422, YUV444, and inp_par_enc::yuv_format.

Referenced by Configure().

Here is the call graph for this function:

void read_slice_group_info ( ImageParameters p_Img,
InputParameters p_Inp 
)

read the slice group configuration file. Returns without action if type is not 0, 2 or 6

Definition at line 768 of file configfile.c.

References error(), errortext, ET_SIZE, inp_par_enc::MbInterlace, no_mem_exit(), inp_par_enc::num_slice_groups_minus1, inp_par_enc::output, inp_par_enc::PicInterlace, inp_par_enc::run_length_minus1, inp_par_enc::slice_group_id, inp_par_enc::SliceGroupConfigFileName, and inp_par_enc::top_left.

Referenced by PatchInp().

Here is the call graph for this function:

static int TestEncoderParams ( Mapping *  Map,
int  bitdepth_qp_scale[3] 
) [static]

Validates encoding parameters.

Returns:
-1 for error

Definition at line 644 of file configfile.c.

References error(), errortext, and ET_SIZE.

Referenced by PatchInp().

Here is the call graph for this function:

static void updateMaxValue ( FrameFormat *  format  )  [static]

Updates images max values.

Definition at line 163 of file configfile.c.

Referenced by updateOutFormat().

static void updateOutFormat ( InputParameters p_Inp  )  [static]

Update output format parameters (resolution & bit-depth) given input.

Definition at line 180 of file configfile.c.

References inp_par_enc::frame_skip, inp_par_enc::output, inp_par_enc::source, inp_par_enc::src_BitDepthRescale, inp_par_enc::src_resize, updateMaxValue(), YUV400, and inp_par_enc::yuv_format.

Referenced by PatchInp().

Here is the call graph for this function:


Documentation generated with DoxyGen