1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

checkasm: add h264chroma tests

Checks all variants of put_h264_chroma and avg_h264_chroma.
This commit is contained in:
Lynne 2023-05-18 16:18:16 +02:00
parent a62a3930c2
commit 783270bfd1
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
4 changed files with 90 additions and 0 deletions

View File

@ -5,6 +5,7 @@ AVCODECOBJS-$(CONFIG_BLOCKDSP) += blockdsp.o
AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o
AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o
AVCODECOBJS-$(CONFIG_G722DSP) += g722dsp.o AVCODECOBJS-$(CONFIG_G722DSP) += g722dsp.o
AVCODECOBJS-$(CONFIG_H264CHROMA) += h264chroma.o
AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o
AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o
AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o

View File

@ -105,6 +105,9 @@ static const struct {
#if CONFIG_G722DSP #if CONFIG_G722DSP
{ "g722dsp", checkasm_check_g722dsp }, { "g722dsp", checkasm_check_g722dsp },
#endif #endif
#if CONFIG_H264CHROMA
{ "h264chroma", checkasm_check_h264chroma },
#endif
#if CONFIG_H264DSP #if CONFIG_H264DSP
{ "h264dsp", checkasm_check_h264dsp }, { "h264dsp", checkasm_check_h264dsp },
#endif #endif

View File

@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void);
void checkasm_check_float_dsp(void); void checkasm_check_float_dsp(void);
void checkasm_check_fmtconvert(void); void checkasm_check_fmtconvert(void);
void checkasm_check_g722dsp(void); void checkasm_check_g722dsp(void);
void checkasm_check_h264chroma(void);
void checkasm_check_h264dsp(void); void checkasm_check_h264dsp(void);
void checkasm_check_h264pred(void); void checkasm_check_h264pred(void);
void checkasm_check_h264qpel(void); void checkasm_check_h264qpel(void);

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) Lynne
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <string.h>
#include <stdint.h>
#include "checkasm.h"
#include "libavcodec/h264chroma.h"
#include "libavutil/mem_internal.h"
#include "libavutil/intreadwrite.h"
#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
#define randomize_buffers(bit_depth) \
do { \
if (bit_depth == 8) { \
for (int i = 0; i < 16*18*2; i++) \
src[i] = rnd() & 0x3; \
} else { \
for (int i = 0; i < 16*18; i += 2) \
AV_WN16(&src[i], rnd() & 0xFF); \
} \
} while (0)
static void check_chroma_mc(void)
{
H264ChromaContext h;
LOCAL_ALIGNED_32(uint8_t, src, [16 * 18 * 2]);
LOCAL_ALIGNED_32(uint8_t, dst0, [16 * 18 * 2]);
LOCAL_ALIGNED_32(uint8_t, dst1, [16 * 18 * 2]);
declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
ptrdiff_t stride, int h, int x, int y);
for (int bit_depth = 8; bit_depth <= 10; bit_depth++) {
ff_h264chroma_init(&h, bit_depth);
randomize_buffers(bit_depth);
for (int size = 0; size < 4; size++) {
#define CHECK_CHROMA_MC(name) \
do { \
if (check_func(h.name## _pixels_tab[size], #name "_mc%d_%d", 1 << size, bit_depth)) { \
for (int x = 0; x < 2; x++) { \
for (int y = 0; y < 2; y++) { \
memcpy(dst0, src, 16 * 18 * SIZEOF_PIXEL); \
memcpy(dst1, src, 16 * 18 * SIZEOF_PIXEL); \
call_ref(dst0, src, 16 * SIZEOF_PIXEL, 16, x, y); \
call_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
if (memcmp(dst0, dst1, 16 * 16 * SIZEOF_PIXEL)) { \
fprintf(stderr, #name ": x:%i, y:%i\n", x, y); \
fail(); \
} \
bench_new(dst1, src, 16 * SIZEOF_PIXEL, 16, x, y); \
} \
} \
} \
} while (0)
CHECK_CHROMA_MC(put_h264_chroma);
CHECK_CHROMA_MC(avg_h264_chroma);
}
}
}
void checkasm_check_h264chroma(void)
{
check_chroma_mc();
report("chroma_mc");
}