| 1 |
|
| /* |
| 2 |
|
| * motion_comp.c |
| 3 |
|
| * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> |
| 4 |
|
| * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
| 5 |
|
| * |
| 6 |
|
| * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. |
| 7 |
|
| * See http://libmpeg2.sourceforge.net/ for updates. |
| 8 |
|
| * |
| 9 |
|
| * mpeg2dec is free software; you can redistribute it and/or modify |
| 10 |
|
| * it under the terms of the GNU General Public License as published by |
| 11 |
|
| * the Free Software Foundation; either version 2 of the License, or |
| 12 |
|
| * (at your option) any later version. |
| 13 |
|
| * |
| 14 |
|
| * mpeg2dec is distributed in the hope that it will be useful, |
| 15 |
|
| * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
|
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
|
| * GNU General Public License for more details. |
| 18 |
|
| * |
| 19 |
|
| * You should have received a copy of the GNU General Public License |
| 20 |
|
| * along with this program; if not, write to the Free Software |
| 21 |
|
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 |
|
| */ |
| 23 |
|
| |
| 24 |
|
| #include "config.h" |
| 25 |
|
| |
| 26 |
|
| #include <inttypes.h> |
| 27 |
|
| |
| 28 |
|
| #include "mpeg2.h" |
| 29 |
|
| #include "attributes.h" |
| 30 |
|
| #include "mpeg2_internal.h" |
| 31 |
|
| |
| 32 |
|
| mpeg2_mc_t mpeg2_mc; |
| 33 |
|
| |
| 34 |
0 |
| void mpeg2_mc_init (uint32_t accel) |
| 35 |
|
| { |
| 36 |
|
| #ifdef ARCH_X86 |
| 37 |
0 |
▶ | if (accel & MPEG2_ACCEL_X86_MMXEXT) |
Branch: 1 branch
| Branch | True | False | Total |
| if (accel & MPEG2_ACCEL_X86_MMXEXT) |
0 |
0 |
0 |
|
| 38 |
0 |
| mpeg2_mc = mpeg2_mc_mmxext; |
| 39 |
0 |
▶ | else if (accel & MPEG2_ACCEL_X86_3DNOW) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (accel & MPEG2_ACCEL_X86_3DNOW) |
0 |
0 |
0 |
|
| 40 |
0 |
| mpeg2_mc = mpeg2_mc_3dnow; |
| 41 |
0 |
▶ | else if (accel & MPEG2_ACCEL_X86_MMX) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (accel & MPEG2_ACCEL_X86_MMX) |
0 |
0 |
0 |
|
| 42 |
0 |
| mpeg2_mc = mpeg2_mc_mmx; |
| 43 |
|
| else |
| 44 |
|
| #endif |
| 45 |
|
| #ifdef ARCH_PPC |
| 46 |
|
| if (accel & MPEG2_ACCEL_PPC_ALTIVEC) |
| 47 |
|
| mpeg2_mc = mpeg2_mc_altivec; |
| 48 |
|
| else |
| 49 |
|
| #endif |
| 50 |
|
| #ifdef ARCH_ALPHA |
| 51 |
|
| if (accel & MPEG2_ACCEL_ALPHA) |
| 52 |
|
| mpeg2_mc = mpeg2_mc_alpha; |
| 53 |
|
| else |
| 54 |
|
| #endif |
| 55 |
|
| #ifdef ARCH_SPARC |
| 56 |
|
| if (accel & MPEG2_ACCEL_SPARC_VIS) |
| 57 |
|
| mpeg2_mc = mpeg2_mc_vis; |
| 58 |
|
| else |
| 59 |
|
| #endif |
| 60 |
|
| #ifdef ARCH_ARM |
| 61 |
|
| if (accel & MPEG2_ACCEL_ARM) { |
| 62 |
|
| mpeg2_mc = mpeg2_mc_arm; |
| 63 |
|
| } else |
| 64 |
|
| #endif |
| 65 |
0 |
| mpeg2_mc = mpeg2_mc_c; |
| 66 |
0 |
| } |
| 67 |
|
| |
| 68 |
|
| #define avg2(a,b) ((a+b+1)>>1) |
| 69 |
|
| #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) |
| 70 |
|
| |
| 71 |
|
| #define predict_o(i) (ref[i]) |
| 72 |
|
| #define predict_x(i) (avg2 (ref[i], ref[i+1])) |
| 73 |
|
| #define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) |
| 74 |
|
| #define predict_xy(i) (avg4 (ref[i], ref[i+1], \ |
| 75 |
|
| (ref+stride)[i], (ref+stride)[i+1])) |
| 76 |
|
| |
| 77 |
|
| #define put(predictor,i) dest[i] = predictor (i) |
| 78 |
|
| #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) |
| 79 |
|
| |
| 80 |
|
| /* mc function template */ |
| 81 |
|
| |
| 82 |
|
| #define MC_FUNC(op,xy) \ |
| 83 |
|
| static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ |
| 84 |
|
| const int stride, int height) \ |
| 85 |
|
| { \ |
| 86 |
|
| do { \ |
| 87 |
|
| op (predict_##xy, 0); \ |
| 88 |
|
| op (predict_##xy, 1); \ |
| 89 |
|
| op (predict_##xy, 2); \ |
| 90 |
|
| op (predict_##xy, 3); \ |
| 91 |
|
| op (predict_##xy, 4); \ |
| 92 |
|
| op (predict_##xy, 5); \ |
| 93 |
|
| op (predict_##xy, 6); \ |
| 94 |
|
| op (predict_##xy, 7); \ |
| 95 |
|
| op (predict_##xy, 8); \ |
| 96 |
|
| op (predict_##xy, 9); \ |
| 97 |
|
| op (predict_##xy, 10); \ |
| 98 |
|
| op (predict_##xy, 11); \ |
| 99 |
|
| op (predict_##xy, 12); \ |
| 100 |
|
| op (predict_##xy, 13); \ |
| 101 |
|
| op (predict_##xy, 14); \ |
| 102 |
|
| op (predict_##xy, 15); \ |
| 103 |
|
| ref += stride; \ |
| 104 |
|
| dest += stride; \ |
| 105 |
|
| } while (--height); \ |
| 106 |
|
| } \ |
| 107 |
|
| static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ |
| 108 |
|
| const int stride, int height) \ |
| 109 |
|
| { \ |
| 110 |
|
| do { \ |
| 111 |
|
| op (predict_##xy, 0); \ |
| 112 |
|
| op (predict_##xy, 1); \ |
| 113 |
|
| op (predict_##xy, 2); \ |
| 114 |
|
| op (predict_##xy, 3); \ |
| 115 |
|
| op (predict_##xy, 4); \ |
| 116 |
|
| op (predict_##xy, 5); \ |
| 117 |
|
| op (predict_##xy, 6); \ |
| 118 |
|
| op (predict_##xy, 7); \ |
| 119 |
|
| ref += stride; \ |
| 120 |
|
| dest += stride; \ |
| 121 |
|
| } while (--height); \ |
| 122 |
|
| } |
| 123 |
|
| |
| 124 |
|
| /* definitions of the actual mc functions */ |
| 125 |
|
| |
| 126 |
0 |
▶ | MC_FUNC (put,o) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (put,o) |
0 |
0 |
0 |
| MC_FUNC (put,o) |
0 |
0 |
0 |
|
| 127 |
0 |
▶ | MC_FUNC (avg,o) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (avg,o) |
0 |
0 |
0 |
| MC_FUNC (avg,o) |
0 |
0 |
0 |
|
| 128 |
0 |
▶ | MC_FUNC (put,x) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (put,x) |
0 |
0 |
0 |
| MC_FUNC (put,x) |
0 |
0 |
0 |
|
| 129 |
0 |
▶ | MC_FUNC (avg,x) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (avg,x) |
0 |
0 |
0 |
| MC_FUNC (avg,x) |
0 |
0 |
0 |
|
| 130 |
0 |
▶ | MC_FUNC (put,y) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (put,y) |
0 |
0 |
0 |
| MC_FUNC (put,y) |
0 |
0 |
0 |
|
| 131 |
0 |
▶ | MC_FUNC (avg,y) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (avg,y) |
0 |
0 |
0 |
| MC_FUNC (avg,y) |
0 |
0 |
0 |
|
| 132 |
0 |
▶ | MC_FUNC (put,xy) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (put,xy) |
0 |
0 |
0 |
| MC_FUNC (put,xy) |
0 |
0 |
0 |
|
| 133 |
0 |
▶ | MC_FUNC (avg,xy) |
Branch: 2 branches
| Branch | True | False | Total |
| MC_FUNC (avg,xy) |
0 |
0 |
0 |
| MC_FUNC (avg,xy) |
0 |
0 |
0 |
|
| 134 |
|
| |
| 135 |
|
| MPEG2_MC_EXTERN (c) |