From a8b84c9a1a8cfe6e08d8de183133f96511d9a32a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 12 Apr 2020 22:14:55 +0200 Subject: 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*). --- test/ref/repack_zimg.log | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/ref/repack_zimg.log b/test/ref/repack_zimg.log index de2dd610e2..2f5a7e98f8 100644 --- a/test/ref/repack_zimg.log +++ b/test/ref/repack_zimg.log @@ -5,10 +5,14 @@ argb using gbrap bgr0 using gbrp bgr24 using gbrp bgr48 using gbrp16 +bgr48be using gbrp16 bgra using gbrap bgra64 using gbrap16 +bgra64be using gbrap16 rgb0 using gbrp rgb24 using gbrp rgb48 using gbrp16 +rgb48be using gbrp16 rgba using gbrap rgba64 using gbrap16 +rgba64be using gbrap16 -- cgit v1.2.3