From patchwork Thu Aug 8 20:52:23 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: 14324 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 B6B2F44A056 for ; Thu, 8 Aug 2019 23:55:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A0A0168AB68; Thu, 8 Aug 2019 23:55:36 +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 ABF9068AB42 for ; Thu, 8 Aug 2019 23:55:28 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id q12so5966589wrj.12 for ; Thu, 08 Aug 2019 13:55:28 -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=fF7Bto0cjzriZ0J68KiesP75bjYKnh1n+69pTrqNQyJNwFNZ8htEoNwKKiEKBWpglq 1SQQI3K9vs+WpG+TVL4d//BI3jU6vp/8gg4ohOplq3pKK1WZ0Ktz9X7nwLSqX3/lRbyk XtlPvt6sQ6z+Egg5UI85Lz+PkDpEwBv9xM2Z4dAH9P4JDwINbjIlnEY8fG9Zl88SsLdH YZQUIdkKkjQgZhiqUfENXkb9wYOZno6/44h4IkkM/13pUvP6el7BxyQ+Yyd6VRakko2/ X2cn81W6y41NHkUZCZA3aQgJ7XE1Oc+OGpCZpaTNsVOkAXyDnt2QLWKYveokjD6OF0pF geTg== 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=nY+eEjZ5L5KK6O97VLsaBMwoXEp7YPJaDZjAnrTRGWTqTMOeX8+Cth6ahphqjW91Fz gI6VzO1STMTI4NaFPLiX3AJnSW4Z8wE1EXcGtVyTtlGlwf5qTZtWREjGzFd7HoR+2P/0 1TKVKf9+cy2E2owH320LYytjLeAecvIRfr9C+hpkUwojSSAe3YkfuXSJUhS6hXRVl8no TdG5TBV1Jwzi4atWpz7+oFOi/B43DXtkQiLa/sqsNtSxnKcssIYsCIOsYeygoFUHQC4K sXZ+OMWdZP5gNMesvuPBINEw91jHXtex1AtazeqvzxXiUFfrByuDNNFFaLPrzTAlTRFK HKLw== X-Gm-Message-State: APjAAAV4qQzh3EmNh7GTiH7FY2boxT11a37Ai0F+Wz0PHWhdyCN8uQEo GQChURNEUaKv0XJUw+Muj8Q0QuayJ18= X-Google-Smtp-Source: APXvYqxvjkTrT3AW7PlTFIKL/Ls2MLzcefB1B8eIRujr+Un9wvLucbs9YgW0pU324E/pNcxAn1/ycg== X-Received: by 2002:a5d:4250:: with SMTP id s16mr4029006wrr.318.1565297727999; Thu, 08 Aug 2019 13:55:27 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:2409:5200:1de8:6b2e:8289:ee0e]) by smtp.gmail.com with ESMTPSA id g25sm3446686wmk.18.2019.08.08.13.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Aug 2019 13:55:27 -0700 (PDT) From: velocityra@gmail.com X-Google-Original-From: velocityra@gmail To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Aug 2019 23:52:23 +0300 Message-Id: <20190808205233.16368-4-velocityra@gmail.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190808205233.16368-1-velocityra@gmail.com> References: <20190808205233.16368-1-velocityra@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v11 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++)