[x265] [PATCH] Merged TEncCfg into Encoder. A few VUI tweaks and fixes

Steve Borho steve at borho.org
Tue Mar 4 18:55:21 CET 2014


On Mon, Mar 3, 2014 at 4:27 PM,  <dtyx265 at gmail.com> wrote:
> # HG changeset patch
> # User David T Yuen <dtyx265 at gmail.com>
> # Date 1393885474 28800
> # Node ID 56fa912d6e7c1d53cd4f677d4afa9580af067ab5
> # Parent  6662df480e39c83ab138d831f883d11fc5b052c5
> Merged TEncCfg into Encoder.  A few VUI tweaks and fixes.

I'm planning to push the patch with a few fixups.

Some comments inlined below, some follow-up cleanups would be greatly
appreciated.

> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibCommon/TComPic.cpp
> --- a/source/Lib/TLibCommon/TComPic.cpp Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibCommon/TComPic.cpp Mon Mar 03 14:24:34 2014 -0800
> @@ -38,7 +38,6 @@
>  #include "TComPic.h"
>  #include "SEI.h"
>  #include "mv.h"
> -#include "TLibEncoder/TEncCfg.h"
>
>  using namespace x265;
>
> @@ -86,13 +85,13 @@
>  TComPic::~TComPic()
>  {}
>
> -bool TComPic::create(TEncCfg* cfg)
> +bool TComPic::create(Encoder* cfg)
>  {
>      /* store conformance window parameters with picture */
>      m_conformanceWindow = cfg->m_conformanceWindow;
>
>      /* store display window parameters with picture */
> -    m_defaultDisplayWindow = cfg->getDefaultDisplayWindow();
> +    m_defaultDisplayWindow = cfg->m_defaultDisplayWindow;
>
>      m_picSym = new TComPicSym;
>      m_origPicYuv = new TComPicYuv;
> @@ -101,18 +100,18 @@
>          return false;
>
>      bool ok = true;
> -    ok &= m_picSym->create(cfg->param.sourceWidth, cfg->param.sourceHeight, cfg->param.internalCsp, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth);
> -    ok &= m_origPicYuv->create(cfg->param.sourceWidth, cfg->param.sourceHeight, cfg->param.internalCsp, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth);
> -    ok &= m_reconPicYuv->create(cfg->param.sourceWidth, cfg->param.sourceHeight, cfg->param.internalCsp, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth);
> -    ok &= m_lowres.create(m_origPicYuv, cfg->param.bframes, !!cfg->param.rc.aqMode);
> +    ok &= m_picSym->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth);
> +    ok &= m_origPicYuv->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth);
> +    ok &= m_reconPicYuv->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth);
> +    ok &= m_lowres.create(m_origPicYuv, cfg->param->bframes, !!cfg->param->rc.aqMode);
>
> -    bool isVbv = cfg->param.rc.vbvBufferSize > 0 && cfg->param.rc.vbvMaxBitrate > 0;
> -    if (ok && (isVbv || cfg->param.rc.aqMode))
> +    bool isVbv = cfg->param->rc.vbvBufferSize > 0 && cfg->param->rc.vbvMaxBitrate > 0;
> +    if (ok && (isVbv || cfg->param->rc.aqMode))
>      {
>          int numRows = m_picSym->getFrameHeightInCU();
>          int numCols = m_picSym->getFrameWidthInCU();
>
> -        if (cfg->param.rc.aqMode)
> +        if (cfg->param->rc.aqMode)
>              CHECKED_MALLOC(m_qpaAq, double, numRows);
>          if (isVbv)
>          {
> @@ -135,9 +134,9 @@
>      return ok;
>  }
>
> -void TComPic::reInit(TEncCfg* cfg)
> +void TComPic::reInit(Encoder* cfg)
>  {
> -    if (cfg->param.rc.vbvBufferSize > 0 && cfg->param.rc.vbvMaxBitrate > 0)
> +    if (cfg->param->rc.vbvBufferSize > 0 && cfg->param->rc.vbvMaxBitrate > 0)
>      {
>          int numRows = m_picSym->getFrameHeightInCU();
>          int numCols = m_picSym->getFrameWidthInCU();
> @@ -150,7 +149,7 @@
>          memset(m_cuCostsForVbv, 0,  numRows * numCols * sizeof(uint32_t));
>          memset(m_qpaRc, 0, numRows * sizeof(double));
>      }
> -    if (cfg->param.rc.aqMode)
> +    if (cfg->param->rc.aqMode)
>          memset(m_qpaAq, 0,  m_picSym->getFrameHeightInCU() * sizeof(double));
>  }
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibCommon/TComPic.h
> --- a/source/Lib/TLibCommon/TComPic.h   Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibCommon/TComPic.h   Mon Mar 03 14:24:34 2014 -0800
> @@ -45,11 +45,12 @@
>  #include "lowres.h"
>  #include "threading.h"
>  #include "md5.h"
> +#include "../../source/encoder/encoder.h"

You could just include "encoder.h" here, the relative paths are
unnecessary.  However, since Encoder is forward decl'd below, there's
no need to include it here anyway.  So I've added the include to
TComPic.cpp

>
>  namespace x265 {
>  // private namespace
>
> -class TEncCfg;
> +class Encoder;
>
>  //! \ingroup TLibCommon
>  //! \{
> @@ -118,9 +119,9 @@
>      TComPic();
>      virtual ~TComPic();
>
> -    bool          create(TEncCfg* cfg);
> +    bool          create(Encoder* cfg);
>      virtual void  destroy(int bframes);
> -    void          reInit(TEncCfg* cfg);
> +    void          reInit(Encoder* cfg);
>
>      bool          getUsedByCurr()           { return m_bUsedByCurr; }
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibCommon/TComSlice.cpp
> --- a/source/Lib/TLibCommon/TComSlice.cpp       Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibCommon/TComSlice.cpp       Mon Mar 03 14:24:34 2014 -0800
> @@ -613,12 +613,9 @@
>      timingInfo->setTimeScale(fpsNum);
>
>      bool rateCnt = (bitRate > 0);
> -    hrd->setNalHrdParametersPresentFlag(rateCnt);
>      hrd->setVclHrdParametersPresentFlag(rateCnt);
>
> -    hrd->setSubPicCpbParamsPresentFlag((numDU > 1));
> -
> -    if (hrd->getSubPicCpbParamsPresentFlag())
> +    if (hrd->getSubPicHrdParamsPresentFlag())
>      {
>          hrd->setTickDivisorMinus2(100 - 2);
>          hrd->setDuCpbRemovalDelayLengthMinus1(7);                  // 8-bit precision ( plus 1 for last DU in AU )
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibCommon/TComSlice.h
> --- a/source/Lib/TLibCommon/TComSlice.h Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibCommon/TComSlice.h Mon Mar 03 14:24:34 2014 -0800
> @@ -298,7 +298,7 @@
>
>      bool m_nalHrdParametersPresentFlag;
>      bool m_vclHrdParametersPresentFlag;
> -    bool m_subPicCpbParamsPresentFlag;
> +    bool m_subPicHrdParamsPresentFlag;
>      uint32_t m_tickDivisorMinus2;
>      uint32_t m_duCpbRemovalDelayLengthMinus1;
>      bool m_subPicCpbParamsInPicTimingSEIFlag;
> @@ -316,7 +316,7 @@
>      TComHRD()
>          : m_nalHrdParametersPresentFlag(0)
>          , m_vclHrdParametersPresentFlag(0)
> -        , m_subPicCpbParamsPresentFlag(false)
> +        , m_subPicHrdParamsPresentFlag(false)
>          , m_tickDivisorMinus2(0)
>          , m_duCpbRemovalDelayLengthMinus1(0)
>          , m_subPicCpbParamsInPicTimingSEIFlag(false)
> @@ -338,9 +338,9 @@
>
>      bool getVclHrdParametersPresentFlag() { return m_vclHrdParametersPresentFlag; }
>
> -    void setSubPicCpbParamsPresentFlag(bool flag) { m_subPicCpbParamsPresentFlag = flag; }
> +    void setSubPicHrdParamsPresentFlag(bool flag) { m_subPicHrdParamsPresentFlag = flag; }
>
> -    bool getSubPicCpbParamsPresentFlag() { return m_subPicCpbParamsPresentFlag; }
> +    bool getSubPicHrdParamsPresentFlag() { return m_subPicHrdParamsPresentFlag; }
>
>      void setTickDivisorMinus2(uint32_t value) { m_tickDivisorMinus2 = value; }
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/SEIwrite.cpp
> --- a/source/Lib/TLibEncoder/SEIwrite.cpp       Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibEncoder/SEIwrite.cpp       Mon Mar 03 14:24:34 2014 -0800
> @@ -295,7 +295,7 @@
>      TComHRD *hrd = vui->getHrdParameters();
>
>      WRITE_UVLC(sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id");
> -    if (!hrd->getSubPicCpbParamsPresentFlag())
> +    if (!hrd->getSubPicHrdParamsPresentFlag())
>      {
>          WRITE_FLAG(sei.m_rapCpbParamsPresentFlag, "rap_cpb_params_present_flag");
>      }
> @@ -315,7 +315,7 @@
>              {
>                  WRITE_CODE(sei.m_initialCpbRemovalDelay[i][nalOrVcl], (hrd->getInitialCpbRemovalDelayLengthMinus1() + 1),           "initial_cpb_removal_delay");
>                  WRITE_CODE(sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl], (hrd->getInitialCpbRemovalDelayLengthMinus1() + 1),      "initial_cpb_removal_delay_offset");
> -                if (hrd->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag)
> +                if (hrd->getSubPicHrdParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag)
>                  {
>                      WRITE_CODE(sei.m_initialAltCpbRemovalDelay[i][nalOrVcl], (hrd->getInitialCpbRemovalDelayLengthMinus1() + 1),     "initial_alt_cpb_removal_delay");
>                      WRITE_CODE(sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl], (hrd->getInitialCpbRemovalDelayLengthMinus1() + 1), "initial_alt_cpb_removal_delay_offset");
> @@ -344,11 +344,11 @@
>      {
>          WRITE_CODE(sei.m_auCpbRemovalDelay - 1, (hrd->getCpbRemovalDelayLengthMinus1() + 1), "au_cpb_removal_delay_minus1");
>          WRITE_CODE(sei.m_picDpbOutputDelay, (hrd->getDpbOutputDelayLengthMinus1() + 1), "pic_dpb_output_delay");
> -        if (hrd->getSubPicCpbParamsPresentFlag())
> +        if (hrd->getSubPicHrdParamsPresentFlag())
>          {
>              WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1() + 1, "pic_dpb_output_du_delay");
>          }
> -        if (hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag())
> +        if (hrd->getSubPicHrdParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag())
>          {
>              WRITE_UVLC(sei.m_numDecodingUnitsMinus1,     "num_decoding_units_minus1");
>              WRITE_FLAG(sei.m_duCommonCpbRemovalDelayFlag, "du_common_cpb_removal_delay_flag");
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/TEncCfg.h
> --- a/source/Lib/TLibEncoder/TEncCfg.h  Mon Mar 03 11:28:22 2014 +0530
> +++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
> @@ -1,336 +0,0 @@

I love patches that delete HM files, especially ugly ones like this one.

> -/* The copyright in this software is being made available under the BSD
> - * License, included below. This software may be subject to other third party
> - * and contributor rights, including patent rights, and no such rights are
> - * granted under this license.
> - *
> - * Copyright (c) 2010-2013, ITU/ISO/IEC
> - * All rights reserved.
> - *
> - * Redistribution and use in source and binary forms, with or without
> - * modification, are permitted provided that the following conditions are met:
> - *
> - *  * Redistributions of source code must retain the above copyright notice,
> - *    this list of conditions and the following disclaimer.
> - *  * Redistributions in binary form must reproduce the above copyright notice,
> - *    this list of conditions and the following disclaimer in the documentation
> - *    and/or other materials provided with the distribution.
> - *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
> - *    be used to endorse or promote products derived from this software without
> - *    specific prior written permission.
> - *
> - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
> - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> - * THE POSSIBILITY OF SUCH DAMAGE.
> - */
> -
> -/** \file     TEncCfg.h
> -    \brief    encoder configuration class (header)
> -*/
> -
> -#ifndef X265_TENCCFG_H
> -#define X265_TENCCFG_H
> -
> -#include "TLibCommon/CommonDef.h"
> -#include "TLibCommon/TComSlice.h"
> -#include <assert.h>
> -
> -namespace x265 {
> -// private namespace
> -
> -//! \ingroup TLibEncoder
> -//! \{
> -
> -// ====================================================================================================================
> -// Class definition
> -// ====================================================================================================================
> -
> -/// encoder configuration class
> -class TEncCfg
> -{
> -protected:
> -
> -    //==== File I/O ========
> -    int       m_conformanceMode;
> -    Window    m_defaultDisplayWindow;         ///< Represents the default display window parameters
> -    TComVPS   m_vps;
> -
> -    /* profile & level */
> -    Profile::Name m_profile;
> -    Level::Tier   m_levelTier;
> -    Level::Name   m_level;
> -
> -    bool      m_progressiveSourceFlag;
> -    bool      m_interlacedSourceFlag;
> -    bool      m_nonPackedConstraintFlag;
> -    bool      m_frameOnlyConstraintFlag;
> -
> -    //====== Coding Structure ========
> -    int       m_maxDecPicBuffering[MAX_TLAYER];
> -    int       m_numReorderPics[MAX_TLAYER];
> -    int       m_maxRefPicNum;                   ///< this is used to mimic the sliding mechanism used by the decoder
> -                                                // TODO: We need to have a common sliding mechanism used by both the encoder and decoder
> -
> -    //======= Transform =============
> -    uint32_t  m_quadtreeTULog2MaxSize;
> -    uint32_t  m_quadtreeTULog2MinSize;
> -
> -    //====== Loop/Deblock Filter ========
> -    bool      m_loopFilterOffsetInPPS;
> -    int       m_loopFilterBetaOffsetDiv2;
> -    int       m_loopFilterTcOffsetDiv2;
> -    int       m_maxNumOffsetsPerPic;
> -
> -    //====== Lossless ========
> -    bool      m_useLossless;
> -
> -    //====== Quality control ========
> -    int       m_maxCuDQPDepth;                  //  Max. depth for a minimum CuDQP (0:default)
> -
> -    //====== Tool list ========
> -    bool      m_bUseASR;
> -    bool      m_usePCM;
> -    uint32_t  m_pcmLog2MaxSize;
> -    uint32_t  m_pcmLog2MinSize;
> -
> -    bool      m_bPCMInputBitDepthFlag;
> -    uint32_t  m_pcmBitDepthLuma;
> -    uint32_t  m_pcmBitDepthChroma;
> -    bool      m_bPCMFilterDisableFlag;
> -    bool      m_loopFilterAcrossTilesEnabledFlag;
> -
> -    int       m_bufferingPeriodSEIEnabled;
> -    int       m_pictureTimingSEIEnabled;
> -    int       m_recoveryPointSEIEnabled;
> -    int       m_displayOrientationSEIAngle;
> -    int       m_gradualDecodingRefreshInfoEnabled;
> -    int       m_decodingUnitInfoSEIEnabled;
> -    int       m_csp;
> -
> -    //====== Weighted Prediction ========
> -
> -    uint32_t  m_log2ParallelMergeLevelMinus2;                 ///< Parallel merge estimation region
> -
> -    int       m_useScalingListId;                             ///< Using quantization matrix i.e. 0=off, 1=default.
> -
> -    bool      m_TransquantBypassEnableFlag;                   ///< transquant_bypass_enable_flag setting in PPS.
> -    bool      m_CUTransquantBypassFlagValue;                  ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
> -    int       m_activeParameterSetsSEIEnabled;                ///< enable active parameter set SEI message
> -    bool      m_vuiParametersPresentFlag;                     ///< enable generation of VUI parameters
> -    bool      m_aspectRatioInfoPresentFlag;                   ///< Signals whether aspect_ratio_idc is present
> -    int       m_aspectRatioIdc;                               ///< aspect_ratio_idc
> -    int       m_sarWidth;                                     ///< horizontal size of the sample aspect ratio
> -    int       m_sarHeight;                                    ///< vertical size of the sample aspect ratio
> -    bool      m_overscanInfoPresentFlag;                      ///< Signals whether overscan_appropriate_flag is present
> -    bool      m_overscanAppropriateFlag;                      ///< Indicates whether conformant decoded pictures are suitable for display using overscan
> -    bool      m_videoSignalTypePresentFlag;                   ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
> -    int       m_videoFormat;                                  ///< Indicates representation of pictures
> -    bool      m_videoFullRangeFlag;                           ///< Indicates the black level and range of luma and chroma signals
> -    bool      m_colourDescriptionPresentFlag;                 ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
> -    int       m_colourPrimaries;                              ///< Indicates chromaticity coordinates of the source primaries
> -    int       m_transferCharacteristics;                      ///< Indicates the opto-electronic transfer characteristics of the source
> -    int       m_matrixCoefficients;                           ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
> -    bool      m_chromaLocInfoPresentFlag;                     ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
> -    int       m_chromaSampleLocTypeTopField;                  ///< Specifies the location of chroma samples for top field
> -    int       m_chromaSampleLocTypeBottomField;               ///< Specifies the location of chroma samples for bottom field
> -    bool      m_neutralChromaIndicationFlag;                  ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
> -    bool      m_frameFieldInfoPresentFlag;                    ///< Indicates that pic_struct and other field coding related values are present in picture timing SEI messages
> -    bool      m_pocProportionalToTimingFlag;                  ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS
> -    int       m_numTicksPocDiffOneMinus1;                     ///< Number of ticks minus 1 that for a POC difference of one
> -    bool      m_bitstreamRestrictionFlag;                     ///< Signals whether bitstream restriction parameters are present
> -    bool      m_motionVectorsOverPicBoundariesFlag;           ///< Indicates that no samples outside the picture boundaries are used for inter prediction
> -    int       m_minSpatialSegmentationIdc;                    ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence
> -    int       m_maxBytesPerPicDenom;                          ///< Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture
> -    int       m_maxBitsPerMinCuDenom;                         ///< Indicates an upper bound for the number of bits of coding_unit() data
> -    int       m_log2MaxMvLengthHorizontal;                    ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
> -    int       m_log2MaxMvLengthVertical;                      ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
> -    bool      m_fieldSeqFlag;                                 ///< Indicates that each picture is a field and has its own SEI timing message
> -    bool      m_vuiTimingInfoPresentFlag;                     ///< Indicates that timing info is added to the VUI
> -    int       m_vuiNumUnitsInTick;                            ///< The number of system ticks in an h265 tick where an h265 tick is in units of system ticks per frame
> -    int       m_vuiTimeScale;                                 ///< The number of system ticks per second
> -    bool      m_vuiHrdParametersPresentFlag;                  ///< Indicates HRD parameters are to be added to the VUI
> -    bool      m_subPicHrdParamsPresentFlag;                   ///< Indicates that sub pic parameters should be added to the HRD
> -    bool      m_restrictedRefPicListsFlag;                    ///< Indicates all P and B slices have the same reference pic list 0 and all B slices have the same reference pic list 1
> -    bool      m_tilesFixedStructureFlag;                      ///< Indicates each PPS in the CVS have the same tile structure fields
> -
> -public:
> -
> -    /* copy of parameters used to create encoder */
> -    x265_param param;
> -
> -    int       bEnableRDOQ;
> -    int       bEnableRDOQTS;
> -
> -    int       m_pad[2];
> -    Window    m_conformanceWindow;
> -
> -    TEncCfg()
> -    {}
> -
> -    virtual ~TEncCfg()
> -    {}
> -
> -    TComVPS *getVPS() { return &m_vps; }
> -
> -    //====== Coding Structure ========
> -
> -    int getMaxRefPicNum() { return m_maxRefPicNum; }
> -
> -    //==== Coding Structure ========
> -
> -    int getMaxDecPicBuffering(uint32_t tlayer) { return m_maxDecPicBuffering[tlayer]; }
> -
> -    int getNumReorderPics(uint32_t tlayer) { return m_numReorderPics[tlayer]; }
> -
> -    //======== Transform =============
> -    uint32_t getQuadtreeTULog2MaxSize() const { return m_quadtreeTULog2MaxSize; }
> -
> -    uint32_t getQuadtreeTULog2MinSize() const { return m_quadtreeTULog2MinSize; }
> -
> -    //==== Loop/Deblock Filter ========
> -    bool getLoopFilterOffsetInPPS() { return m_loopFilterOffsetInPPS; }
> -
> -    int getLoopFilterBetaOffset() { return m_loopFilterBetaOffsetDiv2; }
> -
> -    int getLoopFilterTcOffset() { return m_loopFilterTcOffsetDiv2; }
> -
> -    //==== Quality control ========
> -    int getMaxCuDQPDepth() { return m_maxCuDQPDepth; }
> -
> -    //====== Lossless ========
> -    bool getUseLossless() { return m_useLossless; }
> -
> -    //==== Tool list ========
> -    bool getUseASR() { return m_bUseASR; }
> -
> -    bool getPCMInputBitDepthFlag() { return m_bPCMInputBitDepthFlag; }
> -
> -    bool getPCMFilterDisableFlag() { return m_bPCMFilterDisableFlag; }
> -
> -    bool getUsePCM() { return m_usePCM; }
> -
> -    uint32_t getPCMLog2MaxSize() { return m_pcmLog2MaxSize; }
> -
> -    uint32_t getPCMLog2MinSize() { return m_pcmLog2MinSize; }
> -
> -    int   getMaxNumOffsetsPerPic() { return m_maxNumOffsetsPerPic; }
> -
> -    bool  getLFCrossTileBoundaryFlag() { return m_loopFilterAcrossTilesEnabledFlag; }
> -
> -    int   getBufferingPeriodSEIEnabled() { return m_bufferingPeriodSEIEnabled; }
> -
> -    int   getPictureTimingSEIEnabled() { return m_pictureTimingSEIEnabled; }
> -
> -    int   getRecoveryPointSEIEnabled() { return m_recoveryPointSEIEnabled; }
> -
> -    int   getDisplayOrientationSEIAngle() { return m_displayOrientationSEIAngle; }
> -
> -    int   getGradualDecodingRefreshInfoEnabled() { return m_gradualDecodingRefreshInfoEnabled; }
> -
> -    int   getDecodingUnitInfoSEIEnabled() { return m_decodingUnitInfoSEIEnabled; }
> -
> -    uint32_t getLog2ParallelMergeLevelMinus2() { return m_log2ParallelMergeLevelMinus2; }
> -
> -    int  getUseScalingListId() { return m_useScalingListId; }
> -
> -    bool getTransquantBypassEnableFlag() { return m_TransquantBypassEnableFlag; }
> -
> -    bool getCUTransquantBypassFlagValue() { return m_CUTransquantBypassFlagValue; }
> -
> -    int getActiveParameterSetsSEIEnabled() { return m_activeParameterSetsSEIEnabled; }
> -
> -    bool getVuiParametersPresentFlag() { return m_vuiParametersPresentFlag; }
> -
> -    bool getAspectRatioInfoPresentFlag() { return m_aspectRatioInfoPresentFlag; }
> -
> -    int getAspectRatioIdc() { return m_aspectRatioIdc; }
> -
> -    int getSarWidth() { return m_sarWidth; }
> -
> -    int getSarHeight() { return m_sarHeight; }
> -
> -    bool getOverscanInfoPresentFlag() { return m_overscanInfoPresentFlag; }
> -
> -    bool getOverscanAppropriateFlag() { return m_overscanAppropriateFlag; }
> -
> -    bool getVideoSignalTypePresentFlag() { return m_videoSignalTypePresentFlag; }
> -
> -    int getVideoFormat() { return m_videoFormat; }
> -
> -    int getColorFormat() { return m_csp; }
> -
> -    bool getVideoFullRangeFlag() { return m_videoFullRangeFlag; }
> -
> -    bool getColourDescriptionPresentFlag() { return m_colourDescriptionPresentFlag; }
> -
> -    int getColourPrimaries() { return m_colourPrimaries; }
> -
> -    int getTransferCharacteristics() { return m_transferCharacteristics; }
> -
> -    int getMatrixCoefficients() { return m_matrixCoefficients; }
> -
> -    bool getChromaLocInfoPresentFlag() { return m_chromaLocInfoPresentFlag; }
> -
> -    int getChromaSampleLocTypeTopField() { return m_chromaSampleLocTypeTopField; }
> -
> -    int getChromaSampleLocTypeBottomField() { return m_chromaSampleLocTypeBottomField; }
> -
> -    bool getNeutralChromaIndicationFlag() { return m_neutralChromaIndicationFlag; }
> -
> -    Window &getDefaultDisplayWindow() { return m_defaultDisplayWindow; }
> -
> -    bool getFrameFieldInfoPresentFlag() { return m_frameFieldInfoPresentFlag; }
> -
> -    bool getPocProportionalToTimingFlag() { return m_pocProportionalToTimingFlag; }
> -
> -    int getNumTicksPocDiffOneMinus1() { return m_numTicksPocDiffOneMinus1;    }
> -
> -    bool getBitstreamRestrictionFlag() { return m_bitstreamRestrictionFlag; }
> -
> -    bool getMotionVectorsOverPicBoundariesFlag() { return m_motionVectorsOverPicBoundariesFlag; }
> -
> -    int getMinSpatialSegmentationIdc() { return m_minSpatialSegmentationIdc; }
> -
> -    int getMaxBytesPerPicDenom() { return m_maxBytesPerPicDenom; }
> -
> -    int getMaxBitsPerMinCuDenom() { return m_maxBitsPerMinCuDenom; }
> -
> -    int getLog2MaxMvLengthHorizontal() { return m_log2MaxMvLengthHorizontal; }
> -
> -    int getLog2MaxMvLengthVertical() { return m_log2MaxMvLengthVertical; }
> -
> -    bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; }
> -
> -    bool getInterlacedSourceFlag() const { return m_interlacedSourceFlag; }
> -
> -    bool getNonPackedConstraintFlag() const { return m_nonPackedConstraintFlag; }
> -
> -    bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; }
> -
> -    bool getFieldSeqFlag() const { return m_fieldSeqFlag; }
> -
> -    bool getVuiTimingInfoPresentFlag() const { return m_vuiTimingInfoPresentFlag; }
> -
> -    int getVuiNumUnitsInTick() const { return m_vuiNumUnitsInTick; }
> -
> -    int getVuiTimeScale() const { return m_vuiTimeScale; }
> -
> -    bool getVuiHrdParametersPresentFlag() const { return m_vuiHrdParametersPresentFlag; }
> -
> -    bool getSubPicHrdParamsPresentFlag() const { return m_subPicHrdParamsPresentFlag; }
> -
> -    bool getRestrictedRefPicListsFlag() const { return m_restrictedRefPicListsFlag; }
> -
> -    bool getTilesFixedStructureFlag() const { return m_tilesFixedStructureFlag; }
> -};
> -}
> -//! \}
> -
> -#endif // ifndef X265_TENCCFG_H
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/TEncCu.cpp
> --- a/source/Lib/TLibEncoder/TEncCu.cpp Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibEncoder/TEncCu.cpp Mon Mar 03 14:24:34 2014 -0800
> @@ -103,7 +103,7 @@
>
>      m_origYuv = new TComYuv*[m_totalDepth - 1];
>
> -    int csp = m_cfg->param.internalCsp;
> +    int csp = m_cfg->param->internalCsp;
>
>      bool ok = true;
>      for (int i = 0; i < m_totalDepth - 1; i++)
> @@ -383,7 +383,7 @@
>      }
>      else
>      {
> -        if (m_cfg->param.rdLevel < 5)
> +        if (m_cfg->param->rdLevel < 5)
>          {
>              TComDataCU* outBestCU = NULL;
>
> @@ -734,7 +734,7 @@
>          if (outBestCU->getSlice()->getSliceType() != I_SLICE)
>          {
>              // 2Nx2N
> -            if (m_cfg->param.bEnableEarlySkip)
> +            if (m_cfg->param->bEnableEarlySkip)
>              {
>                  xCheckRDCostInter(outBestCU, outTempCU, SIZE_2Nx2N);
>                  outTempCU->initEstData(depth, qp); // by competition for inter_2Nx2N
> @@ -744,12 +744,12 @@
>
>              outTempCU->initEstData(depth, qp);
>
> -            if (!m_cfg->param.bEnableEarlySkip)
> +            if (!m_cfg->param->bEnableEarlySkip)
>              {
>                  // 2Nx2N, NxN
>                  xCheckRDCostInter(outBestCU, outTempCU, SIZE_2Nx2N);
>                  outTempCU->initEstData(depth, qp);
> -                if (m_cfg->param.bEnableCbfFastMode)
> +                if (m_cfg->param->bEnableCbfFastMode)
>                  {
>                      doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                  }
> @@ -773,14 +773,14 @@
>                      }
>                  }
>
> -                if (m_cfg->param.bEnableRectInter)
> +                if (m_cfg->param->bEnableRectInter)
>                  {
>                      // 2NxN, Nx2N
>                      if (doNotBlockPu)
>                      {
>                          xCheckRDCostInter(outBestCU, outTempCU, SIZE_Nx2N);
>                          outTempCU->initEstData(depth, qp);
> -                        if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_Nx2N)
> +                        if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_Nx2N)
>                          {
>                              doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                          }
> @@ -789,7 +789,7 @@
>                      {
>                          xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxN);
>                          outTempCU->initEstData(depth, qp);
> -                        if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxN)
> +                        if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxN)
>                          {
>                              doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                          }
> @@ -811,7 +811,7 @@
>                          {
>                              xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnU);
>                              outTempCU->initEstData(depth, qp);
> -                            if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
> +                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
>                              {
>                                  doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                              }
> @@ -820,7 +820,7 @@
>                          {
>                              xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnD);
>                              outTempCU->initEstData(depth, qp);
> -                            if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
> +                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
>                              {
>                                  doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                              }
> @@ -832,7 +832,7 @@
>                          {
>                              xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnU, true);
>                              outTempCU->initEstData(depth, qp);
> -                            if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
> +                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnU)
>                              {
>                                  doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                              }
> @@ -841,7 +841,7 @@
>                          {
>                              xCheckRDCostInter(outBestCU, outTempCU, SIZE_2NxnD, true);
>                              outTempCU->initEstData(depth, qp);
> -                            if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
> +                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_2NxnD)
>                              {
>                                  doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                              }
> @@ -855,7 +855,7 @@
>                          {
>                              xCheckRDCostInter(outBestCU, outTempCU, SIZE_nLx2N);
>                              outTempCU->initEstData(depth, qp);
> -                            if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
> +                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
>                              {
>                                  doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                              }
> @@ -872,7 +872,7 @@
>                          {
>                              xCheckRDCostInter(outBestCU, outTempCU, SIZE_nLx2N, true);
>                              outTempCU->initEstData(depth, qp);
> -                            if (m_cfg->param.bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
> +                            if (m_cfg->param->bEnableCbfFastMode && outBestCU->getPartitionSize(0) == SIZE_nLx2N)
>                              {
>                                  doNotBlockPu = outBestCU->getQtRootCbf(0) != 0;
>                              }
> @@ -1231,7 +1231,7 @@
>
>      UChar depth = outTempCU->getDepth(0);
>      outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>      outTempCU->getInterMergeCandidates(0, 0, mvFieldNeighbours, interDirNeighbours, numValidMergeCand);
>
>      int mergeCandBuffer[MRG_MAX_NUM_CANDS];
> @@ -1257,8 +1257,8 @@
>          for (uint32_t mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand)
>          {
>              /* TODO: check only necessary when -F>1, and ref pixels available is in units of LCU rows */
> -            if (mvFieldNeighbours[0 + 2 * mergeCand].mv.y >= (m_cfg->param.searchRange + 1) * 4
> -                || mvFieldNeighbours[1 + 2 * mergeCand].mv.y >= (m_cfg->param.searchRange + 1) * 4)
> +            if (mvFieldNeighbours[0 + 2 * mergeCand].mv.y >= (m_cfg->param->searchRange + 1) * 4
> +                || mvFieldNeighbours[1 + 2 * mergeCand].mv.y >= (m_cfg->param->searchRange + 1) * 4)
>              {
>                  continue;
>              }
> @@ -1268,7 +1268,7 @@
>                  {
>                      // set MC parameters
>                      outTempCU->setPredModeSubParts(MODE_INTER, 0, depth); // interprets depth relative to LCU level
> -                    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(),     0, depth);
> +                    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue,     0, depth);
>                      outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
>                      outTempCU->setMergeFlag(0, true);
>                      outTempCU->setMergeIndex(0, mergeCand);
> @@ -1324,7 +1324,7 @@
>              }
>          }
>
> -        if (noResidual == 0 && m_cfg->param.bEnableEarlySkip)
> +        if (noResidual == 0 && m_cfg->param->bEnableEarlySkip)
>          {
>              if (outBestCU->getQtRootCbf(0) == 0)
>              {
> @@ -1364,7 +1364,7 @@
>      outTempCU->setSkipFlagSubParts(false, 0, depth);
>      outTempCU->setPartSizeSubParts(partSize, 0, depth);
>      outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>
>      m_tmpRecoYuv[depth]->clear();
>      m_tmpResiYuv[depth]->clear();
> @@ -1385,7 +1385,7 @@
>      outTempCU->setSkipFlagSubParts(false, 0, depth);
>      outTempCU->setPartSizeSubParts(partSize, 0, depth);
>      outTempCU->setPredModeSubParts(MODE_INTRA, 0, depth);
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>
>      m_search->estIntraPredQT(outTempCU, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_tmpRecoYuv[depth], preCalcDistC, true);
>
> @@ -1425,7 +1425,7 @@
>      outTempCU->setSkipFlagSubParts(false, 0, depth);
>      outTempCU->setPartSizeSubParts(partSize, 0, depth);
>      outTempCU->setPredModeSubParts(MODE_INTRA, 0, depth);
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>
>      bool bSeparateLumaChroma = true; // choose estimation mode
>      uint32_t preCalcDistC = 0;
> @@ -1482,7 +1482,7 @@
>      outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);
>      outTempCU->setPredModeSubParts(MODE_INTRA, 0, depth);
>      outTempCU->setTrIdxSubParts(0, 0, depth);
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>
>      m_search->IPCMSearch(outTempCU, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_tmpRecoYuv[depth]);
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/TEncCu.h
> --- a/source/Lib/TLibEncoder/TEncCu.h   Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibEncoder/TEncCu.h   Mon Mar 03 14:24:34 2014 -0800
> @@ -111,7 +111,7 @@
>      TComYuv**    m_bestMergeRecoYuv;
>      TComYuv**    m_origYuv;     ///< Original Yuv at each depth
>
> -    TEncCfg*     m_cfg;
> +    Encoder*     m_cfg;

It's a bit of a layering violation to have a top-level encoder pointer
way down here in the guts.  But this can be cleaned up later.

>      TEncSearch*  m_search;
>      TComTrQuant* m_trQuant;
>      TComRdCost*  m_rdCost;
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/TEncSbac.cpp
> --- a/source/Lib/TLibEncoder/TEncSbac.cpp       Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibEncoder/TEncSbac.cpp       Mon Mar 03 14:24:34 2014 -0800
> @@ -685,8 +685,8 @@
>          WRITE_FLAG(hrd->getVclHrdParametersPresentFlag() ? 1 : 0,  "vcl_hrd_parameters_present_flag");
>          if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag())
>          {
> -            WRITE_FLAG(hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,  "sub_pic_cpb_params_present_flag");
> -            if (hrd->getSubPicCpbParamsPresentFlag())
> +            WRITE_FLAG(hrd->getSubPicHrdParamsPresentFlag() ? 1 : 0,  "sub_pic_hrd_params_present_flag");
> +            if (hrd->getSubPicHrdParamsPresentFlag())
>              {
>                  WRITE_CODE(hrd->getTickDivisorMinus2(), 8,              "tick_divisor_minus2");
>                  WRITE_CODE(hrd->getDuCpbRemovalDelayLengthMinus1(), 5,  "du_cpb_removal_delay_length_minus1");
> @@ -695,7 +695,7 @@
>              }
>              WRITE_CODE(hrd->getBitRateScale(), 4,                     "bit_rate_scale");
>              WRITE_CODE(hrd->getCpbSizeScale(), 4,                     "cpb_size_scale");
> -            if (hrd->getSubPicCpbParamsPresentFlag())
> +            if (hrd->getSubPicHrdParamsPresentFlag())
>              {
>                  WRITE_CODE(hrd->getDuCpbSizeScale(), 4,                "du_cpb_size_scale");
>              }
> @@ -738,7 +738,7 @@
>                  {
>                      WRITE_UVLC(hrd->getBitRateValueMinus1(i, j, nalOrVcl), "bit_rate_value_minus1");
>                      WRITE_UVLC(hrd->getCpbSizeValueMinus1(i, j, nalOrVcl), "cpb_size_value_minus1");
> -                    if (hrd->getSubPicCpbParamsPresentFlag())
> +                    if (hrd->getSubPicHrdParamsPresentFlag())
>                      {
>                          WRITE_UVLC(hrd->getDuCpbSizeValueMinus1(i, j, nalOrVcl), "cpb_size_du_value_minus1");
>                          WRITE_UVLC(hrd->getDuBitRateValueMinus1(i, j, nalOrVcl), "bit_rate_du_value_minus1");
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/TEncSearch.cpp
> --- a/source/Lib/TLibEncoder/TEncSearch.cpp     Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Mon Mar 03 14:24:34 2014 -0800
> @@ -80,7 +80,7 @@
>  {
>      if (m_cfg)
>      {
> -        const uint32_t numLayersToAllocate = m_cfg->getQuadtreeTULog2MaxSize() - m_cfg->getQuadtreeTULog2MinSize() + 1;
> +        const uint32_t numLayersToAllocate = m_cfg->m_quadtreeTULog2MaxSize - m_cfg->m_quadtreeTULog2MinSize + 1;
>          for (uint32_t i = 0; i < numLayersToAllocate; ++i)
>          {
>              X265_FREE(m_qtTempCoeffY[i]);
> @@ -108,30 +108,30 @@
>      m_tmpYuvPred.destroy();
>  }
>
> -bool TEncSearch::init(TEncCfg* cfg, TComRdCost* rdCost, TComTrQuant* trQuant)
> +bool TEncSearch::init(Encoder* cfg, TComRdCost* rdCost, TComTrQuant* trQuant)
>  {
>      m_cfg     = cfg;
>      m_trQuant = trQuant;
>      m_rdCost  = rdCost;
>
> -    initTempBuff(cfg->param.internalCsp);
> -    m_me.setSearchMethod(cfg->param.searchMethod);
> -    m_me.setSubpelRefine(cfg->param.subpelRefine);
> +    initTempBuff(cfg->param->internalCsp);

Hmm, cfg->m_csp and cfg->param->internalCsp are redundant, I believe

> +    m_me.setSearchMethod(cfg->param->searchMethod);
> +    m_me.setSubpelRefine(cfg->param->subpelRefine);
>
>      /* When frame parallelism is active, only 'refLagPixels' of reference frames will be guaranteed
>       * available for motion reference.  See refLagRows in FrameEncoder::compressCTURows() */
> -    m_refLagPixels = cfg->param.frameNumThreads > 1 ? cfg->param.searchRange : cfg->param.sourceHeight;
> +    m_refLagPixels = cfg->param->frameNumThreads > 1 ? cfg->param->searchRange : cfg->param->sourceHeight;
>
>      // default to no adaptive range
>      for (int dir = 0; dir < 2; dir++)
>      {
>          for (int ref = 0; ref < MAX_NUM_REF; ref++)
>          {
> -            m_adaptiveRange[dir][ref] = cfg->param.searchRange;
> +            m_adaptiveRange[dir][ref] = cfg->param->searchRange;
>          }
>      }
>
> -    const uint32_t numLayersToAllocate = cfg->getQuadtreeTULog2MaxSize() - cfg->getQuadtreeTULog2MinSize() + 1;
> +    const uint32_t numLayersToAllocate = cfg->m_quadtreeTULog2MaxSize - cfg->m_quadtreeTULog2MinSize + 1;
>      m_qtTempCoeffY  = new TCoeff*[numLayersToAllocate];
>      m_qtTempCoeffCb = new TCoeff*[numLayersToAllocate];
>      m_qtTempCoeffCr = new TCoeff*[numLayersToAllocate];
> @@ -141,7 +141,7 @@
>          m_qtTempCoeffY[i]  = X265_MALLOC(TCoeff, g_maxCUWidth * g_maxCUHeight);
>          m_qtTempCoeffCb[i] = X265_MALLOC(TCoeff, (g_maxCUWidth >> m_hChromaShift) * (g_maxCUHeight >> m_vChromaShift));
>          m_qtTempCoeffCr[i] = X265_MALLOC(TCoeff, (g_maxCUWidth >> m_hChromaShift) * (g_maxCUHeight >> m_vChromaShift));
> -        m_qtTempShortYuv[i].create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param.internalCsp);
> +        m_qtTempShortYuv[i].create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param->internalCsp);
>      }
>
>      const uint32_t numPartitions = 1 << (g_maxCUDepth << 1);
> @@ -160,8 +160,8 @@
>      CHECKED_MALLOC(m_qtTempTUCoeffCb, TCoeff, MAX_TS_WIDTH * MAX_TS_HEIGHT);
>      CHECKED_MALLOC(m_qtTempTUCoeffCr, TCoeff, MAX_TS_WIDTH * MAX_TS_HEIGHT);
>
> -    return m_qtTempTransformSkipYuv.create(g_maxCUWidth, g_maxCUHeight, cfg->param.internalCsp) &&
> -           m_tmpYuvPred.create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param.internalCsp);
> +    return m_qtTempTransformSkipYuv.create(g_maxCUWidth, g_maxCUHeight, cfg->param->internalCsp) &&
> +           m_tmpYuvPred.create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param->internalCsp);
>
>  fail:
>      return false;
> @@ -670,13 +670,13 @@
>      // don't check split if TU size is less or equal to max TU size
>      bool noSplitIntraMaxTuSize = bCheckFull;
>
> -    if (m_cfg->param.rdPenalty && !isIntraSlice)
> +    if (m_cfg->param->rdPenalty && !isIntraSlice)
>      {
>          // in addition don't check split if TU size is less or equal to 16x16 TU size for non-intra slice
>          noSplitIntraMaxTuSize = (trSizeLog2 <= X265_MIN(maxTuSize, 4));
>
>          // if maximum RD-penalty don't check TU size 32x32
> -        if (m_cfg->param.rdPenalty == 2)
> +        if (m_cfg->param->rdPenalty == 2)
>          {
>              bCheckFull = (trSizeLog2 <= X265_MIN(maxTuSize, 4));
>          }
> @@ -701,7 +701,7 @@
>      checkTransformSkip &= (widthTransformSkip == 4 && heightTransformSkip == 4);
>      checkTransformSkip &= (!cu->getCUTransquantBypass(0));
>      checkTransformSkip &= (!((cu->getQP(0) == 0) && (cu->getSlice()->getSPS()->getUseLossless())));
> -    if (m_cfg->param.bEnableTSkipFast)
> +    if (m_cfg->param->bEnableTSkipFast)
>      {
>          checkTransformSkip &= (cu->getPartitionSize(absPartIdx) == SIZE_NxN);
>      }
> @@ -851,7 +851,7 @@
>              }
>              //----- determine rate and r-d cost -----
>              uint32_t singleBits = xGetIntraBitsQT(cu, trDepth, absPartIdx, true, !bLumaOnly);
> -            if (m_cfg->param.rdPenalty && (trSizeLog2 == 5) && !isIntraSlice)
> +            if (m_cfg->param->rdPenalty && (trSizeLog2 == 5) && !isIntraSlice)
>              {
>                  singleBits = singleBits * 4;
>              }
> @@ -988,10 +988,10 @@
>      int maxTuSize = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
>      int isIntraSlice = (cu->getSlice()->getSliceType() == I_SLICE);
>
> -    if (m_cfg->param.rdPenalty && !isIntraSlice)
> +    if (m_cfg->param->rdPenalty && !isIntraSlice)
>      {
>          // if maximum RD-penalty don't check TU size 32x32
> -        if (m_cfg->param.rdPenalty == 2)
> +        if (m_cfg->param->rdPenalty == 2)
>          {
>              bCheckFull = (trSizeLog2 <= X265_MIN(maxTuSize, 4));
>          }
> @@ -1406,7 +1406,7 @@
>          }
>
>          checkTransformSkip &= (trSizeLog2 <= 3);
> -        if (m_cfg->param.bEnableTSkipFast)
> +        if (m_cfg->param->bEnableTSkipFast)
>          {
>              checkTransformSkip &= (trSizeLog2 < 3);
>              if (checkTransformSkip)
> @@ -1689,8 +1689,8 @@
>              assert(((uint32_t)(size_t)residual & (width - 1)) == 0);
>              assert(width <= 32);
>              int part = partitionFromSizes(cu->getWidth(0) >> (trDepth), cu->getHeight(0) >> (trDepth));
> -            primitives.chroma[m_cfg->param.internalCsp].add_ps[part](recon, stride, pred, residual, stride, stride);
> -            primitives.chroma[m_cfg->param.internalCsp].copy_pp[part](reconIPred, reconIPredStride, recon, stride);
> +            primitives.chroma[m_cfg->param->internalCsp].add_ps[part](recon, stride, pred, residual, stride, stride);
> +            primitives.chroma[m_cfg->param->internalCsp].copy_pp[part](reconIPred, reconIPredStride, recon, stride);
>          }
>      }
>      else
> @@ -2504,7 +2504,7 @@
>
>          costCand = xGetInterPredictionError(cu, puIdx);
>          bitsCand = mergeCand + 1;
> -        if (mergeCand == m_cfg->param.maxNumMergeCand - 1)
> +        if (mergeCand == m_cfg->param->maxNumMergeCand - 1)
>          {
>              bitsCand--;
>          }
> diff -r 6662df480e39 -r 56fa912d6e7c source/Lib/TLibEncoder/TEncSearch.h
> --- a/source/Lib/TLibEncoder/TEncSearch.h       Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/Lib/TLibEncoder/TEncSearch.h       Mon Mar 03 14:24:34 2014 -0800
> @@ -47,8 +47,7 @@
>  #include "TLibCommon/TComPic.h"
>  #include "TEncEntropy.h"
>  #include "TEncSbac.h"
> -#include "TEncCfg.h"
> -
> +#include "../../encoder/encoder.h"

again, relative path unnecessary. fixed

>  #include "primitives.h"
>  #include "bitcost.h"
>  #include "motion.h"
> @@ -99,7 +98,7 @@
>      TComYuv         m_qtTempTransformSkipYuv;
>
>      // interface to option
> -    TEncCfg*        m_cfg;
> +    Encoder*        m_cfg;
>
>      // interface to classes
>      TComTrQuant*    m_trQuant;
> @@ -136,7 +135,7 @@
>      TEncSearch();
>      virtual ~TEncSearch();
>
> -    bool init(TEncCfg* cfg, TComRdCost* rdCost, TComTrQuant *trQuant);
> +    bool init(Encoder* cfg, TComRdCost* rdCost, TComTrQuant *trQuant);
>
>  protected:
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/common/param.cpp
> --- a/source/common/param.cpp   Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/common/param.cpp   Mon Mar 03 14:24:34 2014 -0800
> @@ -170,6 +170,7 @@
>      param->defDispWinBottomOffset = 0;
>      param->bEnableVuiTimingInfoPresentFlag = 0;
>      param->bEnableVuiHrdParametersPresentFlag = 0;
> +    param->bEnableNalHrdParametersPresentFlag = 0;
>      param->bEnableBitstreamRestrictionFlag = 0;
>      param->bEnableSubPicHrdParamsPresentFlag = 0;
>  }
> @@ -669,11 +670,18 @@
>          p->bEnableVuiParametersPresentFlag = 1;
>          p->bEnableVuiTimingInfoPresentFlag = atobool(value);
>      }
> +    OPT("hrd")
> +    {
> +        p->bEnableVuiParametersPresentFlag = 1;
> +        p->bEnableVuiTimingInfoPresentFlag = 1;
> +        p->bEnableVuiHrdParametersPresentFlag = atobool(value);
> +    }
>      OPT("nal-hrd")
>      {
>          p->bEnableVuiParametersPresentFlag = 1;
>          p->bEnableVuiTimingInfoPresentFlag = 1;
> -        p->bEnableVuiHrdParametersPresentFlag = atobool(value);
> +        p->bEnableVuiHrdParametersPresentFlag = 1;
> +        p->bEnableNalHrdParametersPresentFlag = parseName(value, x265_nal_hrd_names, bError);
>      }
>      OPT("bitstreamrestriction")
>      {
> @@ -682,8 +690,9 @@
>      }
>      OPT("subpichrd")
>      {
> -        p->bEnableVuiParametersPresentFlag = 1;
> -        p->bEnableVuiHrdParametersPresentFlag = 1;
> +       p->bEnableVuiParametersPresentFlag = 1;
> +       p->bEnableVuiHrdParametersPresentFlag = 1;
> +        p->bEnableNalHrdParametersPresentFlag = 1;

there were tab characters here

>          p->bEnableSubPicHrdParamsPresentFlag = atobool(value);
>      }
>      else
> @@ -950,6 +959,9 @@
>            "Default Display Window Top Offset must be 0 or greater");
>      CHECK(param->defDispWinBottomOffset < 0,
>            "Default Display Window Bottom Offset must be 0 or greater");
> +    CHECK(param->bEnableNalHrdParametersPresentFlag
> +          && param->rc.vbvBufferSize <= 0,
> +          "If nal-hrd specified then vbv buffersize must also be specified");
>      CHECK(param->rc.rfConstant < 0 || param->rc.rfConstant > 51,
>            "Valid quality based VBR range 0 - 51");
>      CHECK(param->bFrameAdaptive < 0 || param->bFrameAdaptive > 2,
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/api.cpp
> --- a/source/encoder/api.cpp    Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/api.cpp    Mon Mar 03 14:24:34 2014 -0800
> @@ -49,9 +49,6 @@
>          encoder->determineLevelAndProfile(param);
>          encoder->configure(param);
>
> -        // save a copy of final parameters in TEncCfg
> -        memcpy(&encoder->param, param, sizeof(*param));
> -
>          x265_print_params(param);
>          encoder->create();
>          encoder->init();
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/compress.cpp
> --- a/source/encoder/compress.cpp       Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/compress.cpp       Mon Mar 03 14:24:34 2014 -0800
> @@ -80,7 +80,7 @@
>
>      cu->setPartSizeSubParts(partSize, 0, depth);
>      cu->setPredModeSubParts(MODE_INTRA, 0, depth);
> -    cu->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    cu->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>
>      uint32_t initTrDepth = cu->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
>      uint32_t width       = cu->getWidth(0) >> initTrDepth;
> @@ -198,7 +198,7 @@
>
>      outTempCU->setPartSizeSubParts(partSize, 0, depth);
>      outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>
>      //do motion compensation only for Luma since luma cost alone is calculated
>      outTempCU->m_totalBits = 0;
> @@ -224,13 +224,13 @@
>
>      UChar depth = outTempCU->getDepth(0);
>      outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
> -    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outTempCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>      outTempCU->getInterMergeCandidates(0, 0, mvFieldNeighbours, interDirNeighbours, numValidMergeCand);
>      outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
>      outTempCU->setMergeFlag(0, true);
>
>      outBestCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
> -    outBestCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
> +    outBestCU->setCUTransquantBypassSubParts(m_cfg->m_CUTransquantBypassFlagValue, 0, depth);
>      outBestCU->setPredModeSubParts(MODE_INTER, 0, depth);
>      outBestCU->setMergeFlag(0, true);
>
> @@ -241,8 +241,8 @@
>      for (int mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand)
>      {
>          /* TODO: check only necessary when -F>1, and ref pixels available is in units of LCU rows */
> -        if (mvFieldNeighbours[0 + 2 * mergeCand].mv.y < (m_cfg->param.searchRange + 1) * 4
> -            && mvFieldNeighbours[1 + 2 * mergeCand].mv.y < (m_cfg->param.searchRange + 1) * 4)
> +        if (mvFieldNeighbours[0 + 2 * mergeCand].mv.y < (m_cfg->param->searchRange + 1) * 4
> +            && mvFieldNeighbours[1 + 2 * mergeCand].mv.y < (m_cfg->param->searchRange + 1) * 4)
>          {
>              // set MC parameters, interprets depth relative to LCU level
>              outTempCU->setMergeIndex(0, mergeCand);
> @@ -253,7 +253,7 @@
>              // do MC only for Luma part
>              m_search->motionCompensation(outTempCU, m_tmpPredYuv[depth], REF_PIC_LIST_X, 0, true, false);
>              bitsCand = mergeCand + 1;
> -            if (mergeCand == (int)m_cfg->param.maxNumMergeCand - 1)
> +            if (mergeCand == (int)m_cfg->param->maxNumMergeCand - 1)
>              {
>                  bitsCand--;
>              }
> @@ -293,7 +293,7 @@
>          outTempCU->m_totalCost = m_rdCost->calcRdSADCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
>          outTempCU->m_sa8dCost = outTempCU->m_totalCost;
>          outBestCU->m_sa8dCost = outTempCU->m_sa8dCost;
> -        if (m_cfg->param.rdLevel >= 1)
> +        if (m_cfg->param->rdLevel >= 1)
>          {
>              //calculate the motion compensation for chroma for the best mode selected
>              int numPart = outBestCU->getNumPartInter();
> @@ -359,7 +359,7 @@
>      bool bInsidePicture = (rpelx < outTempCU->getSlice()->getSPS()->getPicWidthInLumaSamples()) &&
>          (bpely < outTempCU->getSlice()->getSPS()->getPicHeightInLumaSamples());
>
> -    if (depth == 0 && m_cfg->param.rdLevel == 0)
> +    if (depth == 0 && m_cfg->param->rdLevel == 0)
>      {
>          m_origYuv[depth]->copyToPicYuv(cu->getPic()->getPicYuvRec(), cu->getAddr(), 0, 0, 0);
>      }
> @@ -426,8 +426,8 @@
>              /* Compute  Merge Cost */
>              xComputeCostMerge2Nx2N(m_bestMergeCU[depth], m_mergeCU[depth], m_modePredYuv[3][depth], m_bestMergeRecoYuv[depth]);
>              bool earlyskip = false;
> -            if (m_cfg->param.rdLevel >= 1)
> -                earlyskip = (m_cfg->param.bEnableEarlySkip && m_bestMergeCU[depth]->isSkipped(0));
> +            if (m_cfg->param->rdLevel >= 1)
> +                earlyskip = (m_cfg->param->bEnableEarlySkip && m_bestMergeCU[depth]->isSkipped(0));
>
>              if (!earlyskip)
>              {
> @@ -442,7 +442,7 @@
>                  }
>
>                  /*Compute Rect costs*/
> -                if (m_cfg->param.bEnableRectInter)
> +                if (m_cfg->param->bEnableRectInter)
>                  {
>                      xComputeCostInter(m_interCU_Nx2N[depth], m_modePredYuv[1][depth], SIZE_Nx2N);
>                      xComputeCostInter(m_interCU_2NxN[depth], m_modePredYuv[2][depth], SIZE_2NxN);
> @@ -464,7 +464,7 @@
>                      m_modePredYuv[2][depth] = m_bestPredYuv[depth];
>                      m_bestPredYuv[depth] = tempYuv;
>                  }
> -                if (m_cfg->param.rdLevel > 2)
> +                if (m_cfg->param->rdLevel > 2)
>                  {
>                      //calculate the motion compensation for chroma for the best mode selected
>                      int numPart = outBestCU->getNumPartInter();
> @@ -493,7 +493,7 @@
>                  {
>                      /*compute intra cost */
>                      bool bdoIntra = true;
> -                    if (m_cfg->param.rdLevel > 2)
> +                    if (m_cfg->param->rdLevel > 2)
>                      {
>                          bdoIntra = (outBestCU->getCbf(0, TEXT_LUMA) ||  outBestCU->getCbf(0, TEXT_CHROMA_U) ||
>                                      outBestCU->getCbf(0, TEXT_CHROMA_V));
> @@ -501,7 +501,7 @@
>                      if (bdoIntra)
>                      {
>                          xComputeCostIntraInInter(m_intraInInterCU[depth], SIZE_2Nx2N);
> -                        if (m_cfg->param.rdLevel > 2)
> +                        if (m_cfg->param->rdLevel > 2)
>                          {
>                              xEncodeIntraInInter(m_intraInInterCU[depth], m_origYuv[depth], m_modePredYuv[5][depth],
>                                                  m_tmpResiYuv[depth],  m_tmpRecoYuv[depth]);
> @@ -519,7 +519,7 @@
>                          }
>                      }
>                  }
> -                if (m_cfg->param.rdLevel == 2)
> +                if (m_cfg->param->rdLevel == 2)
>                  {
>                      if (m_bestMergeCU[depth]->m_sa8dCost < outBestCU->m_totalCost)
>                      {
> @@ -548,7 +548,7 @@
>                          xEncodeIntraInInter(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],  m_bestRecoYuv[depth]);
>                      }
>                  }
> -                if (m_cfg->param.rdLevel == 1)
> +                if (m_cfg->param->rdLevel == 1)
>                  {
>                      if (m_bestMergeCU[depth]->m_sa8dCost < outBestCU->m_totalCost)
>                      {
> @@ -577,7 +577,7 @@
>                          m_search->generateCoeffRecon(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth], m_bestRecoYuv[depth], false);
>                      }
>                  }
> -                if (m_cfg->param.rdLevel == 0)
> +                if (m_cfg->param->rdLevel == 0)
>                  {
>                      if (outBestCU->getPredictionMode(0) == MODE_INTER)
>                      {
> @@ -601,7 +601,7 @@
>                  m_bestMergeRecoYuv[depth] = tempYuv;
>              }
>
> -            if (m_cfg->param.rdLevel > 0) //checkDQP can be done only after residual encoding is done
> +            if (m_cfg->param->rdLevel > 0) //checkDQP can be done only after residual encoding is done
>                  xCheckDQP(outBestCU);
>              /* Disable recursive analysis for whole CUs temporarily */
>              if ((outBestCU != 0) && (outBestCU->isSkipped(0)))
> @@ -609,7 +609,7 @@
>              else
>                  bSubBranch = true;
>
> -            if (m_cfg->param.rdLevel > 1)
> +            if (m_cfg->param->rdLevel > 1)
>              {
>                  m_entropyCoder->resetBits();
>                  m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth, true);
> @@ -678,7 +678,7 @@
>                  outBestCU->copyToPic((UChar)depth);
>
>                  /* Copy Yuv data to picture Yuv */
> -                if (m_cfg->param.rdLevel != 0)
> +                if (m_cfg->param->rdLevel != 0)
>                      xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(), outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpely);
>                  return;
>              }
> @@ -717,9 +717,9 @@
>  #endif // if EARLY_EXIT
>                  /* Adding costs from best SUbCUs */
>                  outTempCU->copyPartFrom(subBestPartCU, nextDepth_partIndex, nextDepth, true); // Keep best part data to current temporary data.
> -                if (m_cfg->param.rdLevel != 0)
> +                if (m_cfg->param->rdLevel != 0)
>                      xCopyYuv2Tmp(subBestPartCU->getTotalNumPart() * nextDepth_partIndex, nextDepth);
> -                if (m_cfg->param.rdLevel == 0)
> +                if (m_cfg->param->rdLevel == 0)
>                      m_bestPredYuv[nextDepth]->copyToPartYuv(m_tmpPredYuv[depth], subBestPartCU->getTotalNumPart() * nextDepth_partIndex);
>              }
>              else if (bInSlice)
> @@ -731,14 +731,14 @@
>
>          if (!bBoundary)
>          {
> -            if (m_cfg->param.rdLevel > 1)
> +            if (m_cfg->param->rdLevel > 1)
>              {
>                  m_entropyCoder->resetBits();
>                  m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth, true);
>                  outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits
>              }
>          }
> -        if (m_cfg->param.rdLevel > 1)
> +        if (m_cfg->param->rdLevel > 1)
>              outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
>          else
>              outTempCU->m_totalCost = m_rdCost->calcRdSADCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
> @@ -811,11 +811,11 @@
>      /* Copy Best data to Picture for next partition prediction. */
>      outBestCU->copyToPic((UChar)depth);
>
> -    if (m_cfg->param.rdLevel == 0 && depth == 0)
> +    if (m_cfg->param->rdLevel == 0 && depth == 0)
>      {
>          encodeResidue(outBestCU, outBestCU, 0, 0);
>      }
> -    else if (m_cfg->param.rdLevel != 0)
> +    else if (m_cfg->param->rdLevel != 0)
>      {
>          /* Copy Yuv data to picture Yuv */
>          xCopyYuv2Pic(outBestCU->getPic(), outBestCU->getAddr(), outBestCU->getZorderIdxInCU(), depth, depth, outBestCU, lpelx, tpely);
> @@ -874,13 +874,13 @@
>              src2stride = m_bestPredYuv[0]->getCStride();
>              src1stride = m_origYuv[0]->getCStride();
>              dststride = m_tmpResiYuv[depth]->m_cwidth;
> -            primitives.chroma[m_cfg->param.internalCsp].sub_ps[part](dst, dststride, src1, src2, src1stride, src2stride);
> +            primitives.chroma[m_cfg->param->internalCsp].sub_ps[part](dst, dststride, src1, src2, src1stride, src2stride);
>
>              src2 = m_bestPredYuv[0]->getCrAddr(absPartIdx);
>              src1 = m_origYuv[0]->getCrAddr(absPartIdx);
>              dst = m_tmpResiYuv[depth]->getCrAddr(0);
>              dststride = m_tmpResiYuv[depth]->m_cwidth;
> -            primitives.chroma[m_cfg->param.internalCsp].sub_ps[part](dst, dststride, src1, src2, src1stride, src2stride);
> +            primitives.chroma[m_cfg->param->internalCsp].sub_ps[part](dst, dststride, src1, src2, src1stride, src2stride);
>
>              //Residual encoding
>              m_search->residualTransformQuantInter(cu, 0, 0, m_tmpResiYuv[depth], cu->getDepth(0), true);
> @@ -910,12 +910,12 @@
>                  dststride = m_bestRecoYuv[depth]->getCStride();
>                  src1stride = m_bestPredYuv[0]->getCStride();
>                  src2stride = m_tmpResiYuv[depth]->m_cwidth;
> -                primitives.chroma[m_cfg->param.internalCsp].add_ps[part](reco, dststride, pred, res, src1stride, src2stride);
> +                primitives.chroma[m_cfg->param->internalCsp].add_ps[part](reco, dststride, pred, res, src1stride, src2stride);
>
>                  pred = m_bestPredYuv[0]->getCrAddr(absPartIdx);
>                  res = m_tmpResiYuv[depth]->getCrAddr(0);
>                  reco = m_bestRecoYuv[depth]->getCrAddr(0);
> -                primitives.chroma[m_cfg->param.internalCsp].add_ps[part](reco, dststride, pred, res, src1stride, src2stride);
> +                primitives.chroma[m_cfg->param->internalCsp].add_ps[part](reco, dststride, pred, res, src1stride, src2stride);
>                  m_bestRecoYuv[depth]->copyToPicYuv(lcu->getPic()->getPicYuvRec(), lcu->getAddr(), absPartIdx, 0, 0);
>                  return;
>              }
> @@ -934,11 +934,11 @@
>          dst = rec->getCbAddr(cu->getAddr(), absPartIdx);
>          srcstride = m_bestPredYuv[0]->getCStride();
>          dststride = rec->getCStride();
> -        primitives.chroma[m_cfg->param.internalCsp].copy_pp[part](dst, dststride, src, srcstride);
> +        primitives.chroma[m_cfg->param->internalCsp].copy_pp[part](dst, dststride, src, srcstride);
>
>          src = m_bestPredYuv[0]->getCrAddr(absPartIdx);
>          dst = rec->getCrAddr(cu->getAddr(), absPartIdx);
> -        primitives.chroma[m_cfg->param.internalCsp].copy_pp[part](dst, dststride, src, srcstride);
> +        primitives.chroma[m_cfg->param->internalCsp].copy_pp[part](dst, dststride, src, srcstride);
>      }
>      else
>      {
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/cturow.cpp
> --- a/source/encoder/cturow.cpp Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/cturow.cpp Mon Mar 03 14:24:34 2014 -0800
> @@ -33,7 +33,7 @@
>  {
>      m_rdGoOnSbacCoder.init(&m_rdGoOnBinCodersCABAC);
>      m_sbacCoder.init(&m_binCoderCABAC);
> -    m_trQuant.init(1 << top->getQuadtreeTULog2MaxSize(), top->bEnableRDOQ, top->bEnableRDOQTS, top->param.bEnableTSkipFast);
> +    m_trQuant.init(1 << top->m_quadtreeTULog2MaxSize, top->bEnableRDOQ, top->bEnableRDOQTS, top->param->bEnableTSkipFast);
>
>      m_rdSbacCoders = new TEncSbac * *[g_maxCUDepth + 1];
>      m_binCodersCABAC = new TEncBinCABAC * *[g_maxCUDepth + 1];
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/dpb.cpp
> --- a/source/encoder/dpb.cpp    Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/dpb.cpp    Mon Mar 03 14:24:34 2014 -0800
> @@ -23,7 +23,7 @@
>
>  #include "TLibCommon/TComPic.h"
>  #include "TLibCommon/TComSlice.h"
> -#include "TLibEncoder/TEncCfg.h"
> +#include "encoder.h"
>
>  #include "PPA/ppa.h"
>  #include "dpb.h"
> @@ -36,7 +36,7 @@
>      while (!m_picList.empty())
>      {
>          TComPic* pic = m_picList.popFront();
> -        pic->destroy(m_cfg->param.bframes);
> +        pic->destroy(m_cfg->param->bframes);
>          delete pic;
>      }
>  }
> @@ -380,7 +380,7 @@
>      }
>      if (pic->m_lowres.bKeyframe)
>      {
> -        if (m_cfg->param.bOpenGOP)
> +        if (m_cfg->param->bOpenGOP)
>          {
>              return NAL_UNIT_CODED_SLICE_CRA;
>          }
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/dpb.h
> --- a/source/encoder/dpb.h      Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/dpb.h      Mon Mar 03 14:24:34 2014 -0800
> @@ -32,7 +32,7 @@
>  class FrameEncoder;
>  class TComPic;
>  class TComSlice;
> -class TEncCfg;
> +class Encoder;
>
>  class DPB
>  {
> @@ -41,18 +41,18 @@
>      int                m_lastIDR;
>      int                m_pocCRA;
>      bool               m_bRefreshPending;
> -    TEncCfg*           m_cfg;
> +    Encoder*           m_cfg;

Can we just pass a param to dpb?

>      PicList            m_picList;
>      int                m_maxRefL0;
>      int                m_maxRefL1;
>
> -    DPB(TEncCfg *cfg)
> +    DPB(Encoder *cfg)
>          : m_cfg(cfg)
>      {
>          m_lastIDR = 0;
>          m_pocCRA = 0;
>          m_bRefreshPending = false;
> -        m_maxRefL0 = cfg->param.maxNumReferences;
> +        m_maxRefL0 = cfg->param->maxNumReferences;
>          m_maxRefL1 = 1;
>      }
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp        Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/encoder.cpp        Mon Mar 03 14:24:34 2014 -0800
> @@ -93,14 +93,14 @@
>      if (!primitives.sad[0])
>      {
>          // this should be an impossible condition when using our public API, and indicates a serious bug.
> -        x265_log(&param, X265_LOG_ERROR, "Primitives must be initialized before encoder is created\n");
> +        x265_log(param, X265_LOG_ERROR, "Primitives must be initialized before encoder is created\n");
>          abort();
>      }
>
> -    m_frameEncoder = new FrameEncoder[param.frameNumThreads];
> +    m_frameEncoder = new FrameEncoder[param->frameNumThreads];
>      if (m_frameEncoder)
>      {
> -        for (int i = 0; i < param.frameNumThreads; i++)
> +        for (int i = 0; i < param->frameNumThreads; i++)
>          {
>              m_frameEncoder[i].setThreadPool(m_threadPool);
>          }
> @@ -111,22 +111,22 @@
>      m_numWPFrames = 0;
>
>      /* Try to open CSV file handle */
> -    if (param.csvfn)
> +    if (param->csvfn)
>      {
> -        m_csvfpt = fopen(param.csvfn, "r");
> +        m_csvfpt = fopen(param->csvfn, "r");
>          if (m_csvfpt)
>          {
>              // file already exists, re-open for append
>              fclose(m_csvfpt);
> -            m_csvfpt = fopen(param.csvfn, "ab");
> +            m_csvfpt = fopen(param->csvfn, "ab");
>          }
>          else
>          {
>              // new CSV file, write header
> -            m_csvfpt = fopen(param.csvfn, "wb");
> +            m_csvfpt = fopen(param->csvfn, "wb");
>              if (m_csvfpt)
>              {
> -                if (param.logLevel >= X265_LOG_DEBUG)
> +                if (param->logLevel >= X265_LOG_DEBUG)
>                      fprintf(m_csvfpt, "Encode Order, Type, POC, QP, Bits, Y PSNR, U PSNR, V PSNR, YUV PSNR, SSIM, SSIM (dB), Encoding time, Elapsed time, List 0, List 1\n");
>                  else
>                      fprintf(m_csvfpt, "Command, Date/Time, Elapsed Time, FPS, Bitrate, Y PSNR, U PSNR, V PSNR, Global PSNR, SSIM, SSIM (dB), Version\n");
> @@ -139,7 +139,7 @@
>  {
>      if (m_frameEncoder)
>      {
> -        for (int i = 0; i < param.frameNumThreads; i++)
> +        for (int i = 0; i < param->frameNumThreads; i++)
>          {
>              // Ensure frame encoder is idle before destroying it
>              m_frameEncoder[i].getEncodedPicture(NULL);
> @@ -152,7 +152,7 @@
>      while (!m_freeList.empty())
>      {
>          TComPic* pic = m_freeList.popFront();
> -        pic->destroy(param.bframes);
> +        pic->destroy(param->bframes);
>          delete pic;
>      }
>
> @@ -179,12 +179,12 @@
>  {
>      if (m_frameEncoder)
>      {
> -        int numRows = (param.sourceHeight + g_maxCUHeight - 1) / g_maxCUHeight;
> -        for (int i = 0; i < param.frameNumThreads; i++)
> +        int numRows = (param->sourceHeight + g_maxCUHeight - 1) / g_maxCUHeight;
> +        for (int i = 0; i < param->frameNumThreads; i++)
>          {
>              if (!m_frameEncoder[i].init(this, numRows))
>              {
> -                x265_log(&param, X265_LOG_ERROR, "Unable to initialize frame encoder, aborting\n");
> +                x265_log(param, X265_LOG_ERROR, "Unable to initialize frame encoder, aborting\n");
>                  m_aborted = true;
>              }
>          }
> @@ -200,7 +200,7 @@
>   * this picture */
>  void Encoder::signalReconRowCompleted(int poc)
>  {
> -    for (int i = 0; i < param.frameNumThreads; i++)
> +    for (int i = 0; i < param->frameNumThreads; i++)
>      {
>          if (m_frameEncoder[i].m_blockRefPOC == poc)
>              m_frameEncoder[i].m_reconRowWait.trigger();
> @@ -216,8 +216,8 @@
>  {
>      int encIdx, curIdx;
>
> -    curIdx = (m_curEncoder + param.frameNumThreads - 1) % param.frameNumThreads;
> -    encIdx = (curIdx + 1) % param.frameNumThreads;
> +    curIdx = (m_curEncoder + param->frameNumThreads - 1) % param->frameNumThreads;
> +    encIdx = (curIdx + 1) % param->frameNumThreads;
>      while (encIdx != curIdx)
>      {
>          FrameEncoder *encoder = &m_frameEncoder[encIdx];
> @@ -228,7 +228,7 @@
>          rc->bufferFill = X265_MAX(rc->bufferFill, 0);
>          rc->bufferFill += encoder->m_rce.bufferRate;
>          rc->bufferFill = X265_MIN(rc->bufferFill, rc->bufferSize);
> -        encIdx = (encIdx + 1) % param.frameNumThreads;
> +        encIdx = (encIdx + 1) % param->frameNumThreads;
>      }
>  }
>
> @@ -280,15 +280,15 @@
>
>      if (pic_in)
>      {
> -        if (pic_in->colorSpace != param.internalCsp)
> +        if (pic_in->colorSpace != param->internalCsp)
>          {
> -            x265_log(&param, X265_LOG_ERROR, "Unsupported color space (%d) on input\n",
> +            x265_log(param, X265_LOG_ERROR, "Unsupported color space (%d) on input\n",
>                       pic_in->colorSpace);
>              return -1;
>          }
>          if (pic_in->bitDepth < 8 || pic_in->bitDepth > 16)
>          {
> -            x265_log(&param, X265_LOG_ERROR, "Input bit depth (%d) must be between 8 and 16\n",
> +            x265_log(param, X265_LOG_ERROR, "Input bit depth (%d) must be between 8 and 16\n",
>                       pic_in->bitDepth);
>              return -1;
>          }
> @@ -300,15 +300,15 @@
>              if (!pic || !pic->create(this))
>              {
>                  m_aborted = true;
> -                x265_log(&param, X265_LOG_ERROR, "memory allocation failure, aborting encode\n");
> +                x265_log(param, X265_LOG_ERROR, "memory allocation failure, aborting encode\n");
>                  if (pic)
>                  {
> -                    pic->destroy(param.bframes);
> +                    pic->destroy(param->bframes);
>                      delete pic;
>                  }
>                  return -1;
>              }
> -            if (param.bEnableSAO)
> +            if (param->bEnableSAO)
>              {
>                  // TODO: these should be allocated on demand within the encoder
>                  // NOTE: the SAO pointer from m_frameEncoder for read m_maxSplitLevel, etc, we can remove it later
> @@ -331,7 +331,7 @@
>
>          // Encoder holds a reference count until collecting stats
>          ATOMIC_INC(&pic->m_countRefEncoders);
> -        if (param.rc.aqMode || param.bEnableWeightedPred)
> +        if (param->rc.aqMode || param->bEnableWeightedPred)
>              m_rateControl->calcAdaptiveQuantFrame(pic);
>          m_lookahead->addPicture(pic, pic_in->sliceType);
>      }
> @@ -340,7 +340,7 @@
>          m_lookahead->flush();
>
>      FrameEncoder *curEncoder = &m_frameEncoder[m_curEncoder];
> -    m_curEncoder = (m_curEncoder + 1) % param.frameNumThreads;
> +    m_curEncoder = (m_curEncoder + 1) % param->frameNumThreads;
>      int ret = 0;
>
>      // getEncodedPicture() should block until the FrameEncoder has completed
> @@ -359,7 +359,7 @@
>          do
>          {
>              curEncoder = &m_frameEncoder[m_curEncoder];
> -            m_curEncoder = (m_curEncoder + 1) % param.frameNumThreads;
> +            m_curEncoder = (m_curEncoder + 1) % param->frameNumThreads;
>              out = curEncoder->getEncodedPicture(nalunits);
>          }
>          while (!out && flushed != m_curEncoder);
> @@ -486,21 +486,21 @@
>
>  char* Encoder::statsString(EncStats& stat, char* buffer)
>  {
> -    double fps = (double)param.fpsNum / param.fpsDenom;
> +    double fps = (double)param->fpsNum / param->fpsDenom;
>      double scale = fps / 1000 / (double)stat.m_numPics;
>
>      int len = sprintf(buffer, "%-6d ", stat.m_numPics);
>
>      len += sprintf(buffer + len, "Avg QP:%2.2lf", stat.m_totalQp / (double)stat.m_numPics);
>      len += sprintf(buffer + len, "  kb/s: %-8.2lf", stat.m_accBits * scale);
> -    if (param.bEnablePsnr)
> +    if (param->bEnablePsnr)
>      {
>          len += sprintf(buffer + len, "  PSNR Mean: Y:%.3lf U:%.3lf V:%.3lf",
>                         stat.m_psnrSumY / (double)stat.m_numPics,
>                         stat.m_psnrSumU / (double)stat.m_numPics,
>                         stat.m_psnrSumV / (double)stat.m_numPics);
>      }
> -    if (param.bEnableSsim)
> +    if (param->bEnableSsim)
>      {
>          sprintf(buffer + len, "  SSIM Mean: %.6lf (%.3lfdB)",
>                  stat.m_globalSsim / (double)stat.m_numPics,
> @@ -522,7 +522,7 @@
>          StatisticLog finalLog;
>          for (int depth = 0; depth < (int)g_maxCUDepth; depth++)
>          {
> -            for (int j = 0; j < param.frameNumThreads; j++)
> +            for (int j = 0; j < param->frameNumThreads; j++)
>              {
>                  for (int row = 0; row < m_frameEncoder[0].m_numRows; row++)
>                  {
> @@ -622,13 +622,13 @@
>              if (cntInter)
>              {
>                  len += sprintf(stats + len, " Inter "LL "%%", cntInter);
> -                if (param.bEnableAMP)
> +                if (param->bEnableAMP)
>                      len += sprintf(stats + len, "(%dx%d "LL "%% %dx%d "LL "%% %dx%d "LL "%% AMP "LL "%%)",
>                                     cuSize, cuSize, cuInterDistribution[0],
>                                     cuSize / 2, cuSize, cuInterDistribution[2],
>                                     cuSize, cuSize / 2, cuInterDistribution[1],
>                                     cuInterDistribution[3]);
> -                else if (param.bEnableRectInter)
> +                else if (param->bEnableRectInter)
>                      len += sprintf(stats + len, "(%dx%d "LL "%% %dx%d "LL "%% %dx%d "LL "%%)",
>                                     cuSize, cuSize, cuInterDistribution[0],
>                                     cuSize / 2, cuSize, cuInterDistribution[2],
> @@ -654,36 +654,36 @@
>              }
>              const char slicechars[] = "BPI";
>              if (stats[0])
> -                x265_log(&param, X265_LOG_INFO, "%c%-2d: %s\n", slicechars[sliceType], cuSize, stats);
> +                x265_log(param, X265_LOG_INFO, "%c%-2d: %s\n", slicechars[sliceType], cuSize, stats);
>          }
>      }
>
>  #endif // if LOG_CU_STATISTICS
> -    if (param.logLevel >= X265_LOG_INFO)
> +    if (param->logLevel >= X265_LOG_INFO)
>      {
>          char buffer[200];
>          if (m_analyzeI.m_numPics)
> -            x265_log(&param, X265_LOG_INFO, "frame I: %s\n", statsString(m_analyzeI, buffer));
> +            x265_log(param, X265_LOG_INFO, "frame I: %s\n", statsString(m_analyzeI, buffer));
>          if (m_analyzeP.m_numPics)
> -            x265_log(&param, X265_LOG_INFO, "frame P: %s\n", statsString(m_analyzeP, buffer));
> +            x265_log(param, X265_LOG_INFO, "frame P: %s\n", statsString(m_analyzeP, buffer));
>          if (m_analyzeB.m_numPics)
> -            x265_log(&param, X265_LOG_INFO, "frame B: %s\n", statsString(m_analyzeB, buffer));
> +            x265_log(param, X265_LOG_INFO, "frame B: %s\n", statsString(m_analyzeB, buffer));
>          if (m_analyzeAll.m_numPics)
> -            x265_log(&param, X265_LOG_INFO, "global : %s\n", statsString(m_analyzeAll, buffer));
> -        if (param.bEnableWeightedPred && m_analyzeP.m_numPics)
> +            x265_log(param, X265_LOG_INFO, "global : %s\n", statsString(m_analyzeAll, buffer));
> +        if (param->bEnableWeightedPred && m_analyzeP.m_numPics)
>          {
> -            x265_log(&param, X265_LOG_INFO, "%d of %d (%.2f%%) P frames weighted\n",
> +            x265_log(param, X265_LOG_INFO, "%d of %d (%.2f%%) P frames weighted\n",
>                       m_numWPFrames, m_analyzeP.m_numPics, (float)100.0 * m_numWPFrames / m_analyzeP.m_numPics);
>          }
>          int pWithB = 0;
> -        for (int i = 0; i <= param.bframes; i++)
> +        for (int i = 0; i <= param->bframes; i++)
>              pWithB += m_lookahead->histogram[i];
>          if (pWithB)
>          {
>              int p = 0;
> -            for (int i = 0; i <= param.bframes; i++)
> +            for (int i = 0; i <= param->bframes; i++)
>                  p += sprintf(buffer + p, "%.1f%% ", 100. * m_lookahead->histogram[i] / pWithB);
> -            x265_log(&param, X265_LOG_INFO, "consecutive B-frames: %s\n", buffer);
> +            x265_log(param, X265_LOG_INFO, "consecutive B-frames: %s\n", buffer);
>          }
>      }
>  }
> @@ -703,7 +703,7 @@
>          {
>              stats->globalSsim = m_analyzeAll.m_globalSsim / stats->encodedPictureCount;
>              stats->globalPsnr = (stats->globalPsnrY * 6 + stats->globalPsnrU + stats->globalPsnrV) / (8 * stats->encodedPictureCount);
> -            stats->elapsedVideoTime = (double)stats->encodedPictureCount * param.fpsDenom / param.fpsNum;
> +            stats->elapsedVideoTime = (double)stats->encodedPictureCount * param->fpsDenom / param->fpsNum;
>              stats->bitrate = (0.001f * stats->accBits) / stats->elapsedVideoTime;
>          }
>          else
> @@ -722,9 +722,9 @@
>
>  void Encoder::writeLog(int argc, char **argv)
>  {
> -    if (param.logLevel <= X265_LOG_DEBUG && m_csvfpt)
> +    if (param->logLevel <= X265_LOG_DEBUG && m_csvfpt)
>      {
> -        if (param.logLevel == X265_LOG_DEBUG)
> +        if (param->logLevel == X265_LOG_DEBUG)
>          {
>              fprintf(m_csvfpt, "Summary\n");
>              fprintf(m_csvfpt, "Command, Date/Time, Elapsed Time, FPS, Bitrate, Y PSNR, U PSNR, V PSNR, Global PSNR, SSIM, SSIM (dB), Version\n");
> @@ -752,13 +752,13 @@
>          fprintf(m_csvfpt, "%.2f, %.2f, %.2f,",
>                  stats.elapsedEncodeTime, stats.encodedPictureCount / stats.elapsedEncodeTime, stats.bitrate);
>
> -        if (param.bEnablePsnr)
> +        if (param->bEnablePsnr)
>              fprintf(m_csvfpt, " %.3lf, %.3lf, %.3lf, %.3lf,",
>                      stats.globalPsnrY / stats.encodedPictureCount, stats.globalPsnrU / stats.encodedPictureCount,
>                      stats.globalPsnrV / stats.encodedPictureCount, stats.globalPsnr);
>          else
>              fprintf(m_csvfpt, " -, -, -, -,");
> -        if (param.bEnableSsim)
> +        if (param->bEnableSsim)
>              fprintf(m_csvfpt, " %.6f, %6.3f,", stats.globalSsim, x265_ssim(stats.globalSsim));
>          else
>              fprintf(m_csvfpt, " -, -,");
> @@ -821,13 +821,13 @@
>      m_analyzeAll.addBits(bits);
>      m_analyzeAll.addQP(pic->m_avgQpAq);
>
> -    if (param.bEnablePsnr)
> +    if (param->bEnablePsnr)
>      {
>          m_analyzeAll.addPsnr(psnrY, psnrU, psnrV);
>      }
>
>      double ssim = 0.0;
> -    if (param.bEnableSsim && pic->m_ssimCnt > 0)
> +    if (param->bEnableSsim && pic->m_ssimCnt > 0)
>      {
>          ssim = pic->m_ssim / pic->m_ssimCnt;
>          m_analyzeAll.addSsim(ssim);
> @@ -836,32 +836,32 @@
>      {
>          m_analyzeI.addBits(bits);
>          m_analyzeI.addQP(pic->m_avgQpAq);
> -        if (param.bEnablePsnr)
> +        if (param->bEnablePsnr)
>              m_analyzeI.addPsnr(psnrY, psnrU, psnrV);
> -        if (param.bEnableSsim)
> +        if (param->bEnableSsim)
>              m_analyzeI.addSsim(ssim);
>      }
>      else if (slice->isInterP())
>      {
>          m_analyzeP.addBits(bits);
>          m_analyzeP.addQP(pic->m_avgQpAq);
> -        if (param.bEnablePsnr)
> +        if (param->bEnablePsnr)
>              m_analyzeP.addPsnr(psnrY, psnrU, psnrV);
> -        if (param.bEnableSsim)
> +        if (param->bEnableSsim)
>              m_analyzeP.addSsim(ssim);
>      }
>      else if (slice->isInterB())
>      {
>          m_analyzeB.addBits(bits);
>          m_analyzeB.addQP(pic->m_avgQpAq);
> -        if (param.bEnablePsnr)
> +        if (param->bEnablePsnr)
>              m_analyzeB.addPsnr(psnrY, psnrU, psnrV);
> -        if (param.bEnableSsim)
> +        if (param->bEnableSsim)
>              m_analyzeB.addSsim(ssim);
>      }
>
>      // if debug log level is enabled, per frame logging is performed
> -    if (param.logLevel >= X265_LOG_DEBUG)
> +    if (param->logLevel >= X265_LOG_DEBUG)
>      {
>          char c = (slice->isIntra() ? 'I' : slice->isInterP() ? 'P' : 'B');
>          int poc = slice->getPOC();
> @@ -871,9 +871,9 @@
>          char buf[1024];
>          int p;
>          p = sprintf(buf, "POC:%d %c QP %2.2lf(%d) %10d bits", poc, c, pic->m_avgQpAq, slice->getSliceQp(), (int)bits);
> -        if (param.bEnablePsnr)
> +        if (param->bEnablePsnr)
>              p += sprintf(buf + p, " [Y:%6.2lf U:%6.2lf V:%6.2lf]", psnrY, psnrU, psnrV);
> -        if (param.bEnableSsim)
> +        if (param->bEnableSsim)
>              p += sprintf(buf + p, " [SSIM: %.3lfdB]", x265_ssim(ssim));
>
>          if (!slice->isIntra())
> @@ -897,11 +897,11 @@
>          {
>              fprintf(m_csvfpt, "%d, %c-SLICE, %4d, %2.2lf, %10d,", m_outputCount++, c, poc, pic->m_avgQpAq, (int)bits);
>              double psnr = (psnrY * 6 + psnrU + psnrV) / 8;
> -            if (param.bEnablePsnr)
> +            if (param->bEnablePsnr)
>                  fprintf(m_csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,", psnrY, psnrU, psnrV, psnr);
>              else
>                  fprintf(m_csvfpt, " -, -, -, -,");
> -            if (param.bEnableSsim)
> +            if (param->bEnableSsim)
>                  fprintf(m_csvfpt, " %.6f, %6.3f,", ssim, x265_ssim(ssim));
>              else
>                  fprintf(m_csvfpt, " -, -,");
> @@ -927,26 +927,26 @@
>              fprintf(m_csvfpt, "\n");
>          }
>
> -        if (param.decodedPictureHashSEI && param.logLevel >= X265_LOG_FULL)
> +        if (param->decodedPictureHashSEI && param->logLevel >= X265_LOG_FULL)
>          {
>              const char* digestStr = NULL;
> -            if (param.decodedPictureHashSEI == 1)
> +            if (param->decodedPictureHashSEI == 1)
>              {
>                  digestStr = digestToString(curEncoder->m_seiReconPictureDigest.digest, 16);
>                  p += sprintf(buf + p, " [MD5:%s]", digestStr);
>              }
> -            else if (param.decodedPictureHashSEI == 2)
> +            else if (param->decodedPictureHashSEI == 2)
>              {
>                  digestStr = digestToString(curEncoder->m_seiReconPictureDigest.digest, 2);
>                  p += sprintf(buf + p, " [CRC:%s]", digestStr);
>              }
> -            else if (param.decodedPictureHashSEI == 3)
> +            else if (param->decodedPictureHashSEI == 3)
>              {
>                  digestStr = digestToString(curEncoder->m_seiReconPictureDigest.digest, 4);
>                  p += sprintf(buf + p, " [Checksum:%s]", digestStr);
>              }
>          }
> -        x265_log(&param, X265_LOG_DEBUG, "%s\n", buf);
> +        x265_log(param, X265_LOG_DEBUG, "%s\n", buf);
>          fflush(stderr);
>      }
>  }
> @@ -984,10 +984,10 @@
>      /* XXX: may be a good idea to refactor the above into a function
>       * that chooses the actual compatibility based upon options */
>
> -    sps->setPicWidthInLumaSamples(param.sourceWidth);
> -    sps->setPicHeightInLumaSamples(param.sourceHeight);
> +    sps->setPicWidthInLumaSamples(param->sourceWidth);
> +    sps->setPicHeightInLumaSamples(param->sourceHeight);
>      sps->setConformanceWindow(m_conformanceWindow);
> -    sps->setChromaFormatIdc(param.internalCsp);
> +    sps->setChromaFormatIdc(param->internalCsp);
>      sps->setMaxCUWidth(g_maxCUWidth);
>      sps->setMaxCUHeight(g_maxCUHeight);
>      sps->setMaxCUDepth(g_maxCUDepth);
> @@ -1009,8 +1009,8 @@
>
>      sps->setQuadtreeTULog2MaxSize(m_quadtreeTULog2MaxSize);
>      sps->setQuadtreeTULog2MinSize(m_quadtreeTULog2MinSize);
> -    sps->setQuadtreeTUMaxDepthInter(param.tuQTMaxInterDepth);
> -    sps->setQuadtreeTUMaxDepthIntra(param.tuQTMaxIntraDepth);
> +    sps->setQuadtreeTUMaxDepthInter(param->tuQTMaxInterDepth);
> +    sps->setQuadtreeTUMaxDepthIntra(param->tuQTMaxIntraDepth);
>
>      sps->setTMVPFlagsPresent(false);
>      sps->setUseLossless(m_useLossless);
> @@ -1019,10 +1019,10 @@
>
>      for (uint32_t i = 0; i < g_maxCUDepth - g_addCUDepth; i++)
>      {
> -        sps->setAMPAcc(i, param.bEnableAMP);
> +        sps->setAMPAcc(i, param->bEnableAMP);
>      }
>
> -    sps->setUseAMP(param.bEnableAMP);
> +    sps->setUseAMP(param->bEnableAMP);
>
>      for (uint32_t i = g_maxCUDepth - g_addCUDepth; i < g_maxCUDepth; i++)
>      {
> @@ -1035,7 +1035,7 @@
>      sps->setQpBDOffsetY(6 * (X265_DEPTH - 8));
>      sps->setQpBDOffsetC(6 * (X265_DEPTH - 8));
>
> -    sps->setUseSAO(param.bEnableSAO);
> +    sps->setUseSAO(param->bEnableSAO);
>
>      // TODO: hard-code these values in SPS code
>      sps->setMaxTLayers(1);
> @@ -1054,67 +1054,69 @@
>
>      sps->setScalingListFlag((m_useScalingListId == 0) ? 0 : 1);
>
> -    sps->setUseStrongIntraSmoothing(param.bEnableStrongIntraSmoothing);
> +    sps->setUseStrongIntraSmoothing(param->bEnableStrongIntraSmoothing);
>
> -    sps->setVuiParametersPresentFlag(getVuiParametersPresentFlag());
> +    sps->setVuiParametersPresentFlag(param->bEnableVuiParametersPresentFlag);
>      if (sps->getVuiParametersPresentFlag())
>      {
>          TComVUI* vui = sps->getVuiParameters();
> -        vui->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
> -        vui->setAspectRatioIdc(getAspectRatioIdc());
> -        vui->setSarWidth(getSarWidth());
> -        vui->setSarHeight(getSarHeight());
> -        vui->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
> -        vui->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
> -        vui->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
> -        vui->setVideoFormat(getVideoFormat());
> -        vui->setVideoFullRangeFlag(getVideoFullRangeFlag());
> -        vui->setColourDescriptionPresentFlag(getColourDescriptionPresentFlag());
> -        vui->setColourPrimaries(getColourPrimaries());
> -        vui->setTransferCharacteristics(getTransferCharacteristics());
> -        vui->setMatrixCoefficients(getMatrixCoefficients());
> -        vui->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag());
> -        vui->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField());
> -        vui->setChromaSampleLocTypeBottomField(getChromaSampleLocTypeBottomField());
> -        vui->setNeutralChromaIndicationFlag(getNeutralChromaIndicationFlag());
> -        vui->setDefaultDisplayWindow(getDefaultDisplayWindow());
> -        vui->setFrameFieldInfoPresentFlag(getFrameFieldInfoPresentFlag());
> -        vui->setFieldSeqFlag(getFieldSeqFlag());
> -        vui->setHrdParametersPresentFlag(getVuiHrdParametersPresentFlag());
> -        vui->getTimingInfo()->setTimingInfoPresentFlag(getVuiTimingInfoPresentFlag());
> -        vui->getTimingInfo()->setNumUnitsInTick(getVuiNumUnitsInTick());
> -        vui->getTimingInfo()->setTimeScale(getVuiTimeScale());
> -        vui->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());
> -        vui->getTimingInfo()->setNumTicksPocDiffOneMinus1(getNumTicksPocDiffOneMinus1());
> -        vui->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag());
> -        vui->setTilesFixedStructureFlag(getTilesFixedStructureFlag());
> -        vui->setMotionVectorsOverPicBoundariesFlag(getMotionVectorsOverPicBoundariesFlag());
> -        vui->setRestrictedRefPicListsFlag(getRestrictedRefPicListsFlag());
> -        vui->setMinSpatialSegmentationIdc(getMinSpatialSegmentationIdc());
> -        vui->setMaxBytesPerPicDenom(getMaxBytesPerPicDenom());
> -        vui->setMaxBitsPerMinCuDenom(getMaxBitsPerMinCuDenom());
> -        vui->setLog2MaxMvLengthHorizontal(getLog2MaxMvLengthHorizontal());
> -        vui->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical());
> +        vui->setAspectRatioInfoPresentFlag(param->bEnableAspectRatioIdc);
> +        vui->setAspectRatioIdc(param->aspectRatioIdc);
> +        vui->setSarWidth(param->sarWidth);
> +        vui->setSarHeight(param->sarHeight);
> +        vui->setOverscanInfoPresentFlag(param->bEnableOverscanInfoPresentFlag);
> +        vui->setOverscanAppropriateFlag(param->bEnableOverscanAppropriateFlag);
> +        vui->setVideoSignalTypePresentFlag(param->bEnableVideoSignalTypePresentFlag);
> +        vui->setVideoFormat(param->videoFormat);
> +        vui->setVideoFullRangeFlag(param->bEnableVideoFullRangeFlag);
> +        vui->setColourDescriptionPresentFlag(param->bEnableColorDescriptionPresentFlag);
> +        vui->setColourPrimaries(param->colorPrimaries);
> +        vui->setTransferCharacteristics(param->transferCharacteristics);
> +        vui->setMatrixCoefficients(param->matrixCoeffs);
> +        vui->setChromaLocInfoPresentFlag(param->bEnableChromaLocInfoPresentFlag);
> +        vui->setChromaSampleLocTypeTopField(param->chromaSampleLocTypeTopField);
> +        vui->setChromaSampleLocTypeBottomField(param->chromaSampleLocTypeBottomField);
> +        vui->setNeutralChromaIndicationFlag(m_neutralChromaIndicationFlag);
> +        vui->setDefaultDisplayWindow(m_defaultDisplayWindow);
> +        vui->setFrameFieldInfoPresentFlag(param->bEnableFrameFieldInfoPresentFlag);
> +        vui->setFieldSeqFlag(param->bEnableFieldSeqFlag);
> +        vui->setHrdParametersPresentFlag(param->bEnableVuiHrdParametersPresentFlag);
> +        vui->getHrdParameters()->setNalHrdParametersPresentFlag(param->bEnableNalHrdParametersPresentFlag);
> +        vui->getHrdParameters()->setSubPicHrdParamsPresentFlag(param->bEnableSubPicHrdParamsPresentFlag);
> +        vui->getTimingInfo()->setTimingInfoPresentFlag(param->bEnableVuiTimingInfoPresentFlag);
> +        vui->getTimingInfo()->setNumUnitsInTick(param->fpsDenom);
> +        vui->getTimingInfo()->setTimeScale(param->fpsNum);
> +        vui->getTimingInfo()->setPocProportionalToTimingFlag(m_pocProportionalToTimingFlag);
> +        vui->getTimingInfo()->setNumTicksPocDiffOneMinus1(m_numTicksPocDiffOneMinus1);
> +        vui->setBitstreamRestrictionFlag(param->bEnableBitstreamRestrictionFlag);
> +        vui->setTilesFixedStructureFlag(m_tilesFixedStructureFlag);
> +        vui->setMotionVectorsOverPicBoundariesFlag(m_motionVectorsOverPicBoundariesFlag);
> +        vui->setRestrictedRefPicListsFlag(m_restrictedRefPicListsFlag);
> +        vui->setMinSpatialSegmentationIdc(m_minSpatialSegmentationIdc);
> +        vui->setMaxBytesPerPicDenom(m_maxBytesPerPicDenom);
> +        vui->setMaxBitsPerMinCuDenom(m_maxBitsPerMinCuDenom);
> +        vui->setLog2MaxMvLengthHorizontal(m_log2MaxMvLengthHorizontal);
> +        vui->setLog2MaxMvLengthVertical(m_log2MaxMvLengthVertical);

blech, but one thing at a time I suppose

>      }
>
>      /* set the VPS profile information */
> -    *getVPS()->getPTL() = *sps->getPTL();
> -    TimingInfo *t = getVPS()->getTimingInfo();
> +    *m_vps.getPTL() = *sps->getPTL();
> +    TimingInfo *t = m_vps.getTimingInfo();
>      t->setTimingInfoPresentFlag(true);
> -    t->setNumUnitsInTick(param.fpsDenom);
> -    t->setTimeScale(param.fpsNum);
> +    t->setNumUnitsInTick(param->fpsDenom);
> +    t->setTimeScale(param->fpsNum);
>  }
>
>  void Encoder::initPPS(TComPPS *pps)
>  {
> -    pps->setConstrainedIntraPred(param.bEnableConstrainedIntra);
> -    bool bUseDQP = ((getMaxCuDQPDepth() > 0) || param.rc.aqMode) ? true : false;
> +    pps->setConstrainedIntraPred(param->bEnableConstrainedIntra);
> +    bool bUseDQP = (m_maxCuDQPDepth > 0 || param->rc.aqMode) ? true : false;
>
>      int lowestQP = -(6 * (X265_DEPTH - 8)); //m_cSPS.getQpBDOffsetY();
>
> -    if (getUseLossless())
> +    if (m_useLossless)
>      {
> -        if ((getMaxCuDQPDepth() == 0) && (param.rc.qp == lowestQP))
> +        if ((m_maxCuDQPDepth == 0) && (param->rc.qp == lowestQP))
>          {
>              bUseDQP = false;
>          }
> @@ -1137,25 +1139,25 @@
>          pps->setMinCuDQPSize(pps->getSPS()->getMaxCUWidth() >> (pps->getMaxCuDQPDepth()));
>      }
>
> -    pps->setChromaCbQpOffset(param.cbQpOffset);
> -    pps->setChromaCrQpOffset(param.crQpOffset);
> +    pps->setChromaCbQpOffset(param->cbQpOffset);
> +    pps->setChromaCrQpOffset(param->crQpOffset);
>
> -    pps->setEntropyCodingSyncEnabledFlag(param.bEnableWavefront);
> -    pps->setUseWP(param.bEnableWeightedPred);
> -    pps->setWPBiPred(param.bEnableWeightedBiPred);
> +    pps->setEntropyCodingSyncEnabledFlag(param->bEnableWavefront);
> +    pps->setUseWP(param->bEnableWeightedPred);
> +    pps->setWPBiPred(param->bEnableWeightedBiPred);
>      pps->setOutputFlagPresentFlag(false);
> -    pps->setSignHideFlag(param.bEnableSignHiding);
> -    pps->setDeblockingFilterControlPresentFlag(!param.bEnableLoopFilter);
> +    pps->setSignHideFlag(param->bEnableSignHiding);
> +    pps->setDeblockingFilterControlPresentFlag(!param->bEnableLoopFilter);
>      pps->setDeblockingFilterOverrideEnabledFlag(!m_loopFilterOffsetInPPS);
> -    pps->setPicDisableDeblockingFilterFlag(!param.bEnableLoopFilter);
> +    pps->setPicDisableDeblockingFilterFlag(!param->bEnableLoopFilter);
>      pps->setLog2ParallelMergeLevelMinus2(m_log2ParallelMergeLevelMinus2);
> -    pps->setCabacInitPresentFlag(param.frameNumThreads > 1 ? 0 : CABAC_INIT_PRESENT_FLAG);
> +    pps->setCabacInitPresentFlag(param->frameNumThreads > 1 ? 0 : CABAC_INIT_PRESENT_FLAG);
>
>      pps->setNumRefIdxL0DefaultActive(1);
>      pps->setNumRefIdxL1DefaultActive(1);
>
> -    pps->setTransquantBypassEnableFlag(getTransquantBypassEnableFlag());
> -    pps->setUseTransformSkip(param.bEnableTransformSkip);
> +    pps->setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
> +    pps->setUseTransformSkip(param->bEnableTransformSkip);
>      pps->setLoopFilterAcrossTilesEnabledFlag(m_loopFilterAcrossTilesEnabledFlag);
>  }
>
> @@ -1467,21 +1469,19 @@
>      m_loopFilterTcOffsetDiv2 = 0;
>      m_loopFilterAcrossTilesEnabledFlag = 1;
>
> -    TComVPS vps;
> -    vps.setMaxTLayers(1);
> -    vps.setTemporalNestingFlag(true);
> -    vps.setMaxLayers(1);
> +    m_vps.setMaxTLayers(1);
> +    m_vps.setTemporalNestingFlag(true);
> +    m_vps.setMaxLayers(1);
>      for (int i = 0; i < MAX_TLAYER; i++)
>      {
>          /* Increase the DPB size and reorder picture if bpyramid is enabled */
>          m_numReorderPics[i] = (p->bBPyramid && p->bframes > 1) ? 2 : 1;
>          m_maxDecPicBuffering[i] = X265_MIN(MAX_NUM_REF, X265_MAX(m_numReorderPics[i] + 1, p->maxNumReferences) + m_numReorderPics[i]);
>
> -        vps.setNumReorderPics(m_numReorderPics[i], i);
> -        vps.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
> +        m_vps.setNumReorderPics(m_numReorderPics[i], i);
> +        m_vps.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
>      }
>
> -    m_vps = vps;
>      m_maxCuDQPDepth = 0;
>      m_maxNumOffsetsPerPic = 2048;
>      m_log2ParallelMergeLevelMinus2 = 0;
> @@ -1499,29 +1499,10 @@
>      m_decodingUnitInfoSEIEnabled = 0;
>      m_useScalingListId = 0;
>      m_activeParameterSetsSEIEnabled = 0;
> -    m_vuiParametersPresentFlag = p->bEnableVuiParametersPresentFlag;
>      m_minSpatialSegmentationIdc = 0;
> -    m_aspectRatioInfoPresentFlag = p->bEnableAspectRatioIdc;
> -    m_aspectRatioIdc = p->aspectRatioIdc;
> -    m_sarWidth = p->sarWidth;
> -    m_sarHeight = p->sarHeight;
> -    m_overscanInfoPresentFlag = p->bEnableOverscanInfoPresentFlag;
> -    m_overscanAppropriateFlag = p->bEnableOverscanAppropriateFlag;
> -    m_videoSignalTypePresentFlag = p->bEnableVideoSignalTypePresentFlag;
> -    m_videoFormat = p->videoFormat;
> -    m_videoFullRangeFlag = p->bEnableVideoFullRangeFlag;
> -    m_colourDescriptionPresentFlag = p->bEnableColorDescriptionPresentFlag;
> -    m_colourPrimaries = p->colorPrimaries;
> -    m_transferCharacteristics = p->transferCharacteristics;
> -    m_matrixCoefficients = p->matrixCoeffs;
> -    m_chromaLocInfoPresentFlag = p->bEnableChromaLocInfoPresentFlag;
> -    m_chromaSampleLocTypeTopField = p->chromaSampleLocTypeTopField;
> -    m_chromaSampleLocTypeBottomField = p->chromaSampleLocTypeBottomField;
>      m_neutralChromaIndicationFlag = false;
> -    m_frameFieldInfoPresentFlag = p->bEnableFrameFieldInfoPresentFlag;
>      m_pocProportionalToTimingFlag = false;
>      m_numTicksPocDiffOneMinus1 = 0;
> -    m_bitstreamRestrictionFlag = false;
>      m_motionVectorsOverPicBoundariesFlag = false;
>      m_maxBytesPerPicDenom = 2;
>      m_maxBitsPerMinCuDenom = 1;
> @@ -1536,11 +1517,8 @@
>      m_useLossless = false;  // x264 configures this via --qp=0
>      m_TransquantBypassEnableFlag = false;
>      m_CUTransquantBypassFlagValue = false;
> -    m_fieldSeqFlag = p->bEnableFieldSeqFlag;
> -    m_vuiTimingInfoPresentFlag = p->bEnableVuiTimingInfoPresentFlag;
> -    m_vuiHrdParametersPresentFlag = p->bEnableVuiHrdParametersPresentFlag;
> -    m_bitstreamRestrictionFlag = p->bEnableBitstreamRestrictionFlag;
> -    m_subPicHrdParamsPresentFlag = p->bEnableSubPicHrdParamsPresentFlag;
> +
> +    param = p;
>  }
>
>  int Encoder::extractNalData(NALUnitEBSP **nalunits)
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/encoder.h
> --- a/source/encoder/encoder.h  Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/encoder.h  Mon Mar 03 14:24:34 2014 -0800
> @@ -26,7 +26,7 @@
>
>  #include "x265.h"
>
> -#include "TLibEncoder/TEncCfg.h"
> +#include "TLibCommon/TComSlice.h"
>
>  #include "piclist.h"
>
> @@ -69,7 +69,7 @@
>  class ThreadPool;
>  struct NALUnitEBSP;
>
> -class Encoder : public TEncCfg, public x265_encoder
> +class Encoder : public x265_encoder
>  {
>  private:
>
> @@ -107,6 +107,93 @@
>
>  public:
>
> +    int                m_conformanceMode;
> +    TComVPS            m_vps;
> +
> +    /* profile & level */
> +    Profile::Name      m_profile;
> +    Level::Tier        m_levelTier;
> +    Level::Name        m_level;
> +
> +    bool               m_progressiveSourceFlag;
> +    bool               m_interlacedSourceFlag;
> +    bool               m_nonPackedConstraintFlag;
> +    bool               m_frameOnlyConstraintFlag;
> +
> +    //====== Coding Structure ========
> +    int                m_maxDecPicBuffering[MAX_TLAYER];
> +    int                m_numReorderPics[MAX_TLAYER];
> +    int                m_maxRefPicNum;     ///< this is used to mimic the sliding mechanism used by the decoder
> +                                           // TODO: We need to have a common sliding mechanism used by both the encoder and decoder
> +
> +    //======= Transform =============
> +    uint32_t           m_quadtreeTULog2MaxSize;
> +    uint32_t           m_quadtreeTULog2MinSize;
> +
> +    //====== Loop/Deblock Filter ========
> +    bool               m_loopFilterOffsetInPPS;
> +    int                m_loopFilterBetaOffset;
> +    int                m_loopFilterBetaOffsetDiv2;
> +    int                m_loopFilterTcOffset;
> +    int                m_loopFilterTcOffsetDiv2;
> +    int                m_maxNumOffsetsPerPic;
> +
> +    //====== Lossless ========
> +    bool               m_useLossless;
> +
> +    //====== Quality control ========
> +    int                m_maxCuDQPDepth;    //  Max. depth for a minimum CuDQP (0:default)
> +
> +    //====== Tool list ========
> +    bool               m_bUseASR;
> +    bool               m_usePCM;
> +    uint32_t           m_pcmLog2MaxSize;
> +    uint32_t           m_pcmLog2MinSize;
> +
> +    bool               m_bPCMInputBitDepthFlag; //unused field
> +    uint32_t           m_pcmBitDepthLuma;  // unused field, TComSPS has it's own version defaulted to 8
> +    uint32_t           m_pcmBitDepthChroma;// unused field, TComSPS has it's own version defaulted to 8
> +
> +    bool               m_bPCMFilterDisableFlag;
> +    bool               m_loopFilterAcrossTilesEnabledFlag;
> +
> +    int                m_bufferingPeriodSEIEnabled;
> +    int                m_pictureTimingSEIEnabled;
> +    int                m_recoveryPointSEIEnabled;
> +    int                m_displayOrientationSEIAngle;
> +    int                m_gradualDecodingRefreshInfoEnabled;
> +    int                m_decodingUnitInfoSEIEnabled;
> +    int                m_csp;
> +
> +    uint32_t           m_log2ParallelMergeLevelMinus2; ///< Parallel merge estimation region
> +
> +    int                m_useScalingListId; ///< Using quantization matrix i.e. 0=off, 1=default.
> +
> +    bool               m_TransquantBypassEnableFlag;   ///< transquant_bypass_enable_flag setting in PPS.
> +    bool               m_CUTransquantBypassFlagValue;  ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
> +    int                m_activeParameterSetsSEIEnabled;///< enable active parameter set SEI message
> +
> +    bool               m_neutralChromaIndicationFlag;
> +    bool               m_pocProportionalToTimingFlag;
> +    int                m_numTicksPocDiffOneMinus1;
> +    bool               m_tilesFixedStructureFlag;
> +    bool               m_motionVectorsOverPicBoundariesFlag;
> +    bool               m_restrictedRefPicListsFlag;
> +    int                m_minSpatialSegmentationIdc;
> +    int                m_maxBytesPerPicDenom;
> +    int                m_maxBitsPerMinCuDenom;
> +    int                m_log2MaxMvLengthHorizontal;
> +    int                m_log2MaxMvLengthVertical;
> +
> +    x265_param         *param;
> +
> +    int                bEnableRDOQ;
> +    int                bEnableRDOQTS;
> +
> +    int                m_pad[2];
> +    Window             m_conformanceWindow;
> +    Window             m_defaultDisplayWindow;
> +
>      x265_nal* m_nals;
>      char*       m_packetData;
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp   Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/frameencoder.cpp   Mon Mar 03 14:24:34 2014 -0800
> @@ -103,8 +103,8 @@
>      m_top = top;
>      m_cfg = top;
>      m_numRows = numRows;
> -    m_filterRowDelay = (m_cfg->param.saoLcuBasedOptimization && m_cfg->param.saoLcuBoundary) ?
> -        2 : (m_cfg->param.bEnableSAO || m_cfg->param.bEnableLoopFilter ? 1 : 0);
> +    m_filterRowDelay = (m_cfg->param->saoLcuBasedOptimization && m_cfg->param->saoLcuBoundary) ?
> +        2 : (m_cfg->param->bEnableSAO || m_cfg->param->bEnableLoopFilter ? 1 : 0);
>
>      m_rows = new CTURow[m_numRows];
>      for (int i = 0; i < m_numRows; ++i)
> @@ -123,7 +123,7 @@
>      // NOTE: 2 times of numRows because both Encoder and Filter in same queue
>      if (!WaveFront::init(m_numRows * 2))
>      {
> -        x265_log(&m_cfg->param, X265_LOG_ERROR, "unable to initialize wavefront queue\n");
> +        x265_log(m_cfg->param, X265_LOG_ERROR, "unable to initialize wavefront queue\n");
>          m_pool = NULL;
>      }
>
> @@ -138,11 +138,11 @@
>      top->initPPS(&m_pps);
>
>      m_sps.setNumLongTermRefPicSPS(0);
> -    if (m_cfg->getPictureTimingSEIEnabled() || m_cfg->getDecodingUnitInfoSEIEnabled())
> +    if (m_cfg->m_pictureTimingSEIEnabled || m_cfg->m_decodingUnitInfoSEIEnabled)
>      {
> -        m_sps.setHrdParameters(m_cfg->param.fpsNum, m_cfg->param.fpsDenom, 0, m_cfg->param.rc.bitrate, m_cfg->param.bframes > 0);
> +        m_sps.setHrdParameters(m_cfg->param->fpsNum, m_cfg->param->fpsDenom, 0, m_cfg->param->rc.bitrate, m_cfg->param->bframes > 0);
>      }
> -    if (m_cfg->getBufferingPeriodSEIEnabled() || m_cfg->getPictureTimingSEIEnabled() || m_cfg->getDecodingUnitInfoSEIEnabled())
> +    if (m_cfg->m_bufferingPeriodSEIEnabled || m_cfg->m_pictureTimingSEIEnabled || m_cfg->m_decodingUnitInfoSEIEnabled)
>      {
>          m_sps.getVuiParameters()->setHrdParametersPresentFlag(true);
>      }
> @@ -150,7 +150,7 @@
>      m_sps.setTMVPFlagsPresent(true);
>
>      // set default slice level flag to the same as SPS level flag
> -    if (m_cfg->getUseScalingListId() == SCALING_LIST_OFF)
> +    if (m_cfg->m_useScalingListId == SCALING_LIST_OFF)
>      {
>          for (int i = 0; i < m_numRows; i++)
>          {
> @@ -161,7 +161,7 @@
>          m_sps.setScalingListPresentFlag(false);
>          m_pps.setScalingListPresentFlag(false);
>      }
> -    else if (m_cfg->getUseScalingListId() == SCALING_LIST_DEFAULT)
> +    else if (m_cfg->m_useScalingListId == SCALING_LIST_DEFAULT)
>      {
>          for (int i = 0; i < m_numRows; i++)
>          {
> @@ -174,7 +174,7 @@
>      }
>      else
>      {
> -        x265_log(&m_cfg->param, X265_LOG_ERROR, "ScalingList == %d not supported\n", m_top->getUseScalingListId());
> +        x265_log(m_cfg->param, X265_LOG_ERROR, "ScalingList == %d not supported\n", m_top->m_useScalingListId);
>          ok = false;
>      }
>
> @@ -192,7 +192,7 @@
>      /* headers for start of bitstream */
>      OutputNALUnit nalu(NAL_UNIT_VPS);
>      entropyCoder->setBitstream(&nalu.m_bitstream);
> -    entropyCoder->encodeVPS(m_cfg->getVPS());
> +    entropyCoder->encodeVPS(&m_cfg->m_vps);
>      writeRBSPTrailingBits(nalu.m_bitstream);
>      CHECKED_MALLOC(nalunits[count], NALUnitEBSP, 1);
>      nalunits[count]->init(nalu);
> @@ -214,10 +214,10 @@
>      nalunits[count]->init(nalu);
>      count++;
>
> -    if (m_cfg->getActiveParameterSetsSEIEnabled())
> +    if (m_cfg->m_activeParameterSetsSEIEnabled)
>      {
>          SEIActiveParameterSets sei;
> -        sei.activeVPSId = m_cfg->getVPS()->getVPSId();
> +        sei.activeVPSId = m_cfg->m_vps.getVPSId();
>          sei.m_fullRandomAccessFlag = false;
>          sei.m_noParamSetUpdateFlag = false;
>          sei.numSpsIdsMinus1 = 0;
> @@ -231,13 +231,13 @@
>          count++;
>      }
>
> -    if (m_cfg->getDisplayOrientationSEIAngle())
> +    if (m_cfg->m_displayOrientationSEIAngle)
>      {
>          SEIDisplayOrientation sei;
>          sei.cancelFlag = false;
>          sei.horFlip = false;
>          sei.verFlip = false;
> -        sei.anticlockwiseRotation = m_cfg->getDisplayOrientationSEIAngle();
> +        sei.anticlockwiseRotation = m_cfg->m_displayOrientationSEIAngle;
>
>          nalu.resetToType(NAL_UNIT_PREFIX_SEI);
>          entropyCoder->setBitstream(&nalu.m_bitstream);
> @@ -277,16 +277,16 @@
>  #endif
>      if (slice->getPPS()->getDeblockingFilterControlPresentFlag())
>      {
> -        slice->getPPS()->setDeblockingFilterOverrideEnabledFlag(!m_cfg->getLoopFilterOffsetInPPS());
> -        slice->setDeblockingFilterOverrideFlag(!m_cfg->getLoopFilterOffsetInPPS());
> -        slice->getPPS()->setPicDisableDeblockingFilterFlag(!m_cfg->param.bEnableLoopFilter);
> -        slice->setDeblockingFilterDisable(!m_cfg->param.bEnableLoopFilter);
> +        slice->getPPS()->setDeblockingFilterOverrideEnabledFlag(!m_cfg->m_loopFilterOffsetInPPS);
> +        slice->setDeblockingFilterOverrideFlag(!m_cfg->m_loopFilterOffsetInPPS);
> +        slice->getPPS()->setPicDisableDeblockingFilterFlag(!m_cfg->param->bEnableLoopFilter);
> +        slice->setDeblockingFilterDisable(!m_cfg->param->bEnableLoopFilter);
>          if (!slice->getDeblockingFilterDisable())
>          {
> -            slice->getPPS()->setDeblockingFilterBetaOffsetDiv2(m_cfg->getLoopFilterBetaOffset());
> -            slice->getPPS()->setDeblockingFilterTcOffsetDiv2(m_cfg->getLoopFilterTcOffset());
> -            slice->setDeblockingFilterBetaOffsetDiv2(m_cfg->getLoopFilterBetaOffset());
> -            slice->setDeblockingFilterTcOffsetDiv2(m_cfg->getLoopFilterTcOffset());
> +            slice->getPPS()->setDeblockingFilterBetaOffsetDiv2(m_cfg->m_loopFilterBetaOffset);
> +            slice->getPPS()->setDeblockingFilterTcOffsetDiv2(m_cfg->m_loopFilterTcOffset);
> +            slice->setDeblockingFilterBetaOffsetDiv2(m_cfg->m_loopFilterBetaOffset);
> +            slice->setDeblockingFilterTcOffsetDiv2(m_cfg->m_loopFilterTcOffset);
>          }
>      }
>      else
> @@ -297,7 +297,7 @@
>          slice->setDeblockingFilterTcOffsetDiv2(0);
>      }
>
> -    slice->setMaxNumMergeCand(m_cfg->param.maxNumMergeCand);
> +    slice->setMaxNumMergeCand(m_cfg->param->maxNumMergeCand);
>  }
>
>  void FrameEncoder::threadMain()
> @@ -422,15 +422,15 @@
>      slice->setSliceQpDeltaCb(0);
>      slice->setSliceQpDeltaCr(0);
>
> -    int numSubstreams = m_cfg->param.bEnableWavefront ? m_pic->getPicSym()->getFrameHeightInCU() : 1;
> +    int numSubstreams = m_cfg->param->bEnableWavefront ? m_pic->getPicSym()->getFrameHeightInCU() : 1;
>      // TODO: these two items can likely be FrameEncoder member variables to avoid re-allocs
>      TComOutputBitstream*  bitstreamRedirect = new TComOutputBitstream;
>      TComOutputBitstream*  outStreams = new TComOutputBitstream[numSubstreams];
>
> -    if (m_cfg->getUseASR() && !slice->isIntra())
> +    if (m_cfg->m_bUseASR && !slice->isIntra())
>      {
>          int pocCurr = slice->getPOC();
> -        int maxSR = m_cfg->param.searchRange;
> +        int maxSR = m_cfg->param->searchRange;
>          int numPredDir = slice->isInterP() ? 1 : 2;
>
>          for (int dir = 0; dir <= numPredDir; dir++)
> @@ -457,7 +457,7 @@
>      if ((slice->getSliceType() == P_SLICE && slice->getPPS()->getUseWP()) || (slice->getSliceType() == B_SLICE && slice->getPPS()->getWPBiPred()))
>      {
>          assert(slice->getPPS()->getUseWP());
> -        weightAnalyse(*slice, m_cfg->param);
> +        weightAnalyse(*slice, *m_cfg->param);
>      }
>
>      // Generate motion references
> @@ -481,14 +481,14 @@
>      // wave-front behind the CU compression and reconstruction
>      compressCTURows();
>
> -    if (m_cfg->param.bEnableWavefront)
> +    if (m_cfg->param->bEnableWavefront)
>      {
>          slice->setNextSlice(true);
>      }
>
> -    if ((m_cfg->getRecoveryPointSEIEnabled()) && (slice->getSliceType() == I_SLICE))
> +    if ((m_cfg->m_recoveryPointSEIEnabled) && (slice->getSliceType() == I_SLICE))
>      {
> -        if (m_cfg->getGradualDecodingRefreshInfoEnabled() && !slice->getRapPicFlag())
> +        if (m_cfg->m_gradualDecodingRefreshInfoEnabled && !slice->getRapPicFlag())
>          {
>              // Gradual decoding refresh SEI
>              OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
> @@ -668,9 +668,9 @@
>      }
>
>      /* write decoded picture hash SEI messages */
> -    if (m_cfg->param.decodedPictureHashSEI)
> +    if (m_cfg->param->decodedPictureHashSEI)
>      {
> -        if (m_cfg->param.decodedPictureHashSEI == 1)
> +        if (m_cfg->param->decodedPictureHashSEI == 1)
>          {
>              m_seiReconPictureDigest.method = SEIDecodedPictureHash::MD5;
>              for (int i = 0; i < 3; i++)
> @@ -678,7 +678,7 @@
>                  MD5Final(&(m_pic->m_state[i]), m_seiReconPictureDigest.digest[i]);
>              }
>          }
> -        else if (m_cfg->param.decodedPictureHashSEI == 2)
> +        else if (m_cfg->param->decodedPictureHashSEI == 2)
>          {
>              m_seiReconPictureDigest.method = SEIDecodedPictureHash::CRC;
>              for (int i = 0; i < 3; i++)
> @@ -686,7 +686,7 @@
>                  crcFinish((m_pic->m_crc[i]), m_seiReconPictureDigest.digest[i]);
>              }
>          }
> -        else if (m_cfg->param.decodedPictureHashSEI == 3)
> +        else if (m_cfg->param->decodedPictureHashSEI == 3)
>          {
>              m_seiReconPictureDigest.method = SEIDecodedPictureHash::CHECKSUM;
>              for (int i = 0; i < 3; i++)
> @@ -754,7 +754,7 @@
>      g_bJustDoIt = g_bEncDecTraceDisable;
>  #endif
>
> -    const int  bWaveFrontsynchro = m_cfg->param.bEnableWavefront;
> +    const int  bWaveFrontsynchro = m_cfg->param->bEnableWavefront;
>      const uint32_t heightInLCUs = m_pic->getPicSym()->getFrameHeightInCU();
>      const int  numSubstreams = (bWaveFrontsynchro ? heightInLCUs : 1);
>      uint32_t bitsOriginallyInSubstreams = 0;
> @@ -932,7 +932,7 @@
>          m_rows[i].m_busy = false;
>      }
>
> -    int range = m_cfg->param.searchRange; /* fpel search */
> +    int range = m_cfg->param->searchRange; /* fpel search */
>      range    += 1;                        /* diamond search range check lag */
>      range    += 2;                        /* subpel refine */
>      range    += NTAPS_LUMA / 2;           /* subpel filter half-length */
> @@ -945,7 +945,7 @@
>
>      m_frameFilter.start(m_pic);
>
> -    if (m_pool && m_cfg->param.bEnableWavefront)
> +    if (m_pool && m_cfg->param->bEnableWavefront)
>      {
>          WaveFront::clearEnabledRowMask();
>          WaveFront::enqueue();
> @@ -1048,18 +1048,18 @@
>           * the same CU row, which often resulted in bad pointer accesses. We
>           * believe the problem is fixed, but are leaving this check in place
>           * to prevent crashes in case it is not. */
> -        x265_log(&m_cfg->param, X265_LOG_WARNING,
> +        x265_log(m_cfg->param, X265_LOG_WARNING,
>                   "internal error - simulaneous row access detected. Please report HW to x265-devel at videolan.org");
>          return;
>      }
>      curRow.m_busy = true;
>
>      int64_t startTime = x265_mdate();
> -    CTURow& codeRow = m_rows[m_cfg->param.bEnableWavefront ? row : 0];
> +    CTURow& codeRow = m_rows[m_cfg->param->bEnableWavefront ? row : 0];
>      const uint32_t numCols = m_pic->getPicSym()->getFrameWidthInCU();
>      const uint32_t lineStartCUAddr = row * numCols;
>      double qpBase = m_pic->m_avgQpRc;
> -    bool isVbv = m_cfg->param.rc.vbvBufferSize > 0 && m_cfg->param.rc.vbvMaxBitrate > 0;
> +    bool isVbv = m_cfg->param->rc.vbvBufferSize > 0 && m_cfg->param->rc.vbvMaxBitrate > 0;
>      for (uint32_t col = curRow.m_completed; col < numCols; col++)
>      {
>          const uint32_t cuAddr = lineStartCUAddr + col;
> @@ -1068,22 +1068,22 @@
>
>          codeRow.m_entropyCoder.setEntropyCoder(&m_sbacCoder, m_pic->getSlice());
>          codeRow.m_entropyCoder.resetEntropy();
> -        TEncSbac *bufSbac = (m_cfg->param.bEnableWavefront && col == 0 && row > 0) ? &m_rows[row - 1].m_bufferSbacCoder : NULL;
> +        TEncSbac *bufSbac = (m_cfg->param->bEnableWavefront && col == 0 && row > 0) ? &m_rows[row - 1].m_bufferSbacCoder : NULL;
>
>          if ((uint32_t)row >= col && (row != 0) && isVbv)
>              qpBase = m_pic->getCU(cuAddr - numCols + 1)->m_baseQp;
>
> -        if (m_cfg->param.rc.aqMode || isVbv)
> +        if (m_cfg->param->rc.aqMode || isVbv)
>          {
>              int qp = calcQpForCu(m_pic, cuAddr, qpBase);
>              setLambda(qp, row);
>              qp = X265_MIN(qp, MAX_QP);
>              cu->setQP(0, char(qp));
>              cu->m_baseQp = qpBase;
> -            if (m_cfg->param.rc.aqMode)
> +            if (m_cfg->param->rc.aqMode)
>                  m_pic->m_qpaAq[row] += qp;
>          }
> -        codeRow.processCU(cu, m_pic->getSlice(), bufSbac, m_cfg->param.bEnableWavefront && col == 1);
> +        codeRow.processCU(cu, m_pic->getSlice(), bufSbac, m_cfg->param->bEnableWavefront && col == 1);
>          if (isVbv)
>          {
>              // Update encoded bits, satdCost, baseQP for each CU
> @@ -1160,19 +1160,19 @@
>      int block_y = (cuAddr / pic->getPicSym()->getFrameWidthInCU()) * noOfBlocks;
>      int block_x = (cuAddr * noOfBlocks) - block_y * pic->getPicSym()->getFrameWidthInCU();
>
> -    double *qpoffs = (pic->getSlice()->isReferenced() && m_cfg->param.rc.cuTree) ? pic->m_lowres.qpOffset : pic->m_lowres.qpAqOffset;
> +    double *qpoffs = (pic->getSlice()->isReferenced() && m_cfg->param->rc.cuTree) ? pic->m_lowres.qpOffset : pic->m_lowres.qpAqOffset;
>      int cnt = 0, idx = 0;
>      for (int h = 0; h < noOfBlocks && block_y < maxBlockRows; h++, block_y++)
>      {
>          for (int w = 0; w < noOfBlocks && (block_x + w) < maxBlockCols; w++)
>          {
>              idx = block_x + w + (block_y * maxBlockCols);
> -            if (m_cfg->param.rc.aqMode)
> +            if (m_cfg->param->rc.aqMode)
>                  qp_offset += qpoffs[idx];
> -            if (m_cfg->param.rc.vbvBufferSize > 0 && m_cfg->param.rc.vbvMaxBitrate > 0)
> +            if (m_cfg->param->rc.vbvBufferSize > 0 && m_cfg->param->rc.vbvMaxBitrate > 0)
>              {
>                  m_pic->m_cuCostsForVbv[cuAddr] += m_pic->m_lowres.lowresCostForRc[idx];
> -                if (!m_cfg->param.rc.cuTree)
> +                if (!m_cfg->param->rc.cuTree)
>                      m_pic->m_cuCostsForVbv[cuAddr] += m_pic->m_lowres.intraCost[idx];
>              }
>              cnt++;
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/frameencoder.h
> --- a/source/encoder/frameencoder.h     Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/frameencoder.h     Mon Mar 03 14:24:34 2014 -0800
> @@ -175,7 +175,7 @@
>      void determineSliceBounds();
>      int calcQpForCu(TComPic *pic, uint32_t cuAddr, double baseQp);
>      Encoder*                 m_top;
> -    TEncCfg*                 m_cfg;
> +    Encoder*                 m_cfg;
>
>      MotionReference          m_mref[2][MAX_NUM_REF + 1];
>      TEncSbac                 m_sbacCoder;
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/framefilter.cpp
> --- a/source/encoder/framefilter.cpp    Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/framefilter.cpp    Mon Mar 03 14:24:34 2014 -0800
> @@ -45,12 +45,12 @@
>
>  void FrameFilter::destroy()
>  {
> -    if (m_cfg->param.bEnableLoopFilter)
> +    if (m_cfg->param->bEnableLoopFilter)
>      {
>          m_loopFilter.destroy();
>      }
>
> -    if (m_cfg->param.bEnableSAO)
> +    if (m_cfg->param->bEnableSAO)
>      {
>          // NOTE: I don't check sao flag since loopfilter and sao have same control status
>          m_sao.destroy();
> @@ -64,42 +64,42 @@
>      m_top = top;
>      m_cfg = top;
>      m_numRows = numRows;
> -    m_hChromaShift = CHROMA_H_SHIFT(m_cfg->getColorFormat());
> -    m_vChromaShift = CHROMA_V_SHIFT(m_cfg->getColorFormat());
> +    m_hChromaShift = CHROMA_H_SHIFT(m_cfg->m_csp);
> +    m_vChromaShift = CHROMA_V_SHIFT(m_cfg->m_csp);
>
>      // NOTE: for sao only, I write this code because I want to exact match with HM's bug bitstream
>      m_rdGoOnSbacCoderRow0 = rdGoOnSbacCoder;
>
> -    if (top->param.bEnableLoopFilter)
> +    if (top->param->bEnableLoopFilter)
>      {
>          m_loopFilter.create(g_maxCUDepth);
>      }
>
> -    if (top->param.bEnableSAO)
> +    if (top->param->bEnableSAO)
>      {
> -        m_sao.setSaoLcuBoundary(top->param.saoLcuBoundary);
> -        m_sao.setSaoLcuBasedOptimization(top->param.saoLcuBasedOptimization);
> -        m_sao.setMaxNumOffsetsPerPic(top->getMaxNumOffsetsPerPic());
> -        m_sao.create(top->param.sourceWidth, top->param.sourceHeight, g_maxCUWidth, g_maxCUHeight, m_cfg->getColorFormat());
> +        m_sao.setSaoLcuBoundary(top->param->saoLcuBoundary);
> +        m_sao.setSaoLcuBasedOptimization(top->param->saoLcuBasedOptimization);
> +        m_sao.setMaxNumOffsetsPerPic(top->m_maxNumOffsetsPerPic);
> +        m_sao.create(top->param->sourceWidth, top->param->sourceHeight, g_maxCUWidth, g_maxCUHeight, m_cfg->m_csp);
>          m_sao.createEncBuffer();
>      }
>
> -    if (m_cfg->param.bEnableSsim)
> -        m_ssimBuf = (int*)x265_malloc(sizeof(int) * 8 * (m_cfg->param.sourceWidth / 4 + 3));
> +    if (m_cfg->param->bEnableSsim)
> +        m_ssimBuf = (int*)x265_malloc(sizeof(int) * 8 * (m_cfg->param->sourceWidth / 4 + 3));
>  }
>
>  void FrameFilter::start(TComPic *pic)
>  {
>      m_pic = pic;
>
> -    m_saoRowDelay = m_cfg->param.bEnableLoopFilter ? 1 : 0;
> +    m_saoRowDelay = m_cfg->param->bEnableLoopFilter ? 1 : 0;
>      m_loopFilter.setCfg(pic->getSlice()->getPPS()->getLoopFilterAcrossTilesEnabledFlag());
>      m_rdGoOnSbacCoder.init(&m_rdGoOnBinCodersCABAC);
>      m_entropyCoder.setEntropyCoder(&m_rdGoOnSbacCoder, pic->getSlice());
>      m_entropyCoder.setBitstream(&m_bitCounter);
>      m_rdGoOnBinCodersCABAC.m_fracBits = 0;
>
> -    if (m_cfg->param.bEnableSAO)
> +    if (m_cfg->param->bEnableSAO)
>      {
>          m_sao.resetStats();
>          m_sao.createPicSaoInfo(pic);
> @@ -110,7 +110,7 @@
>
>          // NOTE: Disable SAO automatic turn-off when frame parallelism is
>          // enabled for output exact independent of frame thread count
> -        if (m_cfg->param.frameNumThreads > 1)
> +        if (m_cfg->param->frameNumThreads > 1)
>          {
>              saoParam->bSaoFlag[0] = true;
>              saoParam->bSaoFlag[1] = true;
> @@ -120,7 +120,7 @@
>
>  void FrameFilter::end()
>  {
> -    if (m_cfg->param.bEnableSAO)
> +    if (m_cfg->param->bEnableSAO)
>      {
>          m_sao.destroyPicSaoInfo();
>      }
> @@ -130,14 +130,14 @@
>  {
>      PPAScopeEvent(Thread_filterCU);
>
> -    if (!m_cfg->param.bEnableLoopFilter && !m_cfg->param.bEnableSAO)
> +    if (!m_cfg->param->bEnableLoopFilter && !m_cfg->param->bEnableSAO)
>      {
>          processRowPost(row);
>          return;
>      }
>
>      // NOTE: We are here only active both of loopfilter and sao, the row 0 always finished, so we can safe to copy row[0]'s data
> -    if (row == 0 && m_cfg->param.bEnableSAO)
> +    if (row == 0 && m_cfg->param->bEnableSAO)
>      {
>          // NOTE: not need, seems HM's bug, I want to keep output exact matched.
>          m_rdGoOnBinCodersCABAC.m_fracBits = ((TEncBinCABAC*)((TEncSbac*)m_rdGoOnSbacCoderRow0->m_binIf))->m_fracBits;
> @@ -148,12 +148,12 @@
>      const uint32_t lineStartCUAddr = row * numCols;
>
>      // SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
> -    if (m_cfg->param.bEnableSAO && m_cfg->param.saoLcuBasedOptimization && m_cfg->param.saoLcuBoundary)
> +    if (m_cfg->param->bEnableSAO && m_cfg->param->saoLcuBasedOptimization && m_cfg->param->saoLcuBoundary)
>      {
>          m_sao.calcSaoStatsRowCus_BeforeDblk(m_pic, row);
>      }
>
> -    if (m_cfg->param.bEnableLoopFilter)
> +    if (m_cfg->param->bEnableLoopFilter)
>      {
>          for (uint32_t col = 0; col < numCols; col++)
>          {
> @@ -177,7 +177,7 @@
>
>      // SAO
>      SAOParam* saoParam = m_pic->getPicSym()->getSaoParam();
> -    if (m_cfg->param.bEnableSAO && m_sao.getSaoLcuBasedOptimization())
> +    if (m_cfg->param->bEnableSAO && m_sao.getSaoLcuBasedOptimization())
>      {
>          m_sao.rdoSaoUnitRow(saoParam, row);
>
> @@ -191,7 +191,7 @@
>      // this row of CTUs has been encoded
>
>      // NOTE: in --sao-lcu-opt=0 mode, we do it later
> -    if (m_cfg->param.bEnableSAO && !m_sao.getSaoLcuBasedOptimization())
> +    if (m_cfg->param->bEnableSAO && !m_sao.getSaoLcuBasedOptimization())
>          return;
>
>      if (row > 0)
> @@ -201,7 +201,7 @@
>
>      if (row == m_numRows - 1)
>      {
> -        if (m_cfg->param.bEnableSAO && m_sao.getSaoLcuBasedOptimization())
> +        if (m_cfg->param->bEnableSAO && m_sao.getSaoLcuBasedOptimization())
>          {
>              m_sao.rdoSaoUnitRowEnd(saoParam, m_pic->getNumCUsInFrame());
>
> @@ -274,7 +274,7 @@
>          m_top->signalReconRowCompleted(m_pic->getPOC());
>
>      int cuAddr = lineStartCUAddr;
> -    if (m_cfg->param.bEnablePsnr)
> +    if (m_cfg->param->bEnablePsnr)
>      {
>          TComPicYuv* orig  = m_pic->getPicYuvOrg();
>
> @@ -299,7 +299,7 @@
>          m_pic->m_SSDU += ssdU;
>          m_pic->m_SSDV += ssdV;
>      }
> -    if (m_cfg->param.bEnableSsim && m_ssimBuf)
> +    if (m_cfg->param->bEnableSsim && m_ssimBuf)
>      {
>          pixel *rec = (pixel*)m_pic->getPicYuvRec()->getLumaAddr();
>          pixel *org = (pixel*)m_pic->getPicYuvOrg()->getLumaAddr();
> @@ -316,10 +316,10 @@
>          * to avoid alignment of ssim blocks with DCT blocks. */
>          minPixY += bStart ? 2 : -6;
>          m_pic->m_ssim += calculateSSIM(rec + 2 + minPixY * stride1, stride1, org + 2 + minPixY * stride2, stride2,
> -                                       m_cfg->param.sourceWidth - 2, maxPixY - minPixY, m_ssimBuf, &ssim_cnt);
> +                                       m_cfg->param->sourceWidth - 2, maxPixY - minPixY, m_ssimBuf, &ssim_cnt);
>          m_pic->m_ssimCnt += ssim_cnt;
>      }
> -    if (m_cfg->param.decodedPictureHashSEI == 1)
> +    if (m_cfg->param->decodedPictureHashSEI == 1)
>      {
>          uint32_t width = recon->getWidth();
>          uint32_t height = recon->getCUHeight(row);
> @@ -342,7 +342,7 @@
>
>          updateMD5Plane(m_pic->m_state[2], recon->getCrAddr(cuAddr), width, height, stride);
>      }
> -    else if (m_cfg->param.decodedPictureHashSEI == 2)
> +    else if (m_cfg->param->decodedPictureHashSEI == 2)
>      {
>          uint32_t width = recon->getWidth();
>          uint32_t height = recon->getCUHeight(row);
> @@ -359,7 +359,7 @@
>          updateCRC(recon->getCbAddr(cuAddr), m_pic->m_crc[1], height, width, stride);
>          updateCRC(recon->getCrAddr(cuAddr), m_pic->m_crc[2], height, width, stride);
>      }
> -    else if (m_cfg->param.decodedPictureHashSEI == 3)
> +    else if (m_cfg->param->decodedPictureHashSEI == 3)
>      {
>          uint32_t width = recon->getWidth();
>          uint32_t height = recon->getCUHeight(row);
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/framefilter.h
> --- a/source/encoder/framefilter.h      Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/framefilter.h      Mon Mar 03 14:24:34 2014 -0800
> @@ -57,7 +57,7 @@
>  protected:
>
>      Encoder*                    m_top;
> -    TEncCfg*                    m_cfg;
> +    Encoder*                    m_cfg;

ditto here and in ratecontrol.cpp and slicetype.cpp.  it would be
greatly preferred to just pass param to these files instead of Encoder

>      TComPic*                    m_pic;
>      int                         m_hChromaShift;
>      int                         m_vChromaShift;
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/ratecontrol.cpp
> --- a/source/encoder/ratecontrol.cpp    Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/ratecontrol.cpp    Mon Mar 03 14:24:34 2014 -0800
> @@ -24,7 +24,7 @@
>   *****************************************************************************/
>
>  #include "TLibCommon/TComPic.h"
> -#include "TLibEncoder/TEncCfg.h"
> +#include "encoder.h"
>  #include "encoder.h"
>  #include "slicetype.h"
>  #include "ratecontrol.h"
> @@ -75,7 +75,7 @@
>      int stride = pic->getPicYuvOrg()->getStride();
>      int cStride = pic->getPicYuvOrg()->getCStride();
>      uint32_t blockOffsetLuma = block_x + (block_y * stride);
> -    int colorFormat = cfg->param.internalCsp;
> +    int colorFormat = cfg->param->internalCsp;
>      int hShift = CHROMA_H_SHIFT(colorFormat);
>      int vShift = CHROMA_V_SHIFT(colorFormat);
>      uint32_t blockOffsetChroma = (block_x >> hShift) + ((block_y >> vShift) * cStride);
> @@ -105,14 +105,14 @@
>      int block_xy = 0;
>      int block_x = 0, block_y = 0;
>      double strength = 0.f;
> -    if (cfg->param.rc.aqMode == X265_AQ_NONE || cfg->param.rc.aqStrength == 0)
> +    if (cfg->param->rc.aqMode == X265_AQ_NONE || cfg->param->rc.aqStrength == 0)
>      {
>          /* Need to init it anyways for CU tree */
>          int cuWidth = ((maxCol / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
>          int cuHeight = ((maxRow / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
>          int cuCount = cuWidth * cuHeight;
>
> -        if (cfg->param.rc.aqMode && cfg->param.rc.aqStrength == 0)
> +        if (cfg->param->rc.aqMode && cfg->param->rc.aqStrength == 0)
>          {
>              memset(pic->m_lowres.qpOffset, 0, cuCount * sizeof(double));
>              memset(pic->m_lowres.qpAqOffset, 0, cuCount * sizeof(double));
> @@ -123,7 +123,7 @@
>          }
>
>          /* Need variance data for weighted prediction */
> -        if (cfg->param.bEnableWeightedPred)
> +        if (cfg->param->bEnableWeightedPred)
>          {
>              for (block_y = 0; block_y < maxRow; block_y += 16)
>              {
> @@ -138,7 +138,7 @@
>      {
>          block_xy = 0;
>          double avg_adj_pow2 = 0, avg_adj = 0, qp_adj = 0;
> -        if (cfg->param.rc.aqMode == X265_AQ_AUTO_VARIANCE)
> +        if (cfg->param->rc.aqMode == X265_AQ_AUTO_VARIANCE)
>          {
>              double bit_depth_correction = pow(1 << (X265_DEPTH - 8), 0.5);
>              for (block_y = 0; block_y < maxRow; block_y += 16)
> @@ -156,18 +156,18 @@
>
>              avg_adj /= ncu;
>              avg_adj_pow2 /= ncu;
> -            strength = cfg->param.rc.aqStrength * avg_adj / bit_depth_correction;
> +            strength = cfg->param->rc.aqStrength * avg_adj / bit_depth_correction;
>              avg_adj = avg_adj - 0.5f * (avg_adj_pow2 - (14.f * bit_depth_correction)) / avg_adj;
>          }
>          else
> -            strength = cfg->param.rc.aqStrength * 1.0397f;
> +            strength = cfg->param->rc.aqStrength * 1.0397f;
>
>          block_xy = 0;
>          for (block_y = 0; block_y < maxRow; block_y += 16)
>          {
>              for (block_x = 0; block_x < maxCol; block_x += 16)
>              {
> -                if (cfg->param.rc.aqMode == X265_AQ_AUTO_VARIANCE)
> +                if (cfg->param->rc.aqMode == X265_AQ_AUTO_VARIANCE)
>                  {
>                      qp_adj = pic->m_lowres.qpOffset[block_xy];
>                      qp_adj = strength * (qp_adj - avg_adj);
> @@ -185,10 +185,10 @@
>          }
>      }
>
> -    if (cfg->param.bEnableWeightedPred)
> +    if (cfg->param->bEnableWeightedPred)
>      {
> -        int hShift = CHROMA_H_SHIFT(cfg->param.internalCsp);
> -        int vShift = CHROMA_V_SHIFT(cfg->param.internalCsp);
> +        int hShift = CHROMA_H_SHIFT(cfg->param->internalCsp);
> +        int vShift = CHROMA_V_SHIFT(cfg->param->internalCsp);
>          maxCol = ((maxCol + 8) >> 4) << 4;
>          maxRow = ((maxRow + 8) >> 4) << 4;
>          int width[3]  = { maxCol, maxCol >> hShift, maxCol >> hShift };
> @@ -204,50 +204,50 @@
>      }
>  }
>
> -RateControl::RateControl(TEncCfg * _cfg)
> +RateControl::RateControl(Encoder * _cfg)
>  {
>      this->cfg = _cfg;
> -    int lowresCuWidth = ((cfg->param.sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> -    int lowresCuHeight = ((cfg->param.sourceHeight / 2)  + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> +    int lowresCuWidth = ((cfg->param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> +    int lowresCuHeight = ((cfg->param->sourceHeight / 2)  + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
>      ncu = lowresCuWidth * lowresCuHeight;
> -    if (cfg->param.rc.cuTree)
> +    if (cfg->param->rc.cuTree)
>      {
>          qCompress = 1;
> -        cfg->param.rc.pbFactor = 1;
> +        cfg->param->rc.pbFactor = 1;
>      }
>      else
> -        qCompress = cfg->param.rc.qCompress;
> +        qCompress = cfg->param->rc.qCompress;
>
> -    // validate for cfg->param.rc, maybe it is need to add a function like x265_parameters_valiate()
> -    cfg->param.rc.rfConstant = Clip3((double)-QP_BD_OFFSET, (double)51, cfg->param.rc.rfConstant);
> -    cfg->param.rc.rfConstantMax = Clip3((double)-QP_BD_OFFSET, (double)51, cfg->param.rc.rfConstantMax);
> +    // validate for cfg->param->rc, maybe it is need to add a function like x265_parameters_valiate()
> +    cfg->param->rc.rfConstant = Clip3((double)-QP_BD_OFFSET, (double)51, cfg->param->rc.rfConstant);
> +    cfg->param->rc.rfConstantMax = Clip3((double)-QP_BD_OFFSET, (double)51, cfg->param->rc.rfConstantMax);
>      rateFactorMaxIncrement = 0;
>      vbvMinRate = 0;
>
> -    if (cfg->param.rc.rateControlMode == X265_RC_CRF)
> +    if (cfg->param->rc.rateControlMode == X265_RC_CRF)
>      {
> -        cfg->param.rc.qp = (int)cfg->param.rc.rfConstant + QP_BD_OFFSET;
> -        cfg->param.rc.bitrate = 0;
> +        cfg->param->rc.qp = (int)cfg->param->rc.rfConstant + QP_BD_OFFSET;
> +        cfg->param->rc.bitrate = 0;
>
> -        double baseCplx = ncu * (cfg->param.bframes ? 120 : 80);
> -        double mbtree_offset = cfg->param.rc.cuTree ? (1.0 - cfg->param.rc.qCompress) * 13.5 : 0;
> +        double baseCplx = ncu * (cfg->param->bframes ? 120 : 80);
> +        double mbtree_offset = cfg->param->rc.cuTree ? (1.0 - cfg->param->rc.qCompress) * 13.5 : 0;
>          rateFactorConstant = pow(baseCplx, 1 - qCompress) /
> -            qp2qScale(cfg->param.rc.rfConstant + mbtree_offset);
> -        if (cfg->param.rc.rfConstantMax)
> +            qp2qScale(cfg->param->rc.rfConstant + mbtree_offset);
> +        if (cfg->param->rc.rfConstantMax)
>          {
> -            rateFactorMaxIncrement = cfg->param.rc.rfConstantMax - cfg->param.rc.rfConstant;
> +            rateFactorMaxIncrement = cfg->param->rc.rfConstantMax - cfg->param->rc.rfConstant;
>              if (rateFactorMaxIncrement <= 0)
>              {
> -                x265_log(&cfg->param, X265_LOG_WARNING, "CRF max must be greater than CRF\n");
> +                x265_log(cfg->param, X265_LOG_WARNING, "CRF max must be greater than CRF\n");
>                  rateFactorMaxIncrement = 0;
>              }
>          }
>      }
>
> -    isAbr = cfg->param.rc.rateControlMode != X265_RC_CQP; // later add 2pass option
> -    bitrate = cfg->param.rc.bitrate * 1000;
> -    frameDuration = (double)cfg->param.fpsDenom / cfg->param.fpsNum;
> -    qp = cfg->param.rc.qp;
> +    isAbr = cfg->param->rc.rateControlMode != X265_RC_CQP; // later add 2pass option
> +    bitrate = cfg->param->rc.bitrate * 1000;
> +    frameDuration = (double)cfg->param->fpsDenom / cfg->param->fpsNum;
> +    qp = cfg->param->rc.qp;
>      lastRceq = 1; /* handles the cmplxrsum when the previous frame cost is zero */
>      shortTermCplxSum = 0;
>      shortTermCplxCount = 0;
> @@ -256,97 +256,97 @@
>      lastAbrResetPoc = -1;
>      frameSizeEstimated = 0;
>      // vbv initialization
> -    cfg->param.rc.vbvBufferSize = Clip3(0, 2000000, cfg->param.rc.vbvBufferSize);
> -    cfg->param.rc.vbvMaxBitrate = Clip3(0, 2000000, cfg->param.rc.vbvMaxBitrate);
> -    cfg->param.rc.vbvBufferInit = Clip3(0.0, 2000000.0, cfg->param.rc.vbvBufferInit);
> +    cfg->param->rc.vbvBufferSize = Clip3(0, 2000000, cfg->param->rc.vbvBufferSize);
> +    cfg->param->rc.vbvMaxBitrate = Clip3(0, 2000000, cfg->param->rc.vbvMaxBitrate);
> +    cfg->param->rc.vbvBufferInit = Clip3(0.0, 2000000.0, cfg->param->rc.vbvBufferInit);
>      vbvMinRate = 0;
> -    if (cfg->param.rc.vbvBufferSize)
> +    if (cfg->param->rc.vbvBufferSize)
>      {
> -        if (cfg->param.rc.rateControlMode == X265_RC_CQP)
> +        if (cfg->param->rc.rateControlMode == X265_RC_CQP)
>          {
> -            x265_log(&cfg->param, X265_LOG_WARNING, "VBV is incompatible with constant QP, ignored.\n");
> -            cfg->param.rc.vbvBufferSize = 0;
> -            cfg->param.rc.vbvMaxBitrate = 0;
> +            x265_log(cfg->param, X265_LOG_WARNING, "VBV is incompatible with constant QP, ignored.\n");
> +            cfg->param->rc.vbvBufferSize = 0;
> +            cfg->param->rc.vbvMaxBitrate = 0;
>          }
> -        else if (cfg->param.rc.vbvMaxBitrate == 0)
> +        else if (cfg->param->rc.vbvMaxBitrate == 0)
>          {
> -            if (cfg->param.rc.rateControlMode == X265_RC_ABR)
> +            if (cfg->param->rc.rateControlMode == X265_RC_ABR)
>              {
> -                x265_log(&cfg->param, X265_LOG_WARNING, "VBV maxrate unspecified, assuming CBR\n");
> -                cfg->param.rc.vbvMaxBitrate = cfg->param.rc.bitrate;
> +                x265_log(cfg->param, X265_LOG_WARNING, "VBV maxrate unspecified, assuming CBR\n");
> +                cfg->param->rc.vbvMaxBitrate = cfg->param->rc.bitrate;
>              }
>              else
>              {
> -                x265_log(&cfg->param, X265_LOG_WARNING, "VBV bufsize set but maxrate unspecified, ignored\n");
> -                cfg->param.rc.vbvBufferSize = 0;
> +                x265_log(cfg->param, X265_LOG_WARNING, "VBV bufsize set but maxrate unspecified, ignored\n");
> +                cfg->param->rc.vbvBufferSize = 0;
>              }
>          }
> -        else if (cfg->param.rc.vbvMaxBitrate < cfg->param.rc.bitrate &&
> -                 cfg->param.rc.rateControlMode == X265_RC_ABR)
> +        else if (cfg->param->rc.vbvMaxBitrate < cfg->param->rc.bitrate &&
> +                 cfg->param->rc.rateControlMode == X265_RC_ABR)
>          {
> -            x265_log(&cfg->param, X265_LOG_WARNING, "max bitrate less than average bitrate, assuming CBR\n");
> -            cfg->param.rc.bitrate = cfg->param.rc.vbvMaxBitrate;
> +            x265_log(cfg->param, X265_LOG_WARNING, "max bitrate less than average bitrate, assuming CBR\n");
> +            cfg->param->rc.bitrate = cfg->param->rc.vbvMaxBitrate;
>          }
>      }
> -    else if (cfg->param.rc.vbvMaxBitrate)
> +    else if (cfg->param->rc.vbvMaxBitrate)
>      {
> -        x265_log(&cfg->param, X265_LOG_WARNING, "VBV maxrate specified, but no bufsize, ignored\n");
> -        cfg->param.rc.vbvMaxBitrate = 0;
> +        x265_log(cfg->param, X265_LOG_WARNING, "VBV maxrate specified, but no bufsize, ignored\n");
> +        cfg->param->rc.vbvMaxBitrate = 0;
>      }
>
> -    isVbv = cfg->param.rc.vbvMaxBitrate > 0 && cfg->param.rc.vbvBufferSize > 0;
> -    double fps = (double)cfg->param.fpsNum / cfg->param.fpsDenom;
> +    isVbv = cfg->param->rc.vbvMaxBitrate > 0 && cfg->param->rc.vbvBufferSize > 0;
> +    double fps = (double)cfg->param->fpsNum / cfg->param->fpsDenom;
>      if (isVbv)
>      {
>          /* We don't support changing the ABR bitrate right now,
>             so if the stream starts as CBR, keep it CBR. */
> -        if (cfg->param.rc.vbvBufferSize < (int)(cfg->param.rc.vbvMaxBitrate / fps))
> +        if (cfg->param->rc.vbvBufferSize < (int)(cfg->param->rc.vbvMaxBitrate / fps))
>          {
> -            cfg->param.rc.vbvBufferSize = (int)(cfg->param.rc.vbvMaxBitrate / fps);
> -            x265_log(&cfg->param, X265_LOG_WARNING, "VBV buffer size cannot be smaller than one frame, using %d kbit\n",
> -                     cfg->param.rc.vbvBufferSize);
> +            cfg->param->rc.vbvBufferSize = (int)(cfg->param->rc.vbvMaxBitrate / fps);
> +            x265_log(cfg->param, X265_LOG_WARNING, "VBV buffer size cannot be smaller than one frame, using %d kbit\n",
> +                     cfg->param->rc.vbvBufferSize);
>          }
> -        int vbvBufferSize = cfg->param.rc.vbvBufferSize * 1000;
> -        int vbvMaxBitrate = cfg->param.rc.vbvMaxBitrate * 1000;
> +        int vbvBufferSize = cfg->param->rc.vbvBufferSize * 1000;
> +        int vbvMaxBitrate = cfg->param->rc.vbvMaxBitrate * 1000;
>
>          bufferRate = vbvMaxBitrate / fps;
>          vbvMaxRate = vbvMaxBitrate;
>          bufferSize = vbvBufferSize;
>          singleFrameVbv = bufferRate * 1.1 > bufferSize;
>
> -        if (cfg->param.rc.vbvBufferInit > 1.)
> -            cfg->param.rc.vbvBufferInit = Clip3(0.0, 1.0, cfg->param.rc.vbvBufferInit / cfg->param.rc.vbvBufferSize);
> -        cfg->param.rc.vbvBufferInit = Clip3(0.0, 1.0, X265_MAX(cfg->param.rc.vbvBufferInit, bufferRate / bufferSize));
> -        bufferFillFinal = bufferSize * cfg->param.rc.vbvBufferInit;
> -        vbvMinRate = /*!rc->b_2pass && */ cfg->param.rc.rateControlMode == X265_RC_ABR
> -            && cfg->param.rc.vbvMaxBitrate <= cfg->param.rc.bitrate;
> +        if (cfg->param->rc.vbvBufferInit > 1.)
> +            cfg->param->rc.vbvBufferInit = Clip3(0.0, 1.0, cfg->param->rc.vbvBufferInit / cfg->param->rc.vbvBufferSize);
> +        cfg->param->rc.vbvBufferInit = Clip3(0.0, 1.0, X265_MAX(cfg->param->rc.vbvBufferInit, bufferRate / bufferSize));
> +        bufferFillFinal = bufferSize * cfg->param->rc.vbvBufferInit;
> +        vbvMinRate = /*!rc->b_2pass && */ cfg->param->rc.rateControlMode == X265_RC_ABR
> +            && cfg->param->rc.vbvMaxBitrate <= cfg->param->rc.bitrate;
>      }
>
> -    bframes = cfg->param.bframes;
> +    bframes = cfg->param->bframes;
>      bframeBits = 0;
>      leadingNoBSatd = 0;
> -    if (cfg->param.rc.rateControlMode == X265_RC_ABR)
> +    if (cfg->param->rc.rateControlMode == X265_RC_ABR)
>      {
>          /* Adjust the first frame in order to stabilize the quality level compared to the rest */
>  #define ABR_INIT_QP_MIN (24 + QP_BD_OFFSET)
>  #define ABR_INIT_QP_MAX (34 + QP_BD_OFFSET)
>      }
> -    else if (cfg->param.rc.rateControlMode == X265_RC_CRF)
> +    else if (cfg->param->rc.rateControlMode == X265_RC_CRF)
>      {
> -#define ABR_INIT_QP ((int)cfg->param.rc.rfConstant)
> +#define ABR_INIT_QP ((int)cfg->param->rc.rfConstant)
>      }
>      reInit();
>
> -    ipOffset = 6.0 * X265_LOG2(cfg->param.rc.ipFactor);
> -    pbOffset = 6.0 * X265_LOG2(cfg->param.rc.pbFactor);
> +    ipOffset = 6.0 * X265_LOG2(cfg->param->rc.ipFactor);
> +    pbOffset = 6.0 * X265_LOG2(cfg->param->rc.pbFactor);
>      for (int i = 0; i < 3; i++)
>      {
> -        lastQScaleFor[i] = qp2qScale(cfg->param.rc.rateControlMode == X265_RC_CRF ? ABR_INIT_QP : ABR_INIT_QP_MIN);
> +        lastQScaleFor[i] = qp2qScale(cfg->param->rc.rateControlMode == X265_RC_CRF ? ABR_INIT_QP : ABR_INIT_QP_MIN);
>          lmin[i] = qp2qScale(MIN_QP);
>          lmax[i] = qp2qScale(MAX_MAX_QP);
>      }
>
> -    if (cfg->param.rc.rateControlMode == X265_RC_CQP)
> +    if (cfg->param->rc.rateControlMode == X265_RC_CQP)
>      {
>          qpConstant[P_SLICE] = qp;
>          qpConstant[I_SLICE] = Clip3(0, MAX_MAX_QP, (int)(qp - ipOffset + 0.5));
> @@ -354,7 +354,7 @@
>      }
>
>      /* qstep - value set as encoder specific */
> -    lstep = pow(2, cfg->param.rc.qpStep / 6.0);
> +    lstep = pow(2, cfg->param->rc.qpStep / 6.0);
>  }
>
>  void RateControl::reInit()
> @@ -366,7 +366,7 @@
>      cplxrSum = .01 * pow(7.0e5, qCompress) * pow(ncu, 0.5);
>      wantedBitsWindow = bitrate * frameDuration;
>      accumPNorm = .01;
> -    accumPQp = (cfg->param.rc.rateControlMode == X265_RC_CRF ? ABR_INIT_QP : ABR_INIT_QP_MIN) * accumPNorm;
> +    accumPQp = (cfg->param->rc.rateControlMode == X265_RC_CRF ? ABR_INIT_QP : ABR_INIT_QP_MIN) * accumPNorm;
>
>      /* Frame Predictors and Row predictors used in vbv */
>      for (int i = 0; i < 5; i++)
> @@ -504,7 +504,7 @@
>      }
>      else
>      {
> -        double abrBuffer = 2 * cfg->param.rc.rateTolerance * bitrate;
> +        double abrBuffer = 2 * cfg->param->rc.rateTolerance * bitrate;
>
>          /* 1pass ABR */
>
> @@ -530,7 +530,7 @@
>          rce->mvBits = 0;
>          rce->sliceType = sliceType;
>
> -        if (cfg->param.rc.rateControlMode == X265_RC_CRF)
> +        if (cfg->param->rc.rateControlMode == X265_RC_CRF)
>          {
>              q = getQScale(rce, rateFactorConstant);
>          }
> @@ -546,7 +546,7 @@
>              if (!vbvMinRate && currentSatd)
>              {
>                  /* use framesDone instead of POC as poc count is not serial with bframes enabled */
> -                double timeDone = (double)(framesDone - cfg->param.frameNumThreads + 1) * frameDuration;
> +                double timeDone = (double)(framesDone - cfg->param->frameNumThreads + 1) * frameDuration;
>                  wantedBits = timeDone * bitrate;
>                  if (wantedBits > 0 && totalBits > 0)
>                  {
> @@ -557,14 +557,14 @@
>              }
>          }
>
> -        if (sliceType == I_SLICE && cfg->param.keyframeMax > 1
> +        if (sliceType == I_SLICE && cfg->param->keyframeMax > 1
>              && lastNonBPictType != I_SLICE && !isAbrReset)
>          {
>              q = qp2qScale(accumPQp / accumPNorm);
> -            q /= fabs(cfg->param.rc.ipFactor);
> +            q /= fabs(cfg->param->rc.ipFactor);
>          }
>
> -        if (cfg->param.rc.rateControlMode != X265_RC_CRF)
> +        if (cfg->param->rc.rateControlMode != X265_RC_CRF)
>          {
>              double lqmin = 0, lqmax = 0;
>              if (totalBits == 0 && !isVbv)
> @@ -587,7 +587,7 @@
>          else
>          {
>              if (qCompress != 1 && framesDone == 0)
> -                q = qp2qScale(ABR_INIT_QP) / fabs(cfg->param.rc.ipFactor);
> +                q = qp2qScale(ABR_INIT_QP) / fabs(cfg->param->rc.ipFactor);
>          }
>          double lmin1 = lmin[sliceType];
>          double lmax1 = lmax[sliceType];
> @@ -599,7 +599,7 @@
>          lastQScaleFor[sliceType] = q;
>
>          if (curSlice->getPOC() == 0 || (isAbrReset && sliceType == I_SLICE))
> -            lastQScaleFor[P_SLICE] = q * fabs(cfg->param.rc.ipFactor);
> +            lastQScaleFor[P_SLICE] = q * fabs(cfg->param->rc.ipFactor);
>
>          rce->frameSizePlanned = predictSize(&pred[sliceType], q, (double)currentSatd);
>
> @@ -609,7 +609,7 @@
>
>  void RateControl::checkAndResetABR(RateControlEntry* rce, bool isFrameDone)
>  {
> -    double abrBuffer = 2 * cfg->param.rc.rateTolerance * bitrate;
> +    double abrBuffer = 2 * cfg->param->rc.rateTolerance * bitrate;
>
>      // Check if current Slice is a scene cut that follows low detailed/blank frames
>      if (rce->lastSatd > 4 * rce->movingAvgSum)
> @@ -656,7 +656,7 @@
>      // since they are controlled by the P-frames' QPs.
>      if (isVbv && currentSatd > 0)
>      {
> -        if (cfg->param.lookaheadDepth)
> +        if (cfg->param->lookaheadDepth)
>          {
>              int terminate = 0;
>
> @@ -668,9 +668,9 @@
>                  double bufferFillCur = bufferFill - curBits;
>                  double targetFill;
>                  double totalDuration = 0;
> -                frameQ[P_SLICE] = sliceType == I_SLICE ? q * cfg->param.rc.ipFactor : q;
> -                frameQ[B_SLICE] = frameQ[P_SLICE] * cfg->param.rc.pbFactor;
> -                frameQ[I_SLICE] = frameQ[P_SLICE] / cfg->param.rc.ipFactor;
> +                frameQ[P_SLICE] = sliceType == I_SLICE ? q * cfg->param->rc.ipFactor : q;
> +                frameQ[B_SLICE] = frameQ[P_SLICE] * cfg->param->rc.pbFactor;
> +                frameQ[I_SLICE] = frameQ[P_SLICE] / cfg->param->rc.ipFactor;
>                  /* Loop over the planned future frames. */
>                  for (int j = 0; bufferFillCur >= 0 && bufferFillCur <= bufferSize; j++)
>                  {
> @@ -744,7 +744,7 @@
>          {
>              int nb = bframes;
>              double bits = predictSize(&pred[sliceType], q, (double)currentSatd);
> -            double bbits = predictSize(&predBfromP, q * cfg->param.rc.pbFactor, (double)currentSatd);
> +            double bbits = predictSize(&predBfromP, q * cfg->param->rc.pbFactor, (double)currentSatd);
>              double space;
>              if (bbits > bufferRate)
>                  nb = 0;
> @@ -861,8 +861,8 @@
>      double qpAbsoluteMax = MAX_MAX_QP;
>      if (rateFactorMaxIncrement)
>          qpAbsoluteMax = X265_MIN(qpAbsoluteMax, rce->qpNoVbv + rateFactorMaxIncrement);
> -    double qpMax = X265_MIN(prevRowQp + cfg->param.rc.qpStep, qpAbsoluteMax);
> -    double qpMin = X265_MAX(prevRowQp - cfg->param.rc.qpStep, MIN_QP);
> +    double qpMax = X265_MIN(prevRowQp + cfg->param->rc.qpStep, qpAbsoluteMax);
> +    double qpMin = X265_MAX(prevRowQp - cfg->param->rc.qpStep, MIN_QP);
>      double stepSize = 0.5;
>      double bufferLeftPlanned = rce->bufferFill - rce->frameSizePlanned;
>
> @@ -879,7 +879,7 @@
>              qpVbv = X265_MAX(qpVbv, qpMin);
>          }
>          /* More threads means we have to be more cautious in letting ratecontrol use up extra bits. */
> -        double rcTol = bufferLeftPlanned / cfg->param.frameNumThreads * cfg->param.rc.rateTolerance;
> +        double rcTol = bufferLeftPlanned / cfg->param->frameNumThreads * cfg->param->rc.rateTolerance;
>          int32_t encodedBitsSoFar = 0;
>          double accFrameBits = predictRowsSizeSum(pic, qpVbv, encodedBitsSoFar);
>
> @@ -953,14 +953,14 @@
>  {
>      double q;
>
> -    if (cfg->param.rc.cuTree)
> +    if (cfg->param->rc.cuTree)
>      {
>          // Scale and units are obtained from rateNum and rateDenom for videos with fixed frame rates.
> -        double timescale = (double)cfg->param.fpsDenom / (2 * cfg->param.fpsNum);
> -        q = pow(BASE_FRAME_DURATION / CLIP_DURATION(2 * timescale), 1 - cfg->param.rc.qCompress);
> +        double timescale = (double)cfg->param->fpsDenom / (2 * cfg->param->fpsNum);
> +        q = pow(BASE_FRAME_DURATION / CLIP_DURATION(2 * timescale), 1 - cfg->param->rc.qCompress);
>      }
>      else
> -        q = pow(rce->blurredComplexity, 1 - cfg->param.rc.qCompress);
> +        q = pow(rce->blurredComplexity, 1 - cfg->param->rc.qCompress);
>
>      // avoid NaN's in the rc_eq
>      if (rce->texBits + rce->mvBits == 0)
> @@ -1004,7 +1004,7 @@
>      bufferFillFinal -= bits;
>
>      if (bufferFillFinal < 0)
> -        x265_log(&cfg->param, X265_LOG_WARNING, "poc:%d, VBV underflow (%.0f bits)\n", rce->poc, bufferFillFinal);
> +        x265_log(cfg->param, X265_LOG_WARNING, "poc:%d, VBV underflow (%.0f bits)\n", rce->poc, bufferFillFinal);
>
>      bufferFillFinal = X265_MAX(bufferFillFinal, 0);
>      bufferFillFinal += bufferRate;
> @@ -1016,13 +1016,13 @@
>  {
>      if (isAbr)
>      {
> -        if (cfg->param.rc.rateControlMode == X265_RC_ABR)
> +        if (cfg->param->rc.rateControlMode == X265_RC_ABR)
>          {
>              checkAndResetABR(rce, true);
>          }
>          if (!isAbrReset)
>          {
> -            if (cfg->param.rc.aqMode || isVbv)
> +            if (cfg->param->rc.aqMode || isVbv)
>              {
>                  if (pic->m_qpaRc)
>                  {
> @@ -1050,7 +1050,7 @@
>              {
>                  /* Depends on the fact that B-frame's QP is an offset from the following P-frame's.
>                   * Not perfectly accurate with B-refs, but good enough. */
> -                cplxrSum += bits * qp2qScale(rce->qpaRc) / (rce->qRceq * fabs(cfg->param.rc.pbFactor));
> +                cplxrSum += bits * qp2qScale(rce->qpaRc) / (rce->qRceq * fabs(cfg->param->rc.pbFactor));
>              }
>              wantedBitsWindow += frameDuration * bitrate;
>              totalBits += bits;
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/ratecontrol.h
> --- a/source/encoder/ratecontrol.h      Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/ratecontrol.h      Mon Mar 03 14:24:34 2014 -0800
> @@ -34,7 +34,6 @@
>  struct Lookahead;
>  class Encoder;
>  class TComPic;
> -class TEncCfg;
>
>  #define BASE_FRAME_DURATION 0.04
>
> @@ -76,7 +75,7 @@
>  struct RateControl
>  {
>      TComSlice *curSlice;      /* all info about the current frame */
> -    TEncCfg *cfg;
> +    Encoder *cfg;
>      SliceType sliceType;      /* Current frame type */
>      int ncu;                  /* number of CUs in a frame */
>      int keyFrameInterval;     /* TODO: need to initialize in init */
> @@ -125,7 +124,7 @@
>      double qCompress;
>      double qpNoVbv;             /* QP for the current frame if 1-pass VBV was disabled. */
>      double frameSizeEstimated;  /* hold synched frameSize, updated from cu level vbv rc */
> -    RateControl(TEncCfg * _cfg);
> +    RateControl(Encoder * _cfg);
>
>      // to be called for each frame to process RateControl and set QP
>      void rateControlStart(TComPic* pic, Lookahead *, RateControlEntry* rce, Encoder* enc);
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp      Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/slicetype.cpp      Mon Mar 03 14:24:34 2014 -0800
> @@ -27,7 +27,7 @@
>  #include "primitives.h"
>  #include "lowres.h"
>
> -#include "TLibEncoder/TEncCfg.h"
> +#include "encoder.h"
>  #include "slicetype.h"
>  #include "motion.h"
>  #include "mv.h"
> @@ -56,14 +56,14 @@
>      dst.y = median(a.y, b.y, c.y);
>  }
>
> -Lookahead::Lookahead(TEncCfg *_cfg, ThreadPool* pool)
> +Lookahead::Lookahead(Encoder *_cfg, ThreadPool* pool)
>      : est(pool)
>  {
>      this->cfg = _cfg;
> -    lastKeyframe = -cfg->param.keyframeMax;
> +    lastKeyframe = -cfg->param->keyframeMax;
>      lastNonB = NULL;
> -    widthInCU = ((cfg->param.sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> -    heightInCU = ((cfg->param.sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> +    widthInCU = ((cfg->param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> +    heightInCU = ((cfg->param->sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
>      scratch = (int*)x265_malloc(widthInCU * sizeof(int));
>      memset(histogram, 0, sizeof(histogram));
>  }
> @@ -78,14 +78,14 @@
>      while (!inputQueue.empty())
>      {
>          TComPic* pic = inputQueue.popFront();
> -        pic->destroy(cfg->param.bframes);
> +        pic->destroy(cfg->param->bframes);
>          delete pic;
>      }
>
>      while (!outputQueue.empty())
>      {
>          TComPic* pic = outputQueue.popFront();
> -        pic->destroy(cfg->param.bframes);
> +        pic->destroy(cfg->param->bframes);
>          delete pic;
>      }
>
> @@ -96,10 +96,10 @@
>  {
>      TComPicYuv *orig = pic->getPicYuvOrg();
>
> -    pic->m_lowres.init(orig, pic->getSlice()->getPOC(), sliceType, cfg->param.bframes);
> +    pic->m_lowres.init(orig, pic->getSlice()->getPOC(), sliceType, cfg->param->bframes);
>      inputQueue.pushBack(*pic);
>
> -    if (inputQueue.size() >= cfg->param.lookaheadDepth)
> +    if (inputQueue.size() >= cfg->param->lookaheadDepth)
>          slicetypeDecide();
>  }
>
> @@ -172,23 +172,23 @@
>          cost.estimateFrameCost(frames, p0, p1, b, false);
>          cost.flush();
>      }
> -    if (cfg->param.rc.cuTree)
> +    if (cfg->param->rc.cuTree)
>      {
>          pic->m_lowres.satdCost = frameCostRecalculate(frames, p0, p1, b);
> -        if (b && cfg->param.rc.vbvBufferSize)
> +        if (b && cfg->param->rc.vbvBufferSize)
>              frameCostRecalculate(frames, b, b, b);
>      }
>
> -    else if (cfg->param.rc.aqMode)
> +    else if (cfg->param->rc.aqMode)
>          pic->m_lowres.satdCost = pic->m_lowres.costEstAq[b - p0][p1 - b];
>      else
>          pic->m_lowres.satdCost = pic->m_lowres.costEst[b - p0][p1 - b];
>
> -    if (cfg->param.rc.vbvBufferSize > 0 && cfg->param.rc.vbvMaxBitrate > 0)
> +    if (cfg->param->rc.vbvBufferSize > 0 && cfg->param->rc.vbvMaxBitrate > 0)
>      {
>          pic->m_lowres.lowresCostForRc = pic->m_lowres.lowresCosts[b - p0][p1 - b];
>          uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;
> -        uint32_t scale = cfg->param.maxCUSize / (2 * X265_LOWRES_CU_SIZE);
> +        uint32_t scale = cfg->param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);
>          uint32_t widthInLowresCu = (uint32_t)widthInCU, heightInLowresCu = (uint32_t)heightInCU;
>
>          for (uint32_t row = 0; row < pic->getFrameHeightInCU(); row++)
> @@ -215,14 +215,14 @@
>      Lowres *frames[X265_LOOKAHEAD_MAX];
>      TComPic *list[X265_LOOKAHEAD_MAX];
>      TComPic *ipic = inputQueue.first();
> -    bool isKeyFrameAnalyse = (cfg->param.rc.cuTree || (cfg->param.rc.vbvBufferSize && cfg->param.lookaheadDepth));
> +    bool isKeyFrameAnalyse = (cfg->param->rc.cuTree || (cfg->param->rc.vbvBufferSize && cfg->param->lookaheadDepth));
>
>      if (!est.rows && ipic)
>          est.init(cfg, ipic);
>
> -    if ((cfg->param.bFrameAdaptive && cfg->param.bframes) ||
> -        cfg->param.rc.cuTree || cfg->param.scenecutThreshold ||
> -        (cfg->param.lookaheadDepth && cfg->param.rc.vbvBufferSize))
> +    if ((cfg->param->bFrameAdaptive && cfg->param->bframes) ||
> +        cfg->param->rc.cuTree || cfg->param->scenecutThreshold ||
> +        (cfg->param->lookaheadDepth && cfg->param->rc.vbvBufferSize))
>      {
>          slicetypeAnalyse(frames, false);
>      }
> @@ -230,7 +230,7 @@
>          frames[0] = lastNonB;
>
>      int j;
> -    for (j = 0; ipic && j < cfg->param.bframes + 2; ipic = ipic->m_next)
> +    for (j = 0; ipic && j < cfg->param->bframes + 2; ipic = ipic->m_next)
>      {
>          list[j++] = ipic;
>      }
> @@ -242,40 +242,40 @@
>      {
>          Lowres& frm = list[bframes]->m_lowres;
>
> -        if (frm.sliceType == X265_TYPE_BREF && !cfg->param.bBPyramid && brefs == cfg->param.bBPyramid)
> +        if (frm.sliceType == X265_TYPE_BREF && !cfg->param->bBPyramid && brefs == cfg->param->bBPyramid)
>          {
>              frm.sliceType = X265_TYPE_B;
> -            x265_log(&cfg->param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid\n",
> +            x265_log(cfg->param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid\n",
>                       frm.frameNum);
>          }
>
>          /* pyramid with multiple B-refs needs a big enough dpb that the preceding P-frame stays available.
>             smaller dpb could be supported by smart enough use of mmco, but it's easier just to forbid it.*/
> -        else if (frm.sliceType == X265_TYPE_BREF && cfg->param.bBPyramid && brefs &&
> -                 cfg->param.maxNumReferences <= (brefs + 3))
> +        else if (frm.sliceType == X265_TYPE_BREF && cfg->param->bBPyramid && brefs &&
> +                 cfg->param->maxNumReferences <= (brefs + 3))
>          {
>              frm.sliceType = X265_TYPE_B;
> -            x265_log(&cfg->param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid and %d reference frames\n",
> -                     frm.sliceType, cfg->param.maxNumReferences);
> +            x265_log(cfg->param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid and %d reference frames\n",
> +                     frm.sliceType, cfg->param->maxNumReferences);
>          }
>
> -        if ( /*(!cfg->param.intraRefresh || frm.frameNum == 0) && */ frm.frameNum - lastKeyframe >= cfg->param.keyframeMax)
> +        if ( /*(!cfg->param->intraRefresh || frm.frameNum == 0) && */ frm.frameNum - lastKeyframe >= cfg->param->keyframeMax)
>          {
>              if (frm.sliceType == X265_TYPE_AUTO || frm.sliceType == X265_TYPE_I)
> -                frm.sliceType = cfg->param.bOpenGOP && lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
> +                frm.sliceType = cfg->param->bOpenGOP && lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
>              bool warn = frm.sliceType != X265_TYPE_IDR;
> -            if (warn && cfg->param.bOpenGOP)
> +            if (warn && cfg->param->bOpenGOP)
>                  warn &= frm.sliceType != X265_TYPE_I;
>              if (warn)
>              {
> -                x265_log(&cfg->param, X265_LOG_WARNING, "specified frame type (%d) at %d is not compatible with keyframe interval\n",
> +                x265_log(cfg->param, X265_LOG_WARNING, "specified frame type (%d) at %d is not compatible with keyframe interval\n",
>                           frm.sliceType, frm.frameNum);
> -                frm.sliceType = cfg->param.bOpenGOP && lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
> +                frm.sliceType = cfg->param->bOpenGOP && lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
>              }
>          }
> -        if (frm.sliceType == X265_TYPE_I && frm.frameNum - lastKeyframe >= cfg->param.keyframeMin)
> +        if (frm.sliceType == X265_TYPE_I && frm.frameNum - lastKeyframe >= cfg->param->keyframeMin)
>          {
> -            if (cfg->param.bOpenGOP)
> +            if (cfg->param->bOpenGOP)
>              {
>                  lastKeyframe = frm.frameNum;
>                  frm.bKeyframe = true;
> @@ -294,10 +294,10 @@
>                  bframes--;
>              }
>          }
> -        if (bframes == cfg->param.bframes || !list[bframes + 1])
> +        if (bframes == cfg->param->bframes || !list[bframes + 1])
>          {
>              if (IS_X265_TYPE_B(frm.sliceType))
> -                x265_log(&cfg->param, X265_LOG_WARNING, "specified frame type is not compatible with max B-frames\n");
> +                x265_log(cfg->param, X265_LOG_WARNING, "specified frame type is not compatible with max B-frames\n");
>              if (frm.sliceType == X265_TYPE_AUTO || IS_X265_TYPE_B(frm.sliceType))
>                  frm.sliceType = X265_TYPE_P;
>          }
> @@ -316,14 +316,14 @@
>      histogram[bframes]++;
>
>      /* insert a bref into the sequence */
> -    if (cfg->param.bBPyramid && bframes > 1 && !brefs)
> +    if (cfg->param->bBPyramid && bframes > 1 && !brefs)
>      {
>          list[bframes / 2]->m_lowres.sliceType = X265_TYPE_BREF;
>          brefs++;
>      }
>
>      /* calculate the frame costs ahead of time for x264_rc_analyse_slice while we still have lowres */
> -    if (cfg->param.rc.rateControlMode != X265_RC_CQP)
> +    if (cfg->param->rc.rateControlMode != X265_RC_CQP)
>      {
>          int p0, p1, b;
>          p1 = b = bframes + 1;
> @@ -340,7 +340,7 @@
>
>          est.estimateFrameCost(frames, p0, p1, b, 0);
>
> -        if ((p0 != p1 || bframes) && cfg->param.rc.vbvBufferSize)
> +        if ((p0 != p1 || bframes) && cfg->param->rc.vbvBufferSize)
>          {
>              // We need the intra costs for row SATDs
>              est.estimateFrameCost(frames, b, b, b, 0);
> @@ -381,7 +381,7 @@
>      outputQueue.pushBack(*list[bframes]);
>
>      /* Add B-ref frame next to P frame in output queue, the B-ref encode before non B-ref frame */
> -    if (bframes > 1 && cfg->param.bBPyramid)
> +    if (bframes > 1 && cfg->param->bBPyramid)
>      {
>          for (int i = 0; i < bframes; i++)
>          {
> @@ -453,9 +453,9 @@
>  {
>      int64_t cost = est.estimateFrameCost(frames, p0, p1, b, 0);
>
> -    if (cfg->param.rc.aqMode)
> +    if (cfg->param->rc.aqMode)
>      {
> -        if (cfg->param.rc.cuTree)
> +        if (cfg->param->rc.cuTree)
>              return frameCostRecalculate(frames, p0, p1, b);
>          else
>              return frames[b]->costEstAq[b - p0][p1 - b];
> @@ -466,10 +466,10 @@
>  void Lookahead::slicetypeAnalyse(Lowres **frames, bool bKeyframe)
>  {
>      int numFrames, origNumFrames, keyintLimit, framecnt;
> -    int maxSearch = X265_MIN(cfg->param.lookaheadDepth, X265_LOOKAHEAD_MAX);
> +    int maxSearch = X265_MIN(cfg->param->lookaheadDepth, X265_LOOKAHEAD_MAX);
>      int cuCount = NUM_CUS;
>      int resetStart;
> -    bool bIsVbvLookahead = cfg->param.rc.vbvBufferSize && cfg->param.lookaheadDepth;
> +    bool bIsVbvLookahead = cfg->param->rc.vbvBufferSize && cfg->param->lookaheadDepth;
>
>      if (!lastNonB)
>          return;
> @@ -484,19 +484,19 @@
>
>      if (!framecnt)
>      {
> -        if (cfg->param.rc.cuTree)
> +        if (cfg->param->rc.cuTree)
>              cuTree(frames, 0, bKeyframe);
>          return;
>      }
>
>      frames[framecnt + 1] = NULL;
>
> -    keyintLimit = cfg->param.keyframeMax - frames[0]->frameNum + lastKeyframe - 1;
> +    keyintLimit = cfg->param->keyframeMax - frames[0]->frameNum + lastKeyframe - 1;
>      origNumFrames = numFrames = X265_MIN(framecnt, keyintLimit);
>
>      if (bIsVbvLookahead)
>          numFrames = framecnt;
> -    else if (cfg->param.bOpenGOP && numFrames < framecnt)
> +    else if (cfg->param->bOpenGOP && numFrames < framecnt)
>          numFrames++;
>      else if (numFrames == 0)
>      {
> @@ -506,15 +506,15 @@
>
>      int numBFrames = 0;
>      int numAnalyzed = numFrames;
> -    if (cfg->param.scenecutThreshold && scenecut(frames, 0, 1, true, origNumFrames, maxSearch))
> +    if (cfg->param->scenecutThreshold && scenecut(frames, 0, 1, true, origNumFrames, maxSearch))
>      {
>          frames[1]->sliceType = X265_TYPE_I;
>          return;
>      }
>
> -    if (cfg->param.bframes)
> +    if (cfg->param->bframes)
>      {
> -        if (cfg->param.bFrameAdaptive == X265_B_ADAPT_TRELLIS)
> +        if (cfg->param->bFrameAdaptive == X265_B_ADAPT_TRELLIS)
>          {
>              if (numFrames > 1)
>              {
> @@ -537,7 +537,7 @@
>              }
>              frames[numFrames]->sliceType = X265_TYPE_P;
>          }
> -        else if (cfg->param.bFrameAdaptive == X265_B_ADAPT_FAST)
> +        else if (cfg->param->bFrameAdaptive == X265_B_ADAPT_FAST)
>          {
>              int64_t cost1p0, cost2p0, cost1b1, cost2p1;
>
> @@ -565,11 +565,11 @@
>
>  // arbitrary and untuned
>  #define INTER_THRESH 300
> -#define P_SENS_BIAS (50 - cfg->param.bFrameBias)
> +#define P_SENS_BIAS (50 - cfg->param->bFrameBias)
>                  frames[i + 1]->sliceType = X265_TYPE_B;
>
>                  int j;
> -                for (j = i + 2; j <= X265_MIN(i + cfg->param.bframes, numFrames - 1); j++)
> +                for (j = i + 2; j <= X265_MIN(i + cfg->param->bframes, numFrames - 1); j++)
>                  {
>                      int64_t pthresh = X265_MAX(INTER_THRESH - P_SENS_BIAS * (j - i - 1), INTER_THRESH / 10);
>                      int64_t pcost = est.estimateFrameCost(frames, i + 0, j + 1, j + 1, 1);
> @@ -590,7 +590,7 @@
>          }
>          else
>          {
> -            numBFrames = X265_MIN(numFrames - 1, cfg->param.bframes);
> +            numBFrames = X265_MIN(numFrames - 1, cfg->param->bframes);
>              for (int j = 1; j < numFrames; j++)
>              {
>                  frames[j]->sliceType = (j % (numBFrames + 1)) ? X265_TYPE_B : X265_TYPE_P;
> @@ -601,7 +601,7 @@
>          /* Check scenecut on the first minigop. */
>          for (int j = 1; j < numBFrames + 1; j++)
>          {
> -            if (cfg->param.scenecutThreshold && scenecut(frames, j, j + 1, false, origNumFrames, maxSearch))
> +            if (cfg->param->scenecutThreshold && scenecut(frames, j, j + 1, false, origNumFrames, maxSearch))
>              {
>                  frames[j]->sliceType = X265_TYPE_P;
>                  numAnalyzed = j;
> @@ -621,11 +621,11 @@
>          resetStart = bKeyframe ? 1 : 2;
>      }
>
> -    if (cfg->param.rc.cuTree)
> -        cuTree(frames, X265_MIN(numFrames, cfg->param.keyframeMax), bKeyframe);
> +    if (cfg->param->rc.cuTree)
> +        cuTree(frames, X265_MIN(numFrames, cfg->param->keyframeMax), bKeyframe);
>
> -    // if (!cfg->param.bIntraRefresh)
> -    for (int j = keyintLimit + 1; j <= numFrames; j += cfg->param.keyframeMax)
> +    // if (!cfg->param->bIntraRefresh)
> +    for (int j = keyintLimit + 1; j <= numFrames; j += cfg->param->keyframeMax)
>      {
>          frames[j]->sliceType = X265_TYPE_I;
>          resetStart = X265_MIN(resetStart, j + 1);
> @@ -644,13 +644,13 @@
>  bool Lookahead::scenecut(Lowres **frames, int p0, int p1, bool bRealScenecut, int numFrames, int maxSearch)
>  {
>      /* Only do analysis during a normal scenecut check. */
> -    if (bRealScenecut && cfg->param.bframes)
> +    if (bRealScenecut && cfg->param->bframes)
>      {
>          int origmaxp1 = p0 + 1;
>          /* Look ahead to avoid coding short flashes as scenecuts. */
> -        if (cfg->param.bFrameAdaptive == X265_B_ADAPT_TRELLIS)
> +        if (cfg->param->bFrameAdaptive == X265_B_ADAPT_TRELLIS)
>              /* Don't analyse any more frames than the trellis would have covered. */
> -            origmaxp1 += cfg->param.bframes;
> +            origmaxp1 += cfg->param->bframes;
>          else
>              origmaxp1++;
>          int maxp1 = X265_MIN(origmaxp1, numFrames);
> @@ -696,24 +696,24 @@
>      int64_t icost = frame->costEst[0][0];
>      int64_t pcost = frame->costEst[p1 - p0][0];
>      int gopSize = frame->frameNum - lastKeyframe;
> -    float threshMax = (float)(cfg->param.scenecutThreshold / 100.0);
> +    float threshMax = (float)(cfg->param->scenecutThreshold / 100.0);
>
>      /* magic numbers pulled out of thin air */
>      float threshMin = (float)(threshMax * 0.25);
>      float bias;
>
> -    if (cfg->param.keyframeMin == cfg->param.keyframeMax)
> +    if (cfg->param->keyframeMin == cfg->param->keyframeMax)
>          threshMin = threshMax;
> -    if (gopSize <= cfg->param.keyframeMin / 4)
> +    if (gopSize <= cfg->param->keyframeMin / 4)
>          bias = threshMin / 4;
> -    else if (gopSize <= cfg->param.keyframeMin)
> -        bias = threshMin * gopSize / cfg->param.keyframeMin;
> +    else if (gopSize <= cfg->param->keyframeMin)
> +        bias = threshMin * gopSize / cfg->param->keyframeMin;
>      else
>      {
>          bias = threshMin
>              + (threshMax - threshMin)
> -            * (gopSize - cfg->param.keyframeMin)
> -            / (cfg->param.keyframeMax - cfg->param.keyframeMin);
> +            * (gopSize - cfg->param->keyframeMin)
> +            / (cfg->param->keyframeMax - cfg->param->keyframeMin);
>      }
>
>      bool res = pcost >= (1.0 - bias) * icost;
> @@ -721,7 +721,7 @@
>      {
>          int imb = frame->intraMbs[p1 - p0];
>          int pmb = NUM_CUS - imb;
> -        x265_log(&cfg->param, X265_LOG_DEBUG, "scene cut at %d Icost:%d Pcost:%d ratio:%.4f bias:%.4f gop:%d (imb:%d pmb:%d)\n",
> +        x265_log(cfg->param, X265_LOG_DEBUG, "scene cut at %d Icost:%d Pcost:%d ratio:%.4f bias:%.4f gop:%d (imb:%d pmb:%d)\n",
>                   frame->frameNum, icost, pcost, 1. - (double)pcost / icost, bias, gopSize, imb, pmb);
>      }
>      return res;
> @@ -730,7 +730,7 @@
>  void Lookahead::slicetypePath(Lowres **frames, int length, char(*best_paths)[X265_LOOKAHEAD_MAX + 1])
>  {
>      char paths[2][X265_LOOKAHEAD_MAX + 1];
> -    int num_paths = X265_MIN(cfg->param.bframes + 1, length);
> +    int num_paths = X265_MIN(cfg->param->bframes + 1, length);
>      int64_t best_cost = 1LL << 62;
>      int idx = 0;
>
> @@ -778,7 +778,7 @@
>          if (cost > threshold)
>              break;
>
> -        if (cfg->param.bBPyramid && next_p - cur_p > 2)
> +        if (cfg->param->bBPyramid && next_p - cur_p > 2)
>          {
>              int middle = cur_p + (next_p - cur_p) / 2;
>              cost += est.estimateFrameCost(frames, cur_p, next_p, middle, 0);
> @@ -817,7 +817,7 @@
>      double totalDuration = 0.0;
>      for (int j = 0; j <= numframes; j++)
>      {
> -        totalDuration += (double)cfg->param.fpsDenom / cfg->param.fpsNum;
> +        totalDuration += (double)cfg->param->fpsDenom / cfg->param->fpsNum;
>      }
>
>      double averageDuration = totalDuration / (numframes + 1);
> @@ -838,7 +838,7 @@
>      /* Lookaheadless MB-tree is not a theoretically distinct case; the same extrapolation could
>       * be applied to the end of a lookahead buffer of any size.  However, it's most needed when
>       * lookahead=0, so that's what's currently implemented. */
> -    if (!cfg->param.lookaheadDepth)
> +    if (!cfg->param->lookaheadDepth)
>      {
>          if (bIntra)
>          {
> @@ -870,7 +870,7 @@
>          est.estimateFrameCost(frames, curnonb, lastnonb, lastnonb, 0);
>          memset(frames[curnonb]->propagateCost, 0, cuCount * sizeof(uint16_t));
>          bframes = lastnonb - curnonb - 1;
> -        if (cfg->param.bBPyramid && bframes > 1)
> +        if (cfg->param->bBPyramid && bframes > 1)
>          {
>              int middle = (bframes + 1) / 2 + curnonb;
>              est.estimateFrameCost(frames, curnonb, lastnonb, middle, 0);
> @@ -902,7 +902,7 @@
>          lastnonb = curnonb;
>      }
>
> -    if (!cfg->param.lookaheadDepth)
> +    if (!cfg->param->lookaheadDepth)
>      {
>          est.estimateFrameCost(frames, 0, lastnonb, lastnonb, 0);
>          estimateCUPropagate(frames, averageDuration, 0, lastnonb, lastnonb, 1);
> @@ -910,7 +910,7 @@
>      }
>
>      cuTreeFinish(frames[lastnonb], averageDuration, lastnonb);
> -    if (cfg->param.bBPyramid && bframes > 1 && !cfg->param.rc.vbvBufferSize)
> +    if (cfg->param->bBPyramid && bframes > 1 && !cfg->param->rc.vbvBufferSize)
>          cuTreeFinish(frames[lastnonb + (bframes + 1) / 2], averageDuration, 0);
>  }
>
> @@ -918,7 +918,7 @@
>  {
>      uint16_t *refCosts[2] = { frames[p0]->propagateCost, frames[p1]->propagateCost };
>      int32_t distScaleFactor = (((b - p0) << 8) + ((p1 - p0) >> 1)) / (p1 - p0);
> -    int32_t bipredWeight = cfg->param.bEnableWeightedBiPred ? 64 - (distScaleFactor >> 2) : 32;
> +    int32_t bipredWeight = cfg->param->bEnableWeightedBiPred ? 64 - (distScaleFactor >> 2) : 32;
>      MV *mvs[2] = { frames[b]->lowresMvs[0][b - p0 - 1], frames[b]->lowresMvs[1][p1 - b - 1] };
>      int32_t bipredWeights[2] = { bipredWeight, 64 - bipredWeight };
>
> @@ -927,7 +927,7 @@
>      uint16_t *propagateCost = frames[b]->propagateCost;
>
>      x265_emms();
> -    double fpsFactor = CLIP_DURATION((double)cfg->param.fpsDenom / cfg->param.fpsNum) / CLIP_DURATION(averageDuration);
> +    double fpsFactor = CLIP_DURATION((double)cfg->param->fpsDenom / cfg->param->fpsNum) / CLIP_DURATION(averageDuration);
>
>      /* For non-refferd frames the source costs are always zero, so just memset one row and re-use it. */
>      if (!referenced)
> @@ -1011,13 +1011,13 @@
>          }
>      }
>
> -    if (cfg->param.rc.vbvBufferSize && cfg->param.logLevel && referenced)
> +    if (cfg->param->rc.vbvBufferSize && cfg->param->logLevel && referenced)
>          cuTreeFinish(frames[b], averageDuration, b == p1 ? b - p0 : 0);
>  }
>
>  void Lookahead::cuTreeFinish(Lowres *frame, double averageDuration, int ref0Distance)
>  {
> -    int fpsFactor = (int)(CLIP_DURATION(averageDuration) / CLIP_DURATION((double)cfg->param.fpsDenom / cfg->param.fpsNum) * 256);
> +    int fpsFactor = (int)(CLIP_DURATION(averageDuration) / CLIP_DURATION((double)cfg->param->fpsDenom / cfg->param->fpsNum) * 256);
>      double weightdelta = 0.0;
>
>      if (ref0Distance && frame->weightedCostDelta[ref0Distance - 1] > 0)
> @@ -1027,7 +1027,7 @@
>       * concepts are very similar. */
>
>      int cuCount = widthInCU * heightInCU;
> -    double strength = 5.0 * (1.0 - cfg->param.rc.qCompress);
> +    double strength = 5.0 * (1.0 - cfg->param->rc.qCompress);
>
>      for (int cuIndex = 0; cuIndex < cuCount; cuIndex++)
>      {
> @@ -1112,11 +1112,11 @@
>      delete[] rows;
>  }
>
> -void CostEstimate::init(TEncCfg *_cfg, TComPic *pic)
> +void CostEstimate::init(Encoder *_cfg, TComPic *pic)
>  {
>      cfg = _cfg;
> -    widthInCU = ((cfg->param.sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> -    heightInCU = ((cfg->param.sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> +    widthInCU = ((cfg->param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
> +    heightInCU = ((cfg->param->sourceHeight / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
>
>      rows = new EstimateRow[heightInCU];
>      for (int i = 0; i < heightInCU; i++)
> @@ -1134,7 +1134,7 @@
>          WaveFront::enableAllRows();
>      }
>
> -    if (cfg->param.bEnableWeightedPred)
> +    if (cfg->param->bEnableWeightedPred)
>      {
>          TComPicYuv *orig = pic->getPicYuvOrg();
>          paddedLines = pic->m_lowres.lines + 2 * orig->getLumaMarginY();
> @@ -1164,7 +1164,7 @@
>      else
>      {
>          weightedRef.isWeighted = false;
> -        if (cfg->param.bEnableWeightedPred && b == p1 && b != p0 && fenc->lowresMvs[0][b - p0 - 1][0].x == 0x7FFF)
> +        if (cfg->param->bEnableWeightedPred && b == p1 && b != p0 && fenc->lowresMvs[0][b - p0 - 1][0].x == 0x7FFF)
>          {
>              if (!fenc->bIntraCalculated)
>                  estimateFrameCost(frames, b, b, b, 0);
> @@ -1221,7 +1221,7 @@
>          {
>              score += rows[row].costEst;
>              fenc->costEst[0][0] += rows[row].costIntra;
> -            if (cfg->param.rc.aqMode)
> +            if (cfg->param->rc.aqMode)
>              {
>                  fenc->costEstAq[0][0] += rows[row].costIntraAq;
>                  fenc->costEstAq[b - p0][p1 - b] += rows[row].costEstAq;
> @@ -1232,7 +1232,7 @@
>          fenc->bIntraCalculated = true;
>
>          if (b != p1)
> -            score = (uint64_t)score * 100 / (130 + cfg->param.bFrameBias);
> +            score = (uint64_t)score * 100 / (130 + cfg->param->bFrameBias);
>          if (b != p0 || b != p1) //Not Intra cost
>              fenc->costEst[b - p0][p1 - b] = score;
>      }
> diff -r 6662df480e39 -r 56fa912d6e7c source/encoder/slicetype.h
> --- a/source/encoder/slicetype.h        Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/encoder/slicetype.h        Mon Mar 03 14:24:34 2014 -0800
> @@ -33,7 +33,7 @@
>
>  struct Lowres;
>  class TComPic;
> -class TEncCfg;
> +class Encoder;
>
>  #define SET_WEIGHT(w, b, s, d, o) \
>      { \
> @@ -89,9 +89,9 @@
>  {
>      CostEstimate(ThreadPool *p);
>      ~CostEstimate();
> -    void init(TEncCfg *, TComPic *);
> +    void init(Encoder *, TComPic *);
>
> -    TEncCfg         *cfg;
> +    Encoder         *cfg;
>      EstimateRow     *rows;
>      pixel           *wbuffer[4];
>      Lowres         **curframes;
> @@ -118,7 +118,7 @@
>
>  struct Lookahead
>  {
> -    Lookahead(TEncCfg *, ThreadPool *pool);
> +    Lookahead(Encoder *, ThreadPool *pool);
>      ~Lookahead();
>      void init();
>      void destroy();
> @@ -127,7 +127,7 @@
>      PicList          inputQueue;      // input pictures in order received
>      PicList          outputQueue;     // pictures to be encoded, in encode order
>
> -    TEncCfg         *cfg;
> +    Encoder         *cfg;
>      Lowres          *lastNonB;
>      int             *scratch;         // temp buffer
>
> diff -r 6662df480e39 -r 56fa912d6e7c source/x265.cpp
> --- a/source/x265.cpp   Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/x265.cpp   Mon Mar 03 14:24:34 2014 -0800
> @@ -170,7 +170,8 @@
>      { "no-framefieldinfo",    no_argument, NULL, 0 },
>      { "crop-rect",      required_argument, NULL, 0 },
>      { "timinginfo",           no_argument, NULL, 0 },
> -    { "nal-hrd",              no_argument, NULL, 0 },
> +    { "hrd",                  no_argument, NULL, 0 },
> +    { "nal-hrd",        required_argument, NULL, 0 },
>      { "bitstreamrestriction", no_argument, NULL, 0 },
>      { "subpichrd",            no_argument, NULL, 0 },
>      { 0, 0, 0, 0 }
> @@ -394,7 +395,8 @@
>      H0("   --[no-]framefieldinfo         Specify that a pic-struct will be added to the SEI timing message. Default %s\n", OPT(param->bEnableFrameFieldInfoPresentFlag));
>      H0("   --crop-rect <string>          Add 'left,top,right,bottom' to the bitstream-level cropping rectangle\n");
>      H0("   --timinginfo                  Add timing information to the VUI. Defaut %s\n", OPT(param->bEnableVuiTimingInfoPresentFlag));
> -    H0("   --nal-hrd                     Signal HRD information. Default %s\n", OPT(param->bEnableVuiHrdParametersPresentFlag));
> +    H0("   --hrd                         Signal HRD information. Default %s\n", OPT(param->bEnableVuiHrdParametersPresentFlag));
> +    H0("   --nal-hrd <string>            Signal NAL HRD information (requires vbv-buffer size) Choose from none, vbr or cbr.Default none\n");
>      H0("   --bitstreamrestriction        Add bit stream restriction fields to the VUI. Default %s\n", OPT(param->bEnableBitstreamRestrictionFlag));
>      H0("   --subpichrd                   Add sub picture HRD parameters to the HRD. Default %s\n", OPT(param->bEnableSubPicHrdParamsPresentFlag));
>  #undef OPT
> diff -r 6662df480e39 -r 56fa912d6e7c source/x265.h
> --- a/source/x265.h     Mon Mar 03 11:28:22 2014 +0530
> +++ b/source/x265.h     Mon Mar 03 14:24:34 2014 -0800
> @@ -290,6 +290,7 @@
>                                                       "YCgCo", "bt2020nc", "bt2020c", 0 };
>  static const char * const x265_sar_names[] = { "undef", "1:1", "12:11", "10:11", "16:11", "40:33", "24:11", "20:11",
>                                                 "32:11", "80:33", "18:11", "15:11", "64:33", "160:99", "4:3", "3:2", "2:1", 0 };
> +static const char * const x265_nal_hrd_names[] = { "none", "vbr", "cbr", 0 };
>
>  /* x265 input parameters
>   *
> @@ -479,6 +480,10 @@
>
>      /*== Hypothetical Reference Decoder Parameters ==*/
>
> +    /* NAL HRD parameters present flag determines if NAL HRD parameters related
> +     * to Type II bitstream are added to the VUI.  The default is false. */
> +    int       bEnableNalHrdParametersPresentFlag;

this is the kicker, it changes the public API so it will require a
bump to the build number so I'll need to hold off pushing it for a day
or two so I can get all the other queued API changes in all at once.

> +
>      /* Sub pic HRD params present flag determines if tic_divisor_minus2,
>       * du_cpb_removal_delay_increment_length_minus1,
>       * sub_pic_cpb_params_in_pic_timing_sei_flag,
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel



-- 
Steve Borho


More information about the x265-devel mailing list