From patchwork Wed Jan 23 02:39:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 11834 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3804944C379 for ; Wed, 23 Jan 2019 04:47:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E7E268AC18; Wed, 23 Jan 2019 04:47:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5707968ABEC for ; Wed, 23 Jan 2019 04:46:57 +0200 (EET) Received: by mail-io1-f67.google.com with SMTP id g8so546959iok.4 for ; Tue, 22 Jan 2019 18:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=B01OOGrjw4C/cbGEpm9c3WqqaXSzlsPXCNfOGzM0yRo=; b=UXe09VKIkMdkobSfUvE7jEOkypklfq8e88trSzsjwuxanlkBCEIVxN7Bat2OyJ45hr g5Oq7X/YbYHE9Nwm6N/Hxw3gsSAlIY4CVd65XYaYEec6yJHCcv1WLOeVAhPrCqM8bCV6 O0dISfbI/KeBHoxKequ43PrtgW8dr6Wjkf6F4FbzyFkZIL5RIEFXGj7c61fpwWui5/x4 zgzuK1qp8gYC9/UGazUEExYh/Mm1UMCDDvr6p2kW3n8zJ9/PbIwJVCG6Wy3VPkG16MGy R066jE+SyXKwXsd+qEWdKDx3jy7TafiUYzROpIZOQwfYJc9sgnPSfFXFr/EFsrjSQ9m0 FfwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B01OOGrjw4C/cbGEpm9c3WqqaXSzlsPXCNfOGzM0yRo=; b=qbsB3tNUKri9xt9YvkH3ww2ZTKvx4sFYDFYSf2NG5T3L3Kbn5G4C492SZQiFGf0JA6 m2/jRrJ3mpXfgaS0S30mx+xLfP/a7mmPE3xRMXl9/wR68vrLLLh4B4FAYDJSiQY08F8B iJkH3xLSHN9kgphMvV/AJtdj8hAnYnljQVRnmCw8A/oAz/afgs0q8mPELBgfQbim1I1+ tU8MHGISP6+kI04I0tAV7D8nc6fWpLvEYDZ2bQNvQqXouJai2+Y9vOn+YuJk4yvsGqJv Imo2FQmaNcbM3LKE0c5GuFDLLql06w0Gg3qDbCbS2ABjUXBBWCkLth9HT5sUQFU+xriY FkzA== X-Gm-Message-State: AHQUAuYz83GxG3iQc7P4gX0UnlzXkElalAf46GUVMXTH65ygaccuIbGN /jHKVaINd6m4yGvTEtLlQp9X5ilr X-Google-Smtp-Source: AHgI3Ib4mJqHwYQDS7jLQUpM0u2a+PgJWBrScgdX78gfnLiViREZAWr3beHuNkov32QhtOu5AoAAmA== X-Received: by 2002:a6b:b902:: with SMTP id j2mr241396iof.220.1548211168897; Tue, 22 Jan 2019 18:39:28 -0800 (PST) Received: from Rodgers-MBP.localdomain ([71.201.155.37]) by smtp.gmail.com with ESMTPSA id h16sm9089748ith.25.2019.01.22.18.39.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jan 2019 18:39:27 -0800 (PST) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Jan 2019 20:39:14 -0600 Message-Id: <20190123023914.20619-3-rodger.combs@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190123023914.20619-1-rodger.combs@gmail.com> References: <20190123023914.20619-1-rodger.combs@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] tests/checkasm: add vf_yadif tests X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavfilter/vf_yadif.c | 23 ++++--- libavfilter/yadif.h | 2 + tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 + tests/checkasm/checkasm.h | 1 + tests/checkasm/vf_yadif.c | 137 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 158 insertions(+), 9 deletions(-) create mode 100644 tests/checkasm/vf_yadif.c diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 3107924932..575b5a421e 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -311,6 +311,19 @@ static int query_formats(AVFilterContext *ctx) return ff_set_common_formats(ctx, fmts_list); } +void ff_yadif_init(YADIFContext *s) { + if (s->csp->comp[0].depth > 8) { + s->filter_line = filter_line_c_16bit; + s->filter_edges = filter_edges_16bit; + } else { + s->filter_line = filter_line_c; + s->filter_edges = filter_edges; + } + + if (ARCH_X86) + ff_yadif_init_x86(s); +} + static int config_props(AVFilterLink *link) { AVFilterContext *ctx = link->src; @@ -332,16 +345,8 @@ static int config_props(AVFilterLink *link) s->csp = av_pix_fmt_desc_get(link->format); s->filter = filter; - if (s->csp->comp[0].depth > 8) { - s->filter_line = filter_line_c_16bit; - s->filter_edges = filter_edges_16bit; - } else { - s->filter_line = filter_line_c; - s->filter_edges = filter_edges; - } - if (ARCH_X86) - ff_yadif_init_x86(s); + ff_yadif_init(s); return 0; } diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h index c928911b35..aa0ae744f2 100644 --- a/libavfilter/yadif.h +++ b/libavfilter/yadif.h @@ -86,6 +86,8 @@ typedef struct YADIFContext { int current_field; ///< YADIFCurrentField } YADIFContext; +void ff_yadif_init(YADIFContext *s); + void ff_yadif_init_x86(YADIFContext *yadif); int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame); diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 47b7b06d28..eb1ac06151 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -37,6 +37,7 @@ AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o AVFILTEROBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER) += vf_nlmeans.o +AVFILTEROBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index c3f5160132..23cdcb27ae 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -168,6 +168,9 @@ static const struct { #if CONFIG_THRESHOLD_FILTER { "vf_threshold", checkasm_check_vf_threshold }, #endif + #if CONFIG_YADIF_FILTER + { "vf_yadif", checkasm_check_vf_yadif }, + #endif #endif #if CONFIG_SWSCALE { "sw_rgb", checkasm_check_sw_rgb }, diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 9e8e879fd3..a5c593e7b9 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -72,6 +72,7 @@ void checkasm_check_utvideodsp(void); void checkasm_check_v210enc(void); void checkasm_check_vf_hflip(void); void checkasm_check_vf_threshold(void); +void checkasm_check_vf_yadif(void); void checkasm_check_vp8dsp(void); void checkasm_check_vp9dsp(void); void checkasm_check_videodsp(void); diff --git a/tests/checkasm/vf_yadif.c b/tests/checkasm/vf_yadif.c new file mode 100644 index 0000000000..d011a2771d --- /dev/null +++ b/tests/checkasm/vf_yadif.c @@ -0,0 +1,137 @@ +/* + * 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 +#include "checkasm.h" +#include "libavfilter/yadif.h" +#include "libavutil/intreadwrite.h" + +#define WIDTH 64 +#define HEIGHT 4 +#define SIZE WIDTH * HEIGHT + 32 + +#define randomize_buffers(buf, size) \ + do { \ + int j; \ + uint8_t *tmp_buf = (uint8_t*)buf; \ + for (j = 0; j < size; j++) \ + tmp_buf[j] = rnd() & 0xFF; \ + } while (0) + +#define randomize_buffers_10(buf, size) \ + do { \ + int j; \ + uint16_t *tmp_buf = (uint16_t*)buf;\ + for (j = 0; j < size / 2; j++) \ + tmp_buf[j] = rnd() & 0x03FF; \ + } while (0) + +static void check_yadif(enum AVPixelFormat fmt, int imode, const char * report_name){ + LOCAL_ALIGNED_32(uint8_t, cur_buf, [SIZE]); + LOCAL_ALIGNED_32(uint8_t, prev_buf, [SIZE]); + LOCAL_ALIGNED_32(uint8_t, next_buf, [SIZE]); + LOCAL_ALIGNED_32(uint8_t, dst_ref_buf, [SIZE]); + LOCAL_ALIGNED_32(uint8_t, dst_new_buf, [SIZE]); + int w = WIDTH, refs = WIDTH, h = HEIGHT; + int df, pix_3, edge; + int y; + YADIFContext s; + + declare_func(void, void *dst1, void *prev1, void *cur1, void *next1, + int w, int prefs, int mrefs, int parity, int mode); + + memset(cur_buf, 0, SIZE); + memset(prev_buf, 0, SIZE); + memset(next_buf, 0, SIZE); + memset(dst_ref_buf, 0, SIZE); + memset(dst_new_buf, 0, SIZE); + + s.csp = av_pix_fmt_desc_get(fmt); + df = (s.csp->comp[0].depth + 7) / 8; + w /= df; + pix_3 = 3 * df; + edge = 3 + 8 / df - 1; + + if (s.csp->comp[0].depth == 10) { + randomize_buffers_10(cur_buf, WIDTH * HEIGHT); + randomize_buffers_10(prev_buf, WIDTH * HEIGHT); + randomize_buffers_10(next_buf, WIDTH * HEIGHT); + } else { + randomize_buffers(cur_buf, WIDTH * HEIGHT); + randomize_buffers(prev_buf, WIDTH * HEIGHT); + randomize_buffers(next_buf, WIDTH * HEIGHT); + } + + ff_yadif_init(&s); + + if (check_func(s.filter_line, "yadif_%s", report_name)) { + for (int parity = 0; parity <= 1; parity++) { + for (y = 0; y < HEIGHT; y++) { + uint8_t *prev = &prev_buf[y * refs]; + uint8_t *cur = &cur_buf[y * refs]; + uint8_t *next = &next_buf[y * refs]; + uint8_t *dst_ref = &dst_ref_buf[y * refs]; + uint8_t *dst_new = &dst_new_buf[y * refs]; + int mode = y == 1 || y + 2 == HEIGHT ? 2 : imode; + call_ref(dst_ref + pix_3, prev + pix_3, cur + pix_3, + next + pix_3, w - edge, + y + 1 < h ? refs : -refs, + y ? -refs : refs, + parity, mode); + call_new(dst_new + pix_3, prev + pix_3, cur + pix_3, + next + pix_3, w - edge, + y + 1 < h ? refs : -refs, + y ? -refs : refs, + parity, mode); + s.filter_edges(dst_ref, prev, cur, next, w, + y + 1 < h ? refs : -refs, + y ? -refs : refs, + parity, mode); + s.filter_edges(dst_new, prev, cur, next, w, + y + 1 < h ? refs : -refs, + y ? -refs : refs, + parity, mode); + } + if (memcmp(dst_new_buf, dst_ref_buf, WIDTH * HEIGHT)) + fail(); + } + bench_new(dst_new_buf + pix_3, prev_buf + pix_3, + cur_buf + pix_3, next_buf + pix_3, + w - edge, WIDTH, WIDTH, 0, imode); + } +} +void checkasm_check_vf_yadif(void) +{ + check_yadif(AV_PIX_FMT_YUV420P, 0, "8"); + report("yadif_8"); + + check_yadif(AV_PIX_FMT_YUV420P, 2, "8_nospatial"); + report("yadif_8_nospatial"); + + check_yadif(AV_PIX_FMT_YUV420P10, 0, "10"); + report("yadif_10"); + + check_yadif(AV_PIX_FMT_YUV420P10, 2, "10_nospatial"); + report("yadif_10_nospatial"); + + check_yadif(AV_PIX_FMT_YUV420P16, 0, "16"); + report("yadif_16"); + + check_yadif(AV_PIX_FMT_YUV420P16, 2, "16_nospatial"); + report("yadif_16_nospatial"); +}