From 059fa356c06778c4671152f267be6f7af816415b Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 01/11] kodi: adjust kodi minimize patch --- .../kodi/patches/kodi-100.07-disable-minimize.patch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch b/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch index f20e5b5588..7030e2e3c1 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch @@ -9,11 +9,11 @@ Subject: [PATCH 07/13] disable minimize --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp -@@ -4818,7 +4818,6 @@ bool CApplication::SwitchToFullScreen(bo +@@ -2056,7 +2056,6 @@ void CApplication::OnApplicationMessage( + break; - void CApplication::Minimize() - { -- CServiceBroker::GetWinSystem()->Minimize(); - } + case TMSG_MINIMIZE: +- CServiceBroker::GetWinSystem()->Minimize(); + break; - std::string CApplication::GetCurrentPlayer() + case TMSG_EXECUTE_OS: From aea17da3bf7b2db0cc7246a92f4176c530bbebe5 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 02/11] kodi: update to 3d01768 --- packages/mediacenter/kodi/package.mk | 4 ++-- .../kodi-100.03-disable-online-check.patch | 14 +++++++------- ...-100.05-make-binary-addons-executable.patch | 2 +- ....06-dont-set-_NET_WM_STATE_FULLSCREEN.patch | 2 +- .../patches/kodi-100.07-disable-minimize.patch | 2 +- ...use-a-wrapper-to-setup-service-addons.patch | 10 +++++----- .../patches/kodi-100.10-handle-SIGTERM.patch | 18 +++++++++--------- .../kodi-100.16-remove-sysinfo-battery.patch | 8 ++++---- ...100.30-addons-refresh-etc-environment.patch | 4 ++-- ...odi-100.31.le-addons-no-startupenable.patch | 7 +------ 10 files changed, 33 insertions(+), 38 deletions(-) diff --git a/packages/mediacenter/kodi/package.mk b/packages/mediacenter/kodi/package.mk index bf16236492..8de7076e55 100644 --- a/packages/mediacenter/kodi/package.mk +++ b/packages/mediacenter/kodi/package.mk @@ -3,8 +3,8 @@ # Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv) PKG_NAME="kodi" -PKG_VERSION="6402a50950ff6463042f8891ec4029c782730391" -PKG_SHA256="56e1a64f2cd1b38e6997dac3057cdeb81e33109bfa449521493208b514466bd0" +PKG_VERSION="3d01768da145e67708ed378dfc36bb4b61a81624" +PKG_SHA256="fcc2ac30f62b55bf36fb5edf9026cdd4b1af2aaecd17accc0500705850de0cc3" PKG_LICENSE="GPL" PKG_SITE="http://www.kodi.tv" PKG_URL="https://github.com/xbmc/xbmc/archive/${PKG_VERSION}.tar.gz" diff --git a/packages/mediacenter/kodi/patches/kodi-100.03-disable-online-check.patch b/packages/mediacenter/kodi/patches/kodi-100.03-disable-online-check.patch index 6ffd100b9a..aa0889db1e 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.03-disable-online-check.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.03-disable-online-check.patch @@ -13,15 +13,15 @@ Subject: disable online check {"uptime", SYSTEM_UPTIME}, --- a/xbmc/utils/SystemInfo.cpp +++ b/xbmc/utils/SystemInfo.cpp -@@ -271,7 +271,6 @@ bool CSysInfoJob::DoWork() +@@ -274,7 +274,6 @@ bool CSysInfoJob::DoWork() { m_info.systemUptime = GetSystemUpTime(false); m_info.systemTotalUptime = GetSystemUpTime(true); - m_info.internetState = GetInternetState(); m_info.videoEncoder = GetVideoEncoder(); m_info.cpuFrequency = - StringUtils::Format("%4.0f MHz", CServiceBroker::GetCPUInfo()->GetCPUFrequency()); -@@ -1000,9 +999,7 @@ int CSysInfo::GetXbmcBitness(void) + StringUtils::Format("{:4.0f} MHz", CServiceBroker::GetCPUInfo()->GetCPUFrequency()); +@@ -1010,9 +1009,7 @@ int CSysInfo::GetXbmcBitness(void) bool CSysInfo::HasInternet() { @@ -35,10 +35,10 @@ Subject: disable online check --- a/xbmc/windows/GUIWindowSystemInfo.cpp +++ b/xbmc/windows/GUIWindowSystemInfo.cpp @@ -124,7 +124,6 @@ void CGUIWindowSystemInfo::FrameMove() - SetControlLabel(i++, "%s: %s", 13160, NETWORK_GATEWAY_ADDRESS); - SetControlLabel(i++, "%s: %s", 13161, NETWORK_DNS1_ADDRESS); - SetControlLabel(i++, "%s: %s", 20307, NETWORK_DNS2_ADDRESS); -- SetControlLabel(i++, "%s %s", 13295, SYSTEM_INTERNET_STATE); + SetControlLabel(i++, "{}: {}", 13160, NETWORK_GATEWAY_ADDRESS); + SetControlLabel(i++, "{}: {}", 13161, NETWORK_DNS1_ADDRESS); + SetControlLabel(i++, "{}: {}", 20307, NETWORK_DNS2_ADDRESS); +- SetControlLabel(i++, "{} {}", 13295, SYSTEM_INTERNET_STATE); } else if (m_section == CONTROL_BT_VIDEO) diff --git a/packages/mediacenter/kodi/patches/kodi-100.05-make-binary-addons-executable.patch b/packages/mediacenter/kodi/patches/kodi-100.05-make-binary-addons-executable.patch index a23dc418e0..0cb385d3f7 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.05-make-binary-addons-executable.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.05-make-binary-addons-executable.patch @@ -23,7 +23,7 @@ credits to vpeter4 for the patch #include "AddonManager.h" #include "addons/settings/AddonSettings.h" #include "filesystem/Directory.h" -@@ -385,6 +389,28 @@ void OnPreInstall(const AddonPtr& addon) +@@ -390,6 +394,28 @@ void OnPreInstall(const AddonPtr& addon) void OnPostInstall(const AddonPtr& addon, bool update, bool modal) { diff --git a/packages/mediacenter/kodi/patches/kodi-100.06-dont-set-_NET_WM_STATE_FULLSCREEN.patch b/packages/mediacenter/kodi/patches/kodi-100.06-dont-set-_NET_WM_STATE_FULLSCREEN.patch index c564f084d3..5e172f6e97 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.06-dont-set-_NET_WM_STATE_FULLSCREEN.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.06-dont-set-_NET_WM_STATE_FULLSCREEN.patch @@ -14,7 +14,7 @@ this should probably be removed after OE 6 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp -@@ -753,8 +753,6 @@ bool CWinSystemX11::SetWindow(int width, +@@ -756,8 +756,6 @@ bool CWinSystemX11::SetWindow(int width, if (fullscreen && hasWM) { diff --git a/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch b/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch index 7030e2e3c1..8ae0d5c8e0 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.07-disable-minimize.patch @@ -9,7 +9,7 @@ Subject: [PATCH 07/13] disable minimize --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp -@@ -2056,7 +2056,6 @@ void CApplication::OnApplicationMessage( +@@ -2055,7 +2055,6 @@ void CApplication::OnApplicationMessage( break; case TMSG_MINIMIZE: diff --git a/packages/mediacenter/kodi/patches/kodi-100.09-use-a-wrapper-to-setup-service-addons.patch b/packages/mediacenter/kodi/patches/kodi-100.09-use-a-wrapper-to-setup-service-addons.patch index 11adba478e..2ac3fcdb5b 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.09-use-a-wrapper-to-setup-service-addons.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.09-use-a-wrapper-to-setup-service-addons.patch @@ -1,6 +1,6 @@ --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp -@@ -380,6 +380,37 @@ AddonVersion CAddon::GetDependencyVersio +@@ -385,6 +385,37 @@ AddonVersion CAddon::GetDependencyVersio return m_addonInfo->DependencyVersion(dependencyID); } @@ -38,7 +38,7 @@ void OnPreInstall(const AddonPtr& addon) { //Fallback to the pre-install callback in the addon. -@@ -409,6 +440,8 @@ void OnPostInstall(const AddonPtr& addon +@@ -414,6 +445,8 @@ void OnPostInstall(const AddonPtr& addon } closedir(addonsDir); } @@ -47,7 +47,7 @@ // OE addon->OnPostInstall(update, modal); -@@ -416,6 +449,8 @@ void OnPostInstall(const AddonPtr& addon +@@ -421,6 +454,8 @@ void OnPostInstall(const AddonPtr& addon void OnPreUnInstall(const AddonPtr& addon) { @@ -76,7 +76,7 @@ public: --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp -@@ -789,6 +789,7 @@ bool CAddonMgr::DisableAddon(const std:: +@@ -795,6 +795,7 @@ bool CAddonMgr::DisableAddon(const std:: AddonPtr addon; if (GetAddon(id, addon, ADDON_UNKNOWN, OnlyEnabled::NO) && addon != NULL) { @@ -84,7 +84,7 @@ CServiceBroker::GetEventLog().Add(EventPtr(new CAddonManagementEvent(addon, 24141))); } -@@ -834,6 +835,7 @@ bool CAddonMgr::EnableSingle(const std:: +@@ -840,6 +841,7 @@ bool CAddonMgr::EnableSingle(const std:: if (!m_database.EnableAddon(id)) return false; m_disabled.erase(id); diff --git a/packages/mediacenter/kodi/patches/kodi-100.10-handle-SIGTERM.patch b/packages/mediacenter/kodi/patches/kodi-100.10-handle-SIGTERM.patch index 388263de8c..add99dd3c8 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.10-handle-SIGTERM.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.10-handle-SIGTERM.patch @@ -24,7 +24,7 @@ so, when shutdown/reboot is requested: --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp -@@ -2118,12 +2118,12 @@ void CApplication::OnApplicationMessage( +@@ -1935,12 +1935,12 @@ void CApplication::OnApplicationMessage( switch (msg) { case TMSG_POWERDOWN: @@ -39,7 +39,7 @@ so, when shutdown/reboot is requested: break; case TMSG_SHUTDOWN: -@@ -2144,12 +2144,13 @@ void CApplication::OnApplicationMessage( +@@ -1961,12 +1961,13 @@ void CApplication::OnApplicationMessage( case TMSG_RESTART: case TMSG_RESET: @@ -54,7 +54,7 @@ so, when shutdown/reboot is requested: Stop(EXITCODE_RESTARTAPP); #endif break; -@@ -2635,6 +2636,17 @@ bool CApplication::Cleanup() +@@ -2456,6 +2457,17 @@ bool CApplication::Cleanup() } } @@ -72,7 +72,7 @@ so, when shutdown/reboot is requested: void CApplication::Stop(int exitCode) { CLog::Log(LOGINFO, "Stopping player"); -@@ -2661,7 +2673,7 @@ void CApplication::Stop(int exitCode) +@@ -2482,7 +2494,7 @@ void CApplication::Stop(int exitCode) m_frameMoveGuard.unlock(); CVariant vExitCode(CVariant::VariantTypeObject); @@ -81,7 +81,7 @@ so, when shutdown/reboot is requested: CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::System, "OnQuit", vExitCode); // Abort any active screensaver -@@ -2693,7 +2705,6 @@ void CApplication::Stop(int exitCode) +@@ -2514,7 +2526,6 @@ void CApplication::Stop(int exitCode) // Needs cleaning up CApplicationMessenger::GetInstance().Stop(); m_AppFocused = false; @@ -89,7 +89,7 @@ so, when shutdown/reboot is requested: CLog::Log(LOGINFO, "Stopping all"); // cancel any jobs from the jobmanager -@@ -4347,7 +4358,7 @@ void CApplication::ProcessSlow() +@@ -4157,7 +4168,7 @@ void CApplication::ProcessSlow() if (CPlatformPosix::TestQuitFlag()) { CLog::Log(LOGINFO, "Quitting due to POSIX signal"); @@ -100,8 +100,8 @@ so, when shutdown/reboot is requested: --- a/xbmc/Application.h +++ b/xbmc/Application.h -@@ -156,6 +156,7 @@ public: - bool StartServer(enum ESERVERS eServer, bool bStart, bool bWait = false); +@@ -138,6 +138,7 @@ public: + bool InitWindow(RESOLUTION res = RES_INVALID); bool IsCurrentThread() const; + void SetExitCode(int exitCode); @@ -110,7 +110,7 @@ so, when shutdown/reboot is requested: bool LoadCustomWindows(); --- a/xbmc/XBApplicationEx.cpp +++ b/xbmc/XBApplicationEx.cpp -@@ -23,6 +23,7 @@ CXBApplicationEx::CXBApplicationEx() +@@ -22,6 +22,7 @@ CXBApplicationEx::CXBApplicationEx() m_bStop = false; m_AppFocused = true; m_ExitCode = EXITCODE_QUIT; diff --git a/packages/mediacenter/kodi/patches/kodi-100.16-remove-sysinfo-battery.patch b/packages/mediacenter/kodi/patches/kodi-100.16-remove-sysinfo-battery.patch index 835772ea95..d918dc0744 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.16-remove-sysinfo-battery.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.16-remove-sysinfo-battery.patch @@ -1,10 +1,10 @@ --- a/xbmc/windows/GUIWindowSystemInfo.cpp +++ b/xbmc/windows/GUIWindowSystemInfo.cpp @@ -99,7 +99,6 @@ void CGUIWindowSystemInfo::FrameMove() - SetControlLabel(i++, "%s %s", 13283, SYSTEM_OS_VERSION_INFO); - SetControlLabel(i++, "%s: %s", 12390, SYSTEM_UPTIME); - SetControlLabel(i++, "%s: %s", 12394, SYSTEM_TOTALUPTIME); -- SetControlLabel(i++, "%s: %s", 12395, SYSTEM_BATTERY_LEVEL); + SetControlLabel(i++, "{} {}", 13283, SYSTEM_OS_VERSION_INFO); + SetControlLabel(i++, "{}: {}", 12390, SYSTEM_UPTIME); + SetControlLabel(i++, "{}: {}", 12394, SYSTEM_TOTALUPTIME); +- SetControlLabel(i++, "{}: {}", 12395, SYSTEM_BATTERY_LEVEL); } else if (m_section == CONTROL_BT_STORAGE) diff --git a/packages/mediacenter/kodi/patches/kodi-100.30-addons-refresh-etc-environment.patch b/packages/mediacenter/kodi/patches/kodi-100.30-addons-refresh-etc-environment.patch index c7ec60588a..c78fad3f0e 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.30-addons-refresh-etc-environment.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.30-addons-refresh-etc-environment.patch @@ -9,7 +9,7 @@ Subject: [PATCH] refresh /etc/environment on install and uninstall --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp -@@ -445,6 +445,9 @@ void OnPostInstall(const AddonPtr& addon +@@ -450,6 +450,9 @@ void OnPostInstall(const AddonPtr& addon // OE addon->OnPostInstall(update, modal); @@ -19,7 +19,7 @@ Subject: [PATCH] refresh /etc/environment on install and uninstall } void OnPreUnInstall(const AddonPtr& addon) -@@ -457,6 +460,9 @@ void OnPreUnInstall(const AddonPtr& addo +@@ -462,6 +465,9 @@ void OnPreUnInstall(const AddonPtr& addo void OnPostUnInstall(const AddonPtr& addon) { addon->OnPostUnInstall(); diff --git a/packages/mediacenter/kodi/patches/kodi-100.31.le-addons-no-startupenable.patch b/packages/mediacenter/kodi/patches/kodi-100.31.le-addons-no-startupenable.patch index af2190300c..8e0837f4d0 100644 --- a/packages/mediacenter/kodi/patches/kodi-100.31.le-addons-no-startupenable.patch +++ b/packages/mediacenter/kodi/patches/kodi-100.31.le-addons-no-startupenable.patch @@ -10,18 +10,13 @@ https://github.com/xbmc/xbmc/pull/19091 xbmc/platform/linux/PlatformLinux.h | 1 - 1 file changed, 1 deletion(-) -diff --git a/xbmc/platform/linux/PlatformLinux.h b/xbmc/platform/linux/PlatformLinux.h -index c45d41143a..9a872a5f55 100644 --- a/xbmc/platform/linux/PlatformLinux.h +++ b/xbmc/platform/linux/PlatformLinux.h @@ -21,7 +21,6 @@ public: ~CPlatformLinux() override = default; - bool Init() override; + bool InitStageOne() override; - bool IsConfigureAddonsAtStartupEnabled() override { return true; }; private: std::unique_ptr m_lirc; --- -2.31.1 - From 931a232613e361cba7fdaa83373ab866ae962cdb Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 03/11] ffmpeg: update to 4.4 --- packages/multimedia/ffmpeg/package.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/multimedia/ffmpeg/package.mk b/packages/multimedia/ffmpeg/package.mk index 71ff9b1ff7..0ab4cb963b 100644 --- a/packages/multimedia/ffmpeg/package.mk +++ b/packages/multimedia/ffmpeg/package.mk @@ -3,8 +3,8 @@ # Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv) PKG_NAME="ffmpeg" -PKG_VERSION="4.3.2-Matrix-19.1" -PKG_SHA256="c2558449f1eddb6b13ed168288388c7804049c2af8d6db4952ccd6b4af6e9fdd" +PKG_VERSION="4.4-N-Alpha1" +PKG_SHA256="eb396f46ef7c5ac01b67818d0f2c0516fd4ab32aa9065a9ffa71eebede67ff20" PKG_LICENSE="LGPLv2.1+" PKG_SITE="https://ffmpeg.org" PKG_URL="https://github.com/xbmc/FFmpeg/archive/${PKG_VERSION}.tar.gz" From b8b2a2cec80bafaa8378195cb32aec18169dd8a9 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 04/11] ffmpeg gen-patches.sh: update ffmpeg to 4.4 --- tools/ffmpeg/gen-patches.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/ffmpeg/gen-patches.sh b/tools/ffmpeg/gen-patches.sh index 1b4332a0b5..c45d420617 100755 --- a/tools/ffmpeg/gen-patches.sh +++ b/tools/ffmpeg/gen-patches.sh @@ -2,7 +2,7 @@ # base ffmpeg version KODI_FFMPEG_REPO="https://github.com/xbmc/FFmpeg" -KODI_FFMPEG_VERSION="4.3.2-Matrix-19.1" +KODI_FFMPEG_VERSION="4.4-N-Alpha1" ALL_FEATURE_SETS="v4l2-drmprime v4l2-request libreelec rpi" @@ -24,20 +24,20 @@ create_patch() { REFTYPE="branch" case "${FEATURE_SET}" in v4l2-drmprime) - REPO="https://github.com/lrusak/FFmpeg" - REFSPEC="v4l2-drmprime-v5" + REPO="https://github.com/jernejsk/FFmpeg" + REFSPEC="v4l2-drmprime-v6" ;; v4l2-request) REPO="https://github.com/jernejsk/FFmpeg" - REFSPEC="v4l2-request-hwaccel-4.3.1" + REFSPEC="v4l2-request-hwaccel-4.4" ;; libreelec) REPO="https://github.com/LibreELEC/FFmpeg" - REFSPEC="4.3-libreelec-misc" + REFSPEC="4.4-libreelec-misc" ;; rpi) REPO="https://github.com/jc-kynesim/rpi-ffmpeg" - REFSPEC="test/4.3.2/rpi_main" + REFSPEC="dev/4.4/rpi_import_1" ;; *) echo "illegal feature set ${FEATURE_SET}" From 66894bcff8985d781b3ffd6603af9a676434ac7d Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 05/11] Allwinner: kodi: Fix deinterlace filter patch --- .../patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/Allwinner/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch b/projects/Allwinner/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch index d2155fbf94..50bb907b77 100644 --- a/projects/Allwinner/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch +++ b/projects/Allwinner/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch @@ -152,8 +152,8 @@ index 2b334c95d47a..1e5624e7af50 100644 + const AVFilter* outFilter = avfilter_get_by_name("buffersink"); + enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_DRM_PRIME, AV_PIX_FMT_NONE }; + -+ std::string args = StringUtils::Format("video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:" -+ "pixel_aspect=%d/%d:sws_param=flags=2", ++ std::string args = StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:" ++ "pixel_aspect={}/{}", + m_pCodecContext->width, + m_pCodecContext->height, + m_pCodecContext->pix_fmt, @@ -273,7 +273,7 @@ index 2b334c95d47a..1e5624e7af50 100644 + char* graphDump = avfilter_graph_dump(m_pFilterGraph, nullptr); + if (graphDump) + { -+ CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::FilterOpen - Final filter graph:\n%s", ++ CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::FilterOpen - Final filter graph:\n{}", + graphDump); + av_freep(&graphDump); + } From db018784c82e1eda35641dfd8c1ff7ecdc999b20 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 06/11] distro: bump ADDON_VERSION to 10.80.1 --- distributions/LibreELEC/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributions/LibreELEC/version b/distributions/LibreELEC/version index 9e59884620..652bf41447 100644 --- a/distributions/LibreELEC/version +++ b/distributions/LibreELEC/version @@ -5,4 +5,4 @@ OS_VERSION="11.0" # ADDON_VERSION: Addon version - ADDON_VERSION="10.80.0" + ADDON_VERSION="10.80.1" From 4af12ebee60382bbb26999fd5f9721ddc3d93a83 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 07/11] Rockchip: kodi: Fix deinterlace filter patch --- ...0002-WIP-DRMPRIME-deinterlace-filter.patch | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/projects/Rockchip/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch b/projects/Rockchip/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch index 0e19bb6788..50bb907b77 100644 --- a/projects/Rockchip/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch +++ b/projects/Rockchip/patches/kodi/0002-WIP-DRMPRIME-deinterlace-filter.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 58f2acdc63d85eb9818d783a9a858b1ecc267fa7 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Thu, 26 Dec 2019 11:01:51 +0100 -Subject: [PATCH] WIP: DRMPRIME deinterlace filter +Subject: [PATCH 2/2] WIP: DRMPRIME deinterlace filter --- .../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 368 +++++++++++++++--- @@ -9,7 +9,7 @@ Subject: [PATCH] WIP: DRMPRIME deinterlace filter 2 files changed, 322 insertions(+), 55 deletions(-) diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp -index 7507c12e9a..4759dde3f9 100644 +index 2b334c95d47a..1e5624e7af50 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp @@ -79,12 +79,15 @@ CDVDVideoCodecDRMPRIME::CDVDVideoCodecDRMPRIME(CProcessInfo& processInfo) @@ -28,7 +28,7 @@ index 7507c12e9a..4759dde3f9 100644 avcodec_free_context(&m_pCodecContext); } -@@ -341,8 +344,19 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio +@@ -330,8 +333,19 @@ bool CDVDVideoCodecDRMPRIME::Open(CDVDStreamInfo& hints, CDVDCodecOptions& optio } UpdateProcessInfo(m_pCodecContext, m_pCodecContext->pix_fmt); @@ -49,7 +49,7 @@ index 7507c12e9a..4759dde3f9 100644 return true; } -@@ -405,6 +419,8 @@ void CDVDVideoCodecDRMPRIME::Reset() +@@ -394,6 +408,8 @@ void CDVDVideoCodecDRMPRIME::Reset() return; Drain(); @@ -58,7 +58,7 @@ index 7507c12e9a..4759dde3f9 100644 do { -@@ -443,7 +459,7 @@ void CDVDVideoCodecDRMPRIME::Drain() +@@ -432,7 +448,7 @@ void CDVDVideoCodecDRMPRIME::Drain() } } @@ -67,7 +67,7 @@ index 7507c12e9a..4759dde3f9 100644 { pVideoPicture->iWidth = m_pFrame->width; pVideoPicture->iHeight = m_pFrame->height; -@@ -525,13 +541,232 @@ void CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture) +@@ -514,13 +530,232 @@ void CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture) ? DVD_NOPTS_VALUE : static_cast(pts) * DVD_TIME_BASE / AV_TIME_BASE; pVideoPicture->dts = DVD_NOPTS_VALUE; @@ -101,9 +101,8 @@ index 7507c12e9a..4759dde3f9 100644 + } + + return true; - } - --CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() ++} ++ +void CDVDVideoCodecDRMPRIME::FilterTest() +{ + const AVFilter* filter; @@ -153,8 +152,8 @@ index 7507c12e9a..4759dde3f9 100644 + const AVFilter* outFilter = avfilter_get_by_name("buffersink"); + enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_DRM_PRIME, AV_PIX_FMT_NONE }; + -+ std::string args = StringUtils::Format("video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:" -+ "pixel_aspect=%d/%d:sws_param=flags=2", ++ std::string args = StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:" ++ "pixel_aspect={}/{}", + m_pCodecContext->width, + m_pCodecContext->height, + m_pCodecContext->pix_fmt, @@ -249,7 +248,7 @@ index 7507c12e9a..4759dde3f9 100644 + { + char err[AV_ERROR_MAX_STRING_SIZE] = {}; + av_strerror(result, err, AV_ERROR_MAX_STRING_SIZE); -+ CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_config: {} ({})", ++ CLog::Log(LOGERROR, "CDVDVideoCodecDRMPRIME::FilterOpen - avfilter_graph_config: {} ({})", + err, result); + return false; + } @@ -274,7 +273,7 @@ index 7507c12e9a..4759dde3f9 100644 + char* graphDump = avfilter_graph_dump(m_pFilterGraph, nullptr); + if (graphDump) + { -+ CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::FilterOpen - Final filter graph:\n%s", ++ CLog::Log(LOGDEBUG, "CDVDVideoCodecDRMPRIME::FilterOpen - Final filter graph:\n{}", + graphDump); + av_freep(&graphDump); + } @@ -284,9 +283,7 @@ index 7507c12e9a..4759dde3f9 100644 +} + +void CDVDVideoCodecDRMPRIME::FilterClose() - { -- if (!m_pFilterIn) -- return VC_PICTURE; ++{ + if (m_pFilterGraph) + { + CLog::Log(LOGDEBUG, LOGVIDEO, "CDVDVideoCodecDRMPRIME::FilterClose - Freeing filter graph"); @@ -296,14 +293,17 @@ index 7507c12e9a..4759dde3f9 100644 + m_pFilterIn = nullptr; + m_pFilterOut = nullptr; + } -+} + } -+CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() -+{ + CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() + { +- if (!m_pFilterIn) +- return VC_PICTURE; +- int ret = av_buffersrc_add_frame(m_pFilterIn, m_pFrame); if (ret < 0) { -@@ -547,21 +782,14 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() +@@ -536,21 +771,14 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterIn() CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterOut() { @@ -329,7 +329,7 @@ index 7507c12e9a..4759dde3f9 100644 } else if (ret) { -@@ -572,9 +800,27 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterOut() +@@ -561,9 +789,27 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::ProcessFilterOut() return VC_ERROR; } @@ -357,7 +357,7 @@ index 7507c12e9a..4759dde3f9 100644 CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideoPicture) { if (m_codecControlFlags & DVD_CODEC_CTRL_DRAIN) -@@ -586,57 +832,71 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo +@@ -575,57 +821,71 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecDRMPRIME::GetPicture(VideoPicture* pVideo pVideoPicture->videoBuffer = nullptr; } @@ -468,7 +468,7 @@ index 7507c12e9a..4759dde3f9 100644 return VC_PICTURE; } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h -index 7112d1b48a..13bec95135 100644 +index 7112d1b48afb..13bec9513579 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h @@ -38,18 +38,25 @@ public: @@ -498,3 +498,6 @@ index 7112d1b48a..13bec95135 100644 AVFilterGraph* m_pFilterGraph = nullptr; AVFilterContext* m_pFilterIn = nullptr; AVFilterContext* m_pFilterOut = nullptr; +-- +2.29.2 + From 267eca80383c898a35f2c20609357e263ce31819 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 08/11] ffmpeg: update v4l2-drmprime patch Patch created using revisions 081225c..2bb6d0c from branch v4l2-drmprime-v6 of https://github.com/jernejsk/FFmpeg --- .../ffmpeg-001-v4l2-drmprime.patch | 215 ++++-------------- 1 file changed, 50 insertions(+), 165 deletions(-) diff --git a/packages/multimedia/ffmpeg/patches/v4l2-drmprime/ffmpeg-001-v4l2-drmprime.patch b/packages/multimedia/ffmpeg/patches/v4l2-drmprime/ffmpeg-001-v4l2-drmprime.patch index 9313375a37..d6acd23c78 100644 --- a/packages/multimedia/ffmpeg/patches/v4l2-drmprime/ffmpeg-001-v4l2-drmprime.patch +++ b/packages/multimedia/ffmpeg/patches/v4l2-drmprime/ffmpeg-001-v4l2-drmprime.patch @@ -1,122 +1,7 @@ -From b29b5b9f529bbb10cd9880adebf0fb287dcf233b Mon Sep 17 00:00:00 2001 -From: Andriy Gelman -Date: Tue, 28 Apr 2020 22:54:21 -0400 -Subject: [PATCH 01/11] avcodec/v4l2_m2m: Adapt to call close() on init fail - -This fixes several mem leaks when init of encoder/decoder failed. - -Fixes ticket #8285 - -Signed-off-by: Andriy Gelman ---- - libavcodec/v4l2_m2m.c | 8 ++++++++ - libavcodec/v4l2_m2m_dec.c | 10 ++-------- - libavcodec/v4l2_m2m_enc.c | 1 + - 3 files changed, 11 insertions(+), 8 deletions(-) - -diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c -index e48b3a8ccf..bfea70ff0c 100644 ---- a/libavcodec/v4l2_m2m.c -+++ b/libavcodec/v4l2_m2m.c -@@ -338,6 +338,13 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) - V4L2m2mContext *s = priv->context; - int ret; - -+ if (!s) -+ return 0; -+ -+ if (av_codec_is_decoder(s->avctx->codec)) -+ av_packet_unref(&s->buf_pkt); -+ -+ if (s->fd >= 0) { - ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); - if (ret) - av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); -@@ -345,6 +352,7 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) - ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); - if (ret) - av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); -+ } - - ff_v4l2_context_release(&s->output); - -diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index 3e17e0fcac..a2ea0ff73a 100644 ---- a/libavcodec/v4l2_m2m_dec.c -+++ b/libavcodec/v4l2_m2m_dec.c -@@ -212,9 +212,6 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) - ret = ff_v4l2_m2m_codec_init(priv); - if (ret) { - av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n"); -- s->self_ref = NULL; -- av_buffer_unref(&priv->context_ref); -- - return ret; - } - -@@ -223,10 +220,7 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) - - static av_cold int v4l2_decode_close(AVCodecContext *avctx) - { -- V4L2m2mPriv *priv = avctx->priv_data; -- V4L2m2mContext *s = priv->context; -- av_packet_unref(&s->buf_pkt); -- return ff_v4l2_m2m_codec_end(priv); -+ return ff_v4l2_m2m_codec_end(avctx->priv_data); - } - - #define OFFSET(x) offsetof(V4L2m2mPriv, x) -@@ -261,7 +255,7 @@ static const AVOption options[] = { - .close = v4l2_decode_close, \ - .bsfs = bsf_name, \ - .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ -- .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, \ -+ .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \ - .wrapper_name = "v4l2m2m", \ - } - -diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c -index 32321f392f..9f1b2c2ffc 100644 ---- a/libavcodec/v4l2_m2m_enc.c -+++ b/libavcodec/v4l2_m2m_enc.c -@@ -416,6 +416,7 @@ static const AVCodecDefault v4l2_m2m_defaults[] = { - .close = v4l2_encode_close, \ - .defaults = v4l2_m2m_defaults, \ - .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \ -+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \ - .wrapper_name = "v4l2m2m", \ - } - - -From 7aaac68934c0e03a78c9f477ec64e522729a64b7 Mon Sep 17 00:00:00 2001 -From: Andriy Gelman -Date: Tue, 5 May 2020 01:54:54 -0400 -Subject: [PATCH 02/11] avcodec/v4l2_m2m_dec: Use av_packet_move_ref() - -Signed-off-by: Andriy Gelman ---- - libavcodec/v4l2_m2m_dec.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index a2ea0ff73a..45e9a8e9fe 100644 ---- a/libavcodec/v4l2_m2m_dec.c -+++ b/libavcodec/v4l2_m2m_dec.c -@@ -142,8 +142,7 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) - int ret; - - if (s->buf_pkt.size) { -- avpkt = s->buf_pkt; -- memset(&s->buf_pkt, 0, sizeof(AVPacket)); -+ av_packet_move_ref(&avpkt, &s->buf_pkt); - } else { - ret = ff_decode_get_packet(avctx, &avpkt); - if (ret < 0 && ret != AVERROR_EOF) - -From c6b85ed30f06ea99513b13cc768a922ebe4d68c2 Mon Sep 17 00:00:00 2001 +From 40a990827399c05ad3ce3f8242321bd8a67aa0bd Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Tue, 24 Apr 2018 23:00:23 -0700 -Subject: [PATCH 03/11] libavcodec: v4l2m2m: output AVDRMFrameDescriptor +Subject: [PATCH 1/9] libavcodec: v4l2m2m: output AVDRMFrameDescriptor This allows for a zero-copy output by exporting the v4l2 buffer then wrapping that buffer in the AVDRMFrameDescriptor like it is done in rkmpp. @@ -157,7 +42,7 @@ V5: 5 files changed, 213 insertions(+), 12 deletions(-) diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c -index 02f23d954b..4bb2bf6f87 100644 +index 4b2679eb38..cbd3e5680d 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -21,6 +21,7 @@ @@ -397,7 +282,7 @@ index 8dbc7fc104..037e667997 100644 * of how many context-refs we are holding. */ AVBufferRef *context_ref; diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c -index 29b144ed73..7a92df2c3e 100644 +index ff1ea8e57b..e9e8c27a54 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -455,22 +455,54 @@ static int v4l2_release_buffers(V4L2Context* ctx) @@ -460,10 +345,10 @@ index 29b144ed73..7a92df2c3e 100644 static inline int v4l2_try_raw_format(V4L2Context* ctx, enum AVPixelFormat pixfmt) diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h -index 456281f48c..4ee0be653b 100644 +index b67b216331..0fbd19a013 100644 --- a/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h -@@ -63,6 +63,9 @@ typedef struct V4L2m2mContext { +@@ -66,6 +66,9 @@ typedef struct V4L2m2mContext { /* reference back to V4L2m2mPriv */ void *priv; @@ -474,7 +359,7 @@ index 456281f48c..4ee0be653b 100644 typedef struct V4L2m2mPriv { diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index 45e9a8e9fe..eb6ecc8ed5 100644 +index ab07c0a24a..6bc7442702 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -23,6 +23,9 @@ @@ -497,7 +382,7 @@ index 45e9a8e9fe..eb6ecc8ed5 100644 #include "v4l2_context.h" #include "v4l2_m2m.h" #include "v4l2_fmt.h" -@@ -207,6 +213,15 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) +@@ -201,6 +207,15 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) capture->av_codec_id = AV_CODEC_ID_RAWVIDEO; capture->av_pix_fmt = avctx->pix_fmt; @@ -513,7 +398,7 @@ index 45e9a8e9fe..eb6ecc8ed5 100644 s->avctx = avctx; ret = ff_v4l2_m2m_codec_init(priv); if (ret) { -@@ -232,6 +247,11 @@ static const AVOption options[] = { +@@ -226,6 +241,11 @@ static const AVOption options[] = { { NULL}, }; @@ -525,7 +410,7 @@ index 45e9a8e9fe..eb6ecc8ed5 100644 #define M2MDEC_CLASS(NAME) \ static const AVClass v4l2_m2m_ ## NAME ## _dec_class = { \ .class_name = #NAME "_v4l2m2m_decoder", \ -@@ -255,6 +275,9 @@ static const AVOption options[] = { +@@ -249,6 +269,9 @@ static const AVOption options[] = { .bsfs = bsf_name, \ .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \ @@ -536,10 +421,10 @@ index 45e9a8e9fe..eb6ecc8ed5 100644 } -From 2b5cd753892dceba3b211053a6266c40aab38c55 Mon Sep 17 00:00:00 2001 +From 9a2a361c2c84c8da54cd3a74b0d0bb966df8fe69 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Thu, 16 Aug 2018 21:09:40 -0700 -Subject: [PATCH 04/11] libavcodec: v4l2m2m: depends on libdrm +Subject: [PATCH 2/9] libavcodec: v4l2m2m: depends on libdrm --- configure | 1 + @@ -547,10 +432,10 @@ Subject: [PATCH 04/11] libavcodec: v4l2m2m: depends on libdrm 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure -index 8569a60bf8..a049707dd6 100755 +index d7a3f507e8..d203f6f7da 100755 --- a/configure +++ b/configure -@@ -3401,6 +3401,7 @@ sndio_indev_deps="sndio" +@@ -3437,6 +3437,7 @@ sndio_indev_deps="sndio" sndio_outdev_deps="sndio" v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" v4l2_indev_suggest="libv4l2" @@ -559,7 +444,7 @@ index 8569a60bf8..a049707dd6 100755 v4l2_outdev_suggest="libv4l2" vfwcap_indev_deps="vfw32 vfwcap_defines" diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c -index 4bb2bf6f87..c36a73d1fa 100644 +index cbd3e5680d..bebe2c1796 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -21,7 +21,7 @@ @@ -572,10 +457,10 @@ index 4bb2bf6f87..c36a73d1fa 100644 #include #include -From 09a0f1b99548a249991891ee4e02ae6613b545d7 Mon Sep 17 00:00:00 2001 +From 7b0fa2d859c12a8a129c884d16673ca731336c06 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Thu, 16 Aug 2018 21:10:13 -0700 -Subject: [PATCH 05/11] libavcodec: v4l2m2m: set format_modifier to +Subject: [PATCH 3/9] libavcodec: v4l2m2m: set format_modifier to DRM_FORMAT_MOD_LINEAR --- @@ -583,7 +468,7 @@ Subject: [PATCH 05/11] libavcodec: v4l2m2m: set format_modifier to 1 file changed, 2 insertions(+) diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c -index c36a73d1fa..072b77bbda 100644 +index bebe2c1796..12037d5d66 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -328,10 +328,12 @@ static int v4l2_buffer_export_drm(V4L2Buffer* avbuf) @@ -600,10 +485,10 @@ index c36a73d1fa..072b77bbda 100644 } -From e8df5a982f705aaba1e03aef653169bc17a0d464 Mon Sep 17 00:00:00 2001 +From e1857456c8f24e40d5c898886f2f51014e59ee9d Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Thu, 16 Aug 2018 21:10:53 -0700 -Subject: [PATCH 06/11] libavcodec: v4l2m2m: only mmap the buffer when it is +Subject: [PATCH 4/9] libavcodec: v4l2m2m: only mmap the buffer when it is output type and drm prime is used --- @@ -611,7 +496,7 @@ Subject: [PATCH 06/11] libavcodec: v4l2m2m: only mmap the buffer when it is 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c -index 072b77bbda..8162531973 100644 +index 12037d5d66..1adf518ab9 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -662,14 +662,22 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) @@ -644,20 +529,20 @@ index 072b77bbda..8162531973 100644 if (avbuf->plane_info[i].mm_addr == MAP_FAILED) -From 4fb7664bb6be542b691323a03050cdd024585afc Mon Sep 17 00:00:00 2001 +From c8fc3ea1b5777546f7ec72a54b053a2d4fa9fd59 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Thu, 16 Aug 2018 21:11:38 -0700 -Subject: [PATCH 07/11] libavcodec: v4l2m2m: allow using software pixel formats +Subject: [PATCH 5/9] libavcodec: v4l2m2m: allow using software pixel formats --- libavcodec/v4l2_m2m_dec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index eb6ecc8ed5..3b2449ae6c 100644 +index 6bc7442702..4b9baf833c 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c -@@ -219,8 +219,16 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) +@@ -213,8 +213,16 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) * - the DRM frame format is passed in the DRM frame descriptor layer. * check the v4l2_get_drm_frame function. */ @@ -675,7 +560,7 @@ index eb6ecc8ed5..3b2449ae6c 100644 s->avctx = avctx; ret = ff_v4l2_m2m_codec_init(priv); -@@ -276,6 +284,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = { +@@ -270,6 +278,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = { .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \ @@ -684,10 +569,10 @@ index eb6ecc8ed5..3b2449ae6c 100644 .hw_configs = v4l2_m2m_hw_configs, \ .wrapper_name = "v4l2m2m", \ -From 27ae887df07992385b1afc9b532f978066e83774 Mon Sep 17 00:00:00 2001 +From 13f02e940f083f19dbe8b9ac8fc7df45700dd36e Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Mon, 24 Sep 2018 13:39:31 -0700 -Subject: [PATCH 08/11] libavcodec: v4l2m2m: implement hwcontext +Subject: [PATCH 6/9] libavcodec: v4l2m2m: implement hwcontext --- libavcodec/v4l2_buffers.c | 22 ++++++++++++++++++++++ @@ -697,7 +582,7 @@ Subject: [PATCH 08/11] libavcodec: v4l2m2m: implement hwcontext 4 files changed, 37 insertions(+) diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c -index 8162531973..9c5d471c9b 100644 +index 1adf518ab9..6e2a544394 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -435,6 +435,7 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf) @@ -750,10 +635,10 @@ index 22a9532444..e804e94131 100644 /** diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h -index 4ee0be653b..61cb919771 100644 +index 0fbd19a013..adf5997bb5 100644 --- a/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h -@@ -64,6 +64,8 @@ typedef struct V4L2m2mContext { +@@ -67,6 +67,8 @@ typedef struct V4L2m2mContext { /* reference back to V4L2m2mPriv */ void *priv; @@ -763,7 +648,7 @@ index 4ee0be653b..61cb919771 100644 int output_drm; } V4L2m2mContext; diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index 3b2449ae6c..c6b865fde8 100644 +index 4b9baf833c..6c23693137 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -35,6 +35,7 @@ @@ -774,7 +659,7 @@ index 3b2449ae6c..c6b865fde8 100644 #include "v4l2_context.h" #include "v4l2_m2m.h" -@@ -230,6 +231,16 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) +@@ -224,6 +225,16 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) break; } @@ -792,10 +677,10 @@ index 3b2449ae6c..c6b865fde8 100644 ret = ff_v4l2_m2m_codec_init(priv); if (ret) { -From aee464209ec6ad060d352dfb638344a1f4db3ce4 Mon Sep 17 00:00:00 2001 +From 34be198b8039c9df434792f19f0985e45419407e Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Mon, 4 May 2020 13:01:29 -0700 -Subject: [PATCH 09/11] libavcodec: v4l2m2m: allow lower minimum buffer values +Subject: [PATCH 7/9] libavcodec: v4l2m2m: allow lower minimum buffer values There is no reason to enforce a high minimum. In the context of streaming only a few output buffers and capture buffers @@ -807,7 +692,7 @@ alleviate memory pressure when decoding 4K media. 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h -index 61cb919771..feeb162812 100644 +index adf5997bb5..1082b9dad2 100644 --- a/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h @@ -38,7 +38,7 @@ @@ -820,10 +705,10 @@ index 61cb919771..feeb162812 100644 typedef struct V4L2m2mContext { char devname[PATH_MAX]; diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index c6b865fde8..b9725be377 100644 +index 6c23693137..e323c37052 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c -@@ -262,7 +262,7 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) +@@ -256,7 +256,7 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) static const AVOption options[] = { V4L_M2M_DEFAULT_OPTS, { "num_capture_buffers", "Number of buffers in the capture context", @@ -833,10 +718,10 @@ index c6b865fde8..b9725be377 100644 }; -From ffc4419f456c00ab71cf93f792b0473c6de14e64 Mon Sep 17 00:00:00 2001 +From 2956fd1881d28abf6bf77bd9a57866c4ba81d199 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Wed, 6 May 2020 11:12:58 -0700 -Subject: [PATCH 10/11] libavcodec: v4l2m2m: add option to specify pixel format +Subject: [PATCH 8/9] libavcodec: v4l2m2m: add option to specify pixel format used by the decoder --- @@ -846,7 +731,7 @@ Subject: [PATCH 10/11] libavcodec: v4l2m2m: add option to specify pixel format 3 files changed, 12 insertions(+) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c -index 7a92df2c3e..fa2deae888 100644 +index e9e8c27a54..a97b70e836 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -531,6 +531,8 @@ static inline int v4l2_try_raw_format(V4L2Context* ctx, enum AVPixelFormat pixfm @@ -873,7 +758,7 @@ index 7a92df2c3e..fa2deae888 100644 ret = v4l2_try_raw_format(ctx, pixfmt); if (ret){ diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h -index feeb162812..0e88bf9329 100644 +index 1082b9dad2..943a8923c4 100644 --- a/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h @@ -30,6 +30,7 @@ @@ -884,7 +769,7 @@ index feeb162812..0e88bf9329 100644 #include "v4l2_context.h" #define container_of(ptr, type, member) ({ \ -@@ -78,6 +79,7 @@ typedef struct V4L2m2mPriv { +@@ -81,6 +82,7 @@ typedef struct V4L2m2mPriv { int num_output_buffers; int num_capture_buffers; @@ -893,10 +778,10 @@ index feeb162812..0e88bf9329 100644 /** diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index b9725be377..6109deee8a 100644 +index e323c37052..363e998142 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c -@@ -263,6 +263,7 @@ static const AVOption options[] = { +@@ -257,6 +257,7 @@ static const AVOption options[] = { V4L_M2M_DEFAULT_OPTS, { "num_capture_buffers", "Number of buffers in the capture context", OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 2, INT_MAX, FLAGS }, @@ -905,20 +790,20 @@ index b9725be377..6109deee8a 100644 }; -From 8595d06d4909bbec0aa14625fcfc869c6bcef696 Mon Sep 17 00:00:00 2001 +From 2bb6d0cb244590f0c70dd111ed978cd87fa3bee1 Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Mon, 24 Sep 2018 13:39:56 -0700 -Subject: [PATCH 11/11] libavcodec: v4l2m2m: implement flush +Subject: [PATCH 9/9] libavcodec: v4l2m2m: implement flush --- libavcodec/v4l2_m2m_dec.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index 6109deee8a..820cdf241f 100644 +index 363e998142..52ec67cb59 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c -@@ -256,6 +256,41 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) +@@ -250,6 +250,41 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) return ff_v4l2_m2m_codec_end(avctx->priv_data); } @@ -960,7 +845,7 @@ index 6109deee8a..820cdf241f 100644 #define OFFSET(x) offsetof(V4L2m2mPriv, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM -@@ -292,6 +327,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = { +@@ -286,6 +321,7 @@ static const AVCodecHWConfigInternal *v4l2_m2m_hw_configs[] = { .init = v4l2_decode_init, \ .receive_frame = v4l2_receive_frame, \ .close = v4l2_decode_close, \ From 56d53bcfe1910d4c664282875b147ea373a35b8e Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 09/11] ffmpeg: update v4l2-request patch Patch created using revisions 081225c..688bb66 from branch v4l2-request-hwaccel-4.4 of https://github.com/jernejsk/FFmpeg --- .../ffmpeg-001-v4l2-request.patch | 307 +++++++++--------- 1 file changed, 149 insertions(+), 158 deletions(-) diff --git a/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch b/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch index a09da010de..7f72e1aeb9 100644 --- a/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch +++ b/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch @@ -1,4 +1,4 @@ -From fd7c38d6a87d92faaf3b7f18df5cb19918aca3a7 Mon Sep 17 00:00:00 2001 +From 904af26693095364851bbc6c6557fca9b3437b69 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 3 Dec 2018 23:48:04 +0100 Subject: [PATCH 01/18] avutil: add av_buffer_pool_flush() @@ -12,10 +12,10 @@ Signed-off-by: Jonas Karlman 2 files changed, 18 insertions(+) diff --git a/libavutil/buffer.c b/libavutil/buffer.c -index 38a554208a90..b0fedabc3e7d 100644 +index 858633e8c7..41555d9982 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c -@@ -273,6 +273,19 @@ static void buffer_pool_free(AVBufferPool *pool) +@@ -305,6 +305,19 @@ static void buffer_pool_free(AVBufferPool *pool) av_freep(&pool); } @@ -36,11 +36,11 @@ index 38a554208a90..b0fedabc3e7d 100644 { AVBufferPool *pool; diff --git a/libavutil/buffer.h b/libavutil/buffer.h -index c0f3f6cc9abe..998beec9ac5b 100644 +index 241a80ed67..f41363faf1 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h -@@ -267,6 +267,11 @@ AVBufferPool *av_buffer_pool_init2(int size, void *opaque, - AVBufferRef* (*alloc)(void *opaque, int size), +@@ -315,6 +315,11 @@ AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, + #endif void (*pool_free)(void *opaque)); +/** @@ -52,7 +52,7 @@ index c0f3f6cc9abe..998beec9ac5b 100644 * Mark the pool as being available for freeing. It will actually be freed only * once all the allocated buffers associated with the pool are released. Thus it -From 73677b0d323aca461e88c9ee287afb4d6744a0bc Mon Sep 17 00:00:00 2001 +From ec84dc22e99f544e4de7c43e7f8ef9ab7ee8e19b Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 02/18] Add common V4L2 request API code @@ -69,18 +69,18 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request.h diff --git a/configure b/configure -index 36713ab658f9..81ee0e740498 100755 +index d7a3f507e8..f2e203d134 100755 --- a/configure +++ b/configure -@@ -274,6 +274,7 @@ External library support: - --enable-libtls enable LibreSSL (via libtls), needed for https support +@@ -279,6 +279,7 @@ External library support: if openssl, gnutls or mbedtls is not used [no] --enable-libtwolame enable MP2 encoding via libtwolame [no] + --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] + --enable-libudev enable libudev [no] --enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libvidstab enable video stabilization using vid.stab [no] --enable-libvmaf enable vmaf filter via libvmaf [no] -@@ -342,6 +343,7 @@ External library support: +@@ -346,6 +347,7 @@ External library support: --enable-omx-rpi enable OpenMAX IL code for Raspberry Pi [no] --enable-rkmpp enable Rockchip Media Process Platform code [no] --disable-v4l2-m2m disable V4L2 mem2mem code [autodetect] @@ -88,15 +88,15 @@ index 36713ab658f9..81ee0e740498 100755 --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] --disable-videotoolbox disable VideoToolbox code [autodetect] -@@ -1807,6 +1809,7 @@ EXTERNAL_LIBRARY_LIST=" - libtesseract +@@ -1814,6 +1816,7 @@ EXTERNAL_LIBRARY_LIST=" libtheora libtwolame + libuavs3d + libudev libv4l2 + libvmaf libvorbis - libvpx -@@ -1861,6 +1864,7 @@ HWACCEL_LIBRARY_LIST=" +@@ -1868,6 +1871,7 @@ HWACCEL_LIBRARY_LIST=" mmal omx opencl @@ -104,7 +104,7 @@ index 36713ab658f9..81ee0e740498 100755 vulkan " -@@ -2903,6 +2907,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" +@@ -2919,6 +2923,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32" ffnvcodec_deps_any="libdl LoadLibrary" nvdec_deps="ffnvcodec" @@ -112,15 +112,15 @@ index 36713ab658f9..81ee0e740498 100755 vaapi_x11_deps="xlib" videotoolbox_hwaccel_deps="videotoolbox pthreads" videotoolbox_hwaccel_extralibs="-framework QuartzCore" -@@ -6376,6 +6381,7 @@ enabled libtls && require_pkg_config libtls libtls tls.h tls_configur - enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame && +@@ -6438,6 +6443,7 @@ enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } + enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" uavs3d.h uavs3d_decode +enabled libudev && require_pkg_config libudev libudev libudev.h udev_new enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl enabled libvidstab && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit - enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.3.9" libvmaf.h compute_vmaf -@@ -6475,6 +6481,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r + enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.5.2" libvmaf.h compute_vmaf +@@ -6536,6 +6542,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r { enabled libdrm || die "ERROR: rkmpp requires --enable-libdrm"; } } @@ -131,7 +131,7 @@ index 36713ab658f9..81ee0e740498 100755 enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init -@@ -6556,6 +6566,8 @@ if enabled v4l2_m2m; then +@@ -6617,6 +6627,8 @@ if enabled v4l2_m2m; then check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" fi @@ -141,10 +141,10 @@ index 36713ab658f9..81ee0e740498 100755 test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 5a6ea59715af..d74220516826 100644 +index 33a280cf69..90dfffcb20 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -153,6 +153,7 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o +@@ -155,6 +155,7 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o OBJS-$(CONFIG_VP56DSP) += vp56dsp.o OBJS-$(CONFIG_VP8DSP) += vp8dsp.o OBJS-$(CONFIG_V4L2_M2M) += v4l2_m2m.o v4l2_context.o v4l2_buffers.o v4l2_fmt.o @@ -153,7 +153,7 @@ index 5a6ea59715af..d74220516826 100644 OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h -index f421dc909f44..ee78d8ab8e89 100644 +index f421dc909f..ee78d8ab8e 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -80,6 +80,8 @@ typedef struct AVCodecHWConfigInternal { @@ -167,7 +167,7 @@ index f421dc909f44..ee78d8ab8e89 100644 &(const AVCodecHWConfigInternal) { \ diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c new file mode 100644 -index 000000000000..5234b5049b0d +index 0000000000..5234b5049b --- /dev/null +++ b/libavcodec/v4l2_request.c @@ -0,0 +1,984 @@ @@ -1157,7 +1157,7 @@ index 000000000000..5234b5049b0d +} diff --git a/libavcodec/v4l2_request.h b/libavcodec/v4l2_request.h new file mode 100644 -index 000000000000..58d2aa70af80 +index 0000000000..58d2aa70af --- /dev/null +++ b/libavcodec/v4l2_request.h @@ -0,0 +1,77 @@ @@ -1239,7 +1239,7 @@ index 000000000000..58d2aa70af80 + +#endif /* AVCODEC_V4L2_REQUEST_H */ -From 4b5bc3f75955694bfe7af15a323f0c902e53acf1 Mon Sep 17 00:00:00 2001 +From e432d3151f4c5507e40fb1fe8b3c3fb7c7a0a08c Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Wed, 20 Feb 2019 11:18:00 -0300 Subject: [PATCH 03/18] h264dec: add idr_pic_id to slice context @@ -1254,10 +1254,10 @@ Signed-off-by: Jonas Karlman 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 111e1dfe7fa1..81f9a74cb629 100644 +index 2d0605c7f4..c3a7338a70 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -1818,7 +1818,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1830,7 +1830,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, } if (nal->type == H264_NAL_IDR_SLICE) @@ -1267,10 +1267,10 @@ index 111e1dfe7fa1..81f9a74cb629 100644 if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h -index a419615124b2..316dc6a2c890 100644 +index b7b19ba4f1..0698ab95ba 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h -@@ -335,6 +335,7 @@ typedef struct H264SliceContext { +@@ -336,6 +336,7 @@ typedef struct H264SliceContext { int delta_poc[2]; int curr_pic_num; int max_pic_num; @@ -1279,7 +1279,7 @@ index a419615124b2..316dc6a2c890 100644 /** -From 89a05a843c5ecef72b37e5381d2169027e3450b0 Mon Sep 17 00:00:00 2001 +From 84564d13ec0ec40f408622ff6b0d900723bbab5b Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 22 May 2019 14:44:22 +0200 Subject: [PATCH 04/18] h264dec: add ref_pic_marking and pic_order_cnt bit_size @@ -1295,10 +1295,10 @@ Signed-off-by: Jonas Karlman 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 81f9a74cb629..2b370d18e82d 100644 +index c3a7338a70..c28b58cd5d 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -1736,7 +1736,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1748,7 +1748,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, unsigned int slice_type, tmp, i; int field_pic_flag, bottom_field_flag; int first_slice = sl == h->slice_ctx && !h->current_slice; @@ -1307,7 +1307,7 @@ index 81f9a74cb629..2b370d18e82d 100644 if (first_slice) av_assert0(!h->setup_finished); -@@ -1820,6 +1820,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1832,6 +1832,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, if (nal->type == H264_NAL_IDR_SLICE) sl->idr_pic_id = get_ue_golomb_long(&sl->gb); @@ -1315,7 +1315,7 @@ index 81f9a74cb629..2b370d18e82d 100644 if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); -@@ -1833,6 +1834,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1845,6 +1846,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) sl->delta_poc[1] = get_se_golomb(&sl->gb); } @@ -1323,7 +1323,7 @@ index 81f9a74cb629..2b370d18e82d 100644 sl->redundant_pic_count = 0; if (pps->redundant_pic_cnt_present) -@@ -1872,9 +1874,11 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, +@@ -1884,9 +1886,11 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->explicit_ref_marking = 0; if (nal->ref_idc) { @@ -1336,10 +1336,10 @@ index 81f9a74cb629..2b370d18e82d 100644 if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) { diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h -index 316dc6a2c890..f2cabac468d0 100644 +index 0698ab95ba..2b39e82c3b 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h -@@ -328,6 +328,7 @@ typedef struct H264SliceContext { +@@ -329,6 +329,7 @@ typedef struct H264SliceContext { MMCO mmco[MAX_MMCO_COUNT]; int nb_mmco; int explicit_ref_marking; @@ -1347,7 +1347,7 @@ index 316dc6a2c890..f2cabac468d0 100644 int frame_num; int poc_lsb; -@@ -336,6 +337,7 @@ typedef struct H264SliceContext { +@@ -337,6 +338,7 @@ typedef struct H264SliceContext { int curr_pic_num; int max_pic_num; int idr_pic_id; @@ -1356,7 +1356,7 @@ index 316dc6a2c890..f2cabac468d0 100644 /** -From bd9786a78eb4c44325caef40305f86b2856ecad4 Mon Sep 17 00:00:00 2001 +From 5a8628cf6368fe18457d02bf551d5935609efab5 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 05/18] Add V4L2 request API h264 hwaccel @@ -1374,10 +1374,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_h264.c diff --git a/configure b/configure -index 81ee0e740498..0f5b8e355950 100755 +index f2e203d134..b17e4108c1 100755 --- a/configure +++ b/configure -@@ -2925,6 +2925,8 @@ h264_dxva2_hwaccel_deps="dxva2" +@@ -2951,6 +2951,8 @@ h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" h264_nvdec_hwaccel_deps="nvdec" h264_nvdec_hwaccel_select="h264_decoder" @@ -1386,7 +1386,7 @@ index 81ee0e740498..0f5b8e355950 100755 h264_vaapi_hwaccel_deps="vaapi" h264_vaapi_hwaccel_select="h264_decoder" h264_vdpau_hwaccel_deps="vdpau" -@@ -6567,6 +6569,7 @@ if enabled v4l2_m2m; then +@@ -6628,6 +6630,7 @@ if enabled v4l2_m2m; then fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns @@ -1395,22 +1395,22 @@ index 81ee0e740498..0f5b8e355950 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index d74220516826..4f6e7fc2515c 100644 +index 90dfffcb20..426c7528e9 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -903,6 +903,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o +@@ -935,6 +935,7 @@ OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o - OBJS-$(CONFIG_H264_QSV_HWACCEL) += qsvdec_h2645.o + OBJS-$(CONFIG_H264_QSV_HWACCEL) += qsvdec.o +OBJS-$(CONFIG_H264_V4L2REQUEST_HWACCEL) += v4l2_request_h264.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index 2b370d18e82d..dd5ba98a02cb 100644 +index c28b58cd5d..0a10d00aad 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -759,6 +759,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -768,6 +768,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ (CONFIG_H264_D3D11VA_HWACCEL * 2) + \ CONFIG_H264_NVDEC_HWACCEL + \ @@ -1418,7 +1418,7 @@ index 2b370d18e82d..dd5ba98a02cb 100644 CONFIG_H264_VAAPI_HWACCEL + \ CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \ CONFIG_H264_VDPAU_HWACCEL) -@@ -843,6 +844,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -852,6 +853,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #endif #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; @@ -1429,10 +1429,10 @@ index 2b370d18e82d..dd5ba98a02cb 100644 if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c -index 5eedeb3c275d..a504c89565c7 100644 +index 0a999bef43..d78e3eaee3 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c -@@ -1102,6 +1102,9 @@ AVCodec ff_h264_decoder = { +@@ -1076,6 +1076,9 @@ AVCodec ff_h264_decoder = { #endif #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(h264), @@ -1443,10 +1443,10 @@ index 5eedeb3c275d..a504c89565c7 100644 NULL }, diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 6109c89bd63c..f758c34ddcf9 100644 +index 8e54cf73f9..969a1da0f4 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h -@@ -27,6 +27,7 @@ extern const AVHWAccel ff_h264_d3d11va_hwaccel; +@@ -32,6 +32,7 @@ extern const AVHWAccel ff_h264_d3d11va_hwaccel; extern const AVHWAccel ff_h264_d3d11va2_hwaccel; extern const AVHWAccel ff_h264_dxva2_hwaccel; extern const AVHWAccel ff_h264_nvdec_hwaccel; @@ -1456,7 +1456,7 @@ index 6109c89bd63c..f758c34ddcf9 100644 extern const AVHWAccel ff_h264_videotoolbox_hwaccel; diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c new file mode 100644 -index 000000000000..88da8f0a2db0 +index 0000000000..88da8f0a2d --- /dev/null +++ b/libavcodec/v4l2_request_h264.c @@ -0,0 +1,456 @@ @@ -1917,7 +1917,7 @@ index 000000000000..88da8f0a2db0 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From e36de603c7c9daa8e1a833539c7311438eb1dc0c Mon Sep 17 00:00:00 2001 +From 02b8fb17c2a019463dcab4baa1cb0bec63353183 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 06/18] Add V4L2 request API mpeg2 hwaccel @@ -1933,10 +1933,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_mpeg2.c diff --git a/configure b/configure -index 0f5b8e355950..6ed48234dd25 100755 +index b17e4108c1..ec141fabbd 100755 --- a/configure +++ b/configure -@@ -2969,6 +2969,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2" +@@ -2995,6 +2995,8 @@ mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" mpeg2_nvdec_hwaccel_deps="nvdec" mpeg2_nvdec_hwaccel_select="mpeg2video_decoder" @@ -1945,7 +1945,7 @@ index 0f5b8e355950..6ed48234dd25 100755 mpeg2_vaapi_hwaccel_deps="vaapi" mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" mpeg2_vdpau_hwaccel_deps="vdpau" -@@ -6570,6 +6572,7 @@ fi +@@ -6631,6 +6633,7 @@ fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" @@ -1954,22 +1954,22 @@ index 0f5b8e355950..6ed48234dd25 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 4f6e7fc2515c..9a10a292e377 100644 +index 426c7528e9..02c023a447 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -923,6 +923,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o +@@ -955,6 +955,7 @@ OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL) += nvdec_mpeg12.o - OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec_other.o + OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec.o +OBJS-$(CONFIG_MPEG2_V4L2REQUEST_HWACCEL) += v4l2_request_mpeg2.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index f758c34ddcf9..44e00e79b515 100644 +index 969a1da0f4..a8ae1483d8 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h -@@ -48,6 +48,7 @@ extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel; +@@ -53,6 +53,7 @@ extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel; extern const AVHWAccel ff_mpeg2_d3d11va2_hwaccel; extern const AVHWAccel ff_mpeg2_nvdec_hwaccel; extern const AVHWAccel ff_mpeg2_dxva2_hwaccel; @@ -1978,10 +1978,10 @@ index f758c34ddcf9..44e00e79b515 100644 extern const AVHWAccel ff_mpeg2_vdpau_hwaccel; extern const AVHWAccel ff_mpeg2_videotoolbox_hwaccel; diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c -index 99e56532a59e..15aaf97a34c7 100644 +index 94221da2c1..4b0176f6cb 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c -@@ -1154,6 +1154,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { +@@ -1147,6 +1147,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { #endif #if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL AV_PIX_FMT_VIDEOTOOLBOX, @@ -1991,7 +1991,7 @@ index 99e56532a59e..15aaf97a34c7 100644 #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE -@@ -2952,6 +2955,9 @@ AVCodec ff_mpeg2video_decoder = { +@@ -2961,6 +2964,9 @@ AVCodec ff_mpeg2video_decoder = { #endif #if CONFIG_MPEG2_XVMC_HWACCEL HWACCEL_XVMC(mpeg2), @@ -2003,7 +2003,7 @@ index 99e56532a59e..15aaf97a34c7 100644 }, diff --git a/libavcodec/v4l2_request_mpeg2.c b/libavcodec/v4l2_request_mpeg2.c new file mode 100644 -index 000000000000..84d53209c79d +index 0000000000..84d53209c7 --- /dev/null +++ b/libavcodec/v4l2_request_mpeg2.c @@ -0,0 +1,159 @@ @@ -2167,7 +2167,7 @@ index 000000000000..84d53209c79d + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From 8fedb1c1d5c232936ec7ddff71e72dd27dbace6d Mon Sep 17 00:00:00 2001 +From 1cd61e5730acc12c39c964bcf13c73a54203a390 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 22 May 2019 14:46:58 +0200 Subject: [PATCH 07/18] Add V4L2 request API vp8 hwaccel @@ -2180,15 +2180,15 @@ Signed-off-by: Jonas Karlman libavcodec/Makefile | 1 + libavcodec/hwaccels.h | 1 + libavcodec/v4l2_request_vp8.c | 180 ++++++++++++++++++++++++++++++++++ - libavcodec/vp8.c | 8 +- - 5 files changed, 192 insertions(+), 1 deletion(-) + libavcodec/vp8.c | 6 ++ + 5 files changed, 191 insertions(+) create mode 100644 libavcodec/v4l2_request_vp8.c diff --git a/configure b/configure -index 6ed48234dd25..a3c724861caa 100755 +index ec141fabbd..f16bed65a3 100755 --- a/configure +++ b/configure -@@ -3001,6 +3001,8 @@ vc1_vdpau_hwaccel_deps="vdpau" +@@ -3027,6 +3027,8 @@ vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" vp8_nvdec_hwaccel_deps="nvdec" vp8_nvdec_hwaccel_select="vp8_decoder" @@ -2197,7 +2197,7 @@ index 6ed48234dd25..a3c724861caa 100755 vp8_vaapi_hwaccel_deps="vaapi" vp8_vaapi_hwaccel_select="vp8_decoder" vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" -@@ -6573,6 +6575,7 @@ fi +@@ -6634,6 +6636,7 @@ fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;" @@ -2206,10 +2206,10 @@ index 6ed48234dd25..a3c724861caa 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 9a10a292e377..c74d2ebfdd23 100644 +index 02c023a447..c79d678eb3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -939,6 +939,7 @@ OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec_other.o +@@ -971,6 +971,7 @@ OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o OBJS-$(CONFIG_VC1_VDPAU_HWACCEL) += vdpau_vc1.o OBJS-$(CONFIG_VP8_NVDEC_HWACCEL) += nvdec_vp8.o @@ -2218,10 +2218,10 @@ index 9a10a292e377..c74d2ebfdd23 100644 OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 44e00e79b515..14838083ec36 100644 +index a8ae1483d8..9f8d41e367 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h -@@ -64,6 +64,7 @@ extern const AVHWAccel ff_vc1_nvdec_hwaccel; +@@ -69,6 +69,7 @@ extern const AVHWAccel ff_vc1_nvdec_hwaccel; extern const AVHWAccel ff_vc1_vaapi_hwaccel; extern const AVHWAccel ff_vc1_vdpau_hwaccel; extern const AVHWAccel ff_vp8_nvdec_hwaccel; @@ -2231,7 +2231,7 @@ index 44e00e79b515..14838083ec36 100644 extern const AVHWAccel ff_vp9_d3d11va2_hwaccel; diff --git a/libavcodec/v4l2_request_vp8.c b/libavcodec/v4l2_request_vp8.c new file mode 100644 -index 000000000000..bc0fc400727a +index 0000000000..bc0fc40072 --- /dev/null +++ b/libavcodec/v4l2_request_vp8.c @@ -0,0 +1,180 @@ @@ -2416,10 +2416,10 @@ index 000000000000..bc0fc400727a + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c -index e84fcdeaa1e7..0608d9e4e165 100644 +index d16e7b6aa3..8ee768d875 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c -@@ -175,6 +175,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) +@@ -176,6 +176,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) #endif #if CONFIG_VP8_NVDEC_HWACCEL AV_PIX_FMT_CUDA, @@ -2429,16 +2429,7 @@ index e84fcdeaa1e7..0608d9e4e165 100644 #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE, -@@ -198,7 +201,7 @@ int update_dimensions(VP8Context *s, int width, int height, int is_vp7) - return ret; - } - -- if (!s->actually_webp && !is_vp7) { -+ if (!s->actually_webp && !is_vp7 && s->pix_fmt == AV_PIX_FMT_NONE) { - s->pix_fmt = get_pixel_format(s); - if (s->pix_fmt < 0) - return AVERROR(EINVAL); -@@ -2968,6 +2971,9 @@ AVCodec ff_vp8_decoder = { +@@ -2972,6 +2975,9 @@ AVCodec ff_vp8_decoder = { #endif #if CONFIG_VP8_NVDEC_HWACCEL HWACCEL_NVDEC(vp8), @@ -2449,7 +2440,7 @@ index e84fcdeaa1e7..0608d9e4e165 100644 NULL }, -From aba2a109c8191b8e914522c7504f78385e1da3ed Mon Sep 17 00:00:00 2001 +From 0065c180f7345bef065e5704ddb9827dc18b2f4b Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 08/18] Add V4L2 request API hevc hwaccel @@ -2466,10 +2457,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/v4l2_request_hevc.c diff --git a/configure b/configure -index a3c724861caa..94476afd5df1 100755 +index f16bed65a3..02a80cf27f 100755 --- a/configure +++ b/configure -@@ -2941,6 +2941,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" +@@ -2967,6 +2967,8 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_deps="nvdec" hevc_nvdec_hwaccel_select="hevc_decoder" @@ -2478,7 +2469,7 @@ index a3c724861caa..94476afd5df1 100755 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" hevc_vaapi_hwaccel_select="hevc_decoder" hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" -@@ -6574,6 +6576,7 @@ fi +@@ -6635,6 +6637,7 @@ fi check_func_headers "linux/media.h linux/videodev2.h" v4l2_timeval_to_ns check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" @@ -2487,22 +2478,22 @@ index a3c724861caa..94476afd5df1 100755 check_cc vp8_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_VP8_FRAME;" diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index c74d2ebfdd23..d6af854daaa6 100644 +index c79d678eb3..0059074530 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -911,6 +911,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o +@@ -943,6 +943,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o - OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o + OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec.o +OBJS-$(CONFIG_HEVC_V4L2REQUEST_HWACCEL) += v4l2_request_hevc.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o - OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o + OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o h265_profile_level.o OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c -index 1eaeaf72f145..7e47bd7177e1 100644 +index 2231aed259..7507966d71 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c -@@ -372,6 +372,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -392,6 +392,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \ CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \ CONFIG_HEVC_NVDEC_HWACCEL + \ @@ -2510,7 +2501,7 @@ index 1eaeaf72f145..7e47bd7177e1 100644 CONFIG_HEVC_VAAPI_HWACCEL + \ CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \ CONFIG_HEVC_VDPAU_HWACCEL) -@@ -398,6 +399,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -418,6 +419,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; @@ -2520,7 +2511,7 @@ index 1eaeaf72f145..7e47bd7177e1 100644 #endif break; case AV_PIX_FMT_YUV420P10: -@@ -416,6 +420,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -439,6 +443,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; @@ -2530,7 +2521,7 @@ index 1eaeaf72f145..7e47bd7177e1 100644 #endif break; case AV_PIX_FMT_YUV444P: -@@ -3593,6 +3600,9 @@ AVCodec ff_hevc_decoder = { +@@ -3705,6 +3712,9 @@ AVCodec ff_hevc_decoder = { #endif #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(hevc), @@ -2541,10 +2532,10 @@ index 1eaeaf72f145..7e47bd7177e1 100644 NULL }, diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 14838083ec36..bd75e94f4cae 100644 +index 9f8d41e367..ffb9fa5087 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h -@@ -35,6 +35,7 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel; +@@ -40,6 +40,7 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel; extern const AVHWAccel ff_hevc_d3d11va2_hwaccel; extern const AVHWAccel ff_hevc_dxva2_hwaccel; extern const AVHWAccel ff_hevc_nvdec_hwaccel; @@ -2554,7 +2545,7 @@ index 14838083ec36..bd75e94f4cae 100644 extern const AVHWAccel ff_hevc_videotoolbox_hwaccel; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c new file mode 100644 -index 000000000000..d385c2f03615 +index 0000000000..d385c2f036 --- /dev/null +++ b/libavcodec/v4l2_request_hevc.c @@ -0,0 +1,574 @@ @@ -3133,7 +3124,7 @@ index 000000000000..d385c2f03615 + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; -From 7f7d8dd75d175f9f6944ed334c67380b6b4c8cbf Mon Sep 17 00:00:00 2001 +From 5877cc36995d4cdf012bcee11a36e9f4543d35fe Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Thu, 14 Feb 2019 23:20:05 +0100 Subject: [PATCH 09/18] Add and use private linux v5.14 headers for V4L2 @@ -3149,10 +3140,10 @@ Signed-off-by: Jonas Karlman create mode 100644 libavcodec/hevc-ctrls.h diff --git a/configure b/configure -index 94476afd5df1..e90c9b913dcb 100755 +index 02a80cf27f..30ee788711 100755 --- a/configure +++ b/configure -@@ -2941,7 +2941,7 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" +@@ -2967,7 +2967,7 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_deps="nvdec" hevc_nvdec_hwaccel_select="hevc_decoder" @@ -3163,7 +3154,7 @@ index 94476afd5df1..e90c9b913dcb 100755 hevc_vaapi_hwaccel_select="hevc_decoder" diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h new file mode 100644 -index 000000000000..53c0038c792b +index 0000000000..53c0038c79 --- /dev/null +++ b/libavcodec/hevc-ctrls.h @@ -0,0 +1,240 @@ @@ -3408,7 +3399,7 @@ index 000000000000..53c0038c792b + +#endif diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index d385c2f03615..ad555c3bb836 100644 +index d385c2f036..ad555c3bb8 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -19,6 +19,7 @@ @@ -3420,7 +3411,7 @@ index d385c2f03615..ad555c3bb836 100644 #define MAX_SLICES 16 -From 838ed5b6317f13d17b5890d769df325a3aaf0c98 Mon Sep 17 00:00:00 2001 +From 2cdf67404bf52fb684d1857442331f302d3a35d8 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 29 Apr 2019 22:08:59 +0000 Subject: [PATCH 10/18] HACK: hwcontext_drm: do not require drm device @@ -3431,10 +3422,10 @@ Signed-off-by: Jonas Karlman 1 file changed, 5 insertions(+) diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c -index 32cbde82ebfa..aa4794c5e665 100644 +index 7a9fdbd263..6297d1f9b6 100644 --- a/libavutil/hwcontext_drm.c +++ b/libavutil/hwcontext_drm.c -@@ -43,6 +43,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, +@@ -53,6 +53,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, AVDRMDeviceContext *hwctx = hwdev->hwctx; drmVersionPtr version; @@ -3447,7 +3438,7 @@ index 32cbde82ebfa..aa4794c5e665 100644 if (hwctx->fd < 0) return AVERROR(errno); -From 72db468e754b14ea76ad00fea2deaf55f47fac26 Mon Sep 17 00:00:00 2001 +From 37cbcb6ca05cea82e896e661a185dbf32da0702b Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 11/18] WIP: hevc scaling matrix @@ -3459,7 +3450,7 @@ Signed-off-by: Jernej Skrabec 2 files changed, 38 insertions(+) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index 53c0038c792b..0e5c4a2eecff 100644 +index 53c0038c79..0e5c4a2eec 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -19,6 +19,7 @@ @@ -3495,7 +3486,7 @@ index 53c0038c792b..0e5c4a2eecff 100644 #define V4L2_CID_CODEC_HANTRO_BASE (V4L2_CTRL_CLASS_CODEC | 0x1200) /* diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index ad555c3bb836..b6c191120e44 100644 +index ad555c3bb8..b6c191120e 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -27,6 +27,7 @@ typedef struct V4L2RequestControlsHEVC { @@ -3552,7 +3543,7 @@ index ad555c3bb836..b6c191120e44 100644 .id = V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS, .ptr = &controls->slice_params, -From fb279e99271bed8ba6bb3a01fad6cf9232567ff8 Mon Sep 17 00:00:00 2001 +From ddf97421cbb8583af0f96fa53a0d7f12d9f4ed21 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 12/18] WIP: hevc segment address @@ -3564,7 +3555,7 @@ Signed-off-by: Jernej Skrabec 2 files changed, 4 insertions(+) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index 0e5c4a2eecff..42ad0fe81e66 100644 +index 0e5c4a2eec..42ad0fe81e 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -198,6 +198,7 @@ struct v4l2_ctrl_hevc_slice_params { @@ -3576,7 +3567,7 @@ index 0e5c4a2eecff..42ad0fe81e66 100644 __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX]; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index b6c191120e44..f645c538c25c 100644 +index b6c191120e..f645c538c2 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -188,6 +188,9 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, @@ -3590,7 +3581,7 @@ index b6c191120e44..f645c538c25c 100644 .nal_unit_type = h->nal_unit_type, .nuh_temporal_id_plus1 = h->temporal_id + 1, -From 55a85bb6be2b1661c4830b5d085e5657579436a4 Mon Sep 17 00:00:00 2001 +From 1bc89a4553c4c4f7cf4654fe1a7e39de16531126 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sat, 15 Dec 2018 22:32:16 +0100 Subject: [PATCH 13/18] WIP: hevc entry point offsets @@ -3602,7 +3593,7 @@ Signed-off-by: Jernej Skrabec 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index 42ad0fe81e66..a24916603017 100644 +index 42ad0fe81e..a249166030 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -202,7 +202,9 @@ struct v4l2_ctrl_hevc_slice_params { @@ -3617,7 +3608,7 @@ index 42ad0fe81e66..a24916603017 100644 /* ISO/IEC 23008-2, ITU-T Rec. H.265: Weighted prediction parameter */ struct v4l2_hevc_pred_weight_table pred_weight_table; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index f645c538c25c..601202a77d7a 100644 +index f645c538c2..601202a77d 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -256,6 +256,15 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, @@ -3637,7 +3628,7 @@ index f645c538c25c..601202a77d7a 100644 static void fill_sps(struct v4l2_ctrl_hevc_sps *ctrl, const HEVCContext *h) -From 4c1dd736399c6c4f0dbc5510616b16773b892832 Mon Sep 17 00:00:00 2001 +From 79118d89a57da6fe3fa9b065207e4959c56eff76 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Dec 2019 16:13:55 +0100 Subject: [PATCH 14/18] WIP: Add V4L2 request API vp9 hwaccel @@ -3654,10 +3645,10 @@ Signed-off-by: Boris Brezillon create mode 100644 libavcodec/v4l2_request_vp9.c diff --git a/configure b/configure -index e90c9b913dcb..33c8ed54679a 100755 +index 30ee788711..4e3e868d7a 100755 --- a/configure +++ b/configure -@@ -3015,6 +3015,8 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" +@@ -3041,6 +3041,8 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" vp9_dxva2_hwaccel_select="vp9_decoder" vp9_nvdec_hwaccel_deps="nvdec" vp9_nvdec_hwaccel_select="vp9_decoder" @@ -3666,7 +3657,7 @@ index e90c9b913dcb..33c8ed54679a 100755 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" vp9_vaapi_hwaccel_select="vp9_decoder" vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9" -@@ -6579,6 +6581,7 @@ check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" +@@ -6640,6 +6642,7 @@ check_cc h264_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_H264_SLICE;" check_cc hevc_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC_SLICE;" check_cc mpeg2_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2_SLICE;" check_cc vp8_v4l2_request linux/videodev2.h "int i = V4L2_PIX_FMT_VP8_FRAME;" @@ -3675,22 +3666,22 @@ index e90c9b913dcb..33c8ed54679a 100755 check_headers sys/videoio.h test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index d6af854daaa6..2f0e0a0976f6 100644 +index 0059074530..38edf1cfe5 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile -@@ -945,6 +945,7 @@ OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o +@@ -977,6 +977,7 @@ OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_NVDEC_HWACCEL) += nvdec_vp9.o +OBJS-$(CONFIG_VP9_V4L2REQUEST_HWACCEL) += v4l2_request_vp9.o OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o - OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec_other.o + OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index bd75e94f4cae..03a1aefe09bc 100644 +index ffb9fa5087..fc5d0b0479 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h -@@ -71,6 +71,7 @@ extern const AVHWAccel ff_vp9_d3d11va_hwaccel; +@@ -76,6 +76,7 @@ extern const AVHWAccel ff_vp9_d3d11va_hwaccel; extern const AVHWAccel ff_vp9_d3d11va2_hwaccel; extern const AVHWAccel ff_vp9_dxva2_hwaccel; extern const AVHWAccel ff_vp9_nvdec_hwaccel; @@ -3700,7 +3691,7 @@ index bd75e94f4cae..03a1aefe09bc 100644 extern const AVHWAccel ff_wmv3_d3d11va_hwaccel; diff --git a/libavcodec/v4l2_request_vp9.c b/libavcodec/v4l2_request_vp9.c new file mode 100644 -index 000000000000..4074c7fe4b8e +index 0000000000..4074c7fe4b --- /dev/null +++ b/libavcodec/v4l2_request_vp9.c @@ -0,0 +1,352 @@ @@ -4057,7 +4048,7 @@ index 000000000000..4074c7fe4b8e + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c -index fd0bab14a239..434f905c62c5 100644 +index 4659f94ee8..47340c3875 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -191,6 +191,7 @@ static int update_size(AVCodecContext *avctx, int w, int h) @@ -4070,25 +4061,25 @@ index fd0bab14a239..434f905c62c5 100644 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; @@ -223,6 +224,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif - #if CONFIG_VP9_VAAPI_HWACCEL - *fmtp++ = AV_PIX_FMT_VAAPI; + #if CONFIG_VP9_VDPAU_HWACCEL + *fmtp++ = AV_PIX_FMT_VDPAU; +#endif +#if CONFIG_VP9_V4L2REQUEST_HWACCEL + *fmtp++ = AV_PIX_FMT_DRM_PRIME; #endif break; case AV_PIX_FMT_YUV420P12: -@@ -231,6 +235,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) +@@ -234,6 +238,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif - #if CONFIG_VP9_VAAPI_HWACCEL - *fmtp++ = AV_PIX_FMT_VAAPI; + #if CONFIG_VP9_VDPAU_HWACCEL + *fmtp++ = AV_PIX_FMT_VDPAU; +#endif +#if CONFIG_VP9_V4L2REQUEST_HWACCEL + *fmtp++ = AV_PIX_FMT_DRM_PRIME; #endif break; } -@@ -700,7 +707,8 @@ static int decode_frame_header(AVCodecContext *avctx, +@@ -703,7 +710,8 @@ static int decode_frame_header(AVCodecContext *avctx, get_bits(&s->gb, 8) : 255; } @@ -4098,7 +4089,7 @@ index fd0bab14a239..434f905c62c5 100644 s->s.h.segmentation.absolute_vals = get_bits1(&s->gb); for (i = 0; i < 8; i++) { if ((s->s.h.segmentation.feat[i].q_enabled = get_bits1(&s->gb))) -@@ -1909,6 +1917,9 @@ AVCodec ff_vp9_decoder = { +@@ -1912,6 +1920,9 @@ AVCodec ff_vp9_decoder = { #endif #if CONFIG_VP9_VDPAU_HWACCEL HWACCEL_VDPAU(vp9), @@ -4109,7 +4100,7 @@ index fd0bab14a239..434f905c62c5 100644 NULL }, diff --git a/libavcodec/vp9shared.h b/libavcodec/vp9shared.h -index 54726df742f9..fee3568736f7 100644 +index 54726df742..fee3568736 100644 --- a/libavcodec/vp9shared.h +++ b/libavcodec/vp9shared.h @@ -131,6 +131,7 @@ typedef struct VP9BitstreamHeader { @@ -4121,7 +4112,7 @@ index 54726df742f9..fee3568736f7 100644 uint8_t pred_prob[3]; struct { -From b4ce2068a1ba8723908fd39c1b2099b286715dde Mon Sep 17 00:00:00 2001 +From 189a3278e21e4d6ff06d1f1fe4c7430357499471 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 12 Dec 2019 16:13:55 +0100 Subject: [PATCH 15/18] WIP: Add and use vp9 private linux header @@ -4135,10 +4126,10 @@ Signed-off-by: Boris Brezillon create mode 100644 libavcodec/vp9-ctrls.h diff --git a/configure b/configure -index 33c8ed54679a..921e74470145 100755 +index 4e3e868d7a..1c1929d2c2 100755 --- a/configure +++ b/configure -@@ -3015,7 +3015,7 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" +@@ -3041,7 +3041,7 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" vp9_dxva2_hwaccel_select="vp9_decoder" vp9_nvdec_hwaccel_deps="nvdec" vp9_nvdec_hwaccel_select="vp9_decoder" @@ -4148,7 +4139,7 @@ index 33c8ed54679a..921e74470145 100755 vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" vp9_vaapi_hwaccel_select="vp9_decoder" diff --git a/libavcodec/v4l2_request_vp9.c b/libavcodec/v4l2_request_vp9.c -index 4074c7fe4b8e..2e10b7ad1acb 100644 +index 4074c7fe4b..2e10b7ad1a 100644 --- a/libavcodec/v4l2_request_vp9.c +++ b/libavcodec/v4l2_request_vp9.c @@ -19,6 +19,7 @@ @@ -4161,7 +4152,7 @@ index 4074c7fe4b8e..2e10b7ad1acb 100644 struct v4l2_ctrl_vp9_frame_decode_params decode_params; diff --git a/libavcodec/vp9-ctrls.h b/libavcodec/vp9-ctrls.h new file mode 100644 -index 000000000000..0cdea8a18b72 +index 0000000000..0cdea8a18b --- /dev/null +++ b/libavcodec/vp9-ctrls.h @@ -0,0 +1,485 @@ @@ -4651,7 +4642,7 @@ index 000000000000..0cdea8a18b72 + +#endif /* _VP9_CTRLS_H_ */ -From 5ba520963c60bb72e9e418a4392724c619e95f89 Mon Sep 17 00:00:00 2001 +From 8fde9d49bf9fbf0a1a9fdf242753c2b1b6ae377c Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Fri, 15 May 2020 16:54:05 +0000 Subject: [PATCH 16/18] WIP: add NV15 and NV20 support @@ -4663,10 +4654,10 @@ Signed-off-by: Jonas Karlman 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c -index dd5ba98a02cb..c952997d685d 100644 +index 0a10d00aad..45057fd049 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c -@@ -785,10 +785,17 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -794,10 +794,17 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) *fmt++ = AV_PIX_FMT_GBRP10; } else *fmt++ = AV_PIX_FMT_YUV444P10; @@ -4686,7 +4677,7 @@ index dd5ba98a02cb..c952997d685d 100644 break; case 12: if (CHROMA444(h)) { -@@ -827,6 +834,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) +@@ -836,6 +843,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) else *fmt++ = AV_PIX_FMT_YUV444P; } else if (CHROMA422(h)) { @@ -4697,7 +4688,7 @@ index dd5ba98a02cb..c952997d685d 100644 *fmt++ = AV_PIX_FMT_YUVJ422P; else diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c -index 5234b5049b0d..0b294feff2eb 100644 +index 5234b5049b..0b294feff2 100644 --- a/libavcodec/v4l2_request.c +++ b/libavcodec/v4l2_request.c @@ -188,6 +188,13 @@ const uint32_t v4l2_request_capture_pixelformats[] = { @@ -4738,7 +4729,7 @@ index 5234b5049b0d..0b294feff2eb 100644 default: return -1; -From ea35c24c6c19e90e8a33bf9415cf3b90143221f7 Mon Sep 17 00:00:00 2001 +From e60693f9f34d717a53b54768e56ccbbdda375abe Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Mon, 27 Jul 2020 23:15:45 +0000 Subject: [PATCH 17/18] HACK: define drm NV15 and NV20 format @@ -4748,7 +4739,7 @@ Subject: [PATCH 17/18] HACK: define drm NV15 and NV20 format 1 file changed, 8 insertions(+) diff --git a/libavcodec/v4l2_request.c b/libavcodec/v4l2_request.c -index 0b294feff2eb..a8f0ee79eeef 100644 +index 0b294feff2..a8f0ee79ee 100644 --- a/libavcodec/v4l2_request.c +++ b/libavcodec/v4l2_request.c @@ -30,6 +30,14 @@ @@ -4767,7 +4758,7 @@ index 0b294feff2eb..a8f0ee79eeef 100644 { V4L2RequestDescriptor *req = (V4L2RequestDescriptor*)frame->data[0]; -From 36dbf222487a459156f1752436530b3fae39d35c Mon Sep 17 00:00:00 2001 +From 688bb66bf9715c02565b63446b75933282d41805 Mon Sep 17 00:00:00 2001 From: Jonas Karlman Date: Wed, 13 May 2020 22:51:21 +0000 Subject: [PATCH 18/18] WIP: hevc rkvdec fields @@ -4779,7 +4770,7 @@ Signed-off-by: Jonas Karlman 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc-ctrls.h b/libavcodec/hevc-ctrls.h -index a24916603017..cd143526685f 100644 +index a249166030..cd14352668 100644 --- a/libavcodec/hevc-ctrls.h +++ b/libavcodec/hevc-ctrls.h @@ -58,6 +58,8 @@ enum v4l2_mpeg_video_hevc_start_code { @@ -4829,7 +4820,7 @@ index a24916603017..cd143526685f 100644 __u32 entry_point_offset_minus1[256]; __u8 padding[8]; diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c -index 601202a77d7a..be7838244447 100644 +index 601202a77d..be78382444 100644 --- a/libavcodec/v4l2_request_hevc.c +++ b/libavcodec/v4l2_request_hevc.c @@ -214,6 +214,9 @@ static void v4l2_request_hevc_fill_slice_params(const HEVCContext *h, From 1f4fa5d080afc9f5ffd494fac274fc51608a2d89 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 10/11] ffmpeg: update libreelec patch Patch created using revisions dc91b91..635cf67 from branch 4.4-libreelec-misc of https://github.com/LibreELEC/FFmpeg --- .../patches/libreelec/ffmpeg-001-libreelec.patch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/multimedia/ffmpeg/patches/libreelec/ffmpeg-001-libreelec.patch b/packages/multimedia/ffmpeg/patches/libreelec/ffmpeg-001-libreelec.patch index 9db1e95648..cb1c3ec27d 100644 --- a/packages/multimedia/ffmpeg/patches/libreelec/ffmpeg-001-libreelec.patch +++ b/packages/multimedia/ffmpeg/patches/libreelec/ffmpeg-001-libreelec.patch @@ -1,4 +1,4 @@ -From 823b70bfa0f451a0f8cd0539e1707f7bb7ff5891 Mon Sep 17 00:00:00 2001 +From 8f7c8a0f9e28641880d72996b9452e0a9da1288c Mon Sep 17 00:00:00 2001 From: Lukas Rusak Date: Wed, 10 Apr 2019 13:39:21 -0700 Subject: [PATCH 1/2] libavcodec/libdav1d: add libdav1d_get_format method to @@ -18,10 +18,10 @@ decoding is properly activated. 1 file changed, 11 insertions(+) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c -index bbb3ec1e6c..d8a7555c29 100644 +index 3c2a68b7e0..68996426cc 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c -@@ -55,6 +55,16 @@ static const enum AVPixelFormat pix_fmt_rgb[3] = { +@@ -58,6 +58,16 @@ static const enum AVPixelFormat pix_fmt_rgb[3] = { AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, }; @@ -38,7 +38,7 @@ index bbb3ec1e6c..d8a7555c29 100644 static void libdav1d_log_callback(void *opaque, const char *fmt, va_list vl) { AVCodecContext *c = opaque; -@@ -259,6 +269,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) +@@ -264,6 +274,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) c->profile = p->seq_hdr->profile; c->level = ((p->seq_hdr->operating_points[0].major_level - 2) << 2) | p->seq_hdr->operating_points[0].minor_level; @@ -47,7 +47,7 @@ index bbb3ec1e6c..d8a7555c29 100644 frame->height = p->p.h; if (c->width != p->p.w || c->height != p->p.h) { -From 1485078472d107806d1d3f52f89e3ff47ae8715c Mon Sep 17 00:00:00 2001 +From 635cf67be3d37159c96e75f00399b3e232372251 Mon Sep 17 00:00:00 2001 From: chewitt Date: Sun, 11 Aug 2019 07:08:19 +0000 Subject: [PATCH 2/2] add long-term yuv2rgb logging patch @@ -57,7 +57,7 @@ Subject: [PATCH 2/2] add long-term yuv2rgb logging patch 1 file changed, 4 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c -index 588462504e..20364ff318 100644 +index 6a3956e8e2..d6f9aea166 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -688,10 +688,6 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) From 3cb42b52483840ba0a5cfb51d61ce60634b79f17 Mon Sep 17 00:00:00 2001 From: CvH Date: Sat, 25 Sep 2021 15:40:17 +0200 Subject: [PATCH 11/11] ffmpeg: update rpi patch Patch created using revisions dc91b91..42505d1 from branch dev/4.4/rpi_import_1 of https://github.com/jc-kynesim/rpi-ffmpeg --- .../ffmpeg/patches/rpi/ffmpeg-001-rpi.patch | 1287 ++++++++++------- 1 file changed, 737 insertions(+), 550 deletions(-) diff --git a/packages/multimedia/ffmpeg/patches/rpi/ffmpeg-001-rpi.patch b/packages/multimedia/ffmpeg/patches/rpi/ffmpeg-001-rpi.patch index fdd03f7036..acb070e4d6 100644 --- a/packages/multimedia/ffmpeg/patches/rpi/ffmpeg-001-rpi.patch +++ b/packages/multimedia/ffmpeg/patches/rpi/ffmpeg-001-rpi.patch @@ -1,16 +1,16 @@ diff --git a/configure b/configure -index 36713ab658..665d247bf7 100755 +index d7a3f507e8..cfbbb4f27d 100755 --- a/configure +++ b/configure -@@ -274,6 +274,7 @@ External library support: - --enable-libtls enable LibreSSL (via libtls), needed for https support +@@ -279,6 +279,7 @@ External library support: if openssl, gnutls or mbedtls is not used [no] --enable-libtwolame enable MP2 encoding via libtwolame [no] + --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] + --enable-libudev enable libudev [no] --enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libvidstab enable video stabilization using vid.stab [no] --enable-libvmaf enable vmaf filter via libvmaf [no] -@@ -336,12 +337,17 @@ External library support: +@@ -340,12 +341,17 @@ External library support: --enable-libmfx enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no] --enable-libnpp enable Nvidia Performance Primitives-based code [no] --enable-mmal enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no] @@ -28,7 +28,7 @@ index 36713ab658..665d247bf7 100755 --disable-vaapi disable Video Acceleration API (mainly Unix/Intel) code [autodetect] --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] --disable-videotoolbox disable VideoToolbox code [autodetect] -@@ -1771,6 +1777,7 @@ EXTERNAL_LIBRARY_LIST=" +@@ -1774,6 +1780,7 @@ EXTERNAL_LIBRARY_LIST=" libdav1d libdc1394 libdrm @@ -36,15 +36,15 @@ index 36713ab658..665d247bf7 100755 libflite libfontconfig libfreetype -@@ -1807,6 +1814,7 @@ EXTERNAL_LIBRARY_LIST=" - libtesseract +@@ -1814,6 +1821,7 @@ EXTERNAL_LIBRARY_LIST=" libtheora libtwolame + libuavs3d + libudev libv4l2 + libvmaf libvorbis - libvpx -@@ -1861,7 +1869,10 @@ HWACCEL_LIBRARY_LIST=" +@@ -1868,7 +1876,10 @@ HWACCEL_LIBRARY_LIST=" mmal omx opencl @@ -55,7 +55,7 @@ index 36713ab658..665d247bf7 100755 " DOCUMENT_LIST=" -@@ -1877,12 +1888,16 @@ FEATURE_LIST=" +@@ -1884,12 +1895,16 @@ FEATURE_LIST=" gray hardcoded_tables omx_rpi @@ -72,7 +72,7 @@ index 36713ab658..665d247bf7 100755 " # this list should be kept in linking order -@@ -1923,6 +1938,7 @@ SUBSYSTEM_LIST=" +@@ -1930,6 +1945,7 @@ SUBSYSTEM_LIST=" pixelutils network rdft @@ -80,7 +80,7 @@ index 36713ab658..665d247bf7 100755 " # COMPONENT_LIST needs to come last to ensure correct dependency checking -@@ -2405,9 +2421,11 @@ CONFIG_EXTRA=" +@@ -2416,9 +2432,11 @@ CONFIG_EXTRA=" rangecoder riffdec riffenc @@ -92,16 +92,16 @@ index 36713ab658..665d247bf7 100755 scene_sad sinewin snappy -@@ -2737,6 +2755,8 @@ hap_decoder_select="snappy texturedsp" +@@ -2750,6 +2768,8 @@ hap_decoder_select="snappy texturedsp" hap_encoder_deps="libsnappy" hap_encoder_select="texturedspenc" - hevc_decoder_select="bswapdsp cabac golomb hevcparse videodsp" + hevc_decoder_select="atsc_a53 bswapdsp cabac golomb hevcparse videodsp" +hevc_rpi_decoder_deps="rpi" +hevc_rpi_decoder_select="hevc_decoder sand" huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp" huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llvidencdsp" hymt_decoder_select="huffyuv_decoder" -@@ -2903,6 +2923,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" +@@ -2919,6 +2939,7 @@ d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32" ffnvcodec_deps_any="libdl LoadLibrary" nvdec_deps="ffnvcodec" @@ -109,7 +109,7 @@ index 36713ab658..665d247bf7 100755 vaapi_x11_deps="xlib" videotoolbox_hwaccel_deps="videotoolbox pthreads" videotoolbox_hwaccel_extralibs="-framework QuartzCore" -@@ -2934,6 +2955,12 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" +@@ -2960,6 +2981,12 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_deps="nvdec" hevc_nvdec_hwaccel_select="hevc_decoder" @@ -122,7 +122,7 @@ index 36713ab658..665d247bf7 100755 hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC" hevc_vaapi_hwaccel_select="hevc_decoder" hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC" -@@ -3401,8 +3428,14 @@ sndio_indev_deps="sndio" +@@ -3437,8 +3464,14 @@ sndio_indev_deps="sndio" sndio_outdev_deps="sndio" v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" v4l2_indev_suggest="libv4l2" @@ -137,7 +137,7 @@ index 36713ab658..665d247bf7 100755 vfwcap_indev_deps="vfw32 vfwcap_defines" xcbgrab_indev_deps="libxcb" xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes" -@@ -3618,6 +3651,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" +@@ -3657,6 +3690,7 @@ tonemap_vaapi_filter_deps="vaapi VAProcFilterParameterBufferHDRToneMapping" tonemap_opencl_filter_deps="opencl const_nan" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" @@ -145,7 +145,7 @@ index 36713ab658..665d247bf7 100755 unsharp_opencl_filter_deps="opencl" uspp_filter_deps="gpl avcodec" vaguedenoiser_filter_deps="gpl" -@@ -6299,6 +6333,7 @@ enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.4.0" "dav1d +@@ -6357,6 +6391,7 @@ enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.5.0" "dav1d enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion @@ -153,15 +153,15 @@ index 36713ab658..665d247bf7 100755 enabled libfdk_aac && { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac && warn "using libfdk without pkg-config"; } } -@@ -6376,6 +6411,7 @@ enabled libtls && require_pkg_config libtls libtls tls.h tls_configur - enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame && +@@ -6438,6 +6473,7 @@ enabled libtwolame && require libtwolame twolame.h twolame_init -ltwolame { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } + enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" uavs3d.h uavs3d_decode +enabled libudev && require_pkg_config libudev libudev libudev.h udev_new enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl enabled libvidstab && require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit - enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.3.9" libvmaf.h compute_vmaf -@@ -6430,11 +6466,12 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt + enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.5.2" libvmaf.h compute_vmaf +@@ -6491,11 +6527,12 @@ enabled mbedtls && { check_pkg_config mbedtls mbedtls mbedtls/x509_crt check_lib mbedtls mbedtls/ssl.h mbedtls_ssl_init -lmbedtls -lmbedx509 -lmbedcrypto || die "ERROR: mbedTLS not found"; } enabled mediacodec && { enabled jni || die "ERROR: mediacodec requires --enable-jni"; } @@ -176,7 +176,7 @@ index 36713ab658..665d247bf7 100755 die "ERROR: mmal not found" && check_func_headers interface/mmal/mmal.h "MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS"; } enabled openal && { { for al_extralibs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do -@@ -6475,6 +6512,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r +@@ -6536,6 +6573,10 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r { enabled libdrm || die "ERROR: rkmpp requires --enable-libdrm"; } } @@ -187,7 +187,7 @@ index 36713ab658..665d247bf7 100755 enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init -@@ -6556,6 +6597,8 @@ if enabled v4l2_m2m; then +@@ -6617,6 +6658,8 @@ if enabled v4l2_m2m; then check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" fi @@ -197,10 +197,10 @@ index 36713ab658..665d247bf7 100755 test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c -index 2e9448ea2b..7d22427b1b 100644 +index 46bb014de8..a29f7d3b5b 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c -@@ -2118,8 +2118,8 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) +@@ -2186,8 +2186,8 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) ifilter->channel_layout != frame->channel_layout; break; case AVMEDIA_TYPE_VIDEO: @@ -211,7 +211,7 @@ index 2e9448ea2b..7d22427b1b 100644 break; } -@@ -2130,6 +2130,9 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) +@@ -2198,6 +2198,9 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) (ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data)) need_reinit = 1; @@ -221,7 +221,7 @@ index 2e9448ea2b..7d22427b1b 100644 if (need_reinit) { ret = ifilter_parameters_from_frame(ifilter, frame); if (ret < 0) -@@ -2400,8 +2403,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ +@@ -2466,8 +2469,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ decoded_frame->top_field_first = ist->top_field_first; ist->frames_decoded++; @@ -231,7 +231,7 @@ index 2e9448ea2b..7d22427b1b 100644 err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame); if (err < 0) goto fail; -@@ -2819,6 +2821,16 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat +@@ -2895,6 +2897,16 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat } else { const HWAccel *hwaccel = NULL; int i; @@ -248,7 +248,7 @@ index 2e9448ea2b..7d22427b1b 100644 for (i = 0; hwaccels[i].name; i++) { if (hwaccels[i].pix_fmt == *p) { hwaccel = &hwaccels[i]; -@@ -2913,6 +2925,15 @@ static int init_input_stream(int ist_index, char *error, int error_len) +@@ -2990,6 +3002,15 @@ static int init_input_stream(int ist_index, char *error, int error_len) return ret; } @@ -265,7 +265,7 @@ index 2e9448ea2b..7d22427b1b 100644 if (ret == AVERROR_EXPERIMENTAL) abort_codec_experimental(codec, 0); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h -index 828cb2a4ff..f2abea94d7 100644 +index 606f2afe0c..448cd2e009 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -61,6 +61,7 @@ enum HWAccelID { @@ -276,7 +276,7 @@ index 828cb2a4ff..f2abea94d7 100644 }; typedef struct HWAccel { -@@ -590,6 +591,7 @@ extern int video_sync_method; +@@ -611,6 +612,7 @@ extern int video_sync_method; extern float frame_drop_threshold; extern int do_benchmark; extern int do_benchmark_all; @@ -285,10 +285,10 @@ index 828cb2a4ff..f2abea94d7 100644 extern int do_hex_dump; extern int do_pkt_dump; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c -index 422e1268e9..deb89c076d 100644 +index 4ab769c07b..5cdc3a7b6c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c -@@ -1186,8 +1186,8 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) +@@ -1160,8 +1160,8 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) ifilter->format = frame->format; @@ -313,10 +313,10 @@ index fc4a5d31d6..cc69dce40e 100644 name = av_malloc(index_pos + 4); if (!name) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c -index 2eb4e1c973..ffbfa9accf 100644 +index 807e783422..456d4f349b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c -@@ -130,12 +130,22 @@ static const char *opt_name_enc_time_bases[] = {"enc_time_base", NULL +@@ -133,12 +133,22 @@ static const char *const opt_name_enc_time_bases[] = {"enc_time_base" }\ } @@ -339,7 +339,7 @@ index 2eb4e1c973..ffbfa9accf 100644 #endif { 0 }, }; -@@ -155,6 +165,7 @@ float frame_drop_threshold = 0; +@@ -158,6 +168,7 @@ float frame_drop_threshold = 0; int do_deinterlace = 0; int do_benchmark = 0; int do_benchmark_all = 0; @@ -347,7 +347,7 @@ index 2eb4e1c973..ffbfa9accf 100644 int do_hex_dump = 0; int do_pkt_dump = 0; int copy_ts = 0; -@@ -3460,6 +3471,8 @@ const OptionDef options[] = { +@@ -3499,6 +3510,8 @@ const OptionDef options[] = { "add timings for benchmarking" }, { "benchmark_all", OPT_BOOL | OPT_EXPERT, { &do_benchmark_all }, "add timings for each task" }, @@ -357,7 +357,7 @@ index 2eb4e1c973..ffbfa9accf 100644 "write program-readable progress information", "url" }, { "stdin", OPT_BOOL | OPT_EXPERT, { &stdin_interaction }, diff --git a/libavcodec/Makefile b/libavcodec/Makefile -index 5a6ea59715..069865ee37 100644 +index 33a280cf69..be3b73e7c4 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -19,6 +19,7 @@ HEADERS = ac3_parser.h \ @@ -368,15 +368,15 @@ index 5a6ea59715..069865ee37 100644 vaapi.h \ vdpau.h \ version.h \ -@@ -138,6 +139,7 @@ OBJS-$(CONFIG_QSVDEC) += qsvdec.o +@@ -140,6 +141,7 @@ OBJS-$(CONFIG_QSVDEC) += qsvdec.o OBJS-$(CONFIG_QSVENC) += qsvenc.o OBJS-$(CONFIG_RANGECODER) += rangecoder.o OBJS-$(CONFIG_RDFT) += rdft.o +OBJS-$(CONFIG_RPI) += rpi_qpu.o rpi_mailbox.o rpi_zc.o OBJS-$(CONFIG_RV34DSP) += rv34dsp.o OBJS-$(CONFIG_SHARED) += log2_tab.o reverse.o - OBJS-$(CONFIG_SINEWIN) += sinewin.o sinewin_fixed.o -@@ -152,7 +154,10 @@ OBJS-$(CONFIG_VIDEODSP) += videodsp.o + OBJS-$(CONFIG_SINEWIN) += sinewin.o +@@ -154,7 +156,10 @@ OBJS-$(CONFIG_VIDEODSP) += videodsp.o OBJS-$(CONFIG_VP3DSP) += vp3dsp.o OBJS-$(CONFIG_VP56DSP) += vp56dsp.o OBJS-$(CONFIG_VP8DSP) += vp8dsp.o @@ -388,7 +388,7 @@ index 5a6ea59715..069865ee37 100644 OBJS-$(CONFIG_WMA_FREQS) += wma_freqs.o OBJS-$(CONFIG_WMV2DSP) += wmv2dsp.o -@@ -391,6 +396,14 @@ OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec_h2645.o +@@ -403,6 +408,14 @@ OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc_ps_enc.o \ hevc_data.o OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o @@ -403,20 +403,20 @@ index 5a6ea59715..069865ee37 100644 OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o -@@ -909,6 +922,10 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o +@@ -941,6 +954,10 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o - OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o + OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec.o +OBJS-$(CONFIG_HEVC_RPI4_8_HWACCEL) += rpivid_hevc.o +OBJS-$(CONFIG_HEVC_RPI4_10_HWACCEL) += rpivid_hevc.o +OBJS-$(CONFIG_HEVC_V4L2REQUEST_HWACCEL) += v4l2_request_hevc.o v4l2_req_decode_q.o\ + v4l2_req_hevc_v1.o v4l2_req_hevc_v2.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o - OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o + OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o h265_profile_level.o OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o -@@ -1261,3 +1278,31 @@ $(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h +@@ -1297,3 +1314,31 @@ $(SUBDIR)pcm.o: $(SUBDIR)pcm_tables.h + $(SUBDIR)qdm2.o: $(SUBDIR)qdm2_tables.h $(SUBDIR)sinewin.o: $(SUBDIR)sinewin_tables.h - $(SUBDIR)sinewin_fixed.o: $(SUBDIR)sinewin_fixed_tables.h endif + +ifdef CONFIG_HEVC_RPI_DECODER @@ -447,10 +447,10 @@ index 5a6ea59715..069865ee37 100644 +$(SUBDIR)rpi_hevcdec.o $(SUBDIR)rpi_shader_template.o $(SUBDIR)rpi_qpu.o: $(SUBDIR)rpi_hevc_shader.h +endif diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c -index fa0c08d42e..89a25a398d 100644 +index 2e9a3581de..d9571b437f 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c -@@ -149,6 +149,7 @@ extern AVCodec ff_hap_decoder; +@@ -153,6 +153,7 @@ extern AVCodec ff_hap_decoder; extern AVCodec ff_hevc_decoder; extern AVCodec ff_hevc_qsv_decoder; extern AVCodec ff_hevc_rkmpp_decoder; @@ -458,7 +458,7 @@ index fa0c08d42e..89a25a398d 100644 extern AVCodec ff_hevc_v4l2m2m_decoder; extern AVCodec ff_hnm4_video_decoder; extern AVCodec ff_hq_hqa_decoder; -@@ -890,6 +891,41 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) +@@ -917,6 +918,41 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) } } @@ -501,10 +501,10 @@ index fa0c08d42e..89a25a398d 100644 { const AVCodec *p, *experimental = NULL; diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile -index c6be814153..442d60efe4 100644 +index c4ab93aeeb..cd926f7b33 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile -@@ -40,6 +40,8 @@ OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_init_arm.o \ +@@ -39,6 +39,8 @@ OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_init_arm.o \ arm/sbrdsp_init_arm.o OBJS-$(CONFIG_DCA_DECODER) += arm/synth_filter_init_arm.o OBJS-$(CONFIG_HEVC_DECODER) += arm/hevcdsp_init_arm.o @@ -513,7 +513,7 @@ index c6be814153..442d60efe4 100644 OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o OBJS-$(CONFIG_RV40_DECODER) += arm/rv40dsp_init_arm.o OBJS-$(CONFIG_SBC_ENCODER) += arm/sbcdsp_init_arm.o -@@ -140,10 +142,24 @@ NEON-OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_neon.o \ +@@ -137,10 +139,24 @@ NEON-OBJS-$(CONFIG_AAC_DECODER) += arm/aacpsdsp_neon.o \ NEON-OBJS-$(CONFIG_LLAUDDSP) += arm/lossless_audiodsp_neon.o NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/synth_filter_neon.o NEON-OBJS-$(CONFIG_HEVC_DECODER) += arm/hevcdsp_init_neon.o \ @@ -15290,10 +15290,10 @@ index 0000000000..af8c4c03f0 + +endfunc diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h -index c91b2fd169..003079cdc6 100644 +index 8a71c04230..53644506e5 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h -@@ -2567,6 +2567,17 @@ typedef struct AVHWAccel { +@@ -2595,6 +2595,17 @@ typedef struct AVHWAccel { * that avctx->hwaccel_priv_data is invalid. */ int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx); @@ -15312,30 +15312,25 @@ index c91b2fd169..003079cdc6 100644 /** diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h -index 1bf1c620d6..ccfa991f60 100644 +index 38d06b2842..bbf5d70560 100644 --- a/libavcodec/cabac.h +++ b/libavcodec/cabac.h -@@ -43,7 +43,14 @@ extern const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63]; - typedef struct CABACContext{ - int low; - int range; -- int outstanding_count; -+ union -+ { -+ int outstanding_count; -+ struct { -+ uint16_t bits; -+ uint16_t range; -+ } by22; -+ }; +@@ -44,6 +44,10 @@ typedef struct CABACContext{ const uint8_t *bytestream_start; const uint8_t *bytestream; const uint8_t *bytestream_end; ++ struct { ++ uint16_t bits; ++ uint16_t range; ++ } by22; + }CABACContext; + + int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size); diff --git a/libavcodec/codec.h b/libavcodec/codec.h -index 1fda619ee7..b4650f9ec9 100644 +index 50a22f6e3c..5acf572ef4 100644 --- a/libavcodec/codec.h +++ b/libavcodec/codec.h -@@ -349,6 +349,17 @@ const AVCodec *av_codec_iterate(void **opaque); +@@ -367,6 +367,17 @@ const AVCodec *av_codec_iterate(void **opaque); */ AVCodec *avcodec_find_decoder(enum AVCodecID id); @@ -15852,7 +15847,7 @@ index 0000000000..7cbbbf055f + +#endif diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c -index 5af4b788d5..c7314a6af8 100644 +index 463d352055..7feff43c28 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -98,6 +98,19 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal, @@ -15876,10 +15871,10 @@ index 5af4b788d5..c7314a6af8 100644 num = ps->vps->vps_num_units_in_tick; den = ps->vps->vps_time_scale; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c -index 1eaeaf72f1..b6871ff2e2 100644 +index 2231aed259..6d2d66dfdf 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c -@@ -332,6 +332,19 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps) +@@ -333,6 +333,19 @@ static void export_stream_params(HEVCContext *s, const HEVCSPS *sps) ff_set_sar(avctx, sps->vui.sar); @@ -15899,7 +15894,7 @@ index 1eaeaf72f1..b6871ff2e2 100644 if (sps->vui.video_signal_type_present_flag) avctx->color_range = sps->vui.video_full_range_flag ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; -@@ -372,14 +385,20 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -392,14 +405,20 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + \ CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \ CONFIG_HEVC_NVDEC_HWACCEL + \ @@ -15920,7 +15915,7 @@ index 1eaeaf72f1..b6871ff2e2 100644 #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif -@@ -398,9 +417,15 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -418,9 +437,15 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; @@ -15936,7 +15931,7 @@ index 1eaeaf72f1..b6871ff2e2 100644 #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif -@@ -416,6 +441,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) +@@ -439,6 +464,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; @@ -15946,7 +15941,7 @@ index 1eaeaf72f1..b6871ff2e2 100644 #endif break; case AV_PIX_FMT_YUV444P: -@@ -3230,7 +3258,14 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, +@@ -3327,7 +3355,14 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output, s->ref = NULL; ret = decode_nal_units(s, avpkt->data, avpkt->size); if (ret < 0) @@ -15961,7 +15956,7 @@ index 1eaeaf72f1..b6871ff2e2 100644 if (avctx->hwaccel) { if (s->ref && (ret = avctx->hwaccel->end_frame(avctx)) < 0) { -@@ -3585,6 +3620,15 @@ AVCodec ff_hevc_decoder = { +@@ -3697,6 +3732,15 @@ AVCodec ff_hevc_decoder = { #if CONFIG_HEVC_NVDEC_HWACCEL HWACCEL_NVDEC(hevc), #endif @@ -15978,10 +15973,10 @@ index 1eaeaf72f1..b6871ff2e2 100644 HWACCEL_VAAPI(hevc), #endif diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h -index 6109c89bd6..81d200d5ec 100644 +index 8e54cf73f9..2277aadf75 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h -@@ -34,6 +34,9 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel; +@@ -39,6 +39,9 @@ extern const AVHWAccel ff_hevc_d3d11va_hwaccel; extern const AVHWAccel ff_hevc_d3d11va2_hwaccel; extern const AVHWAccel ff_hevc_dxva2_hwaccel; extern const AVHWAccel ff_hevc_nvdec_hwaccel; @@ -16017,7 +16012,7 @@ index f421dc909f..f93283b893 100644 HW_CONFIG_HWACCEL(1, 1, 1, VAAPI, VAAPI, ff_ ## codec ## _vaapi_hwaccel) #define HWACCEL_VDPAU(codec) \ diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c -index 547bece576..bfd1083c16 100644 +index cb15ac072a..f6261db962 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -24,6 +24,9 @@ @@ -16039,10 +16034,10 @@ index 547bece576..bfd1083c16 100644 #include "avcodec.h" diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c -index 601f170447..f890f99931 100644 +index 9176027f15..0b0ff03c18 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c -@@ -191,7 +191,8 @@ static attribute_align_arg void *frame_worker_thread(void *arg) +@@ -209,7 +209,8 @@ FF_ENABLE_DEPRECATION_WARNINGS /* if the previous thread uses hwaccel then we take the lock to ensure * the threads don't run concurrently */ @@ -16052,7 +16047,7 @@ index 601f170447..f890f99931 100644 pthread_mutex_lock(&p->parent->hwaccel_mutex); p->hwaccel_serializing = 1; } -@@ -614,7 +615,9 @@ void ff_thread_finish_setup(AVCodecContext *avctx) { +@@ -636,7 +637,9 @@ void ff_thread_finish_setup(AVCodecContext *avctx) { if (!(avctx->active_thread_type&FF_THREAD_FRAME)) return; @@ -16064,10 +16059,10 @@ index 601f170447..f890f99931 100644 p->hwaccel_serializing = 1; } diff --git a/libavcodec/raw.c b/libavcodec/raw.c -index b6fb91c1c6..f3afb6e09a 100644 +index 079d5c5d10..0781f28615 100644 --- a/libavcodec/raw.c +++ b/libavcodec/raw.c -@@ -293,6 +293,12 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { +@@ -294,6 +294,12 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { AV_PIX_FMT_RGB565LE,MKTAG( 3 , 0 , 0 , 0 ) }, /* flipped RGB565LE */ { AV_PIX_FMT_YUV444P, MKTAG('Y', 'V', '2', '4') }, /* YUV444P, swapped UV */ @@ -46333,7 +46328,7 @@ index 0000000000..85c5b46d75 +}; + diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c -index 02f23d954b..44ed41481e 100644 +index 4b2679eb38..8b10fd5398 100644 --- a/libavcodec/v4l2_buffers.c +++ b/libavcodec/v4l2_buffers.c @@ -21,6 +21,7 @@ @@ -46421,7 +46416,134 @@ index 02f23d954b..44ed41481e 100644 } static enum AVColorPrimaries v4l2_get_color_primaries(V4L2Buffer *buf) -@@ -210,73 +223,159 @@ static enum AVColorTransferCharacteristic v4l2_get_color_trc(V4L2Buffer *buf) +@@ -116,6 +129,105 @@ static enum AVColorPrimaries v4l2_get_color_primaries(V4L2Buffer *buf) + return AVCOL_PRI_UNSPECIFIED; + } + ++static void v4l2_set_color(V4L2Buffer *buf, ++ const enum AVColorPrimaries avcp, ++ const enum AVColorSpace avcs, ++ const enum AVColorTransferCharacteristic avxc) ++{ ++ enum v4l2_ycbcr_encoding ycbcr = V4L2_YCBCR_ENC_DEFAULT; ++ enum v4l2_colorspace cs = V4L2_COLORSPACE_DEFAULT; ++ enum v4l2_xfer_func xfer = V4L2_XFER_FUNC_DEFAULT; ++ ++ switch (avcp) { ++ case AVCOL_PRI_BT709: ++ cs = V4L2_COLORSPACE_REC709; ++ ycbcr = V4L2_YCBCR_ENC_709; ++ break; ++ case AVCOL_PRI_BT470M: ++ cs = V4L2_COLORSPACE_470_SYSTEM_M; ++ ycbcr = V4L2_YCBCR_ENC_601; ++ break; ++ case AVCOL_PRI_BT470BG: ++ cs = V4L2_COLORSPACE_470_SYSTEM_BG; ++ break; ++ case AVCOL_PRI_SMPTE170M: ++ cs = V4L2_COLORSPACE_SMPTE170M; ++ break; ++ case AVCOL_PRI_SMPTE240M: ++ cs = V4L2_COLORSPACE_SMPTE240M; ++ break; ++ case AVCOL_PRI_BT2020: ++ cs = V4L2_COLORSPACE_BT2020; ++ break; ++ case AVCOL_PRI_SMPTE428: ++ case AVCOL_PRI_SMPTE431: ++ case AVCOL_PRI_SMPTE432: ++ case AVCOL_PRI_EBU3213: ++ case AVCOL_PRI_RESERVED: ++ case AVCOL_PRI_FILM: ++ case AVCOL_PRI_UNSPECIFIED: ++ default: ++ break; ++ } ++ ++ switch (avcs) { ++ case AVCOL_SPC_RGB: ++ cs = V4L2_COLORSPACE_SRGB; ++ break; ++ case AVCOL_SPC_BT709: ++ cs = V4L2_COLORSPACE_REC709; ++ break; ++ case AVCOL_SPC_FCC: ++ cs = V4L2_COLORSPACE_470_SYSTEM_M; ++ break; ++ case AVCOL_SPC_BT470BG: ++ cs = V4L2_COLORSPACE_470_SYSTEM_BG; ++ break; ++ case AVCOL_SPC_SMPTE170M: ++ cs = V4L2_COLORSPACE_SMPTE170M; ++ break; ++ case AVCOL_SPC_SMPTE240M: ++ cs = V4L2_COLORSPACE_SMPTE240M; ++ break; ++ case AVCOL_SPC_BT2020_CL: ++ cs = V4L2_COLORSPACE_BT2020; ++ ycbcr = V4L2_YCBCR_ENC_BT2020_CONST_LUM; ++ break; ++ case AVCOL_SPC_BT2020_NCL: ++ cs = V4L2_COLORSPACE_BT2020; ++ break; ++ default: ++ break; ++ } ++ ++ switch (xfer) { ++ case AVCOL_TRC_BT709: ++ xfer = V4L2_XFER_FUNC_709; ++ break; ++ case AVCOL_TRC_IEC61966_2_1: ++ xfer = V4L2_XFER_FUNC_SRGB; ++ break; ++ case AVCOL_TRC_SMPTE240M: ++ xfer = V4L2_XFER_FUNC_SMPTE240M; ++ break; ++ case AVCOL_TRC_SMPTE2084: ++ xfer = V4L2_XFER_FUNC_SMPTE2084; ++ break; ++ default: ++ break; ++ } ++ ++ if (V4L2_TYPE_IS_MULTIPLANAR(buf->buf.type)) { ++ buf->context->format.fmt.pix_mp.colorspace = cs; ++ buf->context->format.fmt.pix_mp.ycbcr_enc = ycbcr; ++ buf->context->format.fmt.pix_mp.xfer_func = xfer; ++ } else { ++ buf->context->format.fmt.pix.colorspace = cs; ++ buf->context->format.fmt.pix.ycbcr_enc = ycbcr; ++ buf->context->format.fmt.pix.xfer_func = xfer; ++ } ++} ++ + static enum AVColorRange v4l2_get_color_range(V4L2Buffer *buf) + { + enum v4l2_quantization qt; +@@ -134,6 +246,20 @@ static enum AVColorRange v4l2_get_color_range(V4L2Buffer *buf) + return AVCOL_RANGE_UNSPECIFIED; + } + ++static void v4l2_set_color_range(V4L2Buffer *buf, const enum AVColorRange avcr) ++{ ++ const enum v4l2_quantization q = ++ avcr == AVCOL_RANGE_MPEG ? V4L2_QUANTIZATION_LIM_RANGE : ++ avcr == AVCOL_RANGE_JPEG ? V4L2_QUANTIZATION_FULL_RANGE : ++ V4L2_QUANTIZATION_DEFAULT; ++ ++ if (V4L2_TYPE_IS_MULTIPLANAR(buf->buf.type)) { ++ buf->context->format.fmt.pix_mp.quantization = q; ++ } else { ++ buf->context->format.fmt.pix.quantization = q; ++ } ++} ++ + static enum AVColorSpace v4l2_get_color_space(V4L2Buffer *buf) + { + enum v4l2_ycbcr_encoding ycbcr; +@@ -210,73 +336,165 @@ static enum AVColorTransferCharacteristic v4l2_get_color_trc(V4L2Buffer *buf) return AVCOL_TRC_UNSPECIFIED; } @@ -46432,19 +46554,14 @@ index 02f23d954b..44ed41481e 100644 - V4L2m2mContext *s = buf_to_m2mctx(avbuf); + return V4L2_FIELD_IS_INTERLACED(buf->buf.field); +} -+ + +- if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) { +- atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel); +static int v4l2_buf_is_top_first(const V4L2Buffer * const buf) +{ + return buf->buf.field == V4L2_FIELD_INTERLACED_TB; +} -- if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) { -- atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel); -+static uint8_t * v4l2_get_drm_frame(V4L2Buffer *avbuf) -+{ -+ AVDRMFrameDescriptor *drm_desc = &avbuf->drm_frame; -+ AVDRMLayerDescriptor *layer; - - if (s->reinit) { - if (!atomic_load(&s->refcount)) - sem_post(&s->refsync); @@ -46456,6 +46573,17 @@ index 02f23d954b..44ed41481e 100644 - else if (avbuf->context->streamon) - ff_v4l2_buffer_enqueue(avbuf); - } ++static void v4l2_set_interlace(V4L2Buffer * const buf, const int is_interlaced, const int is_tff) ++{ ++ buf->buf.field = !is_interlaced ? V4L2_FIELD_NONE : ++ is_tff ? V4L2_FIELD_INTERLACED_TB : V4L2_FIELD_INTERLACED_BT; ++} ++ ++static uint8_t * v4l2_get_drm_frame(V4L2Buffer *avbuf) ++{ ++ AVDRMFrameDescriptor *drm_desc = &avbuf->drm_frame; ++ AVDRMLayerDescriptor *layer; ++ + /* fill the DRM frame descriptor */ + drm_desc->nb_objects = avbuf->num_planes; + drm_desc->nb_layers = 1; @@ -46500,10 +46628,10 @@ index 02f23d954b..44ed41481e 100644 + + if (avbuf->num_planes > 1) + break; ++ ++ layer->nb_planes = 3; - av_buffer_unref(&avbuf->context_ref); -+ layer->nb_planes = 3; -+ + layer->planes[1].object_index = 0; + layer->planes[1].offset = avbuf->plane_info[0].bytesperline * + avbuf->context->format.fmt.pix.height; @@ -46617,15 +46745,14 @@ index 02f23d954b..44ed41481e 100644 + return 0; } --static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, int size, int offset, AVBufferRef* bref) -+static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, int size, int offset) + static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, int size, int offset) { unsigned int bytesused, length; + int rv = 0; if (plane >= out->num_planes) return AVERROR(EINVAL); -@@ -284,32 +383,57 @@ static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, i +@@ -284,32 +502,57 @@ static int v4l2_bufref_to_buf(V4L2Buffer *out, int plane, const uint8_t* data, i length = out->plane_info[plane].length; bytesused = FFMIN(size+offset, length); @@ -46698,7 +46825,7 @@ index 02f23d954b..44ed41481e 100644 } /* fixup special cases */ -@@ -318,17 +442,17 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf) +@@ -318,17 +561,17 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf) case AV_PIX_FMT_NV21: if (avbuf->num_planes > 1) break; @@ -46722,7 +46849,7 @@ index 02f23d954b..44ed41481e 100644 break; default: -@@ -338,68 +462,95 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf) +@@ -338,68 +581,95 @@ static int v4l2_buffer_buf_to_swframe(AVFrame *frame, V4L2Buffer *avbuf) return 0; } @@ -46820,7 +46947,7 @@ index 02f23d954b..44ed41481e 100644 h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h); } - size = frame->linesize[i] * h; -- ret = v4l2_bufref_to_buf(out, 0, frame->data[i], size, offset, frame->buf[i]); +- ret = v4l2_bufref_to_buf(out, 0, frame->data[i], size, offset); - if (ret) - return ret; - offset += size; @@ -46859,7 +46986,7 @@ index 02f23d954b..44ed41481e 100644 + } - for (i = 0; i < out->num_planes; i++) { -- ret = v4l2_bufref_to_buf(out, i, frame->buf[i]->data, frame->buf[i]->size, 0, frame->buf[i]); +- ret = v4l2_bufref_to_buf(out, i, frame->buf[i]->data, frame->buf[i]->size, 0); - if (ret) - return ret; + cpy_2d(dst, dst_stride, @@ -46872,12 +46999,19 @@ index 02f23d954b..44ed41481e 100644 return 0; } -@@ -411,14 +562,15 @@ static int v4l2_buffer_swframe_to_buf(const AVFrame *frame, V4L2Buffer *out) +@@ -411,14 +681,22 @@ static int v4l2_buffer_swframe_to_buf(const AVFrame *frame, V4L2Buffer *out) int ff_v4l2_buffer_avframe_to_buf(const AVFrame *frame, V4L2Buffer *out) { - v4l2_set_pts(out, frame->pts); ++ out->buf.flags = frame->key_frame ? (out->buf.flags & ~V4L2_BUF_FLAG_KEYFRAME) : (out->buf.flags | V4L2_BUF_FLAG_KEYFRAME); ++ // Beware that colour info is held in format rather than the actual ++ // v4l2 buffer struct so this may not be as useful as you might hope ++ v4l2_set_color(out, frame->color_primaries, frame->colorspace, frame->color_trc); ++ v4l2_set_color_range(out, frame->color_range); ++ // PTS & interlace are buffer vars + v4l2_set_pts(out, frame->pts, 0); ++ v4l2_set_interlace(out, frame->interlaced_frame, frame->top_field_first); return v4l2_buffer_swframe_to_buf(frame, out); } @@ -46890,7 +47024,7 @@ index 02f23d954b..44ed41481e 100644 av_frame_unref(frame); -@@ -433,13 +585,24 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf) +@@ -433,13 +711,24 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf) frame->colorspace = v4l2_get_color_space(avbuf); frame->color_range = v4l2_get_color_range(avbuf); frame->color_trc = v4l2_get_color_trc(avbuf); @@ -46919,7 +47053,7 @@ index 02f23d954b..44ed41481e 100644 /* 3. report errors upstream */ if (avbuf->buf.flags & V4L2_BUF_FLAG_ERROR) { -@@ -452,15 +615,16 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf) +@@ -452,15 +741,16 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf) int ff_v4l2_buffer_buf_to_avpkt(AVPacket *pkt, V4L2Buffer *avbuf) { @@ -46941,7 +47075,7 @@ index 02f23d954b..44ed41481e 100644 if (avbuf->buf.flags & V4L2_BUF_FLAG_KEYFRAME) pkt->flags |= AV_PKT_FLAG_KEY; -@@ -470,36 +634,89 @@ int ff_v4l2_buffer_buf_to_avpkt(AVPacket *pkt, V4L2Buffer *avbuf) +@@ -470,36 +760,89 @@ int ff_v4l2_buffer_buf_to_avpkt(AVPacket *pkt, V4L2Buffer *avbuf) pkt->flags |= AV_PKT_FLAG_CORRUPT; } @@ -46957,7 +47091,7 @@ index 02f23d954b..44ed41481e 100644 { int ret; -- ret = v4l2_bufref_to_buf(out, 0, pkt->data, pkt->size, 0, pkt->buf); +- ret = v4l2_bufref_to_buf(out, 0, pkt->data, pkt->size, 0); - if (ret) + if (extlen) { + ret = v4l2_bufref_to_buf(out, 0, extdata, extlen, 0); @@ -46982,9 +47116,8 @@ index 02f23d954b..44ed41481e 100644 +int ff_v4l2_buffer_avpkt_to_buf(const AVPacket *pkt, V4L2Buffer *out) +{ + return ff_v4l2_buffer_avpkt_to_buf_ext(pkt, out, NULL, 0, 0); - } - --int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) ++} ++ + +static void v4l2_buffer_buffer_free(void *opaque, uint8_t *data) +{ @@ -47005,8 +47138,9 @@ index 02f23d954b..44ed41481e 100644 + ff_weak_link_unref(&avbuf->context_wl); + + av_free(avbuf); -+} -+ + } + +-int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) + +int ff_v4l2_buffer_initialize(AVBufferRef ** pbufref, int index, V4L2Context *ctx) { @@ -47018,13 +47152,13 @@ index 02f23d954b..44ed41481e 100644 + *pbufref = NULL; + if (avbuf == NULL) + return AVERROR(ENOMEM); -+ + + bufref = av_buffer_create((uint8_t*)avbuf, sizeof(*avbuf), v4l2_buffer_buffer_free, NULL, 0); + if (bufref == NULL) { + av_free(avbuf); + return AVERROR(ENOMEM); + } - ++ + avbuf->context = ctx; avbuf->buf.memory = V4L2_MEMORY_MMAP; avbuf->buf.type = ctx->type; @@ -47039,7 +47173,7 @@ index 02f23d954b..44ed41481e 100644 if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) { avbuf->buf.length = VIDEO_MAX_PLANES; avbuf->buf.m.planes = avbuf->planes; -@@ -507,7 +724,7 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) +@@ -507,7 +850,7 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) ret = ioctl(buf_to_m2mctx(avbuf)->fd, VIDIOC_QUERYBUF, &avbuf->buf); if (ret < 0) @@ -47048,7 +47182,7 @@ index 02f23d954b..44ed41481e 100644 if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) { avbuf->num_planes = 0; -@@ -527,25 +744,33 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) +@@ -527,25 +870,33 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) { avbuf->plane_info[i].length = avbuf->buf.m.planes[i].length; @@ -47093,7 +47227,7 @@ index 02f23d954b..44ed41481e 100644 if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) { avbuf->buf.m.planes = avbuf->planes; avbuf->buf.length = avbuf->num_planes; -@@ -555,7 +780,20 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) +@@ -555,7 +906,20 @@ int ff_v4l2_buffer_initialize(V4L2Buffer* avbuf, int index) avbuf->buf.length = avbuf->planes[0].length; } @@ -47115,7 +47249,7 @@ index 02f23d954b..44ed41481e 100644 } int ff_v4l2_buffer_enqueue(V4L2Buffer* avbuf) -@@ -564,9 +802,27 @@ int ff_v4l2_buffer_enqueue(V4L2Buffer* avbuf) +@@ -564,9 +928,27 @@ int ff_v4l2_buffer_enqueue(V4L2Buffer* avbuf) avbuf->buf.flags = avbuf->flags; @@ -47223,7 +47357,7 @@ index 8dbc7fc104..9909f349bd 100644 /** * Enqueues a V4L2Buffer diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c -index 29b144ed73..10f86913ad 100644 +index ff1ea8e57b..e94e5e4ab4 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -27,11 +27,13 @@ @@ -47868,16 +48002,16 @@ index 29b144ed73..10f86913ad 100644 + { + if (cmd == VIDIOC_STREAMOFF) + flush_all_buffers_status(ctx); - -- ctx->streamon = (cmd == VIDIOC_STREAMON); ++ + ctx->streamon = (cmd == VIDIOC_STREAMON); + av_log(avctx, AV_LOG_DEBUG, "%s set status %d (%s) OK\n", ctx->name, + cmd, (cmd == VIDIOC_STREAMON) ? "ON" : "OFF"); + } -- return 0; +- ctx->streamon = (cmd == VIDIOC_STREAMON); + ff_mutex_unlock(&ctx->lock); -+ + +- return 0; + return ret; } @@ -48191,7 +48325,7 @@ index 22a9532444..70190e3079 100644 /** * Enqueues a buffer to a V4L2Context from an AVFrame diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c -index e48b3a8ccf..4f3bcd3a51 100644 +index cdfd579810..c5a74b3373 100644 --- a/libavcodec/v4l2_m2m.c +++ b/libavcodec/v4l2_m2m.c @@ -215,13 +215,7 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *s) @@ -48208,45 +48342,35 @@ index e48b3a8ccf..4f3bcd3a51 100644 ff_v4l2_context_release(&s->capture); /* 3. get the new capture format */ -@@ -328,7 +322,10 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context) +@@ -328,11 +322,14 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context) ff_v4l2_context_release(&s->capture); sem_destroy(&s->refsync); - close(s->fd); + if (s->fd != -1) + close(s->fd); -+ -+ av_log(s->avctx, AV_LOG_DEBUG, "V4L2 Context destroyed\n"); + av_frame_unref(s->frame); + av_frame_free(&s->frame); + av_packet_unref(&s->buf_pkt); ++ av_log(s->avctx, AV_LOG_DEBUG, "V4L2 Context destroyed\n"); ++ av_free(s); } -@@ -338,17 +335,34 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) - V4L2m2mContext *s = priv->context; - int ret; -- ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); -- if (ret) -- av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); -+ if (!s) -+ return 0; +@@ -344,6 +341,11 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) + if (!s) + return 0; -- ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); -- if (ret) -- av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); + av_log(s->avctx, AV_LOG_DEBUG, "V4L2 Codec end\n"); + + if (av_codec_is_decoder(s->avctx->codec)) + av_packet_unref(&s->buf_pkt); + -+ if (s->fd >= 0) { -+ ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); -+ if (ret) -+ av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name); -+ -+ ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); -+ if (ret) -+ av_log(s->avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name); -+ } + if (s->fd >= 0) { + ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF); + if (ret) +@@ -356,7 +358,14 @@ int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv) ff_v4l2_context_release(&s->output); @@ -48262,7 +48386,7 @@ index e48b3a8ccf..4f3bcd3a51 100644 return 0; diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h -index 456281f48c..6f2d0d75eb 100644 +index b67b216331..8f054f2f50 100644 --- a/libavcodec/v4l2_m2m.h +++ b/libavcodec/v4l2_m2m.h @@ -30,6 +30,7 @@ @@ -48301,7 +48425,7 @@ index 456281f48c..6f2d0d75eb 100644 /* null frame/packet received */ int draining; -@@ -63,6 +76,23 @@ typedef struct V4L2m2mContext { +@@ -66,6 +79,23 @@ typedef struct V4L2m2mContext { /* reference back to V4L2m2mPriv */ void *priv; @@ -48325,7 +48449,7 @@ index 456281f48c..6f2d0d75eb 100644 } V4L2m2mContext; typedef struct V4L2m2mPriv { -@@ -73,6 +103,7 @@ typedef struct V4L2m2mPriv { +@@ -76,6 +106,7 @@ typedef struct V4L2m2mPriv { int num_output_buffers; int num_capture_buffers; @@ -48333,7 +48457,7 @@ index 456281f48c..6f2d0d75eb 100644 } V4L2m2mPriv; /** -@@ -126,4 +157,16 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx); +@@ -129,4 +160,16 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *ctx); */ int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *ctx); @@ -48351,7 +48475,7 @@ index 456281f48c..6f2d0d75eb 100644 + #endif /* AVCODEC_V4L2_M2M_H */ diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c -index 3e17e0fcac..b9f28220a8 100644 +index ab07c0a24a..b9f28220a8 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -23,6 +23,10 @@ @@ -48475,7 +48599,7 @@ index 3e17e0fcac..b9f28220a8 100644 /* 5. start the capture process */ ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON); -@@ -133,52 +168,312 @@ static int v4l2_prepare_decoder(V4L2m2mContext *s) +@@ -133,54 +168,325 @@ static int v4l2_prepare_decoder(V4L2m2mContext *s) return 0; } @@ -48592,20 +48716,14 @@ index 3e17e0fcac..b9f28220a8 100644 - V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context; - V4L2Context *const capture = &s->capture; - V4L2Context *const output = &s->output; -- AVPacket avpkt = {0}; int ret; -- if (s->buf_pkt.size) { -- avpkt = s->buf_pkt; -- memset(&s->buf_pkt, 0, sizeof(AVPacket)); -- } else { -- ret = ff_decode_get_packet(avctx, &avpkt); -- if (ret < 0 && ret != AVERROR_EOF) + // If we don't already have a coded packet - get a new one + // We will already have a coded pkt if the output Q was full last time we + // tried to Q it -+ if (!s->buf_pkt.size) { -+ ret = ff_decode_get_packet(avctx, &s->buf_pkt); + if (!s->buf_pkt.size) { + ret = ff_decode_get_packet(avctx, &s->buf_pkt); +- if (ret < 0 && ret != AVERROR_EOF) + + if (ret == AVERROR(EAGAIN)) { + if (!stream_started(s)) { @@ -48651,29 +48769,31 @@ index 3e17e0fcac..b9f28220a8 100644 + if ((ret = check_output_streamon(avctx, s)) != 0) + return ret; -- ret = ff_v4l2_context_enqueue_packet(output, &avpkt); -- if (ret < 0) { -- if (ret != AVERROR(EAGAIN)) -- return ret; +- ret = ff_v4l2_context_enqueue_packet(output, &s->buf_pkt); +- if (ret < 0 && ret != AVERROR(EAGAIN)) +- goto fail; + ret = ff_v4l2_context_enqueue_packet(&s->output, &s->buf_pkt, + avctx->extradata, s->extdata_sent ? 0 : avctx->extradata_size, + 1); -- s->buf_pkt = avpkt; -- /* no input buffers available, continue dequeing */ +- /* if EAGAIN don't unref packet and try to enqueue in the next iteration */ +- if (ret != AVERROR(EAGAIN)) + if (ret == AVERROR(EAGAIN)) { + // Out of input buffers - keep packet + ret = NQ_Q_FULL; - } ++ } + else { + // In all other cases we are done with this packet -+ av_packet_unref(&s->buf_pkt); + av_packet_unref(&s->buf_pkt); + s->extdata_sent = 1; -- if (avpkt.size) { +- if (!s->draining) { - ret = v4l2_try_start(avctx); if (ret) { -- av_packet_unref(&avpkt); +- /* cant recover */ +- if (ret != AVERROR(ENOMEM)) +- ret = 0; +- goto fail; + av_log(avctx, AV_LOG_ERROR, "Packet enqueue failure: err=%d\n", ret); + return ret; + } @@ -48685,15 +48805,16 @@ index 3e17e0fcac..b9f28220a8 100644 + if (ret2) { + av_log(avctx, AV_LOG_DEBUG, "Start failure: err=%d\n", ret2); + ret = (ret2 == AVERROR(ENOMEM)) ? ret2 : NQ_DEAD; -+ } -+ } + } + } + +-dequeue: +- return ff_v4l2_context_dequeue_frame(capture, frame, -1); +-fail: +- av_packet_unref(&s->buf_pkt); + return ret; + } -- /* cant recover */ -- if (ret == AVERROR(ENOMEM)) -- return ret; -+ return ret; -+} -+ +static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) +{ + V4L2m2mContext *const s = ((V4L2m2mPriv*)avctx->priv_data)->context; @@ -48737,8 +48858,7 @@ index 3e17e0fcac..b9f28220a8 100644 + // Go again if we got a frame that we need to discard + } while (dst_rv == 0 && xlat_pts_out(avctx, s, frame)); + } - -- return 0; ++ + // Continue trying to enqueue packets if either + // (a) we succeeded last time OR + // (b) enqueue failed due to input Q full AND there is now room @@ -48760,14 +48880,10 @@ index 3e17e0fcac..b9f28220a8 100644 + av_log(avctx, AV_LOG_ERROR, "Streamoff and die?\n"); + ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF); + return -1; - } - } ++ } ++ } +#endif - --dequeue: -- if (!s->buf_pkt.size) -- av_packet_unref(&avpkt); -- return ff_v4l2_context_dequeue_frame(capture, frame, -1); ++ + return dst_rv == 0 ? 0 : + src_rv < 0 ? src_rv : + dst_rv < 0 ? dst_rv : @@ -48815,10 +48931,10 @@ index 3e17e0fcac..b9f28220a8 100644 + // Add 64k to allow for any overheads and/or encoder hopefulness + // with small WxH + return size + (1 << 16); - } - ++} ++ static av_cold int v4l2_decode_init(AVCodecContext *avctx) -@@ -186,8 +481,12 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) + { V4L2Context *capture, *output; V4L2m2mContext *s; V4L2m2mPriv *priv = avctx->priv_data; @@ -48831,7 +48947,7 @@ index 3e17e0fcac..b9f28220a8 100644 ret = ff_v4l2_m2m_create_context(priv, &s); if (ret < 0) return ret; -@@ -204,17 +503,43 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) +@@ -197,9 +503,38 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) output->av_codec_id = avctx->codec_id; output->av_pix_fmt = AV_PIX_FMT_NONE; @@ -48870,22 +48986,11 @@ index 3e17e0fcac..b9f28220a8 100644 s->avctx = avctx; ret = ff_v4l2_m2m_codec_init(priv); - if (ret) { - av_log(avctx, AV_LOG_ERROR, "can't configure decoder\n"); -- s->self_ref = NULL; -- av_buffer_unref(&priv->context_ref); -- - return ret; - } - -@@ -223,10 +548,53 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) +@@ -213,7 +548,53 @@ static av_cold int v4l2_decode_init(AVCodecContext *avctx) static av_cold int v4l2_decode_close(AVCodecContext *avctx) { -- V4L2m2mPriv *priv = avctx->priv_data; -- V4L2m2mContext *s = priv->context; -- av_packet_unref(&s->buf_pkt); -- return ff_v4l2_m2m_codec_end(priv); +- return ff_v4l2_m2m_codec_end(avctx->priv_data); + int rv; + av_log(avctx, AV_LOG_TRACE, "<<< %s\n", __func__); + rv = ff_v4l2_m2m_codec_end(avctx->priv_data); @@ -48936,7 +49041,7 @@ index 3e17e0fcac..b9f28220a8 100644 } #define OFFSET(x) offsetof(V4L2m2mPriv, x) -@@ -235,10 +603,16 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) +@@ -222,10 +603,16 @@ static av_cold int v4l2_decode_close(AVCodecContext *avctx) static const AVOption options[] = { V4L_M2M_DEFAULT_OPTS, { "num_capture_buffers", "Number of buffers in the capture context", @@ -48954,15 +49059,14 @@ index 3e17e0fcac..b9f28220a8 100644 #define M2MDEC_CLASS(NAME) \ static const AVClass v4l2_m2m_ ## NAME ## _dec_class = { \ .class_name = #NAME "_v4l2m2m_decoder", \ -@@ -259,9 +633,15 @@ static const AVOption options[] = { +@@ -246,9 +633,15 @@ static const AVOption options[] = { .init = v4l2_decode_init, \ .receive_frame = v4l2_receive_frame, \ .close = v4l2_decode_close, \ + .flush = v4l2_decode_flush, \ .bsfs = bsf_name, \ .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ -- .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, \ -+ .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \ + .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_INIT_CLEANUP, \ + .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \ + AV_PIX_FMT_NV12, \ + AV_PIX_FMT_YUV420P, \ @@ -48973,10 +49077,10 @@ index 3e17e0fcac..b9f28220a8 100644 diff --git a/libavcodec/v4l2_req_decode_q.c b/libavcodec/v4l2_req_decode_q.c new file mode 100644 -index 0000000000..2adbd5999b +index 0000000000..5b3fb958fa --- /dev/null +++ b/libavcodec/v4l2_req_decode_q.c -@@ -0,0 +1,86 @@ +@@ -0,0 +1,84 @@ +#include +#include +#include @@ -49024,10 +49128,8 @@ index 0000000000..2adbd5999b + + if (d->next) + d->next->prev = d->prev; -+ else { -+ try_signal = 0; // If we were a singleton then no point signalling ++ else + q->tail = d->prev; -+ } + + // Not strictly needed but makes debug easier + d->next = NULL; @@ -49096,10 +49198,10 @@ index 0000000000..af7bbe1de4 + diff --git a/libavcodec/v4l2_req_devscan.c b/libavcodec/v4l2_req_devscan.c new file mode 100644 -index 0000000000..59724a8104 +index 0000000000..cfa94d55c4 --- /dev/null +++ b/libavcodec/v4l2_req_devscan.c -@@ -0,0 +1,452 @@ +@@ -0,0 +1,449 @@ +#include +#include +#include @@ -49434,9 +49536,6 @@ index 0000000000..59724a8104 + goto fail; + } + -+ free(interfaces); -+ return ret; -+ +fail: + free(interfaces); + if (media_fd != -1) @@ -49581,10 +49680,10 @@ index 0000000000..0baef36535 +#endif diff --git a/libavcodec/v4l2_req_dmabufs.c b/libavcodec/v4l2_req_dmabufs.c new file mode 100644 -index 0000000000..0717279e75 +index 0000000000..ae6c648369 --- /dev/null +++ b/libavcodec/v4l2_req_dmabufs.c -@@ -0,0 +1,241 @@ +@@ -0,0 +1,266 @@ +#include +#include +#include @@ -49604,6 +49703,7 @@ index 0000000000..0717279e75 +#define DMABUF_NAME1 "/dev/dma_heap/linux,cma" +#define DMABUF_NAME2 "/dev/dma_heap/reserved" + ++#define TRACE_ALLOC 0 + +struct dmabufs_ctl { + int fd; @@ -49617,6 +49717,11 @@ index 0000000000..0717279e75 + void * mapptr; +}; + ++#if TRACE_ALLOC ++static unsigned int total_bufs = 0; ++static size_t total_size = 0; ++#endif ++ +struct dmabuf_h * dmabuf_import(int fd, size_t size) +{ + struct dmabuf_h *dh; @@ -49636,6 +49741,13 @@ index 0000000000..0717279e75 + .size = size, + .mapptr = MAP_FAILED + }; ++ ++#if TRACE_ALLOC ++ ++total_bufs; ++ total_size += dh->size; ++ request_log("%s: Import: %zd, total=%zd, bufs=%d\n", __func__, dh->size, total_size, total_bufs); ++#endif ++ + return dh; +} + @@ -49678,6 +49790,12 @@ index 0000000000..0717279e75 + .mapptr = MAP_FAILED + }; + ++#if TRACE_ALLOC ++ ++total_bufs; ++ total_size += dh->size; ++ request_log("%s: Alloc: %zd, total=%zd, bufs=%d\n", __func__, dh->size, total_size, total_bufs); ++#endif ++ + return dh; + +fail: @@ -49773,6 +49891,12 @@ index 0000000000..0717279e75 + if (!dh) + return; + ++#if TRACE_ALLOC ++ --total_bufs; ++ total_size -= dh->size; ++ request_log("%s: Free: %zd, total=%zd, bufs=%d\n", __func__, dh->size, total_size, total_bufs); ++#endif ++ + if (dh->mapptr != MAP_FAILED) + munmap(dh->mapptr, dh->size); + while (close(dh->fd) == -1 && errno == EINTR) @@ -49890,10 +50014,10 @@ index 0000000000..42af98e156 + diff --git a/libavcodec/v4l2_req_hevc_vx.c b/libavcodec/v4l2_req_hevc_vx.c new file mode 100644 -index 0000000000..c628bd5ab4 +index 0000000000..c9a8fa7c87 --- /dev/null +++ b/libavcodec/v4l2_req_hevc_vx.c -@@ -0,0 +1,1189 @@ +@@ -0,0 +1,1188 @@ +// File included by v4l2_req_hevc_v* - not compiled on its own + +#include "decode.h" @@ -50861,13 +50985,12 @@ index 0000000000..c628bd5ab4 + } + } + -+ decode_q_remove(&ctx->decode_q, &rd->decode_ent); -+ + // Set the drm_prime desriptor + drm_from_format(&rd->drm, mediabufs_dst_fmt(ctx->mbufs)); + rd->drm.objects[0].fd = dmabuf_fd(qent_dst_dmabuf(rd->qe_dst, 0)); + rd->drm.objects[0].size = dmabuf_size(qent_dst_dmabuf(rd->qe_dst, 0)); + ++ decode_q_remove(&ctx->decode_q, &rd->decode_ent); + return 0; + +fail: @@ -50983,7 +51106,7 @@ index 0000000000..c628bd5ab4 + + av_log(NULL, AV_LOG_DEBUG, "%s: avctx=%p data=%p\n", __func__, avctx, data); + -+ qent_dst_free(&rd->qe_dst); ++ qent_dst_unref(&rd->qe_dst); + + // We don't expect req or qe_src to be set + if (rd->req || rd->qe_src) @@ -51085,10 +51208,10 @@ index 0000000000..c628bd5ab4 + diff --git a/libavcodec/v4l2_req_media.c b/libavcodec/v4l2_req_media.c new file mode 100644 -index 0000000000..9fb02b1d98 +index 0000000000..10f720f814 --- /dev/null +++ b/libavcodec/v4l2_req_media.c -@@ -0,0 +1,1525 @@ +@@ -0,0 +1,1569 @@ +/* + * Copyright (C) 2018 Paul Kocialkowski + * @@ -51271,8 +51394,6 @@ index 0000000000..9fb02b1d98 + +int media_request_start(struct media_request * const req) +{ -+ struct media_pool * const mp = req->mp; -+ + while (ioctl(req->fd, MEDIA_REQUEST_IOC_QUEUE, NULL) == -1) + { + const int err = errno; @@ -51282,7 +51403,7 @@ index 0000000000..9fb02b1d98 + return -err; + } + -+ pollqueue_add_task(mp->pq, req->pt, 2000); ++ pollqueue_add_task(req->pt, 2000); + return 0; +} + @@ -51322,6 +51443,8 @@ index 0000000000..9fb02b1d98 + while (next) { + struct media_request * const req = next; + next = req->next; ++ if (req->pt) ++ polltask_delete(&req->pt); + if (req->fd != -1) + close(req->fd); + free(req); @@ -51363,7 +51486,7 @@ index 0000000000..9fb02b1d98 + goto fail4; + } + -+ req->pt = polltask_new(req->fd, POLLPRI, media_request_done, req); ++ req->pt = polltask_new(pq, req->fd, POLLPRI, media_request_done, req); + if (!req->pt) + goto fail4; + } @@ -51401,15 +51524,17 @@ index 0000000000..9fb02b1d98 +#define INDEX_UNSET (~(uint32_t)0) + +enum qent_status { -+ QENT_NEW, -+ QENT_PENDING, -+ QENT_WAITING, -+ QENT_DONE, -+ QENT_ERROR, ++ QENT_NEW = 0, // Initial state - shouldn't last ++ QENT_FREE, // On free chain ++ QENT_PENDING, // User has ent ++ QENT_WAITING, // On inuse ++ QENT_DONE, // Frame rx ++ QENT_ERROR, // Error + QENT_IMPORT +}; + +struct qent_base { ++ atomic_int ref_count; + struct qent_base *next; + struct qent_base *prev; + enum qent_status status; @@ -51425,22 +51550,23 @@ index 0000000000..9fb02b1d98 + +struct qent_dst { + struct qent_base base; -+ + bool waiting; + pthread_mutex_t lock; + pthread_cond_t cond; + struct ff_weak_link_client * mbc_wl; +}; + ++struct qe_list_head { ++ struct qent_base *head; ++ struct qent_base *tail; ++}; + +struct buf_pool { + pthread_mutex_t lock; + sem_t free_sem; + enum v4l2_buf_type buf_type; -+ struct qent_base *free_head; -+ struct qent_base *free_tail; -+ struct qent_base *inuse_head; -+ struct qent_base *inuse_tail; ++ struct qe_list_head free; ++ struct qe_list_head inuse; +}; + + @@ -51456,6 +51582,7 @@ index 0000000000..9fb02b1d98 + + +#define QENT_BASE_INITIALIZER {\ ++ .ref_count = ATOMIC_VAR_INIT(0),\ + .status = QENT_NEW,\ + .index = INDEX_UNSET\ +} @@ -51469,7 +51596,7 @@ index 0000000000..9fb02b1d98 + } +} + -+static void qe_src_delete(struct qent_src *const be_src) ++static void qe_src_free(struct qent_src *const be_src) +{ + if (!be_src) + return; @@ -51488,6 +51615,18 @@ index 0000000000..9fb02b1d98 + return be_src; +} + ++static void qe_dst_free(struct qent_dst *const be_dst) ++{ ++ if (!be_dst) ++ return; ++ ++ ff_weak_link_unref(&be_dst->mbc_wl); ++ pthread_cond_destroy(&be_dst->cond); ++ pthread_mutex_destroy(&be_dst->lock); ++ qe_base_uninit(&be_dst->base); ++ free(be_dst); ++} ++ +static struct qent_dst * qe_dst_new(void) +{ + struct qent_dst *const be_dst = malloc(sizeof(*be_dst)); @@ -51501,55 +51640,75 @@ index 0000000000..9fb02b1d98 + return be_dst; +} + ++static void ql_add_tail(struct qe_list_head * const ql, struct qent_base * be) ++{ ++ if (ql->tail) ++ ql->tail->next = be; ++ else ++ ql->head = be; ++ be->prev = ql->tail; ++ be->next = NULL; ++ ql->tail = be; ++} ++ ++static struct qent_base * ql_extract(struct qe_list_head * const ql, struct qent_base * be) ++{ ++ if (!be) ++ return NULL; ++ ++ if (be->next) ++ be->next->prev = be->prev; ++ else ++ ql->tail = be->prev; ++ if (be->prev) ++ be->prev->next = be->next; ++ else ++ ql->head = be->next; ++ be->next = NULL; ++ be->prev = NULL; ++ return be; ++} ++ + +static void bq_put_free(struct buf_pool *const bp, struct qent_base * be) +{ -+ if (bp->free_tail) -+ bp->free_tail->next = be; -+ else -+ bp->free_head = be; -+ be->prev = bp->free_tail; -+ be->next = NULL; -+ bp->free_tail = be; ++ ql_add_tail(&bp->free, be); +} + +static struct qent_base * bq_get_free(struct buf_pool *const bp) +{ -+ struct qent_base *be; -+ -+ be = bp->free_head; -+ if (be) { -+ if (be->next) -+ be->next->prev = be->prev; -+ else -+ bp->free_tail = be->prev; -+ bp->free_head = be->next; -+ be->next = NULL; -+ be->prev = NULL; -+ } -+ return be; ++ return ql_extract(&bp->free, bp->free.head); +} + +static struct qent_base * bq_extract_inuse(struct buf_pool *const bp, struct qent_base *const be) +{ -+ if (be->next) -+ be->next->prev = be->prev; -+ else -+ bp->inuse_tail = be->prev; -+ if (be->prev) -+ be->prev->next = be->next; -+ else -+ bp->inuse_head = be->next; -+ be->next = NULL; -+ be->prev = NULL; -+ return be; ++ return ql_extract(&bp->inuse, be); ++} ++ ++static struct qent_base * bq_get_inuse(struct buf_pool *const bp) ++{ ++ return ql_extract(&bp->inuse, bp->inuse.head); +} + +static void bq_free_all_free_src(struct buf_pool *const bp) +{ + struct qent_base *be; + while ((be = bq_get_free(bp)) != NULL) -+ qe_src_delete(base_to_src(be)); ++ qe_src_free(base_to_src(be)); ++} ++ ++static void bq_free_all_inuse_src(struct buf_pool *const bp) ++{ ++ struct qent_base *be; ++ while ((be = bq_get_inuse(bp)) != NULL) ++ qe_src_free(base_to_src(be)); ++} ++ ++static void bq_free_all_free_dst(struct buf_pool *const bp) ++{ ++ struct qent_base *be; ++ while ((be = bq_get_free(bp)) != NULL) ++ qe_dst_free(base_to_dst(be)); +} + +static void queue_put_free(struct buf_pool *const bp, struct qent_base *be) @@ -51560,6 +51719,7 @@ index 0000000000..9fb02b1d98 + /* Clear out state vars */ + be->timestamp.tv_sec = 0; + be->timestamp.tv_usec = 0; ++ be->status = QENT_FREE; + for (i = 0; i < VIDEO_MAX_PLANES && be->dh[i]; ++i) + dmabuf_len_set(be->dh[i], 0); + bq_put_free(bp, be); @@ -51569,7 +51729,7 @@ index 0000000000..9fb02b1d98 + +static bool queue_is_inuse(const struct buf_pool *const bp) +{ -+ return bp->inuse_tail != NULL; ++ return bp->inuse.tail != NULL; +} + +static void queue_put_inuse(struct buf_pool *const bp, struct qent_base *be) @@ -51577,13 +51737,7 @@ index 0000000000..9fb02b1d98 + if (!be) + return; + pthread_mutex_lock(&bp->lock); -+ if (bp->inuse_tail) -+ bp->inuse_tail->next = be; -+ else -+ bp->inuse_head = be; -+ be->prev = bp->inuse_tail; -+ be->next = NULL; -+ bp->inuse_tail = be; ++ ql_add_tail(&bp->inuse, be); + be->status = QENT_WAITING; + pthread_mutex_unlock(&bp->lock); +} @@ -51618,7 +51772,7 @@ index 0000000000..9fb02b1d98 + + pthread_mutex_lock(&bp->lock); + /* Expect 1st in Q, but allow anywhere */ -+ for (be = bp->inuse_head; be; be = be->next) { ++ for (be = bp->inuse.head; be; be = be->next) { + if (dmabuf_fd(be->dh[0]) == fd) { + bq_extract_inuse(bp, be); + break; @@ -51631,14 +51785,12 @@ index 0000000000..9fb02b1d98 + +static void queue_delete(struct buf_pool *const bp) +{ -+ if (!bp) -+ return; + sem_destroy(&bp->free_sem); + pthread_mutex_destroy(&bp->lock); + free(bp); +} + -+static struct buf_pool* queue_new(const int vfd, struct pollqueue * pq) ++static struct buf_pool* queue_new(const int vfd) +{ + struct buf_pool *bp = calloc(1, sizeof(*bp)); + if (!bp) @@ -51761,12 +51913,14 @@ index 0000000000..9fb02b1d98 + return be; +} + -+static void qe_dst_done(struct qent_dst *const dst_be) ++static void qe_dst_done(struct qent_dst * dst_be) +{ + pthread_mutex_lock(&dst_be->lock); + dst_be->waiting = false; + pthread_cond_broadcast(&dst_be->cond); + pthread_mutex_unlock(&dst_be->lock); ++ ++ qent_dst_unref(&dst_be); +} + +static bool qe_dst_waiting(struct qent_dst *const dst_be) @@ -51790,7 +51944,6 @@ index 0000000000..9fb02b1d98 + struct mediabufs_ctl *mbc = v; + struct qent_src *src_be = NULL; + struct qent_dst *dst_be = NULL; -+ bool qrun = false; + + if (!revents) + request_err(mbc->dc, "%s: Timeout\n", __func__); @@ -51806,8 +51959,7 @@ index 0000000000..9fb02b1d98 + /* Reschedule */ + if (mediabufs_wants_poll(mbc)) { + mbc->polling = true; -+ pollqueue_add_task(mbc->pq, mbc->pt, 2000); -+ qrun = true; ++ pollqueue_add_task(mbc->pt, 2000); + } + pthread_mutex_unlock(&mbc->lock); + @@ -51815,8 +51967,6 @@ index 0000000000..9fb02b1d98 + queue_put_free(mbc->src, &src_be->base); + if (dst_be) + qe_dst_done(dst_be); -+ if (!qrun) -+ mediabufs_ctl_unref(&mbc); +} + +int qent_src_params_set(struct qent_src *const be_src, const struct timeval * timestamp) @@ -51915,6 +52065,8 @@ index 0000000000..9fb02b1d98 + dst_be->base.timestamp = (struct timeval){0,0}; + if (qe_v4l2_queue(&dst_be->base, mbc->vfd, NULL, &mbc->dst_fmt, true, false)) + goto fail1; ++ ++ qent_dst_ref(dst_be); + queue_put_inuse(mbc->dst, &dst_be->base); + } + @@ -51924,8 +52076,7 @@ index 0000000000..9fb02b1d98 + + if (!mbc->polling && mediabufs_wants_poll(mbc)) { + mbc->polling = true; -+ mediabufs_ctl_ref(mbc); -+ pollqueue_add_task(mbc->pq, mbc->pt, 2000); ++ pollqueue_add_task(mbc->pt, 2000); + } + pthread_mutex_unlock(&mbc->lock); + @@ -51940,8 +52091,10 @@ index 0000000000..9fb02b1d98 + queue_put_free(mbc->src, &src_be->base); + +// *** TODO: If src Q fails this doesnt unwind properly - separate dst Q from src Q -+ if (dst_be) ++ if (dst_be) { ++ dst_be->base.status = QENT_ERROR; + qe_dst_done(dst_be); ++ } + pthread_mutex_unlock(&mbc->lock); + return MEDIABUFS_ERROR_OPERATION_FAILED; +} @@ -52110,32 +52263,30 @@ index 0000000000..9fb02b1d98 + return status; +} + -+void qent_dst_delete(struct qent_dst *const be_dst) ++struct qent_dst * qent_dst_ref(struct qent_dst * const be_dst) +{ -+ if (!be_dst) -+ return; -+ -+ ff_weak_link_unref(&be_dst->mbc_wl); -+ pthread_cond_destroy(&be_dst->cond); -+ pthread_mutex_destroy(&be_dst->lock); -+ qe_base_uninit(&be_dst->base); -+ free(be_dst); ++ if (be_dst) ++ atomic_fetch_add(&be_dst->base.ref_count, 1); ++ return be_dst; +} + -+void qent_dst_free(struct qent_dst ** const pbe_dst) ++void qent_dst_unref(struct qent_dst ** const pbe_dst) +{ + struct qent_dst * const be_dst = *pbe_dst; + struct mediabufs_ctl * mbc; + if (!be_dst) + return; -+ + *pbe_dst = NULL; ++ ++ if (atomic_fetch_sub(&be_dst->base.ref_count, 1) != 0) ++ return; ++ + if ((mbc = ff_weak_link_lock(&be_dst->mbc_wl)) != NULL) { + queue_put_free(mbc->dst, &be_dst->base); + ff_weak_link_unlock(be_dst->mbc_wl); + } + else { -+ qent_dst_delete(be_dst); ++ qe_dst_free(be_dst); + } +} + @@ -52196,7 +52347,7 @@ index 0000000000..9fb02b1d98 + + if ((be_dst->mbc_wl = ff_weak_link_ref(mbc->this_wlm)) == NULL || + (index = create_dst_buf(mbc)) < 0) { -+ qent_dst_delete(be_dst); ++ qe_dst_free(be_dst); + return NULL; + } + @@ -52211,6 +52362,8 @@ index 0000000000..9fb02b1d98 + return NULL; + } + ++ be_dst->base.status = QENT_PENDING; ++ atomic_store(&be_dst->base.ref_count, 0); + return be_dst; +} + @@ -52266,7 +52419,7 @@ index 0000000000..9fb02b1d98 + + index = create_dst_buf(mbc); + if (index < 0) { -+ qent_dst_delete(be_dst); ++ qe_dst_free(be_dst); + return MEDIABUFS_ERROR_OPERATION_FAILED; + } + @@ -52280,6 +52433,7 @@ index 0000000000..9fb02b1d98 +struct qent_src *mediabufs_src_qent_get(struct mediabufs_ctl *const mbc) +{ + struct qent_base * buf = queue_get_free(mbc->src); ++ buf->status = QENT_PENDING; + return base_to_src(buf); +} + @@ -52324,7 +52478,7 @@ index 0000000000..9fb02b1d98 + goto fail; + } + if (qe_alloc_from_fmt(&be_src->base, dbsc, &mbc->src_fmt)) { -+ qe_src_delete(be_src); ++ qe_src_free(be_src); + goto fail; + } + be_src->base.index = i; @@ -52382,13 +52536,13 @@ index 0000000000..9fb02b1d98 + if (!mbc->stream_on) + return MEDIABUFS_STATUS_SUCCESS; + -+ if (set_stream(mbc->vfd, mbc->src_fmt.type, false) < 0) { -+ request_log("Failed to set stream off src type %d\n", mbc->src_fmt.type); ++ if (set_stream(mbc->vfd, mbc->dst_fmt.type, false) < 0) { ++ request_log("Failed to set stream off dst type %d\n", mbc->dst_fmt.type); + status = MEDIABUFS_ERROR_OPERATION_FAILED; + } + -+ if (set_stream(mbc->vfd, mbc->dst_fmt.type, false) < 0) { -+ request_log("Failed to set stream off dst type %d\n", mbc->dst_fmt.type); ++ if (set_stream(mbc->vfd, mbc->src_fmt.type, false) < 0) { ++ request_log("Failed to set stream off src type %d\n", mbc->src_fmt.type); + status = MEDIABUFS_ERROR_OPERATION_FAILED; + } + @@ -52490,6 +52644,19 @@ index 0000000000..9fb02b1d98 + request_buffers(mbc->vfd, mbc->src_fmt.type, V4L2_MEMORY_MMAP, 0); + request_buffers(mbc->vfd, mbc->dst_fmt.type, V4L2_MEMORY_MMAP, 0); + ++ bq_free_all_free_src(mbc->src); ++ bq_free_all_inuse_src(mbc->src); ++ bq_free_all_free_dst(mbc->dst); ++ ++ { ++ struct qent_dst *dst_be; ++ while ((dst_be = base_to_dst(bq_get_inuse(mbc->dst))) != NULL) { ++ dst_be->base.timestamp = (struct timeval){0}; ++ dst_be->base.status = QENT_ERROR; ++ qe_dst_done(dst_be); ++ } ++ } ++ + queue_delete(mbc->dst); + queue_delete(mbc->src); + close(mbc->vfd); @@ -52580,13 +52747,13 @@ index 0000000000..9fb02b1d98 + goto fail1; + } + -+ mbc->src = queue_new(mbc->vfd, pq); ++ mbc->src = queue_new(mbc->vfd); + if (!mbc->src) + goto fail1; -+ mbc->dst = queue_new(mbc->vfd, pq); ++ mbc->dst = queue_new(mbc->vfd); + if (!mbc->dst) + goto fail2; -+ mbc->pt = polltask_new(mbc->vfd, POLLIN | POLLOUT, mediabufs_poll_cb, mbc); ++ mbc->pt = polltask_new(pq, mbc->vfd, POLLIN | POLLOUT, mediabufs_poll_cb, mbc); + if (!mbc->pt) + goto fail3; + mbc->this_wlm = ff_weak_link_new(mbc); @@ -52616,10 +52783,10 @@ index 0000000000..9fb02b1d98 + diff --git a/libavcodec/v4l2_req_media.h b/libavcodec/v4l2_req_media.h new file mode 100644 -index 0000000000..e503773b1a +index 0000000000..15a6952748 --- /dev/null +++ b/libavcodec/v4l2_req_media.h -@@ -0,0 +1,147 @@ +@@ -0,0 +1,148 @@ +/* +e.h +* @@ -52704,7 +52871,8 @@ index 0000000000..e503773b1a +MediaBufsStatus qent_dst_wait(struct qent_dst *const be); +void qent_dst_delete(struct qent_dst *const be); +// Returns a qent_dst to its mbc free Q or deletes it if the mbc is dead -+void qent_dst_free(struct qent_dst ** const pbe_dst); ++void qent_dst_unref(struct qent_dst ** const pbe_dst); ++struct qent_dst * qent_dst_ref(struct qent_dst * const be_dst); + +const uint8_t * qent_dst_data(struct qent_dst *const be, unsigned int buf_no); +MediaBufsStatus qent_dst_read_start(struct qent_dst *const be); @@ -52769,14 +52937,16 @@ index 0000000000..e503773b1a +#endif diff --git a/libavcodec/v4l2_req_pollqueue.c b/libavcodec/v4l2_req_pollqueue.c new file mode 100644 -index 0000000000..0f7d9020ee +index 0000000000..5c47c50a6f --- /dev/null +++ b/libavcodec/v4l2_req_pollqueue.c -@@ -0,0 +1,280 @@ +@@ -0,0 +1,363 @@ +#include +#include +#include +#include ++#include ++#include +#include +#include +#include @@ -52791,21 +52961,32 @@ index 0000000000..0f7d9020ee + +struct pollqueue; + ++enum polltask_state { ++ POLLTASK_UNQUEUED = 0, ++ POLLTASK_QUEUED, ++ POLLTASK_RUNNING, ++ POLLTASK_Q_KILL, ++ POLLTASK_RUN_KILL, ++}; ++ +struct polltask { + struct polltask *next; + struct polltask *prev; + struct pollqueue *q; ++ enum polltask_state state; + + int fd; -+ short events; /* 0 => deleted */ ++ short events; + + void (*fn)(void *v, short revents); + void * v; + -+ uint64_t timeout; /* 0 => now */ ++ uint64_t timeout; /* CLOCK_MONOTONIC time, 0 => never */ ++ sem_t kill_sem; +}; + +struct pollqueue { ++ atomic_int ref_count; + pthread_mutex_t lock; + + struct polltask *head; @@ -52818,7 +52999,8 @@ index 0000000000..0f7d9020ee + pthread_t worker; +}; + -+struct polltask *polltask_new(const int fd, const short events, ++struct polltask *polltask_new(struct pollqueue *const pq, ++ const int fd, const short events, + void (*const fn)(void *v, short revents), + void *const v) +{ @@ -52834,11 +53016,15 @@ index 0000000000..0f7d9020ee + *pt = (struct polltask){ + .next = NULL, + .prev = NULL, ++ .q = pollqueue_ref(pq), + .fd = fd, + .events = events, + .fn = fn, + .v = v + }; ++ ++ sem_init(&pt->kill_sem, 0, 0); ++ + return pt; +} + @@ -52856,14 +53042,9 @@ index 0000000000..0f7d9020ee + pt->prev = NULL; +} + -+void polltask_delete(struct polltask **const ppt) ++static void polltask_free(struct polltask * const pt) +{ -+ struct polltask *const pt = *ppt; -+ -+ if (!pt) -+ return; -+ *ppt = NULL; -+ ++ sem_destroy(&pt->kill_sem); + free(pt); +} + @@ -52873,6 +53054,37 @@ index 0000000000..0f7d9020ee + return write(pq->prod_fd, &one, sizeof(one)); +} + ++void polltask_delete(struct polltask **const ppt) ++{ ++ struct polltask *const pt = *ppt; ++ struct pollqueue * pq; ++ enum polltask_state state; ++ bool prodme; ++ ++ if (!pt) ++ return; ++ ++ pq = pt->q; ++ pthread_mutex_lock(&pq->lock); ++ state = pt->state; ++ pt->state = (state == POLLTASK_RUNNING) ? POLLTASK_RUN_KILL : POLLTASK_Q_KILL; ++ prodme = !pq->no_prod; ++ pthread_mutex_unlock(&pq->lock); ++ ++ if (state != POLLTASK_UNQUEUED) { ++ if (prodme) ++ pollqueue_prod(pq); ++ while (sem_wait(&pt->kill_sem) && errno == EINTR) ++ /* loop */; ++ } ++ ++ // Leave zapping the ref until we have DQed the PT as might well be ++ // legitimately used in it ++ *ppt = NULL; ++ polltask_free(pt); ++ pollqueue_unref(&pq); ++} ++ +static uint64_t pollqueue_now(int timeout) +{ + struct timespec now; @@ -52884,21 +53096,24 @@ index 0000000000..0f7d9020ee + return now_ms ? now_ms : (uint64_t)1; +} + -+void pollqueue_add_task(struct pollqueue *const pq, struct polltask *const pt, -+ const int timeout) ++void pollqueue_add_task(struct polltask *const pt, const int timeout) +{ -+ bool prodme; ++ bool prodme = false; ++ struct pollqueue * const pq = pt->q; ++ + pthread_mutex_lock(&pq->lock); -+ if (pq->tail) -+ pq->tail->next = pt; -+ else -+ pq->head = pt; -+ pt->prev = pq->tail; -+ pt->next = NULL; -+ pt->q = pq; -+ pt->timeout = timeout < 0 ? 0 : pollqueue_now(timeout); -+ pq->tail = pt; -+ prodme = !pq->no_prod; ++ if (pt->state != POLLTASK_Q_KILL && pt->state != POLLTASK_RUN_KILL) { ++ if (pq->tail) ++ pq->tail->next = pt; ++ else ++ pq->head = pt; ++ pt->prev = pq->tail; ++ pt->next = NULL; ++ pt->state = POLLTASK_QUEUED; ++ pt->timeout = timeout < 0 ? 0 : pollqueue_now(timeout); ++ pq->tail = pt; ++ prodme = !pq->no_prod; ++ } + pthread_mutex_unlock(&pq->lock); + if (prodme) + pollqueue_prod(pq); @@ -52922,6 +53137,15 @@ index 0000000000..0f7d9020ee + for (pt = pq->head; pt; pt = pt->next) { + int64_t t; + ++ if (pt->state == POLLTASK_Q_KILL) { ++ struct polltask * const prev = pt->prev; ++ pollqueue_rem_task(pq, pt); ++ sem_post(&pt->kill_sem); ++ if ((pt = prev) == NULL) ++ break; ++ continue; ++ } ++ + if (n >= asize) { + asize = asize ? asize * 2 : 4; + a = realloc(a, asize * sizeof(*a)); @@ -52964,6 +53188,10 @@ index 0000000000..0f7d9020ee + if (a[i].revents || + (pt->timeout && (int64_t)(now - pt->timeout) >= 0)) { + pollqueue_rem_task(pq, pt); ++ if (pt->state == POLLTASK_QUEUED) ++ pt->state = POLLTASK_RUNNING; ++ if (pt->state == POLLTASK_Q_KILL) ++ pt->state = POLLTASK_RUN_KILL; + pthread_mutex_unlock(&pq->lock); + + /* This can add new entries to the Q but as @@ -52973,6 +53201,10 @@ index 0000000000..0f7d9020ee + pt->fn(pt->v, a[i].revents); + + pthread_mutex_lock(&pq->lock); ++ if (pt->state == POLLTASK_RUNNING) ++ pt->state = POLLTASK_UNQUEUED; ++ if (pt->state == POLLTASK_RUN_KILL) ++ sem_post(&pt->kill_sem); + } + + pt = pt_next; @@ -52995,7 +53227,7 @@ index 0000000000..0f7d9020ee + if (revents) + read(pq->prod_fd, buf, 8); + if (!pq->kill) -+ pollqueue_add_task(pq, pq->prod_pt, -1); ++ pollqueue_add_task(pq->prod_pt, -1); +} + +struct pollqueue * pollqueue_new(void) @@ -53004,26 +53236,29 @@ index 0000000000..0f7d9020ee + if (!pq) + return NULL; + *pq = (struct pollqueue){ ++ .ref_count = ATOMIC_VAR_INIT(0), ++ .lock = PTHREAD_MUTEX_INITIALIZER, + .head = NULL, + .tail = NULL, + .kill = false, -+ .lock = PTHREAD_MUTEX_INITIALIZER, + .prod_fd = -1 + }; + + pq->prod_fd = eventfd(0, EFD_NONBLOCK); + if (pq->prod_fd == 1) + goto fail1; -+ pq->prod_pt = polltask_new(pq->prod_fd, POLLIN, prod_fn, pq); ++ pq->prod_pt = polltask_new(pq, pq->prod_fd, POLLIN, prod_fn, pq); + if (!pq->prod_pt) + goto fail2; -+ pollqueue_add_task(pq, pq->prod_pt, -1); ++ pollqueue_add_task(pq->prod_pt, -1); + if (pthread_create(&pq->worker, NULL, poll_thread, pq)) + goto fail3; ++ // Reset ref count which will have been inced by the add_task ++ atomic_store(&pq->ref_count, 0); + return pq; + +fail3: -+ polltask_delete(&pq->prod_pt); ++ polltask_free(pq->prod_pt); +fail2: + close(pq->prod_fd); +fail1: @@ -53031,49 +53266,66 @@ index 0000000000..0f7d9020ee + return NULL; +} + -+void pollqueue_delete(struct pollqueue **const ppq) ++static void pollqueue_free(struct pollqueue *const pq) +{ -+ struct pollqueue * pq = *ppq; + void *rv; + -+ if (!pq) -+ return; -+ *ppq = NULL; -+ + pthread_mutex_lock(&pq->lock); + pq->kill = true; + pollqueue_prod(pq); + pthread_mutex_unlock(&pq->lock); + + pthread_join(pq->worker, &rv); -+ polltask_delete(&pq->prod_pt); ++ polltask_free(pq->prod_pt); + pthread_mutex_destroy(&pq->lock); + close(pq->prod_fd); + free(pq); +} + ++struct pollqueue * pollqueue_ref(struct pollqueue *const pq) ++{ ++ atomic_fetch_add(&pq->ref_count, 1); ++ return pq; ++} ++ ++void pollqueue_unref(struct pollqueue **const ppq) ++{ ++ struct pollqueue * const pq = *ppq; ++ ++ if (!pq) ++ return; ++ *ppq = NULL; ++ ++ if (atomic_fetch_sub(&pq->ref_count, 1) != 0) ++ return; ++ ++ pollqueue_free(pq); ++} ++ ++ + diff --git a/libavcodec/v4l2_req_pollqueue.h b/libavcodec/v4l2_req_pollqueue.h new file mode 100644 -index 0000000000..dcb0d80258 +index 0000000000..e1182cb2fc --- /dev/null +++ b/libavcodec/v4l2_req_pollqueue.h -@@ -0,0 +1,17 @@ +@@ -0,0 +1,18 @@ +#ifndef POLLQUEUE_H_ +#define POLLQUEUE_H_ + +struct polltask; +struct pollqueue; + -+struct polltask *polltask_new(const int fd, const short events, ++struct polltask *polltask_new(struct pollqueue *const pq, ++ const int fd, const short events, + void (*const fn)(void *v, short revents), + void *const v); +void polltask_delete(struct polltask **const ppt); + -+void pollqueue_add_task(struct pollqueue *const pq, struct polltask *const pt, -+ const int timeout); ++void pollqueue_add_task(struct polltask *const pt, const int timeout); +struct pollqueue * pollqueue_new(void); -+void pollqueue_delete(struct pollqueue **const ppq); ++void pollqueue_unref(struct pollqueue **const ppq); ++struct pollqueue * pollqueue_ref(struct pollqueue *const pq); + +#endif /* POLLQUEUE_H_ */ diff --git a/libavcodec/v4l2_req_utils.h b/libavcodec/v4l2_req_utils.h @@ -53105,10 +53357,10 @@ index 0000000000..9e9a5f7e39 + diff --git a/libavcodec/v4l2_request_hevc.c b/libavcodec/v4l2_request_hevc.c new file mode 100644 -index 0000000000..5f287ee75c +index 0000000000..18ff8c0e64 --- /dev/null +++ b/libavcodec/v4l2_request_hevc.c -@@ -0,0 +1,274 @@ +@@ -0,0 +1,280 @@ +/* + * This file is part of FFmpeg. + * @@ -53200,9 +53452,13 @@ index 0000000000..5f287ee75c +{ + V4L2RequestContextHEVC * const ctx = avctx->internal->hwaccel_priv_data; + ++ av_log(avctx, AV_LOG_DEBUG, "<<< %s\n", __func__); ++ ++ decode_q_wait(&ctx->decode_q, NULL); // Wait for all other threads to be out of decode ++ + mediabufs_ctl_unref(&ctx->mbufs); + media_pool_delete(&ctx->mpool); -+ pollqueue_delete(&ctx->pq); ++ pollqueue_unref(&ctx->pq); + dmabufs_ctl_delete(&ctx->dbufs); + devscan_delete(&ctx->devscan); + @@ -53244,6 +53500,8 @@ index 0000000000..5f287ee75c + const uint32_t src_pix_fmt = V2(ff_v4l2_req_hevc, 1).src_pix_fmt_v4l2; // Assuming constant for all APIs but avoiding V4L2 includes + size_t src_size; + ++ av_log(avctx, AV_LOG_DEBUG, "<<< %s\n", __func__); ++ + if ((ret = devscan_build(avctx, &ctx->devscan)) != 0) { + av_log(avctx, AV_LOG_WARNING, "Failed to find any V4L2 devices\n"); + return (AVERROR(-ret)); @@ -53359,7 +53617,7 @@ index 0000000000..5f287ee75c +fail3: + media_pool_delete(&ctx->mpool); +fail2: -+ pollqueue_delete(&ctx->pq); ++ pollqueue_unref(&ctx->pq); +fail1: + dmabufs_ctl_delete(&ctx->dbufs); +fail0: @@ -53625,10 +53883,10 @@ index 0000000000..415b6a27a0 + + diff --git a/libavdevice/Makefile b/libavdevice/Makefile -index 6ea62b914e..a336cbc596 100644 +index 0dfe47a1f4..ec7c7b4147 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile -@@ -46,6 +46,9 @@ OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_enc.o sndio.o +@@ -47,6 +47,9 @@ OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_enc.o sndio.o OBJS-$(CONFIG_V4L2_INDEV) += v4l2.o v4l2-common.o timefilter.o OBJS-$(CONFIG_V4L2_OUTDEV) += v4l2enc.o v4l2-common.o OBJS-$(CONFIG_VFWCAP_INDEV) += vfwcap.o @@ -53639,10 +53897,10 @@ index 6ea62b914e..a336cbc596 100644 OBJS-$(CONFIG_XV_OUTDEV) += xv.o diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c -index 8633433254..bc15112a00 100644 +index 92b27a1d14..19d2a9de55 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c -@@ -52,6 +52,9 @@ extern AVOutputFormat ff_sndio_muxer; +@@ -53,6 +53,9 @@ extern AVOutputFormat ff_sndio_muxer; extern AVInputFormat ff_v4l2_demuxer; extern AVOutputFormat ff_v4l2_muxer; extern AVInputFormat ff_vfwcap_demuxer; @@ -53654,10 +53912,10 @@ index 8633433254..bc15112a00 100644 diff --git a/libavdevice/drm_vout.c b/libavdevice/drm_vout.c new file mode 100644 -index 0000000000..d58b8fc7c8 +index 0000000000..064cbf6b08 --- /dev/null +++ b/libavdevice/drm_vout.c -@@ -0,0 +1,633 @@ +@@ -0,0 +1,643 @@ +/* + * Copyright (c) 2020 John Cox for Raspberry Pi Trading + * @@ -53714,6 +53972,7 @@ index 0000000000..d58b8fc7c8 + +typedef struct drm_aux_s { + unsigned int fb_handle; ++ uint32_t bo_handles[AV_DRM_MAX_PLANES]; + AVFrame * frame; +} drm_aux_t; + @@ -53827,6 +54086,13 @@ index 0000000000..d58b8fc7c8 + da->fb_handle = 0; + } + ++ for (unsigned int i = 0; i != AV_DRM_MAX_PLANES; ++i) { ++ if (da->bo_handles[i]) { ++ struct drm_gem_close gem_close = {.handle = da->bo_handles[i]}; ++ drmIoctl(de->drm_fd, DRM_IOCTL_GEM_CLOSE, &gem_close); ++ da->bo_handles[i] = 0; ++ } ++ } + av_frame_free(&da->frame); +} + @@ -53872,14 +54138,13 @@ index 0000000000..d58b8fc7c8 + uint32_t pitches[4] = {0}; + uint32_t offsets[4] = {0}; + uint64_t modifiers[4] = {0}; -+ uint32_t bo_object_handles[4] = {0}; + uint32_t bo_handles[4] = {0}; + int i, j, n; + + da->frame = frame; + + for (i = 0; i < desc->nb_objects; ++i) { -+ if (drmPrimeFDToHandle(de->drm_fd, desc->objects[i].fd, bo_object_handles + i) != 0) { ++ if (drmPrimeFDToHandle(de->drm_fd, desc->objects[i].fd, da->bo_handles + i) != 0) { + av_log(s, AV_LOG_WARNING, "drmPrimeFDToHandle[%d](%d) failed: %s\n", i, desc->objects[i].fd, ERRSTR); + return -1; + } @@ -53893,7 +54158,7 @@ index 0000000000..d58b8fc7c8 + pitches[n] = p->pitch; + offsets[n] = p->offset; + modifiers[n] = obj->format_modifier; -+ bo_handles[n] = bo_object_handles[p->object_index]; ++ bo_handles[n] = da->bo_handles[p->object_index]; + ++n; + } + } @@ -54249,6 +54514,9 @@ index 0000000000..d58b8fc7c8 + sem_destroy(&de->q_sem_in); + sem_destroy(&de->q_sem_out); + ++ for (unsigned int i = 0; i != AUX_SIZE; ++i) ++ da_uninit(de, de->aux + i); ++ + av_frame_free(&de->q_next); + + if (de->drm_fd >= 0) { @@ -55663,10 +55931,10 @@ index 0000000000..84723a34ad + .deinit = rpi_vout_deinit, +}; diff --git a/libavfilter/Makefile b/libavfilter/Makefile -index 5123540653..17ccea3150 100644 +index b2c254ea67..2ecd5b3c81 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile -@@ -434,6 +434,7 @@ OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER) += vf_transpose_opencl.o opencl.o o +@@ -459,6 +459,7 @@ OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER) += vf_transpose_opencl.o opencl.o o OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER) += vf_transpose_vaapi.o vaapi_vpp.o OBJS-$(CONFIG_TRIM_FILTER) += trim.o OBJS-$(CONFIG_UNPREMULTIPLY_FILTER) += vf_premultiply.o framesync.o @@ -55675,10 +55943,10 @@ index 5123540653..17ccea3150 100644 OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER) += vf_unsharp_opencl.o opencl.o \ opencl/unsharp.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c -index 1183e40267..2f569057dd 100644 +index 0872c6e0f2..c894cb8bbd 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c -@@ -414,6 +414,7 @@ extern AVFilter ff_vf_transpose_opencl; +@@ -438,6 +438,7 @@ extern AVFilter ff_vf_transpose_opencl; extern AVFilter ff_vf_transpose_vaapi; extern AVFilter ff_vf_trim; extern AVFilter ff_vf_unpremultiply; @@ -55687,7 +55955,7 @@ index 1183e40267..2f569057dd 100644 extern AVFilter ff_vf_unsharp_opencl; extern AVFilter ff_vf_untile; diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c -index 2fe4f0b0f9..5a8e6b3f24 100644 +index f6b572b3de..44fe8b679c 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -32,6 +32,9 @@ @@ -55700,8 +55968,8 @@ index 2fe4f0b0f9..5a8e6b3f24 100644 #define FF_INTERNAL_FIELDS 1 #include "framequeue.h" -@@ -429,6 +432,19 @@ static int can_merge_formats(AVFilterFormats *a_arg, - } +@@ -422,6 +425,19 @@ static int formats_declared(AVFilterContext *f) + return 1; } +#if CONFIG_UNSAND_FILTER @@ -55720,7 +55988,7 @@ index 2fe4f0b0f9..5a8e6b3f24 100644 /** * Perform one round of query_formats() and merging formats lists on the * filter graph. -@@ -469,6 +485,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) +@@ -462,6 +478,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) for (j = 0; j < filter->nb_inputs; j++) { AVFilterLink *link = filter->inputs[j]; int convert_needed = 0; @@ -55728,8 +55996,8 @@ index 2fe4f0b0f9..5a8e6b3f24 100644 if (!link) continue; -@@ -516,11 +533,14 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) - ) +@@ -504,11 +521,14 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) + link->outcfg.formats, link->type) #undef MERGE_DISPATCH - if (convert_needed) { @@ -55744,7 +56012,7 @@ index 2fe4f0b0f9..5a8e6b3f24 100644 if (graph->disable_auto_convert) { av_log(log_ctx, AV_LOG_ERROR, -@@ -533,19 +553,45 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) +@@ -521,19 +541,45 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) /* couldn't merge format lists. auto-insert conversion filter */ switch (link->type) { case AVMEDIA_TYPE_VIDEO: @@ -55760,7 +56028,7 @@ index 2fe4f0b0f9..5a8e6b3f24 100644 + // Only try each extra conversion once + // The unsand output pad should never trigger has_sand_format + // but it is better to be safe -+ if ((extra_convert_tried & 1) == 0 && has_sand_format(link->in_formats)) { ++ if ((extra_convert_tried & 1) == 0 && has_sand_format(link->incfg.formats)) { + if (!(filter = avfilter_get_by_name("unsand"))) { + av_log(log_ctx, AV_LOG_ERROR, "'unsand' filter " + "not present, cannot convert pixel formats.\n"); @@ -55802,33 +56070,25 @@ index 2fe4f0b0f9..5a8e6b3f24 100644 break; case AVMEDIA_TYPE_AUDIO: if (!(filter = avfilter_get_by_name("aresample"))) { -@@ -587,9 +633,19 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) - av_assert0(outlink-> in_channel_layouts->refcount > 0); - av_assert0(outlink->out_channel_layouts->refcount > 0); - } -- if (!ff_merge_formats( inlink->in_formats, inlink->out_formats, inlink->type) || -- !ff_merge_formats(outlink->in_formats, outlink->out_formats, outlink->type)) -+ // If we have added an extra filter we must merge the input -+ // side but we can have another go at the output -+ if (!ff_merge_formats( inlink->in_formats, inlink->out_formats, inlink->type)) -+ ret = AVERROR(ENOSYS); -+ else if (!ff_merge_formats(outlink->in_formats, outlink->out_formats, outlink->type)) -+ { -+ if (can_retry) { +@@ -589,6 +635,13 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) + outlink->outcfg.samplerates) || + CHECKED_MERGE(channel_layouts, outlink->incfg.channel_layouts, + outlink->outcfg.channel_layouts))) { ++ // Try adding an unsand filter & see if that helps ++ if (ret < 0 && can_retry) { + link = outlink; + convert_needed = 1; + continue; + } - ret = AVERROR(ENOSYS); -+ } - if (inlink->type == AVMEDIA_TYPE_AUDIO && - (!ff_merge_samplerates(inlink->in_samplerates, - inlink->out_samplerates) || ++ + if (ret < 0) + return ret; + av_log(log_ctx, AV_LOG_ERROR, diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c -index bf30f54177..eb5dfa22f8 100644 +index da1cf9941e..c588ed23cb 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c -@@ -210,7 +210,7 @@ static int av_buffersrc_add_frame_internal(AVFilterContext *ctx, +@@ -188,7 +188,7 @@ int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFra switch (ctx->outputs[0]->type) { case AVMEDIA_TYPE_VIDEO: @@ -55839,10 +56099,10 @@ index bf30f54177..eb5dfa22f8 100644 case AVMEDIA_TYPE_AUDIO: diff --git a/libavfilter/vf_unsand.c b/libavfilter/vf_unsand.c new file mode 100644 -index 0000000000..fbea56dd09 +index 0000000000..61c03a385c --- /dev/null +++ b/libavfilter/vf_unsand.c -@@ -0,0 +1,234 @@ +@@ -0,0 +1,229 @@ +/* + * Copyright (c) 2007 Bobby Bingham + * @@ -55956,26 +56216,21 @@ index 0000000000..fbea56dd09 + if (ctx->inputs[0] == NULL || ctx->outputs[0] == NULL) + return 0; + -+// printf("Unsand: %s in: ", __func__); -+// dump_fmts(ctx->inputs[0]->in_formats); -+// printf("Unsand: %s out: ", __func__); -+// dump_fmts(ctx->outputs[0]->out_formats); -+ + // Our output formats depend on our input formats and we can't/don't + // want to convert between bit depths so we need to wait for the source + // to have an opinion before we do -+ if (ctx->inputs[0]->in_formats == NULL) ++ if (ctx->inputs[0]->incfg.formats == NULL) + return AVERROR(EAGAIN); + + // Accept anything -+ if (ctx->inputs[0]->out_formats == NULL && -+ (ret = ff_formats_ref(ctx->inputs[0]->in_formats, &ctx->inputs[0]->out_formats)) < 0) ++ if (ctx->inputs[0]->outcfg.formats == NULL && ++ (ret = ff_formats_ref(ctx->inputs[0]->incfg.formats, &ctx->inputs[0]->outcfg.formats)) < 0) + return ret; + + // Filter out sand formats + + // Generate a container if we don't already have one -+ if (ctx->outputs[0]->in_formats == NULL) ++ if (ctx->outputs[0]->incfg.formats == NULL) + { + // Somewhat rubbish way of ensuring we have a good structure + const static enum AVPixelFormat out_fmts[] = {AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}; @@ -55983,15 +56238,15 @@ index 0000000000..fbea56dd09 + + if (formats == NULL) + return AVERROR(ENOMEM); -+ if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->in_formats)) < 0) ++ if ((ret = ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats)) < 0) + return ret; + } + + // Replace old format list with new filtered list derived from what our + // input says it can do + { -+ const AVFilterFormats * const src_ff = ctx->inputs[0]->out_formats; -+ AVFilterFormats * const dst_ff = ctx->outputs[0]->in_formats; ++ const AVFilterFormats * const src_ff = ctx->inputs[0]->outcfg.formats; ++ AVFilterFormats * const dst_ff = ctx->outputs[0]->incfg.formats; + enum AVPixelFormat *dst_fmts = av_malloc(sizeof(enum AVPixelFormat) * src_ff->nb_formats); + int i; + int n = 0; @@ -56030,7 +56285,7 @@ index 0000000000..fbea56dd09 + } + +// printf("Unsand: %s calc: ", __func__); -+// dump_fmts(ctx->outputs[0]->in_formats); ++// dump_fmts(ctx->outputs[0]->incfg.formats); + + return 0; +} @@ -56078,10 +56333,10 @@ index 0000000000..fbea56dd09 +}; + diff --git a/libavformat/utils.c b/libavformat/utils.c -index 7185fbfd71..c7b0553903 100644 +index 1384b56771..27479e3c40 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c -@@ -3048,6 +3048,40 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr) +@@ -3011,6 +3011,40 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr) return 1; } @@ -56122,8 +56377,8 @@ index 7185fbfd71..c7b0553903 100644 /* returns 1 or 0 if or if not decoded data was returned, or a negative error */ static int try_decode_frame(AVFormatContext *s, AVStream *st, const AVPacket *avpkt, AVDictionary **options) -@@ -3082,7 +3116,11 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, - av_dict_set(options ? options : &thread_opt, "threads", "1", 0); +@@ -3049,7 +3083,11 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, + av_dict_set(options ? options : &thread_opt, "lowres", "0", 0); if (s->codec_whitelist) av_dict_set(options ? options : &thread_opt, "codec_whitelist", s->codec_whitelist, 0); - ret = avcodec_open2(avctx, codec, options ? options : &thread_opt); @@ -56135,7 +56390,7 @@ index 7185fbfd71..c7b0553903 100644 if (!options) av_dict_free(&thread_opt); if (ret < 0) { -@@ -3113,6 +3151,14 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, +@@ -3080,6 +3118,14 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, if (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO) { ret = avcodec_send_packet(avctx, &pkt); @@ -56150,9 +56405,9 @@ index 7185fbfd71..c7b0553903 100644 if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) break; if (ret >= 0) -@@ -3723,9 +3769,20 @@ FF_ENABLE_DEPRECATION_WARNINGS +@@ -3708,9 +3754,20 @@ FF_ENABLE_DEPRECATION_WARNINGS // Try to just open decoders, in case this is enough to get parameters. - if (!has_codec_parameters(st, NULL) && st->request_probe <= 0) { + if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0) { if (codec && !avctx->codec) - if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0) - av_log(ic, AV_LOG_WARNING, @@ -56175,7 +56430,7 @@ index 7185fbfd71..c7b0553903 100644 if (!options) av_dict_free(&thread_opt); diff --git a/libavutil/Makefile b/libavutil/Makefile -index 9b08372eb2..c965c2dc85 100644 +index 27bafe9e12..c9075ddf8a 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -68,6 +68,7 @@ HEADERS = adler32.h \ @@ -56186,15 +56441,15 @@ index 9b08372eb2..c965c2dc85 100644 samplefmt.h \ sha.h \ sha512.h \ -@@ -86,6 +87,7 @@ HEADERS = adler32.h \ - tx.h \ +@@ -87,6 +88,7 @@ HEADERS = adler32.h \ + film_grain_params.h \ HEADERS-$(CONFIG_LZO) += lzo.h +HEADERS-$(CONFIG-RPI) += rpi_sand_fn_pw.h ARCH_HEADERS = bswap.h \ intmath.h \ -@@ -180,6 +182,7 @@ OBJS-$(CONFIG_LZO) += lzo.o +@@ -182,6 +184,7 @@ OBJS-$(CONFIG_LZO) += lzo.o OBJS-$(CONFIG_MEDIACODEC) += hwcontext_mediacodec.o OBJS-$(CONFIG_OPENCL) += hwcontext_opencl.o OBJS-$(CONFIG_QSV) += hwcontext_qsv.o @@ -57846,7 +58101,7 @@ index 0000000000..447f367bea +#endif // AVUTIL_ARM_SAND_NEON_H + diff --git a/libavutil/frame.c b/libavutil/frame.c -index 2e952edd29..96e8bf5b3e 100644 +index 75e347bf2f..daa6477485 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -16,6 +16,8 @@ @@ -57868,7 +58123,7 @@ index 2e952edd29..96e8bf5b3e 100644 #if FF_API_FRAME_GET_SET MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp) -@@ -902,6 +907,12 @@ int av_frame_apply_cropping(AVFrame *frame, int flags) +@@ -903,6 +908,12 @@ int av_frame_apply_cropping(AVFrame *frame, int flags) (frame->crop_top + frame->crop_bottom) >= frame->height) return AVERROR(ERANGE); @@ -57882,10 +58137,10 @@ index 2e952edd29..96e8bf5b3e 100644 if (!desc) return AVERROR_BUG; diff --git a/libavutil/frame.h b/libavutil/frame.h -index fc67db0f6c..b1a7eb4858 100644 +index 7d1f8e2935..a4e7dc915d 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h -@@ -968,6 +968,16 @@ int av_frame_apply_cropping(AVFrame *frame, int flags); +@@ -990,6 +990,16 @@ int av_frame_apply_cropping(AVFrame *frame, int flags); */ const char *av_frame_side_data_name(enum AVFrameSideDataType type); @@ -57903,116 +58158,58 @@ index fc67db0f6c..b1a7eb4858 100644 * @} */ diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c -index 32cbde82eb..c5d0b960af 100644 +index 7a9fdbd263..2a498f9b50 100644 --- a/libavutil/hwcontext_drm.c +++ b/libavutil/hwcontext_drm.c -@@ -19,8 +19,10 @@ +@@ -21,6 +21,7 @@ #include #include #include +#include + /* This was introduced in version 4.6. And may not exist all without an + * optional package. So to prevent a hard dependency on needing the Linux +@@ -31,6 +32,7 @@ + #endif + #include +#include #include #include "avassert.h" -@@ -28,6 +30,11 @@ +@@ -38,7 +40,9 @@ #include "hwcontext_drm.h" #include "hwcontext_internal.h" #include "imgutils.h" +- ++#if CONFIG_SAND +#include "libavutil/rpi_sand_fns.h" -+ -+#include -+#include -+#include - ++#endif static void drm_device_free(AVHWDeviceContext *hwdev) -@@ -43,6 +50,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, + { +@@ -53,6 +57,11 @@ static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, AVDRMDeviceContext *hwctx = hwdev->hwctx; drmVersionPtr version; + if (device == NULL) { -+ hwctx->fd = -1; -+ return 0; ++ hwctx->fd = -1; ++ return 0; + } + hwctx->fd = open(device, O_RDWR); if (hwctx->fd < 0) return AVERROR(errno); -@@ -85,18 +97,37 @@ static int drm_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame) - typedef struct DRMMapping { - // Address and length of each mmap()ed region. - int nb_regions; -+ unsigned int dmaflags; - void *address[AV_DRM_MAX_PLANES]; - size_t length[AV_DRM_MAX_PLANES]; -+ int fds[AV_DRM_MAX_PLANES]; - } DRMMapping; - -+static int dmasync(const int fd, const unsigned int flags) -+{ -+ struct dma_buf_sync sync = { -+ .flags = flags -+ }; -+ while (ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync) == -1) { -+ const int err = errno; -+ if (errno == EINTR) -+ continue; -+ av_log(NULL, AV_LOG_WARNING, "%s: ioctl failed: flags=%#x\n", __func__, flags); -+ return -err; -+ } -+ return 0; -+} -+ - static void drm_unmap_frame(AVHWFramesContext *hwfc, - HWMapDescriptor *hwmap) - { - DRMMapping *map = hwmap->priv; - int i; - -- for (i = 0; i < map->nb_regions; i++) -+ for (i = 0; i < map->nb_regions; i++) { - munmap(map->address[i], map->length[i]); -+ dmasync(map->fds[i], DMA_BUF_SYNC_END | map->dmaflags); -+ } - - av_free(map); - } -@@ -114,15 +145,28 @@ static int drm_map_frame(AVHWFramesContext *hwfc, - if (!map) - return AVERROR(ENOMEM); - -+ for (i = 0; i < AV_DRM_MAX_PLANES; i++) -+ map->fds[i] = -1; -+ - mmap_prot = 0; -- if (flags & AV_HWFRAME_MAP_READ) -+ if (flags & AV_HWFRAME_MAP_READ) { -+ map->dmaflags |= DMA_BUF_SYNC_READ; - mmap_prot |= PROT_READ; -- if (flags & AV_HWFRAME_MAP_WRITE) -+ } -+ if (flags & AV_HWFRAME_MAP_WRITE) { -+ map->dmaflags |= DMA_BUF_SYNC_WRITE; +@@ -139,6 +148,8 @@ static int drm_map_frame(AVHWFramesContext *hwfc, + if (flags & AV_HWFRAME_MAP_WRITE) mmap_prot |= PROT_WRITE; -+ } -+ + + if (dst->format == AV_PIX_FMT_NONE) + dst->format = hwfc->sw_format; - - av_assert0(desc->nb_objects <= AV_DRM_MAX_PLANES); - for (i = 0; i < desc->nb_objects; i++) { -- addr = mmap(NULL, desc->objects[i].size, mmap_prot, MAP_SHARED, -+ dmasync(desc->objects[i].fd, DMA_BUF_SYNC_START | map->dmaflags); -+ map->fds[i] = desc->objects[i].fd; -+ -+ addr = mmap(NULL, desc->objects[i].size, mmap_prot, MAP_SHARED | MAP_POPULATE, - desc->objects[i].fd, 0); - if (addr == MAP_FAILED) { - err = AVERROR(errno); -@@ -151,6 +195,23 @@ static int drm_map_frame(AVHWFramesContext *hwfc, + #if HAVE_LINUX_DMA_BUF_H + if (flags & AV_HWFRAME_MAP_READ) + map->sync_flags |= DMA_BUF_SYNC_READ; +@@ -185,6 +196,23 @@ static int drm_map_frame(AVHWFramesContext *hwfc, dst->width = src->width; dst->height = src->height; @@ -58036,18 +58233,7 @@ index 32cbde82eb..c5d0b960af 100644 err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, &drm_unmap_frame, map); -@@ -160,7 +221,9 @@ static int drm_map_frame(AVHWFramesContext *hwfc, - return 0; - - fail: -- for (i = 0; i < desc->nb_objects; i++) { -+ for (i = 0; i < AV_DRM_MAX_PLANES; i++) { -+ if (map->fds[i] != -1) -+ dmasync(map->fds[i], DMA_BUF_SYNC_END | map->dmaflags); - if (map->address[i]) - munmap(map->address[i], map->length[i]); - } -@@ -178,7 +241,15 @@ static int drm_transfer_get_formats(AVHWFramesContext *ctx, +@@ -212,7 +240,15 @@ static int drm_transfer_get_formats(AVHWFramesContext *ctx, if (!pix_fmts) return AVERROR(ENOMEM); @@ -58064,7 +58250,7 @@ index 32cbde82eb..c5d0b960af 100644 pix_fmts[1] = AV_PIX_FMT_NONE; *formats = pix_fmts; -@@ -197,18 +268,80 @@ static int drm_transfer_data_from(AVHWFramesContext *hwfc, +@@ -231,18 +267,80 @@ static int drm_transfer_data_from(AVHWFramesContext *hwfc, map = av_frame_alloc(); if (!map) return AVERROR(ENOMEM); @@ -58080,7 +58266,7 @@ index 32cbde82eb..c5d0b960af 100644 - map->height = dst->height; +#if 0 + av_log(hwfc, AV_LOG_INFO, "%s: src fmt=%d (%d), dst fmt=%d (%d) s=%dx%d l=%d/%d/%d/%d, d=%dx%d l=%d/%d/%d\n", __func__, -+ map->hwfc_format, AV_PIX_FMT_RPI4_8, dst->format, AV_PIX_FMT_YUV420P10LE, ++ hwfc->sw_format, AV_PIX_FMT_RPI4_8, dst->format, AV_PIX_FMT_YUV420P10LE, + map->width, map->height, + map->linesize[0], + map->linesize[1], @@ -58149,7 +58335,7 @@ index 32cbde82eb..c5d0b960af 100644 err = 0; fail: -@@ -223,7 +356,10 @@ static int drm_transfer_data_to(AVHWFramesContext *hwfc, +@@ -257,7 +355,10 @@ static int drm_transfer_data_to(AVHWFramesContext *hwfc, int err; if (src->width > hwfc->width || src->height > hwfc->height) @@ -58161,10 +58347,10 @@ index 32cbde82eb..c5d0b960af 100644 map = av_frame_alloc(); if (!map) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c -index 9d61c52567..1cda09f53c 100644 +index 18c7a0efc8..15eafb4c54 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c -@@ -2371,6 +2371,38 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { +@@ -2395,6 +2395,38 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .name = "vulkan", .flags = AV_PIX_FMT_FLAG_HWACCEL, }, @@ -58204,7 +58390,7 @@ index 9d61c52567..1cda09f53c 100644 #if FF_API_PLUS1_MINUS1 FF_ENABLE_DEPRECATION_WARNINGS diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h -index 1c625cfc8a..e7f543b797 100644 +index 46ef211add..84b7c9dd88 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -357,6 +357,12 @@ enum AVPixelFormat { @@ -58218,8 +58404,8 @@ index 1c625cfc8a..e7f543b797 100644 + AV_PIX_FMT_RPI4_8, + AV_PIX_FMT_RPI4_10, - AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions - }; + AV_PIX_FMT_X2RGB10LE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined + AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), big-endian, X=unused/undefined diff --git a/libavutil/rpi_sand_fn_pw.h b/libavutil/rpi_sand_fn_pw.h new file mode 100644 index 0000000000..0d5d203dc3 @@ -59788,10 +59974,10 @@ index 0000000000..fc14f2a3c2 +1,WPP_F_ericsson_MAIN_2,WPP_F_ericsson_MAIN_2.bit,WPP_F_ericsson_MAIN_2_yuv.md5 diff --git a/pi-util/conf_native.sh b/pi-util/conf_native.sh new file mode 100755 -index 0000000000..d5240ff388 +index 0000000000..13fae3cf78 --- /dev/null +++ b/pi-util/conf_native.sh -@@ -0,0 +1,76 @@ +@@ -0,0 +1,77 @@ +echo "Configure for native build" + +FFSRC=`pwd` @@ -59823,15 +60009,16 @@ index 0000000000..d5240ff388 + RPIOPTS="--enable-mmal --enable-rpi" +fi +C=`lsb_release -sc` ++V=`cat RELEASE` + +SHARED_LIBS="--enable-shared" +if [ "$1" == "--noshared" ]; then + SHARED_LIBS="--disable-shared" -+ OUT=out/$B-$C-static-rel ++ OUT=out/$B-$C-$V-static-rel + echo Static libs +else + echo Shared libs -+ OUT=out/$B-$C-shared-rel ++ OUT=out/$B-$C-$V-shared-rel +fi + +USR_PREFIX=$FFSRC/$OUT/install