mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 01:31:03 +00:00
video-format: Fix up video formats ordering by quality
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5412>
This commit is contained in:
parent
abdd1967ad
commit
510f71fbe4
3 changed files with 40 additions and 23 deletions
|
@ -60,6 +60,10 @@ def parse_format_from_c(token, filename):
|
||||||
|
|
||||||
|
|
||||||
def score_endian(fmt, endian):
|
def score_endian(fmt, endian):
|
||||||
|
native_endianness = [GstVideo.VideoFormat.ARGB64, GstVideo.VideoFormat.AYUV64]
|
||||||
|
if fmt.format in native_endianness:
|
||||||
|
return -1
|
||||||
|
|
||||||
score = 0
|
score = 0
|
||||||
if fmt.flags & GstVideo.VideoFormatFlags.LE:
|
if fmt.flags & GstVideo.VideoFormatFlags.LE:
|
||||||
score = 1
|
score = 1
|
||||||
|
@ -69,6 +73,17 @@ def score_endian(fmt, endian):
|
||||||
return score
|
return score
|
||||||
|
|
||||||
|
|
||||||
|
def score_pixel_stride(fmt):
|
||||||
|
# Prefer power-of-two strides over odd ones, e.g. xRGB over RGB
|
||||||
|
def scale_non_power_of_two(x):
|
||||||
|
if (x & (x - 1) == 0) and x != 0:
|
||||||
|
return x
|
||||||
|
else:
|
||||||
|
return x * 100
|
||||||
|
|
||||||
|
return [scale_non_power_of_two(x) for x in fmt.pixel_stride]
|
||||||
|
|
||||||
|
|
||||||
def sort_video_formats(formats, endian):
|
def sort_video_formats(formats, endian):
|
||||||
return sorted(formats, key=lambda x: (-x.n_components,
|
return sorted(formats, key=lambda x: (-x.n_components,
|
||||||
[-d for d in x.depth],
|
[-d for d in x.depth],
|
||||||
|
@ -76,9 +91,11 @@ def sort_video_formats(formats, endian):
|
||||||
x.h_sub,
|
x.h_sub,
|
||||||
-x.n_planes,
|
-x.n_planes,
|
||||||
score_endian(x, endian),
|
score_endian(x, endian),
|
||||||
[-s for s in x.pixel_stride],
|
|
||||||
(x.flags & GstVideo.VideoFormatFlags.COMPLEX),
|
(x.flags & GstVideo.VideoFormatFlags.COMPLEX),
|
||||||
not (x.flags & GstVideo.VideoFormatFlags.YUV),
|
not (x.flags & GstVideo.VideoFormatFlags.YUV),
|
||||||
|
score_pixel_stride(x),
|
||||||
|
[s for s in x.pixel_stride],
|
||||||
|
[o for o in x.poffset],
|
||||||
x.name))
|
x.name))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,12 @@ G_BEGIN_DECLS
|
||||||
* Since: 1.24
|
* Since: 1.24
|
||||||
*/
|
*/
|
||||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
#define GST_WL_VIDEO_FORMATS "{ AYUV, ABGR, ARGB, BGRA, RGBA, P010_10LE, BGRx, " \
|
#define GST_WL_VIDEO_FORMATS "{ AYUV, RGBA, ARGB, BGRA, ABGR, P010_10LE, v308, " \
|
||||||
"RGBx, xBGR, xRGB, v308, BGR, RGB, Y42B, NV16, NV61, UYVY, YUY2, YVYU, " \
|
"RGBx, xRGB, BGRx, xBGR, RGB, BGR, Y42B, NV16, NV61, YUY2, YVYU, UYVY, " \
|
||||||
"I420, YV12, NV12, NV21, Y41B, YUV9, YVU9, BGR16, RGB16 }"
|
"I420, YV12, NV12, NV21, Y41B, YUV9, YVU9, BGR16, RGB16 }"
|
||||||
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
#define GST_WL_VIDEO_FORMATS "{ AYUV, ABGR, ARGB, BGRA, RGBA, P010_10LE, BGRx, " \
|
#define GST_WL_VIDEO_FORMATS "{ AYUV, RGBA, ARGB, BGRA, ABGR, P010_10LE, v308, " \
|
||||||
"RGBx, xBGR, xRGB, v308, BGR, RGB, Y42B, NV16, NV61, UYVY, YUY2, YVYU, " \
|
"RGBx, xRGB, BGRx, xBGR, RGB, BGR, Y42B, NV16, NV61, YUY2, YVYU, UYVY, " \
|
||||||
"I420, YV12, NV12, NV21, Y41B, YUV9, YVU9, BGR16, RGB16 }"
|
"I420, YV12, NV12, NV21, Y41B, YUV9, YVU9, BGR16, RGB16 }"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1077,40 +1077,40 @@ gconstpointer gst_video_format_get_palette (GstVideoFormat format, gsi
|
||||||
* Since: 1.24
|
* Since: 1.24
|
||||||
*/
|
*/
|
||||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||||
#define GST_VIDEO_FORMATS_ALL_STR "A444_16BE, A444_16LE, ABGR64_BE, ARGB64_BE, " \
|
#define GST_VIDEO_FORMATS_ALL_STR "A444_16BE, A444_16LE, AYUV64, ARGB64, " \
|
||||||
"BGRA64_BE, RGBA64_BE, AYUV64, ABGR64_LE, ARGB64, ARGB64_LE, BGRA64_LE, " \
|
"RGBA64_BE, ARGB64_BE, BGRA64_BE, ABGR64_BE, RGBA64_LE, ARGB64_LE, " \
|
||||||
"RGBA64_LE, A422_16BE, A422_16LE, A420_16BE, A420_16LE, A444_12BE, " \
|
"BGRA64_LE, ABGR64_LE, A422_16BE, A422_16LE, A420_16BE, A420_16LE, " \
|
||||||
"GBRA_12BE, A444_12LE, GBRA_12LE, Y412_BE, Y412_LE, A422_12BE, A422_12LE, " \
|
"A444_12BE, GBRA_12BE, A444_12LE, GBRA_12LE, Y412_BE, Y412_LE, A422_12BE, " \
|
||||||
"A420_12BE, A420_12LE, A444_10BE, GBRA_10BE, A444_10LE, GBRA_10LE, " \
|
"A422_12LE, A420_12BE, A420_12LE, A444_10BE, GBRA_10BE, A444_10LE, " \
|
||||||
"A422_10BE, A422_10LE, A420_10BE, A420_10LE, Y410, BGR10A2_LE, RGB10A2_LE, " \
|
"GBRA_10LE, A422_10BE, A422_10LE, A420_10BE, A420_10LE, Y410, BGR10A2_LE, " \
|
||||||
"A444, GBRA, AYUV, VUYA, ABGR, ARGB, BGRA, RGBA, A422, A420, AV12, " \
|
"RGB10A2_LE, A444, GBRA, AYUV, VUYA, RGBA, ARGB, BGRA, ABGR, A422, A420, " \
|
||||||
"Y444_16BE, GBR_16BE, Y444_16LE, GBR_16LE, v216, P016_BE, P016_LE, " \
|
"AV12, Y444_16BE, GBR_16BE, Y444_16LE, GBR_16LE, v216, P016_BE, P016_LE, " \
|
||||||
"Y444_12BE, GBR_12BE, Y444_12LE, GBR_12LE, I422_12BE, I422_12LE, Y212_BE, " \
|
"Y444_12BE, GBR_12BE, Y444_12LE, GBR_12LE, I422_12BE, I422_12LE, Y212_BE, " \
|
||||||
"Y212_LE, I420_12BE, I420_12LE, P012_BE, P012_LE, Y444_10BE, GBR_10BE, " \
|
"Y212_LE, I420_12BE, I420_12LE, P012_BE, P012_LE, Y444_10BE, GBR_10BE, " \
|
||||||
"Y444_10LE, GBR_10LE, r210, I422_10BE, I422_10LE, NV16_10LE32, Y210, UYVP, " \
|
"Y444_10LE, GBR_10LE, r210, I422_10BE, I422_10LE, NV16_10LE32, Y210, UYVP, " \
|
||||||
"v210, I420_10BE, I420_10LE, P010_10BE, MT2110R, MT2110T, NV12_10BE_8L128, " \
|
"v210, I420_10BE, I420_10LE, P010_10BE, MT2110R, MT2110T, NV12_10BE_8L128, " \
|
||||||
"NV12_10LE40_4L4, P010_10LE, NV12_10LE32, NV12_10LE40, Y444, BGRP, GBR, " \
|
"NV12_10LE40_4L4, P010_10LE, NV12_10LE40, NV12_10LE32, Y444, BGRP, GBR, " \
|
||||||
"RGBP, NV24, BGRx, RGBx, xBGR, xRGB, IYU2, v308, BGR, RGB, Y42B, NV16, " \
|
"RGBP, NV24, v308, IYU2, RGBx, xRGB, BGRx, xBGR, RGB, BGR, Y42B, NV16, " \
|
||||||
"NV61, UYVY, VYUY, YUY2, YVYU, I420, YV12, NV12, NV21, NV12_16L32S, " \
|
"NV61, YUY2, YVYU, UYVY, VYUY, I420, YV12, NV12, NV21, NV12_16L32S, " \
|
||||||
"NV12_32L32, NV12_4L4, NV12_64Z32, NV12_8L128, Y41B, IYU1, YUV9, YVU9, " \
|
"NV12_32L32, NV12_4L4, NV12_64Z32, NV12_8L128, Y41B, IYU1, YUV9, YVU9, " \
|
||||||
"BGR16, RGB16, BGR15, RGB15, RGB8P, GRAY16_BE, GRAY16_LE, GRAY10_LE32, " \
|
"BGR16, RGB16, BGR15, RGB15, RGB8P, GRAY16_BE, GRAY16_LE, GRAY10_LE32, " \
|
||||||
"GRAY8"
|
"GRAY8"
|
||||||
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
#define GST_VIDEO_FORMATS_ALL_STR "A444_16LE, A444_16BE, AYUV64, ABGR64_LE, " \
|
#define GST_VIDEO_FORMATS_ALL_STR "A444_16LE, A444_16BE, AYUV64, RGBA64_LE, " \
|
||||||
"ARGB64, ARGB64_LE, BGRA64_LE, RGBA64_LE, ABGR64_BE, ARGB64_BE, BGRA64_BE, " \
|
"ARGB64, ARGB64_LE, BGRA64_LE, ABGR64_LE, RGBA64_BE, ARGB64_BE, BGRA64_BE, " \
|
||||||
"RGBA64_BE, A422_16LE, A422_16BE, A420_16LE, A420_16BE, A444_12LE, " \
|
"ABGR64_BE, A422_16LE, A422_16BE, A420_16LE, A420_16BE, A444_12LE, " \
|
||||||
"GBRA_12LE, A444_12BE, GBRA_12BE, Y412_LE, Y412_BE, A422_12LE, A422_12BE, " \
|
"GBRA_12LE, A444_12BE, GBRA_12BE, Y412_LE, Y412_BE, A422_12LE, A422_12BE, " \
|
||||||
"A420_12LE, A420_12BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, " \
|
"A420_12LE, A420_12BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, " \
|
||||||
"A422_10LE, A422_10BE, A420_10LE, A420_10BE, BGR10A2_LE, RGB10A2_LE, Y410, " \
|
"A422_10LE, A422_10BE, A420_10LE, A420_10BE, BGR10A2_LE, RGB10A2_LE, Y410, " \
|
||||||
"A444, GBRA, AYUV, VUYA, ABGR, ARGB, BGRA, RGBA, A422, A420, AV12, " \
|
"A444, GBRA, AYUV, VUYA, RGBA, ARGB, BGRA, ABGR, A422, A420, AV12, " \
|
||||||
"Y444_16LE, GBR_16LE, Y444_16BE, GBR_16BE, v216, P016_LE, P016_BE, " \
|
"Y444_16LE, GBR_16LE, Y444_16BE, GBR_16BE, v216, P016_LE, P016_BE, " \
|
||||||
"Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, " \
|
"Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, " \
|
||||||
"Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, " \
|
"Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, " \
|
||||||
"Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, UYVP, " \
|
"Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, UYVP, " \
|
||||||
"v210, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, " \
|
"v210, I420_10LE, I420_10BE, P010_10LE, NV12_10LE40, NV12_10LE32, " \
|
||||||
"P010_10BE, MT2110R, MT2110T, NV12_10BE_8L128, NV12_10LE40_4L4, Y444, " \
|
"P010_10BE, MT2110R, MT2110T, NV12_10BE_8L128, NV12_10LE40_4L4, Y444, " \
|
||||||
"BGRP, GBR, RGBP, NV24, BGRx, RGBx, xBGR, xRGB, IYU2, v308, BGR, RGB, " \
|
"BGRP, GBR, RGBP, NV24, v308, IYU2, RGBx, xRGB, BGRx, xBGR, RGB, BGR, " \
|
||||||
"Y42B, NV16, NV61, UYVY, VYUY, YUY2, YVYU, I420, YV12, NV12, NV21, " \
|
"Y42B, NV16, NV61, YUY2, YVYU, UYVY, VYUY, I420, YV12, NV12, NV21, " \
|
||||||
"NV12_16L32S, NV12_32L32, NV12_4L4, NV12_64Z32, NV12_8L128, Y41B, IYU1, " \
|
"NV12_16L32S, NV12_32L32, NV12_4L4, NV12_64Z32, NV12_8L128, Y41B, IYU1, " \
|
||||||
"YUV9, YVU9, BGR16, RGB16, BGR15, RGB15, RGB8P, GRAY16_LE, GRAY16_BE, " \
|
"YUV9, YVU9, BGR16, RGB16, BGR15, RGB15, RGB8P, GRAY16_LE, GRAY16_BE, " \
|
||||||
"GRAY10_LE32, GRAY8"
|
"GRAY10_LE32, GRAY8"
|
||||||
|
|
Loading…
Reference in a new issue