reconintra.c 15.9 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
6
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS.  All contributing project authors may
8
 *  be found in the AUTHORS file in the root of the source tree.
John Koleszar's avatar
John Koleszar committed
9
10
 */

11
#include <stdio.h>
John Koleszar's avatar
John Koleszar committed
12
#include "vpx_ports/config.h"
13
#include "vpx_rtcd.h"
John Koleszar's avatar
John Koleszar committed
14
15
16
#include "reconintra.h"
#include "vpx_mem/vpx_mem.h"

Paul Wilkins's avatar
Paul Wilkins committed
17
18
/* For skip_recon_mb(), add vp8_build_intra_predictors_mby_s(MACROBLOCKD *xd)
 * and vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *xd).
19
 */
20
21

void d27_predictor(unsigned char *ypred_ptr, int y_stride, int n,
John Koleszar's avatar
John Koleszar committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
                   unsigned char *yabove_row, unsigned char *yleft_col) {
  int r, c, h, w, v;
  int a, b;
  r = 0;
  for (c = 0; c < n - 2; c++) {
    if (c & 1)
      a = yleft_col[r + 1];
    else
      a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
    b = yabove_row[c + 2];
    ypred_ptr[c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
  }
  for (r = 1; r < n / 2 - 1; r++) {
    for (c = 0; c < n - 2 - 2 * r; c++) {
      if (c & 1)
        a = yleft_col[r + 1];
      else
        a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
      b = ypred_ptr[(r - 1) * y_stride + c + 2];
      ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
    }
  }
  for (; r < n - 1; ++r) {
    for (c = 0; c < n; c++) {
      v = (c & 1 ? yleft_col[r + 1] : (yleft_col[r] + yleft_col[r + 1] + 1) >> 1);
      h = r - c / 2;
      ypred_ptr[h * y_stride + c] = v;
    }
  }
  c = 0;
  r = n - 1;
  ypred_ptr[r * y_stride] = (ypred_ptr[(r - 1) * y_stride] +
                             yleft_col[r] + 1) >> 1;
  for (r = n - 2; r >= n / 2; --r) {
    w = c + (n - 1 - r) * 2;
    ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
                                   ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
  }
  for (c = 1; c < n; c++) {
    for (r = n - 1; r >= n / 2 + c / 2; --r) {
      w = c + (n - 1 - r) * 2;
      ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
                                     ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
    }
  }
67
68
69
}

void d63_predictor(unsigned char *ypred_ptr, int y_stride, int n,
John Koleszar's avatar
John Koleszar committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
                   unsigned char *yabove_row, unsigned char *yleft_col) {
  int r, c, h, w, v;
  int a, b;
  c = 0;
  for (r = 0; r < n - 2; r++) {
    if (r & 1)
      a = yabove_row[c + 1];
    else
      a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
    b = yleft_col[r + 2];
    ypred_ptr[r * y_stride] = (2 * a + (r + 1) * b + (r + 3) / 2) / (r + 3);
  }
  for (c = 1; c < n / 2 - 1; c++) {
    for (r = 0; r < n - 2 - 2 * c; r++) {
      if (r & 1)
        a = yabove_row[c + 1];
      else
        a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
      b = ypred_ptr[(r + 2) * y_stride + c - 1];
      ypred_ptr[r * y_stride + c] = (2 * a + (c + 1) * b + (c + 3) / 2) / (c + 3);
    }
  }
  for (; c < n - 1; ++c) {
    for (r = 0; r < n; r++) {
      v = (r & 1 ? yabove_row[c + 1] : (yabove_row[c] + yabove_row[c + 1] + 1) >> 1);
      w = c - r / 2;
      ypred_ptr[r * y_stride + w] = v;
    }
  }
  r = 0;
  c = n - 1;
  ypred_ptr[c] = (ypred_ptr[(c - 1)] + yabove_row[c] + 1) >> 1;
  for (c = n - 2; c >= n / 2; --c) {
    h = r + (n - 1 - c) * 2;
    ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
                                   ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
  }
  for (r = 1; r < n; r++) {
    for (c = n - 1; c >= n / 2 + r / 2; --c) {
      h = r + (n - 1 - c) * 2;
      ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
                                     ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
    }
  }
114
115
116
}

void d45_predictor(unsigned char *ypred_ptr, int y_stride, int n,
John Koleszar's avatar
John Koleszar committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
                   unsigned char *yabove_row, unsigned char *yleft_col) {
  int r, c;
  for (r = 0; r < n - 1; ++r) {
    for (c = 0; c <= r; ++c) {
      ypred_ptr[(r - c) * y_stride + c] =
        (yabove_row[r + 1] * (c + 1) +
         yleft_col[r + 1] * (r - c + 1) + r / 2 + 1) / (r + 2);
    }
  }
  for (c = 0; c <= r; ++c) {
    int yabove_ext = yabove_row[r]; // 2*yabove_row[r] - yabove_row[r-1];
    int yleft_ext = yleft_col[r]; // 2*yleft_col[r] - yleft_col[r-1];
    yabove_ext = (yabove_ext > 255 ? 255 : (yabove_ext < 0 ? 0 : yabove_ext));
    yleft_ext = (yleft_ext > 255 ? 255 : (yleft_ext < 0 ? 0 : yleft_ext));
    ypred_ptr[(r - c) * y_stride + c] =
      (yabove_ext * (c + 1) +
       yleft_ext * (r - c + 1) + r / 2 + 1) / (r + 2);
  }
  for (r = 1; r < n; ++r) {
    for (c = n - r; c < n; ++c)
      ypred_ptr[r * y_stride + c] = (ypred_ptr[(r - 1) * y_stride + c] +
                                     ypred_ptr[r * y_stride + c - 1] + 1) >> 1;
  }
140
141
142
}

void d117_predictor(unsigned char *ypred_ptr, int y_stride, int n,
John Koleszar's avatar
John Koleszar committed
143
144
145
146
147
148
149
150
151
152
153
154
                    unsigned char *yabove_row, unsigned char *yleft_col) {
  int r, c;
  for (c = 0; c < n; c++)
    ypred_ptr[c] = (yabove_row[c - 1] + yabove_row[c] + 1) >> 1;
  ypred_ptr += y_stride;
  for (c = 0; c < n; c++)
    ypred_ptr[c] = yabove_row[c - 1];
  ypred_ptr += y_stride;
  for (r = 2; r < n; ++r) {
    ypred_ptr[0] = yleft_col[r - 2];
    for (c = 1; c < n; c++)
      ypred_ptr[c] = ypred_ptr[-2 * y_stride + c - 1];
155
    ypred_ptr += y_stride;
John Koleszar's avatar
John Koleszar committed
156
  }
157
158
159
}

void d135_predictor(unsigned char *ypred_ptr, int y_stride, int n,
John Koleszar's avatar
John Koleszar committed
160
161
162
163
164
165
166
167
168
169
170
171
                    unsigned char *yabove_row, unsigned char *yleft_col) {
  int r, c;
  ypred_ptr[0] = yabove_row[-1];
  for (c = 1; c < n; c++)
    ypred_ptr[c] = yabove_row[c - 1];
  for (r = 1; r < n; ++r)
    ypred_ptr[r * y_stride] = yleft_col[r - 1];

  ypred_ptr += y_stride;
  for (r = 1; r < n; ++r) {
    for (c = 1; c < n; c++) {
      ypred_ptr[c] = ypred_ptr[-y_stride + c - 1];
172
    }
John Koleszar's avatar
John Koleszar committed
173
174
    ypred_ptr += y_stride;
  }
175
176
177
}

void d153_predictor(unsigned char *ypred_ptr, int y_stride, int n,
John Koleszar's avatar
John Koleszar committed
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
                    unsigned char *yabove_row, unsigned char *yleft_col) {
  int r, c;
  ypred_ptr[0] = (yabove_row[-1] + yleft_col[0] + 1) >> 1;
  for (r = 1; r < n; r++)
    ypred_ptr[r * y_stride] = (yleft_col[r - 1] + yleft_col[r] + 1) >> 1;
  ypred_ptr++;
  ypred_ptr[0] = yabove_row[-1];
  for (r = 1; r < n; r++)
    ypred_ptr[r * y_stride] = yleft_col[r - 1];
  ypred_ptr++;

  for (c = 0; c < n - 2; c++)
    ypred_ptr[c] = yabove_row[c];
  ypred_ptr += y_stride;
  for (r = 1; r < n; ++r) {
193
    for (c = 0; c < n - 2; c++)
John Koleszar's avatar
John Koleszar committed
194
      ypred_ptr[c] = ypred_ptr[-y_stride + c - 2];
195
    ypred_ptr += y_stride;
John Koleszar's avatar
John Koleszar committed
196
  }
197
198
}

199
void vp8_recon_intra_mbuv(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
200
  int i;
John Koleszar's avatar
John Koleszar committed
201

John Koleszar's avatar
John Koleszar committed
202
  for (i = 16; i < 24; i += 2) {
Paul Wilkins's avatar
Paul Wilkins committed
203
    BLOCKD *b = &xd->block[i];
204
    vp8_recon2b(b->predictor, b->diff,*(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
205
  }
John Koleszar's avatar
John Koleszar committed
206
207
}

208
void vp8_build_intra_predictors_internal(unsigned char *src, int src_stride,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
209
                                         unsigned char *ypred_ptr,
210
211
                                         int y_stride, int mode, int bsize,
                                         int up_available, int left_available) {
John Koleszar's avatar
John Koleszar committed
212

Ronald S. Bultje's avatar
Ronald S. Bultje committed
213
214
  unsigned char *yabove_row = src - src_stride;
  unsigned char yleft_col[32];
John Koleszar's avatar
John Koleszar committed
215
216
217
  unsigned char ytop_left = yabove_row[-1];
  int r, c, i;

Ronald S. Bultje's avatar
Ronald S. Bultje committed
218
  for (i = 0; i < bsize; i++) {
219
    yleft_col[i] = src[i * src_stride - 1];
John Koleszar's avatar
John Koleszar committed
220
221
222
223
224
225
226
227
228
  }

  /* for Y */
  switch (mode) {
    case DC_PRED: {
      int expected_dc;
      int i;
      int shift;
      int average = 0;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
229
230
      int log2_bsize_minus_1;

231
232
233
234
      assert(bsize == 4 || bsize == 8 || bsize == 16 || bsize == 32);
      if (bsize == 4) {
        log2_bsize_minus_1 = 1;
      } else if (bsize == 8) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
235
236
237
238
239
240
        log2_bsize_minus_1 = 2;
      } else if (bsize == 16) {
        log2_bsize_minus_1 = 3;
      } else /* bsize == 32 */ {
        log2_bsize_minus_1 = 4;
      }
John Koleszar's avatar
John Koleszar committed
241

242
243
      if (up_available || left_available) {
        if (up_available) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
244
          for (i = 0; i < bsize; i++) {
John Koleszar's avatar
John Koleszar committed
245
246
            average += yabove_row[i];
          }
John Koleszar's avatar
John Koleszar committed
247
248
        }

249
        if (left_available) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
250
          for (i = 0; i < bsize; i++) {
John Koleszar's avatar
John Koleszar committed
251
252
            average += yleft_col[i];
          }
John Koleszar's avatar
John Koleszar committed
253
        }
254
        shift = log2_bsize_minus_1 + up_available + left_available;
John Koleszar's avatar
John Koleszar committed
255
256
257
258
259
        expected_dc = (average + (1 << (shift - 1))) >> shift;
      } else {
        expected_dc = 128;
      }

Ronald S. Bultje's avatar
Ronald S. Bultje committed
260
261
262
      for (r = 0; r < bsize; r++) {
        vpx_memset(ypred_ptr, expected_dc, bsize);
        ypred_ptr += y_stride;
John Koleszar's avatar
John Koleszar committed
263
      }
John Koleszar's avatar
John Koleszar committed
264
265
    }
    break;
John Koleszar's avatar
John Koleszar committed
266
    case V_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
267
268
      for (r = 0; r < bsize; r++) {
        memcpy(ypred_ptr, yabove_row, bsize);
John Koleszar's avatar
John Koleszar committed
269
270
        ypred_ptr += y_stride;
      }
John Koleszar's avatar
John Koleszar committed
271
272
    }
    break;
John Koleszar's avatar
John Koleszar committed
273
    case H_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
274
275
      for (r = 0; r < bsize; r++) {
        vpx_memset(ypred_ptr, yleft_col[r], bsize);
John Koleszar's avatar
John Koleszar committed
276
277
        ypred_ptr += y_stride;
      }
John Koleszar's avatar
John Koleszar committed
278
279
    }
    break;
John Koleszar's avatar
John Koleszar committed
280
    case TM_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
281
282
      for (r = 0; r < bsize; r++) {
        for (c = 0; c < bsize; c++) {
John Koleszar's avatar
John Koleszar committed
283
          int pred =  yleft_col[r] + yabove_row[ c] - ytop_left;
John Koleszar's avatar
John Koleszar committed
284

John Koleszar's avatar
John Koleszar committed
285
286
          if (pred < 0)
            pred = 0;
John Koleszar's avatar
John Koleszar committed
287

John Koleszar's avatar
John Koleszar committed
288
289
          if (pred > 255)
            pred = 255;
John Koleszar's avatar
John Koleszar committed
290

John Koleszar's avatar
John Koleszar committed
291
          ypred_ptr[c] = pred;
John Koleszar's avatar
John Koleszar committed
292
293
        }

John Koleszar's avatar
John Koleszar committed
294
295
        ypred_ptr += y_stride;
      }
John Koleszar's avatar
John Koleszar committed
296
297
    }
    break;
John Koleszar's avatar
John Koleszar committed
298
    case D45_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
299
      d45_predictor(ypred_ptr, y_stride, bsize,  yabove_row, yleft_col);
300
301
    }
    break;
John Koleszar's avatar
John Koleszar committed
302
    case D135_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
303
      d135_predictor(ypred_ptr, y_stride, bsize,  yabove_row, yleft_col);
304
305
    }
    break;
John Koleszar's avatar
John Koleszar committed
306
    case D117_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
307
      d117_predictor(ypred_ptr, y_stride, bsize,  yabove_row, yleft_col);
308
309
    }
    break;
John Koleszar's avatar
John Koleszar committed
310
    case D153_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
311
      d153_predictor(ypred_ptr, y_stride, bsize,  yabove_row, yleft_col);
312
313
    }
    break;
John Koleszar's avatar
John Koleszar committed
314
    case D27_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
315
      d27_predictor(ypred_ptr, y_stride, bsize,  yabove_row, yleft_col);
316
317
    }
    break;
John Koleszar's avatar
John Koleszar committed
318
    case D63_PRED: {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
319
      d63_predictor(ypred_ptr, y_stride, bsize,  yabove_row, yleft_col);
320
321
    }
    break;
322
    case I8X8_PRED:
John Koleszar's avatar
John Koleszar committed
323
324
325
326
327
328
329
    case B_PRED:
    case NEARESTMV:
    case NEARMV:
    case ZEROMV:
    case NEWMV:
    case SPLITMV:
    case MB_MODE_COUNT:
John Koleszar's avatar
John Koleszar committed
330
331
      break;
  }
John Koleszar's avatar
John Koleszar committed
332
333
}

Paul Wilkins's avatar
Paul Wilkins committed
334
void vp8_build_intra_predictors_mby(MACROBLOCKD *xd) {
335
  vp8_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
336
                                      xd->predictor, 16,
337
338
                                      xd->mode_info_context->mbmi.mode, 16,
                                      xd->up_available, xd->left_available);
339
}
John Koleszar's avatar
John Koleszar committed
340

Paul Wilkins's avatar
Paul Wilkins committed
341
void vp8_build_intra_predictors_mby_s(MACROBLOCKD *xd) {
342
  vp8_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
343
                                      xd->dst.y_buffer, xd->dst.y_stride,
344
345
                                      xd->mode_info_context->mbmi.mode, 16,
                                      xd->up_available, xd->left_available);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
346
347
348
}

#if CONFIG_SUPERBLOCKS
349
350
351
352
353
void vp8_build_intra_predictors_sby_s(MACROBLOCKD *xd) {
  vp8_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
                                      xd->dst.y_buffer, xd->dst.y_stride,
                                      xd->mode_info_context->mbmi.mode, 32,
                                      xd->up_available, xd->left_available);
354
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
355
#endif
John Koleszar's avatar
John Koleszar committed
356

357
#if CONFIG_COMP_INTRA_PRED
Paul Wilkins's avatar
Paul Wilkins committed
358
void vp8_build_comp_intra_predictors_mby(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
359
360
361
  unsigned char predictor[2][256];
  int i;

362
  vp8_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
363
                                      predictor[0], 16,
364
                                      xd->mode_info_context->mbmi.mode,
365
366
367
                                      16, xd->up_available,
                                      xd->left_available);
  vp8_build_intra_predictors_internal(xd->dst.y_buffer, xd->dst.y_stride,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
368
                                      predictor[1], 16,
369
                                      xd->mode_info_context->mbmi.second_mode,
370
371
                                      16, xd->up_available,
                                      xd->left_available);
John Koleszar's avatar
John Koleszar committed
372
373

  for (i = 0; i < 256; i++) {
Paul Wilkins's avatar
Paul Wilkins committed
374
    xd->predictor[i] = (predictor[0][i] + predictor[1][i] + 1) >> 1;
John Koleszar's avatar
John Koleszar committed
375
  }
John Koleszar's avatar
John Koleszar committed
376
}
377
#endif
John Koleszar's avatar
John Koleszar committed
378

Paul Wilkins's avatar
Paul Wilkins committed
379
void vp8_build_intra_predictors_mbuv_internal(MACROBLOCKD *xd,
380
381
382
                                              unsigned char *upred_ptr,
                                              unsigned char *vpred_ptr,
                                              int uv_stride,
Ronald S. Bultje's avatar
Ronald S. Bultje committed
383
                                              int mode, int bsize) {
384
385
386
387
388
389
  vp8_build_intra_predictors_internal(xd->dst.u_buffer, xd->dst.uv_stride,
                                      upred_ptr, uv_stride, mode, bsize,
                                      xd->up_available, xd->left_available);
  vp8_build_intra_predictors_internal(xd->dst.v_buffer, xd->dst.uv_stride,
                                      vpred_ptr, uv_stride, mode, bsize,
                                      xd->up_available, xd->left_available);
John Koleszar's avatar
John Koleszar committed
390
}
391

Paul Wilkins's avatar
Paul Wilkins committed
392
void vp8_build_intra_predictors_mbuv(MACROBLOCKD *xd) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
393
394
395
396
  vp8_build_intra_predictors_mbuv_internal(xd, &xd->predictor[256],
                                           &xd->predictor[320], 8,
                                           xd->mode_info_context->mbmi.uv_mode,
                                           8);
397
398
}

Paul Wilkins's avatar
Paul Wilkins committed
399
void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *xd) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
400
401
402
403
404
  vp8_build_intra_predictors_mbuv_internal(xd, xd->dst.u_buffer,
                                           xd->dst.v_buffer,
                                           xd->dst.uv_stride,
                                           xd->mode_info_context->mbmi.uv_mode,
                                           8);
405
406
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
407
408
409
410
411
412
413
414
415
#if CONFIG_SUPERBLOCKS
void vp8_build_intra_predictors_sbuv_s(MACROBLOCKD *xd) {
  vp8_build_intra_predictors_mbuv_internal(xd, xd->dst.u_buffer,
                                           xd->dst.v_buffer, xd->dst.uv_stride,
                                           xd->mode_info_context->mbmi.uv_mode,
                                           16);
}
#endif

416
#if CONFIG_COMP_INTRA_PRED
Paul Wilkins's avatar
Paul Wilkins committed
417
void vp8_build_comp_intra_predictors_mbuv(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
418
419
420
  unsigned char predictor[2][2][64];
  int i;

Paul Wilkins's avatar
Paul Wilkins committed
421
422
  vp8_build_intra_predictors_mbuv_internal(
    xd, predictor[0][0], predictor[1][0], 8,
423
    xd->mode_info_context->mbmi.uv_mode, 8);
Paul Wilkins's avatar
Paul Wilkins committed
424
425
  vp8_build_intra_predictors_mbuv_internal(
    xd, predictor[0][1], predictor[1][1], 8,
426
    xd->mode_info_context->mbmi.second_uv_mode, 8);
John Koleszar's avatar
John Koleszar committed
427
  for (i = 0; i < 64; i++) {
Paul Wilkins's avatar
Paul Wilkins committed
428
    xd->predictor[256 + i] = (predictor[0][0][i] + predictor[0][1][i] + 1) >> 1;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
429
430
    xd->predictor[256 + 64 + i] = (predictor[1][0][i] +
                                   predictor[1][1][i] + 1) >> 1;
John Koleszar's avatar
John Koleszar committed
431
  }
432
433
434
}
#endif

Paul Wilkins's avatar
Paul Wilkins committed
435
void vp8_intra8x8_predict(BLOCKD *xd,
Yaowu Xu's avatar
Yaowu Xu committed
436
                          int mode,
John Koleszar's avatar
John Koleszar committed
437
                          unsigned char *predictor) {
438
439
440
  vp8_build_intra_predictors_internal(*(xd->base_dst) + xd->dst,
                                      xd->dst_stride, predictor, 16,
                                      mode, 8, 1, 1);
Yaowu Xu's avatar
Yaowu Xu committed
441
442
}

443
#if CONFIG_COMP_INTRA_PRED
Paul Wilkins's avatar
Paul Wilkins committed
444
void vp8_comp_intra8x8_predict(BLOCKD *xd,
445
                               int mode, int second_mode,
John Koleszar's avatar
John Koleszar committed
446
447
448
449
                               unsigned char *out_predictor) {
  unsigned char predictor[2][8 * 16];
  int i, j;

Paul Wilkins's avatar
Paul Wilkins committed
450
451
  vp8_intra8x8_predict(xd, mode, predictor[0]);
  vp8_intra8x8_predict(xd, second_mode, predictor[1]);
John Koleszar's avatar
John Koleszar committed
452
453
454
455

  for (i = 0; i < 8 * 16; i += 16) {
    for (j = i; j < i + 8; j++) {
      out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
456
    }
John Koleszar's avatar
John Koleszar committed
457
  }
458
459
460
}
#endif

Paul Wilkins's avatar
Paul Wilkins committed
461
void vp8_intra_uv4x4_predict(BLOCKD *xd,
Yaowu Xu's avatar
Yaowu Xu committed
462
                             int mode,
John Koleszar's avatar
John Koleszar committed
463
                             unsigned char *predictor) {
464
465
466
  vp8_build_intra_predictors_internal(*(xd->base_dst) + xd->dst,
                                      xd->dst_stride, predictor, 8,
                                      mode, 4, 1, 1);
Yaowu Xu's avatar
Yaowu Xu committed
467
468
}

469
#if CONFIG_COMP_INTRA_PRED
Paul Wilkins's avatar
Paul Wilkins committed
470
void vp8_comp_intra_uv4x4_predict(BLOCKD *xd,
471
                                  int mode, int mode2,
John Koleszar's avatar
John Koleszar committed
472
473
474
475
                                  unsigned char *out_predictor) {
  unsigned char predictor[2][8 * 4];
  int i, j;

Paul Wilkins's avatar
Paul Wilkins committed
476
477
  vp8_intra_uv4x4_predict(xd, mode, predictor[0]);
  vp8_intra_uv4x4_predict(xd, mode2, predictor[1]);
John Koleszar's avatar
John Koleszar committed
478
479
480
481

  for (i = 0; i < 4 * 8; i += 8) {
    for (j = i; j < i + 4; j++) {
      out_predictor[j] = (predictor[0][j] + predictor[1][j] + 1) >> 1;
482
    }
John Koleszar's avatar
John Koleszar committed
483
  }
484
485
}
#endif
Yaowu Xu's avatar
Yaowu Xu committed
486
487
488
489
490

/* TODO: try different ways of use Y-UV mode correlation
 Current code assumes that a uv 4x4 block use same mode
 as corresponding Y 8x8 area
 */