OLD | NEW |
1 // Copyright 2011 Google Inc. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // This code is licensed under the same terms as WebM: | 3 // This code is licensed under the same terms as WebM: |
4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
6 // ----------------------------------------------------------------------------- | 6 // ----------------------------------------------------------------------------- |
7 // | 7 // |
8 // VP8Iterator: block iterator | 8 // VP8Iterator: block iterator |
9 // | 9 // |
10 // Author: Skal (pascal.massimino@gmail.com) | 10 // Author: Skal (pascal.massimino@gmail.com) |
11 | 11 |
12 #include <stdlib.h> | |
13 #include <string.h> | 12 #include <string.h> |
14 #include "vp8enci.h" | 13 |
| 14 #include "./vp8enci.h" |
15 | 15 |
16 #if defined(__cplusplus) || defined(c_plusplus) | 16 #if defined(__cplusplus) || defined(c_plusplus) |
17 extern "C" { | 17 extern "C" { |
18 #endif | 18 #endif |
19 | 19 |
20 //------------------------------------------------------------------------------ | 20 //------------------------------------------------------------------------------ |
21 // VP8Iterator | 21 // VP8Iterator |
22 //------------------------------------------------------------------------------ | 22 //------------------------------------------------------------------------------ |
23 | 23 |
24 static void InitLeft(VP8EncIterator* const it) { | 24 static void InitLeft(VP8EncIterator* const it) { |
25 const VP8Encoder* const enc = it->enc_; | 25 const VP8Encoder* const enc = it->enc_; |
26 enc->y_left_[-1] = enc->u_left_[-1] = enc->v_left_[-1] = | 26 enc->y_left_[-1] = enc->u_left_[-1] = enc->v_left_[-1] = |
27 (it->y_) > 0 ? 129 : 127; | 27 (it->y_ > 0) ? 129 : 127; |
28 memset(enc->y_left_, 129, 16); | 28 memset(enc->y_left_, 129, 16); |
29 memset(enc->u_left_, 129, 8); | 29 memset(enc->u_left_, 129, 8); |
30 memset(enc->v_left_, 129, 8); | 30 memset(enc->v_left_, 129, 8); |
31 it->left_nz_[8] = 0; | 31 it->left_nz_[8] = 0; |
32 } | 32 } |
33 | 33 |
34 static void InitTop(VP8EncIterator* const it) { | 34 static void InitTop(VP8EncIterator* const it) { |
35 const VP8Encoder* const enc = it->enc_; | 35 const VP8Encoder* const enc = it->enc_; |
36 const int top_size = enc->mb_w_ * 16; | 36 const size_t top_size = enc->mb_w_ * 16; |
37 memset(enc->y_top_, 127, 2 * top_size); | 37 memset(enc->y_top_, 127, 2 * top_size); |
38 memset(enc->nz_, 0, enc->mb_w_ * sizeof(*enc->nz_)); | 38 memset(enc->nz_, 0, enc->mb_w_ * sizeof(*enc->nz_)); |
39 } | 39 } |
40 | 40 |
41 void VP8IteratorReset(VP8EncIterator* const it) { | 41 void VP8IteratorReset(VP8EncIterator* const it) { |
42 VP8Encoder* const enc = it->enc_; | 42 VP8Encoder* const enc = it->enc_; |
43 it->x_ = 0; | 43 it->x_ = 0; |
44 it->y_ = 0; | 44 it->y_ = 0; |
45 it->y_offset_ = 0; | 45 it->y_offset_ = 0; |
46 it->uv_offset_ = 0; | 46 it->uv_offset_ = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
58 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { | 58 void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) { |
59 it->enc_ = enc; | 59 it->enc_ = enc; |
60 it->y_stride_ = enc->pic_->y_stride; | 60 it->y_stride_ = enc->pic_->y_stride; |
61 it->uv_stride_ = enc->pic_->uv_stride; | 61 it->uv_stride_ = enc->pic_->uv_stride; |
62 // TODO(later): for multithreading, these should be owned by 'it'. | 62 // TODO(later): for multithreading, these should be owned by 'it'. |
63 it->yuv_in_ = enc->yuv_in_; | 63 it->yuv_in_ = enc->yuv_in_; |
64 it->yuv_out_ = enc->yuv_out_; | 64 it->yuv_out_ = enc->yuv_out_; |
65 it->yuv_out2_ = enc->yuv_out2_; | 65 it->yuv_out2_ = enc->yuv_out2_; |
66 it->yuv_p_ = enc->yuv_p_; | 66 it->yuv_p_ = enc->yuv_p_; |
67 it->lf_stats_ = enc->lf_stats_; | 67 it->lf_stats_ = enc->lf_stats_; |
| 68 it->percent0_ = enc->percent_; |
68 VP8IteratorReset(it); | 69 VP8IteratorReset(it); |
69 } | 70 } |
70 | 71 |
| 72 int VP8IteratorProgress(const VP8EncIterator* const it, int delta) { |
| 73 VP8Encoder* const enc = it->enc_; |
| 74 if (delta && enc->pic_->progress_hook) { |
| 75 const int percent = (enc->mb_h_ <= 1) |
| 76 ? it->percent0_ |
| 77 : it->percent0_ + delta * it->y_ / (enc->mb_h_ - 1); |
| 78 return WebPReportProgress(enc->pic_, percent, &enc->percent_); |
| 79 } |
| 80 return 1; |
| 81 } |
| 82 |
71 //------------------------------------------------------------------------------ | 83 //------------------------------------------------------------------------------ |
72 // Import the source samples into the cache. Takes care of replicating | 84 // Import the source samples into the cache. Takes care of replicating |
73 // boundary pixels if necessary. | 85 // boundary pixels if necessary. |
74 | 86 |
| 87 static void ImportBlock(const uint8_t* src, int src_stride, |
| 88 uint8_t* dst, int w, int h, int size) { |
| 89 int i; |
| 90 for (i = 0; i < h; ++i) { |
| 91 memcpy(dst, src, w); |
| 92 if (w < size) { |
| 93 memset(dst + w, dst[w - 1], size - w); |
| 94 } |
| 95 dst += BPS; |
| 96 src += src_stride; |
| 97 } |
| 98 for (i = h; i < size; ++i) { |
| 99 memcpy(dst, dst - BPS, size); |
| 100 dst += BPS; |
| 101 } |
| 102 } |
| 103 |
75 void VP8IteratorImport(const VP8EncIterator* const it) { | 104 void VP8IteratorImport(const VP8EncIterator* const it) { |
76 const VP8Encoder* const enc = it->enc_; | 105 const VP8Encoder* const enc = it->enc_; |
77 const int x = it->x_, y = it->y_; | 106 const int x = it->x_, y = it->y_; |
78 const WebPPicture* const pic = enc->pic_; | 107 const WebPPicture* const pic = enc->pic_; |
79 const uint8_t* ysrc = pic->y + (y * pic->y_stride + x) * 16; | 108 const uint8_t* const ysrc = pic->y + (y * pic->y_stride + x) * 16; |
80 const uint8_t* usrc = pic->u + (y * pic->uv_stride + x) * 8; | 109 const uint8_t* const usrc = pic->u + (y * pic->uv_stride + x) * 8; |
81 const uint8_t* vsrc = pic->v + (y * pic->uv_stride + x) * 8; | 110 const uint8_t* const vsrc = pic->v + (y * pic->uv_stride + x) * 8; |
82 uint8_t* ydst = it->yuv_in_ + Y_OFF; | 111 uint8_t* const ydst = it->yuv_in_ + Y_OFF; |
83 uint8_t* udst = it->yuv_in_ + U_OFF; | 112 uint8_t* const udst = it->yuv_in_ + U_OFF; |
84 uint8_t* vdst = it->yuv_in_ + V_OFF; | 113 uint8_t* const vdst = it->yuv_in_ + V_OFF; |
85 int w = (pic->width - x * 16); | 114 int w = (pic->width - x * 16); |
86 int h = (pic->height - y * 16); | 115 int h = (pic->height - y * 16); |
87 int i; | |
88 | 116 |
89 if (w > 16) w = 16; | 117 if (w > 16) w = 16; |
90 if (h > 16) h = 16; | 118 if (h > 16) h = 16; |
| 119 |
91 // Luma plane | 120 // Luma plane |
92 for (i = 0; i < h; ++i) { | 121 ImportBlock(ysrc, pic->y_stride, ydst, w, h, 16); |
93 memcpy(ydst, ysrc, w); | 122 |
94 if (w < 16) memset(ydst + w, ydst[w - 1], 16 - w); | 123 { // U/V planes |
95 ydst += BPS; | 124 const int uv_w = (w + 1) >> 1; |
96 ysrc += pic->y_stride; | 125 const int uv_h = (h + 1) >> 1; |
97 } | 126 ImportBlock(usrc, pic->uv_stride, udst, uv_w, uv_h, 8); |
98 for (i = h; i < 16; ++i) { | 127 ImportBlock(vsrc, pic->uv_stride, vdst, uv_w, uv_h, 8); |
99 memcpy(ydst, ydst - BPS, 16); | |
100 ydst += BPS; | |
101 } | |
102 // U/V plane | |
103 w = (w + 1) / 2; | |
104 h = (h + 1) / 2; | |
105 for (i = 0; i < h; ++i) { | |
106 memcpy(udst, usrc, w); | |
107 memcpy(vdst, vsrc, w); | |
108 if (w < 8) { | |
109 memset(udst + w, udst[w - 1], 8 - w); | |
110 memset(vdst + w, vdst[w - 1], 8 - w); | |
111 } | |
112 udst += BPS; | |
113 vdst += BPS; | |
114 usrc += pic->uv_stride; | |
115 vsrc += pic->uv_stride; | |
116 } | |
117 for (i = h; i < 8; ++i) { | |
118 memcpy(udst, udst - BPS, 8); | |
119 memcpy(vdst, vdst - BPS, 8); | |
120 udst += BPS; | |
121 vdst += BPS; | |
122 } | 128 } |
123 } | 129 } |
124 | 130 |
125 //------------------------------------------------------------------------------ | 131 //------------------------------------------------------------------------------ |
126 // Copy back the compressed samples into user space if requested. | 132 // Copy back the compressed samples into user space if requested. |
127 | 133 |
| 134 static void ExportBlock(const uint8_t* src, uint8_t* dst, int dst_stride, |
| 135 int w, int h) { |
| 136 while (h-- > 0) { |
| 137 memcpy(dst, src, w); |
| 138 dst += dst_stride; |
| 139 src += BPS; |
| 140 } |
| 141 } |
| 142 |
128 void VP8IteratorExport(const VP8EncIterator* const it) { | 143 void VP8IteratorExport(const VP8EncIterator* const it) { |
129 const VP8Encoder* const enc = it->enc_; | 144 const VP8Encoder* const enc = it->enc_; |
130 if (enc->config_->show_compressed) { | 145 if (enc->config_->show_compressed) { |
131 const int x = it->x_, y = it->y_; | 146 const int x = it->x_, y = it->y_; |
132 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF; | 147 const uint8_t* const ysrc = it->yuv_out_ + Y_OFF; |
133 const uint8_t* const usrc = it->yuv_out_ + U_OFF; | 148 const uint8_t* const usrc = it->yuv_out_ + U_OFF; |
134 const uint8_t* const vsrc = it->yuv_out_ + V_OFF; | 149 const uint8_t* const vsrc = it->yuv_out_ + V_OFF; |
135 const WebPPicture* const pic = enc->pic_; | 150 const WebPPicture* const pic = enc->pic_; |
136 uint8_t* ydst = pic->y + (y * pic->y_stride + x) * 16; | 151 uint8_t* const ydst = pic->y + (y * pic->y_stride + x) * 16; |
137 uint8_t* udst = pic->u + (y * pic->uv_stride + x) * 8; | 152 uint8_t* const udst = pic->u + (y * pic->uv_stride + x) * 8; |
138 uint8_t* vdst = pic->v + (y * pic->uv_stride + x) * 8; | 153 uint8_t* const vdst = pic->v + (y * pic->uv_stride + x) * 8; |
139 int w = (pic->width - x * 16); | 154 int w = (pic->width - x * 16); |
140 int h = (pic->height - y * 16); | 155 int h = (pic->height - y * 16); |
141 int i; | |
142 | 156 |
143 if (w > 16) w = 16; | 157 if (w > 16) w = 16; |
144 if (h > 16) h = 16; | 158 if (h > 16) h = 16; |
145 | 159 |
146 // Luma plane | 160 // Luma plane |
147 for (i = 0; i < h; ++i) { | 161 ExportBlock(ysrc, ydst, pic->y_stride, w, h); |
148 memcpy(ydst + i * pic->y_stride, ysrc + i * BPS, w); | 162 |
149 } | 163 { // U/V planes |
150 // U/V plane | 164 const int uv_w = (w + 1) >> 1; |
151 { | 165 const int uv_h = (h + 1) >> 1; |
152 const int uv_w = (w + 1) / 2; | 166 ExportBlock(usrc, udst, pic->uv_stride, uv_w, uv_h); |
153 const int uv_h = (h + 1) / 2; | 167 ExportBlock(vsrc, vdst, pic->uv_stride, uv_w, uv_h); |
154 for (i = 0; i < uv_h; ++i) { | |
155 memcpy(udst + i * pic->uv_stride, usrc + i * BPS, uv_w); | |
156 memcpy(vdst + i * pic->uv_stride, vsrc + i * BPS, uv_w); | |
157 } | |
158 } | 168 } |
159 } | 169 } |
160 } | 170 } |
161 | 171 |
162 //------------------------------------------------------------------------------ | 172 //------------------------------------------------------------------------------ |
163 // Non-zero contexts setup/teardown | 173 // Non-zero contexts setup/teardown |
164 | 174 |
165 // Nz bits: | 175 // Nz bits: |
166 // 0 1 2 3 Y | 176 // 0 1 2 3 Y |
167 // 4 5 6 7 | 177 // 4 5 6 7 |
168 // 8 9 10 11 | 178 // 8 9 10 11 |
169 // 12 13 14 15 | 179 // 12 13 14 15 |
170 // 16 17 U | 180 // 16 17 U |
171 // 18 19 | 181 // 18 19 |
172 // 20 21 V | 182 // 20 21 V |
173 // 22 23 | 183 // 22 23 |
174 // 24 DC-intra16 | 184 // 24 DC-intra16 |
175 | 185 |
176 // Convert packed context to byte array | 186 // Convert packed context to byte array |
177 #define BIT(nz, n) (!!((nz) & (1 << (n)))) | 187 #define BIT(nz, n) (!!((nz) & (1 << (n)))) |
178 | 188 |
179 void VP8IteratorNzToBytes(VP8EncIterator* const it) { | 189 void VP8IteratorNzToBytes(VP8EncIterator* const it) { |
180 const int tnz = it->nz_[0], lnz = it->nz_[-1]; | 190 const int tnz = it->nz_[0], lnz = it->nz_[-1]; |
| 191 int* const top_nz = it->top_nz_; |
| 192 int* const left_nz = it->left_nz_; |
181 | 193 |
182 // Top-Y | 194 // Top-Y |
183 it->top_nz_[0] = BIT(tnz, 12); | 195 top_nz[0] = BIT(tnz, 12); |
184 it->top_nz_[1] = BIT(tnz, 13); | 196 top_nz[1] = BIT(tnz, 13); |
185 it->top_nz_[2] = BIT(tnz, 14); | 197 top_nz[2] = BIT(tnz, 14); |
186 it->top_nz_[3] = BIT(tnz, 15); | 198 top_nz[3] = BIT(tnz, 15); |
187 // Top-U | 199 // Top-U |
188 it->top_nz_[4] = BIT(tnz, 18); | 200 top_nz[4] = BIT(tnz, 18); |
189 it->top_nz_[5] = BIT(tnz, 19); | 201 top_nz[5] = BIT(tnz, 19); |
190 // Top-V | 202 // Top-V |
191 it->top_nz_[6] = BIT(tnz, 22); | 203 top_nz[6] = BIT(tnz, 22); |
192 it->top_nz_[7] = BIT(tnz, 23); | 204 top_nz[7] = BIT(tnz, 23); |
193 // DC | 205 // DC |
194 it->top_nz_[8] = BIT(tnz, 24); | 206 top_nz[8] = BIT(tnz, 24); |
195 | 207 |
196 // left-Y | 208 // left-Y |
197 it->left_nz_[0] = BIT(lnz, 3); | 209 left_nz[0] = BIT(lnz, 3); |
198 it->left_nz_[1] = BIT(lnz, 7); | 210 left_nz[1] = BIT(lnz, 7); |
199 it->left_nz_[2] = BIT(lnz, 11); | 211 left_nz[2] = BIT(lnz, 11); |
200 it->left_nz_[3] = BIT(lnz, 15); | 212 left_nz[3] = BIT(lnz, 15); |
201 // left-U | 213 // left-U |
202 it->left_nz_[4] = BIT(lnz, 17); | 214 left_nz[4] = BIT(lnz, 17); |
203 it->left_nz_[5] = BIT(lnz, 19); | 215 left_nz[5] = BIT(lnz, 19); |
204 // left-V | 216 // left-V |
205 it->left_nz_[6] = BIT(lnz, 21); | 217 left_nz[6] = BIT(lnz, 21); |
206 it->left_nz_[7] = BIT(lnz, 23); | 218 left_nz[7] = BIT(lnz, 23); |
207 // left-DC is special, iterated separately | 219 // left-DC is special, iterated separately |
208 } | 220 } |
209 | 221 |
210 void VP8IteratorBytesToNz(VP8EncIterator* const it) { | 222 void VP8IteratorBytesToNz(VP8EncIterator* const it) { |
211 uint32_t nz = 0; | 223 uint32_t nz = 0; |
| 224 const int* const top_nz = it->top_nz_; |
| 225 const int* const left_nz = it->left_nz_; |
212 // top | 226 // top |
213 nz |= (it->top_nz_[0] << 12) | (it->top_nz_[1] << 13); | 227 nz |= (top_nz[0] << 12) | (top_nz[1] << 13); |
214 nz |= (it->top_nz_[2] << 14) | (it->top_nz_[3] << 15); | 228 nz |= (top_nz[2] << 14) | (top_nz[3] << 15); |
215 nz |= (it->top_nz_[4] << 18) | (it->top_nz_[5] << 19); | 229 nz |= (top_nz[4] << 18) | (top_nz[5] << 19); |
216 nz |= (it->top_nz_[6] << 22) | (it->top_nz_[7] << 23); | 230 nz |= (top_nz[6] << 22) | (top_nz[7] << 23); |
217 nz |= (it->top_nz_[8] << 24); // we propagate the _top_ bit, esp. for intra4 | 231 nz |= (top_nz[8] << 24); // we propagate the _top_ bit, esp. for intra4 |
218 // left | 232 // left |
219 nz |= (it->left_nz_[0] << 3) | (it->left_nz_[1] << 7); | 233 nz |= (left_nz[0] << 3) | (left_nz[1] << 7); |
220 nz |= (it->left_nz_[2] << 11); | 234 nz |= (left_nz[2] << 11); |
221 nz |= (it->left_nz_[4] << 17) | (it->left_nz_[6] << 21); | 235 nz |= (left_nz[4] << 17) | (left_nz[6] << 21); |
222 | 236 |
223 *it->nz_ = nz; | 237 *it->nz_ = nz; |
224 } | 238 } |
225 | 239 |
226 #undef BIT | 240 #undef BIT |
227 | 241 |
228 //------------------------------------------------------------------------------ | 242 //------------------------------------------------------------------------------ |
229 // Advance to the next position, doing the bookeeping. | 243 // Advance to the next position, doing the bookeeping. |
230 | 244 |
231 int VP8IteratorNext(VP8EncIterator* const it, | 245 int VP8IteratorNext(VP8EncIterator* const it, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 it->nz_ = enc->nz_; | 281 it->nz_ = enc->nz_; |
268 InitLeft(it); | 282 InitLeft(it); |
269 } | 283 } |
270 return (0 < --it->done_); | 284 return (0 < --it->done_); |
271 } | 285 } |
272 | 286 |
273 //------------------------------------------------------------------------------ | 287 //------------------------------------------------------------------------------ |
274 // Helper function to set mode properties | 288 // Helper function to set mode properties |
275 | 289 |
276 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode) { | 290 void VP8SetIntra16Mode(const VP8EncIterator* const it, int mode) { |
| 291 uint8_t* preds = it->preds_; |
277 int y; | 292 int y; |
278 uint8_t* preds = it->preds_; | |
279 for (y = 0; y < 4; ++y) { | 293 for (y = 0; y < 4; ++y) { |
280 memset(preds, mode, 4); | 294 memset(preds, mode, 4); |
281 preds += it->enc_->preds_w_; | 295 preds += it->enc_->preds_w_; |
282 } | 296 } |
283 it->mb_->type_ = 1; | 297 it->mb_->type_ = 1; |
284 } | 298 } |
285 | 299 |
286 void VP8SetIntra4Mode(const VP8EncIterator* const it, int modes[16]) { | 300 void VP8SetIntra4Mode(const VP8EncIterator* const it, const uint8_t* modes) { |
287 int x, y; | |
288 uint8_t* preds = it->preds_; | 301 uint8_t* preds = it->preds_; |
289 for (y = 0; y < 4; ++y) { | 302 int y; |
290 for (x = 0; x < 4; ++x) { | 303 for (y = 4; y > 0; --y) { |
291 preds[x] = modes[x + y * 4]; | 304 memcpy(preds, modes, 4 * sizeof(*modes)); |
292 } | |
293 preds += it->enc_->preds_w_; | 305 preds += it->enc_->preds_w_; |
| 306 modes += 4; |
294 } | 307 } |
295 it->mb_->type_ = 0; | 308 it->mb_->type_ = 0; |
296 } | 309 } |
297 | 310 |
298 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode) { | 311 void VP8SetIntraUVMode(const VP8EncIterator* const it, int mode) { |
299 it->mb_->uv_mode_ = mode; | 312 it->mb_->uv_mode_ = mode; |
300 } | 313 } |
301 | 314 |
302 void VP8SetSkip(const VP8EncIterator* const it, int skip) { | 315 void VP8SetSkip(const VP8EncIterator* const it, int skip) { |
303 it->mb_->skip_ = skip; | 316 it->mb_->skip_ = skip; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // Array to record the position of the top sample to pass to the prediction | 353 // Array to record the position of the top sample to pass to the prediction |
341 // functions in dsp.c. | 354 // functions in dsp.c. |
342 static const uint8_t VP8TopLeftI4[16] = { | 355 static const uint8_t VP8TopLeftI4[16] = { |
343 17, 21, 25, 29, | 356 17, 21, 25, 29, |
344 13, 17, 21, 25, | 357 13, 17, 21, 25, |
345 9, 13, 17, 21, | 358 9, 13, 17, 21, |
346 5, 9, 13, 17 | 359 5, 9, 13, 17 |
347 }; | 360 }; |
348 | 361 |
349 void VP8IteratorStartI4(VP8EncIterator* const it) { | 362 void VP8IteratorStartI4(VP8EncIterator* const it) { |
350 VP8Encoder* const enc = it->enc_; | 363 const VP8Encoder* const enc = it->enc_; |
351 int i; | 364 int i; |
352 | 365 |
353 it->i4_ = 0; // first 4x4 sub-block | 366 it->i4_ = 0; // first 4x4 sub-block |
354 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[0]; | 367 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[0]; |
355 | 368 |
356 // Import the boundary samples | 369 // Import the boundary samples |
357 for (i = 0; i < 17; ++i) { // left | 370 for (i = 0; i < 17; ++i) { // left |
358 it->i4_boundary_[i] = enc->y_left_[15 - i]; | 371 it->i4_boundary_[i] = enc->y_left_[15 - i]; |
359 } | 372 } |
360 for (i = 0; i < 16; ++i) { // top | 373 for (i = 0; i < 16; ++i) { // top |
(...skipping 25 matching lines...) Expand all Loading... |
386 if ((it->i4_ & 3) != 3) { // if not on the right sub-blocks #3, #7, #11, #15 | 399 if ((it->i4_ & 3) != 3) { // if not on the right sub-blocks #3, #7, #11, #15 |
387 for (i = 0; i <= 2; ++i) { // store future left samples | 400 for (i = 0; i <= 2; ++i) { // store future left samples |
388 top[i] = blk[3 + (2 - i) * BPS]; | 401 top[i] = blk[3 + (2 - i) * BPS]; |
389 } | 402 } |
390 } else { // else replicate top-right samples, as says the specs. | 403 } else { // else replicate top-right samples, as says the specs. |
391 for (i = 0; i <= 3; ++i) { | 404 for (i = 0; i <= 3; ++i) { |
392 top[i] = top[i + 4]; | 405 top[i] = top[i + 4]; |
393 } | 406 } |
394 } | 407 } |
395 // move pointers to next sub-block | 408 // move pointers to next sub-block |
396 it->i4_++; | 409 ++it->i4_; |
397 if (it->i4_ == 16) { // we're done | 410 if (it->i4_ == 16) { // we're done |
398 return 0; | 411 return 0; |
399 } | 412 } |
400 | 413 |
401 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[it->i4_]; | 414 it->i4_top_ = it->i4_boundary_ + VP8TopLeftI4[it->i4_]; |
402 return 1; | 415 return 1; |
403 } | 416 } |
404 | 417 |
405 //------------------------------------------------------------------------------ | 418 //------------------------------------------------------------------------------ |
406 | 419 |
407 #if defined(__cplusplus) || defined(c_plusplus) | 420 #if defined(__cplusplus) || defined(c_plusplus) |
408 } // extern "C" | 421 } // extern "C" |
409 #endif | 422 #endif |
OLD | NEW |