source: 3DVCSoftware/branches/HTM-14.1-update-dev1/source/Lib/TLibCommon/TComChromaFormat.cpp @ 1305

Last change on this file since 1305 was 1200, checked in by tech, 9 years ago

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
  • Property svn:eol-style set to native
File size: 5.8 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35#include "TComChromaFormat.h"
36#include "TComPic.h"
37#include "TComDataCU.h"
38#include "TComTrQuant.h"
39#include "TComTU.h"
40
41
42
43
44//----------------------------------------------------------------------------------------------------------------------
45
46InputColourSpaceConversion stringToInputColourSpaceConvert(const std::string &value, const Bool bIsForward)
47{
48  if (value.empty() || value=="UNCHANGED")
49  {
50    return IPCOLOURSPACE_UNCHANGED;
51  }
52  if (bIsForward)
53  {
54    if (value=="YCbCrtoYYY")
55    {
56      return IPCOLOURSPACE_YCbCrtoYYY;
57    }
58    if (value=="YCbCrtoYCrCb")
59    {
60      return IPCOLOURSPACE_YCbCrtoYCrCb;
61    }
62    if (value=="RGBtoGBR")
63    {
64      return IPCOLOURSPACE_RGBtoGBR;
65    }
66  }
67  else
68  {
69    if (value=="YCrCbtoYCbCr")
70    {
71      return IPCOLOURSPACE_YCbCrtoYCrCb;
72    }
73    if (value=="GBRtoRGB")
74    {
75      return IPCOLOURSPACE_RGBtoGBR;
76    }
77  }
78  return NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS;
79}
80
81std::string getListOfColourSpaceConverts(const Bool bIsForward)
82{
83  if (bIsForward)
84  {
85    return "UNCHANGED, YCbCrtoYCrCb, YCbCrtoYYY or RGBtoGBR";
86  }
87  else
88  {
89    return "UNCHANGED, YCrCbtoYCbCr or GBRtoRGB";
90  }
91}
92
93
94//----------------------------------------------------------------------------------------------------------------------
95
96Void getTUEntropyCodingParameters(      TUEntropyCodingParameters &result,
97                                        TComTU                    &rTu,
98                                  const ComponentID                component)
99{
100  //------------------------------------------------
101
102  //set the local parameters
103
104        TComDataCU    *const pcCU            = rTu.getCU();
105  const TComRectangle &      area            = rTu.getRect(component);
106  const UInt                 uiAbsPartIdx    = rTu.GetAbsPartIdxTU(component);
107  const UInt                 log2BlockWidth  = g_aucConvertToBit[area.width]  + 2;
108  const UInt                 log2BlockHeight = g_aucConvertToBit[area.height] + 2;
109  const ChannelType          channelType     = toChannelType(component);
110
111  result.scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, area.width, area.height, component));
112
113  //------------------------------------------------
114
115  //set the group layout
116
117  result.widthInGroups  = area.width  >> MLS_CG_LOG2_WIDTH;
118  result.heightInGroups = area.height >> MLS_CG_LOG2_HEIGHT;
119
120  //------------------------------------------------
121
122  //set the scan orders
123
124  const UInt log2WidthInGroups  = g_aucConvertToBit[result.widthInGroups  * 4];
125  const UInt log2HeightInGroups = g_aucConvertToBit[result.heightInGroups * 4];
126
127  result.scan   = g_scanOrder[ SCAN_GROUPED_4x4 ][ result.scanType ][ log2BlockWidth    ][ log2BlockHeight    ];
128  result.scanCG = g_scanOrder[ SCAN_UNGROUPED   ][ result.scanType ][ log2WidthInGroups ][ log2HeightInGroups ];
129
130  //------------------------------------------------
131
132  //set the significance map context selection parameters
133
134  if (pcCU->getSlice()->getSPS()->getSpsRangeExtension().getTransformSkipContextEnabledFlag()
135      && (pcCU->getCUTransquantBypass(uiAbsPartIdx) || (pcCU->getTransformSkip(uiAbsPartIdx, component) != 0)))
136  {
137    result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_SINGLE];
138  }
139  else
140  {
141    if ((area.width == 4) && (area.height == 4))
142    {
143      result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_4x4];
144    }
145    else if ((area.width == 8) && (area.height == 8))
146    {
147      result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_8x8];
148      if (result.scanType != SCAN_DIAG)
149      {
150        result.firstSignificanceMapContext += nonDiagonalScan8x8ContextOffset[channelType];
151      }
152    }
153    else
154    {
155      result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_NxN];
156    }
157  }
158
159  //------------------------------------------------
160}
161
162
163//----------------------------------------------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.