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*2; i++) \
34  src[i] = rnd() & 0x3; \
35  } else { \
36  for (int i = 0; i < 16*18; i += 2) \
37  AV_WN16(&src[i], rnd() & 0xFF); \
38  } \
39  } while (0)
40 
41 static void check_chroma_mc(void)
42 {
44  LOCAL_ALIGNED_32(uint8_t, src, [16 * 18 * 2]);
45  LOCAL_ALIGNED_32(uint8_t, dst0, [16 * 18 * 2]);
46  LOCAL_ALIGNED_32(uint8_t, dst1, [16 * 18 * 2]);
47 
48  declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
49  ptrdiff_t stride, int h, int x, int y);
50 
51  for (int bit_depth = 8; bit_depth <= 10; bit_depth++) {
54  for (int size = 0; size < 4; size++) {
55 
56 #define CHECK_CHROMA_MC(name) \
57  do { \
58  if (check_func(h.name## _pixels_tab[size], #name "_mc%d_%d", 1 << size, bit_depth)) { \
59  for (int x = 0; x < 2; x++) { \
60  for (int y = 0; y < 2; y++) { \
61  memcpy(dst0, src, 16 * 18 * SIZEOF_PIXEL); \
62  memcpy(dst1, src, 16 * 18 * SIZEOF_PIXEL); \
63  call_ref(dst0, src, 16 * SIZEOF_PIXEL, 16, x, y); \
64  call_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
65  if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL)) { \
66  fprintf(stderr, #name ": x:%i, y:%i\n", x, y); \
67  fail(); \
68  } \
69  bench_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
70  } \
71  } \
72  } \
73  } while (0)
74 
75  CHECK_CHROMA_MC(put_h264_chroma);
76  CHECK_CHROMA_MC(avg_h264_chroma);
77  }
78  }
79 }
80 
82 {
84  report("chroma_mc");
85 }
declare_func_emms
#define declare_func_emms(cpu_flags, ret,...)
Definition: checkasm.h:176
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:41
CHECK_CHROMA_MC
#define CHECK_CHROMA_MC(name)
intreadwrite.h
checkasm_check_h264chroma
void checkasm_check_h264chroma(void)
Definition: h264chroma.c:81
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:156
size
int size
Definition: twinvq_data.h:10344
h264chroma.h
report
#define report
Definition: checkasm.h:182
randomize_buffers
#define randomize_buffers(bit_depth)
Definition: h264chroma.c:30
stride
#define stride
Definition: h264pred_template.c:537
AV_CPU_FLAG_MMX
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:29
ff_h264chroma_init
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
Definition: h264chroma.c:41
H264ChromaContext
Definition: h264chroma.h:27
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
h
h
Definition: vp9dsp_template.c:2038