| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <stdint.h> | ||
| 20 | |||
| 21 | #include "config.h" | ||
| 22 | #include "libavutil/attributes.h" | ||
| 23 | #include "libavutil/cpu.h" | ||
| 24 | #include "libavutil/x86/cpu.h" | ||
| 25 | #include "libavcodec/h264chroma.h" | ||
| 26 | |||
| 27 | void ff_put_h264_chroma_mc2_mmxext (uint8_t *dst, const uint8_t *src, | ||
| 28 | ptrdiff_t stride, int h, int x, int y); | ||
| 29 | void ff_avg_h264_chroma_mc2_mmxext (uint8_t *dst, const uint8_t *src, | ||
| 30 | ptrdiff_t stride, int h, int x, int y); | ||
| 31 | |||
| 32 | void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src, | ||
| 33 | ptrdiff_t stride, int h, int x, int y); | ||
| 34 | void ff_put_h264_chroma_mc4_ssse3 (uint8_t *dst, const uint8_t *src, | ||
| 35 | ptrdiff_t stride, int h, int x, int y); | ||
| 36 | |||
| 37 | void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src, | ||
| 38 | ptrdiff_t stride, int h, int x, int y); | ||
| 39 | void ff_avg_h264_chroma_mc4_ssse3 (uint8_t *dst, const uint8_t *src, | ||
| 40 | ptrdiff_t stride, int h, int x, int y); | ||
| 41 | |||
| 42 | #define CHROMA_MC(OP, NUM, DEPTH, OPT) \ | ||
| 43 | void ff_ ## OP ## _h264_chroma_mc ## NUM ## _ ## DEPTH ## _ ## OPT \ | ||
| 44 | (uint8_t *dst, const uint8_t *src, \ | ||
| 45 | ptrdiff_t stride, int h, int x, int y); | ||
| 46 | |||
| 47 | CHROMA_MC(put, 2, 10, mmxext) | ||
| 48 | CHROMA_MC(avg, 2, 10, mmxext) | ||
| 49 | CHROMA_MC(put, 4, 10, mmxext) | ||
| 50 | CHROMA_MC(avg, 4, 10, mmxext) | ||
| 51 | CHROMA_MC(put, 8, 10, sse2) | ||
| 52 | CHROMA_MC(avg, 8, 10, sse2) | ||
| 53 | CHROMA_MC(put, 8, 10, avx) | ||
| 54 | CHROMA_MC(avg, 8, 10, avx) | ||
| 55 | |||
| 56 | 1361 | av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) | |
| 57 | { | ||
| 58 | 1361 | int high_bit_depth = bit_depth > 8; | |
| 59 | 1361 | int cpu_flags = av_get_cpu_flags(); | |
| 60 | |||
| 61 |
4/4✓ Branch 0 taken 257 times.
✓ Branch 1 taken 1104 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 36 times.
|
1361 | if (EXTERNAL_MMXEXT(cpu_flags) && !high_bit_depth) { |
| 62 | 221 | c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext; | |
| 63 | 221 | c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext; | |
| 64 | } | ||
| 65 | |||
| 66 |
5/6✓ Branch 0 taken 257 times.
✓ Branch 1 taken 1104 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 221 times.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
|
1361 | if (EXTERNAL_MMXEXT(cpu_flags) && bit_depth > 8 && bit_depth <= 10) { |
| 67 | 36 | c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_10_mmxext; | |
| 68 | 36 | c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_10_mmxext; | |
| 69 | 36 | c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_10_mmxext; | |
| 70 | 36 | c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_10_mmxext; | |
| 71 | } | ||
| 72 | |||
| 73 |
5/6✓ Branch 0 taken 251 times.
✓ Branch 1 taken 1110 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 219 times.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
1361 | if (EXTERNAL_SSE2(cpu_flags) && bit_depth > 8 && bit_depth <= 10) { |
| 74 | 32 | c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_sse2; | |
| 75 | 32 | c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_sse2; | |
| 76 | } | ||
| 77 | |||
| 78 |
4/4✓ Branch 0 taken 245 times.
✓ Branch 1 taken 1116 times.
✓ Branch 2 taken 217 times.
✓ Branch 3 taken 28 times.
|
1361 | if (EXTERNAL_SSSE3(cpu_flags) && !high_bit_depth) { |
| 79 | 217 | c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_rnd_ssse3; | |
| 80 | 217 | c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_ssse3; | |
| 81 | 217 | c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_ssse3; | |
| 82 | 217 | c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_ssse3; | |
| 83 | } | ||
| 84 | |||
| 85 |
5/6✓ Branch 0 taken 230 times.
✓ Branch 1 taken 1131 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
1361 | if (EXTERNAL_AVX(cpu_flags) && bit_depth > 8 && bit_depth <= 10) { |
| 86 | // AVX implies !cache64. | ||
| 87 | // TODO: Port cache(32|64) detection from x264. | ||
| 88 | 18 | c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx; | |
| 89 | 18 | c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx; | |
| 90 | } | ||
| 91 | 1361 | } | |
| 92 |