From patchwork Sat Aug 10 22:19:24 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: 14393 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 6D962448F16 for ; Sun, 11 Aug 2019 01:20:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5AA3E68ABCA; Sun, 11 Aug 2019 01:20:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0D9568ABB7 for ; Sun, 11 Aug 2019 01:20:10 +0300 (EEST) Received: by mail-wr1-f66.google.com with SMTP id q12so11128575wrj.12 for ; Sat, 10 Aug 2019 15:20:10 -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=v8GGxWMsP/M6KES8DEzw1MA/FpDJmlRTa1OykEcyc1U=; b=BBxTiOkroY+DDQ7VKYykY9jhTL32PHNSYWsw7fq4JCqGJxYnvSdWEeTAbahDJeo3F9 DS3Mvc4TWZDJ7am9e6jaYnKel0RFrqvq/LXE62hDMLDIB+3pFuRjxwqJYJ68LVVr0ajl cZdv5aRc+fWDqJyN1ZAFAkUx8STyNkcmfhPAc88oASBEFcocz6PUiKDgoCP4nfe0I0fx 8M0R/SDumYUbWkhzsjq7ETN1sKJecj8HJvx2hZm0+FRHvBpZDt0Qq9a9z/zAxPs1uQpI h++/AbtRSkawaDEF8FVrKsuVl/nI4pNIj09hF68dzPVlVTqQ9MA7/RI9vsO3c6lBJrUA i2Ew== 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=v8GGxWMsP/M6KES8DEzw1MA/FpDJmlRTa1OykEcyc1U=; b=mEx1h1wzFJ2J3qTElxO00E8bJXYkeLHIqIY38Mx7+I2V06BSV3gerjVeTim1npdGHx q8oMmHuZlcRlRKSavzhtDrRMHanQFHXpTiV9XBjHt3s+JhjxCUsMHW2XgngQ9erS9V/y GXQwyXrCthwZXlo9+QtUQmJ9Rf9B0kIG8+3qUfo1oYji4h5T7PztdmJGRfREkvXz5/FQ HhbDgIQbc2h4JQi2JYySB+4l8LGTR7hphAwMljy8wUEz57dBBNdt/VMEv2Z2oMatgYHM xBqqHbC21IB3/fopJ/AhyfUKDXhAczvSUntqd2Qd5QKz5mos1p3AsuOwYK3T6NDwFau4 ieOw== X-Gm-Message-State: APjAAAWkLVtKnUs169B7ij/CEkis12kXUffoVN3Ob3KbKx8THcV9ldHf tCuTkDOGti6nwGEsuFdN3uudXM0iwX4= X-Google-Smtp-Source: APXvYqzLXcLAYhuD7v7UHKlkNhKuf0BI3Zm3GYoh8MeLZ/j8SXAQibXL/EV2huVv9cEp5rKjcpFbjw== X-Received: by 2002:adf:83c5:: with SMTP id 63mr3311286wre.86.1565475610034; Sat, 10 Aug 2019 15:20:10 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:2409:5200:5c0b:c2fa:5389:82dd]) by smtp.gmail.com with ESMTPSA id q20sm40403233wrc.79.2019.08.10.15.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Aug 2019 15:20:09 -0700 (PDT) From: Nick Renieris X-Google-Original-From: Nick Renieris To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Aug 2019 01:19:24 +0300 Message-Id: <20190810221934.44996-4-velocityra@gmail.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190810221934.44996-1-velocityra@gmail.com> References: <20190810221934.44996-1-velocityra@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v13 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 a118c37c41..4620508d53 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: @@ -1947,7 +1969,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++)