1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 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 */ 10 11 12 #include "blockd.h" 13 14 typedef enum 15 { 16 PRED = 0, 17 DEST = 1 18 } BLOCKSET; 19 20 void vp8_setup_block 21 ( 22 BLOCKD *b, 23 int mv_stride, 24 unsigned char **base, 25 int Stride, 26 int offset, 27 BLOCKSET bs 28 ) 29 { 30 31 if (bs == DEST) 32 { 33 b->dst_stride = Stride; 34 b->dst = offset; 35 b->base_dst = base; 36 } 37 else 38 { 39 b->pre_stride = Stride; 40 b->pre = offset; 41 b->base_pre = base; 42 } 43 44 } 45 46 void vp8_setup_macroblock(MACROBLOCKD *x, BLOCKSET bs) 47 { 48 int block; 49 50 unsigned char **y, **u, **v; 51 52 if (bs == DEST) 53 { 54 y = &x->dst.y_buffer; 55 u = &x->dst.u_buffer; 56 v = &x->dst.v_buffer; 57 } 58 else 59 { 60 y = &x->pre.y_buffer; 61 u = &x->pre.u_buffer; 62 v = &x->pre.v_buffer; 63 } 64 65 for (block = 0; block < 16; block++) /* y blocks */ 66 { 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); 69 } 70 71 for (block = 16; block < 20; block++) /* U and V blocks */ 72 { 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); 75 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); 78 } 79 } 80 81 void vp8_setup_block_dptrs(MACROBLOCKD *x) 82 { 83 int r, c; 84 85 for (r = 0; r < 4; r++) 86 { 87 for (c = 0; c < 4; c++) 88 { 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; 91 } 92 } 93 94 for (r = 0; r < 2; r++) 95 { 96 for (c = 0; c < 2; c++) 97 { 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; 100 101 } 102 } 103 104 for (r = 0; r < 2; r++) 105 { 106 for (c = 0; c < 2; c++) 107 { 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; 110 111 } 112 } 113 114 x->block[24].diff = &x->diff[384]; 115 116 for (r = 0; r < 25; r++) 117 { 118 x->block[r].qcoeff = x->qcoeff + r * 16; 119 x->block[r].dqcoeff = x->dqcoeff + r * 16; 120 } 121 } 122 123 void vp8_build_block_doffsets(MACROBLOCKD *x) 124 { 125 126 /* handle the destination pitch features */ 127 vp8_setup_macroblock(x, DEST); 128 vp8_setup_macroblock(x, PRED); 129 } 130