Skip to content

Commit

Permalink
Add strndup patch for ffmpeg.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Nov 30, 2024
1 parent f26ee26 commit 4e91bf7
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/av/av_stubs.c b/av/av_stubs.c
index ca9fbdf..90c0888 100644
--- a/av/av_stubs.c
+++ b/av/av_stubs.c
@@ -24,6 +24,7 @@
#include <libavutil/opt.h>
#include <libavutil/parseutils.h>
#include <libavutil/timestamp.h>
+#include <libavutil/mem.h>

#include "av_stubs.h"
#include "avcodec_stubs.h"
@@ -644,7 +645,7 @@ CAMLprim value ocaml_av_find_input_format(value _short_name) {
CAMLparam1(_short_name);
CAMLlocal1(ret);
char *short_name =
- strndup(String_val(_short_name), caml_string_length(_short_name));
+ av_strndup(String_val(_short_name), caml_string_length(_short_name));

if (!short_name)
caml_raise_out_of_memory();
@@ -776,7 +777,7 @@ CAMLprim value ocaml_av_open_input(value _url, value _format, value _interrupt,
}

if (ulen > 0)
- url = strndup(String_val(_url), ulen);
+ url = av_strndup(String_val(_url), ulen);

if (_format != Val_none)
format = InputFormat_val(Some_val(_format));
@@ -1351,13 +1352,13 @@ CAMLprim value ocaml_av_output_format_guess(value _short_name, value _filename,

if (caml_string_length(_short_name) > 0) {
short_name =
- strndup(String_val(_short_name), caml_string_length(_short_name));
+ av_strndup(String_val(_short_name), caml_string_length(_short_name));
if (!short_name)
caml_raise_out_of_memory();
};

if (caml_string_length(_filename) > 0) {
- filename = strndup(String_val(_filename), caml_string_length(_filename));
+ filename = av_strndup(String_val(_filename), caml_string_length(_filename));
if (!filename) {
if (short_name)
free(short_name);
@@ -1366,7 +1367,7 @@ CAMLprim value ocaml_av_output_format_guess(value _short_name, value _filename,
}

if (caml_string_length(_mime) > 0) {
- mime = strndup(String_val(_mime), caml_string_length(_mime));
+ mime = av_strndup(String_val(_mime), caml_string_length(_mime));
if (!mime) {
if (short_name)
free(short_name);
@@ -1553,7 +1554,7 @@ CAMLprim value ocaml_av_open_output(value _interrupt, value _format,
CAMLparam3(_interrupt, _filename, _opts);
CAMLlocal3(ans, ret, unused);
char *filename =
- strndup(String_val(_filename), caml_string_length(_filename));
+ av_strndup(String_val(_filename), caml_string_length(_filename));
avioformat_const AVOutputFormat *format = NULL;
AVDictionary *options = NULL;
char *key, *val;
6 changes: 6 additions & 0 deletions packages/ffmpeg-av-windows/ffmpeg-av-windows.1.2.1/opam
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ conflicts: [
depexts: [
["ffmpeg"] {os-distribution = "mxe"}
]
patches: [
"patches/strndup.patch"
]
extra-files: [
["patches/strndup.patch" "md5=cdc142e1df3c89fc16040806a3c8da38"]
]
build: [
[
"dune"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/avfilter/avfilter_stubs.c b/avfilter/avfilter_stubs.c
index 892bca4..63a48ab 100644
--- a/avfilter/avfilter_stubs.c
+++ b/avfilter/avfilter_stubs.c
@@ -14,6 +14,7 @@
#include <libavfilter/avfilter.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
+#include <libavutil/mem.h>

#define AvFilterContext_val(v) (*(AVFilterContext **)Data_abstract_val(v))

@@ -178,12 +179,12 @@ CAMLprim value ocaml_avfilter_create_filter(value _args, value _instance_name,
caml_raise_not_found();

name =
- strndup(String_val(_instance_name), caml_string_length(_instance_name));
+ av_strndup(String_val(_instance_name), caml_string_length(_instance_name));
if (!name)
caml_raise_out_of_memory();

if (_args != Val_none) {
- args = strndup(String_val(Some_val(_args)),
+ args = av_strndup(String_val(Some_val(_args)),
caml_string_length(Some_val(_args)));

if (!args) {
@@ -309,7 +310,7 @@ CAMLprim value ocaml_avfilter_parse(value _inputs, value _outputs,
append_avfilter_in_out(&outputs, name, filter_ctx, idx);
}

- filters = strndup(String_val(_filters), caml_string_length(_filters));
+ filters = av_strndup(String_val(_filters), caml_string_length(_filters));

if (!filters) {
if (inputs)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ depends: [
conflicts: [
"ffmpeg-windows" {< "0.5.0"}
]
patches: [
"patches/strndup.patch"
]
extra-files: [
["patches/strndup.patch" "md5=ac7db67fe5aa4fa741b92b79d01a3c82"]
]
depexts: [
["ffmpeg"] {os-distribution = "mxe"}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/avutil/avutil_stubs.c b/avutil/avutil_stubs.c
index 78d2f8d..6e99a7d 100644
--- a/avutil/avutil_stubs.c
+++ b/avutil/avutil_stubs.c
@@ -17,6 +17,7 @@
#include <libavutil/avstring.h>
#include <libavutil/pixdesc.h>
#include <libavutil/pixfmt.h>
+#include <libavutil/mem.h>

#include "avutil_stubs.h"
#include "channel_layout_stubs.h"
@@ -512,7 +513,7 @@ enum caml_ba_kind bigarray_kind_of_AVSampleFormat(enum AVSampleFormat sf) {
CAMLprim value ocaml_avutil_find_sample_fmt(value _name) {
CAMLparam1(_name);
CAMLlocal1(ans);
- char *name = strndup(String_val(_name), caml_string_length(_name));
+ char *name = av_strndup(String_val(_name), caml_string_length(_name));
if (!name)
caml_raise_out_of_memory();

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ conflicts: [
depexts: [
["ffmpeg"] {os-distribution = "mxe"}
]
patches: [
"patches/strndup.patch"
]
extra-files: [
["patches/strndup.patch" "md5=08f071e74e62aa8ce837e954570ec598"]
]
build: [
[
"dune"
Expand Down

0 comments on commit 4e91bf7

Please sign in to comment.