Re: [FFmpeg-devel] [PATCH v6] libavfi/dnn: add LibTorch as one of DNN backend

2024-03-15 Thread Jean-Baptiste Kempf
On Fri, 15 Mar 2024, at 05:42, wenbin.chen-at-intel@ffmpeg.org wrote:
> From: Wenbin Chen 
>
> PyTorch is an open source machine learning framework that accelerates
> the path from research prototyping to production deployment. Official
> website: https://pytorch.org/. We call the C++ library of PyTorch as
> LibTorch, the same below.

LGTM. Please apply.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
https://jbkempf.com/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/mips/aaccoder_mips: Remove MIPS-specific aaccoder

2024-03-15 Thread Jean-Baptiste Kempf
On Fri, 15 Mar 2024, at 02:20, Andreas Rheinhardt wrote:
> ff_aac_coder_init_mips() modifies a static const structure of
> function pointers. This will crash if the binary uses relro
> and is a data race in any case.
>
> Furthermore it points to a maintainability issue: The
> AACCoefficientsEncoder structures have been constified
> in commit fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3,
> a Libav commit merged in 318778de9ebec276cb9dfc65509231ca56590d13.
> Libav did not have the MIPS-specific AAC code and so this was
> fine for them; yet FFmpeg had them, but this was not recognized.


LGTM.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
https://jbkempf.com/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v2 9/9] avformat/pcm: decrease target audio frame per sec to 10

2024-03-15 Thread Tobias Rapp

On 14/03/2024 23:04, Marton Balint wrote:




On Thu, 14 Mar 2024, Tobias Rapp wrote:


On 08/03/2024 01:53, Marton Balint wrote:


 This makes the wav and pcm demuxer demux bigger packets, which is more
 efficient.



[...]


 +0, 136000, 136000, 2000,    24000,
 f952be1e1c7d48acd73d652ef4ea3aad
 +0, 138000, 138000, 2000,    24000,
 e42cbabef9d9675429dcb6fa28ce39f4
 +0, 14, 14, 2000,    24000,
 9c6613b980bcbe9ebacbb6a492f53b16
 +0, 142000, 142000, 2000,    24000,
 1882d1ae4b08fa7cc848eba60d645463
 +0, 144000, 144000, 2000,    24000,
 a361b56ba31c90557689631f0e7afc63
 +0, 146000, 146000, 2000,    24000,
 341fbe24112c4060bb643750895a9041
 +0, 148000, 148000, 2000,    24000,
 38340ef2ef764bb8007efe9cd0af54d7
 +0, 15, 15, 2000,    24000,
 9b013a00bbedad211ba33326a3cfaa6e
 +0, 152000, 152000, 2000,    24000,
 9d3469da4442cdfd2b8a5beacb789701
 +0, 154000, 154000, 2000,    24000,
 cf8e3880ecb46011328135dba1015044
 +0, 156000, 156000, 2000,    24000,
 3be9fa7d0e0541269339ee032bda4021
 +0, 158000, 158000, 2000,    24000,
 ffd2646acf86524651416bc412afd846
 +0, 16, 16, 2000,    24000,
 715163d8f82f007b1b6c42b06bd08b5a
 +0, 162000, 162000, 1840,    22080,
 c2079a237d021d7aa27e44acf979b1f0


Noob question: Isn't a much larger total number of samples produced 
here?


The command line which generates the daud file specifies -frames:a 20, 
and 20 from bigger packets will cause a longer output file.


Ah ok, I was just wondering because the packet count changes from 4 to 
65 while the packet size stays at 24000. Didn't notice that a two-step 
process (encoding with limited frame-count into file, then separate 
decoding to get the framemd5) is performed here in contrast to other 
tests with frame-count limit.


Also it might be good to mention in the commit that the audio 
duration is less exact when using commands like "ffmpeg -i $INPUT 
-c:a copy -t 1.0 $OUTPUT".


Ok, will add this to the commit message.


Thanks,
Tobias

___
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 v6] libavfi/dnn: add LibTorch as one of DNN backend

2024-03-15 Thread Guo, Yejun



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Jean-
> Baptiste Kempf
> Sent: Friday, March 15, 2024 3:05 PM
> To: wenbin.chen-at-intel@ffmpeg.org; ffmpeg-devel  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v6] libavfi/dnn: add LibTorch as one of
> DNN backend
> 
> On Fri, 15 Mar 2024, at 05:42, wenbin.chen-at-intel@ffmpeg.org wrote:
> > From: Wenbin Chen 
> >
> > PyTorch is an open source machine learning framework that accelerates
> > the path from research prototyping to production deployment. Official
> > website: https://pytorch.org/. We call the C++ library of PyTorch as
> > LibTorch, the same below.
> 
> LGTM. Please apply.

Cool, I plan to have a clean try next week and then apply the patch, hope not 
too late.

___
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] tests/audiogen: Fix total RIFF chunk size

2024-03-15 Thread Tobias Rapp
The "RIFF" identifier and chunk size fields should not be included
within the size value.
---
 tests/audiogen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/audiogen.c b/tests/audiogen.c
index c43bb70..df1dea6 100644
--- a/tests/audiogen.c
+++ b/tests/audiogen.c
@@ -109,7 +109,7 @@ static void put32(uint32_t v)
 fputc((v >> 24) & 0xff, outfile);
 }
 
-#define HEADER_SIZE  46
+#define HEADER_SIZE  38
 #define FMT_SIZE 18
 #define SAMPLE_SIZE   2
 #define WFORMAT_PCM  0x0001
-- 
2.7.4

___
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] configure: Remove av_restrict

2024-03-15 Thread Martin Storsjö

On Sun, 10 Mar 2024, Andreas Rheinhardt wrote:


All versions of MSVC that support C11 (namely >= v19.27)
also support the restrict keyword, therefore av_restrict
is no longer necessary since 75697836b1db3e0f0a3b7061be6be28d00c675a0.

Signed-off-by: Andreas Rheinhardt 
---
Untested except via godbolt.
MSVC actually uses it for optimizations: https://godbolt.org/z/3EzPnff9T


This change looks good overall, thanks! Fate runs successfully both with 
an old version of MSVC targeting x86_64 and a new one targeting aarch64.


However, MSVC 19.27 (aka 2019 16.7) can't successfully build ffmpeg at the 
moment - it regressed in ec1b6e0cd404b2f7f4d202802b1c0a40d52fc9b0. Now 
building fails with this error:


src/libavcodec/ccaption_dec.c(186): error C2143: syntax error: missing ')' 
before 'sizeof'
src/libavcodec/ccaption_dec.c(186): error C2143: syntax error: missing '{' 
before 'sizeof'
src/libavcodec/ccaption_dec.c(186): error C2059: syntax error: 'sizeof'

This issue is not present with the following version, MSVC 2019 16.8 
(aka 19.28) though.



Btw: The block about __declspec(restrict) was always unneeded
for FFmpeg due to 17fad33f81c7e9787fcdc17934fc1eee6c6aa4bf.
It came from Libav commit 17fad33f81c7e9787fcdc17934fc1eee6c6aa4bf.


This looks like a copypaste typo, I presume the latter should have been 
0cff125200ab53fa3ae70d85b4f614f269fe3426. (The code it changed originated 
in dfa559bcbd41397b3408c59d016631c7c65e320f in libav.)


// Martin

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

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


Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/aom_film_grain: add AOM film grain synthesis

2024-03-15 Thread Niklas Haas
Tested and validated against official reference files.

Any objection to merging this as-is?

I would rather submit a separate series for adding a new public API, as
well as for exposing multiple film grain parameter sets, both of which
are incremental additions on top of the parsing and synthesis code this
series adds.
___
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] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-15 Thread Niklas Haas
> This should be &tmp. It is probably the reason for Michael's segfault.
> Apart from that: It is easier if you simply used 0..2 for *iter (1==
> returned sws_get_class, 2 returned ff_framesync_child_class_iterate).

Changed this function to:

static const AVClass *child_class_iterate(void **iter)
{
void *tmp = NULL;
switch ((uintptr_t)*iter) {
case 0:
*iter = (void*)(uintptr_t)1;
return sws_get_class();
case 1:
*iter = (void*)(uintptr_t)2;
return ff_framesync_child_class_iterate(&tmp);
}

return NULL;
}
___
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] vvcdec: Mark as experimental

2024-03-15 Thread Kieran Kunhya
On Thu, 14 Mar 2024, 22:54 Michael Niedermayer, 
wrote:

> On Wed, Feb 07, 2024 at 10:55:18PM +, Kieran Kunhya wrote:
> > On Wed, 7 Feb 2024 at 22:06, Paul B Mahol  wrote:
> >
> > > On Wed, Feb 7, 2024 at 10:13 PM Kieran Kunhya  wrote:
> > >
> > > > $subj
> > > >
> > > > As discussed at FOSDEM.
> > > >
> > >
> > > Author of this patch above is forced to FUZZ this decoder until
> > > experimental flag is removed.
> > >
> >
> > Sure, I will set some fuzzers up over the weekend.
>
> over a month later ...
> has this been done ?
>
>
> thx
>
> [...]
>

Frank said there was no need as he was doing it himself.

I do not appreciate your passive aggressive tone.

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] configure: Remove av_restrict

2024-03-15 Thread Andreas Rheinhardt
Martin Storsjö:
> On Sun, 10 Mar 2024, Andreas Rheinhardt wrote:
> 
>> All versions of MSVC that support C11 (namely >= v19.27)
>> also support the restrict keyword, therefore av_restrict
>> is no longer necessary since 75697836b1db3e0f0a3b7061be6be28d00c675a0.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>> Untested except via godbolt.
>> MSVC actually uses it for optimizations: https://godbolt.org/z/3EzPnff9T
> 
> This change looks good overall, thanks! Fate runs successfully both with
> an old version of MSVC targeting x86_64 and a new one targeting aarch64.
> 
> However, MSVC 19.27 (aka 2019 16.7) can't successfully build ffmpeg at
> the moment - it regressed in ec1b6e0cd404b2f7f4d202802b1c0a40d52fc9b0.
> Now building fails with this error:
> 
> src/libavcodec/ccaption_dec.c(186): error C2143: syntax error: missing
> ')' before 'sizeof'
> src/libavcodec/ccaption_dec.c(186): error C2143: syntax error: missing
> '{' before 'sizeof'
> src/libavcodec/ccaption_dec.c(186): error C2059: syntax error: 'sizeof'
> 
> This issue is not present with the following version, MSVC 2019 16.8
> (aka 19.28) though.
> 

Testing with Godbolt shows that MSVC 19.27 does not support
_Static_assert. But it supports static_assert (its synonym defined in
assert.h). So this is easy to fix.

>> Btw: The block about __declspec(restrict) was always unneeded
>> for FFmpeg due to 17fad33f81c7e9787fcdc17934fc1eee6c6aa4bf.
>> It came from Libav commit 17fad33f81c7e9787fcdc17934fc1eee6c6aa4bf.
> 
> This looks like a copypaste typo, I presume the latter should have been
> 0cff125200ab53fa3ae70d85b4f614f269fe3426. (The code it changed
> originated in dfa559bcbd41397b3408c59d016631c7c65e320f in libav.)
> 

Correct.

- 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] avcodec/ccaption_dec: Use static_assert instead of _Static_assert

2024-03-15 Thread Andreas Rheinhardt
The latter is not supported by MSVC 19.27.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ccaption_dec.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index faf058ce97..d8b992bb94 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include 
 #include "avcodec.h"
 #include "ass.h"
 #include "codec_internal.h"
@@ -180,9 +181,9 @@ static const char 
charset_overrides[4][128][sizeof("\u266a")] =
 };
 #define EMPTY_START(IDX)
 #define EMPTY_END
-#define ASSERT_ENTRY(IDX, str) \
-_Static_assert(sizeof(str) <= sizeof(charset_overrides[0][0]), \
-   "'" str "' string takes too much space");
+#define ASSERT_ENTRY(IDX, str)\
+static_assert(sizeof(str) <= sizeof(charset_overrides[0][0]), \
+  "'" str "' string takes too much space");
 CHARSET_OVERRIDE_LIST(EMPTY_START, ASSERT_ENTRY, EMPTY_END)
 
 static const unsigned char bg_attribs[8] = // Color
-- 
2.40.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] tools/target_dec_fuzzer: force experimental flag for decoders that need it

2024-03-15 Thread James Almer
Otherwise they will not even open.

Signed-off-by: James Almer 
---
 tools/target_dec_fuzzer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 84b646b7f4..a7642057f3 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -333,6 +333,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 
 ctx->max_samples = maxsamples_per_frame;
 ctx->get_buffer2 = fuzz_get_buffer2;
+if (c->p.capabilities & AV_CODEC_CAP_EXPERIMENTAL)
+ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
 
 if (size > 1024) {
 GetByteContext gbc;
-- 
2.44.0

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

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


[FFmpeg-devel] [PATCH v3 0/9] AFGS1 film grain support

2024-03-15 Thread Niklas Haas
Changes from v2:

- Expose the AFGS1-exclusive parameters publicly (as part of
  AVFilmGrainAOMParams)
- Slightly change the AFGS1 parsing code as a result
- Properly clear whole struct on error, to avoid leaking bad state
- Attach all parameter sets (as separate side data instances), rather
  than just the best
- Add a new public helper function to choose/validate fgp sets

Ended up replacing v2 entirely, instead of making this a separate
series, because I ended up entirely deleting the internal AFGS1 param
set structure I was using previously.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v3 1/9] avutil/film_grain_params: add extra AFGS1 metadata

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

In hindsight, it may have been better for this to be part of the common
film grain struct, to avoid duplication of these fields between it and
H274 (and to allow initialization by av_film_grain_params_alloc), but
I can't add new fields before the union without breaking ABI, and having
the union not be the last parameter will make future extensibility
similarly difficult.
---
 doc/APIchanges|  4 
 libavutil/film_grain_params.h | 15 +++
 libavutil/version.h   |  2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index cf58c8c5f0a..5a192b600af 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-03-08 - xx - lavu 59.2.100 - film_grain_params.h
+  Add AVFilmGrainAOMParams.color_range, color_primaries, color_trc,
+  color_space, width, height, subx, suby and bit_depth.
+
 2024-03-08 - xx - lavc 61.1.100 - avcodec.h
   Add AVCodecContext.[nb_]side_data_prefer_packet.
 
diff --git a/libavutil/film_grain_params.h b/libavutil/film_grain_params.h
index f3bd0a4a6a3..17fefeb06c3 100644
--- a/libavutil/film_grain_params.h
+++ b/libavutil/film_grain_params.h
@@ -120,6 +120,21 @@ typedef struct AVFilmGrainAOMParams {
  * Signals to clip to limited color levels after film grain application.
  */
 int limit_output_range;
+
+/**
+ * Video characteristics metadata, only for AFGS1 streams.
+ */
+enum AVColorRange  color_range;
+enum AVColorPrimaries  color_primaries;
+enum AVColorTransferCharacteristic color_trc;
+enum AVColorSpace  color_space;
+
+/**
+ * Intended display resolution and format, only for AFGS1 streams.
+ */
+int width, height;
+int subx, suby;
+int bit_depth; /* or 0 if unknown */
 } AVFilmGrainAOMParams;
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index 09f8cdc2926..57cad02ec0a 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  59
-#define LIBAVUTIL_VERSION_MINOR   1
+#define LIBAVUTIL_VERSION_MINOR   2
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.44.0

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

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


[FFmpeg-devel] [PATCH v3 2/9] avcodec/av1dec: initialize AFGS1 VSC metadata

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

Unused by AV1, but should still be set properly.
---
 libavcodec/av1dec.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index e6346b51dbe..8a5796c757f 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -1124,6 +1124,10 @@ static int export_film_grain(AVCodecContext *avctx, 
AVFrame *frame)
 aom->uv_mult_luma[1] = film_grain->cr_luma_mult;
 aom->uv_offset[0] = film_grain->cb_offset;
 aom->uv_offset[1] = film_grain->cr_offset;
+aom->color_range = AVCOL_RANGE_UNSPECIFIED;
+aom->color_primaries = AVCOL_PRI_UNSPECIFIED;
+aom->color_trc = AVCOL_TRC_UNSPECIFIED;
+aom->color_space = AVCOL_SPC_UNSPECIFIED;
 
 return 0;
 }
-- 
2.44.0

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

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


[FFmpeg-devel] [PATCH v3 3/9] avcodec/libdav1d: initialize AFGS1 VSC metadata

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

Unused by AV1, but should still be set properly.
---
 libavcodec/libdav1d.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 1aa2d1f3436..6251ea79ba8 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -628,6 +628,10 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
AVFrame *frame)
 fgp->codec.aom.grain_scale_shift = 
p->frame_hdr->film_grain.data.grain_scale_shift;
 fgp->codec.aom.overlap_flag = 
p->frame_hdr->film_grain.data.overlap_flag;
 fgp->codec.aom.limit_output_range = 
p->frame_hdr->film_grain.data.clip_to_restricted_range;
+fgp->codec.aom.color_range = AVCOL_RANGE_UNSPECIFIED;
+fgp->codec.aom.color_primaries = AVCOL_PRI_UNSPECIFIED;
+fgp->codec.aom.color_trc = AVCOL_TRC_UNSPECIFIED;
+fgp->codec.aom.color_space = AVCOL_SPC_UNSPECIFIED;
 
 memcpy(&fgp->codec.aom.y_points, 
&p->frame_hdr->film_grain.data.y_points,
sizeof(fgp->codec.aom.y_points));
-- 
2.44.0

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

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


[FFmpeg-devel] [PATCH v3 4/9] avutil/frame: clarify AV_FRAME_DATA_FILM_GRAIN_PARAMS usage

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

To allow for AFGS1 usage, which can expose multiple parameter sets for
a single frame.
---
 libavutil/frame.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/frame.h b/libavutil/frame.h
index b94687941db..7f616488be8 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -180,6 +180,10 @@ enum AVFrameSideDataType {
 /**
  * Film grain parameters for a frame, described by AVFilmGrainParams.
  * Must be present for every frame which should have film grain applied.
+ *
+ * May be present multiple times, for example when there are multiple
+ * alternative parameter sets for different video signal characteristics.
+ * The user should select the most appropriate set for the application.
  */
 AV_FRAME_DATA_FILM_GRAIN_PARAMS,
 
-- 
2.44.0

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

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


[FFmpeg-devel] [PATCH v3 5/9] avutil/film_grain_params: add av_film_grain_params_select()

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

Common utility function that can be used by all codecs to select the
right (any valid) film grain parameter set. In particular, this is
useful for AFGS1, which has support for multiple parameters.

However, it also performs parameter validation for H274.
---
 doc/APIchanges|  3 ++
 libavutil/film_grain_params.c | 57 +++
 libavutil/film_grain_params.h |  7 +
 libavutil/version.h   |  2 +-
 4 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5a192b600af..34245c8b708 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-03-08 - xx - lavu 59.3.100 - film_grain_params.h
+  Add av_film_grain_params_select().
+
 2024-03-08 - xx - lavu 59.2.100 - film_grain_params.h
   Add AVFilmGrainAOMParams.color_range, color_primaries, color_trc,
   color_space, width, height, subx, suby and bit_depth.
diff --git a/libavutil/film_grain_params.c b/libavutil/film_grain_params.c
index 930d23c7fe9..8c80adc66a7 100644
--- a/libavutil/film_grain_params.c
+++ b/libavutil/film_grain_params.c
@@ -17,6 +17,7 @@
  */
 
 #include "film_grain_params.h"
+#include "pixdesc.h"
 
 AVFilmGrainParams *av_film_grain_params_alloc(size_t *size)
 {
@@ -40,3 +41,59 @@ AVFilmGrainParams 
*av_film_grain_params_create_side_data(AVFrame *frame)
 
 return (AVFilmGrainParams *)side_data->data;
 }
+
+const AVFilmGrainParams *av_film_grain_params_select(const AVFrame *frame)
+{
+const AVFilmGrainParams *fgp, *best = NULL;
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
+const AVFilmGrainAOMParams *aom;
+const AVFilmGrainH274Params *h274;
+if (!desc)
+return NULL;
+
+#define CHECK(a, b, unspec) \
+do {\
+if ((a) != (unspec) && (b) != (unspec) && (a) != (b))   \
+continue;   \
+} while (0)
+
+for (int i = 0; i < frame->nb_side_data; i++) {
+if (frame->side_data[i]->type != AV_FRAME_DATA_FILM_GRAIN_PARAMS)
+continue;
+fgp = (const AVFilmGrainParams*)frame->side_data[i]->data;
+switch (fgp->type) {
+case AV_FILM_GRAIN_PARAMS_NONE:
+continue;
+case AV_FILM_GRAIN_PARAMS_AV1:
+aom = &fgp->codec.aom;
+if (aom->subx != desc->log2_chroma_w || aom->suby != 
desc->log2_chroma_h)
+continue;
+CHECK(aom->bit_depth,   desc->comp[0].depth, 0);
+CHECK(aom->width,   frame->width, 0);
+CHECK(aom->height,  frame->height, 0);
+CHECK(aom->color_range, frame->color_range, 
AVCOL_RANGE_UNSPECIFIED);
+CHECK(aom->color_primaries, frame->color_primaries, 
AVCOL_PRI_UNSPECIFIED);
+CHECK(aom->color_trc,   frame->color_trc,   
AVCOL_TRC_UNSPECIFIED);
+CHECK(aom->color_space, frame->colorspace,  
AVCOL_SPC_UNSPECIFIED);
+
+if (!best ||
+best->codec.aom.width < aom->width ||
+best->codec.aom.height < aom->height)
+best = fgp;
+break;
+case AV_FILM_GRAIN_PARAMS_H274:
+h274 = &fgp->codec.h274;
+/* There are no YUV formats with different bit depth per component,
+ * so just check both against the first component for simplicity */
+CHECK(h274->bit_depth_luma,   desc->comp[0].depth, 0);
+CHECK(h274->bit_depth_chroma, desc->comp[0].depth, 0);
+CHECK(h274->color_range,  frame->color_range, 
AVCOL_RANGE_UNSPECIFIED);
+CHECK(h274->color_primaries,  frame->color_primaries, 
AVCOL_PRI_UNSPECIFIED);
+CHECK(h274->color_trc,frame->color_trc,   
AVCOL_TRC_UNSPECIFIED);
+CHECK(h274->color_space,  frame->colorspace,  
AVCOL_SPC_UNSPECIFIED);
+return fgp; /* H274 can't have multiple resolutions */
+}
+}
+
+return best;
+}
diff --git a/libavutil/film_grain_params.h b/libavutil/film_grain_params.h
index 17fefeb06c3..75c020ceb92 100644
--- a/libavutil/film_grain_params.h
+++ b/libavutil/film_grain_params.h
@@ -272,4 +272,11 @@ AVFilmGrainParams *av_film_grain_params_alloc(size_t 
*size);
  */
 AVFilmGrainParams *av_film_grain_params_create_side_data(AVFrame *frame);
 
+/**
+ * Select the most appropriate film grain parameters set for the frame,
+ * taking into account the frame's format, resolution and video signal
+ * characteristics.
+ */
+const AVFilmGrainParams *av_film_grain_params_select(const AVFrame *frame);
+
 #endif /* AVUTIL_FILM_GRAIN_PARAMS_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 57cad02ec0a..5027b025be4 100644
--- a/libavutil/version.

[FFmpeg-devel] [PATCH v3 6/9] avcodec/aom_film_grain: add AOM film grain synthesis

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

Implementation copied wholesale from dav1d, sans SIMD, under permissive
license. This implementation was extensively verified to be bit-exact,
so it serves as a much better starting point than trying to re-engineer
this from scratch for no reason. (I also authored the original
implementation in dav1d, so any "clean room" implementation would end up
looking much the same, anyway)

The notable changes I had to make while adapting this from the dav1d
code-base to the FFmpeg codebase include:

- reordering variable declarations to avoid triggering warnings
- replacing several inline helpers by avutil equivalents
- changing code that accesses frame metadata
- replacing raw plane copying logic by av_image_copy_plane

Apart from this, the implementation is basically unmodified.
---
 libavcodec/aom_film_grain.c  | 310 ++
 libavcodec/aom_film_grain.h  |  38 ++
 libavcodec/aom_film_grain_template.c | 577 +++
 3 files changed, 925 insertions(+)
 create mode 100644 libavcodec/aom_film_grain.c
 create mode 100644 libavcodec/aom_film_grain.h
 create mode 100644 libavcodec/aom_film_grain_template.c

diff --git a/libavcodec/aom_film_grain.c b/libavcodec/aom_film_grain.c
new file mode 100644
index 000..ffcd71b584b
--- /dev/null
+++ b/libavcodec/aom_film_grain.c
@@ -0,0 +1,310 @@
+/*
+ * AOM film grain synthesis
+ * Copyright (c) 2023 Niklas Haas 
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * AOM film grain synthesis.
+ * @author Niklas Haas 
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+
+#include "aom_film_grain.h"
+
+// Common/shared helpers (not dependent on BIT_DEPTH)
+static inline int get_random_number(const int bits, unsigned *const state) {
+const int r = *state;
+unsigned bit = ((r >> 0) ^ (r >> 1) ^ (r >> 3) ^ (r >> 12)) & 1;
+*state = (r >> 1) | (bit << 15);
+
+return (*state >> (16 - bits)) & ((1 << bits) - 1);
+}
+
+static inline int round2(const int x, const uint64_t shift) {
+return (x + ((1 << shift) >> 1)) >> shift;
+}
+
+enum {
+GRAIN_WIDTH  = 82,
+GRAIN_HEIGHT = 73,
+SUB_GRAIN_WIDTH  = 44,
+SUB_GRAIN_HEIGHT = 38,
+FG_BLOCK_SIZE= 32,
+};
+
+static const int16_t gaussian_sequence[2048];
+
+#define BIT_DEPTH 16
+#include "aom_film_grain_template.c"
+#undef BIT_DEPTH
+
+#define BIT_DEPTH 8
+#include "aom_film_grain_template.c"
+#undef BIT_DEPTH
+
+
+int ff_aom_apply_film_grain(AVFrame *out, const AVFrame *in,
+const AVFilmGrainParams *params)
+{
+const AVFilmGrainAOMParams *const data = ¶ms->codec.aom;
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(out->format);
+const int subx = desc->log2_chroma_w, suby = desc->log2_chroma_h;
+const int pxstep = desc->comp[0].step;
+
+av_assert0(out->format == in->format);
+av_assert0(params->type == AV_FILM_GRAIN_PARAMS_AV1);
+
+// Copy over the non-modified planes
+if (!params->codec.aom.num_y_points) {
+av_image_copy_plane(out->data[0], out->linesize[0],
+in->data[0], in->linesize[0],
+out->width * pxstep, out->height);
+}
+for (int uv = 0; uv < 2; uv++) {
+if (!data->num_uv_points[uv]) {
+av_image_copy_plane(out->data[1+uv], out->linesize[1+uv],
+in->data[1+uv], in->linesize[1+uv],
+AV_CEIL_RSHIFT(out->width, subx) * pxstep,
+AV_CEIL_RSHIFT(out->height, suby));
+}
+}
+
+switch (in->format) {
+case AV_PIX_FMT_GRAY8:
+case AV_PIX_FMT_YUV420P:
+case AV_PIX_FMT_YUV422P:
+case AV_PIX_FMT_YUV444P:
+case AV_PIX_FMT_YUVJ420P:
+case AV_PIX_FMT_YUVJ422P:
+case AV_PIX_FMT_YUVJ444P:
+return apply_film_grain_8(out, in, params);
+case AV_PIX_FMT_GRAY9:
+case AV_PIX_FMT_YUV420P9:
+case AV_PIX_FMT_YUV422P9:
+case AV_PIX_FMT_YUV444P9:
+return apply_film_grain_16(out, in, params, 9);
+case AV_PIX_FMT_GRAY10:
+case AV_PIX_FMT_YUV420P10:
+case AV_PIX_FMT_YUV422P10:
+case AV_PIX_FMT_YUV444P10:
+return apply_film_grain_16(out, in, params, 10);
+

[FFmpeg-devel] [PATCH v3 7/9] avcodec/aom_film_grain: implement AFGS1 parsing

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

Based on the AOMedia Film Grain Synthesis 1 (AFGS1) spec:
  https://aomediacodec.github.io/afgs1-spec/

The parsing has been changed substantially relative to the AV1 film
grain OBU. In particular:

1. There is the possibility of maintaining multiple independent film
   grain parameter sets, and decoders/players are recommended to pick
   the one most appropriate for the intended display resolution. This
   could also be used to e.g. switch between different grain profiles
   without having to re-signal the appropriate coefficients.

2. Supporting this, it's possible to *predict* the grain coefficients
   from previously signalled parameter sets, transmitting only the
   residual.

3. When not predicting, the parameter sets are now stored as a series of
   increments, rather than being directly transmitted.

4. There are several new AFGS1-exclusive fields.

I placed this parser in its own file, rather than h2645_sei.c, since
nothing in the generic AFGS1 film grain payload is specific to T.35, and
to compartmentalize the code base.
---
 libavcodec/aom_film_grain.c | 236 
 libavcodec/aom_film_grain.h |  13 ++
 2 files changed, 249 insertions(+)

diff --git a/libavcodec/aom_film_grain.c b/libavcodec/aom_film_grain.c
index ffcd71b584b..ea38935ca98 100644
--- a/libavcodec/aom_film_grain.c
+++ b/libavcodec/aom_film_grain.c
@@ -29,6 +29,7 @@
 #include "libavutil/imgutils.h"
 
 #include "aom_film_grain.h"
+#include "get_bits.h"
 
 // Common/shared helpers (not dependent on BIT_DEPTH)
 static inline int get_random_number(const int bits, unsigned *const state) {
@@ -118,6 +119,241 @@ int ff_aom_apply_film_grain(AVFrame *out, const AVFrame 
*in,
 return AVERROR_INVALIDDATA;
 }
 
+int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s,
+ const uint8_t *payload, int payload_size)
+{
+GetBitContext gbc, *gb = &gbc;
+AVFilmGrainAOMParams *aom;
+AVFilmGrainParams *fgp, *ref = NULL;
+int ret, num_sets, n, i, uv, num_y_coeffs, update_grain, luma_only;
+
+ret = init_get_bits8(gb, payload, payload_size);
+if (ret < 0)
+return ret;
+
+s->enable = get_bits1(gb);
+if (!s->enable)
+return 0;
+
+skip_bits(gb, 4); // reserved
+num_sets = get_bits(gb, 3) + 1;
+for (n = 0; n < num_sets; n++) {
+int payload_4byte, payload_size, set_idx, apply_units_log2, vsc_flag;
+int predict_scaling, predict_y_scaling, predict_uv_scaling[2];
+int payload_bits, start_position;
+
+start_position = get_bits_count(gb);
+payload_4byte = get_bits1(gb);
+payload_size = get_bits(gb, payload_4byte ? 2 : 8);
+set_idx = get_bits(gb, 3);
+fgp = &s->sets[set_idx];
+aom = &fgp->codec.aom;
+
+fgp->type = get_bits1(gb) ? AV_FILM_GRAIN_PARAMS_AV1 : 
AV_FILM_GRAIN_PARAMS_NONE;
+if (!fgp->type)
+continue;
+
+fgp->seed = get_bits(gb, 16);
+update_grain = get_bits1(gb);
+if (!update_grain)
+continue;
+
+apply_units_log2  = get_bits(gb, 4);
+aom->width  = get_bits(gb, 12) << apply_units_log2;
+aom->height = get_bits(gb, 12) << apply_units_log2;
+luma_only = get_bits1(gb);
+if (luma_only) {
+aom->subx = aom->suby = 0;
+} else {
+aom->subx = get_bits1(gb);
+aom->suby = get_bits1(gb);
+}
+
+aom->bit_depth   = 0;
+aom->color_primaries = AVCOL_PRI_UNSPECIFIED;
+aom->color_trc   = AVCOL_TRC_UNSPECIFIED;
+aom->color_space = AVCOL_SPC_UNSPECIFIED;
+aom->color_range = AVCOL_RANGE_UNSPECIFIED;
+
+vsc_flag = get_bits1(gb); // video_signal_characteristics_flag
+if (vsc_flag) {
+int cicp_flag;
+aom->bit_depth = get_bits(gb, 3) + 8;
+cicp_flag = get_bits1(gb);
+if (cicp_flag) {
+aom->color_primaries = get_bits(gb, 8);
+aom->color_trc = get_bits(gb, 8);
+aom->color_space = get_bits(gb, 8);
+aom->color_range = get_bits1(gb) ? AVCOL_RANGE_JPEG : 
AVCOL_RANGE_MPEG;
+if (aom->color_primaries > AVCOL_PRI_NB ||
+aom->color_primaries == AVCOL_PRI_RESERVED ||
+aom->color_primaries == AVCOL_PRI_RESERVED0 ||
+aom->color_trc > AVCOL_TRC_NB ||
+aom->color_trc == AVCOL_TRC_RESERVED ||
+aom->color_trc == AVCOL_TRC_RESERVED0 ||
+aom->color_space > AVCOL_SPC_NB ||
+aom->color_space == AVCOL_SPC_RESERVED)
+goto error;
+}
+}
+
+predict_scaling = get_bits1(gb);
+if (predict_scaling && (!ref || ref == fgp))
+goto error; // prediction must be from valid, different set
+
+predict_y_scaling = predict_scaling ? get_bits1(gb)

[FFmpeg-devel] [PATCH v3 8/9] avcodec/h2645_sei: decode AFGS1 T.35 SEI

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

I restricted this SEI to HEVC for now, until I see a H.264 sample.
---
 libavcodec/Makefile|  2 +-
 libavcodec/h2645_sei.c | 25 +
 libavcodec/h2645_sei.h |  3 +++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 708434ac76c..824845276ae 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -105,7 +105,7 @@ OBJS-$(CONFIG_H264_SEI)+= h264_sei.o 
h2645_sei.o
 OBJS-$(CONFIG_HEVCPARSE)   += hevc_parse.o hevc_ps.o hevc_data.o \
   h2645data.o h2645_parse.o h2645_vui.o
 OBJS-$(CONFIG_HEVC_SEI)+= hevc_sei.o h2645_sei.o \
-  dynamic_hdr_vivid.o
+  dynamic_hdr_vivid.o aom_film_grain.o
 OBJS-$(CONFIG_HPELDSP) += hpeldsp.o
 OBJS-$(CONFIG_HUFFMAN) += huffman.o
 OBJS-$(CONFIG_HUFFYUVDSP)  += huffyuvdsp.o
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index e60606f43f9..2e79b9ea78b 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -209,6 +209,24 @@ static int decode_registered_user_data(H2645SEI *h, 
GetByteContext *gb,
 }
 break;
 }
+case 0x5890: { // aom_provider_code
+const uint16_t aom_grain_provider_oriented_code = 0x0001;
+uint16_t provider_oriented_code;
+
+if (!IS_HEVC(codec_id))
+goto unsupported_provider_code;
+
+if (bytestream2_get_bytes_left(gb) < 2)
+return AVERROR_INVALIDDATA;
+
+provider_oriented_code = bytestream2_get_byteu(gb);
+if (provider_oriented_code == aom_grain_provider_oriented_code) {
+return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
+gb->buffer,
+
bytestream2_get_bytes_left(gb));
+}
+break;
+}
 unsupported_provider_code:
 #endif
 default:
@@ -692,6 +710,12 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
 }
 
+#if CONFIG_HEVC_SEI
+ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame);
+if (ret < 0)
+return ret;
+#endif
+
 if (sei->ambient_viewing_environment.present) {
 H2645SEIAmbientViewingEnvironment *env =
 &sei->ambient_viewing_environment;
@@ -788,4 +812,5 @@ void ff_h2645_sei_reset(H2645SEI *s)
 s->ambient_viewing_environment.present = 0;
 s->mastering_display.present = 0;
 s->content_light.present = 0;
+s->aom_film_grain.enable = 0;
 }
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 0ebf48011af..b9a6c7587b1 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -23,7 +23,9 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/frame.h"
+#include "libavutil/film_grain_params.h"
 
+#include "aom_film_grain.h"
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_id.h"
@@ -132,6 +134,7 @@ typedef struct H2645SEI {
 H2645SEIAmbientViewingEnvironment ambient_viewing_environment;
 H2645SEIMasteringDisplay mastering_display;
 H2645SEIContentLight content_light;
+AVFilmGrainAFGS1Params aom_film_grain;
 } H2645SEI;
 
 enum {
-- 
2.44.0

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

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


[FFmpeg-devel] [PATCH v3 9/9] avcodec/hevcdec: apply AOM film grain synthesis

2024-03-15 Thread Niklas Haas
From: Niklas Haas 

Following the usual logic for H.274 film grain.
---
 libavcodec/Makefile  |  2 +-
 libavcodec/hevcdec.c | 29 ++---
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 824845276ae..7ef2e03ca6a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -432,7 +432,7 @@ OBJS-$(CONFIG_HDR_ENCODER) += hdrenc.o
 OBJS-$(CONFIG_HEVC_DECODER)+= hevcdec.o hevc_mvs.o \
   hevc_cabac.o hevc_refs.o hevcpred.o  
  \
   hevcdsp.o hevc_filter.o hevc_data.o \
-  h274.o
+  h274.o aom_film_grain.o
 OBJS-$(CONFIG_HEVC_AMF_ENCODER)+= amfenc_hevc.o
 OBJS-$(CONFIG_HEVC_CUVID_DECODER)  += cuviddec.o
 OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 76aa6b45882..575836e340c 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -35,6 +35,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/timecode.h"
 
+#include "aom_film_grain.h"
 #include "bswapdsp.h"
 #include "cabac_functions.h"
 #include "codec_internal.h"
@@ -388,7 +389,8 @@ static int export_stream_params_from_sei(HEVCContext *s)
 avctx->color_trc = 
s->sei.common.alternative_transfer.preferred_transfer_characteristics;
 }
 
-if (s->sei.common.film_grain_characteristics.present)
+if (s->sei.common.film_grain_characteristics.present ||
+s->sei.common.aom_film_grain.enable)
 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
 
 return 0;
@@ -2885,11 +2887,13 @@ static int hevc_frame_start(HEVCContext *s)
 else
 s->ref->frame->flags &= ~AV_FRAME_FLAG_KEY;
 
-s->ref->needs_fg = s->sei.common.film_grain_characteristics.present &&
+s->ref->needs_fg = (s->sei.common.film_grain_characteristics.present ||
+s->sei.common.aom_film_grain.enable) &&
 !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
 !s->avctx->hwaccel;
 
 if (s->ref->needs_fg &&
+s->sei.common.film_grain_characteristics.present &&
 
!ff_h274_film_grain_params_supported(s->sei.common.film_grain_characteristics.model_id,
  s->ref->frame->format)) {
 av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, 
&s->film_grain_warning_shown,
@@ -2934,14 +2938,24 @@ fail:
 static int hevc_frame_end(HEVCContext *s)
 {
 HEVCFrame *out = s->ref;
-const AVFrameSideData *sd;
+const AVFilmGrainParams *fgp;
 av_unused int ret;
 
 if (out->needs_fg) {
-sd = av_frame_get_side_data(out->frame, 
AV_FRAME_DATA_FILM_GRAIN_PARAMS);
-av_assert0(out->frame_grain->buf[0] && sd);
-ret = ff_h274_apply_film_grain(out->frame_grain, out->frame, 
&s->h274db,
-   (AVFilmGrainParams *) sd->data);
+av_assert0(out->frame_grain->buf[0]);
+fgp = av_film_grain_params_select(out->frame);
+switch (fgp->type) {
+case AV_FILM_GRAIN_PARAMS_NONE:
+av_assert0(0);
+return AVERROR_BUG;
+case AV_FILM_GRAIN_PARAMS_H274:
+ret = ff_h274_apply_film_grain(out->frame_grain, out->frame,
+   &s->h274db, fgp);
+break;
+case AV_FILM_GRAIN_PARAMS_AV1:
+ret = ff_aom_apply_film_grain(out->frame_grain, out->frame, fgp);
+break;
+}
 av_assert1(ret >= 0);
 }
 
@@ -3596,6 +3610,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer;
 s->sei.common.mastering_display= s0->sei.common.mastering_display;
 s->sei.common.content_light= s0->sei.common.content_light;
+s->sei.common.aom_film_grain   = s0->sei.common.aom_film_grain;
 
 ret = export_stream_params_from_sei(s);
 if (ret < 0)
-- 
2.44.0

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

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


Re: [FFmpeg-devel] [PATCH v3 5/9] avutil/film_grain_params: add av_film_grain_params_select()

2024-03-15 Thread Niklas Haas
On Fri, 15 Mar 2024 12:58:58 +0100 Niklas Haas  wrote:
> From: Niklas Haas 
> 
> Common utility function that can be used by all codecs to select the
> right (any valid) film grain parameter set. In particular, this is
> useful for AFGS1, which has support for multiple parameters.
> 
> However, it also performs parameter validation for H274.
> ---
>  doc/APIchanges|  3 ++
>  libavutil/film_grain_params.c | 57 +++
>  libavutil/film_grain_params.h |  7 +
>  libavutil/version.h   |  2 +-
>  4 files changed, 68 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 5a192b600af..34245c8b708 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
>  
>  API changes, most recent first:
>  
> +2024-03-08 - xx - lavu 59.3.100 - film_grain_params.h
> +  Add av_film_grain_params_select().
> +
>  2024-03-08 - xx - lavu 59.2.100 - film_grain_params.h
>Add AVFilmGrainAOMParams.color_range, color_primaries, color_trc,
>color_space, width, height, subx, suby and bit_depth.
> diff --git a/libavutil/film_grain_params.c b/libavutil/film_grain_params.c
> index 930d23c7fe9..8c80adc66a7 100644
> --- a/libavutil/film_grain_params.c
> +++ b/libavutil/film_grain_params.c
> @@ -17,6 +17,7 @@
>   */
>  
>  #include "film_grain_params.h"
> +#include "pixdesc.h"
>  
>  AVFilmGrainParams *av_film_grain_params_alloc(size_t *size)
>  {
> @@ -40,3 +41,59 @@ AVFilmGrainParams 
> *av_film_grain_params_create_side_data(AVFrame *frame)
>  
>  return (AVFilmGrainParams *)side_data->data;
>  }
> +
> +const AVFilmGrainParams *av_film_grain_params_select(const AVFrame *frame)
> +{
> +const AVFilmGrainParams *fgp, *best = NULL;
> +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
> +const AVFilmGrainAOMParams *aom;
> +const AVFilmGrainH274Params *h274;
> +if (!desc)
> +return NULL;
> +
> +#define CHECK(a, b, unspec) \
> +do {\
> +if ((a) != (unspec) && (b) != (unspec) && (a) != (b))   \
> +continue;   \
> +} while (0)
> +
> +for (int i = 0; i < frame->nb_side_data; i++) {
> +if (frame->side_data[i]->type != AV_FRAME_DATA_FILM_GRAIN_PARAMS)
> +continue;
> +fgp = (const AVFilmGrainParams*)frame->side_data[i]->data;
> +switch (fgp->type) {
> +case AV_FILM_GRAIN_PARAMS_NONE:
> +continue;
> +case AV_FILM_GRAIN_PARAMS_AV1:
> +aom = &fgp->codec.aom;
> +if (aom->subx != desc->log2_chroma_w || aom->suby != 
> desc->log2_chroma_h)
> +continue;
> +CHECK(aom->bit_depth,   desc->comp[0].depth, 0);
> +CHECK(aom->width,   frame->width, 0);
> +CHECK(aom->height,  frame->height, 0);

This condition is wrong, it should allow all aom->width <= frame->width;
not just an exact match.

> +CHECK(aom->color_range, frame->color_range, 
> AVCOL_RANGE_UNSPECIFIED);
> +CHECK(aom->color_primaries, frame->color_primaries, 
> AVCOL_PRI_UNSPECIFIED);
> +CHECK(aom->color_trc,   frame->color_trc,   
> AVCOL_TRC_UNSPECIFIED);
> +CHECK(aom->color_space, frame->colorspace,  
> AVCOL_SPC_UNSPECIFIED);
> +
> +if (!best ||
> +best->codec.aom.width < aom->width ||
> +best->codec.aom.height < aom->height)
> +best = fgp;
> +break;
> +case AV_FILM_GRAIN_PARAMS_H274:
> +h274 = &fgp->codec.h274;
> +/* There are no YUV formats with different bit depth per 
> component,
> + * so just check both against the first component for simplicity 
> */
> +CHECK(h274->bit_depth_luma,   desc->comp[0].depth, 0);
> +CHECK(h274->bit_depth_chroma, desc->comp[0].depth, 0);
> +CHECK(h274->color_range,  frame->color_range, 
> AVCOL_RANGE_UNSPECIFIED);
> +CHECK(h274->color_primaries,  frame->color_primaries, 
> AVCOL_PRI_UNSPECIFIED);
> +CHECK(h274->color_trc,frame->color_trc,   
> AVCOL_TRC_UNSPECIFIED);
> +CHECK(h274->color_space,  frame->colorspace,  
> AVCOL_SPC_UNSPECIFIED);
> +return fgp; /* H274 can't have multiple resolutions */
> +}
> +}
> +
> +return best;
> +}
> diff --git a/libavutil/film_grain_params.h b/libavutil/film_grain_params.h
> index 17fefeb06c3..75c020ceb92 100644
> --- a/libavutil/film_grain_params.h
> +++ b/libavutil/film_grain_params.h
> @@ -272,4 +272,11 @@ AVFilmGrainParams *av_film_grain_params_alloc(size_t 
> *size);
>   */
>  AVFilmGrainParams *av_film_grain_params_create_side_data(AVFrame *frame);
>  
> +/**
> + * S

Re: [FFmpeg-devel] [PATCH v3 2/9] avcodec/av1dec: initialize AFGS1 VSC metadata

2024-03-15 Thread Niklas Haas
On Fri, 15 Mar 2024 09:20:04 -0300 James Almer  wrote:
> On 3/15/2024 8:58 AM, Niklas Haas wrote:
> > From: Niklas Haas 
> > 
> > Unused by AV1, but should still be set properly.
> 
> The doxy for av_film_grain_params_alloc() says "Allocate an 
> AVFilmGrainParams structure and set its fields to default values", so 
> this should be done there.

This function doesn't know whether the film grain is of type AV1 or
H274, and so cannot set the correct codec-specific parameter defaults.

Unless, of course, we add these fields to the common struct, as
discussed above. (Or if we add the type to the function signature)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 01/26] fate/aac: add missing aresample filter dependency

2024-03-15 Thread James Almer

On 3/14/2024 8:00 PM, James Almer wrote:

Signed-off-by: James Almer 
---
  tests/fate/aac.mak | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 4f8d1cdcea..817944773d 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -243,17 +243,17 @@ fate-aac-latm_stereo_to_51: REF = 
$(SAMPLES)/aac/latm_stereo_to_51_ref.s16
  fate-aac-autobsf-adtstoasc: CMD = transcode "aac" 
$(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.adts \
  matroska "-c:a copy" "-c:a copy"
  
-FATE_AAC-$(call  DEMDEC, AAC,AAC)  += $(FATE_AAC_CT_RAW)

-FATE_AAC-$(call  DEMDEC, MOV,AAC)  += $(FATE_AAC)
-FATE_AAC_LATM-$(call DEMDEC, MPEGTS, AAC_LATM) += $(FATE_AAC_LATM)
-FATE_AAC-$(call  DEMDEC, AAC,AAC_FIXED)+= $(FATE_AAC_FIXED)
+FATE_AAC-$(call  DEMDEC, AAC,AAC,   ARESAMPLE_FILTER) += 
$(FATE_AAC_CT_RAW)
+FATE_AAC-$(call  DEMDEC, MOV,AAC,   ARESAMPLE_FILTER) += 
$(FATE_AAC)
+FATE_AAC_LATM-$(call DEMDEC, MPEGTS, AAC_LATM,  ARESAMPLE_FILTER) += 
$(FATE_AAC_LATM)
+FATE_AAC-$(call  DEMDEC, AAC,AAC_FIXED, ARESAMPLE_FILTER) += 
$(FATE_AAC_FIXED)
  
  FATE_AAC_ALL = $(FATE_AAC-yes) $(FATE_AAC_LATM-yes) $(FATE_AAC_FIXED-yes)
  
  $(FATE_AAC_ALL): CMP  = oneoff

  $(FATE_AAC_ALL): FUZZ = 2
  
-FATE_AAC_ENCODE-$(call ENCMUX, AAC, ADTS) += $(FATE_AAC_ENCODE)

+FATE_AAC_ENCODE-$(call ENCMUX, AAC, ADTS, ARESAMPLE_FILTER) += 
$(FATE_AAC_ENCODE)
  
  FATE_AAC_BSF-$(call ALLYES, AAC_DEMUXER AAC_ADTSTOASC_BSF MATROSKA_MUXER) += fate-aac-autobsf-adtstoasc


Will apply the set soon since it's trivial and fixes running fate with 
libswresample disabled.

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

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


[FFmpeg-devel] [PATCH] avcodec/tests/snowenc: Fix mixed declaration and code

2024-03-15 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/tests/snowenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/tests/snowenc.c b/libavcodec/tests/snowenc.c
index 37198cd4e3..3dad07d3a5 100644
--- a/libavcodec/tests/snowenc.c
+++ b/libavcodec/tests/snowenc.c
@@ -35,9 +35,9 @@ int main(void){
 SnowContext s;
 int i;
 AVLFG prng;
+int ret = 0;
 s.spatial_decomposition_count=6;
 s.spatial_decomposition_type=1;
-int ret = 0;
 
 s.temp_dwt_buffer  = av_calloc(width, sizeof(*s.temp_dwt_buffer));
 s.temp_idwt_buffer = av_calloc(width, sizeof(*s.temp_idwt_buffer));
-- 
2.40.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] avcodec/tests/snowenc: Fix mixed declaration and code

2024-03-15 Thread Sean McGovern
Hi,


On Fri, Mar 15, 2024, 10:24 Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/tests/snowenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/tests/snowenc.c b/libavcodec/tests/snowenc.c
> index 37198cd4e3..3dad07d3a5 100644
> --- a/libavcodec/tests/snowenc.c
> +++ b/libavcodec/tests/snowenc.c
> @@ -35,9 +35,9 @@ int main(void){
>  SnowContext s;
>  int i;
>  AVLFG prng;
> +int ret = 0;
>  s.spatial_decomposition_count=6;
>  s.spatial_decomposition_type=1;
> -int ret = 0;
>
>  s.temp_dwt_buffer  = av_calloc(width, sizeof(*s.temp_dwt_buffer));
>  s.temp_idwt_buffer = av_calloc(width, sizeof(*s.temp_idwt_buffer));
> --
> 2.40.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".
>

OK, looks good to me.

Thanks,
Sean McGovern

>
___
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/aeaenc: Fix printf-specifier

2024-03-15 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/aeaenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c
index 65d018c844..495e98c6a2 100644
--- a/libavformat/aeaenc.c
+++ b/libavformat/aeaenc.c
@@ -91,7 +91,7 @@ static int aea_write_trailer(struct AVFormatContext *s)
 avio_seek(pb, 260, SEEK_SET);
 total_blocks = st->nb_frames * st->codecpar->ch_layout.nb_channels;
 if (total_blocks > UINT32_MAX) {
-av_log(s, AV_LOG_WARNING, "Too many frames in the file to properly 
encode the header (%ld)."
+av_log(s, AV_LOG_WARNING, "Too many frames in the file to properly 
encode the header (%"PRId64")."
" Block count in the header will be truncated.\n", 
total_blocks);
 total_blocks = UINT32_MAX;
 }
-- 
2.40.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] avformat/crypto: Avoid cast, use proper printf specifier

2024-03-15 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index 75b00020bc..4393fb6399 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -254,7 +254,7 @@ static int64_t crypto_seek(URLContext *h, int64_t pos, int 
whence)
 newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE );
 if (newpos < 0) {
 av_log(h, AV_LOG_ERROR,
-"Crypto: seek_end - can't get file size (pos=%lld)\r\n", (long 
long int)pos);
+"Crypto: seek_end - can't get file size (pos=%"PRId64")\r\n", 
pos);
 return newpos;
 }
 pos = newpos - pos;
-- 
2.40.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 05/26] fate/amrnb: add missing aresample filter dependency

2024-03-15 Thread Andreas Rheinhardt
James Almer:
> Signed-off-by: James Almer 
> ---
>  tests/fate/amrnb.mak | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/fate/amrnb.mak b/tests/fate/amrnb.mak
> index 6f5ed413e3..3eb8b324f3 100644
> --- a/tests/fate/amrnb.mak
> +++ b/tests/fate/amrnb.mak
> @@ -30,11 +30,11 @@ FATE_AMRNB += fate-amrnb-12k2
>  fate-amrnb-12k2: CMD = pcm -i $(TARGET_SAMPLES)/amrnb/12.2k.amr
>  fate-amrnb-12k2: REF = $(SAMPLES)/amrnb/12.2k.pcm
>  
> -FATE_AMRNB_REMUX-$(call REMUX, AMR, AMR_PARSER) += fate-amrnb-remux
> +FATE_AMRNB_REMUX-$(call REMUX, AMR, AMR_PARSER ARESAMPLE_FILTER) += 
> fate-amrnb-remux
>  fate-amrnb-remux: CMD = transcode amr $(TARGET_SAMPLES)/amrnb/10.2k.amr amr 
> "-c copy" "-c copy -t 1"
>  
>  $(FATE_AMRNB): CMP = stddev
>  
> -FATE_SAMPLES_AVCONV-$(call DEMDEC, AMR, AMRNB) += $(FATE_AMRNB)
> +FATE_SAMPLES_AVCONV-$(call DEMDEC, AMR, AMRNB, ARESAMPLE_FILTER) += 
> $(FATE_AMRNB)
>  FATE_SAMPLES_FFMPEG += $(FATE_AMRNB_REMUX-yes)
>  fate-amrnb: $(FATE_AMRNB) $(FATE_AMRNB_REMUX-yes)

Please change FATE_SAMPLES_AVCONV to FATE_SAMPLES_FFMPEG on every line
you already touch.

- 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] vvcdec: Mark as experimental

2024-03-15 Thread Frank Plowman
On 15/03/2024 10:22, Kieran Kunhya wrote:
> On Thu, 14 Mar 2024, 22:54 Michael Niedermayer, 
> wrote:
> 
>> On Wed, Feb 07, 2024 at 10:55:18PM +, Kieran Kunhya wrote:
>>> On Wed, 7 Feb 2024 at 22:06, Paul B Mahol  wrote:
>>>
 On Wed, Feb 7, 2024 at 10:13 PM Kieran Kunhya  wrote:

> $subj
>
> As discussed at FOSDEM.
>

 Author of this patch above is forced to FUZZ this decoder until
 experimental flag is removed.

>>>
>>> Sure, I will set some fuzzers up over the weekend.
>>
>> over a month later ...
>> has this been done ?
>>
>>
>> thx
>>
>> [...]
>>
> 
> Frank said there was no need as he was doing it himself.
> 
> I do not appreciate your passive aggressive tone.
> 
> Kieran
> 

I have been fuzzing since the end of January.  Various patches have made
the decoder much more robust than it was then.  Still getting a crash on
occasion, but most are now false positives due to assertion failures
rather than segmentation faults or other potential security issues.
That being said, the hardware I am using is extremely modest compared to
oss-fuzz's.

-- 
Frank
___
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] vvcdec: Mark as experimental

2024-03-15 Thread Andreas Rheinhardt
Frank Plowman:
> On 15/03/2024 10:22, Kieran Kunhya wrote:
>> On Thu, 14 Mar 2024, 22:54 Michael Niedermayer, 
>> wrote:
>>
>>> On Wed, Feb 07, 2024 at 10:55:18PM +, Kieran Kunhya wrote:
 On Wed, 7 Feb 2024 at 22:06, Paul B Mahol  wrote:

> On Wed, Feb 7, 2024 at 10:13 PM Kieran Kunhya  wrote:
>
>> $subj
>>
>> As discussed at FOSDEM.
>>
>
> Author of this patch above is forced to FUZZ this decoder until
> experimental flag is removed.
>

 Sure, I will set some fuzzers up over the weekend.
>>>
>>> over a month later ...
>>> has this been done ?
>>>
>>>
>>> thx
>>>
>>> [...]
>>>
>>
>> Frank said there was no need as he was doing it himself.
>>
>> I do not appreciate your passive aggressive tone.
>>
>> Kieran
>>
> 
> I have been fuzzing since the end of January.  Various patches have made
> the decoder much more robust than it was then.  Still getting a crash on
> occasion, but most are now false positives due to assertion failures
> rather than segmentation faults or other potential security issues.
> That being said, the hardware I am using is extremely modest compared to
> oss-fuzz's.

An assertion failure is not a false positive. Even if it is an av_assert2.

- 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: enable UDP IPv6 multicast interface selection

2024-03-15 Thread Rémi Denis-Courmont
Le jeudi 14 mars 2024, 11:22:40 EET Ignjatović, Lazar (RS) a écrit :
> avformat: enable UDP IPv6 multicast interface selection
> 
> localaddr option now properly works with IPv6 addresses. Properly resolved
> interface index in places where default 0 interface index is used (marked
> with TODO: within udp.c). Added SO_BINDTODEVICE for mcast sockets that are
> used for reading from the network.

AFAIK, that is privileged, and is not intended for the purpose of scoping 
multicast.Where the need arises to specify an interface for multicast, there 
is typically a dedicated ioctl or field of an ioctl.

> Need for this arises from the fact that
> [ffx1::*] and [ffx2::*] mcast addresses need to have a defined interface
> for binding to avoid ambiguity between multiple link-local networks on the
> same host. Failing to set this option causes errors on Linux systems for
> interface and link-local scopes.
>
> For mcast addresses, bind to mcast address is attempted as before. In case
> that this fails, which will happen on Windows, socket is bound to
> INADDR_ANY/IN6ADDR_ANY_INIT depending on address family. Actual interface
> selection is performed using udp_set_multicast_interface to point to the
> desired interface for sending/listening.
> 
> Utilization of sin6_scope_id field enables usage and adequate resolving of
> IPv6 addresses that utilize zone index (e.g. fe80::1ff:fe23:4567:890a%eth2 )
> This is not fully supported on Windows, thus relying on this field is not
> done on Windows systems.
> 
> Closes: #368
> 
> Signed-off-by: Lazar Ignjatovic 
> ---
>  configure |  3 ++
>  libavformat/ip.c  | 45 
>  libavformat/ip.h  |  6 
>  libavformat/network.h |  6 
>  libavformat/udp.c | 80 ++-
>  5 files changed, 132 insertions(+), 8 deletions(-)
> 
> diff --git a/configure b/configure
> index c34bdd13f5..77f03948ce 100755
> --- a/configure
> +++ b/configure
> @@ -2256,6 +2256,7 @@ HEADERS_LIST="
>  valgrind_valgrind_h
>  windows_h
>  winsock2_h
> +iphlpapi_h
>  "
> 
>  INTRINSICS_LIST="
> @@ -6408,6 +6409,8 @@ if ! disabled network; then
>  check_struct winsock2.h "struct sockaddr" sa_len
>  check_type ws2tcpip.h "struct sockaddr_in6"
>  check_type ws2tcpip.h "struct sockaddr_storage"
> +check_headers iphlpapi.h && network_extralibs+=" -liphlpapi" ||
> disable iphlpapi_h +check_func_headers iphlpapi.h
> GetBestInterfaceEx
>  else
>  disable network
>  fi
> diff --git a/libavformat/ip.c b/libavformat/ip.c
> index b2c7ef07e5..4f2d998c34 100644
> --- a/libavformat/ip.c
> +++ b/libavformat/ip.c
> @@ -18,6 +18,9 @@
>   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
> 
> +#define _DEFAULT_SOURCE
> +#define _SVID_SOURCE
> +
>  #include 
>  #include "ip.h"
>  #include "libavutil/avstring.h"
> @@ -159,3 +162,45 @@ void ff_ip_reset_filters(IPSourceFilters *filters)
>  filters->nb_include_addrs = 0;
>  filters->nb_exclude_addrs = 0;
>  }
> +
> +unsigned int ff_ip_resolve_interface_index(struct sockaddr_storage
> *local_addr) +{
> +#if HAVE_WINSOCK2_H && HAVE_IPHLPAPI_H
> +DWORD retval;
> +unsigned long iface;
> +
> +if (local_addr == NULL)
> +return 0;
> +
> +retval = GetBestInterfaceEx((struct sockaddr*)local_addr, &iface);
> +if (retval == NO_ERROR)
> +return iface;
> +
> +return 0;
> +#elif !HAVE_WINSOCK2_H
> +struct ifaddrs *ifaddr, *ifa;
> +
> +if (local_addr == NULL)
> +return 0;
> +
> +/* Special case for link-local addresses, relevant interface is stored
> in sin6_scope_id */ +#if HAVE_STRUCT_SOCKADDR_IN6 &&
> defined(IN6_IS_ADDR_LINKLOCAL)
> +if (local_addr->ss_family == AF_INET6 &&
> IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)local_addr)->sin6_addr)) {

Invalid cast, breaks aliasing, AFAICT.

> + 
>   unsigned int interface;
> +interface = ((struct sockaddr_in6*)local_addr)->sin6_scope_id;

> +
> +if (interface != 0)
> +return interface;
> +}
> +#endif
> +if (getifaddrs(&ifaddr) == -1)
> +return 0;
> +
> +for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
> +if (ifa->ifa_addr != NULL && compare_addr((struct
> sockaddr_storage*)ifa->ifa_addr, local_addr) == 0) +return
> if_nametoindex(ifa->ifa_name);

> +}
> +
> +return 0;
> +#endif
> +}
> diff --git a/libavformat/ip.h b/libavformat/ip.h
> index b76cdab91c..4085e96f08 100644
> --- a/libavformat/ip.h
> +++ b/libavformat/ip.h
> @@ -69,4 +69,10 @@ int ff_ip_parse_blocks(void *log_ctx, const char *buf,
> IPSourceFilters *filters) */
>  void ff_ip_reset_filters(IPSourceFilters *filters);
> 
> +/**
> + * Resolves IP address to an associated interface index
> + * @return interface index, 0 as default interface value on error
> + */
> +unsigned int ff_ip_resolve_interface_index(struct sockaddr_storage
> *local_addr); +
>  #endif /* AVFO

[FFmpeg-devel] [PATCH 1/3] avformat/aeadec: Export title

2024-03-15 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/aeadec.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/aeadec.c b/libavformat/aeadec.c
index 4cb2da6639..20170a89b3 100644
--- a/libavformat/aeadec.c
+++ b/libavformat/aeadec.c
@@ -23,6 +23,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "demux.h"
 #include "pcm.h"
 
@@ -59,12 +60,20 @@ static int aea_read_probe(const AVProbeData *p)
 static int aea_read_header(AVFormatContext *s)
 {
 AVStream *st = avformat_new_stream(s, NULL);
-int channels;
+char title[256 + 1];
+int channels, ret;
 if (!st)
 return AVERROR(ENOMEM);
 
-/* Parse the amount of channels and skip to pos 2048(0x800) */
-avio_skip(s->pb, 264);
+/* Read the title, parse the number of channels and skip to pos 
2048(0x800) */
+avio_rl32(s->pb); // magic
+ret = ffio_read_size(s->pb, title, sizeof(title) - 1);
+if (ret < 0)
+return ret;
+title[sizeof(title) - 1] = '\0';
+if (title[0] != '\0')
+av_dict_set(&st->metadata, "title", title, 0);
+avio_rl32(s->pb); // Block count
 channels = avio_r8(s->pb);
 avio_skip(s->pb, 1783);
 
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 2/3] avformat/aeadec: Use sample rate as time base

2024-03-15 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/aeadec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/aeadec.c b/libavformat/aeadec.c
index 20170a89b3..be18e7b725 100644
--- a/libavformat/aeadec.c
+++ b/libavformat/aeadec.c
@@ -25,6 +25,7 @@
 #include "avformat.h"
 #include "avio_internal.h"
 #include "demux.h"
+#include "internal.h"
 #include "pcm.h"
 
 #define AT1_SU_SIZE 212
@@ -91,6 +92,7 @@ static int aea_read_header(AVFormatContext *s)
 av_channel_layout_default(&st->codecpar->ch_layout, channels);
 
 st->codecpar->block_align = AT1_SU_SIZE * 
st->codecpar->ch_layout.nb_channels;
+avpriv_set_pts_info(st, 64, 1, 44100);
 return 0;
 }
 
-- 
2.40.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 3/3] fate/atrac: Add atrac->aea, atrac->matroska remux tests

2024-03-15 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/atrac.mak| 12 +++-
 tests/ref/fate/atrac-aea-remux  | 94 +
 tests/ref/fate/atrac-matroska-remux | 94 +
 3 files changed, 198 insertions(+), 2 deletions(-)
 create mode 100644 tests/ref/fate/atrac-aea-remux
 create mode 100644 tests/ref/fate/atrac-matroska-remux

diff --git a/tests/fate/atrac.mak b/tests/fate/atrac.mak
index 1c91357559..592d1819df 100644
--- a/tests/fate/atrac.mak
+++ b/tests/fate/atrac.mak
@@ -37,8 +37,16 @@ FATE_ATRAC_ALL = $(FATE_ATRAC1-yes) $(FATE_ATRAC3-yes) 
$(FATE_ATRAC3P-yes)
 
 $(FATE_ATRAC_ALL): CMP = oneoff
 
-FATE_SAMPLES_AVCONV += $(FATE_ATRAC_ALL)
+FATE_ATRAC_REMUX-$(call REMUX, AEA) += fate-atrac-aea-remux
+fate-atrac-aea-remux: CMD = transcode aea 
$(TARGET_SAMPLES)/atrac1/test_tones_small.aea \
+aea "-c copy" "-c copy -t 1"
 
-fate-atrac:   $(FATE_ATRAC_ALL)
+FATE_ATRAC_REMUX-$(call REMUX, MATROSKA, AEA_DEMUXER ATRAC1_DECODER) += 
fate-atrac-matroska-remux
+fate-atrac-matroska-remux: CMD = transcode aea $(TARGET_SAMPLES)/aea/chirp.aea 
\
+ matroska "-c copy" "-c copy -t 1"
+
+FATE_SAMPLES_FFMPEG += $(FATE_ATRAC_ALL) $(FATE_ATRAC_REMUX-yes)
+
+fate-atrac:   $(FATE_ATRAC_ALL) $(FATE_ATRAC_REMUX-yes)
 fate-atrac3:  $(FATE_ATRAC3-yes)
 fate-atrac3p: $(FATE_ATRAC3P-yes)
diff --git a/tests/ref/fate/atrac-aea-remux b/tests/ref/fate/atrac-aea-remux
new file mode 100644
index 00..45bab7abbb
--- /dev/null
+++ b/tests/ref/fate/atrac-aea-remux
@@ -0,0 +1,94 @@
+1fd2eaaebf44772f959c25b58eda9b5d *tests/data/fate/atrac-aea-remux.aea
+10 tests/data/fate/atrac-aea-remux.aea
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: atrac1
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,  0,  0,  512,  424, 0x3b6509a4
+0,512,512,  512,  424, 0x3b6509a4
+0,   1024,   1024,  512,  424, 0x3b6509a4
+0,   1536,   1536,  512,  424, 0x3b6509a4
+0,   2048,   2048,  512,  424, 0x3b6509a4
+0,   2560,   2560,  512,  424, 0x3b6509a4
+0,   3072,   3072,  512,  424, 0x3b6509a4
+0,   3584,   3584,  512,  424, 0x3b6509a4
+0,   4096,   4096,  512,  424, 0x3b6509a4
+0,   4608,   4608,  512,  424, 0x3b6509a4
+0,   5120,   5120,  512,  424, 0x3b6509a4
+0,   5632,   5632,  512,  424, 0x3b6509a4
+0,   6144,   6144,  512,  424, 0x3b6509a4
+0,   6656,   6656,  512,  424, 0x3b6509a4
+0,   7168,   7168,  512,  424, 0x3b6509a4
+0,   7680,   7680,  512,  424, 0x3b6509a4
+0,   8192,   8192,  512,  424, 0x3b6509a4
+0,   8704,   8704,  512,  424, 0x3b6509a4
+0,   9216,   9216,  512,  424, 0x3b6509a4
+0,   9728,   9728,  512,  424, 0x3b6509a4
+0,  10240,  10240,  512,  424, 0x3b6509a4
+0,  10752,  10752,  512,  424, 0x3b6509a4
+0,  11264,  11264,  512,  424, 0x3b6509a4
+0,  11776,  11776,  512,  424, 0x3b6509a4
+0,  12288,  12288,  512,  424, 0x3b6509a4
+0,  12800,  12800,  512,  424, 0x3b6509a4
+0,  13312,  13312,  512,  424, 0x3b6509a4
+0,  13824,  13824,  512,  424, 0x3b6509a4
+0,  14336,  14336,  512,  424, 0x3b6509a4
+0,  14848,  14848,  512,  424, 0x3b6509a4
+0,  15360,  15360,  512,  424, 0x3b6509a4
+0,  15872,  15872,  512,  424, 0x3b6509a4
+0,  16384,  16384,  512,  424, 0x3b6509a4
+0,  16896,  16896,  512,  424, 0x3b6509a4
+0,  17408,  17408,  512,  424, 0x3b6509a4
+0,  17920,  17920,  512,  424, 0x3b6509a4
+0,  18432,  18432,  512,  424, 0x3b6509a4
+0,  18944,  18944,  512,  424, 0x3b6509a4
+0,  19456,  19456,  512,  424, 0x3b6509a4
+0,  19968,  19968,  512,  424, 0x3b6509a4
+0,  20480,  20480,  512,  424, 0x3b6509a4
+0,  20992,  20992,  512,  424, 0x3b6509a4
+0,  21504,  21504,  512,  424, 0x3b6509a4
+0,  22016,  22016,  512,  424, 0x3b6509a4
+0,  22528,  22528,  512,  424, 0x3b6509a4
+0,  23040,  23040,  512,  424, 0x3b6509a4
+0,  23552,  23552,  512,  424, 0x3b6509a4
+0,  24064,  24064,  512,  424, 0x3b6509a4
+0,  24576,  24576,  512,  424, 0x3b6509a4
+0,  25088,  25088,  512,  424, 0x3b6509a4
+0,  25600,  25600,  512,  424, 0x3b6509a4
+0,  26112,  26112,  512,  424, 0x3b6509a4
+0,  26624,  26624,  512,  424, 0x3b6509a4
+0,  27136,  27136,  512,  4

[FFmpeg-devel] [PATCH] libavfilter: add PipeWire-based grab

2024-03-15 Thread François-Simon Fauteux-Chapleau
This is a revised version of the "pipewiregrab" patch submitted by
Abhishek Ojha a few months ago:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20231227162504.690730-1-abhishek.o...@savoirfairelinux.com/
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20231227162504.690730-2-abhishek.o...@savoirfairelinux.com/

The main change is that the patch is now implemented as a libavfilter
source filter instead of a libavdevice input device, as was requested in
a comment on the previous version.

There are also several small changes meant to fix bugs or simplify the
code, but the overall structure remains the same as before: we use the
ScreenCast interface provided by XDG Desktop Portal to obtain a file
descriptor, which is then used to create a PipeWire stream. The data from
that stream can then be used to generate frames for FFmpeg.

To test the patch:
ffplay -f lavfi -i pipewiregrab

Signed-off-by: François-Simon Fauteux-Chapleau 

---
 configure   |   16 +
 libavfilter/Makefile|1 +
 libavfilter/allfilters.c|1 +
 libavfilter/vsrc_pipewiregrab.c | 1357 +++
 4 files changed, 1375 insertions(+)
 create mode 100644 libavfilter/vsrc_pipewiregrab.c

diff --git a/configure b/configure
index 2b4c4ec9a2..f31651dce2 100755
--- a/configure
+++ b/configure
@@ -301,6 +301,7 @@ External library support:
   --enable-libxcb-shm  enable X11 grabbing shm communication [autodetect]
   --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
   --enable-libxcb-shapeenable X11 grabbing shape rendering [autodetect]
+  --enable-libpipewire enable screen grabbing using pipewire [autodetect]
   --enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
   --enable-libxml2 enable XML parsing using the C library libxml2, 
needed
@@ -1792,6 +1793,8 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST="
 libxcb_shm
 libxcb_shape
 libxcb_xfixes
+libpipewire
+libgio_unix
 lzma
 mediafoundation
 metal
@@ -3817,6 +3820,7 @@ pad_opencl_filter_deps="opencl"
 pan_filter_deps="swresample"
 perspective_filter_deps="gpl"
 phase_filter_deps="gpl"
+pipewiregrab_filter_deps="libpipewire libgio_unix pthreads"
 pp7_filter_deps="gpl"
 pp_filter_deps="gpl postproc"
 prewitt_opencl_filter_deps="opencl"
@@ -7126,6 +7130,18 @@ if enabled libxcb; then
 enabled libxcb_xfixes && check_pkg_config libxcb_xfixes xcb-xfixes 
xcb/xfixes.h xcb_xfixes_get_cursor_image
 fi
 
+# Starting with version 0.3.52, PipeWire's spa library uses the 
__LOCALE_C_ONLY macro to determine
+# whether the locale_t type (introduced in POSIX.1-2008) and some related 
functions are available (see
+# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2390 for more 
information).
+# Unfortunately, this macro is specific to uclibc, which can cause build 
issues on systems that use a
+# different implementation of libc if POSIX 2008 support isn't enabled (which 
is the case for FFmpeg currently).
+# As a workaround for this problem, we add a compilation flag to ensure that 
__LOCALE_C_ONLY is always defined.
+add_cppflags -D__LOCALE_C_ONLY
+enabled libpipewire && check_pkg_config libpipewire "libpipewire-0.3 >= 
0.3.40" pipewire/pipewire.h pw_init
+if enabled libpipewire; then
+enabled libgio_unix && check_pkg_config libgio_unix gio-unix-2.0 gio/gio.h 
g_main_loop_new
+fi
+
 check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"
 
 # check if building for desktop or uwp
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 994d9773ba..982904be2d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -600,6 +600,7 @@ OBJS-$(CONFIG_NULLSRC_FILTER)+= 
vsrc_testsrc.o
 OBJS-$(CONFIG_OPENCLSRC_FILTER)  += vf_program_opencl.o opencl.o
 OBJS-$(CONFIG_PAL75BARS_FILTER)  += vsrc_testsrc.o
 OBJS-$(CONFIG_PAL100BARS_FILTER) += vsrc_testsrc.o
+OBJS-$(CONFIG_PIPEWIREGRAB_FILTER)   += vsrc_pipewiregrab.o
 OBJS-$(CONFIG_QRENCODE_FILTER)   += qrencode.o textutils.o
 OBJS-$(CONFIG_QRENCODESRC_FILTER)+= qrencode.o textutils.o
 OBJS-$(CONFIG_RGBTESTSRC_FILTER) += vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 149bf50997..a3c9c891b0 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -567,6 +567,7 @@ extern const AVFilter ff_vsrc_openclsrc;
 extern const AVFilter ff_vsrc_qrencodesrc;
 extern const AVFilter ff_vsrc_pal75bars;
 extern const AVFilter ff_vsrc_pal100bars;
+extern const AVFilter ff_vsrc_pipewiregrab;
 extern const AVFilter ff_vsrc_rgbtestsrc;
 extern const AVFilter ff_vsrc_sierpinski;
 extern const AVFilter ff_vsrc_smptebars;
diff --git a/libavfilter/vsrc_pipewiregrab.c b/libavfilter/vsrc_pipewiregrab.c
new file mode 100644
index 00..870e0f2d30
--- /dev/null
+++ b/libavfilter/vsrc_pipewiregrab.

[FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o

2024-03-15 Thread Helmut K. C. Tessarek

Hello,

It's me again - the dude who compiles ffmpeg for macOS... ;-)

I haven't updated the referenced libbluray, but only compiled ffmpeg the 
way I always do. The last time was about 3 days ago and all was good.


This is the git hash of ffmpeg I tried to compile: b47abd5737

duplicate symbol '_dec_init' in:
fftools/ffmpeg_dec.o
/Users/Shared/ffmpeg/sw/lib/libbluray.a(libbluray_la-dec.o)
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)


The only code that changed was ffmpeg and libx265, thus I suspect it was 
a change to ffmpeg. I can't really do a git bisect, because this error 
only happens after ffmpeg is compiled at the linker stage, so that would 
take me forever


However, the dev who did a change related to this would probably know 
right away.


Cheers,
  K. C.


--
regards Helmut K. C. Tessarek  KeyID 0x172380A011EF4944
Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944

/*
   Thou shalt not follow the NULL pointer for chaos and madness
   await thee at its end.
*/


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

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


Re: [FFmpeg-devel] [PATCH] tools/target_dec_fuzzer: force experimental flag for decoders that need it

2024-03-15 Thread Michael Niedermayer
On Fri, Mar 15, 2024 at 08:56:53AM -0300, James Almer wrote:
> Otherwise they will not even open.
> 
> Signed-off-by: James Almer 
> ---
>  tools/target_dec_fuzzer.c | 2 ++
>  1 file changed, 2 insertions(+)

should be ok if it works

thx

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

Democracy is the form of government in which you can choose your dictator


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

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


[FFmpeg-devel] [PATCH 1/3] swscale: [LA] Optimize range convert for yuvj420p.

2024-03-15 Thread Shiyou Yin
---
 libswscale/loongarch/swscale.S| 368 ++
 libswscale/loongarch/swscale_init_loongarch.c |  33 ++
 libswscale/loongarch/swscale_loongarch.h  |  11 +
 libswscale/swscale_internal.h |   1 +
 libswscale/utils.c|   6 +-
 5 files changed, 418 insertions(+), 1 deletion(-)

diff --git a/libswscale/loongarch/swscale.S b/libswscale/loongarch/swscale.S
index aa4c5cbe28..67b1bc834d 100644
--- a/libswscale/loongarch/swscale.S
+++ b/libswscale/loongarch/swscale.S
@@ -1866,3 +1866,371 @@ function ff_hscale_16_to_19_sub_lsx
 ld.d s8,  sp, 64
 addi.d   sp,  sp, 72
 endfunc
+
+function lumRangeFromJpeg_lsx
+li.w  t0,14071
+li.w  t1,33561947
+vreplgr2vr.h  vr0,   t0
+srli.wt2,a1,3
+andi  t3,a1,7
+beqz  t2,2f
+1:
+vld   vr1,   a0,0
+vreplgr2vr.w  vr2,   t1
+vreplgr2vr.w  vr3,   t1
+vmaddwev.w.h  vr2,   vr0,   vr1
+vmaddwod.w.h  vr3,   vr0,   vr1
+vsrai.w   vr2,   vr2,   14
+vsrai.w   vr3,   vr3,   14
+vpackev.h vr1,   vr3,   vr2
+vst   vr1,   a0,0
+addi.da0,a0,16
+addi.dt2,t2,-1
+bnez  t2,1b
+2:
+beqz  t3,4f
+3:
+ld.h  t4,a0,0
+mul.w t4,t4,t0
+add.w t4,t4,t1
+srai.wt4,t4,14
+st.h  t4,a0,0
+addi.da0,a0,2
+addi.dt3,t3,-1
+bnez  t3,3b
+4:
+endfunc
+
+function lumRangeFromJpeg_lasx
+li.w   t0,14071
+li.w   t1,33561947
+xvreplgr2vr.h  xr0,   t0
+srli.w t2,a1,4
+andi   t3,a1,15
+beqz   t2,2f
+1:
+xvld   xr1,   a0,0
+xvreplgr2vr.w  xr2,   t1
+xvreplgr2vr.w  xr3,   t1
+xvmaddwev.w.h  xr2,   xr0,   xr1
+xvmaddwod.w.h  xr3,   xr0,   xr1
+xvsrai.w   xr2,   xr2,   14
+xvsrai.w   xr3,   xr3,   14
+xvpackev.h xr1,   xr3,   xr2
+xvst   xr1,   a0,0
+addi.d a0,a0,32
+addi.d t2,t2,-1
+bnez   t2,1b
+2:
+beqz  t3,4f
+3:
+ld.h  t4,a0,0
+mul.w t4,t4,t0
+add.w t4,t4,t1
+srai.wt4,t4,14
+st.h  t4,a0,0
+addi.da0,a0,2
+addi.dt3,t3,-1
+bnez  t3,3b
+4:
+endfunc
+
+function lumRangeToJpeg_lsx
+li.w  t0,19077
+li.w  t1,-39057361
+li.w  t2,30189
+vreplgr2vr.h  vr0,   t0
+vreplgr2vr.h  vr4,   t2
+srli.wt2,a1,3
+andi  t3,a1,7
+beqz  t2,2f
+1:
+vld   vr1,   a0,0
+vreplgr2vr.w  vr2,   t1
+vreplgr2vr.w  vr3,   t1
+vmin.hvr1,   vr1,   vr4
+vmaddwev.w.h  vr2,   vr0,   vr1
+vmaddwod.w.h  vr3,   vr0,   vr1
+vsrai.w   vr2,   vr2,   14
+vsrai.w   vr3,   vr3,   14
+vpackev.h vr1,   vr3,   vr2
+vst   vr1,   a0,0
+addi.da0,a0,16
+addi.dt2,t2,-1
+bnez  t2,1b
+2:
+beqz  t3,4f
+3:
+ld.h  t4,a0,0
+vreplgr2vr.h  vr1,   t4
+vmin.hvr1,   vr1,   vr4
+vpickve2gr.h  t4,vr1,   0
+mul.w t4,t4,t0
+add.w t4,t4,t1
+srai.wt4,t4,14
+st.h  t4,a0,0
+addi.da0,a0,2
+addi.dt3,t3,-1
+bnez  t3,3b
+4:
+endfunc
+
+function lumRangeToJpeg_lasx
+li.w   t0,19077
+li.w   t1,-39057361
+li.w   t2,30189
+xvreplgr2vr.h  xr0,   t0
+xvreplgr2vr.h  xr4,   t2
+srli.w t2,a1,4
+andi   t3,a1,15
+beqz   t2,2f
+1:
+xvld   xr1,   a0,0
+xvreplgr2vr.w  xr2,   t1
+xvreplgr2vr.w  xr3,   t1
+xvmin.hxr1,   xr1,   xr4
+xvmaddwev.w.h  xr2,   xr0,   xr1
+xvmaddwod.w.h  xr3,   xr0,   xr1
+xvsrai.w   xr2,   xr2,   14
+xvsrai.w   xr3,   xr3,   14
+xvpackev.h xr1,   xr3,   xr2
+xvst   xr1,   a0,0
+addi.d a0,a0,32
+addi.d t2,t2,-1
+bnez   t2,1b
+2:
+beqz   t3,4f
+3:
+ld.h   t4,a0,0
+vreplgr2vr.h   vr1,   t4
+vmin.h vr1,   vr1,   vr4
+vpickve2gr.h   t4,vr1,   0
+mul.w  t4,t4,t0
+add.w  t4,t4,t1
+srai.w t4,t4,14
+st.h   t4,a0,0
+addi.d a0,a0,2
+addi.d t3,t3,-1
+bnez

[FFmpeg-devel] Add optimization in swscale for LA.

2024-03-15 Thread Shiyou Yin
[PATCH 1/3] swscale: [LA] Optimize range convert for yuvj420p.
[PATCH 2/3] swscale: [LA] Optimize yuv2plane1_8_c.
[PATCH 3/3] swscale: [LA] Optimize swscale funcs in input.c

___
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/3] swscale: [LA] Optimize yuv2plane1_8_c.

2024-03-15 Thread Shiyou Yin
---
 libswscale/loongarch/output.S | 254 +-
 libswscale/loongarch/output_lasx.c|  23 +-
 libswscale/loongarch/output_lsx.c |  22 +-
 libswscale/loongarch/swscale_init_loongarch.c |  12 +-
 libswscale/loongarch/swscale_loongarch.h  |  29 +-
 5 files changed, 324 insertions(+), 16 deletions(-)

diff --git a/libswscale/loongarch/output.S b/libswscale/loongarch/output.S
index b44bac502a..d71667e38a 100644
--- a/libswscale/loongarch/output.S
+++ b/libswscale/loongarch/output.S
@@ -23,11 +23,11 @@
 
 #include "libavcodec/loongarch/loongson_asm.S"
 
-/* static void ff_yuv2planeX_8_lsx(const int16_t *filter, int filterSize,
+/* static void yuv2planeX_8_lsx(const int16_t *filter, int filterSize,
  * const int16_t **src, uint8_t *dest, int 
dstW,
  * const uint8_t *dither, int offset)
  */
-function ff_yuv2planeX_8_lsx
+function yuv2planeX_8_lsx
 addi.w  t1, a6, 1
 addi.w  t2, a6, 2
 addi.w  t3, a6, 3
@@ -136,3 +136,253 @@ function ff_yuv2planeX_8_lsx
 blt zero,   a4, .DEST
 .END:
 endfunc
+
+/*
+ * void yuv2plane1_8_lsx(const int16_t *src, uint8_t *dest, int dstW,
+ *   const uint8_t *dither, int offset)
+ */
+function yuv2plane1_8_lsx
+addi.w   t1,a4,1
+addi.w   t2,a4,2
+addi.w   t3,a4,3
+addi.w   t4,a4,4
+addi.w   t5,a4,5
+addi.w   t6,a4,6
+addi.w   t7,a4,7
+andi t0,a4,7
+andi t1,t1,7
+andi t2,t2,7
+andi t3,t3,7
+andi t4,t4,7
+andi t5,t5,7
+andi t6,t6,7
+andi t7,t7,7
+ldx.bu   t0,a3,t0
+ldx.bu   t1,a3,t1
+ldx.bu   t2,a3,t2
+ldx.bu   t3,a3,t3
+ldx.bu   t4,a3,t4
+ldx.bu   t5,a3,t5
+ldx.bu   t6,a3,t6
+ldx.bu   t7,a3,t7
+vinsgr2vr.h  vr1,   t0,0
+vinsgr2vr.h  vr1,   t1,1
+vinsgr2vr.h  vr1,   t2,2
+vinsgr2vr.h  vr1,   t3,3
+vinsgr2vr.h  vr1,   t4,4
+vinsgr2vr.h  vr1,   t5,5
+vinsgr2vr.h  vr1,   t6,6
+vinsgr2vr.h  vr1,   t7,7
+vsub.h   vr0,   vr0,   vr0
+vilvl.h  vr2,   vr0,   vr1
+vilvh.h  vr3,   vr0,   vr1
+
+andi t8,a2,7
+srli.d   a2,a2,3
+beqz a2,2f
+1:
+vld  vr1,   a0,0
+addi.d   a0,a0,16
+vshuf4i.dvr0,   vr1,   8
+vexth.w.hvr4,   vr0
+vexth.w.hvr5,   vr1
+
+vadd.w   vr4,   vr2,   vr4
+vadd.w   vr5,   vr3,   vr5
+vsrai.w  vr4,   vr4,   7
+vsrai.w  vr5,   vr5,   7
+vclip255.w   vr4,   vr4
+vclip255.w   vr5,   vr5
+vpickev.hvr1,   vr5,   vr4
+vpickev.bvr1,   vr1,   vr1
+fst.df1,a1,0
+addi.d   a1,a1,8
+addi.d   a2,a2,-1
+bnez a2,1b
+2:
+beqz t8,4f
+3:
+add.wa4,a4,t8
+addi.w   t1,a4,1
+addi.w   t2,a4,2
+addi.w   t3,a4,3
+addi.w   t4,a4,4
+addi.w   t5,a4,5
+addi.w   t6,a4,6
+addi.w   t7,a4,7
+andi t0,a4,7
+andi t1,t1,7
+andi t2,t2,7
+andi t3,t3,7
+andi t4,t4,7
+andi t5,t5,7
+andi t6,t6,7
+andi t7,t7,7
+ldx.bu   t0,a3,t0
+ldx.bu   t1,a3,t1
+ldx.bu   t2,a3,t2
+ldx.bu   t3,a3,t3
+ldx.bu   t4,a3,t4
+ldx.bu   t5,a3,t5
+ldx.bu   t6,a3,t6
+ldx.bu   t7,a3,t7
+vinsgr2vr.h  vr1,   t0,0
+vinsgr2vr.h  vr1,   t1,1
+vinsgr2vr.h  vr1,   t2,2
+vinsgr2vr.h  vr1,   t3,3
+vinsgr2vr.h  vr1,   t4,4
+vinsgr2vr.h  vr1,   t5,5
+vinsgr2vr.h  vr1,   t6,6
+vinsgr2vr.h  vr1,   t7,7
+vsub.h   vr0,   vr0,   vr0
+vilvl.h  vr2,   vr0,   vr1
+vilvh.h  vr3,   vr0,   vr1
+
+addi.d   a0,a0,-16
+add.da0,a0,t8
+add.da0,a0,t8
+addi.d   a1,a1,-8
+add.da1,a1,t8
+
+vld  vr1,   a0,0
+vshuf4i.dvr0,   vr1,   8
+vexth.w.hvr4,   vr0
+vexth.w.hvr5,   vr1
+
+vadd.w   vr4,   vr2,   vr4
+vadd.w   vr5,   vr3,   vr5
+vsrai.w  vr4,   vr4,   7
+vsrai.w  vr5,   vr5,   7
+vclip255.w   vr4,   vr4
+vclip255.w   vr5,   vr5
+vpickev.hvr1,   vr5,   vr4
+vpicke

[FFmpeg-devel] [PATCH 3/3] swscale: [LA] Optimize swscale funcs in input.c

2024-03-15 Thread Shiyou Yin
Optimized 7 funcs with LSX and LASX:
1. yuy2ToUV_c
2. yvy2ToUV_c
3. uyvyToUV_c
4. nv12ToUV_c
5. nv21ToUV_c
6. abgrToA_c
7. rgbaToA_c
---
 libswscale/loongarch/Makefile |   1 +
 libswscale/loongarch/input.S  | 495 ++
 libswscale/loongarch/input_lasx.c |  43 ++
 libswscale/loongarch/input_lsx.c  |  65 +++
 libswscale/loongarch/swscale_init_loongarch.c |  20 +-
 libswscale/loongarch/swscale_loongarch.h  |  46 ++
 6 files changed, 652 insertions(+), 18 deletions(-)
 create mode 100644 libswscale/loongarch/input_lsx.c

diff --git a/libswscale/loongarch/Makefile b/libswscale/loongarch/Makefile
index c35ba309a4..7ba11d492e 100644
--- a/libswscale/loongarch/Makefile
+++ b/libswscale/loongarch/Makefile
@@ -9,4 +9,5 @@ LSX-OBJS-$(CONFIG_SWSCALE)  += loongarch/swscale.o \
loongarch/input.o   \
loongarch/output.o  \
loongarch/output_lsx.o  \
+   loongarch/input_lsx.o   \
loongarch/yuv2rgb_lsx.o
diff --git a/libswscale/loongarch/input.S b/libswscale/loongarch/input.S
index d01f7384b1..717592b004 100644
--- a/libswscale/loongarch/input.S
+++ b/libswscale/loongarch/input.S
@@ -283,3 +283,498 @@ function planar_rgb_to_uv_lsx
 ld.ds3, sp,16
 addi.d  sp, sp,24
 endfunc
+
+/*
+ * void yuy2ToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src1,
+ *   const uint8_t *src2, int width, uint32_t *unused, void 
*opq)
+ */
+function yuy2ToUV_lsx
+andi t0,a5,7
+srli.d   a5,a5,3
+beqz a5,2f
+1:
+vld  vr0,   a3,1
+vld  vr1,   a3,17
+addi.d   a5,a5,-1
+addi.d   a3,a3,32
+vpickev.bvr2,   vr1,   vr0
+vpickev.bvr0,   vr2,   vr2
+vpickod.bvr1,   vr2,   vr2
+fst.df0,a0,0
+fst.df1,a1,0
+addi.d   a0,a0,8
+addi.d   a1,a1,8
+bnez a5,1b
+2:
+beqz t0,4f
+3:
+ld.b t1,a3,1
+ld.b t2,a3,3
+addi.d   a3,a3,4
+addi.d   t0,t0,-1
+st.b t1,a0,0
+st.b t2,a1,0
+addi.d   a0,a0,1
+addi.d   a1,a1,1
+bnez t0,3b
+4:
+endfunc
+
+function yuy2ToUV_lasx
+andi t0,a5,15
+srli.d   a5,a5,4
+beqz a5,2f
+1:
+xvld xr0,   a3,1
+xvld xr1,   a3,33
+addi.d   a5,a5,-1
+addi.d   a3,a3,64
+xvpickev.b   xr2,   xr1,   xr0
+xvpermi.dxr2,   xr2,   0xd8
+xvpickev.b   xr0,   xr2,   xr2
+xvpermi.dxr0,   xr0,   0xd8
+xvpickod.b   xr1,   xr2,   xr2
+xvpermi.dxr1,   xr1,   0xd8
+vst  vr0,   a0,0
+vst  vr1,   a1,0
+addi.d   a0,a0,16
+addi.d   a1,a1,16
+bnez a5,1b
+2:
+beqz t0,4f
+3:
+ld.b t1,a3,1
+ld.b t2,a3,3
+addi.d   a3,a3,4
+addi.d   t0,t0,-1
+st.b t1,a0,0
+st.b t2,a1,0
+addi.d   a0,a0,1
+addi.d   a1,a1,1
+bnez t0,3b
+4:
+endfunc
+
+/*
+ * void yvy2ToUV_lsx(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src1,
+ *   const uint8_t *src2, int width, uint32_t *unused, void 
*opq)
+ */
+function yvy2ToUV_lsx
+andi t0,a5,7
+srli.d   a5,a5,3
+beqz a5,2f
+1:
+vld  vr0,   a3,1
+vld  vr1,   a3,17
+addi.d   a5,a5,-1
+addi.d   a3,a3,32
+vpickev.bvr2,   vr1,   vr0
+vpickev.bvr0,   vr2,   vr2
+vpickod.bvr1,   vr2,   vr2
+fst.df0,a1,0
+fst.df1,a0,0
+addi.d   a0,a0,8
+addi.d   a1,a1,8
+bnez a5,1b
+2:
+beqz t0,4f
+3:
+ld.b t1,a3,1
+ld.b t2,a3,3
+addi.d   a3,a3,4
+addi.d   t0,t0,-1
+st.b t1,a1,0
+st.b t2,a0,0
+addi.d   a0,a0,1
+addi.d   a1,a1,1
+bnez t0,3b
+4:
+endfunc
+
+function yvy2ToUV_lasx
+andi t0,a5,15
+srli.d   a5,a5,4
+beqz a5,2f
+1:
+xvld xr0,   a3,1
+xvld xr1,   a3,33
+addi.d   a5,a5,-1
+addi.d   a3,a3,64
+xvpickev.b   xr2,   xr1,   xr0
+xvpermi.dxr2,   xr2,   0xd8
+xvpickev.b   xr0,   xr2,   xr2
+xvpermi.dxr0, 

[FFmpeg-devel] [PATCH] avformat/mpegtsenc: correct bitstream check

2024-03-15 Thread Gyan Doshi
8559cce3c3 made the bitstream check generic using a LUT.
However, one of the comparisons which involves a bitwise AND
and equality check is faulty due to operator precedence.

First reported and analysed at
https://github.com/streamlink/streamlink/issues/5876

Fixes #10908
---
 libavformat/mpegtsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, 
AVStream *st,
 pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
 (AV_RB24(pkt->data) != 0x01 ||
 (st->codecpar->extradata_size > 0 &&
-(st->codecpar->extradata[0] & e->mask == e->value
+((st->codecpar->extradata[0] & e->mask) == e->value
 return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
 }
 return 1;
-- 
2.44.0

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

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


Re: [FFmpeg-devel] [PATCH 1/3] swscale: [LA] Optimize range convert for yuvj420p.

2024-03-15 Thread 陈昊
LGTM

2024-03-16 11:03:31 "yinshiyou...@loongson.cn"  写道:
> ---
>  libswscale/loongarch/swscale.S| 368 ++
>  libswscale/loongarch/swscale_init_loongarch.c |  33 ++
>  libswscale/loongarch/swscale_loongarch.h  |  11 +
>  libswscale/swscale_internal.h |   1 +
>  libswscale/utils.c|   6 +-
>  5 files changed, 418 insertions(+), 1 deletion(-)
> 
> diff --git a/libswscale/loongarch/swscale.S b/libswscale/loongarch/swscale.S
> index aa4c5cbe28..67b1bc834d 100644
> --- a/libswscale/loongarch/swscale.S
> +++ b/libswscale/loongarch/swscale.S
> @@ -1866,3 +1866,371 @@ function ff_hscale_16_to_19_sub_lsx
>  ld.d s8,  sp, 64
>  addi.d   sp,  sp, 72
>  endfunc
> +
> +function lumRangeFromJpeg_lsx
> +li.w  t0,14071
> +li.w  t1,33561947
> +vreplgr2vr.h  vr0,   t0
> +srli.wt2,a1,3
> +andi  t3,a1,7
> +beqz  t2,2f
> +1:
> +vld   vr1,   a0,0
> +vreplgr2vr.w  vr2,   t1
> +vreplgr2vr.w  vr3,   t1
> +vmaddwev.w.h  vr2,   vr0,   vr1
> +vmaddwod.w.h  vr3,   vr0,   vr1
> +vsrai.w   vr2,   vr2,   14
> +vsrai.w   vr3,   vr3,   14
> +vpackev.h vr1,   vr3,   vr2
> +vst   vr1,   a0,0
> +addi.da0,a0,16
> +addi.dt2,t2,-1
> +bnez  t2,1b
> +2:
> +beqz  t3,4f
> +3:
> +ld.h  t4,a0,0
> +mul.w t4,t4,t0
> +add.w t4,t4,t1
> +srai.wt4,t4,14
> +st.h  t4,a0,0
> +addi.da0,a0,2
> +addi.dt3,t3,-1
> +bnez  t3,3b
> +4:
> +endfunc
> +
> +function lumRangeFromJpeg_lasx
> +li.w   t0,14071
> +li.w   t1,33561947
> +xvreplgr2vr.h  xr0,   t0
> +srli.w t2,a1,4
> +andi   t3,a1,15
> +beqz   t2,2f
> +1:
> +xvld   xr1,   a0,0
> +xvreplgr2vr.w  xr2,   t1
> +xvreplgr2vr.w  xr3,   t1
> +xvmaddwev.w.h  xr2,   xr0,   xr1
> +xvmaddwod.w.h  xr3,   xr0,   xr1
> +xvsrai.w   xr2,   xr2,   14
> +xvsrai.w   xr3,   xr3,   14
> +xvpackev.h xr1,   xr3,   xr2
> +xvst   xr1,   a0,0
> +addi.d a0,a0,32
> +addi.d t2,t2,-1
> +bnez   t2,1b
> +2:
> +beqz  t3,4f
> +3:
> +ld.h  t4,a0,0
> +mul.w t4,t4,t0
> +add.w t4,t4,t1
> +srai.wt4,t4,14
> +st.h  t4,a0,0
> +addi.da0,a0,2
> +addi.dt3,t3,-1
> +bnez  t3,3b
> +4:
> +endfunc
> +
> +function lumRangeToJpeg_lsx
> +li.w  t0,19077
> +li.w  t1,-39057361
> +li.w  t2,30189
> +vreplgr2vr.h  vr0,   t0
> +vreplgr2vr.h  vr4,   t2
> +srli.wt2,a1,3
> +andi  t3,a1,7
> +beqz  t2,2f
> +1:
> +vld   vr1,   a0,0
> +vreplgr2vr.w  vr2,   t1
> +vreplgr2vr.w  vr3,   t1
> +vmin.hvr1,   vr1,   vr4
> +vmaddwev.w.h  vr2,   vr0,   vr1
> +vmaddwod.w.h  vr3,   vr0,   vr1
> +vsrai.w   vr2,   vr2,   14
> +vsrai.w   vr3,   vr3,   14
> +vpackev.h vr1,   vr3,   vr2
> +vst   vr1,   a0,0
> +addi.da0,a0,16
> +addi.dt2,t2,-1
> +bnez  t2,1b
> +2:
> +beqz  t3,4f
> +3:
> +ld.h  t4,a0,0
> +vreplgr2vr.h  vr1,   t4
> +vmin.hvr1,   vr1,   vr4
> +vpickve2gr.h  t4,vr1,   0
> +mul.w t4,t4,t0
> +add.w t4,t4,t1
> +srai.wt4,t4,14
> +st.h  t4,a0,0
> +addi.da0,a0,2
> +addi.dt3,t3,-1
> +bnez  t3,3b
> +4:
> +endfunc
> +
> +function lumRangeToJpeg_lasx
> +li.w   t0,19077
> +li.w   t1,-39057361
> +li.w   t2,30189
> +xvreplgr2vr.h  xr0,   t0
> +xvreplgr2vr.h  xr4,   t2
> +srli.w t2,a1,4
> +andi   t3,a1,15
> +beqz   t2,2f
> +1:
> +xvld   xr1,   a0,0
> +xvreplgr2vr.w  xr2,   t1
> +xvreplgr2vr.w  xr3,   t1
> +xvmin.hxr1,   xr1,   xr4
> +xvmaddwev.w.h  xr2,   xr0,   xr1
> +xvmaddwod.w.h  xr3,   xr0,   xr1
> +xvsrai.w   xr2,   xr2,   14
> +xvsrai.w   xr3,   xr3,   14
> +xvpackev.h xr1,   xr3,   xr2
> +xvst   xr1,   a0,0
> +addi.d a0,a0,32
> +addi.d t2,t2,-1
> +bnez   t2,1b
> +2:
> +beqz   t3,4f
> +3:
> +ld.h