1 |
|
/***************************************************************************** |
2 |
|
* |
3 |
|
* XVID MPEG-4 VIDEO CODEC |
4 |
|
* - Interpolation related header - |
5 |
|
* |
6 |
|
* Copyright(C) 2001-2003 Peter Ross <pross@xvid.org> |
7 |
|
* |
8 |
|
* This program is free software ; you can redistribute it and/or modify |
9 |
|
* it under the terms of the GNU General Public License as published by |
10 |
|
* the Free Software Foundation ; either version 2 of the License, or |
11 |
|
* (at your option) any later version. |
12 |
|
* |
13 |
|
* This program is distributed in the hope that it will be useful, |
14 |
|
* but WITHOUT ANY WARRANTY ; without even the implied warranty of |
15 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
* GNU General Public License for more details. |
17 |
|
* |
18 |
|
* You should have received a copy of the GNU General Public License |
19 |
|
* along with this program ; if not, write to the Free Software |
20 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
|
* |
22 |
|
* $Id$ |
23 |
|
* |
24 |
|
****************************************************************************/ |
25 |
|
|
26 |
#ifndef _INTERPOLATE8X8_H_ |
#ifndef _INTERPOLATE8X8_H_ |
27 |
#define _INTERPOLATE8X8_H_ |
#define _INTERPOLATE8X8_H_ |
28 |
|
|
147 |
const uint32_t stride, |
const uint32_t stride, |
148 |
const uint32_t rounding) |
const uint32_t rounding) |
149 |
{ |
{ |
|
int32_t ddx, ddy; |
|
150 |
|
|
151 |
switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) |
const uint8_t * const src = refn + (y + (dy>>1)) * stride + x + (dx>>1); |
152 |
{ |
uint8_t * const dst = cur + y * stride + x; |
153 |
|
|
154 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
155 |
case 0: |
case 0: |
156 |
ddx = dx / 2; |
transfer8x8_copy(dst, src, stride); |
|
ddy = dy / 2; |
|
|
transfer8x8_copy(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride); |
|
157 |
break; |
break; |
|
|
|
158 |
case 1: |
case 1: |
159 |
ddx = dx / 2; |
interpolate8x8_halfpel_v(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
160 |
break; |
break; |
|
|
|
161 |
case 2: |
case 2: |
162 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h(dst, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
163 |
break; |
break; |
|
|
|
164 |
default: |
default: |
165 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv(dst, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(cur + y * stride + x, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
166 |
break; |
break; |
167 |
} |
} |
168 |
} |
} |
205 |
static __inline uint8_t * |
static __inline uint8_t * |
206 |
interpolate8x8_switch2(uint8_t * const buffer, |
interpolate8x8_switch2(uint8_t * const buffer, |
207 |
const uint8_t * const refn, |
const uint8_t * const refn, |
208 |
const uint32_t x, |
const int x, |
209 |
const uint32_t y, |
const int y, |
210 |
const int32_t dx, |
const int dx, |
211 |
const int dy, |
const int dy, |
212 |
const uint32_t stride, |
const uint32_t stride, |
213 |
const uint32_t rounding) |
const uint32_t rounding) |
214 |
{ |
{ |
|
int32_t ddx, ddy; |
|
215 |
|
|
216 |
switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) |
const uint8_t * const src = refn + (y + (dy>>1)) * stride + x + (dx>>1); |
|
{ |
|
|
case 0: |
|
|
return (uint8_t *)refn + (int)((y + dy/2) * stride + x + dx/2); |
|
217 |
|
|
218 |
|
switch (((dx & 1) << 1) + (dy & 1)) { /* ((dx%2)?2:0)+((dy%2)?1:0) */ |
219 |
|
case 0: |
220 |
|
return (uint8_t *)src; |
221 |
case 1: |
case 1: |
222 |
ddx = dx / 2; |
interpolate8x8_halfpel_v(buffer, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_v(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
223 |
break; |
break; |
|
|
|
224 |
case 2: |
case 2: |
225 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_h(buffer, src, stride, rounding); |
|
ddy = dy / 2; |
|
|
interpolate8x8_halfpel_h(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
226 |
break; |
break; |
|
|
|
227 |
default: |
default: |
228 |
ddx = (dx - 1) / 2; |
interpolate8x8_halfpel_hv(buffer, src, stride, rounding); |
|
ddy = (dy - 1) / 2; |
|
|
interpolate8x8_halfpel_hv(buffer, |
|
|
refn + (int)((y + ddy) * stride + x + ddx), stride, |
|
|
rounding); |
|
229 |
break; |
break; |
230 |
} |
} |
231 |
return buffer; |
return buffer; |