### Description

Adds opencv-python and ffmpeg.

### Status

opencv-python is modularized with a bunch of modules, I'll keep updating the status.

- [x] Core library
- [x] JPEG
- [x] PNG
- [x] WEBP
- [x] Image processing
- [x] video processing (FFMPEG)
- [x] objectdetect
- [x] dnn
- [x] ml
- [x] calib3d
- [x] feature2d
- [x] highgui (built, but nonsense)
- [x] photo
- [x] stitching
- [x] flann
- contrib algorithms?
- extra modules?

### Checklists

<!-- Note on checklists:
     If you think some of these steps are not necessary for your PR,
     just remove those checkboxes, or mark them as checked. Otherwise,
     if some checkboxes are left unmarked, we might assume that your PR
     is not ready to be merged and we might keep you waiting -->

- [x] Add a [CHANGELOG](https://github.com/pyodide/pyodide/blob/main/docs/project/changelog.md) entry
- [x] Add / update tests

Resolve #381
Resolve #1627
PKG Add opencv-python and ffmpeg. ### Description

Adds opencv-python and ffmpeg.

### Status

opencv-python is modularized with a bunch of modules, I'll keep updating the status.

- [x] Core library
- [x] JPEG
- [x] PNG
- [x] WEBP
- [x] Image processing
- [x] video processing (FFMPEG)
- [x] objectdetect
- [x] dnn
- [x] ml
- [x] calib3d
- [x] feature2d
- [x] highgui (built, but nonsense)
- [x] photo
- [x] stitching
- [x] flann
- contrib algorithms?
- extra modules?

### Checklists

<!-- Note on checklists:
     If you think some of these steps are not necessary for your PR,
     just remove those checkboxes, or mark them as checked. Otherwise,
     if some checkboxes are left unmarked, we might assume that your PR
     is not ready to be merged and we might keep you waiting -->

- [x] Add a [CHANGELOG](https://github.com/pyodide/pyodide/blob/main/docs/project/changelog.md) entry
- [x] Add / update tests

Resolve #381
Resolve #1627
From 77cdba9a810726e01542ab330ee7ec49f446a50e Mon Sep 17 00:00:00 2001
From: Roman Yurchak <rth.yurchak@gmail.com>
Date: Thu, 31 Mar 2022 17:19:07 -0700
Subject: [PATCH 04/14] Fix ieee754

Use float error status without external includes in numpy

A better solution would be to rely on FE_DIVBYZERO, FE_DIVBYZERO etc
defined in musl's fenv.h (https://github.com/numpy/numpy/pull/12124)
however these are not valid for emscripten
(https://github.com/emscripten-core/emscripten/issues/13678)
---
 numpy/core/src/npymath/ieee754.c.src | 30 ++++++++--------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/numpy/core/src/npymath/ieee754.c.src b/numpy/core/src/npymath/ieee754.c.src
index 4e6ddb712..6aecb7577 100644
--- a/numpy/core/src/npymath/ieee754.c.src
+++ b/numpy/core/src/npymath/ieee754.c.src
@@ -682,7 +682,8 @@ void npy_set_floatstatus_invalid(void)
 }
 
 #elif defined(_MSC_VER) || (defined(__osf__) && defined(__alpha)) || \
-      defined (__UCLIBC__) || (defined(__arc__) && defined(__GLIBC__))
+      defined (__UCLIBC__) || (defined(__arc__) && defined(__GLIBC__)) || \
+      defined(__EMSCRIPTEN__)
 
 /*
  * By using a volatile floating point value,
@@ -719,37 +720,22 @@ void npy_set_floatstatus_invalid(void)
 }
 
 /* MS Windows -----------------------------------------------------*/
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__EMSCRIPTEN__)
 
 #include <float.h>
 
 int npy_get_floatstatus_barrier(char *param)
 {
-    /*
-     * By using a volatile, the compiler cannot reorder this call
-     */
-#if defined(_WIN64)
-    int fpstatus = _statusfp();
-#else
-    /* windows enables sse on 32 bit, so check both flags */
-    int fpstatus, fpstatus2;
-    _statusfp2(&fpstatus, &fpstatus2);
-    fpstatus |= fpstatus2;
-#endif
-    if (param != NULL) {
-        volatile char NPY_UNUSED(c) = *(char*)param;
-    }
-    return ((SW_ZERODIVIDE & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) |
-           ((SW_OVERFLOW & fpstatus) ? NPY_FPE_OVERFLOW : 0) |
-           ((SW_UNDERFLOW & fpstatus) ? NPY_FPE_UNDERFLOW : 0) |
-           ((SW_INVALID & fpstatus) ? NPY_FPE_INVALID : 0);
+   /* 
+   TODO: This is a suboptimal implementation from numpy 1.15.4 that would lead
+   to issues like https://github.com/numpy/numpy/issues/12095 
+   */
+   return 0;
 }
 
 int npy_clear_floatstatus_barrier(char *param)
 {
     int fpstatus = npy_get_floatstatus_barrier(param);
-    _clearfp();
-
     return fpstatus;
 }
 
-- 
2.25.1


From 77cdba9a810726e01542ab330ee7ec49f446a50e Mon Sep 17 00:00:00 2001
From: Roman Yurchak <rth.yurchak@gmail.com>
Date: Thu, 31 Mar 2022 17:19:07 -0700
Subject: [PATCH 04/14] Fix ieee754

Use float error status without external includes in numpy

A better solution would be to rely on FE_DIVBYZERO, FE_DIVBYZERO etc
defined in musl's fenv.h (https://github.com/numpy/numpy/pull/12124)
however these are not valid for emscripten
(https://github.com/emscripten-core/emscripten/issues/13678)
---
 numpy/core/src/npymath/ieee754.c.src | 30 ++++++++--------------------
 1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/numpy/core/src/npymath/ieee754.c.src b/numpy/core/src/npymath/ieee754.c.src
index 4e6ddb712..6aecb7577 100644
--- a/numpy/core/src/npymath/ieee754.c.src
+++ b/numpy/core/src/npymath/ieee754.c.src
@@ -682,7 +682,8 @@ void npy_set_floatstatus_invalid(void)
 }
 
 #elif defined(_MSC_VER) || (defined(__osf__) && defined(__alpha)) || \
-      defined (__UCLIBC__) || (defined(__arc__) && defined(__GLIBC__))
+      defined (__UCLIBC__) || (defined(__arc__) && defined(__GLIBC__)) || \
+      defined(__EMSCRIPTEN__)
 
 /*
  * By using a volatile floating point value,
@@ -719,37 +720,22 @@ void npy_set_floatstatus_invalid(void)
 }
 
 /* MS Windows -----------------------------------------------------*/
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__EMSCRIPTEN__)
 
 #include <float.h>
 
 int npy_get_floatstatus_barrier(char *param)
 {
-    /*
-     * By using a volatile, the compiler cannot reorder this call
-     */
-#if defined(_WIN64)
-    int fpstatus = _statusfp();
-#else
-    /* windows enables sse on 32 bit, so check both flags */
-    int fpstatus, fpstatus2;
-    _statusfp2(&fpstatus, &fpstatus2);
-    fpstatus |= fpstatus2;
-#endif
-    if (param != NULL) {
-        volatile char NPY_UNUSED(c) = *(char*)param;
-    }
-    return ((SW_ZERODIVIDE & fpstatus) ? NPY_FPE_DIVIDEBYZERO : 0) |
-           ((SW_OVERFLOW & fpstatus) ? NPY_FPE_OVERFLOW : 0) |
-           ((SW_UNDERFLOW & fpstatus) ? NPY_FPE_UNDERFLOW : 0) |
-           ((SW_INVALID & fpstatus) ? NPY_FPE_INVALID : 0);
+   /* 
+   TODO: This is a suboptimal implementation from numpy 1.15.4 that would lead
+   to issues like https://github.com/numpy/numpy/issues/12095 
+   */
+   return 0;
 }
 
 int npy_clear_floatstatus_barrier(char *param)
 {
     int fpstatus = npy_get_floatstatus_barrier(param);
-    _clearfp();
-
     return fpstatus;
 }
 
-- 
2.25.1

