aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Renieris <velocityra@gmail.com>2019-08-29 16:10:47 +0300
committerPaul B Mahol <onemda@gmail.com>2019-09-02 09:26:52 +0200
commitc510ed2ee8b3d5ec373d9d8a7e5a25c132ca620e (patch)
tree5f442eb4d02c62d03c98a2716854483953ad2db5
parent33b6752a708f9afc2a99a86ff28a42803e52bc28 (diff)
downloadffmpeg-c510ed2ee8b3d5ec373d9d8a7e5a25c132ca620e.tar.gz
lavc/tiff: Force DNG pixel data endianness on an edge case
This fixes "X7 RAW" and "X7 CinemaDNG" samples here: - https://www.dji.com/gr/zenmuse-x7/info#downloads Signed-off-by: Nick Renieris <velocityra@gmail.com>
-rw-r--r--libavcodec/tiff.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index b4015178f2..8cbcbdf7a5 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)) {