summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorNick Renieris <velocityra@gmail.com>2019-08-29 16:10:50 +0300
committerPaul B Mahol <onemda@gmail.com>2019-09-02 09:26:52 +0200
commitc44aa7f1761bc836f74727e70dc16409e8ccbb9c (patch)
treed67b908d2f17de944bd204ab88a9ad40825ce47d /libavcodec
parent31acdf4351a13195baa8ab453f4429d150dc25a2 (diff)
lavc/tiff: Decode 10-bit and 14-bit DNG images
10-bit sample: http://www.rawsamples.ch/raws/phones/RAW_ONEPLUS_ONE-A0001.DNG 14-bit sample: https://drive.google.com/open?id=0B4JyRT3Lth5HVndyOTVOdWktM3J4TFEydTk1MnY3RWlpSzVB Signed-off-by: Nick Renieris <velocityra@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/tiff.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 4b40df73f9..f199fa27e8 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -309,14 +309,19 @@ static void av_always_inline horizontal_fill(TiffContext *s,
dst[(width+offset)*2+0] = (usePtr ? src[width] : c) >> 4;
}
break;
- case 12: {
- uint16_t *dst16 = (uint16_t *)dst;
- GetBitContext gb;
- init_get_bits8(&gb, src, width);
- for (int i = 0; i < s->width; i++) {
- dst16[i] = get_bits(&gb, 12) << 4;
- }
- }
+ case 10:
+ case 12:
+ case 14: {
+ uint16_t *dst16 = (uint16_t *)dst;
+ int is_dng = (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG);
+ uint8_t shift = is_dng ? 0 : 16 - bpp;
+ GetBitContext gb;
+
+ init_get_bits8(&gb, src, width);
+ for (int i = 0; i < s->width; i++) {
+ dst16[i] = get_bits(&gb, bpp) << shift;
+ }
+ }
break;
default:
if (usePtr) {
@@ -1067,7 +1072,9 @@ static int init_image(TiffContext *s, ThreadFrame *frame)
return AVERROR_PATCHWELCOME;
}
break;
+ case 10101:
case 10121:
+ case 10141:
switch (AV_RL32(s->pattern)) {
case 0x02010100:
s->avctx->pix_fmt = s->le ? AV_PIX_FMT_BAYER_RGGB16LE : AV_PIX_FMT_BAYER_RGGB16BE;