From f23e663a21829356e966f6f815dd3372462084a1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 Oct 2019 16:14:36 +0200 Subject: zimg: support 3 component 16 bit pixel unpacking Works for RGB (e.g. rgb48le) and XYZ. It's unsure whether XYZ is really correctly converted. --- video/zimg.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'video') diff --git a/video/zimg.c b/video/zimg.c index c5b0d07b62..d9fde65f19 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -253,6 +253,17 @@ static void xccc8_pack(void *dst, void *src[], int x0, int x1) } } +// 3 16 bit color components written to 3 planes. +static void ccc16_unpack(void *src, void *dst[], int x0, int x1) +{ + uint16_t *r = src; + for (int x = x0; x < x1; x++) { + ((uint16_t *)dst[0])[x] = *r++; + ((uint16_t *)dst[1])[x] = *r++; + ((uint16_t *)dst[2])[x] = *r++; + } +} + static int packed_repack(void *user, unsigned i, unsigned x0, unsigned x1) { struct mp_zimg_repack *r = user; @@ -357,6 +368,17 @@ static void setup_regular_rgb_packer(struct mp_zimg_repack *r) r->components[n] = corder[p->components[first + n]]; return; } + + if (desc.component_size == 2 && p->num_components == 3) { + if (r->pack) // no packer yet + return; + r->repack = packed_repack; + r->packed_repack_scanline = ccc16_unpack; + r->zimgfmt = planar_fmt; + for (int n = 0; n < 3; n++) + r->components[n] = corder[p->components[n]]; + return; + } } // (ctx can be NULL for the sake of probing.) -- cgit v1.2.3