Re: [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Matthieu Bouron
On Wed, Feb 14, 2024 at 11:31:21PM +, Mark Thompson wrote:
> On 13/02/2024 22:50, Matthieu Bouron wrote:
> > This will allow to use the jni utils in libavformat. This will be mostly 
> > useful
> > to add Android content-uri support.
> > 
> > This deprecates avcodec/jni.h functions in favor of the ones from 
> > avutil/jni.h.
> > ---
> >   doc/APIchanges |   6 +
> >   libavcodec/Makefile|   3 +-
> >   libavcodec/jni.c   |  48 +
> >   libavcodec/jni.h   |   8 +
> >   libavcodec/mediacodec.c|   6 +-
> >   libavcodec/mediacodec_surface.c|   6 +-
> >   libavcodec/mediacodec_wrapper.c| 200 ++---
> >   libavcodec/mediacodecdec.c |   3 +-
> >   libavutil/Makefile |   4 +
> >   libavutil/jni.c|  78 
> >   libavutil/jni.h|  46 +
> >   libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
> >   libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
> >   13 files changed, 283 insertions(+), 187 deletions(-)
> >   create mode 100644 libavutil/jni.c
> >   create mode 100644 libavutil/jni.h
> >   rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
> >   rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)
> 
> Why?
> 
> libavformat already depends on libavcodec.

Since both libavformat  and libavcodec will use it, it seems more
logical to put the code in libavutil. It could also benefits
libavutil/hwcontext_mediacodec.

[...]
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Mark Thompson

On 13/02/2024 22:50, Matthieu Bouron wrote:

This will allow to use the jni utils in libavformat. This will be mostly useful
to add Android content-uri support.

This deprecates avcodec/jni.h functions in favor of the ones from avutil/jni.h.
---
  doc/APIchanges |   6 +
  libavcodec/Makefile|   3 +-
  libavcodec/jni.c   |  48 +
  libavcodec/jni.h   |   8 +
  libavcodec/mediacodec.c|   6 +-
  libavcodec/mediacodec_surface.c|   6 +-
  libavcodec/mediacodec_wrapper.c| 200 ++---
  libavcodec/mediacodecdec.c |   3 +-
  libavutil/Makefile |   4 +
  libavutil/jni.c|  78 
  libavutil/jni.h|  46 +
  libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
  libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
  13 files changed, 283 insertions(+), 187 deletions(-)
  create mode 100644 libavutil/jni.c
  create mode 100644 libavutil/jni.h
  rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
  rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)


Why?

libavformat already depends on libavcodec.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Matthieu Bouron
On Wed, Feb 14, 2024 at 07:18:04PM +0100, Michael Niedermayer wrote:
> On Tue, Feb 13, 2024 at 11:50:09PM +0100, Matthieu Bouron wrote:
> > This will allow to use the jni utils in libavformat. This will be mostly 
> > useful
> > to add Android content-uri support.
> > 
> > This deprecates avcodec/jni.h functions in favor of the ones from 
> > avutil/jni.h.
> > ---
> >  doc/APIchanges |   6 +
> >  libavcodec/Makefile|   3 +-
> >  libavcodec/jni.c   |  48 +
> >  libavcodec/jni.h   |   8 +
> >  libavcodec/mediacodec.c|   6 +-
> >  libavcodec/mediacodec_surface.c|   6 +-
> >  libavcodec/mediacodec_wrapper.c| 200 ++---
> >  libavcodec/mediacodecdec.c |   3 +-
> >  libavutil/Makefile |   4 +
> >  libavutil/jni.c|  78 
> >  libavutil/jni.h|  46 +
> >  libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
> >  libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
> >  13 files changed, 283 insertions(+), 187 deletions(-)
> >  create mode 100644 libavutil/jni.c
> >  create mode 100644 libavutil/jni.h
> >  rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
> >  rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)
> 
> this breaks build
> 
>  make
> CClibavutil/jni.o
> libavutil/jni.c:68:5: error: no previous prototype for ‘av_jni_set_java_vm’ 
> [-Werror=missing-prototypes]
>  int av_jni_set_java_vm(void *vm, void *log_ctx)
>  ^~
> libavutil/jni.c:73:7: error: no previous prototype for ‘av_jni_get_java_vm’ 
> [-Werror=missing-prototypes]
>  void *av_jni_get_java_vm(void *log_ctx)
>^~
> cc1: some warnings being treated as errors
> ffbuild/common.mak:81: recipe for target 'libavutil/jni.o' failed
> make: *** [libavutil/jni.o] Error 1

Thanks, new patch attached.

[...]
>From 5b6a127143d8a3d111f7bef1a3e3bc9aab60a8ea Mon Sep 17 00:00:00 2001
From: Matthieu Bouron 
Date: Mon, 12 Feb 2024 18:33:41 +0100
Subject: [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

This will allow to use the jni utils in libavformat. This will be mostly useful
to add Android content-uri support.

This deprecates avcodec/jni.h functions in favor of the ones from avutil/jni.h.
---
 doc/APIchanges |   6 +
 libavcodec/Makefile|   3 +-
 libavcodec/jni.c   |  49 +
 libavcodec/jni.h   |   8 +
 libavcodec/mediacodec.c|   6 +-
 libavcodec/mediacodec_surface.c|   6 +-
 libavcodec/mediacodec_wrapper.c| 200 ++---
 libavcodec/mediacodecdec.c |   3 +-
 libavutil/Makefile |   4 +
 libavutil/jni.c|  78 
 libavutil/jni.h|  46 +
 libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
 libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
 13 files changed, 284 insertions(+), 187 deletions(-)
 create mode 100644 libavutil/jni.c
 create mode 100644 libavutil/jni.h
 rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
 rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)

diff --git a/doc/APIchanges b/doc/APIchanges
index 221fea30c2..45611ea7ea 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,12 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2024-02-xx - xx - lavu 58.39.100 - jni.h
+  Add av_jni_set_jvm() and av_jni_get_jvm().
+
+2024-02-xx - xx - lavc 60.40.100 - jni.h
+  Deprecate av_jni_set_java_vm() and av_jni_get_java_vm().
+
 2024-02-xx - xx - lavu 58.38.100 - channel_layout.h
   Add av_channel_layout_retype().
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 470d7cb9b1..f8584d8dfd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -117,7 +117,7 @@ OBJS-$(CONFIG_IIRFILTER)   += iirfilter.o
 OBJS-$(CONFIG_INFLATE_WRAPPER) += zlib_wrapper.o
 OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o msmpeg4data.o
 OBJS-$(CONFIG_IVIDSP)  += ivi_dsp.o
-OBJS-$(CONFIG_JNI) += ffjni.o jni.o
+OBJS-$(CONFIG_JNI) += jni.o
 OBJS-$(CONFIG_JPEGTABLES)  += jpegtables.o
 OBJS-$(CONFIG_LCMS2)   += fflcms2.o
 OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o
@@ -1269,7 +1269,6 @@ SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
 SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_D3D12VA)  += d3d12va_decode.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
-SKIPHEADERS-$(CONFIG_JNI)  += ffjni.h
 SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h
 

Re: [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Michael Niedermayer
On Tue, Feb 13, 2024 at 11:50:09PM +0100, Matthieu Bouron wrote:
> This will allow to use the jni utils in libavformat. This will be mostly 
> useful
> to add Android content-uri support.
> 
> This deprecates avcodec/jni.h functions in favor of the ones from 
> avutil/jni.h.
> ---
>  doc/APIchanges |   6 +
>  libavcodec/Makefile|   3 +-
>  libavcodec/jni.c   |  48 +
>  libavcodec/jni.h   |   8 +
>  libavcodec/mediacodec.c|   6 +-
>  libavcodec/mediacodec_surface.c|   6 +-
>  libavcodec/mediacodec_wrapper.c| 200 ++---
>  libavcodec/mediacodecdec.c |   3 +-
>  libavutil/Makefile |   4 +
>  libavutil/jni.c|  78 
>  libavutil/jni.h|  46 +
>  libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
>  libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
>  13 files changed, 283 insertions(+), 187 deletions(-)
>  create mode 100644 libavutil/jni.c
>  create mode 100644 libavutil/jni.h
>  rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
>  rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)

this breaks build

 make
CC  libavutil/jni.o
libavutil/jni.c:68:5: error: no previous prototype for ‘av_jni_set_java_vm’ 
[-Werror=missing-prototypes]
 int av_jni_set_java_vm(void *vm, void *log_ctx)
 ^~
libavutil/jni.c:73:7: error: no previous prototype for ‘av_jni_get_java_vm’ 
[-Werror=missing-prototypes]
 void *av_jni_get_java_vm(void *log_ctx)
   ^~
cc1: some warnings being treated as errors
ffbuild/common.mak:81: recipe for target 'libavutil/jni.o' failed
make: *** [libavutil/jni.o] Error 1


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-13 Thread Matthieu Bouron
This will allow to use the jni utils in libavformat. This will be mostly useful
to add Android content-uri support.

This deprecates avcodec/jni.h functions in favor of the ones from avutil/jni.h.
---
 doc/APIchanges |   6 +
 libavcodec/Makefile|   3 +-
 libavcodec/jni.c   |  48 +
 libavcodec/jni.h   |   8 +
 libavcodec/mediacodec.c|   6 +-
 libavcodec/mediacodec_surface.c|   6 +-
 libavcodec/mediacodec_wrapper.c| 200 ++---
 libavcodec/mediacodecdec.c |   3 +-
 libavutil/Makefile |   4 +
 libavutil/jni.c|  78 
 libavutil/jni.h|  46 +
 libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
 libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
 13 files changed, 283 insertions(+), 187 deletions(-)
 create mode 100644 libavutil/jni.c
 create mode 100644 libavutil/jni.h
 rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
 rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)

diff --git a/doc/APIchanges b/doc/APIchanges
index 221fea30c2..45611ea7ea 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,12 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2024-02-xx - xx - lavu 58.39.100 - jni.h
+  Add av_jni_set_jvm() and av_jni_get_jvm().
+
+2024-02-xx - xx - lavc 60.40.100 - jni.h
+  Deprecate av_jni_set_java_vm() and av_jni_get_java_vm().
+
 2024-02-xx - xx - lavu 58.38.100 - channel_layout.h
   Add av_channel_layout_retype().
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 470d7cb9b1..f8584d8dfd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -117,7 +117,7 @@ OBJS-$(CONFIG_IIRFILTER)   += iirfilter.o
 OBJS-$(CONFIG_INFLATE_WRAPPER) += zlib_wrapper.o
 OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o msmpeg4data.o
 OBJS-$(CONFIG_IVIDSP)  += ivi_dsp.o
-OBJS-$(CONFIG_JNI) += ffjni.o jni.o
+OBJS-$(CONFIG_JNI) += jni.o
 OBJS-$(CONFIG_JPEGTABLES)  += jpegtables.o
 OBJS-$(CONFIG_LCMS2)   += fflcms2.o
 OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o
@@ -1269,7 +1269,6 @@ SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
 SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_D3D12VA)  += d3d12va_decode.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
-SKIPHEADERS-$(CONFIG_JNI)  += ffjni.h
 SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h
 SKIPHEADERS-$(CONFIG_LIBAOM)   += libaom.h
 SKIPHEADERS-$(CONFIG_LIBJXL)   += libjxl.h
diff --git a/libavcodec/jni.c b/libavcodec/jni.c
index ae6490de9d..a98c27d73a 100644
--- a/libavcodec/jni.c
+++ b/libavcodec/jni.c
@@ -20,60 +20,18 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
-
 #include 
 
 #include "libavutil/error.h"
+#include "libavutil/jni.h"
 #include "jni.h"
 
-#if CONFIG_JNI
-#include 
-#include 
-
-#include "libavutil/log.h"
-#include "ffjni.h"
-
-static void *java_vm;
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-
-int av_jni_set_java_vm(void *vm, void *log_ctx)
-{
-int ret = 0;
-
-pthread_mutex_lock();
-if (java_vm == NULL) {
-java_vm = vm;
-} else if (java_vm != vm) {
-ret = AVERROR(EINVAL);
-av_log(log_ctx, AV_LOG_ERROR, "A Java virtual machine has already been 
set");
-}
-pthread_mutex_unlock();
-
-return ret;
-}
-
-void *av_jni_get_java_vm(void *log_ctx)
-{
-void *vm;
-
-pthread_mutex_lock();
-vm = java_vm;
-pthread_mutex_unlock();
-
-return vm;
-}
-
-#else
-
 int av_jni_set_java_vm(void *vm, void *log_ctx)
 {
-return AVERROR(ENOSYS);
+return av_jni_set_jvm(vm, log_ctx);
 }
 
 void *av_jni_get_java_vm(void *log_ctx)
 {
-return NULL;
+return av_jni_get_jvm(log_ctx);
 }
-
-#endif
diff --git a/libavcodec/jni.h b/libavcodec/jni.h
index dd99e92611..49ddab4120 100644
--- a/libavcodec/jni.h
+++ b/libavcodec/jni.h
@@ -23,6 +23,8 @@
 #ifndef AVCODEC_JNI_H
 #define AVCODEC_JNI_H
 
+#include 
+
 /*
  * Manually set a Java virtual machine which will be used to retrieve the JNI
  * environment. Once a Java VM is set it cannot be changed afterwards, meaning
@@ -32,7 +34,10 @@
  * @param vm Java virtual machine
  * @param log_ctx context used for logging, can be NULL
  * @return 0 on success, < 0 otherwise
+ *
+ * @deprecated use av_jni_set_jvm from libavutil/jni.h
  */
+attribute_deprecated
 int av_jni_set_java_vm(void *vm, void *log_ctx);
 
 /*
@@ -40,7 +45,10 @@ int av_jni_set_java_vm(void *vm, void *log_ctx);
  *
  * @param vm Java virtual machine
  * @return a pointer to the Java virtual machine
+