19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: qpel.h,v 1.2 2004-03-22 22:36:23 edgomez Exp $ |
* $Id: qpel.h,v 1.3 2004-08-10 21:58:55 edgomez Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
26 |
#ifndef _XVID_QPEL_H_ |
#ifndef _XVID_QPEL_H_ |
27 |
#define _XVID_QPEL_H_ |
#define _XVID_QPEL_H_ |
28 |
|
|
29 |
|
#include "interpolate8x8.h" |
30 |
#include "../utils/mem_transfer.h" |
#include "../utils/mem_transfer.h" |
31 |
|
|
32 |
/***************************************************************************** |
/***************************************************************************** |
67 |
****************************************************************************/ |
****************************************************************************/ |
68 |
extern void xvid_Init_QP(); |
extern void xvid_Init_QP(); |
69 |
|
|
70 |
|
extern XVID_QP_FUNCS xvid_QP_Funcs_C_ref; /* for P-frames */ |
71 |
|
extern XVID_QP_FUNCS xvid_QP_Add_Funcs_C_ref; /* for B-frames */ |
72 |
|
|
73 |
extern XVID_QP_FUNCS xvid_QP_Funcs_C; /* for P-frames */ |
extern XVID_QP_FUNCS xvid_QP_Funcs_C; /* for P-frames */ |
74 |
extern XVID_QP_FUNCS xvid_QP_Add_Funcs_C; /* for B-frames */ |
extern XVID_QP_FUNCS xvid_QP_Add_Funcs_C; /* for B-frames */ |
75 |
|
|
102 |
****************************************************************************/ |
****************************************************************************/ |
103 |
|
|
104 |
static void __inline |
static void __inline |
105 |
new_interpolate16x16_quarterpel(uint8_t * const cur, |
interpolate16x16_quarterpel(uint8_t * const cur, |
106 |
uint8_t * const refn, |
uint8_t * const refn, |
107 |
uint8_t * const refh, |
uint8_t * const refh, |
108 |
uint8_t * const refv, |
uint8_t * const refv, |
123 |
const int32_t xRef = x*4 + dx; |
const int32_t xRef = x*4 + dx; |
124 |
const int32_t yRef = y*4 + dy; |
const int32_t yRef = y*4 + dy; |
125 |
|
|
126 |
Ops = xvid_QP_Funcs; /* TODO: pass as argument */ |
Ops = xvid_QP_Funcs; |
127 |
quads = (dx&3) | ((dy&3)<<2); |
quads = (dx&3) | ((dy&3)<<2); |
128 |
|
|
129 |
x_int = xRef/4; |
x_int = xRef/4; |
204 |
} |
} |
205 |
|
|
206 |
static void __inline |
static void __inline |
207 |
new_interpolate16x8_quarterpel(uint8_t * const cur, |
interpolate16x16_add_quarterpel(uint8_t * const cur, |
208 |
|
uint8_t * const refn, |
209 |
|
uint8_t * const refh, |
210 |
|
uint8_t * const refv, |
211 |
|
uint8_t * const refhv, |
212 |
|
const uint32_t x, const uint32_t y, |
213 |
|
const int32_t dx, const int dy, |
214 |
|
const uint32_t stride, |
215 |
|
const uint32_t rounding) |
216 |
|
{ |
217 |
|
const uint8_t *src; |
218 |
|
uint8_t *dst; |
219 |
|
uint8_t *tmp; |
220 |
|
int32_t quads; |
221 |
|
const XVID_QP_FUNCS *Ops; |
222 |
|
const XVID_QP_FUNCS *Ops_Copy; |
223 |
|
|
224 |
|
int32_t x_int, y_int; |
225 |
|
|
226 |
|
const int32_t xRef = x*4 + dx; |
227 |
|
const int32_t yRef = y*4 + dy; |
228 |
|
|
229 |
|
Ops = xvid_QP_Add_Funcs; |
230 |
|
Ops_Copy = xvid_QP_Funcs; |
231 |
|
quads = (dx&3) | ((dy&3)<<2); |
232 |
|
|
233 |
|
x_int = xRef/4; |
234 |
|
if (xRef < 0 && xRef % 4) |
235 |
|
x_int--; |
236 |
|
|
237 |
|
y_int = yRef/4; |
238 |
|
if (yRef < 0 && yRef % 4) |
239 |
|
y_int--; |
240 |
|
|
241 |
|
dst = cur + y * stride + x; |
242 |
|
src = refn + y_int * stride + x_int; |
243 |
|
|
244 |
|
tmp = refh; /* we need at least a 16 x stride scratch block */ |
245 |
|
|
246 |
|
switch(quads) { |
247 |
|
case 0: |
248 |
|
/* NB: there is no halfpel involved ! the name's function can be |
249 |
|
* misleading */ |
250 |
|
interpolate8x8_halfpel_add(dst, src, stride, rounding); |
251 |
|
interpolate8x8_halfpel_add(dst+8, src+8, stride, rounding); |
252 |
|
interpolate8x8_halfpel_add(dst+8*stride, src+8*stride, stride, rounding); |
253 |
|
interpolate8x8_halfpel_add(dst+8*stride+8, src+8*stride+8, stride, rounding); |
254 |
|
break; |
255 |
|
case 1: |
256 |
|
Ops->H_Pass_Avrg(dst, src, 16, stride, rounding); |
257 |
|
break; |
258 |
|
case 2: |
259 |
|
Ops->H_Pass(dst, src, 16, stride, rounding); |
260 |
|
break; |
261 |
|
case 3: |
262 |
|
Ops->H_Pass_Avrg_Up(dst, src, 16, stride, rounding); |
263 |
|
break; |
264 |
|
case 4: |
265 |
|
Ops->V_Pass_Avrg(dst, src, 16, stride, rounding); |
266 |
|
break; |
267 |
|
case 5: |
268 |
|
Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding); |
269 |
|
Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding); |
270 |
|
break; |
271 |
|
case 6: |
272 |
|
Ops_Copy->H_Pass(tmp, src, 17, stride, rounding); |
273 |
|
Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding); |
274 |
|
break; |
275 |
|
case 7: |
276 |
|
Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding); |
277 |
|
Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding); |
278 |
|
break; |
279 |
|
case 8: |
280 |
|
Ops->V_Pass(dst, src, 16, stride, rounding); |
281 |
|
break; |
282 |
|
case 9: |
283 |
|
Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding); |
284 |
|
Ops->V_Pass(dst, tmp, 16, stride, rounding); |
285 |
|
break; |
286 |
|
case 10: |
287 |
|
Ops_Copy->H_Pass(tmp, src, 17, stride, rounding); |
288 |
|
Ops->V_Pass(dst, tmp, 16, stride, rounding); |
289 |
|
break; |
290 |
|
case 11: |
291 |
|
Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding); |
292 |
|
Ops->V_Pass(dst, tmp, 16, stride, rounding); |
293 |
|
break; |
294 |
|
case 12: |
295 |
|
Ops->V_Pass_Avrg_Up(dst, src, 16, stride, rounding); |
296 |
|
break; |
297 |
|
case 13: |
298 |
|
Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding); |
299 |
|
Ops->V_Pass_Avrg_Up(dst, tmp, 16, stride, rounding); |
300 |
|
break; |
301 |
|
case 14: |
302 |
|
Ops_Copy->H_Pass(tmp, src, 17, stride, rounding); |
303 |
|
Ops->V_Pass_Avrg_Up( dst, tmp, 16, stride, rounding); |
304 |
|
break; |
305 |
|
case 15: |
306 |
|
Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding); |
307 |
|
Ops->V_Pass_Avrg_Up(dst, tmp, 16, stride, rounding); |
308 |
|
break; |
309 |
|
} |
310 |
|
} |
311 |
|
|
312 |
|
static void __inline |
313 |
|
interpolate16x8_quarterpel(uint8_t * const cur, |
314 |
uint8_t * const refn, |
uint8_t * const refn, |
315 |
uint8_t * const refh, |
uint8_t * const refh, |
316 |
uint8_t * const refv, |
uint8_t * const refv, |
331 |
const int32_t xRef = x*4 + dx; |
const int32_t xRef = x*4 + dx; |
332 |
const int32_t yRef = y*4 + dy; |
const int32_t yRef = y*4 + dy; |
333 |
|
|
334 |
Ops = xvid_QP_Funcs; /* TODO: pass as argument */ |
Ops = xvid_QP_Funcs; |
335 |
quads = (dx&3) | ((dy&3)<<2); |
quads = (dx&3) | ((dy&3)<<2); |
336 |
|
|
337 |
x_int = xRef/4; |
x_int = xRef/4; |
410 |
} |
} |
411 |
|
|
412 |
static void __inline |
static void __inline |
413 |
new_interpolate8x8_quarterpel(uint8_t * const cur, |
interpolate8x8_quarterpel(uint8_t * const cur, |
414 |
uint8_t * const refn, |
uint8_t * const refn, |
415 |
uint8_t * const refh, |
uint8_t * const refh, |
416 |
uint8_t * const refv, |
uint8_t * const refv, |
431 |
const int32_t xRef = x*4 + dx; |
const int32_t xRef = x*4 + dx; |
432 |
const int32_t yRef = y*4 + dy; |
const int32_t yRef = y*4 + dy; |
433 |
|
|
434 |
Ops = xvid_QP_Funcs; /* TODO: pass as argument */ |
Ops = xvid_QP_Funcs; |
435 |
quads = (dx&3) | ((dy&3)<<2); |
quads = (dx&3) | ((dy&3)<<2); |
436 |
|
|
437 |
x_int = xRef/4; |
x_int = xRef/4; |
508 |
} |
} |
509 |
} |
} |
510 |
|
|
511 |
|
static void __inline |
512 |
|
interpolate8x8_add_quarterpel(uint8_t * const cur, |
513 |
|
uint8_t * const refn, |
514 |
|
uint8_t * const refh, |
515 |
|
uint8_t * const refv, |
516 |
|
uint8_t * const refhv, |
517 |
|
const uint32_t x, const uint32_t y, |
518 |
|
const int32_t dx, const int dy, |
519 |
|
const uint32_t stride, |
520 |
|
const uint32_t rounding) |
521 |
|
{ |
522 |
|
const uint8_t *src; |
523 |
|
uint8_t *dst; |
524 |
|
uint8_t *tmp; |
525 |
|
int32_t quads; |
526 |
|
const XVID_QP_FUNCS *Ops; |
527 |
|
const XVID_QP_FUNCS *Ops_Copy; |
528 |
|
|
529 |
|
int32_t x_int, y_int; |
530 |
|
|
531 |
|
const int32_t xRef = x*4 + dx; |
532 |
|
const int32_t yRef = y*4 + dy; |
533 |
|
|
534 |
|
Ops = xvid_QP_Add_Funcs; |
535 |
|
Ops_Copy = xvid_QP_Funcs; |
536 |
|
quads = (dx&3) | ((dy&3)<<2); |
537 |
|
|
538 |
|
x_int = xRef/4; |
539 |
|
if (xRef < 0 && xRef % 4) |
540 |
|
x_int--; |
541 |
|
|
542 |
|
y_int = yRef/4; |
543 |
|
if (yRef < 0 && yRef % 4) |
544 |
|
y_int--; |
545 |
|
|
546 |
|
dst = cur + y * stride + x; |
547 |
|
src = refn + y_int * stride + x_int; |
548 |
|
|
549 |
|
tmp = refh; /* we need at least a 16 x stride scratch block */ |
550 |
|
|
551 |
|
switch(quads) { |
552 |
|
case 0: |
553 |
|
/* Misleading function name, there is no halfpel involved |
554 |
|
* just dst and src averaging with rounding=0 */ |
555 |
|
interpolate8x8_halfpel_add(dst, src, stride, rounding); |
556 |
|
break; |
557 |
|
case 1: |
558 |
|
Ops->H_Pass_Avrg_8(dst, src, 8, stride, rounding); |
559 |
|
break; |
560 |
|
case 2: |
561 |
|
Ops->H_Pass_8(dst, src, 8, stride, rounding); |
562 |
|
break; |
563 |
|
case 3: |
564 |
|
Ops->H_Pass_Avrg_Up_8(dst, src, 8, stride, rounding); |
565 |
|
break; |
566 |
|
case 4: |
567 |
|
Ops->V_Pass_Avrg_8(dst, src, 8, stride, rounding); |
568 |
|
break; |
569 |
|
case 5: |
570 |
|
Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding); |
571 |
|
Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding); |
572 |
|
break; |
573 |
|
case 6: |
574 |
|
Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding); |
575 |
|
Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding); |
576 |
|
break; |
577 |
|
case 7: |
578 |
|
Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding); |
579 |
|
Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding); |
580 |
|
break; |
581 |
|
case 8: |
582 |
|
Ops->V_Pass_8(dst, src, 8, stride, rounding); |
583 |
|
break; |
584 |
|
case 9: |
585 |
|
Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding); |
586 |
|
Ops->V_Pass_8(dst, tmp, 8, stride, rounding); |
587 |
|
break; |
588 |
|
case 10: |
589 |
|
Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding); |
590 |
|
Ops->V_Pass_8(dst, tmp, 8, stride, rounding); |
591 |
|
break; |
592 |
|
case 11: |
593 |
|
Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding); |
594 |
|
Ops->V_Pass_8(dst, tmp, 8, stride, rounding); |
595 |
|
break; |
596 |
|
case 12: |
597 |
|
Ops->V_Pass_Avrg_Up_8(dst, src, 8, stride, rounding); |
598 |
|
break; |
599 |
|
case 13: |
600 |
|
Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding); |
601 |
|
Ops->V_Pass_Avrg_Up_8(dst, tmp, 8, stride, rounding); |
602 |
|
break; |
603 |
|
case 14: |
604 |
|
Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding); |
605 |
|
Ops->V_Pass_Avrg_Up_8( dst, tmp, 8, stride, rounding); |
606 |
|
break; |
607 |
|
case 15: |
608 |
|
Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding); |
609 |
|
Ops->V_Pass_Avrg_Up_8(dst, tmp, 8, stride, rounding); |
610 |
|
break; |
611 |
|
} |
612 |
|
} |
613 |
|
|
614 |
#endif /* _XVID_QPEL_H_ */ |
#endif /* _XVID_QPEL_H_ */ |