summaryrefslogtreecommitdiff
path: root/vp9/common/vp9_mbpitch.c
blob: 3a918522bffe651f54a4bf426f176b74021bbbf9 (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
/*
 *  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 "vp9/common/vp9_blockd.h"

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

static void setup_block(BLOCKD *b, uint8_t **base, uint8_t **base2,
                        int stride, int offset, BLOCKSET bs) {
  if (bs == DEST) {
    b->dst_stride = stride;
    b->dst = offset;
    b->base_dst = base;
  }
}

static void setup_macroblock(MACROBLOCKD *mb, BLOCKSET bs) {
  BLOCKD *blockd = mb->block;
  uint8_t **y, **u, **v, **y2, **u2, **v2;
  int i, stride;

  if (bs == DEST) {
    y = &mb->plane[0].dst.buf;
    u = &mb->plane[1].dst.buf;
    v = &mb->plane[2].dst.buf;

    y2 = NULL;
    u2 = NULL;
    v2 = NULL;
  }

  // luma
  stride = mb->plane[0].dst.stride;
  for (i = 0; i < 16; ++i) {
    const int offset = (i >> 2) * 4 * stride + (i & 3) * 4;
    setup_block(&blockd[i], y, y2, stride, offset, bs);
  }

  // chroma
  stride = mb->plane[1].dst.stride;
  for (i = 16; i < 20; i++) {
    const int offset = ((i - 16) >> 1) * 4 * stride + (i & 1) * 4;
    setup_block(&blockd[i],     u, u2, stride, offset, bs);
    setup_block(&blockd[i + 4], v, v2, stride, offset, bs);
  }
}

void vp9_setup_block_dptrs(MACROBLOCKD *mb) {
  int i;

  for (i = 0; i < MAX_MB_PLANE; i++) {
    mb->plane[i].plane_type = i ? PLANE_TYPE_UV : PLANE_TYPE_Y_WITH_DC;
    mb->plane[i].subsampling_x = !!i;
    mb->plane[i].subsampling_y = !!i;
  }
}

void vp9_build_block_doffsets(MACROBLOCKD *mb) {
  // handle the destination pitch features
  setup_macroblock(mb, DEST);
}