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-2014, 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 | |
---|
46 | InputColourSpaceConversion stringToInputColourSpaceConvert(const std::string &value, const Bool bIsForward) |
---|
47 | { |
---|
48 | if (value.empty() || value=="UNCHANGED") return IPCOLOURSPACE_UNCHANGED; |
---|
49 | if (bIsForward) |
---|
50 | { |
---|
51 | if (value=="YCbCrtoYYY") return IPCOLOURSPACE_YCbCrtoYYY; |
---|
52 | if (value=="YCbCrtoYCrCb") return IPCOLOURSPACE_YCbCrtoYCrCb; |
---|
53 | if (value=="RGBtoGBR") return IPCOLOURSPACE_RGBtoGBR; |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | if (value=="YCrCbtoYCbCr") return IPCOLOURSPACE_YCbCrtoYCrCb; |
---|
58 | if (value=="GBRtoRGB") return IPCOLOURSPACE_RGBtoGBR; |
---|
59 | } |
---|
60 | return NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS; |
---|
61 | } |
---|
62 | |
---|
63 | std::string getListOfColourSpaceConverts(const Bool bIsForward) |
---|
64 | { |
---|
65 | if (bIsForward) |
---|
66 | { |
---|
67 | return "UNCHANGED, YCbCrtoYCrCb, YCbCrtoYYY or RGBtoGBR"; |
---|
68 | } |
---|
69 | else |
---|
70 | { |
---|
71 | return "UNCHANGED, YCrCbtoYCbCr or GBRtoRGB"; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | //---------------------------------------------------------------------------------------------------------------------- |
---|
77 | |
---|
78 | Void getTUEntropyCodingParameters( TUEntropyCodingParameters &result, |
---|
79 | TComTU &rTu, |
---|
80 | const ComponentID component) |
---|
81 | { |
---|
82 | //------------------------------------------------ |
---|
83 | |
---|
84 | //set the local parameters |
---|
85 | |
---|
86 | TComDataCU *const pcCU = rTu.getCU(); |
---|
87 | const TComRectangle & area = rTu.getRect(component); |
---|
88 | const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(component); |
---|
89 | const UInt log2BlockWidth = g_aucConvertToBit[area.width] + 2; |
---|
90 | const UInt log2BlockHeight = g_aucConvertToBit[area.height] + 2; |
---|
91 | const ChannelType channelType = toChannelType(component); |
---|
92 | |
---|
93 | result.scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, area.width, area.height, component)); |
---|
94 | |
---|
95 | //------------------------------------------------ |
---|
96 | |
---|
97 | //set the group layout |
---|
98 | |
---|
99 | result.widthInGroups = area.width >> MLS_CG_LOG2_WIDTH; |
---|
100 | result.heightInGroups = area.height >> MLS_CG_LOG2_HEIGHT; |
---|
101 | |
---|
102 | //------------------------------------------------ |
---|
103 | |
---|
104 | //set the scan orders |
---|
105 | |
---|
106 | const UInt log2WidthInGroups = g_aucConvertToBit[result.widthInGroups * 4]; |
---|
107 | const UInt log2HeightInGroups = g_aucConvertToBit[result.heightInGroups * 4]; |
---|
108 | |
---|
109 | result.scan = g_scanOrder[ SCAN_GROUPED_4x4 ][ result.scanType ][ log2BlockWidth ][ log2BlockHeight ]; |
---|
110 | result.scanCG = g_scanOrder[ SCAN_UNGROUPED ][ result.scanType ][ log2WidthInGroups ][ log2HeightInGroups ]; |
---|
111 | |
---|
112 | //------------------------------------------------ |
---|
113 | |
---|
114 | //set the significance map context selection parameters |
---|
115 | |
---|
116 | if (pcCU->getSlice()->getSPS()->getUseSingleSignificanceMapContext() |
---|
117 | && (pcCU->getCUTransquantBypass(uiAbsPartIdx) || (pcCU->getTransformSkip(uiAbsPartIdx, component) != 0))) |
---|
118 | { |
---|
119 | result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_SINGLE]; |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | if ((area.width == 4) && (area.height == 4)) |
---|
124 | { |
---|
125 | result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_4x4]; |
---|
126 | } |
---|
127 | else if ((area.width == 8) && (area.height == 8)) |
---|
128 | { |
---|
129 | result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_8x8]; |
---|
130 | if (result.scanType != SCAN_DIAG) result.firstSignificanceMapContext += nonDiagonalScan8x8ContextOffset[channelType]; |
---|
131 | } |
---|
132 | else |
---|
133 | { |
---|
134 | result.firstSignificanceMapContext = significanceMapContextSetStart[channelType][CONTEXT_TYPE_NxN]; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | //------------------------------------------------ |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | //---------------------------------------------------------------------------------------------------------------------- |
---|