From patchwork Sun Aug 11 14:45:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: velocityra@gmail.com X-Patchwork-Id: 14416 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 97B39448588 for ; Sun, 11 Aug 2019 17:46:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 86C1A68AC16; Sun, 11 Aug 2019 17:46:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 37FC768ABBE for ; Sun, 11 Aug 2019 17:46:29 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id g17so102436735wrr.5 for ; Sun, 11 Aug 2019 07:46:29 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=3YrDgAufI16bwkhL93iY1X3hSU3SnRn+gA5r0PJMOCo=; b=lDk0eQmO9/XhDhIkNoYmgEtZkJl6y6HtixViCY7ZpX33qEGECv1bMNuoCcjFJwdWq1 NFTQsMHGflZWteWAzjmekFqrO765CQ3/200/l6dQFabP/AW5MPjObq43bPAIMVPtCRgr 8Xu0HLlDFQ1UPgNQ9jP+WFvZikTvgIjVNljJ1Nu5SPlk+dcLeub/uXT3BvVPvQypLxVz aRFsAbzwd0xZEVPewLMZAF3HdaGZxf7To7/oQB5xv82AXspqO2raVwlNOGYJ/0iUx7C2 mXzyxsroG+UfwzEq3KIQTPZRNN0KPDCSxTi90lORBumiiixp7gnN4Zypl3n77UlI017x QlCw== 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:mime-version:content-transfer-encoding; bh=3YrDgAufI16bwkhL93iY1X3hSU3SnRn+gA5r0PJMOCo=; b=ocYfPRN5cyJTvEE7bz0prl1MivnuKEwtOFD/ClGLvvhMOg9/ea0aoUnlK79uvwLK54 5ZdLyb4nL1CAAw8Q0hfzOyJcKH7ztiRNIyI2Zg7vxuVMfbu60nM/dG1kI5F/JpeyfpTH Ixbq7SqGJdYfDVSfTnw3HO8lCweWmbzRsASloQgnCfuvx7mC5z4urItI44zEJH9790JE kVXcZDJvrZXHVDsePWTKMlJ+wnEIt1xKdqnmYD6vpeS0zAWvbwwWZ7fQycD0NGzlcWjo ud2EIwvU2bGBhDX/mCnYgKUtWbjIbrzPenXQwiIPZ52wNiOWneXk0lvF36PfDnT3kP/n P2Vg== X-Gm-Message-State: APjAAAVRoNT4gssqNfX/45UTgLFoNJPdxwO7ozyLkc3Xqat8QymgQmQ7 yqjoDgYTvI8fzrN1PdGPdoXit931y4s= X-Google-Smtp-Source: APXvYqyfchh9+VyfEYVLz+gECVIRwXt6p6+POZ2g0rugeJnjyGOktQmRMfsK1bGZmG7JMYWAaVb7aQ== X-Received: by 2002:adf:c613:: with SMTP id n19mr35535420wrg.109.1565534788303; Sun, 11 Aug 2019 07:46:28 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:2409:5200:94bc:d60f:d153:ccb1]) by smtp.gmail.com with ESMTPSA id f10sm8376360wrm.31.2019.08.11.07.46.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Aug 2019 07:46:27 -0700 (PDT) From: Nick Renieris X-Google-Original-From: Nick Renieris To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Aug 2019 17:45:32 +0300 Message-Id: <20190811144542.11704-4-velocityra@gmail.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190811144542.11704-1-velocityra@gmail.com> References: <20190811073641.GZ3219@michaelspb> <20190811144542.11704-1-velocityra@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v14 04/14] lavc/tiff: Apply color scaling to uncompressed DNGs 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 Cc: Nick Renieris Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Nick Renieris Signed-off-by: Nick Renieris --- libavcodec/tiff.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index a2102f32b5..040e83ba7c 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -556,6 +556,7 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid int is_yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && (desc->flags & AV_PIX_FMT_FLAG_PLANAR) && desc->nb_components >= 3; + int is_dng; if (s->planar) width /= s->bppcount; @@ -657,6 +658,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid bytestream2_init(&s->gb, src, size); bytestream2_init_writer(&pb, dst, is_yuv ? s->yuv_line_size : (stride * lines)); + is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG); + for (line = 0; line < lines; line++) { if (src - ssrc > size) { av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n"); @@ -679,6 +682,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid for (i = 0; i < width; i++) dst[i] = ff_reverse[src[i]]; } + + /* Color processing for DNG images with uncompressed strips (non-tiled) */ + if (is_dng) { + int is_u16, pixel_size_bytes, pixel_size_bits; + + is_u16 = (s->bpp > 8); + pixel_size_bits = (is_u16 ? 16 : 8); + pixel_size_bytes = (is_u16 ? sizeof(uint16_t) : sizeof(uint8_t)); + + dng_blit(s, + dst, + 0, // no stride, only 1 line + dst, + 0, // no stride, only 1 line + width / pixel_size_bytes * pixel_size_bits / s->bpp, // need to account for [1, 16] bpp + 1, + is_u16); + } + src += width; break; case TIFF_PACKBITS: @@ -1945,7 +1967,8 @@ again: FFSWAP(int, p->linesize[0], p->linesize[1]); } - if (s->is_bayer && s->white_level && s->bpp == 16) { + if (s->is_bayer && s->white_level && s->bpp == 16 && + !(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG)) { uint16_t *dst = (uint16_t *)p->data[0]; for (i = 0; i < s->height; i++) { for (j = 0; j < s->width; j++)