diff options
author | wm4 <wm4@nowhere> | 2020-04-12 22:14:55 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-04-13 15:56:27 +0200 |
commit | a8b84c9a1a8cfe6e08d8de183133f96511d9a32a (patch) | |
tree | 365d1f0a2a3dc8fb480327f6a39fd5ef68318d8f /video/img_format.h | |
parent | c99d95ac17364c46bc161867d1102361f05a6cc5 (diff) | |
download | mpv-a8b84c9a1a8cfe6e08d8de183133f96511d9a32a.tar.bz2 mpv-a8b84c9a1a8cfe6e08d8de183133f96511d9a32a.tar.xz |
zimg: add support for big endian input and output
One of the extremely annoying dumb things in ffmpeg is that most pixel
formats are available as little endian and big endian variants. (The
sane way would be having native endian formats only.) Usually, most of
the real codecs use native formats only, while non-native formats are
used by fringe raw codecs only. But the PNG encoders and decoders
unfortunately use big endian formats, and since PNG it such a popular
format, this causes problems for us. In particular, the current zimg
wrapper will refuse to work (and mpv will fall back to sws) when writing
non-8 bit PNGs.
So add non-native endian support to zimg. This is done in a fairly
"generic" way (which means lots of potential for bugs). If input is a
"regular" format (and just byte-swapped), the rest happens
automatically, which happens to cover all interesting formats.
Some things could be more efficient; for example, unpacking is done on
the data before it's passed to the unpacker. You could make endian
swapping part of the actual unpacking process, which might be slightly
faster. You could avoid copying twice in some cases (such as when
there's no actual repacker, or if alignment needs to be corrected). But
I don't really care. It's reasonably fast for the normal case.
Not entirely sure whether this is correct. Some (but not many) formats
are covered by the tests, some I tested manually. Some I can't even
test, because libswscale doesn't support them (like nv20*).
Diffstat (limited to 'video/img_format.h')
-rw-r--r-- | video/img_format.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/video/img_format.h b/video/img_format.h index 9137457340..b5f42148ad 100644 --- a/video/img_format.h +++ b/video/img_format.h @@ -137,6 +137,10 @@ struct mp_regular_imgfmt { bool mp_get_regular_imgfmt(struct mp_regular_imgfmt *dst, int imgfmt); int mp_find_regular_imgfmt(struct mp_regular_imgfmt *src); +// If imgfmt is valid, and there exists a format that is exactly the same, but +// has inverse endianness, return this other format. Otherwise return 0. +int mp_find_other_endian(int imgfmt); + enum mp_imgfmt { IMGFMT_NONE = 0, |