Accepting request 983700 from home:StefanBruens:branches:science

- update to 4.6.0, highlights below, for details check
  https://github.com/opencv/opencv/wiki/ChangeLog#version460
  * OpenCV project infrastructure migrating on GitHub Actions
    workflows for CI and release purposes
  * Added support for GCC 12, Clang 15
  * Added support for FFmpeg 5.0
  * DNN module patches:
    + Improved layers / activations / supported more models:
      - LSTM (+CUDA), resize (+ONNX13), Sign, Shrink, Reciprocal,
        depth2space, space2depth
      - fixes in Reduce, Slice, Expand
    + Disabled floating-point denormals processing #21521
    + Changed layer names in ONNX importer to support "output"
      entities properly
    + Added TIM-VX NPU backend support:
      https://github.com/opencv/opencv/wiki/TIM-VX-Backend-For-Running-OpenCV-On-NPU
    + Added Softmax parameter to ClassificationModel
    + Added audio speech recognition sample (C++) #21458
    + Intel® Inference Engine backend (OpenVINO):
      - added initial support for OpenVINO 2022.1 release
      - removed support of legacy API (dropped since 2020.3)
  * G-API module:
    + G-API framework:
      - Introduced a Grayscale image format support for
        cv::MediaFrame: #21511;
      - Enabeled .reshape() support in the CPU backend: #21669;
      - Fixed possible hang in streaming execution mode with constant
        inputs: #21567;
      - Introduced proper error/exception propagation in the
        asynchronous streaming execution mode: #21660;
      - Fixed new stream event handling: #21731.
    + Fluid backend:
      - Fixed horizontal pass in the Resize kernel, fixed Valgrind
        issues: #21144;
      - Extended Resize kernel with F32 version: #21678,
        added AVX: #21728.
      - Enabled dynamic dispatch for Split4 kernel: #21520;
      - Enabled dynamic dispatch for Merge3 kernel: #21529;
      - Added a SIMD version for DivC kernel: #21474;
      - Added a SIMD version for DivRC kernel: #21530;
      - Enabled dynamic dispatch for Add kernel: #21686;
      - Enabled dynamic dispatch for Sub kernel: #21746;
      - Added a SIMD version for ConvertTo kernel: #21777;
      - Fixed kernel matrix size for Sobel kernel: #21613.
    + Intel® OpenVINO™ inference backend:
      - Fixed NV12 format support for remote memory when OpenVINO
        remote context is used: #21424.
      - Implemented correct error handling in the backend: #21579.
      - Fixed ngraph warnings #21362.
    + OpenCV AI Kit backend:
      - Introduced a new backend to program OpenCV AI Kit boards via
        G-API. Currently the backend is in experimental state, but allows
        to build Camera+NN pipeline and supports heterogeneity (mixing
        with host-side code): #20785, #21504.
    + Media integration:
      - Enabled GPU inference with oneVPL and DirectX11 on Windows in
        Intel OpenVINO inference backend: #21232, #21618, #21658, #21687,
        #21688. Now GPU textures decoded by oneVPL decoder can be
        preprocessed and inferred on GPU with no extra host processing.
      - Enabled oneVPL support on Linux: #21883.
      - Extended GStreamer pipeline source with Grayscale image format
        support: #21560.
    + Python bindings:
      - Exposed GStreamer pipeline source in Python bindings: #20832.
      - Fixed Python bindings for CudaBufferPool, cudacodec and cudastereo
        modules in OpenCV Contrib.
    + Samples:
      - Introduced a pipeline modelling tool for cascaded model
        benchmarking: #21477, #21636, #21719. The tool supports a
        declarative YAML-based config to describe pipelines with simulated
        pre-/post-processing. The tool collects and reports latency and
        throughput information for the modelled pipeline.
    + Other changes and fixes:
      - Moved GKernelPackage into cv:: namespace by default, its cv::gapi::
        alias remain for compatibility: #21318;
      - Moved Resize kernel from core to imgproc kernel packages for
        CPU, OpenCL, and Fluid backends: #21157. Also moved tests
        appropriately: #21475;
      - Avoided sporadic test failures in DivC: #21626;
      - Fixed 1D Mat handling in the framework: #21782;
      - Reduced the number of G-API generated accuracy tests: #21909.
- Drop upstream patches:
  * 0001-highgui-Fix-unresolved-OpenGL-functions-for-Qt-backe.patch
  * videoio_initial_FFmpeg_5_0_support.patch
  * videoio_ffmpeg_avoid_memory_leaks.patch

OBS-URL: https://build.opensuse.org/request/show/983700
OBS-URL: https://build.opensuse.org/package/show/science/opencv?expand=0&rev=33
This commit is contained in:
Stefan Brüns 2022-06-27 16:05:05 +00:00 committed by Git OBS Bridge
parent 70a5e1ec8b
commit e20cd82f32
9 changed files with 133 additions and 1162 deletions

View File

@ -1,35 +0,0 @@
From 2835c13cbd14f4f41996a2c1f73ef860c89c20f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sun, 26 Dec 2021 00:08:06 +0100
Subject: [PATCH] highgui: Fix unresolved OpenGL functions for Qt backend
The Qt backend directly calls some OpenGL functions (glClear, glHint,
glViewport), but since OCV 4.5.5 the GL libraries are no longer part
of the global extra dependencies. When linking with "-Wl,--no-undefined"
this causes linker errors:
`opencv-4.5.5/modules/highgui/src/window_QT.cpp:3307: undefined reference to `glClear'`
Related issues: #21299
---
modules/highgui/CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt
index 6123ea1436..45e66dfa1e 100644
--- a/modules/highgui/CMakeLists.txt
+++ b/modules/highgui/CMakeLists.txt
@@ -279,6 +279,10 @@ if(OPENCV_HIGHGUI_BUILTIN_BACKEND STREQUAL "WIN32UI" AND HAVE_OPENGL AND OPENGL_
ocv_target_link_libraries(${the_module} PRIVATE "${OPENGL_LIBRARIES}")
endif()
+if(OPENCV_HIGHGUI_BUILTIN_BACKEND MATCHES "^QT" AND HAVE_OPENGL AND OPENGL_LIBRARIES)
+ ocv_target_link_libraries(${the_module} PRIVATE "${OPENGL_LIBRARIES}")
+endif()
+
if(MSVC AND NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
--
2.34.1

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a1cfdcf6619387ca9e232687504da996aaa9f7b5689986b8331ec02cb61d28ad
size 89879893

3
opencv-4.6.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
size 90208971

View File

@ -1,3 +1,92 @@
-------------------------------------------------------------------
Sun Jun 19 13:25:26 UTC 2022 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
- update to 4.6.0, highlights below, for details check
https://github.com/opencv/opencv/wiki/ChangeLog#version460
* OpenCV project infrastructure migrating on GitHub Actions
workflows for CI and release purposes
* Added support for GCC 12, Clang 15
* Added support for FFmpeg 5.0
* DNN module patches:
+ Improved layers / activations / supported more models:
- LSTM (+CUDA), resize (+ONNX13), Sign, Shrink, Reciprocal,
depth2space, space2depth
- fixes in Reduce, Slice, Expand
+ Disabled floating-point denormals processing #21521
+ Changed layer names in ONNX importer to support "output"
entities properly
+ Added TIM-VX NPU backend support:
https://github.com/opencv/opencv/wiki/TIM-VX-Backend-For-Running-OpenCV-On-NPU
+ Added Softmax parameter to ClassificationModel
+ Added audio speech recognition sample (C++) #21458
+ Intel® Inference Engine backend (OpenVINO):
- added initial support for OpenVINO 2022.1 release
- removed support of legacy API (dropped since 2020.3)
* G-API module:
+ G-API framework:
- Introduced a Grayscale image format support for
cv::MediaFrame: #21511;
- Enabeled .reshape() support in the CPU backend: #21669;
- Fixed possible hang in streaming execution mode with constant
inputs: #21567;
- Introduced proper error/exception propagation in the
asynchronous streaming execution mode: #21660;
- Fixed new stream event handling: #21731.
+ Fluid backend:
- Fixed horizontal pass in the Resize kernel, fixed Valgrind
issues: #21144;
- Extended Resize kernel with F32 version: #21678,
added AVX: #21728.
- Enabled dynamic dispatch for Split4 kernel: #21520;
- Enabled dynamic dispatch for Merge3 kernel: #21529;
- Added a SIMD version for DivC kernel: #21474;
- Added a SIMD version for DivRC kernel: #21530;
- Enabled dynamic dispatch for Add kernel: #21686;
- Enabled dynamic dispatch for Sub kernel: #21746;
- Added a SIMD version for ConvertTo kernel: #21777;
- Fixed kernel matrix size for Sobel kernel: #21613.
+ Intel® OpenVINO™ inference backend:
- Fixed NV12 format support for remote memory when OpenVINO
remote context is used: #21424.
- Implemented correct error handling in the backend: #21579.
- Fixed ngraph warnings #21362.
+ OpenCV AI Kit backend:
- Introduced a new backend to program OpenCV AI Kit boards via
G-API. Currently the backend is in experimental state, but allows
to build Camera+NN pipeline and supports heterogeneity (mixing
with host-side code): #20785, #21504.
+ Media integration:
- Enabled GPU inference with oneVPL and DirectX11 on Windows in
Intel OpenVINO inference backend: #21232, #21618, #21658, #21687,
#21688. Now GPU textures decoded by oneVPL decoder can be
preprocessed and inferred on GPU with no extra host processing.
- Enabled oneVPL support on Linux: #21883.
- Extended GStreamer pipeline source with Grayscale image format
support: #21560.
+ Python bindings:
- Exposed GStreamer pipeline source in Python bindings: #20832.
- Fixed Python bindings for CudaBufferPool, cudacodec and cudastereo
modules in OpenCV Contrib.
+ Samples:
- Introduced a pipeline modelling tool for cascaded model
benchmarking: #21477, #21636, #21719. The tool supports a
declarative YAML-based config to describe pipelines with simulated
pre-/post-processing. The tool collects and reports latency and
throughput information for the modelled pipeline.
+ Other changes and fixes:
- Moved GKernelPackage into cv:: namespace by default, its cv::gapi::
alias remain for compatibility: #21318;
- Moved Resize kernel from core to imgproc kernel packages for
CPU, OpenCL, and Fluid backends: #21157. Also moved tests
appropriately: #21475;
- Avoided sporadic test failures in DivC: #21626;
- Fixed 1D Mat handling in the framework: #21782;
- Reduced the number of G-API generated accuracy tests: #21909.
- Drop upstream patches:
* 0001-highgui-Fix-unresolved-OpenGL-functions-for-Qt-backe.patch
* videoio_initial_FFmpeg_5_0_support.patch
* videoio_ffmpeg_avoid_memory_leaks.patch
-------------------------------------------------------------------
Fri Apr 29 16:54:16 UTC 2022 - Stefan Brüns <stefan.bruens@rwth-aachen.de>

View File

@ -22,20 +22,15 @@
%endif
%define libname lib%{name}
%define soname 405
%define soname 406
# disabled by default as many fail
%bcond_with tests
%bcond_without gapi
%bcond_without ffmpeg
%if %{suse_version} < 1550
%bcond_without python2
%else
%bcond_with python2
%endif
%bcond_without python3
%bcond_without openblas
Name: opencv
Version: 4.5.5
Version: 4.6.0
Release: 0
Summary: Collection of algorithms for computer vision
# GPL-2.0 AND Apache-2.0 files are in 3rdparty/ittnotify which is not build
@ -45,12 +40,6 @@ URL: https://opencv.org/
Source0: https://github.com/opencv/opencv/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
# Several modules from the opencv_contrib package
Source1: https://github.com/opencv/opencv_contrib/archive/%{version}.tar.gz#/opencv_contrib-%{version}.tar.gz
# PATCH-FIX-UPSTREAM
Patch0: 0001-highgui-Fix-unresolved-OpenGL-functions-for-Qt-backe.patch
# PATCH-FIX-UPSTREAM
Patch1: https://github.com/opencv/opencv/pull/21754.patch#/videoio_initial_FFmpeg_5_0_support.patch
# PATCH-FIX-UPSTREAM
Patch2: https://github.com/opencv/opencv/commit/271f7df3435c619ceba9261f88dcfbb0714b0b0d.patch#/videoio_ffmpeg_avoid_memory_leaks.patch
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: libeigen3-devel
@ -82,11 +71,6 @@ BuildRequires: ade-devel >= 0.1.0
%if %{with openblas}
BuildRequires: openblas-devel
%endif
%if %{with python2}
BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(python)
BuildRequires: python2-numpy-devel
%endif
%if %{with python3}
BuildRequires: python-rpm-macros
BuildRequires: python3-numpy-devel
@ -113,7 +97,7 @@ Computer Vision algorithms.
Summary: Classifier cascades for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{name} < %{version}-%{release}
Conflicts: %{name} < 4.5.1
Provides: %{name}:%{_datadir}/opencv4/lbpcascades/lbpcascade_silverware.xml
BuildArch: noarch
@ -148,11 +132,18 @@ Requires: %{name}4-cascades-data
%description -n libopencv_face%{soname}
Face detection libraries for OpenCV
%package -n libopencv_gapi%{soname}
Summary: G-API library component for OpenCV
License: BSD-3-Clause
Group: System/Libraries
%description -n libopencv_gapi%{soname}
G-API library component for OpenCV
%package -n libopencv_highgui%{soname}
Summary: Higlevel GUI libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
%description -n libopencv_highgui%{soname}
Higlevel GUI libraries for OpenCV
@ -161,7 +152,6 @@ Higlevel GUI libraries for OpenCV
Summary: Image codec libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
%description -n libopencv_imgcodecs%{soname}
Image codec libraries for OpenCV
@ -170,7 +160,6 @@ Image codec libraries for OpenCV
Summary: Superresolution libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
%description -n libopencv_superres%{soname}
Superresolution libraries for OpenCV
@ -179,17 +168,23 @@ Superresolution libraries for OpenCV
Summary: Face detection libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
Requires: %{name}4-cascades-data
%description -n libopencv_objdetect%{soname}
Object detection libraries for OpenCV
%package -n libopencv_optflow%{soname}
Summary: Optical flow calculation libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
%description -n libopencv_optflow%{soname}
Optical flow calculation libraries for OpenCV
%package -n libopencv_videoio%{soname}
Summary: Video IO libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
%description -n libopencv_videoio%{soname}
Video IO libraries for OpenCV
@ -198,7 +193,6 @@ Video IO libraries for OpenCV
Summary: Video stabilization libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
%description -n libopencv_videostab%{soname}
Video stabilization libraries for OpenCV
@ -207,7 +201,6 @@ Video stabilization libraries for OpenCV
Summary: Image processing libraries for OpenCV
License: BSD-3-Clause
Group: System/Libraries
Conflicts: %{libname}%{soname} < %{version}-%{release}
%description -n libopencv_ximgproc%{soname}
Image processing libraries for OpenCV
@ -219,9 +212,11 @@ Group: Development/Libraries/C and C++
Requires: %{libname}%{soname} = %{version}
Requires: libopencv_aruco%{soname} = %{version}
Requires: libopencv_face%{soname} = %{version}
Requires: libopencv_gapi%{soname} = %{version}
Requires: libopencv_highgui%{soname} = %{version}
Requires: libopencv_imgcodecs%{soname} = %{version}
Requires: libopencv_objdetect%{soname} = %{version}
Requires: libopencv_optflow%{soname} = %{version}
Requires: libopencv_superres%{soname} = %{version}
Requires: libopencv_videoio%{soname} = %{version}
Requires: libopencv_videostab%{soname} = %{version}
@ -241,18 +236,6 @@ This package contains the OpenCV C/C++ library and header files, as well as
documentation. It should be installed if you want to develop programs that will
use the OpenCV library.
%package -n python2-%{name}
Summary: Python 2 bindings for apps which use OpenCV
License: BSD-3-Clause
Group: Development/Libraries/Python
Provides: python-%{name} = %{version}-%{release}
Obsoletes: python-%{name} < %{version}-%{release}
Provides: python-%{name}-qt5 = %{version}
Obsoletes: python-%{name}-qt5 < %{version}
%description -n python2-%{name}
This package contains Python 2 bindings for the OpenCV library.
%package -n python3-%{name}
Summary: Python 3 bindings for apps which use OpenCV
License: BSD-3-Clause
@ -267,11 +250,11 @@ This package contains Python 3 bindings for the OpenCV library.
Summary: Documentation and examples for OpenCV
License: BSD-3-Clause
Group: Documentation/Other
Recommends: python
# Since this package also contains examples that need -devel to be compiled
Suggests: %{name}-devel
Provides: %{name}-qt5-doc = %{version}
Obsoletes: %{name}-qt5-doc < %{version}
BuildArch: noarch
%description doc
This package contains the documentation and examples for the OpenCV library.
@ -282,6 +265,7 @@ This package contains the documentation and examples for the OpenCV library.
# Only copy over modules we need
mv opencv_contrib-%{version}/modules/{aruco,face,tracking,optflow,plot,shape,superres,videostab,ximgproc} modules/
rm -Rf opencv_contrib-%{version}/modules/*
cp opencv_contrib-%{version}/LICENSE LICENSE.contrib
# Remove Windows specific files
@ -307,9 +291,10 @@ rm -f doc/packaging.txt
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DENABLE_OMIT_FRAME_POINTER=OFF \
-DENABLE_OMIT_FRAME_POINTER=ON \
-DWITH_QT=ON \
-DWITH_OPENGL=ON \
-DOpenGL_GL_PREFERENCE:STRING="GLVND" \
-DWITH_UNICAP=ON \
-DWITH_XINE=ON \
-DWITH_IPP=OFF \
@ -342,7 +327,6 @@ rm -f doc/packaging.txt
%endif
-DPYTHON_DEFAULT_EXECUTABLE=%{_bindir}/python3 \
-DOPENCV_SKIP_PYTHON_LOADER=ON \
-DOPENCV_PYTHON2_INSTALL_PATH=%{python2_sitearch} \
-DOPENCV_PYTHON3_INSTALL_PATH=%{python3_sitearch} \
-DOPENCV_DOWNLOAD_TRIES_LIST:STRING="" \
-DWITH_JASPER=OFF \
@ -362,6 +346,7 @@ chmod 644 %{buildroot}%{_docdir}/%{name}-doc/examples/python/*.py
rm %{buildroot}%{_bindir}/setup_vars_opencv4.sh
# Fix duplicated install prefix in pkg-config file
cat %{buildroot}%{_libdir}/pkgconfig/opencv4.pc
sed -i -e 's|//usr||g' %{buildroot}%{_libdir}/pkgconfig/opencv4.pc
%fdupes -s %{buildroot}%{_docdir}/%{name}-doc/examples
@ -384,12 +369,16 @@ grep -E 'model|stepping|flags' /proc/cpuinfo | head -n4
%postun -n libopencv_aruco%{soname} -p /sbin/ldconfig
%post -n libopencv_face%{soname} -p /sbin/ldconfig
%postun -n libopencv_face%{soname} -p /sbin/ldconfig
%post -n libopencv_gapi%{soname} -p /sbin/ldconfig
%postun -n libopencv_gapi%{soname} -p /sbin/ldconfig
%post -n libopencv_highgui%{soname} -p /sbin/ldconfig
%postun -n libopencv_highgui%{soname} -p /sbin/ldconfig
%post -n libopencv_imgcodecs%{soname} -p /sbin/ldconfig
%postun -n libopencv_imgcodecs%{soname} -p /sbin/ldconfig
%post -n libopencv_objdetect%{soname} -p /sbin/ldconfig
%postun -n libopencv_objdetect%{soname} -p /sbin/ldconfig
%post -n libopencv_optflow%{soname} -p /sbin/ldconfig
%postun -n libopencv_optflow%{soname} -p /sbin/ldconfig
%post -n libopencv_superres%{soname} -p /sbin/ldconfig
%postun -n libopencv_superres%{soname} -p /sbin/ldconfig
%post -n libopencv_videoio%{soname} -p /sbin/ldconfig
@ -417,12 +406,8 @@ grep -E 'model|stepping|flags' /proc/cpuinfo | head -n4
%{_libdir}/libopencv_dnn.so.*
%{_libdir}/libopencv_features2d.so.*
%{_libdir}/libopencv_flann.so.*
%if %{with gapi}
%{_libdir}/libopencv_gapi.so.*
%endif
%{_libdir}/libopencv_imgproc.so.*
%{_libdir}/libopencv_ml.so.*
%{_libdir}/libopencv_optflow.so.*
%{_libdir}/libopencv_photo.so.*
%{_libdir}/libopencv_plot.so.*
%{_libdir}/libopencv_shape.so.*
@ -436,6 +421,11 @@ grep -E 'model|stepping|flags' /proc/cpuinfo | head -n4
%files -n libopencv_face%{soname}
%{_libdir}/libopencv_face.so.*
%if %{with gapi}
%files -n libopencv_gapi%{soname}
%{_libdir}/libopencv_gapi.so.*
%endif
%files -n libopencv_highgui%{soname}
%{_libdir}/libopencv_highgui.so.*
@ -445,6 +435,9 @@ grep -E 'model|stepping|flags' /proc/cpuinfo | head -n4
%files -n libopencv_objdetect%{soname}
%{_libdir}/libopencv_objdetect.so.*
%files -n libopencv_optflow%{soname}
%{_libdir}/libopencv_optflow.so.*
%files -n libopencv_superres%{soname}
%{_libdir}/libopencv_superres.so.*
@ -467,12 +460,6 @@ grep -E 'model|stepping|flags' /proc/cpuinfo | head -n4
%{_libdir}/cmake/opencv4/OpenCVModules*.cmake
%{_datadir}/opencv4/valgrind*
%if %{with python2}
%files -n python2-%{name}
%license LICENSE LICENSE.contrib
%{python_sitearch}/cv2.so
%endif
%if %{with python3}
%files -n python3-%{name}
%license LICENSE LICENSE.contrib

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a97c2eaecf7a23c6dbd119a609c6d7fae903e5f9ff5f1fe678933e01c67a6c11
size 60563220

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7
size 59667769

View File

@ -1,69 +0,0 @@
From 271f7df3435c619ceba9261f88dcfbb0714b0b0d Mon Sep 17 00:00:00 2001
From: Alexander Alekhin <alexander.a.alekhin@gmail.com>
Date: Fri, 1 Apr 2022 18:02:14 +0000
Subject: [PATCH] videoio(ffmpeg): avoid memory leaks
---
modules/videoio/src/cap_ffmpeg_impl.hpp | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp
index 91a0f710aa63..b7fa0b745c1e 100644
--- a/modules/videoio/src/cap_ffmpeg_impl.hpp
+++ b/modules/videoio/src/cap_ffmpeg_impl.hpp
@@ -2496,17 +2496,13 @@ double CvVideoWriter_FFMPEG::getProperty(int propId) const
/// close video output stream and free associated memory
void CvVideoWriter_FFMPEG::close()
{
- // nothing to do if already released
- if ( !picture )
- return;
-
/* no more frame to compress. The codec has a latency of a few
frames if using B frames, so we get the last frames by
passing the same picture again */
// TODO -- do we need to account for latency here?
/* write the trailer, if any */
- if(ok && oc)
+ if (picture && ok && oc)
{
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
if (!(oc->oformat->flags & AVFMT_RAWPICTURE))
@@ -2529,7 +2525,7 @@ void CvVideoWriter_FFMPEG::close()
}
// free pictures
- if( context->pix_fmt != input_pix_fmt)
+ if (picture && context && context->pix_fmt != input_pix_fmt)
{
if(picture->data[0])
free(picture->data[0]);
@@ -2540,8 +2536,14 @@ void CvVideoWriter_FFMPEG::close()
if (input_picture)
av_free(input_picture);
+#ifdef CV_FFMPEG_CODECPAR
+ avcodec_free_context(&context);
+#else
/* close codec */
- avcodec_close(context);
+ if (context) // fixed after https://github.com/FFmpeg/FFmpeg/commit/3e1f507f3e8f16b716aa115552d243b48ae809bd
+ avcodec_close(context);
+ context = NULL;
+#endif
av_free(outbuf);
@@ -2935,10 +2937,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
#endif
#ifdef CV_FFMPEG_CODECPAR
- if (context)
- {
- avcodec_free_context(&context);
- }
+ avcodec_free_context(&context);
#endif
context = icv_configure_video_stream_FFMPEG(oc, video_st, codec,
width, height, (int) (bitrate + 0.5),

File diff suppressed because it is too large Load Diff