Re: [FFmpeg-devel] [PATCH v17 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi() and getenv_utf8()

2022-06-19 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Sunday, June 19, 2022 8:28 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v17 1/5] libavutil: Add
> wchartoutf8(), wchartoansi(), utf8toansi() and getenv_utf8()
> 
> Soft Works:
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Andreas Rheinhardt
> >> Sent: Sunday, June 19, 2022 6:59 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH v17 1/5] libavutil: Add
> >> wchartoutf8(), wchartoansi(), utf8toansi() and getenv_utf8()
> >>
> >> Nil Admirari:
> >>> wchartoutf8() converts strings returned by WinAPI into UTF-8,
> >>> which is FFmpeg's preffered encoding.
> >>>
> >>> Some external dependencies, such as AviSynth, are still
> >>> not Unicode-enabled. utf8toansi() converts UTF-8 strings
> >>> into ANSI in two steps: UTF-8 -> wchar_t -> ANSI.
> >>> wchartoansi() is responsible for the second step of the
> conversion.
> >>> Conversion in just one step is not supported by WinAPI.
> >>>
> >>> Since these character converting functions allocate the buffer
> >>> of necessary size, they also facilitate the removal of MAX_PATH
> >> limit
> >>> in places where fixed-size ANSI/WCHAR strings were used
> >>> as filename buffers.
> >>>
> >>> getenv_utf8() wraps _wgetenv() converting its input from
> >>> and its output to UTF-8. Compared to plain getenv(),
> >>> getenv_utf8() requires a cleanup.
> >>>
> >>> Because of that, in places that only test the existence of
> >>> an environment variable or compare its value with a string
> >>> consisting entirely of ASCII characters, the use of plain
> getenv()
> >>> is still preferred. (libavutil/log.c check_color_terminal()
> >>> is an example of such a place.)
> >>>
> >>> Plain getenv() is also preffered in UNIX-only code,
> >>> such as bktr.c, fbdev_common.c, oss.c in libavdevice
> >>> or af_ladspa.c in libavfilter.
> >>> ---
> >>>  configure  |  1 +
> >>>  libavutil/getenv_utf8.h| 71
> >> ++
> >>>  libavutil/wchar_filename.h | 51 +++
> >>>  3 files changed, 123 insertions(+)
> >>>  create mode 100644 libavutil/getenv_utf8.h
> >>>
> >>> diff --git a/configure b/configure
> >>> index 3dca1c4bd3..fa37a74531 100755
> >>> --- a/configure
> >>> +++ b/configure
> >>> @@ -2272,6 +2272,7 @@ SYSTEM_FUNCS="
> >>>  fcntl
> >>>  getaddrinfo
> >>>  getauxval
> >>> +getenv
> >>>  gethrtime
> >>>  getopt
> >>>  GetModuleHandle
> >>> diff --git a/libavutil/getenv_utf8.h b/libavutil/getenv_utf8.h
> >>> new file mode 100644
> >>> index 00..161e3e6202
> >>> --- /dev/null
> >>> +++ b/libavutil/getenv_utf8.h
> >>> @@ -0,0 +1,71 @@
> >>> +/*
> >>> + * This file is part of FFmpeg.
> >>> + *
> >>> + * FFmpeg is free software; you can redistribute it and/or
> >>> + * modify it under the terms of the GNU Lesser General Public
> >>> + * License as published by the Free Software Foundation; either
> >>> + * version 2.1 of the License, or (at your option) any later
> >> version.
> >>> + *
> >>> + * FFmpeg is distributed in the hope that it will be useful,
> >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty
> of
> >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >> GNU
> >>> + * Lesser General Public License for more details.
> >>> + *
> >>> + * You should have received a copy of the GNU Lesser General
> >> Public
> >>> + * License along with FFmpeg; if not, write to the Free Software
> >>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> >> 02110-1301 USA
> >>> + */
> >>> +
> >>> +#ifndef AVUTIL_GETENV_UTF8_H
> >>> +#define AVUTIL_GETENV_UTF8_H
> >>> +
> >>> +#include 
> >>> +
> >>> +#include "mem.h"
> >>> +
> >>> +#ifdef HAVE_GETENV
> >>> +
> >>> +#ifdef _WIN32
> >>> +
> >>> +#include "libavutil/wchar_filename.h"
> >>> +
> >>> +static inline char *getenv_utf8(const char *varname)
> >>> +{
> >>> +wchar_t *varname_w, *var_w;
> >>> +char *var;
> >>> +
> >>> +if (utf8towchar(varname, &varname_w))
> >>> +return NULL;
> >>> +if (!varname_w)
> >>> +return NULL;
> >>> +
> >>> +var_w = _wgetenv(varname_w);
> >>> +av_free(varname_w);
> >>> +
> >>> +if (!var_w)
> >>> +return NULL;
> >>> +if (wchartoutf8(var_w, &var))
> >>> +return NULL;
> >>> +
> >>> +return var;
> >>> +
> >>> +// No CP_ACP fallback compared to other *_utf8() functions:
> >>> +// non UTF-8 strings must not be returned.
> >>> +}
> >>> +
> >>> +#else
> >>> +
> >>> +static inline char *getenv_utf8(const char *varname)
> >>> +{
> >>> +return av_strdup(getenv(varname));
> >>
> >> This forces allocations and frees in scenarios where this is
> wholly
> >> unnecessary.
> >
> > Why do you think this is unnecessary? At least on Windows, there is
> > no guarantee regarding the lifetime of strings returned from
> > getenv(). In case when

Re: [FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

2022-06-19 Thread Martin Storsjö

On Sat, 18 Jun 2022, Soft Works wrote:





-Original Message-
From: ffmpeg-devel  On Behalf Of
Martin Storsjö
Sent: Sunday, June 19, 2022 12:24 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove
MAX_PATH limit and use UTF-8 version of getenv()

On Fri, 17 Jun 2022, Nil Admirari wrote:


1. getenv() is replaced with getenv_utf8() across libavformat.
2. New versions of AviSynth+ are now called with UTF-8 filenames.
3. Old versions of AviSynth are still using ANSI strings,
  but MAX_PATH limit on filename is removed.
---
libavformat/avisynth.c| 39 +++-

---

libavformat/http.c| 20 +---
libavformat/ipfsgateway.c | 35 +++
libavformat/tls.c | 11 +--
4 files changed, 72 insertions(+), 33 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index c8f3f4b6a3..d90117e422 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -29,6 +29,7 @@
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
+#include "libavutil/getenv_utf8.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/parseutils.h"


This actually causes some surprise breakage in MSVC builds. Here,
getenv_utf8.h includes windows.h. If including windows.h and winsock2
headers in the same file, the winsock2 headers must be included
before.

I fixed it locally by moving this new include down, with a comment
like
this:

/* This header can include . That header has to be
included after
  * winsock2 headers (included by network.h and os_support.h above).
*/


This is the recommended way:


#define WIN32_LEAN_AND_MEAN

#include 
#include 


Thanks, adding #define WIN32_LEAN_AND_MEAN in wchar_filename.h fixes the 
issue.


// Martin
___
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 v17 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

2022-06-19 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Martin Storsjö
> Sent: Sunday, June 19, 2022 9:49 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove
> MAX_PATH limit and use UTF-8 version of getenv()
> 
> On Sat, 18 Jun 2022, Soft Works wrote:
> 
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Martin Storsjö
> >> Sent: Sunday, June 19, 2022 12:24 AM
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove
> >> MAX_PATH limit and use UTF-8 version of getenv()
> >>
> >> On Fri, 17 Jun 2022, Nil Admirari wrote:
> >>
> >>> 1. getenv() is replaced with getenv_utf8() across libavformat.
> >>> 2. New versions of AviSynth+ are now called with UTF-8 filenames.
> >>> 3. Old versions of AviSynth are still using ANSI strings,
> >>>   but MAX_PATH limit on filename is removed.
> >>> ---
> >>> libavformat/avisynth.c| 39 +++---
> --
> >> ---
> >>> libavformat/http.c| 20 +---
> >>> libavformat/ipfsgateway.c | 35 +++---
> -
> >>> libavformat/tls.c | 11 +--
> >>> 4 files changed, 72 insertions(+), 33 deletions(-)
> >>>
> >>> diff --git a/libavformat/http.c b/libavformat/http.c
> >>> index c8f3f4b6a3..d90117e422 100644
> >>> --- a/libavformat/http.c
> >>> +++ b/libavformat/http.c
> >>> @@ -29,6 +29,7 @@
> >>> #include "libavutil/avassert.h"
> >>> #include "libavutil/avstring.h"
> >>> #include "libavutil/bprint.h"
> >>> +#include "libavutil/getenv_utf8.h"
> >>> #include "libavutil/opt.h"
> >>> #include "libavutil/time.h"
> >>> #include "libavutil/parseutils.h"
> >>
> >> This actually causes some surprise breakage in MSVC builds. Here,
> >> getenv_utf8.h includes windows.h. If including windows.h and
> winsock2
> >> headers in the same file, the winsock2 headers must be included
> >> before.
> >>
> >> I fixed it locally by moving this new include down, with a comment
> >> like
> >> this:
> >>
> >> /* This header can include . That header has to be
> >> included after
> >>   * winsock2 headers (included by network.h and os_support.h
> above).
> >> */
> >
> > This is the recommended way:
> >
> >
> > #define WIN32_LEAN_AND_MEAN
> >
> > #include 
> > #include 
> 
> Thanks, adding #define WIN32_LEAN_AND_MEAN in wchar_filename.h fixes
> the
> issue.

Besides that, it also sounds good  :-)
sw

___
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 v2] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Gyan Doshi
Default avctx->frame_size is 0 which led to init failure for
audio MediaFoundation encoders since 827d6fe73d.

The MF audio encoders accept variable frame size input buffers.

Fixes #9802
---
 libavcodec/mfenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 13ed7b3e11..8618e54ea3 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1239,7 +1239,7 @@ static int mf_init(AVCodecContext *avctx)
 FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet), 
\
 EXTRA  
\
 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
-  AV_CODEC_CAP_DR1,
\
+  AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, 
\
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |   
\
   FF_CODEC_CAP_INIT_CLEANUP,   
\
 };
-- 
2.36.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 v2] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Andreas Rheinhardt
Gyan Doshi:
> Default avctx->frame_size is 0 which led to init failure for
> audio MediaFoundation encoders since 827d6fe73d.
> 
> The MF audio encoders accept variable frame size input buffers.
> 
> Fixes #9802
> ---
>  libavcodec/mfenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
> index 13ed7b3e11..8618e54ea3 100644
> --- a/libavcodec/mfenc.c
> +++ b/libavcodec/mfenc.c
> @@ -1239,7 +1239,7 @@ static int mf_init(AVCodecContext *avctx)
>  FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet),   
>   \
>  EXTRA
>   \
>  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | 
>   \
> -  AV_CODEC_CAP_DR1,  
>   \
> +  AV_CODEC_CAP_DR1 | 
> AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \
>  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | 
>   \
>FF_CODEC_CAP_INIT_CLEANUP, 
>   \
>  };

This will add this capability to both audio and video encoders, although
it makes no sense for the latter.

- 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 v2] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Gyan Doshi:
>> Default avctx->frame_size is 0 which led to init failure for
>> audio MediaFoundation encoders since 827d6fe73d.
>>
>> The MF audio encoders accept variable frame size input buffers.
>>
>> Fixes #9802
>> ---
>>  libavcodec/mfenc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
>> index 13ed7b3e11..8618e54ea3 100644
>> --- a/libavcodec/mfenc.c
>> +++ b/libavcodec/mfenc.c
>> @@ -1239,7 +1239,7 @@ static int mf_init(AVCodecContext *avctx)
>>  FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet),  
>>\
>>  EXTRA   
>>\
>>  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |
>>\
>> -  AV_CODEC_CAP_DR1, 
>>\
>> +  AV_CODEC_CAP_DR1 | 
>> AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \
>>  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
>>\
>>FF_CODEC_CAP_INIT_CLEANUP,
>>\
>>  };
> 
> This will add this capability to both audio and video encoders, although
> it makes no sense for the latter.
> 

This should actually been covered by the libavcodec-avcodec FATE test.
How did you test your patch?

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


[FFmpeg-devel] [PATCH v3] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Gyan Doshi
Default avctx->frame_size is 0 which led to init failure for
audio MediaFoundation encoders since 827d6fe73d.

The MF audio encoders accept variable frame size input buffers.

Fixes #9802
---
 libavcodec/mfenc.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 13ed7b3e11..bbe78605a9 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1220,7 +1220,7 @@ static int mf_init(AVCodecContext *avctx)
 
 #define OFFSET(x) offsetof(MFContext, x)
 
-#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, EXTRA) \
+#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS) \
 static const AVClass ff_ ## NAME ## _mf_encoder_class = {  
\
 .class_name = #NAME "_mf", 
\
 .item_name  = av_default_item_name,
\
@@ -1237,9 +1237,8 @@ static int mf_init(AVCodecContext *avctx)
 .init   = mf_init, 
\
 .close  = mf_close,
\
 FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet), 
\
-EXTRA  
\
-.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
-  AV_CODEC_CAP_DR1,
\
+FMTS   
\
+CAPS   
\
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |   
\
   FF_CODEC_CAP_INIT_CLEANUP,   
\
 };
@@ -1247,10 +1246,13 @@ static int mf_init(AVCodecContext *avctx)
 #define AFMTS \
 .p.sample_fmts  = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
\
  AV_SAMPLE_FMT_NONE },
+#define ACAPS \
+.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
+  AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
 
-MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS);
-MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS);
-MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS);
+MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS);
+MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS);
+MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS);
 
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption venc_opts[] = {
@@ -1283,6 +1285,9 @@ static const AVOption venc_opts[] = {
 .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,   
\
 AV_PIX_FMT_YUV420P,
\
 AV_PIX_FMT_NONE },
+#define VCAPS \
+.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
+  AV_CODEC_CAP_DR1,
 
-MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS);
-MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS);
+MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS, VCAPS);
+MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS, VCAPS);
-- 
2.36.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 v2] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Gyan Doshi




On 2022-06-19 02:54 pm, Andreas Rheinhardt wrote:

Andreas Rheinhardt:

Gyan Doshi:

Default avctx->frame_size is 0 which led to init failure for
audio MediaFoundation encoders since 827d6fe73d.

The MF audio encoders accept variable frame size input buffers.

Fixes #9802
---
  libavcodec/mfenc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 13ed7b3e11..8618e54ea3 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1239,7 +1239,7 @@ static int mf_init(AVCodecContext *avctx)
  FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet),
 \
  EXTRA 
 \
  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |  
 \
-  AV_CODEC_CAP_DR1,
\
+  AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, 
\
  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |  
 \
FF_CODEC_CAP_INIT_CLEANUP,  
 \
  };

This will add this capability to both audio and video encoders, although
it makes no sense for the latter.


This should actually been covered by the libavcodec-avcodec FATE test.
How did you test your patch?


Manually. I didn't expect HW / ext lib encoders to be covered by FATE, 
and indeed I don't find anything for MF.


Regards,
Gyan
___
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 v2] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Gyan Doshi



On 2022-06-19 03:36 pm, Gyan Doshi wrote:



On 2022-06-19 02:54 pm, Andreas Rheinhardt wrote:

Andreas Rheinhardt:

Gyan Doshi:

Default avctx->frame_size is 0 which led to init failure for
audio MediaFoundation encoders since 827d6fe73d.

The MF audio encoders accept variable frame size input buffers.

Fixes #9802
---
  libavcodec/mfenc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 13ed7b3e11..8618e54ea3 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1239,7 +1239,7 @@ static int mf_init(AVCodecContext *avctx)
FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet), \
EXTRA \
  .p.capabilities = AV_CODEC_CAP_DELAY | 
AV_CODEC_CAP_HYBRID |   \

- AV_CODEC_CAP_DR1,    \
+  AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \
  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE 
|   \

FF_CODEC_CAP_INIT_CLEANUP,   \
  };
This will add this capability to both audio and video encoders, 
although

it makes no sense for the latter.


This should actually been covered by the libavcodec-avcodec FATE test.
How did you test your patch?


Manually. I didn't expect HW / ext lib encoders to be covered by FATE, 
and indeed I don't find anything for MF.


And Patchwork FATE does not show any fails for v2.
I do see lavc/avcodec testprog, but I rarely do avcodec so didn't 
remember that.


Regards,
Gyan
___
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 v2] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Andreas Rheinhardt
Gyan Doshi:
> 
> 
> On 2022-06-19 03:36 pm, Gyan Doshi wrote:
>>
>>
>> On 2022-06-19 02:54 pm, Andreas Rheinhardt wrote:
>>> Andreas Rheinhardt:
 Gyan Doshi:
> Default avctx->frame_size is 0 which led to init failure for
> audio MediaFoundation encoders since 827d6fe73d.
>
> The MF audio encoders accept variable frame size input buffers.
>
> Fixes #9802
> ---
>   libavcodec/mfenc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
> index 13ed7b3e11..8618e54ea3 100644
> --- a/libavcodec/mfenc.c
> +++ b/libavcodec/mfenc.c
> @@ -1239,7 +1239,7 @@ static int mf_init(AVCodecContext *avctx)
> FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet), \
> EXTRA \
>   .p.capabilities = AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_HYBRID |   \
> - AV_CODEC_CAP_DR1,    \
> +  AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \
>   .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE
> |   \
> FF_CODEC_CAP_INIT_CLEANUP,   \
>   };
 This will add this capability to both audio and video encoders,
 although
 it makes no sense for the latter.

>>> This should actually been covered by the libavcodec-avcodec FATE test.
>>> How did you test your patch?
>>
>> Manually. I didn't expect HW / ext lib encoders to be covered by FATE,
>> and indeed I don't find anything for MF.
> 
> And Patchwork FATE does not show any fails for v2.
> I do see lavc/avcodec testprog, but I rarely do avcodec so didn't
> remember that.
> 

Patchwork doesn't have a Windows box, i.e. mediafoundation is not
covered by them.

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


[FFmpeg-devel] [PATCH v18 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8() and freeenv_utf8()

2022-06-19 Thread Nil Admirari
wchartoutf8() converts strings returned by WinAPI into UTF-8,
which is FFmpeg's preffered encoding.

Some external dependencies, such as AviSynth, are still
not Unicode-enabled. utf8toansi() converts UTF-8 strings
into ANSI in two steps: UTF-8 -> wchar_t -> ANSI.
wchartoansi() is responsible for the second step of the conversion.
Conversion in just one step is not supported by WinAPI.

Since these character converting functions allocate the buffer
of necessary size, they also facilitate the removal of MAX_PATH limit
in places where fixed-size ANSI/WCHAR strings were used
as filename buffers.

getenv_utf8() wraps _wgetenv() converting its input from
and its output to UTF-8. Compared to plain getenv(),
getenv_utf8() requires a cleanup.

Because of that, in places that only test the existence of
an environment variable or compare its value with a string
consisting entirely of ASCII characters, the use of plain getenv()
is still preferred. (libavutil/log.c check_color_terminal()
is an example of such a place.)

Plain getenv() is also preffered in UNIX-only code,
such as bktr.c, fbdev_common.c, oss.c in libavdevice
or af_ladspa.c in libavfilter.
---
 configure  |  1 +
 libavutil/getenv_utf8.h| 83 ++
 libavutil/wchar_filename.h | 53 
 3 files changed, 137 insertions(+)
 create mode 100644 libavutil/getenv_utf8.h

diff --git a/configure b/configure
index 7ffbb85e21..3a97610209 100755
--- a/configure
+++ b/configure
@@ -2272,6 +2272,7 @@ SYSTEM_FUNCS="
 fcntl
 getaddrinfo
 getauxval
+getenv
 gethrtime
 getopt
 GetModuleHandle
diff --git a/libavutil/getenv_utf8.h b/libavutil/getenv_utf8.h
new file mode 100644
index 00..799fef9839
--- /dev/null
+++ b/libavutil/getenv_utf8.h
@@ -0,0 +1,83 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_GETENV_UTF8_H
+#define AVUTIL_GETENV_UTF8_H
+
+#include 
+
+#include "config.h"
+#include "mem.h"
+
+#if HAVE_GETENV
+
+#ifdef _WIN32
+
+#include "libavutil/wchar_filename.h"
+
+static inline char *getenv_utf8(const char *varname)
+{
+wchar_t *varname_w, *var_w;
+char *var;
+
+if (utf8towchar(varname, &varname_w))
+return NULL;
+if (!varname_w)
+return NULL;
+
+var_w = _wgetenv(varname_w);
+av_free(varname_w);
+
+if (!var_w)
+return NULL;
+if (wchartoutf8(var_w, &var))
+return NULL;
+
+return var;
+
+// No CP_ACP fallback compared to other *_utf8() functions:
+// non UTF-8 strings must not be returned.
+}
+
+static inline void freeenv_utf8(const char *var)
+{
+av_free(var);
+}
+
+#else
+
+static inline char *getenv_utf8(const char *varname)
+{
+return getenv(varname);
+}
+
+static inline void freeenv_utf8(const char *)
+{
+}
+
+#endif // _WIN32
+
+#else
+
+#define getenv_utf8(x) NULL
+
+#define freeenv_utf8(x) ((void) 0)
+
+#endif // HAVE_GETENV
+
+#endif // AVUTIL_GETENV_UTF8_H
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index f36d9dfea3..08de073ed7 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -20,6 +20,8 @@
 #define AVUTIL_WCHAR_FILENAME_H
 
 #ifdef _WIN32
+
+#define WIN32_LEAN_AND_MEAN
 #include 
 #include "mem.h"
 
@@ -41,6 +43,57 @@ static inline int utf8towchar(const char *filename_utf8, 
wchar_t **filename_w)
 return 0;
 }
 
+av_warn_unused_result
+static inline int wchartocp(unsigned int code_page, const wchar_t *filename_w,
+char **filename)
+{
+DWORD flags = code_page == CP_UTF8 ? WC_ERR_INVALID_CHARS : 0;
+int num_chars = WideCharToMultiByte(code_page, flags, filename_w, -1,
+NULL, 0, NULL, NULL);
+if (num_chars <= 0) {
+*filename = NULL;
+return 0;
+}
+*filename = av_malloc_array(num_chars, sizeof *filename);
+if (!*filename) {
+errno = ENOMEM;
+return -1;
+}
+WideCharToMultiByte(code_page, flags, filename_w, -1,
+*filename, num_chars, NULL, NULL);
+return 0;
+}
+
+av_warn_unused_result
+static inline int wchartoutf8(const wchar_t *filename_w, char **filename)
+{
+return wchartocp(CP_UTF8, filename_w, filename);
+}
+
+a

[FFmpeg-devel] [PATCH v18 3/5] fftools: Remove MAX_PATH limit and switch to UTF-8 versions of fopen() and getenv()

2022-06-19 Thread Nil Admirari
---
 fftools/cmdutils.c   | 53 +---
 fftools/ffmpeg_opt.c |  9 ++--
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 5d7cdc3e10..69a6f54ea3 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -39,6 +39,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/display.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/libm.h"
@@ -47,9 +48,11 @@
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
 #include "cmdutils.h"
+#include "fopen_utf8.h"
 #include "opt_common.h"
 #ifdef _WIN32
 #include 
+#include "compat/w32dlfcn.h"
 #endif
 
 AVDictionary *sws_dict;
@@ -465,7 +468,7 @@ static void check_options(const OptionDef *po)
 void parse_loglevel(int argc, char **argv, const OptionDef *options)
 {
 int idx = locate_option(argc, argv, options, "loglevel");
-const char *env;
+char *env;
 
 check_options(options);
 
@@ -474,7 +477,8 @@ void parse_loglevel(int argc, char **argv, const OptionDef 
*options)
 if (idx && argv[idx + 1])
 opt_loglevel(NULL, "loglevel", argv[idx + 1]);
 idx = locate_option(argc, argv, options, "report");
-if ((env = getenv("FFREPORT")) || idx) {
+env = getenv_utf8("FFREPORT");
+if (env || idx) {
 FILE *report_file = NULL;
 init_report(env, &report_file);
 if (report_file) {
@@ -487,6 +491,7 @@ void parse_loglevel(int argc, char **argv, const OptionDef 
*options)
 fflush(report_file);
 }
 }
+freeenv_utf8(env);
 idx = locate_option(argc, argv, options, "hide_banner");
 if (idx)
 hide_banner = 1;
@@ -812,28 +817,45 @@ FILE *get_preset_file(char *filename, size_t 
filename_size,
 {
 FILE *f = NULL;
 int i;
-const char *base[3] = { getenv("FFMPEG_DATADIR"),
-getenv("HOME"),
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+char *datadir = NULL;
+#endif
+char *env_home = getenv_utf8("HOME");
+char *env_ffmpeg_datadir = getenv_utf8("FFMPEG_DATADIR");
+const char *base[3] = { env_home,
+env_ffmpeg_datadir,
 FFMPEG_DATADIR, };
 
 if (is_path) {
 av_strlcpy(filename, preset_name, filename_size);
-f = fopen(filename, "r");
+f = fopen_utf8(filename, "r");
 } else {
 #if HAVE_GETMODULEHANDLE && defined(_WIN32)
-char datadir[MAX_PATH], *ls;
+wchar_t *datadir_w = get_module_filename(NULL);
 base[2] = NULL;
 
-if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, 
sizeof(datadir) - 1))
+if (wchartoutf8(datadir_w, &datadir))
+datadir = NULL;
+av_free(datadir_w);
+
+if (datadir)
 {
-for (ls = datadir; ls < datadir + strlen(datadir); ls++)
+char *ls;
+for (ls = datadir; *ls; ls++)
 if (*ls == '\\') *ls = '/';
 
 if (ls = strrchr(datadir, '/'))
 {
-*ls = 0;
-strncat(datadir, "/ffpresets",  sizeof(datadir) - 1 - 
strlen(datadir));
-base[2] = datadir;
+ptrdiff_t datadir_len = ls - datadir;
+size_t desired_size = datadir_len + strlen("/ffpresets") + 1;
+char *new_datadir = av_realloc_array(
+datadir, desired_size, sizeof *datadir);
+if (new_datadir) {
+datadir = new_datadir;
+datadir[datadir_len] = 0;
+strncat(datadir, "/ffpresets",  desired_size - 1 - 
datadir_len);
+base[2] = datadir;
+}
 }
 }
 #endif
@@ -842,17 +864,22 @@ FILE *get_preset_file(char *filename, size_t 
filename_size,
 continue;
 snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
  i != 1 ? "" : "/.ffmpeg", preset_name);
-f = fopen(filename, "r");
+f = fopen_utf8(filename, "r");
 if (!f && codec_name) {
 snprintf(filename, filename_size,
  "%s%s/%s-%s.ffpreset",
  base[i], i != 1 ? "" : "/.ffmpeg", codec_name,
  preset_name);
-f = fopen(filename, "r");
+f = fopen_utf8(filename, "r");
 }
 }
 }
 
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+av_free(datadir);
+#endif
+freeenv_utf8(env_ffmpeg_datadir);
+freeenv_utf8(env_home);
 return f;
 }
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 398067da96..e08455478f 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -44,6 +44,7 @@
 #include "libavutil/avutil.h"
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
+#include "libavut

[FFmpeg-devel] [PATCH v18 2/5] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW

2022-06-19 Thread Nil Admirari
---
 compat/w32dlfcn.h | 100 --
 libavcodec/mf_utils.h |   1 +
 2 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h
index 52a94efafb..fb1aa1b72e 100644
--- a/compat/w32dlfcn.h
+++ b/compat/w32dlfcn.h
@@ -20,11 +20,40 @@
 #define COMPAT_W32DLFCN_H
 
 #ifdef _WIN32
+#include 
+
 #include 
+
 #include "config.h"
-#if (_WIN32_WINNT < 0x0602) || HAVE_WINRT
+#include "libavutil/macros.h"
 #include "libavutil/wchar_filename.h"
-#endif
+
+static inline wchar_t *get_module_filename(HMODULE module)
+{
+wchar_t *path = NULL, *new_path;
+DWORD path_size = 0, path_len;
+
+do {
+path_size = path_size ? FFMIN(2 * path_size, INT16_MAX + 1) : MAX_PATH;
+new_path = av_realloc_array(path, path_size, sizeof *path);
+if (!new_path) {
+av_free(path);
+return NULL;
+}
+path = new_path;
+// Returns path_size in case of insufficient buffer.
+// Whether the error is set or not and whether the output
+// is null-terminated or not depends on the version of Windows.
+path_len = GetModuleFileNameW(module, path, path_size);
+} while (path_len && path_size <= INT16_MAX && path_size <= path_len);
+
+if (!path_len) {
+av_free(path);
+return NULL;
+}
+return path;
+}
+
 /**
  * Safe function used to open dynamic libs. This attempts to improve program 
security
  * by removing the current directory from the dll search path. Only dll's 
found in the
@@ -34,29 +63,53 @@
  */
 static inline HMODULE win32_dlopen(const char *name)
 {
+wchar_t *name_w;
+HMODULE module = NULL;
+if (utf8towchar(name, &name_w))
+name_w = NULL;
 #if _WIN32_WINNT < 0x0602
-// Need to check if KB2533623 is available
+// On Win7 and earlier we check if KB2533623 is available
 if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), 
"SetDefaultDllDirectories")) {
-HMODULE module = NULL;
-wchar_t *path = NULL, *name_w = NULL;
-DWORD pathlen;
-if (utf8towchar(name, &name_w))
+wchar_t *path = NULL, *new_path;
+DWORD pathlen, pathsize, namelen;
+if (!name_w)
 goto exit;
-path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t));
+namelen = wcslen(name_w);
 // Try local directory first
-pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
-pathlen = wcsrchr(path, '\\') - path;
-if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+path = get_module_filename(NULL);
+if (!path)
+goto exit;
+new_path = wcsrchr(path, '\\');
+if (!new_path)
 goto exit;
-path[pathlen] = '\\';
+pathlen = new_path - path;
+pathsize = pathlen + namelen + 2;
+new_path = av_realloc_array(path, pathsize, sizeof *path);
+if (!new_path)
+goto exit;
+path = new_path;
 wcscpy(path + pathlen + 1, name_w);
 module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
 if (module == NULL) {
 // Next try System32 directory
-pathlen = GetSystemDirectoryW(path, MAX_PATH);
-if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+pathlen = GetSystemDirectoryW(path, pathsize);
+if (!pathlen)
 goto exit;
-path[pathlen] = '\\';
+// Buffer is not enough in two cases:
+// 1. system directory + \ + module name
+// 2. system directory even without the module name.
+if (pathlen + namelen + 2 > pathsize) {
+pathsize = pathlen + namelen + 2;
+new_path = av_realloc_array(path, pathsize, sizeof *path);
+if (!new_path)
+goto exit;
+path = new_path;
+// Query again to handle the case #2.
+pathlen = GetSystemDirectoryW(path, pathsize);
+if (!pathlen)
+goto exit;
+}
+path[pathlen] = L'\\';
 wcscpy(path + pathlen + 1, name_w);
 module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
 }
@@ -73,16 +126,19 @@ exit:
 #   define LOAD_LIBRARY_SEARCH_SYSTEM320x0800
 #endif
 #if HAVE_WINRT
-wchar_t *name_w = NULL;
-int ret;
-if (utf8towchar(name, &name_w))
+if (!name_w)
 return NULL;
-ret = LoadPackagedLibrary(name_w, 0);
-av_free(name_w);
-return ret;
+module = LoadPackagedLibrary(name_w, 0);
 #else
-return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 
LOAD_LIBRARY_SEARCH_SYSTEM32);
+#define LOAD_FLAGS (LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 
LOAD_LIBRARY_SEARCH_SYSTEM32)
+/* filename may be be in CP_ACP */
+if (!name_w)
+return LoadLibraryExA(name, NULL, LOAD_FLAGS);
+

[FFmpeg-devel] [PATCH v18 5/5] libavfilter/vf_frei0r.c: Use UTF-8 version of getenv()

2022-06-19 Thread Nil Admirari
---
 libavfilter/vf_frei0r.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index f11ae6e55c..9a7a11604a 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -31,6 +31,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/common.h"
 #include "libavutil/eval.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
@@ -204,7 +205,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 }
 
 /* see: http://frei0r.dyne.org/codedoc/html/group__pluglocations.html */
-if ((path = av_strdup(getenv("FREI0R_PATH" {
+if ((path = getenv_utf8("FREI0R_PATH"))) {
 #ifdef _WIN32
 const char *separator = ";";
 #else
@@ -227,16 +228,21 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 }
 
 check_path_end:
-av_free(path);
+freeenv_utf8(path);
 if (ret < 0)
 return ret;
 }
-if (!s->dl_handle && (path = getenv("HOME"))) {
+if (!s->dl_handle && (path = getenv_utf8("HOME"))) {
 char *prefix = av_asprintf("%s/.frei0r-1/lib/", path);
-if (!prefix)
-return AVERROR(ENOMEM);
+if (!prefix) {
+ret = AVERROR(ENOMEM);
+goto home_path_end;
+}
 ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
 av_free(prefix);
+
+home_path_end:
+freeenv_utf8(path);
 if (ret < 0)
 return ret;
 }
-- 
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 v18 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

2022-06-19 Thread Nil Admirari
1. getenv() is replaced with getenv_utf8() across libavformat.
2. New versions of AviSynth+ are now called with UTF-8 filenames.
3. Old versions of AviSynth are still using ANSI strings,
   but MAX_PATH limit on filename is removed.
---
 libavformat/avisynth.c| 39 +++
 libavformat/http.c| 22 ++
 libavformat/ipfsgateway.c | 35 +++
 libavformat/tls.c | 11 +--
 4 files changed, 73 insertions(+), 34 deletions(-)

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 8ba2bdead2..a97d12b6b6 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -34,6 +34,7 @@
 /* Platform-specific directives. */
 #ifdef _WIN32
   #include "compat/w32dlfcn.h"
+  #include "libavutil/wchar_filename.h"
   #undef EXTERN_C
   #define AVISYNTH_LIB "avisynth"
 #else
@@ -56,6 +57,7 @@ typedef struct AviSynthLibrary {
 #define AVSC_DECLARE_FUNC(name) name ## _func name
 AVSC_DECLARE_FUNC(avs_bit_blt);
 AVSC_DECLARE_FUNC(avs_clip_get_error);
+AVSC_DECLARE_FUNC(avs_check_version);
 AVSC_DECLARE_FUNC(avs_create_script_environment);
 AVSC_DECLARE_FUNC(avs_delete_script_environment);
 AVSC_DECLARE_FUNC(avs_get_audio);
@@ -137,6 +139,7 @@ static av_cold int avisynth_load_library(void)
 
 LOAD_AVS_FUNC(avs_bit_blt, 0);
 LOAD_AVS_FUNC(avs_clip_get_error, 0);
+LOAD_AVS_FUNC(avs_check_version, 0);
 LOAD_AVS_FUNC(avs_create_script_environment, 0);
 LOAD_AVS_FUNC(avs_delete_script_environment, 0);
 LOAD_AVS_FUNC(avs_get_audio, 0);
@@ -807,26 +810,38 @@ static int avisynth_create_stream(AVFormatContext *s)
 static int avisynth_open_file(AVFormatContext *s)
 {
 AviSynthContext *avs = s->priv_data;
-AVS_Value arg, val;
+AVS_Value val;
 int ret;
-#ifdef _WIN32
-char filename_ansi[MAX_PATH * 4];
-wchar_t filename_wc[MAX_PATH * 4];
-#endif
 
 if (ret = avisynth_context_create(s))
 return ret;
 
+if (!avs_library.avs_check_version(avs->env, 7)) {
+AVS_Value args[] = {
+avs_new_value_string(s->url),
+avs_new_value_bool(1) // filename is in UTF-8
+};
+val = avs_library.avs_invoke(avs->env, "Import",
+ avs_new_value_array(args, 2), 0);
+} else {
+AVS_Value arg;
 #ifdef _WIN32
-/* Convert UTF-8 to ANSI code page */
-MultiByteToWideChar(CP_UTF8, 0, s->url, -1, filename_wc, MAX_PATH * 4);
-WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
-MAX_PATH * 4, NULL, NULL);
-arg = avs_new_value_string(filename_ansi);
+char *filename_ansi;
+/* Convert UTF-8 to ANSI code page */
+if (utf8toansi(s->url, &filename_ansi)) {
+ret = AVERROR_UNKNOWN;
+goto fail;
+}
+arg = avs_new_value_string(filename_ansi);
 #else
-arg = avs_new_value_string(s->url);
+arg = avs_new_value_string(s->url);
 #endif
-val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
+val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
+#ifdef _WIN32
+av_free(filename_ansi);
+#endif
+}
+
 if (avs_is_error(val)) {
 av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
 ret = AVERROR_UNKNOWN;
diff --git a/libavformat/http.c b/libavformat/http.c
index c8f3f4b6a3..f80ea7bf35 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -29,6 +29,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
 #include "libavutil/parseutils.h"
@@ -198,12 +199,13 @@ void ff_http_init_auth_state(URLContext *dest, const 
URLContext *src)
 static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
 {
 const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
+char *env_http_proxy, *env_no_proxy;
 char *hashmark;
 char hostname[1024], hoststr[1024], proto[10];
 char auth[1024], proxyauth[1024] = "";
 char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE + 1];
 char buf[1024], urlbuf[MAX_URL_SIZE];
-int port, use_proxy, err;
+int port, use_proxy, err = 0;
 HTTPContext *s = h->priv_data;
 
 av_url_split(proto, sizeof(proto), auth, sizeof(auth),
@@ -211,9 +213,13 @@ static int http_open_cnx_internal(URLContext *h, 
AVDictionary **options)
  path1, sizeof(path1), s->location);
 ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
 
-proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy");
-use_proxy  = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) &&
+env_http_proxy = getenv_utf8("http_proxy");
+proxy_path = s->http_proxy ? s->http_proxy : env_http_proxy;
+
+env_no_proxy = getenv_utf8("no_proxy");
+use_proxy  = !ff_http_match_no_proxy(env_no_proxy, ho

[FFmpeg-devel] [PATCH v19 5/5] libavfilter/vf_frei0r.c: Use UTF-8 version of getenv()

2022-06-19 Thread Nil Admirari
---
 libavfilter/vf_frei0r.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index f11ae6e55c..c3176ea1f7 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -31,6 +31,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/common.h"
 #include "libavutil/eval.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
@@ -188,7 +189,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 f0r_init_ff0r_init;
 f0r_get_plugin_info_f f0r_get_plugin_info;
 f0r_plugin_info_t *pi;
-char *path;
+char *path, *env_frei0r_path;
 int ret = 0;
 int i;
 static const char* const frei0r_pathlist[] = {
@@ -204,7 +205,10 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 }
 
 /* see: http://frei0r.dyne.org/codedoc/html/group__pluglocations.html */
-if ((path = av_strdup(getenv("FREI0R_PATH" {
+env_frei0r_path = getenv_utf8("FREI0R_PATH");
+path = av_strdup(env_frei0r_path);
+freeenv_utf8(env_frei0r_path);
+if (path) {
 #ifdef _WIN32
 const char *separator = ";";
 #else
@@ -231,12 +235,17 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 if (ret < 0)
 return ret;
 }
-if (!s->dl_handle && (path = getenv("HOME"))) {
+if (!s->dl_handle && (path = getenv_utf8("HOME"))) {
 char *prefix = av_asprintf("%s/.frei0r-1/lib/", path);
-if (!prefix)
-return AVERROR(ENOMEM);
+if (!prefix) {
+ret = AVERROR(ENOMEM);
+goto home_path_end;
+}
 ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
 av_free(prefix);
+
+home_path_end:
+freeenv_utf8(path);
 if (ret < 0)
 return ret;
 }
-- 
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 v19 2/5] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW

2022-06-19 Thread Nil Admirari
---
 compat/w32dlfcn.h | 100 --
 libavcodec/mf_utils.h |   1 +
 2 files changed, 79 insertions(+), 22 deletions(-)

diff --git a/compat/w32dlfcn.h b/compat/w32dlfcn.h
index 52a94efafb..fb1aa1b72e 100644
--- a/compat/w32dlfcn.h
+++ b/compat/w32dlfcn.h
@@ -20,11 +20,40 @@
 #define COMPAT_W32DLFCN_H
 
 #ifdef _WIN32
+#include 
+
 #include 
+
 #include "config.h"
-#if (_WIN32_WINNT < 0x0602) || HAVE_WINRT
+#include "libavutil/macros.h"
 #include "libavutil/wchar_filename.h"
-#endif
+
+static inline wchar_t *get_module_filename(HMODULE module)
+{
+wchar_t *path = NULL, *new_path;
+DWORD path_size = 0, path_len;
+
+do {
+path_size = path_size ? FFMIN(2 * path_size, INT16_MAX + 1) : MAX_PATH;
+new_path = av_realloc_array(path, path_size, sizeof *path);
+if (!new_path) {
+av_free(path);
+return NULL;
+}
+path = new_path;
+// Returns path_size in case of insufficient buffer.
+// Whether the error is set or not and whether the output
+// is null-terminated or not depends on the version of Windows.
+path_len = GetModuleFileNameW(module, path, path_size);
+} while (path_len && path_size <= INT16_MAX && path_size <= path_len);
+
+if (!path_len) {
+av_free(path);
+return NULL;
+}
+return path;
+}
+
 /**
  * Safe function used to open dynamic libs. This attempts to improve program 
security
  * by removing the current directory from the dll search path. Only dll's 
found in the
@@ -34,29 +63,53 @@
  */
 static inline HMODULE win32_dlopen(const char *name)
 {
+wchar_t *name_w;
+HMODULE module = NULL;
+if (utf8towchar(name, &name_w))
+name_w = NULL;
 #if _WIN32_WINNT < 0x0602
-// Need to check if KB2533623 is available
+// On Win7 and earlier we check if KB2533623 is available
 if (!GetProcAddress(GetModuleHandleW(L"kernel32.dll"), 
"SetDefaultDllDirectories")) {
-HMODULE module = NULL;
-wchar_t *path = NULL, *name_w = NULL;
-DWORD pathlen;
-if (utf8towchar(name, &name_w))
+wchar_t *path = NULL, *new_path;
+DWORD pathlen, pathsize, namelen;
+if (!name_w)
 goto exit;
-path = (wchar_t *)av_calloc(MAX_PATH, sizeof(wchar_t));
+namelen = wcslen(name_w);
 // Try local directory first
-pathlen = GetModuleFileNameW(NULL, path, MAX_PATH);
-pathlen = wcsrchr(path, '\\') - path;
-if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+path = get_module_filename(NULL);
+if (!path)
+goto exit;
+new_path = wcsrchr(path, '\\');
+if (!new_path)
 goto exit;
-path[pathlen] = '\\';
+pathlen = new_path - path;
+pathsize = pathlen + namelen + 2;
+new_path = av_realloc_array(path, pathsize, sizeof *path);
+if (!new_path)
+goto exit;
+path = new_path;
 wcscpy(path + pathlen + 1, name_w);
 module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
 if (module == NULL) {
 // Next try System32 directory
-pathlen = GetSystemDirectoryW(path, MAX_PATH);
-if (pathlen == 0 || pathlen + wcslen(name_w) + 2 > MAX_PATH)
+pathlen = GetSystemDirectoryW(path, pathsize);
+if (!pathlen)
 goto exit;
-path[pathlen] = '\\';
+// Buffer is not enough in two cases:
+// 1. system directory + \ + module name
+// 2. system directory even without the module name.
+if (pathlen + namelen + 2 > pathsize) {
+pathsize = pathlen + namelen + 2;
+new_path = av_realloc_array(path, pathsize, sizeof *path);
+if (!new_path)
+goto exit;
+path = new_path;
+// Query again to handle the case #2.
+pathlen = GetSystemDirectoryW(path, pathsize);
+if (!pathlen)
+goto exit;
+}
+path[pathlen] = L'\\';
 wcscpy(path + pathlen + 1, name_w);
 module = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
 }
@@ -73,16 +126,19 @@ exit:
 #   define LOAD_LIBRARY_SEARCH_SYSTEM320x0800
 #endif
 #if HAVE_WINRT
-wchar_t *name_w = NULL;
-int ret;
-if (utf8towchar(name, &name_w))
+if (!name_w)
 return NULL;
-ret = LoadPackagedLibrary(name_w, 0);
-av_free(name_w);
-return ret;
+module = LoadPackagedLibrary(name_w, 0);
 #else
-return LoadLibraryExA(name, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 
LOAD_LIBRARY_SEARCH_SYSTEM32);
+#define LOAD_FLAGS (LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 
LOAD_LIBRARY_SEARCH_SYSTEM32)
+/* filename may be be in CP_ACP */
+if (!name_w)
+return LoadLibraryExA(name, NULL, LOAD_FLAGS);
+

[FFmpeg-devel] [PATCH v19 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8() and freeenv_utf8()

2022-06-19 Thread Nil Admirari
wchartoutf8() converts strings returned by WinAPI into UTF-8,
which is FFmpeg's preffered encoding.

Some external dependencies, such as AviSynth, are still
not Unicode-enabled. utf8toansi() converts UTF-8 strings
into ANSI in two steps: UTF-8 -> wchar_t -> ANSI.
wchartoansi() is responsible for the second step of the conversion.
Conversion in just one step is not supported by WinAPI.

Since these character converting functions allocate the buffer
of necessary size, they also facilitate the removal of MAX_PATH limit
in places where fixed-size ANSI/WCHAR strings were used
as filename buffers.

getenv_utf8() wraps _wgetenv() converting its input from
and its output to UTF-8. Compared to plain getenv(),
getenv_utf8() requires a cleanup.

Because of that, in places that only test the existence of
an environment variable or compare its value with a string
consisting entirely of ASCII characters, the use of plain getenv()
is still preferred. (libavutil/log.c check_color_terminal()
is an example of such a place.)

Plain getenv() is also preffered in UNIX-only code,
such as bktr.c, fbdev_common.c, oss.c in libavdevice
or af_ladspa.c in libavfilter.
---
 configure  |  1 +
 libavutil/getenv_utf8.h| 83 ++
 libavutil/wchar_filename.h | 53 
 3 files changed, 137 insertions(+)
 create mode 100644 libavutil/getenv_utf8.h

diff --git a/configure b/configure
index 7ffbb85e21..3a97610209 100755
--- a/configure
+++ b/configure
@@ -2272,6 +2272,7 @@ SYSTEM_FUNCS="
 fcntl
 getaddrinfo
 getauxval
+getenv
 gethrtime
 getopt
 GetModuleHandle
diff --git a/libavutil/getenv_utf8.h b/libavutil/getenv_utf8.h
new file mode 100644
index 00..799fef9839
--- /dev/null
+++ b/libavutil/getenv_utf8.h
@@ -0,0 +1,83 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_GETENV_UTF8_H
+#define AVUTIL_GETENV_UTF8_H
+
+#include 
+
+#include "config.h"
+#include "mem.h"
+
+#if HAVE_GETENV
+
+#ifdef _WIN32
+
+#include "libavutil/wchar_filename.h"
+
+static inline char *getenv_utf8(const char *varname)
+{
+wchar_t *varname_w, *var_w;
+char *var;
+
+if (utf8towchar(varname, &varname_w))
+return NULL;
+if (!varname_w)
+return NULL;
+
+var_w = _wgetenv(varname_w);
+av_free(varname_w);
+
+if (!var_w)
+return NULL;
+if (wchartoutf8(var_w, &var))
+return NULL;
+
+return var;
+
+// No CP_ACP fallback compared to other *_utf8() functions:
+// non UTF-8 strings must not be returned.
+}
+
+static inline void freeenv_utf8(const char *var)
+{
+av_free(var);
+}
+
+#else
+
+static inline char *getenv_utf8(const char *varname)
+{
+return getenv(varname);
+}
+
+static inline void freeenv_utf8(const char *)
+{
+}
+
+#endif // _WIN32
+
+#else
+
+#define getenv_utf8(x) NULL
+
+#define freeenv_utf8(x) ((void) 0)
+
+#endif // HAVE_GETENV
+
+#endif // AVUTIL_GETENV_UTF8_H
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index f36d9dfea3..08de073ed7 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -20,6 +20,8 @@
 #define AVUTIL_WCHAR_FILENAME_H
 
 #ifdef _WIN32
+
+#define WIN32_LEAN_AND_MEAN
 #include 
 #include "mem.h"
 
@@ -41,6 +43,57 @@ static inline int utf8towchar(const char *filename_utf8, 
wchar_t **filename_w)
 return 0;
 }
 
+av_warn_unused_result
+static inline int wchartocp(unsigned int code_page, const wchar_t *filename_w,
+char **filename)
+{
+DWORD flags = code_page == CP_UTF8 ? WC_ERR_INVALID_CHARS : 0;
+int num_chars = WideCharToMultiByte(code_page, flags, filename_w, -1,
+NULL, 0, NULL, NULL);
+if (num_chars <= 0) {
+*filename = NULL;
+return 0;
+}
+*filename = av_malloc_array(num_chars, sizeof *filename);
+if (!*filename) {
+errno = ENOMEM;
+return -1;
+}
+WideCharToMultiByte(code_page, flags, filename_w, -1,
+*filename, num_chars, NULL, NULL);
+return 0;
+}
+
+av_warn_unused_result
+static inline int wchartoutf8(const wchar_t *filename_w, char **filename)
+{
+return wchartocp(CP_UTF8, filename_w, filename);
+}
+
+a

[FFmpeg-devel] [PATCH v19 3/5] fftools: Remove MAX_PATH limit and switch to UTF-8 versions of fopen() and getenv()

2022-06-19 Thread Nil Admirari
---
 fftools/cmdutils.c   | 53 +---
 fftools/ffmpeg_opt.c |  9 ++--
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 5d7cdc3e10..69a6f54ea3 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -39,6 +39,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/display.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/libm.h"
@@ -47,9 +48,11 @@
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
 #include "cmdutils.h"
+#include "fopen_utf8.h"
 #include "opt_common.h"
 #ifdef _WIN32
 #include 
+#include "compat/w32dlfcn.h"
 #endif
 
 AVDictionary *sws_dict;
@@ -465,7 +468,7 @@ static void check_options(const OptionDef *po)
 void parse_loglevel(int argc, char **argv, const OptionDef *options)
 {
 int idx = locate_option(argc, argv, options, "loglevel");
-const char *env;
+char *env;
 
 check_options(options);
 
@@ -474,7 +477,8 @@ void parse_loglevel(int argc, char **argv, const OptionDef 
*options)
 if (idx && argv[idx + 1])
 opt_loglevel(NULL, "loglevel", argv[idx + 1]);
 idx = locate_option(argc, argv, options, "report");
-if ((env = getenv("FFREPORT")) || idx) {
+env = getenv_utf8("FFREPORT");
+if (env || idx) {
 FILE *report_file = NULL;
 init_report(env, &report_file);
 if (report_file) {
@@ -487,6 +491,7 @@ void parse_loglevel(int argc, char **argv, const OptionDef 
*options)
 fflush(report_file);
 }
 }
+freeenv_utf8(env);
 idx = locate_option(argc, argv, options, "hide_banner");
 if (idx)
 hide_banner = 1;
@@ -812,28 +817,45 @@ FILE *get_preset_file(char *filename, size_t 
filename_size,
 {
 FILE *f = NULL;
 int i;
-const char *base[3] = { getenv("FFMPEG_DATADIR"),
-getenv("HOME"),
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+char *datadir = NULL;
+#endif
+char *env_home = getenv_utf8("HOME");
+char *env_ffmpeg_datadir = getenv_utf8("FFMPEG_DATADIR");
+const char *base[3] = { env_home,
+env_ffmpeg_datadir,
 FFMPEG_DATADIR, };
 
 if (is_path) {
 av_strlcpy(filename, preset_name, filename_size);
-f = fopen(filename, "r");
+f = fopen_utf8(filename, "r");
 } else {
 #if HAVE_GETMODULEHANDLE && defined(_WIN32)
-char datadir[MAX_PATH], *ls;
+wchar_t *datadir_w = get_module_filename(NULL);
 base[2] = NULL;
 
-if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, 
sizeof(datadir) - 1))
+if (wchartoutf8(datadir_w, &datadir))
+datadir = NULL;
+av_free(datadir_w);
+
+if (datadir)
 {
-for (ls = datadir; ls < datadir + strlen(datadir); ls++)
+char *ls;
+for (ls = datadir; *ls; ls++)
 if (*ls == '\\') *ls = '/';
 
 if (ls = strrchr(datadir, '/'))
 {
-*ls = 0;
-strncat(datadir, "/ffpresets",  sizeof(datadir) - 1 - 
strlen(datadir));
-base[2] = datadir;
+ptrdiff_t datadir_len = ls - datadir;
+size_t desired_size = datadir_len + strlen("/ffpresets") + 1;
+char *new_datadir = av_realloc_array(
+datadir, desired_size, sizeof *datadir);
+if (new_datadir) {
+datadir = new_datadir;
+datadir[datadir_len] = 0;
+strncat(datadir, "/ffpresets",  desired_size - 1 - 
datadir_len);
+base[2] = datadir;
+}
 }
 }
 #endif
@@ -842,17 +864,22 @@ FILE *get_preset_file(char *filename, size_t 
filename_size,
 continue;
 snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i],
  i != 1 ? "" : "/.ffmpeg", preset_name);
-f = fopen(filename, "r");
+f = fopen_utf8(filename, "r");
 if (!f && codec_name) {
 snprintf(filename, filename_size,
  "%s%s/%s-%s.ffpreset",
  base[i], i != 1 ? "" : "/.ffmpeg", codec_name,
  preset_name);
-f = fopen(filename, "r");
+f = fopen_utf8(filename, "r");
 }
 }
 }
 
+#if HAVE_GETMODULEHANDLE && defined(_WIN32)
+av_free(datadir);
+#endif
+freeenv_utf8(env_ffmpeg_datadir);
+freeenv_utf8(env_home);
 return f;
 }
 
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 398067da96..e08455478f 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -44,6 +44,7 @@
 #include "libavutil/avutil.h"
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
+#include "libavut

[FFmpeg-devel] [PATCH v19 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

2022-06-19 Thread Nil Admirari
1. getenv() is replaced with getenv_utf8() across libavformat.
2. New versions of AviSynth+ are now called with UTF-8 filenames.
3. Old versions of AviSynth are still using ANSI strings,
   but MAX_PATH limit on filename is removed.
---
 libavformat/avisynth.c| 39 +++
 libavformat/http.c| 22 ++
 libavformat/ipfsgateway.c | 35 +++
 libavformat/tls.c | 11 +--
 4 files changed, 73 insertions(+), 34 deletions(-)

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 8ba2bdead2..a97d12b6b6 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -34,6 +34,7 @@
 /* Platform-specific directives. */
 #ifdef _WIN32
   #include "compat/w32dlfcn.h"
+  #include "libavutil/wchar_filename.h"
   #undef EXTERN_C
   #define AVISYNTH_LIB "avisynth"
 #else
@@ -56,6 +57,7 @@ typedef struct AviSynthLibrary {
 #define AVSC_DECLARE_FUNC(name) name ## _func name
 AVSC_DECLARE_FUNC(avs_bit_blt);
 AVSC_DECLARE_FUNC(avs_clip_get_error);
+AVSC_DECLARE_FUNC(avs_check_version);
 AVSC_DECLARE_FUNC(avs_create_script_environment);
 AVSC_DECLARE_FUNC(avs_delete_script_environment);
 AVSC_DECLARE_FUNC(avs_get_audio);
@@ -137,6 +139,7 @@ static av_cold int avisynth_load_library(void)
 
 LOAD_AVS_FUNC(avs_bit_blt, 0);
 LOAD_AVS_FUNC(avs_clip_get_error, 0);
+LOAD_AVS_FUNC(avs_check_version, 0);
 LOAD_AVS_FUNC(avs_create_script_environment, 0);
 LOAD_AVS_FUNC(avs_delete_script_environment, 0);
 LOAD_AVS_FUNC(avs_get_audio, 0);
@@ -807,26 +810,38 @@ static int avisynth_create_stream(AVFormatContext *s)
 static int avisynth_open_file(AVFormatContext *s)
 {
 AviSynthContext *avs = s->priv_data;
-AVS_Value arg, val;
+AVS_Value val;
 int ret;
-#ifdef _WIN32
-char filename_ansi[MAX_PATH * 4];
-wchar_t filename_wc[MAX_PATH * 4];
-#endif
 
 if (ret = avisynth_context_create(s))
 return ret;
 
+if (!avs_library.avs_check_version(avs->env, 7)) {
+AVS_Value args[] = {
+avs_new_value_string(s->url),
+avs_new_value_bool(1) // filename is in UTF-8
+};
+val = avs_library.avs_invoke(avs->env, "Import",
+ avs_new_value_array(args, 2), 0);
+} else {
+AVS_Value arg;
 #ifdef _WIN32
-/* Convert UTF-8 to ANSI code page */
-MultiByteToWideChar(CP_UTF8, 0, s->url, -1, filename_wc, MAX_PATH * 4);
-WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi,
-MAX_PATH * 4, NULL, NULL);
-arg = avs_new_value_string(filename_ansi);
+char *filename_ansi;
+/* Convert UTF-8 to ANSI code page */
+if (utf8toansi(s->url, &filename_ansi)) {
+ret = AVERROR_UNKNOWN;
+goto fail;
+}
+arg = avs_new_value_string(filename_ansi);
 #else
-arg = avs_new_value_string(s->url);
+arg = avs_new_value_string(s->url);
 #endif
-val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
+val = avs_library.avs_invoke(avs->env, "Import", arg, 0);
+#ifdef _WIN32
+av_free(filename_ansi);
+#endif
+}
+
 if (avs_is_error(val)) {
 av_log(s, AV_LOG_ERROR, "%s\n", avs_as_error(val));
 ret = AVERROR_UNKNOWN;
diff --git a/libavformat/http.c b/libavformat/http.c
index c8f3f4b6a3..f80ea7bf35 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -29,6 +29,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
 #include "libavutil/parseutils.h"
@@ -198,12 +199,13 @@ void ff_http_init_auth_state(URLContext *dest, const 
URLContext *src)
 static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
 {
 const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
+char *env_http_proxy, *env_no_proxy;
 char *hashmark;
 char hostname[1024], hoststr[1024], proto[10];
 char auth[1024], proxyauth[1024] = "";
 char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE + 1];
 char buf[1024], urlbuf[MAX_URL_SIZE];
-int port, use_proxy, err;
+int port, use_proxy, err = 0;
 HTTPContext *s = h->priv_data;
 
 av_url_split(proto, sizeof(proto), auth, sizeof(auth),
@@ -211,9 +213,13 @@ static int http_open_cnx_internal(URLContext *h, 
AVDictionary **options)
  path1, sizeof(path1), s->location);
 ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
 
-proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy");
-use_proxy  = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) &&
+env_http_proxy = getenv_utf8("http_proxy");
+proxy_path = s->http_proxy ? s->http_proxy : env_http_proxy;
+
+env_no_proxy = getenv_utf8("no_proxy");
+use_proxy  = !ff_http_match_no_proxy(env_no_proxy, ho

Re: [FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

2022-06-19 Thread nil-admirari
> Thanks, adding #define WIN32_LEAN_AND_MEAN in wchar_filename.h fixes the 
> issue.

Added WIN32_LEAN_AND_MEAN:
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297804.html



___
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 v17 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

2022-06-19 Thread nil-admirari
> FWIW - I wasn't entirely sure we can conclude that we always pass through 
> a case that initializes the err variable here, so just to be sure, I 
> locally amended this patch to initialize the err variable to 0 too.

Fixed: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297806.html



___
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 v17 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi() and getenv_utf8()

2022-06-19 Thread nil-admirari
> Note that this should be #if HAVE_GETENV - these constants are always 
> defined and evaluate to 0 or 1. No need to resend the patchset just for 
> that. (I added an explicit #include "config.h" above here too, just to 
> make it clearer.)

Fixed: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297804.html



___
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 v17 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi() and getenv_utf8()

2022-06-19 Thread nil-admirari
> This forces allocations and frees in scenarios where this is wholly
> unnecessary. This can be avoided by adding a custom deallocator for
> strings returned via getenv_utf8: Namely a define/wrapper around av_free
> in the _WIN32 and a no-op else.

Done: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297804.html

Note, however, that the introduction of freeenv_utf8()
doubles allocations and deallocations in vf_frei0r.c on Windows:
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297802.html

These additional memory operations can be avoided only with a whole bunch
of new #ifdef _WIN32 and #if HAVE_GETENV, which haven't been done.



___
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] SDL2 verison for pkg_config fallback

2022-06-19 Thread dvhh
pkg_config fallback for SDL2 use 2.1.0 as max (excluded) version
where the pkg_config specify 3.0.0
Correcting fallback version to be in line with the pkg_config version

Signed-off-by: dvhh 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 3dca1c4bd3..6ecacbb1bb 100755
--- a/configure
+++ b/configure
@@ -6750,7 +6750,7 @@ if enabled sdl2; then
 sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
 sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
 test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
-test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags &&
+test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | 
SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x03" $sdl2_cflags &&
 check_func_headers SDL_events.h SDL_PollEvent $sdl2_extralibs 
$sdl2_cflags &&
 enable sdl2
 fi
-- 
2.30.2

___
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 v3] avcodec/mfenc: set variable frame size flag.

2022-06-19 Thread Gyan Doshi




On 2022-06-19 03:15 pm, Gyan Doshi wrote:

Default avctx->frame_size is 0 which led to init failure for
audio MediaFoundation encoders since 827d6fe73d.

The MF audio encoders accept variable frame size input buffers.

Fixes #9802


Plan to push tomorrow.



---
  libavcodec/mfenc.c | 23 ++-
  1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index 13ed7b3e11..bbe78605a9 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -1220,7 +1220,7 @@ static int mf_init(AVCodecContext *avctx)
  
  #define OFFSET(x) offsetof(MFContext, x)
  
-#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, EXTRA) \

+#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS) \
  static const AVClass ff_ ## NAME ## _mf_encoder_class = { 
 \
  .class_name = #NAME "_mf",
 \
  .item_name  = av_default_item_name,   
 \
@@ -1237,9 +1237,8 @@ static int mf_init(AVCodecContext *avctx)
  .init   = mf_init,
 \
  .close  = mf_close,   
 \
  FF_CODEC_RECEIVE_PACKET_CB(mf_receive_packet),
 \
-EXTRA  
\
-.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
-  AV_CODEC_CAP_DR1,
\
+FMTS   
\
+CAPS   
\
  .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |  
 \
FF_CODEC_CAP_INIT_CLEANUP,  
 \
  };
@@ -1247,10 +1246,13 @@ static int mf_init(AVCodecContext *avctx)
  #define AFMTS \
  .p.sample_fmts  = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,   
 \
   AV_SAMPLE_FMT_NONE },
+#define ACAPS \
+.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
+  AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE,
  
-MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS);

-MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS);
-MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS);
+MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS);
+MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS);
+MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS);
  
  #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM

  static const AVOption venc_opts[] = {
@@ -1283,6 +1285,9 @@ static const AVOption venc_opts[] = {
  .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,  
 \
  AV_PIX_FMT_YUV420P,   
 \
  AV_PIX_FMT_NONE },
+#define VCAPS \
+.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID |   
\
+  AV_CODEC_CAP_DR1,
  
-MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS);

-MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS);
+MF_ENCODER(VIDEO, h264,H264, venc_opts, VFMTS, VCAPS);
+MF_ENCODER(VIDEO, hevc,HEVC, venc_opts, VFMTS, VCAPS);


___
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] SDL2 verison for pkg_config fallback

2022-06-19 Thread Timo Rothenpieler

On 17.06.2022 18:46, dvhh wrote:

pkg_config fallback for SDL2 use 2.1.0 as max (excluded) version
where the pkg_config specify 3.0.0
Correcting fallback version to be in line with the pkg_config version


Why? Any version the new versioning scheme will have a pkg-config file.
___
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] avcodec/libx265: make X265 CSP selection pixel format independent

2022-06-19 Thread Jan Ekström
Currently the format listing misses the J formats completely, yet
they are marked as supported in the encoder. Thus to make the logic
support them while not explicitly listing them, make the logic
utilize chroma subsampling information in both width and height
available through the pixel format descriptor.
---
 libavcodec/libx265.c | 61 ++--
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 4dcdcd7a77..e00cb6fd8c 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -240,39 +240,40 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 }
 }
 
-switch (avctx->pix_fmt) {
-case AV_PIX_FMT_YUV420P:
-case AV_PIX_FMT_YUV420P10:
-case AV_PIX_FMT_YUV420P12:
-ctx->params->internalCsp = X265_CSP_I420;
-break;
-case AV_PIX_FMT_YUV422P:
-case AV_PIX_FMT_YUV422P10:
-case AV_PIX_FMT_YUV422P12:
-ctx->params->internalCsp = X265_CSP_I422;
-break;
-case AV_PIX_FMT_GBRP:
-case AV_PIX_FMT_GBRP10:
-case AV_PIX_FMT_GBRP12:
-ctx->params->vui.matrixCoeffs = AVCOL_SPC_RGB;
-ctx->params->vui.bEnableVideoSignalTypePresentFlag  = 1;
-ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
-case AV_PIX_FMT_YUV444P:
-case AV_PIX_FMT_YUV444P10:
-case AV_PIX_FMT_YUV444P12:
+switch (desc->log2_chroma_w) {
+// 4:4:4, RGB. gray
+case 0:
+// gray
+if (desc->nb_components == 1) {
+if (ctx->api->api_build_number < 85) {
+av_log(avctx, AV_LOG_ERROR,
+   "libx265 version is %d, must be at least 85 for gray 
encoding.\n",
+   ctx->api->api_build_number);
+return AVERROR_INVALIDDATA;
+}
+ctx->params->internalCsp = X265_CSP_I400;
+break;
+}
+
+// set RGB identity matrix for RGB
+if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
+ctx->params->vui.matrixCoeffs = AVCOL_SPC_RGB;
+ctx->params->vui.bEnableVideoSignalTypePresentFlag  = 1;
+ctx->params->vui.bEnableColorDescriptionPresentFlag = 1;
+}
+
 ctx->params->internalCsp = X265_CSP_I444;
 break;
-case AV_PIX_FMT_GRAY8:
-case AV_PIX_FMT_GRAY10:
-case AV_PIX_FMT_GRAY12:
-if (ctx->api->api_build_number < 85) {
-av_log(avctx, AV_LOG_ERROR,
-   "libx265 version is %d, must be at least 85 for gray 
encoding.\n",
-   ctx->api->api_build_number);
-return AVERROR_INVALIDDATA;
-}
-ctx->params->internalCsp = X265_CSP_I400;
+// 4:2:0, 4:2:2
+case 1:
+ctx->params->internalCsp = desc->log2_chroma_h == 1 ?
+X265_CSP_I420 : X265_CSP_I422;
 break;
+default:
+av_log(avctx, AV_LOG_ERROR,
+   "Pixel format '%s' cannot be mapped to a libx265 CSP!\n",
+   desc->name);
+return AVERROR_BUG;
 }
 
 if (ctx->crf >= 0) {
-- 
2.36.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] SDL2 verison for pkg_config fallback

2022-06-19 Thread dvhh
On Sun, 19 Jun 2022 17:46:58 +0200
Timo Rothenpieler  wrote:

> On 17.06.2022 18:46, dvhh wrote:
> > pkg_config fallback for SDL2 use 2.1.0 as max (excluded) version
> > where the pkg_config specify 3.0.0
> > Correcting fallback version to be in line with the pkg_config version
> 
> Why? Any version the new versioning scheme will have a pkg-config file.

I am cross-compiling for Windows aarch64 and noticed the discrepancy, 
pkg_config does not appear to be an option in that case.

this is what I got from the log:
---
test_pkg_config sdl2 sdl2 >= 2.0.1 sdl2 < 3.0.0 SDL_events.h SDL_PollEvent
false --exists --print-errors sdl2 >= 2.0.1 sdl2 < 3.0.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] [PATCH v19 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8() and freeenv_utf8()

2022-06-19 Thread Martin Storsjö

On Sun, 19 Jun 2022, Nil Admirari wrote:


wchartoutf8() converts strings returned by WinAPI into UTF-8,
which is FFmpeg's preffered encoding.

Some external dependencies, such as AviSynth, are still
not Unicode-enabled. utf8toansi() converts UTF-8 strings
into ANSI in two steps: UTF-8 -> wchar_t -> ANSI.
wchartoansi() is responsible for the second step of the conversion.
Conversion in just one step is not supported by WinAPI.

Since these character converting functions allocate the buffer
of necessary size, they also facilitate the removal of MAX_PATH limit
in places where fixed-size ANSI/WCHAR strings were used
as filename buffers.

getenv_utf8() wraps _wgetenv() converting its input from
and its output to UTF-8. Compared to plain getenv(),
getenv_utf8() requires a cleanup.

Because of that, in places that only test the existence of
an environment variable or compare its value with a string
consisting entirely of ASCII characters, the use of plain getenv()
is still preferred. (libavutil/log.c check_color_terminal()
is an example of such a place.)

Plain getenv() is also preffered in UNIX-only code,
such as bktr.c, fbdev_common.c, oss.c in libavdevice
or af_ladspa.c in libavfilter.
---
configure  |  1 +
libavutil/getenv_utf8.h| 83 ++
libavutil/wchar_filename.h | 53 
3 files changed, 137 insertions(+)
create mode 100644 libavutil/getenv_utf8.h


Looks good overall, thanks! The freeenv_utf8 function needed a couple 
minor fixes though, to fix these warnings/errors:


src/libavutil/getenv_utf8.h: In function ‘freeenv_utf8’:
src/libavutil/getenv_utf8.h:59:13: warning: passing argument 1 of 
‘av_free’ discards ‘const’ qualifier from pointer target type 
[-Wdiscarded-qualifiers]

   59 | av_free(var);


In file included from src/libavformat/http.c:32:
src/libavutil/getenv_utf8.h: In function ‘freeenv_utf8’:
src/libavutil/getenv_utf8.h:69:33: error: parameter name omitted
   69 | static inline void freeenv_utf8(char *)

Fixed locally with these changes:

@@ -54,7 +54,7 @@ static inline char *getenv_utf8(const char *varname)
 // non UTF-8 strings must not be returned.
 }

-static inline void freeenv_utf8(const char *var)
+static inline void freeenv_utf8(char *var)
 {
 av_free(var);
 }
@@ -66,7 +66,7 @@ static inline char *getenv_utf8(const char *varname)
 return getenv(varname);
 }

-static inline void freeenv_utf8(const char *)
+static inline void freeenv_utf8(char *var)
 {
 }

(No need to resend for these changes IMO.)

If there's no further comments, I'd push this set tomorrow, with these 
changes amended.


// Martin
___
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] SDL2 verison for pkg_config fallback

2022-06-19 Thread Martin Storsjö

On Mon, 20 Jun 2022, dvhh wrote:


On Sun, 19 Jun 2022 17:46:58 +0200
Timo Rothenpieler  wrote:


On 17.06.2022 18:46, dvhh wrote:

pkg_config fallback for SDL2 use 2.1.0 as max (excluded) version
where the pkg_config specify 3.0.0
Correcting fallback version to be in line with the pkg_config version


Why? Any version the new versioning scheme will have a pkg-config file.


I am cross-compiling for Windows aarch64 and noticed the discrepancy, 
pkg_config does not appear to be an option in that case.

this is what I got from the log:
---
test_pkg_config sdl2 sdl2 >= 2.0.1 sdl2 < 3.0.0 SDL_events.h SDL_PollEvent
false --exists --print-errors sdl2 >= 2.0.1 sdl2 < 3.0.0
---


Instead of an aarch64-w64-mingw32-pkg-config, you can configure with 
--pkg-config=pkg-config, and set PKG_CONFIG_LIBDIR=.


That said, this patch seems like a consistent followup to 
e5163b1d34381a3319214a902ef1df923dd2eeba - so either we apply this, or 
decide to scrap the non-pkgconfig fallback for this library. (Applying 
this patch in the meantime probably doesn't hurt, while deciding on 
whether pkg-config can be required here.)


// Martin

___
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] oss: account for sample size when computing timestamp

2022-06-19 Thread Marton Balint




On Wed, 15 Jun 2022, Matt Jacobson wrote:


Hi,


On Jun 1, 2022, at 5:06 AM, Matt Jacobson  wrote:

Don't assume each sample is one byte in size.  Doing so results in wrong and
occasionally non-monotonically-increasing timestamps.

Fix nearby cosmetic typo.


Friendly ping on this patch.  Original mail:



Please let me know if any changes are desired.  If not, could someone please
help me commit it?  (Is there a process to request access?)


Thanks, will apply.

Regards,
Marton
___
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] avformat/concat: fix missing metadata

2022-06-19 Thread Marton Balint




On Sun, 12 Jun 2022, Steven Hartland wrote:


Remove return after copying extradata as this prevents metadata
being duplicated correctly.


The return there originated from commit 
b24d6c5303720fbd59cbd25c392229450660 and seems very much intentional 
to not overwrite stream parameters after every packet.


So what is the issue you are trying to fix? Some parameters change after 
the avformat_find_stream_info() returned?


Regards,
Marton



Signed-off-by: Steven Hartland 
---
libavformat/concatdec.c   | 1 -
tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index e57da59e04..11ed2bd4c3 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -182,7 +182,6 @@ static int copy_stream_props(AVStream *st, AVStream
*source_st)
}
memcpy(st->codecpar->extradata, source_st->codecpar->extradata,
   source_st->codecpar->extradata_size);
-return 0;
}
if ((ret = avcodec_parameters_copy(st->codecpar, source_st->codecpar))
< 0)
return ret;
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index 9603ca21d0..d98e8b71e1 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -211,5 +211,5 @@
video|1|171982|1.910911|168382|1.870911|3600|0.04|17440|206988|__|MPEGTS
Str

video|1|175582|1.950911|171982|1.910911|3600|0.04|15019|224848|__|MPEGTS
Stream ID|224

-0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/9|0|0.00|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this
is stream 0
+0|mp2|unknown|audio|[3][0][0][0]|0x0003|fltp|44100|1|mono|0|N/A|0/0|0/0|1/9|0|0.00|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this
is stream 0
1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/9|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this
is stream 1|CPB properties|0|0|0|49152|-1
--
2.25.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 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 5.1

2022-06-19 Thread Marton Balint




On Thu, 9 Jun 2022, Neal Gompa wrote:


On Tue, Jun 7, 2022 at 7:35 AM Michael Niedermayer
 wrote:


Hi all

As was discussed previously the 5.1 release should be in june/july
That means in the next weeks probably!
If you know of any regressions, security issues or other major bugs,
please help fixing them

Also as was suggested before, this release will get the "LTS" tag
unless people feel thats a bad idea of course



There were a few fixes we have in Fedora on top of 5.0 that would be
nice to have in upstream 5.1:

* http://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/292877.html
* http://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/292853.html
* http://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/293194.html

Would it be possible to make sure these are in?



These are already merged, except the last patch, which needs some further 
explanaition if this is cosmetic change or actually changes some behaviour 
(other than the possible user facing error message)


Regards,
Marton
___
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] doc/examples/muxing: code rewrite with improved readability and fixed issues

2022-06-19 Thread Leo Izen



On 6/18/22 21:05, Paolo Prete wrote:

A new patch is attached to this mail.


Don't forget to add -v2 to your git format-patch line, which changes the 
patch header so it says [PATCH v2], which makes it easier for other 
readers to keep track of things. Also, it's usually a good idea to 
provide a shortlist of what changed in the new patch to help out

reviewers.

- Leo Izen (thebombzen)
___
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/4] avformat/mov: Add special case for slow duplication loop in mov_read_trun()

2022-06-19 Thread Michael Niedermayer
On Sun, Jun 19, 2022 at 12:17:54AM +0200, Marton Balint wrote:
> 
> 
> On Sat, 18 Jun 2022, Michael Niedermayer wrote:
> 
> > This extra code is ugly, better solution is welcome
> 
> If you work on fixing these issues, it is kind of your job to find an
> elegant and maintainable solution. If you can't find one with reasonable
> amount of work, then IMHO it is better to leave the timeout issue in the
> code.

yes, you are correct
still such patches should be posted to the mailing list

thx

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

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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


Re: [FFmpeg-devel] [PATCH] avformat/mov: read PCM audio configuration box ('pcmC') if available

2022-06-19 Thread Marton Balint




On Tue, 7 Jun 2022, Ivan Baykalov wrote:


For ipcm and fpcm streams, big-endian format is the default, but it can be 
changed
with additional 'pcmC' sub-atom of audio sample description.

Details can be found in ISO/IEC 23003-5:2020

Fixes ticket #9763
Fixes ticket #9790


Thanks for this, I have factorized the duplicated code from 
existing endianness setting and also simplified your patch a bit. Will 
post it as a reply to this mail.


Regards,
Marton


---
libavformat/mov.c | 60 +++
1 file changed, 60 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d7be593a86..f71a470d9c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7567,6 +7567,65 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
return atom.size;
}

+static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+int version, format_flags, pcm_sample_size;
+AVStream *st;
+
+if (atom.size < 6) {
+av_log(c->fc, AV_LOG_ERROR, "Empty pcmC box\n");
+return AVERROR_INVALIDDATA;
+}
+
+version = avio_r8(pb);
+if (version) {
+av_log(c->fc, AV_LOG_WARNING, "Unsupported pcmC box version %d\n", 
version);
+return 0;
+}
+
+avio_rb24(pb);  // flags
+
+if (c->fc->nb_streams < 1)
+return 0;
+st = c->fc->streams[c->fc->nb_streams-1];
+if (!st || !st->codecpar)
+return 0;
+
+format_flags = avio_r8(pb);
+if (format_flags == 1) { // indicates little-endian format. If not 
present, big-endian format is used
+if (st->codecpar->codec_tag == MKTAG('i','p','c','m')) {
+switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_PCM_S16BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+break;
+case AV_CODEC_ID_PCM_S24BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
+break;
+case AV_CODEC_ID_PCM_S32BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
+break;
+}
+}
+else if (st->codecpar->codec_tag == MKTAG('f','p','c','m')) {
+switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_PCM_F32BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
+break;
+case AV_CODEC_ID_PCM_F64BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE;
+break;
+}
+}
+}
+
+pcm_sample_size = avio_r8(pb);
+if (pcm_sample_size != st->codecpar->bits_per_coded_sample) {
+av_log(c->fc, AV_LOG_WARNING, "Unexpected pcmC sample size (%d vs %d)\n", 
pcm_sample_size, st->codecpar->bits_per_coded_sample);
+}
+
+return 0;
+}
+
static const MOVParseTableEntry mov_default_parse_table[] = {
{ MKTAG('A','C','L','R'), mov_read_aclr },
{ MKTAG('A','P','R','G'), mov_read_avid },
@@ -7670,6 +7729,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
{ MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */
{ MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */
{ MKTAG('i','l','o','c'), mov_read_iloc },
+{ MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */
{ 0, NULL }
};

--
2.35.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 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] avformat/mov: factorize setting little endian PCM streams

2022-06-19 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mov.c | 51 +--
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3ec0ea2361..0660a51492 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1544,35 +1544,38 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0;
 }
 
-static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+static void set_last_stream_little_endian(AVFormatContext *fc)
 {
 AVStream *st;
-int little_endian;
 
-if (c->fc->nb_streams < 1)
-return 0;
-st = c->fc->streams[c->fc->nb_streams-1];
+if (fc->nb_streams < 1)
+return;
+st = fc->streams[fc->nb_streams-1];
 
-little_endian = avio_rb16(pb) & 0xFF;
-av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian);
-if (little_endian == 1) {
-switch (st->codecpar->codec_id) {
-case AV_CODEC_ID_PCM_S24BE:
-st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
-break;
-case AV_CODEC_ID_PCM_S32BE:
-st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
-break;
-case AV_CODEC_ID_PCM_F32BE:
-st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
-break;
-case AV_CODEC_ID_PCM_F64BE:
-st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE;
-break;
-default:
-break;
-}
+switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_PCM_S24BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
+break;
+case AV_CODEC_ID_PCM_S32BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
+break;
+case AV_CODEC_ID_PCM_F32BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
+break;
+case AV_CODEC_ID_PCM_F64BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE;
+break;
+default:
+break;
 }
+}
+
+static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+int little_endian = avio_rb16(pb) & 0xFF;
+av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian);
+if (little_endian == 1)
+set_last_stream_little_endian(c->fc);
 return 0;
 }
 
-- 
2.35.3

___
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] avformat/mov: read PCM audio configuration box ('pcmC') if available

2022-06-19 Thread Marton Balint
From: Ivan Baykalov <4ru...@gmail.com>

For ipcm and fpcm streams, big-endian format is the default, but it can be 
changed
with additional 'pcmC' sub-atom of audio sample description.

Details can be found in ISO/IEC 23003-5:2020

Fixes ticket #9763.
Fixes ticket #9790.

Patch simplified by Marton Balint.

Signed-off-by: Marton Balint 
---
 libavformat/mov.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0660a51492..c6fbe511c0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1553,6 +1553,9 @@ static void set_last_stream_little_endian(AVFormatContext 
*fc)
 st = fc->streams[fc->nb_streams-1];
 
 switch (st->codecpar->codec_id) {
+case AV_CODEC_ID_PCM_S16BE:
+st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+break;
 case AV_CODEC_ID_PCM_S24BE:
 st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
 break;
@@ -1579,6 +1582,24 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_pcmc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+int format_flags;
+
+if (atom.size < 6) {
+av_log(c->fc, AV_LOG_ERROR, "Empty pcmC box\n");
+return AVERROR_INVALIDDATA;
+}
+
+avio_r8(pb);// version
+avio_rb24(pb);  // flags
+format_flags = avio_r8(pb);
+if (format_flags == 1) // indicates little-endian format. If not present, 
big-endian format is used
+set_last_stream_little_endian(c->fc);
+
+return 0;
+}
+
 static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
@@ -7674,6 +7695,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */
 { MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */
 { MKTAG('i','l','o','c'), mov_read_iloc },
+{ MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */
 { 0, NULL }
 };
 
-- 
2.35.3

___
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 v19 3/5] fftools: Remove MAX_PATH limit and switch to UTF-8 versions of fopen() and getenv()

2022-06-19 Thread Michael Niedermayer
On Sun, Jun 19, 2022 at 02:40:54PM +0300, Nil Admirari wrote:
> ---
>  fftools/cmdutils.c   | 53 +---
>  fftools/ffmpeg_opt.c |  9 ++--
>  2 files changed, 47 insertions(+), 15 deletions(-)

breaks build on ubuntu 

CC  fftools/ffmpeg_opt.o
In file included from fftools/ffmpeg_opt.c:47:0:
./libavutil/getenv_utf8.h: In function ‘freeenv_utf8’:
./libavutil/getenv_utf8.h:69:1: error: parameter name omitted
 static inline void freeenv_utf8(const char *)
 ^~
ffbuild/common.mak:81: recipe for target 'fftools/ffmpeg_opt.o' failed
make: *** [fftools/ffmpeg_opt.o] Error 1
CC  fftools/cmdutils.o
In file included from fftools/cmdutils.c:42:0:
./libavutil/getenv_utf8.h: In function ‘freeenv_utf8’:
./libavutil/getenv_utf8.h:69:1: error: parameter name omitted
 static inline void freeenv_utf8(const char *)
 ^~
ffbuild/common.mak:81: recipe for target 'fftools/cmdutils.o' failed
make: *** [fftools/cmdutils.o] Error 1
make: Target 'all' not remade because of errors.

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck empty input parser

2022-06-19 Thread Andreas Rheinhardt
Marton Balint:
> 
> 
> On Sat, 18 Jun 2022, Michael Niedermayer wrote:
> 
>> On Fri, Jun 17, 2022 at 09:53:13PM +0200, Marton Balint wrote:
>>>
>>>
>>> On Tue, 8 Feb 2022, Michael Niedermayer wrote:
>>>
 Fixes: read_frame_internal() which does not return even though both
 demuxer and parser do return
 Fixes:
 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304


 Found-by: continuous fuzzing process
 https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
 Signed-off-by: Michael Niedermayer 
 ---
 libavformat/demux.c | 6 ++
 1 file changed, 6 insertions(+)

 diff --git a/libavformat/demux.c b/libavformat/demux.c
 index ec34b65288..dd42d32710 100644
 --- a/libavformat/demux.c
 +++ b/libavformat/demux.c
 @@ -1222,11 +1222,15 @@ static int
 read_frame_internal(AVFormatContext *s, AVPacket *pkt)
     FFFormatContext *const si = ffformatcontext(s);
     int ret, got_packet = 0;
     AVDictionary *metadata = NULL;
 +    int empty = 0;

     while (!got_packet && !si->parse_queue.head) {
     AVStream *st;
     FFStream *sti;

 +    if (empty > 1)
 +    return AVERROR(EAGAIN);
 +
     /* read next packet */
     ret = ff_read_packet(s, pkt);
     if (ret < 0) {
 @@ -1317,6 +1321,8 @@ static int read_frame_internal(AVFormatContext
 *s, AVPacket *pkt)
     }
     got_packet = 1;
     } else if (st->discard < AVDISCARD_ALL) {
 +    if (pkt->size == 0)
 +    empty ++;
     if ((ret = parse_packet(s, pkt, pkt->stream_index, 0)) < 0)
     return ret;
     st->codecpar->sample_rate = sti->avctx->sample_rate;
 -- 
 2.17.1
>>>
>>> Sorry, just noticed this patchset, and it is very hackish.
>>
>> yes thats why i waited so many month before i applied it
>> some patchsets i forget but this i kept pushing away
>>
>>>
>>> For starters the meaning of AVERROR(EAGAIN) for
>>> av_read_frame()/read_frame_internal() is not very well defined.
>>> Should the
>>> user retry immediately? Should the user sleep() sometime and the
>>> retry? Can
>>> the user expect that a loop of av_read_frame() will eventually return
>>> something different than AVERROR(EAGAIN)?
>>
>> In the context of this problem the idea is to give the user an opertunity
>> to do something else in a single threaded environment or error out if
>> its taking too long not produingh anything
>>
>>
>>>
>>> I am not sure I understand the original issue entirely, but it looks
>>> that
>>> instead of fixing the component which returns infinite amount of zero
>>> sized
>>> packets you implemented a check that makes the user get an EAGAIN()
>>> on the
>>> second zero-sized packet.
>>
>> IIRC the problem was that the demuxer produced 0 sized packets and
>> alot of them
>> for a file only a few hundread bytes large.
> 
> AFAIK a demuxer is not supposed to generate 0-sized packets. Or do you
> think otherwise?

Is it not possible to use zero-sized packets to clear the screen (i.e.
convey the end timestamp of subtitles transmitted earlier)? (The
subtitle formats without duration currently use packets with a size > 0
for that, but there is no real reason why this need to be so.)
Another reason for zero-sized packets were side-data only packets (maybe
not now, but it might be used in the future; after all, we are
constantly adding new side-data-types).

(This does not mean that I am against your proposed patch.)

- Andreas

PS: The fact that the parsing API is based upon buffers and not
AVPackets btw leads to buggy side-data handling: If a parser introduces
delay, then the side-data will not be attached to the correct packet,
but to the preceding one.
___
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 5.1

2022-06-19 Thread Neal Gompa
On Sun, Jun 19, 2022 at 4:59 PM Marton Balint  wrote:
>
>
>
> On Thu, 9 Jun 2022, Neal Gompa wrote:
>
> > On Tue, Jun 7, 2022 at 7:35 AM Michael Niedermayer
> >  wrote:
> >>
> >> Hi all
> >>
> >> As was discussed previously the 5.1 release should be in june/july
> >> That means in the next weeks probably!
> >> If you know of any regressions, security issues or other major bugs,
> >> please help fixing them
> >>
> >> Also as was suggested before, this release will get the "LTS" tag
> >> unless people feel thats a bad idea of course
> >>
> >
> > There were a few fixes we have in Fedora on top of 5.0 that would be
> > nice to have in upstream 5.1:
> >
> > * http://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/292877.html
> > * http://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/292853.html
> > * http://ffmpeg.org/pipermail/ffmpeg-devel/2022-February/293194.html
> >
> > Would it be possible to make sure these are in?
> >
>
> These are already merged, except the last patch, which needs some further
> explanaition if this is cosmetic change or actually changes some behaviour
> (other than the possible user facing error message)

It basically just changes the user facing error message to clients
that interpret the errors to something that makes sense.



-- 
真実はいつも一つ!/ Always, there's only one truth!
___
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 5/5] libavfilter/vf_frei0r.c: Use UTF-8 version of getenv()

2022-06-19 Thread Andreas Rheinhardt
From: Nil Admirari 

---
This version has the advantage that duplicating the string
is checked and that av_strdup(NULL) (whose behaviour is undocumented)
is avoided.

Here is a branch complete with these changes:
https://github.com/mkver/FFmpeg/commits/getenv
The Windows version has not been tested.

 libavfilter/vf_frei0r.c | 20 
 libavutil/getenv_utf8.h | 12 
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index f11ae6e55c..46b4175ba2 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -31,6 +31,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/common.h"
 #include "libavutil/eval.h"
+#include "libavutil/getenv_utf8.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
@@ -204,13 +205,19 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 }
 
 /* see: http://frei0r.dyne.org/codedoc/html/group__pluglocations.html */
-if ((path = av_strdup(getenv("FREI0R_PATH" {
+path = getenv_utf8("FREI0R_PATH");
+if (path) {
 #ifdef _WIN32
 const char *separator = ";";
 #else
 const char *separator = ":";
 #endif
 char *p, *ptr = NULL;
+
+path = getenv_make_writable(path);
+if (!path)
+return AVERROR(ENOMEM);
+
 for (p = path; p = av_strtok(p, separator, &ptr); p = NULL) {
 /* add additional trailing slash in case it is missing */
 char *p1 = av_asprintf("%s/", p);
@@ -231,12 +238,17 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
 if (ret < 0)
 return ret;
 }
-if (!s->dl_handle && (path = getenv("HOME"))) {
+if (!s->dl_handle && (path = getenv_utf8("HOME"))) {
 char *prefix = av_asprintf("%s/.frei0r-1/lib/", path);
-if (!prefix)
-return AVERROR(ENOMEM);
+if (!prefix) {
+ret = AVERROR(ENOMEM);
+goto home_path_end;
+}
 ret = load_path(ctx, &s->dl_handle, prefix, dl_name);
 av_free(prefix);
+
+home_path_end:
+freeenv_utf8(path);
 if (ret < 0)
 return ret;
 }
diff --git a/libavutil/getenv_utf8.h b/libavutil/getenv_utf8.h
index 03d108eed4..37a778b7aa 100644
--- a/libavutil/getenv_utf8.h
+++ b/libavutil/getenv_utf8.h
@@ -59,6 +59,11 @@ static inline void freeenv_utf8(char *var)
 av_free(var);
 }
 
+static inline char *getenv_make_writable(char *var)
+{
+return var;
+}
+
 #else
 
 static inline char *getenv_utf8(const char *varname)
@@ -70,6 +75,11 @@ static inline void freeenv_utf8(char *var)
 {
 }
 
+static inline char *getenv_make_writable(const char *var)
+{
+return av_strdup(var);
+}
+
 #endif // _WIN32
 
 #else
@@ -78,6 +88,8 @@ static inline void freeenv_utf8(char *var)
 
 #define freeenv_utf8(x) ((void) 0)
 
+#define getenv_make_writable(x) NULL
+
 #endif // HAVE_GETENV
 
 #endif // AVUTIL_GETENV_UTF8_H
-- 
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 v17 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi() and getenv_utf8()

2022-06-19 Thread Andreas Rheinhardt
nil-admir...@mailo.com:
>> This forces allocations and frees in scenarios where this is wholly
>> unnecessary. This can be avoided by adding a custom deallocator for
>> strings returned via getenv_utf8: Namely a define/wrapper around av_free
>> in the _WIN32 and a no-op else.
> 
> Done: https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297804.html
> 

Thanks for this.

> Note, however, that the introduction of freeenv_utf8()
> doubles allocations and deallocations in vf_frei0r.c on Windows:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2022-June/297802.html
> 
> These additional memory operations can be avoided only with a whole bunch
> of new #ifdef _WIN32 and #if HAVE_GETENV, which haven't been done.
> 

Or any reuses the #ifs from getenv_utf8.h.
https://github.com/mkver/FFmpeg/commits/getenv contains a version that
does this.

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