diff options
author | wm4 <wm4@nowhere> | 2020-05-18 00:24:31 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-18 01:54:59 +0200 |
commit | 27e5416c124884758bb206bb5948221a5f00f87d (patch) | |
tree | 3c5a8bae440f24a83171439738490a5153900918 /test/img_format.c | |
parent | caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce (diff) | |
download | mpv-27e5416c124884758bb206bb5948221a5f00f87d.tar.bz2 mpv-27e5416c124884758bb206bb5948221a5f00f87d.tar.xz |
video: add pixel component location metadata
I thought I'd probably want something like this, so the hardcoded stuff
in repack.c can be removed eventually. Of course this has no purpose at
all, and will not have any. (For now, this provides only metadata, and
nothing uses it, apart from the "test" that dumps it as text.)
This adds full support for AV_PIX_FMT_UYYVYY411 (probably out of spite,
because the format is 100% useless). Support for some mpv-only formats
is missing, ironically.
The code goes through _lengths_ to try to make sense out of the FFmpeg
AVPixFmtDescriptor data. Which is even more amazing that the new
metadata basically mirrors pixdesc, and just adds to it. Considering
code complexity and speed issues (it takes time to crunch through all
this shit all the time), and especially the fact that pixdesc is very
_incomplete_, it would probably better to have our own table to all
formats. But then we'd not scramble every time FFmpeg adds a new format,
which would be annoying. On the other hand, by using pixdesc, we get the
excitement to see whether this code will work, or break everything in
catastrophic ways.
The data structure still sucks a lot. Maybe I'll redo it again. The text
dump is weirdly differently formatted than the C struct - because I'm
not happy with the representation. Maybe I'll redo it all over again.
In summary: this commit does nothing.
Diffstat (limited to 'test/img_format.c')
-rw-r--r-- | test/img_format.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/img_format.c b/test/img_format.c index 9cd8186ab6..02bda18bd4 100644 --- a/test/img_format.c +++ b/test/img_format.c @@ -110,6 +110,39 @@ static void run(struct test_ctx *ctx) fprintf(f, " [NODESC]\n"); } + struct mp_imgfmt_layout pd; + mp_imgfmt_get_layout(mpfmt, &pd); + + for (int n = 0; n < d.num_planes; n++) { + fprintf(f, " %d: %dbits", n, pd.bits[n]); + if (pd.extra_w) + fprintf(f, " w=%d", pd.extra_w + 1); + if (pd.endian_bytes) + fprintf(f, " endian_bytes=%d", pd.endian_bytes); + for (int x = 0; x < MP_NUM_COMPONENTS; x++) { + struct mp_imgfmt_comp_desc cm = pd.comps[x]; + fprintf(f, " {"); + if (cm.plane == n) { + if (cm.size) { + fprintf(f, "%d:%d", cm.offset, cm.size); + if (cm.pad) + fprintf(f, "/%d", cm.pad); + } else { + assert(cm.offset == 0); + assert(cm.pad == 0); + } + } + fprintf(f, "}"); + } + fprintf(f, "\n"); + if (pd.extra_w) { + fprintf(f, " extra_luma_offsets=["); + for (int x = 0; x < pd.extra_w; x++) + fprintf(f, " %d", pd.extra_luma_offsets[x]); + fprintf(f, "]\n"); + } + } + if (!(d.flags & MP_IMGFLAG_HWACCEL) && pixfmt != AV_PIX_FMT_NONE) { AVFrame *fr = av_frame_alloc(); fr->format = pixfmt; |