@@ -438,34 +438,8 @@ static int libavcodec_decompress_reconfigure(void *state, struct video_desc desc
438438}
439439
440440static bool has_conversion (enum AVPixelFormat pix_fmt , codec_t * ug_pix_fmt ) {
441- {
442- codec_t mapped_pix_fmt = get_av_to_ug_pixfmt (pix_fmt );
443- if (mapped_pix_fmt != VIDEO_CODEC_NONE ) {
444- * ug_pix_fmt = mapped_pix_fmt ;
445- return true;
446- }
447- }
448-
449- for (const struct av_to_uv_conversion * c = get_av_to_uv_conversions (); c -> uv_codec != VIDEO_CODEC_NONE ; c ++ ) {
450- if (c -> av_codec != pix_fmt ) { // this conversion is not valid
451- continue ;
452- }
453-
454- if (c -> native ) {
455- * ug_pix_fmt = c -> uv_codec ;
456- return true;
457- }
458- }
459-
460- for (const struct av_to_uv_conversion * c = get_av_to_uv_conversions (); c -> uv_codec != VIDEO_CODEC_NONE ; c ++ ) {
461- if (c -> av_codec != pix_fmt ) { // this conversion is not valid
462- continue ;
463- }
464-
465- * ug_pix_fmt = c -> uv_codec ;
466- return true;
467- }
468- return false;
441+ enum AVPixelFormat fmt [2 ] = { pix_fmt };
442+ return (* ug_pix_fmt = get_best_ug_codec_to_av (fmt , true)) != VIDEO_CODEC_NONE ;
469443}
470444
471445#ifdef HWACC_RPI4
@@ -724,8 +698,6 @@ static void parallel_convert(av_to_uv_convert_p convert, char *dst, AVFrame *in,
724698 */
725699static int change_pixfmt (AVFrame * frame , unsigned char * dst , int av_codec , codec_t out_codec , int width , int height ,
726700 int pitch , int rgb_shift [static restrict 3 ], struct state_libavcodec_decompress_sws * sws ) {
727- av_to_uv_convert_p convert = NULL ;
728-
729701 debug_file_dump ("lavd-avframe" , serialize_video_avframe , frame );
730702
731703 if (get_av_to_ug_pixfmt (av_codec ) == out_codec ) {
@@ -737,11 +709,7 @@ static int change_pixfmt(AVFrame *frame, unsigned char *dst, int av_codec, codec
737709 return FALSE;
738710 }
739711
740- for (const struct av_to_uv_conversion * c = get_av_to_uv_conversions (); c -> uv_codec != VIDEO_CODEC_NONE ; c ++ ) {
741- if (c -> av_codec == av_codec && c -> uv_codec == out_codec ) {
742- convert = c -> convert ;
743- }
744- }
712+ av_to_uv_convert_p convert = get_av_to_uv_conversion (av_codec , out_codec );
745713
746714 if (convert ) {
747715 if (!codec_is_const_size (out_codec ))
0 commit comments