From patchwork Thu Aug 29 13:10:43 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: 14783 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 B930044A068 for ; Thu, 29 Aug 2019 16:12:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9AB6B687F2C; Thu, 29 Aug 2019 16:12:25 +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 474B6687F16 for ; Thu, 29 Aug 2019 16:12:16 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id c3so3376985wrd.7 for ; Thu, 29 Aug 2019 06:12:16 -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=NDIjf4+wzhdUmO8XlzveRJz93EXgKPxPDW25hzGRJEI=; b=d5U/mztx3d26VpDT+fKWAS7Q3jzHH3QMvNdzjL9wkpcg788fc3dsQCQF31yMPJiKPk A4v7h3wD0+RvtaztIye8AVp1miA7EaRbGnaaYvuiy8es6caPqhS4ReoYRudNM9CXEGVD PKk9nwrBrW6yRzO0RgcRmA9vK06evLxZCp3JWgoWjuu+z14ex6QZ0mxjRk8KmJ1mBb02 uAcWHf2NHDiGIJOyZhgTapA/emej3oSmujdPWn5A3TgjjxrRiEpuyrB26mxLjY030uoW +Y/3zQX7oCXrHTZM+1MIXjb1ZnBxm2uxeEL5HOjK9Omz3LvEHUsXVzA2VuFoFfG0FbJl lXBA== 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=NDIjf4+wzhdUmO8XlzveRJz93EXgKPxPDW25hzGRJEI=; b=JC+BgmQg3+x6+zMAY5d81+ECRFfe3JSeo7cxQ3CoqY9ozIo+wAB+5sN+Ap/eJk+MBM HqftuNQl5a40IahJSyNrKSiVgLNeWG7bgiSvu0bxUL8R8U4ZimmwvxAJvIP3WrKuZxS0 ti6Zz0IHpzNlrpwP4JHuxkSjD6P3L/vUPW1/RPVR9uYIFQm5T6iv5GggjI+FvJdYSNkJ DIy1T867oQc2Ix51pkw9stjtXsqUEzevEL701hp8VVhEQqZNw+pHdfr5aPwesuxpInQQ W+DWWC5GSkzaZASFXOPstmAoOOl+IY7keLTpS8N+zoHH9l3lDCe1vpLikx13ivm+SX6c ClIg== X-Gm-Message-State: APjAAAXI60vrShZfEgSBkgjuVRxMYdGkrYUDXgj642QuYcaKyn/YbLIQ cVZG0oNJCSgRO1Gzhd8KK7h2ROLu X-Google-Smtp-Source: APXvYqz2aCqpCDmwF1l88DngBoQNPz3LtxaMPjamVFg06ZXPJLHEQ3SRWCG+FuPq9Guai0Yt4yLbDw== X-Received: by 2002:a5d:54cd:: with SMTP id x13mr1765785wrv.12.1567084335433; Thu, 29 Aug 2019 06:12:15 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:240d:9b00:4ca1:2ce9:2e6c:c246]) by smtp.gmail.com with ESMTPSA id m17sm1676644wrs.9.2019.08.29.06.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 06:12:13 -0700 (PDT) From: Nick Renieris X-Google-Original-From: Nick Renieris To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2019 16:10:43 +0300 Message-Id: <20190829131054.16404-4-velocityra@gmail.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190829131054.16404-1-velocityra@gmail.com> References: <20190829131054.16404-1-velocityra@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v17 04/15] 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 eb064eec5c..78b4bd5301 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 * s->bppcount, // 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++)