diff options
author | wm4 <wm4@nowhere> | 2020-05-17 14:57:13 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-18 01:54:59 +0200 |
commit | caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce (patch) | |
tree | 492d46f6ab40eee4c5b3e17b3666d21843db4166 /video/image_writer.c | |
parent | 00ac63c37b18ef3e7fbe5c227eb10073b264a26a (diff) | |
download | mpv-caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce.tar.bz2 mpv-caee8748da5c25b928f699bfa9f1ac4a5f3ae0ce.tar.xz |
video: clean up some imgfmt related stuff
Remove the vaguely defined plane_bits and component_bits fields from
struct mp_imgfmt_desc. Add weird replacements for existing uses. Remove
the bytes[] field, replace uses with bpp[].
Fix some potential alignment issues in existing code. As a compromise,
split mp_image_pixel_ptr() into 2 functions, because I think it's a bad
idea to implicitly round, but for some callers being slightly less
strict is convenient.
This shouldn't really change anything. In fact, it's a 100% useless
change. I'm just cleaning up what I started almost 8 years ago (see
commit 00653a3eb052). With this I've decided to keep mp_imgfmt_desc,
just removing the weird parts, and keeping the saner parts.
Diffstat (limited to 'video/image_writer.c')
-rw-r--r-- | video/image_writer.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/video/image_writer.c b/video/image_writer.c index 8c3cf98d19..fb297f9c0f 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -259,9 +259,17 @@ static int get_encoder_format(struct AVCodec *codec, int srcfmt, bool highdepth) int fmt = pixfmt2imgfmt(pix_fmts[n]); if (!fmt) continue; - // Ignore formats larger than 8 bit per pixel. - if (!highdepth && IMGFMT_RGB_DEPTH(fmt) > 32) - continue; + if (!highdepth) { + // Ignore formats larger than 8 bit per pixel. (Or which are unknown.) + struct mp_regular_imgfmt rdesc; + if (!mp_get_regular_imgfmt(&rdesc, fmt)) { + int ofmt = mp_find_other_endian(fmt); + if (!mp_get_regular_imgfmt(&rdesc, ofmt)) + continue; + } + if (rdesc.component_size > 1) + continue; + } current = current ? mp_imgfmt_select_best(current, fmt, srcfmt) : fmt; } return current; |