Skip to content

Commit 7aa204d

Browse files
committed
from_lavc_pf_priority: fine-grain selection
If there is no direct conversion from a AV PF compatible with internal format, penalize a bit. This may be mostly unneeded but just in case. It can be safely reverted, anyways.
1 parent 647d862 commit 7aa204d

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/libavcodec/from_lavc_vid_conv.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,10 +3175,19 @@ from_lavc_pf_priority(struct pixfmt_desc internal, codec_t ugc)
31753175
if (internal.depth == 0) { // unspecified internal format
31763176
return VDEC_PRIO_LOW;
31773177
}
3178-
/// @todo what about returning lower prio if
3179-
/// !pixdesc_equals(av_pixfmt_get_desc(av_to_uv_conversion.av_codec),
3180-
/// internal)
3181-
return VDEC_PRIO_NORMAL;
3178+
for (unsigned i = 0; i < ARR_COUNT(av_to_uv_conversions); i++) {
3179+
if (av_to_uv_conversions[i].uv_codec != ugc) {
3180+
continue;
3181+
}
3182+
if (pixdesc_equals(
3183+
av_pixfmt_get_desc(av_to_uv_conversions[i].av_codec),
3184+
internal)) {
3185+
// conv from AV PF with same props as internal
3186+
return VDEC_PRIO_NORMAL;
3187+
}
3188+
}
3189+
// the conversion may be not direct but over intermediate UG codec_t
3190+
return VDEC_PRIO_NOT_PREFERRED;
31823191
}
31833192

31843193
#pragma GCC diagnostic pop

src/video_decompress.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @brief API for video decompress drivers
77
*/
88
/*
9-
* Copyright (c) 2011-2019 CESNET, z. s. p. o.
9+
* Copyright (c) 2011-2025 CESNET
1010
* All rights reserved.
1111
*
1212
* Redistribution and use in source and binary forms, with or without
@@ -141,11 +141,8 @@ enum vdec_priority {
141141
VDEC_PRIO_NORMAL = 500, ///< decoder can decode the given properties but
142142
///< is not dedicated (lavd)
143143
VDEC_PRIO_NOT_PREFERRED =
144-
800, ///< decoder can decode given properties but the decode
145-
///< is suboptimal (like color space conversion)
146-
///< @todo consider removing this - as this is after
147-
///< probe, the CS conv will be needed for all
148-
///< decoders (so it will not differentiate)
144+
800, ///< decoder can perhaps decode given properties but the decode
145+
///< may be is suboptimal (not efficient PF conversion or so)
149146
VDEC_PRIO_LOW = 900, ///< the decoder is unsure if it can decode the
150147
///< stream (eg. unknown properties)
151148
};

0 commit comments

Comments
 (0)