| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * SIMD-optimized halfpel functions | ||
| 3 | * Copyright (c) 2000, 2001 Fabrice Bellard | ||
| 4 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
| 5 | * | ||
| 6 | * This file is part of FFmpeg. | ||
| 7 | * | ||
| 8 | * FFmpeg is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * FFmpeg 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 GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with FFmpeg; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | * | ||
| 22 | * MMX optimization by Nick Kurshev <nickols_k@mail.ru> | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include <stddef.h> | ||
| 26 | #include <stdint.h> | ||
| 27 | |||
| 28 | #include "libavutil/attributes.h" | ||
| 29 | #include "libavutil/cpu.h" | ||
| 30 | #include "libavutil/x86/cpu.h" | ||
| 31 | #include "libavcodec/avcodec.h" | ||
| 32 | #include "libavcodec/hpeldsp.h" | ||
| 33 | #include "fpel.h" | ||
| 34 | #include "hpeldsp.h" | ||
| 35 | |||
| 36 | void ff_put_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels, | ||
| 37 | ptrdiff_t line_size, int h); | ||
| 38 | void ff_put_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 39 | ptrdiff_t line_size, int h); | ||
| 40 | void ff_avg_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 41 | ptrdiff_t line_size, int h); | ||
| 42 | void ff_put_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 43 | ptrdiff_t line_size, int h); | ||
| 44 | void ff_avg_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 45 | ptrdiff_t line_size, int h); | ||
| 46 | void ff_put_no_rnd_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels, | ||
| 47 | ptrdiff_t line_size, int h); | ||
| 48 | void ff_put_no_rnd_pixels8_x2_exact_mmxext(uint8_t *block, | ||
| 49 | const uint8_t *pixels, | ||
| 50 | ptrdiff_t line_size, int h); | ||
| 51 | void ff_put_no_rnd_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 52 | ptrdiff_t line_size, int h); | ||
| 53 | void ff_avg_no_rnd_pixels16_x2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 54 | ptrdiff_t line_size, int h); | ||
| 55 | void ff_put_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels, | ||
| 56 | ptrdiff_t line_size, int h); | ||
| 57 | void ff_put_no_rnd_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels, | ||
| 58 | ptrdiff_t line_size, int h); | ||
| 59 | void ff_put_no_rnd_pixels8_y2_exact_mmxext(uint8_t *block, | ||
| 60 | const uint8_t *pixels, | ||
| 61 | ptrdiff_t line_size, int h); | ||
| 62 | void ff_put_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 63 | ptrdiff_t line_size, int h); | ||
| 64 | void ff_avg_no_rnd_pixels16_y2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 65 | ptrdiff_t line_size, int h); | ||
| 66 | void ff_put_no_rnd_pixels8_xy2_ssse3(uint8_t *block, const uint8_t *pixels, | ||
| 67 | ptrdiff_t line_size, int h); | ||
| 68 | void ff_put_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 69 | ptrdiff_t line_size, int h); | ||
| 70 | void ff_avg_no_rnd_pixels16_xy2_sse2(uint8_t *block, const uint8_t *pixels, | ||
| 71 | ptrdiff_t line_size, int h); | ||
| 72 | void ff_avg_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels, | ||
| 73 | ptrdiff_t line_size, int h); | ||
| 74 | void ff_avg_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels, | ||
| 75 | ptrdiff_t line_size, int h); | ||
| 76 | |||
| 77 | 170 | static void hpeldsp_init_mmxext(HpelDSPContext *c, int flags) | |
| 78 | { | ||
| 79 | #if HAVE_MMXEXT_EXTERNAL | ||
| 80 | 170 | c->put_pixels_tab[1][1] = ff_put_pixels8_x2_mmxext; | |
| 81 | 170 | c->put_pixels_tab[1][2] = ff_put_pixels8_y2_mmxext; | |
| 82 | |||
| 83 | 170 | c->avg_pixels_tab[1][0] = ff_avg_pixels8_mmxext; | |
| 84 | 170 | c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_mmxext; | |
| 85 | 170 | c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_mmxext; | |
| 86 | |||
| 87 | 170 | c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext; | |
| 88 | 170 | c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext; | |
| 89 | |||
| 90 |
2/2✓ Branch 0 taken 142 times.
✓ Branch 1 taken 28 times.
|
170 | if (!(flags & AV_CODEC_FLAG_BITEXACT)) { |
| 91 | 142 | c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_mmxext; | |
| 92 | 142 | c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_mmxext; | |
| 93 | } | ||
| 94 | #endif /* HAVE_MMXEXT_EXTERNAL */ | ||
| 95 | 170 | } | |
| 96 | |||
| 97 | 168 | static void hpeldsp_init_sse2(HpelDSPContext *c, int flags) | |
| 98 | { | ||
| 99 | #if HAVE_SSE2_EXTERNAL | ||
| 100 | 168 | c->put_pixels_tab[0][0] = ff_put_pixels16_sse2; | |
| 101 | 168 | c->put_pixels_tab[0][1] = ff_put_pixels16_x2_sse2; | |
| 102 | 168 | c->put_pixels_tab[0][2] = ff_put_pixels16_y2_sse2; | |
| 103 | 168 | c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_sse2; | |
| 104 | |||
| 105 | 168 | c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_sse2; | |
| 106 | 168 | c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_sse2; | |
| 107 | 168 | c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_sse2; | |
| 108 | 168 | c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_sse2; | |
| 109 | |||
| 110 | 168 | c->put_no_rnd_pixels_tab[1][0] = | |
| 111 | 168 | c->put_pixels_tab[1][0] = ff_put_pixels8_sse2; | |
| 112 | |||
| 113 | 168 | c->avg_pixels_tab[0][0] = ff_avg_pixels16_sse2; | |
| 114 | 168 | c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_sse2; | |
| 115 | 168 | c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_sse2; | |
| 116 | 168 | c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_sse2; | |
| 117 | |||
| 118 | 168 | c->avg_no_rnd_pixels_tab[0] = ff_avg_pixels16_sse2; | |
| 119 | 168 | c->avg_no_rnd_pixels_tab[1] = ff_avg_no_rnd_pixels16_x2_sse2; | |
| 120 | 168 | c->avg_no_rnd_pixels_tab[2] = ff_avg_no_rnd_pixels16_y2_sse2; | |
| 121 | 168 | c->avg_no_rnd_pixels_tab[3] = ff_avg_no_rnd_pixels16_xy2_sse2; | |
| 122 | #endif /* HAVE_SSE2_EXTERNAL */ | ||
| 123 | 168 | } | |
| 124 | |||
| 125 | 166 | static void hpeldsp_init_ssse3(HpelDSPContext *c, int flags) | |
| 126 | { | ||
| 127 | #if HAVE_SSSE3_EXTERNAL | ||
| 128 | 166 | c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_ssse3; | |
| 129 | 166 | c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_ssse3; | |
| 130 | 166 | c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_ssse3; | |
| 131 | 166 | c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_ssse3; | |
| 132 | |||
| 133 | 166 | c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_ssse3; | |
| 134 | #endif | ||
| 135 | 166 | } | |
| 136 | |||
| 137 | 941 | av_cold void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags) | |
| 138 | { | ||
| 139 | 941 | int cpu_flags = av_get_cpu_flags(); | |
| 140 | |||
| 141 |
2/2✓ Branch 0 taken 170 times.
✓ Branch 1 taken 771 times.
|
941 | if (EXTERNAL_MMXEXT(cpu_flags)) |
| 142 | 170 | hpeldsp_init_mmxext(c, flags); | |
| 143 | |||
| 144 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 773 times.
|
941 | if (EXTERNAL_SSE2(cpu_flags)) |
| 145 | 168 | hpeldsp_init_sse2(c, flags); | |
| 146 | |||
| 147 |
2/2✓ Branch 0 taken 166 times.
✓ Branch 1 taken 775 times.
|
941 | if (EXTERNAL_SSSE3(cpu_flags)) |
| 148 | 166 | hpeldsp_init_ssse3(c, flags); | |
| 149 | 941 | } | |
| 150 |