Lines Matching +full:- +full:it
3 // Use of this source code is governed by a BSD-style license
8 // -----------------------------------------------------------------------------
19 //------------------------------------------------------------------------------
21 //------------------------------------------------------------------------------
23 static void InitLeft(VP8EncIterator* const it) { in InitLeft() argument
24 it->y_left_[-1] = it->u_left_[-1] = it->v_left_[-1] = in InitLeft()
25 (it->y_ > 0) ? 129 : 127; in InitLeft()
26 memset(it->y_left_, 129, 16); in InitLeft()
27 memset(it->u_left_, 129, 8); in InitLeft()
28 memset(it->v_left_, 129, 8); in InitLeft()
29 it->left_nz_[8] = 0; in InitLeft()
30 if (it->top_derr_ != NULL) { in InitLeft()
31 memset(&it->left_derr_, 0, sizeof(it->left_derr_)); in InitLeft()
35 static void InitTop(VP8EncIterator* const it) { in InitTop() argument
36 const VP8Encoder* const enc = it->enc_; in InitTop()
37 const size_t top_size = enc->mb_w_ * 16; in InitTop()
38 memset(enc->y_top_, 127, 2 * top_size); in InitTop()
39 memset(enc->nz_, 0, enc->mb_w_ * sizeof(*enc->nz_)); in InitTop()
40 if (enc->top_derr_ != NULL) { in InitTop()
41 memset(enc->top_derr_, 0, enc->mb_w_ * sizeof(*enc->top_derr_)); in InitTop()
45 void VP8IteratorSetRow(VP8EncIterator* const it, int y) { in VP8IteratorSetRow() argument
46 VP8Encoder* const enc = it->enc_; in VP8IteratorSetRow()
47 it->x_ = 0; in VP8IteratorSetRow()
48 it->y_ = y; in VP8IteratorSetRow()
49 it->bw_ = &enc->parts_[y & (enc->num_parts_ - 1)]; in VP8IteratorSetRow()
50 it->preds_ = enc->preds_ + y * 4 * enc->preds_w_; in VP8IteratorSetRow()
51 it->nz_ = enc->nz_; in VP8IteratorSetRow()
52 it->mb_ = enc->mb_info_ + y * enc->mb_w_; in VP8IteratorSetRow()
53 it->y_top_ = enc->y_top_; in VP8IteratorSetRow()
54 it->uv_top_ = enc->uv_top_; in VP8IteratorSetRow()
55 InitLeft(it); in VP8IteratorSetRow()
59 static void VP8IteratorReset(VP8EncIterator* const it) { in VP8IteratorReset() argument
60 VP8Encoder* const enc = it->enc_; in VP8IteratorReset()
61 VP8IteratorSetRow(it, 0); in VP8IteratorReset()
62 VP8IteratorSetCountDown(it, enc->mb_w_ * enc->mb_h_); // default in VP8IteratorReset()
63 InitTop(it); in VP8IteratorReset()
64 memset(it->bit_count_, 0, sizeof(it->bit_count_)); in VP8IteratorReset()
65 it->do_trellis_ = 0; in VP8IteratorReset()
68 void VP8IteratorSetCountDown(VP8EncIterator* const it, int count_down) { in VP8IteratorSetCountDown() argument
69 it->count_down_ = it->count_down0_ = count_down; in VP8IteratorSetCountDown()
72 int VP8IteratorIsDone(const VP8EncIterator* const it) { in VP8IteratorIsDone() argument
73 return (it->count_down_ <= 0); in VP8IteratorIsDone()
76 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { in VP8IteratorInit() argument
77 it->enc_ = enc; in VP8IteratorInit()
78 it->yuv_in_ = (uint8_t*)WEBP_ALIGN(it->yuv_mem_); in VP8IteratorInit()
79 it->yuv_out_ = it->yuv_in_ + YUV_SIZE_ENC; in VP8IteratorInit()
80 it->yuv_out2_ = it->yuv_out_ + YUV_SIZE_ENC; in VP8IteratorInit()
81 it->yuv_p_ = it->yuv_out2_ + YUV_SIZE_ENC; in VP8IteratorInit()
82 it->lf_stats_ = enc->lf_stats_; in VP8IteratorInit()
83 it->percent0_ = enc->percent_; in VP8IteratorInit()
84 it->y_left_ = (uint8_t*)WEBP_ALIGN(it->yuv_left_mem_ + 1); in VP8IteratorInit()
85 it->u_left_ = it->y_left_ + 16 + 16; in VP8IteratorInit()
86 it->v_left_ = it->u_left_ + 16; in VP8IteratorInit()
87 it->top_derr_ = enc->top_derr_; in VP8IteratorInit()
88 VP8IteratorReset(it); in VP8IteratorInit()
91 int VP8IteratorProgress(const VP8EncIterator* const it, int delta) { in VP8IteratorProgress() argument
92 VP8Encoder* const enc = it->enc_; in VP8IteratorProgress()
93 if (delta && enc->pic_->progress_hook != NULL) { in VP8IteratorProgress()
94 const int done = it->count_down0_ - it->count_down_; in VP8IteratorProgress()
95 const int percent = (it->count_down0_ <= 0) in VP8IteratorProgress()
96 ? it->percent0_ in VP8IteratorProgress()
97 : it->percent0_ + delta * done / it->count_down0_; in VP8IteratorProgress()
98 return WebPReportProgress(enc->pic_, percent, &enc->percent_); in VP8IteratorProgress()
103 //------------------------------------------------------------------------------
115 memset(dst + w, dst[w - 1], size - w); in ImportBlock()
121 memcpy(dst, dst - BPS, size); in ImportBlock()
130 for (; i < total_len; ++i) dst[i] = dst[len - 1]; in ImportLine()
133 void VP8IteratorImport(VP8EncIterator* const it, uint8_t* const tmp_32) { in VP8IteratorImport() argument
134 const VP8Encoder* const enc = it->enc_; in VP8IteratorImport()
135 const int x = it->x_, y = it->y_; in VP8IteratorImport()
136 const WebPPicture* const pic = enc->pic_; in VP8IteratorImport()
137 const uint8_t* const ysrc = pic->y + (y * pic->y_stride + x) * 16; in VP8IteratorImport()
138 const uint8_t* const usrc = pic->u + (y * pic->uv_stride + x) * 8; in VP8IteratorImport()
139 const uint8_t* const vsrc = pic->v + (y * pic->uv_stride + x) * 8; in VP8IteratorImport()
140 const int w = MinSize(pic->width - x * 16, 16); in VP8IteratorImport()
141 const int h = MinSize(pic->height - y * 16, 16); in VP8IteratorImport()
145 ImportBlock(ysrc, pic->y_stride, it->yuv_in_ + Y_OFF_ENC, w, h, 16); in VP8IteratorImport()
146 ImportBlock(usrc, pic->uv_stride, it->yuv_in_ + U_OFF_ENC, uv_w, uv_h, 8); in VP8IteratorImport()
147 ImportBlock(vsrc, pic->uv_stride, it->yuv_in_ + V_OFF_ENC, uv_w, uv_h, 8); in VP8IteratorImport()
153 InitLeft(it); in VP8IteratorImport()
156 it->y_left_[-1] = it->u_left_[-1] = it->v_left_[-1] = 127; in VP8IteratorImport()
158 it->y_left_[-1] = ysrc[- 1 - pic->y_stride]; in VP8IteratorImport()
159 it->u_left_[-1] = usrc[- 1 - pic->uv_stride]; in VP8IteratorImport()
160 it->v_left_[-1] = vsrc[- 1 - pic->uv_stride]; in VP8IteratorImport()
162 ImportLine(ysrc - 1, pic->y_stride, it->y_left_, h, 16); in VP8IteratorImport()
163 ImportLine(usrc - 1, pic->uv_stride, it->u_left_, uv_h, 8); in VP8IteratorImport()
164 ImportLine(vsrc - 1, pic->uv_stride, it->v_left_, uv_h, 8); in VP8IteratorImport()
167 it->y_top_ = tmp_32 + 0; in VP8IteratorImport()
168 it->uv_top_ = tmp_32 + 16; in VP8IteratorImport()
172 ImportLine(ysrc - pic->y_stride, 1, tmp_32, w, 16); in VP8IteratorImport()
173 ImportLine(usrc - pic->uv_stride, 1, tmp_32 + 16, uv_w, 8); in VP8IteratorImport()
174 ImportLine(vsrc - pic->uv_stride, 1, tmp_32 + 16 + 8, uv_w, 8); in VP8IteratorImport()
178 //------------------------------------------------------------------------------
183 while (h-- > 0) { in ExportBlock()
190 void VP8IteratorExport(const VP8EncIterator* const it) { in VP8IteratorExport() argument
191 const VP8Encoder* const enc = it->enc_; in VP8IteratorExport()
192 if (enc->config_->show_compressed) { in VP8IteratorExport()
193 const int x = it->x_, y = it->y_; in VP8IteratorExport()
194 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF_ENC; in VP8IteratorExport()
195 const uint8_t* const usrc = it->yuv_out_ + U_OFF_ENC; in VP8IteratorExport()
196 const uint8_t* const vsrc = it->yuv_out_ + V_OFF_ENC; in VP8IteratorExport()
197 const WebPPicture* const pic = enc->pic_; in VP8IteratorExport()
198 uint8_t* const ydst = pic->y + (y * pic->y_stride + x) * 16; in VP8IteratorExport()
199 uint8_t* const udst = pic->u + (y * pic->uv_stride + x) * 8; in VP8IteratorExport()
200 uint8_t* const vdst = pic->v + (y * pic->uv_stride + x) * 8; in VP8IteratorExport()
201 int w = (pic->width - x * 16); in VP8IteratorExport()
202 int h = (pic->height - y * 16); in VP8IteratorExport()
208 ExportBlock(ysrc, ydst, pic->y_stride, w, h); in VP8IteratorExport()
213 ExportBlock(usrc, udst, pic->uv_stride, uv_w, uv_h); in VP8IteratorExport()
214 ExportBlock(vsrc, vdst, pic->uv_stride, uv_w, uv_h); in VP8IteratorExport()
219 //------------------------------------------------------------------------------
220 // Non-zero contexts setup/teardown
231 // 24 DC-intra16
236 void VP8IteratorNzToBytes(VP8EncIterator* const it) { in VP8IteratorNzToBytes() argument
237 const int tnz = it->nz_[0], lnz = it->nz_[-1]; in VP8IteratorNzToBytes()
238 int* const top_nz = it->top_nz_; in VP8IteratorNzToBytes()
239 int* const left_nz = it->left_nz_; in VP8IteratorNzToBytes()
241 // Top-Y in VP8IteratorNzToBytes()
246 // Top-U in VP8IteratorNzToBytes()
249 // Top-V in VP8IteratorNzToBytes()
255 // left-Y in VP8IteratorNzToBytes()
260 // left-U in VP8IteratorNzToBytes()
263 // left-V in VP8IteratorNzToBytes()
266 // left-DC is special, iterated separately in VP8IteratorNzToBytes()
269 void VP8IteratorBytesToNz(VP8EncIterator* const it) { in VP8IteratorBytesToNz() argument
271 const int* const top_nz = it->top_nz_; in VP8IteratorBytesToNz()
272 const int* const left_nz = it->left_nz_; in VP8IteratorBytesToNz()
284 *it->nz_ = nz; in VP8IteratorBytesToNz()
289 //------------------------------------------------------------------------------
292 void VP8IteratorSaveBoundary(VP8EncIterator* const it) { in VP8IteratorSaveBoundary() argument
293 VP8Encoder* const enc = it->enc_; in VP8IteratorSaveBoundary()
294 const int x = it->x_, y = it->y_; in VP8IteratorSaveBoundary()
295 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF_ENC; in VP8IteratorSaveBoundary()
296 const uint8_t* const uvsrc = it->yuv_out_ + U_OFF_ENC; in VP8IteratorSaveBoundary()
297 if (x < enc->mb_w_ - 1) { // left in VP8IteratorSaveBoundary()
300 it->y_left_[i] = ysrc[15 + i * BPS]; in VP8IteratorSaveBoundary()
303 it->u_left_[i] = uvsrc[7 + i * BPS]; in VP8IteratorSaveBoundary()
304 it->v_left_[i] = uvsrc[15 + i * BPS]; in VP8IteratorSaveBoundary()
306 // top-left (before 'top'!) in VP8IteratorSaveBoundary()
307 it->y_left_[-1] = it->y_top_[15]; in VP8IteratorSaveBoundary()
308 it->u_left_[-1] = it->uv_top_[0 + 7]; in VP8IteratorSaveBoundary()
309 it->v_left_[-1] = it->uv_top_[8 + 7]; in VP8IteratorSaveBoundary()
311 if (y < enc->mb_h_ - 1) { // top in VP8IteratorSaveBoundary()
312 memcpy(it->y_top_, ysrc + 15 * BPS, 16); in VP8IteratorSaveBoundary()
313 memcpy(it->uv_top_, uvsrc + 7 * BPS, 8 + 8); in VP8IteratorSaveBoundary()
317 int VP8IteratorNext(VP8EncIterator* const it) { in VP8IteratorNext() argument
318 if (++it->x_ == it->enc_->mb_w_) { in VP8IteratorNext()
319 VP8IteratorSetRow(it, ++it->y_); in VP8IteratorNext()
321 it->preds_ += 4; in VP8IteratorNext()
322 it->mb_ += 1; in VP8IteratorNext()
323 it->nz_ += 1; in VP8IteratorNext()
324 it->y_top_ += 16; in VP8IteratorNext()
325 it->uv_top_ += 16; in VP8IteratorNext()
327 return (0 < --it->count_down_); in VP8IteratorNext()
330 //------------------------------------------------------------------------------
333 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode) { in VP8SetIntra16Mode() argument
334 uint8_t* preds = it->preds_; in VP8SetIntra16Mode()
338 preds += it->enc_->preds_w_; in VP8SetIntra16Mode()
340 it->mb_->type_ = 1; in VP8SetIntra16Mode()
343 void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes) { in VP8SetIntra4Mode() argument
344 uint8_t* preds = it->preds_; in VP8SetIntra4Mode()
346 for (y = 4; y > 0; --y) { in VP8SetIntra4Mode()
348 preds += it->enc_->preds_w_; in VP8SetIntra4Mode()
351 it->mb_->type_ = 0; in VP8SetIntra4Mode()
354 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode) { in VP8SetIntraUVMode() argument
355 it->mb_->uv_mode_ = mode; in VP8SetIntraUVMode()
358 void VP8SetSkip(const VP8EncIterator* const it, int skip) { in VP8SetSkip() argument
359 it->mb_->skip_ = skip; in VP8SetSkip()
362 void VP8SetSegment(const VP8EncIterator* const it, int segment) { in VP8SetSegment() argument
363 it->mb_->segment_ = segment; in VP8SetSegment()
366 //------------------------------------------------------------------------------
367 // Intra4x4 sub-blocks iteration
373 // 16|17 18 19 20|21 22 23 24|25 26 27 28|29 30 31 32|33 34 35 36 <- Top-right
374 // --+-----------+-----------+-----------+-----------+
379 // --+-----------+-----------+-----------+-----------+
384 // --+-----------+-----------+-----------+-----------+
389 // --+-----------+-----------+-----------+-----------+
394 // --+-----------+-----------+-----------+-----------+
405 void VP8IteratorStartI4(VP8EncIterator* const it) { in VP8IteratorStartI4() argument
406 const VP8Encoder* const enc = it->enc_; in VP8IteratorStartI4()
409 it->i4_ = 0; // first 4x4 sub-block in VP8IteratorStartI4()
410 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[0]; in VP8IteratorStartI4()
414 it->i4_boundary_[i] = it->y_left_[15 - i]; in VP8IteratorStartI4()
417 it->i4_boundary_[17 + i] = it->y_top_[i]; in VP8IteratorStartI4()
419 // top-right samples have a special case on the far right of the picture in VP8IteratorStartI4()
420 if (it->x_ < enc->mb_w_ - 1) { in VP8IteratorStartI4()
422 it->i4_boundary_[17 + i] = it->y_top_[i]; in VP8IteratorStartI4()
426 it->i4_boundary_[17 + i] = it->i4_boundary_[17 + 15]; in VP8IteratorStartI4()
436 memset(it->i4_boundary_ + sizeof(it->i4_boundary_) - 3, 0xaa, 3); in VP8IteratorStartI4()
438 VP8IteratorNzToBytes(it); // import the non-zero context in VP8IteratorStartI4()
441 int VP8IteratorRotateI4(VP8EncIterator* const it, in VP8IteratorRotateI4() argument
443 const uint8_t* const blk = yuv_out + VP8Scan[it->i4_]; in VP8IteratorRotateI4()
444 uint8_t* const top = it->i4_top_; in VP8IteratorRotateI4()
449 top[-4 + i] = blk[i + 3 * BPS]; // store future top samples in VP8IteratorRotateI4()
451 if ((it->i4_ & 3) != 3) { // if not on the right sub-blocks #3, #7, #11, #15 in VP8IteratorRotateI4()
453 top[i] = blk[3 + (2 - i) * BPS]; in VP8IteratorRotateI4()
455 } else { // else replicate top-right samples, as says the specs. in VP8IteratorRotateI4()
460 // move pointers to next sub-block in VP8IteratorRotateI4()
461 ++it->i4_; in VP8IteratorRotateI4()
462 if (it->i4_ == 16) { // we're done in VP8IteratorRotateI4()
466 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[it->i4_]; in VP8IteratorRotateI4()
470 //------------------------------------------------------------------------------