From patchwork Mon Jun 26 22:15:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 4130 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp1342404vsb; Mon, 26 Jun 2017 15:15:38 -0700 (PDT) X-Received: by 10.28.113.142 with SMTP id d14mr1195833wmi.10.1498515338748; Mon, 26 Jun 2017 15:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498515338; cv=none; d=google.com; s=arc-20160816; b=g7xbIb7BH0la1+hNdNod7XCBUDqCPJsilcsOztmImqJxKPmO7y01uPVgIGPe5w4asW Z+aetNIEPLnIi0v5e7tMj5zPaJd8FcCNIfNF13c1vqrfqM8xwQI9p8EscpK2PCZe6CQx Dhie1xY1DPC4pXRVmDUDWhVsCl1DyclFJ6ndlqxFvi3gZyyJvGtSKbkyC/FliYlNlMin ceL4+KR9PfNMrJLZYlzeVhJzYAgdq44vK87i56npoBDPlSq7RLP5hSgNkRxtvGj5MhPa k13G0x3pU5JLEUuucNyMXibysI2vaKSESA/P6grVf1SWSomqqlYRacnjSmp8x37mPmlK DdYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=zsDjaBeYFn5BClWAuBw7mb5H/8mKtuP0TfPa3YVySFA=; b=jtQIf22JlpcR8TSWsu7evdo1jL+zcvluoyPA2dflTLb/5Yr0008i+igjNRQhCTXPg+ 2eV02vAaK3RpOeBO2jsHbIV1QlRcT2YwhTFV9XXQtGM4XdMWHrpJwb9BSBXDEGhZwvaQ RzxP8I7ql4o2pcZ6vlBHonCH/g4lvPU2ez7kA1/C/lj+ZEg6Y0zn4/i2RHVlMbARcNcI wyeixcA3pjo6m6vbEBktd6wC9sCDDlVlToKen+KNef082V993K7AjFT5+BL69f2BTnlL 2mxvYDKrHFSD0T318UR13ZRgQlaGmNAoaeGd2mruUEuQ3t6Uav8Ysb61gCmQYdB/ksig qrsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=ZKCm6faG; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e138si867073wma.64.2017.06.26.15.15.38; Mon, 26 Jun 2017 15:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=ZKCm6faG; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7DCE868A3C1; Tue, 27 Jun 2017 01:15:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C37DA689F16 for ; Tue, 27 Jun 2017 01:15:27 +0300 (EEST) Received: by mail-wm0-f53.google.com with SMTP id w126so9328155wme.0 for ; Mon, 26 Jun 2017 15:15:29 -0700 (PDT) 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; bh=up87Fh7S5IdomfZElzBasg6PpXSmo2iuLEjUd6sXu0c=; b=ZKCm6faGWqFkfCxAZeBYld10ZejdGkll1aiAAG30cgGT9cG+mfcroWUrBeuVw0P3dH oZSKQG2nEUChUWK7alABGpE7XxeVxzqzSYM7llRvxhlCW1B6C8CV9vY1iB1M4sPg29yz ScnXCRDbVsYOtzKmOmiYRzk0PszGQN2nof2IYq9J5MTIEN/2itjvGOMuHG+dIY8l6uhf a+p1wXPkfVSMMXLFqzYRxYNCE7+oGqMvNzyYNuNsE48fwgP7tyHw3tF7MEQ4w47bZJkK aQs1A5WBMvWwnU1T/8MCoxlnhGtqjFzwaF0SH6Z7G3sppG9JqiUBLnYoD4BO5TY8WQU3 ZPmQ== 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; bh=up87Fh7S5IdomfZElzBasg6PpXSmo2iuLEjUd6sXu0c=; b=WJDS0v3EAHJ/EnPQulDN9/nJ1j+Dge76j1jjUBKd4rHc2+CNsGjed5f5YwNutxgoaz zTmgvH7PhHrGb5S3XnG/b580Lge1pAD6yVpK9KIFvM+Ln+lCkSpPd2LR29YrAot/7MMP TOr3qVgmx4P/KxXwX7RYD8XTY8P+Ug/MkNxQiewXHYYco2yjAq/Axlgdvdm0pfguCTjw vNaiH1uxo/rUggjHMJW3ux3WeH4dd9pqmue8OcRuy8DCj7Z6tSQfnknZgTWxxuGmXd+2 HGYB5inN2cGAlcToyst0XUf3qBwIOZVfpQewRr1JtES4MnZ2cFHRwOmhXM/qKZiyVwMZ FYFQ== X-Gm-Message-State: AKS2vOyktubKZVdkftdIsCur0FrbBFXkCtAU0LQnQpVGK0usbYy5P+Ei zdMLYEp4mrwpk43L X-Received: by 10.28.191.29 with SMTP id p29mr988683wmf.60.1498515328458; Mon, 26 Jun 2017 15:15:28 -0700 (PDT) Received: from localhost.localdomain ([94.250.174.60]) by smtp.gmail.com with ESMTPSA id m187sm804961wmb.10.2017.06.26.15.15.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Jun 2017 15:15:27 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Jun 2017 00:15:17 +0200 Message-Id: <20170626221517.28245-1-onemda@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170626213826.20030-1-onemda@gmail.com> References: <20170626213826.20030-1-onemda@gmail.com> Subject: [FFmpeg-devel] [PATCH] avcodec/utvideodec: add SIMD for restore_rgb_planes 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 2 +- libavcodec/utvideo.h | 2 + libavcodec/utvideodec.c | 53 +++----------------- libavcodec/utvideodsp.c | 82 +++++++++++++++++++++++++++++++ libavcodec/utvideodsp.h | 39 +++++++++++++++ libavcodec/x86/Makefile | 2 + libavcodec/x86/utvideodsp.asm | 101 +++++++++++++++++++++++++++++++++++++++ libavcodec/x86/utvideodsp_init.c | 43 +++++++++++++++++ 8 files changed, 277 insertions(+), 47 deletions(-) create mode 100644 libavcodec/utvideodsp.c create mode 100644 libavcodec/utvideodsp.h create mode 100644 libavcodec/x86/utvideodsp.asm create mode 100644 libavcodec/x86/utvideodsp_init.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f0cba88..b440a00 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -583,7 +583,7 @@ OBJS-$(CONFIG_TTA_ENCODER) += ttaenc.o ttaencdsp.o ttadata.o OBJS-$(CONFIG_TWINVQ_DECODER) += twinvqdec.o twinvq.o OBJS-$(CONFIG_TXD_DECODER) += txd.o OBJS-$(CONFIG_ULTI_DECODER) += ulti.o -OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o utvideo.o +OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodec.o utvideo.o utvideodsp.o OBJS-$(CONFIG_UTVIDEO_ENCODER) += utvideoenc.o utvideo.o OBJS-$(CONFIG_V210_DECODER) += v210dec.o OBJS-$(CONFIG_V210_ENCODER) += v210enc.o diff --git a/libavcodec/utvideo.h b/libavcodec/utvideo.h index 9559c83..a811785 100644 --- a/libavcodec/utvideo.h +++ b/libavcodec/utvideo.h @@ -30,6 +30,7 @@ #include "libavutil/common.h" #include "avcodec.h" #include "bswapdsp.h" +#include "utvideodsp.h" #include "lossless_videodsp.h" #include "lossless_videoencdsp.h" @@ -66,6 +67,7 @@ extern const int ff_ut_pred_order[5]; typedef struct UtvideoContext { const AVClass *class; AVCodecContext *avctx; + UTVideoDSPContext utdsp; BswapDSPContext bdsp; LLVidDSPContext llviddsp; LLVidEncDSPContext llvidencdsp; diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c index 0c6f89e..44841aa 100644 --- a/libavcodec/utvideodec.c +++ b/libavcodec/utvideodec.c @@ -333,50 +333,6 @@ fail: return AVERROR_INVALIDDATA; } -static void restore_rgb_planes(AVFrame *frame, int width, int height) -{ - uint8_t *src_r = (uint8_t *)frame->data[2]; - uint8_t *src_g = (uint8_t *)frame->data[0]; - uint8_t *src_b = (uint8_t *)frame->data[1]; - uint8_t r, g, b; - int i, j; - - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { - r = src_r[i]; - g = src_g[i]; - b = src_b[i]; - src_r[i] = r + g - 0x80; - src_b[i] = b + g - 0x80; - } - src_r += frame->linesize[2]; - src_g += frame->linesize[0]; - src_b += frame->linesize[1]; - } -} - -static void restore_rgb_planes10(AVFrame *frame, int width, int height) -{ - uint16_t *src_r = (uint16_t *)frame->data[2]; - uint16_t *src_g = (uint16_t *)frame->data[0]; - uint16_t *src_b = (uint16_t *)frame->data[1]; - int r, g, b; - int i, j; - - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { - r = src_r[i]; - g = src_g[i]; - b = src_b[i]; - src_r[i] = (r + g - 0x200) & 0x3FF; - src_b[i] = (b + g - 0x200) & 0x3FF; - } - src_r += frame->linesize[2] / 2; - src_g += frame->linesize[0] / 2; - src_b += frame->linesize[1] / 2; - } -} - #undef A #undef B #undef C @@ -696,7 +652,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } } } - restore_rgb_planes(frame.f, avctx->width, avctx->height); + c->utdsp.restore_rgb_planes(frame.f->data[2], frame.f->data[0], frame.f->data[1], + frame.f->linesize[2], frame.f->linesize[0], frame.f->linesize[1], + avctx->width, avctx->height); break; case AV_PIX_FMT_GBRAP10: case AV_PIX_FMT_GBRP10: @@ -709,7 +667,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (ret) return ret; } - restore_rgb_planes10(frame.f, avctx->width, avctx->height); + c->utdsp.restore_rgb_planes10((uint16_t *)frame.f->data[2], (uint16_t *)frame.f->data[0], (uint16_t *)frame.f->data[1], + frame.f->linesize[2] / 2, frame.f->linesize[0] / 2, frame.f->linesize[1] / 2, + avctx->width, avctx->height); break; case AV_PIX_FMT_YUV420P: for (i = 0; i < 3; i++) { @@ -830,6 +790,7 @@ static av_cold int decode_init(AVCodecContext *avctx) c->avctx = avctx; + ff_utvideodsp_init(&c->utdsp); ff_bswapdsp_init(&c->bdsp); ff_llviddsp_init(&c->llviddsp); diff --git a/libavcodec/utvideodsp.c b/libavcodec/utvideodsp.c new file mode 100644 index 0000000..0831a6b --- /dev/null +++ b/libavcodec/utvideodsp.c @@ -0,0 +1,82 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 "config.h" +#include "libavutil/attributes.h" +#include "utvideodsp.h" + +static void restore_rgb_planes_c(uint8_t *src_r, + uint8_t *src_g, + uint8_t *src_b, + ptrdiff_t linesize_r, + ptrdiff_t linesize_g, + ptrdiff_t linesize_b, + int width, int height) +{ + uint8_t r, g, b; + int i, j; + + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + r = src_r[i]; + g = src_g[i]; + b = src_b[i]; + src_r[i] = r + g - 0x80; + src_b[i] = b + g - 0x80; + } + src_r += linesize_r; + src_g += linesize_g; + src_b += linesize_b; + } +} + +static void restore_rgb_planes10_c(uint16_t *src_r, + uint16_t *src_g, + uint16_t *src_b, + ptrdiff_t linesize_r, + ptrdiff_t linesize_g, + ptrdiff_t linesize_b, + int width, int height) +{ + int r, g, b; + int i, j; + + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + r = src_r[i]; + g = src_g[i]; + b = src_b[i]; + src_r[i] = (r + g - 0x200) & 0x3FF; + src_b[i] = (b + g - 0x200) & 0x3FF; + } + src_r += linesize_r; + src_g += linesize_g; + src_b += linesize_b; + } +} + +av_cold void ff_utvideodsp_init(UTVideoDSPContext *c) +{ + c->restore_rgb_planes = restore_rgb_planes_c; + c->restore_rgb_planes10 = restore_rgb_planes10_c; + + if (ARCH_X86) + ff_utvideodsp_init_x86(c); +} diff --git a/libavcodec/utvideodsp.h b/libavcodec/utvideodsp.h new file mode 100644 index 0000000..a3d2550 --- /dev/null +++ b/libavcodec/utvideodsp.h @@ -0,0 +1,39 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 + */ + +#ifndef AVCODEC_UTVIDEODSP_H +#define AVCODEC_UTVIDEODSP_H + +#include +#include +#include "libavutil/pixfmt.h" +#include "config.h" + +typedef struct UTVideoDSPContext { + void (*restore_rgb_planes)(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b, + ptrdiff_t linesize_r, ptrdiff_t linesize_g, + ptrdiff_t linesize_b, int width, int height); + void (*restore_rgb_planes10)(uint16_t *src_r, uint16_t *src_g, uint16_t *src_b, + ptrdiff_t linesize_r, ptrdiff_t linesize_g, + ptrdiff_t linesize_b, int width, int height); +} UTVideoDSPContext; + +void ff_utvideodsp_init(UTVideoDSPContext *c); +void ff_utvideodsp_init_x86(UTVideoDSPContext *c); + +#endif /* AVCODEC_UTVIDEODSP_H */ diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index b86700b..0dbc465 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -65,6 +65,7 @@ OBJS-$(CONFIG_TAK_DECODER) += x86/takdsp_init.o OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp_init.o OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp_init.o OBJS-$(CONFIG_TTA_ENCODER) += x86/ttaencdsp_init.o +OBJS-$(CONFIG_UTVIDEO_DECODER) += x86/utvideodsp_init.o OBJS-$(CONFIG_V210_DECODER) += x86/v210-init.o OBJS-$(CONFIG_V210_ENCODER) += x86/v210enc_init.o OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp_init.o @@ -171,6 +172,7 @@ X86ASM-OBJS-$(CONFIG_TAK_DECODER) += x86/takdsp.o X86ASM-OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o X86ASM-OBJS-$(CONFIG_TTA_DECODER) += x86/ttadsp.o X86ASM-OBJS-$(CONFIG_TTA_ENCODER) += x86/ttaencdsp.o +X86ASM-OBJS-$(CONFIG_UTVIDEO_DECODER) += x86/utvideodsp.o X86ASM-OBJS-$(CONFIG_V210_ENCODER) += x86/v210enc.o X86ASM-OBJS-$(CONFIG_V210_DECODER) += x86/v210.o X86ASM-OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp.o diff --git a/libavcodec/x86/utvideodsp.asm b/libavcodec/x86/utvideodsp.asm new file mode 100644 index 0000000..2e96f8b --- /dev/null +++ b/libavcodec/x86/utvideodsp.asm @@ -0,0 +1,101 @@ +;****************************************************************************** +;* SIMD-optimized UTVideo functions +;* Copyright (c) 2017 Paul B Mahol +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 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 +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser 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 "libavutil/x86/x86util.asm" + +SECTION_RODATA + +pb_128: times 16 db 128 +pw_512: times 8 dw 512 +pw_1023: times 8 dw 1023 + +SECTION .text + +INIT_XMM sse2 + +; void restore_rgb_planes(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b, +; ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b, +; int width, int height) +cglobal restore_rgb_planes, 8,9,4, src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, w, h, x + movsxdifnidn wq, wd + add src_rq, wq + add src_gq, wq + add src_bq, wq + neg wq + mova m3, [pb_128] +.nextrow: + mov xq, wq + + .loop: + mova m0, [src_rq + xq] + mova m1, [src_gq + xq] + mova m2, [src_bq + xq] + psubb m1, m3 + paddb m0, m1 + paddb m2, m1 + mova [src_rq+xq], m0 + mova [src_bq+xq], m2 + add xq, mmsize + jl .loop + + add src_rq, linesize_rq + add src_gq, linesize_gq + add src_bq, linesize_bq + sub hq, 1 + jg .nextrow + REP_RET + +cglobal restore_rgb_planes10, 8,9,5, src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, w, h, x + movsxd wq, wd + shl wd, 1 + shl linesize_rq, 1 + shl linesize_gq, 1 + shl linesize_bq, 1 + add src_rq, wq + add src_gq, wq + add src_bq, wq + mova m3, [pw_512] + mova m4, [pw_1023] + neg wq +.nextrow: + mov xq, wq + + .loop: + mova m0, [src_rq + xq] + mova m1, [src_gq + xq] + mova m2, [src_bq + xq] + paddw m0, m1 + paddw m2, m1 + psubw m0, m3 + psubw m2, m3 + pand m0, m4 + pand m2, m4 + mova [src_rq+xq], m0 + mova [src_bq+xq], m2 + add xq, mmsize + jl .loop + + add src_rq, linesize_rq + add src_gq, linesize_gq + add src_bq, linesize_bq + sub hq, 1 + jg .nextrow + REP_RET diff --git a/libavcodec/x86/utvideodsp_init.c b/libavcodec/x86/utvideodsp_init.c new file mode 100644 index 0000000..d415692 --- /dev/null +++ b/libavcodec/x86/utvideodsp_init.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/asm.h" +#include "libavutil/x86/cpu.h" +#include "libavcodec/utvideodsp.h" + +void ff_restore_rgb_planes_sse2(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b, + ptrdiff_t linesize_r, ptrdiff_t linesize_g, + ptrdiff_t linesize_b, int width, int height); +void ff_restore_rgb_planes10_sse2(uint16_t *src_r, uint16_t *src_g, uint16_t *src_b, + ptrdiff_t linesize_r, ptrdiff_t linesize_g, + ptrdiff_t linesize_b, int width, int height); + +av_cold void ff_utvideodsp_init_x86(UTVideoDSPContext *c) +{ + int cpu_flags = av_get_cpu_flags(); + + if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags)) { + c->restore_rgb_planes = ff_restore_rgb_planes_sse2; + c->restore_rgb_planes10 = ff_restore_rgb_planes10_sse2; + } +}