Re: [FFmpeg-devel] [PATCH v1 1/6] avcodec/evc: Set the AV_FRAME_FLAG_KEY flag for a decoded frame when the decoded packet contains a keyframe

2024-05-06 Thread Dawid Kozinski/Multimedia (PLT) /SRPOL/Staff Engineer/Samsung Electronics




> -Original Message-
> From: ffmpeg-devel  On Behalf Of James
> Almer
> Sent: środa, 17 kwietnia 2024 14:39
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v1 1/6] avcodec/evc: Set the
> AV_FRAME_FLAG_KEY flag for a decoded frame when the decoded packet
> contains a keyframe
> 
> On 4/17/2024 2:22 AM, Dawid Kozinski wrote:
> > Signed-off-by: Dawid Kozinski 
> > ---
> >   libavcodec/libxevd.c | 5 +
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/libavcodec/libxevd.c b/libavcodec/libxevd.c index
> > c6c7327e65..e864bd5200 100644
> > --- a/libavcodec/libxevd.c
> > +++ b/libavcodec/libxevd.c
> > @@ -391,6 +391,11 @@ static int libxevd_receive_frame(AVCodecContext
> *avctx, AVFrame *frame)
> >   if (stat.read != nalu_size)
> >   av_log(avctx, AV_LOG_INFO, "Different reading of
> > bitstream (in:%d, read:%d)\n,", nalu_size, stat.read);
> >
> > +if (stat.stype == XEVD_ST_I) {
> > +frame->pict_type = AV_PICTURE_TYPE_I;
> > +frame->flags |= AV_FRAME_FLAG_KEY;
> > +}
> 
> Shouldn't this be inside the stat.fnum >= 0 block below?
> 
> > +
> >   // stat.fnum - has negative value if the decoded data is
not frame
> >   if (stat.fnum >= 0) {
Moved
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://protect2.fireeye.com/v1/url?k=a29889eb-c3139cd2-a29902a4-
> 000babffae10-eb1fef97e1007353&q=1&e=c04d8490-c1e2-4395-83d3-
> 7ea762e16a64&u=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmp
> eg-devel
> 
> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org
> with subject "unsubscribe".


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

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


[FFmpeg-devel] [PATCH 1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally

2024-05-06 Thread Andreas Rheinhardt
The fixed point decoder needs it since
905fdb06010e554262fca3c12b362bb69a11de85.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aactab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 3cef9c5d2b..3718b81a07 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -105,6 +105,7 @@ av_cold void ff_aac_float_common_init(void)
 static AVOnce init_static_once = AV_ONCE_INIT;
 ff_thread_once(&init_static_once, aac_float_common_init);
 }
+#endif
 
 const float ff_ltp_coef[8] = {
 0.570829, 0.696616, 0.813004, 0.911304,
@@ -144,7 +145,6 @@ const float * const ff_tns_tmp2_map[4] = {
 tns_tmp2_map_1_3,
 tns_tmp2_map_1_4
 };
-#endif
 
 const uint8_t ff_aac_num_swb_1024[] = {
 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
-- 
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] avcodec/aacsbr: Fix type mismatch

2024-05-06 Thread Andreas Rheinhardt
ff_aac_sbr_apply() and ff_aac_sbr_apply_fixed() still used
pointers to INTFLOAT which is float or int depending upon
whether USE_FIXED is set or not; in particular, according
to these declarations both functions have the same type.
But that is wrong and given that aacdec.c sets USE_FIXED,
it sees the wrong type for ff_aac_sbr_apply().
Fix this by avoiding INTFLOAT in aacsbr.h (which also means
that aac_defines.h need not be included there any more).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 1 +
 libavcodec/aacsbr.h | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 72f2d7e7ba..c6b93e33a2 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -42,6 +42,7 @@
 #include "aacdec_tab.h"
 
 #include "libavcodec/aac.h"
+#include "libavcodec/aac_defines.h"
 #include "libavcodec/aacsbr.h"
 #include "libavcodec/aactab.h"
 #include "libavcodec/adts_header.h"
diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h
index cd030aa801..656ef5258e 100644
--- a/libavcodec/aacsbr.h
+++ b/libavcodec/aacsbr.h
@@ -31,7 +31,6 @@
 
 #include "get_bits.h"
 #include "aac/aacdec.h"
-#include "aac_defines.h"
 
 #include "libavutil/attributes_internal.h"
 
@@ -91,9 +90,9 @@ int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, 
ChannelElement *che,
 
 /** Apply one SBR element to one AAC element. */
 void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che,
-  int id_aac, INTFLOAT* L, INTFLOAT* R);
+  int id_aac, float *L, float *R);
 void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
-int id_aac, INTFLOAT* L, INTFLOAT* R);
+int id_aac, int *L, int *R);
 
 FF_VISIBILITY_POP_HIDDEN
 
-- 
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] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Andreas Rheinhardt
The approach used here has the advantage not to rely
on any DCE.
Also improve certain the checks from
3390693bfb907765f833766f370e0ba8c7894f44 a bit.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 62 -
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index c6b93e33a2..6a74b05168 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -63,6 +63,20 @@
 #include "libavutil/version.h"
 #include "libavutil/thread.h"
 
+#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
+#define IS_FIXED(is_fixed) (is_fixed)
+#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
+((is_fixed) ? RENAME_FIXED(func_or_obj) func_args : (func_or_obj) 
func_args)
+#elif CONFIG_AAC_DECODER
+#define IS_FIXED(is_fixed) 0
+#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
+((func_or_obj) func_args)
+#else
+#define IS_FIXED(is_fixed) 1
+#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
+(RENAME_FIXED(func_or_obj) func_args)
+#endif
+
 /*
  * supported tools
  *
@@ -150,11 +164,8 @@ static av_cold int che_configure(AACDecContext *ac,
 return AVERROR_INVALIDDATA;
 if (che_pos) {
 if (!ac->che[type][id]) {
-int ret;
-if (ac->is_fixed)
-ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, &ac->che[type][id], 
type);
-else
-ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], type);
+int ret = FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_alloc_init,
+ (ac, &ac->che[type][id], type));
 if (ret < 0)
 return ret;
 }
@@ -171,10 +182,7 @@ static av_cold int che_configure(AACDecContext *ac,
 }
 } else {
 if (ac->che[type][id]) {
-if (ac->is_fixed)
-ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
-else
-ff_aac_sbr_ctx_close(ac->che[type][id]);
+FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_close, 
(ac->che[type][id]));
 }
 av_freep(&ac->che[type][id]);
 }
@@ -1122,8 +1130,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
 int is_fixed = ac->is_fixed;
-void (*sbr_close)(ChannelElement *che) = is_fixed ? 
ff_aac_sbr_ctx_close_fixed :
-ff_aac_sbr_ctx_close;
+void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_fixed, 
ff_aac_sbr_ctx_close, );
 
 for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
 for (int i = 0; i < MAX_ELEM_ID; i++) {
@@ -1154,7 +1161,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 static av_cold int init_dsp(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
-int is_fixed = ac->is_fixed, ret;
+int is_fixed = IS_FIXED(ac->is_fixed), ret;
 float scale_fixed, scale_float;
 const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
 enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
@@ -1188,8 +1195,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
-ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
-ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
+ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
+ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
 
 return ac->dsp.init(ac);
 }
@@ -1315,9 +1322,9 @@ static void decode_ltp(AACDecContext *ac, 
LongTermPrediction *ltp,
 int sfb;
 
 ltp->lag  = get_bits(gb, 11);
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
+if (IS_FIXED(ac->is_fixed))
 ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
-else if (CONFIG_AAC_DECODER)
+else
 ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
 
 for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
@@ -1626,9 +1633,9 @@ static int decode_tns(AACDecContext *ac, 
TemporalNoiseShaping *tns,
 tmp2_idx = 2 * coef_compress + coef_res;
 
 for (i = 0; i < tns->order[w][filt]; i++) {
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
+if (IS_FIXED(ac->is_fixed))
 tns->coef_fixed[w][filt][i] = 
Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]);
-else if (CONFIG_AAC_DECODER)
+else
 tns->coef[w][filt][i] = 
ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
 }
 }
@@ -1977,11 +1984,8 @@ static int decode_extension_payload(AACDecContext *ac, 
GetBitContext *gb, int cn
 ac->avctx->profile = AV_PROFILE_AAC_HE;
 }
 
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
-res = ff_aac_sbr_decode_extension_fixed(ac, che, gb, crc_flag, 
cnt, elem_type);
-   

Re: [FFmpeg-devel] [PATCH] avformat/mxfdec: only check index_edit_rate when calculating the index tables

2024-05-06 Thread Tomas Härdin
lör 2024-05-04 klockan 03:49 +0200 skrev Marton Balint:
> 
> 
> On Fri, 3 May 2024, Tomas Härdin wrote:
> 
> > tor 2024-05-02 klockan 23:01 +0200 skrev Marton Balint:
> > > 
> > > 
> > > On Mon, 29 Apr 2024, Tomas Härdin wrote:
> > > 
> > > > mån 2024-04-15 klockan 21:34 +0200 skrev Marton Balint:
> > > > > Commit ed49391961999f028e0bc55767d0eef6eeb15e49 started
> > > > > rejecting
> > > > > negative
> > > > > index segment edit rates to avoid negative av_rescale
> > > > > parameters.
> > > > > There are two
> > > > > problems with this:
> > > > > 
> > > > > 1) there is already a validation for zero (uninitialized)
> > > > > rates
> > > > > later
> > > > > on
> > > > > 2) it rejects files with 0/0 index edit rates which do exist
> > > > > and
> > > > > we
> > > > > should
> > > > > continue to support those
> > > > 
> > > > There are no such files in FATE last time I checked. At the
> > > > very
> > > > least
> > > > we need to know which vendor is producing such broken files.
> > > > 
> > > > Without tests covering the workflows we want to support, we
> > > > have no
> > > > confidence in refactoriing. This leads to cargo culting. And to
> > > > be
> > > > sure, every workflow we support means a non-trivial amount of
> > > > work,
> > > > especially when it comes to MXF.
> > > 
> > > I can add a comment to the code or the commit message, we did
> > > this
> > > plenty 
> > > of times in the past. The broken software is Marquise
> > > Technologies MT
> > > Mediabase 4.7.2 by the way. I can also rework the patch to keep
> > > rejecting 
> > > negative values and only allow zero, as that is the only thing I
> > > *know* to 
> > > exist.
> > 
> > We could also tell Marquise Technologies to fix their software. MXF
> > is
> > a living ecosystem
> > 
> > > If we add a new FATE file for every fixed file or workflow, the
> > > amount of 
> > > FATE samples (and the time fate will run) will increase
> > > significantly, I 
> > > am not sure that is intended.
> > 
> > "Support any old workflow but don't add tests for them" is a
> > ridiculous
> > position. It also prevents refactoring. There are real costs to
> > supporting workflows that no one uses. Hence why I mention SLAs.
> > The
> > only people interested in MXF are professionals.
> 
> And what if a home user gets a file from a professional user?
> Crippling 
> professional use cases from ffmpeg, or make professional features a 
> payable option - via SLA or otherwise - is something I cannot
> support.

This is a blackleg mindset.

> > > In this case, I could only craft an MXF
> > > file, because I don't have access to the software.
> > 
> > Yes we can craft arbitrarily broken files. That doesn't help
> > anyone.
> > It's just cargo culting.
> 
> Cargo culting would be fixing files which do not exists in the wild.
> Files with 0/0 index edit rate do exist. So this patch clearly helps 
> anybody who is trying to play those.

My focus is on workflows and the MXF ecosystem in general, not
individual files. Files can be fixed. Other implementations can be
patched to no longer output broken files.

A liberal attitude towards broken implementations begets yet more
broken implementations and yet more busywork for us.

> I can create a fate test for supporting 0/0 index edit rates if that
> is 
> indeed preferred.

No, use an actual real sample demonstrating the need for the behavior.
Sadly the sample in the relevant ticket for this 404'd last time I
looked.

When we know why and who needs a specific fix for a broken muxer, we
have an avenue for making sure support for that broken muxer is still
needed and, when it is no longer necessary, we can do one of the most
productive things you can do in programming: removing dead code.

/Tomas
___
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 01/10] avfilter/dnn: Refactor DNN parameter configuration system

2024-05-06 Thread Guo, Yejun



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Zhao
> Zhili
> Sent: Tuesday, April 30, 2024 3:12 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Zhao Zhili 
> Subject: [FFmpeg-devel] [PATCH v3 01/10] avfilter/dnn: Refactor DNN
> parameter configuration system
> 
> From: Zhao Zhili 
> 
> This patch trying to resolve mulitiple issues related to parameter
> configuration:
> 
> Firstly, each DNN filters duplicate DNN_COMMON_OPTIONS, which should
> be the common options of backend.
> 
> Secondly, backend options are hidden behind the scene. It's a
> AV_OPT_TYPE_STRING backend_configs for user, and parsed by each
> backend. We don't know each backend support what kind of options
> from the help message.
> 
> Third, DNN backends duplicate DNN_BACKEND_COMMON_OPTIONS.
> 
> Last but not the least, pass backend options via AV_OPT_TYPE_STRING
> makes it hard to pass AV_OPT_TYPE_BINARY to backend, if not impossible.
> 
> This patch puts backend common options and each backend options inside
> DnnContext to reduce code duplication, make options user friendly, and
> easy to extend for future usecase.
> 
> There is a known issue that, for a filter which only support one or two
> of the backends, the help message still show the option of all three
> backends. Each DNN filter should be able to run on any backend. Current
> issue is mostly due to incomplete implementation (e.g., libtorch only
> support DFT_PROCESS_FRAME), and lack of maintenance on the filters.

This patch 01 basically looks good, two comments:
- it is possible that we add one dnn filter with one backend support first, and 
then
other backends one by one some-time later. So, please adjust the help message 
accordingly with only the supported backends.

- is it possible to split this patch into small patches for an easier detail 
review?

> 
> For example,
> 
> ./ffmpeg -h filter=dnn_processing
> 
> dnn_processing AVOptions:
>dnn_backend   ..FV... DNN backend (from INT_MIN to
> INT_MAX) (default tensorflow)
>  tensorflow  1..FV... tensorflow backend flag
>  openvino2..FV... openvino backend flag
>  torch   3..FV... torch backend flag
> 
> dnn_base AVOptions:
>model  ..F path to model file
>input  ..F input name of the model
>output ..F output name of the model
>backend_configs..F...P backend configs (deprecated)
>options..F...P backend configs (deprecated)
>nireq ..F number of request (from 0 to 
> INT_MAX)
> (default 0)
>async ..F use DNN async inference 
> (default true)
>device ..F device to run model
> 
> dnn_tensorflow AVOptions:
>sess_config..F config for SessionOptions
> 
> dnn_openvino AVOptions:
>batch_size..F batch size per request (from 1 
> to 1000)
> (default 1)
>input_resizable   ..F can input be resizable or not 
> (default
> false)
>layout..F input layout of model (from 0 
> to 2) (default
> none)
>  none0..F none
>  nchw1..F nchw
>  nhwc2..F nhwc
>scale   ..F Add scale preprocess operation. 
> Divide each
> element of input by specified value. (from INT_MIN to INT_MAX) (default 0)
>mean..F Add mean preprocess operation. 
> Subtract
> specified value from each element of input. (from INT_MIN to INT_MAX)
> (default 0)
> 
> dnn_th AVOptions:
>optimize  ..F turn on graph executor 
> optimization (from 0
> to 1) (default 0)
> ---
>  libavfilter/dnn/dnn_backend_common.h   |  13 ++-
>  libavfilter/dnn/dnn_backend_openvino.c | 146 ++---
>  libavfilter/dnn/dnn_backend_tf.c   |  82 +-
>  libavfilter/dnn/dnn_backend_torch.cpp  |  67 
>  libavfilter/dnn/dnn_interface.c|  89 +++
>  libavfilter/dnn_filter_common.c|  38 ++-
>  libavfilter/dnn_filter_common.h|  39 +++
>  libavfilter/dnn_interface.h|  67 +++-
>  libavfilter/vf_derain.c|   6 +-
>  libavfilter/vf_dnn_classify.c  |   4 +-
>  libavfilter/vf_dnn_detect.c|   4 +-
>  libavfilter/vf_dnn_processing.c|   4 +-
>  libavfilter/vf_sr.c|   6 +-
>  13 files changed, 336 insertions(+), 229 deletions(-)
___
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 04/12] avcodec/aac/aacdec: Remove unnecessary ff_thread_once()

2024-05-06 Thread Andreas Rheinhardt
ff_aacdec_common_init_once() already uses its own AVOnce.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 6a74b05168..f6a7266123 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -61,7 +61,6 @@
 #include "libavutil/opt.h"
 #include "libavutil/tx.h"
 #include "libavutil/version.h"
-#include "libavutil/thread.h"
 
 #if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
 #define IS_FIXED(is_fixed) (is_fixed)
@@ -1120,12 +1119,6 @@ static int sample_rate_idx (int rate)
 elsereturn 11;
 }
 
-static av_cold void aac_static_table_init(void)
-{
-ff_aacdec_common_init_once();
-}
-static AVOnce aac_table_init = AV_ONCE_INIT;
-
 static av_cold int decode_close(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
@@ -1209,9 +1202,7 @@ static av_cold int 
aac_decode_init_internal(AVCodecContext *avctx)
 if (avctx->sample_rate > 96000)
 return AVERROR_INVALIDDATA;
 
-ret = ff_thread_once(&aac_table_init, &aac_static_table_init);
-if (ret != 0)
-return AVERROR_UNKNOWN;
+ff_aacdec_common_init_once();
 
 ac->avctx = avctx;
 ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
-- 
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 05/12] avcodec/aac/aacdec: Move channel number check out of init_dsp()

2024-05-06 Thread Andreas Rheinhardt
Also move initializing random_state.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index f6a7266123..a78a669602 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1159,13 +1159,6 @@ static av_cold int init_dsp(AVCodecContext *avctx)
 const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
 enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
 
-if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
-av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
-return AVERROR_INVALIDDATA;
-}
-
-ac->random_state = 0x1f2e3d4c;
-
 #define MDCT_INIT(s, fn, len, sval)  \
 scale_fixed = (sval) * 128.0f;   \
 scale_float = (sval) / 32768.0f; \
@@ -1248,6 +1241,13 @@ static av_cold int 
aac_decode_init_internal(AVCodecContext *avctx)
 }
 }
 
+if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
+av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
+return AVERROR_INVALIDDATA;
+}
+
+ac->random_state = 0x1f2e3d4c;
+
 return init_dsp(avctx);
 }
 
-- 
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 06/12] avcodec/aac/aacdec: Avoid branch to set sample_fmt

2024-05-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index a78a669602..1dc4af8a0d 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1200,11 +1200,6 @@ static av_cold int 
aac_decode_init_internal(AVCodecContext *avctx)
 ac->avctx = avctx;
 ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
 
-if (ac->is_fixed)
-avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
-else
-avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
 if (avctx->extradata_size > 0) {
 if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
 avctx->extradata,
@@ -1254,14 +1249,20 @@ static av_cold int 
aac_decode_init_internal(AVCodecContext *avctx)
 static av_cold int aac_decode_init(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
+
 ac->is_fixed = 0;
+avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
+
 return aac_decode_init_internal(avctx);
 }
 
 static av_cold int aac_decode_init_fixed(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
+
 ac->is_fixed = 1;
+avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
+
 return aac_decode_init_internal(avctx);
 }
 
-- 
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 07/12] avcodec/aac/aacdec_float: Call ff_aac_float_common_init() only once

2024-05-06 Thread Andreas Rheinhardt
That's enough.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec_float.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index 5c4eec1204..511db1a604 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -64,6 +64,8 @@ static void init_tables_float_fn(void)
 AAC_RENAME(ff_init_ff_sine_windows)(9);
 
 AAC_RENAME(ff_aac_sbr_init)();
+
+ff_aac_float_common_init();
 }
 
 static int init(AACDecContext *ac)
@@ -75,8 +77,6 @@ static int init(AACDecContext *ac)
 if (!ac->fdsp)
 return AVERROR(ENOMEM);
 
-ff_aac_float_common_init();
-
 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 08/12] avcodec/aac/aacdec_(fixed|float): Avoid AAC_RENAME, INTFLOAT

2024-05-06 Thread Andreas Rheinhardt
Unnecessary now that this has been detemplatized.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec_fixed.c | 20 ++--
 libavcodec/aac/aacdec_float.c | 18 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 92204180a1..083f3b073e 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -43,22 +43,22 @@
 #include "libavcodec/cbrt_data.h"
 #include "libavcodec/aacsbr.h"
 
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_long_1024))[1024];
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_short_128))[128];
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(aac_kbd_long_960))[960];
-DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(aac_kbd_short_120))[120];
+DECLARE_ALIGNED(32, static int, aac_kbd_long_1024_fixed)[1024];
+DECLARE_ALIGNED(32, static int, aac_kbd_short_128_fixed)[128];
+DECLARE_ALIGNED(32, static int, aac_kbd_long_960_fixed)[960];
+DECLARE_ALIGNED(32, static int, aac_kbd_short_120_fixed)[120];
 
 static void init_tables_fixed_fn(void)
 {
-AAC_RENAME(ff_cbrt_tableinit)();
+ff_cbrt_tableinit_fixed();
 
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
+ff_kbd_window_init_fixed(aac_kbd_long_1024_fixed, 4.0, 1024);
+ff_kbd_window_init_fixed(aac_kbd_short_128_fixed, 6.0, 128);
 
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
+ff_kbd_window_init_fixed(aac_kbd_long_960_fixed, 4.0, 960);
+ff_kbd_window_init_fixed(aac_kbd_short_120_fixed, 6.0, 120);
 
-AAC_RENAME(ff_aac_sbr_init)();
+ff_aac_sbr_init_fixed();
 
 init_sine_windows_fixed();
 }
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index 511db1a604..5efc0c1e54 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -51,19 +51,19 @@ DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
 
 static void init_tables_float_fn(void)
 {
-AAC_RENAME(ff_cbrt_tableinit)();
+ff_cbrt_tableinit();
 
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
+ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
+ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
 
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
-AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
+ff_kbd_window_init(aac_kbd_long_960, 4.0, 960);
+ff_kbd_window_init(aac_kbd_short_120, 6.0, 120);
 
-AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
-AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);
-AAC_RENAME(ff_init_ff_sine_windows)(9);
+ff_sine_window_init(sine_960, 960);
+ff_sine_window_init(sine_120, 120);
+ff_init_ff_sine_windows(9);
 
-AAC_RENAME(ff_aac_sbr_init)();
+ff_aac_sbr_init();
 
 ff_aac_float_common_init();
 }
-- 
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 09/12] avcodec/aac/aacdec: Mark flush as cold

2024-05-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 1dc4af8a0d..07dcc2672a 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -539,7 +539,7 @@ static int output_configure(AACDecContext *ac,
 return 0;
 }
 
-static void flush(AVCodecContext *avctx)
+static av_cold void flush(AVCodecContext *avctx)
 {
 AACDecContext *ac= avctx->priv_data;
 int type, i, j;
-- 
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 10/12] avcodec/aac/aacdec: Avoid compiling latm decoder if disabled

2024-05-06 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 07dcc2672a..cd80dd1d7a 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -2510,7 +2510,9 @@ static int aac_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 return buf_size > buf_offset ? buf_consumed : buf_size;
 }
 
+#if CONFIG_AAC_LATM_DECODER
 #include "aacdec_latm.h"
+#endif
 
 #define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
 #define OFF(field) offsetof(AACDecContext, field)
-- 
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 11/12] avcodec/aac/aacdec: Move init functions to aacdec_fixed/float

2024-05-06 Thread Andreas Rheinhardt
This allows to merge it with AACDecDSP.init and remove the latter
(it is called only once anyway); it also allows to make
the fixed/float AACDecDSP and AACDecProc implementations internal
to aacdec_fixed/float.c (which also fixes a violation of our
naming conventions). And it avoids a -Wunused-function warning
when either decoder is disabled.

Signed-off-by: Andreas Rheinhardt 
---
One could also move the FFCodecs, too. This would necessitate
using external linkage for several decode_frame-related functions
as well as flush and close; but it would allow to make the
fixed/float init function static.

 libavcodec/aac/aacdec.c   | 31 --
 libavcodec/aac/aacdec.h   | 11 +++--
 libavcodec/aac/aacdec_dsp_template.c  |  4 +---
 libavcodec/aac/aacdec_fixed.c | 32 +--
 libavcodec/aac/aacdec_float.c | 32 +--
 libavcodec/aac/aacdec_latm.h  |  2 +-
 libavcodec/aac/aacdec_proc_template.c |  2 +-
 7 files changed, 50 insertions(+), 64 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index cd80dd1d7a..dc81df174c 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1181,13 +1181,10 @@ static av_cold int init_dsp(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
-ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
-ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
-
-return ac->dsp.init(ac);
+return 0;
 }
 
-static av_cold int aac_decode_init_internal(AVCodecContext *avctx)
+av_cold int ff_aac_decode_init(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
 int ret;
@@ -1246,26 +1243,6 @@ static av_cold int 
aac_decode_init_internal(AVCodecContext *avctx)
 return init_dsp(avctx);
 }
 
-static av_cold int aac_decode_init(AVCodecContext *avctx)
-{
-AACDecContext *ac = avctx->priv_data;
-
-ac->is_fixed = 0;
-avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
-return aac_decode_init_internal(avctx);
-}
-
-static av_cold int aac_decode_init_fixed(AVCodecContext *avctx)
-{
-AACDecContext *ac = avctx->priv_data;
-
-ac->is_fixed = 1;
-avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
-
-return aac_decode_init_internal(avctx);
-}
-
 /**
  * Skip data_stream_element; reference: table 4.10.
  */
@@ -2555,7 +2532,7 @@ const FFCodec ff_aac_decoder = {
 .p.id= AV_CODEC_ID_AAC,
 .p.priv_class= &decoder_class,
 .priv_data_size  = sizeof(AACDecContext),
-.init= aac_decode_init,
+.init= ff_aac_decode_init_float,
 .close   = decode_close,
 FF_CODEC_DECODE_CB(aac_decode_frame),
 .p.sample_fmts   = (const enum AVSampleFormat[]) {
@@ -2577,7 +2554,7 @@ const FFCodec ff_aac_fixed_decoder = {
 .p.id= AV_CODEC_ID_AAC,
 .p.priv_class= &decoder_class,
 .priv_data_size  = sizeof(AACDecContext),
-.init= aac_decode_init_fixed,
+.init= ff_aac_decode_init_fixed,
 .close   = decode_close,
 FF_CODEC_DECODE_CB(aac_decode_frame),
 .p.sample_fmts   = (const enum AVSampleFormat[]) {
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 4cf764e2e9..775c007aeb 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -216,8 +216,6 @@ typedef struct AACDecProc {
  * DSP-specific primitives
  */
 typedef struct AACDecDSP {
-int (*init)(AACDecContext *ac);
-
 void (*dequant_scalefactors)(SingleChannelElement *sce);
 
 void (*apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe);
@@ -339,12 +337,9 @@ struct AACDecContext {
 #define fdsp  RENAME_FIXED(fdsp)
 #endif
 
-extern const AACDecDSP aac_dsp;
-extern const AACDecDSP aac_dsp_fixed;
-
-extern const AACDecProc aac_proc;
-extern const AACDecProc aac_proc_fixed;
-
+int ff_aac_decode_init(struct AVCodecContext *avctx);
+int ff_aac_decode_init_float(struct AVCodecContext *avctx);
+int ff_aac_decode_init_fixed(struct AVCodecContext *avctx);
 int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce,
   GetBitContext *gb, int common_window, int scale_flag);
 
diff --git a/libavcodec/aac/aacdec_dsp_template.c 
b/libavcodec/aac/aacdec_dsp_template.c
index a42b40f674..70f0a3cce6 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -615,9 +615,7 @@ static void AAC_RENAME(apply_prediction)(AACDecContext *ac, 
SingleChannelElement
 reset_all_predictors(sce->AAC_RENAME(predictor_state));
 }
 
-const AACDecDSP AAC_RENAME(aac_dsp) = {
-.init = &AAC_RENAME(init),
-
+static const AACDecDSP AAC_RENAME(aac_dsp) = {
 .dequant_scalefactors = &AAC_RENAME(dequant_scalefactors),
 .apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo),
 .apply_intensity_stereo = &AAC_RENAME(apply_intensity_stereo),
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 083f3b073e..79d35e05f

[FFmpeg-devel] [PATCH 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly

2024-05-06 Thread Andreas Rheinhardt
This is more in line with how we initialize DSP functions
and avoids tables of function pointers as well as relocations
for these.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec_dsp_template.c  | 43 ++-
 libavcodec/aac/aacdec_fixed.c |  4 +--
 libavcodec/aac/aacdec_float.c |  4 +--
 libavcodec/aac/aacdec_proc_template.c | 11 ---
 4 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/libavcodec/aac/aacdec_dsp_template.c 
b/libavcodec/aac/aacdec_dsp_template.c
index 70f0a3cce6..621baef8ca 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -615,23 +615,26 @@ static void AAC_RENAME(apply_prediction)(AACDecContext 
*ac, SingleChannelElement
 reset_all_predictors(sce->AAC_RENAME(predictor_state));
 }
 
-static const AACDecDSP AAC_RENAME(aac_dsp) = {
-.dequant_scalefactors = &AAC_RENAME(dequant_scalefactors),
-.apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo),
-.apply_intensity_stereo = &AAC_RENAME(apply_intensity_stereo),
-.apply_tns = &AAC_RENAME(apply_tns),
-.apply_ltp = &AAC_RENAME(apply_ltp),
-.update_ltp = &AAC_RENAME(update_ltp),
-
-.apply_prediction = AAC_RENAME(apply_prediction),
-
-.imdct_and_windowing = AAC_RENAME(imdct_and_windowing),
-.imdct_and_windowing_960 = AAC_RENAME(imdct_and_windowing_960),
-.imdct_and_windowing_ld = AAC_RENAME(imdct_and_windowing_ld),
-.imdct_and_windowing_eld = AAC_RENAME(imdct_and_windowing_eld),
-
-.apply_dependent_coupling = AAC_RENAME(apply_dependent_coupling),
-.apply_independent_coupling = AAC_RENAME(apply_independent_coupling),
-
-.clip_output = AAC_RENAME(clip_output),
-};
+static av_cold void AAC_RENAME(aac_dsp_init)(AACDecDSP *aac_dsp)
+{
+#define SET(member) aac_dsp->member = AAC_RENAME(member)
+SET(dequant_scalefactors);
+SET(apply_mid_side_stereo);
+SET(apply_intensity_stereo);
+SET(apply_tns);
+SET(apply_ltp);
+SET(update_ltp);
+
+SET(apply_prediction);
+
+SET(imdct_and_windowing);
+SET(imdct_and_windowing_960);
+SET(imdct_and_windowing_ld);
+SET(imdct_and_windowing_eld);
+
+SET(apply_dependent_coupling);
+SET(apply_independent_coupling);
+
+SET(clip_output);
+#undef SET
+}
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 79d35e05fb..de90880884 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -90,8 +90,8 @@ av_cold int ff_aac_decode_init_fixed(AVCodecContext *avctx)
 ac->is_fixed = 1;
 avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
 
-ac->dsp  = aac_dsp_fixed;
-ac->proc = aac_proc_fixed;
+aac_dsp_init_fixed(&ac->dsp);
+aac_proc_init_fixed(&ac->proc);
 
 ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
 if (!ac->fdsp)
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index d48a21eef2..885d824fa7 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -160,8 +160,8 @@ av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
 ac->is_fixed = 0;
 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 
-ac->dsp  = aac_dsp;
-ac->proc = aac_proc;
+aac_dsp_init(&ac->dsp);
+aac_proc_init(&ac->proc);
 
 ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
 if (!ac->fdsp)
diff --git a/libavcodec/aac/aacdec_proc_template.c 
b/libavcodec/aac/aacdec_proc_template.c
index 1ffea2f93b..fecf228b3b 100644
--- a/libavcodec/aac/aacdec_proc_template.c
+++ b/libavcodec/aac/aacdec_proc_template.c
@@ -433,7 +433,10 @@ static int AAC_RENAME(decode_cce)(AACDecContext *ac, 
GetBitContext *gb, ChannelE
 return 0;
 }
 
-static const AACDecProc AAC_RENAME(aac_proc) = {
-.decode_spectrum_and_dequant = AAC_RENAME(decode_spectrum_and_dequant),
-.decode_cce = AAC_RENAME(decode_cce),
-};
+static av_cold void AAC_RENAME(aac_proc_init)(AACDecProc *aac_proc)
+{
+#define SET(member) aac_proc->member = AAC_RENAME(member)
+SET(decode_spectrum_and_dequant);
+SET(decode_cce);
+#undef SET
+}
-- 
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 v2 2/2] avcodec/vvcdec: ff_vvc_frame_submit, avoid initializing task twice.

2024-05-06 Thread Nuo Mi
On Thu, Apr 25, 2024 at 10:02 PM Nuo Mi  wrote:

> For some error bitstreams, a CTU belongs to two slices/entry points.
> If the decoder initializes and submmits the CTU task twice, it may crash
> the program
> or cause it to enter an infinite loop.
>
> Reported-by: Frank Plowman 
>
> Applied.
Thank you
___
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 4/4] tests/checkasm/vvc_alf: add check_alf_classify

2024-05-06 Thread Nuo Mi
On Wed, May 1, 2024 at 7:06 PM  wrote:

> From: Wu Jianhua 
>
> Perforamnce Test (fps):
> clip  before  after delta
> Tango2_3840x2160_60_10_420_27_LD.266  56  115   105.36%
> RitualDance_1920x1080_60_10_420_32_LD.266 272 481   76.83%
> RitualDance_1920x1080_60_10_420_37_RA.266 303 426   40.59%
>
> Signed-off-by: Wu Jianhua 
>
Hi Jianhua,
Thank you for the patch.
yasm build failed.

libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:805: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:806: error: `%xdefine' expects a macro
identifier
libavcodec/x86/vvc/vvc_alf.asm:807: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:807: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:807: error: (CAT_UNDEF:1) `%undef' expects a
macro identifier
libavcodec/x86/vvc/vvc_alf.asm:807: error: (CAT_UNDEF:1) `%un

Re: [FFmpeg-devel] [PATCH v3 01/10] avfilter/dnn: Refactor DNN parameter configuration system

2024-05-06 Thread Zhao Zhili


> On May 6, 2024, at 19:48, Guo, Yejun  
> wrote:
> 
>> -Original Message-
>> From: ffmpeg-devel > > On Behalf Of Zhao
>> Zhili
>> Sent: Tuesday, April 30, 2024 3:12 PM
>> To: ffmpeg-devel@ffmpeg.org 
>> Cc: Zhao Zhili mailto:zhiliz...@tencent.com>>
>> Subject: [FFmpeg-devel] [PATCH v3 01/10] avfilter/dnn: Refactor DNN
>> parameter configuration system
>> 
>> From: Zhao Zhili 
>> 
>> This patch trying to resolve mulitiple issues related to parameter
>> configuration:
>> 
>> Firstly, each DNN filters duplicate DNN_COMMON_OPTIONS, which should
>> be the common options of backend.
>> 
>> Secondly, backend options are hidden behind the scene. It's a
>> AV_OPT_TYPE_STRING backend_configs for user, and parsed by each
>> backend. We don't know each backend support what kind of options
>> from the help message.
>> 
>> Third, DNN backends duplicate DNN_BACKEND_COMMON_OPTIONS.
>> 
>> Last but not the least, pass backend options via AV_OPT_TYPE_STRING
>> makes it hard to pass AV_OPT_TYPE_BINARY to backend, if not impossible.
>> 
>> This patch puts backend common options and each backend options inside
>> DnnContext to reduce code duplication, make options user friendly, and
>> easy to extend for future usecase.
>> 
>> There is a known issue that, for a filter which only support one or two
>> of the backends, the help message still show the option of all three
>> backends. Each DNN filter should be able to run on any backend. Current
>> issue is mostly due to incomplete implementation (e.g., libtorch only
>> support DFT_PROCESS_FRAME), and lack of maintenance on the filters.
> 
> This patch 01 basically looks good, two comments:
> - it is possible that we add one dnn filter with one backend support first, 
> and then
> other backends one by one some-time later. So, please adjust the help message 
> accordingly with only the supported backends.

I can’t figure out how to do that properly without duplicating some code for 
each
filter. Do you have any idea?

> 
> - is it possible to split this patch into small patches for an easier detail 
> review?

The configuration methods were scattered across filter common code, filters, 
backend
common code and backend implementation. I have written six version, patch 1/10
is hard to split to small patches like patch 2-10.

> 
>> 
>> For example,
>> 
>> ./ffmpeg -h filter=dnn_processing
>> 
>> dnn_processing AVOptions:
>>   dnn_backend   ..FV... DNN backend (from INT_MIN to
>> INT_MAX) (default tensorflow)
>> tensorflow  1..FV... tensorflow backend flag
>> openvino2..FV... openvino backend flag
>> torch   3..FV... torch backend flag
>> 
>> dnn_base AVOptions:
>>   model  ..F path to model file
>>   input  ..F input name of the model
>>   output ..F output name of the model
>>   backend_configs..F...P backend configs (deprecated)
>>   options..F...P backend configs (deprecated)
>>   nireq ..F number of request (from 0 to 
>> INT_MAX)
>> (default 0)
>>   async ..F use DNN async inference 
>> (default true)
>>   device ..F device to run model
>> 
>> dnn_tensorflow AVOptions:
>>   sess_config..F config for SessionOptions
>> 
>> dnn_openvino AVOptions:
>>   batch_size..F batch size per request (from 1 
>> to 1000)
>> (default 1)
>>   input_resizable   ..F can input be resizable or not 
>> (default
>> false)
>>   layout..F input layout of model (from 0 
>> to 2) (default
>> none)
>> none0..F none
>> nchw1..F nchw
>> nhwc2..F nhwc
>>   scale   ..F Add scale preprocess operation. 
>> Divide each
>> element of input by specified value. (from INT_MIN to INT_MAX) (default 0)
>>   mean..F Add mean preprocess operation. 
>> Subtract
>> specified value from each element of input. (from INT_MIN to INT_MAX)
>> (default 0)
>> 
>> dnn_th AVOptions:
>>   optimize  ..F turn on graph executor 
>> optimization (from 0
>> to 1) (default 0)
>> ---
>> libavfilter/dnn/dnn_backend_common.h   |  13 ++-
>> libavfilter/dnn/dnn_backend_openvino.c | 146 ++---
>> libavfilter/dnn/dnn_backend_tf.c   |  82 +-
>> libavfilter/dnn/dnn_backend_torch.cpp  |  67 
>> libavfilter/dnn/dnn_interface.c|  89 +++
>> libavfilter/dnn_filter_common.c|  38 ++-
>> libavfilter/dnn_filter_common.h|  39 +++
>> libavfilter/dnn_interface.h|  67 +++-
>> libavfilter/vf_derain.c|   6 +-
>> libavfilter/

[FFmpeg-devel] [PATCH v2 3/12] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Andreas Rheinhardt
The approach used here has the advantage not to rely
on any DCE.
Also improve certain the checks from
3390693bfb907765f833766f370e0ba8c7894f44 a bit.

Signed-off-by: Andreas Rheinhardt 
---
Now also avoiding the casts in ff_aac_sbr_apply().

 libavcodec/aac/aacdec.c | 63 +
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index c6b93e33a2..4f2a634de7 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -63,6 +63,20 @@
 #include "libavutil/version.h"
 #include "libavutil/thread.h"
 
+#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
+#define IS_FIXED(is_fixed) (is_fixed)
+#define FIXED_OR_FLOAT_EXT(is_fixed, fixed, float) \
+((is_fixed) ? (fixed) : (float))
+#elif CONFIG_AAC_DECODER
+#define IS_FIXED(is_fixed) 0
+#define FIXED_OR_FLOAT_EXT(is_fixed, fixed, float) (float)
+#else
+#define IS_FIXED(is_fixed) 1
+#define FIXED_OR_FLOAT_EXT(is_fixed, fixed, float) (fixed)
+#endif
+#define FIXED_OR_FLOAT(is_fixed, func_or_obj) \
+FIXED_OR_FLOAT_EXT((is_fixed), RENAME_FIXED(func_or_obj), func_or_obj)
+
 /*
  * supported tools
  *
@@ -150,11 +164,7 @@ static av_cold int che_configure(AACDecContext *ac,
 return AVERROR_INVALIDDATA;
 if (che_pos) {
 if (!ac->che[type][id]) {
-int ret;
-if (ac->is_fixed)
-ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, &ac->che[type][id], 
type);
-else
-ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], type);
+int ret = FIXED_OR_FLOAT(ac->is_fixed, 
ff_aac_sbr_ctx_alloc_init)(ac, &ac->che[type][id], type);
 if (ret < 0)
 return ret;
 }
@@ -171,10 +181,7 @@ static av_cold int che_configure(AACDecContext *ac,
 }
 } else {
 if (ac->che[type][id]) {
-if (ac->is_fixed)
-ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
-else
-ff_aac_sbr_ctx_close(ac->che[type][id]);
+FIXED_OR_FLOAT(ac->is_fixed, 
ff_aac_sbr_ctx_close)(ac->che[type][id]);
 }
 av_freep(&ac->che[type][id]);
 }
@@ -1122,8 +1129,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
 int is_fixed = ac->is_fixed;
-void (*sbr_close)(ChannelElement *che) = is_fixed ? 
ff_aac_sbr_ctx_close_fixed :
-ff_aac_sbr_ctx_close;
+void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_fixed, 
ff_aac_sbr_ctx_close);
 
 for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
 for (int i = 0; i < MAX_ELEM_ID; i++) {
@@ -1154,7 +1160,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 static av_cold int init_dsp(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
-int is_fixed = ac->is_fixed, ret;
+int is_fixed = IS_FIXED(ac->is_fixed), ret;
 float scale_fixed, scale_float;
 const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
 enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
@@ -1188,8 +1194,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
 if (ret < 0)
 return ret;
 
-ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
-ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
+ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp);
+ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc);
 
 return ac->dsp.init(ac);
 }
@@ -1315,9 +1321,9 @@ static void decode_ltp(AACDecContext *ac, 
LongTermPrediction *ltp,
 int sfb;
 
 ltp->lag  = get_bits(gb, 11);
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
+if (IS_FIXED(ac->is_fixed))
 ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
-else if (CONFIG_AAC_DECODER)
+else
 ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
 
 for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
@@ -1626,9 +1632,9 @@ static int decode_tns(AACDecContext *ac, 
TemporalNoiseShaping *tns,
 tmp2_idx = 2 * coef_compress + coef_res;
 
 for (i = 0; i < tns->order[w][filt]; i++) {
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
+if (IS_FIXED(ac->is_fixed))
 tns->coef_fixed[w][filt][i] = 
Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)]);
-else if (CONFIG_AAC_DECODER)
+else
 tns->coef[w][filt][i] = 
ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
 }
 }
@@ -1977,11 +1983,7 @@ static int decode_extension_payload(AACDecContext *ac, 
GetBitContext *gb, int cn
 ac->avctx->profile = AV_PROFILE_AAC_HE;
 }
 
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
-res = ff_aac_sbr_decode_extension_fixed(ac, che, gb, crc_flag, 
cnt, elem_type);
-  

Re: [FFmpeg-devel] [PATCH] avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD

2024-05-06 Thread Sean McGovern
Hi Brad,

On Sun, May 5, 2024 at 11:22 PM Brad Smith
 wrote:
>
> avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD
>
> Use the machdep.altivec sysctl on NetBSD for AltiVec detection
> as is done with OpenBSD.
>
> Signed-off-by: Brad Smith 
> ---
>  libavutil/ppc/cpu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
> index bc8bb5f47c..2b13cda662 100644
> --- a/libavutil/ppc/cpu.c
> +++ b/libavutil/ppc/cpu.c
> @@ -27,7 +27,7 @@
>  #if HAVE_UNISTD_H
>  #include 
>  #endif
> -#elif defined(__OpenBSD__)
> +#elif defined(__NetBSD__) || defined(__OpenBSD__)
>  #include 
>  #include 
>  #include 
> @@ -56,8 +56,8 @@ int ff_get_cpu_flags_ppc(void)
>  if (result == VECTORTYPE_ALTIVEC)
>  return AV_CPU_FLAG_ALTIVEC;
>  return 0;
> -#elif defined(__APPLE__) || defined(__OpenBSD__)
> -#ifdef __OpenBSD__
> +#elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
> +#if defined(__NetBSD__) || defined(__OpenBSD__)
>  int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC};
>  #else
>  int sels[2] = {CTL_HW, HW_VECTORUNIT};
> --
> 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".

OK, looks good to me.

-- 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 1/3] avutil/opt: add a note about the av_opt_set_chlayout() behavior

2024-05-06 Thread James Almer
Based on the one for av_opt_set_dict_val().

Signed-off-by: James Almer 
---
 libavutil/opt.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/opt.h b/libavutil/opt.h
index 2d76ec6105..1b30a32317 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -797,6 +797,10 @@ int av_opt_set_image_size(void *obj, const char *name, int 
w, int h, int search_
 int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, 
int search_flags);
 int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat 
fmt, int search_flags);
 int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int 
search_flags);
+/**
+ * @note Any old chlayout present is discarded and replaced with a copy of the 
new one. The
+ * caller still owns layout is and responsible for uninitializing it.
+ */
 int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout 
*layout, int search_flags);
 /**
  * @note Any old dictionary present is discarded and replaced with a copy of 
the new one. The
-- 
2.45.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 2/3] avutil/opt: don't set a channel layout if the option is flagged as read only

2024-05-06 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/opt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index a892e056cb..60b0c2a946 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -949,6 +949,8 @@ int av_opt_set_chlayout(void *obj, const char *name,
 
 if (!o || !target_obj)
 return AVERROR_OPTION_NOT_FOUND;
+if (o->flags & AV_OPT_FLAG_READONLY)
+return AVERROR(EINVAL);
 
 dst = (AVChannelLayout*)((uint8_t*)target_obj + o->offset);
 
-- 
2.45.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 3/3] avutil/opt: propagate av_dict_copy() errors in av_opt_{get, set}_dict_val()

2024-05-06 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/opt.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 60b0c2a946..23bc8c887c 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -934,9 +934,8 @@ int av_opt_set_dict_val(void *obj, const char *name, const 
AVDictionary *val,
 
 dst = (AVDictionary **)(((uint8_t *)target_obj) + o->offset);
 av_dict_free(dst);
-av_dict_copy(dst, val, 0);
 
-return 0;
+return av_dict_copy(dst, val, 0);
 }
 
 int av_opt_set_chlayout(void *obj, const char *name,
@@ -1348,9 +1347,8 @@ int av_opt_get_dict_val(void *obj, const char *name, int 
search_flags, AVDiction
 return AVERROR(EINVAL);
 
 src = *(AVDictionary **)(((uint8_t *)target_obj) + o->offset);
-av_dict_copy(out_val, src, 0);
 
-return 0;
+return av_dict_copy(out_val, src, 0);;
 }
 
 int av_opt_flag_is_set(void *obj, const char *field_name, const char 
*flag_name)
-- 
2.45.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] tests/checkasm/svq1enc: Use proper range for input

2024-05-06 Thread Andreas Rheinhardt
ssd_int8_vs_int16 is only called from encode_block()
in svq1enc.c; it calls it in stages: At stage 0,
the int16_t array contains the difference of two
uint16_t. At each of the following stages, the
int16_t array is filled by subtracting an int8_t from
the current stage's int16_t array. The maximum stage
is five, so the int16_t are in the range
(-255 + 5 * 127)..(255 + 5 * 128).

This commit modifies the checkasm test to only use
values from this range, fixing (undefined) integer overflow
in the test.

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

diff --git a/tests/checkasm/svq1enc.c b/tests/checkasm/svq1enc.c
index 1a6f531141..f9abdcbff8 100644
--- a/tests/checkasm/svq1enc.c
+++ b/tests/checkasm/svq1enc.c
@@ -18,7 +18,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
 #include "libavcodec/svq1encdsp.h"
@@ -26,11 +25,13 @@
 #include "checkasm.h"
 
 #define BUF_SIZE 1024
+#define MIN_VAL (-255 - 5 * 127)
+#define MAX_VAL ( 255 + 5 * 128)
 
 #define randomize(buf, len) \
 do { \
 for (int i = 0; i < len; i++) \
-buf[i] = ((rnd() % 65281) - 32641); \
+buf[i] = ((rnd() % (MAX_VAL - MIN_VAL + 1)) + MIN_VAL); \
 } while (0)
 
 static void test_ssd_int8_vs_int16(SVQ1EncDSPContext *s) {
-- 
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 4/4] avutil/opt: free the temporary layout in av_opt_is_set_to_default()

2024-05-06 Thread James Almer
Signed-off-by: James Almer 
---
 libavutil/opt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 23bc8c887c..2c5f422bd6 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -2309,7 +2309,9 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o)
 if ((ret = av_channel_layout_from_string(&ch_layout, 
o->default_val.str)) < 0)
 return ret;
 }
-return !av_channel_layout_compare((AVChannelLayout *)dst, &ch_layout);
+ret = !av_channel_layout_compare((AVChannelLayout *)dst, &ch_layout);
+av_channel_layout_uninit(&ch_layout);
+return ret;
 }
 case AV_OPT_TYPE_STRING:
 str = *(char **)dst;
-- 
2.45.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] avutil/opt: add a note about the av_opt_set_chlayout() behavior

2024-05-06 Thread Andreas Rheinhardt
James Almer:
> Based on the one for av_opt_set_dict_val().
> 
> Signed-off-by: James Almer 
> ---
>  libavutil/opt.h | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavutil/opt.h b/libavutil/opt.h
> index 2d76ec6105..1b30a32317 100644
> --- a/libavutil/opt.h
> +++ b/libavutil/opt.h
> @@ -797,6 +797,10 @@ int av_opt_set_image_size(void *obj, const char *name, 
> int w, int h, int search_
>  int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat 
> fmt, int search_flags);
>  int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat 
> fmt, int search_flags);
>  int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int 
> search_flags);
> +/**
> + * @note Any old chlayout present is discarded and replaced with a copy of 
> the new one. The
> + * caller still owns layout is and responsible for uninitializing it.

FFSWAP(is, and)

(Apart from this: The behaviour is clear from the fact that
av_opt_set_chlayout() accepts a pointer to const.)

> + */
>  int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout 
> *layout, int search_flags);
>  /**
>   * @note Any old dictionary present is discarded and replaced with a copy of 
> the new one. The

___
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][GSoC 2024] libavcodec/vvc: convert (*sad) to (*sad[6]) to prepare for AVX2 funcs

2024-05-06 Thread Stone Chen
On Wed, May 1, 2024 at 6:59 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Stone Chen:
> > To prepare for adding AVX2 functions for different block widths, change
> VVCInterDSPContext to contain (*sad[6]) instead of (*sad). This also
> default initializes the pointer array with the scalar function and the
> calling sites to jump to the correct function based on block width. There's
> no change in functionality.
> > ---
> >  libavcodec/vvc/dsp.h| 2 +-
> >  libavcodec/vvc/inter.c  | 4 ++--
> >  libavcodec/vvc/inter_template.c | 5 -
> >  3 files changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/vvc/dsp.h b/libavcodec/vvc/dsp.h
> > index 9810ac314c..b06a3ef10e 100644
> > --- a/libavcodec/vvc/dsp.h
> > +++ b/libavcodec/vvc/dsp.h
> > @@ -86,7 +86,7 @@ typedef struct VVCInterDSPContext {
> >
> >  void (*apply_bdof)(uint8_t *dst, ptrdiff_t dst_stride, int16_t
> *src0, int16_t *src1, int block_w, int block_h);
> >
> > -int (*sad)(const int16_t *src0, const int16_t *src1, int dx, int
> dy, int block_w, int block_h);
> > +int (*sad[6])(const int16_t *src0, const int16_t *src1, int dx, int
> dy, int block_w, int block_h);
> >  void (*dmvr[2][2])(int16_t *dst, const uint8_t *src, ptrdiff_t
> src_stride, int height,
> >  intptr_t mx, intptr_t my, int width);
> >  } VVCInterDSPContext;
> > diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
> > index 4a8d1d866a..a68f4f9452 100644
> > --- a/libavcodec/vvc/inter.c
> > +++ b/libavcodec/vvc/inter.c
> > @@ -742,7 +742,7 @@ static void dmvr_mv_refine(VVCLocalContext *lc,
> MvField *mvf, MvField *orig_mv,
> >  fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride,
> pred_h, mx, my, pred_w);
> >  }
> >
> > -min_sad = fc->vvcdsp.inter.sad(tmp[L0], tmp[L1], dx, dy, block_w,
> block_h);
> > +min_sad = fc->vvcdsp.inter.sad[av_log2(block_w) - 2](tmp[L0],
> tmp[L1], dx, dy, block_w, block_h);
> >  min_sad -= min_sad >> 2;
> >  sad[dy][dx] = min_sad;
> >
> > @@ -752,7 +752,7 @@ static void dmvr_mv_refine(VVCLocalContext *lc,
> MvField *mvf, MvField *orig_mv,
> >  for (dy = 0; dy < SAD_ARRAY_SIZE; dy++) {
> >  for (dx = 0; dx < SAD_ARRAY_SIZE; dx++) {
> >  if (dx != sr_range || dy != sr_range) {
> > -sad[dy][dx] = fc->vvcdsp.inter.sad(lc->tmp,
> lc->tmp1, dx, dy, block_w, block_h);
> > +sad[dy][dx] = fc->vvcdsp.inter.sad[av_log2(block_w)
> - 2](lc->tmp, lc->tmp1, dx, dy, block_w, block_h);
> >  if (sad[dy][dx] < min_sad) {
> >  min_sad = sad[dy][dx];
> >  min_dx = dx;
> > diff --git a/libavcodec/vvc/inter_template.c
> b/libavcodec/vvc/inter_template.c
> > index e2fbfd4fc0..545e8dd184 100644
> > --- a/libavcodec/vvc/inter_template.c
> > +++ b/libavcodec/vvc/inter_template.c
> > @@ -458,7 +458,10 @@ static void
> FUNC(ff_vvc_inter_dsp_init)(VVCInterDSPContext *const inter)
> >  inter->apply_prof_uni_w = FUNC(apply_prof_uni_w);
> >  inter->apply_bdof   = FUNC(apply_bdof);
> >  inter->prof_grad_filter = FUNC(prof_grad_filter);
> > -inter->sad  = vvc_sad;
> > +
> > +for (int i = 0; i < FF_ARRAY_ELEMS(inter->sad); i++) {
> > +inter->sad[i]   = vvc_sad;
> > +}
> >  }
> >
> >  #undef FUNCS
>
> Why is the jump depending upon block width not performed inside your
> avx2 implementation?
>
> - Andreas
>

Hi Andreas,

Sorry missed your email,

In hindsight, there's no particular reason, besides that it was the easiest
way (for me) to get jumps to different functions.
I guess I could just use compares to block width and jumps? Or
alternatively figure out how to write a jump table in asm.

Would those methods be better or did you have something different in mind?

Thanks for the feedback!
Stone


>
> ___
> 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 v2 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-06 Thread Christian Bartnik
From: Thomas Siedel 

Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.

Co-authored-by: Christian Bartnik chris1031...@gmail.com
Signed-off-by: Christian Bartnik 
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvdec.c  | 617 +
 4 files changed, 624 insertions(+)
 create mode 100644 libavcodec/libvvdec.c

diff --git a/configure b/configure
index cb312d9c73..a7a9da3276 100755
--- a/configure
+++ b/configure
@@ -294,6 +294,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvencenable H.266/VVC encoding via vvenc [no]
+  --enable-libvvdecenable H.266/VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1968,6 +1969,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvenc
+libvvdec
 libwebp
 libxevd
 libxeve
@@ -3551,6 +3553,8 @@ libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvenc_encoder_deps="libvvenc"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -7014,6 +7018,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version

 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 54d85f6aaa..851b62179d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1156,6 +1156,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index bb2c3ce017..9e0ad00b23 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -802,6 +802,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern const FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvenc_encoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..7f94a81b37
--- /dev/null
+++ b/libavcodec/libvvdec.c
@@ -0,0 +1,617 @@
+/*
+ * H.266 decoding using the VVdeC library
+ *
+ * Copyright (C) 2022, Thomas Siedel
+ *
+ * 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 "config_components.h"
+
+#include 
+
+#include "libavutil/common.h"
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/frame.h"
+#include "libavutil/mastering_display_metadata.h"
+#include "libavutil/log.h"
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "decode.h"
+#include "internal.h"
+#include "profiles.h"
+
+#include "cbs_h266.h"
+
+typedef struct VVdeCContext {
+AVClass  *av_class;
+vvdecDecoder *vvde

[FFmpeg-devel] [PATCH v2 1/2] avcodec: add external enc libvvenc for H266/VVC

2024-05-06 Thread Christian Bartnik
From: Thomas Siedel 

Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.

Co-authored-by: Christian Bartnik chris1031...@gmail.com
Signed-off-by: Christian Bartnik 
---
 configure  |   4 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 501 +
 4 files changed, 507 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index ed74583a6f..cb312d9c73 100755
--- a/configure
+++ b/configure
@@ -293,6 +293,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvenc
 libwebp
 libxevd
 libxeve
@@ -3548,6 +3550,7 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvenc_encoder_deps="libvvenc"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -7010,6 +7013,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version

 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cff6347bdb..54d85f6aaa 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1155,6 +1155,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f4705651fb..bb2c3ce017 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -801,6 +801,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern const FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..c459273f44
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,501 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * Copyright (C) 2022, Thomas Siedel
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/mem.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/frame.h"
+#include "libavutil/log.h"
+
+typedef struct VVenCOptions {
+int preset; // preset 0: faster  4: slower
+int qp; // quantization parameter 0-63
+int subjectiveOptimization; // perceptually motivated QP adapta

[FFmpeg-devel] [PATCH v2 0/2] Add support for H266/VVC encoding

2024-05-06 Thread Christian Bartnik
This patchset is based on the latest patchset from Thomas Siedel
(thomas...@spin-digital.com).
Since almost all changes from the patchset but libvvenc and libvvdec has been
merged this patch only implements the libvvenc and libvvdec wrapper
implementation.
As ffmpeg already has it´s own vvc decoder, feel free to cherry pick libvvenc
only.
The libvvenc patch only has been aligend to the current master without changing
the implementation.
The libvvdec patch has been cleaned up by removing the extradata parsing files
and using existing code from cbs_h266.

Christian Bartnik (2):
  avcodec: add external enc libvvenc for H266/VVC
  avcodec: add external dec libvvdec for H266/VVC

 configure  |   9 +
 libavcodec/Makefile|   2 +
 libavcodec/allcodecs.c |   2 +
 libavcodec/libvvdec.c  | 617 +
 libavcodec/libvvenc.c  | 501 +
 5 files changed, 1131 insertions(+)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c

--
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 v3 1/2] checkasm: add test for fdct

2024-05-06 Thread Ramiro Polla
On Thu, May 2, 2024 at 8:05 PM Rémi Denis-Courmont  wrote:
> Le keskiviikkona 17. huhtikuuta 2024, 21.01.37 EEST Ramiro Polla a écrit :
[...]
> > +static void check_fdct(void)
> > +{
> > +LOCAL_ALIGNED_16(int16_t, block0, [64]);
> > +LOCAL_ALIGNED_16(int16_t, block1, [64]);
> > +
> > +AVCodecContext avctx = { 0 };
>
> AFAICT, that is not a legal context for ff_fdctdst_init(), which expect
> bits_per_raw_sample to be one of 8, 9 or 10. It would also be good manners to
> initialise dct_algo.

Thanks for spotting it. New patch coming up in a while.

I'll send a similar patch to fix checkasm/idctdsp after this is merged.
___
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/2] checkasm: add test for fdct

2024-05-06 Thread Ramiro Polla
Reviewed-by: Martin Storsjö 
Reviewed-by: Rémi Denis-Courmont 
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/fdctdsp.c  | 71 +++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 77 insertions(+)
 create mode 100644 tests/checkasm/fdctdsp.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 3e40aba2c3..b5bb885201 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -4,6 +4,7 @@ AVCODECOBJS-$(CONFIG_AC3DSP)+= ac3dsp.o
 AVCODECOBJS-$(CONFIG_AUDIODSP)  += audiodsp.o
 AVCODECOBJS-$(CONFIG_BLOCKDSP)  += blockdsp.o
 AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
+AVCODECOBJS-$(CONFIG_FDCTDSP)   += fdctdsp.o
 AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
 AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
 AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 9be32fc16e..e5d39e2116 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -106,6 +106,9 @@ static const struct {
 #if CONFIG_EXR_DECODER
 { "exrdsp", checkasm_check_exrdsp },
 #endif
+#if CONFIG_FDCTDSP
+{ "fdctdsp", checkasm_check_fdctdsp },
+#endif
 #if CONFIG_FLAC_DECODER
 { "flacdsp", checkasm_check_flacdsp },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 173360af60..8807a37a43 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -85,6 +85,7 @@ void checkasm_check_blockdsp(void);
 void checkasm_check_bswapdsp(void);
 void checkasm_check_colorspace(void);
 void checkasm_check_exrdsp(void);
+void checkasm_check_fdctdsp(void);
 void checkasm_check_fixed_dsp(void);
 void checkasm_check_flacdsp(void);
 void checkasm_check_float_dsp(void);
diff --git a/tests/checkasm/fdctdsp.c b/tests/checkasm/fdctdsp.c
new file mode 100644
index 00..c640a00656
--- /dev/null
+++ b/tests/checkasm/fdctdsp.c
@@ -0,0 +1,71 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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 
+
+#include "checkasm.h"
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/fdctdsp.h"
+
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/mem_internal.h"
+
+static int int16_cmp_off_by_n(const int16_t *ref, const int16_t *test, size_t 
n, int accuracy)
+{
+for (size_t i = 0; i < n; i++) {
+if (abs(ref[i] - test[i]) > accuracy)
+return 1;
+}
+return 0;
+}
+
+static void check_fdct(void)
+{
+LOCAL_ALIGNED_16(int16_t, block0, [64]);
+LOCAL_ALIGNED_16(int16_t, block1, [64]);
+
+AVCodecContext avctx = {
+.bits_per_raw_sample = 8,
+.dct_algo = FF_DCT_AUTO,
+};
+FDCTDSPContext h;
+
+ff_fdctdsp_init(&h, &avctx);
+
+if (check_func(h.fdct, "fdct")) {
+declare_func(void, int16_t *);
+for (int i = 0; i < 64; i++) {
+uint8_t r = rnd();
+block0[i] = r;
+block1[i] = r;
+}
+call_ref(block0);
+call_new(block1);
+if (int16_cmp_off_by_n(block0, block1, 64, 2))
+fail();
+bench_new(block1);
+}
+}
+
+void checkasm_check_fdctdsp(void)
+{
+check_fdct();
+report("fdctdsp");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index 4a8e312da9..9b5e2b0d98 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -8,6 +8,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp 
\
 fate-checkasm-blockdsp  \
 fate-checkasm-bswapdsp  \
 fate-checkasm-exrdsp\
+fate-checkasm-fdctdsp   \
 fate-checkasm-fixed_dsp \
 fate-checkasm-flacdsp   \
 fate-checkasm-float_dsp \
-- 
2.30.2

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

Re: [FFmpeg-devel] [PATCH 4/6] nvdec_av1: Use av1dec force_integer_mv value

2024-05-06 Thread Timo Rothenpieler

On 27.04.2024 17:30, Mark Thompson wrote:

---
  libavcodec/nvdec_av1.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c
index 4efa420e66..8a46db1ed5 100644
--- a/libavcodec/nvdec_av1.c
+++ b/libavcodec/nvdec_av1.c
@@ -106,9 +106,7 @@ static int nvdec_av1_start_frame(AVCodecContext *avctx, 
const uint8_t *buffer, u
  .show_frame   = frame_header->show_frame,
  .disable_cdf_update   = frame_header->disable_cdf_update,
  .allow_screen_content_tools   = 
frame_header->allow_screen_content_tools,
-.force_integer_mv = frame_header->force_integer_mv ||
-frame_header->frame_type == 
AV1_FRAME_INTRA_ONLY ||
-frame_header->frame_type == 
AV1_FRAME_KEY,
+.force_integer_mv = s->cur_frame.force_integer_mv;


that ";" should be a ","

Works fine with that fixed.


  .coded_denom  = frame_header->coded_denom,
  .allow_intrabc= frame_header->allow_intrabc,
  .allow_high_precision_mv  = 
frame_header->allow_high_precision_mv,


___
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 v4 1/2] checkasm: add test for fdct

2024-05-06 Thread Rémi Denis-Courmont
Le maanantaina 6. toukokuuta 2024, 20.18.39 EEST Ramiro Polla a écrit :
> Reviewed-by: Martin Storsjö 
> Reviewed-by: Rémi Denis-Courmont 
> ---
>  tests/checkasm/Makefile   |  1 +
>  tests/checkasm/checkasm.c |  3 ++
>  tests/checkasm/checkasm.h |  1 +
>  tests/checkasm/fdctdsp.c  | 71 +++
>  tests/fate/checkasm.mak   |  1 +
>  5 files changed, 77 insertions(+)
>  create mode 100644 tests/checkasm/fdctdsp.c
> 
> diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
> index 3e40aba2c3..b5bb885201 100644
> --- a/tests/checkasm/Makefile
> +++ b/tests/checkasm/Makefile
> @@ -4,6 +4,7 @@ AVCODECOBJS-$(CONFIG_AC3DSP)+= ac3dsp.o
>  AVCODECOBJS-$(CONFIG_AUDIODSP)  += audiodsp.o
>  AVCODECOBJS-$(CONFIG_BLOCKDSP)  += blockdsp.o
>  AVCODECOBJS-$(CONFIG_BSWAPDSP)  += bswapdsp.o
> +AVCODECOBJS-$(CONFIG_FDCTDSP)   += fdctdsp.o
>  AVCODECOBJS-$(CONFIG_FMTCONVERT)+= fmtconvert.o
>  AVCODECOBJS-$(CONFIG_G722DSP)   += g722dsp.o
>  AVCODECOBJS-$(CONFIG_H264CHROMA)+= h264chroma.o
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index 9be32fc16e..e5d39e2116 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -106,6 +106,9 @@ static const struct {
>  #if CONFIG_EXR_DECODER
>  { "exrdsp", checkasm_check_exrdsp },
>  #endif
> +#if CONFIG_FDCTDSP
> +{ "fdctdsp", checkasm_check_fdctdsp },
> +#endif
>  #if CONFIG_FLAC_DECODER
>  { "flacdsp", checkasm_check_flacdsp },
>  #endif
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index 173360af60..8807a37a43 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -85,6 +85,7 @@ void checkasm_check_blockdsp(void);
>  void checkasm_check_bswapdsp(void);
>  void checkasm_check_colorspace(void);
>  void checkasm_check_exrdsp(void);
> +void checkasm_check_fdctdsp(void);
>  void checkasm_check_fixed_dsp(void);
>  void checkasm_check_flacdsp(void);
>  void checkasm_check_float_dsp(void);
> diff --git a/tests/checkasm/fdctdsp.c b/tests/checkasm/fdctdsp.c
> new file mode 100644
> index 00..c640a00656
> --- /dev/null
> +++ b/tests/checkasm/fdctdsp.c
> @@ -0,0 +1,71 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 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 General Public License for more details.
> + *
> + * You should have received a copy of the GNU 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 
> +
> +#include "checkasm.h"
> +
> +#include "libavcodec/avcodec.h"
> +#include "libavcodec/fdctdsp.h"
> +
> +#include "libavutil/common.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/mem_internal.h"
> +
> +static int int16_cmp_off_by_n(const int16_t *ref, const int16_t *test,
> size_t n, int accuracy) +{
> +for (size_t i = 0; i < n; i++) {
> +if (abs(ref[i] - test[i]) > accuracy)
> +return 1;
> +}
> +return 0;
> +}
> +
> +static void check_fdct(void)
> +{
> +LOCAL_ALIGNED_16(int16_t, block0, [64]);
> +LOCAL_ALIGNED_16(int16_t, block1, [64]);
> +
> +AVCodecContext avctx = {
> +.bits_per_raw_sample = 8,
> +.dct_algo = FF_DCT_AUTO,
> +};
> +FDCTDSPContext h;
> +
> +ff_fdctdsp_init(&h, &avctx);
> +
> +if (check_func(h.fdct, "fdct")) {
> +declare_func(void, int16_t *);
> +for (int i = 0; i < 64; i++) {
> +uint8_t r = rnd();
> +block0[i] = r;
> +block1[i] = r;
> +}
> +call_ref(block0);
> +call_new(block1);
> +if (int16_cmp_off_by_n(block0, block1, 64, 2))
> +fail();
> +bench_new(block1);
> +}
> +}
> +
> +void checkasm_check_fdctdsp(void)
> +{
> +check_fdct();
> +report("fdctdsp");
> +}
> diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
> index 4a8e312da9..9b5e2b0d98 100644
> --- a/tests/fate/checkasm.mak
> +++ b/tests/fate/checkasm.mak
> @@ -8,6 +8,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp 
>\ fate-checkasm-blockdsp  \
> fate-checkasm-bswapdsp  \
> fate-checkasm-exrdsp\ +   
> fate-checkasm-fdctdsp   \
> fate-checkasm-fixed_dsp \
> fate-checkasm-flacdsp 

Re: [FFmpeg-devel] [PATCH v3 1/2] checkasm: add test for fdct

2024-05-06 Thread Rémi Denis-Courmont
Le maanantaina 6. toukokuuta 2024, 20.18.11 EEST Ramiro Polla a écrit :
> I'll send a similar patch to fix checkasm/idctdsp after this is merged.

The idctdsp test does not actually test the iDCT, but only the trivial-ish 
add/put helpers, so it does not care about the context. You're welcome to fix 
it anyway of course.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



___
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 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Lynne
May 6, 2024, 11:31 by andreas.rheinha...@outlook.com:

> The approach used here has the advantage not to rely
> on any DCE.
> Also improve certain the checks from
> 3390693bfb907765f833766f370e0ba8c7894f44 a bit.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/aac/aacdec.c | 62 -
>  1 file changed, 31 insertions(+), 31 deletions(-)
>
> diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
> index c6b93e33a2..6a74b05168 100644
> --- a/libavcodec/aac/aacdec.c
> +++ b/libavcodec/aac/aacdec.c
> @@ -63,6 +63,20 @@
>  #include "libavutil/version.h"
>  #include "libavutil/thread.h"
>  
> +#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
> +#define IS_FIXED(is_fixed) (is_fixed)
> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
> +((is_fixed) ? RENAME_FIXED(func_or_obj) func_args : (func_or_obj) 
> func_args)
> +#elif CONFIG_AAC_DECODER
> +#define IS_FIXED(is_fixed) 0
> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
> +((func_or_obj) func_args)
> +#else
> +#define IS_FIXED(is_fixed) 1
> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
> +(RENAME_FIXED(func_or_obj) func_args)
> +#endif
> +
>  /*
>  * supported tools
>  *
> @@ -150,11 +164,8 @@ static av_cold int che_configure(AACDecContext *ac,
>  return AVERROR_INVALIDDATA;
>  if (che_pos) {
>  if (!ac->che[type][id]) {
> -int ret;
> -if (ac->is_fixed)
> -ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, 
> &ac->che[type][id], type);
> -else
> -ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], 
> type);
> +int ret = FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_alloc_init,
> + (ac, &ac->che[type][id], type));
>  if (ret < 0)
>  return ret;
>  }
> @@ -171,10 +182,7 @@ static av_cold int che_configure(AACDecContext *ac,
>  }
>  } else {
>  if (ac->che[type][id]) {
> -if (ac->is_fixed)
> -ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
> -else
> -ff_aac_sbr_ctx_close(ac->che[type][id]);
> +FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_close, 
> (ac->che[type][id]));
>  }
>  av_freep(&ac->che[type][id]);
>  }
> @@ -1122,8 +1130,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
>  {
>  AACDecContext *ac = avctx->priv_data;
>  int is_fixed = ac->is_fixed;
> -void (*sbr_close)(ChannelElement *che) = is_fixed ? 
> ff_aac_sbr_ctx_close_fixed :
> -ff_aac_sbr_ctx_close;
> +void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_fixed, 
> ff_aac_sbr_ctx_close, );
>  
>  for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
>  for (int i = 0; i < MAX_ELEM_ID; i++) {
> @@ -1154,7 +1161,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
>  static av_cold int init_dsp(AVCodecContext *avctx)
>  {
>  AACDecContext *ac = avctx->priv_data;
> -int is_fixed = ac->is_fixed, ret;
> +int is_fixed = IS_FIXED(ac->is_fixed), ret;
>  float scale_fixed, scale_float;
>  const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
>  enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
> @@ -1188,8 +1195,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
>  if (ret < 0)
>  return ret;
>  
> -ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
> -ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
> +ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
> +ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
>  
>  return ac->dsp.init(ac);
>  }
> @@ -1315,9 +1322,9 @@ static void decode_ltp(AACDecContext *ac, 
> LongTermPrediction *ltp,
>  int sfb;
>  
>  ltp->lag  = get_bits(gb, 11);
> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
> +if (IS_FIXED(ac->is_fixed))
>  ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
> -else if (CONFIG_AAC_DECODER)
> +else
>  ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
>  
>  for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
> @@ -1626,9 +1633,9 @@ static int decode_tns(AACDecContext *ac, 
> TemporalNoiseShaping *tns,
>  tmp2_idx = 2 * coef_compress + coef_res;
>  
>  for (i = 0; i < tns->order[w][filt]; i++) {
> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
> +if (IS_FIXED(ac->is_fixed))
>  tns->coef_fixed[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, 
> coef_len)]);
> -else if (CONFIG_AAC_DECODER)
> +else
>  tns->coef[w][filt][i] = ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
>  }
>  }
> @@ -1977,11 +1984,8 @@ static int decode_extension_payload(AACDecContext *ac, 
> GetBitContext *gb, int cn
>  ac->avctx->profile = AV_PROFILE_AAC_HE;
>  }
>  
> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
> -res = ff_aac_sbr_decode_extension_fixed(ac, che, gb, crc_flag, 
> cnt, elem_type);
> -else if (C

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/aacsbr: Fix type mismatch

2024-05-06 Thread Lynne
May 6, 2024, 11:31 by andreas.rheinha...@outlook.com:

> ff_aac_sbr_apply() and ff_aac_sbr_apply_fixed() still used
> pointers to INTFLOAT which is float or int depending upon
> whether USE_FIXED is set or not; in particular, according
> to these declarations both functions have the same type.
> But that is wrong and given that aacdec.c sets USE_FIXED,
> it sees the wrong type for ff_aac_sbr_apply().
> Fix this by avoiding INTFLOAT in aacsbr.h (which also means
> that aac_defines.h need not be included there any more).
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/aac/aacdec.c | 1 +
>  libavcodec/aacsbr.h | 5 ++---
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
> index 72f2d7e7ba..c6b93e33a2 100644
> --- a/libavcodec/aac/aacdec.c
> +++ b/libavcodec/aac/aacdec.c
> @@ -42,6 +42,7 @@
>  #include "aacdec_tab.h"
>  
>  #include "libavcodec/aac.h"
> +#include "libavcodec/aac_defines.h"
>  #include "libavcodec/aacsbr.h"
>  #include "libavcodec/aactab.h"
>  #include "libavcodec/adts_header.h"
> diff --git a/libavcodec/aacsbr.h b/libavcodec/aacsbr.h
> index cd030aa801..656ef5258e 100644
> --- a/libavcodec/aacsbr.h
> +++ b/libavcodec/aacsbr.h
> @@ -31,7 +31,6 @@
>  
>  #include "get_bits.h"
>  #include "aac/aacdec.h"
> -#include "aac_defines.h"
>  
>  #include "libavutil/attributes_internal.h"
>  
> @@ -91,9 +90,9 @@ int ff_aac_sbr_decode_extension_fixed(AACDecContext *ac, 
> ChannelElement *che,
>  
>  /** Apply one SBR element to one AAC element. */
>  void ff_aac_sbr_apply(AACDecContext *ac, ChannelElement *che,
> -  int id_aac, INTFLOAT* L, INTFLOAT* R);
> +  int id_aac, float *L, float *R);
>  void ff_aac_sbr_apply_fixed(AACDecContext *ac, ChannelElement *che,
> -int id_aac, INTFLOAT* L, INTFLOAT* R);
> +int id_aac, int *L, int *R); 
>

Patch 1 and 2 look good to me
___
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 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly

2024-05-06 Thread Lynne
May 6, 2024, 14:16 by andreas.rheinha...@outlook.com:

> This is more in line with how we initialize DSP functions
> and avoids tables of function pointers as well as relocations
> for these.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/aac/aacdec_dsp_template.c  | 43 ++-
>  libavcodec/aac/aacdec_fixed.c |  4 +--
>  libavcodec/aac/aacdec_float.c |  4 +--
>  libavcodec/aac/aacdec_proc_template.c | 11 ---
>  4 files changed, 34 insertions(+), 28 deletions(-)
>

Nice
Patch 4 to 12 LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 1/3] lavc/h265_profile_level: Expand profile compatibility checking

2024-05-06 Thread Mark Thompson
Replace existing get_profile() with find_profile(), which finds the
lowest compatible profile rather than requiring an exact match.
---
Series changes since v1:
* Added H265_PROFILE_INVALID with value zero because it simplifies some code 
(and the values don't matter).
* Fixed the h265-levels test.
* Added a new h265-profiles test which tests the profile compatibility checking.
* Fixed missing VAAPI profiles.


 libavcodec/h265_profile_level.c | 78 +
 libavcodec/h265_profile_level.h | 71 +-
 libavcodec/tests/h265_levels.c  |  2 +-
 libavcodec/vaapi_hevc.c |  2 +-
 libavcodec/vdpau_hevc.c |  2 +-
 5 files changed, 123 insertions(+), 32 deletions(-)

diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
index 7ff9681f65..2e4a1c88bf 100644
--- a/libavcodec/h265_profile_level.c
+++ b/libavcodec/h265_profile_level.c
@@ -40,6 +40,7 @@ static const H265LevelDescriptor h265_levels[] = {
 };
 
 static const H265ProfileDescriptor h265_profiles[] = {
+{ "Invalid" },
 // profile_idc   8bit   one-picture
 //   HT-profile  | 422chroma| lower-bit-rate
 //   |  14bit|  | 420chroma |  | CpbVclFactor MinCrScaleFactor
@@ -119,41 +120,62 @@ static const H265ProfileDescriptor h265_profiles[] = {
   5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
 };
 
+_Static_assert(H265_PROFILE_COUNT == FF_ARRAY_ELEMS(h265_profiles),
+   "Incorrect H.265 profiles table.");
 
-const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel 
*ptl)
+
+const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
+ int profile)
 {
-int i;
+const H265ProfileDescriptor *desc;
+
+av_assert0(profile > H265_PROFILE_INVALID &&
+   profile < H265_PROFILE_COUNT);
 
 if (ptl->general_profile_space)
-return NULL;
+return 0;
 
-for (i = 0; i < FF_ARRAY_ELEMS(h265_profiles); i++) {
-const H265ProfileDescriptor *profile = &h265_profiles[i];
+desc = &h265_profiles[profile];
 
-if (ptl->general_profile_idc &&
-ptl->general_profile_idc != profile->profile_idc)
-continue;
-if (!ptl->general_profile_compatibility_flag[profile->profile_idc])
-continue;
+if (ptl->general_profile_idc &&
+ptl->general_profile_idc != desc->profile_idc)
+return 0;
+if (!ptl->general_profile_compatibility_flag[desc->profile_idc])
+return 0;
 
-#define check_flag(name) \
-if (profile->name < 2) { \
-if (profile->name != ptl->general_ ## name ## _constraint_flag) \
-continue; \
-}
-check_flag(max_14bit);
-check_flag(max_12bit);
-check_flag(max_10bit);
-check_flag(max_8bit);
-check_flag(max_422chroma);
-check_flag(max_420chroma);
-check_flag(max_monochrome);
-check_flag(intra);
-check_flag(one_picture_only);
-check_flag(lower_bit_rate);
+#define check_flag(flag) \
+if (desc->flag < 2 && \
+desc->flag > ptl->general_ ## flag ## _constraint_flag) \
+return 0;
+check_flag(max_14bit);
+check_flag(max_12bit);
+check_flag(max_10bit);
+check_flag(max_8bit);
+check_flag(max_422chroma);
+check_flag(max_420chroma);
+check_flag(max_monochrome);
+check_flag(intra);
+check_flag(one_picture_only);
+check_flag(lower_bit_rate);
 #undef check_flag
 
-return profile;
+return 1;
+}
+
+
+const H265ProfileDescriptor *ff_h265_get_profile(int profile)
+{
+av_assert0(profile > H265_PROFILE_INVALID &&
+   profile < H265_PROFILE_COUNT);
+
+return &h265_profiles[profile];
+}
+
+const H265ProfileDescriptor *ff_h265_find_profile(const 
H265RawProfileTierLevel *ptl)
+{
+for (int p = 1; p < H265_PROFILE_COUNT; p++) {
+if (ff_h265_profile_compatible(ptl, p))
+return &h265_profiles[p];
 }
 
 return NULL;
@@ -171,12 +193,12 @@ const H265LevelDescriptor *ff_h265_guess_level(const 
H265RawProfileTierLevel *pt
 int i;
 
 if (ptl)
-profile = ff_h265_get_profile(ptl);
+profile = ff_h265_find_profile(ptl);
 else
 profile = NULL;
 if (!profile) {
 // Default to using multiplication factors for Main profile.
-profile = &h265_profiles[4];
+profile = &h265_profiles[H265_PROFILE_MAIN];
 }
 
 pic_size = width * height;
diff --git a/libavcodec/h265_profile_level.h b/libavcodec/h265_profile_level.h
index cd30ac5c50..e4e63dfef1 100644
--- a/libavcodec/h265_profile_level.h
+++ b/libavcodec/h265_profile_level.h
@@ -24,6 +24,50 @@
 #include "cbs_h265.h"
 
 
+// Enumeration of all H.265 profiles.
+// The list is ordered to match table A.10; numeric values are an index
+// into the latest version of this table and have no codec meaning.
+enum {
+H265_PROFILE_I

[FFmpeg-devel] [PATCH v2 2/3] lavc: Add test for H.265 profile handling

2024-05-06 Thread Mark Thompson
---
 libavcodec/Makefile  |   2 +-
 libavcodec/tests/.gitignore  |   1 +
 libavcodec/tests/h265_profiles.c | 440 +++
 tests/fate/libavcodec.mak|   5 +
 4 files changed, 447 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/h265_profiles.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cff6347bdb..15e38ded28 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1307,7 +1307,7 @@ TESTPROGS-$(CONFIG_MJPEG_ENCODER) += 
mjpegenc_huffman
 TESTPROGS-$(HAVE_MMX) += motion
 TESTPROGS-$(CONFIG_MPEGVIDEO) += mpeg12framerate
 TESTPROGS-$(CONFIG_H264_METADATA_BSF) += h264_levels
-TESTPROGS-$(CONFIG_HEVC_METADATA_BSF) += h265_levels
+TESTPROGS-$(CONFIG_HEVC_METADATA_BSF) += h265_levels h265_profiles
 TESTPROGS-$(CONFIG_RANGECODER)+= rangecoder
 TESTPROGS-$(CONFIG_SNOW_ENCODER)  += snowenc
 
diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore
index 0df4ae10a0..bf29f03911 100644
--- a/libavcodec/tests/.gitignore
+++ b/libavcodec/tests/.gitignore
@@ -10,6 +10,7 @@
 /golomb
 /h264_levels
 /h265_levels
+/h265_profiles
 /htmlsubtitles
 /iirfilter
 /jpeg2000dwt
diff --git a/libavcodec/tests/h265_profiles.c b/libavcodec/tests/h265_profiles.c
new file mode 100644
index 00..6a0df58d0b
--- /dev/null
+++ b/libavcodec/tests/h265_profiles.c
@@ -0,0 +1,440 @@
+/*
+ * 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/bprint.h"
+#include "libavutil/common.h"
+#include "libavcodec/h265_profile_level.h"
+
+
+enum {
+TYPE_MAIN,
+TYPE_SP,
+TYPE_REXT_INTER,
+TYPE_REXT_INTRA,
+TYPE_HT,
+TYPE_HT_INTRA,
+TYPE_SCC,
+TYPE_HT_SCC,
+TYPE_COUNT,
+};
+enum {
+DEPTH_8,
+DEPTH_10,
+DEPTH_12,
+DEPTH_14,
+DEPTH_16,
+DEPTH_COUNT,
+};
+enum {
+CHROMA_MONO,
+CHROMA_420,
+CHROMA_422,
+CHROMA_444,
+CHROMA_COUNT,
+};
+
+// Table of all profiles indexed by chroma subsampling, bit depth and
+// profile type.  This is currently only being used to verify that
+// profile properties are correct, but if there is some other need for
+// this lookup in lavc then the table should be moved to the common
+// profile-level code.  All profiles should appear exactly once in this
+// table (also verified by a test below).
+static int profile_table[CHROMA_COUNT][DEPTH_COUNT][TYPE_COUNT] = {
+[CHROMA_MONO] = {
+[DEPTH_8] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MONOCHROME,
+},
+[DEPTH_10] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MONOCHROME_10,
+},
+[DEPTH_12] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MONOCHROME_12,
+},
+[DEPTH_16] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MONOCHROME_16,
+},
+},
+[CHROMA_420] = {
+[DEPTH_8] = {
+[TYPE_MAIN]   = H265_PROFILE_MAIN,
+[TYPE_SP] = H265_PROFILE_MAIN_STILL_PICTURE,
+[TYPE_REXT_INTRA] = H265_PROFILE_MAIN_INTRA,
+[TYPE_SCC]= H265_PROFILE_SCREEN_EXTENDED_MAIN,
+},
+[DEPTH_10] = {
+[TYPE_MAIN]   = H265_PROFILE_MAIN_10,
+[TYPE_SP] = H265_PROFILE_MAIN_10_STILL_PICTURE,
+[TYPE_REXT_INTRA] = H265_PROFILE_MAIN_10_INTRA,
+[TYPE_SCC]= H265_PROFILE_SCREEN_EXTENDED_MAIN_10,
+},
+[DEPTH_12] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MAIN_12,
+[TYPE_REXT_INTRA] = H265_PROFILE_MAIN_12_INTRA,
+},
+},
+[CHROMA_422] ={
+[DEPTH_10] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MAIN_422_10,
+[TYPE_REXT_INTRA] = H265_PROFILE_MAIN_422_10_INTRA,
+},
+[DEPTH_12] = {
+[TYPE_REXT_INTER] = H265_PROFILE_MAIN_422_12,
+[TYPE_REXT_INTRA] = H265_PROFILE_MAIN_422_12_INTRA,
+},
+},
+[CHROMA_444] ={
+[DEPTH_8] = {
+[TYPE_SP] = H265_PROFILE_MAIN_444_STILL_PICTURE,
+[TYPE_REXT_INTER] = H265_PROFILE_MAIN_444,
+[TYPE_REXT_INTRA] = H265_PROFILE_MAIN_444_INTRA,
+[TYPE_HT] = H265_PROFILE_HIGH_THROUGHPUT_444,
+   

[FFmpeg-devel] [PATCH v2 3/3] lavc/vaapi_hevc: Don't require exact profiles

2024-05-06 Thread Mark Thompson
Rather than turning the constraint flags into a single profile and then
searching for that profile (and failing if it doesn't match any profile
exactly), instead search all supported profiles and use the first one
which supports the given set of constraint flags.
---
 libavcodec/vaapi_decode.c | 45 +++---
 libavcodec/vaapi_hevc.c   | 99 ++-
 libavcodec/vaapi_hevc.h   |  4 +-
 3 files changed, 87 insertions(+), 61 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 21b273cd0f..f1327464f5 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -387,7 +387,9 @@ static const struct {
 enum AVCodecID codec_id;
 int codec_profile;
 VAProfile va_profile;
-VAProfile (*profile_parser)(AVCodecContext *avctx);
+VAProfile (*match_profile)(AVCodecContext *avctx,
+   const VAProfile *profile_list,
+   int profile_count);
 } vaapi_profile_map[] = {
 #define MAP(c, p, v, ...) { AV_CODEC_ID_ ## c, AV_PROFILE_ ## p, VAProfile ## 
v, __VA_ARGS__ }
 MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2Simple ),
@@ -414,9 +416,9 @@ static const struct {
 #endif
 #if VA_CHECK_VERSION(1, 2, 0) && CONFIG_HEVC_VAAPI_HWACCEL
 MAP(HEVC,HEVC_REXT,   None,
- ff_vaapi_parse_hevc_rext_scc_profile ),
+ ff_vaapi_hevc_match_rext_scc_profile ),
 MAP(HEVC,HEVC_SCC,None,
- ff_vaapi_parse_hevc_rext_scc_profile ),
+ ff_vaapi_hevc_match_rext_scc_profile ),
 #endif
 MAP(MJPEG,   MJPEG_HUFFMAN_BASELINE_DCT,
   JPEGBaseline),
@@ -499,22 +501,33 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 vaapi_profile_map[i].codec_profile == AV_PROFILE_UNKNOWN)
 profile_match = 1;
 
-va_profile = vaapi_profile_map[i].profile_parser ?
- vaapi_profile_map[i].profile_parser(avctx) :
- vaapi_profile_map[i].va_profile;
 codec_profile = vaapi_profile_map[i].codec_profile;
-
-for (j = 0; j < profile_count; j++) {
-if (va_profile == profile_list[j]) {
-exact_match = profile_match;
+if (vaapi_profile_map[i].match_profile) {
+va_profile =
+vaapi_profile_map[i].match_profile(avctx, profile_list,
+   profile_count);
+if (va_profile != VAProfileNone) {
+matched_va_profile = va_profile;
+matched_ff_profile = codec_profile;
+exact_match = 1;
 break;
 }
-}
-if (j < profile_count) {
-matched_va_profile = va_profile;
-matched_ff_profile = codec_profile;
-if (exact_match)
-break;
+} else {
+va_profile = vaapi_profile_map[i].va_profile;
+
+for (j = 0; j < profile_count; j++) {
+if (va_profile == profile_list[j]) {
+exact_match = profile_match;
+break;
+}
+}
+
+if (j < profile_count) {
+matched_va_profile = va_profile;
+matched_ff_profile = codec_profile;
+if (exact_match)
+break;
+}
 }
 }
 av_freep(&profile_list);
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 77f55ff8b1..bda9b5f589 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -590,63 +590,74 @@ static int ptl_convert(const PTLCommon *general_ptl, 
H265RawProfileTierLevel *h2
 }
 
 /*
- * Find exact va_profile for HEVC Range Extension and Screen Content Coding 
Extension
+ * Find compatible va_profile for HEVC Range Extension and Screen
+ * Content Coding Extension profiles.
  */
-VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
+VAProfile ff_vaapi_hevc_match_rext_scc_profile(AVCodecContext *avctx,
+   const VAProfile *profile_list,
+   int profile_count)
 {
 const HEVCContext *h = avctx->priv_data;
 const HEVCSPS *sps = h->ps.sps;
 const PTL *ptl = &sps->ptl;
 const PTLCommon *general_ptl = &ptl->general_ptl;
-const H265ProfileDescriptor *profile;
 H265RawProfileTierLevel h265_raw_ptl = {0};
 
+static const struct {
+int profile;
+VAProfile va_profile;
+} map[] = {
+#if VA_CHECK_VERSION(1, 2, 0)
+{ H265_PROFILE_MAIN_12,
+  VAProfileHEVCMain12 },
+{ H265_PROFILE_MAIN_422_10,
+  VAProfileHEVCMain422_10 },
+{ H265_PROFILE_MAIN_422_12,
+  VAProfileHEVCMain422_12 },
+{ H265_PROFILE_MAIN_444,
+  VAProfileHEVCMain444 },
+{ H265_PROFILE_MAIN_444_10,
+  VAProfileHEVCMain444_10 },

Re: [FFmpeg-devel] [PATCH v3 6/9] lavc/vp8dsp: R-V V put_epel hv

2024-05-06 Thread Rémi Denis-Courmont
Le maanantaina 6. toukokuuta 2024, 6.38.06 EEST u...@foxmail.com a écrit :
> From: sunyuechi 
> 
> C908:
> vp8_put_epel4_h4v4_c: 20.0
> vp8_put_epel4_h4v4_rvv_i32: 11.0
> vp8_put_epel4_h4v6_c: 25.2
> vp8_put_epel4_h4v6_rvv_i32: 13.5
> vp8_put_epel4_h6v4_c: 22.2
> vp8_put_epel4_h6v4_rvv_i32: 14.5
> vp8_put_epel4_h6v6_c: 29.0
> vp8_put_epel4_h6v6_rvv_i32: 15.7
> vp8_put_epel8_h4v4_c: 73.0
> vp8_put_epel8_h4v4_rvv_i32: 22.2
> vp8_put_epel8_h4v6_c: 90.5
> vp8_put_epel8_h4v6_rvv_i32: 26.7
> vp8_put_epel8_h6v4_c: 85.0
> vp8_put_epel8_h6v4_rvv_i32: 27.2
> vp8_put_epel8_h6v6_c: 104.7
> vp8_put_epel8_h6v6_rvv_i32: 29.5
> vp8_put_epel16_h4v4_c: 145.5
> vp8_put_epel16_h4v4_rvv_i32: 26.5
> vp8_put_epel16_h4v6_c: 190.7
> vp8_put_epel16_h4v6_rvv_i32: 47.5
> vp8_put_epel16_h6v4_c: 173.7
> vp8_put_epel16_h6v4_rvv_i32: 33.2
> vp8_put_epel16_h6v6_c: 222.2
> vp8_put_epel16_h6v6_rvv_i32: 35.5
> ---
>  libavcodec/riscv/vp8dsp_init.c |  13 
>  libavcodec/riscv/vp8dsp_rvv.S  | 117 +++--
>  2 files changed, 109 insertions(+), 21 deletions(-)
> 
> diff --git a/libavcodec/riscv/vp8dsp_init.c b/libavcodec/riscv/vp8dsp_init.c
> index dc3e087f01..463c8fa0a2 100644
> --- a/libavcodec/riscv/vp8dsp_init.c
> +++ b/libavcodec/riscv/vp8dsp_init.c
> @@ -97,6 +97,19 @@ av_cold void ff_vp78dsp_init_riscv(VP8DSPContext *c)
>  c->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_rvv;
>  c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_rvv;
>  c->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_rvv;
> +
> +c->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_rvv;
> +c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_rvv;
> +c->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_rvv;
> +c->put_vp8_epel_pixels_tab[0][2][1] = ff_put_vp8_epel16_h4v6_rvv;
> +c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_rvv;
> +c->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_rvv;
> +c->put_vp8_epel_pixels_tab[0][1][1] = ff_put_vp8_epel16_h4v4_rvv;
> +c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_rvv;
> +c->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_rvv;
> +c->put_vp8_epel_pixels_tab[0][1][2] = ff_put_vp8_epel16_h6v4_rvv;
> +c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_rvv;
> +c->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_rvv;
>  }
>  #endif
>  #endif
> diff --git a/libavcodec/riscv/vp8dsp_rvv.S b/libavcodec/riscv/vp8dsp_rvv.S
> index bf268e4d8d..baa8152830 100644
> --- a/libavcodec/riscv/vp8dsp_rvv.S
> +++ b/libavcodec/riscv/vp8dsp_rvv.S
> @@ -161,26 +161,26 @@ const subpel_filters
>  .byte 0,  -1,  12, 123,  -6, 0
>  endconst
> 
> -.macro epel_filter size type
> -lla t2, subpel_filters
> +.macro epel_filter size type regtype
> +lla \regtype\()2, subpel_filters
>  .ifc \type,v
> -addit0, a6, -1
> +addi\regtype\()0, a6, -1

IMO, passing a complete register name, if you really need to vary it, would be 
simpler and more flexible than an ABI register type prefix.

>  .elseif \type == h
> -addit0, a5, -1
> +addi\regtype\()0, a5, -1
>  .endif
> -li  t1, 6
> -mul t0, t0, t1
> -add t0, t0, t2
> +li  \regtype\()1, 6
> +mul \regtype\()0, \regtype\()0, \regtype\()1
> +add \regtype\()0, \regtype\()0, \regtype\()2
>  .irp n 1,2,3,4
> -lb  t\n, \n(t0)
> +lb  \regtype\n, \n(\regtype\()0)
>  .endr
>  .ifc \size,6
> -lb  t5, 5(t0)
> -lb  t0, (t0)
> +lb  \regtype\()5, 5(\regtype\()0)
> +lb  \regtype\()0, (\regtype\()0)
>  .endif
>  .endm
> 
> -.macro epel_load dst len size type
> +.macro epel_load dst len size type from_mem regtype
>  .ifc \type,v
>  mv  a5, a3
>  .else
> @@ -189,24 +189,35 @@ endconst
>  sub t6, a2, a5
>  add a7, a2, a5
> 
> +.if \from_mem
>  vle8.v  v24, (a2)
>  vle8.v  v22, (t6)
>  vle8.v  v26, (a7)
>  add a7, a7, a5
>  vle8.v  v28, (a7)
> -vwmulu.vx   v16, v24, t2
> -vwmulu.vx   v20, v26, t3
> +vwmulu.vx   v16, v24, \regtype\()2
> +vwmulu.vx   v20, v26, \regtype\()3
>  .ifc \size,6
>  sub t6, t6, a5
>  add a7, a7, a5
>  vle8.v  v24, (t6)
>  vle8.v  v26, (a7)
> -vwmaccu.vx  v16, t0, v24
> -vwmaccu.vx  v16, t5, v26
> +vwmaccu.vx  v16, \regtype\()0, v24
> +vwmaccu.vx  v16, \regtype\()5, v26
> +.endif
> +

Re: [FFmpeg-devel] [PATCH 4/6] nvdec_av1: Use av1dec force_integer_mv value

2024-05-06 Thread Mark Thompson
On 06/05/2024 18:19, Timo Rothenpieler wrote:
> On 27.04.2024 17:30, Mark Thompson wrote:
>> ---
>>   libavcodec/nvdec_av1.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c
>> index 4efa420e66..8a46db1ed5 100644
>> --- a/libavcodec/nvdec_av1.c
>> +++ b/libavcodec/nvdec_av1.c
>> @@ -106,9 +106,7 @@ static int nvdec_av1_start_frame(AVCodecContext *avctx, 
>> const uint8_t *buffer, u
>>   .show_frame   = frame_header->show_frame,
>>   .disable_cdf_update   = 
>> frame_header->disable_cdf_update,
>>   .allow_screen_content_tools   = 
>> frame_header->allow_screen_content_tools,
>> -    .force_integer_mv = frame_header->force_integer_mv 
>> ||
>> -    frame_header->frame_type == 
>> AV1_FRAME_INTRA_ONLY ||
>> -    frame_header->frame_type == 
>> AV1_FRAME_KEY,
>> +    .force_integer_mv = s->cur_frame.force_integer_mv;
> 
> that ";" should be a ","
> 
> Works fine with that fixed.

Urgh, thank you for testing and catching that.

Fixed and pushed the set (with approval from Lynne).

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Andreas Rheinhardt
Lynne:
> May 6, 2024, 11:31 by andreas.rheinha...@outlook.com:
> 
>> The approach used here has the advantage not to rely
>> on any DCE.
>> Also improve certain the checks from
>> 3390693bfb907765f833766f370e0ba8c7894f44 a bit.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/aac/aacdec.c | 62 -
>>  1 file changed, 31 insertions(+), 31 deletions(-)
>>
>> diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
>> index c6b93e33a2..6a74b05168 100644
>> --- a/libavcodec/aac/aacdec.c
>> +++ b/libavcodec/aac/aacdec.c
>> @@ -63,6 +63,20 @@
>>  #include "libavutil/version.h"
>>  #include "libavutil/thread.h"
>>  
>> +#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
>> +#define IS_FIXED(is_fixed) (is_fixed)
>> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
>> +((is_fixed) ? RENAME_FIXED(func_or_obj) func_args : (func_or_obj) 
>> func_args)
>> +#elif CONFIG_AAC_DECODER
>> +#define IS_FIXED(is_fixed) 0
>> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
>> +((func_or_obj) func_args)
>> +#else
>> +#define IS_FIXED(is_fixed) 1
>> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
>> +(RENAME_FIXED(func_or_obj) func_args)
>> +#endif
>> +
>>  /*
>>  * supported tools
>>  *
>> @@ -150,11 +164,8 @@ static av_cold int che_configure(AACDecContext *ac,
>>  return AVERROR_INVALIDDATA;
>>  if (che_pos) {
>>  if (!ac->che[type][id]) {
>> -int ret;
>> -if (ac->is_fixed)
>> -ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, 
>> &ac->che[type][id], type);
>> -else
>> -ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], 
>> type);
>> +int ret = FIXED_OR_FLOAT(ac->is_fixed, 
>> ff_aac_sbr_ctx_alloc_init,
>> + (ac, &ac->che[type][id], type));
>>  if (ret < 0)
>>  return ret;
>>  }
>> @@ -171,10 +182,7 @@ static av_cold int che_configure(AACDecContext *ac,
>>  }
>>  } else {
>>  if (ac->che[type][id]) {
>> -if (ac->is_fixed)
>> -ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
>> -else
>> -ff_aac_sbr_ctx_close(ac->che[type][id]);
>> +FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_close, 
>> (ac->che[type][id]));
>>  }
>>  av_freep(&ac->che[type][id]);
>>  }
>> @@ -1122,8 +1130,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
>>  {
>>  AACDecContext *ac = avctx->priv_data;
>>  int is_fixed = ac->is_fixed;
>> -void (*sbr_close)(ChannelElement *che) = is_fixed ? 
>> ff_aac_sbr_ctx_close_fixed :
>> -
>> ff_aac_sbr_ctx_close;
>> +void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_fixed, 
>> ff_aac_sbr_ctx_close, );
>>  
>>  for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
>>  for (int i = 0; i < MAX_ELEM_ID; i++) {
>> @@ -1154,7 +1161,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
>>  static av_cold int init_dsp(AVCodecContext *avctx)
>>  {
>>  AACDecContext *ac = avctx->priv_data;
>> -int is_fixed = ac->is_fixed, ret;
>> +int is_fixed = IS_FIXED(ac->is_fixed), ret;
>>  float scale_fixed, scale_float;
>>  const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
>>  enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
>> @@ -1188,8 +1195,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
>>  if (ret < 0)
>>  return ret;
>>  
>> -ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
>> -ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
>> +ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
>> +ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
>>  
>>  return ac->dsp.init(ac);
>>  }
>> @@ -1315,9 +1322,9 @@ static void decode_ltp(AACDecContext *ac, 
>> LongTermPrediction *ltp,
>>  int sfb;
>>  
>>  ltp->lag  = get_bits(gb, 11);
>> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
>> +if (IS_FIXED(ac->is_fixed))
>>  ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
>> -else if (CONFIG_AAC_DECODER)
>> +else
>>  ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
>>  
>>  for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
>> @@ -1626,9 +1633,9 @@ static int decode_tns(AACDecContext *ac, 
>> TemporalNoiseShaping *tns,
>>  tmp2_idx = 2 * coef_compress + coef_res;
>>  
>>  for (i = 0; i < tns->order[w][filt]; i++) {
>> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
>> +if (IS_FIXED(ac->is_fixed))
>>  tns->coef_fixed[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, 
>> coef_len)]);
>> -else if (CONFIG_AAC_DECODER)
>> +else
>>  tns->coef[w][filt][i] = ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
>>  }
>>  }
>> @@ -1977,11 +1984,8 @@ static int decode_extension_payload(AACDecContext 
>> *ac, GetBitContext *gb, int cn
>>  ac->avctx->profile = AV_PROFILE_AAC_HE;
>>  }
>>  
>> -if (CONFIG_AAC_F

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_h264: Don't try to merge fields in DPB for non-field pics

2024-05-06 Thread Mark Thompson
On 05/05/2024 17:36, David Rosca wrote:
> This path can be hit when there are missing references while decoding
> progressive stream and would completely break the DPB contents.
> ---
>  libavcodec/vaapi_h264.c | 30 --
>  1 file changed, 16 insertions(+), 14 deletions(-)

Can you share a stream which does this in a progressive case?

My understanding of this (though I suspect I am missing something) is that we 
are filling from the short/long DPB lists which should not contain duplicates 
(not RefPicListX, which can), so I'm not seeing how this case could be 
triggered.

If you do have two DPB entries which are different frames but refer to the same 
surface then that seems like a bug elsewhere.

Thanks,

- Mark


> diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
> index b47531ce1c..ca0076f57a 100644
> --- a/libavcodec/vaapi_h264.c
> +++ b/libavcodec/vaapi_h264.c
> @@ -98,22 +98,24 @@ static int dpb_add(DPB *dpb, const H264Picture *pic)
>  if (dpb->size >= dpb->max_size)
>  return -1;
>  
> -for (i = 0; i < dpb->size; i++) {
> -VAPictureH264 * const va_pic = &dpb->va_pics[i];
> -if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f)) {
> -VAPictureH264 temp_va_pic;
> -fill_vaapi_pic(&temp_va_pic, pic, 0);
> -
> -if ((temp_va_pic.flags ^ va_pic->flags) & 
> (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) {
> -va_pic->flags |= temp_va_pic.flags & 
> (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD);
> -/* Merge second field */
> -if (temp_va_pic.flags & VA_PICTURE_H264_TOP_FIELD) {
> -va_pic->TopFieldOrderCnt= 
> temp_va_pic.TopFieldOrderCnt;
> -} else {
> -va_pic->BottomFieldOrderCnt = 
> temp_va_pic.BottomFieldOrderCnt;
> +if (pic->field_picture) {
> +for (i = 0; i < dpb->size; i++) {
> +VAPictureH264 * const va_pic = &dpb->va_pics[i];
> +if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f)) {
> +VAPictureH264 temp_va_pic;
> +fill_vaapi_pic(&temp_va_pic, pic, 0);
> +
> +if ((temp_va_pic.flags ^ va_pic->flags) & 
> (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) {
> +va_pic->flags |= temp_va_pic.flags & 
> (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD);
> +/* Merge second field */
> +if (temp_va_pic.flags & VA_PICTURE_H264_TOP_FIELD) {
> +va_pic->TopFieldOrderCnt= 
> temp_va_pic.TopFieldOrderCnt;
> +} else {
> +va_pic->BottomFieldOrderCnt = 
> temp_va_pic.BottomFieldOrderCnt;
> +}
>  }
> +return 0;
>  }
> -return 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 v2 1/3] lavc/h265_profile_level: Expand profile compatibility checking

2024-05-06 Thread Andreas Rheinhardt
Mark Thompson:
> Replace existing get_profile() with find_profile(), which finds the
> lowest compatible profile rather than requiring an exact match.
> ---
> Series changes since v1:
> * Added H265_PROFILE_INVALID with value zero because it simplifies some code 
> (and the values don't matter).

What code is simplified by using zero (instead of -1)? I only see that
it leads to the addition of an unnecessary entry to h265_profiles.

> * Fixed the h265-levels test.
> * Added a new h265-profiles test which tests the profile compatibility 
> checking.
> * Fixed missing VAAPI profiles.
> 
> 
>  libavcodec/h265_profile_level.c | 78 +
>  libavcodec/h265_profile_level.h | 71 +-
>  libavcodec/tests/h265_levels.c  |  2 +-
>  libavcodec/vaapi_hevc.c |  2 +-
>  libavcodec/vdpau_hevc.c |  2 +-
>  5 files changed, 123 insertions(+), 32 deletions(-)
> 
> diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
> index 7ff9681f65..2e4a1c88bf 100644
> --- a/libavcodec/h265_profile_level.c
> +++ b/libavcodec/h265_profile_level.c
> @@ -40,6 +40,7 @@ static const H265LevelDescriptor h265_levels[] = {
>  };
>  
>  static const H265ProfileDescriptor h265_profiles[] = {
> +{ "Invalid" },
>  // profile_idc   8bit   one-picture
>  //   HT-profile  | 422chroma| lower-bit-rate
>  //   |  14bit|  | 420chroma |  | CpbVclFactor MinCrScaleFactor
> @@ -119,41 +120,62 @@ static const H265ProfileDescriptor h265_profiles[] = {
>5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
>  };
>  
> +_Static_assert(H265_PROFILE_COUNT == FF_ARRAY_ELEMS(h265_profiles),
> +   "Incorrect H.265 profiles table.");
>  
> -const H265ProfileDescriptor *ff_h265_get_profile(const 
> H265RawProfileTierLevel *ptl)
> +
> +const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
> + int profile)

Why don't you add a tag to this enum and pass a proper enum here?

>  {
> -int i;
> +const H265ProfileDescriptor *desc;
> +
> +av_assert0(profile > H265_PROFILE_INVALID &&
> +   profile < H265_PROFILE_COUNT);
>  
>  if (ptl->general_profile_space)
> -return NULL;
> +return 0;
>  
> -for (i = 0; i < FF_ARRAY_ELEMS(h265_profiles); i++) {
> -const H265ProfileDescriptor *profile = &h265_profiles[i];
> +desc = &h265_profiles[profile];
>  
> -if (ptl->general_profile_idc &&
> -ptl->general_profile_idc != profile->profile_idc)
> -continue;
> -if (!ptl->general_profile_compatibility_flag[profile->profile_idc])
> -continue;
> +if (ptl->general_profile_idc &&
> +ptl->general_profile_idc != desc->profile_idc)
> +return 0;
> +if (!ptl->general_profile_compatibility_flag[desc->profile_idc])
> +return 0;
>  
> -#define check_flag(name) \
> -if (profile->name < 2) { \
> -if (profile->name != ptl->general_ ## name ## _constraint_flag) \
> -continue; \
> -}
> -check_flag(max_14bit);
> -check_flag(max_12bit);
> -check_flag(max_10bit);
> -check_flag(max_8bit);
> -check_flag(max_422chroma);
> -check_flag(max_420chroma);
> -check_flag(max_monochrome);
> -check_flag(intra);
> -check_flag(one_picture_only);
> -check_flag(lower_bit_rate);
> +#define check_flag(flag) \
> +if (desc->flag < 2 && \
> +desc->flag > ptl->general_ ## flag ## _constraint_flag) \
> +return 0;
> +check_flag(max_14bit);
> +check_flag(max_12bit);
> +check_flag(max_10bit);
> +check_flag(max_8bit);
> +check_flag(max_422chroma);
> +check_flag(max_420chroma);
> +check_flag(max_monochrome);
> +check_flag(intra);
> +check_flag(one_picture_only);
> +check_flag(lower_bit_rate);
>  #undef check_flag
>  
> -return profile;
> +return 1;
> +}
> +
> +
> +const H265ProfileDescriptor *ff_h265_get_profile(int profile)
> +{
> +av_assert0(profile > H265_PROFILE_INVALID &&
> +   profile < H265_PROFILE_COUNT);
> +
> +return &h265_profiles[profile];
> +}
> +
> +const H265ProfileDescriptor *ff_h265_find_profile(const 
> H265RawProfileTierLevel *ptl)
> +{
> +for (int p = 1; p < H265_PROFILE_COUNT; p++) {
> +if (ff_h265_profile_compatible(ptl, p))
> +return &h265_profiles[p];
>  }
>  
>  return NULL;
> @@ -171,12 +193,12 @@ const H265LevelDescriptor *ff_h265_guess_level(const 
> H265RawProfileTierLevel *pt
>  int i;
>  
>  if (ptl)
> -profile = ff_h265_get_profile(ptl);
> +profile = ff_h265_find_profile(ptl);
>  else
>  profile = NULL;
>  if (!profile) {
>  // Default to using multiplication factors for Main profile.
> -profile = &h265_profiles[4];
> +profile = &h265_profiles[H265_PROFILE

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Lynne
May 6, 2024, 21:39 by andreas.rheinha...@outlook.com:

> Lynne:
>
>> May 6, 2024, 11:31 by andreas.rheinha...@outlook.com:
>>
>>> The approach used here has the advantage not to rely
>>> on any DCE.
>>> Also improve certain the checks from
>>> 3390693bfb907765f833766f370e0ba8c7894f44 a bit.
>>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavcodec/aac/aacdec.c | 62 -
>>>  1 file changed, 31 insertions(+), 31 deletions(-)
>>>
>>> diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
>>> index c6b93e33a2..6a74b05168 100644
>>> --- a/libavcodec/aac/aacdec.c
>>> +++ b/libavcodec/aac/aacdec.c
>>> @@ -63,6 +63,20 @@
>>>  #include "libavutil/version.h"
>>>  #include "libavutil/thread.h"
>>>  
>>> +#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
>>> +#define IS_FIXED(is_fixed) (is_fixed)
>>> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
>>> +((is_fixed) ? RENAME_FIXED(func_or_obj) func_args : (func_or_obj) 
>>> func_args)
>>> +#elif CONFIG_AAC_DECODER
>>> +#define IS_FIXED(is_fixed) 0
>>> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
>>> +((func_or_obj) func_args)
>>> +#else
>>> +#define IS_FIXED(is_fixed) 1
>>> +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
>>> +(RENAME_FIXED(func_or_obj) func_args)
>>> +#endif
>>> +
>>>  /*
>>>  * supported tools
>>>  *
>>> @@ -150,11 +164,8 @@ static av_cold int che_configure(AACDecContext *ac,
>>>  return AVERROR_INVALIDDATA;
>>>  if (che_pos) {
>>>  if (!ac->che[type][id]) {
>>> -int ret;
>>> -if (ac->is_fixed)
>>> -ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, 
>>> &ac->che[type][id], type);
>>> -else
>>> -ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], 
>>> type);
>>> +int ret = FIXED_OR_FLOAT(ac->is_fixed, 
>>> ff_aac_sbr_ctx_alloc_init,
>>> + (ac, &ac->che[type][id], type));
>>>  if (ret < 0)
>>>  return ret;
>>>  }
>>> @@ -171,10 +182,7 @@ static av_cold int che_configure(AACDecContext *ac,
>>>  }
>>>  } else {
>>>  if (ac->che[type][id]) {
>>> -if (ac->is_fixed)
>>> -ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
>>> -else
>>> -ff_aac_sbr_ctx_close(ac->che[type][id]);
>>> +FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_close, 
>>> (ac->che[type][id]));
>>>  }
>>>  av_freep(&ac->che[type][id]);
>>>  }
>>> @@ -1122,8 +1130,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
>>>  {
>>>  AACDecContext *ac = avctx->priv_data;
>>>  int is_fixed = ac->is_fixed;
>>> -void (*sbr_close)(ChannelElement *che) = is_fixed ? 
>>> ff_aac_sbr_ctx_close_fixed :
>>> -
>>> ff_aac_sbr_ctx_close;
>>> +void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_fixed, 
>>> ff_aac_sbr_ctx_close, );
>>>  
>>>  for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
>>>  for (int i = 0; i < MAX_ELEM_ID; i++) {
>>> @@ -1154,7 +1161,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
>>>  static av_cold int init_dsp(AVCodecContext *avctx)
>>>  {
>>>  AACDecContext *ac = avctx->priv_data;
>>> -int is_fixed = ac->is_fixed, ret;
>>> +int is_fixed = IS_FIXED(ac->is_fixed), ret;
>>>  float scale_fixed, scale_float;
>>>  const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
>>>  enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
>>> @@ -1188,8 +1195,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
>>>  if (ret < 0)
>>>  return ret;
>>>  
>>> -ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
>>> -ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
>>> +ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
>>> +ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
>>>  
>>>  return ac->dsp.init(ac);
>>>  }
>>> @@ -1315,9 +1322,9 @@ static void decode_ltp(AACDecContext *ac, 
>>> LongTermPrediction *ltp,
>>>  int sfb;
>>>  
>>>  ltp->lag  = get_bits(gb, 11);
>>> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
>>> +if (IS_FIXED(ac->is_fixed))
>>>  ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
>>> -else if (CONFIG_AAC_DECODER)
>>> +else
>>>  ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
>>>  
>>>  for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
>>> @@ -1626,9 +1633,9 @@ static int decode_tns(AACDecContext *ac, 
>>> TemporalNoiseShaping *tns,
>>>  tmp2_idx = 2 * coef_compress + coef_res;
>>>  
>>>  for (i = 0; i < tns->order[w][filt]; i++) {
>>> -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
>>> +if (IS_FIXED(ac->is_fixed))
>>>  tns->coef_fixed[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, 
>>> coef_len)]);
>>> -else if (CONFIG_AAC_DECODER)
>>> +else
>>>  tns->coef[w][filt][i] = ff_tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
>>>  }
>>>  }
>>> @@ -

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Andreas Rheinhardt
Lynne:
> May 6, 2024, 21:39 by andreas.rheinha...@outlook.com:
> 
>> Lynne:
>>
>>> May 6, 2024, 11:31 by andreas.rheinha...@outlook.com:
>>>
 The approach used here has the advantage not to rely
 on any DCE.
 Also improve certain the checks from
 3390693bfb907765f833766f370e0ba8c7894f44 a bit.

 Signed-off-by: Andreas Rheinhardt 
 ---
  libavcodec/aac/aacdec.c | 62 -
  1 file changed, 31 insertions(+), 31 deletions(-)

 diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
 index c6b93e33a2..6a74b05168 100644
 --- a/libavcodec/aac/aacdec.c
 +++ b/libavcodec/aac/aacdec.c
 @@ -63,6 +63,20 @@
  #include "libavutil/version.h"
  #include "libavutil/thread.h"
  
 +#if CONFIG_AAC_DECODER && CONFIG_AAC_FIXED_DECODER
 +#define IS_FIXED(is_fixed) (is_fixed)
 +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
 +((is_fixed) ? RENAME_FIXED(func_or_obj) func_args : (func_or_obj) 
 func_args)
 +#elif CONFIG_AAC_DECODER
 +#define IS_FIXED(is_fixed) 0
 +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
 +((func_or_obj) func_args)
 +#else
 +#define IS_FIXED(is_fixed) 1
 +#define FIXED_OR_FLOAT(is_fixed, func_or_obj, func_args) \
 +(RENAME_FIXED(func_or_obj) func_args)
 +#endif
 +
  /*
  * supported tools
  *
 @@ -150,11 +164,8 @@ static av_cold int che_configure(AACDecContext *ac,
  return AVERROR_INVALIDDATA;
  if (che_pos) {
  if (!ac->che[type][id]) {
 -int ret;
 -if (ac->is_fixed)
 -ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, 
 &ac->che[type][id], type);
 -else
 -ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], 
 type);
 +int ret = FIXED_OR_FLOAT(ac->is_fixed, 
 ff_aac_sbr_ctx_alloc_init,
 + (ac, &ac->che[type][id], type));
  if (ret < 0)
  return ret;
  }
 @@ -171,10 +182,7 @@ static av_cold int che_configure(AACDecContext *ac,
  }
  } else {
  if (ac->che[type][id]) {
 -if (ac->is_fixed)
 -ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
 -else
 -ff_aac_sbr_ctx_close(ac->che[type][id]);
 +FIXED_OR_FLOAT(ac->is_fixed, ff_aac_sbr_ctx_close, 
 (ac->che[type][id]));
  }
  av_freep(&ac->che[type][id]);
  }
 @@ -1122,8 +1130,7 @@ static av_cold int decode_close(AVCodecContext 
 *avctx)
  {
  AACDecContext *ac = avctx->priv_data;
  int is_fixed = ac->is_fixed;
 -void (*sbr_close)(ChannelElement *che) = is_fixed ? 
 ff_aac_sbr_ctx_close_fixed :
 -
 ff_aac_sbr_ctx_close;
 +void (*sbr_close)(ChannelElement *che) = FIXED_OR_FLOAT(is_fixed, 
 ff_aac_sbr_ctx_close, );
  
  for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
  for (int i = 0; i < MAX_ELEM_ID; i++) {
 @@ -1154,7 +1161,7 @@ static av_cold int decode_close(AVCodecContext 
 *avctx)
  static av_cold int init_dsp(AVCodecContext *avctx)
  {
  AACDecContext *ac = avctx->priv_data;
 -int is_fixed = ac->is_fixed, ret;
 +int is_fixed = IS_FIXED(ac->is_fixed), ret;
  float scale_fixed, scale_float;
  const float *const scalep = is_fixed ? &scale_fixed : &scale_float;
  enum AVTXType tx_type = is_fixed ? AV_TX_INT32_MDCT : AV_TX_FLOAT_MDCT;
 @@ -1188,8 +1195,8 @@ static av_cold int init_dsp(AVCodecContext *avctx)
  if (ret < 0)
  return ret;
  
 -ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
 -ac->proc = is_fixed ? aac_proc_fixed : aac_proc;
 +ac->dsp  = FIXED_OR_FLOAT(is_fixed, aac_dsp, );
 +ac->proc = FIXED_OR_FLOAT(is_fixed, aac_proc, );
  
  return ac->dsp.init(ac);
  }
 @@ -1315,9 +1322,9 @@ static void decode_ltp(AACDecContext *ac, 
 LongTermPrediction *ltp,
  int sfb;
  
  ltp->lag  = get_bits(gb, 11);
 -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
 +if (IS_FIXED(ac->is_fixed))
  ltp->coef_fixed = Q30(ff_ltp_coef[get_bits(gb, 3)]);
 -else if (CONFIG_AAC_DECODER)
 +else
  ltp->coef = ff_ltp_coef[get_bits(gb, 3)];
  
  for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
 @@ -1626,9 +1633,9 @@ static int decode_tns(AACDecContext *ac, 
 TemporalNoiseShaping *tns,
  tmp2_idx = 2 * coef_compress + coef_res;
  
  for (i = 0; i < tns->order[w][filt]; i++) {
 -if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
 +if (IS_FIXED(ac->is_fixed))
  tns->coef_fixed[w][filt][i] = Q31(ff_tns_tmp2_map[tmp2_idx][get_bits(gb, 
 coef_len)]);
 -else if (CONFIG_

Re: [FFmpeg-devel] [PATCH v2 1/3] lavc/h265_profile_level: Expand profile compatibility checking

2024-05-06 Thread Mark Thompson
On 06/05/2024 20:56, Andreas Rheinhardt wrote:
> Mark Thompson:
>> Replace existing get_profile() with find_profile(), which finds the
>> lowest compatible profile rather than requiring an exact match.
>> ---
>> Series changes since v1:
>> * Added H265_PROFILE_INVALID with value zero because it simplifies some code 
>> (and the values don't matter).
> 
> What code is simplified by using zero (instead of -1)? I only see that
> it leads to the addition of an unnecessary entry to h265_profiles.

The large number of empty entries in profile_table in the test work by being 
zero-initialised.  Filling them with -1 would not be fun.

(I originally put that table (and the bprint function) in h265_profile_level.c, 
but when no library caller was using it I moved it to the test.)

>> * Fixed the h265-levels test.
>> * Added a new h265-profiles test which tests the profile compatibility 
>> checking.
>> * Fixed missing VAAPI profiles.
>>
>>
>>  libavcodec/h265_profile_level.c | 78 +
>>  libavcodec/h265_profile_level.h | 71 +-
>>  libavcodec/tests/h265_levels.c  |  2 +-
>>  libavcodec/vaapi_hevc.c |  2 +-
>>  libavcodec/vdpau_hevc.c |  2 +-
>>  5 files changed, 123 insertions(+), 32 deletions(-)
>>
>> diff --git a/libavcodec/h265_profile_level.c 
>> b/libavcodec/h265_profile_level.c
>> index 7ff9681f65..2e4a1c88bf 100644
>> --- a/libavcodec/h265_profile_level.c
>> +++ b/libavcodec/h265_profile_level.c
>> @@ -40,6 +40,7 @@ static const H265LevelDescriptor h265_levels[] = {
>>  };
>>  
>>  static const H265ProfileDescriptor h265_profiles[] = {
>> +{ "Invalid" },
>>  // profile_idc   8bit   one-picture
>>  //   HT-profile  | 422chroma| lower-bit-rate
>>  //   |  14bit|  | 420chroma |  | CpbVclFactor MinCrScaleFactor
>> @@ -119,41 +120,62 @@ static const H265ProfileDescriptor h265_profiles[] = {
>>5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
>>  };
>>  
>> +_Static_assert(H265_PROFILE_COUNT == FF_ARRAY_ELEMS(h265_profiles),
>> +   "Incorrect H.265 profiles table.");
>>  
>> -const H265ProfileDescriptor *ff_h265_get_profile(const 
>> H265RawProfileTierLevel *ptl)
>> +
>> +const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
>> + int profile)
> 
> Why don't you add a tag to this enum and pass a proper enum here?

No reason.  I can add an explicit type if you prefer that?

>>  {
>> -int i;
>> +const H265ProfileDescriptor *desc;
>> +
>> +av_assert0(profile > H265_PROFILE_INVALID &&
>> +   profile < H265_PROFILE_COUNT);
>>  
>>  if (ptl->general_profile_space)
>> -return NULL;
>> +return 0;
>>  
>> -for (i = 0; i < FF_ARRAY_ELEMS(h265_profiles); i++) {
>> -const H265ProfileDescriptor *profile = &h265_profiles[i];
>> +desc = &h265_profiles[profile];
>>  
>> -if (ptl->general_profile_idc &&
>> -ptl->general_profile_idc != profile->profile_idc)
>> -continue;
>> -if (!ptl->general_profile_compatibility_flag[profile->profile_idc])
>> -continue;
>> +if (ptl->general_profile_idc &&
>> +ptl->general_profile_idc != desc->profile_idc)
>> +return 0;
>> +if (!ptl->general_profile_compatibility_flag[desc->profile_idc])
>> +return 0;
>>  
>> -#define check_flag(name) \
>> -if (profile->name < 2) { \
>> -if (profile->name != ptl->general_ ## name ## _constraint_flag) 
>> \
>> -continue; \
>> -}
>> -check_flag(max_14bit);
>> -check_flag(max_12bit);
>> -check_flag(max_10bit);
>> -check_flag(max_8bit);
>> -check_flag(max_422chroma);
>> -check_flag(max_420chroma);
>> -check_flag(max_monochrome);
>> -check_flag(intra);
>> -check_flag(one_picture_only);
>> -check_flag(lower_bit_rate);
>> +#define check_flag(flag) \
>> +if (desc->flag < 2 && \
>> +desc->flag > ptl->general_ ## flag ## _constraint_flag) \
>> +return 0;
>> +check_flag(max_14bit);
>> +check_flag(max_12bit);
>> +check_flag(max_10bit);
>> +check_flag(max_8bit);
>> +check_flag(max_422chroma);
>> +check_flag(max_420chroma);
>> +check_flag(max_monochrome);
>> +check_flag(intra);
>> +check_flag(one_picture_only);
>> +check_flag(lower_bit_rate);
>>  #undef check_flag
>>  
>> -return profile;
>> +return 1;
>> +}
>> +
>> ...

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH 2/2] lavu/riscv: add hwprobe() for CPU detection

2024-05-06 Thread Martin Storsjö

On Fri, 3 May 2024, Rémi Denis-Courmont wrote:


This adds the Linux-specific function call to detect CPU features. Unlike
the more portable auxillary vector, this supports extensions other than
single lettered ones. At this point, FFmpeg already needs this to detect
Zba and Zbb at run-time, and probably will need it for Zvbb in the near
future.

Support will be available in glibc 2.40 onward.
---
configure |  3 +++
libavutil/riscv/cpu.c | 25 +
2 files changed, 28 insertions(+)



@@ -27,10 +29,33 @@
#include 
#define HWCAP_RV(letter) (1ul << ((letter) - 'A'))
#endif
+#ifdef HAVE_SYS_HWPROBE_H


Aren't these kind of config.h macros always defined, but with the values 
0/1? I.e., shouldn't this use #if instead of #ifdef?


// 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] [PATCH 1/2] WIP avcodec/videotoolbox: add AV1 hardware acceleration

2024-05-06 Thread Черненко Руслан
This patch adds support for hw accelerated AV1 decoding on new Apple 
Silicon M3 CPUs. It's registered on the trac [1]
The first patch is the patch I used to proceed working on this feature 
from Jan Ekström . I took his commit from his branch 
on github [2].

This is my first patch into ffmpeg.

[1] https://trac.ffmpeg.org/ticket/1064
[2] 
https://github.com/jeeb/ffmpeg/commit/7d0ec776e148d77314ae7fc1419cef1b6d7d201e

Signed-off-by: Chernenko Ruslan 
---
 configure |  4 ++
 libavcodec/Makefile   |  1 +
 libavcodec/av1dec.c   | 10 
 libavcodec/hwaccels.h |  1 +
 libavcodec/videotoolbox.c | 14 +
 libavcodec/videotoolbox_av1.c | 99 +++
 libavcodec/vt_internal.h  |  1 +
 7 files changed, 130 insertions(+)
 create mode 100644 libavcodec/videotoolbox_av1.c

diff --git a/configure b/configure
index 8101b4fce6..661d956480 100755
--- a/configure
+++ b/configure
@@ -2461,6 +2461,7 @@ TYPES_LIST="
 kCMVideoCodecType_HEVC
 kCMVideoCodecType_HEVCWithAlpha
 kCMVideoCodecType_VP9
+kCMVideoCodecType_AV1
 kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
 kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange
 kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange
@@ -3155,6 +3156,8 @@ av1_vaapi_hwaccel_deps="vaapi 
VADecPictureParameterBufferAV1_bit_depth_idx"

 av1_vaapi_hwaccel_select="av1_decoder"
 av1_vdpau_hwaccel_deps="vdpau VdpPictureInfoAV1"
 av1_vdpau_hwaccel_select="av1_decoder"
+av1_videotoolbox_hwaccel_deps="videotoolbox"
+av1_videotoolbox_hwaccel_select="av1_decoder"
 av1_vulkan_hwaccel_deps="vulkan"
 av1_vulkan_hwaccel_select="av1_decoder"
 h263_vaapi_hwaccel_deps="vaapi"
@@ -6672,6 +6675,7 @@ enabled videotoolbox && {
 check_func_headers CoreMedia/CMFormatDescription.h 
kCMVideoCodecType_HEVC "-framework CoreMedia"
 check_func_headers CoreMedia/CMFormatDescription.h 
kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia"
 check_func_headers CoreMedia/CMFormatDescription.h 
kCMVideoCodecType_VP9 "-framework CoreMedia"
+check_func_headers CoreMedia/CMFormatDescription.h 
kCMVideoCodecType_AV1 "-framework CoreMedia"
 check_func_headers CoreVideo/CVPixelBuffer.h 
kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
 check_func_headers CoreVideo/CVPixelBuffer.h 
kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo"
 check_func_headers CoreVideo/CVPixelBuffer.h 
kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo"

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cff6347bdb..c044db5eb6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1002,6 +1002,7 @@ OBJS-$(CONFIG_AV1_D3D12VA_HWACCEL)+= 
dxva2_av1.o d3d12va_av1.o

 OBJS-$(CONFIG_AV1_NVDEC_HWACCEL)  += nvdec_av1.o
 OBJS-$(CONFIG_AV1_VAAPI_HWACCEL)  += vaapi_av1.o
 OBJS-$(CONFIG_AV1_VDPAU_HWACCEL)  += vdpau_av1.o
+OBJS-$(CONFIG_AV1_VIDEOTOOLBOX_HWACCEL)   += videotoolbox_av1.o
 OBJS-$(CONFIG_AV1_VULKAN_HWACCEL) += vulkan_decode.o vulkan_av1.o
 OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o
 OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index 79a30a114d..2ac0d0af4a 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -541,6 +541,7 @@ static int get_pixel_format(AVCodecContext *avctx)
  CONFIG_AV1_NVDEC_HWACCEL + \
  CONFIG_AV1_VAAPI_HWACCEL + \
  CONFIG_AV1_VDPAU_HWACCEL + \
+ CONFIG_AV1_VIDEOTOOLBOX_HWACCEL + \
  CONFIG_AV1_VULKAN_HWACCEL)
 enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
 @@ -568,6 +569,9 @@ static int get_pixel_format(AVCodecContext *avctx)
 #if CONFIG_AV1_VDPAU_HWACCEL
 *fmtp++ = AV_PIX_FMT_VDPAU;
 #endif
+#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL
+*fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX;
+#endif
 #if CONFIG_AV1_VULKAN_HWACCEL
 *fmtp++ = AV_PIX_FMT_VULKAN;
 #endif
@@ -592,6 +596,9 @@ static int get_pixel_format(AVCodecContext *avctx)
 #if CONFIG_AV1_VDPAU_HWACCEL
 *fmtp++ = AV_PIX_FMT_VDPAU;
 #endif
+#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL
+*fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX;
+#endif
 #if CONFIG_AV1_VULKAN_HWACCEL
 *fmtp++ = AV_PIX_FMT_VULKAN;
 #endif
@@ -1581,6 +1588,9 @@ const FFCodec ff_av1_decoder = {
 #if CONFIG_AV1_VDPAU_HWACCEL
 HWACCEL_VDPAU(av1),
 #endif
+#if CONFIG_AV1_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(av1),
+#endif
 #if CONFIG_AV1_VULKAN_HWACCEL
 HWACCEL_VULKAN(av1),
 #endif
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 5171e4c7d7..2b9bdc8fc9 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -26,6 +26,7 @@ extern const struct FFHWAccel ff_av1_dxva2_hwaccel;
 extern const struct FFHWAccel ff_av1_nvdec_hwaccel;
 extern const struct FFHWAccel ff_av1_vaapi_hwaccel;
 extern const struc

[FFmpeg-devel] [PATCH 2/2] avcodec/videotoolbox: av1 decoding not copying the sequence header obu into the bitstream

2024-05-06 Thread Черненко Руслан

Signed-off-by: Chernenko Ruslan 
---
 libavcodec/videotoolbox_av1.c | 102 --
 1 file changed, 72 insertions(+), 30 deletions(-)

diff --git a/libavcodec/videotoolbox_av1.c b/libavcodec/videotoolbox_av1.c
index 7f7270c466..736f2548db 100644
--- a/libavcodec/videotoolbox_av1.c
+++ b/libavcodec/videotoolbox_av1.c
@@ -19,50 +19,90 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
02110-1301 USA

  */
 -#include "libavformat/avio.h"
-#include "libavformat/avio_internal.h"
-#define CALLED_FROM_AVCODEC 1
-#include "libavformat/av1.c"
-#undef CALLED_FROM_AVCODEC
 -#include "libavutil/avutil.h"
-#include "libavutil/frame.h"
-#include "libavutil/pixfmt.h"
+#include "libavutil/mem.h"
  #include "av1dec.h"
-#include "codec_id.h"
 #include "hwaccel_internal.h"
 #include "internal.h"
 #include "vt_internal.h"
 -CFDataRef ff_videotoolbox_av1c_extradata_create(AVCodecContext *avctx)
+
+CFDataRef ff_videotoolbox_av1c_extradata_create(AVCodecContext *avctx) {
+
+AV1DecContext *s = avctx->priv_data;
+avctx->extradata = av_fast_realloc(avctx->extradata, + 
&avctx->extradata_size, +s->seq_data_ref->size + 4);

+avctx->extradata_size = s->seq_data_ref->size + 4;
+avctx->extradata[0] = 0x81; // version and marker (constant)
+avctx->extradata[1] = s->raw_seq->seq_profile << 5 | 
s->raw_seq->seq_level_idx[0];

+avctx->extradata[2] = s->raw_seq->seq_tier[0] << 7 |
+s->raw_seq->color_config.high_bitdepth << 6 | + 
   s->raw_seq->color_config.twelve_bit << 5 |

+s->raw_seq->color_config.mono_chrome << 4 |
+s->raw_seq->color_config.subsampling_x << 3 |
+s->raw_seq->color_config.subsampling_y << 2 |
+s->raw_seq->color_config.chroma_sample_position;
++
+if (s->raw_seq->initial_display_delay_present_flag) + 
avctx->extradata[3] = 0 << 5 | 
s->raw_seq->initial_display_delay_present_flag << 4 | 
s->raw_seq->initial_display_delay_minus_1[0];

+else
+avctx->extradata[3] = 0x00;
+memcpy(avctx->extradata + 4, s->seq_data_ref->data, 
s->seq_data_ref->size);
+CFDataRef data = CFDataCreate(kCFAllocatorDefault, 
avctx->extradata, avctx->extradata_size);

+return data;
+};
+
+
+static int videotoolbox_av1_decode_params(AVCodecContext *avctx,
+ int header_type,
+ const uint8_t *buffer,
+ uint32_t size)
 {
-AVIOContext *pb;
-uint8_t *buf;
-CFDataRef data = NULL;
-int buf_size = 0;
-int ret = avio_open_dyn_buf(&pb);
-if (ret < 0)
-return NULL;
+VTContext *vtctx = avctx->internal->hwaccel_priv_data;
+void *tmp;
 -ret = ff_isom_write_av1c(pb, avctx->extradata, 
avctx->extradata_size, 1);

-if (ret < 0)
-goto fail;
+tmp = av_fast_realloc(vtctx->bitstream,
+ &vtctx->allocated_size,
+ size);
 -buf_size = avio_get_dyn_buf(pb, &buf);
-if (buf_size)
-data = CFDataCreate(kCFAllocatorDefault, buf, buf_size);
+if (!tmp)
+return AVERROR(ENOMEM);
 -fail:
-ffio_free_dyn_buf(&pb);
+vtctx->bitstream = tmp;
 -return data;
+// copy the sequence header obu into the bitstream
+memcpy(vtctx->bitstream + vtctx->bitstream_size, + 
buffer, +size);

+
+vtctx->bitstream_size += size;
+return 0;
 }
  static int videotoolbox_av1_start_frame(AVCodecContext *avctx,
 const uint8_t *buffer,
 uint32_t size)
 {
+
++VTContext *vtctx = avctx->internal->hwaccel_priv_data;
+void *tmp;
+
+tmp = av_fast_realloc(vtctx->bitstream,
+ &vtctx->allocated_size,
+ size);
+
+if (!tmp)
+return AVERROR(ENOMEM);
+
+vtctx->bitstream = tmp;
+
+// copy the frame data into the bitstream
+memcpy(vtctx->bitstream + vtctx->bitstream_size, buffer, size);
+vtctx->bitstream_size += size;
 return 0;
 }
 @@ -70,17 +110,18 @@ static int 
videotoolbox_av1_decode_slice(AVCodecContext *avctx,

  const uint8_t *buffer,
  uint32_t size)
 {
-VTContext *vtctx = avctx->internal->hwaccel_priv_data;
-
-return ff_videotoolbox_buffer_copy(vtctx, buffer, size);
+return 0;
 }
  static int videotoolbox_av1_end_frame(AVCodecContext *avctx)
 {
 const AV1DecContext *s = avctx->priv_data;
+VTContext *vtctx = avctx->internal->hwaccel_priv_data;
 AVFrame *frame = s->cur_frame.f;
 -return ff_videotoolbox_common_end_frame(avctx, frame);
+int ret =  ff_videotoolbox_common_end_frame(avctx, frame);
+vtctx->bitstream_size = 0;
+return ret;
 }

[FFmpeg-devel] [PATCH 25/28] avcodec/x86/mpegvideoencdsp_init: Remove bits_per_raw_sample check

2024-05-06 Thread Andreas Rheinhardt
This check has been added in 19a0729b4cfacfd90b8ee84ab0c093ff7e397e65;
this commit added high bit-depth versions of draw_edges
and added the check to indicate that the mmx version only
supports eight bits.
Yet there is no high bit depth draw_edges function any more
since d4d186d185df98492d8935a87c5b5cf369db9748; since then,
the mmx version and the C version always behave the same,
yet said check has not been removed. This commit does so.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/mpegvideoencdsp_init.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavcodec/x86/mpegvideoencdsp_init.c 
b/libavcodec/x86/mpegvideoencdsp_init.c
index ec174b15aa..9fa7ee4824 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -233,9 +233,7 @@ av_cold void 
ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
 }
 c->add_8x8basis = add_8x8basis_mmx;
 
-if (avctx->bits_per_raw_sample <= 8) {
-c->draw_edges = draw_edges_mmx;
-}
+c->draw_edges = draw_edges_mmx;
 }
 
 if (INLINE_AMD3DNOW(cpu_flags)) {
-- 
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 26/28] avcodec/mpegvideoencdsp: Factor draw_edges out in its own context

2024-05-06 Thread Andreas Rheinhardt
This allows to remove a dependency of the dirac decoder (!)
on mpegvideoenc.

Signed-off-by: Andreas Rheinhardt 
---
 configure |   7 +-
 libavcodec/Makefile   |   1 +
 libavcodec/diracdec.c |  14 +--
 libavcodec/drawedgesdsp.c |  61 ++
 libavcodec/drawedgesdsp.h |  35 ++
 libavcodec/mpegvideo.h|   2 +
 libavcodec/mpegvideo_enc.c|   9 +-
 libavcodec/mpegvideoencdsp.c  |  32 --
 libavcodec/mpegvideoencdsp.h  |   6 -
 libavcodec/snowenc.c  |  13 ++-
 libavcodec/x86/Makefile   |   1 +
 libavcodec/x86/drawedgesdsp.c | 157 ++
 libavcodec/x86/mpegvideo.c|   2 +-
 libavcodec/x86/mpegvideoencdsp_init.c | 118 ---
 14 files changed, 281 insertions(+), 177 deletions(-)
 create mode 100644 libavcodec/drawedgesdsp.c
 create mode 100644 libavcodec/drawedgesdsp.h
 create mode 100644 libavcodec/x86/drawedgesdsp.c

diff --git a/configure b/configure
index bea4547e20..edb1ddca33 100755
--- a/configure
+++ b/configure
@@ -2552,6 +2552,7 @@ CONFIG_EXTRA="
 dnn
 dovi_rpudec
 dovi_rpuenc
+drawedgesdsp
 dvprofile
 evcparse
 exif
@@ -2868,7 +2869,7 @@ mpeg_er_select="error_resilience"
 mpegaudio_select="mpegaudiodsp mpegaudioheader"
 mpegvideo_select="blockdsp hpeldsp idctdsp videodsp"
 mpegvideodec_select="h264chroma mpegvideo mpeg_er"
-mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp"
+mpegvideoenc_select="aandcttables drawedgesdsp fdctdsp me_cmp mpegvideo 
pixblockdsp"
 msmpeg4dec_select="h263_decoder"
 msmpeg4enc_select="h263_encoder"
 vc1dsp_select="h264chroma qpeldsp startcode"
@@ -2918,7 +2919,7 @@ cook_decoder_select="audiodsp sinewin"
 cri_decoder_select="mjpeg_decoder"
 cscd_decoder_suggest="zlib"
 dds_decoder_select="texturedsp"
-dirac_decoder_select="dirac_parse dwt golomb mpegvideoenc qpeldsp videodsp"
+dirac_decoder_select="dirac_parse drawedgesdsp dwt golomb qpeldsp videodsp"
 dnxhd_decoder_select="blockdsp idctdsp"
 dnxhd_encoder_select="blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp 
videodsp"
 dvvideo_decoder_select="dvprofile idctdsp"
@@ -3060,7 +3061,7 @@ shorten_decoder_select="bswapdsp"
 sipr_decoder_select="lsp"
 smvjpeg_decoder_select="mjpeg_decoder"
 snow_decoder_select="dwt h264qpel rangecoder videodsp"
-snow_encoder_select="dwt h264qpel hpeldsp me_cmp mpegvideoenc rangecoder 
videodsp"
+snow_encoder_select="drawedgesdsp dwt h264qpel hpeldsp me_cmp mpegvideoenc 
rangecoder videodsp"
 sonic_decoder_select="golomb rangecoder"
 sonic_encoder_select="golomb rangecoder"
 sonic_ls_encoder_select="golomb rangecoder"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3e8a44e89c..dff6193bc2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -89,6 +89,7 @@ OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
 OBJS-$(CONFIG_DEFLATE_WRAPPER) += zlib_wrapper.o
 OBJS-$(CONFIG_DOVI_RPUDEC) += dovi_rpu.o dovi_rpudec.o
 OBJS-$(CONFIG_DOVI_RPUENC) += dovi_rpu.o dovi_rpuenc.o
+OBJS-$(CONFIG_DRAWEDGESDSP)+= drawedgesdsp.o
 OBJS-$(CONFIG_ERROR_RESILIENCE)+= error_resilience.o
 OBJS-$(CONFIG_EVCPARSE)+= evc_parse.o evc_ps.o
 OBJS-$(CONFIG_EXIF)+= exif.o tiff_common.o
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index f1fde0b339..f0df74e131 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -34,11 +34,11 @@
 #include "get_bits.h"
 #include "codec_internal.h"
 #include "decode.h"
+#include "drawedgesdsp.h"
 #include "golomb.h"
 #include "dirac_arith.h"
 #include "dirac_vlc.h"
 #include "mpegpicture.h"
-#include "mpegvideoencdsp.h"
 #include "dirac_dwt.h"
 #include "dirac.h"
 #include "diractab.h"
@@ -135,7 +135,7 @@ typedef struct DiracSlice {
 
 typedef struct DiracContext {
 AVCodecContext *avctx;
-MpegvideoEncDSPContext mpvencdsp;
+DrawEdgesDSPContext drawedges;
 VideoDSPContext vdsp;
 DiracDSPContext diracdsp;
 DiracVersionInfo version;
@@ -397,7 +397,7 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx)
 s->thread_buf_size = -1;
 
 ff_diracdsp_init(&s->diracdsp);
-ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
+ff_drawedgesdsp_init(&s->drawedges);
 ff_videodsp_init(&s->vdsp, 8);
 
 for (i = 0; i < MAX_FRAMES; i++) {
@@ -1836,7 +1836,7 @@ static int interpolate_refplane(DiracContext *s, 
DiracFrame *ref, int plane, int
 int i, edge = EDGE_WIDTH/2;
 
 ref->hpel[plane][0] = ref->avframe->data[plane];
-s->mpvencdsp.draw_edges(ref->hpel[plane][0], 
ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | 
EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, 
this needs to be ensured */
+s->drawedges.draw_edges(ref->hpel[plane][0], 
ref->avframe->linesize[plane], width, height, edge, edge, EDGE_TOP | 
EDGE

[FFmpeg-devel] [PATCH 27/28] avcodec/mpegvideoencdsp: Pass bitexact flag directly

2024-05-06 Thread Andreas Rheinhardt
Don't pass an AVCodecContext*. This avoids inclusions of avcodec.h
and makes it clearer which parameter affect the returned function
pointers.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/arm/mpegvideoencdsp_init_arm.c   |  3 +--
 libavcodec/dnxhdenc.c   |  2 +-
 libavcodec/mips/mpegvideoencdsp_init_mips.c |  2 +-
 libavcodec/mpegvideo_enc.c  |  2 +-
 libavcodec/mpegvideoencdsp.c| 11 +--
 libavcodec/mpegvideoencdsp.h| 17 +
 libavcodec/ppc/mpegvideoencdsp.c|  2 +-
 libavcodec/svq1enc.c|  2 +-
 libavcodec/x86/mpegvideoencdsp_init.c   | 13 -
 9 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/libavcodec/arm/mpegvideoencdsp_init_arm.c 
b/libavcodec/arm/mpegvideoencdsp_init_arm.c
index a95b5bebe9..842079267b 100644
--- a/libavcodec/arm/mpegvideoencdsp_init_arm.c
+++ b/libavcodec/arm/mpegvideoencdsp_init_arm.c
@@ -21,14 +21,13 @@
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
 #include "libavutil/arm/cpu.h"
-#include "libavcodec/avcodec.h"
 #include "libavcodec/mpegvideoencdsp.h"
 
 int ff_pix_norm1_armv6(const uint8_t *pix, int line_size);
 int ff_pix_sum_armv6(const uint8_t *pix, int line_size);
 
 av_cold void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c,
- AVCodecContext *avctx)
+ int bitexact)
 {
 int cpu_flags = av_get_cpu_flags();
 
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 0cb25d7714..6417dc48b9 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -423,7 +423,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
 ff_blockdsp_init(&ctx->bdsp);
 ff_fdctdsp_init(&ctx->m.fdsp, avctx);
 ff_mpv_idct_init(&ctx->m);
-ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx);
+ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx->flags & 
AV_CODEC_FLAG_BITEXACT);
 ff_pixblockdsp_init(&ctx->m.pdsp, avctx);
 ff_dct_encode_init(&ctx->m);
 
diff --git a/libavcodec/mips/mpegvideoencdsp_init_mips.c 
b/libavcodec/mips/mpegvideoencdsp_init_mips.c
index 3efbeec34a..4a279e9942 100644
--- a/libavcodec/mips/mpegvideoencdsp_init_mips.c
+++ b/libavcodec/mips/mpegvideoencdsp_init_mips.c
@@ -24,7 +24,7 @@
 #include "h263dsp_mips.h"
 
 av_cold void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c,
-  AVCodecContext *avctx)
+  int bitexact)
 {
 int cpu_flags = av_get_cpu_flags();
 
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ab14538b33..cfdd8fa3c4 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -809,7 +809,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 
 ff_fdctdsp_init(&s->fdsp, avctx);
 ff_me_cmp_init(&s->mecc, avctx);
-ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx);
+ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx->flags & 
AV_CODEC_FLAG_BITEXACT);
 ff_drawedgesdsp_init(&s->drawedges);
 ff_pixblockdsp_init(&s->pdsp, avctx);
 
diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c
index a6de93456d..b8f740630a 100644
--- a/libavcodec/mpegvideoencdsp.c
+++ b/libavcodec/mpegvideoencdsp.c
@@ -22,7 +22,6 @@
 #include "libavutil/avassert.h"
 #include "libavutil/attributes.h"
 #include "libavutil/imgutils.h"
-#include "avcodec.h"
 #include "me_cmp.h"
 #include "mpegvideoencdsp.h"
 
@@ -200,7 +199,7 @@ static void shrink88(uint8_t *dst, int dst_wrap,
 }
 
 av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
- AVCodecContext *avctx)
+ int bitexact)
 {
 c->try_8x8basis = try_8x8basis_c;
 c->add_8x8basis = add_8x8basis_c;
@@ -214,12 +213,12 @@ av_cold void 
ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
 c->pix_norm1 = pix_norm1_c;
 
 #if ARCH_ARM
-ff_mpegvideoencdsp_init_arm(c, avctx);
+ff_mpegvideoencdsp_init_arm(c, bitexact);
 #elif ARCH_PPC
-ff_mpegvideoencdsp_init_ppc(c, avctx);
+ff_mpegvideoencdsp_init_ppc(c, bitexact);
 #elif ARCH_X86
-ff_mpegvideoencdsp_init_x86(c, avctx);
+ff_mpegvideoencdsp_init_x86(c, bitexact);
 #elif ARCH_MIPS
-ff_mpegvideoencdsp_init_mips(c, avctx);
+ff_mpegvideoencdsp_init_mips(c, bitexact);
 #endif
 }
diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h
index 46b40cf30e..08dd758494 100644
--- a/libavcodec/mpegvideoencdsp.h
+++ b/libavcodec/mpegvideoencdsp.h
@@ -21,8 +21,6 @@
 
 #include 
 
-#include "avcodec.h"
-
 #define BASIS_SHIFT 16
 #define RECON_SHIFT 6
 
@@ -38,15 +36,10 @@ typedef struct MpegvideoEncDSPContext {
   int src_wrap, int width, int height);
 } MpegvideoEncDSPContext;
 
-void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c,
- AVCodecContext *avctx);
-void ff_mpegv

[FFmpeg-devel] [PATCH 28/28] avcodec/diracdec: Don't use EDGE_WIDTH from mpegpicture.h

2024-05-06 Thread Andreas Rheinhardt
There is nothing that forces us to use the same value
as mpegvideo_enc.c, so define our own constant.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/diracdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index f0df74e131..df52e56098 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -38,13 +38,14 @@
 #include "golomb.h"
 #include "dirac_arith.h"
 #include "dirac_vlc.h"
-#include "mpegpicture.h"
 #include "dirac_dwt.h"
 #include "dirac.h"
 #include "diractab.h"
 #include "diracdsp.h"
 #include "videodsp.h"
 
+#define EDGE_WIDTH 16
+
 /**
  * The spec limits this to 3 for frame coding, but in practice can be as high 
as 6
  */
-- 
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 v3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Andreas Rheinhardt
This is achieved by using function pointers for AAC SBR functions.
This unfortunately necessitated to use void* in
ff_aac_sbr_apply(_fixed).
Fixes ticket #10999.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aac/aacdec.c   | 35 ++-
 libavcodec/aac/aacdec.h   |  7 ++
 libavcodec/aac/aacdec_proc_template.c |  6 +
 libavcodec/aacsbr.h   |  4 +--
 libavcodec/aacsbr_template.c  |  3 ++-
 5 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 4206ad1b5d..7457fe6c97 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -149,11 +149,7 @@ static av_cold int che_configure(AACDecContext *ac,
 return AVERROR_INVALIDDATA;
 if (che_pos) {
 if (!ac->che[type][id]) {
-int ret;
-if (ac->is_fixed)
-ret = ff_aac_sbr_ctx_alloc_init_fixed(ac, &ac->che[type][id], 
type);
-else
-ret = ff_aac_sbr_ctx_alloc_init(ac, &ac->che[type][id], type);
+int ret = ac->proc.sbr_ctx_alloc_init(ac, &ac->che[type][id], 
type);
 if (ret < 0)
 return ret;
 }
@@ -170,10 +166,7 @@ static av_cold int che_configure(AACDecContext *ac,
 }
 } else {
 if (ac->che[type][id]) {
-if (ac->is_fixed)
-ff_aac_sbr_ctx_close_fixed(ac->che[type][id]);
-else
-ff_aac_sbr_ctx_close(ac->che[type][id]);
+ac->proc.sbr_ctx_close(ac->che[type][id]);
 }
 av_freep(&ac->che[type][id]);
 }
@@ -1114,14 +1107,11 @@ static int sample_rate_idx (int rate)
 static av_cold int decode_close(AVCodecContext *avctx)
 {
 AACDecContext *ac = avctx->priv_data;
-int is_fixed = ac->is_fixed;
-void (*sbr_close)(ChannelElement *che) = is_fixed ? 
ff_aac_sbr_ctx_close_fixed :
-ff_aac_sbr_ctx_close;
 
 for (int type = 0; type < FF_ARRAY_ELEMS(ac->che); type++) {
 for (int i = 0; i < MAX_ELEM_ID; i++) {
 if (ac->che[type][i]) {
-sbr_close(ac->che[type][i]);
+ac->proc.sbr_ctx_close(ac->che[type][i]);
 av_freep(&ac->che[type][i]);
 }
 }
@@ -1136,7 +1126,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 av_tx_uninit(&ac->mdct_ltp);
 
 // Compiler will optimize this branch away.
-if (is_fixed)
+if (ac->is_fixed)
 av_freep(&ac->RENAME_FIXED(fdsp));
 else
 av_freep(&ac->fdsp);
@@ -1946,11 +1936,7 @@ static int decode_extension_payload(AACDecContext *ac, 
GetBitContext *gb, int cn
 ac->avctx->profile = AV_PROFILE_AAC_HE;
 }
 
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
-res = ff_aac_sbr_decode_extension_fixed(ac, che, gb, crc_flag, 
cnt, elem_type);
-else if (CONFIG_AAC_DECODER)
-res = ff_aac_sbr_decode_extension(ac, che, gb, crc_flag, cnt, 
elem_type);
-
+ac->proc.sbr_decode_extension(ac, che, gb, crc_flag, cnt, elem_type);
 
 if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) {
 av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as 
stereo.\n");
@@ -2059,14 +2045,9 @@ static void spectral_to_sample(AACDecContext *ac, int 
samples)
 ac->dsp.update_ltp(ac, &che->ch[1]);
 }
 if (ac->oc[1].m4ac.sbr > 0) {
-if (CONFIG_AAC_FIXED_DECODER && ac->is_fixed)
-ff_aac_sbr_apply_fixed(ac, che, type,
-   (void *)che->ch[0].output,
-   (void *)che->ch[1].output);
-else if (CONFIG_AAC_DECODER)
-ff_aac_sbr_apply(ac, che, type,
- (void *)che->ch[0].output,
- (void *)che->ch[1].output);
+ac->proc.sbr_apply(ac, che, type,
+   che->ch[0].output,
+   che->ch[1].output);
 }
 }
 if (type <= TYPE_CCE)
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 775c007aeb..eed53c6c96 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -210,6 +210,13 @@ typedef struct AACDecProc {
SingleChannelElement *sce);
 
 int (*decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelElement 
*che);
+
+int (*sbr_ctx_alloc_init)(AACDecContext *ac, ChannelElement **che, int 
id_aac);
+int (*sbr_decode_extension)(AACDecContext *ac, ChannelElement *che,
+GetBitContext *gb, int crc, int cnt, int 
id_aac);
+void (*sbr_apply)(A

Re: [FFmpeg-devel] [PATCH v3] avcodec/aac/aacdec: Fix linking errors with only one decoder enabled

2024-05-06 Thread Lynne
May 7, 2024, 00:38 by andreas.rheinha...@outlook.com:

> This is achieved by using function pointers for AAC SBR functions.
> This unfortunately necessitated to use void* in
> ff_aac_sbr_apply(_fixed).
> Fixes ticket #10999.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
> libavcodec/aac/aacdec.c   | 35 ++-
> libavcodec/aac/aacdec.h   |  7 ++
> libavcodec/aac/aacdec_proc_template.c |  6 +
> libavcodec/aacsbr.h   |  4 +--
> libavcodec/aacsbr_template.c  |  3 ++-
> 5 files changed, 25 insertions(+), 30 deletions(-)
>

Very nice, thanks
This sets us up to detemplate SBR too in the future.
LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 26/28] avcodec/mpegvideoencdsp: Factor draw_edges out in its own context

2024-05-06 Thread Lynne
May 6, 2024, 23:53 by andreas.rheinha...@outlook.com:

> This allows to remove a dependency of the dirac decoder (!)
> on mpegvideoenc.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  configure |   7 +-
>  libavcodec/Makefile   |   1 +
>  libavcodec/diracdec.c |  14 +--
>  libavcodec/drawedgesdsp.c |  61 ++
>  libavcodec/drawedgesdsp.h |  35 ++
>  libavcodec/mpegvideo.h|   2 +
>  libavcodec/mpegvideo_enc.c|   9 +-
>  libavcodec/mpegvideoencdsp.c  |  32 --
>  libavcodec/mpegvideoencdsp.h  |   6 -
>  libavcodec/snowenc.c  |  13 ++-
>  libavcodec/x86/Makefile   |   1 +
>  libavcodec/x86/drawedgesdsp.c | 157 ++
>  libavcodec/x86/mpegvideo.c|   2 +-
>  libavcodec/x86/mpegvideoencdsp_init.c | 118 ---
>  14 files changed, 281 insertions(+), 177 deletions(-)
>  create mode 100644 libavcodec/drawedgesdsp.c
>  create mode 100644 libavcodec/drawedgesdsp.h
>  create mode 100644 libavcodec/x86/drawedgesdsp.c
>

26, 27 and 28 all LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 25/28] avcodec/x86/mpegvideoencdsp_init: Remove bits_per_raw_sample check

2024-05-06 Thread Michael Niedermayer
On Mon, May 06, 2024 at 11:52:24PM +0200, Andreas Rheinhardt wrote:
> This check has been added in 19a0729b4cfacfd90b8ee84ab0c093ff7e397e65;
> this commit added high bit-depth versions of draw_edges
> and added the check to indicate that the mmx version only
> supports eight bits.
> Yet there is no high bit depth draw_edges function any more
> since d4d186d185df98492d8935a87c5b5cf369db9748; since then,
> the mmx version and the C version always behave the same,
> yet said check has not been removed. This commit does so.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/x86/mpegvideoencdsp_init.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/libavcodec/x86/mpegvideoencdsp_init.c 
> b/libavcodec/x86/mpegvideoencdsp_init.c
> index ec174b15aa..9fa7ee4824 100644
> --- a/libavcodec/x86/mpegvideoencdsp_init.c
> +++ b/libavcodec/x86/mpegvideoencdsp_init.c
> @@ -233,9 +233,7 @@ av_cold void 
> ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
>  }
>  c->add_8x8basis = add_8x8basis_mmx;
>  
> -if (avctx->bits_per_raw_sample <= 8) {
> -c->draw_edges = draw_edges_mmx;
> -}
> +c->draw_edges = draw_edges_mmx;

does draw_edges_mmx support >8 bit ?
if not the code prior to the patch looks correct to me.
and the patch removes a part of >8bit support
it would be better to finish the >8bit support

thx

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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] checkasm/blockdsp: don't randomize the buffers for fill_block_tab

2024-05-06 Thread James Almer
It ignores and overwrites the previous values.
Fixes running the test under ubsan.

Signed-off-by: James Almer 
---
 tests/checkasm/blockdsp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c
index 19d69b8687..ab87fc8fa4 100644
--- a/tests/checkasm/blockdsp.c
+++ b/tests/checkasm/blockdsp.c
@@ -71,7 +71,8 @@ static void check_fill(BlockDSPContext *h){
  ptrdiff_t line_size, int h);
 if (check_func(h->fill_block_tab[t], "blockdsp.%s", tests[t].name)) {
 uint8_t value = rnd();
-randomize_buffers(tests[t].size);
+memset(buf0, 0, sizeof(*buf0) * n * n);
+memset(buf1, 0, sizeof(*buf0) * n * n);
 call_ref(buf0, value, n, n);
 call_new(buf1, value, n, n);
 if (memcmp(buf0, buf1, sizeof(*buf0) * n * n))
-- 
2.45.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 v2 1/2] avcodec: add external enc libvvenc for H266/VVC

2024-05-06 Thread Nuo Mi
Hi Christian,
Thank you for the patch.
Let us review and merge the encoder part.

On Tue, May 7, 2024 at 1:05 AM Christian Bartnik 
wrote:

> From: Thomas Siedel 
>
> Add external encoder VVenC for H266/VVC encoding.
> Register new encoder libvvenc.
> Add libvvenc to wrap the vvenc interface.
> libvvenc implements encoder option: preset,qp,period,subjopt,
> vvenc-params,levelidc,tier.
> Enable encoder by adding --enable-libvvenc in configure step.
>
> Co-authored-by: Christian Bartnik chris1031...@gmail.com
> Signed-off-by: Christian Bartnik 
> ---
>  configure  |   4 +
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/libvvenc.c  | 501 +
>  4 files changed, 507 insertions(+)
>  create mode 100644 libavcodec/libvvenc.c
>
> diff --git a/configure b/configure
> index ed74583a6f..cb312d9c73 100755
> --- a/configure
> +++ b/configure
> @@ -293,6 +293,7 @@ External library support:
>--enable-libvorbis   enable Vorbis en/decoding via libvorbis,
> native implementation exists [no]
>--enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
> +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
>--enable-libwebp enable WebP encoding via libwebp [no]
>--enable-libx264 enable H.264 encoding via x264 [no]
>--enable-libx265 enable HEVC encoding via x265 [no]
> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
>  libvmaf
>  libvorbis
>  libvpx
> +libvvenc
>  libwebp
>  libxevd
>  libxeve
> @@ -3548,6 +3550,7 @@ libvpx_vp8_decoder_deps="libvpx"
>  libvpx_vp8_encoder_deps="libvpx"
>  libvpx_vp9_decoder_deps="libvpx"
>  libvpx_vp9_encoder_deps="libvpx"
> +libvvenc_encoder_deps="libvvenc"
>  libwebp_encoder_deps="libwebp"
>  libwebp_anim_encoder_deps="libwebp"
>  libx262_encoder_deps="libx262"
> @@ -7010,6 +7013,7 @@ enabled libvpx&& {
>  die "libvpx enabled but no supported decoders found"
>  fi
>  }
> +enabled libvvenc  && require_pkg_config libvvenc "libvvenc >=
> 1.6.1" "vvenc/vvenc.h" vvenc_get_version
>
>  enabled libwebp   && {
>  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp
> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index cff6347bdb..54d85f6aaa 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1155,6 +1155,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) +=
> libvpxdec.o
>  OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
>  OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
>  OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
> +OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
>  OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o
> libwebpenc.o
>  OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o
> libwebpenc_animencoder.o
>  OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index f4705651fb..bb2c3ce017 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -801,6 +801,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
>  extern const FFCodec ff_libvpx_vp8_decoder;
>  extern FFCodec ff_libvpx_vp9_encoder;
>  extern const FFCodec ff_libvpx_vp9_decoder;
> +extern const FFCodec ff_libvvenc_encoder;
>  /* preferred over libwebp */
>  extern const FFCodec ff_libwebp_anim_encoder;
>  extern const FFCodec ff_libwebp_encoder;
> diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
> new file mode 100644
> index 00..c459273f44
> --- /dev/null
> +++ b/libavcodec/libvvenc.c
> @@ -0,0 +1,501 @@
> +/*
> + * H.266 encoding using the VVenC library
> + *
> + * Copyright (C) 2022, Thomas Siedel
> + *
> + * 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 "config_components.h"
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "avcodec.h"
> +#include "codec_internal.h"
> +#include "encode.h"
> +#include "internal.h"
> +#include "packet_internal.h"
> +#include "profiles.h"
> +
> +#include "libavutil/avutil.h"
> +#include "libavutil/mem.h"
> +#include "libavutil

Re: [FFmpeg-devel] [PATCH] avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD

2024-05-06 Thread Michael Niedermayer
On Sun, May 05, 2024 at 11:21:58PM -0400, Brad Smith wrote:
> avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD
> 
> Use the machdep.altivec sysctl on NetBSD for AltiVec detection
> as is done with OpenBSD.
> 
> Signed-off-by: Brad Smith 
> ---
>  libavutil/ppc/cpu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

you seem to be sending alot of bsd related patches, maybe
you want to send a patch that adds you to the MAINTAINERs file?

thx

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

Elect your leaders based on what they did after the last election, not
based on what they say before an election.



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 6/9] lavc/vp8dsp: R-V V put_epel hv

2024-05-06 Thread uk7b
From: sunyuechi 

C908:
vp8_put_epel4_h4v4_c: 20.0
vp8_put_epel4_h4v4_rvv_i32: 11.0
vp8_put_epel4_h4v6_c: 25.2
vp8_put_epel4_h4v6_rvv_i32: 13.5
vp8_put_epel4_h6v4_c: 22.2
vp8_put_epel4_h6v4_rvv_i32: 14.5
vp8_put_epel4_h6v6_c: 29.0
vp8_put_epel4_h6v6_rvv_i32: 15.7
vp8_put_epel8_h4v4_c: 73.0
vp8_put_epel8_h4v4_rvv_i32: 22.2
vp8_put_epel8_h4v6_c: 90.5
vp8_put_epel8_h4v6_rvv_i32: 26.7
vp8_put_epel8_h6v4_c: 85.0
vp8_put_epel8_h6v4_rvv_i32: 27.2
vp8_put_epel8_h6v6_c: 104.7
vp8_put_epel8_h6v6_rvv_i32: 29.5
vp8_put_epel16_h4v4_c: 145.5
vp8_put_epel16_h4v4_rvv_i32: 26.5
vp8_put_epel16_h4v6_c: 190.7
vp8_put_epel16_h4v6_rvv_i32: 47.5
vp8_put_epel16_h6v4_c: 173.7
vp8_put_epel16_h6v4_rvv_i32: 33.2
vp8_put_epel16_h6v6_c: 222.2
vp8_put_epel16_h6v6_rvv_i32: 35.5
---
 libavcodec/riscv/vp8dsp_init.c |  13 
 libavcodec/riscv/vp8dsp_rvv.S  | 123 +++--
 2 files changed, 115 insertions(+), 21 deletions(-)

diff --git a/libavcodec/riscv/vp8dsp_init.c b/libavcodec/riscv/vp8dsp_init.c
index dc3e087f01..463c8fa0a2 100644
--- a/libavcodec/riscv/vp8dsp_init.c
+++ b/libavcodec/riscv/vp8dsp_init.c
@@ -97,6 +97,19 @@ av_cold void ff_vp78dsp_init_riscv(VP8DSPContext *c)
 c->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_rvv;
 c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_rvv;
 c->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_rvv;
+
+c->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_rvv;
+c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_rvv;
+c->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_rvv;
+c->put_vp8_epel_pixels_tab[0][2][1] = ff_put_vp8_epel16_h4v6_rvv;
+c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_rvv;
+c->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_rvv;
+c->put_vp8_epel_pixels_tab[0][1][1] = ff_put_vp8_epel16_h4v4_rvv;
+c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_rvv;
+c->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_rvv;
+c->put_vp8_epel_pixels_tab[0][1][2] = ff_put_vp8_epel16_h6v4_rvv;
+c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_rvv;
+c->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_rvv;
 }
 #endif
 #endif
diff --git a/libavcodec/riscv/vp8dsp_rvv.S b/libavcodec/riscv/vp8dsp_rvv.S
index bf268e4d8d..71945f3d77 100644
--- a/libavcodec/riscv/vp8dsp_rvv.S
+++ b/libavcodec/riscv/vp8dsp_rvv.S
@@ -161,26 +161,26 @@ const subpel_filters
 .byte 0,  -1,  12, 123,  -6, 0
 endconst
 
-.macro epel_filter size type
-lla t2, subpel_filters
+.macro epel_filter size type regtype
+lla \regtype\()2, subpel_filters
 .ifc \type,v
-addit0, a6, -1
+addi\regtype\()0, a6, -1
 .elseif \type == h
-addit0, a5, -1
+addi\regtype\()0, a5, -1
 .endif
-li  t1, 6
-mul t0, t0, t1
-add t0, t0, t2
+li  \regtype\()1, 6
+mul \regtype\()0, \regtype\()0, \regtype\()1
+add \regtype\()0, \regtype\()0, \regtype\()2
 .irp n 1,2,3,4
-lb  t\n, \n(t0)
+lb  \regtype\n, \n(\regtype\()0)
 .endr
 .ifc \size,6
-lb  t5, 5(t0)
-lb  t0, (t0)
+lb  \regtype\()5, 5(\regtype\()0)
+lb  \regtype\()0, (\regtype\()0)
 .endif
 .endm
 
-.macro epel_load dst len size type
+.macro epel_load dst len size type from_mem regtype
 .ifc \type,v
 mv  a5, a3
 .else
@@ -189,24 +189,35 @@ endconst
 sub t6, a2, a5
 add a7, a2, a5
 
+.if \from_mem
 vle8.v  v24, (a2)
 vle8.v  v22, (t6)
 vle8.v  v26, (a7)
 add a7, a7, a5
 vle8.v  v28, (a7)
-vwmulu.vx   v16, v24, t2
-vwmulu.vx   v20, v26, t3
+vwmulu.vx   v16, v24, \regtype\()2
+vwmulu.vx   v20, v26, \regtype\()3
 .ifc \size,6
 sub t6, t6, a5
 add a7, a7, a5
 vle8.v  v24, (t6)
 vle8.v  v26, (a7)
-vwmaccu.vx  v16, t0, v24
-vwmaccu.vx  v16, t5, v26
+vwmaccu.vx  v16, \regtype\()0, v24
+vwmaccu.vx  v16, \regtype\()5, v26
+.endif
+vwmaccsu.vx v16, \regtype\()1, v22
+vwmaccsu.vx v16, \regtype\()4, v28
+.else
+vwmulu.vx   v16, v4, \regtype\()2
+vwmulu.vx   v20, v6, \regtype\()3
+.ifc \size,6
+vwmaccu.vx  v16, \regtype\()0, v0
+vwmaccu.vx  v16, \regtype\()5, v10
+.endif
+vwmaccsu.vx v16, \regtype\()1, v2
+vwmaccsu.vx v16, \regtype\()4, v8
 .endif
 li  t6, 64
-

Re: [FFmpeg-devel] [PATCH v3 6/9] lavc/vp8dsp: R-V V put_epel hv

2024-05-06 Thread flow gg
> IMO, passing a complete register name, if you really need to vary it,
would be
simpler and more flexible than an ABI register type prefix.

If the full register name is passed here, some require four parameters,
some require six parameters, and there is often repetition.
I feel it's easy to get confused about the differences between the
parameters passed each time.
If use a prefix instead, would only need one parameter, which I think would
be less error-prone.

> This code actually requires ==, not >=.
> You can do that but you only need half the stack space and offsets.

Ok, fixed it

Rémi Denis-Courmont  于2024年5月7日周二 03:25写道:

> Le maanantaina 6. toukokuuta 2024, 6.38.06 EEST u...@foxmail.com a écrit :
> > From: sunyuechi 
> >
> > C908:
> > vp8_put_epel4_h4v4_c: 20.0
> > vp8_put_epel4_h4v4_rvv_i32: 11.0
> > vp8_put_epel4_h4v6_c: 25.2
> > vp8_put_epel4_h4v6_rvv_i32: 13.5
> > vp8_put_epel4_h6v4_c: 22.2
> > vp8_put_epel4_h6v4_rvv_i32: 14.5
> > vp8_put_epel4_h6v6_c: 29.0
> > vp8_put_epel4_h6v6_rvv_i32: 15.7
> > vp8_put_epel8_h4v4_c: 73.0
> > vp8_put_epel8_h4v4_rvv_i32: 22.2
> > vp8_put_epel8_h4v6_c: 90.5
> > vp8_put_epel8_h4v6_rvv_i32: 26.7
> > vp8_put_epel8_h6v4_c: 85.0
> > vp8_put_epel8_h6v4_rvv_i32: 27.2
> > vp8_put_epel8_h6v6_c: 104.7
> > vp8_put_epel8_h6v6_rvv_i32: 29.5
> > vp8_put_epel16_h4v4_c: 145.5
> > vp8_put_epel16_h4v4_rvv_i32: 26.5
> > vp8_put_epel16_h4v6_c: 190.7
> > vp8_put_epel16_h4v6_rvv_i32: 47.5
> > vp8_put_epel16_h6v4_c: 173.7
> > vp8_put_epel16_h6v4_rvv_i32: 33.2
> > vp8_put_epel16_h6v6_c: 222.2
> > vp8_put_epel16_h6v6_rvv_i32: 35.5
> > ---
> >  libavcodec/riscv/vp8dsp_init.c |  13 
> >  libavcodec/riscv/vp8dsp_rvv.S  | 117 +++--
> >  2 files changed, 109 insertions(+), 21 deletions(-)
> >
> > diff --git a/libavcodec/riscv/vp8dsp_init.c
> b/libavcodec/riscv/vp8dsp_init.c
> > index dc3e087f01..463c8fa0a2 100644
> > --- a/libavcodec/riscv/vp8dsp_init.c
> > +++ b/libavcodec/riscv/vp8dsp_init.c
> > @@ -97,6 +97,19 @@ av_cold void ff_vp78dsp_init_riscv(VP8DSPContext *c)
> >  c->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_rvv;
> >  c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_rvv;
> >  c->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_rvv;
> > +
> > +c->put_vp8_epel_pixels_tab[0][2][2] =
> ff_put_vp8_epel16_h6v6_rvv;
> > +c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_rvv;
> > +c->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_rvv;
> > +c->put_vp8_epel_pixels_tab[0][2][1] =
> ff_put_vp8_epel16_h4v6_rvv;
> > +c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_rvv;
> > +c->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_rvv;
> > +c->put_vp8_epel_pixels_tab[0][1][1] =
> ff_put_vp8_epel16_h4v4_rvv;
> > +c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_rvv;
> > +c->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_rvv;
> > +c->put_vp8_epel_pixels_tab[0][1][2] =
> ff_put_vp8_epel16_h6v4_rvv;
> > +c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_rvv;
> > +c->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_rvv;
> >  }
> >  #endif
> >  #endif
> > diff --git a/libavcodec/riscv/vp8dsp_rvv.S
> b/libavcodec/riscv/vp8dsp_rvv.S
> > index bf268e4d8d..baa8152830 100644
> > --- a/libavcodec/riscv/vp8dsp_rvv.S
> > +++ b/libavcodec/riscv/vp8dsp_rvv.S
> > @@ -161,26 +161,26 @@ const subpel_filters
> >  .byte 0,  -1,  12, 123,  -6, 0
> >  endconst
> >
> > -.macro epel_filter size type
> > -lla t2, subpel_filters
> > +.macro epel_filter size type regtype
> > +lla \regtype\()2, subpel_filters
> >  .ifc \type,v
> > -addit0, a6, -1
> > +addi\regtype\()0, a6, -1
>
> IMO, passing a complete register name, if you really need to vary it,
> would be
> simpler and more flexible than an ABI register type prefix.
>
> >  .elseif \type == h
> > -addit0, a5, -1
> > +addi\regtype\()0, a5, -1
> >  .endif
> > -li  t1, 6
> > -mul t0, t0, t1
> > -add t0, t0, t2
> > +li  \regtype\()1, 6
> > +mul \regtype\()0, \regtype\()0, \regtype\()1
> > +add \regtype\()0, \regtype\()0, \regtype\()2
> >  .irp n 1,2,3,4
> > -lb  t\n, \n(t0)
> > +lb  \regtype\n, \n(\regtype\()0)
> >  .endr
> >  .ifc \size,6
> > -lb  t5, 5(t0)
> > -lb  t0, (t0)
> > +lb  \regtype\()5, 5(\regtype\()0)
> > +lb  \regtype\()0, (\regtype\()0)
> >  .endif
> >  .endm
> >
> > -.macro epel_load dst len size type
> > +.macro epel_load dst len size type from_mem regtype
> >  .ifc \type,v
> >  mv  a5, a3
> >  .else
> > @@

Re: [FFmpeg-devel] [PATCH v4 1/5] configure: Remove libva 1.x support

2024-05-06 Thread Xiang, Haihao
On So, 2024-05-05 at 20:01 +0100, Mark Thompson wrote:
> libva 2.0 was released in 2017 and the 2.x versions are included in all
> supported distributions nowadays.  Various features no longer need any
> configure check after this command, including all codecs except AV1.
> Note that the libva version is the API version plus one, so this is
> removing support for VAAPI 0.x and requiring VAAPI 1.x.
> ---
> Changes to the series since v3:
> * Reorder so that the series doesn't need to be squashed.
> * New patch to remove the driver quirk support (deprecated in the public
>   header, but will have no effect if set).
> 
>  configure | 25 ++---
>  1 file changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/configure b/configure
> index ed74583a6f..69fde0bf35 100755
> --- a/configure
> +++ b/configure
> @@ -2625,7 +2625,6 @@ CONFIG_EXTRA="
>  texturedsp
>  texturedspenc
>  tpeldsp
> -    vaapi_1

CONFIG_VAAPI_1 is used in the code. Removing this only caused compiling errors.

libavfilter/vaapi_vpp.c: In function ‘ff_vaapi_vpp_config_output’:
libavfilter/vaapi_vpp.c:207:9: error: ‘CONFIG_VAAPI_1’ undeclared (first use in
this function); did you mean ‘CONFIG_VAAPI’?
  207 | if (CONFIG_VAAPI_1)
  | ^~
  | CONFIG_VAAPI


Thanks
Haihao


>  vaapi_encode
>  vc1dsp
>  videodsp
> @@ -3189,7 +3188,7 @@ hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
>  hevc_dxva2_hwaccel_select="hevc_decoder"
>  hevc_nvdec_hwaccel_deps="nvdec"
>  hevc_nvdec_hwaccel_select="hevc_decoder"
> -hevc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferHEVC"
> +hevc_vaapi_hwaccel_deps="vaapi"
>  hevc_vaapi_hwaccel_select="hevc_decoder"
>  hevc_vdpau_hwaccel_deps="vdpau VdpPictureInfoHEVC"
>  hevc_vdpau_hwaccel_select="hevc_decoder"
> @@ -3261,7 +3260,7 @@ vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9"
>  vp9_dxva2_hwaccel_select="vp9_decoder"
>  vp9_nvdec_hwaccel_deps="nvdec"
>  vp9_nvdec_hwaccel_select="vp9_decoder"
> -vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth"
> +vp9_vaapi_hwaccel_deps="vaapi"
>  vp9_vaapi_hwaccel_select="vp9_decoder"
>  vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9"
>  vp9_vdpau_hwaccel_select="vp9_decoder"
> @@ -3354,7 +3353,6 @@ hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec"
>  hevc_qsv_encoder_select="hevcparse qsvenc"
>  hevc_rkmpp_decoder_deps="rkmpp"
>  hevc_rkmpp_decoder_select="hevc_mp4toannexb_bsf"
> -hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
>  hevc_vaapi_encoder_select="atsc_a53 cbs_h265 vaapi_encode"
>  hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
>  hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
> @@ -3363,7 +3361,6 @@ mjpeg_cuvid_decoder_deps="cuvid"
>  mjpeg_qsv_decoder_select="qsvdec"
>  mjpeg_qsv_encoder_deps="libmfx"
>  mjpeg_qsv_encoder_select="qsvenc"
> -mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
>  mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode"
>  mp3_mf_encoder_deps="mediafoundation"
>  mpeg1_cuvid_decoder_deps="cuvid"
> @@ -3392,7 +3389,6 @@ vp8_mediacodec_decoder_deps="mediacodec"
>  vp8_mediacodec_encoder_deps="mediacodec"
>  vp8_qsv_decoder_select="qsvdec"
>  vp8_rkmpp_decoder_deps="rkmpp"
> -vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
>  vp8_vaapi_encoder_select="vaapi_encode"
>  vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
>  vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
> @@ -3401,7 +3397,6 @@ vp9_mediacodec_decoder_deps="mediacodec"
>  vp9_mediacodec_encoder_deps="mediacodec"
>  vp9_qsv_decoder_select="qsvdec"
>  vp9_rkmpp_decoder_deps="rkmpp"
> -vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
>  vp9_vaapi_encoder_select="vaapi_encode"
>  vp9_qsv_encoder_deps="libmfx MFX_CODEC_VP9"
>  vp9_qsv_encoder_select="qsvenc"
> @@ -3952,9 +3947,9 @@ xfade_vulkan_filter_deps="vulkan spirv_compiler"
>  yadif_cuda_filter_deps="ffnvcodec"
>  yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
>  yadif_videotoolbox_filter_deps="metal corevideo videotoolbox"
> -hstack_vaapi_filter_deps="vaapi_1"
> -vstack_vaapi_filter_deps="vaapi_1"
> -xstack_vaapi_filter_deps="vaapi_1"
> +hstack_vaapi_filter_deps="vaapi"
> +vstack_vaapi_filter_deps="vaapi"
> +xstack_vaapi_filter_deps="vaapi"
>  hstack_qsv_filter_deps="libmfx"
>  hstack_qsv_filter_select="qsvvpp"
>  vstack_qsv_filter_deps="libmfx"
> @@ -7252,7 +7247,7 @@ enabled libdrm &&
>  check_pkg_config libdrm_getfb2 libdrm "xf86drmMode.h" drmModeGetFB2
>  
>  enabled vaapi &&
> -    check_pkg_config vaapi "libva >= 0.35.0" "va/va.h" vaInitialize
> +    check_pkg_config vaapi "libva >= 1.0.0" "va/va.h" vaInitialize
>  
>  if enabled vaapi; then
>  case $target_os in
> @@ -7268,18 +7263,10 @@ if enabled vaapi; then
>  check_pkg_config vaapi_x11 "libva-x11" "va/va_x11.h" vaGetDisplay
>  fi
>  
> -    check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
> -
> -    check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"

Re: [FFmpeg-devel] [PATCH] checkasm/blockdsp: don't randomize the buffers for fill_block_tab

2024-05-06 Thread Martin Storsjö

On Mon, 6 May 2024, James Almer wrote:


It ignores and overwrites the previous values.
Fixes running the test under ubsan.

Signed-off-by: James Almer 
---
tests/checkasm/blockdsp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)


The change is probably correct, but what issue is ubsan complaining about? 
If this would just be a dead store of unused random values, that shouldn't 
be an ubsan issue in general, right?


// 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] [PATCH] lavc/vaapi_h264: Fix merging fields in DPB with missing references

2024-05-06 Thread David Rosca
If there are missing references, h264 decode does error concealment
by copying previous refs which means there will be duplicated surfaces
and this code would try to merge them instead of correctly appending
to DPB. Make sure the fields were actually merged before early return.
---
 libavcodec/vaapi_h264.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index b47531ce1c..c62a320e97 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -112,8 +112,9 @@ static int dpb_add(DPB *dpb, const H264Picture *pic)
 } else {
 va_pic->BottomFieldOrderCnt = 
temp_va_pic.BottomFieldOrderCnt;
 }
+return 0;
 }
-return 0;
+break;
 }
 }
 
-- 
2.45.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] lavc/vaapi_h264: Don't try to merge fields in DPB for non-field pics

2024-05-06 Thread David Rosca
On Mon, May 6, 2024 at 9:55 PM Mark Thompson  wrote:
>
> On 05/05/2024 17:36, David Rosca wrote:
> > This path can be hit when there are missing references while decoding
> > progressive stream and would completely break the DPB contents.
> > ---
> >  libavcodec/vaapi_h264.c | 30 --
> >  1 file changed, 16 insertions(+), 14 deletions(-)
>
> Can you share a stream which does this in a progressive case?

https://github.com/nowrep/chiaki4deck/raw/samples/samples/missingframes.h264

>
> My understanding of this (though I suspect I am missing something) is that we 
> are filling from the short/long DPB lists which should not contain duplicates 
> (not RefPicListX, which can), so I'm not seeing how this case could be 
> triggered.
>
> If you do have two DPB entries which are different frames but refer to the 
> same surface then that seems like a bug elsewhere.

It comes from the error concealment in h264dec which copies previous
ref for missing refs. It can actually also happen for interlaced
streams. I've sent a new patch that should fix it for both progressive
and interlaced.

https://github.com/FFmpeg/FFmpeg/blob/b1037d4ebe7b7f9548ce1ed24a2929aedbe9a27a/libavcodec/h264_slice.c#L1520-L1559

Thanks,
David

>
> Thanks,
>
> - Mark
>
>
> > diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
> > index b47531ce1c..ca0076f57a 100644
> > --- a/libavcodec/vaapi_h264.c
> > +++ b/libavcodec/vaapi_h264.c
> > @@ -98,22 +98,24 @@ static int dpb_add(DPB *dpb, const H264Picture *pic)
> >  if (dpb->size >= dpb->max_size)
> >  return -1;
> >
> > -for (i = 0; i < dpb->size; i++) {
> > -VAPictureH264 * const va_pic = &dpb->va_pics[i];
> > -if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f)) {
> > -VAPictureH264 temp_va_pic;
> > -fill_vaapi_pic(&temp_va_pic, pic, 0);
> > -
> > -if ((temp_va_pic.flags ^ va_pic->flags) & 
> > (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) {
> > -va_pic->flags |= temp_va_pic.flags & 
> > (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD);
> > -/* Merge second field */
> > -if (temp_va_pic.flags & VA_PICTURE_H264_TOP_FIELD) {
> > -va_pic->TopFieldOrderCnt= 
> > temp_va_pic.TopFieldOrderCnt;
> > -} else {
> > -va_pic->BottomFieldOrderCnt = 
> > temp_va_pic.BottomFieldOrderCnt;
> > +if (pic->field_picture) {
> > +for (i = 0; i < dpb->size; i++) {
> > +VAPictureH264 * const va_pic = &dpb->va_pics[i];
> > +if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f)) {
> > +VAPictureH264 temp_va_pic;
> > +fill_vaapi_pic(&temp_va_pic, pic, 0);
> > +
> > +if ((temp_va_pic.flags ^ va_pic->flags) & 
> > (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) {
> > +va_pic->flags |= temp_va_pic.flags & 
> > (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD);
> > +/* Merge second field */
> > +if (temp_va_pic.flags & VA_PICTURE_H264_TOP_FIELD) {
> > +va_pic->TopFieldOrderCnt= 
> > temp_va_pic.TopFieldOrderCnt;
> > +} else {
> > +va_pic->BottomFieldOrderCnt = 
> > temp_va_pic.BottomFieldOrderCnt;
> > +}
> >  }
> > +return 0;
> >  }
> > -return 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 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".