Changeset 852 in 3DVCSoftware


Ignore:
Timestamp:
13 Feb 2014, 22:34:17 (10 years ago)
Author:
tech
Message:

Update HM-12.0 -> HM-13.0.

Location:
branches/HTM-10.0-dev0
Files:
3 added
179 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-10.0-dev0/COPYING

    r56 r852  
    44granted under this license.   
    55
    6 Copyright (c) 2010-2012, ITU/ISO/IEC
     6Copyright (c) 2010-2014, ITU/ISO/IEC
    77All rights reserved.
    88
  • branches/HTM-10.0-dev0/HM.xcodeproj/project.pbxproj

    r608 r852  
    10841084                                HEADER_SEARCH_PATHS = source/Lib;
    10851085                                ONLY_ACTIVE_ARCH = YES;
    1086                                 SDKROOT = macosx;
     1086                                SDKROOT = "";
    10871087                        };
    10881088                        name = Debug;
     
    10981098                                GCC_WARN_UNUSED_VARIABLE = YES;
    10991099                                HEADER_SEARCH_PATHS = source/Lib;
    1100                                 SDKROOT = macosx;
     1100                                SDKROOT = "";
    11011101                        };
    11021102                        name = Release;
  • branches/HTM-10.0-dev0/build/linux/common/makefile.base

    r608 r852  
    1414
    1515CPP     = g++
     16CC      = gcc
    1617AR      = ar
    1718LD      = $(CPP)
     
    6364#
    6465# release cpp
    65 RELEASE_CPPFLAGS  =  -O3 -ffloat-store -Wuninitialized
     66RELEASE_CPPFLAGS  =  -O3 -Wuninitialized
    6667
    6768
     
    208209                rm -f $(OBJ_DIR)/$*.d.d
    209210endef
     211define COMPILE_AND_DEPEND_RELEASE_C
     212        $(CC) -c -MMD -MF $(OBJ_DIR)/$*.r.d -MT $(OBJ_DIR)/$*.r.o $(CPPFLAGS) $(RELEASE_CPPFLAGS) -o $@ $(CURDIR)/$<
     213        @cp $(OBJ_DIR)/$*.r.d $(OBJ_DIR)/$*.r.P; \
     214                sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
     215                -e '/^$$/ d' -e 's/$$/ :/' < $(OBJ_DIR)/$*.r.d >> $(OBJ_DIR)/$*.r.P; \
     216                rm -f $(OBJ_DIR)/$*.r.d
     217endef
     218define COMPILE_AND_DEPEND_DEBUG_C
     219        $(CC) -c -MMD -MF $(OBJ_DIR)/$*.d.d -MT $(OBJ_DIR)/$*.d.o $(CPPFLAGS) $(DEBUG_CPPFLAGS) -o $@ $(CURDIR)/$<
     220        @cp $(OBJ_DIR)/$*.d.d $(OBJ_DIR)/$*.d.P; \
     221                sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
     222                -e '/^$$/ d' -e 's/$$/ :/' < $(OBJ_DIR)/$*.d.d >> $(OBJ_DIR)/$*.d.P; \
     223                rm -f $(OBJ_DIR)/$*.d.d
     224endef
    210225
    211226# create release objects
     
    251266# create release objects
    252267$(OBJ_DIR)/%.r.o: $(SRC_DIR)/%.c
    253         $(COMPILE_AND_DEPEND_RELEASE)
     268        $(COMPILE_AND_DEPEND_RELEASE_C)
    254269
    255270# create debug objects
    256271$(OBJ_DIR)/%.d.o: $(SRC_DIR)/%.c
    257         $(COMPILE_AND_DEPEND_DEBUG)
     272        $(COMPILE_AND_DEPEND_DEBUG_C)
    258273
    259274# create release objects
    260275$(OBJ_DIR)/%.r.o: $(SRC_DIR1)/%.c
    261         $(COMPILE_AND_DEPEND_RELEASE)
     276        $(COMPILE_AND_DEPEND_RELEASE_C)
    262277
    263278# create debug objects
    264279$(OBJ_DIR)/%.d.o: $(SRC_DIR1)/%.c
    265         $(COMPILE_AND_DEPEND_DEBUG)
     280        $(COMPILE_AND_DEPEND_DEBUG_C)
    266281
    267282# create release objects
    268283$(OBJ_DIR)/%.r.o: $(SRC_DIR2)/%.c
    269         $(COMPILE_AND_DEPEND_RELEASE)
     284        $(COMPILE_AND_DEPEND_RELEASE_C)
    270285
    271286# create debug objects
    272287$(OBJ_DIR)/%.d.o: $(SRC_DIR2)/%.c
    273         $(COMPILE_AND_DEPEND_DEBUG)
     288        $(COMPILE_AND_DEPEND_DEBUG_C)
    274289
    275290# create release objects
    276291$(OBJ_DIR)/%.r.o: $(SRC_DIR3)/%.c
    277         $(COMPILE_AND_DEPEND_RELEASE)
     292        $(COMPILE_AND_DEPEND_RELEASE_C)
    278293
    279294# create debug objects
    280295$(OBJ_DIR)/%.d.o: $(SRC_DIR3)/%.c
    281         $(COMPILE_AND_DEPEND_DEBUG)
     296        $(COMPILE_AND_DEPEND_DEBUG_C)
    282297
    283298# create release objects
    284299$(OBJ_DIR)/%.r.o: $(SRC_DIR4)/%.c
    285         $(COMPILE_AND_DEPEND_RELEASE)
     300        $(COMPILE_AND_DEPEND_RELEASE_C)
    286301
    287302# create debug objects
    288303$(OBJ_DIR)/%.d.o: $(SRC_DIR4)/%.c
    289         $(COMPILE_AND_DEPEND_DEBUG)
     304        $(COMPILE_AND_DEPEND_DEBUG_C)
    290305
    291306
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_2view+depth_AllIntra.cfg

    r738 r852  
    149149#============ Lossless ================
    150150TransquantBypassEnableFlag: 0  # Value of PPS flag.
    151 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     151CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    152152
    153153#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_2view_AllIntra.cfg

    r655 r852  
    122122#============ Lossless ================
    123123TransquantBypassEnableFlag: 0  # Value of PPS flag.
    124 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     124CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    125125
    126126#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_3view+depth_AllIntra.cfg

    r738 r852  
    164164#============ Lossless ================
    165165TransquantBypassEnableFlag: 0  # Value of PPS flag.
    166 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     166CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    167167
    168168#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/allintra/baseCfg_3view_AllIntra.cfg

    r655 r852  
    124124#============ Lossless ================
    125125TransquantBypassEnableFlag: 0  # Value of PPS flag.
    126 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     126CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    127127
    128128#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/fco/baseCfg_3view+depth.cfg

    r833 r852  
    213213#============ Lossless ================
    214214TransquantBypassEnableFlag: 0  # Value of PPS flag.
    215 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     215CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    216216
    217217#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/NonCTC/rc/baseCfg_3view+depth_rate_control.cfg

    r724 r852  
    213213#============ Lossless ================
    214214TransquantBypassEnableFlag: 0  # Value of PPS flag.
    215 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     215CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    216216
    217217#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg

    r833 r852  
    183183#============ Lossless ================
    184184TransquantBypassEnableFlag: 0  # Value of PPS flag.
    185 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     185CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    186186
    187187#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_2view.cfg

    r724 r852  
    156156#============ Lossless ================
    157157TransquantBypassEnableFlag: 0  # Value of PPS flag.
    158 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     158CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    159159
    160160#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg

    r833 r852  
    213213#============ Lossless ================
    214214TransquantBypassEnableFlag: 0  # Value of PPS flag.
    215 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     215CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    216216
    217217#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/baseCfg_3view.cfg

    r622 r852  
    171171#============ Lossless ================
    172172TransquantBypassEnableFlag: 0  # Value of PPS flag.
    173 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     173CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    174174
    175175#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/3D-HEVC/fullCfg.cfg

    r735 r852  
    219219#============ Lossless ================
    220220TransquantBypassEnableFlag: 0  # Value of PPS flag.
    221 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     221CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    222222
    223223#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_intra_main.cfg

    r655 r852  
    9797#============ Lossless ================
    9898TransquantBypassEnableFlag: 0  # Value of PPS flag.
    99 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     99CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    100100                                                       
    101101### DO NOT ADD ANYTHING BELOW THIS LINE ###
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_intra_main10.cfg

    r655 r852  
    9797#============ Lossless ================
    9898TransquantBypassEnableFlag: 0  # Value of PPS flag.
    99 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     99CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    100100
    101101                                                       
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_lowdelay_P_main.cfg

    r655 r852  
    102102#============ Lossless ================
    103103TransquantBypassEnableFlag: 0  # Value of PPS flag.
    104 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     104CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    105105
    106106#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_lowdelay_P_main10.cfg

    r655 r852  
    102102#============ Lossless ================
    103103TransquantBypassEnableFlag: 0  # Value of PPS flag.
    104 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     104CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    105105
    106106#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_lowdelay_main.cfg

    r655 r852  
    102102#============ Lossless ================
    103103TransquantBypassEnableFlag: 0  # Value of PPS flag.
    104 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     104CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    105105
    106106#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_lowdelay_main10.cfg

    r655 r852  
    102102#============ Lossless ================
    103103TransquantBypassEnableFlag: 0  # Value of PPS flag.
    104 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     104CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    105105
    106106#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_randomaccess_main.cfg

    r655 r852  
    106106#============ Lossless ================
    107107TransquantBypassEnableFlag: 0  # Value of PPS flag.
    108 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     108CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    109109
    110110#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/encoder_randomaccess_main10.cfg

    r655 r852  
    106106#============ Lossless ================
    107107TransquantBypassEnableFlag: 0  # Value of PPS flag.
    108 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     108CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    109109
    110110#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/per-sequence/Kimono.cfg

    r655 r852  
    88FramesToBeEncoded              : 240         # Number of frames to be coded
    99
    10 Level                         : 4.0
     10Level                         : 4
  • branches/HTM-10.0-dev0/cfg/HEVC/HM/per-sequence/ParkScene.cfg

    r655 r852  
    88FramesToBeEncoded              : 240         # Number of frames to be coded
    99
    10 Level                         : 4.0
     10Level                         : 4
  • branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_2view.cfg

    r622 r852  
    150150#============ Lossless ================
    151151TransquantBypassEnableFlag: 0  # Value of PPS flag.
    152 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     152CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    153153
    154154#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/MV-HEVC/baseCfg_3view.cfg

    r622 r852  
    167167#============ Lossless ================
    168168TransquantBypassEnableFlag: 0  # Value of PPS flag.
    169 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     169CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    170170
    171171#============ Rate Control ======================
  • branches/HTM-10.0-dev0/cfg/MV-HEVC/fullCfg.cfg

    r622 r852  
    164164#============ Lossless ================
    165165TransquantBypassEnableFlag: 0  # Value of PPS flag.
    166 CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
     166CUTransquantBypassFlagForce: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
    167167
    168168#============ Rate Control ======================
  • branches/HTM-10.0-dev0/doc/Doxyfile

    r608 r852  
    3333# if some version control system is used.
    3434
    35 PROJECT_NUMBER         = HM-11.0
     35PROJECT_NUMBER         = HM-13.0
    3636
    3737# Using the PROJECT_BRIEF tag one can provide an optional one line description
  • branches/HTM-10.0-dev0/doc/mainpage.h

    r608 r852  
    2525 * granted under this license. 
    2626 *
    27  * Copyright (c) 2010-2012, ITU/ISO/IEC
     27 * Copyright (c) 2010-2014, ITU/ISO/IEC
    2828 * All rights reserved.
    2929 *
  • branches/HTM-10.0-dev0/doc/software-manual.tex

    r608 r852  
    9999\author{%
    100100        Frank Bossen
    101         \email{bossen@docomoinnovations.com}
     101        \email{frank@bossentech.com}
    102102        \and
    103103        David Flynn
    104         \email{davidf@rd.bbc.co.uk}
     104        \email{dflynn@blackberry.com}
    105105        \and
    106106        Karsten S\"uhring
     
    118118\begin{abstract}
    119119This document is a user manual describing usage of reference software
    120 for the HEVC project. It applies to version 11.0
     120for the HEVC project. It applies to version 13.0
    121121of the software.
    122122\end{abstract}
     
    952952
    953953
    954 
    955 %%
    956 %% Entropy coding parameters
    957 %%
    958 \begin{OptionTable}{Entropy coding parameters}
    959 \Option{SBACRD} &
    960 \ShortOption{\None} &
    961 \Default{true} &
    962 Enables or disables the use of bit counts from arithmetic coder in
    963 rate-distortion decisions.
    964 \\
    965 \end{OptionTable}
    966 
    967 
    968954%%
    969955%% Slice coding parameters
     
    11831169transquant_bypass_enable_flag that is transmitted in the PPS.
    11841170
    1185 See CUTransquantBypassFlagValue for further details.
    1186 \\
    1187 
    1188 \Option{CUTransquantBypassFlagValue} &
     1171See CUTransquantBypassFlagForce for further details.
     1172\\
     1173
     1174\Option{CUTransquantBypassFlagForce} &
    11891175\ShortOption{\None} &
    11901176\Default{0} &
    11911177Controls the per CU transformation, quantization and filtering
    11921178mode decision.
    1193 This option corresponds to the value of the per CU cu_transquant_bypass_flag.
    1194 \par
    1195 \begin{tabular}{cp{0.45\textwidth}}
    1196  0 & Bypass is not performed on any CU \\
    1197  1 & Bypass is performed on all CUs \\
     1179This option controls the value of the per CU cu_transquant_bypass_flag.
     1180\par
     1181\begin{tabular}{cp{0.45\textwidth}}
     1182 0 & Bypass is searched on a CU-by-CU basis and will be used if the cost is lower than not bypassing. \\
     1183 1 & Bypass is forced for all CUs. \\
    11981184\end{tabular}
    11991185
     
    12041190\ShortOption{\None} &
    12051191\Default{false} &
    1206 Enables or disables the use of PCM.
     1192Enables or disables the use of PCM. The encoder will use cost measures on a CU-by-CU basis to determine if PCM mode is to be applied.
    12071193\\
    12081194
     
    19241910\section{Using the decoder}
    19251911\begin{verbatim}
    1926 TappDecoder -b str.bin -o dec.yuv [options]
     1912TAppDecoder -b str.bin -o dec.yuv [options]
    19271913\end{verbatim}
    19281914
  • branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecCfg.cpp

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecCfg.h

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    165165  Bool firstSlice        = true;
    166166#endif
    167  
     167  Bool loopFiltered      = false;
     168
    168169  while (!!bitstreamFile)
    169170  {
     
    278279          bitstreamFile.seekg(location-streamoff(3));
    279280          bytestream.reset();
     281#if H_MV_ENC_DEC_TRAC
    280282#if ENC_DEC_TRACE
    281 #if H_MV_ENC_DEC_TRAC
    282283          const Bool resetCounter = false;
    283284          if ( resetCounter )
     
    287288          else
    288289          {
    289             g_disableHLSTrace = true;     // Trancing of second parsing of SH is not carried out
    290           }         
    291 #else
    292           g_nSymbolCounter = symCount;
    293 #endif
    294 #endif
    295         }
    296       }
    297     }
    298     if (bNewPicture || !bitstreamFile)
    299     {
    300 #if H_MV
    301       assert( decIdxLastPic != -1 );
    302       m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
    303 #else
    304       m_cTDecTop.executeLoopFilters(poc, pcListPic);
    305 #endif
     290            g_disableHLSTrace = true;     // Tracing of second parsing of SH is not carried out
     291          }     
     292#endif
     293#endif
     294        }
     295      }
     296    }
     297    if (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS )
     298    {
     299      if (!loopFiltered || bitstreamFile)
     300      {
     301#if H_MV
     302        assert( decIdxLastPic != -1 );
     303        m_tDecTop[decIdxLastPic]->endPicDecoding(poc, pcListPic, m_targetDecLayerIdSet );
     304#else
     305        m_cTDecTop.executeLoopFilters(poc, pcListPic);
     306#endif
     307      }
     308      loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS);
    306309    }
    307310#if H_3D
     
    351354#endif
    352355      }
     356      if (nalu.m_nalUnitType == NAL_UNIT_EOS)
     357      {
     358#if H_MV
     359        xFlushOutput( pcListPic, decIdxLastPic );
     360#else
     361        xFlushOutput( pcListPic );
     362#endif
     363      }
    353364      // write reconstruction to file
    354365      if(bNewPicture)
     
    462473#endif
    463474{
     475
     476  if (pcListPic->empty())
     477  {
     478    return;
     479  }
     480
    464481  TComList<TComPic*>::iterator iterPic   = pcListPic->begin();
    465482  Int numPicsNotYetDisplayed = 0;
     
    647664#endif
    648665{
    649   if(!pcListPic)
     666  if(!pcListPic || pcListPic->empty())
    650667  {
    651668    return;
  • branches/HTM-10.0-dev0/source/App/TAppDecoder/TAppDecTop.h

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/TAppDecoder/decmain.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.cpp

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    444444  ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
    445445  ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
     446#if H_MV 
    446447  // Coding structure parameters
    447 #if H_MV 
    448448  ("IntraPeriod,-ip",         m_iIntraPeriod,std::vector<Int>(1,-1), "Intra period in frames, (-1: only first frame), per layer")
    449449#else
     450  // Coding structure paramters
    450451("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
    451452#endif
     
    492493  ("RDOQTS",                        m_useRDOQTS,                true )
    493494  ("RDpenalty",                     m_rdPenalty,                0,  "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
    494   // Entropy coding parameters
    495   ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
    496495 
    497496  // Deblocking filter parameters
     
    539538  ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")   
    540539  ("SAOLcuBoundary",           m_saoLcuBoundary,            false, "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
    541   ("SAOLcuBasedOptimization",  m_saoLcuBasedOptimization,   true,  "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
    542540  ("SliceMode",                m_sliceMode,                0,     "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
    543541  ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
     
    559557  ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
    560558  ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
    561 
    562   ("LosslessCuEnabled",        m_useLossless, false)
    563559
    564560  ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
     
    590586  ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
    591587  ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
    592 #if RATE_CONTROL_LAMBDA_DOMAIN
    593588  ( "RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control" )
    594589  ( "TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate" )
    595 #if M0036_RC_IMPROVEMENT
    596590  ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit,     0, "Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation" )
    597 #else
    598   ( "KeepHierarchicalBit", m_RCKeepHierarchicalBit, false, "Rate control: keep hierarchical bit allocation in rate control algorithm" )
    599 #endif
    600591  ( "LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC" )
    601592  ( "RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model" )
     
    610601  ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
    611602#endif
    612 #else
    613   ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
    614   ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
    615   ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
    616 
    617 #if KWU_RC_VIEWRC_E0227
    618   ("ViewWiseTargetBits, -vtbr" ,  m_viewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
    619   ("TargetBitAssign, -ta", m_viewWiseRateCtrl, false, "View-wise rate control on/off")
    620 #endif
    621 #if KWU_RC_MADPRED_E0227
    622   ("DepthMADPred, -dm", m_depthMADPred, (UInt)0, "Depth based MAD prediction on/off")
    623 #endif
    624 #endif
    625 
    626603#if H_MV
    627604
     
    653630
    654631  ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
    655   ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false, "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
     632  ("CUTransquantBypassFlagForce", m_CUTransquantBypassFlagForce, false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
    656633  ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
    657634  ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true, "Enable strong intra smoothing for 32x32 blocks")
     
    20211998      m_maxTempLayer = m_GOPList[i].m_temporalId+1;
    20221999    }
    2023     xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P', "Slice type must be equal to B or P");
     2000    xConfirmPara(m_GOPList[i].m_sliceType!='B'&&m_GOPList[i].m_sliceType!='P'&&m_GOPList[i].m_sliceType!='I', "Slice type must be equal to B or P or I");
    20242001  }
    20252002  for(Int i=0; i<MAX_TLAYER; i++)
     
    21722149  }
    21732150
    2174 #if RATE_CONTROL_LAMBDA_DOMAIN
    21752151  if ( m_RCEnableRateControl )
    21762152  {
     
    21852161    xConfirmPara( m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n" );
    21862162  }
    2187 #else
    2188   if(m_enableRateCtrl)
    2189   {
    2190     Int numLCUInWidth  = (m_iSourceWidth  / m_uiMaxCUWidth) + (( m_iSourceWidth  %  m_uiMaxCUWidth ) ? 1 : 0);
    2191     Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight)+ (( m_iSourceHeight %  m_uiMaxCUHeight) ? 1 : 0);
    2192     Int numLCUInPic    =  numLCUInWidth * numLCUInHeight;
    2193 
    2194     xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" );
    2195 
    2196 #if !KWU_FIX_URQ
    2197     m_iMaxDeltaQP       = MAX_DELTA_QP;
    2198 #endif
    2199     m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
    2200   }
    2201 #endif
    22022163#if H_MV
    22032164  // VPS VUI
     
    22232184#endif
    22242185
    2225   xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue, "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
     2186  xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
    22262187
    22272188  xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
     
    23432304  printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC );
    23442305  printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma );
    2345 #if RATE_CONTROL_LAMBDA_DOMAIN
    23462306  printf("RateControl                  : %d\n", m_RCEnableRateControl );
    23472307  if(m_RCEnableRateControl)
     
    23732333#endif
    23742334  }
    2375 #else
    2376   printf("RateControl                  : %d\n", m_enableRateCtrl);
    2377   if(m_enableRateCtrl)
    2378   {
    2379     printf("TargetBitrate                : %d\n", m_targetBitrate);
    2380     printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
    2381 
    2382 #if KWU_RC_MADPRED_E0227
    2383     printf("Depth based MAD prediction   : %d\n", m_depthMADPred);
    2384 #endif
    2385 #if KWU_RC_VIEWRC_E0227
    2386     printf("View-wise Rate control       : %d\n", m_viewWiseRateCtrl);
    2387     if(m_viewWiseRateCtrl)
    2388     {
    2389 
    2390       printf("ViewWiseTargetBits           : ");
    2391       for (Int i = 0 ; i < m_iNumberOfViews ; i++)
    2392         printf("%d ", m_viewTargetBits[i]);
    2393       printf("\n");
    2394     }
    2395     else
    2396     {
    2397       printf("TargetBitrate                : %d\n", m_targetBitrate );
    2398     }
    2399 #endif
    2400   }
    2401 #endif
    24022335  printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
    24032336#if H_3D
     
    24292362  printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
    24302363  printf("HAD:%d ", m_bUseHADME           );
    2431   printf("SRD:%d ", m_bUseSBACRD          );
    24322364  printf("RDQ:%d ", m_useRDOQ            );
    24332365  printf("RDQTS:%d ", m_useRDOQTS        );
     
    24582390#endif
    24592391  printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
    2460   printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization)?(1):(0));
    2461 
    2462   printf("LosslessCuEnabled:%d ", (m_useLossless)? 1:0 );
     2392  if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
     2393  {
     2394    printf("TransQuantBypassEnabled: =1 ");
     2395  }
     2396  else
     2397  {
     2398    printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
     2399  }
    24632400  printf("WPP:%d ", (Int)m_useWeightedPred);
    24642401  printf("WPB:%d ", (Int)m_useWeightedBiPred);
  • branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncCfg.h

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    259259  Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
    260260
    261   // coding tool (lossless)
    262   Bool      m_useLossless;                                    ///< flag for using lossless coding
     261  // coding tool (SAO)
    263262#if H_MV
    264263  std::vector<Bool> m_bUseSAO;
     
    268267  Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
    269268  Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
    270   Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
    271269  // coding tools (loop filter)
    272270#if H_MV
     
    288286
    289287  // coding tools (encoder-only parameters)
    290   Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
    291288  Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
    292289  Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
     
    372369  Int       m_TMVPModeId;
    373370  Int       m_signHideFlag;
    374 #if RATE_CONTROL_LAMBDA_DOMAIN
    375371  Bool      m_RCEnableRateControl;                ///< enable rate control or not
    376372  Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
    377 #if M0036_RC_IMPROVEMENT
    378373  Int       m_RCKeepHierarchicalBit;              ///< 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation
    379 #else
    380   Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
    381 #endif
    382374  Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
    383375  Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
     
    392384  UInt       m_depthMADPred;
    393385#endif
    394 #else
    395   Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
    396   Int       m_targetBitrate;                                 ///< target bitrate
    397   Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
    398 
    399 #if KWU_RC_VIEWRC_E0227
    400   vector<Int>     m_viewTargetBits;
    401   Bool      m_viewWiseRateCtrl;                              ///< Flag for using view-wise rate control
    402 #endif
    403 #if KWU_RC_MADPRED_E0227
    404   UInt       m_depthMADPred;
    405 #endif
    406 #endif
    407386  Int       m_useScalingListId;                               ///< using quantization matrix
    408387  Char*     m_scalingListFile;                                ///< quantization matrix file name
    409388
    410389  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
    411   Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
     390  Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
    412391
    413392  Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
  • branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncTop.cpp

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    309309#endif
    310310
    311   Int lowestQP;
    312   lowestQP =  - 6*(g_bitDepthY - 8); // XXX: check
    313 
    314 #if H_MV
    315   if ((m_iMaxDeltaQP == 0 ) && (m_iQP[layerIdInVps] == lowestQP) && (m_useLossless == true))
    316 #else
    317   if ((m_iMaxDeltaQP == 0 ) && (m_iQP == lowestQP) && (m_useLossless == true))
    318 #endif
    319   {
    320     m_bUseAdaptiveQP = false;
    321   }
    322311  m_cTEncTop.setUseAdaptiveQP                ( m_bUseAdaptiveQP  );
    323312  m_cTEncTop.setQPAdaptationRange            ( m_iQPAdaptationRange );
    324313 
    325314  //====== Tool list ========
    326   m_cTEncTop.setUseSBACRD                    ( m_bUseSBACRD   );
    327315  m_cTEncTop.setDeltaQpRD                    ( m_uiDeltaQpRD  );
    328316  m_cTEncTop.setUseASR                       ( m_bUseASR      );
    329317  m_cTEncTop.setUseHADME                     ( m_bUseHADME    );
    330   m_cTEncTop.setUseLossless                  ( m_useLossless );
    331318#if H_MV
    332319  m_cTEncTop.setdQPs                         ( m_aidQP[layerIdInVps]   );
     
    396383
    397384  m_cTEncTop.setSaoLcuBoundary (m_saoLcuBoundary);
    398   m_cTEncTop.setSaoLcuBasedOptimization (m_saoLcuBasedOptimization);
    399385  m_cTEncTop.setPCMInputBitDepthFlag  ( m_bPCMInputBitDepthFlag);
    400386  m_cTEncTop.setPCMFilterDisableFlag  ( m_bPCMFilterDisableFlag);
     
    461447  m_cTEncTop.setScalingListFile            ( m_scalingListFile   );
    462448  m_cTEncTop.setSignHideFlag(m_signHideFlag);
    463 #if RATE_CONTROL_LAMBDA_DOMAIN
    464449#if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
    465450  if(!m_cTEncTop.getIsDepth())    //only for texture
     
    482467  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
    483468  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
    484 
    485469#if KWU_RC_MADPRED_E0227
    486470  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    487471  {
    488472    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
    489 
    490473    if(m_cTEncTop.getUseDepthMADPred())
    491474    {
     
    498481  {
    499482    m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
    500 
    501483    if(m_iNumberOfViews == 1)
    502484    {
     
    552534  }
    553535#endif
    554 #else
    555 #if KWU_RC_VIEWRC_E0227 || KWU_RC_MADPRED_E0227
    556   if(!m_cTEncTop.getIsDepth())    //only for texture
    557   {
    558     m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
    559     m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
    560     m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
    561   }
    562   else
    563   {
    564     m_cTEncTop.setUseRateCtrl         ( 0 );
    565   }
    566 #else
    567   m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
    568   m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
    569   m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
    570 #endif
    571 
    572  
    573 #if KWU_RC_MADPRED_E0227
    574   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    575   {
    576     m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_depthMADPred       : 0);
    577 
    578     if(m_cTEncTop.getUseDepthMADPred())
    579     {
    580       m_cTEncTop.setCamParam(&m_cCameraData);
    581     }
    582   }
    583 #endif
    584 
    585 #if KWU_RC_VIEWRC_E0227
    586   if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
    587   {
    588     m_cTEncTop.setUseViewWiseRateCtrl(m_viewWiseRateCtrl);
    589     if(m_iNumberOfViews == 1)
    590     {
    591       if(m_viewWiseRateCtrl)
    592       {
    593         m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
    594       }
    595       else
    596       {
    597         m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
    598       }
    599     }
    600     else
    601     {
    602       if(m_viewWiseRateCtrl)
    603       {
    604         m_cTEncTop.setTargetBitrate(m_viewTargetBits[layerIdInVps>>1]);
    605       }
    606       else
    607       {
    608         if(m_iNumberOfViews == 2)
    609         {
    610           if(m_cTEncTop.getViewId() == 0)
    611           {
    612             m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*80)/100 );
    613           }
    614           else if(m_cTEncTop.getViewId() == 1)
    615           {
    616             m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*20)/100 );
    617           }
    618         }
    619         else if(m_iNumberOfViews == 3)
    620         {
    621           if(m_cTEncTop.getViewId() == 0)
    622           {
    623             m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*66)/100 );
    624           }
    625           else if(m_cTEncTop.getViewId() == 1)
    626           {
    627             m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
    628           }
    629           else if(m_cTEncTop.getViewId() == 2)
    630           {
    631             m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
    632           }
    633         }
    634         else
    635         {
    636           m_cTEncTop.setTargetBitrate              ( m_targetBitrate );
    637         }
    638       }
    639     }
    640   }
    641 #endif
    642 #endif
    643536  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
    644   m_cTEncTop.setCUTransquantBypassFlagValue(m_CUTransquantBypassFlagValue);
     537  m_cTEncTop.setCUTransquantBypassFlagForceValue(m_CUTransquantBypassFlagForce);
    645538  m_cTEncTop.setUseRecalculateQPAccordingToLambda( m_recalculateQPAccordingToLambda );
    646539  m_cTEncTop.setUseStrongIntraSmoothing( m_useStrongIntraSmoothing );
     
    932825    }
    933826
    934 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ
    935     for(Int layer=0; layer < m_numberOfLayers; layer++ )
    936     {
    937       if(m_acTEncTopList[layer]->getUseRateCtrl()  && !m_acTEncTopList[layer]->getIsDepth())
    938       {
    939         m_acTEncTopList[layer]->getRateCtrl()->updateRCGOPStatus();
    940       }
    941     }
    942 #endif
    943 
    944827    gopSize = maxGopSize;
    945828  }
     
    12031086      rateStatsAccum(au, stats);   
    12041087    }
    1205 #endif   
     1088#endif
    12061089  }
    12071090}
     
    12211104    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    12221105    case NAL_UNIT_CODED_SLICE_TRAIL_N:
    1223     case NAL_UNIT_CODED_SLICE_TLA_R:
     1106    case NAL_UNIT_CODED_SLICE_TSA_R:
    12241107    case NAL_UNIT_CODED_SLICE_TSA_N:
    12251108    case NAL_UNIT_CODED_SLICE_STSA_R:
     
    19631846}
    19641847#endif
    1965 
    19661848//! \}
  • branches/HTM-10.0-dev0/source/App/TAppEncoder/TAppEncTop.h

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/TAppEncoder/encmain.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/ExtractBitrates.cpp

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/ExtractBitrates.h

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/ExtractBitratesMain.cpp

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/GuessLambdaModifiers.cpp

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/GuessLambdaModifiers.h

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/GuessLambdaModifiersMain.cpp

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/RuntimeError.h

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/encode.shl

    r56 r852  
    44# granted under this license. 
    55#
    6 # Copyright (c) 2010-2012, ITU/ISO/IEC
     6# Copyright (c) 2010-2014, ITU/ISO/IEC
    77# All rights reserved.
    88#
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/encodeCommand.sh

    r56 r852  
    66# granted under this license. 
    77#
    8 # Copyright (c) 2010-2012, ITU/ISO/IEC
     8# Copyright (c) 2010-2014, ITU/ISO/IEC
    99# All rights reserved.
    1010#
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/makefile

    r56 r852  
    44# granted under this license. 
    55#
    6 # Copyright (c) 2010-2012, ITU/ISO/IEC
     6# Copyright (c) 2010-2014, ITU/ISO/IEC
    77# All rights reserved.
    88#
  • branches/HTM-10.0-dev0/source/App/utils/BitrateTargeting/targetBitrates.sh

    r56 r852  
    66# granted under this license. 
    77#
    8 # Copyright (c) 2010-2012, ITU/ISO/IEC
     8# Copyright (c) 2010-2014, ITU/ISO/IEC
    99# All rights reserved.
    1010#
  • branches/HTM-10.0-dev0/source/App/utils/annexBbytecount.cpp

    r56 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/App/utils/convert_NtoMbit_YCbCr.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TAppCommon/program_options_lite.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3838#include <list>
    3939#include <map>
     40#include <algorithm>
    4041#include "program_options_lite.h"
    4142#include  "../TLibCommon/TypeDef.h"
  • branches/HTM-10.0-dev0/source/Lib/TAppCommon/program_options_lite.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/AccessUnit.h

    r608 r852  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/CommonDef.h

    r849 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6161#if H_MV
    6262#define NV_VERSION        "10.0"                ///< Current software version
    63 #define HM_VERSION        "12.0"                ///<
     63#define HM_VERSION        "13.0"                ///<
    6464#else
    65 #define NV_VERSION        "12.0"                 ///< Current software version
     65#define NV_VERSION        "13.0"                 ///< Current software version
    6666#endif
    6767
     
    247247 
    248248  NAL_UNIT_CODED_SLICE_TSA_N,     // 2
    249   NAL_UNIT_CODED_SLICE_TLA_R,       // 3
     249  NAL_UNIT_CODED_SLICE_TSA_R,       // 3
    250250 
    251251  NAL_UNIT_CODED_SLICE_STSA_N,    // 4
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel3DBuffer.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextModel3DBuffer.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextTables.h

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4242//! \ingroup TLibCommon
    4343//! \{
    44 #define FIX827 1 ///< Fix for issue #827: CABAC init tables
    45 #define FIX712 1 ///< Fix for issue #712: CABAC init tables
    4644
    4745// ====================================================================================================================
     
    5856
    5957#define NUM_PART_SIZE_CTX             4       ///< number of context models for partition size
    60 #define NUM_CU_AMP_CTX                1       ///< number of context models for partition size (AMP)
    6158#define NUM_PRED_MODE_CTX             1       ///< number of context models for prediction mode
    6259
     
    6966#define NUM_REF_NO_CTX                2       ///< number of context models for reference index
    7067#define NUM_TRANS_SUBDIV_FLAG_CTX     3       ///< number of context models for transform subdivision flags
    71 #define NUM_QT_CBF_CTX                5       ///< number of context models for QT CBF
     68#define NUM_QT_CBF_CTX                4       ///< number of context models for QT CBF
    7269#define NUM_QT_ROOT_CBF_CTX           1       ///< number of context models for QT ROOT CBF
    7370#define NUM_DELTA_QP_CTX              3       ///< number of context models for dQP
     
    8885#define NUM_ABS_FLAG_CTX_CHROMA        2      ///< number of context models for greater than 2 flag of chroma
    8986
    90 #define NUM_MVP_IDX_CTX               2       ///< number of context models for MVP index
     87#define NUM_MVP_IDX_CTX               1       ///< number of context models for MVP index
    9188
    9289#define NUM_SAO_MERGE_FLAG_CTX        1       ///< number of context models for SAO merge flags
     
    199196INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 
    200197{
    201   { 154,  139,  CNU,  CNU, },
    202   { 154,  139,  CNU,  CNU, },
    203   { 184,  CNU,  CNU,  CNU, },
    204 };
    205 
    206 static const UChar
    207 INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = 
    208 {
    209   { 154, },
    210   { 154, },
    211   { CNU, },
     198  { 154,  139,  154,  154 },
     199  { 154,  139,  154,  154 },
     200  { 184,  CNU,  CNU,  CNU },
    212201};
    213202
     
    271260INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 
    272261{
    273   { 153,  111,  CNU,  CNU,  CNU,  149,   92,  167,  CNU,  CNU, },
    274   { 153,  111,  CNU,  CNU,  CNU,  149,  107,  167,  CNU,  CNU, },
    275   { 111,  141,  CNU,  CNU,  CNU,   94,  138,  182,  CNU,  CNU, },
     262  { 153,  111,  CNU,  CNU,   149,   92,  167,  154 },
     263  { 153,  111,  CNU,  CNU,   149,  107,  167,  154 },
     264  { 111,  141,  CNU,  CNU,    94,  138,  182,  154 },
    276265};
    277266
     
    339328INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 
    340329{
    341   { 168,  CNU, },
    342   { 168,  CNU, },
    343   { CNU,  CNU, },
     330  { 168 },
     331  { 168 },
     332  { CNU },
    344333};
    345334
     
    355344INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] =
    356345{
    357 #if FIX827
    358346  { 160, },
    359347  { 185, },
    360348  { 200, },
    361 #else
    362   { 200, },
    363   { 185, },
    364   { 160, },
    365 #endif
    366349};
    367350
     
    369352INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] =
    370353{
    371 #if FIX712
    372354  { 224,  167,  122, },
    373355  { 124,  138,   94, },
    374356  { 153,  138,  138, },
    375 #else
    376   { 153,  138,  138, },
    377   { 124,  138,   94, },
    378   { 224,  167,  122, },
    379 #endif
    380357};
    381358
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/NAL.h

    r608 r852  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7979    return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R
    8080        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N
    81         || m_nalUnitType == NAL_UNIT_CODED_SLICE_TLA_R
     81        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R
    8282        || m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N
    8383        || m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/SEI.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/SEI.h

    r608 r852  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComBitCounter.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComBitStream.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComBitStream.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComCABACTables.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComCABACTables.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    488488}
    489489
    490 const NDBFBlockInfo& NDBFBlockInfo::operator= (const NDBFBlockInfo& src)
    491 {
    492   this->tileID = src.tileID;
    493   this->sliceID= src.sliceID;
    494   this->startSU= src.startSU;
    495   this->endSU  = src.endSU;
    496   this->widthSU= src.widthSU;
    497   this->heightSU=src.heightSU;
    498   this->posX   = src.posX;
    499   this->posY   = src.posY;
    500   this->width  = src.width;
    501   this->height = src.height;
    502   ::memcpy(this->isBorderAvailable, src.isBorderAvailable, sizeof(Bool)*((Int)NUM_SGU_BORDER));
    503   this->allBordersAvailable = src.allBordersAvailable;
    504 
    505   return *this;
    506 }
    507 
    508 
    509490// ====================================================================================================================
    510491// Public member functions
     
    801782*- set last-coded qp value according to input last-coded qp
    802783*/
    803 Void TComDataCU::initEstData( UInt uiDepth, Int qp )
     784Void TComDataCU::initEstData( UInt uiDepth, Int qp, Bool bTransquantBypass )
    804785{
    805786  m_dTotalCost         = MAX_DOUBLE;
     
    829810      m_pePartSize[ui] = SIZE_NONE;
    830811      m_pePredMode[ui] = MODE_NONE;
    831       m_CUTransquantBypass[ui] = false;
     812      m_CUTransquantBypass[ui] = bTransquantBypass;
    832813      m_pbIPCMFlag[ui] = 0;
    833814      m_phQP[ui] = qp;
     
    59805961    xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
    59815962  }
    5982   bAdded = bAddedSmvp;
    5983   if (pInfo->iN==2) bAdded = true;
    5984 
    5985   if(!bAdded)
     5963
     5964  if (!bAddedSmvp)
    59865965  {
    59875966    bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
     
    66416620{
    66426621  return getPic()->getPicSym()->getInverseCUOrderMap(m_uiCUAddr)*(1<<(m_pcSlice->getSPS()->getMaxCUDepth()<<1))+m_uiAbsIdxInLCU;
    6643 }
    6644 
    6645 /** Set neighboring blocks availabilities for non-deblocked filtering
    6646  * \param numLCUInPicWidth number of LCUs in picture width
    6647  * \param numLCUInPicHeight number of LCUs in picture height
    6648  * \param numSUInLCUWidth number of SUs in LCU width
    6649  * \param numSUInLCUHeight number of SUs in LCU height
    6650  * \param picWidth picture width
    6651  * \param picHeight picture height
    6652  * \param bIndependentSliceBoundaryEnabled true for independent slice boundary enabled
    6653  * \param bTopTileBoundary true means that top boundary coincides tile boundary
    6654  * \param bDownTileBoundary true means that bottom boundary coincides tile boundary
    6655  * \param bLeftTileBoundary true means that left boundary coincides tile boundary
    6656  * \param bRightTileBoundary true means that right boundary coincides tile boundary
    6657  * \param bIndependentTileBoundaryEnabled true for independent tile boundary enabled
    6658  */
    6659 Void TComDataCU::setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt /*numLCUInPicHeight*/, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
    6660                                                     ,std::vector<Bool>& LFCrossSliceBoundary
    6661                                                     ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    6662                                                     ,Bool bIndependentTileBoundaryEnabled)
    6663 {
    6664   UInt numSUInLCU = numSUInLCUWidth*numSUInLCUHeight;
    6665   Int* pSliceIDMapLCU = m_piSliceSUMap;
    6666   Bool onlyOneSliceInPic = ((Int)LFCrossSliceBoundary.size() == 1);
    6667   UInt uiLPelX, uiTPelY;
    6668   UInt width, height;
    6669   Bool bPicRBoundary, bPicBBoundary, bPicTBoundary, bPicLBoundary;
    6670   Bool bLCURBoundary= false, bLCUBBoundary= false, bLCUTBoundary= false, bLCULBoundary= false;
    6671   Bool* pbAvailBorder;
    6672   Bool* pbAvail;
    6673   UInt rTLSU, rBRSU, widthSU, heightSU;
    6674   UInt zRefSU;
    6675   Int* pRefID;
    6676   Int* pRefMapLCU;
    6677   UInt rTRefSU= 0, rBRefSU= 0, rLRefSU= 0, rRRefSU= 0;
    6678   Int* pRRefMapLCU= NULL;
    6679   Int* pLRefMapLCU= NULL;
    6680   Int* pTRefMapLCU= NULL;
    6681   Int* pBRefMapLCU= NULL;
    6682   Int  sliceID;
    6683   UInt numSGU = (UInt)m_vNDFBlock.size();
    6684 
    6685   for(Int i=0; i< numSGU; i++)
    6686   {
    6687     NDBFBlockInfo& rSGU = m_vNDFBlock[i];
    6688 
    6689     sliceID = rSGU.sliceID;
    6690     uiLPelX = rSGU.posX;
    6691     uiTPelY = rSGU.posY;
    6692     width   = rSGU.width;
    6693     height  = rSGU.height;
    6694     rTLSU     = g_auiZscanToRaster[ rSGU.startSU ];
    6695     rBRSU     = g_auiZscanToRaster[ rSGU.endSU   ];
    6696     widthSU   = rSGU.widthSU;
    6697     heightSU  = rSGU.heightSU;
    6698 
    6699     pbAvailBorder = rSGU.isBorderAvailable;
    6700 
    6701     bPicTBoundary= (uiTPelY == 0                       )?(true):(false);
    6702     bPicLBoundary= (uiLPelX == 0                       )?(true):(false);
    6703     bPicRBoundary= (!(uiLPelX+ width < picWidth )  )?(true):(false);
    6704     bPicBBoundary= (!(uiTPelY + height < picHeight))?(true):(false);
    6705 
    6706     bLCULBoundary = (rTLSU % numSUInLCUWidth == 0)?(true):(false);
    6707     bLCURBoundary = ( (rTLSU+ widthSU) % numSUInLCUWidth == 0)?(true):(false);
    6708     bLCUTBoundary = ( (UInt)(rTLSU / numSUInLCUWidth)== 0)?(true):(false);
    6709     bLCUBBoundary = ( (UInt)(rBRSU / numSUInLCUWidth) == (numSUInLCUHeight-1) )?(true):(false);
    6710 
    6711     //       SGU_L
    6712     pbAvail = &(pbAvailBorder[SGU_L]);
    6713     if(bPicLBoundary)
    6714     {
    6715       *pbAvail = false;
    6716     }
    6717     else if (onlyOneSliceInPic)
    6718     {
    6719       *pbAvail = true;
    6720     }
    6721     else
    6722     {
    6723       //      bLCULBoundary = (rTLSU % uiNumSUInLCUWidth == 0)?(true):(false);
    6724       if(bLCULBoundary)
    6725       {
    6726         rLRefSU     = rTLSU + numSUInLCUWidth -1;
    6727         zRefSU      = g_auiRasterToZscan[rLRefSU];
    6728         pRefMapLCU = pLRefMapLCU= (pSliceIDMapLCU - numSUInLCU);
    6729       }
    6730       else
    6731       {
    6732         zRefSU   = g_auiRasterToZscan[rTLSU - 1];
    6733         pRefMapLCU  = pSliceIDMapLCU;
    6734       }
    6735       pRefID = pRefMapLCU + zRefSU;
    6736       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6737     }
    6738 
    6739     //       SGU_R
    6740     pbAvail = &(pbAvailBorder[SGU_R]);
    6741     if(bPicRBoundary)
    6742     {
    6743       *pbAvail = false;
    6744     }
    6745     else if (onlyOneSliceInPic)
    6746     {
    6747       *pbAvail = true;
    6748     }
    6749     else
    6750     {
    6751       //       bLCURBoundary = ( (rTLSU+ uiWidthSU) % uiNumSUInLCUWidth == 0)?(true):(false);
    6752       if(bLCURBoundary)
    6753       {
    6754         rRRefSU      = rTLSU + widthSU - numSUInLCUWidth;
    6755         zRefSU       = g_auiRasterToZscan[rRRefSU];
    6756         pRefMapLCU  = pRRefMapLCU= (pSliceIDMapLCU + numSUInLCU);
    6757       }
    6758       else
    6759       {
    6760         zRefSU       = g_auiRasterToZscan[rTLSU + widthSU];
    6761         pRefMapLCU  = pSliceIDMapLCU;
    6762       }
    6763       pRefID = pRefMapLCU + zRefSU;
    6764       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6765     }
    6766 
    6767     //       SGU_T
    6768     pbAvail = &(pbAvailBorder[SGU_T]);
    6769     if(bPicTBoundary)
    6770     {
    6771       *pbAvail = false;
    6772     }
    6773     else if (onlyOneSliceInPic)
    6774     {
    6775       *pbAvail = true;
    6776     }
    6777     else
    6778     {
    6779       //      bLCUTBoundary = ( (UInt)(rTLSU / uiNumSUInLCUWidth)== 0)?(true):(false);
    6780       if(bLCUTBoundary)
    6781       {
    6782         rTRefSU      = numSUInLCU - (numSUInLCUWidth - rTLSU);
    6783         zRefSU       = g_auiRasterToZscan[rTRefSU];
    6784         pRefMapLCU  = pTRefMapLCU= (pSliceIDMapLCU - (numLCUInPicWidth*numSUInLCU));
    6785       }
    6786       else
    6787       {
    6788         zRefSU       = g_auiRasterToZscan[rTLSU - numSUInLCUWidth];
    6789         pRefMapLCU  = pSliceIDMapLCU;
    6790       }
    6791       pRefID = pRefMapLCU + zRefSU;
    6792       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6793     }
    6794 
    6795     //       SGU_B
    6796     pbAvail = &(pbAvailBorder[SGU_B]);
    6797     if(bPicBBoundary)
    6798     {
    6799       *pbAvail = false;
    6800     }
    6801     else if (onlyOneSliceInPic)
    6802     {
    6803       *pbAvail = true;
    6804     }
    6805     else
    6806     {
    6807       //      bLCUBBoundary = ( (UInt)(rBRSU / uiNumSUInLCUWidth) == (uiNumSUInLCUHeight-1) )?(true):(false);
    6808       if(bLCUBBoundary)
    6809       {
    6810         rBRefSU      = rTLSU % numSUInLCUWidth;
    6811         zRefSU       = g_auiRasterToZscan[rBRefSU];
    6812         pRefMapLCU  = pBRefMapLCU= (pSliceIDMapLCU + (numLCUInPicWidth*numSUInLCU));
    6813       }
    6814       else
    6815       {
    6816         zRefSU       = g_auiRasterToZscan[rTLSU + (heightSU*numSUInLCUWidth)];
    6817         pRefMapLCU  = pSliceIDMapLCU;
    6818       }
    6819       pRefID = pRefMapLCU + zRefSU;
    6820       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6821     }
    6822 
    6823     //       SGU_TL
    6824     pbAvail = &(pbAvailBorder[SGU_TL]);
    6825     if(bPicTBoundary || bPicLBoundary)
    6826     {
    6827       *pbAvail = false;
    6828     }
    6829     else if (onlyOneSliceInPic)
    6830     {
    6831       *pbAvail = true;
    6832     }
    6833     else
    6834     {
    6835       if(bLCUTBoundary && bLCULBoundary)
    6836       {
    6837         zRefSU       = numSUInLCU -1;
    6838         pRefMapLCU  = pSliceIDMapLCU - ( (numLCUInPicWidth+1)*numSUInLCU);
    6839       }
    6840       else if(bLCUTBoundary)
    6841       {
    6842         zRefSU       = g_auiRasterToZscan[ rTRefSU- 1];
    6843         pRefMapLCU  = pTRefMapLCU;
    6844       }
    6845       else if(bLCULBoundary)
    6846       {
    6847         zRefSU       = g_auiRasterToZscan[ rLRefSU- numSUInLCUWidth ];
    6848         pRefMapLCU  = pLRefMapLCU;
    6849       }
    6850       else //inside LCU
    6851       {
    6852         zRefSU       = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth -1];
    6853         pRefMapLCU  = pSliceIDMapLCU;
    6854       }
    6855       pRefID = pRefMapLCU + zRefSU;
    6856       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6857     }
    6858 
    6859     //       SGU_TR
    6860     pbAvail = &(pbAvailBorder[SGU_TR]);
    6861     if(bPicTBoundary || bPicRBoundary)
    6862     {
    6863       *pbAvail = false;
    6864     }
    6865     else if (onlyOneSliceInPic)
    6866     {
    6867       *pbAvail = true;
    6868     }
    6869     else
    6870     {
    6871       if(bLCUTBoundary && bLCURBoundary)
    6872       {
    6873         zRefSU      = g_auiRasterToZscan[numSUInLCU - numSUInLCUWidth];
    6874         pRefMapLCU  = pSliceIDMapLCU - ( (numLCUInPicWidth-1)*numSUInLCU);       
    6875       }
    6876       else if(bLCUTBoundary)
    6877       {
    6878         zRefSU       = g_auiRasterToZscan[ rTRefSU+ widthSU];
    6879         pRefMapLCU  = pTRefMapLCU;
    6880       }
    6881       else if(bLCURBoundary)
    6882       {
    6883         zRefSU       = g_auiRasterToZscan[ rRRefSU- numSUInLCUWidth ];
    6884         pRefMapLCU  = pRRefMapLCU;
    6885       }
    6886       else //inside LCU
    6887       {
    6888         zRefSU       = g_auiRasterToZscan[ rTLSU - numSUInLCUWidth +widthSU];
    6889         pRefMapLCU  = pSliceIDMapLCU;
    6890       }
    6891       pRefID = pRefMapLCU + zRefSU;
    6892       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6893     }
    6894 
    6895     //       SGU_BL
    6896     pbAvail = &(pbAvailBorder[SGU_BL]);
    6897     if(bPicBBoundary || bPicLBoundary)
    6898     {
    6899       *pbAvail = false;
    6900     }
    6901     else if (onlyOneSliceInPic)
    6902     {
    6903       *pbAvail = true;
    6904     }
    6905     else
    6906     {
    6907       if(bLCUBBoundary && bLCULBoundary)
    6908       {
    6909         zRefSU      = g_auiRasterToZscan[numSUInLCUWidth - 1];
    6910         pRefMapLCU  = pSliceIDMapLCU + ( (numLCUInPicWidth-1)*numSUInLCU);       
    6911       }
    6912       else if(bLCUBBoundary)
    6913       {
    6914         zRefSU       = g_auiRasterToZscan[ rBRefSU - 1];
    6915         pRefMapLCU  = pBRefMapLCU;
    6916       }
    6917       else if(bLCULBoundary)
    6918       {
    6919         zRefSU       = g_auiRasterToZscan[ rLRefSU+ heightSU*numSUInLCUWidth ];
    6920         pRefMapLCU  = pLRefMapLCU;
    6921       }
    6922       else //inside LCU
    6923       {
    6924         zRefSU       = g_auiRasterToZscan[ rTLSU + heightSU*numSUInLCUWidth -1];
    6925         pRefMapLCU  = pSliceIDMapLCU;
    6926       }
    6927       pRefID = pRefMapLCU + zRefSU;
    6928       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6929     }
    6930 
    6931     //       SGU_BR
    6932     pbAvail = &(pbAvailBorder[SGU_BR]);
    6933     if(bPicBBoundary || bPicRBoundary)
    6934     {
    6935       *pbAvail = false;
    6936     }
    6937     else if (onlyOneSliceInPic)
    6938     {
    6939       *pbAvail = true;
    6940     }
    6941     else
    6942     {
    6943       if(bLCUBBoundary && bLCURBoundary)
    6944       {
    6945         zRefSU = 0;
    6946         pRefMapLCU = pSliceIDMapLCU+ ( (numLCUInPicWidth+1)*numSUInLCU);
    6947       }
    6948       else if(bLCUBBoundary)
    6949       {
    6950         zRefSU      = g_auiRasterToZscan[ rBRefSU + widthSU];
    6951         pRefMapLCU = pBRefMapLCU;
    6952       }
    6953       else if(bLCURBoundary)
    6954       {
    6955         zRefSU      = g_auiRasterToZscan[ rRRefSU + (heightSU*numSUInLCUWidth)];
    6956         pRefMapLCU = pRRefMapLCU;
    6957       }
    6958       else //inside LCU
    6959       {
    6960         zRefSU      = g_auiRasterToZscan[ rTLSU + (heightSU*numSUInLCUWidth)+ widthSU];
    6961         pRefMapLCU = pSliceIDMapLCU;
    6962       }
    6963       pRefID = pRefMapLCU + zRefSU;
    6964       *pbAvail = (*pRefID == sliceID)?(true):((*pRefID > sliceID)?(LFCrossSliceBoundary[*pRefID]):(LFCrossSliceBoundary[sliceID]));
    6965     }
    6966 
    6967     if(bIndependentTileBoundaryEnabled)
    6968     {
    6969       //left LCU boundary
    6970       if(!bPicLBoundary && bLCULBoundary)
    6971       {
    6972         if(bLeftTileBoundary)
    6973         {
    6974           pbAvailBorder[SGU_L] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_BL] = false;
    6975         }
    6976       }
    6977       //right LCU boundary
    6978       if(!bPicRBoundary && bLCURBoundary)
    6979       {
    6980         if(bRightTileBoundary)
    6981         {
    6982           pbAvailBorder[SGU_R] = pbAvailBorder[SGU_TR] = pbAvailBorder[SGU_BR] = false;
    6983         }
    6984       }
    6985       //top LCU boundary
    6986       if(!bPicTBoundary && bLCUTBoundary)
    6987       {
    6988         if(bTopTileBoundary)
    6989         {
    6990           pbAvailBorder[SGU_T] = pbAvailBorder[SGU_TL] = pbAvailBorder[SGU_TR] = false;
    6991         }
    6992       }
    6993       //down LCU boundary
    6994       if(!bPicBBoundary && bLCUBBoundary)
    6995       {
    6996         if(bDownTileBoundary)
    6997         {
    6998           pbAvailBorder[SGU_B] = pbAvailBorder[SGU_BL] = pbAvailBorder[SGU_BR] = false;
    6999         }
    7000       }
    7001     }
    7002     rSGU.allBordersAvailable = true;
    7003     for(Int b=0; b< NUM_SGU_BORDER; b++)
    7004     {
    7005       if(pbAvailBorder[b] == false)
    7006       {
    7007         rSGU.allBordersAvailable = false;
    7008         break;
    7009       }
    7010     }
    7011   }
    70126622}
    70136623
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComDataCU.h

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5959//! \{
    6060
    61 // ====================================================================================================================
    62 // Non-deblocking in-loop filter processing block data structure
    63 // ====================================================================================================================
    64 
    65 /// Non-deblocking filter processing block border tag
    66 enum NDBFBlockBorderTag
    67 {
    68   SGU_L = 0,
    69   SGU_R,
    70   SGU_T,
    71   SGU_B,
    72   SGU_TL,
    73   SGU_TR,
    74   SGU_BL,
    75   SGU_BR,
    76   NUM_SGU_BORDER
    77 };
    78 
    79 /// Non-deblocking filter processing block information
    80 struct NDBFBlockInfo
    81 {
    82   Int   tileID;   //!< tile ID
    83   Int   sliceID;  //!< slice ID
    84   UInt  startSU;  //!< starting SU z-scan address in LCU
    85   UInt  endSU;    //!< ending SU z-scan address in LCU
    86   UInt  widthSU;  //!< number of SUs in width
    87   UInt  heightSU; //!< number of SUs in height
    88   UInt  posX;     //!< top-left X coordinate in picture
    89   UInt  posY;     //!< top-left Y coordinate in picture
    90   UInt  width;    //!< number of pixels in width
    91   UInt  height;   //!< number of pixels in height
    92   Bool  isBorderAvailable[NUM_SGU_BORDER];  //!< the border availabilities
    93   Bool  allBordersAvailable;
    94 
    95   NDBFBlockInfo():tileID(0), sliceID(0), startSU(0), endSU(0) {} //!< constructor
    96   const NDBFBlockInfo& operator= (const NDBFBlockInfo& src);  //!< "=" operator
    97 };
    9861
    9962#if H_3D_DBBP
     
    176139  Pel*          m_pcIPCMSampleCr;     ///< PCM sample buffer (Cr)
    177140
    178   Int*          m_piSliceSUMap;       ///< pointer of slice ID map
    179   std::vector<NDBFBlockInfo> m_vNDFBlock;
    180 
    181141  // -------------------------------------------------------------------------------------------------------------------
    182142  // neighbour access variables
     
    342302 
    343303  Void          initCU                ( TComPic* pcPic, UInt uiCUAddr );
    344   Void          initEstData           ( UInt uiDepth, Int qp );
     304  Void          initEstData           ( UInt uiDepth, Int qp, Bool bTransquantBypass );
    345305  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
    346306  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
     
    522482  DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
    523483#endif
    524   /// get slice ID for SU
    525   Int           getSUSliceID          (UInt uiIdx)              {return m_piSliceSUMap[uiIdx];      }
    526 
    527   /// get the pointer of slice ID map
    528   Int*          getSliceSUMap         ()                        {return m_piSliceSUMap;             }
    529 
    530   /// set the pointer of slice ID map
    531   Void          setSliceSUMap         (Int *pi)                 {m_piSliceSUMap = pi;               }
    532 
    533   std::vector<NDBFBlockInfo>* getNDBFilterBlocks()      {return &m_vNDFBlock;}
    534   Void setNDBFilterBlockBorderAvailability(UInt numLCUInPicWidth, UInt numLCUInPicHeight, UInt numSUInLCUWidth, UInt numSUInLCUHeight, UInt picWidth, UInt picHeight
    535                                           ,std::vector<Bool>& LFCrossSliceBoundary
    536                                           ,Bool bTopTileBoundary, Bool bDownTileBoundary, Bool bLeftTileBoundary, Bool bRightTileBoundary
    537                                           ,Bool bIndependentTileBoundaryEnabled );
    538484#if H_3D_NBDV
    539485  Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComList.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComLoopFilter.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComLoopFilter.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComMotionInfo.h

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComMv.h

    r655 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPattern.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPattern.h

    r655 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPic.cpp

    r738 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5656, m_bNeededForOutput                      (false)
    5757, m_uiCurrSliceIdx                        (0)
    58 , m_pSliceSUMap                           (NULL)
    59 , m_pbValidSlice                          (NULL)
    60 , m_sliceGranularityForNDBFilter          (0)
    61 , m_bIndependentSliceBoundaryForNDBFilter (false)
    62 , m_bIndependentTileBoundaryForNDBFilter  (false)
    63 , m_pNDBFilterYuvTmp                      (NULL)
    6458, m_bCheckLTMSB                           (false)
    6559#if H_MV
     
    117111  memcpy(m_numReorderPics, numReorderPics, MAX_TLAYER*sizeof(Int));
    118112
    119   /* initialize the texture to depth reference status */
    120113#if H_3D_FCO
     114/* initialize the texture to depth reference status */
    121115  for (int j=0; j<2; j++)
    122116  {
     
    174168}
    175169
    176 /** Create non-deblocked filter information
    177  * \param pSliceStartAddress array for storing slice start addresses
    178  * \param numSlices number of slices in picture
    179  * \param sliceGranularityDepth slice granularity
    180  * \param bNDBFilterCrossSliceBoundary cross-slice-boundary in-loop filtering; true for "cross".
    181  * \param numTiles number of tiles in picture
    182  * \param bNDBFilterCrossTileBoundary cross-tile-boundary in-loop filtering; true for "cross".
    183  */
    184 Void TComPic::createNonDBFilterInfo(std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
    185                                     ,std::vector<Bool>* LFCrossSliceBoundary
    186                                     ,Int numTiles
    187                                     ,Bool bNDBFilterCrossTileBoundary)
    188 {
    189   UInt maxNumSUInLCU = getNumPartInCU();
    190   UInt numLCUInPic   = getNumCUsInFrame();
    191   UInt picWidth      = getSlice(0)->getSPS()->getPicWidthInLumaSamples();
    192   UInt picHeight     = getSlice(0)->getSPS()->getPicHeightInLumaSamples();
    193   Int  numLCUsInPicWidth = getFrameWidthInCU();
    194   Int  numLCUsInPicHeight= getFrameHeightInCU();
    195   UInt maxNumSUInLCUWidth = getNumPartInWidth();
    196   UInt maxNumSUInLCUHeight= getNumPartInHeight();
    197   Int  numSlices = (Int) sliceStartAddress.size() - 1;
    198   m_bIndependentSliceBoundaryForNDBFilter = false;
    199   if(numSlices > 1)
    200   {
    201     for(Int s=0; s< numSlices; s++)
    202     {
    203       if((*LFCrossSliceBoundary)[s] == false)
    204       {
    205         m_bIndependentSliceBoundaryForNDBFilter = true;
    206       }
    207     }
    208   }
    209   m_sliceGranularityForNDBFilter = sliceGranularityDepth;
    210   m_bIndependentTileBoundaryForNDBFilter  = (bNDBFilterCrossTileBoundary)?(false) :((numTiles > 1)?(true):(false));
    211 
    212   m_pbValidSlice = new Bool[numSlices];
    213   for(Int s=0; s< numSlices; s++)
    214   {
    215     m_pbValidSlice[s] = true;
    216   }
    217   m_pSliceSUMap = new Int[maxNumSUInLCU * numLCUInPic];
    218 
    219   //initialization
    220   for(UInt i=0; i< (maxNumSUInLCU * numLCUInPic); i++ )
    221   {
    222     m_pSliceSUMap[i] = -1;
    223   }
    224   for( UInt CUAddr = 0; CUAddr < numLCUInPic ; CUAddr++ )
    225   {
    226     TComDataCU* pcCU = getCU( CUAddr );
    227     pcCU->setSliceSUMap(m_pSliceSUMap + (CUAddr* maxNumSUInLCU));
    228     pcCU->getNDBFilterBlocks()->clear();
    229   }
    230   m_vSliceCUDataLink.clear();
    231 
    232   m_vSliceCUDataLink.resize(numSlices);
    233 
    234   UInt startAddr, endAddr, firstCUInStartLCU, startLCU, endLCU, lastCUInEndLCU, uiAddr;
    235   UInt LPelX, TPelY, LCUX, LCUY;
    236   UInt currSU;
    237   UInt startSU, endSU;
    238 
    239   for(Int s=0; s< numSlices; s++)
    240   {
    241     //1st step: decide the real start address
    242     startAddr = sliceStartAddress[s];
    243     endAddr   = sliceStartAddress[s+1] -1;
    244 
    245     startLCU            = startAddr / maxNumSUInLCU;
    246     firstCUInStartLCU   = startAddr % maxNumSUInLCU;
    247 
    248     endLCU              = endAddr   / maxNumSUInLCU;
    249     lastCUInEndLCU      = endAddr   % maxNumSUInLCU;   
    250 
    251     uiAddr = m_apcPicSym->getCUOrderMap(startLCU);
    252 
    253     LCUX      = getCU(uiAddr)->getCUPelX();
    254     LCUY      = getCU(uiAddr)->getCUPelY();
    255     LPelX     = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[firstCUInStartLCU] ];
    256     TPelY     = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[firstCUInStartLCU] ];
    257     currSU    = firstCUInStartLCU;
    258 
    259     Bool bMoveToNextLCU = false;
    260     Bool bSliceInOneLCU = (startLCU == endLCU);
    261 
    262     while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
    263     {
    264       currSU ++;
    265 
    266       if(bSliceInOneLCU)
    267       {
    268         if(currSU > lastCUInEndLCU)
    269         {
    270           m_pbValidSlice[s] = false;
    271           break;
    272         }
    273       }
    274 
    275       if(currSU >= maxNumSUInLCU )
    276       {
    277         bMoveToNextLCU = true;
    278         break;
    279       }
    280 
    281       LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    282       TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    283 
    284     }
    285 
    286 
    287     if(!m_pbValidSlice[s])
    288     {
    289       continue;
    290     }
    291 
    292     if(currSU != firstCUInStartLCU)
    293     {
    294       if(!bMoveToNextLCU)
    295       {
    296         firstCUInStartLCU = currSU;
    297       }
    298       else
    299       {
    300         startLCU++;
    301         firstCUInStartLCU = 0;
    302         assert( startLCU < getNumCUsInFrame());
    303       }
    304       assert(startLCU*maxNumSUInLCU + firstCUInStartLCU < endAddr);
    305     }
    306 
    307 
    308     //2nd step: assign NonDBFilterInfo to each processing block
    309     for(UInt i= startLCU; i <= endLCU; i++)
    310     {
    311       startSU = (i == startLCU)?(firstCUInStartLCU):(0);
    312       endSU   = (i == endLCU  )?(lastCUInEndLCU   ):(maxNumSUInLCU -1);
    313 
    314       uiAddr = m_apcPicSym->getCUOrderMap(i);
    315       Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
    316 
    317       TComDataCU* pcCU = getCU(uiAddr);
    318       m_vSliceCUDataLink[s].push_back(pcCU);
    319 
    320       createNonDBFilterInfoLCU(iTileID, s, pcCU, startSU, endSU, m_sliceGranularityForNDBFilter, picWidth, picHeight);
    321     }
    322   }
    323 
    324   //step 3: border availability
    325   for(Int s=0; s< numSlices; s++)
    326   {
    327     if(!m_pbValidSlice[s])
    328     {
    329       continue;
    330     }
    331 
    332     for(Int i=0; i< m_vSliceCUDataLink[s].size(); i++)
    333     {
    334       TComDataCU* pcCU = m_vSliceCUDataLink[s][i];
    335       uiAddr = pcCU->getAddr();
    336 
    337       if(pcCU->getPic()==0)
    338       {
    339         continue;
    340       }
    341       Int iTileID= m_apcPicSym->getTileIdxMap(uiAddr);
    342       Bool bTopTileBoundary = false, bDownTileBoundary= false, bLeftTileBoundary= false, bRightTileBoundary= false;
    343 
    344       if(m_bIndependentTileBoundaryForNDBFilter)
    345       {
    346         //left
    347         if( uiAddr % numLCUsInPicWidth != 0)
    348         {
    349           bLeftTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr -1) != iTileID )?true:false;
    350         }
    351         //right
    352         if( (uiAddr % numLCUsInPicWidth) != (numLCUsInPicWidth -1) )
    353         {
    354           bRightTileBoundary = ( m_apcPicSym->getTileIdxMap(uiAddr +1) != iTileID)?true:false;
    355         }
    356         //top
    357         if( uiAddr >= numLCUsInPicWidth)
    358         {
    359           bTopTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr - numLCUsInPicWidth) !=  iTileID )?true:false;
    360         }
    361         //down
    362         if( uiAddr + numLCUsInPicWidth < numLCUInPic )
    363         {
    364           bDownTileBoundary = (m_apcPicSym->getTileIdxMap(uiAddr + numLCUsInPicWidth) != iTileID)?true:false;
    365         }
    366 
    367       }
    368 
    369       pcCU->setNDBFilterBlockBorderAvailability(numLCUsInPicWidth, numLCUsInPicHeight, maxNumSUInLCUWidth, maxNumSUInLCUHeight,picWidth, picHeight
    370         , *LFCrossSliceBoundary
    371         ,bTopTileBoundary, bDownTileBoundary, bLeftTileBoundary, bRightTileBoundary
    372         ,m_bIndependentTileBoundaryForNDBFilter);
    373 
    374     }
    375 
    376   }
    377 
    378   if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
    379   {
    380     m_pNDBFilterYuvTmp = new TComPicYuv();
    381     m_pNDBFilterYuvTmp->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    382   }
    383 
    384 }
    385 
    386 /** Create non-deblocked filter information for LCU
    387  * \param tileID tile index
    388  * \param sliceID slice index
    389  * \param pcCU CU data pointer
    390  * \param startSU start SU index in LCU
    391  * \param endSU end SU index in LCU
    392  * \param sliceGranularyDepth slice granularity
    393  * \param picWidth picture width
    394  * \param picHeight picture height
    395  */
    396 Void TComPic::createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight)
    397 {
    398   UInt LCUX          = pcCU->getCUPelX();
    399   UInt LCUY          = pcCU->getCUPelY();
    400   Int* pCUSliceMap    = pcCU->getSliceSUMap();
    401   UInt maxNumSUInLCU = getNumPartInCU();
    402   UInt maxNumSUInSGU = maxNumSUInLCU >> (sliceGranularyDepth << 1);
    403   UInt maxNumSUInLCUWidth = getNumPartInWidth();
    404   UInt LPelX, TPelY;
    405   UInt currSU;
    406 
    407 
    408   //get the number of valid NBFilterBLock
    409   currSU   = startSU;
    410   while(currSU <= endSU)
    411   {
    412     LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    413     TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    414 
    415     while(!( LPelX < picWidth ) || !( TPelY < picHeight ))
    416     {
    417       currSU += maxNumSUInSGU;
    418       if(currSU >= maxNumSUInLCU || currSU > endSU)
    419       {
    420         break;
    421       }
    422       LPelX = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[currSU] ];
    423       TPelY = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[currSU] ];
    424     }
    425 
    426     if(currSU >= maxNumSUInLCU || currSU > endSU)
    427     {
    428       break;
    429     }
    430 
    431     NDBFBlockInfo NDBFBlock;
    432 
    433     NDBFBlock.tileID  = tileID;
    434     NDBFBlock.sliceID = sliceID;
    435     NDBFBlock.posY    = TPelY;
    436     NDBFBlock.posX    = LPelX;
    437     NDBFBlock.startSU = currSU;
    438 
    439     UInt uiLastValidSU  = currSU;
    440     UInt uiIdx, uiLPelX_su, uiTPelY_su;
    441     for(uiIdx = currSU; uiIdx < currSU + maxNumSUInSGU; uiIdx++)
    442     {
    443       if(uiIdx > endSU)
    444       {
    445         break;       
    446       }
    447       uiLPelX_su   = LCUX + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
    448       uiTPelY_su   = LCUY + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    449       if( !(uiLPelX_su < picWidth ) || !( uiTPelY_su < picHeight ))
    450       {
    451         continue;
    452       }
    453       pCUSliceMap[uiIdx] = sliceID;
    454       uiLastValidSU = uiIdx;
    455     }
    456     NDBFBlock.endSU = uiLastValidSU;
    457 
    458     UInt rTLSU = g_auiZscanToRaster[ NDBFBlock.startSU ];
    459     UInt rBRSU = g_auiZscanToRaster[ NDBFBlock.endSU   ];
    460     NDBFBlock.widthSU  = (rBRSU % maxNumSUInLCUWidth) - (rTLSU % maxNumSUInLCUWidth)+ 1;
    461     NDBFBlock.heightSU = (UInt)(rBRSU / maxNumSUInLCUWidth) - (UInt)(rTLSU / maxNumSUInLCUWidth)+ 1;
    462     NDBFBlock.width    = NDBFBlock.widthSU  * getMinCUWidth();
    463     NDBFBlock.height   = NDBFBlock.heightSU * getMinCUHeight();
    464 
    465     pcCU->getNDBFilterBlocks()->push_back(NDBFBlock);
    466 
    467     currSU += maxNumSUInSGU;
    468   }
    469 
    470 }
    471 
    472 /** destroy non-deblocked filter information for LCU
    473  */
    474 Void TComPic::destroyNonDBFilterInfo()
    475 {
    476   if(m_pbValidSlice != NULL)
    477   {
    478     delete[] m_pbValidSlice;
    479     m_pbValidSlice = NULL;
    480   }
    481 
    482   if(m_pSliceSUMap != NULL)
    483   {
    484     delete[] m_pSliceSUMap;
    485     m_pSliceSUMap = NULL;
    486   }
    487   for( UInt CUAddr = 0; CUAddr < getNumCUsInFrame() ; CUAddr++ )
    488   {
    489     TComDataCU* pcCU = getCU( CUAddr );
    490     pcCU->getNDBFilterBlocks()->clear();
    491   }
    492 
    493   if( m_bIndependentSliceBoundaryForNDBFilter || m_bIndependentTileBoundaryForNDBFilter)
    494   {
    495     m_pNDBFilterYuvTmp->destroy();
    496     delete m_pNDBFilterYuvTmp;
    497     m_pNDBFilterYuvTmp = NULL;
    498   }
    499 
    500 }
     170Bool  TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr)
     171{
     172  Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCUOrderMap(getCU(currAddr)->getSlice()->getSliceCurStartCUAddr()/getNumPartInCU()));
     173  Bool mergeCtbInTile     = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr));
     174  return (mergeCtbInSliceSeg && mergeCtbInTile);
     175}
     176
    501177#if H_MV
    502178Void TComPic::print( Bool legend )
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPic.h

    r655 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7070  Bool                  m_bNeededForOutput;
    7171  UInt                  m_uiCurrSliceIdx;         // Index of current slice
    72   Int*                  m_pSliceSUMap;
    73   Bool*                 m_pbValidSlice;
    74   Int                   m_sliceGranularityForNDBFilter;
    75   Bool                  m_bIndependentSliceBoundaryForNDBFilter;
    76   Bool                  m_bIndependentTileBoundaryForNDBFilter;
    77   TComPicYuv*           m_pNDBFilterYuvTmp;    //!< temporary picture buffer when non-cross slice/tile boundary in-loop filtering is enabled
    7872  Bool                  m_bCheckLTMSB;
    7973 
     
    198192  Window&       getDefDisplayWindow()   { return m_defaultDisplayWindow; }
    199193
    200   Void          createNonDBFilterInfo   (std::vector<Int> sliceStartAddress, Int sliceGranularityDepth
    201                                         ,std::vector<Bool>* LFCrossSliceBoundary
    202                                         ,Int  numTiles = 1
    203                                         ,Bool bNDBFilterCrossTileBoundary = true);
    204   Void          createNonDBFilterInfoLCU(Int tileID, Int sliceID, TComDataCU* pcCU, UInt startSU, UInt endSU, Int sliceGranularyDepth, UInt picWidth, UInt picHeight);
    205   Void          destroyNonDBFilterInfo();
    206 
    207   Bool          getValidSlice                                  (Int sliceID)  {return m_pbValidSlice[sliceID];}
    208   Bool          getIndependentSliceBoundaryForNDBFilter        ()             {return m_bIndependentSliceBoundaryForNDBFilter;}
    209   Bool          getIndependentTileBoundaryForNDBFilter         ()             {return m_bIndependentTileBoundaryForNDBFilter; }
    210   TComPicYuv*   getYuvPicBufferForIndependentBoundaryProcessing()             {return m_pNDBFilterYuvTmp;}
    211   std::vector<TComDataCU*>& getOneSliceCUDataForNDBFilter      (Int sliceID) { return m_vSliceCUDataLink[sliceID];}
    212 
     194  Bool          getSAOMergeAvailability(Int currAddr, Int mergeAddr);
    213195
    214196  /* field coding parameters*/
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicSym.cpp

    r655 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6767,m_puiTileIdxMap(NULL)
    6868,m_puiInverseCUOrderMap(NULL)
     69,m_saoBlkParams(NULL)
    6970{};
    7071
     
    122123    m_puiInverseCUOrderMap[i] = i;
    123124  }
    124   m_saoParam = NULL;
     125
     126  m_saoBlkParams = new SAOBlkParam[m_uiNumCUsInFrame];
    125127}
    126128
     
    163165  m_puiInverseCUOrderMap = NULL;
    164166 
    165   if (m_saoParam)
    166   {
    167     TComSampleAdaptiveOffset::freeSaoParam(m_saoParam);
    168     delete m_saoParam;
    169     m_saoParam = NULL;
     167  if(m_saoBlkParams)
     168  {
     169    delete[] m_saoBlkParams; m_saoBlkParams = NULL;
    170170  }
    171171}
     
    308308}
    309309
    310 Void TComPicSym::allocSaoParam(TComSampleAdaptiveOffset *sao)
    311 {
    312   m_saoParam = new SAOParam;
    313   sao->allocSaoParam(m_saoParam);
     310Void TComPicSym::deriveLoopFilterBoundaryAvailibility(Int ctu,
     311                                                      Bool& isLeftAvail,
     312                                                      Bool& isRightAvail,
     313                                                      Bool& isAboveAvail,
     314                                                      Bool& isBelowAvail,
     315                                                      Bool& isAboveLeftAvail,
     316                                                      Bool& isAboveRightAvail,
     317                                                      Bool& isBelowLeftAvail,
     318                                                      Bool& isBelowRightAvail
     319                                                      )
     320{
     321
     322  isLeftAvail      = (ctu % m_uiWidthInCU != 0);
     323  isRightAvail     = (ctu % m_uiWidthInCU != m_uiWidthInCU-1);
     324  isAboveAvail     = (ctu >= m_uiWidthInCU );
     325  isBelowAvail     = (ctu <  m_uiNumCUsInFrame - m_uiWidthInCU);
     326  isAboveLeftAvail = (isAboveAvail && isLeftAvail);
     327  isAboveRightAvail= (isAboveAvail && isRightAvail);
     328  isBelowLeftAvail = (isBelowAvail && isLeftAvail);
     329  isBelowRightAvail= (isBelowAvail && isRightAvail);
     330
     331  Bool isLoopFiltAcrossTilePPS = getCU(ctu)->getSlice()->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
     332
     333  {
     334    TComDataCU* ctuCurr  = getCU(ctu);
     335    TComDataCU* ctuLeft  = isLeftAvail ?getCU(ctu-1):NULL;
     336    TComDataCU* ctuRight = isRightAvail?getCU(ctu+1):NULL;
     337    TComDataCU* ctuAbove = isAboveAvail?getCU(ctu-m_uiWidthInCU):NULL;
     338    TComDataCU* ctuBelow = isBelowAvail?getCU(ctu+m_uiWidthInCU):NULL;
     339    TComDataCU* ctuAboveLeft  = isAboveLeftAvail ? getCU(ctu-m_uiWidthInCU-1):NULL;
     340    TComDataCU* ctuAboveRigtht= isAboveRightAvail? getCU(ctu-m_uiWidthInCU+1):NULL;
     341    TComDataCU* ctuBelowLeft  = isBelowLeftAvail ? getCU(ctu+m_uiWidthInCU-1):NULL;
     342    TComDataCU* ctuBelowRight = isBelowRightAvail? getCU(ctu+m_uiWidthInCU+1):NULL;
     343
     344    {
     345      //left
     346      if(ctuLeft != NULL)
     347      {
     348        isLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuLeft->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true;
     349      }
     350      //above
     351      if(ctuAbove != NULL)
     352      {
     353        isAboveAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuAbove->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true;
     354      }
     355      //right
     356      if(ctuRight != NULL)
     357      {
     358        isRightAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuRight->getSlice()->getSliceCurStartCUAddr())?ctuRight->getSlice()->getLFCrossSliceBoundaryFlag():true;
     359      }
     360      //below
     361      if(ctuBelow != NULL)
     362      {
     363        isBelowAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuBelow->getSlice()->getSliceCurStartCUAddr())?ctuBelow->getSlice()->getLFCrossSliceBoundaryFlag():true;
     364      }
     365      //above-left
     366      if(ctuAboveLeft != NULL)
     367      {
     368        isAboveLeftAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuAboveLeft->getSlice()->getSliceCurStartCUAddr())?ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag():true;
     369      }
     370      //below-right
     371      if(ctuBelowRight != NULL)
     372{
     373        isBelowRightAvail = (ctuCurr->getSlice()->getSliceCurStartCUAddr() != ctuBelowRight->getSlice()->getSliceCurStartCUAddr())?ctuBelowRight->getSlice()->getLFCrossSliceBoundaryFlag():true;
     374      }
     375
     376
     377      //above-right
     378      if(ctuAboveRigtht != NULL)
     379      {
     380        Int curSliceStartEncOrder  = ctuCurr->getSlice()->getSliceCurStartCUAddr();
     381        Int aboveRigthtSliceStartEncOrder = ctuAboveRigtht->getSlice()->getSliceCurStartCUAddr();
     382
     383        isAboveRightAvail = (curSliceStartEncOrder == aboveRigthtSliceStartEncOrder)?(true):
     384          (
     385          (curSliceStartEncOrder > aboveRigthtSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
     386          :(ctuAboveRigtht->getSlice()->getLFCrossSliceBoundaryFlag())
     387          );         
     388      }
     389      //below-left
     390      if(ctuBelowLeft != NULL)
     391      {
     392        Int curSliceStartEncOrder  = ctuCurr->getSlice()->getSliceCurStartCUAddr();
     393        Int belowLeftSliceStartEncOrder = ctuBelowLeft->getSlice()->getSliceCurStartCUAddr();
     394
     395        isBelowLeftAvail = (curSliceStartEncOrder == belowLeftSliceStartEncOrder)?(true):
     396          (
     397          (curSliceStartEncOrder > belowLeftSliceStartEncOrder)?(ctuCurr->getSlice()->getLFCrossSliceBoundaryFlag())
     398          :(ctuBelowLeft->getSlice()->getLFCrossSliceBoundaryFlag())
     399          );
     400      }       
     401    }
     402
     403    if(!isLoopFiltAcrossTilePPS)
     404    {     
     405      isLeftAvail      = (!isLeftAvail      ) ?false:(getTileIdxMap( ctuLeft->getAddr()         ) == getTileIdxMap( ctu ));
     406      isAboveAvail     = (!isAboveAvail     ) ?false:(getTileIdxMap( ctuAbove->getAddr()        ) == getTileIdxMap( ctu ));
     407      isRightAvail     = (!isRightAvail     ) ?false:(getTileIdxMap( ctuRight->getAddr()        ) == getTileIdxMap( ctu ));
     408      isBelowAvail     = (!isBelowAvail     ) ?false:(getTileIdxMap( ctuBelow->getAddr()        ) == getTileIdxMap( ctu ));
     409      isAboveLeftAvail = (!isAboveLeftAvail ) ?false:(getTileIdxMap( ctuAboveLeft->getAddr()    ) == getTileIdxMap( ctu ));
     410      isAboveRightAvail= (!isAboveRightAvail) ?false:(getTileIdxMap( ctuAboveRigtht->getAddr()  ) == getTileIdxMap( ctu ));
     411      isBelowLeftAvail = (!isBelowLeftAvail ) ?false:(getTileIdxMap( ctuBelowLeft->getAddr()    ) == getTileIdxMap( ctu ));
     412      isBelowRightAvail= (!isBelowRightAvail) ?false:(getTileIdxMap( ctuBelowRight->getAddr()   ) == getTileIdxMap( ctu ));
     413    }
     414  }
     415
    314416}
    315417
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicSym.h

    r655 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    107107  UInt*         m_puiInverseCUOrderMap;
    108108
    109   SAOParam *m_saoParam;
     109  SAOBlkParam *m_saoBlkParams;
    110110public:
    111111  Void        create  ( Int iPicWidth, Int iPicHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth );
     
    144144  Void         xInitTiles();
    145145  UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
    146   Void allocSaoParam(TComSampleAdaptiveOffset *sao);
    147   SAOParam *getSaoParam() { return m_saoParam; }
     146  SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;}
     147  Void deriveLoopFilterBoundaryAvailibility(Int ctu, Bool& isLeftAvail,Bool& isRightAvail,Bool& isAboveAvail,Bool& isBelowAvail,Bool& isAboveLeftAvail,Bool& isAboveRightAvail,Bool& isBelowLeftAvail,Bool& isBelowRightAvail);
     148
     149
    148150};// END CLASS DEFINITION TComPicSym
    149151
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicYuv.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicYuv.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r608 r852  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComPrediction.h

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5151Double TComRdCost::m_dDisparityCoeff = 1.0;
    5252#endif
    53 
    5453TComRdCost::TComRdCost()
    5554{
     
    354353  }
    355354#endif
    356  
    357355  // initialize
    358356  rcDistParam.iSubShift  = 0;
     
    395393  }
    396394#endif
    397 
    398395  // initialize
    399396  rcDistParam.iSubShift  = 0;
     
    401398
    402399// Setting the Distortion Parameter for Inter (subpel ME with step)
    403 #if NS_HAD
    404 Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME, Bool bUseNSHAD )
    405 #else
    406400Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME )
    407 #endif
    408401{
    409402  // set Original & Curr Pointer / Stride
     
    420413  rcDistParam.iCols    = pcPatternKey->getROIYWidth();
    421414  rcDistParam.iRows    = pcPatternKey->getROIYHeight();
    422 #if NS_HAD
    423   rcDistParam.bUseNSHAD = bUseNSHAD;
    424 #endif
    425415 
    426416  // set distortion function
     
    454444  }
    455445#endif
    456  
    457446  // initialize
    458447  rcDistParam.iSubShift  = 0;
     
    460449
    461450Void
    462 #if NS_HAD
    463 TComRdCost::setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard, Bool bUseNSHAD )
    464 #else
    465451TComRdCost::setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard )
    466 #endif
    467452{
    468453  rcDP.pOrg       = p1;
     
    476461  rcDP.bitDepth   = bitDepth;
    477462  rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
    478  
    479463#if H_3D_DBBP
    480464  if( m_bUseMask )
     
    482466    rcDP.DistFunc = (bHadamard)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD;
    483467  }
    484 #endif
    485  
    486 #if NS_HAD
    487   rcDP.bUseNSHAD  = bUseNSHAD;
    488468#endif
    489469}
     
    506486    }
    507487  }
    508   else if ( ( (iWidth % 4) == 0 ) && ( (iHeight % 4) == 0 ) )
    509   {
     488  else
     489  {
     490    assert(iWidth % 4 == 0 && iHeight % 4 == 0);
     491   
    510492    for ( y=0; y<iHeight; y+= 4 )
    511493    {
     
    518500    }
    519501  }
    520   else
    521   {
    522     for ( y=0; y<iHeight; y+= 2 )
    523     {
    524       for ( x=0; x<iWidth; x+= 2 )
    525       {
    526         uiSum += xCalcHADs8x8( &pi0[x], &pi1[x], iStride0, iStride1, 1 );
    527       }
    528       pi0 += iStride0*2;
    529       pi1 += iStride1*2;
    530     }
    531   }
    532502 
    533503  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
     
    572542
    573543
    574 #if WEIGHTED_CHROMA_DISTORTION
    575544UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText, DFunc eDFunc)
    576 #else
    577 UInt TComRdCost::getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc )
    578 #endif
    579545{
    580546  DistParam cDtParam;
     
    596562  cDtParam.bUseSDCMRSAD = false;
    597563#endif
    598 #if WEIGHTED_CHROMA_DISTORTION
    599564  if (eText == TEXT_CHROMA_U)
    600565  {
     
    609574    return cDtParam.DistFunc( &cDtParam );
    610575  }
    611 #else
    612   return cDtParam.DistFunc( &cDtParam );
    613 #endif
    614576}
    615577#if H_3D_VSO
     
    664626#endif
    665627
    666 #if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
     628#if KWU_RC_MADPRED_E0227
    667629UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    668630{
     
    908870}
    909871#endif
    910 
    911872// --------------------------------------------------------------------------------------------------------------------
    912873// SAD
     
    34673428}
    34683429
    3469 #if NS_HAD
    3470 UInt TComRdCost::xCalcHADs16x4( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3471 {
    3472   Int k, i, j, jj, sad=0;
    3473   Int diff[64], m1[4][16], m2[4][16];
    3474   assert( iStep == 1 );
    3475   for( k = 0; k < 64; k += 16 )
    3476   {
    3477     diff[k+0] = piOrg[0] - piCur[0];
    3478     diff[k+1] = piOrg[1] - piCur[1];
    3479     diff[k+2] = piOrg[2] - piCur[2];
    3480     diff[k+3] = piOrg[3] - piCur[3];
    3481     diff[k+4] = piOrg[4] - piCur[4];
    3482     diff[k+5] = piOrg[5] - piCur[5];
    3483     diff[k+6] = piOrg[6] - piCur[6];
    3484     diff[k+7] = piOrg[7] - piCur[7];
    3485 
    3486     diff[k+8]  = piOrg[8]  - piCur[8] ;
    3487     diff[k+9]  = piOrg[9]  - piCur[9] ;
    3488     diff[k+10] = piOrg[10] - piCur[10];
    3489     diff[k+11] = piOrg[11] - piCur[11];
    3490     diff[k+12] = piOrg[12] - piCur[12];
    3491     diff[k+13] = piOrg[13] - piCur[13];
    3492     diff[k+14] = piOrg[14] - piCur[14];
    3493     diff[k+15] = piOrg[15] - piCur[15];
    3494 
    3495     piCur += iStrideCur;
    3496     piOrg += iStrideOrg;
    3497   }
    3498 
    3499   //horizontal
    3500   for (j=0; j < 4; j++)
    3501   {
    3502     jj = j << 4;
    3503 
    3504     m2[j][0]  = diff[jj  ] + diff[jj+8];
    3505     m2[j][1]  = diff[jj+1] + diff[jj+9];
    3506     m2[j][2]  = diff[jj+2] + diff[jj+10];
    3507     m2[j][3]  = diff[jj+3] + diff[jj+11];
    3508     m2[j][4]  = diff[jj+4] + diff[jj+12];
    3509     m2[j][5]  = diff[jj+5] + diff[jj+13];
    3510     m2[j][6]  = diff[jj+6] + diff[jj+14];
    3511     m2[j][7]  = diff[jj+7] + diff[jj+15];
    3512     m2[j][8]  = diff[jj  ] - diff[jj+8];
    3513     m2[j][9]  = diff[jj+1] - diff[jj+9];
    3514     m2[j][10] = diff[jj+2] - diff[jj+10];
    3515     m2[j][11] = diff[jj+3] - diff[jj+11];
    3516     m2[j][12] = diff[jj+4] - diff[jj+12];
    3517     m2[j][13] = diff[jj+5] - diff[jj+13];
    3518     m2[j][14] = diff[jj+6] - diff[jj+14];
    3519     m2[j][15] = diff[jj+7] - diff[jj+15];
    3520 
    3521     m1[j][0]  = m2[j][0]  + m2[j][4];
    3522     m1[j][1]  = m2[j][1]  + m2[j][5];
    3523     m1[j][2]  = m2[j][2]  + m2[j][6];
    3524     m1[j][3]  = m2[j][3]  + m2[j][7];
    3525     m1[j][4]  = m2[j][0]  - m2[j][4];
    3526     m1[j][5]  = m2[j][1]  - m2[j][5];
    3527     m1[j][6]  = m2[j][2]  - m2[j][6];
    3528     m1[j][7]  = m2[j][3]  - m2[j][7];
    3529     m1[j][8]  = m2[j][8]  + m2[j][12];
    3530     m1[j][9]  = m2[j][9]  + m2[j][13];
    3531     m1[j][10] = m2[j][10] + m2[j][14];
    3532     m1[j][11] = m2[j][11] + m2[j][15];
    3533     m1[j][12] = m2[j][8]  - m2[j][12];
    3534     m1[j][13] = m2[j][9]  - m2[j][13];
    3535     m1[j][14] = m2[j][10] - m2[j][14];
    3536     m1[j][15] = m2[j][11] - m2[j][15];
    3537 
    3538     m2[j][0]  = m1[j][0]  + m1[j][2];
    3539     m2[j][1]  = m1[j][1]  + m1[j][3];
    3540     m2[j][2]  = m1[j][0]  - m1[j][2];
    3541     m2[j][3]  = m1[j][1]  - m1[j][3];
    3542     m2[j][4]  = m1[j][4]  + m1[j][6];
    3543     m2[j][5]  = m1[j][5]  + m1[j][7];
    3544     m2[j][6]  = m1[j][4]  - m1[j][6];
    3545     m2[j][7]  = m1[j][5]  - m1[j][7];
    3546     m2[j][8]  = m1[j][8]  + m1[j][10];
    3547     m2[j][9]  = m1[j][9]  + m1[j][11];
    3548     m2[j][10] = m1[j][8]  - m1[j][10];
    3549     m2[j][11] = m1[j][9]  - m1[j][11];
    3550     m2[j][12] = m1[j][12] + m1[j][14];
    3551     m2[j][13] = m1[j][13] + m1[j][15];
    3552     m2[j][14] = m1[j][12] - m1[j][14];
    3553     m2[j][15] = m1[j][13] - m1[j][15];
    3554 
    3555     m1[j][0]  = m2[j][0]  + m2[j][1];
    3556     m1[j][1]  = m2[j][0]  - m2[j][1];
    3557     m1[j][2]  = m2[j][2]  + m2[j][3];
    3558     m1[j][3]  = m2[j][2]  - m2[j][3];
    3559     m1[j][4]  = m2[j][4]  + m2[j][5];
    3560     m1[j][5]  = m2[j][4]  - m2[j][5];
    3561     m1[j][6]  = m2[j][6]  + m2[j][7];
    3562     m1[j][7]  = m2[j][6]  - m2[j][7];
    3563     m1[j][8]  = m2[j][8]  + m2[j][9];
    3564     m1[j][9]  = m2[j][8]  - m2[j][9];
    3565     m1[j][10] = m2[j][10] + m2[j][11];
    3566     m1[j][11] = m2[j][10] - m2[j][11];
    3567     m1[j][12] = m2[j][12] + m2[j][13];
    3568     m1[j][13] = m2[j][12] - m2[j][13];
    3569     m1[j][14] = m2[j][14] + m2[j][15];
    3570     m1[j][15] = m2[j][14] - m2[j][15];
    3571   }
    3572 
    3573   //vertical
    3574   for (i=0; i < 16; i++)
    3575   {   
    3576     m2[0][i] = m1[0][i] + m1[2][i];
    3577     m2[1][i] = m1[1][i] + m1[3][i];
    3578     m2[2][i] = m1[0][i] - m1[2][i];
    3579     m2[3][i] = m1[1][i] - m1[3][i];
    3580 
    3581     m1[0][i] = m2[0][i] + m2[1][i];
    3582     m1[1][i] = m2[0][i] - m2[1][i];
    3583     m1[2][i] = m2[2][i] + m2[3][i];
    3584     m1[3][i] = m2[2][i] - m2[3][i];
    3585   }
    3586 
    3587   for (i = 0; i < 4; i++)
    3588   {
    3589     for (j = 0; j < 16; j++)
    3590     {
    3591       sad += abs(m1[i][j]);
    3592     }
    3593   }
    3594 
    3595   sad=((sad+2)>>2);
    3596 
    3597   return sad;
    3598 }
    3599 
    3600 UInt TComRdCost::xCalcHADs4x16( Pel *piOrg, Pel *piCur, Int iStrideOrg, Int iStrideCur, Int iStep )
    3601 {
    3602   Int k, i, j, jj, sad=0;
    3603   Int diff[64], m1[16][4], m2[16][4], m3[16][4];
    3604   assert( iStep == 1 );
    3605   for( k = 0; k < 64; k += 4 )
    3606   {
    3607     diff[k+0] = piOrg[0] - piCur[0];
    3608     diff[k+1] = piOrg[1] - piCur[1];
    3609     diff[k+2] = piOrg[2] - piCur[2];
    3610     diff[k+3] = piOrg[3] - piCur[3];
    3611 
    3612     piCur += iStrideCur;
    3613     piOrg += iStrideOrg;
    3614   }
    3615 
    3616   //horizontal
    3617   for (j=0; j < 16; j++)
    3618   {
    3619     jj = j << 2;
    3620     m2[j][0] = diff[jj  ] + diff[jj+2];
    3621     m2[j][1] = diff[jj+1] + diff[jj+3];
    3622     m2[j][2] = diff[jj  ] - diff[jj+2];
    3623     m2[j][3] = diff[jj+1] - diff[jj+3];
    3624 
    3625     m1[j][0] = m2[j][0] + m2[j][1];
    3626     m1[j][1] = m2[j][0] - m2[j][1];
    3627     m1[j][2] = m2[j][2] + m2[j][3];
    3628     m1[j][3] = m2[j][2] - m2[j][3];
    3629   }
    3630 
    3631   //vertical
    3632   for (i=0; i < 4; i++)
    3633   {
    3634     m2[0][i]  = m1[0][i] + m1[8][i];
    3635     m2[1][i]  = m1[1][i] + m1[9][i];
    3636     m2[2][i]  = m1[2][i] + m1[10][i];
    3637     m2[3][i]  = m1[3][i] + m1[11][i];
    3638     m2[4][i]  = m1[4][i] + m1[12][i];
    3639     m2[5][i]  = m1[5][i] + m1[13][i];
    3640     m2[6][i]  = m1[6][i] + m1[14][i];
    3641     m2[7][i]  = m1[7][i] + m1[15][i];
    3642     m2[8][i]  = m1[0][i] - m1[8][i];
    3643     m2[9][i]  = m1[1][i] - m1[9][i];
    3644     m2[10][i] = m1[2][i] - m1[10][i];
    3645     m2[11][i] = m1[3][i] - m1[11][i];
    3646     m2[12][i] = m1[4][i] - m1[12][i];
    3647     m2[13][i] = m1[5][i] - m1[13][i];
    3648     m2[14][i] = m1[6][i] - m1[14][i];
    3649     m2[15][i] = m1[7][i] - m1[15][i];
    3650 
    3651     m3[0][i]  = m2[0][i]  + m2[4][i];
    3652     m3[1][i]  = m2[1][i]  + m2[5][i];
    3653     m3[2][i]  = m2[2][i]  + m2[6][i];
    3654     m3[3][i]  = m2[3][i]  + m2[7][i];
    3655     m3[4][i]  = m2[0][i]  - m2[4][i];
    3656     m3[5][i]  = m2[1][i]  - m2[5][i];
    3657     m3[6][i]  = m2[2][i]  - m2[6][i];
    3658     m3[7][i]  = m2[3][i]  - m2[7][i];
    3659     m3[8][i]  = m2[8][i]  + m2[12][i];
    3660     m3[9][i]  = m2[9][i]  + m2[13][i];
    3661     m3[10][i] = m2[10][i] + m2[14][i];
    3662     m3[11][i] = m2[11][i] + m2[15][i];
    3663     m3[12][i] = m2[8][i]  - m2[12][i];
    3664     m3[13][i] = m2[9][i]  - m2[13][i];
    3665     m3[14][i] = m2[10][i] - m2[14][i];
    3666     m3[15][i] = m2[11][i] - m2[15][i];
    3667 
    3668     m1[0][i]  = m3[0][i]  + m3[2][i];
    3669     m1[1][i]  = m3[1][i]  + m3[3][i];
    3670     m1[2][i]  = m3[0][i]  - m3[2][i];
    3671     m1[3][i]  = m3[1][i]  - m3[3][i];
    3672     m1[4][i]  = m3[4][i]  + m3[6][i];
    3673     m1[5][i]  = m3[5][i]  + m3[7][i];
    3674     m1[6][i]  = m3[4][i]  - m3[6][i];
    3675     m1[7][i]  = m3[5][i]  - m3[7][i];
    3676     m1[8][i]  = m3[8][i]  + m3[10][i];
    3677     m1[9][i]  = m3[9][i]  + m3[11][i];
    3678     m1[10][i] = m3[8][i]  - m3[10][i];
    3679     m1[11][i] = m3[9][i]  - m3[11][i];
    3680     m1[12][i] = m3[12][i] + m3[14][i];
    3681     m1[13][i] = m3[13][i] + m3[15][i];
    3682     m1[14][i] = m3[12][i] - m3[14][i];
    3683     m1[15][i] = m3[13][i] - m3[15][i];
    3684 
    3685     m2[0][i]  = m1[0][i]  + m1[1][i];
    3686     m2[1][i]  = m1[0][i]  - m1[1][i];
    3687     m2[2][i]  = m1[2][i]  + m1[3][i];
    3688     m2[3][i]  = m1[2][i]  - m1[3][i];
    3689     m2[4][i]  = m1[4][i]  + m1[5][i];
    3690     m2[5][i]  = m1[4][i]  - m1[5][i];
    3691     m2[6][i]  = m1[6][i]  + m1[7][i];
    3692     m2[7][i]  = m1[6][i]  - m1[7][i];
    3693     m2[8][i]  = m1[8][i]  + m1[9][i];
    3694     m2[9][i]  = m1[8][i]  - m1[9][i];
    3695     m2[10][i] = m1[10][i] + m1[11][i];
    3696     m2[11][i] = m1[10][i] - m1[11][i];
    3697     m2[12][i] = m1[12][i] + m1[13][i];
    3698     m2[13][i] = m1[12][i] - m1[13][i];
    3699     m2[14][i] = m1[14][i] + m1[15][i];
    3700     m2[15][i] = m1[14][i] - m1[15][i];
    3701   }
    3702 
    3703   for (i = 0; i < 16; i++)
    3704   {
    3705     for (j = 0; j < 4; j++)
    3706     {
    3707       sad += abs(m2[i][j]);
    3708     }
    3709   }
    3710 
    3711   sad=((sad+2)>>2);
    3712 
    3713   return sad;
    3714 }
    3715 #endif
    3716 
    37173430UInt TComRdCost::xGetHADs4( DistParam* pcDtParam )
    37183431{
     
    38093522  UInt uiSum = 0;
    38103523 
    3811 #if NS_HAD
    3812   if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
    3813 #else
    38143524  if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
    3815 #endif
    38163525  {
    38173526    Int  iOffsetOrg = iStrideOrg<<3;
     
    38273536    }
    38283537  }
    3829 #if NS_HAD
    3830   else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
    3831   {
    3832     Int  iOffsetOrg = iStrideOrg<<2;
    3833     Int  iOffsetCur = iStrideCur<<2;
    3834     for ( y=0; y<iRows; y+= 4 )
    3835     {
    3836       for ( x=0; x<iCols; x+= 16 )
    3837       {
    3838         uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3839       }
    3840       piOrg += iOffsetOrg;
    3841       piCur += iOffsetCur;
    3842     }
    3843   }
    3844   else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
    3845   {
    3846     Int  iOffsetOrg = iStrideOrg<<4;
    3847     Int  iOffsetCur = iStrideCur<<4;
    3848     for ( y=0; y<iRows; y+= 16 )
    3849     {
    3850       for ( x=0; x<iCols; x+= 4 )
    3851       {
    3852         uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
    3853       }
    3854       piOrg += iOffsetOrg;
    3855       piCur += iOffsetCur;
    3856     }
    3857   }
    3858 #endif
    38593538  else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
    38603539  {
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCost.h

    r833 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    107107  UInt            uiComp;           // uiComp = 0 (luma Y), 1 (chroma U), 2 (chroma V)
    108108
    109 #if NS_HAD
    110   Bool            bUseNSHAD;
    111 #endif
    112 
    113109  // (vertical) subsampling shift (for reducing complexity)
    114110  // - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc.
     
    127123    iSubShift = 0;
    128124    bitDepth = 0;
    129 #if NS_HAD
    130     bUseNSHAD = false;
    131 #endif
    132125#if H_3D_VSO
    133126    // SAIT_VSO_EST_A0033
     
    155148#endif 
    156149 
    157 #if WEIGHTED_CHROMA_DISTORTION
    158150  Double                  m_cbDistortionWeight;
    159151  Double                  m_crDistortionWeight;
    160 #endif
    161152  Double                  m_dLambda;
    162153  Double                  m_sqrtLambda;
     
    201192
    202193 
    203 #if WEIGHTED_CHROMA_DISTORTION
    204194  Void    setCbDistortionWeight      ( Double cbDistortionWeight) { m_cbDistortionWeight = cbDistortionWeight; };
    205195  Void    setCrDistortionWeight      ( Double crDistortionWeight) { m_crDistortionWeight = crDistortionWeight; };
    206 #endif
    207196  Void    setLambda      ( Double dLambda );
    208197  Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
     
    215204#endif
    216205
    217 #if RATE_CONTROL_LAMBDA_DOMAIN
    218206  Double  getLambda() { return m_dLambda; }
    219 #if M0036_RC_IMPROVEMENT
    220207  Double  getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);}
    221 #endif
    222 #endif
    223208 
    224209  // Distortion Functions
     
    227212  Void    setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam );
    228213  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
    229 #if NS_HAD
    230   Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false, Bool bUseNSHAD=false );
    231   Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false, Bool bUseNSHAD=false );
    232 #else
    233214  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
    234215  Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    235 #endif
    236216 
    237217#if H_3D_DBBP
     
    337317  static UInt xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    338318  static UInt xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    339 #if NS_HAD
    340   static UInt xCalcHADs16x4     ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    341   static UInt xCalcHADs4x16     ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    342 #endif
    343  
    344319#if H_3D_DBBP
    345320  static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
     
    350325 
    351326public:
    352 #if WEIGHTED_CHROMA_DISTORTION
    353327  UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE );
    354 #else
    355   UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
    356 #endif
    357 
    358 #if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
     328
     329#if KWU_RC_MADPRED_E0227
    359330  UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    360331#endif
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCostWeightPrediction.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRdCostWeightPrediction.h

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.cpp

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    327327UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
    328328
     329#if H_3D_DIM_DMM
    329330// ====================================================================================================================
    330331// Depth coding modes
    331332// ====================================================================================================================
    332 #if H_3D_DIM_DMM
    333333const WedgeResolution g_dmmWedgeResolution[6] =
    334334{
     
    372372Bool g_traceTU = true;
    373373Bool g_disableHLSTrace = false;
    374 UInt64 g_stopAtCounter       = 48;
     374UInt64 g_stopAtCounter       = 0;
    375375Bool g_traceCopyBack         = false;
    376376Bool g_decTraceDispDer       = false;
    377377Bool g_decTraceMvFromMerge   = false;
     378Bool g_stopAtPos             = false;
     379Bool g_outputPos             = false;
    378380#endif
    379381#endif
     
    395397const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
    396398const UInt g_uiGroupIdx[ 32 ]   = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9};
    397 
    398 // Rice parameters for absolute transform levels
    399 const UInt g_auiGoRiceRange[5] =
    400 {
    401   7, 14, 26, 46, 78
    402 };
    403 
    404 const UInt g_auiGoRicePrefixLen[5] =
    405 {
    406   8, 7, 6, 5, 4
    407 };
    408399
    409400Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight)
     
    573564#if H_MV_ENC_DEC_TRAC
    574565#if ENC_DEC_TRACE
     566Void stopAtPos( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight )
     567{
     568
     569  if ( g_outputPos )
     570  {
     571    std::cout << "POC\t"        << poc
     572              << "\tLayerId\t"  << layerId
     573              << "\tCuPelX\t"   << cuPelX 
     574              << "\tCuPelY\t"   << cuPelY
     575              << "\tCuWidth\t"  << cuWidth
     576              << "\tCuHeight\t" << cuHeight
     577              << std::endl;
     578  }
     579
     580  Bool stopFlag = false;
     581  if ( g_stopAtPos && poc == 0 && layerId == 1 )
     582  {
     583    Bool stopAtCU = true;
     584    if ( stopAtCU )        // Stop at CU with specific size
     585    {   
     586      stopFlag = ( cuPelX  == 888 ) && ( cuPelY  == 248 ) && ( cuWidth == 8 ) && ( cuHeight == 8);
     587    }
     588    else
     589    {                     // Stop at specific position
     590      Int xPos = 888;
     591      Int yPos = 248;
     592
     593      Int cuPelXEnd = cuPelX + cuWidth  - 1;
     594      Int cuPelYEnd = cuPelY + cuHeight - 1;
     595
     596      stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos );
     597    }
     598  }
     599 
     600  if ( stopFlag )
     601  { // Set breakpoint here.
     602    std::cout << "Stop position. Break point here." << std::endl;
     603  } 
     604}
     605
    575606Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt )
    576607{
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComRom.h

    r773 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6* Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    126126extern const UInt   g_uiMinInGroup[ 10 ];
    127127
    128 extern const UInt   g_auiGoRiceRange[5];                  //!< maximum value coded with Rice codes
    129 extern const UInt   g_auiGoRicePrefixLen[5];              //!< prefix length for each maximum value
    130  
    131128extern const UInt   g_sigLastScan8x8[ 3 ][ 4 ];           //!< coefficient group scan order for 8x8 TUs
    132129extern       UInt   g_sigLastScanCG32x32[ 64 ];
     
    222219 extern UInt64 g_stopAtCounter;         // Counter to set breakpoint.
    223220 extern Bool   g_traceCopyBack;         // Output samples on copy back 
    224  extern Bool   g_decTraceDispDer; // Trace derived disparity vectors (decoder only)
     221 extern Bool   g_decTraceDispDer;       // Trace derived disparity vectors (decoder only)
    225222 extern Bool   g_decTraceMvFromMerge;   // Trace motion vectors obtained from merge (decoder only)
     223 extern Bool   g_stopAtPos;             // Stop at position
     224 extern Bool   g_outputPos;             // Output position
    226225
    227226#define DTRACE_CU(x,y)             writeToTraceFile( x,y, g_traceCU );
     
    232231#define DTRACE_TU_S(x)             writeToTraceFile( x,   g_traceTU );
    233232
    234 
    235233 Void           writeToTraceFile( const Char* symbolName, Int val, Bool doIt );
    236234 Void           writeToTraceFile( const Char* symbolName, Bool doIt );
     235 Void           stopAtPos       ( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight );
    237236#endif
    238237#else
  • branches/HTM-10.0-dev0/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r608 r852  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2013, ITU/ISO/IEC
     6 * Copyright (c) 2010-2014, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4141#include <stdio.h>
    4242#include <math.h>
    43 
    4443//! \ingroup TLibCommon
    4544//! \{
    46 
    47 SAOParam::~SAOParam()
    48 {
    49   for (Int i = 0 ; i<3; i++)
    50   {
    51     if (psSaoPart[i])
    52     {
    53       delete [] psSaoPart[i];
    54     }
    55   }
    56 }
    57 
    58 // ====================================================================================================================
    59 // Tables
    60 // ====================================================================================================================
     45UInt g_saoMaxOffsetQVal[NUM_SAO_COMPONENTS];
     46
     47SAOOffset::SAOOffset()
     48{
     49  reset();
     50}
     51
     52SAOOffset::~SAOOffset()
     53{
     54
     55}
     56
     57Void SAOOffset::reset()
     58{
     59  modeIdc = SAO_MODE_OFF;
     60  typeIdc = -1;
     61  typeAuxInfo = -1;
     62  ::memset(offset, 0, sizeof(Int)* MAX_NUM_SAO_CLASSES);
     63}
     64
     65const SAOOffset& SAOOffset::operator= (const SAOOffset& src)
     66{
     67  modeIdc = src.modeIdc;
     68  typeIdc = src.typeIdc;
     69  typeAuxInfo = src.typeAuxInfo;
     70  ::memcpy(offset, src.offset, sizeof(Int)* MAX_NUM_SAO_CLASSES);
     71
     72  return *this;
     73}
     74
     75
     76SAOBlkParam::SAOBlkParam()
     77{
     78  reset();
     79}
     80
     81SAOBlkParam::~SAOBlkParam()
     82{
     83
     84}
     85
     86Void SAOBlkParam::reset()
     87{
     88  for(Int compIdx=0; compIdx< 3; compIdx++)
     89  {
     90    offsetParam[compIdx].reset();
     91  }
     92}
     93
     94const SAOBlkParam& SAOBlkParam::operator= (const SAOBlkParam& src)
     95{
     96  for(Int compIdx=0; compIdx< 3; compIdx++)
     97  {
     98    offsetParam[compIdx] = src.offsetParam[compIdx];
     99  }
     100  return *this;
     101
     102}
    61103
    62104TComSampleAdaptiveOffset::TComSampleAdaptiveOffset()
    63105{
    64   m_pClipTable = NULL;
    65   m_pClipTableBase = NULL;
    66   m_pChromaClipTable = NULL;
    67   m_pChromaClipTableBase = NULL;
    68   m_iOffsetBo = NULL;
    69   m_iChromaOffsetBo = NULL;
    70   m_lumaTableBo = NULL;
    71   m_chromaTableBo = NULL;
    72   m_iUpBuff1 = NULL;
    73   m_iUpBuff2 = NULL;
    74   m_iUpBufft = NULL;
    75   ipSwap = NULL;
    76 
    77   m_pTmpU1 = NULL;
    78   m_pTmpU2 = NULL;
    79   m_pTmpL1 = NULL;
    80   m_pTmpL2 = NULL;
    81 }
     106  m_tempPicYuv = NULL;
     107  for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     108  {
     109    m_offsetClipTable[compIdx] = NULL;
     110  }
     111  m_signTable = NULL;
     112
     113 
     114  m_lineBufWidth = 0;
     115  m_signLineBuf1 = NULL;
     116  m_signLineBuf2 = NULL;
     117}
     118
    82119
    83120TComSampleAdaptiveOffset::~TComSampleAdaptiveOffset()
    84121{
    85 
    86 }
    87 
    88 const Int TComSampleAdaptiveOffset::m_aiNumCulPartsLevel[5] =
    89 {
    90   1,   //level 0
    91   5,   //level 1
    92   21,  //level 2
    93   85,  //level 3
    94   341, //level 4
    95 };
    96 
    97 const UInt TComSampleAdaptiveOffset::m_auiEoTable[9] =
    98 {
    99   1, //0   
    100   2, //1   
    101   0, //2
    102   3, //3
    103   4, //4
    104   0, //5 
    105   0, //6 
    106   0, //7
    107   0
    108 };
    109 
    110 const Int TComSampleAdaptiveOffset::m_iNumClass[MAX_NUM_SAO_TYPE] =
    111 {
    112   SAO_EO_LEN,
    113   SAO_EO_LEN,
    114   SAO_EO_LEN,
    115   SAO_EO_LEN,
    116   SAO_BO_LEN
    117 };
    118 
    119 const UInt TComSampleAdaptiveOffset::m_uiMaxDepth = SAO_MAX_DEPTH;
    120 
    121 
    122 /** convert Level Row Col to Idx
    123  * \param   level,  row,  col
    124  */
    125 Int  TComSampleAdaptiveOffset::convertLevelRowCol2Idx(Int level, Int row, Int col)
    126 {
    127   Int idx;
    128   if (level == 0)
    129   {
    130     idx = 0;
    131   }
    132   else if (level == 1)
    133   {
    134     idx = 1 + row*2 + col;
    135   }
    136   else if (level == 2)
    137   {
    138     idx = 5 + row*4 + col;
    139   }
    140   else if (level == 3)
    141   {
    142     idx = 21 + row*8 + col;
    143   }
    144   else // (level == 4)
    145   {
    146     idx = 85 + row*16 + col;
    147   }
    148   return idx;
    149 }
    150 
    151 /** create SampleAdaptiveOffset memory.
    152  * \param
    153  */
    154 Void TComSampleAdaptiveOffset::create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight )
    155 {
    156   m_iPicWidth  = uiSourceWidth;
    157   m_iPicHeight = uiSourceHeight;
    158 
    159   m_uiMaxCUWidth  = uiMaxCUWidth;
    160   m_uiMaxCUHeight = uiMaxCUHeight;
    161 
    162   m_iNumCuInWidth  = m_iPicWidth / m_uiMaxCUWidth;
    163   m_iNumCuInWidth += ( m_iPicWidth % m_uiMaxCUWidth ) ? 1 : 0;
    164 
    165   m_iNumCuInHeight  = m_iPicHeight / m_uiMaxCUHeight;
    166   m_iNumCuInHeight += ( m_iPicHeight % m_uiMaxCUHeight ) ? 1 : 0;
    167 
    168   Int iMaxSplitLevelHeight = (Int)(logf((Float)m_iNumCuInHeight)/logf(2.0));
    169   Int iMaxSplitLevelWidth  = (Int)(logf((Float)m_iNumCuInWidth )/logf(2.0));
    170 
    171   m_uiMaxSplitLevel = (iMaxSplitLevelHeight < iMaxSplitLevelWidth)?(iMaxSplitLevelHeight):(iMaxSplitLevelWidth);
    172   m_uiMaxSplitLevel = (m_uiMaxSplitLevel< m_uiMaxDepth)?(m_uiMaxSplitLevel):(m_uiMaxDepth);
    173   /* various structures are overloaded to store per component data.
    174    * m_iNumTotalParts must allow for sufficient storage in any allocated arrays */
    175   m_iNumTotalParts  = max(3,m_aiNumCulPartsLevel[m_uiMaxSplitLevel]);
    176 
    177   UInt uiPixelRangeY = 1 << g_bitDepthY;
    178   UInt uiBoRangeShiftY = g_bitDepthY - SAO_BO_BITS;
    179 
    180   m_lumaTableBo = new Pel [uiPixelRangeY];
    181   for (Int k2=0; k2<uiPixelRangeY; k2++)
    182   {
    183     m_lumaTableBo[k2] = 1 + (k2>>uiBoRangeShiftY);
    184   }
    185 
    186   UInt uiPixelRangeC = 1 << g_bitDepthC;
    187   UInt uiBoRangeShiftC = g_bitDepthC - SAO_BO_BITS;
    188 
    189   m_chromaTableBo = new Pel [uiPixelRangeC];
    190   for (Int k2=0; k2<uiPixelRangeC; k2++)
    191   {
    192     m_chromaTableBo[k2] = 1 + (k2>>uiBoRangeShiftC);
    193   }
    194 
    195   m_iUpBuff1 = new Int[m_iPicWidth+2];
    196   m_iUpBuff2 = new Int[m_iPicWidth+2];
    197   m_iUpBufft = new Int[m_iPicWidth+2];
    198 
    199   m_iUpBuff1++;
    200   m_iUpBuff2++;
    201   m_iUpBufft++;
    202   Pel i;
    203 
    204   UInt uiMaxY  = (1 << g_bitDepthY) - 1;;
    205   UInt uiMinY  = 0;
    206 
    207   Int iCRangeExt = uiMaxY>>1;
    208 
    209   m_pClipTableBase = new Pel[uiMaxY+2*iCRangeExt];
    210   m_iOffsetBo      = new Int[uiMaxY+2*iCRangeExt];
    211 
    212   for(i=0;i<(uiMinY+iCRangeExt);i++)
    213   {
    214     m_pClipTableBase[i] = uiMinY;
    215   }
    216 
    217   for(i=uiMinY+iCRangeExt;i<(uiMaxY+  iCRangeExt);i++)
    218   {
    219     m_pClipTableBase[i] = i-iCRangeExt;
    220   }
    221 
    222   for(i=uiMaxY+iCRangeExt;i<(uiMaxY+2*iCRangeExt);i++)
    223   {
    224     m_pClipTableBase[i] = uiMaxY;
    225   }
    226 
    227   m_pClipTable = &(m_pClipTableBase[iCRangeExt]);
    228 
    229   UInt uiMaxC  = (1 << g_bitDepthC) - 1;
    230   UInt uiMinC  = 0;
    231 
    232   Int iCRangeExtC = uiMaxC>>1;
    233 
    234   m_pChromaClipTableBase = new Pel[uiMaxC+2*iCRangeExtC];
    235   m_iChromaOffsetBo      = new Int[uiMaxC+2*iCRangeExtC];
    236 
    237   for(i=0;i<(uiMinC+iCRangeExtC);i++)
    238   {
    239     m_pChromaClipTableBase[i] = uiMinC;
    240   }
    241 
    242   for(i=uiMinC+iCRangeExtC;i<(uiMaxC+  iCRangeExtC);i++)
    243   {
    244     m_pChromaClipTableBase[i] = i-iCRangeExtC;
    245   }
    246 
    247   for(i=uiMaxC+iCRangeExtC;i<(uiMaxC+2*iCRangeExtC);i++)
    248   {
    249     m_pChromaClipTableBase[i] = uiMaxC;
    250   }
    251 
    252   m_pChromaClipTable = &(m_pChromaClipTableBase[iCRangeExtC]);
    253 
    254   m_pTmpL1 = new Pel [m_uiMaxCUHeight+1];
    255   m_pTmpL2 = new Pel [m_uiMaxCUHeight+1];
    256   m_pTmpU1 = new Pel [m_iPicWidth];
    257   m_pTmpU2 = new Pel [m_iPicWidth];
    258 }
    259 
    260 /** destroy SampleAdaptiveOffset memory.
    261  * \param
    262  */
     122  destroy();
     123 
     124  if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL;
     125  if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL;
     126}
     127
     128Void TComSampleAdaptiveOffset::create( Int picWidth, Int picHeight, UInt maxCUWidth, UInt maxCUHeight, UInt maxCUDepth )
     129{
     130  destroy();
     131
     132  m_picWidth = picWidth;   
     133  m_picHeight= picHeight;
     134  m_maxCUWidth= maxCUWidth;
     135  m_maxCUHeight= maxCUHeight;
     136
     137  m_numCTUInWidth = (m_picWidth/m_maxCUWidth) + ((m_picWidth % m_maxCUWidth)?1:0);
     138  m_numCTUInHeight= (m_picHeight/m_maxCUHeight) + ((m_picHeight % m_maxCUHeight)?1:0);
     139  m_numCTUsPic = m_numCTUInHeight*m_numCTUInWidth;
     140
     141  //temporary picture buffer
     142  if ( !m_tempPicYuv )
     143  {
     144    m_tempPicYuv = new TComPicYuv;
     145    m_tempPicYuv->create( m_picWidth, m_picHeight, m_maxCUWidth, m_maxCUHeight, maxCUDepth );
     146  }
     147
     148  //bit-depth related
     149  for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     150  {
     151    Int bitDepthSample = (compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC;
     152    m_offsetStepLog2  [compIdx] = max(bitDepthSample - MAX_SAO_TRUNCATED_BITDEPTH, 0);
     153    g_saoMaxOffsetQVal[compIdx] = (1<<(min(bitDepthSample,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; //Table 9-32, inclusive
     154  }
     155
     156  //look-up table for clipping
     157  for(Int compIdx =0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     158  {
     159    Int bitDepthSample = (compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC; //exclusive
     160    Int maxSampleValue = (1<< bitDepthSample); //exclusive
     161    Int maxOffsetValue = (g_saoMaxOffsetQVal[compIdx] << m_offsetStepLog2[compIdx]);
     162
     163    m_offsetClipTable[compIdx] = new Int[(maxSampleValue + maxOffsetValue -1)+ (maxOffsetValue)+1 ]; //positive & negative range plus 0
     164    m_offsetClip[compIdx] = &(m_offsetClipTable[compIdx][maxOffsetValue]);
     165
     166    //assign clipped values
     167    Int* offsetClipPtr = m_offsetClip[compIdx];
     168    for(Int k=0; k< maxSampleValue; k++)
     169    {
     170      *(offsetClipPtr + k) = k;
     171    }
     172    for(Int k=0; k< maxOffsetValue; k++ )
     173    {
     174      *(offsetClipPtr + maxSampleValue+ k) = maxSampleValue-1;
     175      *(offsetClipPtr -k -1 )              = 0;
     176    }
     177    if(compIdx == SAO_Y) //g_bitDepthY is always larger than or equal to g_bitDepthC
     178    {
     179      m_signTable = new Short[ 2*(maxSampleValue-1) + 1 ];
     180      m_sign = &(m_signTable[maxSampleValue-1]);
     181
     182      m_sign[0] = 0;
     183      for(Int k=1; k< maxSampleValue; k++)
     184      {
     185        m_sign[k] = 1;
     186        m_sign[-k]= -1;
     187      }
     188    }
     189  } 
     190
     191}
     192
    263193Void TComSampleAdaptiveOffset::destroy()
    264194{
    265   if (m_pClipTableBase)
    266   {
    267     delete [] m_pClipTableBase; m_pClipTableBase = NULL;
    268   }
    269   if (m_iOffsetBo)
    270   {
    271     delete [] m_iOffsetBo; m_iOffsetBo = NULL;
    272   }
    273   if (m_lumaTableBo)
    274   {
    275     delete[] m_lumaTableBo; m_lumaTableBo = NULL;
    276   }
    277 
    278   if (m_pChromaClipTableBase)
    279   {
    280     delete [] m_pChromaClipTableBase; m_pChromaClipTableBase = NULL;
    281   }
    282   if (m_iChromaOffsetBo)
    283   {
    284     delete [] m_iChromaOffsetBo; m_iChromaOffsetBo = NULL;
    285   }
    286   if (m_chromaTableBo)
    287   {
    288     delete[] m_chromaTableBo; m_chromaTableBo = NULL;
    289   }
    290 
    291   if (m_iUpBuff1)
    292   {
    293     m_iUpBuff1--;
    294     delete [] m_iUpBuff1; m_iUpBuff1 = NULL;
    295   }
    296   if (m_iUpBuff2)
    297   {
    298     m_iUpBuff2--;
    299     delete [] m_iUpBuff2; m_iUpBuff2 = NULL;
    300   }
    301   if (m_iUpBufft)
    302   {
    303     m_iUpBufft--;
    304     delete [] m_iUpBufft; m_iUpBufft = NULL;
    305   }
    306   if (m_pTmpL1)
    307   {
    308     delete [] m_pTmpL1; m_pTmpL1 = NULL;
    309   }
    310   if (m_pTmpL2)
    311   {
    312     delete [] m_pTmpL2; m_pTmpL2 = NULL;
    313   }
    314   if (m_pTmpU1)
    315   {
    316     delete [] m_pTmpU1; m_pTmpU1 = NULL;
    317   }
    318   if (m_pTmpU2)
    319   {
    320     delete [] m_pTmpU2; m_pTmpU2 = NULL;
    321   }
    322 }
    323 
    324 /** allocate memory for SAO parameters
    325  * \param    *pcSaoParam
    326  */
    327 Void TComSampleAdaptiveOffset::allocSaoParam(SAOParam *pcSaoParam)
    328 {
    329   pcSaoParam->iMaxSplitLevel = m_uiMaxSplitLevel;
    330   pcSaoParam->psSaoPart[0] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    331   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,0);
    332   pcSaoParam->psSaoPart[1] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    333   pcSaoParam->psSaoPart[2] = new SAOQTPart[ m_aiNumCulPartsLevel[pcSaoParam->iMaxSplitLevel] ];
    334   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,1);
    335   initSAOParam(pcSaoParam, 0, 0, 0, -1, 0, m_iNumCuInWidth-1,  0, m_iNumCuInHeight-1,2);
    336   pcSaoParam->numCuInWidth  = m_iNumCuInWidth;
    337   pcSaoParam->numCuInHeight = m_iNumCuInHeight;
    338   pcSaoParam->saoLcuParam[0] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    339   pcSaoParam->saoLcuParam[1] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    340   pcSaoParam->saoLcuParam[2] = new SaoLcuParam [m_iNumCuInHeight*m_iNumCuInWidth];
    341 }
    342 
    343 /** initialize SAO parameters
    344  * \param    *pcSaoParam,  iPartLevel,  iPartRow,  iPartCol,  iParentPartIdx,  StartCUX,  EndCUX,  StartCUY,  EndCUY,  iYCbCr
    345  */
    346 Void TComSampleAdaptiveOffset::initSAOParam(SAOParam *pcSaoParam, Int iPartLevel, Int iPartRow, Int iPartCol, Int iParentPartIdx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY, Int iYCbCr)
    347 {
    348   Int j;
    349   Int iPartIdx = convertLevelRowCol2Idx(iPartLevel, iPartRow, iPartCol);
    350 
    351   SAOQTPart* pSaoPart;
    352 
    353   pSaoPart = &(pcSaoParam->psSaoPart[iYCbCr][iPartIdx]);
    354 
    355   pSaoPart->PartIdx   = iPartIdx;
    356   pSaoPart->PartLevel = iPartLevel;
    357   pSaoPart->PartRow   = iPartRow;
    358   pSaoPart->PartCol   = iPartCol;
    359 
    360   pSaoPart->StartCUX  = StartCUX;
    361   pSaoPart->EndCUX    = EndCUX;
    362   pSaoPart->StartCUY  = StartCUY;
    363   pSaoPart->EndCUY    = EndCUY;
    364 
    365   pSaoPart->UpPartIdx = iParentPartIdx;
    366   pSaoPart->iBestType   = -1;
    367   pSaoPart->iLength     =  0;
    368 
    369   pSaoPart->subTypeIdx = 0;
    370 
    371   for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    372   {
    373     pSaoPart->iOffset[j] = 0;
    374   }
    375 
    376   if(pSaoPart->PartLevel != m_uiMaxSplitLevel)
    377   {
    378     Int DownLevel    = (iPartLevel+1 );
    379     Int DownRowStart = (iPartRow << 1);
    380     Int DownColStart = (iPartCol << 1);
    381 
    382     Int iDownRowIdx, iDownColIdx;
    383     Int NumCUWidth,  NumCUHeight;
    384     Int NumCULeft;
    385     Int NumCUTop;
    386 
    387     Int DownStartCUX, DownStartCUY;
    388     Int DownEndCUX, DownEndCUY;
    389 
    390     NumCUWidth  = EndCUX - StartCUX +1;
    391     NumCUHeight = EndCUY - StartCUY +1;
    392     NumCULeft   = (NumCUWidth  >> 1);
    393     NumCUTop    = (NumCUHeight >> 1);
    394 
    395     DownStartCUX= StartCUX;
    396     DownEndCUX  = DownStartCUX + NumCULeft - 1;
    397     DownStartCUY= StartCUY;
    398     DownEndCUY  = DownStartCUY + NumCUTop  - 1;
    399     iDownRowIdx = DownRowStart + 0;
    400     iDownColIdx = DownColStart + 0;
    401 
    402     pSaoPart->DownPartsIdx[0]= convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    403 
    404     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx, DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    405 
    406     DownStartCUX = StartCUX + NumCULeft;
    407     DownEndCUX   = EndCUX;
    408     DownStartCUY = StartCUY;
    409     DownEndCUY   = DownStartCUY + NumCUTop -1;
    410     iDownRowIdx  = DownRowStart + 0;
    411     iDownColIdx  = DownColStart + 1;
    412 
    413     pSaoPart->DownPartsIdx[1] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    414 
    415     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx,  DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    416 
    417     DownStartCUX = StartCUX;
    418     DownEndCUX   = DownStartCUX + NumCULeft -1;
    419     DownStartCUY = StartCUY + NumCUTop;
    420     DownEndCUY   = EndCUY;
    421     iDownRowIdx  = DownRowStart + 1;
    422     iDownColIdx  = DownColStart + 0;
    423 
    424     pSaoPart->DownPartsIdx[2] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    425 
    426     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx, DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    427 
    428     DownStartCUX = StartCUX+ NumCULeft;
    429     DownEndCUX   = EndCUX;
    430     DownStartCUY = StartCUY + NumCUTop;
    431     DownEndCUY   = EndCUY;
    432     iDownRowIdx  = DownRowStart + 1;
    433     iDownColIdx  = DownColStart + 1;
    434 
    435     pSaoPart->DownPartsIdx[3] = convertLevelRowCol2Idx(DownLevel, iDownRowIdx, iDownColIdx);
    436 
    437     initSAOParam(pcSaoParam, DownLevel, iDownRowIdx, iDownColIdx, iPartIdx,DownStartCUX, DownEndCUX, DownStartCUY, DownEndCUY, iYCbCr);
    438   }
    439   else
    440   {
    441     pSaoPart->DownPartsIdx[0]=pSaoPart->DownPartsIdx[1]= pSaoPart->DownPartsIdx[2]= pSaoPart->DownPartsIdx[3]= -1;
    442   }
    443 }
    444 
    445 /** free memory of SAO parameters
    446  * \param   pcSaoParam
    447  */
    448 Void TComSampleAdaptiveOffset::freeSaoParam(SAOParam *pcSaoParam)
    449 {
    450   delete [] pcSaoParam->psSaoPart[0];
    451   delete [] pcSaoParam->psSaoPart[1];
    452   delete [] pcSaoParam->psSaoPart[2];
    453   pcSaoParam->psSaoPart[0] = 0;
    454   pcSaoParam->psSaoPart[1] = 0;
    455   pcSaoParam->psSaoPart[2] = 0;
    456   if( pcSaoParam->saoLcuParam[0])
    457   {
    458     delete [] pcSaoParam->saoLcuParam[0]; pcSaoParam->saoLcuParam[0] = NULL;
    459   }
    460   if( pcSaoParam->saoLcuParam[1])
    461   {
    462     delete [] pcSaoParam->saoLcuParam[1]; pcSaoParam->saoLcuParam[1] = NULL;
    463   }
    464   if( pcSaoParam->saoLcuParam[2])
    465   {
    466     delete [] pcSaoParam->saoLcuParam[2]; pcSaoParam->saoLcuParam[2] = NULL;
    467   }
    468 }
    469 
    470 /** reset SAO parameters
    471  * \param   pcSaoParam
    472  */
    473 Void TComSampleAdaptiveOffset::resetSAOParam(SAOParam *pcSaoParam)
    474 {
    475   Int iNumComponet = 3;
    476   for(Int c=0; c<iNumComponet; c++)
    477   {
    478 if (c<2)
    479   {
    480     pcSaoParam->bSaoFlag[c] = 0;
    481   }
    482     for(Int i=0; i< m_aiNumCulPartsLevel[m_uiMaxSplitLevel]; i++)
    483     {
    484       pcSaoParam->psSaoPart[c][i].iBestType     = -1;
    485       pcSaoParam->psSaoPart[c][i].iLength       =  0;
    486       pcSaoParam->psSaoPart[c][i].bSplit        = false;
    487       pcSaoParam->psSaoPart[c][i].bProcessed    = false;
    488       pcSaoParam->psSaoPart[c][i].dMinCost      = MAX_DOUBLE;
    489       pcSaoParam->psSaoPart[c][i].iMinDist      = MAX_INT;
    490       pcSaoParam->psSaoPart[c][i].iMinRate      = MAX_INT;
    491       pcSaoParam->psSaoPart[c][i].subTypeIdx    = 0;
    492       for (Int j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    493       {
    494         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    495         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    496         pcSaoParam->psSaoPart[c][i].iOffset[j] = 0;
    497       }
    498     }
    499     pcSaoParam->oneUnitFlag[0]   = 0;
    500     pcSaoParam->oneUnitFlag[1]   = 0;
    501     pcSaoParam->oneUnitFlag[2]   = 0;
    502     resetLcuPart(pcSaoParam->saoLcuParam[0]);
    503     resetLcuPart(pcSaoParam->saoLcuParam[1]);
    504     resetLcuPart(pcSaoParam->saoLcuParam[2]);
    505   }
    506 }
    507 
    508 /** get the sign of input variable
    509  * \param   x
    510  */
    511 inline Int xSign(Int x)
    512 {
    513   return ((x >> 31) | ((Int)( (((UInt) -x)) >> 31)));
    514 }
    515 
    516 /** initialize variables for SAO process
    517  * \param  pcPic picture data pointer
    518  */
    519 Void TComSampleAdaptiveOffset::createPicSaoInfo(TComPic* pcPic)
    520 {
    521   m_pcPic   = pcPic;
    522   m_bUseNIF = ( pcPic->getIndependentSliceBoundaryForNDBFilter() || pcPic->getIndependentTileBoundaryForNDBFilter() );
    523   if(m_bUseNIF)
    524   {
    525     m_pcYuvTmp = pcPic->getYuvPicBufferForIndependentBoundaryProcessing();
    526   }
    527 }
    528 
    529 Void TComSampleAdaptiveOffset::destroyPicSaoInfo()
    530 {
    531 
    532 }
    533 
    534 /** sample adaptive offset process for one LCU
    535  * \param   iAddr, iSaoType, iYCbCr
    536  */
    537 Void TComSampleAdaptiveOffset::processSaoCu(Int iAddr, Int iSaoType, Int iYCbCr)
    538 {
    539   if(!m_bUseNIF)
    540   {
    541     processSaoCuOrg( iAddr, iSaoType, iYCbCr);
    542   }
    543   else
    544   { 
    545     Int  isChroma = (iYCbCr != 0)? 1:0;
    546     Int  stride   = (iYCbCr != 0)?(m_pcPic->getCStride()):(m_pcPic->getStride());
    547     Pel* pPicRest = getPicYuvAddr(m_pcPic->getPicYuvRec(), iYCbCr);
    548     Pel* pPicDec  = getPicYuvAddr(m_pcYuvTmp, iYCbCr);
    549 
    550     std::vector<NDBFBlockInfo>& vFilterBlocks = *(m_pcPic->getCU(iAddr)->getNDBFilterBlocks());
    551 
    552     //variables
    553     UInt  xPos, yPos, width, height;
    554     Bool* pbBorderAvail;
    555     UInt  posOffset;
    556 
    557     for(Int i=0; i< vFilterBlocks.size(); i++)
    558     {
    559       xPos        = vFilterBlocks[i].posX   >> isChroma;
    560       yPos        = vFilterBlocks[i].posY   >> isChroma;
    561       width       = vFilterBlocks[i].width  >> isChroma;
    562       height      = vFilterBlocks[i].height >> isChroma;
    563       pbBorderAvail = vFilterBlocks[i].isBorderAvailable;
    564 
    565       posOffset = (yPos* stride) + xPos;
    566 
    567       processSaoBlock(pPicDec+ posOffset, pPicRest+ posOffset, stride, iSaoType, width, height, pbBorderAvail, iYCbCr);
    568     }
    569   }
    570 }
    571 
    572 /** Perform SAO for non-cross-slice or non-cross-tile process
    573  * \param  pDec to-be-filtered block buffer pointer
    574  * \param  pRest filtered block buffer pointer
    575  * \param  stride picture buffer stride
    576  * \param  saoType SAO offset type
    577  * \param  xPos x coordinate
    578  * \param  yPos y coordinate
    579  * \param  width block width
    580  * \param  height block height
    581  * \param  pbBorderAvail availabilities of block border pixels
    582  */
    583 Void TComSampleAdaptiveOffset::processSaoBlock(Pel* pDec, Pel* pRest, Int stride, Int saoType, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr)
    584 {
    585   //variables
    586   Int startX, startY, endX, endY, x, y;
    587   Int signLeft,signRight,signDown,signDown1;
    588   UInt edgeType;
    589   Pel *pClipTbl = (iYCbCr==0)?m_pClipTable:m_pChromaClipTable;
    590   Int *pOffsetBo = (iYCbCr==0)?m_iOffsetBo: m_iChromaOffsetBo;
    591 
    592   switch (saoType)
    593   {
    594   case SAO_EO_0: // dir: -
    595     {
    596 
    597       startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    598       endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
     195  if ( m_tempPicYuv )
     196  {
     197    m_tempPicYuv->destroy();
     198    delete m_tempPicYuv;
     199    m_tempPicYuv = NULL;
     200  }
     201
     202  for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     203  {
     204    if(m_offsetClipTable[compIdx])
     205    {
     206      delete[] m_offsetClipTable[compIdx]; m_offsetClipTable[compIdx] = NULL;
     207    }
     208  }
     209  if( m_signTable )
     210  {
     211    delete[] m_signTable; m_signTable = NULL;
     212  }
     213}
     214
     215Void TComSampleAdaptiveOffset::invertQuantOffsets(Int compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets)
     216{
     217  Int codedOffset[MAX_NUM_SAO_CLASSES];
     218
     219  ::memcpy(codedOffset, srcOffsets, sizeof(Int)*MAX_NUM_SAO_CLASSES);
     220  ::memset(dstOffsets, 0, sizeof(Int)*MAX_NUM_SAO_CLASSES);
     221
     222  if(typeIdc == SAO_TYPE_START_BO)
     223  {
     224    for(Int i=0; i< 4; i++)
     225    {
     226      dstOffsets[(typeAuxInfo+ i)%NUM_SAO_BO_CLASSES] = codedOffset[(typeAuxInfo+ i)%NUM_SAO_BO_CLASSES]*(1<<m_offsetStepLog2[compIdx]);
     227    }
     228  }
     229  else //EO
     230  {
     231    for(Int i=0; i< NUM_SAO_EO_CLASSES; i++)
     232    {
     233      dstOffsets[i] = codedOffset[i] *(1<<m_offsetStepLog2[compIdx]);
     234    }
     235    assert(dstOffsets[SAO_CLASS_EO_PLAIN] == 0); //keep EO plain offset as zero
     236  }
     237
     238}
     239
     240Int TComSampleAdaptiveOffset::getMergeList(TComPic* pic, Int ctu, SAOBlkParam* blkParams, std::vector<SAOBlkParam*>& mergeList)
     241{
     242  Int ctuX = ctu % m_numCTUInWidth;
     243  Int ctuY = ctu / m_numCTUInWidth;
     244  Int mergedCTUPos;
     245  Int numValidMergeCandidates = 0;
     246
     247  for(Int mergeType=0; mergeType< NUM_SAO_MERGE_TYPES; mergeType++)
     248  {
     249    SAOBlkParam* mergeCandidate = NULL;
     250
     251    switch(mergeType)
     252    {
     253    case SAO_MERGE_ABOVE:
     254      {
     255        if(ctuY > 0)
     256        {
     257          mergedCTUPos = ctu- m_numCTUInWidth;
     258          if( pic->getSAOMergeAvailability(ctu, mergedCTUPos) )
     259          {
     260            mergeCandidate = &(blkParams[mergedCTUPos]);
     261          }
     262        }
     263      }
     264      break;
     265    case SAO_MERGE_LEFT:
     266      {
     267        if(ctuX > 0)
     268        {
     269          mergedCTUPos = ctu- 1;
     270          if( pic->getSAOMergeAvailability(ctu, mergedCTUPos) )
     271          {
     272            mergeCandidate = &(blkParams[mergedCTUPos]);
     273          }
     274        }
     275      }
     276      break;
     277    default:
     278      {
     279        printf("not a supported merge type");
     280        assert(0);
     281        exit(-1);
     282      }
     283    }
     284
     285    mergeList.push_back(mergeCandidate);
     286    if (mergeCandidate != NULL)
     287    {
     288      numValidMergeCandidates++;
     289    }
     290  }
     291
     292  return numValidMergeCandidates;
     293}
     294
     295
     296Void TComSampleAdaptiveOffset::reconstructBlkSAOParam(SAOBlkParam& recParam, std::vector<SAOBlkParam*>& mergeList)
     297{
     298  for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++)
     299  {
     300    SAOOffset& offsetParam = recParam[compIdx];
     301
     302    if(offsetParam.modeIdc == SAO_MODE_OFF)
     303    {
     304      continue;
     305    }
     306
     307    switch(offsetParam.modeIdc)
     308    {
     309    case SAO_MODE_NEW:
     310      {
     311        invertQuantOffsets(compIdx, offsetParam.typeIdc, offsetParam.typeAuxInfo, offsetParam.offset, offsetParam.offset);
     312      }
     313      break;
     314    case SAO_MODE_MERGE:
     315      {
     316        SAOBlkParam* mergeTarget = mergeList[offsetParam.typeIdc];
     317        assert(mergeTarget != NULL);
     318
     319        offsetParam = (*mergeTarget)[compIdx];
     320      }
     321      break;
     322    default:
     323      {
     324        printf("Not a supported mode");
     325        assert(0);
     326        exit(-1);
     327      }
     328    }
     329  }
     330}
     331
     332Void TComSampleAdaptiveOffset::reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams)
     333{
     334  m_picSAOEnabled[SAO_Y] = m_picSAOEnabled[SAO_Cb] = m_picSAOEnabled[SAO_Cr] = false;
     335
     336  for(Int ctu=0; ctu< m_numCTUsPic; ctu++)
     337  {
     338    std::vector<SAOBlkParam*> mergeList;
     339    getMergeList(pic, ctu, saoBlkParams, mergeList);
     340
     341    reconstructBlkSAOParam(saoBlkParams[ctu], mergeList);
     342
     343    for(Int compIdx=0; compIdx< NUM_SAO_COMPONENTS; compIdx++)
     344    {
     345      if(saoBlkParams[ctu][compIdx].modeIdc != SAO_MODE_OFF)
     346      {
     347        m_picSAOEnabled[compIdx] = true;
     348      }
     349    }
     350  }
     351
     352
     353}
     354
     355
     356Void TComSampleAdaptiveOffset::offsetBlock(Int compIdx, Int typeIdx, Int* offset 
     357                                          , Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
     358                                          , Bool isLeftAvail,  Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail)
     359{
     360  if(m_lineBufWidth != m_maxCUWidth)
     361  {
     362    m_lineBufWidth = m_maxCUWidth;
     363   
     364    if (m_signLineBuf1) delete[] m_signLineBuf1; m_signLineBuf1 = NULL;
     365    m_signLineBuf1 = new Char[m_lineBufWidth+1];
     366   
     367    if (m_signLineBuf2) delete[] m_signLineBuf2; m_signLineBuf2 = NULL;
     368    m_signLineBuf2 = new Char[m_lineBufWidth+1];
     369  }
     370
     371  Int* offsetClip = m_offsetClip[compIdx];
     372
     373  Int x,y, startX, startY, endX, endY, edgeType;
     374  Int firstLineStartX, firstLineEndX, lastLineStartX, lastLineEndX;
     375  Char signLeft, signRight, signDown;
     376
     377  Pel* srcLine = srcBlk;
     378  Pel* resLine = resBlk;
     379
     380  switch(typeIdx)
     381  {
     382  case SAO_TYPE_EO_0:
     383    {
     384      offset += 2;
     385      startX = isLeftAvail ? 0 : 1;
     386      endX   = isRightAvail ? width : (width -1);
    599387      for (y=0; y< height; y++)
    600388      {
    601         signLeft = xSign(pDec[startX] - pDec[startX-1]);
     389        signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
    602390        for (x=startX; x< endX; x++)
    603391        {
    604           signRight =  xSign(pDec[x] - pDec[x+1]);
    605           edgeType =  signRight + signLeft + 2;
     392          signRight = (Char)m_sign[srcLine[x] - srcLine[x+1]];
     393          edgeType =  signRight + signLeft;
    606394          signLeft  = -signRight;
    607395
    608           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
     396          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    609397        }
    610         pDec  += stride;
    611         pRest += stride;
    612       }
    613       break;
    614     }
    615   case SAO_EO_1: // dir: |
    616     {
    617       startY = (pbBorderAvail[SGU_T]) ? 0 : 1;
    618       endY   = (pbBorderAvail[SGU_B]) ? height : height-1;
    619       if (!pbBorderAvail[SGU_T])
    620       {
    621         pDec  += stride;
    622         pRest += stride;
    623       }
     398        srcLine  += srcStride;
     399        resLine += resStride;
     400      }
     401
     402    }
     403    break;
     404  case SAO_TYPE_EO_90:
     405    {
     406      offset += 2;
     407      Char *signUpLine = m_signLineBuf1;
     408
     409      startY = isAboveAvail ? 0 : 1;
     410      endY   = isBelowAvail ? height : height-1;
     411      if (!isAboveAvail)
     412      {
     413        srcLine += srcStride;
     414        resLine += resStride;
     415      }
     416
     417      Pel* srcLineAbove= srcLine- srcStride;
    624418      for (x=0; x< width; x++)
    625419      {
    626         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x-stride]);
    627       }
     420        signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]];
     421      }
     422
     423      Pel* srcLineBelow;
    628424      for (y=startY; y<endY; y++)
    629425      {
     426        srcLineBelow= srcLine+ srcStride;
     427
    630428        for (x=0; x< width; x++)
    631429        {
    632           signDown  = xSign(pDec[x] - pDec[x+stride]);
    633           edgeType = signDown + m_iUpBuff1[x] + 2;
    634           m_iUpBuff1[x]= -signDown;
    635 
    636           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
     430          signDown  = (Char)m_sign[srcLine[x] - srcLineBelow[x]];
     431          edgeType = signDown + signUpLine[x];
     432          signUpLine[x]= -signDown;
     433
     434          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
    637435        }
    638         pDec  += stride;
    639         pRest += stride;
    640       }
    641       break;
    642     }
    643   case SAO_EO_2: // dir: 135
    644     {
    645       Int posShift= stride + 1;
    646 
    647       startX = (pbBorderAvail[SGU_L]) ? 0 : 1 ;
    648       endX   = (pbBorderAvail[SGU_R]) ? width : (width-1);
    649 
    650       //prepare 2nd line upper sign
    651       pDec += stride;
     436        srcLine += srcStride;
     437        resLine += resStride;
     438      }
     439
     440    }
     441    break;
     442  case SAO_TYPE_EO_135:
     443    {
     444      offset += 2;
     445      Char *signUpLine, *signDownLine, *signTmpLine;
     446
     447      signUpLine  = m_signLineBuf1;
     448      signDownLine= m_signLineBuf2;
     449
     450      startX = isLeftAvail ? 0 : 1 ;
     451      endX   = isRightAvail ? width : (width-1);
     452
     453      //prepare 2nd line's upper sign
     454      Pel* srcLineBelow= srcLine+ srcStride;
    652455      for (x=startX; x< endX+1; x++)
    653456      {
    654         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x- posShift]);
     457        signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x- 1]];
    655458      }
    656459
    657460      //1st line
    658       pDec -= stride;
    659       if(pbBorderAvail[SGU_TL])
    660       {
    661         x= 0;
    662         edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    663         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    664 
    665       }
    666       if(pbBorderAvail[SGU_T])
    667       {
    668         for(x= 1; x< endX; x++)
    669         {
    670           edgeType      =  xSign(pDec[x] - pDec[x- posShift]) - m_iUpBuff1[x+1] + 2;
    671           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    672         }
    673       }
    674       pDec   += stride;
    675       pRest  += stride;
     461      Pel* srcLineAbove= srcLine- srcStride;
     462      firstLineStartX = isAboveLeftAvail ? 0 : 1;
     463      firstLineEndX   = isAboveAvail? endX: 1;
     464      for(x= firstLineStartX; x< firstLineEndX; x++)
     465      {
     466        edgeType  =  m_sign[srcLine[x] - srcLineAbove[x- 1]] - signUpLine[x+1];
     467        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     468      }
     469      srcLine  += srcStride;
     470      resLine  += resStride;
    676471
    677472
     
    679474      for (y= 1; y< height-1; y++)
    680475      {
     476        srcLineBelow= srcLine+ srcStride;
     477
    681478        for (x=startX; x<endX; x++)
    682479        {
    683           signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    684           edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    685           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    686 
    687           m_iUpBufft[x+1] = -signDown1;
     480          signDown =  (Char)m_sign[srcLine[x] - srcLineBelow[x+ 1]] ;
     481          edgeType =  signDown + signUpLine[x];
     482          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     483
     484          signDownLine[x+1] = -signDown;
    688485        }
    689         m_iUpBufft[startX] = xSign(pDec[stride+startX] - pDec[startX-1]);
    690 
    691         ipSwap     = m_iUpBuff1;
    692         m_iUpBuff1 = m_iUpBufft;
    693         m_iUpBufft = ipSwap;
    694 
    695         pDec  += stride;
    696         pRest += stride;
     486        signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]];
     487
     488        signTmpLine  = signUpLine;
     489        signUpLine   = signDownLine;
     490        signDownLine = signTmpLine;
     491
     492        srcLine += srcStride;
     493        resLine += resStride;
    697494      }
    698495
    699496      //last line
    700       if(pbBorderAvail[SGU_B])
    701       {
    702         for(x= startX; x< width-1; x++)
    703         {
    704           edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    705           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    706         }
    707       }
    708       if(pbBorderAvail[SGU_BR])
    709       {
    710         x= width -1;
    711         edgeType =  xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    712         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    713       }
    714       break;
    715     }
    716   case SAO_EO_3: // dir: 45
    717     {
    718       Int  posShift     = stride - 1;
    719       startX = (pbBorderAvail[SGU_L]) ? 0 : 1;
    720       endX   = (pbBorderAvail[SGU_R]) ? width : (width -1);
     497      srcLineBelow= srcLine+ srcStride;
     498      lastLineStartX = isBelowAvail ? startX : (width -1);
     499      lastLineEndX   = isBelowRightAvail ? width : (width -1);
     500      for(x= lastLineStartX; x< lastLineEndX; x++)
     501      {
     502        edgeType =  m_sign[srcLine[x] - srcLineBelow[x+ 1]] + signUpLine[x];
     503        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     504
     505      }
     506    }
     507    break;
     508  case SAO_TYPE_EO_45:
     509    {
     510      offset += 2;
     511      Char *signUpLine = m_signLineBuf1+1;
     512
     513      startX = isLeftAvail ? 0 : 1;
     514      endX   = isRightAvail ? width : (width -1);
    721515
    722516      //prepare 2nd line upper sign
    723       pDec += stride;
     517      Pel* srcLineBelow= srcLine+ srcStride;
    724518      for (x=startX-1; x< endX; x++)
    725519      {
    726         m_iUpBuff1[x] = xSign(pDec[x] - pDec[x- posShift]);
     520        signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]];
    727521      }
    728522
    729523
    730524      //first line
    731       pDec -= stride;
    732       if(pbBorderAvail[SGU_T])
    733       {
    734         for(x= startX; x< width -1; x++)
    735         {
    736           edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    737           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    738         }
    739       }
    740       if(pbBorderAvail[SGU_TR])
    741       {
    742         x= width-1;
    743         edgeType = xSign(pDec[x] - pDec[x- posShift]) -m_iUpBuff1[x-1] + 2;
    744         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    745       }
    746       pDec  += stride;
    747       pRest += stride;
     525      Pel* srcLineAbove= srcLine- srcStride;
     526      firstLineStartX = isAboveAvail ? startX : (width -1 );
     527      firstLineEndX   = isAboveRightAvail ? width : (width-1);
     528      for(x= firstLineStartX; x< firstLineEndX; x++)
     529      {
     530        edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] -signUpLine[x-1];
     531        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     532      }
     533      srcLine += srcStride;
     534      resLine += resStride;
    748535
    749536      //middle lines
    750537      for (y= 1; y< height-1; y++)
    751538      {
     539        srcLineBelow= srcLine+ srcStride;
     540
    752541        for(x= startX; x< endX; x++)
    753542        {
    754           signDown1      =  xSign(pDec[x] - pDec[x+ posShift]) ;
    755           edgeType      =  signDown1 + m_iUpBuff1[x] + 2;
    756 
    757           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    758           m_iUpBuff1[x-1] = -signDown1;
     543          signDown =  (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ;
     544          edgeType =  signDown + signUpLine[x];
     545          resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     546          signUpLine[x-1] = -signDown;
    759547        }
    760         m_iUpBuff1[endX-1] = xSign(pDec[endX-1 + stride] - pDec[endX]);
    761 
    762         pDec  += stride;
    763         pRest += stride;
     548        signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]];
     549        srcLine  += srcStride;
     550        resLine += resStride;
    764551      }
    765552
    766553      //last line
    767       if(pbBorderAvail[SGU_BL])
    768       {
    769         x= 0;
    770         edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    771         pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    772 
    773       }
    774       if(pbBorderAvail[SGU_B])
    775       {
    776         for(x= 1; x< endX; x++)
    777         {
    778           edgeType = xSign(pDec[x] - pDec[x+ posShift]) + m_iUpBuff1[x] + 2;
    779           pRest[x] = pClipTbl[pDec[x] + m_iOffsetEo[edgeType]];
    780         }
    781       }
    782       break;
    783     }   
    784   case SAO_BO:
    785     {
     554      srcLineBelow= srcLine+ srcStride;
     555      lastLineStartX = isBelowLeftAvail ? 0 : 1;
     556      lastLineEndX   = isBelowAvail ? endX : 1;
     557      for(x= lastLineStartX; x< lastLineEndX; x++)
     558      {
     559        edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + signUpLine[x];
     560        resLine[x] = offsetClip[srcLine[x] + offset[edgeType]];
     561
     562      }
     563    }
     564    break;
     565  case SAO_TYPE_BO:
     566    {
     567      Int shiftBits = ((compIdx == SAO_Y)?g_bitDepthY:g_bitDepthC)- NUM_SAO_BO_CLASSES_LOG2;
    786568      for (y=0; y< height; y++)
    787569      {
    788570        for (x=0; x< width; x++)
    789571        {
    790           pRest[x] = pOffsetBo[pDec[x]];
     572          resLine[x] = offsetClip[ srcLine[x] + offset[srcLine[x] >> shiftBits] ];
    791573        }
    792         pRest += stride;
    793         pDec  += stride;
    794       }
    795       break;
    796     }
    797   default: break;
    798   }
    799 
    800 }
    801 
    802 /** sample adaptive offset process for one LCU crossing LCU boundary
    803  * \param   iAddr, iSaoType, iYCbCr
    804  */
    805 Void TComSampleAdaptiveOffset::processSaoCuOrg(Int iAddr, Int iSaoType, Int iYCbCr)
    806 {
    807   Int x,y;
    808   TComDataCU *pTmpCu = m_pcPic->getCU(iAddr);
    809   Pel* pRec;
    810   Int  iStride;
    811   Int  iLcuWidth  = m_uiMaxCUWidth;
    812   Int  iLcuHeight = m_uiMaxCUHeight;
    813   UInt uiLPelX    = pTmpCu->getCUPelX();
    814   UInt uiTPelY    = pTmpCu->getCUPelY();
    815   UInt uiRPelX;
    816   UInt uiBPelY;
    817   Int  iSignLeft;
    818   Int  iSignRight;
    819   Int  iSignDown;
    820   Int  iSignDown1;
    821   Int  iSignDown2;
    822   UInt uiEdgeType;
    823   Int iPicWidthTmp;
    824   Int iPicHeightTmp;
    825   Int iStartX;
    826   Int iStartY;
    827   Int iEndX;
    828   Int iEndY;
    829   Int iIsChroma = (iYCbCr!=0)? 1:0;
    830   Int iShift;
    831   Int iCuHeightTmp;
    832   Pel *pTmpLSwap;
    833   Pel *pTmpL;
    834   Pel *pTmpU;
    835   Pel *pClipTbl = NULL;
    836   Int *pOffsetBo = NULL;
    837 
    838   iPicWidthTmp  = m_iPicWidth  >> iIsChroma;
    839   iPicHeightTmp = m_iPicHeight >> iIsChroma;
    840   iLcuWidth     = iLcuWidth    >> iIsChroma;
    841   iLcuHeight    = iLcuHeight   >> iIsChroma;
    842   uiLPelX       = uiLPelX      >> iIsChroma;
    843   uiTPelY       = uiTPelY      >> iIsChroma;
    844   uiRPelX       = uiLPelX + iLcuWidth  ;
    845   uiBPelY       = uiTPelY + iLcuHeight ;
    846   uiRPelX       = uiRPelX > iPicWidthTmp  ? iPicWidthTmp  : uiRPelX;
    847   uiBPelY       = uiBPelY > iPicHeightTmp ? iPicHeightTmp : uiBPelY;
    848   iLcuWidth     = uiRPelX - uiLPelX;
    849   iLcuHeight    = uiBPelY - uiTPelY;
    850 
    851   if(pTmpCu->getPic()==0)
    852   {
    853     return;
    854   }
    855   if (iYCbCr == 0)
    856   {
    857     pRec       = m_pcPic->getPicYuvRec()->getLumaAddr(iAddr);
    858     iStride    = m_pcPic->getStride();
    859   }
    860   else if (iYCbCr == 1)
    861   {
    862     pRec       = m_pcPic->getPicYuvRec()->getCbAddr(iAddr);
    863     iStride    = m_pcPic->getCStride();
    864   }
    865   else
    866   {
    867     pRec       = m_pcPic->getPicYuvRec()->getCrAddr(iAddr);
    868     iStride    = m_pcPic->getCStride();
    869   }
    870 
    871 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
    872   {
    873     iCuHeightTmp = (m_uiMaxCUHeight >> iIsChroma);
    874     iShift = (m_uiMaxCUWidth>> iIsChroma)-1;
    875     for (Int i=0;i<iCuHeightTmp+1;i++)
    876     {
    877       m_pTmpL2[i] = pRec[iShift];
    878       pRec += iStride;
    879     }
    880     pRec -= (iStride*(iCuHeightTmp+1));
    881 
    882     pTmpL = m_pTmpL1;
    883     pTmpU = &(m_pTmpU1[uiLPelX]);
    884   }
    885 
    886   pClipTbl = (iYCbCr==0)? m_pClipTable:m_pChromaClipTable;
    887   pOffsetBo = (iYCbCr==0)? m_iOffsetBo:m_iChromaOffsetBo;
    888 
    889   switch (iSaoType)
    890   {
    891   case SAO_EO_0: // dir: -
    892     {
    893       iStartX = (uiLPelX == 0) ? 1 : 0;
    894       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    895       for (y=0; y<iLcuHeight; y++)
    896       {
    897         iSignLeft = xSign(pRec[iStartX] - pTmpL[y]);
    898         for (x=iStartX; x< iEndX; x++)
    899         {
    900           iSignRight =  xSign(pRec[x] - pRec[x+1]);
    901           uiEdgeType =  iSignRight + iSignLeft + 2;
    902           iSignLeft  = -iSignRight;
    903 
    904           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    905         }
    906         pRec += iStride;
    907       }
    908       break;
    909     }
    910   case SAO_EO_1: // dir: |
    911     {
    912       iStartY = (uiTPelY == 0) ? 1 : 0;
    913       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    914       if (uiTPelY == 0)
    915       {
    916         pRec += iStride;
    917       }
    918       for (x=0; x< iLcuWidth; x++)
    919       {
    920         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x]);
    921       }
    922       for (y=iStartY; y<iEndY; y++)
    923       {
    924         for (x=0; x<iLcuWidth; x++)
    925         {
    926           iSignDown  = xSign(pRec[x] - pRec[x+iStride]);
    927           uiEdgeType = iSignDown + m_iUpBuff1[x] + 2;
    928           m_iUpBuff1[x]= -iSignDown;
    929 
    930           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    931         }
    932         pRec += iStride;
    933       }
    934       break;
    935     }
    936   case SAO_EO_2: // dir: 135
    937     {
    938       iStartX = (uiLPelX == 0)            ? 1 : 0;
    939       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    940 
    941       iStartY = (uiTPelY == 0) ?             1 : 0;
    942       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    943 
    944       if (uiTPelY == 0)
    945       {
    946         pRec += iStride;
    947       }
    948 
    949       for (x=iStartX; x<iEndX; x++)
    950       {
    951         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x-1]);
    952       }
    953       for (y=iStartY; y<iEndY; y++)
    954       {
    955         iSignDown2 = xSign(pRec[iStride+iStartX] - pTmpL[y]);
    956         for (x=iStartX; x<iEndX; x++)
    957         {
    958           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride+1]) ;
    959           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    960           m_iUpBufft[x+1] = -iSignDown1;
    961           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    962         }
    963         m_iUpBufft[iStartX] = iSignDown2;
    964 
    965         ipSwap     = m_iUpBuff1;
    966         m_iUpBuff1 = m_iUpBufft;
    967         m_iUpBufft = ipSwap;
    968 
    969         pRec += iStride;
    970       }
    971       break;
    972     }
    973   case SAO_EO_3: // dir: 45
    974     {
    975       iStartX = (uiLPelX == 0) ? 1 : 0;
    976       iEndX   = (uiRPelX == iPicWidthTmp) ? iLcuWidth-1 : iLcuWidth;
    977 
    978       iStartY = (uiTPelY == 0) ? 1 : 0;
    979       iEndY   = (uiBPelY == iPicHeightTmp) ? iLcuHeight-1 : iLcuHeight;
    980 
    981       if (iStartY == 1)
    982       {
    983         pRec += iStride;
    984       }
    985 
    986       for (x=iStartX-1; x<iEndX; x++)
    987       {
    988         m_iUpBuff1[x] = xSign(pRec[x] - pTmpU[x+1]);
    989       }
    990       for (y=iStartY; y<iEndY; y++)
    991       {
    992         x=iStartX;
    993         iSignDown1      =  xSign(pRec[x] - pTmpL[y+1]) ;
    994         uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    995         m_iUpBuff1[x-1] = -iSignDown1;
    996         pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    997         for (x=iStartX+1; x<iEndX; x++)
    998         {
    999           iSignDown1      =  xSign(pRec[x] - pRec[x+iStride-1]) ;
    1000           uiEdgeType      =  iSignDown1 + m_iUpBuff1[x] + 2;
    1001           m_iUpBuff1[x-1] = -iSignDown1;
    1002           pRec[x] = pClipTbl[pRec[x] + m_iOffsetEo[uiEdgeType]];
    1003         }
    1004         m_iUpBuff1[iEndX-1] = xSign(pRec[iEndX-1 + iStride] - pRec[iEndX]);
    1005 
    1006         pRec += iStride;
    1007       }
    1008       break;
    1009     }   
    1010   case SAO_BO:
    1011     {
    1012       for (y=0; y<iLcuHeight; y++)
    1013       {
    1014         for (x=0; x<iLcuWidth; x++)
    1015         {
    1016           pRec[x] = pOffsetBo[pRec[x]];
    1017         }
    1018         pRec += iStride;
    1019       }
    1020       break;
    1021     }
    1022   default: break;
    1023   }
    1024 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
    1025   {
    1026     pTmpLSwap = m_pTmpL1;
    1027     m_pTmpL1  = m_pTmpL2;
    1028     m_pTmpL2  = pTmpLSwap;
    1029   }
    1030 }
    1031 /** Sample adaptive offset process
    1032  * \param pcPic, pcSaoParam 
    1033  */
    1034 Void TComSampleAdaptiveOffset::SAOProcess(SAOParam* pcSaoParam)
    1035 {
    1036   {
    1037     m_uiSaoBitIncreaseY = max(g_bitDepthY - 10, 0);
    1038     m_uiSaoBitIncreaseC = max(g_bitDepthC - 10, 0);
    1039 
    1040     if(m_bUseNIF)
    1041     {
    1042       m_pcPic->getPicYuvRec()->copyToPic(m_pcYuvTmp);
    1043     }
    1044     if (m_saoLcuBasedOptimization)
    1045     {
    1046       pcSaoParam->oneUnitFlag[0] = 0; 
    1047       pcSaoParam->oneUnitFlag[1] = 0; 
    1048       pcSaoParam->oneUnitFlag[2] = 0; 
    1049     }
    1050     Int iY  = 0;
    1051     {
    1052       processSaoUnitAll( pcSaoParam->saoLcuParam[iY], pcSaoParam->oneUnitFlag[iY], iY);
    1053     }
    1054     {
    1055        processSaoUnitAll( pcSaoParam->saoLcuParam[1], pcSaoParam->oneUnitFlag[1], 1);//Cb
    1056        processSaoUnitAll( pcSaoParam->saoLcuParam[2], pcSaoParam->oneUnitFlag[2], 2);//Cr
    1057     }
    1058     m_pcPic = NULL;
    1059   }
    1060 }
    1061 
    1062 Pel* TComSampleAdaptiveOffset::getPicYuvAddr(TComPicYuv* pcPicYuv, Int iYCbCr, Int iAddr)
    1063 {
    1064   switch (iYCbCr)
    1065   {
    1066   case 0:
    1067     return pcPicYuv->getLumaAddr(iAddr);
    1068     break;
    1069   case 1:
    1070     return pcPicYuv->getCbAddr(iAddr);
    1071     break;
    1072   case 2:
    1073     return pcPicYuv->getCrAddr(iAddr);
     574        srcLine += srcStride;
     575        resLine += resStride;
     576      }
     577    }
    1074578    break;
    1075579  default:
    1076     return NULL;
     580    {
     581      printf("Not a supported SAO types\n");
     582      assert(0);
     583      exit(-1);
     584    }
     585  }
     586
     587
     588}
     589
     590Void TComSampleAdaptiveOffset::offsetCTU(Int ctu, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam& saoblkParam, TComPic* pPic)
     591{
     592  Bool isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail;
     593
     594  if(
     595    (saoblkParam[SAO_Y ].modeIdc == SAO_MODE_OFF) &&
     596    (saoblkParam[SAO_Cb].modeIdc == SAO_MODE_OFF) &&
     597    (saoblkParam[SAO_Cr].modeIdc == SAO_MODE_OFF)
     598    )
     599  {
     600    return;
     601  }
     602
     603  //block boundary availability
     604  pPic->getPicSym()->deriveLoopFilterBoundaryAvailibility(ctu, isLeftAvail,isRightAvail,isAboveAvail,isBelowAvail,isAboveLeftAvail,isAboveRightAvail,isBelowLeftAvail,isBelowRightAvail);
     605
     606  Int yPos   = (ctu / m_numCTUInWidth)*m_maxCUHeight;
     607  Int xPos   = (ctu % m_numCTUInWidth)*m_maxCUWidth;
     608  Int height = (yPos + m_maxCUHeight > m_picHeight)?(m_picHeight- yPos):m_maxCUHeight;
     609  Int width  = (xPos + m_maxCUWidth  > m_picWidth )?(m_picWidth - xPos):m_maxCUWidth;
     610
     611  for(Int compIdx= 0; compIdx < NUM_SAO_COMPONENTS; compIdx++)
     612  {
     613    SAOOffset& ctbOffset = saoblkParam[compIdx];
     614
     615    if(ctbOffset.modeIdc != SAO_MODE_OFF)
     616    {
     617      Bool isLuma     = (compIdx == SAO_Y);
     618      Int  formatShift= isLuma?0:1;
     619
     620      Int  blkWidth   = (width  >> formatShift);
     621      Int  blkHeight  = (height >> formatShift);
     622      Int  blkYPos    = (yPos   >> formatShift);
     623      Int  blkXPos    = (xPos   >> formatShift);
     624
     625      Int  srcStride = isLuma?srcYuv->getStride():srcYuv->getCStride();
     626      Pel* srcBlk    = getPicBuf(srcYuv, compIdx)+ (yPos >> formatShift)*srcStride+ (xPos >> formatShift);
     627
     628      Int  resStride  = isLuma?resYuv->getStride():resYuv->getCStride();
     629      Pel* resBlk     = getPicBuf(resYuv, compIdx)+ blkYPos*resStride+ blkXPos;
     630
     631      offsetBlock( compIdx, ctbOffset.typeIdc, ctbOffset.offset
     632                  , srcBlk, resBlk, srcStride, resStride, blkWidth, blkHeight
     633                  , isLeftAvail, isRightAvail
     634                  , isAboveAvail, isBelowAvail
     635                  , isAboveLeftAvail, isAboveRightAvail
     636                  , isBelowLeftAvail, isBelowRightAvail
     637                  );
     638    }
     639  } //compIdx
     640
     641}
     642
     643
     644Void TComSampleAdaptiveOffset::SAOProcess(TComPic* pDecPic)
     645{
     646  if(!m_picSAOEnabled[SAO_Y] && !m_picSAOEnabled[SAO_Cb] && !m_picSAOEnabled[SAO_Cr])
     647  {
     648    return;
     649  }
     650  TComPicYuv* resYuv = pDecPic->getPicYuvRec();
     651  TComPicYuv* srcYuv = m_tempPicYuv;
     652  resYuv->copyToPic(srcYuv);
     653  for(Int ctu= 0; ctu < m_numCTUsPic; ctu++)
     654  {
     655    offsetCTU(ctu, srcYuv, resYuv, (pDecPic->getPicSym()->getSAOBlkParam())[ctu], pDecPic);
     656  } //ctu
     657}
     658
     659
     660Pel* TComSampleAdaptiveOffset::getPicBuf(TComPicYuv* pPicYuv, Int compIdx)
     661{
     662  Pel* pBuf = NULL;
     663  switch(compIdx)
     664  {
     665  case SAO_Y:
     666    {
     667      pBuf = pPicYuv->getLumaAddr();
     668    }
    1077669    break;
    1078   }
    1079 }
    1080 /** Process SAO all units
    1081  * \param saoLcuParam SAO LCU parameters
    1082  * \param oneUnitFlag one unit flag
    1083  * \param yCbCr color componet index
    1084  */
    1085 Void TComSampleAdaptiveOffset::processSaoUnitAll(SaoLcuParam* saoLcuParam, Bool oneUnitFlag, Int yCbCr)
    1086 {
    1087   Pel *pRec;
    1088   Int picWidthTmp;
    1089 
    1090   if (yCbCr == 0)
    1091   {
    1092     pRec        = m_pcPic->getPicYuvRec()->getLumaAddr();
    1093     picWidthTmp = m_iPicWidth;
    1094   }
    1095   else if (yCbCr == 1)
    1096   {
    1097     pRec        = m_pcPic->getPicYuvRec()->getCbAddr();
    1098     picWidthTmp = m_iPicWidth>>1;
    1099   }
    1100   else
    1101   {
    1102     pRec        = m_pcPic->getPicYuvRec()->getCrAddr();
    1103     picWidthTmp = m_iPicWidth>>1;
    1104   }
    1105 
    1106   memcpy(m_pTmpU1, pRec, sizeof(Pel)*picWidthTmp);
    1107 
    1108   Int  i;
    1109   UInt edgeType;
    1110   Pel* ppLumaTable = NULL;
    1111   Pel* pClipTable = NULL;
    1112   Int* pOffsetBo = NULL;
    1113   Int  typeIdx;
    1114 
    1115   Int offset[LUMA_GROUP_NUM+1];
    1116   Int idxX;
    1117   Int idxY;
    1118   Int addr;
    1119   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1120   Int frameHeightInCU = m_pcPic->getFrameHeightInCU();
    1121   Int stride;
    1122   Pel *tmpUSwap;
    1123   Int isChroma = (yCbCr == 0) ? 0:1;
    1124   Bool mergeLeftFlag;
    1125   Int saoBitIncrease = (yCbCr == 0) ? m_uiSaoBitIncreaseY : m_uiSaoBitIncreaseC;
    1126 
    1127   pOffsetBo = (yCbCr==0) ? m_iOffsetBo : m_iChromaOffsetBo;
    1128 
    1129   offset[0] = 0;
    1130   for (idxY = 0; idxY< frameHeightInCU; idxY++)
    1131   {
    1132     addr = idxY * frameWidthInCU;
    1133     if (yCbCr == 0)
    1134     {
    1135       pRec  = m_pcPic->getPicYuvRec()->getLumaAddr(addr);
    1136       stride = m_pcPic->getStride();
    1137       picWidthTmp = m_iPicWidth;
    1138     }
    1139     else if (yCbCr == 1)
    1140     {
    1141       pRec  = m_pcPic->getPicYuvRec()->getCbAddr(addr);
    1142       stride = m_pcPic->getCStride();
    1143       picWidthTmp = m_iPicWidth>>1;
    1144     }
    1145     else
    1146     {
    1147       pRec  = m_pcPic->getPicYuvRec()->getCrAddr(addr);
    1148       stride = m_pcPic->getCStride();
    1149       picWidthTmp = m_iPicWidth>>1;
    1150     }
    1151 
    1152     //     pRec += iStride*(m_uiMaxCUHeight-1);
    1153     for (i=0;i<(m_uiMaxCUHeight>>isChroma)+1;i++)
    1154     {
    1155       m_pTmpL1[i] = pRec[0];
    1156       pRec+=stride;
    1157     }
    1158     pRec-=(stride<<1);
    1159 
    1160     memcpy(m_pTmpU2, pRec, sizeof(Pel)*picWidthTmp);
    1161 
    1162     for (idxX = 0; idxX < frameWidthInCU; idxX++)
    1163     {
    1164       addr = idxY * frameWidthInCU + idxX;
    1165 
    1166       if (oneUnitFlag)
    1167       {
    1168         typeIdx = saoLcuParam[0].typeIdx;
    1169         mergeLeftFlag = (addr == 0)? 0:1;
    1170       }
    1171       else
    1172       {
    1173         typeIdx = saoLcuParam[addr].typeIdx;
    1174         mergeLeftFlag = saoLcuParam[addr].mergeLeftFlag;
    1175       }
    1176       if (typeIdx>=0)
    1177       {
    1178         if (!mergeLeftFlag)
    1179         {
    1180 
    1181           if (typeIdx == SAO_BO)
    1182           {
    1183             for (i=0; i<SAO_MAX_BO_CLASSES+1;i++)
    1184             {
    1185               offset[i] = 0;
    1186             }
    1187             for (i=0; i<saoLcuParam[addr].length; i++)
    1188             {
    1189               offset[ (saoLcuParam[addr].subTypeIdx +i)%SAO_MAX_BO_CLASSES  +1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    1190             }
    1191 
    1192             ppLumaTable = (yCbCr==0)?m_lumaTableBo:m_chromaTableBo;
    1193             pClipTable = (yCbCr==0)?m_pClipTable:m_pChromaClipTable;
    1194 
    1195             Int bitDepth = (yCbCr==0) ? g_bitDepthY : g_bitDepthC;
    1196             for (i=0;i<(1<<bitDepth);i++)
    1197             {
    1198               pOffsetBo[i] = pClipTable[i + offset[ppLumaTable[i]]];
    1199             }
    1200 
    1201           }
    1202           if (typeIdx == SAO_EO_0 || typeIdx == SAO_EO_1 || typeIdx == SAO_EO_2 || typeIdx == SAO_EO_3)
    1203           {
    1204             for (i=0;i<saoLcuParam[addr].length;i++)
    1205             {
    1206               offset[i+1] = saoLcuParam[addr].offset[i] << saoBitIncrease;
    1207             }
    1208             for (edgeType=0;edgeType<6;edgeType++)
    1209             {
    1210               m_iOffsetEo[edgeType]= offset[m_auiEoTable[edgeType]];
    1211             }
    1212           }
    1213         }
    1214         processSaoCu(addr, typeIdx, yCbCr);
    1215       }
    1216       else
    1217       {
    1218         if (idxX != (frameWidthInCU-1))
    1219         {
    1220           if (yCbCr == 0)
    1221           {
    1222             pRec  = m_pcPic->getPicYuvRec()->getLumaAddr(addr);
    1223             stride = m_pcPic->getStride();
    1224           }
    1225           else if (yCbCr == 1)
    1226           {
    1227             pRec  = m_pcPic->getPicYuvRec()->getCbAddr(addr);
    1228             stride = m_pcPic->getCStride();
    1229           }
    1230           else
    1231           {
    1232             pRec  = m_pcPic->getPicYuvRec()->getCrAddr(addr);
    1233             stride = m_pcPic->getCStride();
    1234           }
    1235           Int widthShift = m_uiMaxCUWidth>>isChroma;
    1236           for (i=0;i<(m_uiMaxCUHeight>>isChroma)+1;i++)
    1237           {
    1238             m_pTmpL1[i] = pRec[widthShift-1];
    1239             pRec+=stride;
    1240           }
    1241         }
    1242       }
    1243     }
    1244     tmpUSwap = m_pTmpU1;
    1245     m_pTmpU1 = m_pTmpU2;
    1246     m_pTmpU2 = tmpUSwap;
    1247   }
    1248 
    1249 }
    1250 /** Reset SAO LCU part
    1251  * \param saoLcuParam
    1252  */
    1253 Void TComSampleAdaptiveOffset::resetLcuPart(SaoLcuParam* saoLcuParam)
    1254 {
    1255   Int i,j;
    1256   for (i=0;i<m_iNumCuInWidth*m_iNumCuInHeight;i++)
    1257   {
    1258     saoLcuParam[i].mergeUpFlag     =  1;
    1259     saoLcuParam[i].mergeLeftFlag =  0;
    1260     saoLcuParam[i].partIdx   =  0;
    1261     saoLcuParam[i].typeIdx      = -1;
    1262     for (j=0;j<MAX_NUM_SAO_OFFSETS;j++)
    1263     {
    1264       saoLcuParam[i].offset[j] = 0;
    1265     }
    1266     saoLcuParam[i].subTypeIdx = 0;
    1267   }
    1268 }
    1269 
    1270 /** convert QP part to SAO unit
    1271 * \param saoParam SAO parameter
    1272 * \param partIdx SAO part index
    1273 * \param yCbCr color component index
    1274  */
    1275 Void TComSampleAdaptiveOffset::convertQT2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr)
    1276 {
    1277 
    1278   SAOQTPart*  saoPart= &(saoParam->psSaoPart[yCbCr][partIdx]);
    1279   if (!saoPart->bSplit)
    1280   {
    1281     convertOnePart2SaoUnit(saoParam, partIdx, yCbCr);
    1282     return;
    1283   }
    1284 
    1285   if (saoPart->PartLevel < m_uiMaxSplitLevel)
    1286   {
    1287     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[0], yCbCr);
    1288     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[1], yCbCr);
    1289     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[2], yCbCr);
    1290     convertQT2SaoUnit(saoParam, saoPart->DownPartsIdx[3], yCbCr);
    1291   }
    1292 }
    1293 /** convert one SAO part to SAO unit
    1294 * \param saoParam SAO parameter
    1295 * \param partIdx SAO part index
    1296 * \param yCbCr color component index
    1297  */
    1298 Void TComSampleAdaptiveOffset::convertOnePart2SaoUnit(SAOParam *saoParam, UInt partIdx, Int yCbCr)
    1299 {
    1300   Int j;
    1301   Int idxX;
    1302   Int idxY;
    1303   Int addr;
    1304   Int frameWidthInCU = m_pcPic->getFrameWidthInCU();
    1305   SAOQTPart* saoQTPart = saoParam->psSaoPart[yCbCr];
    1306   SaoLcuParam* saoLcuParam = saoParam->saoLcuParam[yCbCr];
    1307 
    1308   for (idxY = saoQTPart[partIdx].StartCUY; idxY<= saoQTPart[partIdx].EndCUY; idxY++)
    1309