FFmpeg
h264chroma.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) Lynne
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include <string.h>
22 #include <stdint.h>
23 #include "checkasm.h"
24 #include "libavcodec/h264chroma.h"
25 #include "libavutil/mem_internal.h"
26 #include "libavutil/intreadwrite.h"
27 
28 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
29 
30 #define randomize_buffers(bit_depth) \
31  do { \
32  if (bit_depth == 8) { \
33  for (int i = 0; i < 16*18; i++) \
34  src[i] = rnd(); \
35  } else { \
36  unsigned mask = (1 << bit_depth) - 1;\
37  for (int i = 0; i < 16*18*2; i += 2) \
38  AV_WN16A(&src[i], rnd() & mask); \
39  } \
40  } while (0)
41 
42 static void check_chroma_mc(void)
43 {
45  DECLARE_ALIGNED_4(uint8_t, src) [16 * 18 * 2];
46  DECLARE_ALIGNED_16(uint8_t, dst0)[16 * 18 * 2];
47  DECLARE_ALIGNED_16(uint8_t, dst1)[16 * 18 * 2];
48 
49  declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
50  ptrdiff_t stride, int h, int x, int y);
51 
52  for (int bit_depth = 8; bit_depth <= 10; bit_depth++) {
55  for (int size = 0; size < 3; size++) {
56 
57 #define CHECK_CHROMA_MC(name) \
58  do { \
59  if (check_func(h.name## _pixels_tab[size], #name "_mc%d_%d", 1 << (3-size), bit_depth)) { \
60  for (int x = 0; x < 2; x++) { \
61  for (int y = 0; y < 2; y++) { \
62  memcpy(dst0, src, 16 * 18 * SIZEOF_PIXEL); \
63  memcpy(dst1, src, 16 * 18 * SIZEOF_PIXEL); \
64  call_ref(dst0, src, 16 * SIZEOF_PIXEL, 16, x, y); \
65  call_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
66  if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL)) { \
67  fprintf(stderr, #name "_%d: x:%i, y:%i\n", bit_depth, x, y); \
68  fail(); \
69  } \
70  bench_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
71  } \
72  } \
73  } \
74  } while (0)
75 
76  CHECK_CHROMA_MC(put_h264_chroma);
77  CHECK_CHROMA_MC(avg_h264_chroma);
78  }
79  }
80 }
81 
83 {
85  report("chroma_mc");
86 }
declare_func_emms
#define declare_func_emms(cpu_flags, ret,...)
Definition: checkasm.h:217
mem_internal.h
bit_depth
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition: af_astats.c:246
checkasm.h
check_chroma_mc
static void check_chroma_mc(void)
Definition: h264chroma.c:42
CHECK_CHROMA_MC
#define CHECK_CHROMA_MC(name)
intreadwrite.h
checkasm_check_h264chroma
void checkasm_check_h264chroma(void)
Definition: h264chroma.c:82
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
size
int size
Definition: twinvq_data.h:10344
h264chroma.h
report
#define report
Definition: checkasm.h:223
randomize_buffers
#define randomize_buffers(bit_depth)
Definition: h264chroma.c:30
AV_CPU_FLAG_MMX
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:32
DECLARE_ALIGNED_4
#define DECLARE_ALIGNED_4(t, v)
Definition: mem_internal.h:110
ff_h264chroma_init
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
Definition: h264chroma.c:39
H264ChromaContext
Definition: h264chroma.h:27
DECLARE_ALIGNED_16
#define DECLARE_ALIGNED_16(t, v)
Definition: mem_internal.h:112
h
h
Definition: vp9dsp_template.c:2070
stride
#define stride
Definition: h264pred_template.c:536
src
#define src
Definition: vp8dsp.c:248