From patchwork Tue Aug 20 13:37:36 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: 14619 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 77970448AEE for ; Tue, 20 Aug 2019 16:43:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5763768A995; Tue, 20 Aug 2019 16:43:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5FE8688391 for ; Tue, 20 Aug 2019 16:43:34 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id f72so2663320wmf.5 for ; Tue, 20 Aug 2019 06:43:34 -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; bh=YPU8YXVVqHd0u/VtF7jDEwNd/2zk2eVZcBCxgsT/f0o=; b=TJXgpFPRWFBtP2fkFl1vSpQW/rRhEyuCojGU1hhvHAzAxXGCdalrOnjjyS+k/vu6rW ncQW7dePctjTrlUawp3rC99Ws7uuCjwc4sV5vxqTmGq7acHiHEUrM1xVU7LhN4g8xAjr kzcaxPBhRNU+dPLS6znphLiUw6buqR7ZtQus6GN+Ft6zDS6H+BxAITW5tcS3TnZjSkNO Lj6oTQlSRXCtLfjxdQq+GvW6kiQsqtRsUiHpdlR9fCxY/n1Ou3jDG1kT2rJOfVguUoxa hucMSQZ6qCYlPWaUeOYrBNCJ8I4wtTngT0Mh9lwSwEu4ASBjplM9Bxd1Q+nlejqZ/96p ch/A== 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=YPU8YXVVqHd0u/VtF7jDEwNd/2zk2eVZcBCxgsT/f0o=; b=gvYjZgO5tJXkcJVbsK/OK97Z4hU4UwA3CPNNL1kGV0mxGpCwDlLQue7OUCM3SZ6W8t K6wujxscpL+cF6UeIEDM6dWVJv36/XP3wiQLTUYOg530Bs2uEEGl6u63poRJkVTcXczs xh4W8l8PAN4i+smNv9TvdmrRQW186M0j8f/MZhTj3qMkwzdeM7zM0azXpbUcmhx3AGEP a+/HZRg6Lr5vAwacq84Up1WGFCmfq1UVfj628BNYCHKzzbEWfmIEL/KoJTetZkBviRN+ TcaDLDAs1PpurTzxAzNud17fJBjhM7ps7hxY1kxaDvO0fP94P/kwBqwhgg5g4kBuhRS4 lyvA== X-Gm-Message-State: APjAAAXoavlSlvUWHpTjIfEeM+epZ1hoK7b+W8A5lNXjKT4ilxANc4NU cZ98+IkOA7aB5MHHVzgzRr2yyGLz X-Google-Smtp-Source: APXvYqy/tat6s7m7TSQ2XRIXD/LgpCFkA01h1kOJC1L/qCUphYFE0/jYjuIavMtMOK/HO38BsctUkw== X-Received: by 2002:a05:600c:54c:: with SMTP id k12mr16149wmc.117.1566308297125; Tue, 20 Aug 2019 06:38:17 -0700 (PDT) Received: from localhost.localdomain (ppp-94-66-223-133.home.otenet.gr. [94.66.223.133]) by smtp.gmail.com with ESMTPSA id t14sm11545882wrs.58.2019.08.20.06.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 06:38:16 -0700 (PDT) From: Nick Renieris To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Aug 2019 16:37:36 +0300 Message-Id: <20190820133747.30983-4-velocityra@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820133747.30983-1-velocityra@gmail.com> References: <20190811144542.11704-13-velocityra@gmail.com> <20190820133747.30983-1-velocityra@gmail.com> Subject: [FFmpeg-devel] [PATCH v15 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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..dd1295fad6 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++)