31 static const uint32_t
pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff };
32 static const uint32_t
pixel_mask_lf[3] = { 0xff0fff0f, 0x01ff000f, 0x03ff000f };
34 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
35 #define SIZEOF_COEF (2 * ((bit_depth + 7) / 8))
36 #define PIXEL_STRIDE 16
38 #define randomize_buffers() \
41 uint32_t mask = pixel_mask[bit_depth - 8]; \
42 for (y = 0; y < sz; y++) { \
43 for (x = 0; x < PIXEL_STRIDE; x += 4) { \
44 AV_WN32A(src + y * PIXEL_STRIDE + x, rnd() & mask); \
45 AV_WN32A(dst + y * PIXEL_STRIDE + x, rnd() & mask); \
47 for (x = 0; x < sz; x++) { \
48 if (bit_depth == 8) { \
49 coef[y * sz + x] = src[y * PIXEL_STRIDE + x] - \
50 dst[y * PIXEL_STRIDE + x]; \
52 ((int32_t *)coef)[y * sz + x] = \
53 ((uint16_t *)src)[y * (PIXEL_STRIDE/2) + x] - \
54 ((uint16_t *)dst)[y * (PIXEL_STRIDE/2) + x]; \
60 #define dct4x4_impl(size, dctcoef) \
61 static void dct4x4_##size(dctcoef *coef) \
65 for (i = 0; i < 4; i++) { \
66 const int z0 = coef[i*4 + 0] + coef[i*4 + 3]; \
67 const int z1 = coef[i*4 + 1] + coef[i*4 + 2]; \
68 const int z2 = coef[i*4 + 0] - coef[i*4 + 3]; \
69 const int z3 = coef[i*4 + 1] - coef[i*4 + 2]; \
70 tmp[i + 4*0] = z0 + z1; \
71 tmp[i + 4*1] = 2*z2 + z3; \
72 tmp[i + 4*2] = z0 - z1; \
73 tmp[i + 4*3] = z2 - 2*z3; \
75 for (i = 0; i < 4; i++) { \
76 const int z0 = tmp[i*4 + 0] + tmp[i*4 + 3]; \
77 const int z1 = tmp[i*4 + 1] + tmp[i*4 + 2]; \
78 const int z2 = tmp[i*4 + 0] - tmp[i*4 + 3]; \
79 const int z3 = tmp[i*4 + 1] - tmp[i*4 + 2]; \
80 coef[i*4 + 0] = z0 + z1; \
81 coef[i*4 + 1] = 2*z2 + z3; \
82 coef[i*4 + 2] = z0 - z1; \
83 coef[i*4 + 3] = z2 - 2*z3; \
85 for (y = 0; y < 4; y++) { \
86 for (x = 0; x < 4; x++) { \
87 static const int scale[] = { 13107 * 10, 8066 * 13, 5243 * 16 }; \
88 const int idx = (y & 1) + (x & 1); \
89 coef[y*4 + x] = (coef[y*4 + x] * scale[idx] + (1 << 14)) >> 15; \
94 #define DCT8_1D(src, srcstride, dst, dststride) do { \
95 const int a0 = (src)[srcstride * 0] + (src)[srcstride * 7]; \
96 const int a1 = (src)[srcstride * 0] - (src)[srcstride * 7]; \
97 const int a2 = (src)[srcstride * 1] + (src)[srcstride * 6]; \
98 const int a3 = (src)[srcstride * 1] - (src)[srcstride * 6]; \
99 const int a4 = (src)[srcstride * 2] + (src)[srcstride * 5]; \
100 const int a5 = (src)[srcstride * 2] - (src)[srcstride * 5]; \
101 const int a6 = (src)[srcstride * 3] + (src)[srcstride * 4]; \
102 const int a7 = (src)[srcstride * 3] - (src)[srcstride * 4]; \
103 const int b0 = a0 + a6; \
104 const int b1 = a2 + a4; \
105 const int b2 = a0 - a6; \
106 const int b3 = a2 - a4; \
107 const int b4 = a3 + a5 + (a1 + (a1 >> 1)); \
108 const int b5 = a1 - a7 - (a5 + (a5 >> 1)); \
109 const int b6 = a1 + a7 - (a3 + (a3 >> 1)); \
110 const int b7 = a3 - a5 + (a7 + (a7 >> 1)); \
111 (dst)[dststride * 0] = b0 + b1; \
112 (dst)[dststride * 1] = b4 + (b7 >> 2); \
113 (dst)[dststride * 2] = b2 + (b3 >> 1); \
114 (dst)[dststride * 3] = b5 + (b6 >> 2); \
115 (dst)[dststride * 4] = b0 - b1; \
116 (dst)[dststride * 5] = b6 - (b5 >> 2); \
117 (dst)[dststride * 6] = (b2 >> 1) - b3; \
118 (dst)[dststride * 7] = (b4 >> 2) - b7; \
121 #define dct8x8_impl(size, dctcoef) \
122 static void dct8x8_##size(dctcoef *coef) \
126 for (i = 0; i < 8; i++) \
127 DCT8_1D(coef + i, 8, tmp + i, 8); \
129 for (i = 0; i < 8; i++) \
130 DCT8_1D(tmp + 8*i, 1, coef + i, 8); \
132 for (y = 0; y < 8; y++) { \
133 for (x = 0; x < 8; x++) { \
134 static const int scale[] = { \
135 13107 * 20, 11428 * 18, 20972 * 32, \
136 12222 * 19, 16777 * 25, 15481 * 24, \
138 static const int idxmap[] = { \
144 const int idx = idxmap[(y & 3) * 4 + (x & 3)]; \
145 coef[y*8 + x] = ((int64_t)coef[y*8 + x] * \
146 scale[idx] + (1 << 17)) >> 18; \
190 for (sz = 4; sz <= 8; sz += 4) {
198 for (
dc = 0;
dc <= 1;
dc++) {
200 switch ((sz << 1) |
dc) {
201 case (4 << 1) | 0:
idct =
h.h264_idct_add;
break;
202 case (4 << 1) | 1:
idct =
h.h264_idct_dc_add;
break;
203 case (8 << 1) | 0:
idct =
h.h264_idct8_add;
break;
204 case (8 << 1) | 1:
idct =
h.h264_idct8_dc_add;
break;
207 for (align = 0; align < 16; align += sz *
SIZEOF_PIXEL) {
208 uint8_t *dst1 = dst1_base + align;
249 int sz = 4, intra = 0;
250 int block_offset[16] = { 0 };
253 idct =
h.h264_idct_add16;
254 name =
"h264_idct_add16";
257 idct =
h.h264_idct_add16intra;
258 name =
"h264_idct_add16intra";
262 idct =
h.h264_idct8_add4;
263 name =
"h264_idct8_add4";
267 memset(nnzc, 0, 15 * 8);
269 for (
i = 0;
i < 16 * 16;
i += sz * sz) {
272 int16_t coef[8 * 8 * 2];
274 int block_y = (
index / 16) * sz;
275 int block_x =
index % 16;
285 for (y = 0; y < sz; y++)
294 if (intra && nnz == 1)
297 nnzc[
scan8[
i / 16]] = nnz;
325 int alphas[36], betas[36];
329 int alpha,
int beta, int8_t *tc0);
335 for (
i = 35,
a = 255,
c = 250;
i >= 0;
i--) {
338 tc0[
i][0] = tc0[
i][3] = (
c + 6) / 10;
339 tc0[
i][1] = (
c + 7) / 15;
340 tc0[
i][2] = (
c + 9) / 20;
345 #define CHECK_LOOP_FILTER(name, align, idc) \
347 if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \
348 for (j = 0; j < 36; j++) { \
349 intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \
350 for (i = 0; i < 1024; i+=4) { \
351 AV_WN32A(dst + i, rnd() & mask); \
353 memcpy(dst0, dst, 32 * 16 * 2); \
354 memcpy(dst1, dst, 32 * 16 * 2); \
356 call_ref(dst0 + off, 32, alphas[j], betas[j], tc0[j]); \
357 call_new(dst1 + off, 32, alphas[j], betas[j], tc0[j]); \
358 if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \
359 fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d " \
360 "tc0:{%d,%d,%d,%d}\n", j, alphas[j], betas[j], \
361 tc0[j][0], tc0[j][1], tc0[j][2], tc0[j][3]); \
364 bench_new(dst1, 32, alphas[j], betas[j], tc0[j]); \
379 #undef CHECK_LOOP_FILTER
390 int alphas[36], betas[36];
393 int alpha,
int beta);
399 for (
i = 35,
a = 255;
i >= 0;
i--) {
405 #define CHECK_LOOP_FILTER(name, align, idc) \
407 if (check_func(h.name, #name #idc "_%dbpp", bit_depth)) { \
408 for (j = 0; j < 36; j++) { \
409 intptr_t off = 8 * 32 + (j & 15) * 4 * !align; \
410 for (i = 0; i < 1024; i+=4) { \
411 AV_WN32A(dst + i, rnd() & mask); \
413 memcpy(dst0, dst, 32 * 16 * 2); \
414 memcpy(dst1, dst, 32 * 16 * 2); \
416 call_ref(dst0 + off, 32, alphas[j], betas[j]); \
417 call_new(dst1 + off, 32, alphas[j], betas[j]); \
418 if (memcmp(dst0, dst1, 32 * 16 * SIZEOF_PIXEL)) { \
419 fprintf(stderr, #name #idc ": j:%d, alpha:%d beta:%d\n", \
420 j, alphas[j], betas[j]); \
423 bench_new(dst1, 32, alphas[j], betas[j]); \
438 #undef CHECK_LOOP_FILTER
452 report(
"loop_filter_intra");
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
Libavcodec external API header.
#define declare_func_emms(cpu_flags, ret,...)
#define check_func(func,...)
common internal and external API header
#define AV_CPU_FLAG_MMX
standard MMX
static const uint8_t scan8[16 *3+3]
static void FUNCC() h264_h_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_v_loop_filter_luma_intra(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_luma_mbaff(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_v_loop_filter_chroma(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_h_loop_filter_chroma_intra(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
static void FUNCC() h264_v_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_h_loop_filter_luma_intra(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_luma_mbaff_intra(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_luma(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_v_loop_filter_chroma_intra(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
static void FUNCC() h264_h_loop_filter_chroma_mbaff(uint8_t *pix, ptrdiff_t stride, int alpha, int beta, int8_t *tc0)
static void FUNCC() h264_h_loop_filter_chroma_mbaff_intra(uint8_t *pix, ptrdiff_t stride, int alpha, int beta)
static const int16_t alpha[]
static void idct(int16_t block[64])
av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
common internal API header
static const uint16_t mask[17]
#define LOCAL_ALIGNED_16(t, v,...)
typedef void(RENAME(mix_any_func_type))
Context for storing H.264 DSP functions.
void checkasm_check_h264dsp(void)
#define randomize_buffers()
static void check_loop_filter(void)
static void check_idct_multiple(void)
static void check_loop_filter_intra(void)
static const uint32_t pixel_mask_lf[3]
static void check_idct(void)
#define CHECK_LOOP_FILTER(name, align, idc)
static void dct8x8(int16_t *coef, int bit_depth)
static const uint32_t pixel_mask[3]
#define dct4x4_impl(size, dctcoef)
#define dct8x8_impl(size, dctcoef)
static void dct4x4(int16_t *coef)
static const uint8_t offset[127][2]