From patchwork Mon Sep 5 05:14:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37669 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2411693pzh; Sun, 4 Sep 2022 22:15:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ccL77DW2Zi+bIH5Gdea+tvIqhEd9OTKdzyxXAA8NJ6aGIWh4KLsRONMGd3++8zfFxclQd X-Received: by 2002:a17:907:2705:b0:741:6caa:20f4 with SMTP id w5-20020a170907270500b007416caa20f4mr25638163ejk.35.1662354910174; Sun, 04 Sep 2022 22:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662354910; cv=none; d=google.com; s=arc-20160816; b=N2gGsFHN3j53VnCLQP3WTj2ngik7sB1O4F803RU5p75bKpD2S8TrQFb7bSa7a9mWFA XQ96pWRH0vtnrCLCScb0Q29tNkleTBxP5EgB9qiwKYi/69th1GCnYS3lxt+4RU57Zixf PRyWHeSuZ3vBEBZDTfZVq5/0nPwmapAlUXDcOOBTdrLSOt4kI820ptt2AlhPym6JpDGj TF34blVAh5oTa9+nocucHd7l81E4kMSgAyXsAkCaC6auPk2ycZnmcbYwaljYbKxl3XhO cZu+BLf721zOE0wKr42AXUf/roJ7Hu5youjAfHCrLeAbIRrHu9g1G62rKhwh9mYW+PDA gM8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=hz2VHw5ovVF89oJ8Joe4sGbjXO+6GY/YyQsUjCUErr8=; b=JRosdtebJMqXpoKFdOBmKH7kVcBPNr9p2uq4W1B1iL5854nzyao5P/DUbSBFT5RgH8 Q3wfHPEHsnOFZslFeT8MYNyKLw2CtaDBfS/0jcuLHWwKdojDK1LwU41n6Xw3gCLLJ9Hi 53G/apmHfHsjCl414UtrNkwFr1Yl3TiW/Z6eE9OUcXh8DPZRbknMoVABWYXiAZ8EhCJz RATIdxhkO65Fa4dsDT+DtZA4M9vGUDpJkusxF8kkN8FqLH2wdlryyBX3Opm7xuGG35qz fabbiVLvRQvr7gJD8HxVAg3DbjOevCd6853Qe9jdhFu/EyVlnmpROvzx/C1v3Kwjkf+j Y8Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=BUKDswRA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e9-20020a1709062d4900b0073dce13c643si6303465eji.872.2022.09.04.22.15.09; Sun, 04 Sep 2022 22:15:10 -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=@overt.org header.s=mail header.b=BUKDswRA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 910E968B968; Mon, 5 Sep 2022 08:14:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.overt.org (mail.overt.org [157.230.92.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0E9C568B389 for ; Mon, 5 Sep 2022 08:14:45 +0300 (EEST) Received: from authenticated-user (mail.overt.org [157.230.92.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id B9E543F73E; Mon, 5 Sep 2022 00:14:43 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1662354884; bh=uXXDrMW5zeh2iANBWgC86c/kluL7s+x4wEg+HS/FoDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUKDswRAUWRAorU8cjRg9k4oMexhQByoKicZI24wOpZq31fMjBqhCEgvktnHa12Sf NJFnGHr753Ug2fdTYak6beOuwZkAj5UhQK+Em+4Yp165DLo6/nQbAVIcJ2qlxvFpOY f5yZWHKiBpUQyquM6OpQMLy4FLYwSbMo4icaNtVYuhWoDyqKN00wmQIekRmbhwYI6u q2Y4vw4W/jepcre7Od/O/8GdjUJivtV1a6qsFUv3kmvja0nZcmVrYH89fMmqFMO12z QyLhDbmw4DPxBo0NssUYOjZZmGfSS/gZ/YxBCTtS/ckkM/8wzUvY895E/6oxLlEesA koY4sO25EmcLg== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Sep 2022 22:14:28 -0700 Message-Id: <20220905051430.218289-3-philipl@overt.org> In-Reply-To: <20220905051430.218289-1-philipl@overt.org> References: <20220905051430.218289-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] swscale/input: add support for P012 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zlRo82GiHK6F As we now have three of these formats, I added macros to generate the conversion functions. Signed-off-by: Philip Langdale --- libswscale/input.c | 123 +++++++++++++++++++++++---------------------- libswscale/utils.c | 2 + 2 files changed, 66 insertions(+), 59 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index 8032360907..babedfd541 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -749,67 +749,60 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, nvXXtoUV_c(dstV, dstU, src1, width); } -static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, - const uint8_t *unused2, int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6); - } -} - -static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, - const uint8_t *unused2, int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6); +#define p01x_uv_wrapper(bits, shift) \ + static void p0 ## bits ## LEToUV_c(uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *unused0, \ + const uint8_t *src1, \ + const uint8_t *src2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> shift); \ + AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> shift); \ + } \ + } \ + \ + static void p0 ## bits ## BEToUV_c(uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *unused0, \ + const uint8_t *src1, \ + const uint8_t *src2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> shift); \ + AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> shift); \ + } \ } -} -static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6); - AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6); - } -} - -static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6); - AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6); - } -} - -static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0)); - AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2)); - } -} - -static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0)); - AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2)); - } -} +#define p01x_wrapper(bits, shift) \ + static void p0 ## bits ## LEToY_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, \ + const uint8_t *unused2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> shift); \ + } \ + } \ + \ + static void p0 ## bits ## BEToY_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, \ + const uint8_t *unused2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> shift); \ + } \ + } \ + p01x_uv_wrapper(bits, shift) + +p01x_wrapper(10, 6); +p01x_wrapper(12, 4); +p01x_uv_wrapper(16, 0); #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos)) @@ -1413,6 +1406,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_P410BE: c->chrToYV12 = p010BEToUV_c; break; + case AV_PIX_FMT_P012LE: + c->chrToYV12 = p012LEToUV_c; + break; + case AV_PIX_FMT_P012BE: + c->chrToYV12 = p012BEToUV_c; + break; case AV_PIX_FMT_P016LE: case AV_PIX_FMT_P216LE: case AV_PIX_FMT_P416LE: @@ -1893,6 +1892,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_P410BE: c->lumToYV12 = p010BEToY_c; break; + case AV_PIX_FMT_P012LE: + c->lumToYV12 = p012LEToY_c; + break; + case AV_PIX_FMT_P012BE: + c->lumToYV12 = p012BEToY_c; + break; case AV_PIX_FMT_GRAYF32LE: c->lumToYV12 = grayf32leToY16_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index a67e07b612..a7f77cd39d 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -236,6 +236,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_AYUV64LE] = { 1, 1}, [AV_PIX_FMT_P010LE] = { 1, 1 }, [AV_PIX_FMT_P010BE] = { 1, 1 }, + [AV_PIX_FMT_P012LE] = { 1, 0 }, + [AV_PIX_FMT_P012BE] = { 1, 0 }, [AV_PIX_FMT_P016LE] = { 1, 1 }, [AV_PIX_FMT_P016BE] = { 1, 1 }, [AV_PIX_FMT_GRAYF32LE] = { 1, 1 },