From patchwork Thu Aug 1 13:04:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 2836975 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7B5C39F9C8 for ; Thu, 1 Aug 2013 13:05:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A7D420187 for ; Thu, 1 Aug 2013 13:05:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0867820217 for ; Thu, 1 Aug 2013 13:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755447Ab3HANFI (ORCPT ); Thu, 1 Aug 2013 09:05:08 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:62031 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750886Ab3HANFF (ORCPT ); Thu, 1 Aug 2013 09:05:05 -0400 Received: by mail-lb0-f182.google.com with SMTP id v20so1522987lbc.27 for ; Thu, 01 Aug 2013 06:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=vcGQqL/UXs8dikaiS3ZgOS+f68x4sLFcc35BC2NnQ1o=; b=CjFIMzksIw8FrKvtoOijHvYSwa6n+/wBk22cykVu3h4dhNz0KuGTkONfFkx0eatzhr NAklqlf+6G6BE4stGMON6rzZ6nwolxge6h/JZuHqg5VNP924jliNERE+9uLbNsiY+ZpB 6h+a1kA1IAqX/T2b/P3MwlNLnjXiQyGmuxRYXHVl2HjjkkUPWEiHp+PxdrM6CYdGufgM VqXicJqjG8XJP5VcELfMtJiTZIDHs81ILOae5omabT0aZMCQRgIJZnKFGPKx7kIE+/z/ f1ATCIMKWAzkq67lBtjfHgiFk18Ml9qfzrY9fkXCyHgJv+w4GkhafxKPNMqNifdquOdg Q5BQ== X-Received: by 10.152.5.197 with SMTP id u5mr694774lau.59.1375362304294; Thu, 01 Aug 2013 06:05:04 -0700 (PDT) Received: from localhost (0x4dd4aed9.adsl.cybercity.dk. [77.212.174.217]) by mx.google.com with ESMTPSA id w9sm1234726lbk.7.2013.08.01.06.05.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 01 Aug 2013 06:05:03 -0700 (PDT) From: Ricardo Ribalda Delgado To: hans.verkuil@cisco.com, linux-media@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH 1/2] libv4lconvert: Support for Y16 pixel format Date: Thu, 1 Aug 2013 15:04:53 +0200 Message-Id: <1375362294-30741-2-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375362294-30741-1-git-send-email-ricardo.ribalda@gmail.com> References: <1375362294-30741-1-git-send-email-ricardo.ribalda@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for V4L2_PIX_FMT_Y16 format. Signed-off-by: Ricardo Ribalda Delgado --- lib/libv4lconvert/libv4lconvert-priv.h | 6 ++++++ lib/libv4lconvert/libv4lconvert.c | 19 +++++++++++++++++++ lib/libv4lconvert/rgbyuv.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/lib/libv4lconvert/libv4lconvert-priv.h b/lib/libv4lconvert/libv4lconvert-priv.h index c37e220..6422fdd 100644 --- a/lib/libv4lconvert/libv4lconvert-priv.h +++ b/lib/libv4lconvert/libv4lconvert-priv.h @@ -152,6 +152,12 @@ void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest, void v4lconvert_grey_to_yuv420(const unsigned char *src, unsigned char *dest, const struct v4l2_format *src_fmt); +void v4lconvert_y16_to_rgb24(const unsigned char *src, unsigned char *dest, + int width, int height); + +void v4lconvert_y16_to_yuv420(const unsigned char *src, unsigned char *dest, + const struct v4l2_format *src_fmt); + int v4lconvert_y10b_to_rgb24(struct v4lconvert_data *data, const unsigned char *src, unsigned char *dest, int width, int height); diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index 60010f1..bc5e34f 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -128,6 +128,7 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = { { V4L2_PIX_FMT_Y4, 8, 20, 20, 0 }, { V4L2_PIX_FMT_Y6, 8, 20, 20, 0 }, { V4L2_PIX_FMT_Y10BPACK, 10, 20, 20, 0 }, + { V4L2_PIX_FMT_Y16, 16, 20, 20, 0 }, }; static const struct v4lconvert_pixfmt supported_dst_pixfmts[] = { @@ -989,6 +990,24 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, break; } + case V4L2_PIX_FMT_Y16: + switch (dest_pix_fmt) { + case V4L2_PIX_FMT_RGB24: + case V4L2_PIX_FMT_BGR24: + v4lconvert_y16_to_rgb24(src, dest, width, height); + break; + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + v4lconvert_y16_to_yuv420(src, dest, fmt); + break; + } + if (src_size < (width * height * 2)) { + V4LCONVERT_ERR("short y16 data frame\n"); + errno = EPIPE; + result = -1; + } + break; + case V4L2_PIX_FMT_GREY: case V4L2_PIX_FMT_Y4: case V4L2_PIX_FMT_Y6: diff --git a/lib/libv4lconvert/rgbyuv.c b/lib/libv4lconvert/rgbyuv.c index d05abe9..bef034f 100644 --- a/lib/libv4lconvert/rgbyuv.c +++ b/lib/libv4lconvert/rgbyuv.c @@ -586,6 +586,36 @@ void v4lconvert_rgb565_to_yuv420(const unsigned char *src, unsigned char *dest, } } +void v4lconvert_y16_to_rgb24(const unsigned char *src, unsigned char *dest, + int width, int height) +{ + int j; + while (--height >= 0) { + for (j = 0; j < width; j++) { + *dest++ = *src; + *dest++ = *src; + *dest++ = *src; + src+=2; + } + } +} + +void v4lconvert_y16_to_yuv420(const unsigned char *src, unsigned char *dest, + const struct v4l2_format *src_fmt) +{ + int x, y; + + /* Y */ + for (y = 0; y < src_fmt->fmt.pix.height; y++) + for (x = 0; x < src_fmt->fmt.pix.width; x++){ + *dest++ = *src; + src+=2; + } + + /* Clear U/V */ + memset(dest, 0x80, src_fmt->fmt.pix.width * src_fmt->fmt.pix.height / 2); +} + void v4lconvert_grey_to_rgb24(const unsigned char *src, unsigned char *dest, int width, int height) {