[FFmpeg-devel] [PATCH] avcodec/vlc: multi vlc fix

2023-09-17 Thread Paul B Mahol
Attached.
From 1bd41c73a9113fd99c4f920dd9493fab258c6a84 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Sun, 17 Sep 2023 10:29:34 +0200
Subject: [PATCH] avcodec/vlc: add correct upper limit for recursive function

Signed-off-by: Paul B Mahol 
---
 libavcodec/vlc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
index b353d2e86c..3b66c94354 100644
--- a/libavcodec/vlc.c
+++ b/libavcodec/vlc.c
@@ -419,7 +419,7 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
 }
 
 add_level(table, nb_elems, nb_codes, numbits, buf,
-  0, 0, numbits, 0, minbits, max, count, &info);
+  0, 0, FFMIN(maxbits, numbits), 0, minbits, max, count, &info);
 
 av_log(NULL, AV_LOG_DEBUG, "Joint: %d/%d/%d/%d/%d codes min=%ubits max=%u\n",
count[0], count[1], count[2], count[3], count[4], minbits, max);
-- 
2.42.0

___
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] [FFmpeg-cvslog] avcodec/utvideodec: add vlc multi support

2023-09-17 Thread Paul B Mahol
On Sat, Sep 16, 2023 at 6:40 PM Michael Niedermayer 
wrote:

> On Fri, Sep 15, 2023 at 01:24:39AM +0200, Paul B Mahol wrote:
> > On Fri, Sep 15, 2023 at 12:19 AM Michael Niedermayer <
> mich...@niedermayer.cc>
> > wrote:
> >
> > > On Wed, Sep 06, 2023 at 10:19:29PM +, Christophe Gisquet wrote:
> > > > ffmpeg | branch: master | Christophe Gisquet <
> > > christophe.gisq...@gmail.com> | Sun Jul  9 12:56:35 2017 +|
> > > [da888b790af779a7489068c25f9e7ab8ac653d41] | committer: Paul B Mahol
> > > >
> > > > avcodec/utvideodec: add vlc multi support
> > > >
> > > > Faster decoding, by average 50% faster overall.
> > > >
> > > > >
> > >
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da888b790af779a7489068c25f9e7ab8ac653d41
> > > > ---
> > > >
> > > >  libavcodec/utvideo.h|  1 +
> > > >  libavcodec/utvideodec.c | 92
> > > -
> > > >  2 files changed, 46 insertions(+), 47 deletions(-)
> > > >
> > > > diff --git a/libavcodec/utvideo.h b/libavcodec/utvideo.h
> > > > index 9da9329ff3..e5160aa394 100644
> > > > --- a/libavcodec/utvideo.h
> > > > +++ b/libavcodec/utvideo.h
> > > > @@ -81,6 +81,7 @@ typedef struct UtvideoContext {
> > > >  ptrdiff_t slice_stride;
> > > >  uint8_t *slice_bits, *slice_buffer[4];
> > > >  int  slice_bits_size;
> > > > +void*buffer;
> > > >
> > > >  const uint8_t *packed_stream[4][256];
> > > >  size_t packed_stream_size[4][256];
> > > > diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
> > > > index 1f00c58950..ab390be0fa 100644
> > > > --- a/libavcodec/utvideodec.c
> > > > +++ b/libavcodec/utvideodec.c
> > > > @@ -46,7 +46,7 @@ typedef struct HuffEntry {
> > > >  } HuffEntry;
> > > >
> > > >  static int build_huff(UtvideoContext *c, const uint8_t *src, VLC
> *vlc,
> > > > -  int *fsym, unsigned nb_elems)
> > > > +  VLC_MULTI *multi, int *fsym, unsigned
> nb_elems)
> > > >  {
> > >
> > > before this patch the whole application finishes within 130ms
> > > after this patch with teh short table
> > >
> > >
> > >
> 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,24,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,24,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
> > >
> >
> > This is of no use to me.
> > If you have file then provide it.
>
> I dont have one but I made one for you
> its attached
>

See vlc patch on ML.


>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> While the State exists there can be no freedom; when there is freedom there
> will be no State. -- Vladimir Lenin
> ___
> 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 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/2] avdevice/android_camera: fix missing include for usleep

2023-09-17 Thread Andreas Rheinhardt
Zhao Zhili:
> From: Zhao Zhili 
> 
> Signed-off-by: Zhao Zhili 
> ---
>  libavdevice/android_camera.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavdevice/android_camera.c b/libavdevice/android_camera.c
> index 1934999c18..0425b27518 100644
> --- a/libavdevice/android_camera.c
> +++ b/libavdevice/android_camera.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 

Sorry for having broken this in
ee485b4051c24e2cebe46b426294b346f0f5fff4. When creating this patch, I
just looked at what os_support.h directly provided (namely redefinitions
of lseek and fstat etc.) and checked what files used any of this. I
don't not check for indirect includes that are not redefined by
os_support.h. (And honestly, if something relies on indirect includes,
then that's the bug.)

- Andreas

___
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 2/2] avcodec/jni: make global variables static

2023-09-17 Thread Matthieu Bouron
On Sun, Sep 17, 2023 at 5:38 AM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> Signed-off-by: Zhao Zhili 
> ---
>  libavcodec/jni.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/jni.c b/libavcodec/jni.c
> index 85dcf2abaf..ae6490de9d 100644
> --- a/libavcodec/jni.c
> +++ b/libavcodec/jni.c
> @@ -34,8 +34,8 @@
>  #include "libavutil/log.h"
>  #include "ffjni.h"
>
> -void *java_vm;
> -pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
> +static void *java_vm;
> +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
>
>  int av_jni_set_java_vm(void *vm, void *log_ctx)
>  {
> --
> 2.34.1
>
>
LGTM.

Thanks,
Matthieu
___
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] avcodec/vlc: multi vlc fix

2023-09-17 Thread Michael Niedermayer
On Sun, Sep 17, 2023 at 10:39:21AM +0200, Paul B Mahol wrote:
> Attached.

>  vlc.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> d870bba425f718274648fad97b10f71d1698b543  
> 0001-avcodec-vlc-add-correct-upper-limit-for-recursive-fu.patch
> From 1bd41c73a9113fd99c4f920dd9493fab258c6a84 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Sun, 17 Sep 2023 10:29:34 +0200
> Subject: [PATCH] avcodec/vlc: add correct upper limit for recursive function
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/vlc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks!

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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] configure: rework parsing --cpu arguments to support all features unless blacklisted

2023-09-17 Thread James Almer
Keeping an ever growing list of CPUs just to pass -march to the compiler and
enable fast_cmov is a waste of time. Every CPU we know has limitations is
already handled here, so just fallback to enabling everything when a passed in
argument is not covered by those.

This will enable optimizations for CPU architectures released in the past 7 or
so years with supported GCC and clang compilers when using them as argument in
configure, instead of silently ignoring them.

Signed-off-by: James Almer 
---
 configure | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index bd7f7697c8..27602c8e14 100755
--- a/configure
+++ b/configure
@@ -5445,20 +5445,18 @@ elif enabled x86; then
 cpuflags="-march=$cpu"
 disable i686
 ;;
-# targets that do support nopl and conditional mov (cmov)
-
i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx\
-
|core*|atom|bonnell|nehalem|westmere|silvermont|sandybridge|ivybridge|haswell|broadwell|skylake*|knl\
-|amdfam10|barcelona|b[dt]ver*|znver*)
-cpuflags="-march=$cpu"
-enable i686
-enable fast_cmov
-;;
 # targets that do support conditional mov but on which it's slow
 pentium4|pentium4m|prescott|nocona)
 cpuflags="-march=$cpu"
 enable i686
 disable fast_cmov
 ;;
+# everything else should support nopl and conditional mov (cmov)
+*)
+cpuflags="-march=$cpu"
+enable i686
+enable fast_cmov
+;;
 esac
 
 fi
-- 
2.42.0

___
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/2] avcodec/pthread_frame: Remove FF_API_SLICE_OFFSET

2023-09-17 Thread Andreas Rheinhardt
Since 432adca5fedcb277b9a715a723cfd40735ec58f8 no decoder
looks at the slice_count and slice_offset fields at all,
so there is no reason to synchronize them between the worker
and the user thread.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/pthread_frame.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index b53fb54906..59989831a3 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -424,22 +424,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 FF_DISABLE_DEPRECATION_WARNINGS
 dst->reordered_opaque = src->reordered_opaque;
 FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
-#if FF_API_SLICE_OFFSET
-FF_DISABLE_DEPRECATION_WARNINGS
-if (src->slice_count && src->slice_offset) {
-if (dst->slice_count < src->slice_count) {
-int err = av_reallocp_array(&dst->slice_offset, src->slice_count,
-sizeof(*dst->slice_offset));
-if (err < 0)
-return err;
-}
-memcpy(dst->slice_offset, src->slice_offset,
-   src->slice_count * sizeof(*dst->slice_offset));
-}
-dst->slice_count = src->slice_count;
-FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
 av_packet_unref(dst->internal->last_pkt_props);
@@ -756,12 +740,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 av_freep(&ctx->priv_data);
 }
 
-#if FF_API_SLICE_OFFSET
-FF_DISABLE_DEPRECATION_WARNINGS
-av_freep(&ctx->slice_offset);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 av_buffer_unref(&ctx->internal->pool);
 av_packet_free(&ctx->internal->last_pkt_props);
 av_freep(&ctx->internal);
-- 
2.34.1

___
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 2/2] avcodec/pthread_frame: Constify src pointees

2023-09-17 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/pthread_frame.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 59989831a3..138576778d 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -265,7 +265,7 @@ static attribute_align_arg void *frame_worker_thread(void 
*arg)
  * @param for_user 0 if the destination is a codec thread, 1 if the 
destination is the user's thread
  * @return 0 on success, negative error code on failure
  */
-static int update_context_from_thread(AVCodecContext *dst, AVCodecContext 
*src, int for_user)
+static int update_context_from_thread(AVCodecContext *dst, const 
AVCodecContext *src, int for_user)
 {
 const FFCodec *const codec = ffcodec(dst->codec);
 int err = 0;
@@ -394,7 +394,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
  * @param src The source context.
  * @return 0 on success, negative error code on failure
  */
-static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
+static int update_context_from_user(AVCodecContext *dst, const AVCodecContext 
*src)
 {
 int err;
 
-- 
2.34.1

___
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/2] avcodec/pthread_frame: Remove FF_API_SLICE_OFFSET

2023-09-17 Thread Paul B Mahol
LGTM
___
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 2/2] avcodec/pthread_frame: Constify src pointees

2023-09-17 Thread Paul B Mahol
LGTM
___
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] lavd/sdl2: postpone sdl2 window creation

2023-09-17 Thread Xiang, Haihao
From: Haihao Xiang 

Since 2d924b3, sdl2_write_header() and sdl2_write_packet() are called
in two different threads. However SDL2 requires window creation and
rendering should be done in the same thread, otherwise it shows nothing
when specifying SDL2 output device.

$ ffmpeg -f lavfi -i yuvtestsrc -pix_fmt yuv420p -f sdl2 "sdl2"

Signed-off-by: Haihao Xiang 
---
 libavdevice/sdl2.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/libavdevice/sdl2.c b/libavdevice/sdl2.c
index 342a253dc0..c9f7f03c28 100644
--- a/libavdevice/sdl2.c
+++ b/libavdevice/sdl2.c
@@ -158,6 +158,11 @@ static int sdl2_write_trailer(AVFormatContext *s)
 }
 
 static int sdl2_write_header(AVFormatContext *s)
+{
+return 0;
+}
+
+static int sdl2_init(AVFormatContext *s)
 {
 SDLContext *sdl = s->priv_data;
 AVStream *st = s->streams[0];
@@ -165,6 +170,9 @@ static int sdl2_write_header(AVFormatContext *s)
 int i, ret = 0;
 int flags  = 0;
 
+if (sdl->inited)
+return 0;
+
 if (!sdl->window_title)
 sdl->window_title = av_strdup(s->url);
 
@@ -249,6 +257,11 @@ static int sdl2_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int linesize[4];
 
 SDL_Event event;
+
+ret = sdl2_init(s);
+if (ret)
+return ret;
+
 if (SDL_PollEvent(&event)){
 switch (event.type) {
 case SDL_KEYDOWN:
-- 
2.34.1

___
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".