summaryrefslogtreecommitdiffstats
path: root/video/img_format.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-06-29 20:51:37 +0200
committerwm4 <wm4@nowhere>2017-06-29 20:52:05 +0200
commit1dffcb01678c20294fa60a0402b02acaeab65606 (patch)
treed2ab7190c8a4305c741c81fb81ca0ec9060995e5 /video/img_format.h
parent016c9a1d8f1fe2078d3aa1d6d4ebb31616e10f09 (diff)
downloadmpv-1dffcb01678c20294fa60a0402b02acaeab65606.tar.bz2
mpv-1dffcb01678c20294fa60a0402b02acaeab65606.tar.xz
vo_opengl: rely on FFmpeg pixdesc a bit more
Add something that allows is to extract the component order from various RGBA formats. In fact, also handle YUV, GBRP, and XYZ formats with this. It introduces a new struct mp_regular_imgfmt, that hopefully will eventually replace struct mp_imgfmt_desc. The latter is still needed by a lot of code though, especially generic code. Also vo_opengl still uses the old one, so this commit is sort of incomplete. Due to its genericness, it's also possible that this commit introduces rendering bugs, or accepts formats it shouldn't accept.
Diffstat (limited to 'video/img_format.h')
-rw-r--r--video/img_format.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/video/img_format.h b/video/img_format.h
index 11d3fc92b8..3411bd0b2c 100644
--- a/video/img_format.h
+++ b/video/img_format.h
@@ -22,6 +22,7 @@
#include "osdep/endian.h"
#include "misc/bstr.h"
+#include "video/csputils.h"
#if BYTE_ORDER == BIG_ENDIAN
#define MP_SELECT_LE_BE(LE, BE) BE
@@ -101,6 +102,38 @@ struct mp_imgfmt_desc {
struct mp_imgfmt_desc mp_imgfmt_get_desc(int imgfmt);
+// MP_CSP_AUTO for YUV, MP_CSP_RGB or MP_CSP_XYZ otherwise.
+// (Because IMGFMT/AV_PIX_FMT conflate format and csp for RGB and XYZ.)
+enum mp_csp mp_imgfmt_get_forced_csp(int imgfmt);
+
+#define MP_NUM_COMPONENTS 4
+
+struct mp_regular_imgfmt_plane {
+ uint8_t num_components;
+ // 1 is luminance/red/gray, 2 is green/Cb, 3 is blue/Cr, 4 is alpha.
+ // 0 is used for padding (undefined contents).
+ uint8_t components[MP_NUM_COMPONENTS];
+};
+
+// This describes pixel formats that are byte aligned, have byte aligned
+// components, native endian, etc.
+struct mp_regular_imgfmt {
+ // Size of each component in bytes.
+ uint8_t component_size;
+
+ // If >0, LSB padding, if <0, MSB padding. The padding bits are always 0.
+ // This applies: bit_depth = component_size * 8 - abs(component_pad)
+ int8_t component_pad;
+
+ uint8_t num_planes;
+ struct mp_regular_imgfmt_plane planes[MP_MAX_PLANES];
+
+ // Chroma pixel size (1x1 is 4:4:4)
+ uint8_t chroma_w, chroma_h;
+};
+
+bool mp_get_regular_imgfmt(struct mp_regular_imgfmt *dst, int imgfmt);
+
enum mp_imgfmt {
IMGFMT_NONE = 0,