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) {