From b643d8fe020c934bcc2f5f81d096be58b10bbb10 Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 27 May 2022 16:03:09 -0500 Subject: [DOM:Media] Update ffmpeg - Part 2: Add support for libavcodec 59/FFmpeg 5.0 --- dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp | 40 ++++++++++++++++------ dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp | 3 ++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp index 426e9f74b..6b54baba2 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp @@ -71,13 +71,16 @@ FFmpegLibWrapper::Link() AV_FUNC_56 = 1 << 3, AV_FUNC_57 = 1 << 4, AV_FUNC_58 = 1 << 5, + AV_FUNC_59 = 1 << 6, AV_FUNC_AVUTIL_53 = AV_FUNC_53 | AV_FUNC_AVUTIL_MASK, AV_FUNC_AVUTIL_54 = AV_FUNC_54 | AV_FUNC_AVUTIL_MASK, AV_FUNC_AVUTIL_55 = AV_FUNC_55 | AV_FUNC_AVUTIL_MASK, AV_FUNC_AVUTIL_56 = AV_FUNC_56 | AV_FUNC_AVUTIL_MASK, AV_FUNC_AVUTIL_57 = AV_FUNC_57 | AV_FUNC_AVUTIL_MASK, AV_FUNC_AVUTIL_58 = AV_FUNC_58 | AV_FUNC_AVUTIL_MASK, - AV_FUNC_AVCODEC_ALL = AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | AV_FUNC_56 | AV_FUNC_57 | AV_FUNC_58, + AV_FUNC_AVUTIL_59 = AV_FUNC_59 | AV_FUNC_AVUTIL_MASK, + AV_FUNC_AVCODEC_ALL = AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | AV_FUNC_56 | + AV_FUNC_57 | AV_FUNC_58 | AV_FUNC_59, AV_FUNC_AVUTIL_ALL = AV_FUNC_AVCODEC_ALL | AV_FUNC_AVUTIL_MASK }; @@ -100,6 +103,9 @@ FFmpegLibWrapper::Link() case 58: version = AV_FUNC_58; break; + case 59: + version = AV_FUNC_59; + break; default: FFMPEG_LOG("Unknown avcodec version"); Unlink(); @@ -129,15 +135,19 @@ FFmpegLibWrapper::Link() : LinkResult::MissingLibAVFunction; \ } - AV_FUNC(av_lockmgr_register, AV_FUNC_AVCODEC_ALL) + AV_FUNC(av_lockmgr_register, AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | + AV_FUNC_56 | AV_FUNC_57 | AV_FUNC_58) AV_FUNC(avcodec_alloc_context3, AV_FUNC_AVCODEC_ALL) AV_FUNC(avcodec_close, AV_FUNC_AVCODEC_ALL) - AV_FUNC(avcodec_decode_audio4, AV_FUNC_AVCODEC_ALL) - AV_FUNC(avcodec_decode_video2, AV_FUNC_AVCODEC_ALL) + AV_FUNC(avcodec_decode_audio4, AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | + AV_FUNC_56 | AV_FUNC_57 | AV_FUNC_58) + AV_FUNC(avcodec_decode_video2, AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | + AV_FUNC_56 | AV_FUNC_57 | AV_FUNC_58) AV_FUNC(avcodec_find_decoder, AV_FUNC_AVCODEC_ALL) AV_FUNC(avcodec_flush_buffers, AV_FUNC_AVCODEC_ALL) AV_FUNC(avcodec_open2, AV_FUNC_AVCODEC_ALL) - AV_FUNC(avcodec_register_all, AV_FUNC_AVCODEC_ALL) + AV_FUNC(avcodec_register_all, AV_FUNC_53 | AV_FUNC_54 | AV_FUNC_55 | + AV_FUNC_56 | AV_FUNC_57 | AV_FUNC_58) AV_FUNC(av_init_packet, AV_FUNC_AVCODEC_ALL) AV_FUNC(av_parser_init, AV_FUNC_AVCODEC_ALL) AV_FUNC(av_parser_close, AV_FUNC_AVCODEC_ALL) @@ -145,19 +155,27 @@ FFmpegLibWrapper::Link() AV_FUNC(avcodec_alloc_frame, (AV_FUNC_53 | AV_FUNC_54)) AV_FUNC(avcodec_get_frame_defaults, (AV_FUNC_53 | AV_FUNC_54)) AV_FUNC(avcodec_free_frame, AV_FUNC_54) - AV_FUNC(avcodec_send_packet, AV_FUNC_58) - AV_FUNC(avcodec_receive_frame, AV_FUNC_58) + AV_FUNC(avcodec_send_packet, AV_FUNC_58 | AV_FUNC_59) + AV_FUNC(avcodec_receive_frame, AV_FUNC_58 | AV_FUNC_59) AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL) AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL) AV_FUNC(av_freep, AV_FUNC_AVUTIL_ALL) - AV_FUNC(av_frame_alloc, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58)) - AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58)) - AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58)) + AV_FUNC(av_frame_alloc, + (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | + AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59)) + AV_FUNC(av_frame_free, + (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | + AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59)) + AV_FUNC(av_frame_unref, + (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | + AV_FUNC_AVUTIL_58 | AV_FUNC_AVUTIL_59)) AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL) #undef AV_FUNC #undef AV_FUNC_OPTION - avcodec_register_all(); + if (avcodec_register_all) { + avcodec_register_all(); + } #ifdef DEBUG av_log_set_level(AV_LOG_DEBUG); #endif diff --git a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp index 513a8998b..2e0c25260 100644 --- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp @@ -26,7 +26,9 @@ public: static FFmpegLibWrapper sLibAV; static const char* sLibs[] = { + "libavcodec.so.59", "libavcodec.so.58", + "libavcodec-ffmpeg.so.59", "libavcodec-ffmpeg.so.58", "libavcodec-ffmpeg.so.57", "libavcodec-ffmpeg.so.56", @@ -129,6 +131,7 @@ FFmpegRuntimeLinker::CreateDecoderModule() case 56: module = FFmpegDecoderModule<55>::Create(&sLibAV); break; case 57: module = FFmpegDecoderModule<57>::Create(&sLibAV); break; case 58: module = FFmpegDecoderModule<58>::Create(&sLibAV); break; + case 59: module = FFmpegDecoderModule<59>::Create(&sLibAV); break; default: module = nullptr; } return module.forget(); -- cgit v1.2.3