[FFmpeg-devel] [PATCH v3] wmavoice: convert DCT-I/DST-I to lavu/tx

2023-08-31 Thread Lynne
Added a patch to fix scaling of R2R transforms and
improved table generation precision slightly.

Planning to push this at the end of today, as it has been
on the mailing list for over a month with two LGTMs.

>From 145b5ca2be45e07fe16b700aa2b42cbeaa6d1a28 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Thu, 3 Aug 2023 18:21:23 +0200
Subject: [PATCH 01/11] lavu/tx: add real to real and real to imaginary RDFT
 transforms

These are in-place transforms, required for DCT-I and DST-I.

Templated as the mod2 variant requires minor modifications, and is
required specifically for DCT-I/DST-I.
---
 doc/APIchanges  |   3 +
 libavutil/tx.c  |  18 -
 libavutil/tx.h  |  10 +++
 libavutil/tx_template.c | 175 +++-
 libavutil/version.h |   2 +-
 5 files changed, 167 insertions(+), 41 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ad1efe708d..db3242b667 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-07-xx - xx - lavu 58.18.100 - tx.h
+  Add AV_TX_REAL_TO_REAL and AV_TX_REAL_TO_IMAGINARY
+
 2023-08-18 - xx - lavu 58.17.100 - channel_layout.h
   All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
 
diff --git a/libavutil/tx.c b/libavutil/tx.c
index e25abf998f..e9826e6107 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -437,7 +437,9 @@ int ff_tx_decompose_length(int dst[TX_MAX_DECOMPOSITIONS], enum AVTXType type,
 
 /* Check direction for non-orthogonal codelets */
 if (((cd->flags & FF_TX_FORWARD_ONLY) && inv) ||
-((cd->flags & (FF_TX_INVERSE_ONLY | AV_TX_FULL_IMDCT)) && !inv))
+((cd->flags & (FF_TX_INVERSE_ONLY | AV_TX_FULL_IMDCT)) && !inv) ||
+((cd->flags & (FF_TX_FORWARD_ONLY | AV_TX_REAL_TO_REAL)) && inv) ||
+((cd->flags & (FF_TX_FORWARD_ONLY | AV_TX_REAL_TO_IMAGINARY)) && inv))
 continue;
 
 /* Check if the CPU supports the required ISA */
@@ -560,6 +562,10 @@ static void print_flags(AVBPrint *bp, uint64_t f)
 av_bprintf(bp, "%spreshuf", prev > 1 ? sep : "");
 if ((f & AV_TX_FULL_IMDCT) && ++prev)
 av_bprintf(bp, "%simdct_full", prev > 1 ? sep : "");
+if ((f & AV_TX_REAL_TO_REAL) && ++prev)
+av_bprintf(bp, "%sreal_to_real", prev > 1 ? sep : "");
+if ((f & AV_TX_REAL_TO_IMAGINARY) && ++prev)
+av_bprintf(bp, "%sreal_to_imaginary", prev > 1 ? sep : "");
 if ((f & FF_TX_ASM_CALL) && ++prev)
 av_bprintf(bp, "%sasm_call", prev > 1 ? sep : "");
 av_bprintf(bp, "]");
@@ -717,7 +723,11 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type,
 uint64_t req_flags = flags;
 
 /* Flags the codelet may require to be present */
-uint64_t inv_req_mask = AV_TX_FULL_IMDCT | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL;
+uint64_t inv_req_mask = AV_TX_FULL_IMDCT |
+AV_TX_REAL_TO_REAL |
+AV_TX_REAL_TO_IMAGINARY |
+FF_TX_PRESHUFFLE |
+FF_TX_ASM_CALL;
 
 /* Unaligned codelets are compatible with the aligned flag */
 if (req_flags & FF_TX_ALIGNED)
@@ -742,7 +752,9 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type,
 
 /* Check direction for non-orthogonal codelets */
 if (((cd->flags & FF_TX_FORWARD_ONLY) && inv) ||
-((cd->flags & (FF_TX_INVERSE_ONLY | AV_TX_FULL_IMDCT)) && !inv))
+((cd->flags & (FF_TX_INVERSE_ONLY | AV_TX_FULL_IMDCT)) && !inv) ||
+((cd->flags & (FF_TX_FORWARD_ONLY | AV_TX_REAL_TO_REAL)) && inv) ||
+((cd->flags & (FF_TX_FORWARD_ONLY | AV_TX_REAL_TO_IMAGINARY)) && inv))
 continue;
 
 /* Check if the requested flags match from both sides */
diff --git a/libavutil/tx.h b/libavutil/tx.h
index 064edbc097..d178e8ee9d 100644
--- a/libavutil/tx.h
+++ b/libavutil/tx.h
@@ -149,6 +149,16 @@ enum AVTXFlags {
  * Ignored for all transforms but inverse MDCTs.
  */
 AV_TX_FULL_IMDCT = 1ULL << 2,
+
+/**
+ * Perform a real to half-complex RDFT.
+ * Only the real, or imaginary coefficients will
+ * be output, depending on the flag used. Only available for forward RDFTs.
+ * Output array must have enough space to hold N complex values
+ * (regular size for a real to complex transform).
+ */
+AV_TX_REAL_TO_REAL  = 1ULL << 3,
+AV_TX_REAL_TO_IMAGINARY = 1ULL << 4,
 };
 
 /**
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index c4ec9502e0..c56dcf0826 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -1613,14 +1613,17 @@ static av_cold int TX_NAME(ff_tx_rdft_init)(AVTXContext *s,
 int ret;
 double f, m;
 TXSample *tab;
+int len4 = FFALIGN(len, 4) / 4;
 
 s->scale_d 

Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable low-latency mode for HEVC

2023-08-31 Thread Richard Kern


> On Sep 1, 2023, at 12:07 AM, myp...@gmail.com wrote:
> 
> On Fri, Sep 1, 2023 at 11:50 AM "zhilizhao(赵志立)"  
> wrote:
>> 
>> 
>> 
 On Sep 1, 2023, at 09:13, myp...@gmail.com wrote:
>>> 
>>> On Fri, Sep 1, 2023 at 2:13 AM Zhao Zhili  wrote:
 
 
> From: ffmpeg-devel  On Behalf Of Jun Zhao
> Sent: 2023年8月31日 22:50
> To: ffmpeg-devel@ffmpeg.org
> Cc: Jun Zhao ; Jun Zhao 
> Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable 
> low-latency mode for HEVC
> 
> Enable the HEVC encoder that supports low-latency mode.
> 
> Signed-off-by: Jun Zhao 
> ---
> libavcodec/videotoolboxenc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 8e493c4f7a..bfc03787a0 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -1568,7 +1568,8 @@ static int vtenc_configure_encoder(AVCodecContext 
> *avctx)
> #endif
> 
>// low-latency mode: eliminate frame reordering, follow a 
> one-in-one-out encoding mode
> -if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
> AV_CODEC_ID_H264) {
> +if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
> +(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
> AV_CODEC_ID_HEVC)) {
 
 How about just remove the codec_id check?
 Is there any unwelcome side effects for encoders other than H264/HEVC?
>>> 
>>> 1. One reason is that there are now other encoders available, such as
>>> prores_videotoolbox.
>>> 
>>> 2. It may be more appropriate to use a strictly qualified check
>>> instead of an open condition.
>> 
>> Both HEVC and ProRes failed with low_latency on my machine (with or without 
>> -allow_sw 1)
>> 
>> [hevc_videotoolbox @ 0x6192a380] Error: cannot create compression 
>> session: -12902
>> [prores_videotoolbox @ 0x6192a380] Error: cannot create compression 
>> session: -12902
>> 
>>kVTParameterErr = 
>> -12902,
>> 
> I think you missed the other options, low delay in VT encoder need to
> co-work with some other options
> 
>> 1. FFmpeg users should have an idea whether or not to set 
>> AV_CODEC_FLAG_LOW_DELAY.
>> AV_CODEC_FLAG_LOW_DELAY doesn’t make sense for ProRes, but if user wants to 
>> try, let he/she
>> do.
>> 
>> 2. I can’t find API to query the capability. Only VideoToolBox framework 
>> itself know how
>> to handle the argument. There isn’t much protect to provide for users.
>> 
> Yes, now FFmpeg VT encoder didn't used the capability query, I think
> need to used the some API VTCopySupportedPropertyDictionaryForEncoder
> for capability query, this my next step
That’s a good idea. We don’t have to worry about codec checks or unexpected 
failures if the HEVC encoder on some devices doesn’t support it. Ideally we can 
print out a warn message and ignore the low-delay flag. 

>> Even with H.264, the results is unexpected: the input framerate is 25 but 
>> the output
>> framerate is 5, it dropped 80 percent frames silently.
>> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable low-latency mode for HEVC

2023-08-31 Thread myp...@gmail.com
On Fri, Sep 1, 2023 at 11:50 AM "zhilizhao(赵志立)"  wrote:
>
>
>
> > On Sep 1, 2023, at 09:13, myp...@gmail.com wrote:
> >
> > On Fri, Sep 1, 2023 at 2:13 AM Zhao Zhili  wrote:
> >>
> >>
> >>> From: ffmpeg-devel  On Behalf Of Jun Zhao
> >>> Sent: 2023年8月31日 22:50
> >>> To: ffmpeg-devel@ffmpeg.org
> >>> Cc: Jun Zhao ; Jun Zhao 
> >>> Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable 
> >>> low-latency mode for HEVC
> >>>
> >>> Enable the HEVC encoder that supports low-latency mode.
> >>>
> >>> Signed-off-by: Jun Zhao 
> >>> ---
> >>> libavcodec/videotoolboxenc.c | 3 ++-
> >>> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> >>> index 8e493c4f7a..bfc03787a0 100644
> >>> --- a/libavcodec/videotoolboxenc.c
> >>> +++ b/libavcodec/videotoolboxenc.c
> >>> @@ -1568,7 +1568,8 @@ static int vtenc_configure_encoder(AVCodecContext 
> >>> *avctx)
> >>> #endif
> >>>
> >>> // low-latency mode: eliminate frame reordering, follow a 
> >>> one-in-one-out encoding mode
> >>> -if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
> >>> AV_CODEC_ID_H264) {
> >>> +if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
> >>> +(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
> >>> AV_CODEC_ID_HEVC)) {
> >>
> >> How about just remove the codec_id check?
> >> Is there any unwelcome side effects for encoders other than H264/HEVC?
> >
> > 1. One reason is that there are now other encoders available, such as
> > prores_videotoolbox.
> >
> > 2. It may be more appropriate to use a strictly qualified check
> > instead of an open condition.
>
> Both HEVC and ProRes failed with low_latency on my machine (with or without 
> -allow_sw 1)
>
> [hevc_videotoolbox @ 0x6192a380] Error: cannot create compression 
> session: -12902
> [prores_videotoolbox @ 0x6192a380] Error: cannot create compression 
> session: -12902
>
> kVTParameterErr = 
> -12902,
>
I think you missed the other options, low delay in VT encoder need to
co-work with some other options

> 1. FFmpeg users should have an idea whether or not to set 
> AV_CODEC_FLAG_LOW_DELAY.
> AV_CODEC_FLAG_LOW_DELAY doesn’t make sense for ProRes, but if user wants to 
> try, let he/she
> do.
>
> 2. I can’t find API to query the capability. Only VideoToolBox framework 
> itself know how
> to handle the argument. There isn’t much protect to provide for users.
>
Yes, now FFmpeg VT encoder didn't used the capability query, I think
need to used the some API VTCopySupportedPropertyDictionaryForEncoder
for capability query, this my next step
> Even with H.264, the results is unexpected: the input framerate is 25 but the 
> output
> framerate is 5, it dropped 80 percent frames silently.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable low-latency mode for HEVC

2023-08-31 Thread zhilizhao(赵志立)


> On Sep 1, 2023, at 09:13, myp...@gmail.com wrote:
> 
> On Fri, Sep 1, 2023 at 2:13 AM Zhao Zhili  wrote:
>> 
>> 
>>> From: ffmpeg-devel  On Behalf Of Jun Zhao
>>> Sent: 2023年8月31日 22:50
>>> To: ffmpeg-devel@ffmpeg.org
>>> Cc: Jun Zhao ; Jun Zhao 
>>> Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable 
>>> low-latency mode for HEVC
>>> 
>>> Enable the HEVC encoder that supports low-latency mode.
>>> 
>>> Signed-off-by: Jun Zhao 
>>> ---
>>> libavcodec/videotoolboxenc.c | 3 ++-
>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>>> index 8e493c4f7a..bfc03787a0 100644
>>> --- a/libavcodec/videotoolboxenc.c
>>> +++ b/libavcodec/videotoolboxenc.c
>>> @@ -1568,7 +1568,8 @@ static int vtenc_configure_encoder(AVCodecContext 
>>> *avctx)
>>> #endif
>>> 
>>> // low-latency mode: eliminate frame reordering, follow a 
>>> one-in-one-out encoding mode
>>> -if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
>>> AV_CODEC_ID_H264) {
>>> +if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
>>> +(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
>>> AV_CODEC_ID_HEVC)) {
>> 
>> How about just remove the codec_id check?
>> Is there any unwelcome side effects for encoders other than H264/HEVC?
> 
> 1. One reason is that there are now other encoders available, such as
> prores_videotoolbox.
> 
> 2. It may be more appropriate to use a strictly qualified check
> instead of an open condition.

Both HEVC and ProRes failed with low_latency on my machine (with or without 
-allow_sw 1)

[hevc_videotoolbox @ 0x6192a380] Error: cannot create compression session: 
-12902
[prores_videotoolbox @ 0x6192a380] Error: cannot create compression 
session: -12902

kVTParameterErr = 
-12902,

1. FFmpeg users should have an idea whether or not to set 
AV_CODEC_FLAG_LOW_DELAY.
AV_CODEC_FLAG_LOW_DELAY doesn’t make sense for ProRes, but if user wants to 
try, let he/she
do.

2. I can’t find API to query the capability. Only VideoToolBox framework itself 
know how
to handle the argument. There isn’t much protect to provide for users.

Even with H.264, the results is unexpected: the input framerate is 25 but the 
output
framerate is 5, it dropped 80 percent frames silently.

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


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

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable low-latency mode for HEVC

2023-08-31 Thread myp...@gmail.com
On Fri, Sep 1, 2023 at 2:13 AM Zhao Zhili  wrote:
>
>
> > From: ffmpeg-devel  On Behalf Of Jun Zhao
> > Sent: 2023年8月31日 22:50
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Jun Zhao ; Jun Zhao 
> > Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable 
> > low-latency mode for HEVC
> >
> > Enable the HEVC encoder that supports low-latency mode.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  libavcodec/videotoolboxenc.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> > index 8e493c4f7a..bfc03787a0 100644
> > --- a/libavcodec/videotoolboxenc.c
> > +++ b/libavcodec/videotoolboxenc.c
> > @@ -1568,7 +1568,8 @@ static int vtenc_configure_encoder(AVCodecContext 
> > *avctx)
> >  #endif
> >
> >  // low-latency mode: eliminate frame reordering, follow a 
> > one-in-one-out encoding mode
> > -if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
> > AV_CODEC_ID_H264) {
> > +if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
> > +(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
> > AV_CODEC_ID_HEVC)) {
>
> How about just remove the codec_id check?
> Is there any unwelcome side effects for encoders other than H264/HEVC?

1. One reason is that there are now other encoders available, such as
prores_videotoolbox.

2. It may be more appropriate to use a strictly qualified check
instead of an open condition.
___
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/matroska(dec|enc): Rename macro to avoid clash with winbase.h

2023-08-31 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> winbase.h defines IGNORE and is included via bzlib.h when compiling
> for Windows. So rename this macro to NOTHING.
> Also rename the muxer macro for consistency.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/matroskadec.c | 4 ++--
>  libavformat/matroskaenc.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 21f52ccab2..fda77b0b89 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -2171,8 +2171,8 @@ static int mkv_stereo3d_conv(AVStream *st, 
> MatroskaVideoStereoModeType stereo_mo
>  } stereo_mode_conv [] = {
>  #define STEREO_MODE_CONV(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, 
> WEBM) \
>  [(STEREOMODETYPE)] = { .type = (STEREO3DTYPE), .flags = (FLAGS) },
> -#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
> -STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, IGNORE)
> +#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
> +STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, NOTHING)
>  };
>  AVStereo3D *stereo;
>  int ret;
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index d26c0fa059..bf2ca7106b 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -1633,9 +1633,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
> EbmlWriter *writer,
>   * values to be in the range 0..254. */
>  #define STEREOMODE(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
>  [(STEREO3DTYPE)][!!((FLAGS) & AV_STEREO3D_FLAG_INVERT)] = 
> (STEREOMODETYPE) + 1,
> -#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
> +#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
>  static const unsigned char conversion_table[][2] = {
> -STEREOMODE_STEREO3D_MAPPING(STEREOMODE, IGNORE)
> +STEREOMODE_STEREO3D_MAPPING(STEREOMODE, NOTHING)
>  };
>  int fmt;
>  

Will apply.

- 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] avformat/internal: Don't auto-include os_support.h

2023-08-31 Thread Andreas Rheinhardt
Martin Storsjö:
> On Thu, 31 Aug 2023, Andreas Rheinhardt wrote:
> 
>> It includes various Windows-specific headers when compiling
>> for Windows and these sometimes cause issues: E.g. winbase.h
>> defines IGNORE, which clashes with a macro used in the Matroska
>> muxer (since 884653ee5be03ed38db957c14fad51b300611c8c) and demuxer.
>>
>> This header provides fallback defines for various stuff that is
>> mostly not used directly by (de)muxers at all:
>> mkdir, rename, rmdir, unlink, access, poll, pollfd, nfds_t,
>> closesocket, socklen_t, fstat, stat, lseek, SHUT_(RD|WR|RDWR)
>> and various POLL* constants.
>>
>> Ergo fix this issue by not auto-including this header in lots
>> of places via an inclusion in internal.h and instead include
>> it everywhere where the above stuff is used (most of these
>> translation units already included os_support.h).
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> libavformat/img2dec.c  | 1 +
>> libavformat/internal.h | 1 -
>> libavformat/rtsp.h | 1 +
>> libavformat/utils.c    | 1 +
>> 4 files changed, 3 insertions(+), 1 deletion(-)
> 
> Ok with me, if you did a reasonable effort to check that this covers all
> the cases of the redirected functions. Spreading those includes
> everywhere isn't very nice indeed.
> 

I used
'\b(mkdir|rename|rmdir|unlink|access|poll|pollfd|nfds_t|closesocket|socklen_t|fstat|stat|lseek|SHUT_(RD|WR|RDWR)|POLL(IN|OUT|RDNORM|WRNORM|RDBAND|WRBAND|PRI|ERR|HUP|NVAL))\b'

(Also note that internal.h is not included everywhere.)

> This increases the risk of accidentally adding new uses of these
> functions without picking up the redirects, but I guess that's manageable.
> 

It also reduces the risk of accidentally causing macro conflicts like
with IGNORE.

- 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 14/14] avutil/internal: Don't auto-include emms.h

2023-08-31 Thread Andreas Rheinhardt
Instead include emms.h wherever it is needed.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3enc.c |  1 +
 libavcodec/avcodec.c|  1 +
 libavcodec/bink.c   |  1 +
 libavcodec/cavsdec.c|  1 +
 libavcodec/dca_core.c   |  1 +
 libavcodec/decode.c |  1 +
 libavcodec/dvdec.c  |  1 +
 libavcodec/dvenc.c  |  1 +
 libavcodec/encode.c |  1 +
 libavcodec/faandct.c|  1 +
 libavcodec/faanidct.c   |  1 +
 libavcodec/h264_picture.c   |  1 +
 libavcodec/h264dec.c|  1 +
 libavcodec/huffyuvdec.c |  1 +
 libavcodec/huffyuvenc.c |  1 +
 libavcodec/mjpegdec.c   |  1 +
 libavcodec/mpeg12dec.c  |  1 +
 libavcodec/mpegutils.c  |  1 +
 libavcodec/mpegvideo_dec.c  |  1 +
 libavcodec/mpegvideo_enc.c  |  1 +
 libavcodec/ratecontrol.c|  1 +
 libavcodec/sbcenc.c |  1 +
 libavcodec/snowdec.c|  1 +
 libavcodec/snowenc.c|  1 +
 libavcodec/svq1enc.c|  1 +
 libavcodec/tests/dct.c  |  1 +
 libavcodec/tests/motion.c   |  1 +
 libavcodec/vp3.c|  1 +
 libavfilter/vf_deshake.c|  1 +
 libavfilter/vf_fspp.c   |  1 +
 libavfilter/vf_gradfun.c|  1 +
 libavfilter/vf_hqdn3d.c |  1 +
 libavfilter/vf_mpdecimate.c |  1 +
 libavfilter/vf_noise.c  |  1 +
 libavfilter/vf_pp7.c|  1 +
 libavfilter/vf_pullup.c |  1 +
 libavfilter/vf_spp.c|  1 +
 libavutil/{x86 => }/emms.h  | 14 +++---
 libavutil/internal.h|  8 
 libswscale/swscale.c|  1 +
 libswscale/utils.c  |  1 +
 tests/checkasm/checkasm.h   |  1 +
 tests/checkasm/vp9dsp.c |  1 +
 43 files changed, 52 insertions(+), 11 deletions(-)
 rename libavutil/{x86 => }/emms.h (91%)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 3cb4e5f029..56c8d239c5 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -33,6 +33,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
+#include "libavutil/emms.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 0700a53b5c..131834b6de 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -28,6 +28,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/emms.h"
 #include "libavutil/fifo.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index e3822d689c..8d96dee705 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -21,6 +21,7 @@
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/emms.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 37071dfbc7..b356da0b04 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -26,6 +26,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/emms.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "golomb.h"
diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index c50d005a56..ff3cc2fe45 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -19,6 +19,7 @@
  */
 
 #include "libavutil/channel_layout.h"
+#include "libavutil/emms.h"
 #include "dcaadpcm.h"
 #include "dcadec.h"
 #include "dcadata.h"
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 7eada8e9ab..169ee79acd 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -32,6 +32,7 @@
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
+#include "libavutil/emms.h"
 #include "libavutil/fifo.h"
 #include "libavutil/frame.h"
 #include "libavutil/hwcontext.h"
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index c57578a208..04282483f4 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -36,6 +36,7 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/emms.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 7bd50174b7..ce21247081 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -29,6 +29,7 @@
 #include "config.h"
 
 #include "libavutil/attributes.h"
+#include "libavutil/emms.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 32cc903b1f..b92593770c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -21,6 +21,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/emms.h"
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
index 38c392bbae..b0b11859a7 100644

[FFmpeg-devel] [PATCH 06/13] avfilter/af_volume: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
The floating point dsp code does not use MMX registers
since 2718a3be1f8867fd4f6cb3f452d6917838b1ed88.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_volume.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 926529947c..b41c15e867 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -447,8 +447,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 
-emms_c();
-
 if (buf != out_buf)
 av_frame_free(&buf);
 
-- 
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 10/13] avcodec/pcm: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
The floating point dsp code does not use MMX registers
since 2718a3be1f8867fd4f6cb3f452d6917838b1ed88.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/pcm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 467ecb4fe0..4abca7cc07 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -538,7 +538,6 @@ static int pcm_decode_frame(AVCodecContext *avctx, AVFrame 
*frame,
 s->vector_fmul_scalar((float *)frame->extended_data[0],
   (const float *)frame->extended_data[0],
   s->scale, FFALIGN(frame->nb_samples * 
avctx->ch_layout.nb_channels, 4));
-emms_c();
 }
 
 *got_frame_ptr = 1;
-- 
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 09/13] avfilter/af_amultiply: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
The floating point dsp code does not use MMX registers
since 2718a3be1f8867fd4f6cb3f452d6917838b1ed88.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_amultiply.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/af_amultiply.c b/libavfilter/af_amultiply.c
index 3d8782002b..0e2bdacd8f 100644
--- a/libavfilter/af_amultiply.c
+++ b/libavfilter/af_amultiply.c
@@ -90,7 +90,6 @@ static int activate(AVFilterContext *ctx)
  plane_samples);
 }
 }
-emms_c();
 
 av_frame_free(&s->frames[0]);
 av_frame_free(&s->frames[1]);
-- 
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 08/13] avfilter/af_headphone: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
The floating point dsp code does not use MMX registers
since 2718a3be1f8867fd4f6cb3f452d6917838b1ed88.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_headphone.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
index c8f753387f..7651ead731 100644
--- a/libavfilter/af_headphone.c
+++ b/libavfilter/af_headphone.c
@@ -359,7 +359,6 @@ static int headphone_frame(HeadphoneContext *s, AVFrame 
*in, AVFilterLink *outli
 } else {
 ff_filter_execute(ctx, headphone_fast_convolute, &td, NULL, 2);
 }
-emms_c();
 
 if (n_clippings[0] + n_clippings[1] > 0) {
 av_log(ctx, AV_LOG_WARNING, "%d of %d samples clipped. Please reduce 
gain.\n",
-- 
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 07/13] avfilter/af_sofalizer: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
The floating point dsp code does not use MMX registers
since 2718a3be1f8867fd4f6cb3f452d6917838b1ed88.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_sofalizer.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c
index 60e0da30e9..5c2f34aa42 100644
--- a/libavfilter/af_sofalizer.c
+++ b/libavfilter/af_sofalizer.c
@@ -598,7 +598,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 } else if (s->type == FREQUENCY_DOMAIN) {
 ff_filter_execute(ctx, sofalizer_fast_convolute, &td, NULL, 2);
 }
-emms_c();
 
 /* display error message if clipping occurred */
 if (n_clippings[0] + n_clippings[1] > 0) {
-- 
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 13/13] tests/checkasm/sw_scale: Avoid declare_func_emms where possible

2023-08-31 Thread Andreas Rheinhardt
This makes the test stricter because it is checked that the
MMX registers are not accidentally clobbered.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/sw_scale.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index 3b8dd310ec..1305b38744 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -110,9 +110,9 @@ static void check_yuv2yuv1(int accurate)
 const int OFFSET_SIZES = sizeof(offsets)/sizeof(offsets[0]);
 const char *accurate_str = (accurate) ? "accurate" : "approximate";
 
-declare_func_emms(AV_CPU_FLAG_MMX, void,
-  const int16_t *src, uint8_t *dest,
-  int dstW, const uint8_t *dither, int offset);
+declare_func(void,
+ const int16_t *src, uint8_t *dest,
+ int dstW, const uint8_t *dither, int offset);
 
 LOCAL_ALIGNED_16(int16_t, src_pixels, [LARGEST_INPUT_SIZE]);
 LOCAL_ALIGNED_16(uint8_t, dst0, [LARGEST_INPUT_SIZE]);
@@ -288,9 +288,9 @@ static void check_hscale(void)
 
 // The dst parameter here is either int16_t or int32_t but we use void* to
 // just cover both cases.
-declare_func_emms(AV_CPU_FLAG_MMX, void, void *c, void *dst, int dstW,
-  const uint8_t *src, const int16_t *filter,
-  const int32_t *filterPos, int filterSize);
+declare_func(void, void *c, void *dst, int dstW,
+ const uint8_t *src, const int16_t *filter,
+ const int32_t *filterPos, int filterSize);
 
 ctx = sws_alloc_context();
 if (sws_init_context(ctx, NULL, NULL) < 0)
-- 
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 05/13] avfilter/afir_template: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
The floating point dsp code does not use MMX registers
since 2718a3be1f8867fd4f6cb3f452d6917838b1ed88.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/afir_template.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/afir_template.c b/libavfilter/afir_template.c
index 099fda2520..9a11ec2fa6 100644
--- a/libavfilter/afir_template.c
+++ b/libavfilter/afir_template.c
@@ -318,7 +318,6 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame 
*out, int ch, int ioffs
 #else
 s->fdsp->vector_dmul_scalar(src + input_offset, in, dry_gain, 
FFALIGN(nb_samples, 8));
 #endif
-emms_c();
 } else {
 ftype *src2 = src + input_offset;
 for (int n = 0; n < nb_samples; n++)
@@ -385,7 +384,6 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame 
*out, int ch, int ioffs
 #else
 s->fdsp->vector_dmul_scalar(ptr, ptr, wet_gain, FFALIGN(nb_samples, 
8));
 #endif
-emms_c();
 } else {
 for (int n = 0; n < nb_samples; n++)
 ptr[n] *= wet_gain;
-- 
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 12/13] tests/checkasm/llvidencdsp: Don't use declare_func_emms

2023-08-31 Thread Andreas Rheinhardt
Only sub_media_pred has an MMXEXT version, so one can use
the version with the stricter check (that checks that
the MMX registers have not been clobbered) for sub_left_predict.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/llviddspenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/checkasm/llviddspenc.c b/tests/checkasm/llviddspenc.c
index e12003aeeb..c2eb63519f 100644
--- a/tests/checkasm/llviddspenc.c
+++ b/tests/checkasm/llviddspenc.c
@@ -81,8 +81,8 @@ static void check_sub_left_pred(LLVidEncDSPContext *c)
 LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE * MAX_HEIGHT]);
 LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE * MAX_HEIGHT]);
 
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src,
-  ptrdiff_t stride, ptrdiff_t width, int height);
+declare_func(void, uint8_t *dst, const uint8_t *src,
+ ptrdiff_t stride, ptrdiff_t width, int height);
 
 memset(dst0, 0, MAX_STRIDE * MAX_HEIGHT);
 memset(dst1, 0, MAX_STRIDE * MAX_HEIGHT);
-- 
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 11/13] tests/checkasm/hevc_*: Avoid using declare_func_emms where possible

2023-08-31 Thread Andreas Rheinhardt
Only the idct_dc and add_residual functions have MMX versions,
so one can use the version with the stricter check (that checks
that the MMX registers have not been clobbered) for all the other
checks.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/hevc_deblock.c |  2 +-
 tests/checkasm/hevc_idct.c|  2 +-
 tests/checkasm/hevc_pel.c | 52 +--
 tests/checkasm/hevc_sao.c |  8 +++---
 4 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/tests/checkasm/hevc_deblock.c b/tests/checkasm/hevc_deblock.c
index 5e4338af1c..66fc8d5646 100644
--- a/tests/checkasm/hevc_deblock.c
+++ b/tests/checkasm/hevc_deblock.c
@@ -55,7 +55,7 @@ static void check_deblock_chroma(HEVCDSPContext *h, int 
bit_depth)
 LOCAL_ALIGNED_32(uint8_t, buf0, [BUF_SIZE]);
 LOCAL_ALIGNED_32(uint8_t, buf1, [BUF_SIZE]);
 
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *pix, ptrdiff_t stride, 
int32_t *tc, uint8_t *no_p, uint8_t *no_q);
+declare_func(void, uint8_t *pix, ptrdiff_t stride, int32_t *tc, uint8_t 
*no_p, uint8_t *no_q);
 
 if (check_func(h->hevc_h_loop_filter_chroma, 
"hevc_h_loop_filter_chroma%d", bit_depth)) {
 for (int i = 0; i < 4; i++) {
diff --git a/tests/checkasm/hevc_idct.c b/tests/checkasm/hevc_idct.c
index 49cfc4801f..9da8b858a0 100644
--- a/tests/checkasm/hevc_idct.c
+++ b/tests/checkasm/hevc_idct.c
@@ -91,7 +91,7 @@ static void check_transform_luma(HEVCDSPContext *h, int 
bit_depth)
 
 int block_size = 4;
 int size = block_size * block_size;
-declare_func_emms(AV_CPU_FLAG_MMXEXT, void, int16_t *coeffs);
+declare_func(void, int16_t *coeffs);
 
 randomize_buffers(coeffs0, size);
 memcpy(coeffs1, coeffs0, sizeof(*coeffs0) * size);
diff --git a/tests/checkasm/hevc_pel.c b/tests/checkasm/hevc_pel.c
index 43aa5cd084..f9a7a7717c 100644
--- a/tests/checkasm/hevc_pel.c
+++ b/tests/checkasm/hevc_pel.c
@@ -79,8 +79,8 @@ static void checkasm_check_hevc_qpel(void)
 
 HEVCDSPContext h;
 int size, bit_depth, i, j, row;
-declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, int16_t 
*dst, uint8_t *src, ptrdiff_t srcstride,
-  int height, 
intptr_t mx, intptr_t my, int width);
+declare_func(void, int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
+ int height, intptr_t mx, intptr_t my, int width);
 
 for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
 ff_hevc_dsp_init(&h, bit_depth);
@@ -123,8 +123,8 @@ static void checkasm_check_hevc_qpel_uni(void)
 
 HEVCDSPContext h;
 int size, bit_depth, i, j;
-declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t 
*dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-  int height, 
intptr_t mx, intptr_t my, int width);
+declare_func(void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, 
ptrdiff_t srcstride,
+ int height, intptr_t mx, intptr_t my, int width);
 
 for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
 ff_hevc_dsp_init(&h, bit_depth);
@@ -165,8 +165,8 @@ static void checkasm_check_hevc_qpel_uni_w(void)
 HEVCDSPContext h;
 int size, bit_depth, i, j;
 const int *denom, *wx, *ox;
-declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t 
*dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-  int height, 
int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
+declare_func(void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, 
ptrdiff_t srcstride,
+ int height, int denom, int wx, int ox, intptr_t mx, intptr_t 
my, int width);
 
 for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
 ff_hevc_dsp_init(&h, bit_depth);
@@ -214,9 +214,9 @@ static void checkasm_check_hevc_qpel_bi(void)
 
 HEVCDSPContext h;
 int size, bit_depth, i, j;
-declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t 
*dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-  int16_t 
*src2,
-  int height, 
intptr_t mx, intptr_t my, int width);
+declare_func(void, uint8_t *dst, ptrdiff_t dststride, uint8_t *src, 
ptrdiff_t srcstride,
+ int16_t *src2,
+ int height, intptr_t mx, intptr_t my, int width);
 
 for (bit_depth = 8; bit_depth <= 12; bit_depth++) {
 ff_hevc_dsp_init(&h, bit_depth);
@@ -259,10 +259,10 @@ static void checkasm_check_hevc_qpel_bi_w(void)
 HEVCDSPContext h;
 int size, bit_depth, i, j;
 const int *denom, *wx, *ox;
-declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t 
*dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-  

[FFmpeg-devel] [PATCH 04/13] avfilter/vf_bwdif: Remove obsolete emms_c()

2023-08-31 Thread Andreas Rheinhardt
Obsolete since ed42a51930d9cca6dfed35c4af4b5b3a3f7f6a04.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_bwdif.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c
index 5f5f8e4610..6195e6cb64 100644
--- a/libavfilter/vf_bwdif.c
+++ b/libavfilter/vf_bwdif.c
@@ -319,8 +319,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic,
 if (yadif->current_field == YADIF_FIELD_END) {
 yadif->current_field = YADIF_FIELD_NORMAL;
 }
-
-emms_c();
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
-- 
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 03/13] avfilter/vf_colorspace: Remove redundant emms_c()

2023-08-31 Thread Andreas Rheinhardt
It is not even clear what these emms_c() are supposed to achieve:
create_filtergraph() (where it may be called) does not call
ASM functions itself; it merely sets some function pointers.
Furthermore, there are no colorspacedsp functions using MMX
(checked by checkasm which does not use declare_new_emms()).
Finally, checking whether to issue emms_c() is overblown anyway.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_colorspace.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 852dc11c6c..2a30434401 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -400,7 +400,7 @@ static int create_filtergraph(AVFilterContext *ctx,
 ColorSpaceContext *s = ctx->priv;
 const AVPixFmtDescriptor *in_desc  = av_pix_fmt_desc_get(in->format);
 const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(out->format);
-int emms = 0, m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv 
= 0;
+int m, n, o, res, fmt_identical, redo_yuv2rgb = 0, redo_rgb2yuv = 0;
 
 #define supported_depth(d) ((d) == 8 || (d) == 10 || (d) == 12)
 #define supported_subsampling(lcw, lch) \
@@ -494,7 +494,6 @@ static int create_filtergraph(AVFilterContext *ctx,
 s->lrgb2lrgb_coeffs[m][n][o] = 
s->lrgb2lrgb_coeffs[m][n][0];
 }
 
-emms = 1;
 }
 }
 
@@ -542,7 +541,6 @@ static int create_filtergraph(AVFilterContext *ctx,
 res = fill_gamma_table(s);
 if (res < 0)
 return res;
-emms = 1;
 }
 
 if (!s->in_lumacoef) {
@@ -625,7 +623,6 @@ static int create_filtergraph(AVFilterContext *ctx,
 av_assert2(s->yuv2rgb_coeffs[0][0][0] == 
s->yuv2rgb_coeffs[2][0][0]);
 s->yuv2rgb = s->dsp.yuv2rgb[(in_desc->comp[0].depth - 8) >> 1]
[in_desc->log2_chroma_h + 
in_desc->log2_chroma_w];
-emms = 1;
 }
 
 if (redo_rgb2yuv) {
@@ -656,7 +653,6 @@ static int create_filtergraph(AVFilterContext *ctx,
[out_desc->log2_chroma_h + 
out_desc->log2_chroma_w];
 s->rgb2yuv_fsb = s->dsp.rgb2yuv_fsb[(out_desc->comp[0].depth - 8) 
>> 1]
[out_desc->log2_chroma_h + 
out_desc->log2_chroma_w];
-emms = 1;
 }
 
 if (s->yuv2yuv_fastmode && (redo_yuv2rgb || redo_rgb2yuv)) {
@@ -683,9 +679,6 @@ static int create_filtergraph(AVFilterContext *ctx,
 }
 }
 
-if (emms)
-emms_c();
-
 return 0;
 }
 
-- 
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 02/13] avfilter/vf_gblur: Remove unnecessary emms_c()

2023-08-31 Thread Andreas Rheinhardt
There is no MMX ASM code for gblur.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_gblur.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index 6e8ef96235..6ce2c84736 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -73,7 +73,6 @@ static int filter_horizontally(AVFilterContext *ctx, void 
*arg, int jobnr, int n
 
 s->horiz_slice(buffer + width * slice_start, width, slice_end - 
slice_start,
steps, nu, boundaryscale, localbuf);
-emms_c();
 return 0;
 }
 
-- 
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 01/13] avfilter: Remove unnecessary emms_c for ff_scene_sad_get_fn

2023-08-31 Thread Andreas Rheinhardt
ff_scene_sad_get_fn() does not return functions that use
MMX at all.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/f_select.c| 1 -
 libavfilter/vf_framerate.c| 1 -
 libavfilter/vf_freezedetect.c | 1 -
 libavfilter/vf_minterpolate.c | 1 -
 libavfilter/vf_scdet.c| 1 -
 5 files changed, 5 deletions(-)

diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 49fcdc31ff..c9e216f51c 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -294,7 +294,6 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame 
*frame)
 count += select->width[plane] * select->height[plane];
 }
 
-emms_c();
 mafd = (double)sad / count / (1ULL << (select->bitdepth - 8));
 diff = fabs(mafd - select->prev_mafd);
 ret  = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 6ef5dca27a..6d448be74c 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -76,7 +76,6 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame 
*crnt, AVFrame *next
 
 ff_dlog(ctx, "get_scene_score() process\n");
 s->sad(crnt->data[0], crnt->linesize[0], next->data[0], 
next->linesize[0], crnt->width, crnt->height, &sad);
-emms_c();
 mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << 
s->bitdepth);
 diff = fabs(mafd - s->prev_mafd);
 ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
diff --git a/libavfilter/vf_freezedetect.c b/libavfilter/vf_freezedetect.c
index fb4e59b127..18d392d9ae 100644
--- a/libavfilter/vf_freezedetect.c
+++ b/libavfilter/vf_freezedetect.c
@@ -131,7 +131,6 @@ static int is_frozen(FreezeDetectContext *s, AVFrame 
*reference, AVFrame *frame)
 count += s->width[plane] * s->height[plane];
 }
 }
-emms_c();
 mafd = (double)sad / count / (1ULL << s->bitdepth);
 return (mafd <= s->noise);
 }
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index 610ac6b1bb..9920210ece 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -825,7 +825,6 @@ static int detect_scene_change(AVFilterContext *ctx)
 double ret = 0, mafd, diff;
 uint64_t sad;
 mi_ctx->sad(p1, linesize1, p2, linesize2, input->w, input->h, &sad);
-emms_c();
 mafd = (double) sad * 100.0 / (input->h * input->w) / (1 << 
mi_ctx->bitdepth);
 diff = fabs(mafd - mi_ctx->prev_mafd);
 ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
diff --git a/libavfilter/vf_scdet.c b/libavfilter/vf_scdet.c
index 6de84a43a0..15399cfebf 100644
--- a/libavfilter/vf_scdet.c
+++ b/libavfilter/vf_scdet.c
@@ -126,7 +126,6 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame 
*frame)
 count += s->width[plane] * s->height[plane];
 }
 
-emms_c();
 mafd = (double)sad * 100. / count / (1ULL << s->bitdepth);
 diff = fabs(mafd - s->prev_mafd);
 ret  = av_clipf(FFMIN(mafd, diff), 0, 100.);
-- 
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] avformat/internal: Don't auto-include os_support.h

2023-08-31 Thread Martin Storsjö

On Thu, 31 Aug 2023, Andreas Rheinhardt wrote:


It includes various Windows-specific headers when compiling
for Windows and these sometimes cause issues: E.g. winbase.h
defines IGNORE, which clashes with a macro used in the Matroska
muxer (since 884653ee5be03ed38db957c14fad51b300611c8c) and demuxer.

This header provides fallback defines for various stuff that is
mostly not used directly by (de)muxers at all:
mkdir, rename, rmdir, unlink, access, poll, pollfd, nfds_t,
closesocket, socklen_t, fstat, stat, lseek, SHUT_(RD|WR|RDWR)
and various POLL* constants.

Ergo fix this issue by not auto-including this header in lots
of places via an inclusion in internal.h and instead include
it everywhere where the above stuff is used (most of these
translation units already included os_support.h).

Signed-off-by: Andreas Rheinhardt 
---
libavformat/img2dec.c  | 1 +
libavformat/internal.h | 1 -
libavformat/rtsp.h | 1 +
libavformat/utils.c| 1 +
4 files changed, 3 insertions(+), 1 deletion(-)


Ok with me, if you did a reasonable effort to check that this covers all 
the cases of the redirected functions. Spreading those includes everywhere 
isn't very nice indeed.


This increases the risk of accidentally adding new uses of these functions 
without picking up the redirects, but I guess that's manageable.


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


[FFmpeg-devel] Working on an LTC source filter - can this be made seekable?

2023-08-31 Thread Johannes Maibaum

Hello,

as my first dive into the ffmpeg source, I am working on an 
Linear/Longitudinal Time Code (LTC) source filter for ffmpeg using 
https://github.com/x42/libltc here:


https://git.sr.ht/~jmaibaum/ffmpeg/log/ltc

The basics are working fine and turned out to be fairly easy to achieve, 
even though I am still missing essential features, major refactorings, 
and proper testing, before I would consider it ready for inclusion into 
ffmpeg. I am planning to get there eventually once my free time allows.


Yet, I am now facing an issue where I am unsure if the plan to add the 
ltcsrc as a libav source filter was correct in the first place?


One of the use-cases I have in mind for the ltcsrc filter involves 
having it generate an LTC signal while playing another audio or video 
file in sync, i.e. the LTC signal should of course always match the 
current position of the audio/video file's playback position. It should 
be possible to seek arbitrarily inside the video player, thus. the LTC 
timecode being generated after a seek event signal must always stay in 
sync to the new playback position of the audio/video file.


But apparently libav-filters are by design not supporting seek events at 
all though, at least not from ffplay, where running


ffplay -f lavfi -i ltcsrc

and then trying to seek results in "error while seeking". This error 
also happens with all other filters I tried using in the ffplay command 
line above. Similar quick checks trying to use the filter from within 
mpv resulted in an unseekable playback.


I can successfully send commands (via asendcmd) to change the timecode 
being generated on the fly, but this feels like a bad workaround for the 
use-case described above.


I took a brief look into other ffmpeg modules (codecs, formats, 
devices), but from my current understanding a (source) filter is the 
correct way to implement ltcsrc.


Thus, my question is: Can this use-case even be solved by implementing 
ltcsrc as a filter? If not, how can I implement an ltcsrc that can be 
used "like" a filter (i.e. supporting things like receiving commands to 
change other parameters on the fly) in my use-case, but also supporting 
seek events?



Cheers,
Johannes
___
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] avfilter: add libvmaf_cuda

2023-08-31 Thread Kyle Swanson
Hi,

On Wed, Aug 30, 2023 at 9:44 AM Kyle Swanson  wrote:
> Fixed in the attached patch.

Any other reviews, or is this one OK to merge now?

Thanks,
Kyle
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable low-latency mode for HEVC

2023-08-31 Thread Zhao Zhili

> From: ffmpeg-devel  On Behalf Of Jun Zhao
> Sent: 2023年8月31日 22:50
> To: ffmpeg-devel@ffmpeg.org
> Cc: Jun Zhao ; Jun Zhao 
> Subject: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: enable low-latency 
> mode for HEVC
> 
> Enable the HEVC encoder that supports low-latency mode.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/videotoolboxenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 8e493c4f7a..bfc03787a0 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -1568,7 +1568,8 @@ static int vtenc_configure_encoder(AVCodecContext 
> *avctx)
>  #endif
> 
>  // low-latency mode: eliminate frame reordering, follow a one-in-one-out 
> encoding mode
> -if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
> AV_CODEC_ID_H264) {
> +if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
> +(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
> AV_CODEC_ID_HEVC)) {

How about just remove the codec_id check?
Is there any unwelcome side effects for encoders other than H264/HEVC?

>  CFDictionarySetValue(enc_info,
>   
> compat_keys.kVTVideoEncoderSpecification_EnableLowLatencyRateControl,
>   kCFBooleanTrue);
> --
> 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] [PATCH] avformat/mov: add io_order option to disable demuxer level interleave

2023-08-31 Thread Zhao Zhili

> From: ffmpeg-devel  On Behalf Of Derek 
> Buitenhuis
> Sent: 2023年8月31日 23:59
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avformat/mov: add io_order option to 
> disable demuxer level interleave
> 
> On 8/28/2023 5:06 PM, Zhao Zhili wrote:
> > -if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && 
> > current_sample->pos < sample->pos) ||
> > +if (!sample || (force_io_order && current_sample->pos < 
> > sample->pos) ||
> 
> Hmm, I think the name `io_order` is a misnomer: It still will not, for 
> example,
> output packets in I/O order if the mdat has backwards packets (i.e. mdat 
> starts
> with the last packet, and ends with the first packet, which is very stupid, 
> but
> technically legal in ISOBMFF/QTFF).
> 
> Maybe something like `no_reinterleaving`? Naming is hard, and I am not much
> better at it.

It takes me more time to naming and write the doc than coding. The idea is 
plain and simple, but
hard to describe with a phrase.

Is `reinterleaving` a word? How about `interleave` or `interleaved_read` with 
default value to true?

> 
> - Derek
> ___
> 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] avformat/matroska(dec|enc): Rename macro to avoid clash with winbase.h

2023-08-31 Thread Andreas Rheinhardt
winbase.h defines IGNORE and is included via bzlib.h when compiling
for Windows. So rename this macro to NOTHING.
Also rename the muxer macro for consistency.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskadec.c | 4 ++--
 libavformat/matroskaenc.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 21f52ccab2..fda77b0b89 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2171,8 +2171,8 @@ static int mkv_stereo3d_conv(AVStream *st, 
MatroskaVideoStereoModeType stereo_mo
 } stereo_mode_conv [] = {
 #define STEREO_MODE_CONV(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, 
WEBM) \
 [(STEREOMODETYPE)] = { .type = (STEREO3DTYPE), .flags = (FLAGS) },
-#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
-STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, IGNORE)
+#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
+STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, NOTHING)
 };
 AVStereo3D *stereo;
 int ret;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index d26c0fa059..bf2ca7106b 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1633,9 +1633,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
EbmlWriter *writer,
  * values to be in the range 0..254. */
 #define STEREOMODE(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
 [(STEREO3DTYPE)][!!((FLAGS) & AV_STEREO3D_FLAG_INVERT)] = (STEREOMODETYPE) 
+ 1,
-#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
+#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
 static const unsigned char conversion_table[][2] = {
-STEREOMODE_STEREO3D_MAPPING(STEREOMODE, IGNORE)
+STEREOMODE_STEREO3D_MAPPING(STEREOMODE, NOTHING)
 };
 int fmt;
 
-- 
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] OSQ lossless audio format support

2023-08-31 Thread Paul B Mahol
Gonna push soon.
___
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] avformat/internal: Don't auto-include os_support.h

2023-08-31 Thread Andreas Rheinhardt
It includes various Windows-specific headers when compiling
for Windows and these sometimes cause issues: E.g. winbase.h
defines IGNORE, which clashes with a macro used in the Matroska
muxer (since 884653ee5be03ed38db957c14fad51b300611c8c) and demuxer.

This header provides fallback defines for various stuff that is
mostly not used directly by (de)muxers at all:
mkdir, rename, rmdir, unlink, access, poll, pollfd, nfds_t,
closesocket, socklen_t, fstat, stat, lseek, SHUT_(RD|WR|RDWR)
and various POLL* constants.

Ergo fix this issue by not auto-including this header in lots
of places via an inclusion in internal.h and instead include
it everywhere where the above stuff is used (most of these
translation units already included os_support.h).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/img2dec.c  | 1 +
 libavformat/internal.h | 1 -
 libavformat/rtsp.h | 1 +
 libavformat/utils.c| 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 15fd67927f..2761cb37a4 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -36,6 +36,7 @@
 #include "avio_internal.h"
 #include "internal.h"
 #include "img2.h"
+#include "os_support.h"
 #include "libavcodec/jpegxl_parse.h"
 #include "libavcodec/mjpeg.h"
 #include "libavcodec/vbn.h"
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 594afd731d..53e70ccb53 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -26,7 +26,6 @@
 #include "libavcodec/packet_internal.h"
 
 #include "avformat.h"
-#include "os_support.h"
 
 #define MAX_URL_SIZE 4096
 
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 6e500fd56a..83b2e3f4fb 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -28,6 +28,7 @@
 #include "network.h"
 #include "httpauth.h"
 #include "internal.h"
+#include "os_support.h"
 
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cf4d68bff9..c722743744 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -37,6 +37,7 @@
 #if CONFIG_NETWORK
 #include "network.h"
 #endif
+#include "os_support.h"
 
 static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER;
 
-- 
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] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-08-31 Thread Stefano Sabatini
On date Thursday 2023-08-31 18:51:52 +0200, Andreas Rheinhardt wrote:
> Stefano Sabatini:
> > +int sws_get_gaussian_vec(SwsVector **vecp,
> > + AVClass *log_ctx,
> > + double standard_deviation, double quality);
> >  
> 
> Seriously? A pointer to an AVClass as log_ctx? It is actually AVClass**
> (the logcontext must have a pointer to an AVClass as its first member),
> but we always use NULL.

Sorry, sloppy editing on my side.

> Apart from that: I am not really convinced that the improvement is worth
> the hassle.

This is not a high-profile function (probably it's never used outside
lavfi) and provides an opportunity to move the API to the correct
direction.
>From 69c33f62e15de3d199d54187d38c0856418f0981 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini 
Date: Sat, 26 Aug 2023 14:20:35 +0200
Subject: [PATCH 1/2] lsws/swscale.h: introduce sws_get_gaussian_vec

Use in place of sws_getGaussianVec.

The new function enable better error handling, and provide better naming
for the variance variable, now named standard_deviation to reflect the
meaning of the parameter.
---
 doc/APIchanges |  3 +++
 libswscale/swscale.h   | 27 +++-
 libswscale/utils.c | 42 ++
 libswscale/version.h   |  2 +-
 libswscale/version_major.h |  4 
 5 files changed, 67 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ad1efe708d..bad2d61027 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-08-26 - xx - lsws 7.4.100 - swscale.h
+  Introduce sws_get_gaussian_vec, use in place of sws_getGaussianVec.
+
 2023-08-18 - xx - lavu 58.17.100 - channel_layout.h
   All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
 
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 9d4612aaf3..55f2fc4a48 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -355,11 +355,36 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
  */
 SwsVector *sws_allocVec(int length);
 
+#if FF_API_SWS_GET_GAUSSIAN_VEC
 /**
- * Return a normalized Gaussian curve used to filter stuff
+ * Return a normalized Gaussian curve used to filter stuff.
+ *
  * quality = 3 is high quality, lower is lower quality.
+ * @deprecated use sws_get_gaussian_vector()
  */
+attribute_deprecated
 SwsVector *sws_getGaussianVec(double variance, double quality);
+#endif
+
+/**
+ * Compute and return a normalized Gaussian vector.
+ *
+ * @param vecp: pointer where the computed vector is put in case of
+ *success
+ * @param standard_deviation the standard deviation used to generate
+ *the Gaussian vector, must be a non-negative value
+ * @param quality the quality of the generated Gaussian vector, must
+ *be a non-negative value. It affects the lenght of the generated
+ *vector. A value equal to 3 corresponds to high quality.
+ * @param log_ctx a pointer to an arbitrary struct of which the first
+ *field is a pointer to an AVClass struct (used for av_log)
+ *used for logging, can be NULL
+ *
+ * @return a negative error code on error, non negative otherwise
+ */
+int sws_get_gaussian_vec(SwsVector **vecp,
+ double standard_deviation, double quality,
+ void *log_ctx);
 
 /**
  * Scale all the coefficients of a by the scalar value.
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 8e74c6603e..fd9b2d33d0 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2139,31 +2139,55 @@ SwsVector *sws_allocVec(int length)
 return vec;
 }
 
-SwsVector *sws_getGaussianVec(double variance, double quality)
+int sws_get_gaussian_vec(SwsVector **vecp,
+ double standard_deviation, double quality,
+ void *log_ctx)
 {
-const int length = (int)(variance * quality + 0.5) | 1;
+const int length = (int)(standard_deviation * quality + 0.5) | 1;
 int i;
 double middle  = (length - 1) * 0.5;
 SwsVector *vec;
+const double variance = standard_deviation * standard_deviation;
 
-if(variance < 0 || quality < 0)
-return NULL;
+if (standard_deviation < 0 || quality < 0) {
+av_log(log_ctx, AV_LOG_ERROR,
+   "Invalid negative standard deviation %f or quality %f provided as input to the sws_get_gaussian_vec function\n",
+   standard_deviation, quality);
+return AVERROR(EINVAL);
+}
 
 vec = sws_allocVec(length);
-
-if (!vec)
-return NULL;
+if (!vec) {
+av_log(log_ctx, AV_LOG_ERROR,
+   "Could not allocate vector for the sws_get_gaussian_vec function\n");
+return AVERROR(ENOMEM);
+}
 
 for (i = 0; i < length; i++) {
 double dist = i - middle;
-vec->coeff[i] = exp(-dist * dis

Re: [FFmpeg-devel] [PATCH] lavc/libx264: enable x4->params.analyse.b_fast_pskip if mb_info is set

2023-08-31 Thread Stefano Sabatini
On date Thursday 2023-08-31 15:38:09 +0100, Kieran Kunhya wrote:
> On Thu, 31 Aug 2023 at 15:30, Kieran Kunhya  wrote:
> 
> >
> >
> > On Thu, 31 Aug 2023 at 15:12, Carotti, Elias via ffmpeg-devel <
> > ffmpeg-devel@ffmpeg.org> wrote:
> >
> >> Hi
> >>
> >> -Original Message-
> >> From: ffmpeg-devel  On Behalf Of
> >> Stefano Sabatini
> >> Sent: Friday, August 25, 2023 12:01 PM
> >> To: FFmpeg development discussions and patches 
> >> Cc: Stefano Sabatini 
> >> Subject: [EXTERNAL] [FFmpeg-devel] [PATCH] lavc/libx264: enable
> >> x4->params.analyse.b_fast_pskip if mb_info is set
> >>
> >> CAUTION: This email originated from outside of the organization. Do not
> >> click links or open attachments unless you can confirm the sender and know
> >> the content is safe.
> >>
> >>
> >>
> >> x4->params.analyse.b_fast_pskip should only be forced in case mb_info
> >> is set.
> >>
> >> Fix output change introduced in 418c954e318.
> >> ---
> >>  libavcodec/libx264.c | 4 +++-
> >>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index
> >> 1a7dc7bdd5..a2877d7f75 100644
> >> --- a/libavcodec/libx264.c
> >> +++ b/libavcodec/libx264.c
> >> @@ -1190,7 +1190,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>  }
> >>
> >>  x4->params.analyse.b_mb_info = x4->mb_info;
> >> -x4->params.analyse.b_fast_pskip = 1;
> >> +if (x4->mb_info) {
> >> +x4->params.analyse.b_fast_pskip = x4->mb_info;
> >> +}
> >>
> >>  // update AVCodecContext with x264 parameters
> >>  avctx->has_b_frames = x4->params.i_bframe ?
> >> --
> >> 2.25.1
> >>
> >>
> >> Sorry for the delay. I agree, this was missing in the patch.
> >> Best
> >> Elias
> >>
> >
> > What does this patch actually do?
> >
> > Kieran
> >
> 

> In particular why are you turning on fast_pskip silently based on a
> completely different setting?

The patch is fixing the regression introduced by the unconditional
setting of b_fast_pskip.

Now the question is if it makes sense to set mb_info without
b_fast_pskip (in both case this should be probably documented).

@Elias can you comment about the mb_info/b_fast_pskip use case?
___
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] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-08-31 Thread Andreas Rheinhardt
Stefano Sabatini:
> +int sws_get_gaussian_vec(SwsVector **vecp,
> + AVClass *log_ctx,
> + double standard_deviation, double quality);
>  

Seriously? A pointer to an AVClass as log_ctx? It is actually AVClass**
(the logcontext must have a pointer to an AVClass as its first member),
but we always use NULL.

Apart from that: I am not really convinced that the improvement is worth
the hassle.

> 
> +if (standard_deviation < 0 || quality < 0) {
> +av_log(NULL, AV_LOG_ERROR,
> +   "Invalid negative standard deviation %f or quality %f 
> provided as input to the sws_get_gaussian_vec function\n",
> +   standard_deviation, quality);

Here you are not even using the logctx.

- 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] avformat/mov: add io_order option to disable demuxer level interleave

2023-08-31 Thread Derek Buitenhuis
On 8/28/2023 5:06 PM, Zhao Zhili wrote:
> -if (!sample || (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && 
> current_sample->pos < sample->pos) ||
> +if (!sample || (force_io_order && current_sample->pos < 
> sample->pos) ||

Hmm, I think the name `io_order` is a misnomer: It still will not, for example,
output packets in I/O order if the mdat has backwards packets (i.e. mdat starts
with the last packet, and ends with the first packet, which is very stupid, but
technically legal in ISOBMFF/QTFF).

Maybe something like `no_reinterleaving`? Naming is hard, and I am not much
better at it.

- Derek
___
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] Build failed with newer glslang

2023-08-31 Thread Stefano Sabatini
On date Tuesday 2023-08-29 11:33:43 +0200, Luca Bonissi wrote:
> Newer glslang does no more provide static libraries libOSDependent.a and
> libOGLCompiler.a.
> These libraries are only used in configure's test to detect spirv_compiler,
> but are no more necessary even with older glslang.
> 
> The following patch fixes the build issue.
> 
> Signed-off-by: Luca Bonissi 
> --
> 
> --- ffmpeg-5.1.3/configure.orig   2023-03-26 16:21:00.0 +0200
> +++ ffmpeg-5.1.3/configure2023-08-29 10:50:29.433307045 +0200

Please use git format-patch and send a patch against current mainline
(also the patch below seems mangled):
https://ffmpeg.org/developer.html#Submitting-patches
___
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] lsws, lavfi: use sws_get_gaussian_vec

2023-08-31 Thread Stefano Sabatini
On date Saturday 2023-08-26 17:13:19 +0200, Andreas Rheinhardt wrote:
> Stefano Sabatini:
> > Use in place of deprecated sws_getGaussianVec.
> 

> This patchset should have been sent as a reply to the patch actually
> adding sws_get_gaussian_vec.

Noted.

> > ---
> >  libavfilter/vf_sab.c   | 17 +
> >  libavfilter/vf_smartblur.c |  8 
> >  libswscale/utils.c | 32 ++--
> >  3 files changed, 31 insertions(+), 26 deletions(-)
> > 
[...]
> > -if (!filter->lumH || !filter->lumV || !filter->chrH || !filter->chrV)
> > -goto fail;
> > +#define SET_FILTER_VECTOR(name_, standard_deviation_, quality_) \
> > +if (standard_deviation_ != 0.0) {   \
> > +sws_get_gaussian_vec(&filter->name_,\
> > + standard_deviation_, quality_);\
> > +} else {\
> > +filter->name_ = sws_getIdentityVec();   \
> > +}   \
> > +if (!filter->name_) \
> > +goto fail;  \
> > +
> > +SET_FILTER_VECTOR(lumH, lumaGBlur, 3.0);
> > +SET_FILTER_VECTOR(lumV, lumaGBlur, 3.0);
> > +SET_FILTER_VECTOR(chrH, chromaGBlur, 3.0);
> > +SET_FILTER_VECTOR(chrV, chromaGBlur, 3.0);
> 
> This will check lumaGBlur/chromaGBlur twice.

Dropped the macro and updated.
>From 77eeaffc7d3f9e8cd2778f7c686f97d3a5f69ac1 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini 
Date: Sat, 26 Aug 2023 15:08:55 +0200
Subject: [PATCH 2/4] lsws,lavfi: use sws_get_gaussian_vec

Use in place of deprecated sws_getGaussianVec.
---
 libavfilter/vf_sab.c   | 17 +
 libavfilter/vf_smartblur.c |  8 
 libswscale/utils.c |  8 
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/libavfilter/vf_sab.c b/libavfilter/vf_sab.c
index 5e0687c9a2..6ae00d3eeb 100644
--- a/libavfilter/vf_sab.c
+++ b/libavfilter/vf_sab.c
@@ -143,7 +143,7 @@ static int open_filter_param(FilterParam *f, int width, int height, unsigned int
 {
 SwsVector *vec;
 SwsFilter sws_f;
-int i, x, y;
+int ret, i, x, y;
 int linesize = FFALIGN(width, 8);
 
 f->pre_filter_buf = av_malloc(linesize * height);
@@ -151,7 +151,10 @@ static int open_filter_param(FilterParam *f, int width, int height, unsigned int
 return AVERROR(ENOMEM);
 
 f->pre_filter_linesize = linesize;
-vec = sws_getGaussianVec(f->pre_filter_radius, f->quality);
+ret = sws_get_gaussian_vec(&vec, NULL, f->pre_filter_radius, f->quality);
+if (ret < 0)
+return ret;
+
 sws_f.lumH = sws_f.lumV = vec;
 sws_f.chrH = sws_f.chrV = NULL;
 f->pre_filter_context = sws_getContext(width, height, AV_PIX_FMT_GRAY8,
@@ -159,7 +162,10 @@ static int open_filter_param(FilterParam *f, int width, int height, unsigned int
sws_flags, &sws_f, NULL, NULL);
 sws_freeVec(vec);
 
-vec = sws_getGaussianVec(f->strength, 5.0);
+ret = sws_get_gaussian_vec(&vec, NULL, f->strength, 5.0);
+if (ret < 0)
+return ret;
+
 for (i = 0; i < COLOR_DIFF_COEFF_SIZE; i++) {
 double d;
 int index = i-COLOR_DIFF_COEFF_SIZE/2 + vec->length/2;
@@ -171,7 +177,10 @@ static int open_filter_param(FilterParam *f, int width, int height, unsigned int
 }
 sws_freeVec(vec);
 
-vec = sws_getGaussianVec(f->radius, f->quality);
+ret = sws_get_gaussian_vec(&vec, NULL, f->radius, f->quality);
+if (ret < 0)
+return ret;
+
 f->dist_width= vec->length;
 f->dist_linesize = FFALIGN(vec->length, 8);
 f->dist_coeff= av_malloc_array(f->dist_width, f->dist_linesize * sizeof(*f->dist_coeff));
diff --git a/libavfilter/vf_smartblur.c b/libavfilter/vf_smartblur.c
index 85d8d502e1..13a4225990 100644
--- a/libavfilter/vf_smartblur.c
+++ b/libavfilter/vf_smartblur.c
@@ -126,11 +126,11 @@ static int alloc_sws_context(FilterParam *f, int width, int height, unsigned int
 {
 SwsVector *vec;
 SwsFilter sws_filter;
+int ret;
 
-vec = sws_getGaussianVec(f->radius, f->quality);
-
-if (!vec)
-return AVERROR(EINVAL);
+ret = sws_get_gaussian_vec(&vec, NULL, f->radius, f->quality);
+if (ret < 0)
+return ret;
 
 sws_scaleVec(vec, f->strength);
 vec->coeff[vec->length / 2] += 1.0 - f->strength;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index e56df87d9f..5bdaf50392 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2367,16 +2367,16 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
 return NULL;
 
 if (lumaGBlur != 0.0) {
-filter->lumH = sws_getGaussianVec(lumaGBlur, 3.0);
-filter->lumV = sws_getGaussianVec(lumaGBlur, 

Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-08-31 Thread Stefano Sabatini
On date Saturday 2023-08-26 17:15:27 +0200, Andreas Rheinhardt wrote:
> Stefano Sabatini:
> > Use in place of sws_getGaussianVec.
> > 
> > The new function enable better log handling, and provide better naming
> 
> Better log handling? Why?
> 
> > for the variance variable, now named standard_deviation to reflect the
> > meaning of the parameter.
> > ---
> >  doc/APIchanges |  3 +++
> >  libswscale/swscale.h   | 21 ++-
> >  libswscale/utils.c | 41 +-
> >  libswscale/version.h   |  2 +-
> >  libswscale/version_major.h |  4 
> >  5 files changed, 60 insertions(+), 11 deletions(-)
> > 
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index ad1efe708d..bad2d61027 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 
> > 2023-02-09
> >  
> >  API changes, most recent first:
> >  
> > +2023-08-26 - xx - lsws 7.4.100 - swscale.h
> > +  Introduce sws_get_gaussian_vec, use in place of sws_getGaussianVec.
> > +
> >  2023-08-18 - xx - lavu 58.17.100 - channel_layout.h
> >All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
> >  
> > diff --git a/libswscale/swscale.h b/libswscale/swscale.h
> > index 9d4612aaf3..f002b5c7d2 100644
> > --- a/libswscale/swscale.h
> > +++ b/libswscale/swscale.h
> > @@ -355,11 +355,30 @@ int sws_getColorspaceDetails(struct SwsContext *c, 
> > int **inv_table,
> >   */
> >  SwsVector *sws_allocVec(int length);
> >  
> > +#if FF_API_SWS_GET_GAUSSIAN_VEC
> >  /**
> > - * Return a normalized Gaussian curve used to filter stuff
> > + * Return a normalized Gaussian curve used to filter stuff.
> > + *
> >   * quality = 3 is high quality, lower is lower quality.
> >   */
> >  SwsVector *sws_getGaussianVec(double variance, double quality);
> 
> Missing attribute_deprecated as well as the @deprecated doxygen thing
> refering to its replacement.

Updated.
>From 49efd5c9d711ba605bd19be67adc425dc52aeeb1 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini 
Date: Sat, 26 Aug 2023 14:20:35 +0200
Subject: [PATCH 1/4] lsws/swscale.h: introduce sws_get_gaussian_vec

Use in place of sws_getGaussianVec.

The new function enable better error handling, and provide better naming
for the variance variable, now named standard_deviation to reflect the
meaning of the parameter.
---
 doc/APIchanges |  3 +++
 libswscale/swscale.h   | 25 ++-
 libswscale/utils.c | 42 ++
 libswscale/version.h   |  2 +-
 libswscale/version_major.h |  4 
 5 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ad1efe708d..bad2d61027 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-08-26 - xx - lsws 7.4.100 - swscale.h
+  Introduce sws_get_gaussian_vec, use in place of sws_getGaussianVec.
+
 2023-08-18 - xx - lavu 58.17.100 - channel_layout.h
   All AV_CHANNEL_LAYOUT_* macros are now compatible with C++ 17 and older.
 
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 9d4612aaf3..febcb97bfd 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -355,11 +355,34 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
  */
 SwsVector *sws_allocVec(int length);
 
+#if FF_API_SWS_GET_GAUSSIAN_VEC
 /**
- * Return a normalized Gaussian curve used to filter stuff
+ * Return a normalized Gaussian curve used to filter stuff.
+ *
  * quality = 3 is high quality, lower is lower quality.
+ * @deprecated use sws_get_gaussian_vector()
  */
+attribute_deprecated
 SwsVector *sws_getGaussianVec(double variance, double quality);
+#endif
+
+/**
+ * Compute and return a normalized Gaussian vector.
+ *
+ * @param vecp: pointer where the computed vector is put in case of
+ *success
+ * @param log_ctx context used for logging, can be NULL
+ * @param standard_deviation the standard deviation used to generate
+ *the Gaussian vector, must be a non-negative value
+ * @param quality the quality of the generated Gaussian vector, must
+ *be a non-negative value. It affects the lenght of the generated
+ *vector. A value equal to 3 corresponds to high quality.
+ *
+ * @return a negative error code on error, non negative otherwise
+ */
+int sws_get_gaussian_vec(SwsVector **vecp,
+ AVClass *log_ctx,
+ double standard_deviation, double quality);
 
 /**
  * Scale all the coefficients of a by the scalar value.
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 8e74c6603e..e56df87d9f 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2139,31 +2139,55 @@ SwsVector *sws_allocVec(int length)
 return vec;
 }
 
-SwsVector *sws_getGaussianVec(double variance, double quality)
+int sws_ge

Re: [FFmpeg-devel] [PATCH 4/6] doc/developer: add a code behaviour section to development policy

2023-08-31 Thread Stefano Sabatini
On date Tuesday 2023-08-29 10:34:45 +0200, Anton Khirnov wrote:
> Quoting Stefano Sabatini (2023-08-27 14:38:44)
> > Il sab 26 ago 2023, 20:08 Anton Khirnov  ha scritto:
> > 
> > > Document our longstanding de facto policies on things like correctness,
> > > thread-safety, UB, etc.
> > >
> > 
> > UB?
> 
> undefined behavior

yes, let's avoid acronyms

> 
> > 
> > ---
> > >  doc/developer.texi | 50 +-
> > >  1 file changed, 36 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/doc/developer.texi b/doc/developer.texi
> > > index df43119f98..afa0148137 100644
> > > --- a/doc/developer.texi
> > > +++ b/doc/developer.texi
> > > @@ -274,10 +274,6 @@ symbols. If in doubt, just avoid names starting with
> > > @code{_} altogether.
> > >  @section Miscellaneous conventions
> > >
> > >  @itemize @bullet
> > > -@item
> > > -fprintf and printf are forbidden in libavformat and libavcodec,
> > > -please use av_log() instead.
> > > -
> > >  @item
> > >  Casts should be used only when necessary. Unneeded parentheses
> > >  should also be avoided if they don't make the code easier to understand.
> > > @@ -286,6 +282,42 @@ should also be avoided if they don't make the code
> > > easier to understand.
> > >  @anchor{Development Policy}
> > >  @chapter Development Policy
> > >
> > > +@section Code behaviour
> > > +
> > > +@subheading Correctness
> > > +The code must be valid. It must not crash, abort, access invalid
> > > pointers, leak
> > > +memory, cause data races or signed integer overflow, or otherwise invoke
> > > +undefined behaviour.
> > 
> > 
> > Invoke => assume?
> 

> No, 'assume' would mean something else. 'cause' maybe.

"cause" sounds good.

> 
> > 
> > Error codes should be checked and, when applicable,
> > > +forwarded to the caller.
> > > +
> > > +@subheading Thread- and library-safety
> > > +Our libraries may be called by multiple independent callers in the same
> > > process.
> > > +These calls may happen from any number of threads and the different call
> > > sites
> > > +may not be aware of each other - e.g. a user program may be calling us
> > > directly,
> > >
> > 
> > Calling us -> calling the/our libraries
> 

> I wanted to avoid using the word 'libraries' multiple times, to avoid
> possible confusion of which library is being talked about - whether ours
> or some external one.

But using "us" is even more confusing (who/what is "us"?), I have no
better ideas than repeating "our/the FFmpeg libraries".
___
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] lsws/swscale.h: introduce sws_get_gaussian_vec

2023-08-31 Thread Stefano Sabatini
On date Saturday 2023-08-26 17:15:36 +0200, Anton Khirnov wrote:
> Quoting Stefano Sabatini (2023-08-26 14:23:28)
> > Use in place of sws_getGaussianVec.
> > 
> > The new function enable better log handling, and provide better naming
> > for the variance variable, now named standard_deviation to reflect the
> > meaning of the parameter.
> 

> Logging to NULL does not seem like an improvement to me.

Adding the log_ctx.

> Renaming a function parameter does not require an API break.

The main point was improving the naming of the variable, but while at
it I'm also adding the logging context and providing a return code to
specify an error failure, and moving to snake_case convention which is
the one used by the new API additions.
___
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] lavc/videotoolboxenc: enable low-latency mode for HEVC

2023-08-31 Thread Jun Zhao
Enable the HEVC encoder that supports low-latency mode.

Signed-off-by: Jun Zhao 
---
 libavcodec/videotoolboxenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 8e493c4f7a..bfc03787a0 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1568,7 +1568,8 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
 #endif
 
 // low-latency mode: eliminate frame reordering, follow a one-in-one-out 
encoding mode
-if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
AV_CODEC_ID_H264) {
+if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
+(avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_HEVC)) {
 CFDictionarySetValue(enc_info,
  
compat_keys.kVTVideoEncoderSpecification_EnableLowLatencyRateControl,
  kCFBooleanTrue);
-- 
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] [PATCH 1/2] avdevice/decklink_dec: add explicit specifier

2023-08-31 Thread Jun Zhao
The explicit specifier used with a single argument constructor
to prevent implicit type conversions.

Signed-off-by: Jun Zhao 
---
 libavdevice/decklink_dec.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 11640f72ca..671573853b 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -577,7 +577,7 @@ static void handle_klv(AVFormatContext *avctx, decklink_ctx 
*ctx, IDeckLinkVideo
 class decklink_input_callback : public IDeckLinkInputCallback
 {
 public:
-decklink_input_callback(AVFormatContext *_avctx);
+explicit decklink_input_callback(AVFormatContext *_avctx);
 ~decklink_input_callback();
 
 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID 
*ppv) { return E_NOINTERFACE; }
-- 
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".


Re: [FFmpeg-devel] [PATCH] lavc/libx264: enable x4->params.analyse.b_fast_pskip if mb_info is set

2023-08-31 Thread Kieran Kunhya
On Thu, 31 Aug 2023 at 15:30, Kieran Kunhya  wrote:

>
>
> On Thu, 31 Aug 2023 at 15:12, Carotti, Elias via ffmpeg-devel <
> ffmpeg-devel@ffmpeg.org> wrote:
>
>> Hi
>>
>> -Original Message-
>> From: ffmpeg-devel  On Behalf Of
>> Stefano Sabatini
>> Sent: Friday, August 25, 2023 12:01 PM
>> To: FFmpeg development discussions and patches 
>> Cc: Stefano Sabatini 
>> Subject: [EXTERNAL] [FFmpeg-devel] [PATCH] lavc/libx264: enable
>> x4->params.analyse.b_fast_pskip if mb_info is set
>>
>> CAUTION: This email originated from outside of the organization. Do not
>> click links or open attachments unless you can confirm the sender and know
>> the content is safe.
>>
>>
>>
>> x4->params.analyse.b_fast_pskip should only be forced in case mb_info
>> is set.
>>
>> Fix output change introduced in 418c954e318.
>> ---
>>  libavcodec/libx264.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index
>> 1a7dc7bdd5..a2877d7f75 100644
>> --- a/libavcodec/libx264.c
>> +++ b/libavcodec/libx264.c
>> @@ -1190,7 +1190,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  }
>>
>>  x4->params.analyse.b_mb_info = x4->mb_info;
>> -x4->params.analyse.b_fast_pskip = 1;
>> +if (x4->mb_info) {
>> +x4->params.analyse.b_fast_pskip = x4->mb_info;
>> +}
>>
>>  // update AVCodecContext with x264 parameters
>>  avctx->has_b_frames = x4->params.i_bframe ?
>> --
>> 2.25.1
>>
>>
>> Sorry for the delay. I agree, this was missing in the patch.
>> Best
>> Elias
>>
>
> What does this patch actually do?
>
> Kieran
>

In particular why are you turning on fast_pskip silently based on a
completely different setting?

Kieran
___
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] lavc/libx264: enable x4->params.analyse.b_fast_pskip if mb_info is set

2023-08-31 Thread Kieran Kunhya
On Thu, 31 Aug 2023 at 15:12, Carotti, Elias via ffmpeg-devel <
ffmpeg-devel@ffmpeg.org> wrote:

> Hi
>
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Stefano
> Sabatini
> Sent: Friday, August 25, 2023 12:01 PM
> To: FFmpeg development discussions and patches 
> Cc: Stefano Sabatini 
> Subject: [EXTERNAL] [FFmpeg-devel] [PATCH] lavc/libx264: enable
> x4->params.analyse.b_fast_pskip if mb_info is set
>
> CAUTION: This email originated from outside of the organization. Do not
> click links or open attachments unless you can confirm the sender and know
> the content is safe.
>
>
>
> x4->params.analyse.b_fast_pskip should only be forced in case mb_info
> is set.
>
> Fix output change introduced in 418c954e318.
> ---
>  libavcodec/libx264.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index
> 1a7dc7bdd5..a2877d7f75 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -1190,7 +1190,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>
>  x4->params.analyse.b_mb_info = x4->mb_info;
> -x4->params.analyse.b_fast_pskip = 1;
> +if (x4->mb_info) {
> +x4->params.analyse.b_fast_pskip = x4->mb_info;
> +}
>
>  // update AVCodecContext with x264 parameters
>  avctx->has_b_frames = x4->params.i_bframe ?
> --
> 2.25.1
>
>
> Sorry for the delay. I agree, this was missing in the patch.
> Best
> Elias
>

What does this patch actually do?

Kieran
___
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] lavc/libx264: enable x4->params.analyse.b_fast_pskip if mb_info is set

2023-08-31 Thread Carotti, Elias via ffmpeg-devel
Hi

-Original Message-
From: ffmpeg-devel  On Behalf Of Stefano 
Sabatini
Sent: Friday, August 25, 2023 12:01 PM
To: FFmpeg development discussions and patches 
Cc: Stefano Sabatini 
Subject: [EXTERNAL] [FFmpeg-devel] [PATCH] lavc/libx264: enable 
x4->params.analyse.b_fast_pskip if mb_info is set

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you can confirm the sender and know the 
content is safe.



x4->params.analyse.b_fast_pskip should only be forced in case mb_info
is set.

Fix output change introduced in 418c954e318.
---
 libavcodec/libx264.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 
1a7dc7bdd5..a2877d7f75 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -1190,7 +1190,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }

 x4->params.analyse.b_mb_info = x4->mb_info;
-x4->params.analyse.b_fast_pskip = 1;
+if (x4->mb_info) {
+x4->params.analyse.b_fast_pskip = x4->mb_info;
+}

 // update AVCodecContext with x264 parameters
 avctx->has_b_frames = x4->params.i_bframe ?
--
2.25.1


Sorry for the delay. I agree, this was missing in the patch.
Best
Elias

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



NICE SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro delle Imprese 
di Milano Monza Brianza Lodi REA n. 2096882, Capitale Sociale: 10.329,14 EUR 
i.v., Cod. Fisc. e P.IVA 01133050052, Societa con Socio Unico



___
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] sending RTSP keep alive even when paused

2023-08-31 Thread Tmc Tmc
Thank you for the response.

With all due respect, my email is NOT about the RTSP standard, or the
vendor specifics.

FFmpeg code already does the necessary stuff by sending either
GET_PARAMETER or OPTIONS.

I was merely talking about moving that a little above, so that it
works the same way in even more cases - i.e., even when the video is
paused.

Hope that clarifies.

Thanks.



Le 27 août 2023 17:43:13 GMT+03:00, Tmc Tmc https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>> a écrit :
>*Hi All,
*>*I found a bug in ffmpeg's RTSP implementation.
*>>*The workflow is as follows:
*>>*1. Have a RTSP server that supports Pause.
*>*2. Have ffmpeg play a video from that server (rtsp://:...).
*>*3. Pause the video in ffmpeg.
*>*4. ffmpeg does NOT properly send the keep alive when Paused
*>*(either "GET_PARAMETER" or "OPTIONS"). This is the bug.
*
Neither of these are standard means of keeping alive according to the
(vague) RTSP 1.0 specification. In fact, sending GET_PARAMETER is
non-standard, and known to break some servers (the request is standard
but there are no standard parameters with which to use it).

OPTIONS should really not keep the session alive at all.

Unfortunately this is the sad situation of RTSP 1.0. You need
vendor-specific hacks.

>*5. Since the RTSP server expects the keep alive, after the specified
*>*timeout (usually 60s) it closes the connection.
*>>*The bug is in libavformat/rtspdec.c, rtsp_read_packet method.
*>>*This method first does ff_rtsp_fetch_packet, which fails when the server is
*>*Paused, causing it to never send the "GET_PARAMETER" or "OPTIONS" which is
*>*placed after this call.
*>>*The fix is to simply move that block of code before ff_rtsp_fetch_packet.
*>*That is, move the entire if block:
*>*if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) { ... }
*>*just before the call to:
*>*ret = ff_rtsp_fetch_packet(s, pkt);
*>>*I have tested this and it seems to work well for our cases.
*>>*Your thoughts and comments on this are welcome.
*>>*Thanks.
*>*___
*>*ffmpeg-devel mailing list
*>*ffmpeg-devel at ffmpeg.org 
*>*https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

*>>*To unsubscribe, visit link above, or email
*>*ffmpeg-devel-request at 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 v4 6/8] lavc/vaapi_encode: Separate reference frame into previous/future list

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

To support more reference frames from different directions.

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c   | 112 +---
 libavcodec/vaapi_encode.h   |  15 +++--
 libavcodec/vaapi_encode_h264.c  |  94 +--
 libavcodec/vaapi_encode_h265.c  |  76 +-
 libavcodec/vaapi_encode_mpeg2.c |   6 +-
 libavcodec/vaapi_encode_vp8.c   |   6 +-
 libavcodec/vaapi_encode_vp9.c   |  26 
 7 files changed, 208 insertions(+), 127 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 719daedbc9..790450aa21 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -276,21 +276,34 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
 av_log(avctx, AV_LOG_DEBUG, "Issuing encode for pic %"PRId64"/%"PRId64" "
"as type %s.\n", pic->display_order, pic->encode_order,
picture_type_name[pic->type]);
-if (pic->nb_refs == 0) {
+if (pic->nb_refs[0] == 0 && pic->nb_refs[1] == 0) {
 av_log(avctx, AV_LOG_DEBUG, "No reference pictures.\n");
 } else {
-av_log(avctx, AV_LOG_DEBUG, "Refers to:");
-for (i = 0; i < pic->nb_refs; i++) {
+av_log(avctx, AV_LOG_DEBUG, "L0 refers to");
+for (i = 0; i < pic->nb_refs[0]; i++) {
 av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
-   pic->refs[i]->display_order, pic->refs[i]->encode_order);
+   pic->refs[0][i]->display_order, 
pic->refs[0][i]->encode_order);
 }
 av_log(avctx, AV_LOG_DEBUG, ".\n");
+
+if (pic->nb_refs[1]) {
+av_log(avctx, AV_LOG_DEBUG, "L1 refers to");
+for (i = 0; i < pic->nb_refs[1]; i++) {
+av_log(avctx, AV_LOG_DEBUG, " %"PRId64"/%"PRId64,
+   pic->refs[1][i]->display_order, 
pic->refs[1][i]->encode_order);
+}
+av_log(avctx, AV_LOG_DEBUG, ".\n");
+}
 }
 
 av_assert0(!pic->encode_issued);
-for (i = 0; i < pic->nb_refs; i++) {
-av_assert0(pic->refs[i]);
-av_assert0(pic->refs[i]->encode_issued);
+for (i = 0; i < pic->nb_refs[0]; i++) {
+av_assert0(pic->refs[0][i]);
+av_assert0(pic->refs[0][i]->encode_issued);
+}
+for (i = 0; i < pic->nb_refs[1]; i++) {
+av_assert0(pic->refs[1][i]);
+av_assert0(pic->refs[1][i]->encode_issued);
 }
 
 av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface);
@@ -832,8 +845,12 @@ static void vaapi_encode_add_ref(AVCodecContext *avctx,
 
 if (is_ref) {
 av_assert0(pic != target);
-av_assert0(pic->nb_refs < MAX_PICTURE_REFERENCES);
-pic->refs[pic->nb_refs++] = target;
+av_assert0(pic->nb_refs[0] < MAX_PICTURE_REFERENCES &&
+   pic->nb_refs[1] < MAX_PICTURE_REFERENCES);
+if (target->display_order < pic->display_order)
+pic->refs[0][pic->nb_refs[0]++] = target;
+else
+pic->refs[1][pic->nb_refs[1]++] = target;
 ++refs;
 }
 
@@ -862,10 +879,16 @@ static void vaapi_encode_remove_refs(AVCodecContext 
*avctx,
 if (pic->ref_removed[level])
 return;
 
-for (i = 0; i < pic->nb_refs; i++) {
-av_assert0(pic->refs[i]);
---pic->refs[i]->ref_count[level];
-av_assert0(pic->refs[i]->ref_count[level] >= 0);
+for (i = 0; i < pic->nb_refs[0]; i++) {
+av_assert0(pic->refs[0][i]);
+--pic->refs[0][i]->ref_count[level];
+av_assert0(pic->refs[0][i]->ref_count[level] >= 0);
+}
+
+for (i = 0; i < pic->nb_refs[1]; i++) {
+av_assert0(pic->refs[1][i]);
+--pic->refs[1][i]->ref_count[level];
+av_assert0(pic->refs[1][i]->ref_count[level] >= 0);
 }
 
 for (i = 0; i < pic->nb_dpb_pics; i++) {
@@ -910,7 +933,7 @@ static void vaapi_encode_set_b_pictures(AVCodecContext 
*avctx,
 vaapi_encode_add_ref(avctx, pic, end,   1, 1, 0);
 vaapi_encode_add_ref(avctx, pic, prev,  0, 0, 1);
 
-for (ref = end->refs[1]; ref; ref = ref->refs[1])
+for (ref = end->refs[1][0]; ref; ref = ref->refs[1][0])
 vaapi_encode_add_ref(avctx, pic, ref, 0, 1, 0);
 }
 *last = prev;
@@ -933,7 +956,7 @@ static void vaapi_encode_set_b_pictures(AVCodecContext 
*avctx,
 vaapi_encode_add_ref(avctx, pic, end,   1, 1, 0);
 vaapi_encode_add_ref(avctx, pic, prev,  0, 0, 1);
 
-for (ref = end->refs[1]; ref; ref = ref->refs[1])
+for (ref = end->refs[1][0]; ref; ref = ref->refs[1][0])
 vaapi_encode_add_ref(avctx, pic, ref, 0, 1, 0);
 
 if (i > 1)
@@ -947,11 +970,44 @@ static void vaapi_encode_set_b_pictures(AVCodecContext 
*avctx,
 }
 }
 
+static void vaapi_encode_add_next_prev(AVCodecContext *avctx,
+   VAAPIEncodePicture *pic)
+{
+VAAPIEncodeContext *ctx = avctx->priv_d

[FFmpeg-devel] [PATCH v4 8/8] lavc/av1: Add unit test for level handling

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 libavcodec/tests/.gitignore   |   1 +
 libavcodec/tests/av1_levels.c | 124 ++
 tests/fate/libavcodec.mak |   5 ++
 3 files changed, 130 insertions(+)
 create mode 100644 libavcodec/tests/av1_levels.c

diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore
index 2acfc4e804..5e0ccc5838 100644
--- a/libavcodec/tests/.gitignore
+++ b/libavcodec/tests/.gitignore
@@ -1,3 +1,4 @@
+/av1_levels
 /avcodec
 /avfft
 /avpacket
diff --git a/libavcodec/tests/av1_levels.c b/libavcodec/tests/av1_levels.c
new file mode 100644
index 00..738903b24b
--- /dev/null
+++ b/libavcodec/tests/av1_levels.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2023 Intel Corporation
+ *
+ * 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
+ */
+
+#include "libavutil/common.h"
+#include "libavcodec/av1_levels.h"
+
+static const struct {
+int width;
+int height;
+float framerate;
+int level_idx;
+} test_sizes[] = {
+{  426,  240,  30.0,  0 },
+{  640,  360,  30.0,  1 },
+{  854,  480,  30.0,  4 },
+{ 1280,  720,  30.0,  5 },
+{ 1920, 1080,  30.0,  8 },
+{ 1920, 1080,  60.0,  9 },
+{ 3840, 2160,  30.0, 12 },
+{ 3840, 2160,  60.0, 13 },
+{ 3840, 2160, 120.0, 14 },
+{ 7680, 4320,  30.0, 16 },
+{ 7680, 4320,  60.0, 17 },
+{ 7680, 4320, 120.0, 18 },
+};
+
+static const struct {
+int64_t bitrate;
+int tier;
+int level_idx;
+} test_bitrate[] = {
+{   150, 0,  0 },
+{   300, 0,  1 },
+{   600, 0,  4 },
+{  1000, 0,  5 },
+{  1200, 0,  8 },
+{  3000, 1,  8 },
+{  2000, 0,  9 },
+{  5000, 1,  9 },
+{  3000, 0, 12 },
+{ 1, 1, 12 },
+{  4000, 0, 13 },
+{ 16000, 1, 13 },
+{  6000, 0, 14 },
+{ 24000, 1, 14 },
+{ 1, 0, 17 },
+{ 48000, 1, 17 },
+{ 16000, 0, 18 },
+{ 8, 1, 18 },
+};
+
+static const struct {
+int tiles;
+int tile_cols;
+int level_idx;
+} test_tiles[] = {
+{8,  4,  0 },
+{   16,  6,  4 },
+{   32,  8,  8 },
+{   64,  8, 12 },
+{  128, 16, 16 },
+};
+
+int main(void)
+{
+const AV1LevelDescriptor *level;
+int i;
+
+#define CHECK(expected, format, ...) do { \
+if (level ? (level->level_idx != expected) \
+ : !level) { \
+av_log(NULL, AV_LOG_ERROR, "Incorrect level for " \
+   format ": expected %d, got %d.\n", __VA_ARGS__, \
+   expected, level ? level->level_idx : -1); \
+return 1; \
+} \
+} while (0)
+
+for (i = 0; i < FF_ARRAY_ELEMS(test_sizes); i++) {
+level = ff_av1_guess_level(0, 0,
+   test_sizes[i].width,
+   test_sizes[i].height,
+   0, 0, test_sizes[i].framerate);
+CHECK(test_sizes[i].level_idx, "size %dx%d, framerate %f",
+  test_sizes[i].width, test_sizes[i].height, 
test_sizes[i].framerate);
+}
+
+for (i = 0; i < FF_ARRAY_ELEMS(test_bitrate); i++) {
+level = ff_av1_guess_level(test_bitrate[i].bitrate,
+   test_bitrate[i].tier,
+   0, 0, 0, 0, 0);
+CHECK(test_bitrate[i].level_idx, "bitrate %"PRId64" tier %d",
+  test_bitrate[i].bitrate, test_bitrate[i].tier);
+}
+
+for (i = 0; i < FF_ARRAY_ELEMS(test_tiles); i++) {
+level = ff_av1_guess_level(0, 0, 0, 0,
+   test_tiles[i].tiles,
+   test_tiles[i].tile_cols,
+   0);
+CHECK(test_tiles[i].level_idx, "tiles %d, tile cols %d",
+  test_tiles[i].tiles,
+  test_tiles[i].tile_cols);
+}
+
+return 0;
+}
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 8f56fae3a8..1a5694fa5f 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -1,3 +1,8 @@
+FATE_LIBAVCODEC-$(CONFIG_AV1_VAAPI_ENCODER) += fate-av1-levels
+fate-av1-levels: libavcodec/tests/av1_levels$(EXESUF)
+fate-av1-levels: CMD = run libavcodec/tests/av1_levels$(EXE

[FFmpeg-devel] [PATCH v4 7/8] lavc/vaapi_encode: Add VAAPI AV1 encoder

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
Fixed the discussions in V3.

 Changelog |   1 +
 configure |   3 +
 doc/encoders.texi |  14 +
 libavcodec/Makefile   |   2 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/av1_levels.c   |  92 
 libavcodec/av1_levels.h   |  58 +++
 libavcodec/vaapi_encode.c | 198 +--
 libavcodec/vaapi_encode.h |  24 +
 libavcodec/vaapi_encode_av1.c | 949 ++
 libavcodec/version.h  |   2 +-
 11 files changed, 1311 insertions(+), 33 deletions(-)
 create mode 100644 libavcodec/av1_levels.c
 create mode 100644 libavcodec/av1_levels.h
 create mode 100644 libavcodec/vaapi_encode_av1.c

diff --git a/Changelog b/Changelog
index c010e86159..b10c65a4c5 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ version :
 - support for the P_SKIP hinting to speed up libx264 encoding
 - Support HEVC,VP9,AV1 codec in enhanced flv format
 - apsnr and asisdr audio filters
+- VAAPI AV1 encoder
 
 
 version 6.0:
diff --git a/configure b/configure
index bd7f7697c8..ec7a80cd48 100755
--- a/configure
+++ b/configure
@@ -3323,6 +3323,8 @@ av1_qsv_decoder_select="qsvdec"
 av1_qsv_encoder_select="qsvenc"
 av1_qsv_encoder_deps="libvpl"
 av1_amf_encoder_deps="amf"
+av1_vaapi_encoder_deps="VAEncPictureParameterBufferAV1"
+av1_vaapi_encoder_select="cbs_av1 vaapi_encode"
 
 # parsers
 aac_parser_select="adts_header mpeg4audio"
@@ -7110,6 +7112,7 @@ if enabled vaapi; then
 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
 check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
 check_type "va/va.h va/va_enc_vp9.h"  "VAEncPictureParameterBufferVP9"
+check_type "va/va.h va/va_enc_av1.h"  "VAEncPictureParameterBufferAV1"
 fi
 
 if enabled_all opencl libdrm ; then
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 6f8f5e127e..d7d9584a0c 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3995,6 +3995,20 @@ Average variable bitrate.
 Each encoder also has its own specific options:
 @table @option
 
+@item av1_vaapi
+@option{profile} sets the value of @emph{seq_profile}.
+@option{tier} sets the value of @emph{seq_tier}.
+@option{level} sets the value of @emph{seq_level_idx}.
+
+@table @option
+@item tiles
+Set the number of tiles to encode the input video with, as columns x rows.
+(default is auto, which means use minimal tile column/row number).
+@item tile_groups
+Set tile groups number. All the tiles will be distributed as evenly as 
possible to
+each tile group. (default is 1).
+@end table
+
 @item h264_vaapi
 @option{profile} sets the value of @emph{profile_idc} and the 
@emph{constraint_set*_flag}s.
 @option{level} sets the value of @emph{level_idc}.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f961d0abd6..e315299a0e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -258,6 +258,7 @@ OBJS-$(CONFIG_AV1_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_AV1_MEDIACODEC_ENCODER)  += mediacodecenc.o
 OBJS-$(CONFIG_AV1_NVENC_ENCODER)   += nvenc_av1.o nvenc.o
 OBJS-$(CONFIG_AV1_QSV_ENCODER) += qsvenc_av1.o
+OBJS-$(CONFIG_AV1_VAAPI_ENCODER)   += vaapi_encode_av1.o av1_levels.o
 OBJS-$(CONFIG_AVRN_DECODER)+= avrndec.o
 OBJS-$(CONFIG_AVRP_DECODER)+= r210dec.o
 OBJS-$(CONFIG_AVRP_ENCODER)+= r210enc.o
@@ -1322,6 +1323,7 @@ TESTPROGS = avcodec   
  \
 jpeg2000dwt \
 mathops\
 
+TESTPROGS-$(CONFIG_AV1_VAAPI_ENCODER) += av1_levels
 TESTPROGS-$(CONFIG_CABAC) += cabac
 TESTPROGS-$(CONFIG_DCT)   += avfft
 TESTPROGS-$(CONFIG_FFT)   += fft fft-fixed32
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 8775d15a4f..c43c1d7b48 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -844,6 +844,7 @@ extern const FFCodec ff_av1_nvenc_encoder;
 extern const FFCodec ff_av1_qsv_decoder;
 extern const FFCodec ff_av1_qsv_encoder;
 extern const FFCodec ff_av1_amf_encoder;
+extern const FFCodec ff_av1_vaapi_encoder;
 extern const FFCodec ff_libopenh264_encoder;
 extern const FFCodec ff_libopenh264_decoder;
 extern const FFCodec ff_h264_amf_encoder;
diff --git a/libavcodec/av1_levels.c b/libavcodec/av1_levels.c
new file mode 100644
index 00..19b6ee1736
--- /dev/null
+++ b/libavcodec/av1_levels.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2023 Intel Corporation
+ *
+ * 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 usefu

[FFmpeg-devel] [PATCH v4 5/8] lavc/vaapi_encode: Extract set output pkt property function

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c | 65 +++
 1 file changed, 38 insertions(+), 27 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 8c9f14df66..719daedbc9 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -650,6 +650,41 @@ fail_at_end:
 return err;
 }
 
+static int vaapi_encode_set_output_property(AVCodecContext *avctx,
+VAAPIEncodePicture *pic,
+AVPacket *pkt)
+{
+VAAPIEncodeContext *ctx = avctx->priv_data;
+
+if (pic->type == PICTURE_TYPE_IDR)
+pkt->flags |= AV_PKT_FLAG_KEY;
+
+pkt->pts = pic->pts;
+pkt->duration = pic->duration;
+
+// for no-delay encoders this is handled in generic codec
+if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY &&
+avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
+pkt->opaque = pic->opaque;
+pkt->opaque_ref = pic->opaque_ref;
+pic->opaque_ref = NULL;
+}
+
+if (ctx->output_delay == 0) {
+pkt->dts = pkt->pts;
+} else if (pic->encode_order < ctx->decode_delay) {
+if (ctx->ts_ring[pic->encode_order] < INT64_MIN + ctx->dts_pts_diff)
+pkt->dts = INT64_MIN;
+else
+pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
+} else {
+pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
+(3 * ctx->output_delay + ctx->async_depth)];
+}
+
+return 0;
+}
+
 static int vaapi_encode_output(AVCodecContext *avctx,
VAAPIEncodePicture *pic, AVPacket *pkt)
 {
@@ -691,12 +726,6 @@ static int vaapi_encode_output(AVCodecContext *avctx,
 ptr += buf->size;
 }
 
-if (pic->type == PICTURE_TYPE_IDR)
-pkt->flags |= AV_PKT_FLAG_KEY;
-
-pkt->pts = pic->pts;
-pkt->duration = pic->duration;
-
 vas = vaUnmapBuffer(ctx->hwctx->display, pic->output_buffer);
 if (vas != VA_STATUS_SUCCESS) {
 av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "
@@ -705,14 +734,6 @@ static int vaapi_encode_output(AVCodecContext *avctx,
 goto fail;
 }
 
-// for no-delay encoders this is handled in generic codec
-if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY &&
-avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
-pkt->opaque = pic->opaque;
-pkt->opaque_ref = pic->opaque_ref;
-pic->opaque_ref = NULL;
-}
-
 av_buffer_unref(&pic->output_buffer_ref);
 pic->output_buffer = VA_INVALID_ID;
 
@@ -1273,19 +1294,9 @@ int ff_vaapi_encode_receive_packet(AVCodecContext 
*avctx, AVPacket *pkt)
 return err;
 }
 
-if (ctx->output_delay == 0) {
-pkt->dts = pkt->pts;
-} else if (pic->encode_order < ctx->decode_delay) {
-if (ctx->ts_ring[pic->encode_order] < INT64_MIN + ctx->dts_pts_diff)
-pkt->dts = INT64_MIN;
-else
-pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff;
-} else {
-pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) %
-(3 * ctx->output_delay + ctx->async_depth)];
-}
-av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" dts 
%"PRId64".\n",
-   pkt->pts, pkt->dts);
+vaapi_encode_set_output_property(avctx, pic, pkt);
+av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64", dts %"PRId64", "
+   "size %d bytes.\n", pkt->pts, pkt->dts, pkt->size);
 
 ctx->output_order = pic->encode_order;
 vaapi_encode_clear_old(avctx);
-- 
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] [PATCH v4 2/8] cbs: Make tracing more general

2023-08-31 Thread fei . w . wang-at-intel . com
From: Mark Thompson 

Turn tracing into callbacks for each syntax element, with default
callbacks to match current trace_headers behaviour for debug.  Move
the construction of bit strings into the trace callback, which
simplifies all of the read and write functions.

Signed-off-by: Fei Wang 
---
 libavcodec/cbs.c   | 121 +--
 libavcodec/cbs.h   |  88 +-
 libavcodec/cbs_av1.c   | 206 +
 libavcodec/cbs_bsf.c   |   5 +
 libavcodec/cbs_h2645.c | 134 +
 libavcodec/cbs_internal.h  |  85 +-
 libavcodec/cbs_vp9.c   | 108 +
 libavcodec/trace_headers_bsf.c |   2 +
 8 files changed, 373 insertions(+), 376 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 3ec8285e21..daf7f66427 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -117,8 +117,9 @@ av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr,
 
 ctx->decompose_unit_types = NULL;
 
-ctx->trace_enable = 0;
-ctx->trace_level  = AV_LOG_TRACE;
+ctx->trace_enable  = 0;
+ctx->trace_level   = AV_LOG_TRACE;
+ctx->trace_context = ctx;
 
 *ctx_ptr = ctx;
 return 0;
@@ -496,19 +497,27 @@ void ff_cbs_trace_header(CodedBitstreamContext *ctx,
 av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name);
 }
 
-void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position,
- const char *str, const int *subscripts,
- const char *bits, int64_t value)
+void ff_cbs_trace_read_log(void *trace_context,
+   GetBitContext *gbc, int length,
+   const char *str, const int *subscripts,
+   int64_t value)
 {
+CodedBitstreamContext *ctx = trace_context;
 char name[256];
+char bits[256];
 size_t name_len, bits_len;
 int pad, subs, i, j, k, n;
-
-if (!ctx->trace_enable)
-return;
+int position;
 
 av_assert0(value >= INT_MIN && value <= UINT32_MAX);
 
+position = get_bits_count(gbc);
+
+av_assert0(length < 256);
+for (i = 0; i < length; i++)
+bits[i] = get_bits1(gbc) ? '1' : '0';
+bits[length] = 0;
+
 subs = subscripts ? subscripts[0] : 0;
 n = 0;
 for (i = j = 0; str[i];) {
@@ -535,7 +544,7 @@ void ff_cbs_trace_syntax_element(CodedBitstreamContext 
*ctx, int position,
 av_assert0(n == subs);
 
 name_len = strlen(name);
-bits_len = strlen(bits);
+bits_len = length;
 
 if (name_len + bits_len > 60)
 pad = bits_len + 2;
@@ -546,6 +555,36 @@ void ff_cbs_trace_syntax_element(CodedBitstreamContext 
*ctx, int position,
position, name, pad, bits, value);
 }
 
+void ff_cbs_trace_write_log(void *trace_context,
+PutBitContext *pbc, int length,
+const char *str, const int *subscripts,
+int64_t value)
+{
+CodedBitstreamContext *ctx = trace_context;
+
+// Ensure that the syntax element is written to the output buffer,
+// make a GetBitContext pointed at the start position, then call the
+// read log function which can read the bits back to log them.
+
+GetBitContext gbc;
+int position;
+
+if (length > 0) {
+PutBitContext flush;
+flush = *pbc;
+flush_put_bits(&flush);
+}
+
+position = put_bits_count(pbc);
+av_assert0(position >= length);
+
+init_get_bits(&gbc, pbc->buf, position);
+
+skip_bits_long(&gbc, position - length);
+
+ff_cbs_trace_read_log(ctx, &gbc, length, str, subscripts, value);
+}
+
 static av_always_inline int cbs_read_unsigned(CodedBitstreamContext *ctx,
   GetBitContext *gbc,
   int width, const char *name,
@@ -555,7 +594,8 @@ static av_always_inline int 
cbs_read_unsigned(CodedBitstreamContext *ctx,
   uint32_t range_max)
 {
 uint32_t value;
-int position;
+
+CBS_TRACE_READ_START();
 
 av_assert0(width > 0 && width <= 32);
 
@@ -565,21 +605,9 @@ static av_always_inline int 
cbs_read_unsigned(CodedBitstreamContext *ctx,
 return AVERROR_INVALIDDATA;
 }
 
-if (ctx->trace_enable)
-position = get_bits_count(gbc);
-
 value = get_bits_long(gbc, width);
 
-if (ctx->trace_enable) {
-char bits[33];
-int i;
-for (i = 0; i < width; i++)
-bits[i] = value >> (width - i - 1) & 1 ? '1' : '0';
-bits[i] = 0;
-
-ff_cbs_trace_syntax_element(ctx, position, name, subscripts,
-bits, value);
-}
+CBS_TRACE_READ_END();
 
 if (value < range_min || value > range_max) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "%s out of range: "
@@ -613,6 +641,8 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, 
Put

[FFmpeg-devel] [PATCH v4 4/8] lavc/vaapi_encode: Init pic at the beginning of API

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_encode.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index bfca315a7a..8c9f14df66 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1205,7 +1205,7 @@ fail:
 int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
 {
 VAAPIEncodeContext *ctx = avctx->priv_data;
-VAAPIEncodePicture *pic;
+VAAPIEncodePicture *pic = NULL;
 AVFrame *frame = ctx->frame;
 int err;
 
@@ -1228,8 +1228,6 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 }
 
 if (ctx->has_sync_buffer_func) {
-pic = NULL;
-
 if (av_fifo_can_write(ctx->encode_fifo)) {
 err = vaapi_encode_pick_next(avctx, &pic);
 if (!err) {
@@ -1255,7 +1253,6 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, 
AVPacket *pkt)
 av_fifo_read(ctx->encode_fifo, &pic, 1);
 ctx->encode_order = pic->encode_order + 1;
 } else {
-pic = NULL;
 err = vaapi_encode_pick_next(avctx, &pic);
 if (err < 0)
 return err;
-- 
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] [PATCH v4 3/8] avcodec/cbs_av1: Allow specifying obu size byte length

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 libavcodec/cbs_av1.c | 30 +-
 libavcodec/cbs_av1.h |  1 +
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index aa92639235..0c08256cc8 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -138,15 +138,19 @@ static int cbs_av1_read_leb128(CodedBitstreamContext 
*ctx, GetBitContext *gbc,
 return 0;
 }
 
+/** Minimum byte length will be used to indicate the len128 of value if 
byte_len is 0. */
 static int cbs_av1_write_leb128(CodedBitstreamContext *ctx, PutBitContext *pbc,
-const char *name, uint64_t value)
+const char *name, uint64_t value, uint8_t 
byte_len)
 {
 int len, i;
 uint8_t byte;
 
 CBS_TRACE_WRITE_START();
 
-len = (av_log2(value) + 7) / 7;
+if (byte_len)
+av_assert0(byte_len >= (av_log2(value) + 7) / 7);
+
+len = byte_len ? byte_len : (av_log2(value) + 7) / 7;
 
 for (i = 0; i < len; i++) {
 if (put_bits_left(pbc) < 8)
@@ -618,7 +622,7 @@ static size_t cbs_av1_get_payload_bytes_left(GetBitContext 
*gbc)
 } while (0)
 
 #define leb128(name) do { \
-CHECK(cbs_av1_write_leb128(ctx, rw, #name, current->name)); \
+CHECK(cbs_av1_write_leb128(ctx, rw, #name, current->name, 0)); \
 } while (0)
 
 #define infer(name, value) do { \
@@ -1002,9 +1006,14 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
 
 if (obu->header.obu_has_size_field) {
 pbc_tmp = *pbc;
-// Add space for the size field to fill later.
-put_bits32(pbc, 0);
-put_bits32(pbc, 0);
+if (obu->obu_size_byte_len) {
+for (int i = 0; i < obu->obu_size_byte_len; i++)
+put_bits(pbc, 8, 0);
+} else {
+// Add space for the size field to fill later.
+put_bits32(pbc, 0);
+put_bits32(pbc, 0);
+}
 }
 
 td = NULL;
@@ -1124,7 +1133,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
 end_pos   /= 8;
 
 *pbc = pbc_tmp;
-err = cbs_av1_write_leb128(ctx, pbc, "obu_size", obu->obu_size);
+err = cbs_av1_write_leb128(ctx, pbc, "obu_size", obu->obu_size, 
obu->obu_size_byte_len);
 if (err < 0)
 goto error;
 
@@ -1141,8 +1150,11 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
 }
 
 if (obu->obu_size > 0) {
-memmove(pbc->buf + data_pos,
-pbc->buf + start_pos, header_size);
+if (!obu->obu_size_byte_len) {
+obu->obu_size_byte_len = start_pos - data_pos;
+memmove(pbc->buf + data_pos,
+pbc->buf + start_pos, header_size);
+}
 skip_put_bytes(pbc, header_size);
 
 if (td) {
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 64dfdce9c4..a9e2d2284f 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -401,6 +401,7 @@ typedef struct AV1RawOBU {
 AV1RawOBUHeader header;
 
 size_t obu_size;
+uint8_t obu_size_byte_len;
 
 union {
 AV1RawSequenceHeader sequence_header;
-- 
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] [PATCH v4 1/8] avcodec/cbs_av1: Add tx mode enum values

2023-08-31 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 libavcodec/av1.h | 7 +++
 libavcodec/cbs_av1_syntax_template.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/av1.h b/libavcodec/av1.h
index 384f7cddc7..8704bc41c1 100644
--- a/libavcodec/av1.h
+++ b/libavcodec/av1.h
@@ -175,6 +175,13 @@ enum {
 AV1_RESTORE_SWITCHABLE = 3,
 };
 
+// TX mode (section 6.8.21)
+enum {
+AV1_ONLY_4X4= 0,
+AV1_TX_MODE_LARGEST = 1,
+AV1_TX_MODE_SELECT  = 2,
+};
+
 // Sequence Headers are actually unbounded because one can use
 // an arbitrary number of leading zeroes when encoding via uvlc.
 // The following estimate is based around using the lowest number
diff --git a/libavcodec/cbs_av1_syntax_template.c 
b/libavcodec/cbs_av1_syntax_template.c
index a747e17784..3a5cafbfb7 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1028,9 +1028,9 @@ static int FUNC(read_tx_mode)(CodedBitstreamContext *ctx, 
RWContext *rw,
 int err;
 
 if (priv->coded_lossless)
-infer(tx_mode, 0);
+infer(tx_mode, AV1_ONLY_4X4);
 else
-increment(tx_mode, 1, 2);
+increment(tx_mode, AV1_TX_MODE_LARGEST, AV1_TX_MODE_SELECT);
 
 return 0;
 }
-- 
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".