/src/libde265/libde265/intrapred.h
Line | Count | Source |
1 | | /* |
2 | | * H.265 video codec. |
3 | | * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de> |
4 | | * |
5 | | * This file is part of libde265. |
6 | | * |
7 | | * libde265 is free software: you can redistribute it and/or modify |
8 | | * it under the terms of the GNU Lesser General Public License as |
9 | | * published by the Free Software Foundation, either version 3 of |
10 | | * the License, or (at your option) any later version. |
11 | | * |
12 | | * libde265 is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | * GNU Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public License |
18 | | * along with libde265. If not, see <http://www.gnu.org/licenses/>. |
19 | | */ |
20 | | |
21 | | #ifndef DE265_INTRAPRED_H |
22 | | #define DE265_INTRAPRED_H |
23 | | |
24 | | #include "libde265/decctx.h" |
25 | | |
26 | | extern const int intraPredAngle_table[1+34]; |
27 | | |
28 | | |
29 | | /* Fill the three intra-pred-mode candidates into candModeList. |
30 | | Block position is (x,y) and you also have to give the PUidx for this |
31 | | block (which is (x>>Log2MinPUSize) + (y>>Log2MinPUSize)*PicWidthInMinPUs). |
32 | | availableA/B is the output of check_CTB_available(). |
33 | | */ |
34 | | void fillIntraPredModeCandidates(enum IntraPredMode candModeList[3], |
35 | | int x,int y, int PUidx, |
36 | | bool availableA, // left |
37 | | bool availableB, // top |
38 | | const de265_image* img); |
39 | | |
40 | | |
41 | | inline void fillIntraPredModeCandidates(enum IntraPredMode candModeList[3], int x,int y, |
42 | | bool availableA, // left |
43 | | bool availableB, // top |
44 | | const de265_image* img) |
45 | 0 | { |
46 | 0 | int PUidx = img->get_sps().getPUIndexRS(x,y); |
47 | 0 | fillIntraPredModeCandidates(candModeList, x,y, PUidx, availableA,availableB, img); |
48 | 0 | } |
49 | | |
50 | | void fillIntraPredModeCandidates(enum IntraPredMode candModeList[3], |
51 | | enum IntraPredMode candIntraPredModeA, |
52 | | enum IntraPredMode candIntraPredModeB); |
53 | | |
54 | | |
55 | | /* Return value >= 0 -> use mpm_idx(return value) |
56 | | else -> use rem_intra(-return value-1) |
57 | | |
58 | | This function may modify the candModeList ! |
59 | | */ |
60 | | int find_intra_pred_mode(enum IntraPredMode mode, |
61 | | enum IntraPredMode candModeList[3]); |
62 | | |
63 | | void list_chroma_pred_candidates(enum IntraPredMode chroma_mode[5], |
64 | | enum IntraPredMode luma_mode); |
65 | | |
66 | | int get_intra_scan_idx(int log2TrafoSize, enum IntraPredMode intraPredMode, int cIdx, |
67 | | const seq_parameter_set* sps); |
68 | | |
69 | | int get_intra_scan_idx_luma (int log2TrafoSize, enum IntraPredMode intraPredMode); // DEPRECATED |
70 | | int get_intra_scan_idx_chroma(int log2TrafoSize, enum IntraPredMode intraPredMode); // DEPRECATED |
71 | | |
72 | | enum IntraPredMode lumaPredMode_to_chromaPredMode(enum IntraPredMode luma, |
73 | | enum IntraChromaPredMode chroma); |
74 | | |
75 | | /* |
76 | | void decode_intra_block(decoder_context* ctx, |
77 | | thread_context* tctx, |
78 | | int cIdx, |
79 | | int xB0,int yB0, // position of TU in frame (chroma adapted) |
80 | | int x0,int y0, // position of CU in frame (chroma adapted) |
81 | | int log2TrafoSize, int trafoDepth, |
82 | | enum IntraPredMode intraPredMode, |
83 | | bool transform_skip_flag); |
84 | | */ |
85 | | |
86 | | //void fill_border_samples(decoder_context* ctx, int xB,int yB, |
87 | | // int nT, int cIdx, uint8_t* out_border); |
88 | | |
89 | | void decode_intra_prediction(de265_image* img, |
90 | | int xB0,int yB0, |
91 | | enum IntraPredMode intraPredMode, |
92 | | int nT, int cIdx); |
93 | | |
94 | | // TODO: remove this |
95 | | template <class pixel_t> void decode_intra_prediction(de265_image* img, |
96 | | int xB0,int yB0, |
97 | | enum IntraPredMode intraPredMode, |
98 | | pixel_t* dst, int nT, int cIdx); |
99 | | |
100 | | |
101 | | |
102 | | |
103 | | // --- internal use only --- |
104 | | |
105 | | // Actually, the largest TB block can only be 32, but in some intra-pred-mode algorithms |
106 | | // (e.g. min-residual), we may call intra prediction on the maximum CTB size (64). |
107 | | static const int MAX_INTRA_PRED_BLOCK_SIZE = 64; |
108 | | |
109 | | |
110 | | template <class pixel_t> |
111 | | class intra_border_computer |
112 | | { |
113 | | public: |
114 | | pixel_t* out_border; |
115 | | |
116 | | const de265_image* img; |
117 | | int nT; |
118 | | int cIdx; |
119 | | |
120 | | int xB,yB; |
121 | | |
122 | | const seq_parameter_set* sps; |
123 | | const pic_parameter_set* pps; |
124 | | |
125 | | uint8_t available_data[4*MAX_INTRA_PRED_BLOCK_SIZE + 1]; |
126 | | uint8_t* available; |
127 | | |
128 | | int SubWidth; |
129 | | int SubHeight; |
130 | | |
131 | | bool availableLeft; // is CTB at left side available? |
132 | | bool availableTop; // is CTB at top side available? |
133 | | bool availableTopRight; // is CTB at top-right side available? |
134 | | bool availableTopLeft; // if CTB at top-left pixel available? |
135 | | |
136 | | int nBottom; |
137 | | int nRight; |
138 | | int nAvail; |
139 | | pixel_t firstValue; |
140 | | |
141 | | void init(pixel_t* _out_border, |
142 | 9.98M | const de265_image* _img, int _nT, int _cIdx, int _xB, int _yB) { |
143 | 9.98M | img=_img; nT=_nT; cIdx=_cIdx; |
144 | 9.98M | out_border=_out_border; xB=_xB; yB=_yB; |
145 | | |
146 | 9.98M | assert(nT <= MAX_INTRA_PRED_BLOCK_SIZE); |
147 | | |
148 | 9.98M | availableLeft=true; |
149 | 9.98M | availableTop=true; |
150 | 9.98M | availableTopRight=true; |
151 | 9.98M | availableTopLeft=true; |
152 | 9.98M | } intra_border_computer<unsigned short>::init(unsigned short*, de265_image const*, int, int, int, int) Line | Count | Source | 142 | 5.27M | const de265_image* _img, int _nT, int _cIdx, int _xB, int _yB) { | 143 | 5.27M | img=_img; nT=_nT; cIdx=_cIdx; | 144 | 5.27M | out_border=_out_border; xB=_xB; yB=_yB; | 145 | | | 146 | 5.27M | assert(nT <= MAX_INTRA_PRED_BLOCK_SIZE); | 147 | | | 148 | 5.27M | availableLeft=true; | 149 | 5.27M | availableTop=true; | 150 | 5.27M | availableTopRight=true; | 151 | 5.27M | availableTopLeft=true; | 152 | 5.27M | } |
intra_border_computer<unsigned char>::init(unsigned char*, de265_image const*, int, int, int, int) Line | Count | Source | 142 | 4.70M | const de265_image* _img, int _nT, int _cIdx, int _xB, int _yB) { | 143 | 4.70M | img=_img; nT=_nT; cIdx=_cIdx; | 144 | 4.70M | out_border=_out_border; xB=_xB; yB=_yB; | 145 | | | 146 | 4.70M | assert(nT <= MAX_INTRA_PRED_BLOCK_SIZE); | 147 | | | 148 | 4.70M | availableLeft=true; | 149 | 4.70M | availableTop=true; | 150 | 4.70M | availableTopRight=true; | 151 | 4.70M | availableTopLeft=true; | 152 | 4.70M | } |
|
153 | | void preproc(); |
154 | | void fill_from_image(); |
155 | | |
156 | | void reference_sample_substitution(); |
157 | | }; |
158 | | |
159 | | |
160 | | #ifdef DE265_LOG_TRACE |
161 | | template <class pixel_t> |
162 | | void print_border(pixel_t* data, uint8_t* available, int nT) |
163 | | { |
164 | | for (int i=-2*nT ; i<=2*nT ; i++) { |
165 | | if (i==0 || i==1 || i==-nT || i==nT+1) { |
166 | | logtrace(LogIntraPred,"|"); |
167 | | } else { |
168 | | logtrace(LogIntraPred," "); |
169 | | } |
170 | | |
171 | | if (available==nullptr || available[i]) { |
172 | | logtrace(LogIntraPred,"%02x",data[i]); |
173 | | } |
174 | | else { |
175 | | logtrace(LogIntraPred,"--"); |
176 | | } |
177 | | } |
178 | | } |
179 | | #else |
180 | | #define print_border(data, available, nT) |
181 | | #endif |
182 | | |
183 | | |
184 | | // (8.4.4.2.3) |
185 | | template <class pixel_t> |
186 | | void intra_prediction_sample_filtering(const seq_parameter_set& sps, |
187 | | pixel_t* p, |
188 | | int nT, int cIdx, |
189 | | enum IntraPredMode intraPredMode) |
190 | 4.74M | { |
191 | 4.74M | int filterFlag; |
192 | | |
193 | | //printf("filtering, mode: %d\n",intraPredMode); |
194 | | |
195 | 4.74M | if (intraPredMode==INTRA_DC || nT==4) { |
196 | 4.13M | filterFlag = 0; |
197 | 4.13M | } else { |
198 | 607k | int minDistVerHor = std::min( std::abs((int)intraPredMode-26), |
199 | 607k | std::abs((int)intraPredMode-10) ); |
200 | | |
201 | | //printf("mindist: %d\n",minDistVerHor); |
202 | | |
203 | 607k | switch (nT) { |
204 | 560k | case 8: filterFlag = (minDistVerHor>7) ? 1 : 0; break; |
205 | 35.1k | case 16: filterFlag = (minDistVerHor>1) ? 1 : 0; break; |
206 | 11.9k | case 32: filterFlag = (minDistVerHor>0) ? 1 : 0; break; |
207 | | // there is no official 64x64 TB block, but we call this for some intra-pred mode algorithms |
208 | | // on the whole CB (2Nx2N mode for the whole CTB) |
209 | 0 | case 64: filterFlag = 0; break; |
210 | 0 | default: filterFlag = -1; assert(false); break; // should never happen |
211 | 607k | } |
212 | 607k | } |
213 | | |
214 | | |
215 | 4.74M | if (filterFlag) { |
216 | 395k | int biIntFlag = (sps.strong_intra_smoothing_enable_flag && |
217 | 293k | cIdx==0 && |
218 | 262k | nT==32 && |
219 | 6.98k | std::abs(p[0]+p[ 64]-2*p[ 32]) < (1<<(sps.bit_depth_luma-5)) && |
220 | 5.79k | std::abs(p[0]+p[-64]-2*p[-32]) < (1<<(sps.bit_depth_luma-5))) |
221 | 395k | ? 1 : 0; |
222 | | |
223 | 395k | pixel_t pF_mem[4*32+1]; |
224 | 395k | pixel_t* pF = &pF_mem[2*32]; |
225 | | |
226 | 395k | if (biIntFlag) { |
227 | 4.03k | pF[-2*nT] = p[-2*nT]; |
228 | 4.03k | pF[ 2*nT] = p[ 2*nT]; |
229 | 4.03k | pF[ 0] = p[ 0]; |
230 | | |
231 | 258k | for (int i=1;i<=63;i++) { |
232 | 254k | pF[-i] = p[0] + ((i*(p[-64]-p[0])+32)>>6); |
233 | 254k | pF[ i] = p[0] + ((i*(p[ 64]-p[0])+32)>>6); |
234 | 254k | } |
235 | 391k | } else { |
236 | 391k | pF[-2*nT] = p[-2*nT]; |
237 | 391k | pF[ 2*nT] = p[ 2*nT]; |
238 | | |
239 | 14.0M | for (int i=-(2*nT-1) ; i<=2*nT-1 ; i++) |
240 | 13.6M | { |
241 | 13.6M | pF[i] = (p[i+1] + 2*p[i] + p[i-1] + 2) >> 2; |
242 | 13.6M | } |
243 | 391k | } |
244 | | |
245 | | |
246 | | // copy back to original array |
247 | | |
248 | 395k | memcpy(p-2*nT, pF-2*nT, (4*nT+1) * sizeof(pixel_t)); |
249 | 395k | } |
250 | 4.34M | else { |
251 | | // do nothing ? |
252 | 4.34M | } |
253 | | |
254 | | |
255 | 4.74M | logtrace(LogIntraPred,"post filtering: "); |
256 | 4.74M | print_border(p,nullptr,nT); |
257 | 4.74M | logtrace(LogIntraPred,"\n"); |
258 | 4.74M | } void intra_prediction_sample_filtering<unsigned short>(seq_parameter_set const&, unsigned short*, int, int, IntraPredMode) Line | Count | Source | 190 | 3.11M | { | 191 | 3.11M | int filterFlag; | 192 | | | 193 | | //printf("filtering, mode: %d\n",intraPredMode); | 194 | | | 195 | 3.11M | if (intraPredMode==INTRA_DC || nT==4) { | 196 | 2.80M | filterFlag = 0; | 197 | 2.80M | } else { | 198 | 314k | int minDistVerHor = std::min( std::abs((int)intraPredMode-26), | 199 | 314k | std::abs((int)intraPredMode-10) ); | 200 | | | 201 | | //printf("mindist: %d\n",minDistVerHor); | 202 | | | 203 | 314k | switch (nT) { | 204 | 289k | case 8: filterFlag = (minDistVerHor>7) ? 1 : 0; break; | 205 | 18.5k | case 16: filterFlag = (minDistVerHor>1) ? 1 : 0; break; | 206 | 6.67k | case 32: filterFlag = (minDistVerHor>0) ? 1 : 0; break; | 207 | | // there is no official 64x64 TB block, but we call this for some intra-pred mode algorithms | 208 | | // on the whole CB (2Nx2N mode for the whole CTB) | 209 | 0 | case 64: filterFlag = 0; break; | 210 | 0 | default: filterFlag = -1; assert(false); break; // should never happen | 211 | 314k | } | 212 | 314k | } | 213 | | | 214 | | | 215 | 3.11M | if (filterFlag) { | 216 | 209k | int biIntFlag = (sps.strong_intra_smoothing_enable_flag && | 217 | 137k | cIdx==0 && | 218 | 122k | nT==32 && | 219 | 4.35k | std::abs(p[0]+p[ 64]-2*p[ 32]) < (1<<(sps.bit_depth_luma-5)) && | 220 | 3.69k | std::abs(p[0]+p[-64]-2*p[-32]) < (1<<(sps.bit_depth_luma-5))) | 221 | 209k | ? 1 : 0; | 222 | | | 223 | 209k | pixel_t pF_mem[4*32+1]; | 224 | 209k | pixel_t* pF = &pF_mem[2*32]; | 225 | | | 226 | 209k | if (biIntFlag) { | 227 | 2.68k | pF[-2*nT] = p[-2*nT]; | 228 | 2.68k | pF[ 2*nT] = p[ 2*nT]; | 229 | 2.68k | pF[ 0] = p[ 0]; | 230 | | | 231 | 171k | for (int i=1;i<=63;i++) { | 232 | 168k | pF[-i] = p[0] + ((i*(p[-64]-p[0])+32)>>6); | 233 | 168k | pF[ i] = p[0] + ((i*(p[ 64]-p[0])+32)>>6); | 234 | 168k | } | 235 | 206k | } else { | 236 | 206k | pF[-2*nT] = p[-2*nT]; | 237 | 206k | pF[ 2*nT] = p[ 2*nT]; | 238 | | | 239 | 7.36M | for (int i=-(2*nT-1) ; i<=2*nT-1 ; i++) | 240 | 7.16M | { | 241 | 7.16M | pF[i] = (p[i+1] + 2*p[i] + p[i-1] + 2) >> 2; | 242 | 7.16M | } | 243 | 206k | } | 244 | | | 245 | | | 246 | | // copy back to original array | 247 | | | 248 | 209k | memcpy(p-2*nT, pF-2*nT, (4*nT+1) * sizeof(pixel_t)); | 249 | 209k | } | 250 | 2.90M | else { | 251 | | // do nothing ? | 252 | 2.90M | } | 253 | | | 254 | | | 255 | 3.11M | logtrace(LogIntraPred,"post filtering: "); | 256 | 3.11M | print_border(p,nullptr,nT); | 257 | 3.11M | logtrace(LogIntraPred,"\n"); | 258 | 3.11M | } |
void intra_prediction_sample_filtering<unsigned char>(seq_parameter_set const&, unsigned char*, int, int, IntraPredMode) Line | Count | Source | 190 | 1.62M | { | 191 | 1.62M | int filterFlag; | 192 | | | 193 | | //printf("filtering, mode: %d\n",intraPredMode); | 194 | | | 195 | 1.62M | if (intraPredMode==INTRA_DC || nT==4) { | 196 | 1.33M | filterFlag = 0; | 197 | 1.33M | } else { | 198 | 292k | int minDistVerHor = std::min( std::abs((int)intraPredMode-26), | 199 | 292k | std::abs((int)intraPredMode-10) ); | 200 | | | 201 | | //printf("mindist: %d\n",minDistVerHor); | 202 | | | 203 | 292k | switch (nT) { | 204 | 271k | case 8: filterFlag = (minDistVerHor>7) ? 1 : 0; break; | 205 | 16.6k | case 16: filterFlag = (minDistVerHor>1) ? 1 : 0; break; | 206 | 5.27k | case 32: filterFlag = (minDistVerHor>0) ? 1 : 0; break; | 207 | | // there is no official 64x64 TB block, but we call this for some intra-pred mode algorithms | 208 | | // on the whole CB (2Nx2N mode for the whole CTB) | 209 | 0 | case 64: filterFlag = 0; break; | 210 | 0 | default: filterFlag = -1; assert(false); break; // should never happen | 211 | 292k | } | 212 | 292k | } | 213 | | | 214 | | | 215 | 1.62M | if (filterFlag) { | 216 | 186k | int biIntFlag = (sps.strong_intra_smoothing_enable_flag && | 217 | 155k | cIdx==0 && | 218 | 140k | nT==32 && | 219 | 2.62k | std::abs(p[0]+p[ 64]-2*p[ 32]) < (1<<(sps.bit_depth_luma-5)) && | 220 | 2.10k | std::abs(p[0]+p[-64]-2*p[-32]) < (1<<(sps.bit_depth_luma-5))) | 221 | 186k | ? 1 : 0; | 222 | | | 223 | 186k | pixel_t pF_mem[4*32+1]; | 224 | 186k | pixel_t* pF = &pF_mem[2*32]; | 225 | | | 226 | 186k | if (biIntFlag) { | 227 | 1.35k | pF[-2*nT] = p[-2*nT]; | 228 | 1.35k | pF[ 2*nT] = p[ 2*nT]; | 229 | 1.35k | pF[ 0] = p[ 0]; | 230 | | | 231 | 86.6k | for (int i=1;i<=63;i++) { | 232 | 85.3k | pF[-i] = p[0] + ((i*(p[-64]-p[0])+32)>>6); | 233 | 85.3k | pF[ i] = p[0] + ((i*(p[ 64]-p[0])+32)>>6); | 234 | 85.3k | } | 235 | 185k | } else { | 236 | 185k | pF[-2*nT] = p[-2*nT]; | 237 | 185k | pF[ 2*nT] = p[ 2*nT]; | 238 | | | 239 | 6.66M | for (int i=-(2*nT-1) ; i<=2*nT-1 ; i++) | 240 | 6.47M | { | 241 | 6.47M | pF[i] = (p[i+1] + 2*p[i] + p[i-1] + 2) >> 2; | 242 | 6.47M | } | 243 | 185k | } | 244 | | | 245 | | | 246 | | // copy back to original array | 247 | | | 248 | 186k | memcpy(p-2*nT, pF-2*nT, (4*nT+1) * sizeof(pixel_t)); | 249 | 186k | } | 250 | 1.43M | else { | 251 | | // do nothing ? | 252 | 1.43M | } | 253 | | | 254 | | | 255 | 1.62M | logtrace(LogIntraPred,"post filtering: "); | 256 | 1.62M | print_border(p,nullptr,nT); | 257 | 1.62M | logtrace(LogIntraPred,"\n"); | 258 | 1.62M | } |
|
259 | | |
260 | | |
261 | | template <class pixel_t> |
262 | | void intra_prediction_planar(pixel_t* dst, int dstStride, |
263 | | int nT,int cIdx, |
264 | | pixel_t* border) |
265 | 2.10M | { |
266 | 2.10M | int Log2_nT = Log2(nT); |
267 | | |
268 | 11.2M | for (int y=0;y<nT;y++) |
269 | 54.1M | for (int x=0;x<nT;x++) |
270 | 44.9M | { |
271 | 44.9M | dst[x+y*dstStride] = ((nT-1-x)*border[-1-y] + (x+1)*border[ 1+nT] + |
272 | 44.9M | (nT-1-y)*border[ 1+x] + (y+1)*border[-1-nT] + nT) >> (Log2_nT+1); |
273 | 44.9M | } |
274 | | |
275 | | |
276 | 2.10M | logtrace(LogIntraPred,"result of planar prediction\n"); |
277 | | |
278 | 11.2M | for (int y=0;y<nT;y++) |
279 | 9.16M | { |
280 | 54.1M | for (int x=0;x<nT;x++) |
281 | 44.9M | logtrace(LogIntraPred,"%02x ", dst[x+y*dstStride]); |
282 | | |
283 | 9.16M | logtrace(LogIntraPred,"\n"); |
284 | 9.16M | } |
285 | 2.10M | } Unexecuted instantiation: void intra_prediction_planar<unsigned char>(unsigned char*, int, int, int, unsigned char*) void intra_prediction_planar<unsigned short>(unsigned short*, int, int, int, unsigned short*) Line | Count | Source | 265 | 2.10M | { | 266 | 2.10M | int Log2_nT = Log2(nT); | 267 | | | 268 | 11.2M | for (int y=0;y<nT;y++) | 269 | 54.1M | for (int x=0;x<nT;x++) | 270 | 44.9M | { | 271 | 44.9M | dst[x+y*dstStride] = ((nT-1-x)*border[-1-y] + (x+1)*border[ 1+nT] + | 272 | 44.9M | (nT-1-y)*border[ 1+x] + (y+1)*border[-1-nT] + nT) >> (Log2_nT+1); | 273 | 44.9M | } | 274 | | | 275 | | | 276 | 2.10M | logtrace(LogIntraPred,"result of planar prediction\n"); | 277 | | | 278 | 11.2M | for (int y=0;y<nT;y++) | 279 | 9.16M | { | 280 | 54.1M | for (int x=0;x<nT;x++) | 281 | 44.9M | logtrace(LogIntraPred,"%02x ", dst[x+y*dstStride]); | 282 | | | 283 | 9.16M | logtrace(LogIntraPred,"\n"); | 284 | 9.16M | } | 285 | 2.10M | } |
|
286 | | |
287 | | |
288 | | template <class pixel_t> |
289 | | void intra_prediction_DC(pixel_t* dst, int dstStride, |
290 | | int nT,int cIdx, |
291 | | pixel_t* border) |
292 | 600k | { |
293 | 600k | int Log2_nT = Log2(nT); |
294 | | |
295 | 600k | int dcVal = 0; |
296 | 3.24M | for (int i=0;i<nT;i++) |
297 | 2.64M | { |
298 | 2.64M | dcVal += border[ i+1]; |
299 | 2.64M | dcVal += border[-i-1]; |
300 | 2.64M | } |
301 | | |
302 | 600k | dcVal += nT; |
303 | 600k | dcVal >>= Log2_nT+1; |
304 | | |
305 | 600k | if (cIdx==0 && nT<32) { |
306 | 358k | dst[0] = (border[-1] + 2*dcVal + border[1] +2) >> 2; |
307 | | |
308 | 1.57M | for (int x=1;x<nT;x++) { dst[x] = (border[ x+1] + 3*dcVal+2)>>2; } |
309 | 1.57M | for (int y=1;y<nT;y++) { dst[y*dstStride] = (border[-y-1] + 3*dcVal+2)>>2; } |
310 | 1.57M | for (int y=1;y<nT;y++) |
311 | 5.99M | for (int x=1;x<nT;x++) |
312 | 4.77M | { |
313 | 4.77M | dst[x+y*dstStride] = dcVal; |
314 | 4.77M | } |
315 | 358k | } else { |
316 | 1.30M | for (int y=0;y<nT;y++) |
317 | 6.82M | for (int x=0;x<nT;x++) |
318 | 5.75M | { |
319 | 5.75M | dst[x+y*dstStride] = dcVal; |
320 | 5.75M | } |
321 | 241k | } |
322 | 600k | } Unexecuted instantiation: void intra_prediction_DC<unsigned char>(unsigned char*, int, int, int, unsigned char*) void intra_prediction_DC<unsigned short>(unsigned short*, int, int, int, unsigned short*) Line | Count | Source | 292 | 600k | { | 293 | 600k | int Log2_nT = Log2(nT); | 294 | | | 295 | 600k | int dcVal = 0; | 296 | 3.24M | for (int i=0;i<nT;i++) | 297 | 2.64M | { | 298 | 2.64M | dcVal += border[ i+1]; | 299 | 2.64M | dcVal += border[-i-1]; | 300 | 2.64M | } | 301 | | | 302 | 600k | dcVal += nT; | 303 | 600k | dcVal >>= Log2_nT+1; | 304 | | | 305 | 600k | if (cIdx==0 && nT<32) { | 306 | 358k | dst[0] = (border[-1] + 2*dcVal + border[1] +2) >> 2; | 307 | | | 308 | 1.57M | for (int x=1;x<nT;x++) { dst[x] = (border[ x+1] + 3*dcVal+2)>>2; } | 309 | 1.57M | for (int y=1;y<nT;y++) { dst[y*dstStride] = (border[-y-1] + 3*dcVal+2)>>2; } | 310 | 1.57M | for (int y=1;y<nT;y++) | 311 | 5.99M | for (int x=1;x<nT;x++) | 312 | 4.77M | { | 313 | 4.77M | dst[x+y*dstStride] = dcVal; | 314 | 4.77M | } | 315 | 358k | } else { | 316 | 1.30M | for (int y=0;y<nT;y++) | 317 | 6.82M | for (int x=0;x<nT;x++) | 318 | 5.75M | { | 319 | 5.75M | dst[x+y*dstStride] = dcVal; | 320 | 5.75M | } | 321 | 241k | } | 322 | 600k | } |
|
323 | | |
324 | | |
325 | | extern const int intraPredAngle_table[1+34]; |
326 | | extern const int invAngle_table[25-10]; |
327 | | |
328 | | |
329 | | // (8.4.4.2.6) |
330 | | template <class pixel_t> |
331 | | void intra_prediction_angular(pixel_t* dst, int dstStride, |
332 | | int bit_depth, bool disableIntraBoundaryFilter, |
333 | | int xB0,int yB0, |
334 | | enum IntraPredMode intraPredMode, |
335 | | int nT,int cIdx, |
336 | | pixel_t* border) |
337 | 2.57M | { |
338 | 2.57M | pixel_t ref_mem[4*MAX_INTRA_PRED_BLOCK_SIZE+1]; // TODO: what is the required range here ? |
339 | 2.57M | pixel_t* ref=&ref_mem[2*MAX_INTRA_PRED_BLOCK_SIZE]; |
340 | | |
341 | 2.57M | assert(intraPredMode<35); |
342 | 2.57M | assert(intraPredMode>=2); |
343 | | |
344 | 2.57M | int intraPredAngle = intraPredAngle_table[intraPredMode]; |
345 | | |
346 | 2.57M | if (intraPredMode >= 18) { |
347 | | |
348 | 5.21M | for (int x=0;x<=nT;x++) |
349 | 4.42M | { ref[x] = border[x]; } |
350 | | |
351 | 795k | if (intraPredAngle<0) { |
352 | 309k | int invAngle = invAngle_table[intraPredMode-11]; |
353 | | |
354 | 309k | if ((nT*intraPredAngle)>>5 < -1) { |
355 | 911k | for (int x=(nT*intraPredAngle)>>5; x<=-1; x++) { |
356 | 698k | ref[x] = border[0-((x*invAngle+128)>>8)]; |
357 | 698k | } |
358 | 213k | } |
359 | 486k | } else { |
360 | 2.72M | for (int x=nT+1; x<=2*nT;x++) { |
361 | 2.23M | ref[x] = border[x]; |
362 | 2.23M | } |
363 | 486k | } |
364 | | |
365 | 4.42M | for (int y=0;y<nT;y++) |
366 | 23.9M | for (int x=0;x<nT;x++) |
367 | 20.2M | { |
368 | 20.2M | int iIdx = ((y+1)*intraPredAngle)>>5; |
369 | 20.2M | int iFact= ((y+1)*intraPredAngle)&31; |
370 | | |
371 | 20.2M | if (iFact != 0) { |
372 | 13.1M | dst[x+y*dstStride] = ((32-iFact)*ref[x+iIdx+1] + iFact*ref[x+iIdx+2] + 16)>>5; |
373 | 13.1M | } else { |
374 | 7.14M | dst[x+y*dstStride] = ref[x+iIdx+1]; |
375 | 7.14M | } |
376 | 20.2M | } |
377 | | |
378 | 795k | if (intraPredMode==26 && cIdx==0 && nT<32 && !disableIntraBoundaryFilter) { |
379 | 337k | for (int y=0;y<nT;y++) { |
380 | 276k | dst[0+y*dstStride] = Clip_BitDepth(border[1] + ((border[-1-y] - border[0])>>1), bit_depth); |
381 | 276k | } |
382 | 60.5k | } |
383 | 795k | } |
384 | 1.77M | else { // intraPredAngle < 18 |
385 | | |
386 | 11.4M | for (int x=0;x<=nT;x++) |
387 | 9.71M | { ref[x] = border[-x]; } // DIFF (neg) |
388 | | |
389 | 1.77M | if (intraPredAngle<0) { |
390 | 202k | int invAngle = invAngle_table[intraPredMode-11]; |
391 | | |
392 | 202k | if ((nT*intraPredAngle)>>5 < -1) { |
393 | 592k | for (int x=(nT*intraPredAngle)>>5; x<=-1; x++) { |
394 | 448k | ref[x] = border[((x*invAngle+128)>>8)]; // DIFF (neg) |
395 | 448k | } |
396 | 144k | } |
397 | 1.57M | } else { |
398 | 8.59M | for (int x=nT+1; x<=2*nT;x++) { |
399 | 7.02M | ref[x] = border[-x]; // DIFF (neg) |
400 | 7.02M | } |
401 | 1.57M | } |
402 | | |
403 | 9.71M | for (int y=0;y<nT;y++) |
404 | 49.7M | for (int x=0;x<nT;x++) |
405 | 41.8M | { |
406 | 41.8M | int iIdx = ((x+1)*intraPredAngle)>>5; // DIFF (x<->y) |
407 | 41.8M | int iFact= ((x+1)*intraPredAngle)&31; // DIFF (x<->y) |
408 | | |
409 | 41.8M | if (iFact != 0) { |
410 | 15.5M | dst[x+y*dstStride] = ((32-iFact)*ref[y+iIdx+1] + iFact*ref[y+iIdx+2] + 16)>>5; // DIFF (x<->y) |
411 | 26.3M | } else { |
412 | 26.3M | dst[x+y*dstStride] = ref[y+iIdx+1]; // DIFF (x<->y) |
413 | 26.3M | } |
414 | 41.8M | } |
415 | | |
416 | 1.77M | if (intraPredMode==10 && cIdx==0 && nT<32 && !disableIntraBoundaryFilter) { // DIFF 26->10 |
417 | 170k | for (int x=0;x<nT;x++) { // DIFF (x<->y) |
418 | 140k | dst[x] = Clip_BitDepth(border[-1] + ((border[1+x] - border[0])>>1), bit_depth); // DIFF (x<->y && neg) |
419 | 140k | } |
420 | 29.6k | } |
421 | 1.77M | } |
422 | | |
423 | | |
424 | 2.57M | logtrace(LogIntraPred,"result of angular intra prediction (mode=%d):\n",intraPredMode); |
425 | | |
426 | 14.1M | for (int y=0;y<nT;y++) |
427 | 11.5M | { |
428 | 73.6M | for (int x=0;x<nT;x++) |
429 | 62.1M | logtrace(LogIntraPred,"%02x ", dst[x+y*dstStride]); |
430 | | |
431 | 11.5M | logtrace(LogIntraPred,"\n"); |
432 | 11.5M | } |
433 | 2.57M | } Unexecuted instantiation: void intra_prediction_angular<unsigned char>(unsigned char*, int, int, bool, int, int, IntraPredMode, int, int, unsigned char*) void intra_prediction_angular<unsigned short>(unsigned short*, int, int, bool, int, int, IntraPredMode, int, int, unsigned short*) Line | Count | Source | 337 | 2.57M | { | 338 | 2.57M | pixel_t ref_mem[4*MAX_INTRA_PRED_BLOCK_SIZE+1]; // TODO: what is the required range here ? | 339 | 2.57M | pixel_t* ref=&ref_mem[2*MAX_INTRA_PRED_BLOCK_SIZE]; | 340 | | | 341 | 2.57M | assert(intraPredMode<35); | 342 | 2.57M | assert(intraPredMode>=2); | 343 | | | 344 | 2.57M | int intraPredAngle = intraPredAngle_table[intraPredMode]; | 345 | | | 346 | 2.57M | if (intraPredMode >= 18) { | 347 | | | 348 | 5.21M | for (int x=0;x<=nT;x++) | 349 | 4.42M | { ref[x] = border[x]; } | 350 | | | 351 | 795k | if (intraPredAngle<0) { | 352 | 309k | int invAngle = invAngle_table[intraPredMode-11]; | 353 | | | 354 | 309k | if ((nT*intraPredAngle)>>5 < -1) { | 355 | 911k | for (int x=(nT*intraPredAngle)>>5; x<=-1; x++) { | 356 | 698k | ref[x] = border[0-((x*invAngle+128)>>8)]; | 357 | 698k | } | 358 | 213k | } | 359 | 486k | } else { | 360 | 2.72M | for (int x=nT+1; x<=2*nT;x++) { | 361 | 2.23M | ref[x] = border[x]; | 362 | 2.23M | } | 363 | 486k | } | 364 | | | 365 | 4.42M | for (int y=0;y<nT;y++) | 366 | 23.9M | for (int x=0;x<nT;x++) | 367 | 20.2M | { | 368 | 20.2M | int iIdx = ((y+1)*intraPredAngle)>>5; | 369 | 20.2M | int iFact= ((y+1)*intraPredAngle)&31; | 370 | | | 371 | 20.2M | if (iFact != 0) { | 372 | 13.1M | dst[x+y*dstStride] = ((32-iFact)*ref[x+iIdx+1] + iFact*ref[x+iIdx+2] + 16)>>5; | 373 | 13.1M | } else { | 374 | 7.14M | dst[x+y*dstStride] = ref[x+iIdx+1]; | 375 | 7.14M | } | 376 | 20.2M | } | 377 | | | 378 | 795k | if (intraPredMode==26 && cIdx==0 && nT<32 && !disableIntraBoundaryFilter) { | 379 | 337k | for (int y=0;y<nT;y++) { | 380 | 276k | dst[0+y*dstStride] = Clip_BitDepth(border[1] + ((border[-1-y] - border[0])>>1), bit_depth); | 381 | 276k | } | 382 | 60.5k | } | 383 | 795k | } | 384 | 1.77M | else { // intraPredAngle < 18 | 385 | | | 386 | 11.4M | for (int x=0;x<=nT;x++) | 387 | 9.71M | { ref[x] = border[-x]; } // DIFF (neg) | 388 | | | 389 | 1.77M | if (intraPredAngle<0) { | 390 | 202k | int invAngle = invAngle_table[intraPredMode-11]; | 391 | | | 392 | 202k | if ((nT*intraPredAngle)>>5 < -1) { | 393 | 592k | for (int x=(nT*intraPredAngle)>>5; x<=-1; x++) { | 394 | 448k | ref[x] = border[((x*invAngle+128)>>8)]; // DIFF (neg) | 395 | 448k | } | 396 | 144k | } | 397 | 1.57M | } else { | 398 | 8.59M | for (int x=nT+1; x<=2*nT;x++) { | 399 | 7.02M | ref[x] = border[-x]; // DIFF (neg) | 400 | 7.02M | } | 401 | 1.57M | } | 402 | | | 403 | 9.71M | for (int y=0;y<nT;y++) | 404 | 49.7M | for (int x=0;x<nT;x++) | 405 | 41.8M | { | 406 | 41.8M | int iIdx = ((x+1)*intraPredAngle)>>5; // DIFF (x<->y) | 407 | 41.8M | int iFact= ((x+1)*intraPredAngle)&31; // DIFF (x<->y) | 408 | | | 409 | 41.8M | if (iFact != 0) { | 410 | 15.5M | dst[x+y*dstStride] = ((32-iFact)*ref[y+iIdx+1] + iFact*ref[y+iIdx+2] + 16)>>5; // DIFF (x<->y) | 411 | 26.3M | } else { | 412 | 26.3M | dst[x+y*dstStride] = ref[y+iIdx+1]; // DIFF (x<->y) | 413 | 26.3M | } | 414 | 41.8M | } | 415 | | | 416 | 1.77M | if (intraPredMode==10 && cIdx==0 && nT<32 && !disableIntraBoundaryFilter) { // DIFF 26->10 | 417 | 170k | for (int x=0;x<nT;x++) { // DIFF (x<->y) | 418 | 140k | dst[x] = Clip_BitDepth(border[-1] + ((border[1+x] - border[0])>>1), bit_depth); // DIFF (x<->y && neg) | 419 | 140k | } | 420 | 29.6k | } | 421 | 1.77M | } | 422 | | | 423 | | | 424 | 2.57M | logtrace(LogIntraPred,"result of angular intra prediction (mode=%d):\n",intraPredMode); | 425 | | | 426 | 14.1M | for (int y=0;y<nT;y++) | 427 | 11.5M | { | 428 | 73.6M | for (int x=0;x<nT;x++) | 429 | 62.1M | logtrace(LogIntraPred,"%02x ", dst[x+y*dstStride]); | 430 | | | 431 | 11.5M | logtrace(LogIntraPred,"\n"); | 432 | 11.5M | } | 433 | 2.57M | } |
|
434 | | |
435 | | |
436 | | template <class pixel_t> |
437 | | void intra_border_computer<pixel_t>::preproc() |
438 | 9.98M | { |
439 | 9.98M | sps = &img->get_sps(); |
440 | 9.98M | pps = &img->get_pps(); |
441 | | |
442 | 9.98M | SubWidth = (cIdx==0) ? 1 : sps->SubWidthC; |
443 | 9.98M | SubHeight = (cIdx==0) ? 1 : sps->SubHeightC; |
444 | | |
445 | | // --- check for CTB boundaries --- |
446 | | |
447 | 9.98M | int xBLuma = xB * SubWidth; |
448 | 9.98M | int yBLuma = yB * SubHeight; |
449 | | |
450 | 9.98M | int log2CtbSize = sps->Log2CtbSizeY; |
451 | 9.98M | int picWidthInCtbs = sps->PicWidthInCtbsY; |
452 | | |
453 | | |
454 | | //printf("xB/yB: %d %d\n",xB,yB); |
455 | | |
456 | | // are we at left image border |
457 | | |
458 | 9.98M | if (xBLuma == 0) { |
459 | 80.7k | availableLeft = false; |
460 | 80.7k | availableTopLeft = false; |
461 | 80.7k | xBLuma = 0; // fake value, available flags are already set to false |
462 | 80.7k | } |
463 | | |
464 | | |
465 | | // are we at top image border |
466 | | |
467 | 9.98M | if (yBLuma == 0) { |
468 | 643k | availableTop = false; |
469 | 643k | availableTopLeft = false; |
470 | 643k | availableTopRight = false; |
471 | 643k | yBLuma = 0; // fake value, available flags are already set to false |
472 | 643k | } |
473 | | |
474 | 9.98M | if (xBLuma+nT*SubWidth >= sps->pic_width_in_luma_samples) { |
475 | 97.8k | availableTopRight=false; |
476 | 97.8k | } |
477 | | |
478 | | // check for tile and slice boundaries |
479 | | |
480 | 9.98M | int xCurrCtb = xBLuma >> log2CtbSize; |
481 | 9.98M | int yCurrCtb = yBLuma >> log2CtbSize; |
482 | 9.98M | int xLeftCtb = (xBLuma-1) >> log2CtbSize; |
483 | 9.98M | int xRightCtb = (xBLuma+nT*SubWidth) >> log2CtbSize; |
484 | 9.98M | int yTopCtb = (yBLuma-1) >> log2CtbSize; |
485 | | |
486 | 9.98M | int currCTBSlice = img->get_SliceAddrRS(xCurrCtb,yCurrCtb); |
487 | 9.98M | int leftCTBSlice = availableLeft ? img->get_SliceAddrRS(xLeftCtb, yCurrCtb) : -1; |
488 | 9.98M | int topCTBSlice = availableTop ? img->get_SliceAddrRS(xCurrCtb, yTopCtb) : -1; |
489 | 9.98M | int toprightCTBSlice = availableTopRight ? img->get_SliceAddrRS(xRightCtb, yTopCtb) : -1; |
490 | 9.98M | int topleftCTBSlice = availableTopLeft ? img->get_SliceAddrRS(xLeftCtb, yTopCtb) : -1; |
491 | | |
492 | | /* |
493 | | printf("size: %d\n",pps->scan->TileIdRS.size()); |
494 | | printf("curr: %d left: %d top: %d\n", |
495 | | xCurrCtb+yCurrCtb*picWidthInCtbs, |
496 | | availableLeft ? xLeftCtb+yCurrCtb*picWidthInCtbs : 9999, |
497 | | availableTop ? xCurrCtb+yTopCtb*picWidthInCtbs : 9999); |
498 | | */ |
499 | 9.98M | uint32_t currCTBTileID = pps->scan->TileIdRS[xCurrCtb+yCurrCtb*picWidthInCtbs]; |
500 | 9.98M | uint32_t leftCTBTileID = availableLeft ? pps->scan->TileIdRS[xLeftCtb+yCurrCtb*picWidthInCtbs] : UINT32_MAX; |
501 | 9.98M | uint32_t topCTBTileID = availableTop ? pps->scan->TileIdRS[xCurrCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; |
502 | 9.98M | uint32_t topleftCTBTileID = availableTopLeft ? pps->scan->TileIdRS[xLeftCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; |
503 | 9.98M | uint32_t toprightCTBTileID= availableTopRight? pps->scan->TileIdRS[xRightCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; |
504 | | |
505 | 9.98M | if (leftCTBSlice != currCTBSlice || leftCTBTileID != currCTBTileID ) availableLeft = false; |
506 | 9.98M | if (topCTBSlice != currCTBSlice || topCTBTileID != currCTBTileID ) availableTop = false; |
507 | 9.98M | if (topleftCTBSlice !=currCTBSlice||topleftCTBTileID!=currCTBTileID ) availableTopLeft = false; |
508 | 9.98M | if (toprightCTBSlice!=currCTBSlice||toprightCTBTileID!=currCTBTileID) availableTopRight= false; |
509 | | |
510 | | |
511 | | // number of pixels that are in the valid image area to the right and to the bottom |
512 | | |
513 | 9.98M | nBottom = sps->pic_height_in_luma_samples - yB*SubHeight; |
514 | 9.98M | nBottom=(nBottom+SubHeight-1)/SubHeight; |
515 | 9.98M | if (nBottom>2*nT) nBottom=2*nT; |
516 | | |
517 | 9.98M | nRight = sps->pic_width_in_luma_samples - xB*SubWidth; |
518 | 9.98M | nRight =(nRight +SubWidth-1)/SubWidth; |
519 | 9.98M | if (nRight >2*nT) nRight=2*nT; |
520 | | |
521 | 9.98M | nAvail=0; |
522 | | |
523 | 9.98M | available = &available_data[2*MAX_INTRA_PRED_BLOCK_SIZE]; |
524 | | |
525 | 9.98M | memset(available-2*nT, 0, 4*nT+1); |
526 | 9.98M | } intra_border_computer<unsigned short>::preproc() Line | Count | Source | 438 | 5.27M | { | 439 | 5.27M | sps = &img->get_sps(); | 440 | 5.27M | pps = &img->get_pps(); | 441 | | | 442 | 5.27M | SubWidth = (cIdx==0) ? 1 : sps->SubWidthC; | 443 | 5.27M | SubHeight = (cIdx==0) ? 1 : sps->SubHeightC; | 444 | | | 445 | | // --- check for CTB boundaries --- | 446 | | | 447 | 5.27M | int xBLuma = xB * SubWidth; | 448 | 5.27M | int yBLuma = yB * SubHeight; | 449 | | | 450 | 5.27M | int log2CtbSize = sps->Log2CtbSizeY; | 451 | 5.27M | int picWidthInCtbs = sps->PicWidthInCtbsY; | 452 | | | 453 | | | 454 | | //printf("xB/yB: %d %d\n",xB,yB); | 455 | | | 456 | | // are we at left image border | 457 | | | 458 | 5.27M | if (xBLuma == 0) { | 459 | 38.7k | availableLeft = false; | 460 | 38.7k | availableTopLeft = false; | 461 | 38.7k | xBLuma = 0; // fake value, available flags are already set to false | 462 | 38.7k | } | 463 | | | 464 | | | 465 | | // are we at top image border | 466 | | | 467 | 5.27M | if (yBLuma == 0) { | 468 | 334k | availableTop = false; | 469 | 334k | availableTopLeft = false; | 470 | 334k | availableTopRight = false; | 471 | 334k | yBLuma = 0; // fake value, available flags are already set to false | 472 | 334k | } | 473 | | | 474 | 5.27M | if (xBLuma+nT*SubWidth >= sps->pic_width_in_luma_samples) { | 475 | 48.6k | availableTopRight=false; | 476 | 48.6k | } | 477 | | | 478 | | // check for tile and slice boundaries | 479 | | | 480 | 5.27M | int xCurrCtb = xBLuma >> log2CtbSize; | 481 | 5.27M | int yCurrCtb = yBLuma >> log2CtbSize; | 482 | 5.27M | int xLeftCtb = (xBLuma-1) >> log2CtbSize; | 483 | 5.27M | int xRightCtb = (xBLuma+nT*SubWidth) >> log2CtbSize; | 484 | 5.27M | int yTopCtb = (yBLuma-1) >> log2CtbSize; | 485 | | | 486 | 5.27M | int currCTBSlice = img->get_SliceAddrRS(xCurrCtb,yCurrCtb); | 487 | 5.27M | int leftCTBSlice = availableLeft ? img->get_SliceAddrRS(xLeftCtb, yCurrCtb) : -1; | 488 | 5.27M | int topCTBSlice = availableTop ? img->get_SliceAddrRS(xCurrCtb, yTopCtb) : -1; | 489 | 5.27M | int toprightCTBSlice = availableTopRight ? img->get_SliceAddrRS(xRightCtb, yTopCtb) : -1; | 490 | 5.27M | int topleftCTBSlice = availableTopLeft ? img->get_SliceAddrRS(xLeftCtb, yTopCtb) : -1; | 491 | | | 492 | | /* | 493 | | printf("size: %d\n",pps->scan->TileIdRS.size()); | 494 | | printf("curr: %d left: %d top: %d\n", | 495 | | xCurrCtb+yCurrCtb*picWidthInCtbs, | 496 | | availableLeft ? xLeftCtb+yCurrCtb*picWidthInCtbs : 9999, | 497 | | availableTop ? xCurrCtb+yTopCtb*picWidthInCtbs : 9999); | 498 | | */ | 499 | 5.27M | uint32_t currCTBTileID = pps->scan->TileIdRS[xCurrCtb+yCurrCtb*picWidthInCtbs]; | 500 | 5.27M | uint32_t leftCTBTileID = availableLeft ? pps->scan->TileIdRS[xLeftCtb+yCurrCtb*picWidthInCtbs] : UINT32_MAX; | 501 | 5.27M | uint32_t topCTBTileID = availableTop ? pps->scan->TileIdRS[xCurrCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; | 502 | 5.27M | uint32_t topleftCTBTileID = availableTopLeft ? pps->scan->TileIdRS[xLeftCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; | 503 | 5.27M | uint32_t toprightCTBTileID= availableTopRight? pps->scan->TileIdRS[xRightCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; | 504 | | | 505 | 5.27M | if (leftCTBSlice != currCTBSlice || leftCTBTileID != currCTBTileID ) availableLeft = false; | 506 | 5.27M | if (topCTBSlice != currCTBSlice || topCTBTileID != currCTBTileID ) availableTop = false; | 507 | 5.27M | if (topleftCTBSlice !=currCTBSlice||topleftCTBTileID!=currCTBTileID ) availableTopLeft = false; | 508 | 5.27M | if (toprightCTBSlice!=currCTBSlice||toprightCTBTileID!=currCTBTileID) availableTopRight= false; | 509 | | | 510 | | | 511 | | // number of pixels that are in the valid image area to the right and to the bottom | 512 | | | 513 | 5.27M | nBottom = sps->pic_height_in_luma_samples - yB*SubHeight; | 514 | 5.27M | nBottom=(nBottom+SubHeight-1)/SubHeight; | 515 | 5.27M | if (nBottom>2*nT) nBottom=2*nT; | 516 | | | 517 | 5.27M | nRight = sps->pic_width_in_luma_samples - xB*SubWidth; | 518 | 5.27M | nRight =(nRight +SubWidth-1)/SubWidth; | 519 | 5.27M | if (nRight >2*nT) nRight=2*nT; | 520 | | | 521 | 5.27M | nAvail=0; | 522 | | | 523 | 5.27M | available = &available_data[2*MAX_INTRA_PRED_BLOCK_SIZE]; | 524 | | | 525 | 5.27M | memset(available-2*nT, 0, 4*nT+1); | 526 | 5.27M | } |
intra_border_computer<unsigned char>::preproc() Line | Count | Source | 438 | 4.70M | { | 439 | 4.70M | sps = &img->get_sps(); | 440 | 4.70M | pps = &img->get_pps(); | 441 | | | 442 | 4.70M | SubWidth = (cIdx==0) ? 1 : sps->SubWidthC; | 443 | 4.70M | SubHeight = (cIdx==0) ? 1 : sps->SubHeightC; | 444 | | | 445 | | // --- check for CTB boundaries --- | 446 | | | 447 | 4.70M | int xBLuma = xB * SubWidth; | 448 | 4.70M | int yBLuma = yB * SubHeight; | 449 | | | 450 | 4.70M | int log2CtbSize = sps->Log2CtbSizeY; | 451 | 4.70M | int picWidthInCtbs = sps->PicWidthInCtbsY; | 452 | | | 453 | | | 454 | | //printf("xB/yB: %d %d\n",xB,yB); | 455 | | | 456 | | // are we at left image border | 457 | | | 458 | 4.70M | if (xBLuma == 0) { | 459 | 42.0k | availableLeft = false; | 460 | 42.0k | availableTopLeft = false; | 461 | 42.0k | xBLuma = 0; // fake value, available flags are already set to false | 462 | 42.0k | } | 463 | | | 464 | | | 465 | | // are we at top image border | 466 | | | 467 | 4.70M | if (yBLuma == 0) { | 468 | 308k | availableTop = false; | 469 | 308k | availableTopLeft = false; | 470 | 308k | availableTopRight = false; | 471 | 308k | yBLuma = 0; // fake value, available flags are already set to false | 472 | 308k | } | 473 | | | 474 | 4.70M | if (xBLuma+nT*SubWidth >= sps->pic_width_in_luma_samples) { | 475 | 49.1k | availableTopRight=false; | 476 | 49.1k | } | 477 | | | 478 | | // check for tile and slice boundaries | 479 | | | 480 | 4.70M | int xCurrCtb = xBLuma >> log2CtbSize; | 481 | 4.70M | int yCurrCtb = yBLuma >> log2CtbSize; | 482 | 4.70M | int xLeftCtb = (xBLuma-1) >> log2CtbSize; | 483 | 4.70M | int xRightCtb = (xBLuma+nT*SubWidth) >> log2CtbSize; | 484 | 4.70M | int yTopCtb = (yBLuma-1) >> log2CtbSize; | 485 | | | 486 | 4.70M | int currCTBSlice = img->get_SliceAddrRS(xCurrCtb,yCurrCtb); | 487 | 4.70M | int leftCTBSlice = availableLeft ? img->get_SliceAddrRS(xLeftCtb, yCurrCtb) : -1; | 488 | 4.70M | int topCTBSlice = availableTop ? img->get_SliceAddrRS(xCurrCtb, yTopCtb) : -1; | 489 | 4.70M | int toprightCTBSlice = availableTopRight ? img->get_SliceAddrRS(xRightCtb, yTopCtb) : -1; | 490 | 4.70M | int topleftCTBSlice = availableTopLeft ? img->get_SliceAddrRS(xLeftCtb, yTopCtb) : -1; | 491 | | | 492 | | /* | 493 | | printf("size: %d\n",pps->scan->TileIdRS.size()); | 494 | | printf("curr: %d left: %d top: %d\n", | 495 | | xCurrCtb+yCurrCtb*picWidthInCtbs, | 496 | | availableLeft ? xLeftCtb+yCurrCtb*picWidthInCtbs : 9999, | 497 | | availableTop ? xCurrCtb+yTopCtb*picWidthInCtbs : 9999); | 498 | | */ | 499 | 4.70M | uint32_t currCTBTileID = pps->scan->TileIdRS[xCurrCtb+yCurrCtb*picWidthInCtbs]; | 500 | 4.70M | uint32_t leftCTBTileID = availableLeft ? pps->scan->TileIdRS[xLeftCtb+yCurrCtb*picWidthInCtbs] : UINT32_MAX; | 501 | 4.70M | uint32_t topCTBTileID = availableTop ? pps->scan->TileIdRS[xCurrCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; | 502 | 4.70M | uint32_t topleftCTBTileID = availableTopLeft ? pps->scan->TileIdRS[xLeftCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; | 503 | 4.70M | uint32_t toprightCTBTileID= availableTopRight? pps->scan->TileIdRS[xRightCtb+yTopCtb*picWidthInCtbs] : UINT32_MAX; | 504 | | | 505 | 4.70M | if (leftCTBSlice != currCTBSlice || leftCTBTileID != currCTBTileID ) availableLeft = false; | 506 | 4.70M | if (topCTBSlice != currCTBSlice || topCTBTileID != currCTBTileID ) availableTop = false; | 507 | 4.70M | if (topleftCTBSlice !=currCTBSlice||topleftCTBTileID!=currCTBTileID ) availableTopLeft = false; | 508 | 4.70M | if (toprightCTBSlice!=currCTBSlice||toprightCTBTileID!=currCTBTileID) availableTopRight= false; | 509 | | | 510 | | | 511 | | // number of pixels that are in the valid image area to the right and to the bottom | 512 | | | 513 | 4.70M | nBottom = sps->pic_height_in_luma_samples - yB*SubHeight; | 514 | 4.70M | nBottom=(nBottom+SubHeight-1)/SubHeight; | 515 | 4.70M | if (nBottom>2*nT) nBottom=2*nT; | 516 | | | 517 | 4.70M | nRight = sps->pic_width_in_luma_samples - xB*SubWidth; | 518 | 4.70M | nRight =(nRight +SubWidth-1)/SubWidth; | 519 | 4.70M | if (nRight >2*nT) nRight=2*nT; | 520 | | | 521 | 4.70M | nAvail=0; | 522 | | | 523 | 4.70M | available = &available_data[2*MAX_INTRA_PRED_BLOCK_SIZE]; | 524 | | | 525 | 4.70M | memset(available-2*nT, 0, 4*nT+1); | 526 | 4.70M | } |
|
527 | | |
528 | | |
529 | | template <class pixel_t> |
530 | | void intra_border_computer<pixel_t>::fill_from_image() |
531 | 9.98M | { |
532 | 9.98M | assert(nT<=32); |
533 | | |
534 | 9.98M | pixel_t* image; |
535 | 9.98M | ptrdiff_t stride; |
536 | 9.98M | image = (pixel_t*)img->get_image_plane(cIdx); |
537 | 9.98M | stride = img->get_image_stride(cIdx); |
538 | | |
539 | 9.98M | int xBLuma = xB * SubWidth; |
540 | 9.98M | int yBLuma = yB * SubHeight; |
541 | | |
542 | 9.98M | int currBlockAddr = pps->scan->MinTbAddrZS[ (xBLuma>>sps->Log2MinTrafoSize) + |
543 | 9.98M | (yBLuma>>sps->Log2MinTrafoSize) * sps->PicWidthInTbsY ]; |
544 | | |
545 | | |
546 | | // copy pixels at left column |
547 | | |
548 | 31.3M | for (int y=nBottom-1 ; y>=0 ; y-=4) |
549 | 21.3M | if (availableLeft) |
550 | 21.0M | { |
551 | 21.0M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) + |
552 | 21.0M | (((yB+y)*SubHeight)>>sps->Log2MinTrafoSize) |
553 | 21.0M | * sps->PicWidthInTbsY ]; |
554 | | |
555 | 21.0M | bool availableN = NBlockAddr <= currBlockAddr; |
556 | | |
557 | 21.0M | if (pps->constrained_intra_pred_flag) { |
558 | 739k | if (img->get_pred_mode((xB-1)*SubWidth,(yB+y)*SubHeight)!=MODE_INTRA) |
559 | 15.2k | availableN = false; |
560 | 739k | } |
561 | | |
562 | 21.0M | if (availableN) { |
563 | 15.8M | if (!nAvail) firstValue = image[xB-1 + (yB+y)*stride]; |
564 | | |
565 | 79.3M | for (int i=0;i<4;i++) { |
566 | 63.4M | available[-y+i-1] = availableN; |
567 | 63.4M | out_border[-y+i-1] = image[xB-1 + (yB+y-i)*stride]; |
568 | 63.4M | } |
569 | | |
570 | 15.8M | nAvail+=4; |
571 | 15.8M | } |
572 | 21.0M | } |
573 | | |
574 | | // copy pixel at top-left position |
575 | | |
576 | 9.98M | if (availableTopLeft) |
577 | 9.25M | { |
578 | 9.25M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) + |
579 | 9.25M | (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize) |
580 | 9.25M | * sps->PicWidthInTbsY ]; |
581 | | |
582 | 9.25M | bool availableN = NBlockAddr <= currBlockAddr; |
583 | | |
584 | 9.25M | if (pps->constrained_intra_pred_flag) { |
585 | 311k | if (img->get_pred_mode((xB-1)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) { |
586 | 11.0k | availableN = false; |
587 | 11.0k | } |
588 | 311k | } |
589 | | |
590 | 9.25M | if (availableN) { |
591 | 9.24M | if (!nAvail) firstValue = image[xB-1 + (yB-1)*stride]; |
592 | | |
593 | 9.24M | out_border[0] = image[xB-1 + (yB-1)*stride]; |
594 | 9.24M | available[0] = availableN; |
595 | 9.24M | nAvail++; |
596 | 9.24M | } |
597 | 9.25M | } |
598 | | |
599 | | // copy pixels at top row |
600 | | |
601 | 32.0M | for (int x=0 ; x<nRight ; x+=4) { |
602 | 22.0M | bool borderAvailable; |
603 | 22.0M | if (x<nT) borderAvailable=availableTop; |
604 | 10.9M | else borderAvailable=availableTopRight; |
605 | | |
606 | 22.0M | if (borderAvailable) |
607 | 20.2M | { |
608 | 20.2M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB+x)*SubWidth )>>sps->Log2MinTrafoSize) + |
609 | 20.2M | (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize) |
610 | 20.2M | * sps->PicWidthInTbsY ]; |
611 | | |
612 | 20.2M | bool availableN = NBlockAddr <= currBlockAddr; |
613 | | |
614 | 20.2M | if (pps->constrained_intra_pred_flag) { |
615 | 725k | if (img->get_pred_mode((xB+x)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) { |
616 | 12.6k | availableN = false; |
617 | 12.6k | } |
618 | 725k | } |
619 | | |
620 | | |
621 | 20.2M | if (availableN) { |
622 | 15.3M | if (!nAvail) firstValue = image[xB+x + (yB-1)*stride]; |
623 | | |
624 | 76.8M | for (int i=0;i<4;i++) { |
625 | 61.4M | out_border[x+i+1] = image[xB+x+i + (yB-1)*stride]; |
626 | 61.4M | available[x+i+1] = availableN; |
627 | 61.4M | } |
628 | | |
629 | 15.3M | nAvail+=4; |
630 | 15.3M | } |
631 | 20.2M | } |
632 | 22.0M | } |
633 | 9.98M | } intra_border_computer<unsigned short>::fill_from_image() Line | Count | Source | 531 | 5.27M | { | 532 | 5.27M | assert(nT<=32); | 533 | | | 534 | 5.27M | pixel_t* image; | 535 | 5.27M | ptrdiff_t stride; | 536 | 5.27M | image = (pixel_t*)img->get_image_plane(cIdx); | 537 | 5.27M | stride = img->get_image_stride(cIdx); | 538 | | | 539 | 5.27M | int xBLuma = xB * SubWidth; | 540 | 5.27M | int yBLuma = yB * SubHeight; | 541 | | | 542 | 5.27M | int currBlockAddr = pps->scan->MinTbAddrZS[ (xBLuma>>sps->Log2MinTrafoSize) + | 543 | 5.27M | (yBLuma>>sps->Log2MinTrafoSize) * sps->PicWidthInTbsY ]; | 544 | | | 545 | | | 546 | | // copy pixels at left column | 547 | | | 548 | 16.5M | for (int y=nBottom-1 ; y>=0 ; y-=4) | 549 | 11.2M | if (availableLeft) | 550 | 11.1M | { | 551 | 11.1M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) + | 552 | 11.1M | (((yB+y)*SubHeight)>>sps->Log2MinTrafoSize) | 553 | 11.1M | * sps->PicWidthInTbsY ]; | 554 | | | 555 | 11.1M | bool availableN = NBlockAddr <= currBlockAddr; | 556 | | | 557 | 11.1M | if (pps->constrained_intra_pred_flag) { | 558 | 428k | if (img->get_pred_mode((xB-1)*SubWidth,(yB+y)*SubHeight)!=MODE_INTRA) | 559 | 5.82k | availableN = false; | 560 | 428k | } | 561 | | | 562 | 11.1M | if (availableN) { | 563 | 8.20M | if (!nAvail) firstValue = image[xB-1 + (yB+y)*stride]; | 564 | | | 565 | 41.0M | for (int i=0;i<4;i++) { | 566 | 32.8M | available[-y+i-1] = availableN; | 567 | 32.8M | out_border[-y+i-1] = image[xB-1 + (yB+y-i)*stride]; | 568 | 32.8M | } | 569 | | | 570 | 8.20M | nAvail+=4; | 571 | 8.20M | } | 572 | 11.1M | } | 573 | | | 574 | | // copy pixel at top-left position | 575 | | | 576 | 5.27M | if (availableTopLeft) | 577 | 4.90M | { | 578 | 4.90M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) + | 579 | 4.90M | (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize) | 580 | 4.90M | * sps->PicWidthInTbsY ]; | 581 | | | 582 | 4.90M | bool availableN = NBlockAddr <= currBlockAddr; | 583 | | | 584 | 4.90M | if (pps->constrained_intra_pred_flag) { | 585 | 179k | if (img->get_pred_mode((xB-1)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) { | 586 | 4.98k | availableN = false; | 587 | 4.98k | } | 588 | 179k | } | 589 | | | 590 | 4.90M | if (availableN) { | 591 | 4.89M | if (!nAvail) firstValue = image[xB-1 + (yB-1)*stride]; | 592 | | | 593 | 4.89M | out_border[0] = image[xB-1 + (yB-1)*stride]; | 594 | 4.89M | available[0] = availableN; | 595 | 4.89M | nAvail++; | 596 | 4.89M | } | 597 | 4.90M | } | 598 | | | 599 | | // copy pixels at top row | 600 | | | 601 | 16.9M | for (int x=0 ; x<nRight ; x+=4) { | 602 | 11.6M | bool borderAvailable; | 603 | 11.6M | if (x<nT) borderAvailable=availableTop; | 604 | 5.77M | else borderAvailable=availableTopRight; | 605 | | | 606 | 11.6M | if (borderAvailable) | 607 | 10.7M | { | 608 | 10.7M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB+x)*SubWidth )>>sps->Log2MinTrafoSize) + | 609 | 10.7M | (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize) | 610 | 10.7M | * sps->PicWidthInTbsY ]; | 611 | | | 612 | 10.7M | bool availableN = NBlockAddr <= currBlockAddr; | 613 | | | 614 | 10.7M | if (pps->constrained_intra_pred_flag) { | 615 | 423k | if (img->get_pred_mode((xB+x)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) { | 616 | 6.19k | availableN = false; | 617 | 6.19k | } | 618 | 423k | } | 619 | | | 620 | | | 621 | 10.7M | if (availableN) { | 622 | 8.28M | if (!nAvail) firstValue = image[xB+x + (yB-1)*stride]; | 623 | | | 624 | 41.4M | for (int i=0;i<4;i++) { | 625 | 33.1M | out_border[x+i+1] = image[xB+x+i + (yB-1)*stride]; | 626 | 33.1M | available[x+i+1] = availableN; | 627 | 33.1M | } | 628 | | | 629 | 8.28M | nAvail+=4; | 630 | 8.28M | } | 631 | 10.7M | } | 632 | 11.6M | } | 633 | 5.27M | } |
intra_border_computer<unsigned char>::fill_from_image() Line | Count | Source | 531 | 4.70M | { | 532 | 4.70M | assert(nT<=32); | 533 | | | 534 | 4.70M | pixel_t* image; | 535 | 4.70M | ptrdiff_t stride; | 536 | 4.70M | image = (pixel_t*)img->get_image_plane(cIdx); | 537 | 4.70M | stride = img->get_image_stride(cIdx); | 538 | | | 539 | 4.70M | int xBLuma = xB * SubWidth; | 540 | 4.70M | int yBLuma = yB * SubHeight; | 541 | | | 542 | 4.70M | int currBlockAddr = pps->scan->MinTbAddrZS[ (xBLuma>>sps->Log2MinTrafoSize) + | 543 | 4.70M | (yBLuma>>sps->Log2MinTrafoSize) * sps->PicWidthInTbsY ]; | 544 | | | 545 | | | 546 | | // copy pixels at left column | 547 | | | 548 | 14.8M | for (int y=nBottom-1 ; y>=0 ; y-=4) | 549 | 10.0M | if (availableLeft) | 550 | 9.97M | { | 551 | 9.97M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) + | 552 | 9.97M | (((yB+y)*SubHeight)>>sps->Log2MinTrafoSize) | 553 | 9.97M | * sps->PicWidthInTbsY ]; | 554 | | | 555 | 9.97M | bool availableN = NBlockAddr <= currBlockAddr; | 556 | | | 557 | 9.97M | if (pps->constrained_intra_pred_flag) { | 558 | 310k | if (img->get_pred_mode((xB-1)*SubWidth,(yB+y)*SubHeight)!=MODE_INTRA) | 559 | 9.40k | availableN = false; | 560 | 310k | } | 561 | | | 562 | 9.97M | if (availableN) { | 563 | 7.65M | if (!nAvail) firstValue = image[xB-1 + (yB+y)*stride]; | 564 | | | 565 | 38.2M | for (int i=0;i<4;i++) { | 566 | 30.6M | available[-y+i-1] = availableN; | 567 | 30.6M | out_border[-y+i-1] = image[xB-1 + (yB+y-i)*stride]; | 568 | 30.6M | } | 569 | | | 570 | 7.65M | nAvail+=4; | 571 | 7.65M | } | 572 | 9.97M | } | 573 | | | 574 | | // copy pixel at top-left position | 575 | | | 576 | 4.70M | if (availableTopLeft) | 577 | 4.34M | { | 578 | 4.34M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB-1)*SubWidth )>>sps->Log2MinTrafoSize) + | 579 | 4.34M | (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize) | 580 | 4.34M | * sps->PicWidthInTbsY ]; | 581 | | | 582 | 4.34M | bool availableN = NBlockAddr <= currBlockAddr; | 583 | | | 584 | 4.34M | if (pps->constrained_intra_pred_flag) { | 585 | 131k | if (img->get_pred_mode((xB-1)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) { | 586 | 6.08k | availableN = false; | 587 | 6.08k | } | 588 | 131k | } | 589 | | | 590 | 4.34M | if (availableN) { | 591 | 4.34M | if (!nAvail) firstValue = image[xB-1 + (yB-1)*stride]; | 592 | | | 593 | 4.34M | out_border[0] = image[xB-1 + (yB-1)*stride]; | 594 | 4.34M | available[0] = availableN; | 595 | 4.34M | nAvail++; | 596 | 4.34M | } | 597 | 4.34M | } | 598 | | | 599 | | // copy pixels at top row | 600 | | | 601 | 15.1M | for (int x=0 ; x<nRight ; x+=4) { | 602 | 10.4M | bool borderAvailable; | 603 | 10.4M | if (x<nT) borderAvailable=availableTop; | 604 | 5.18M | else borderAvailable=availableTopRight; | 605 | | | 606 | 10.4M | if (borderAvailable) | 607 | 9.55M | { | 608 | 9.55M | int NBlockAddr = pps->scan->MinTbAddrZS[ (((xB+x)*SubWidth )>>sps->Log2MinTrafoSize) + | 609 | 9.55M | (((yB-1)*SubHeight)>>sps->Log2MinTrafoSize) | 610 | 9.55M | * sps->PicWidthInTbsY ]; | 611 | | | 612 | 9.55M | bool availableN = NBlockAddr <= currBlockAddr; | 613 | | | 614 | 9.55M | if (pps->constrained_intra_pred_flag) { | 615 | 302k | if (img->get_pred_mode((xB+x)*SubWidth,(yB-1)*SubHeight)!=MODE_INTRA) { | 616 | 6.48k | availableN = false; | 617 | 6.48k | } | 618 | 302k | } | 619 | | | 620 | | | 621 | 9.55M | if (availableN) { | 622 | 7.08M | if (!nAvail) firstValue = image[xB+x + (yB-1)*stride]; | 623 | | | 624 | 35.4M | for (int i=0;i<4;i++) { | 625 | 28.3M | out_border[x+i+1] = image[xB+x+i + (yB-1)*stride]; | 626 | 28.3M | available[x+i+1] = availableN; | 627 | 28.3M | } | 628 | | | 629 | 7.08M | nAvail+=4; | 630 | 7.08M | } | 631 | 9.55M | } | 632 | 10.4M | } | 633 | 4.70M | } |
|
634 | | |
635 | | |
636 | | |
637 | | template <class pixel_t> |
638 | | void intra_border_computer<pixel_t>::reference_sample_substitution() |
639 | 9.98M | { |
640 | | // reference sample substitution |
641 | | |
642 | 9.98M | const int bit_depth = img->get_bit_depth(cIdx); |
643 | | |
644 | 9.98M | if (nAvail!=4*nT+1) { |
645 | 7.20M | if (nAvail==0) { |
646 | 8.67k | if (sizeof(pixel_t)==1) { |
647 | 4.87k | memset(out_border-2*nT, 1<<(bit_depth-1), 4*nT+1); |
648 | 4.87k | } |
649 | 3.80k | else { |
650 | 190k | for (int i = -2*nT; i <= 2*nT ; i++) { |
651 | 186k | out_border[i] = 1<<(bit_depth-1); |
652 | 186k | } |
653 | 3.80k | } |
654 | 8.67k | } |
655 | 7.20M | else { |
656 | 7.20M | if (!available[-2*nT]) { |
657 | 5.41M | out_border[-2*nT] = firstValue; |
658 | 5.41M | } |
659 | | |
660 | 136M | for (int i=-2*nT+1; i<=2*nT; i++) |
661 | 129M | if (!available[i]) { |
662 | 47.4M | out_border[i]=out_border[i-1]; |
663 | 47.4M | } |
664 | 7.20M | } |
665 | 7.20M | } |
666 | | |
667 | 9.98M | logtrace(LogIntraPred,"availableN: "); |
668 | 9.98M | print_border(available,nullptr,nT); |
669 | 9.98M | logtrace(LogIntraPred,"\n"); |
670 | | |
671 | 9.98M | logtrace(LogIntraPred,"output: "); |
672 | 9.98M | print_border(out_border,nullptr,nT); |
673 | 9.98M | logtrace(LogIntraPred,"\n"); |
674 | 9.98M | } intra_border_computer<unsigned short>::reference_sample_substitution() Line | Count | Source | 639 | 5.27M | { | 640 | | // reference sample substitution | 641 | | | 642 | 5.27M | const int bit_depth = img->get_bit_depth(cIdx); | 643 | | | 644 | 5.27M | if (nAvail!=4*nT+1) { | 645 | 3.80M | if (nAvail==0) { | 646 | 3.80k | if (sizeof(pixel_t)==1) { | 647 | 0 | memset(out_border-2*nT, 1<<(bit_depth-1), 4*nT+1); | 648 | 0 | } | 649 | 3.80k | else { | 650 | 190k | for (int i = -2*nT; i <= 2*nT ; i++) { | 651 | 186k | out_border[i] = 1<<(bit_depth-1); | 652 | 186k | } | 653 | 3.80k | } | 654 | 3.80k | } | 655 | 3.79M | else { | 656 | 3.79M | if (!available[-2*nT]) { | 657 | 3.01M | out_border[-2*nT] = firstValue; | 658 | 3.01M | } | 659 | | | 660 | 71.7M | for (int i=-2*nT+1; i<=2*nT; i++) | 661 | 67.9M | if (!available[i]) { | 662 | 24.6M | out_border[i]=out_border[i-1]; | 663 | 24.6M | } | 664 | 3.79M | } | 665 | 3.80M | } | 666 | | | 667 | 5.27M | logtrace(LogIntraPred,"availableN: "); | 668 | 5.27M | print_border(available,nullptr,nT); | 669 | 5.27M | logtrace(LogIntraPred,"\n"); | 670 | | | 671 | 5.27M | logtrace(LogIntraPred,"output: "); | 672 | 5.27M | print_border(out_border,nullptr,nT); | 673 | 5.27M | logtrace(LogIntraPred,"\n"); | 674 | 5.27M | } |
intra_border_computer<unsigned char>::reference_sample_substitution() Line | Count | Source | 639 | 4.70M | { | 640 | | // reference sample substitution | 641 | | | 642 | 4.70M | const int bit_depth = img->get_bit_depth(cIdx); | 643 | | | 644 | 4.70M | if (nAvail!=4*nT+1) { | 645 | 3.40M | if (nAvail==0) { | 646 | 4.87k | if (sizeof(pixel_t)==1) { | 647 | 4.87k | memset(out_border-2*nT, 1<<(bit_depth-1), 4*nT+1); | 648 | 4.87k | } | 649 | 0 | else { | 650 | 0 | for (int i = -2*nT; i <= 2*nT ; i++) { | 651 | 0 | out_border[i] = 1<<(bit_depth-1); | 652 | 0 | } | 653 | 0 | } | 654 | 4.87k | } | 655 | 3.40M | else { | 656 | 3.40M | if (!available[-2*nT]) { | 657 | 2.39M | out_border[-2*nT] = firstValue; | 658 | 2.39M | } | 659 | | | 660 | 64.7M | for (int i=-2*nT+1; i<=2*nT; i++) | 661 | 61.3M | if (!available[i]) { | 662 | 22.7M | out_border[i]=out_border[i-1]; | 663 | 22.7M | } | 664 | 3.40M | } | 665 | 3.40M | } | 666 | | | 667 | 4.70M | logtrace(LogIntraPred,"availableN: "); | 668 | 4.70M | print_border(available,nullptr,nT); | 669 | 4.70M | logtrace(LogIntraPred,"\n"); | 670 | | | 671 | 4.70M | logtrace(LogIntraPred,"output: "); | 672 | 4.70M | print_border(out_border,nullptr,nT); | 673 | 4.70M | logtrace(LogIntraPred,"\n"); | 674 | 4.70M | } |
|
675 | | |
676 | | |
677 | | #endif |