From patchwork Sat Feb 9 13:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10804469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A7801669 for ; Sat, 9 Feb 2019 13:54:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E644D2A64F for ; Sat, 9 Feb 2019 13:54:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D80C52A690; Sat, 9 Feb 2019 13:54:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE1432A690 for ; Sat, 9 Feb 2019 13:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726940AbfBINym (ORCPT ); Sat, 9 Feb 2019 08:54:42 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54269 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbfBINym (ORCPT ); Sat, 9 Feb 2019 08:54:42 -0500 Received: by mail-wm1-f67.google.com with SMTP id d15so8509866wmb.3 for ; Sat, 09 Feb 2019 05:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8HNEFm09fHJw68jRxGOgD6bYNXu9KdFAMQNqM5i/EcM=; b=iOYcECShK4xbsvt0DN5zAb3P1dkDuu8iR1oxsKTpbl6TZvaKveBLXoWYGTA5BGYAWf RhIca7/KBf1HH4kiULrsUzPF4pTgg044YCsWf6VKwIQhIk7qD6OXSnw1xDd2b2b9JsV4 GAcPXrohQpv3BNi/b5hNhPUaCdo/kLZwJFPl2XL0utLw8VmmaU/SAWqsH+Gz0cGs5+xu d1ee/x7qTG+HZDl6xigus/CX8afWhW3GK0+CMgfMyRODIgxejqFLiU6q/udfO9HgI3An vzO+aJX3TpT2S7ivAhd9/BLd6YpeNCRs1AjpugSXiWjKXk5RP+xHt9CLgc1FB4KyjZEB Ke9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8HNEFm09fHJw68jRxGOgD6bYNXu9KdFAMQNqM5i/EcM=; b=KwDOMZ3SuiWdgbDQXm8W+GBVpLKqcbnABcuYCxyLl57WAui8r8Fe8HAzDNe+hq9XKU +Pl6owBdK47HOu/ZyntMxEyZ41s4+05M4/xChl8VzmpKImcL2WjjOqDF+/4Tne+Ly4/H MyGOW8BGKtrXyd9dCafvhRuXJMHdwi+HU8oCQYIqlTD9uPWRBTx9DO2Mp7SHC46pb/xD WEIjlTe/P0H3sIULCvtVl2GjR7lXK3e7TOgsLcgJeyiavnVngvEgrh29rq14oJuK/TKa yjEUzSynIQDqqAchCPXk+heFP8D8BF7uACo1Qg7vYYrv1MDlD8pzI0kYKLGbRJ4SxNKy XXvw== X-Gm-Message-State: AHQUAuYOouvbrgcTBS2TgpjCVELNf4mcOrVoWB6b3G2agz4IZNd2DtJv 6abNw15/lMtBZr3n4Jh5CxY9iBMHgvQ= X-Google-Smtp-Source: AHgI3IaP8rBgsqsA38gKrewc+YLLnG2eDvuyT+AsL6V/fNgjsmtZ9os7RgkMstl657ziYO9trJ8tAg== X-Received: by 2002:adf:8121:: with SMTP id 30mr14157306wrm.51.1549720478940; Sat, 09 Feb 2019 05:54:38 -0800 (PST) Received: from localhost.localdomain ([87.70.76.19]) by smtp.gmail.com with ESMTPSA id a15sm2864081wrx.58.2019.02.09.05.54.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Feb 2019 05:54:38 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 1/9] media: vicodec: Move raw frame preparation code to a function Date: Sat, 9 Feb 2019 05:54:19 -0800 Message-Id: <20190209135427.20630-2-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190209135427.20630-1-dafna3@gmail.com> References: <20190209135427.20630-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce 'prepare_raw_frame' function that fills the values of a raw frame struct according to the format. Signed-off-by: Dafna Hirschfeld --- .../media/platform/vicodec/codec-v4l2-fwht.c | 140 ++++++++++-------- 1 file changed, 75 insertions(+), 65 deletions(-) diff --git a/drivers/media/platform/vicodec/codec-v4l2-fwht.c b/drivers/media/platform/vicodec/codec-v4l2-fwht.c index c15034849133..728ed5012aed 100644 --- a/drivers/media/platform/vicodec/codec-v4l2-fwht.c +++ b/drivers/media/platform/vicodec/codec-v4l2-fwht.c @@ -75,117 +75,127 @@ const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx) return v4l2_fwht_pixfmts + idx; } -int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) +static int prepare_raw_frame(struct fwht_raw_frame *rf, + const struct v4l2_fwht_pixfmt_info *info, u8 *buf, + unsigned int size) { - unsigned int size = state->stride * state->coded_height; - unsigned int chroma_stride = state->stride; - const struct v4l2_fwht_pixfmt_info *info = state->info; - struct fwht_cframe_hdr *p_hdr; - struct fwht_cframe cf; - struct fwht_raw_frame rf; - u32 encoding; - u32 flags = 0; - - if (!info) - return -EINVAL; - - rf.luma = p_in; - rf.width_div = info->width_div; - rf.height_div = info->height_div; - rf.luma_alpha_step = info->luma_alpha_step; - rf.chroma_step = info->chroma_step; - rf.alpha = NULL; - rf.components_num = info->components_num; + rf->luma = buf; + rf->width_div = info->width_div; + rf->height_div = info->height_div; + rf->luma_alpha_step = info->luma_alpha_step; + rf->chroma_step = info->chroma_step; + rf->alpha = NULL; + rf->components_num = info->components_num; switch (info->id) { case V4L2_PIX_FMT_GREY: - rf.cb = NULL; - rf.cr = NULL; + rf->cb = NULL; + rf->cr = NULL; break; case V4L2_PIX_FMT_YUV420: - rf.cb = rf.luma + size; - rf.cr = rf.cb + size / 4; - chroma_stride /= 2; + rf->cb = rf->luma + size; + rf->cr = rf->cb + size / 4; break; case V4L2_PIX_FMT_YVU420: - rf.cr = rf.luma + size; - rf.cb = rf.cr + size / 4; - chroma_stride /= 2; + rf->cr = rf->luma + size; + rf->cb = rf->cr + size / 4; break; case V4L2_PIX_FMT_YUV422P: - rf.cb = rf.luma + size; - rf.cr = rf.cb + size / 2; - chroma_stride /= 2; + rf->cb = rf->luma + size; + rf->cr = rf->cb + size / 2; break; case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV24: - rf.cb = rf.luma + size; - rf.cr = rf.cb + 1; + rf->cb = rf->luma + size; + rf->cr = rf->cb + 1; break; case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV42: - rf.cr = rf.luma + size; - rf.cb = rf.cr + 1; + rf->cr = rf->luma + size; + rf->cb = rf->cr + 1; break; case V4L2_PIX_FMT_YUYV: - rf.cb = rf.luma + 1; - rf.cr = rf.cb + 2; + rf->cb = rf->luma + 1; + rf->cr = rf->cb + 2; break; case V4L2_PIX_FMT_YVYU: - rf.cr = rf.luma + 1; - rf.cb = rf.cr + 2; + rf->cr = rf->luma + 1; + rf->cb = rf->cr + 2; break; case V4L2_PIX_FMT_UYVY: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; break; case V4L2_PIX_FMT_VYUY: - rf.cr = rf.luma; - rf.cb = rf.cr + 2; - rf.luma++; + rf->cr = rf->luma; + rf->cb = rf->cr + 2; + rf->luma++; break; case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_HSV24: - rf.cr = rf.luma; - rf.cb = rf.cr + 2; - rf.luma++; + rf->cr = rf->luma; + rf->cb = rf->cr + 2; + rf->luma++; break; case V4L2_PIX_FMT_BGR24: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; break; case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_XRGB32: case V4L2_PIX_FMT_HSV32: - rf.cr = rf.luma + 1; - rf.cb = rf.cr + 2; - rf.luma += 2; + rf->cr = rf->luma + 1; + rf->cb = rf->cr + 2; + rf->luma += 2; break; case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_XBGR32: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; break; case V4L2_PIX_FMT_ARGB32: - rf.alpha = rf.luma; - rf.cr = rf.luma + 1; - rf.cb = rf.cr + 2; - rf.luma += 2; + rf->alpha = rf->luma; + rf->cr = rf->luma + 1; + rf->cb = rf->cr + 2; + rf->luma += 2; break; case V4L2_PIX_FMT_ABGR32: - rf.cb = rf.luma; - rf.cr = rf.cb + 2; - rf.luma++; - rf.alpha = rf.cr + 1; + rf->cb = rf->luma; + rf->cr = rf->cb + 2; + rf->luma++; + rf->alpha = rf->cr + 1; break; default: return -EINVAL; } + return 0; +} + +int v4l2_fwht_encode(struct v4l2_fwht_state *state, u8 *p_in, u8 *p_out) +{ + unsigned int size = state->stride * state->coded_height; + unsigned int chroma_stride = state->stride; + const struct v4l2_fwht_pixfmt_info *info = state->info; + struct fwht_cframe_hdr *p_hdr; + struct fwht_cframe cf; + struct fwht_raw_frame rf; + u32 encoding; + u32 flags = 0; + + if (!info) + return -EINVAL; + + if (prepare_raw_frame(&rf, info, p_in, size)) + return -EINVAL; + if (info->id == V4L2_PIX_FMT_YUV420 || + info->id == V4L2_PIX_FMT_YVU420 || + info->id == V4L2_PIX_FMT_YUV422P) + chroma_stride /= 2; cf.i_frame_qp = state->i_frame_qp; cf.p_frame_qp = state->p_frame_qp;