From 5722686910fdfbec36fa2b1bba002fe2c08543cb Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 22 Feb 2023 16:21:34 +0100 Subject: [PATCH] video dec: change chosen disp pixfmt from compress Use compare_pixfmt for codec sorting resulting in different selection, eg: uv -t testcard:codec=R10k -c libavcodec:encoder=libx265:yuv -d dummy:codec=decklink Used to end with v210 (compressed properties was 10-bit YUV 4:4:4; internal codec detected as Y416). Now it ends with R12L - note that this is still not optimal as it should be rather R10k. For GL it even ends up with RG48. The previous behavior can be triggered by `--conv-policy cds`. refer to GH-295 --- src/rtp/video_decoders.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index 94783b041..e73e6d4e2 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -1008,21 +1008,11 @@ static vector> video_decoder_order_output_codecs(codec_t remaining.push_back(codec); } if (comp_int_fmt != VIDEO_CODEC_NONE) { - // sort - first codec of the same color space as internal (YUV - // is implicitly !RGB), then the other - // inside those 2 groups, sort nearest higher first, then downwardly the lower bit depts sort(remaining.begin(), remaining.end(), [comp_int_fmt](const codec_t &a, const codec_t &b) { - if (codec_is_a_rgb(a) != codec_is_a_rgb(b)) { // RGB and YUV (or vice versa) - return codec_is_a_rgb(a) == codec_is_a_rgb(comp_int_fmt); - } - // either a or b is lower than comp_int_fmt bit depth - sort higher bit depth first - if (get_bits_per_component(a) < get_bits_per_component(comp_int_fmt) || - get_bits_per_component(b) < get_bits_per_component(comp_int_fmt)) { - return get_bits_per_component(a) > get_bits_per_component(b); - } - // both are equal or higher - sort lower bit depth first - return get_bits_per_component(a) < get_bits_per_component(b); - + struct pixfmt_desc src_desc = get_pixfmt_desc(comp_int_fmt); + struct pixfmt_desc desc_a = get_pixfmt_desc(a); + struct pixfmt_desc desc_b = get_pixfmt_desc(b); + return compare_pixdesc(&desc_a, &desc_b, &src_desc) < 0; }); } for (auto & c : remaining) {