summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-20 16:14:36 +0200
committerwm4 <wm4@nowhere>2019-10-20 16:16:28 +0200
commitf23e663a21829356e966f6f815dd3372462084a1 (patch)
tree5b0f4a528aff813475903ca245013dfcaa3851b2
parent577c00510b7d42b209a51be60c135eec73b60015 (diff)
downloadmpv-f23e663a21829356e966f6f815dd3372462084a1.tar.bz2
mpv-f23e663a21829356e966f6f815dd3372462084a1.tar.xz
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.
-rw-r--r--video/zimg.c22
1 files changed, 22 insertions, 0 deletions
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.)