Merge "vp8_rd_pick_best_mbsegmentation code restructure"
[libvpx.git] / vp8 / common / mbpitch.c
blobaf55e2fe07b5faeebdedb7a8fb6313770883d74d
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * 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.
9 */
12 #include "blockd.h"
14 typedef enum
16 PRED = 0,
17 DEST = 1
18 } BLOCKSET;
20 void vp8_setup_block
22 BLOCKD *b,
23 int mv_stride,
24 unsigned char **base,
25 int Stride,
26 int offset,
27 BLOCKSET bs
31 if (bs == DEST)
33 b->dst_stride = Stride;
34 b->dst = offset;
35 b->base_dst = base;
37 else
39 b->pre_stride = Stride;
40 b->pre = offset;
41 b->base_pre = base;
46 void vp8_setup_macroblock(MACROBLOCKD *x, BLOCKSET bs)
48 int block;
50 unsigned char **y, **u, **v;
52 if (bs == DEST)
54 y = &x->dst.y_buffer;
55 u = &x->dst.u_buffer;
56 v = &x->dst.v_buffer;
58 else
60 y = &x->pre.y_buffer;
61 u = &x->pre.u_buffer;
62 v = &x->pre.v_buffer;
65 for (block = 0; block < 16; block++) /* y blocks */
67 vp8_setup_block(&x->block[block], x->dst.y_stride, y, x->dst.y_stride,
68 (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs);
71 for (block = 16; block < 20; block++) /* U and V blocks */
73 vp8_setup_block(&x->block[block], x->dst.uv_stride, u, x->dst.uv_stride,
74 ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
76 vp8_setup_block(&x->block[block+4], x->dst.uv_stride, v, x->dst.uv_stride,
77 ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
81 void vp8_setup_block_dptrs(MACROBLOCKD *x)
83 int r, c;
85 for (r = 0; r < 4; r++)
87 for (c = 0; c < 4; c++)
89 x->block[r*4+c].diff = &x->diff[r * 4 * 16 + c * 4];
90 x->block[r*4+c].predictor = x->predictor + r * 4 * 16 + c * 4;
94 for (r = 0; r < 2; r++)
96 for (c = 0; c < 2; c++)
98 x->block[16+r*2+c].diff = &x->diff[256 + r * 4 * 8 + c * 4];
99 x->block[16+r*2+c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4;
104 for (r = 0; r < 2; r++)
106 for (c = 0; c < 2; c++)
108 x->block[20+r*2+c].diff = &x->diff[320+ r * 4 * 8 + c * 4];
109 x->block[20+r*2+c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4;
114 x->block[24].diff = &x->diff[384];
116 for (r = 0; r < 25; r++)
118 x->block[r].qcoeff = x->qcoeff + r * 16;
119 x->block[r].dqcoeff = x->dqcoeff + r * 16;
123 void vp8_build_block_doffsets(MACROBLOCKD *x)
126 /* handle the destination pitch features */
127 vp8_setup_macroblock(x, DEST);
128 vp8_setup_macroblock(x, PRED);