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

Variables

static int mb_width_cr [4] = {0,8, 8,16}
static 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 727 of file configfile.c.

Referenced by PatchInp().

static void compute_frameno_params ( InputParameters *  params  )  [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 898 of file configfile.c.

References InputParameters::EnableIDRGOP, InputParameters::frame_skip, InputParameters::idr_period, InputParameters::last_frame, InputParameters::no_frames, InputParameters::no_frm_base, and InputParameters::NumberBFrames.

Referenced by PatchInp().

void Configure ( int  ac,
char *  av[] 
)

Parse the command line parameters and read the config files.

Parameters:
ac number of command line parameters
av command line parameters

Definition at line 256 of file configfile.c.

References DisplayEncoderParams(), InputParameters::DisplayEncParams, 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 ( void   )  [static]

Outputs encoding parameters.

Returns:
-1 for error

Definition at line 700 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 391 of file configfile.c.

References errortext, ET_SIZE, f, and no_mem_exit().

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

Here is the call graph for this function:

static void getNumberOfFrames ( VideoDataFile *  input_file  )  [static]

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

Definition at line 145 of file configfile.c.

References getVideoFileSize(), InputParameters::infile_header, InputParameters::no_frames, InputParameters::source, and InputParameters::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 127 of file configfile.c.

Referenced by getNumberOfFrames().

static int InitEncoderParams ( void   )  [static]

Sets initial values for encoding parameters.

Returns:
-1 for error

Definition at line 600 of file configfile.c.

Referenced by Configure().

void JMHelpExit ( void   ) 

print help message and exit

Definition at line 91 of file configfile.c.

Referenced by Configure().

static int ParameterNameToMapIndex ( char *  s  )  [static]

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

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

Definition at line 580 of file configfile.c.

Referenced by ParseContent().

void ParseContent ( 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:
buf buffer to be parsed
bufsize buffer size of buffer

Definition at line 448 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 ( void   )  [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 938 of file configfile.c.

References InputParameters::adaptive_idr_period, InputParameters::AdaptiveRounding, ImageParameters::auto_crop_bottom, ImageParameters::auto_crop_right, InputParameters::B_List0_refs, InputParameters::B_List1_refs, InputParameters::basicunit, InputParameters::BiPredMESearchRange, InputParameters::BiPredMotionEstimation, InputParameters::BiPredSearch, InputParameters::blc_size, InputParameters::BRefPictures, CeilLog2(), InputParameters::ChromaMCBuffer, InputParameters::ChromaMEEnable, CloseFiles(), compute_frameno_params(), DIR_SPATIAL, DIR_TEMPORAL, InputParameters::direct_spatial_mv_pred_flag, InputParameters::directInferenceFlag, InputParameters::DisableIntra16x16, InputParameters::DisableIntra4x4, InputParameters::DisableSubpelME, InputParameters::EnableIDRGOP, InputParameters::EnableIPCM, InputParameters::EnableOpenGOP, InputParameters::EPZSGrid, InputParameters::EPZSSubPelGrid, error(), errortext, ET_SIZE, F_PEL, InputParameters::FastIntra16x16, InputParameters::FastIntra4x4, InputParameters::FastIntra8x8, InputParameters::FastIntraChroma, InputParameters::FastIntraMD, InputParameters::FastMDEnable, InputParameters::frame_skip, FREXT_CAVLC444, FREXT_Hi422, FREXT_Hi444, FREXT_HP, InputParameters::GenerateMultiplePPS, getNumberOfFrames(), H_PEL, InputParameters::HierarchicalCoding, InputParameters::idr_period, InputParameters::input_file1, InputParameters::intra_delay, InputParameters::intra_period, InputParameters::jumpd, LevelCheck(), InputParameters::Log2MaxFNumMinus4, InputParameters::Log2MaxPOCLsbMinus4, InputParameters::MbInterlace, InputParameters::MEErrorMetric, InputParameters::ModeDecisionMetric, InputParameters::no_frames, InputParameters::no_frm_base, InputParameters::num_ref_frames, InputParameters::num_slice_groups_minus1, InputParameters::NumberBFrames, InputParameters::NumFramesInELSubSeq, InputParameters::NumRedundantHierarchy, InputParameters::of_mode, OneComponentChromaPrediction4x4_regenerate(), OneComponentChromaPrediction4x4_retrieve(), OpenFiles(), InputParameters::output, p_dec, InputParameters::P_List0_refs, p_trace, PAR_OF_ANNEXB, PAR_OF_RTP, ParseFrameNoFormatFromString(), ParseSizeFromString(), InputParameters::part_size, InputParameters::pic_order_cnt_type, InputParameters::PicInterlace, InputParameters::PocMemoryManagement, InputParameters::PrimaryGOPLength, ProfileCheck(), InputParameters::ProfileIDC, Q_PEL, InputParameters::RCEnable, InputParameters::RCUpdateMode, InputParameters::rdopt, InputParameters::RDOQ_CP_Mode, InputParameters::RDOQ_CP_MV, InputParameters::RDOQ_QP_Num, InputParameters::RDPictureDecision, read_slice_group_info(), InputParameters::ReconFile, InputParameters::redundant_pic_flag, InputParameters::ReferenceReorder, InputParameters::ScalingMatrixPresentFlag, InputParameters::search_range, InputParameters::SearchMode, InputParameters::separate_colour_plane_flag, InputParameters::slice_argument, InputParameters::slice_group_map_type, InputParameters::slice_mode, InputParameters::source, InputParameters::sp_periodicity, InputParameters::SparePictureOption, InputParameters::src_BitDepthRescale, TestEncoderParams(), InputParameters::TraceFile, InputParameters::Transform8x8Mode, updateOutFormat(), InputParameters::UseRDOQuant, InputParameters::WeightedBiprediction, InputParameters::WeightedPrediction, InputParameters::WPMCPrecFullRef, InputParameters::WPMCPrecision, YUV400, YUV422, YUV444, and InputParameters::yuv_format.

Referenced by Configure().

Here is the call graph for this function:

void read_slice_group_info (  ) 

static int TestEncoderParams ( int  bitdepth_qp_scale[3]  )  [static]

Validates encoding parameters.

Returns:
-1 for error

Definition at line 623 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 162 of file configfile.c.

Referenced by updateOutFormat().

static void updateOutFormat ( InputParameters *  params  )  [static]

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

Definition at line 179 of file configfile.c.

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

Referenced by PatchInp().

Here is the call graph for this function:


Documentation generated with DoxyGen