FFmpeg
Loading...
Searching...
No Matches
h264chroma_init.c
Go to the documentation of this file.
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"
23#include "libavutil/cpu.h"
24#include "libavutil/x86/cpu.h"
26
27void ff_put_h264_chroma_mc2_mmxext (uint8_t *dst, const uint8_t *src,
28 ptrdiff_t stride, int h, int x, int y);
29void ff_avg_h264_chroma_mc2_mmxext (uint8_t *dst, const uint8_t *src,
30 ptrdiff_t stride, int h, int x, int y);
31
32void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src,
33 ptrdiff_t stride, int h, int x, int y);
34void ff_put_h264_chroma_mc4_ssse3 (uint8_t *dst, const uint8_t *src,
35 ptrdiff_t stride, int h, int x, int y);
36
37void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src,
38 ptrdiff_t stride, int h, int x, int y);
39void 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) \
43void 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
47CHROMA_MC(put, 2, 10, mmxext)
48CHROMA_MC(avg, 2, 10, mmxext)
49CHROMA_MC(put, 4, 10, mmxext)
50CHROMA_MC(avg, 4, 10, mmxext)
51CHROMA_MC(put, 8, 10, sse2)
52CHROMA_MC(avg, 8, 10, sse2)
53CHROMA_MC(put, 8, 10, avx)
54CHROMA_MC(avg, 8, 10, avx)
55
57{
58 int high_bit_depth = bit_depth > 8;
60
61 if (EXTERNAL_MMXEXT(cpu_flags) && !high_bit_depth) {
62 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext;
63 c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext;
64 }
65
66 if (EXTERNAL_MMXEXT(cpu_flags) && bit_depth > 8 && bit_depth <= 10) {
67 c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_10_mmxext;
68 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_10_mmxext;
69 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_10_mmxext;
70 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_10_mmxext;
71 }
72
73 if (EXTERNAL_SSE2(cpu_flags) && bit_depth > 8 && bit_depth <= 10) {
74 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_sse2;
75 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_sse2;
76 }
77
78 if (EXTERNAL_SSSE3(cpu_flags) && !high_bit_depth) {
79 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_rnd_ssse3;
80 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_ssse3;
81 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_ssse3;
82 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_ssse3;
83 }
84
85 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 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx;
89 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx;
90 }
91}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
#define avg(a, b, c, d)
void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth)
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define EXTERNAL_AVX(flags)
Definition cpu.h:64
#define EXTERNAL_MMXEXT(flags)
Definition cpu.h:51
#define EXTERNAL_SSSE3(flags)
Definition cpu.h:59
#define EXTERNAL_SSE2(flags)
Definition cpu.h:53
#define stride
#define src
Definition vp8dsp.c:248
static double c[64]
void ff_put_h264_chroma_mc2_mmxext(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
void ff_avg_h264_chroma_mc2_mmxext(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
#define CHROMA_MC(OP, NUM, DEPTH, OPT)
void ff_avg_h264_chroma_mc4_ssse3(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)
void ff_put_h264_chroma_mc4_ssse3(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y)