| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // VP8Iterator: block iterator | 10 // VP8Iterator: block iterator |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 int VP8IteratorIsDone(const VP8EncIterator* const it) { | 65 int VP8IteratorIsDone(const VP8EncIterator* const it) { |
| 66 return (it->count_down_ <= 0); | 66 return (it->count_down_ <= 0); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { | 69 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { |
| 70 it->enc_ = enc; | 70 it->enc_ = enc; |
| 71 it->y_stride_ = enc->pic_->y_stride; | 71 it->y_stride_ = enc->pic_->y_stride; |
| 72 it->uv_stride_ = enc->pic_->uv_stride; | 72 it->uv_stride_ = enc->pic_->uv_stride; |
| 73 it->yuv_in_ = (uint8_t*)DO_ALIGN(it->yuv_mem_); | 73 it->yuv_in_ = (uint8_t*)WEBP_ALIGN(it->yuv_mem_); |
| 74 it->yuv_out_ = it->yuv_in_ + YUV_SIZE; | 74 it->yuv_out_ = it->yuv_in_ + YUV_SIZE_ENC; |
| 75 it->yuv_out2_ = it->yuv_out_ + YUV_SIZE; | 75 it->yuv_out2_ = it->yuv_out_ + YUV_SIZE_ENC; |
| 76 it->yuv_p_ = it->yuv_out2_ + YUV_SIZE; | 76 it->yuv_p_ = it->yuv_out2_ + YUV_SIZE_ENC; |
| 77 it->lf_stats_ = enc->lf_stats_; | 77 it->lf_stats_ = enc->lf_stats_; |
| 78 it->percent0_ = enc->percent_; | 78 it->percent0_ = enc->percent_; |
| 79 it->y_left_ = (uint8_t*)DO_ALIGN(it->yuv_left_mem_ + 1); | 79 it->y_left_ = (uint8_t*)WEBP_ALIGN(it->yuv_left_mem_ + 1); |
| 80 it->u_left_ = it->y_left_ + 16 + 16; | 80 it->u_left_ = it->y_left_ + 16 + 16; |
| 81 it->v_left_ = it->u_left_ + 16; | 81 it->v_left_ = it->u_left_ + 16; |
| 82 VP8IteratorReset(it); | 82 VP8IteratorReset(it); |
| 83 } | 83 } |
| 84 | 84 |
| 85 int VP8IteratorProgress(const VP8EncIterator* const it, int delta) { | 85 int VP8IteratorProgress(const VP8EncIterator* const it, int delta) { |
| 86 VP8Encoder* const enc = it->enc_; | 86 VP8Encoder* const enc = it->enc_; |
| 87 if (delta && enc->pic_->progress_hook != NULL) { | 87 if (delta && enc->pic_->progress_hook != NULL) { |
| 88 const int done = it->count_down0_ - it->count_down_; | 88 const int done = it->count_down0_ - it->count_down_; |
| 89 const int percent = (it->count_down0_ <= 0) | 89 const int percent = (it->count_down0_ <= 0) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 const int x = it->x_, y = it->y_; | 129 const int x = it->x_, y = it->y_; |
| 130 const WebPPicture* const pic = enc->pic_; | 130 const WebPPicture* const pic = enc->pic_; |
| 131 const uint8_t* const ysrc = pic->y + (y * pic->y_stride + x) * 16; | 131 const uint8_t* const ysrc = pic->y + (y * pic->y_stride + x) * 16; |
| 132 const uint8_t* const usrc = pic->u + (y * pic->uv_stride + x) * 8; | 132 const uint8_t* const usrc = pic->u + (y * pic->uv_stride + x) * 8; |
| 133 const uint8_t* const vsrc = pic->v + (y * pic->uv_stride + x) * 8; | 133 const uint8_t* const vsrc = pic->v + (y * pic->uv_stride + x) * 8; |
| 134 const int w = MinSize(pic->width - x * 16, 16); | 134 const int w = MinSize(pic->width - x * 16, 16); |
| 135 const int h = MinSize(pic->height - y * 16, 16); | 135 const int h = MinSize(pic->height - y * 16, 16); |
| 136 const int uv_w = (w + 1) >> 1; | 136 const int uv_w = (w + 1) >> 1; |
| 137 const int uv_h = (h + 1) >> 1; | 137 const int uv_h = (h + 1) >> 1; |
| 138 | 138 |
| 139 ImportBlock(ysrc, pic->y_stride, it->yuv_in_ + Y_OFF, w, h, 16); | 139 ImportBlock(ysrc, pic->y_stride, it->yuv_in_ + Y_OFF_ENC, w, h, 16); |
| 140 ImportBlock(usrc, pic->uv_stride, it->yuv_in_ + U_OFF, uv_w, uv_h, 8); | 140 ImportBlock(usrc, pic->uv_stride, it->yuv_in_ + U_OFF_ENC, uv_w, uv_h, 8); |
| 141 ImportBlock(vsrc, pic->uv_stride, it->yuv_in_ + V_OFF, uv_w, uv_h, 8); | 141 ImportBlock(vsrc, pic->uv_stride, it->yuv_in_ + V_OFF_ENC, uv_w, uv_h, 8); |
| 142 | 142 |
| 143 if (tmp_32 == NULL) return; | 143 if (tmp_32 == NULL) return; |
| 144 | 144 |
| 145 // Import source (uncompressed) samples into boundary. | 145 // Import source (uncompressed) samples into boundary. |
| 146 if (x == 0) { | 146 if (x == 0) { |
| 147 InitLeft(it); | 147 InitLeft(it); |
| 148 } else { | 148 } else { |
| 149 if (y == 0) { | 149 if (y == 0) { |
| 150 it->y_left_[-1] = it->u_left_[-1] = it->v_left_[-1] = 127; | 150 it->y_left_[-1] = it->u_left_[-1] = it->v_left_[-1] = 127; |
| 151 } else { | 151 } else { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 178 memcpy(dst, src, w); | 178 memcpy(dst, src, w); |
| 179 dst += dst_stride; | 179 dst += dst_stride; |
| 180 src += BPS; | 180 src += BPS; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 void VP8IteratorExport(const VP8EncIterator* const it) { | 184 void VP8IteratorExport(const VP8EncIterator* const it) { |
| 185 const VP8Encoder* const enc = it->enc_; | 185 const VP8Encoder* const enc = it->enc_; |
| 186 if (enc->config_->show_compressed) { | 186 if (enc->config_->show_compressed) { |
| 187 const int x = it->x_, y = it->y_; | 187 const int x = it->x_, y = it->y_; |
| 188 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF; | 188 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF_ENC; |
| 189 const uint8_t* const usrc = it->yuv_out_ + U_OFF; | 189 const uint8_t* const usrc = it->yuv_out_ + U_OFF_ENC; |
| 190 const uint8_t* const vsrc = it->yuv_out_ + V_OFF; | 190 const uint8_t* const vsrc = it->yuv_out_ + V_OFF_ENC; |
| 191 const WebPPicture* const pic = enc->pic_; | 191 const WebPPicture* const pic = enc->pic_; |
| 192 uint8_t* const ydst = pic->y + (y * pic->y_stride + x) * 16; | 192 uint8_t* const ydst = pic->y + (y * pic->y_stride + x) * 16; |
| 193 uint8_t* const udst = pic->u + (y * pic->uv_stride + x) * 8; | 193 uint8_t* const udst = pic->u + (y * pic->uv_stride + x) * 8; |
| 194 uint8_t* const vdst = pic->v + (y * pic->uv_stride + x) * 8; | 194 uint8_t* const vdst = pic->v + (y * pic->uv_stride + x) * 8; |
| 195 int w = (pic->width - x * 16); | 195 int w = (pic->width - x * 16); |
| 196 int h = (pic->height - y * 16); | 196 int h = (pic->height - y * 16); |
| 197 | 197 |
| 198 if (w > 16) w = 16; | 198 if (w > 16) w = 16; |
| 199 if (h > 16) h = 16; | 199 if (h > 16) h = 16; |
| 200 | 200 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 279 } |
| 280 | 280 |
| 281 #undef BIT | 281 #undef BIT |
| 282 | 282 |
| 283 //------------------------------------------------------------------------------ | 283 //------------------------------------------------------------------------------ |
| 284 // Advance to the next position, doing the bookkeeping. | 284 // Advance to the next position, doing the bookkeeping. |
| 285 | 285 |
| 286 void VP8IteratorSaveBoundary(VP8EncIterator* const it) { | 286 void VP8IteratorSaveBoundary(VP8EncIterator* const it) { |
| 287 VP8Encoder* const enc = it->enc_; | 287 VP8Encoder* const enc = it->enc_; |
| 288 const int x = it->x_, y = it->y_; | 288 const int x = it->x_, y = it->y_; |
| 289 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF; | 289 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF_ENC; |
| 290 const uint8_t* const uvsrc = it->yuv_out_ + U_OFF; | 290 const uint8_t* const uvsrc = it->yuv_out_ + U_OFF_ENC; |
| 291 if (x < enc->mb_w_ - 1) { // left | 291 if (x < enc->mb_w_ - 1) { // left |
| 292 int i; | 292 int i; |
| 293 for (i = 0; i < 16; ++i) { | 293 for (i = 0; i < 16; ++i) { |
| 294 it->y_left_[i] = ysrc[15 + i * BPS]; | 294 it->y_left_[i] = ysrc[15 + i * BPS]; |
| 295 } | 295 } |
| 296 for (i = 0; i < 8; ++i) { | 296 for (i = 0; i < 8; ++i) { |
| 297 it->u_left_[i] = uvsrc[7 + i * BPS]; | 297 it->u_left_[i] = uvsrc[7 + i * BPS]; |
| 298 it->v_left_[i] = uvsrc[15 + i * BPS]; | 298 it->v_left_[i] = uvsrc[15 + i * BPS]; |
| 299 } | 299 } |
| 300 // top-left (before 'top'!) | 300 // top-left (before 'top'!) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 if (it->i4_ == 16) { // we're done | 447 if (it->i4_ == 16) { // we're done |
| 448 return 0; | 448 return 0; |
| 449 } | 449 } |
| 450 | 450 |
| 451 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[it->i4_]; | 451 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[it->i4_]; |
| 452 return 1; | 452 return 1; |
| 453 } | 453 } |
| 454 | 454 |
| 455 //------------------------------------------------------------------------------ | 455 //------------------------------------------------------------------------------ |
| 456 | 456 |
| OLD | NEW |