New Upstream Snapshot - ocaml-ffmpeg

Ready changes

Summary

Merged new upstream version: 1.1.7 (was: 1.1.6).

Diff

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 394fa02..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: CI
-
-on: [push]
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.ref }}
-  cancel-in-progress: true
-
-jobs:
-  build:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [macos-latest, ubuntu-latest]
-    steps:
-    - name: Build and test module
-      uses: savonet/build-and-test-ocaml-module@main
diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml
deleted file mode 100644
index 7469c8f..0000000
--- a/.github/workflows/doc.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-name: Doc build
-
-on:
-  push:
-    branches:
-      - main
-
-jobs:
-  build_doc:
-    runs-on: ubuntu-latest
-    steps:
-    - name: Checkout code
-      uses: actions/checkout@v1
-    - name: Setup OCaml
-      uses: ocaml/setup-ocaml@v2
-      with:
-        ocaml-compiler: 4.14.x
-    - name: Pin locally
-      run: opam pin -y add --no-action .
-    - name: Install locally
-      run: opam install -y --with-doc ffmpeg
-    - name: Build doc
-      run: opam exec dune build @doc
-    - name: Deploy doc
-      uses: JamesIves/github-pages-deploy-action@4.1.4
-      with:
-        branch: gh-pages
-        folder: _build/default/_doc/_html
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 899df85..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-_build/
-*.install
-.*sw*
-.merlin
-*~
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 83f76ee..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "m4"]
-	path = m4
-	url = git://github.com/savonet/m4.git
diff --git a/.ocamlformat b/.ocamlformat
index ff63c58..3663901 100644
--- a/.ocamlformat
+++ b/.ocamlformat
@@ -1,4 +1,4 @@
-version=0.19.0
+version=0.24.1
 profile = conventional
 break-separators = after
 space-around-lists = false
diff --git a/CHANGES b/CHANGES
index 1ffee7e..a78e190 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+1.1.7 (2023-02-08)
+=====
+* Filter `NaN` when converting floats to and from
+  OCaml in `swresample`.
+
 1.1.6 (2022-09-26)
 ======
 * Fix channel layout breakage with recent FFmpeg with new channel layout API.
diff --git a/av/av_stubs.c b/av/av_stubs.c
index 0a5bde4..f4b5e93 100644
--- a/av/av_stubs.c
+++ b/av/av_stubs.c
@@ -1,5 +1,7 @@
 #include <string.h>
 
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/bigarray.h>
 #include <caml/callback.h>
@@ -545,7 +547,7 @@ CAMLprim value caml_av_input_io_finalise(value _avio) {
 
   // format_context is freed as part of close_av.
   av_free(avio->avio_context->buffer);
-  avio_context_free(avio->avio_context);
+  avio_context_free(&avio->avio_context);
 
   if (avio->read_cb)
     caml_remove_generational_global_root(&avio->read_cb);
diff --git a/avcodec/avcodec_stubs.c b/avcodec/avcodec_stubs.c
index f5e9326..feb3056 100644
--- a/avcodec/avcodec_stubs.c
+++ b/avcodec/avcodec_stubs.c
@@ -1,3 +1,5 @@
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/bigarray.h>
 #include <caml/callback.h>
diff --git a/avdevice/avdevice_stubs.c b/avdevice/avdevice_stubs.c
index e17fa58..e91f14e 100644
--- a/avdevice/avdevice_stubs.c
+++ b/avdevice/avdevice_stubs.c
@@ -1,3 +1,5 @@
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/callback.h>
 #include <caml/custom.h>
diff --git a/avfilter/avfilter_stubs.c b/avfilter/avfilter_stubs.c
index eb56d5c..9fffbde 100644
--- a/avfilter/avfilter_stubs.c
+++ b/avfilter/avfilter_stubs.c
@@ -1,5 +1,7 @@
 #include <string.h>
 
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/callback.h>
 #include <caml/custom.h>
diff --git a/avutil/avutil_stubs.c b/avutil/avutil_stubs.c
index 16f1079..84d6d2d 100644
--- a/avutil/avutil_stubs.c
+++ b/avutil/avutil_stubs.c
@@ -2,6 +2,8 @@
 #include <pthread.h>
 #include <string.h>
 
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/bigarray.h>
 #include <caml/callback.h>
@@ -787,7 +789,11 @@ CAMLprim value ocaml_avutil_audio_frame_get_channels(value _frame) {
   CAMLparam1(_frame);
   AVFrame *frame = Frame_val(_frame);
 
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 19, 100)
   CAMLreturn(Val_int(frame->channels));
+#else
+  CAMLreturn(Val_int(frame->ch_layout.nb_channels));
+#endif
 }
 
 CAMLprim value ocaml_avutil_audio_frame_get_channel_layout(value _frame) {
diff --git a/debian/changelog b/debian/changelog
index 6c27a0c..5bb1ab6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ocaml-ffmpeg (1.1.7-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sun, 26 Feb 2023 23:10:41 -0000
+
 ocaml-ffmpeg (1.1.6-2) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --git a/dune-project b/dune-project
index a4a91fd..77d5adc 100644
--- a/dune-project
+++ b/dune-project
@@ -1,7 +1,7 @@
-(lang dune 2.9)
+(lang dune 3.6)
 
 (name ffmpeg)
-(version 1.1.6)
+(version 1.1.7)
 (source (github savonet/ocaml-ffmpeg))
 (license LGPL-2.1-only)
 (authors "The Savonet Team <savonet-users@lists.sourceforge.net>")
diff --git a/ffmpeg-av.opam b/ffmpeg-av.opam
index d2bbb12..814e562 100644
--- a/ffmpeg-av.opam
+++ b/ffmpeg-av.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg libraries -- top-level helpers"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "ffmpeg-avutil" {= version}
   "ffmpeg-avcodec" {= version}
@@ -29,11 +29,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg-avcodec.opam b/ffmpeg-avcodec.opam
index 5f8396a..16598c0 100644
--- a/ffmpeg-avcodec.opam
+++ b/ffmpeg-avcodec.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg avcodec library"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "ffmpeg-avutil" {= version}
   "odoc" {with-doc}
@@ -28,11 +28,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg-avdevice.opam b/ffmpeg-avdevice.opam
index 1506e39..52b3731 100644
--- a/ffmpeg-avdevice.opam
+++ b/ffmpeg-avdevice.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg avdevice library"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "ffmpeg-av" {= version}
   "odoc" {with-doc}
@@ -28,11 +28,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg-avfilter.opam b/ffmpeg-avfilter.opam
index 2f07d6f..44d7a21 100644
--- a/ffmpeg-avfilter.opam
+++ b/ffmpeg-avfilter.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg avfilter library"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "ffmpeg-avutil" {= version}
   "odoc" {with-doc}
@@ -28,11 +28,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg-avutil.opam b/ffmpeg-avutil.opam
index ff02de6..c6f4935 100644
--- a/ffmpeg-avutil.opam
+++ b/ffmpeg-avutil.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg avutil libraries"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "base-threads"
   "odoc" {with-doc}
@@ -28,11 +28,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg-swresample.opam b/ffmpeg-swresample.opam
index 9113981..c0f5dc0 100644
--- a/ffmpeg-swresample.opam
+++ b/ffmpeg-swresample.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg swresample library"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "ffmpeg-avutil" {= version}
   "ffmpeg-avcodec" {= version}
@@ -29,11 +29,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg-swscale.opam b/ffmpeg-swscale.opam
index 47780a2..fe51439 100644
--- a/ffmpeg-swscale.opam
+++ b/ffmpeg-swscale.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg swscale library"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -11,7 +11,7 @@ depends: [
   "conf-pkg-config" {build}
   "conf-ffmpeg" {build}
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "dune-configurator" {build}
   "ffmpeg-avutil" {= version}
   "odoc" {with-doc}
@@ -28,11 +28,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/ffmpeg.opam b/ffmpeg.opam
index e7254d8..0f15263 100644
--- a/ffmpeg.opam
+++ b/ffmpeg.opam
@@ -1,6 +1,6 @@
 # This file is generated by dune, edit dune-project instead
 opam-version: "2.0"
-version: "1.1.6"
+version: "1.1.7"
 synopsis: "Bindings for the ffmpeg libraries"
 maintainer: ["Romain Beauxis <toots@rastageeks.org>"]
 authors: ["The Savonet Team <savonet-users@lists.sourceforge.net>"]
@@ -9,7 +9,7 @@ homepage: "https://github.com/savonet/ocaml-ffmpeg"
 bug-reports: "https://github.com/savonet/ocaml-ffmpeg/issues"
 depends: [
   "ocaml" {>= "4.08.0"}
-  "dune" {>= "2.9"}
+  "dune" {>= "3.6"}
   "ffmpeg-av" {= version}
   "ffmpeg-avutil" {= version}
   "ffmpeg-avcodec" {= version}
@@ -28,11 +28,9 @@ build: [
     name
     "-j"
     jobs
-    "--promote-install-files=false"
     "@install"
     "@runtest" {with-test}
     "@doc" {with-doc}
   ]
-  ["dune" "install" "-p" name "--create-install-files" name]
 ]
 dev-repo: "git+https://github.com/savonet/ocaml-ffmpeg.git"
diff --git a/gen_code/gen_code.ml b/gen_code/gen_code.ml
index b01215d..52d27f1 100644
--- a/gen_code/gen_code.ml
+++ b/gen_code/gen_code.ml
@@ -127,8 +127,10 @@ let translate_enum_lines ?h_oc ?ml_oc lines labels =
         tab_name;
         "[i][0])return ";
         tab_name;
-        "[i][1];\n}\nFail(\"Could not find C value for %ld in " ^ tab_name
-        ^ ". Do you need to recompile the ffmpeg binding?\", v);\nreturn -1;\n}";
+        "[i][1];\n}\nFail(\"Could not find C value for %llu in " ^ tab_name
+        ^ ". Do you need to recompile the ffmpeg binding?\", (uint64_t)v);\n\
+           return -1;\n\
+           }";
       ];
 
     print_c
@@ -157,8 +159,10 @@ let translate_enum_lines ?h_oc ?ml_oc lines labels =
         tab_name;
         "[i][1])return ";
         tab_name;
-        "[i][0];\n}\nFail(\"Could not find OCaml value for %d in " ^ tab_name
-        ^ ". Do you need to recompile the ffmpeg binding?\", t);\nreturn -1;\n}";
+        "[i][0];\n}\nFail(\"Could not find OCaml value for %llu in " ^ tab_name
+        ^ ". Do you need to recompile the ffmpeg binding?\", (uint64_t)t);\n\
+           return -1;\n\
+           }";
       ])
 
 let translate_c_values_opt ?h_oc ?ml_oc ~pre_process in_names enums_labels =
diff --git a/swresample/swresample_stubs.c b/swresample/swresample_stubs.c
index 184c204..ec92d07 100644
--- a/swresample/swresample_stubs.c
+++ b/swresample/swresample_stubs.c
@@ -1,3 +1,5 @@
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/bigarray.h>
 #include <caml/callback.h>
@@ -26,6 +28,12 @@
 #include "swresample_options_stubs.h"
 #include "swresample_stubs.h"
 
+static inline double filter_nan(double s) {
+  if (s != s)
+    return 0;
+  return s;
+}
+
 /***** Contexts *****/
 struct audio_t {
   uint8_t **data;
@@ -73,8 +81,10 @@ static int get_in_samples_frame(swr_t *swr, value *in_vector, int offset) {
   AVFrame *frame = Frame_val(*in_vector);
 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56, 0, 100)
   int nb_channels = av_frame_get_channels(frame);
-#else
+#elif LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 19, 100)
   int nb_channels = frame->channels;
+#else
+  int nb_channels = frame->ch_layout.nb_channels;
 #endif
 
   if (offset != 0)
@@ -156,7 +166,7 @@ static int get_in_samples_float_array(swr_t *swr, value *in_vector,
   double *pcm = (double *)swr->in.data[0];
 
   for (i = 0; i < linesize; i++) {
-    pcm[i] = Double_field(*in_vector, i + offset);
+    pcm[i] = filter_nan(Double_field(*in_vector, i + offset));
   }
 
   return nb_samples;
@@ -186,7 +196,7 @@ static int get_in_samples_planar_float_array(swr_t *swr, value *in_vector,
     double *pcm = (double *)swr->in.data[i];
 
     for (j = 0; j < nb_samples; j++) {
-      pcm[j] = Double_field(fa, j + offset);
+      pcm[j] = filter_nan(Double_field(fa, j + offset));
     }
   }
   CAMLreturnT(int, nb_samples);
@@ -344,7 +354,7 @@ static void convert_to_float_array(swr_t *swr, int in_nb_samples,
   double *pcm = (double *)swr->out.data[0];
 
   for (i = 0; i < len; i++) {
-    Store_double_field(swr->out_vector, i, pcm[i]);
+    Store_double_field(swr->out_vector, i, filter_nan(pcm[i]));
   }
 }
 
@@ -375,7 +385,7 @@ static void convert_to_planar_float_array(swr_t *swr, int in_nb_samples,
     pcm = (double *)swr->out.data[i];
 
     for (j = 0; j < ret; j++)
-      Store_double_field(Field(swr->out_vector, i), j, pcm[j]);
+      Store_double_field(Field(swr->out_vector, i), j, filter_nan(pcm[j]));
   }
 }
 
diff --git a/swscale/swscale_stubs.c b/swscale/swscale_stubs.c
index 3b44525..2b69f1a 100644
--- a/swscale/swscale_stubs.c
+++ b/swscale/swscale_stubs.c
@@ -1,3 +1,5 @@
+#define CAML_NAME_SPACE 1
+
 #include <caml/alloc.h>
 #include <caml/bigarray.h>
 #include <caml/callback.h>

More details

Full run details

Historical runs