summaryrefslogtreecommitdiff
path: root/vp8/common/mbpitch.c
blob: 1a8431742f1e050b951ccc2f4adfacbc3ab6ce78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
67
68
69
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
114
115
116
117
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */


#include "blockd.h"

typedef enum {
  PRED = 0,
  DEST = 1
} BLOCKSET;

static void setup_block
(
  BLOCKD *b,
  int mv_stride,
  unsigned char **base,
  unsigned char **base2,
  int Stride,
  int offset,
  BLOCKSET bs
) {

  if (bs == DEST) {
    b->dst_stride = Stride;
    b->dst = offset;
    b->base_dst = base;
  } else {
    b->pre_stride = Stride;
    b->pre = offset;
    b->base_pre = base;
    b->base_second_pre = base2;
  }

}


static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs) {
  int block;

  unsigned char **y, **u, **v;
  unsigned char **y2, **u2, **v2;

  if (bs == DEST) {
    y = &x->dst.y_buffer;
    u = &x->dst.u_buffer;
    v = &x->dst.v_buffer;
  } else {
    y = &x->pre.y_buffer;
    u = &x->pre.u_buffer;
    v = &x->pre.v_buffer;

    y2 = &x->second_pre.y_buffer;
    u2 = &x->second_pre.u_buffer;
    v2 = &x->second_pre.v_buffer;
  }

  for (block = 0; block < 16; block++) { /* y blocks */
    setup_block(&x->block[block], x->dst.y_stride, y, y2, x->dst.y_stride,
                (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs);
  }

  for (block = 16; block < 20; block++) { /* U and V blocks */
    setup_block(&x->block[block], x->dst.uv_stride, u, u2, x->dst.uv_stride,
                ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);

    setup_block(&x->block[block + 4], x->dst.uv_stride, v, v2, x->dst.uv_stride,
                ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
  }
}

void vp8_setup_block_dptrs(MACROBLOCKD *x) {
  int r, c;

  for (r = 0; r < 4; r++) {
    for (c = 0; c < 4; c++) {
      x->block[r * 4 + c].diff      = &x->diff[r * 4 * 16 + c * 4];
      x->block[r * 4 + c].predictor = x->predictor + r * 4 * 16 + c * 4;
    }
  }

  for (r = 0; r < 2; r++) {
    for (c = 0; c < 2; c++) {
      x->block[16 + r * 2 + c].diff      = &x->diff[256 + r * 4 * 8 + c * 4];
      x->block[16 + r * 2 + c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4;

    }
  }

  for (r = 0; r < 2; r++) {
    for (c = 0; c < 2; c++) {
      x->block[20 + r * 2 + c].diff      = &x->diff[320 + r * 4 * 8 + c * 4];
      x->block[20 + r * 2 + c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4;

    }
  }

  x->block[24].diff = &x->diff[384];

  for (r = 0; r < 25; r++) {
    x->block[r].qcoeff  = x->qcoeff  + r * 16;
    x->block[r].dqcoeff = x->dqcoeff + r * 16;
  }
}

void vp8_build_block_doffsets(MACROBLOCKD *x) {

  /* handle the destination pitch features */
  setup_macroblock(x, DEST);
  setup_macroblock(x, PRED);
}