diff options
author | rcombs <rcombs@rcombs.me> | 2021-12-23 03:19:11 -0600 |
---|---|---|
committer | rcombs <rcombs@rcombs.me> | 2022-01-04 20:01:10 -0600 |
commit | a5f1f0558f07d7464faa4d8ede976c5043219932 (patch) | |
tree | ee77c5f8848c0c72f8fb40d49634a810c31d9953 | |
parent | ff9bb93145e8098c1c8d494f3b85a5a0b6bb7467 (diff) | |
download | ffmpeg-a5f1f0558f07d7464faa4d8ede976c5043219932.tar.gz |
swscale: introduce isDataInHighBits
-rw-r--r-- | libswscale/swscale_internal.h | 19 | ||||
-rw-r--r-- | libswscale/tests/pixdesc_query.c | 1 | ||||
-rw-r--r-- | tests/ref/fate/sws-pixdesc-query | 12 |
3 files changed, 32 insertions, 0 deletions
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 64aa0b9804..b4acaceebd 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -892,6 +892,25 @@ static av_always_inline int usePal(enum AVPixelFormat pix_fmt) } } +/* + * Identity formats where the data is in the high bits, and the low bits are shifted away. + */ +static av_always_inline int isDataInHighBits(enum AVPixelFormat pix_fmt) +{ + int i; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); + av_assert0(desc); + if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL)) + return 0; + for (i = 0; i < desc->nb_components; i++) { + if (!desc->comp[i].shift) + return 0; + if ((desc->comp[i].shift + desc->comp[i].depth) & 0x7) + return 0; + } + return 1; +} + extern const uint64_t ff_dither4[2]; extern const uint64_t ff_dither8[2]; diff --git a/libswscale/tests/pixdesc_query.c b/libswscale/tests/pixdesc_query.c index f6dd8bae68..dce2e50577 100644 --- a/libswscale/tests/pixdesc_query.c +++ b/libswscale/tests/pixdesc_query.c @@ -45,6 +45,7 @@ static const struct { {"PackedRGB", isPackedRGB}, {"PlanarRGB", isPlanarRGB}, {"usePal", usePal}, + {"DataInHighBits", isDataInHighBits}, }; static int cmp_str(const void *a, const void *b) diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index 553c039061..a17284784f 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -952,3 +952,15 @@ usePal: rgb4_byte rgb8 +DataInHighBits: + p010be + p010le + p210be + p210le + p410be + p410le + xyz12be + xyz12le + y210be + y210le + |