From patchwork Wed Aug 28 12:27:16 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: 14741 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 2A86C449C03 for ; Wed, 28 Aug 2019 15:33:58 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0B87768AB51; Wed, 28 Aug 2019 15:33:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0FDAB68AB37 for ; Wed, 28 Aug 2019 15:33:52 +0300 (EEST) Received: by mail-wr1-f44.google.com with SMTP id y8so2311062wrn.10 for ; Wed, 28 Aug 2019 05:33:52 -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=PjEPo6mm9GeJedtZdyeycVFj4SMOKmuwZ52plxlkyzc=; b=uiDt8BEOIzgieyEGoZbgE8f7ZsBQlpdBnm2rHDJuDFbpJeTyvvOziYyZQ661Fq5eTA lOQx9f/WWmAOMJHqUHmc7qUVX27eZHuwIyyO9vbFQ4Ie2gxs4Ou9K/S3IkmZCyEEZaSc pVjOS7ynhivD3tKqAqvWuakBW5xR/tnJ+nAD5hcuGjgjnN/QmYvTLnz41yp+YTrs9d15 zGPYoM3M64uxrNmTTyx6VKxjxWVFMF0sAavlUhW9UhCKOFRKrZk8uKM4HISr4AOeWG/E N7UFx2m65MivOFrMfdK2kJ3NaI1/5FMv8v7y0COsTYJ1A6d6lXNTQElgmqYeAhh7vuV5 UvAg== 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=PjEPo6mm9GeJedtZdyeycVFj4SMOKmuwZ52plxlkyzc=; b=iMCBoGx3DQDvOCMsqGZQNNtL+KOpIcST9EOM8Yo2sP2t0zdeyfYl+INzPuOxsBw4Z3 pWFVpC1SMuH5TjhEnSVIaR6SEcif0QdSnLTZi8oPgnYTwAhl3PH4wCWbNukIgxocsHhw Irdw2+myzPrpXh9FveSYnpoxJqIP1enOoDR9X1mEqoHWqT7lxF14MT1m0bBV0/3NvOua bWDkn+H8ZqL+flCpQ5nhFtgCJji74dzN8/vHXGSGN3Ef16kAtAPkppB1Wy75T8HqTVSR c0aOXAt8mHabWSYhnUskBKqUXMaczWog9CucNH+4pbCnyht7ZeqUag0KAa3T8FOw6F+f dV0Q== X-Gm-Message-State: APjAAAXoG2Aqa3R5YkfO3YhL7DadDg7KHe37yGcgzUVoOUdgBaP3zJ4Y cYx4MGaagrQ12Aj9nt7v3pvPZ0oc X-Google-Smtp-Source: APXvYqzWS0Is2HkKZc6te3FpEKTN4QBr3Ur5DGG+L8gIyqECye9i4cY+k72vw9xlwpBv6mLFKgIeNg== X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr4138557wrx.328.1566995302556; Wed, 28 Aug 2019 05:28:22 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:240d:9b00:f046:3e76:1fc3:c038]) by smtp.gmail.com with ESMTPSA id a17sm2588958wmm.47.2019.08.28.05.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2019 05:28:21 -0700 (PDT) From: Nick Renieris X-Google-Original-From: Nick Renieris To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Aug 2019 15:27:16 +0300 Message-Id: <20190828122723.19640-8-velocityra@gmail.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190828122723.19640-1-velocityra@gmail.com> References: <20190822125635.GD23202@sunshine.barsnick.net> <20190828122723.19640-1-velocityra@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v16 08/15] lavc/tiff: Force DNG pixel data endianness on an edge case 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 This fixes "X7 RAW" and "X7 CinemaDNG" samples here: - https://www.dji.com/gr/zenmuse-x7/info#downloads Signed-off-by: Nick Renieris --- libavcodec/tiff.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 28b8f42edd..b1d4c50e74 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1038,6 +1038,18 @@ static int init_image(TiffContext *s, ThreadFrame *frame) AV_RL32(s->pattern)); return AVERROR_PATCHWELCOME; } + /* Force endianness as mentioned in 'DNG Specification: Chapter 3: BitsPerSample' + NOTE: The spec actually specifies big-endian, not sure why we need little-endian, but + such images don't work otherwise. Examples are images produced by Zenmuse X7. */ + if ((s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG) + && (s->bpp != 8 && s->bpp != 16 && s->bpp != 32)) { + switch (s->avctx->pix_fmt) { + case AV_PIX_FMT_BAYER_RGGB16BE: s->avctx->pix_fmt = AV_PIX_FMT_BAYER_RGGB16LE; break; + case AV_PIX_FMT_BAYER_BGGR16BE: s->avctx->pix_fmt = AV_PIX_FMT_BAYER_BGGR16LE; break; + case AV_PIX_FMT_BAYER_GBRG16BE: s->avctx->pix_fmt = AV_PIX_FMT_BAYER_GBRG16LE; break; + case AV_PIX_FMT_BAYER_GRBG16BE: s->avctx->pix_fmt = AV_PIX_FMT_BAYER_GRBG16LE; break; + } + } break; case 10161: switch (AV_RL32(s->pattern)) {