diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:36:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:36:56 +0000 |
commit | 51de1d8436100f725f3576aefa24a2bd2057bc28 (patch) | |
tree | c6d1d5264b6d40a8d7ca34129f36b7d61e188af3 /video/repack.h | |
parent | Initial commit. (diff) | |
download | mpv-51de1d8436100f725f3576aefa24a2bd2057bc28.tar.xz mpv-51de1d8436100f725f3576aefa24a2bd2057bc28.zip |
Adding upstream version 0.37.0.upstream/0.37.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'video/repack.h')
-rw-r--r-- | video/repack.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/video/repack.h b/video/repack.h new file mode 100644 index 0000000..7afe7ed --- /dev/null +++ b/video/repack.h @@ -0,0 +1,76 @@ +#pragma once + +#include <stdbool.h> + +enum { + // This controls bheavior with different bit widths per component (like + // RGB565). If ROUND_DOWN is specified, the planar format will use the min. + // bit width of all components, otherwise the transformation is lossless. + REPACK_CREATE_ROUND_DOWN = (1 << 0), + + // Expand some (not all) low bit depth fringe formats to 8 bit on unpack. + REPACK_CREATE_EXPAND_8BIT = (1 << 1), + + // For mp_repack_create_planar(). If specified, the planar format uses a + // float 32 bit sample format. No range expansion is done. + REPACK_CREATE_PLANAR_F32 = (1 << 2), +}; + +struct mp_repack; +struct mp_image; + +// Create a repacker between any format (imgfmt parameter) and an equivalent +// planar format (that is native endian). If pack==true, imgfmt is the output, +// otherwise it is the input. The respective other input/output is the planar +// format. The planar format can be queried with mp_repack_get_format_*(). +// Note that some formats may change the "implied" colorspace (for example, +// packed xyz unpacks as rgb). +// If imgfmt is already planar, a passthrough repacker may be created. +// imgfmt: src or dst format (usually packed, non-planar, etc.) +// pack: true if imgfmt is dst, false if imgfmt is src +// flags: any of REPACK_CREATE_* flags +// returns: NULL on failure, otherwise free with talloc_free(). +struct mp_repack *mp_repack_create_planar(int imgfmt, bool pack, int flags); + +// Return input and output formats for which rp was created. +int mp_repack_get_format_src(struct mp_repack *rp); +int mp_repack_get_format_dst(struct mp_repack *rp); + +// Return pixel alignment. For x, this is a lowest pixel count at which there is +// a byte boundary and a full chroma pixel (horizontal subsampling) on src/dst. +// For y, this is the pixel height of the vertical subsampling. +// Always returns a power of 2. +int mp_repack_get_align_x(struct mp_repack *rp); +int mp_repack_get_align_y(struct mp_repack *rp); + +// Repack a single line from dst to src, as set in repack_config_buffers(). +// For subsampled chroma formats, this copies as many luma/alpha rows as needed +// for a complete line (e.g. 2 luma lines, 1 chroma line for 4:2:0). +// dst_x, src_x, y must be aligned to the pixel alignment. w may be unaligned +// if at the right crop-border of the image, but must be always aligned to +// horiz. sub-sampling. y is subject to hslice. +void repack_line(struct mp_repack *rp, int dst_x, int dst_y, + int src_x, int src_y, int w); + +// Configure with a source and target buffer. The rp instance will keep the +// mp_image pointers and access them on repack_line() calls. Refcounting is +// not respected - the caller needs to make sure dst is always writable. +// The images can have different sizes (as repack_line() lets you use different +// target coordinates for dst/src). +// This also allocaters potentially required temporary buffers. +// dst_flags: REPACK_BUF_* flags for dst +// dst: where repack_line() writes to +// src_flags: REPACK_BUF_* flags for src +// src: where repack_line() reads from +// enable_passthrough: if non-NULL, an bool array of size MP_MAX_PLANES indexed +// by plane; a true entry requests disabling copying the +// plane data to the dst plane. The function will write to +// this array whether the plane can really be passed through +// (i.e. will set array entries from true to false if pass- +// through is not possible). It writes to all MP_MAX_PLANES +// entries. If NULL, all entries are implicitly false. +// returns: success (fails on OOM) +bool repack_config_buffers(struct mp_repack *rp, + int dst_flags, struct mp_image *dst, + int src_flags, struct mp_image *src, + bool *enable_passthrough); |