diff options
author | wm4 <wm4@nowhere> | 2019-10-20 19:39:59 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-10-20 19:41:18 +0200 |
commit | 525e712757c8cc5c61f3eeb23234f9264fcb8a2c (patch) | |
tree | 07ed25ebfa16231fd1abe220c348ab3e7de3113c /video/zimg.c | |
parent | 631379bea9a6f490f221a1326b1fe674e2651203 (diff) | |
download | mpv-525e712757c8cc5c61f3eeb23234f9264fcb8a2c.tar.bz2 mpv-525e712757c8cc5c61f3eeb23234f9264fcb8a2c.tar.xz |
zimg: support RGB30 output
This may be used later elsewhere.
Diffstat (limited to 'video/zimg.c')
-rw-r--r-- | video/zimg.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/video/zimg.c b/video/zimg.c index fcd1034cd0..32e9d88f23 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -268,6 +268,17 @@ static void ccc16_unpack(void *src, void *dst[], int x0, int x1) } } +// 3 10 bit color components source from 3 planes, plus 2 MSB padding bits. +static void x2ccc10_pack(void *dst, void *src[], int x0, int x1) +{ + for (int x = x0; x < x1; x++) { + ((uint32_t *)dst)[x] = + ((uint16_t *)src[0])[x] | + ((uint32_t)((uint16_t *)src[1])[x] << 10) | + ((uint32_t)((uint16_t *)src[2])[x] << 20); + } +} + static int packed_repack(void *user, unsigned i, unsigned x0, unsigned x1) { struct mp_zimg_repack *r = user; @@ -320,6 +331,21 @@ static void wrap_buffer(struct mp_zimg_repack *r, r->mpi = mpi; } +static void setup_misc_packer(struct mp_zimg_repack *r) +{ + if (r->zimgfmt == IMGFMT_RGB30) { + int planar_fmt = mp_imgfmt_find(0, 0, 3, 10, MP_IMGFLAG_RGB_P); + if (!planar_fmt || !r->pack) + return; + r->zimgfmt = planar_fmt; + r->repack = packed_repack; + r->packed_repack_scanline = x2ccc10_pack; + static int c_order[] = {3, 2, 1}; + for (int n = 0; n < 3; n++) + r->components[n] = corder_gbrp[c_order[n]]; + } +} + // Tries to set a packer/unpacker for component-wise byte aligned RGB formats. static void setup_regular_rgb_packer(struct mp_zimg_repack *r) { @@ -394,7 +420,10 @@ static bool setup_format(zimg_image_format *zfmt, struct mp_zimg_repack *r, r->zimgfmt = fmt.imgfmt; - setup_regular_rgb_packer(r); + if (!r->repack) + setup_misc_packer(r); + if (!r->repack) + setup_regular_rgb_packer(r); struct mp_regular_imgfmt desc; if (!mp_get_regular_imgfmt(&desc, r->zimgfmt)) |