[FFmpeg-devel] [PATCH 9/9] avcodec/vp3: Replace check by assert

2024-05-17 Thread Michael Niedermayer
Fixes: CID1452425 Logically dead code

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 09527607767..d03a1c9dbc1 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2001,8 +2001,7 @@ static int vp4_mc_loop_filter(Vp3DecodeContext *s, int 
plane, int motion_x, int
 x_offset = (-(x + 2) & 7) + 2;
 y_offset = (-(y + 2) & 7) + 2;
 
-if (x_offset > 8 + x_subpel && y_offset > 8 + y_subpel)
-return 0;
+av_assert1(!(x_offset > 8 + x_subpel && y_offset > 8 + y_subpel));
 
 s->vdsp.emulated_edge_mc(loop, motion_source - stride - 1,
  loop_stride, stride,
-- 
2.45.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 8/9] avcodec/vp8: Forward return of ff_vpx_init_range_decoder()

2024-05-17 Thread Michael Niedermayer
Fixes: CID1507483 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vp8.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 19f32b34006..8e91613068a 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -341,9 +341,8 @@ static int setup_partitions(VP8Context *s, const uint8_t 
*buf, int buf_size)
 }
 
 s->coeff_partition_size[i] = buf_size;
-ff_vpx_init_range_decoder(>coeff_partition[i], buf, buf_size);
 
-return 0;
+return ff_vpx_init_range_decoder(>coeff_partition[i], buf, buf_size);
 }
 
 static void vp7_get_quants(VP8Context *s)
-- 
2.45.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 7/9] avcodec/vlc: Cleanup on multi table alloc failure in ff_vlc_init_multi_from_lengths()

2024-05-17 Thread Michael Niedermayer
Fixes: CID1544630 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vlc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
index ee09d96fd61..f46ecbb55e9 100644
--- a/libavcodec/vlc.c
+++ b/libavcodec/vlc.c
@@ -529,7 +529,7 @@ int ff_vlc_init_multi_from_lengths(VLC *vlc, VLC_MULTI 
*multi, int nb_bits, int
 
 multi->table = av_malloc(sizeof(*multi->table) << nb_bits);
 if (!multi->table)
-return AVERROR(ENOMEM);
+goto fail;
 
 j = code = 0;
 for (int i = 0; i < nb_codes; i++, lens += lens_wrap) {
-- 
2.45.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 6/9] avcodec/vc1_parser: Assert init_get_bits success

2024-05-17 Thread Michael Niedermayer
The buffer used is a fixed size buffer from the context, it cannot be too large 
nor
can it be NULL

Helps: CID1441935 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vc1_parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index ec284dca009..a1557b1ec7e 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -66,7 +66,9 @@ static void vc1_extract_header(AVCodecParserContext *s, 
AVCodecContext *avctx,
 GetBitContext gb;
 int ret;
 vpc->v.s.avctx = avctx;
-init_get_bits8(, buf, buf_size);
+ret = init_get_bits8(, buf, buf_size);
+av_assert1(ret >= 0);
+
 switch (vpc->prev_start_code) {
 case VC1_CODE_SEQHDR & 0xFF:
 ff_vc1_decode_sequence_header(avctx, >v, );
-- 
2.45.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 5/9] avcodec/vc1_block: remove unneeded store to off in vc1_decode_p_mb_intfi()

2024-05-17 Thread Michael Niedermayer
Found while reviewing code related to coverity

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vc1_block.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 1e8e294ad89..322acebfe50 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -1771,7 +1771,6 @@ static int vc1_decode_p_mb_intfi(VC1Context *v)
 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & 
AV_CODEC_FLAG_GRAY))
 continue;
 
v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
-off  = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
 block_cbp |= 0xf << (i << 2);
 }
 } else {
-- 
2.45.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/9] avcodec/vc1_block: remove unused off from vc1_decode_p_mb_intfr()

2024-05-17 Thread Michael Niedermayer
Fixes: CID1435166 Unused value
Fixes: CID1529221 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vc1_block.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index a6ee4922f95..1e8e294ad89 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -1607,10 +1607,6 @@ static int vc1_decode_p_mb_intfr(VC1Context *v)
 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & 
AV_CODEC_FLAG_GRAY))
 continue;
 
v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
-if (i < 4)
-off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * 
s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
-else
-off = 0;
 block_cbp |= 0xf << (i << 2);
 }
 
-- 
2.45.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/9] avcodec/vble: Check av_image_get_buffer_size() for failure

2024-05-17 Thread Michael Niedermayer
Fixes: CID1461482 Improper use of negative value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vble.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vble.c b/libavcodec/vble.c
index 32157913c77..c585b1ed9fc 100644
--- a/libavcodec/vble.c
+++ b/libavcodec/vble.c
@@ -191,6 +191,9 @@ static av_cold int vble_decode_init(AVCodecContext *avctx)
 ctx->size = av_image_get_buffer_size(avctx->pix_fmt,
  avctx->width, avctx->height, 1);
 
+if (ctx->size < 0)
+return ctx->size;
+
 ctx->val = av_malloc_array(ctx->size, sizeof(*ctx->val));
 
 if (!ctx->val) {
-- 
2.45.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/9] avcodec/tiff: Assert init_get_bits8() success in unpack_gray()

2024-05-17 Thread Michael Niedermayer
Helps: CID1441939 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/tiff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index ca7e9f6aba9..31de6ad7308 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -457,7 +457,8 @@ static void unpack_gray(TiffContext *s, AVFrame *p,
 GetBitContext gb;
 uint16_t *dst = (uint16_t *)(p->data[0] + lnum * p->linesize[0]);
 
-init_get_bits8(, src, width);
+int ret = init_get_bits8(, src, width);
+av_assert1(ret >= 0);
 
 for (int i = 0; i < s->width; i++) {
 dst[i] = get_bits(, bpp);
-- 
2.45.1

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

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


[FFmpeg-devel] [PATCH 1/9] avcodec/tiff: Assert init_get_bits8() success in horizontal_fill()

2024-05-17 Thread Michael Niedermayer
Helps: CID1441167 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer 
---
 libavcodec/tiff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 19301d9e490..ca7e9f6aba9 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -422,7 +422,8 @@ static void av_always_inline horizontal_fill(TiffContext *s,
 uint8_t shift = is_dng ? 0 : 16 - bpp;
 GetBitContext gb;
 
-init_get_bits8(, src, width);
+int ret = init_get_bits8(, src, width);
+av_assert1(ret >= 0);
 for (int i = 0; i < s->width; i++) {
 dst16[i] = get_bits(, bpp) << shift;
 }
-- 
2.45.1

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/vc1_loopfilter: Factor duplicate code in vc1_b_h_intfi_loop_filter()

2024-05-17 Thread Michael Niedermayer
On Wed, May 25, 2022 at 05:53:12PM +0200, Michael Niedermayer wrote:
> On Tue, May 24, 2022 at 08:50:51PM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > Fixes: CID1435168
> > > 
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavcodec/vc1_loopfilter.c | 5 +
> > >  1 file changed, 1 insertion(+), 4 deletions(-)
> > > 
> > > diff --git a/libavcodec/vc1_loopfilter.c b/libavcodec/vc1_loopfilter.c
> > > index 0f990cccef..ee694ede28 100644
> > > --- a/libavcodec/vc1_loopfilter.c
> > > +++ b/libavcodec/vc1_loopfilter.c
> > > @@ -1125,10 +1125,7 @@ static av_always_inline void 
> > > vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *d
> > >  dst = dest + (block_num & 2) * 4 * s->linesize + (block_num & 1) 
> > > * 8;
> > >  
> > >  if (!(flags & RIGHT_EDGE) || !(block_num & 5)) {
> > > -if (block_num > 3)
> > > -v->vc1dsp.vc1_h_loop_filter8(dst + 8, linesize, pq);
> > > -else
> > > -v->vc1dsp.vc1_h_loop_filter8(dst + 8, linesize, pq);
> > > +v->vc1dsp.vc1_h_loop_filter8(dst + 8, linesize, pq);
> > >  }
> > >  
> > >  tt = ttblk[0] >> (block_num * 4) & 0xf;
> > 
> > Are you certain that the current code is actually correct or whether
> > something else was intended?
> 
> iam not certain no but the vc1_b_v_intfi_loop_filter() function also
> treats luma and chroma the same
> 
> if(!(flags & BOTTOM_EDGE) || block_num < 2)
> v->vc1dsp.vc1_v_loop_filter8(dst + 8 * linesize, linesize, pq);
> 
> this is just the matching function for horizontal instead of vertical
> 
> also whan looking at the 4x4 4x8 and 8x4 cases i see no difference
> between horizontal and vertical for intfi. But ultimately yes of course
> it could be buggy and something else could be correct.
> 
> but if i replace this by an abort()
> make: *** [fate-vc1_sa10143] Error 134
> make: *** [fate-vc1_ilaced_twomv] Error 134
> 
> Fate fails, so it should be tested

will apply this unless someone has some further insight in this or objection
as i just run into this again

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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

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


Re: [FFmpeg-devel] [PATCH] lavc/libvpxenc: Fix parsing of ts_layering_mode parameter

2024-05-17 Thread James Zern via ffmpeg-devel
Hi,

On Wed, May 15, 2024 at 11:11 PM Aaron Thompson via ffmpeg-devel
 wrote:
>
> The value was being parsed as base 4, so the value "4" was invalid and
> would result in ts_layering_mode being set to 0.
>
> Signed-off-by: Aaron Thompson 
> ---
>  libavcodec/libvpxenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

lgtm. Good catch. I applied this with a micro version bump.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avcodec/tiff: Fix leak on error

2024-05-17 Thread Michael Niedermayer
On Fri, May 17, 2024 at 09:51:05PM +0200, Andreas Rheinhardt wrote:
> Fixes Coverity issue #1516957.

Please mark issues that you fixed in coverity accordingly so that others
(like me) see it and know what issues remain outstanding by well looking
at the list of outstanding issues

thx

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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] avfilter/vf_v360: Add assert to suppress Coverity false positives

2024-05-17 Thread Andreas Rheinhardt
Should fix many Coverity false positives, namely #1457947-#1457994
as well as #1461195-#146210.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_v360.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 5ea6e0d865..299dbe9ff5 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -286,6 +286,8 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext 
*ctx, void *arg, int jo
 const AVFrame *in = td->in;
\
 AVFrame *out = td->out;
\

\
+av_assert1(s->nb_planes <= AV_VIDEO_MAX_PLANES);   
\
+   
\
 for (int stereo = 0; stereo < 1 + s->out_stereo > STEREO_2D; stereo++) {   
\
 for (int plane = 0; plane < s->nb_planes; plane++) {   
\
 const unsigned map = s->map[plane];
\
-- 
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 4/5] avcodec/sga: Check non constant init_get_bits8()

2024-05-17 Thread Michael Niedermayer
On Fri, May 17, 2024 at 09:53:21AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1473562 Unchecked return value
> > Fixes: CID1473592 Unchecked return value
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/sga.c | 10 --
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/sga.c b/libavcodec/sga.c
> > index 0f42cf912b2..aca941e057e 100644
> > --- a/libavcodec/sga.c
> > +++ b/libavcodec/sga.c
> > @@ -254,11 +254,14 @@ static int decode_palmapdata(AVCodecContext *avctx)
> >  const int bits = (s->nb_pal + 1) / 2;
> >  GetByteContext *gb = >gb;
> >  GetBitContext pm;
> > +int ret;
> >  
> >  bytestream2_seek(gb, s->palmapdata_offset, SEEK_SET);
> >  if (bytestream2_get_bytes_left(gb) < s->palmapdata_size)
> >  return AVERROR_INVALIDDATA;
> > -init_get_bits8(, gb->buffer, s->palmapdata_size);
> > +ret = init_get_bits8(, gb->buffer, s->palmapdata_size);
> > +if (ret < 0)
> > +return ret;
> >  
> >  for (int y = 0; y < s->tiles_h; y++) {
> >  uint8_t *dst = s->palmapindex_data + y * s->tiles_w;
> > @@ -277,11 +280,14 @@ static int decode_tiledata(AVCodecContext *avctx)
> >  SGAVideoContext *s = avctx->priv_data;
> >  GetByteContext *gb = >gb;
> >  GetBitContext tm;
> > +int ret;
> >  
> >  bytestream2_seek(gb, s->tiledata_offset, SEEK_SET);
> >  if (bytestream2_get_bytes_left(gb) < s->tiledata_size)
> >  return AVERROR_INVALIDDATA;
> > -init_get_bits8(, gb->buffer, s->tiledata_size);
> > +ret = init_get_bits8(, gb->buffer, s->tiledata_size);
> > +if (ret < 0)
> > +return ret;
> >  
> >  for (int n = 0; n < s->nb_tiles; n++) {
> >  uint8_t *dst = s->tileindex_data + n * 64;
> 
> Both of these can not fail and could be checked via av_assert1:
> palmapdata_size is given by (s->tiles_w * s->tiles_h * ((s->nb_pal + 1)
> / 2) + 7) / 8 with tiles_w and tiles_h being in the 0..255 range and
> nb_pal being in the 0..4 range.
> tiledata_size is given by s->nb_tiles * 32; nb_tiles fits in 16 bits (it
> is either read via AV_RB16 or is given as the product of tiles_h *
> tiles_w, both of which are read from simple uint8_t.

ill use av_assert1()

thx

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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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] avcodec/vc1_parser: Check init_get_bits8()

2024-05-17 Thread Andreas Rheinhardt
Addresses Coverity issue #1441935.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1_parser.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
index ec284dca00..a536a7bcf8 100644
--- a/libavcodec/vc1_parser.c
+++ b/libavcodec/vc1_parser.c
@@ -26,6 +26,7 @@
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "parser.h"
 #include "vc1.h"
 #include "get_bits.h"
@@ -66,7 +67,9 @@ static void vc1_extract_header(AVCodecParserContext *s, 
AVCodecContext *avctx,
 GetBitContext gb;
 int ret;
 vpc->v.s.avctx = avctx;
-init_get_bits8(, buf, buf_size);
+ret = init_get_bits8(, buf, buf_size);
+av_assert1(ret >= 0); // buf_size is bounded by UNESCAPED_THRESHOLD
+
 switch (vpc->prev_start_code) {
 case VC1_CODE_SEQHDR & 0xFF:
 ff_vc1_decode_sequence_header(avctx, >v, );
-- 
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] avcodec/jpeg2000dec: fix HT block decoder issue #10905

2024-05-17 Thread WATANABE Osamu
Signed-off-by: Pierre-Anthony Lemieux 
---
libavcodec/jpeg2000htdec.c   | 122 ---
tests/ref/fate/jpeg2000dec-ds0_ht_01_b11 |   2 +-
2 files changed, 63 insertions(+), 61 deletions(-)

diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c
index fa704b665e..62f70c32a8 100644
--- a/libavcodec/jpeg2000htdec.c
+++ b/libavcodec/jpeg2000htdec.c
@@ -196,7 +196,7 @@ static void jpeg2000_bitbuf_refill_forward(StateVars 
*buffer, const uint8_t *arr
while (buffer->bits_left < 32) {
buffer->tmp = 0xFF;
buffer->bits = (buffer->last == 0xFF) ? 7 : 8;
-if (buffer->pos <= length) {
+if (buffer->pos < length) {
buffer->tmp = array[buffer->pos];
buffer->pos += 1;
buffer->last = buffer->tmp;
@@ -508,17 +508,17 @@ static int jpeg2000_decode_sig_emb(const 
Jpeg2000DecoderContext *s, MelDecoderSt
}

av_always_inline
-static int jpeg2000_get_state(int x1, int x2, int width, int shift_by,
+static int jpeg2000_get_state(int x1, int x2, int stride, int shift_by,
  const uint8_t *block_states)
{
-return (block_states[(x1 + 1) * (width + 2) + (x2 + 1)] >> shift_by) & 1;
+return (block_states[(x1 + 1) * stride + (x2 + 1)] >> shift_by) & 1;
}

av_always_inline
-static void jpeg2000_modify_state(int x1, int x2, int width,
- int value, uint8_t *block_states)
+static void jpeg2000_modify_state(int x1, int x2, int stride,
+  int value, uint8_t *block_states)
{
-block_states[(x1 + 1) * (width + 2) + (x2 + 1)] |= value;
+block_states[(x1 + 1) * stride + (x2 + 1)] |= value;
}

av_always_inline
@@ -528,8 +528,8 @@ static int jpeg2000_decode_ht_cleanup_segment(const 
Jpeg2000DecoderContext *s,
  StateVars *mel_stream, StateVars 
*vlc_stream,
  StateVars *mag_sgn_stream, const 
uint8_t *Dcup,
  uint32_t Lcup, uint32_t Pcup, 
uint8_t pLSB,
-  int width, int height, int32_t 
*sample_buf,
-  uint8_t *block_states)
+  int width, int height, const int 
stride,
+  int32_t *sample_buf, uint8_t 
*block_states)
{
uint16_t q  = 0; // Represents current quad position
uint16_t q1, q2;
@@ -958,32 +958,32 @@ static int jpeg2000_decode_ht_cleanup_segment(const 
Jpeg2000DecoderContext *s,
j1 = 2 * y;
j2 = 2 * x;

-sample_buf[j2 + (j1 * width)] = (int32_t)*mu;
-jpeg2000_modify_state(j1, j2, width, *sigma, block_states);
+sample_buf[j2 + (j1 * stride)] = (int32_t)*mu;
+jpeg2000_modify_state(j1, j2, stride, *sigma, block_states);
sigma += 1;
mu += 1;

x1 = y != quad_height - 1 || is_border_y == 0;
-sample_buf[j2 + ((j1 + 1) * width)] = ((int32_t)*mu) * x1;
-jpeg2000_modify_state(j1 + 1, j2, width, (*sigma) * x1, 
block_states);
+sample_buf[j2 + ((j1 + 1) * stride)] = ((int32_t)*mu) * x1;
+jpeg2000_modify_state(j1 + 1, j2, stride, (*sigma) * x1, 
block_states);
sigma += 1;
mu += 1;

x2 = x != quad_width - 1 || is_border_x == 0;
-sample_buf[(j2 + 1) + (j1 * width)] = ((int32_t)*mu) * x2;
-jpeg2000_modify_state(j1, j2 + 1, width, (*sigma) * x2, 
block_states);
+sample_buf[(j2 + 1) + (j1 * stride)] = ((int32_t)*mu) * x2;
+jpeg2000_modify_state(j1, j2 + 1, stride, (*sigma) * x2, 
block_states);
sigma += 1;
mu += 1;

x3 = x1 | x2;
-sample_buf[(j2 + 1) + (j1 + 1) * width] = ((int32_t)*mu) * x3;
-jpeg2000_modify_state(j1 + 1, j2 + 1, width, (*sigma) * x3, 
block_states);
+sample_buf[(j2 + 1) + (j1 + 1) * stride] = ((int32_t)*mu) * x3;
+jpeg2000_modify_state(j1 + 1, j2 + 1, stride, (*sigma) * x3, 
block_states);
sigma += 1;
mu += 1;
}
}
ret = 1;
-free:
+free:
av_freep(_n);
av_freep();
av_freep(_n);
@@ -992,39 +992,39 @@ free:

static void jpeg2000_calc_mbr(uint8_t *mbr, const uint16_t i, const uint16_t j,
  const uint32_t mbr_info, uint8_t causal_cond,
-  uint8_t *block_states, int width)
+  uint8_t *block_states, int stride)
{
int local_mbr = 0;

-local_mbr |= jpeg2000_get_state(i - 1, j - 1, width, HT_SHIFT_SIGMA, 
block_states);
-local_mbr |= jpeg2000_get_state(i - 1, j + 0, width, HT_SHIFT_SIGMA, 
block_states);
-local_mbr |= jpeg2000_get_state(i - 1, j + 1, width, HT_SHIFT_SIGMA, 
block_states);
+local_mbr |= jpeg2000_get_state(i - 1, j 

Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-17 Thread Rémi Denis-Courmont


Le 17 mai 2024 21:50:20 GMT+03:00, Michael Niedermayer  
a écrit :
>Let me reword this for 2024:
>The people on the booth are predominantly male. Similarly ffmpeg-devel
>is predominantly male. More gender diversity would be good.

As you've noted, this is an obvious problem but not an FFmpeg-specific problem. 
It is a industry -wide problem, and to a large extent even a problem for all of 
STEM.

I don't think that paying people, specifically women, to staff FFmpeg booths 
would do any good. At best that would be putting the cart before the horse. 
Instead, we should get more females involved in the project, and that should 
naturally increase the ratio of women representing FFmpeg at events.

With that noted, I don't think that this has or should have anything to do with 
STF. Judging by the name, it is meant to improve tech for the German people and 
the world at large. There are other funds to address the underrepresentation of 
women in OSS, and by all means, engage with them if you want funding for that.
___
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] test/jpeg2000dec: regenerate ds0_ht_01_b11 (HTJ2K lossless)

2024-05-17 Thread Andreas Rheinhardt
WATANABE Osamu:
> Signed-off-by: Pierre-Anthony Lemieux 
> ---
> tests/ref/fate/jpeg2000dec-ds0_ht_01_b11 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11 
> b/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11
> index af3eaa086d..d923cc2109 100644
> --- a/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11
> +++ b/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11
> @@ -3,4 +3,4 @@
> #codec_id 0: rawvideo
> #dimensions 0: 128x128
> #sar 0: 0/1
> -0,  0,  0,1,16384, 0x44426324
> +0,  0,  0,1,16384, 0x04a3647e

If a commit necessitates changing fate ref files, then said changes need
to be part of the patch and not in separate commits (so that fate passes
with each patch of a patchset).

- Andreas

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

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


[FFmpeg-devel] [PATCH] avcodec/tiff: Fix leak on error

2024-05-17 Thread Andreas Rheinhardt
Fixes Coverity issue #1516957.

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

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 19301d9e49..111ce3ea3a 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -2267,8 +2267,10 @@ again:
 group_size = s->width * channels;
 
 tmpbuf = av_malloc(ssize);
-if (!tmpbuf)
+if (!tmpbuf) {
+av_free(five_planes);
 return AVERROR(ENOMEM);
+}
 
 if (s->avctx->pix_fmt == AV_PIX_FMT_RGBF32LE ||
 s->avctx->pix_fmt == AV_PIX_FMT_RGBAF32LE) {
-- 
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/2] test/jpeg2000dec: regenerate ds0_ht_01_b11 (HTJ2K lossless)

2024-05-17 Thread WATANABE Osamu
Signed-off-by: Pierre-Anthony Lemieux 
---
tests/ref/fate/jpeg2000dec-ds0_ht_01_b11 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11 
b/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11
index af3eaa086d..d923cc2109 100644
--- a/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11
+++ b/tests/ref/fate/jpeg2000dec-ds0_ht_01_b11
@@ -3,4 +3,4 @@
#codec_id 0: rawvideo
#dimensions 0: 128x128
#sar 0: 0/1
-0,  0,  0,1,16384, 0x44426324
+0,  0,  0,1,16384, 0x04a3647e
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: fix HT block decoder issue #10905

2024-05-17 Thread WATANABE Osamu
Signed-off-by: Pierre-Anthony Lemieux 
---
libavcodec/jpeg2000htdec.c | 122 +++--
1 file changed, 62 insertions(+), 60 deletions(-)

diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c
index fa704b665e..62f70c32a8 100644
--- a/libavcodec/jpeg2000htdec.c
+++ b/libavcodec/jpeg2000htdec.c
@@ -196,7 +196,7 @@ static void jpeg2000_bitbuf_refill_forward(StateVars 
*buffer, const uint8_t *arr
while (buffer->bits_left < 32) {
buffer->tmp = 0xFF;
buffer->bits = (buffer->last == 0xFF) ? 7 : 8;
-if (buffer->pos <= length) {
+if (buffer->pos < length) {
buffer->tmp = array[buffer->pos];
buffer->pos += 1;
buffer->last = buffer->tmp;
@@ -508,17 +508,17 @@ static int jpeg2000_decode_sig_emb(const 
Jpeg2000DecoderContext *s, MelDecoderSt
}

av_always_inline
-static int jpeg2000_get_state(int x1, int x2, int width, int shift_by,
+static int jpeg2000_get_state(int x1, int x2, int stride, int shift_by,
  const uint8_t *block_states)
{
-return (block_states[(x1 + 1) * (width + 2) + (x2 + 1)] >> shift_by) & 1;
+return (block_states[(x1 + 1) * stride + (x2 + 1)] >> shift_by) & 1;
}

av_always_inline
-static void jpeg2000_modify_state(int x1, int x2, int width,
- int value, uint8_t *block_states)
+static void jpeg2000_modify_state(int x1, int x2, int stride,
+  int value, uint8_t *block_states)
{
-block_states[(x1 + 1) * (width + 2) + (x2 + 1)] |= value;
+block_states[(x1 + 1) * stride + (x2 + 1)] |= value;
}

av_always_inline
@@ -528,8 +528,8 @@ static int jpeg2000_decode_ht_cleanup_segment(const 
Jpeg2000DecoderContext *s,
  StateVars *mel_stream, StateVars 
*vlc_stream,
  StateVars *mag_sgn_stream, const 
uint8_t *Dcup,
  uint32_t Lcup, uint32_t Pcup, 
uint8_t pLSB,
-  int width, int height, int32_t 
*sample_buf,
-  uint8_t *block_states)
+  int width, int height, const int 
stride,
+  int32_t *sample_buf, uint8_t 
*block_states)
{
uint16_t q  = 0; // Represents current quad position
uint16_t q1, q2;
@@ -958,32 +958,32 @@ static int jpeg2000_decode_ht_cleanup_segment(const 
Jpeg2000DecoderContext *s,
j1 = 2 * y;
j2 = 2 * x;

-sample_buf[j2 + (j1 * width)] = (int32_t)*mu;
-jpeg2000_modify_state(j1, j2, width, *sigma, block_states);
+sample_buf[j2 + (j1 * stride)] = (int32_t)*mu;
+jpeg2000_modify_state(j1, j2, stride, *sigma, block_states);
sigma += 1;
mu += 1;

x1 = y != quad_height - 1 || is_border_y == 0;
-sample_buf[j2 + ((j1 + 1) * width)] = ((int32_t)*mu) * x1;
-jpeg2000_modify_state(j1 + 1, j2, width, (*sigma) * x1, 
block_states);
+sample_buf[j2 + ((j1 + 1) * stride)] = ((int32_t)*mu) * x1;
+jpeg2000_modify_state(j1 + 1, j2, stride, (*sigma) * x1, 
block_states);
sigma += 1;
mu += 1;

x2 = x != quad_width - 1 || is_border_x == 0;
-sample_buf[(j2 + 1) + (j1 * width)] = ((int32_t)*mu) * x2;
-jpeg2000_modify_state(j1, j2 + 1, width, (*sigma) * x2, 
block_states);
+sample_buf[(j2 + 1) + (j1 * stride)] = ((int32_t)*mu) * x2;
+jpeg2000_modify_state(j1, j2 + 1, stride, (*sigma) * x2, 
block_states);
sigma += 1;
mu += 1;

x3 = x1 | x2;
-sample_buf[(j2 + 1) + (j1 + 1) * width] = ((int32_t)*mu) * x3;
-jpeg2000_modify_state(j1 + 1, j2 + 1, width, (*sigma) * x3, 
block_states);
+sample_buf[(j2 + 1) + (j1 + 1) * stride] = ((int32_t)*mu) * x3;
+jpeg2000_modify_state(j1 + 1, j2 + 1, stride, (*sigma) * x3, 
block_states);
sigma += 1;
mu += 1;
}
}
ret = 1;
-free:
+free:
av_freep(_n);
av_freep();
av_freep(_n);
@@ -992,39 +992,39 @@ free:

static void jpeg2000_calc_mbr(uint8_t *mbr, const uint16_t i, const uint16_t j,
  const uint32_t mbr_info, uint8_t causal_cond,
-  uint8_t *block_states, int width)
+  uint8_t *block_states, int stride)
{
int local_mbr = 0;

-local_mbr |= jpeg2000_get_state(i - 1, j - 1, width, HT_SHIFT_SIGMA, 
block_states);
-local_mbr |= jpeg2000_get_state(i - 1, j + 0, width, HT_SHIFT_SIGMA, 
block_states);
-local_mbr |= jpeg2000_get_state(i - 1, j + 1, width, HT_SHIFT_SIGMA, 
block_states);
+local_mbr |= jpeg2000_get_state(i - 1, j - 1, stride, HT_SHIFT_SIGMA, 
block_states);
+

[FFmpeg-devel] [PATCH] avutil/hwcontext_qsv: fix GCC 14.1 warnings

2024-05-17 Thread Oleg Tolmatcev
This patch fixes warnings produced by GCC 14.1 in hwcontext_qsv.c. It
fixes the issue https://trac.ffmpeg.org/ticket/11004.

Best regards
Oleg Tolmatcev


0001-avutil-hwcontext_qsv-fix-GCC-14.1-warnings.patch
Description: Binary data
___
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] fftools/ffmpeg_filter: Fix leak on error

2024-05-17 Thread Andreas Rheinhardt
Do this by attaching the FilterGraph directly to more permanent
storage from which it will be automatically freed.
Fixes Coverity issue #1596533.

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

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 382d0f75b1..12cca684b4 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1198,10 +1198,10 @@ int init_simple_filtergraph(InputStream *ist, 
OutputStream *ost,
 FilterGraphPriv *fgp;
 int ret;
 
-ret = fg_create(, graph_desc, sch);
+ret = fg_create(>fg_simple, graph_desc, sch);
 if (ret < 0)
 return ret;
-ost->fg_simple = fg;
+fg  = ost->fg_simple;
 fgp = fgp_from_fg(fg);
 
 fgp->is_simple = 1;
-- 
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] avfilter/vf_dnn_detect: Fix segfault on init error

2024-05-17 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_dnn_detect.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index bacea3ef29..56206d6f9f 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -808,11 +808,13 @@ static av_cold void dnn_detect_uninit(AVFilterContext 
*context)
 DnnDetectContext *ctx = context->priv;
 AVDetectionBBox *bbox;
 ff_dnn_uninit(>dnnctx);
-while(av_fifo_can_read(ctx->bboxes_fifo)) {
-av_fifo_read(ctx->bboxes_fifo, , 1);
-av_freep();
+if (ctx->bboxes_fifo) {
+while (av_fifo_can_read(ctx->bboxes_fifo)) {
+av_fifo_read(ctx->bboxes_fifo, , 1);
+av_freep();
+}
+av_fifo_freep2(>bboxes_fifo);
 }
-av_fifo_freep2(>bboxes_fifo);
 av_freep(>anchors);
 free_detect_labels(ctx);
 }
-- 
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] [RFC] STF 2025

2024-05-17 Thread Derek Buitenhuis
On 5/17/2024 7:50 PM, Michael Niedermayer wrote:
> The people on the booth are predominantly male. Similarly ffmpeg-devel
> is predominantly male. More gender diversity would be good.

That I can agree with.

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

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


Re: [FFmpeg-devel] [PATCH v3 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-17 Thread Kieran Kunhya
In this project we prefer internal decoders to external libs.

On Fri, 17 May 2024, 18:20 Cosmin Stejerean via ffmpeg-devel, <
ffmpeg-devel@ffmpeg.org> wrote:

>
>
> > On May 14, 2024, at 9:28 AM, Lynne via ffmpeg-devel <
> ffmpeg-devel@ffmpeg.org> wrote:
> >
> > On 14/05/2024 17:09, Christian Bartnik wrote:
> >> From: Thomas Siedel 
> >> Add external decoder VVdeC for H266/VVC decoding.
> >> Register new decoder libvvdec.
> >> 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
> >
> > I would prefer to have this one skipped, as initially suggested.
>
> Why? I tried to look back through the list but didn't see anything.
>
> - Cosmin
>
___
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] [RFC] STF 2025

2024-05-17 Thread Michael Niedermayer
On Fri, May 17, 2024 at 11:08:17AM -0400, Vittorio Giovara wrote:
> On Fri, May 17, 2024 at 9:50 AM Michael Niedermayer 
> wrote:
> 
> > Hi all
> >
> > Before this is forgotten again, better start some dicsussion too early
> > than too late
> >
> > I propose that if we have the oppertunity again next year to receive a
> > grant
> > from STF. That we use it to fund:
> >
> > * Paul to work on FFmpeg full time. My idea here is that he can work on
> > whatever
> >   he likes in FFmpeg (so its not full time employment for specific work but
> >   simply full time employment for him to work on whatever he likes in
> > FFmpeg any
> >   way he likes) Paul is the 2nd largest contributor to FFmpeg (git
> > shortlog -s -n)
> >
> 
> why? nothing against Paul, but this seems pretty arbitrary, and many people
> would like to be paid to do whatever they want
> if we start sponsoring people there should be clear statements of work,
> goals, and everything in between

Sure, my goal is to have the whole team payed eventually to work on FFmpeg.
Paul is the most important ATM, he is the biggest contributor who stopped
contributing.

If it would succeed to fund him. I would suggest to repeat this with more
people.

The problem with "clear goals" is that paul without any rules or goals
did work on exactly what made sense for FFmpeg, I dont think adding any
rules will make this better.


> 
> * Fund administrative / maintainance work (one example is the mailman
> > upgrade that is needed
> >   with the next OS upgrade on one of our servers (this is not as trivial
> > as one might
> >   expect). Another example here may be some git related tools if we find
> > something that
> >   theres a broad consensus about.
> >
> > * Fund maintaince on the bug tracker, try to reproduce bugs, ask users to
> > provide
> >   reproduceable cases, close bugs still unreproduceable, ...
> >   ATM we have over 2000 "new" bugs that are not even marked as open
> >
> 
> I see no mention of github/gitlab work, despite being highly requested on
> the list.
> Is it because we assume it'll be done already by next year? :)

that was supposed to be part of "git related tools"

thx

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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

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


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-17 Thread Michael Niedermayer
On Fri, May 17, 2024 at 04:26:55PM +0100, Derek Buitenhuis wrote:
> On 5/17/2024 2:49 PM, Michael Niedermayer wrote:
> > Also we need more cute girls on these events, everything i hear
> > its 100% male geeks/hackers.
> 
> This is gross and sexist.

This was definitly not meant to be either of that.

Let me reword this for 2024:
The people on the booth are predominantly male. Similarly ffmpeg-devel
is predominantly male. More gender diversity would be good.

And lets have some cute puppies and other animals on the booth as they
might attract some additional visitors.

Thx

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

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.


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] avformat/flacdec: Reorder allocations to avoid leak on error

2024-05-17 Thread Andreas Rheinhardt
Fixes Coverity issue #1591795.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/flacdec.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 3d35da5fea..3c317acaee 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -283,12 +283,6 @@ static av_unused int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
 if (avio_seek(s->pb, *ppos, SEEK_SET) < 0)
 return AV_NOPTS_VALUE;
 
-parser = av_parser_init(st->codecpar->codec_id);
-if (!parser){
-return AV_NOPTS_VALUE;
-}
-parser->flags |= PARSER_FLAG_USE_CODEC_TS;
-
 if (!flac->parser_dec) {
 flac->parser_dec = avcodec_alloc_context3(NULL);
 if (!flac->parser_dec)
@@ -299,6 +293,11 @@ static av_unused int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
 return ret;
 }
 
+parser = av_parser_init(st->codecpar->codec_id);
+if (!parser)
+return AV_NOPTS_VALUE;
+parser->flags |= PARSER_FLAG_USE_CODEC_TS;
+
 for (;;){
 uint8_t *data;
 int size;
-- 
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/2] avcodec/ac3enc: Move transient PutBitContext to stack

2024-05-17 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3enc.c  | 187 ++-
 libavcodec/ac3enc.h  |   6 +-
 libavcodec/eac3enc.c | 123 ++--
 3 files changed, 159 insertions(+), 157 deletions(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 1a869ab865..3649289865 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1634,63 +1634,63 @@ static void ac3_quantize_mantissas(AC3EncodeContext *s)
 /*
  * Write the AC-3 frame header to the output bitstream.
  */
-static void ac3_output_frame_header(AC3EncodeContext *s)
+static void ac3_output_frame_header(AC3EncodeContext *s, PutBitContext *pb)
 {
 AC3EncOptions *opt = >options;
 
-put_bits(>pb, 16, 0x0b77);   /* frame header */
-put_bits(>pb, 16, 0);/* crc1: will be filled later */
-put_bits(>pb, 2,  s->bit_alloc.sr_code);
-put_bits(>pb, 6,  s->frame_size_code + (s->frame_size - 
s->frame_size_min) / 2);
-put_bits(>pb, 5,  s->bitstream_id);
-put_bits(>pb, 3,  s->bitstream_mode);
-put_bits(>pb, 3,  s->channel_mode);
+put_bits(pb, 16, 0x0b77);   /* frame header */
+put_bits(pb, 16, 0);/* crc1: will be filled later */
+put_bits(pb, 2,  s->bit_alloc.sr_code);
+put_bits(pb, 6,  s->frame_size_code + (s->frame_size - s->frame_size_min) 
/ 2);
+put_bits(pb, 5,  s->bitstream_id);
+put_bits(pb, 3,  s->bitstream_mode);
+put_bits(pb, 3,  s->channel_mode);
 if ((s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO)
-put_bits(>pb, 2, s->center_mix_level);
+put_bits(pb, 2, s->center_mix_level);
 if (s->channel_mode & 0x04)
-put_bits(>pb, 2, s->surround_mix_level);
+put_bits(pb, 2, s->surround_mix_level);
 if (s->channel_mode == AC3_CHMODE_STEREO)
-put_bits(>pb, 2, opt->dolby_surround_mode);
-put_bits(>pb, 1, s->lfe_on); /* LFE */
-put_bits(>pb, 5, -opt->dialogue_level);
-put_bits(>pb, 1, 0); /* no compression control word */
-put_bits(>pb, 1, 0); /* no lang code */
-put_bits(>pb, 1, opt->audio_production_info);
+put_bits(pb, 2, opt->dolby_surround_mode);
+put_bits(pb, 1, s->lfe_on); /* LFE */
+put_bits(pb, 5, -opt->dialogue_level);
+put_bits(pb, 1, 0); /* no compression control word */
+put_bits(pb, 1, 0); /* no lang code */
+put_bits(pb, 1, opt->audio_production_info);
 if (opt->audio_production_info) {
-put_bits(>pb, 5, opt->mixing_level - 80);
-put_bits(>pb, 2, opt->room_type);
+put_bits(pb, 5, opt->mixing_level - 80);
+put_bits(pb, 2, opt->room_type);
 }
-put_bits(>pb, 1, opt->copyright);
-put_bits(>pb, 1, opt->original);
+put_bits(pb, 1, opt->copyright);
+put_bits(pb, 1, opt->original);
 if (s->bitstream_id == 6) {
 /* alternate bit stream syntax */
-put_bits(>pb, 1, opt->extended_bsi_1);
+put_bits(pb, 1, opt->extended_bsi_1);
 if (opt->extended_bsi_1) {
-put_bits(>pb, 2, opt->preferred_stereo_downmix);
-put_bits(>pb, 3, s->ltrt_center_mix_level);
-put_bits(>pb, 3, s->ltrt_surround_mix_level);
-put_bits(>pb, 3, s->loro_center_mix_level);
-put_bits(>pb, 3, s->loro_surround_mix_level);
+put_bits(pb, 2, opt->preferred_stereo_downmix);
+put_bits(pb, 3, s->ltrt_center_mix_level);
+put_bits(pb, 3, s->ltrt_surround_mix_level);
+put_bits(pb, 3, s->loro_center_mix_level);
+put_bits(pb, 3, s->loro_surround_mix_level);
 }
-put_bits(>pb, 1, opt->extended_bsi_2);
+put_bits(pb, 1, opt->extended_bsi_2);
 if (opt->extended_bsi_2) {
-put_bits(>pb, 2, opt->dolby_surround_ex_mode);
-put_bits(>pb, 2, opt->dolby_headphone_mode);
-put_bits(>pb, 1, opt->ad_converter_type);
-put_bits(>pb, 9, 0); /* xbsi2 and encinfo : reserved */
+put_bits(pb, 2, opt->dolby_surround_ex_mode);
+put_bits(pb, 2, opt->dolby_headphone_mode);
+put_bits(pb, 1, opt->ad_converter_type);
+put_bits(pb, 9, 0); /* xbsi2 and encinfo : reserved */
 }
 } else {
-put_bits(>pb, 1, 0); /* no time code 1 */
-put_bits(>pb, 1, 0); /* no time code 2 */
+put_bits(pb, 1, 0); /* no time code 1 */
+put_bits(pb, 1, 0); /* no time code 2 */
 }
-put_bits(>pb, 1, 0); /* no additional bit stream info */
+put_bits(pb, 1, 0); /* no additional bit stream info */
 }
 
 
 /*
  * Write one audio block to the output bitstream.
  */
-static void output_audio_block(AC3EncodeContext *s, int blk)
+static void output_audio_block(AC3EncodeContext *s, PutBitContext *pb, int blk)
 {
 int ch, i, baie, bnd, got_cpl, av_uninit(ch0);
 AC3Block *block = >blocks[blk];
@@ -1698,48 +1698,48 @@ static void 

[FFmpeg-devel] [PATCH 1/2] avcodec/ac3enc_template: Avoid always-true check

2024-05-17 Thread Andreas Rheinhardt
This might also help Coverity with issue #1596532.

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

diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 49fc6d7f37..049666fdca 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -31,6 +31,7 @@
 #include 
 
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "libavutil/mem_internal.h"
 
 #include "audiodsp.h"
@@ -50,14 +51,15 @@
  */
 static void apply_mdct(AC3EncodeContext *s, uint8_t * const *samples)
 {
-int blk, ch;
+av_assert1(s->num_blocks > 0);
 
-for (ch = 0; ch < s->channels; ch++) {
+for (int ch = 0; ch < s->channels; ch++) {
 const SampleType *input_samples0 = (const 
SampleType*)s->planar_samples[ch];
 /* Reorder channels from native order to AC-3 order. */
 const SampleType *input_samples1 = (const 
SampleType*)samples[s->channel_map[ch]];
+int blk = 0;
 
-for (blk = 0; blk < s->num_blocks; blk++) {
+do {
 AC3Block *block = >blocks[blk];
 SampleType *windowed_samples = s->RENAME(windowed_samples);
 
@@ -71,7 +73,8 @@ static void apply_mdct(AC3EncodeContext *s, uint8_t * const 
*samples)
  windowed_samples, sizeof(*windowed_samples));
 input_samples0  = input_samples1;
 input_samples1 += AC3_BLOCK_SIZE;
-}
+} while (++blk < s->num_blocks);
+
 /* Store last 256 samples of current frame */
 memcpy(s->planar_samples[ch], input_samples0,
AC3_BLOCK_SIZE * sizeof(*input_samples0));
-- 
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 v3 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-17 Thread Cosmin Stejerean via ffmpeg-devel


> On May 14, 2024, at 9:28 AM, Lynne via ffmpeg-devel  
> wrote:
> 
> On 14/05/2024 17:09, Christian Bartnik wrote:
>> From: Thomas Siedel 
>> Add external decoder VVdeC for H266/VVC decoding.
>> Register new decoder libvvdec.
>> 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
> 
> I would prefer to have this one skipped, as initially suggested.

Why? I tried to look back through the list but didn't see anything.

- Cosmin
___
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/1] lavc/vc1dsp: R-V V vc1_unescape_buffer

2024-05-17 Thread Rémi Denis-Courmont
Notes:
- The loop is biased toward no unescaped bytes as that should be most common.
- The input byte array is slid rather than the (8 times smaller) bit-mask,
  as RISC-V V does not provide a bit-mask (or bit-wise) slide instruction.
- There are two comparisons with 0 per iteration, for the same reason.
- In case of match, bytes are copied until the first match, and the loop is
  restarted after the escape byte. Vector compression (vcompress.vm) could
  discard all escape bytes but that is be slower if escape bytes are rare.

T-Head C908:
vc1dsp.vc1_unescape_buffer_c:  12749.5
vc1dsp.vc1_unescape_buffer_rvv_i32: 6009.0
---
 libavcodec/riscv/vc1dsp_init.c |  2 ++
 libavcodec/riscv/vc1dsp_rvv.S  | 53 ++
 2 files changed, 55 insertions(+)

diff --git a/libavcodec/riscv/vc1dsp_init.c b/libavcodec/riscv/vc1dsp_init.c
index 8ef0c1f40f..f105a3a3c6 100644
--- a/libavcodec/riscv/vc1dsp_init.c
+++ b/libavcodec/riscv/vc1dsp_init.c
@@ -35,6 +35,7 @@ void ff_avg_pixels16x16_rvv(uint8_t *dst, const uint8_t *src, 
ptrdiff_t line_siz
 void ff_avg_pixels8x8_rvv(uint8_t *dst, const uint8_t *src, ptrdiff_t 
line_size, int rnd);
 int ff_startcode_find_candidate_rvb(const uint8_t *, int);
 int ff_startcode_find_candidate_rvv(const uint8_t *, int);
+int ff_vc1_unescape_buffer_rvv(const uint8_t *, int, uint8_t *);
 
 av_cold void ff_vc1dsp_init_riscv(VC1DSPContext *dsp)
 {
@@ -62,6 +63,7 @@ av_cold void ff_vc1dsp_init_riscv(VC1DSPContext *dsp)
 }
 }
 dsp->startcode_find_candidate = ff_startcode_find_candidate_rvv;
+dsp->vc1_unescape_buffer = ff_vc1_unescape_buffer_rvv;
 }
 # endif
 #endif
diff --git a/libavcodec/riscv/vc1dsp_rvv.S b/libavcodec/riscv/vc1dsp_rvv.S
index 7c2b47f66c..1166f35cad 100644
--- a/libavcodec/riscv/vc1dsp_rvv.S
+++ b/libavcodec/riscv/vc1dsp_rvv.S
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2023 Institue of Software Chinese Academy of Sciences (ISCAS).
+ * Copyright (c) 2024 Rémi Denis-Courmont.
  *
  * This file is part of FFmpeg.
  *
@@ -159,3 +160,55 @@ func ff_avg_pixels8x8_rvv, zve64x
 
 ret
 endfunc
+
+func ff_vc1_unescape_buffer_rvv, zve32x
+vsetivli   zero, 2, e8, m1, ta, ma
+vmv.v.iv8, -1
+li t4, 1
+vmv.v.iv12, -1
+li t3, -1
+mv t5, a2
+blez   a1, 3f
+1:
+vsetvlit0, a1, e8, m4, ta, ma
+vle8.v v16, (a0)
+vslideup.viv8, v16, 2
+addi   t0, t0, -1 # we cannot fully process the last element
+vslideup.viv12, v16, 1
+vslide1down.vx v20, v16, t3
+vsetvlizero, t0, e8, m4, ta, ma
+vmseq.vi   v0, v8, 0
+vmseq.vi   v1, v12, 0
+vmseq.vi   v2, v16, 3
+vmand.mm   v0, v0, v1
+vmsltu.vi  v3, v20, 4
+vmand.mm   v0, v0, v2
+vmand.mm   v0, v0, v3
+vfirst.m   t2, v0
+bgez   t2, 4f # found an escape byte?
+
+vse8.v v16, (a2)
+addi   t2, t0, -2
+adda2, a2, t0
+2:
+vslidedown.vx  v8, v16, t2
+suba1, a1, t0
+vslidedown.vi  v12, v8, 1
+adda0, a0, t0
+bgtu   a1, t4, 1b // size > 1
+
+lb t0, (a0)
+sb t0, (a2) # copy last byte (cannot be escaped)
+addi   a2, a2, 1
+3:
+suba0, a2, t5
+ret
+4:
+vsetvlizero, t2, e8, m4, ta, ma
+vse8.v v16, (a2)
+addi   t0, t2, 1
+adda2, a2, t2
+addi   t2, t2, -1
+vsetvlizero, t0, e8, m4, ta, ma
+j  2b
+endfunc
-- 
2.43.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 3/6] avformat/tee: Constify AVDictionaryEntry* pointee where possible

2024-05-17 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> This is in preparation for using av_dict_iterate().
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/tee.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 1cbbb80dbb..87159681ed 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
> TeeSlave *tee_slave)
>  {
>  int i, ret;
>  AVDictionary *options = NULL, *bsf_options = NULL;
> -AVDictionaryEntry *entry;
> +const AVDictionaryEntry *entry;
>  char *filename;
>  char *format = NULL, *select = NULL, *on_fail = NULL;
>  char *use_fifo = NULL, *fifo_options_str = NULL;
> @@ -172,8 +172,9 @@ static int open_slave(AVFormatContext *avf, char *slave, 
> TeeSlave *tee_slave)
>  return ret;
>  
>  #define CONSUME_OPTION(option, field, action) do {  \
> -if ((entry = av_dict_get(options, option, NULL, 0))) {  \
> -field = entry->value;   \
> +AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0);  \
> +if (en) {   \
> +field = en->value;  \
>  { action }  \
>  av_dict_set(, option, NULL, 0); \
>  }   \

Added the following necessary diff from the next patch locally:

-   entry->value = NULL; /* prevent it from being freed */)
+   en->value = NULL; /* prevent it from being freed */)

- Andreas

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

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


Re: [FFmpeg-devel] [PATCH v3 5/9] lavc/vp9dsp: R-V V mc avg

2024-05-17 Thread flow gg
yeah, updated it in the reply

Rémi Denis-Courmont  于2024年5月17日周五 23:11写道:

> Le maanantaina 13. toukokuuta 2024, 19.59.22 EEST u...@foxmail.com a
> écrit :
> > From: sunyuechi 
> >
> > C908:
> > vp9_avg4_8bpp_c: 1.2
> > vp9_avg4_8bpp_rvv_i64: 1.0
> > vp9_avg8_8bpp_c: 3.7
> > vp9_avg8_8bpp_rvv_i64: 1.5
> > vp9_avg16_8bpp_c: 14.7
> > vp9_avg16_8bpp_rvv_i64: 3.5
> > vp9_avg32_8bpp_c: 57.7
> > vp9_avg32_8bpp_rvv_i64: 10.0
> > vp9_avg64_8bpp_c: 229.0
> > vp9_avg64_8bpp_rvv_i64: 31.7
> > ---
> >  libavcodec/riscv/Makefile  |  3 +-
> >  libavcodec/riscv/vp9_mc_rvv.S  | 58 ++
> >  libavcodec/riscv/vp9dsp_init.c | 18 +++
> >  3 files changed, 78 insertions(+), 1 deletion(-)
> >  create mode 100644 libavcodec/riscv/vp9_mc_rvv.S
> >
> > diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
> > index 0cd900104f..1183357b37 100644
> > --- a/libavcodec/riscv/Makefile
> > +++ b/libavcodec/riscv/Makefile
> > @@ -64,6 +64,7 @@ RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
> >  OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
> >  RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \
> >   riscv/vp9_mc_rvi.o
> > -RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o
> > +RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
> > +  riscv/vp9_mc_rvv.o
> >  OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
> >  RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
> > diff --git a/libavcodec/riscv/vp9_mc_rvv.S
> b/libavcodec/riscv/vp9_mc_rvv.S
> > new file mode 100644
> > index 00..5d917e7b98
> > --- /dev/null
> > +++ b/libavcodec/riscv/vp9_mc_rvv.S
> > @@ -0,0 +1,58 @@
> > +/*
> > + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences
> > (ISCAS). + *
> > + * 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/riscv/asm.S"
> > +
> > +.macro vsetvlstatic8 len an maxlen mn=m4
> > +.if \len == 4
> > +vsetivlizero, \len, e8, mf4, ta, ma
> > +.elseif \len == 8
> > +vsetivlizero, \len, e8, mf2, ta, ma
> > +.elseif \len == 16
> > +vsetivlizero, \len, e8, m1, ta, ma
> > +.elseif \len == 32
> > +li  \an, \len
> > +vsetvli zero, \an, e8, m2, ta, ma
> > +.elseif \len == 64
> > +li  \an, \maxlen
> > +vsetvli zero, \an, e8, \mn, ta, ma
> > +.endif
> > +.endm
> > +
> > +.macro copy_avg len
> > +func ff_avg\len\()_rvv, zve32x
> > +csrwi   vxrm, 0
> > +vsetvlstatic8   \len t0 64
> > +1:
> > +addia4, a4, -1
> > +vle8.v  v8, (a2)
> > +vle8.v  v16, (a0)
> > +vaaddu.vv   v8, v8, v16
> > +vse8.v  v8, (a0)
> > +add a2, a2, a3
> > +add a0, a0, a1
> > +bneza4, 1b
> > +ret
>
> Doesn't this get slightly faster by interleaving scalar and vector
> instructions?
>
> > +endfunc
> > +.endm
> > +
> > +.irp len 64, 32, 16, 8, 4
> > +copy_avg \len
> > +.endr
> > diff --git a/libavcodec/riscv/vp9dsp_init.c
> b/libavcodec/riscv/vp9dsp_init.c
> > index 184fadbaf7..1922484a1d 100644
> > --- a/libavcodec/riscv/vp9dsp_init.c
> > +++ b/libavcodec/riscv/vp9dsp_init.c
> > @@ -48,6 +48,24 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext
> > *dsp, int bpp) }
> >  # endif
> >
> > +#if HAVE_RVV
> > +if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) &&
> ff_rv_vlen_least(128))
> > { +
> > +#define init_fpel(idx1, sz)   \
> > +dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv;  \
> > +dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv;  \
> > +dsp->mc[idx1][FILTER_8TAP_SHARP  ][1][0][0] = ff_avg##sz##_rvv;  \
> > +dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_avg##sz##_rvv
> > +
> > +init_fpel(0, 64);
> > +init_fpel(1, 32);
> > +init_fpel(2, 16);
> > +init_fpel(3, 8);
> > +init_fpel(4, 4);
> > +
> > +#undef init_fpel
> > +}
> > +#endif
> >  #endif
> >  }
>
>
> --
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/

[FFmpeg-devel] [PATCH 1/5] lavc/vp9dsp: R-V V mc avg

2024-05-17 Thread uk7b
From: sunyuechi 

C908:
vp9_avg4_8bpp_c: 1.2
vp9_avg4_8bpp_rvv_i64: 1.0
vp9_avg8_8bpp_c: 3.7
vp9_avg8_8bpp_rvv_i64: 1.5
vp9_avg16_8bpp_c: 14.7
vp9_avg16_8bpp_rvv_i64: 3.5
vp9_avg32_8bpp_c: 57.7
vp9_avg32_8bpp_rvv_i64: 10.0
vp9_avg64_8bpp_c: 229.0
vp9_avg64_8bpp_rvv_i64: 31.7
---
 libavcodec/riscv/Makefile  |  3 +-
 libavcodec/riscv/vp9_mc_rvv.S  | 58 ++
 libavcodec/riscv/vp9dsp_init.c | 18 +++
 3 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/riscv/vp9_mc_rvv.S

diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 27b268ae39..4739d83522 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -65,6 +65,7 @@ RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
 OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
 RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \
  riscv/vp9_mc_rvi.o
-RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o
+RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
+  riscv/vp9_mc_rvv.o
 OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
 RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
new file mode 100644
index 00..9ee7f04dd1
--- /dev/null
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS).
+ *
+ * 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/riscv/asm.S"
+
+.macro vsetvlstatic8 len an maxlen mn=m4
+.if \len == 4
+vsetivlizero, \len, e8, mf4, ta, ma
+.elseif \len == 8
+vsetivlizero, \len, e8, mf2, ta, ma
+.elseif \len == 16
+vsetivlizero, \len, e8, m1, ta, ma
+.elseif \len == 32
+li  \an, \len
+vsetvli zero, \an, e8, m2, ta, ma
+.elseif \len == 64
+li  \an, \maxlen
+vsetvli zero, \an, e8, \mn, ta, ma
+.endif
+.endm
+
+.macro copy_avg len
+func ff_avg\len\()_rvv, zve32x
+csrwi   vxrm, 0
+vsetvlstatic8   \len t0 64
+1:
+vle8.v  v8, (a2)
+vle8.v  v16, (a0)
+vaaddu.vv   v8, v8, v16
+addia4, a4, -1
+vse8.v  v8, (a0)
+add a2, a2, a3
+add a0, a0, a1
+bneza4, 1b
+ret
+endfunc
+.endm
+
+.irp len 64, 32, 16, 8, 4
+copy_avg \len
+.endr
diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
index ab99294d44..6bfe23563a 100644
--- a/libavcodec/riscv/vp9dsp_init.c
+++ b/libavcodec/riscv/vp9dsp_init.c
@@ -48,6 +48,24 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, 
int bpp)
 }
 # endif
 
+#if HAVE_RVV
+if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) {
+
+#define init_fpel(idx1, sz)   \
+dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv;  \
+dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv;  \
+dsp->mc[idx1][FILTER_8TAP_SHARP  ][1][0][0] = ff_avg##sz##_rvv;  \
+dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_avg##sz##_rvv
+
+init_fpel(0, 64);
+init_fpel(1, 32);
+init_fpel(2, 16);
+init_fpel(3, 8);
+init_fpel(4, 4);
+
+#undef init_fpel
+}
+#endif
 #endif
 }
 
-- 
2.45.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 5/6] avcodec/lib*, avformat/tee: Simplify iterating over AVDictionary

2024-05-17 Thread epirat07


On 17 May 2024, at 17:44, Andreas Rheinhardt wrote:

> epira...@gmail.com:
>>
>>
>> On 17 May 2024, at 17:25, Andreas Rheinhardt wrote:
>>
>>> Signed-off-by: Andreas Rheinhardt 
>>> ---
>>>  libavcodec/libaomenc.c  | 4 ++--
>>>  libavcodec/libkvazaar.c | 4 ++--
>>>  libavcodec/libsvtav1.c  | 6 +++---
>>>  libavcodec/libx264.c| 4 ++--
>>>  libavcodec/libx265.c| 4 ++--
>>>  libavformat/tee.c   | 4 ++--
>>>  6 files changed, 13 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
>>> index c39853c20f..dec74ebecd 100644
>>> --- a/libavcodec/libaomenc.c
>>> +++ b/libavcodec/libaomenc.c
>>> @@ -970,9 +970,9 @@ static av_cold int aom_init(AVCodecContext *avctx,
>>>
>>>  #if AOM_ENCODER_ABI_VERSION >= 23
>>>  {
>>> -AVDictionaryEntry *en = NULL;
>>> +const AVDictionaryEntry *en = NULL;
>>>
>>> -while ((en = av_dict_get(ctx->aom_params, "", en, 
>>> AV_DICT_IGNORE_SUFFIX))) {
>>> +while ((en = av_dict_iterate(ctx->aom_params, en))) {
>>>  int ret = aom_codec_set_option(>encoder, en->key, 
>>> en->value);
>>>  if (ret != AOM_CODEC_OK) {
>>>  log_encoder_error(avctx, en->key);
>>> diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
>>> index 0711d9ab38..cd731ae9d0 100644
>>> --- a/libavcodec/libkvazaar.c
>>> +++ b/libavcodec/libkvazaar.c
>>> @@ -111,8 +111,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  if (ctx->kvz_params) {
>>>  AVDictionary *dict = NULL;
>>>  if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
>>> -AVDictionaryEntry *entry = NULL;
>>> -while ((entry = av_dict_get(dict, "", entry, 
>>> AV_DICT_IGNORE_SUFFIX))) {
>>> +const AVDictionaryEntry *entry = NULL;
>>> +while ((entry = av_dict_iterate(dict, entry))) {
>>>  if (!api->config_parse(cfg, entry->key, entry->value)) {
>>>  av_log(avctx, AV_LOG_WARNING, "Invalid option: 
>>> %s=%s.\n",
>>> entry->key, entry->value);
>>> diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
>>> index 9bc165f0cf..2fef8c8971 100644
>>> --- a/libavcodec/libsvtav1.c
>>> +++ b/libavcodec/libsvtav1.c
>>> @@ -210,7 +210,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
>>> *param,
>>>  {
>>>  SvtContext *svt_enc = avctx->priv_data;
>>>  const AVPixFmtDescriptor *desc;
>>> -AVDictionaryEntry *en = NULL;
>>> +const AVDictionaryEntry av_unused *en = NULL;
>>>
>>>  // Update param from options
>>>  if (svt_enc->enc_mode >= -1)
>>> @@ -326,7 +326,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  handle_side_data(avctx, param);
>>>
>>>  #if SVT_AV1_CHECK_VERSION(0, 9, 1)
>>> -while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, 
>>> AV_DICT_IGNORE_SUFFIX))) {
>>> +while ((en = av_dict_iterate(svt_enc->svtav1_opts, en))) {
>>>  EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, 
>>> en->value);
>>>  if (ret != EB_ErrorNone) {
>>>  int level = (avctx->err_recognition & AV_EF_EXPLODE) ? 
>>> AV_LOG_ERROR : AV_LOG_WARNING;
>>> @@ -336,7 +336,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  }
>>>  }
>>>  #else
>>> -if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, 
>>> AV_DICT_IGNORE_SUFFIX))) {
>>> +if (av_dict_count(svt_enc->svtav1_opts)) {
>>>  int level = (avctx->err_recognition & AV_EF_EXPLODE) ? 
>>> AV_LOG_ERROR : AV_LOG_WARNING;
>>>  av_log(avctx, level, "svt-params needs libavcodec to be compiled 
>>> with SVT-AV1 "
>>>   "headers >= 0.9.1.\n");
>>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
>>> index 2715f277f1..29d1a7ccbc 100644
>>> --- a/libavcodec/libx264.c
>>> +++ b/libavcodec/libx264.c
>>> @@ -1385,8 +1385,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  x4->params.b_repeat_headers = 1;
>>>
>>>  {
>>> -AVDictionaryEntry *en = NULL;
>>> -while (en = av_dict_get(x4->x264_params, "", en, 
>>> AV_DICT_IGNORE_SUFFIX)) {
>>> +const AVDictionaryEntry *en = NULL;
>>> +while (en = av_dict_iterate(x4->x264_params, en)) {
>>
>> Missing pair of braces to make the compiler not warn about assignment in 
>> check, no?
>>
>
> I did not change the parentheses in this patch at all as doing so would
> be orthogonal to the patch. We use this style without the additional
> pair of parentheses everywhere and actually add -Wno-parentheses in
> configure (line 7429).

Indeed sorry, I had pulled parts of AVDict out of tree when I did a bunch of 
work
on it a while ago to easier test a lot of edge cases and debug things.

Any reason why we silence this, as just adding a pair of braces to make intent
clearer vs accidentally doing it wrong somewhere seems worth it…

Anyway, LGTM then for this patch, sorry for the noise.

>
>>> if ((ret = x264_param_parse(>params, en->key, en->value)) < 
>>> 0) {
>>> 

Re: [FFmpeg-devel] [PATCH 5/6] avcodec/lib*, avformat/tee: Simplify iterating over AVDictionary

2024-05-17 Thread Andreas Rheinhardt
epira...@gmail.com:
> 
> 
> On 17 May 2024, at 17:25, Andreas Rheinhardt wrote:
> 
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/libaomenc.c  | 4 ++--
>>  libavcodec/libkvazaar.c | 4 ++--
>>  libavcodec/libsvtav1.c  | 6 +++---
>>  libavcodec/libx264.c| 4 ++--
>>  libavcodec/libx265.c| 4 ++--
>>  libavformat/tee.c   | 4 ++--
>>  6 files changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
>> index c39853c20f..dec74ebecd 100644
>> --- a/libavcodec/libaomenc.c
>> +++ b/libavcodec/libaomenc.c
>> @@ -970,9 +970,9 @@ static av_cold int aom_init(AVCodecContext *avctx,
>>
>>  #if AOM_ENCODER_ABI_VERSION >= 23
>>  {
>> -AVDictionaryEntry *en = NULL;
>> +const AVDictionaryEntry *en = NULL;
>>
>> -while ((en = av_dict_get(ctx->aom_params, "", en, 
>> AV_DICT_IGNORE_SUFFIX))) {
>> +while ((en = av_dict_iterate(ctx->aom_params, en))) {
>>  int ret = aom_codec_set_option(>encoder, en->key, 
>> en->value);
>>  if (ret != AOM_CODEC_OK) {
>>  log_encoder_error(avctx, en->key);
>> diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
>> index 0711d9ab38..cd731ae9d0 100644
>> --- a/libavcodec/libkvazaar.c
>> +++ b/libavcodec/libkvazaar.c
>> @@ -111,8 +111,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  if (ctx->kvz_params) {
>>  AVDictionary *dict = NULL;
>>  if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
>> -AVDictionaryEntry *entry = NULL;
>> -while ((entry = av_dict_get(dict, "", entry, 
>> AV_DICT_IGNORE_SUFFIX))) {
>> +const AVDictionaryEntry *entry = NULL;
>> +while ((entry = av_dict_iterate(dict, entry))) {
>>  if (!api->config_parse(cfg, entry->key, entry->value)) {
>>  av_log(avctx, AV_LOG_WARNING, "Invalid option: 
>> %s=%s.\n",
>> entry->key, entry->value);
>> diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
>> index 9bc165f0cf..2fef8c8971 100644
>> --- a/libavcodec/libsvtav1.c
>> +++ b/libavcodec/libsvtav1.c
>> @@ -210,7 +210,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
>> *param,
>>  {
>>  SvtContext *svt_enc = avctx->priv_data;
>>  const AVPixFmtDescriptor *desc;
>> -AVDictionaryEntry *en = NULL;
>> +const AVDictionaryEntry av_unused *en = NULL;
>>
>>  // Update param from options
>>  if (svt_enc->enc_mode >= -1)
>> @@ -326,7 +326,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  handle_side_data(avctx, param);
>>
>>  #if SVT_AV1_CHECK_VERSION(0, 9, 1)
>> -while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, 
>> AV_DICT_IGNORE_SUFFIX))) {
>> +while ((en = av_dict_iterate(svt_enc->svtav1_opts, en))) {
>>  EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, 
>> en->value);
>>  if (ret != EB_ErrorNone) {
>>  int level = (avctx->err_recognition & AV_EF_EXPLODE) ? 
>> AV_LOG_ERROR : AV_LOG_WARNING;
>> @@ -336,7 +336,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  }
>>  }
>>  #else
>> -if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, 
>> AV_DICT_IGNORE_SUFFIX))) {
>> +if (av_dict_count(svt_enc->svtav1_opts)) {
>>  int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR 
>> : AV_LOG_WARNING;
>>  av_log(avctx, level, "svt-params needs libavcodec to be compiled 
>> with SVT-AV1 "
>>   "headers >= 0.9.1.\n");
>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
>> index 2715f277f1..29d1a7ccbc 100644
>> --- a/libavcodec/libx264.c
>> +++ b/libavcodec/libx264.c
>> @@ -1385,8 +1385,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  x4->params.b_repeat_headers = 1;
>>
>>  {
>> -AVDictionaryEntry *en = NULL;
>> -while (en = av_dict_get(x4->x264_params, "", en, 
>> AV_DICT_IGNORE_SUFFIX)) {
>> +const AVDictionaryEntry *en = NULL;
>> +while (en = av_dict_iterate(x4->x264_params, en)) {
> 
> Missing pair of braces to make the compiler not warn about assignment in 
> check, no?
> 

I did not change the parentheses in this patch at all as doing so would
be orthogonal to the patch. We use this style without the additional
pair of parentheses everywhere and actually add -Wno-parentheses in
configure (line 7429).

>> if ((ret = x264_param_parse(>params, en->key, en->value)) < 
>> 0) {
>> av_log(avctx, AV_LOG_WARNING,
>>"Error parsing option '%s = %s'.\n",
>> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
>> index c4ce5d..ac1dbc4f97 100644
>> --- a/libavcodec/libx265.c
>> +++ b/libavcodec/libx265.c
>> @@ -495,8 +495,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  }
>>
>>  {
>> -AVDictionaryEntry *en = NULL;
>> -while ((en = av_dict_get(ctx->x265_opts, "", en, 
>> AV_DICT_IGNORE_SUFFIX))) {
>> +const AVDictionaryEntry *en = NULL;
>> +

Re: [FFmpeg-devel] [PATCH 3/6] avformat/tee: Constify AVDictionaryEntry* pointee where possible

2024-05-17 Thread epirat07
On 17 May 2024, at 17:25, Andreas Rheinhardt wrote:

> This is in preparation for using av_dict_iterate().
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/tee.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 1cbbb80dbb..87159681ed 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
> TeeSlave *tee_slave)
>  {
>  int i, ret;
>  AVDictionary *options = NULL, *bsf_options = NULL;
> -AVDictionaryEntry *entry;
> +const AVDictionaryEntry *entry;
>  char *filename;
>  char *format = NULL, *select = NULL, *on_fail = NULL;
>  char *use_fifo = NULL, *fifo_options_str = NULL;
> @@ -172,8 +172,9 @@ static int open_slave(AVFormatContext *avf, char *slave, 
> TeeSlave *tee_slave)
>  return ret;
>
>  #define CONSUME_OPTION(option, field, action) do {  \
> -if ((entry = av_dict_get(options, option, NULL, 0))) {  \
> -field = entry->value;   \
> +AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0);  \
> +if (en) {   \
> +field = en->value;  \
>  { action }  \
>  av_dict_set(, option, NULL, 0); \
>  }   \
> -- 
> 2.40.1
>

LGTM, thanks!

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

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


Re: [FFmpeg-devel] [PATCH 5/6] avcodec/lib*, avformat/tee: Simplify iterating over AVDictionary

2024-05-17 Thread epirat07



On 17 May 2024, at 17:25, Andreas Rheinhardt wrote:

> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/libaomenc.c  | 4 ++--
>  libavcodec/libkvazaar.c | 4 ++--
>  libavcodec/libsvtav1.c  | 6 +++---
>  libavcodec/libx264.c| 4 ++--
>  libavcodec/libx265.c| 4 ++--
>  libavformat/tee.c   | 4 ++--
>  6 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index c39853c20f..dec74ebecd 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -970,9 +970,9 @@ static av_cold int aom_init(AVCodecContext *avctx,
>
>  #if AOM_ENCODER_ABI_VERSION >= 23
>  {
> -AVDictionaryEntry *en = NULL;
> +const AVDictionaryEntry *en = NULL;
>
> -while ((en = av_dict_get(ctx->aom_params, "", en, 
> AV_DICT_IGNORE_SUFFIX))) {
> +while ((en = av_dict_iterate(ctx->aom_params, en))) {
>  int ret = aom_codec_set_option(>encoder, en->key, 
> en->value);
>  if (ret != AOM_CODEC_OK) {
>  log_encoder_error(avctx, en->key);
> diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
> index 0711d9ab38..cd731ae9d0 100644
> --- a/libavcodec/libkvazaar.c
> +++ b/libavcodec/libkvazaar.c
> @@ -111,8 +111,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  if (ctx->kvz_params) {
>  AVDictionary *dict = NULL;
>  if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
> -AVDictionaryEntry *entry = NULL;
> -while ((entry = av_dict_get(dict, "", entry, 
> AV_DICT_IGNORE_SUFFIX))) {
> +const AVDictionaryEntry *entry = NULL;
> +while ((entry = av_dict_iterate(dict, entry))) {
>  if (!api->config_parse(cfg, entry->key, entry->value)) {
>  av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n",
> entry->key, entry->value);
> diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
> index 9bc165f0cf..2fef8c8971 100644
> --- a/libavcodec/libsvtav1.c
> +++ b/libavcodec/libsvtav1.c
> @@ -210,7 +210,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
> *param,
>  {
>  SvtContext *svt_enc = avctx->priv_data;
>  const AVPixFmtDescriptor *desc;
> -AVDictionaryEntry *en = NULL;
> +const AVDictionaryEntry av_unused *en = NULL;
>
>  // Update param from options
>  if (svt_enc->enc_mode >= -1)
> @@ -326,7 +326,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  handle_side_data(avctx, param);
>
>  #if SVT_AV1_CHECK_VERSION(0, 9, 1)
> -while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, 
> AV_DICT_IGNORE_SUFFIX))) {
> +while ((en = av_dict_iterate(svt_enc->svtav1_opts, en))) {
>  EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, 
> en->value);
>  if (ret != EB_ErrorNone) {
>  int level = (avctx->err_recognition & AV_EF_EXPLODE) ? 
> AV_LOG_ERROR : AV_LOG_WARNING;
> @@ -336,7 +336,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>  }
>  #else
> -if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, 
> AV_DICT_IGNORE_SUFFIX))) {
> +if (av_dict_count(svt_enc->svtav1_opts)) {
>  int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR 
> : AV_LOG_WARNING;
>  av_log(avctx, level, "svt-params needs libavcodec to be compiled 
> with SVT-AV1 "
>   "headers >= 0.9.1.\n");
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 2715f277f1..29d1a7ccbc 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -1385,8 +1385,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  x4->params.b_repeat_headers = 1;
>
>  {
> -AVDictionaryEntry *en = NULL;
> -while (en = av_dict_get(x4->x264_params, "", en, 
> AV_DICT_IGNORE_SUFFIX)) {
> +const AVDictionaryEntry *en = NULL;
> +while (en = av_dict_iterate(x4->x264_params, en)) {

Missing pair of braces to make the compiler not warn about assignment in check, 
no?

> if ((ret = x264_param_parse(>params, en->key, en->value)) < 
> 0) {
> av_log(avctx, AV_LOG_WARNING,
>"Error parsing option '%s = %s'.\n",
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index c4ce5d..ac1dbc4f97 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -495,8 +495,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>
>  {
> -AVDictionaryEntry *en = NULL;
> -while ((en = av_dict_get(ctx->x265_opts, "", en, 
> AV_DICT_IGNORE_SUFFIX))) {
> +const AVDictionaryEntry *en = NULL;
> +while ((en = av_dict_iterate(ctx->x265_opts, en))) {
>  int parse_ret = ctx->api->param_parse(ctx->params, en->key, 
> en->value);
>
>  switch (parse_ret) {
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 0c0543fa65..1a2a8ead82 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -313,7 +313,7 @@ static int open_slave(AVFormatContext 

Re: [FFmpeg-devel] [PATCH 6/6] fftools, avfilter, avformat: Simplify check for "is dictionary empty?"

2024-05-17 Thread epirat07
On 17 May 2024, at 17:25, Andreas Rheinhardt wrote:

> Signed-off-by: Andreas Rheinhardt 
> ---
>  fftools/ffmpeg.c   | 4 ++--
>  fftools/ffplay.c   | 4 ++--
>  fftools/ffprobe.c  | 2 +-
>  libavfilter/avfilter.c | 4 ++--
>  libavformat/aacdec.c   | 2 +-
>  libavformat/http.c | 8 
>  libavformat/mpc.c  | 2 +-
>  libavformat/oggenc.c   | 2 +-
>  libavformat/wvdec.c| 2 +-
>  9 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 1f50ed6805..c86fd5065e 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -484,8 +484,8 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b)
>
>  int check_avoptions(AVDictionary *m)
>  {
> -const AVDictionaryEntry *t;
> -if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
> +const AVDictionaryEntry *t = av_dict_iterate(m, NULL);
> +if (t) {
>  av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
>  return AVERROR_OPTION_NOT_FOUND;
>  }
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index b9d11eecee..5a66bfa38d 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -2694,7 +2694,7 @@ static int stream_component_open(VideoState *is, int 
> stream_index)
>  if ((ret = avcodec_open2(avctx, codec, )) < 0) {
>  goto fail;
>  }
> -if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
> +if ((t = av_dict_iterate(opts, NULL))) {
>  av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
>  ret =  AVERROR_OPTION_NOT_FOUND;
>  goto fail;
> @@ -2862,7 +2862,7 @@ static int read_thread(void *arg)
>  if (scan_all_pmts_set)
>  av_dict_set(_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
>
> -if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
> +if ((t = av_dict_iterate(format_opts, NULL))) {
>  av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
>  ret = AVERROR_OPTION_NOT_FOUND;
>  goto fail;
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 5b40dad527..2d38e5dfdc 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -3951,7 +3951,7 @@ static int open_input_file(InputFile *ifile, const char 
> *filename,
>  exit(1);
>  }
>
> -if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
> +if ((t = av_dict_iterate(opts, NULL))) {
>  av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d 
> not found\n",
> t->key, stream->index);
>  return AVERROR_OPTION_NOT_FOUND;
> diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> index 049e4f62ca..2dc8820184 100644
> --- a/libavfilter/avfilter.c
> +++ b/libavfilter/avfilter.c
> @@ -941,7 +941,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
> **options)
>  int avfilter_init_str(AVFilterContext *filter, const char *args)
>  {
>  AVDictionary *options = NULL;
> -AVDictionaryEntry *e;
> +const AVDictionaryEntry *e;
>  int ret = 0;
>
>  if (args && *args) {
> @@ -954,7 +954,7 @@ int avfilter_init_str(AVFilterContext *filter, const char 
> *args)
>  if (ret < 0)
>  goto fail;
>
> -if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
> +if ((e = av_dict_iterate(options, NULL))) {
>  av_log(filter, AV_LOG_ERROR, "No such option: %s.\n", e->key);
>  ret = AVERROR_OPTION_NOT_FOUND;
>  goto fail;
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index e267886e1a..a8be251815 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -119,7 +119,7 @@ static int adts_aac_read_header(AVFormatContext *s)
>
>  ff_id3v1_read(s);
>  if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
> -!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
> +!av_dict_count(s->metadata)) {
>  int64_t cur = avio_tell(s->pb);
>  ff_ape_parse_tag(s);
>  avio_seek(s->pb, cur, SEEK_SET);
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 1a67068a44..ec60bc0b17 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -990,7 +990,7 @@ static int parse_set_cookie(const char *set_cookie, 
> AVDictionary **dict)
>  static int parse_cookie(HTTPContext *s, const char *p, AVDictionary 
> **cookies)
>  {
>  AVDictionary *new_params = NULL;
> -AVDictionaryEntry *e, *cookie_entry;
> +const AVDictionaryEntry *e, *cookie_entry;
>  char *eql, *name;
>
>  // ensure the cookie is parsable
> @@ -998,7 +998,7 @@ static int parse_cookie(HTTPContext *s, const char *p, 
> AVDictionary **cookies)
>  return -1;
>
>  // if there is no cookie value there is nothing to parse
> -cookie_entry = av_dict_get(new_params, "", NULL, AV_DICT_IGNORE_SUFFIX);
> +cookie_entry = av_dict_iterate(new_params, NULL);
>  if (!cookie_entry || 

[FFmpeg-devel] [PATCH 1/6] avformat/utils: Use static mutexes instead of ff_lock_avformat()

2024-05-17 Thread Andreas Rheinhardt
Its existence is a remnant of (libavcodec's) lock-manager API
which has been removed in a04c2c707de2ce850f79870e84ac9d7ec7aa9143.
There is no need to use the same lock for avisynth, chromaprint
or tls, so switch to ordinary static mutexes instead.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/avisynth.c| 15 +--
 libavformat/chromaprint.c | 12 +++-
 libavformat/internal.h|  3 ---
 libavformat/tls_gnutls.c  | 16 +++-
 libavformat/tls_openssl.c | 17 +++--
 libavformat/utils.c   | 13 -
 6 files changed, 30 insertions(+), 46 deletions(-)

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 1709bf4051..625bdf7e3a 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -23,6 +23,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
+#include "libavutil/thread.h"
 
 #include "avformat.h"
 #include "demux.h"
@@ -130,6 +131,8 @@ static const int avs_planes_yuva[4]   = { AVS_PLANAR_Y, 
AVS_PLANAR_U,
 static const int avs_planes_rgba[4]   = { AVS_PLANAR_G, AVS_PLANAR_B,
   AVS_PLANAR_R, AVS_PLANAR_A };
 
+static AVMutex avisynth_mutex = AV_MUTEX_INITIALIZER;
+
 /* A conflict between C++ global objects, atexit, and dynamic loading requires
  * us to register our own atexit handler to prevent double freeing. */
 static AviSynthLibrary avs_library;
@@ -1083,15 +1086,15 @@ static av_cold int avisynth_read_header(AVFormatContext 
*s)
 int ret;
 
 // Calling library must implement a lock for thread-safe opens.
-if (ret = ff_lock_avformat())
-return ret;
+if (ff_mutex_lock(_mutex))
+return AVERROR_UNKNOWN;
 
 if (ret = avisynth_open_file(s)) {
-ff_unlock_avformat();
+ff_mutex_unlock(_mutex);
 return ret;
 }
 
-ff_unlock_avformat();
+ff_mutex_unlock(_mutex);
 return 0;
 }
 
@@ -1127,11 +1130,11 @@ static int avisynth_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 
 static av_cold int avisynth_read_close(AVFormatContext *s)
 {
-if (ff_lock_avformat())
+if (ff_mutex_lock(_mutex))
 return AVERROR_UNKNOWN;
 
 avisynth_context_destroy(s->priv_data);
-ff_unlock_avformat();
+ff_mutex_unlock(_mutex);
 return 0;
 }
 
diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index 1cdca47ea5..eae233a651 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -20,15 +20,17 @@
  */
 
 #include "avformat.h"
-#include "internal.h"
 #include "mux.h"
 #include "libavutil/opt.h"
+#include "libavutil/thread.h"
 #include 
 
 #define CPR_VERSION_INT AV_VERSION_INT(CHROMAPRINT_VERSION_MAJOR, \
CHROMAPRINT_VERSION_MINOR, \
CHROMAPRINT_VERSION_PATCH)
 
+static AVMutex chromaprint_mutex = AV_MUTEX_INITIALIZER;
+
 typedef enum FingerprintFormat {
 FINGERPRINT_RAW,
 FINGERPRINT_COMPRESSED,
@@ -52,9 +54,9 @@ static void deinit(AVFormatContext *s)
 ChromaprintMuxContext *const cpr = s->priv_data;
 
 if (cpr->ctx) {
-ff_lock_avformat();
+ff_mutex_lock(_mutex);
 chromaprint_free(cpr->ctx);
-ff_unlock_avformat();
+ff_mutex_unlock(_mutex);
 }
 }
 
@@ -63,9 +65,9 @@ static av_cold int init(AVFormatContext *s)
 ChromaprintMuxContext *cpr = s->priv_data;
 AVStream *st;
 
-ff_lock_avformat();
+ff_mutex_lock(_mutex);
 cpr->ctx = chromaprint_new(cpr->algorithm);
-ff_unlock_avformat();
+ff_mutex_unlock(_mutex);
 
 if (!cpr->ctx) {
 av_log(s, AV_LOG_ERROR, "Failed to create chromaprint context.\n");
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 7f3d1c0086..6bad4fd119 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -727,9 +727,6 @@ struct AVBPrint;
  */
 int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint 
*buf);
 
-int ff_lock_avformat(void);
-int ff_unlock_avformat(void);
-
 /**
  * Set AVFormatContext url field to the provided pointer. The pointer must
  * point to a valid string. The existing url field is freed if necessary. Also
diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index 2ab38a199b..df251ad79c 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -25,15 +25,12 @@
 #include 
 
 #include "avformat.h"
-#include "internal.h"
 #include "network.h"
 #include "os_support.h"
 #include "url.h"
 #include "tls.h"
-#include "libavcodec/internal.h"
-#include "libavutil/avstring.h"
 #include "libavutil/opt.h"
-#include "libavutil/parseutils.h"
+#include "libavutil/thread.h"
 
 #ifndef GNUTLS_VERSION_NUMBER
 #define GNUTLS_VERSION_NUMBER LIBGNUTLS_VERSION_NUMBER
@@ -41,7 +38,6 @@
 
 #if HAVE_THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
 #include 
-#include "libavutil/thread.h"
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
 #endif
 
@@ -54,22 +50,24 @@ typedef struct TLSContext {
 int 

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/mlpdec: Set AV_FRAME_FLAG_KEY explicitly

2024-05-17 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> It is currently always set for all audio frames, but this is
> wrong (namely for MLP/TrueHD) and will be changed.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mlpdec.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> index 305c5d2b36..e85dac36a7 100644
> --- a/libavcodec/mlpdec.c
> +++ b/libavcodec/mlpdec.c
> @@ -1212,6 +1212,7 @@ static int read_access_unit(AVCodecContext *avctx, 
> AVFrame *frame,
>  goto error;
>  m->is_major_sync_unit = 1;
>  header_size += m->major_sync_header_size;
> +frame->flags |= AV_FRAME_FLAG_KEY;
>  }
>  
>  if (!m->params_valid) {

Will apply this patchset tomorrow unless there are objections.

- Andreas

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

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


Re: [FFmpeg-devel] [RFC] STF 2025

2024-05-17 Thread Derek Buitenhuis
On 5/17/2024 2:49 PM, Michael Niedermayer wrote:
> Also we need more cute girls on these events, everything i hear
> its 100% male geeks/hackers.

This is gross and sexist.

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

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


[FFmpeg-devel] [PATCH 6/6] fftools, avfilter, avformat: Simplify check for "is dictionary empty?"

2024-05-17 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg.c   | 4 ++--
 fftools/ffplay.c   | 4 ++--
 fftools/ffprobe.c  | 2 +-
 libavfilter/avfilter.c | 4 ++--
 libavformat/aacdec.c   | 2 +-
 libavformat/http.c | 8 
 libavformat/mpc.c  | 2 +-
 libavformat/oggenc.c   | 2 +-
 libavformat/wvdec.c| 2 +-
 9 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1f50ed6805..c86fd5065e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -484,8 +484,8 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b)
 
 int check_avoptions(AVDictionary *m)
 {
-const AVDictionaryEntry *t;
-if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+const AVDictionaryEntry *t = av_dict_iterate(m, NULL);
+if (t) {
 av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
 return AVERROR_OPTION_NOT_FOUND;
 }
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index b9d11eecee..5a66bfa38d 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2694,7 +2694,7 @@ static int stream_component_open(VideoState *is, int 
stream_index)
 if ((ret = avcodec_open2(avctx, codec, )) < 0) {
 goto fail;
 }
-if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+if ((t = av_dict_iterate(opts, NULL))) {
 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
 ret =  AVERROR_OPTION_NOT_FOUND;
 goto fail;
@@ -2862,7 +2862,7 @@ static int read_thread(void *arg)
 if (scan_all_pmts_set)
 av_dict_set(_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
 
-if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+if ((t = av_dict_iterate(format_opts, NULL))) {
 av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
 ret = AVERROR_OPTION_NOT_FOUND;
 goto fail;
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 5b40dad527..2d38e5dfdc 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -3951,7 +3951,7 @@ static int open_input_file(InputFile *ifile, const char 
*filename,
 exit(1);
 }
 
-if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+if ((t = av_dict_iterate(opts, NULL))) {
 av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not 
found\n",
t->key, stream->index);
 return AVERROR_OPTION_NOT_FOUND;
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 049e4f62ca..2dc8820184 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -941,7 +941,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 int avfilter_init_str(AVFilterContext *filter, const char *args)
 {
 AVDictionary *options = NULL;
-AVDictionaryEntry *e;
+const AVDictionaryEntry *e;
 int ret = 0;
 
 if (args && *args) {
@@ -954,7 +954,7 @@ int avfilter_init_str(AVFilterContext *filter, const char 
*args)
 if (ret < 0)
 goto fail;
 
-if ((e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+if ((e = av_dict_iterate(options, NULL))) {
 av_log(filter, AV_LOG_ERROR, "No such option: %s.\n", e->key);
 ret = AVERROR_OPTION_NOT_FOUND;
 goto fail;
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index e267886e1a..a8be251815 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -119,7 +119,7 @@ static int adts_aac_read_header(AVFormatContext *s)
 
 ff_id3v1_read(s);
 if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
-!av_dict_get(s->metadata, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
+!av_dict_count(s->metadata)) {
 int64_t cur = avio_tell(s->pb);
 ff_ape_parse_tag(s);
 avio_seek(s->pb, cur, SEEK_SET);
diff --git a/libavformat/http.c b/libavformat/http.c
index 1a67068a44..ec60bc0b17 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -990,7 +990,7 @@ static int parse_set_cookie(const char *set_cookie, 
AVDictionary **dict)
 static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
 {
 AVDictionary *new_params = NULL;
-AVDictionaryEntry *e, *cookie_entry;
+const AVDictionaryEntry *e, *cookie_entry;
 char *eql, *name;
 
 // ensure the cookie is parsable
@@ -998,7 +998,7 @@ static int parse_cookie(HTTPContext *s, const char *p, 
AVDictionary **cookies)
 return -1;
 
 // if there is no cookie value there is nothing to parse
-cookie_entry = av_dict_get(new_params, "", NULL, AV_DICT_IGNORE_SUFFIX);
+cookie_entry = av_dict_iterate(new_params, NULL);
 if (!cookie_entry || !cookie_entry->value) {
 av_dict_free(_params);
 return -1;
@@ -1300,7 +1300,7 @@ static int get_cookies(HTTPContext *s, char **cookies, 
const char *path,
 *cookies = NULL;
 while ((cookie = av_strtok(next, "\n", )) && !ret) {
 AVDictionary *cookie_params = NULL;
-

[FFmpeg-devel] [PATCH 5/6] avcodec/lib*, avformat/tee: Simplify iterating over AVDictionary

2024-05-17 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/libaomenc.c  | 4 ++--
 libavcodec/libkvazaar.c | 4 ++--
 libavcodec/libsvtav1.c  | 6 +++---
 libavcodec/libx264.c| 4 ++--
 libavcodec/libx265.c| 4 ++--
 libavformat/tee.c   | 4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index c39853c20f..dec74ebecd 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -970,9 +970,9 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 #if AOM_ENCODER_ABI_VERSION >= 23
 {
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry *en = NULL;
 
-while ((en = av_dict_get(ctx->aom_params, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
+while ((en = av_dict_iterate(ctx->aom_params, en))) {
 int ret = aom_codec_set_option(>encoder, en->key, en->value);
 if (ret != AOM_CODEC_OK) {
 log_encoder_error(avctx, en->key);
diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
index 0711d9ab38..cd731ae9d0 100644
--- a/libavcodec/libkvazaar.c
+++ b/libavcodec/libkvazaar.c
@@ -111,8 +111,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (ctx->kvz_params) {
 AVDictionary *dict = NULL;
 if (!av_dict_parse_string(, ctx->kvz_params, "=", ",", 0)) {
-AVDictionaryEntry *entry = NULL;
-while ((entry = av_dict_get(dict, "", entry, 
AV_DICT_IGNORE_SUFFIX))) {
+const AVDictionaryEntry *entry = NULL;
+while ((entry = av_dict_iterate(dict, entry))) {
 if (!api->config_parse(cfg, entry->key, entry->value)) {
 av_log(avctx, AV_LOG_WARNING, "Invalid option: %s=%s.\n",
entry->key, entry->value);
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 9bc165f0cf..2fef8c8971 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -210,7 +210,7 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 {
 SvtContext *svt_enc = avctx->priv_data;
 const AVPixFmtDescriptor *desc;
-AVDictionaryEntry *en = NULL;
+const AVDictionaryEntry av_unused *en = NULL;
 
 // Update param from options
 if (svt_enc->enc_mode >= -1)
@@ -326,7 +326,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 handle_side_data(avctx, param);
 
 #if SVT_AV1_CHECK_VERSION(0, 9, 1)
-while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
+while ((en = av_dict_iterate(svt_enc->svtav1_opts, en))) {
 EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, 
en->value);
 if (ret != EB_ErrorNone) {
 int level = (avctx->err_recognition & AV_EF_EXPLODE) ? 
AV_LOG_ERROR : AV_LOG_WARNING;
@@ -336,7 +336,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 #else
-if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, 
AV_DICT_IGNORE_SUFFIX))) {
+if (av_dict_count(svt_enc->svtav1_opts)) {
 int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : 
AV_LOG_WARNING;
 av_log(avctx, level, "svt-params needs libavcodec to be compiled with 
SVT-AV1 "
  "headers >= 0.9.1.\n");
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 2715f277f1..29d1a7ccbc 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -1385,8 +1385,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 x4->params.b_repeat_headers = 1;
 
 {
-AVDictionaryEntry *en = NULL;
-while (en = av_dict_get(x4->x264_params, "", en, 
AV_DICT_IGNORE_SUFFIX)) {
+const AVDictionaryEntry *en = NULL;
+while (en = av_dict_iterate(x4->x264_params, en)) {
if ((ret = x264_param_parse(>params, en->key, en->value)) < 0) {
av_log(avctx, AV_LOG_WARNING,
   "Error parsing option '%s = %s'.\n",
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index c4ce5d..ac1dbc4f97 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -495,8 +495,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 {
-AVDictionaryEntry *en = NULL;
-while ((en = av_dict_get(ctx->x265_opts, "", en, 
AV_DICT_IGNORE_SUFFIX))) {
+const AVDictionaryEntry *en = NULL;
+while ((en = av_dict_iterate(ctx->x265_opts, en))) {
 int parse_ret = ctx->api->param_parse(ctx->params, en->key, 
en->value);
 
 switch (parse_ret) {
diff --git a/libavformat/tee.c b/libavformat/tee.c
index 0c0543fa65..1a2a8ead82 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -313,7 +313,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 }
 
 entry = NULL;
-while (entry = av_dict_get(bsf_options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
+while (entry = av_dict_iterate(bsf_options, NULL)) {
 const char *spec = entry->key;
 if (*spec) {
 if (strspn(spec, slave_bsfs_spec_sep) != 1) {
@@ -390,7 +390,7 @@ static int 

[FFmpeg-devel] [PATCH 4/6] avformat/tee: Use smaller scope for variables

2024-05-17 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/tee.c | 71 +++
 1 file changed, 35 insertions(+), 36 deletions(-)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 87159681ed..0c0543fa65 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -119,7 +119,6 @@ static int parse_slave_fifo_options(const char 
*fifo_options, TeeSlave *tee_slav
 static int close_slave(TeeSlave *tee_slave)
 {
 AVFormatContext *avf;
-unsigned i;
 int ret = 0;
 
 av_dict_free(_slave->fifo_options);
@@ -131,7 +130,7 @@ static int close_slave(TeeSlave *tee_slave)
 ret = av_write_trailer(avf);
 
 if (tee_slave->bsfs) {
-for (i = 0; i < avf->nb_streams; ++i)
+for (unsigned i = 0; i < avf->nb_streams; ++i)
 av_bsf_free(_slave->bsfs[i]);
 }
 av_freep(_slave->stream_map);
@@ -146,9 +145,8 @@ static int close_slave(TeeSlave *tee_slave)
 static void close_slaves(AVFormatContext *avf)
 {
 TeeContext *tee = avf->priv_data;
-unsigned i;
 
-for (i = 0; i < tee->nb_slaves; i++) {
+for (unsigned i = 0; i < tee->nb_slaves; i++) {
 close_slave(>slaves[i]);
 }
 av_freep(>slaves);
@@ -156,14 +154,12 @@ static void close_slaves(AVFormatContext *avf)
 
 static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
 {
-int i, ret;
+int ret;
 AVDictionary *options = NULL, *bsf_options = NULL;
 const AVDictionaryEntry *entry;
 char *filename;
-char *format = NULL, *select = NULL, *on_fail = NULL;
-char *use_fifo = NULL, *fifo_options_str = NULL;
+char *format = NULL, *select = NULL;
 AVFormatContext *avf2 = NULL;
-AVStream *st, *st2;
 int stream_count;
 int fullret;
 char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, 
*tmp_select = NULL;
@@ -181,22 +177,25 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 } while (0)
 #define STEAL_OPTION(option, field) \
 CONSUME_OPTION(option, field,   \
-   entry->value = NULL; /* prevent it from being freed */)
-#define PROCESS_OPTION(option, field, function, on_error)   \
-CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } 
goto end; })
+   en->value = NULL; /* prevent it from being freed */)
+#define PROCESS_OPTION(option, function, on_error) do { \
+const char *value;  \
+CONSUME_OPTION(option, value, if ((ret = function) < 0) \
+  { { on_error } goto end; });  \
+} while (0)
 
 STEAL_OPTION("f", format);
 STEAL_OPTION("select", select);
-PROCESS_OPTION("onfail", on_fail,
-   parse_slave_failure_policy_option(on_fail, tee_slave),
+PROCESS_OPTION("onfail",
+   parse_slave_failure_policy_option(value, tee_slave),
av_log(avf, AV_LOG_ERROR, "Invalid onfail option value, "
   "valid options are 'abort' and 'ignore'\n"););
-PROCESS_OPTION("use_fifo", use_fifo,
-   parse_slave_fifo_policy(use_fifo, tee_slave),
+PROCESS_OPTION("use_fifo",
+   parse_slave_fifo_policy(value, tee_slave),
av_log(avf, AV_LOG_ERROR, "Error parsing fifo options: 
%s\n",
   av_err2str(ret)););
-PROCESS_OPTION("fifo_options", fifo_options_str,
-   parse_slave_fifo_options(fifo_options_str, tee_slave), ;);
+PROCESS_OPTION("fifo_options",
+   parse_slave_fifo_options(value, tee_slave), ;);
 entry = NULL;
 while ((entry = av_dict_get(options, "bsfs", entry, 
AV_DICT_IGNORE_SUFFIX))) {
 /* trim out strlen("bsfs") characters from key */
@@ -250,8 +249,9 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 }
 
 stream_count = 0;
-for (i = 0; i < avf->nb_streams; i++) {
-st = avf->streams[i];
+for (unsigned i = 0; i < avf->nb_streams; i++) {
+const AVStream *st = avf->streams[i];
+AVStream *st2;
 if (select) {
 tmp_select = av_strdup(select);  // av_strtok is destructive so we 
regenerate it in each loop
 if (!tmp_select) {
@@ -326,7 +326,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 spec++; /* consume separator */
 }
 
-for (i = 0; i < avf2->nb_streams; i++) {
+for (unsigned i = 0; i < avf2->nb_streams; i++) {
 ret = avformat_match_stream_specifier(avf2, avf2->streams[i], 
spec);
 if (ret < 0) {
 av_log(avf, AV_LOG_ERROR,
@@ -357,7 +357,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 av_dict_set(_options, entry->key, NULL, 

[FFmpeg-devel] [PATCH 3/6] avformat/tee: Constify AVDictionaryEntry* pointee where possible

2024-05-17 Thread Andreas Rheinhardt
This is in preparation for using av_dict_iterate().

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

diff --git a/libavformat/tee.c b/libavformat/tee.c
index 1cbbb80dbb..87159681ed 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -158,7 +158,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 {
 int i, ret;
 AVDictionary *options = NULL, *bsf_options = NULL;
-AVDictionaryEntry *entry;
+const AVDictionaryEntry *entry;
 char *filename;
 char *format = NULL, *select = NULL, *on_fail = NULL;
 char *use_fifo = NULL, *fifo_options_str = NULL;
@@ -172,8 +172,9 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 return ret;
 
 #define CONSUME_OPTION(option, field, action) do {  \
-if ((entry = av_dict_get(options, option, NULL, 0))) {  \
-field = entry->value;   \
+AVDictionaryEntry *en = av_dict_get(options, option, NULL, 0);  \
+if (en) {   \
+field = en->value;  \
 { action }  \
 av_dict_set(, option, NULL, 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 2/6] avformat/tls_openssl: #if ff_openssl_init/deinit() away if possible

2024-05-17 Thread Andreas Rheinhardt
These functions do nothing useful when used with a non-ancient
version of openssl (namely 1.1.0 or above).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/network.c |  9 +++--
 libavformat/tls_openssl.c | 34 --
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/libavformat/network.c b/libavformat/network.c
index f752efc411..6db82b6d26 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -18,8 +18,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "config_components.h"
 
+#if CONFIG_TLS_PROTOCOL && CONFIG_OPENSSL
+#include 
+#endif
+
 #include 
 #include "network.h"
 #include "tls.h"
@@ -31,7 +36,7 @@
 int ff_tls_init(void)
 {
 #if CONFIG_TLS_PROTOCOL
-#if CONFIG_OPENSSL
+#if CONFIG_OPENSSL && OPENSSL_VERSION_NUMBER < 0x1010L
 int ret;
 if ((ret = ff_openssl_init()) < 0)
 return ret;
@@ -46,7 +51,7 @@ int ff_tls_init(void)
 void ff_tls_deinit(void)
 {
 #if CONFIG_TLS_PROTOCOL
-#if CONFIG_OPENSSL
+#if CONFIG_OPENSSL && OPENSSL_VERSION_NUMBER < 0x1010L
 ff_openssl_deinit();
 #endif
 #if CONFIG_GNUTLS
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 89d7c6e1ea..8b0cf9efb2 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -23,16 +23,12 @@
 #include "os_support.h"
 #include "url.h"
 #include "tls.h"
-#include "libavutil/mem.h"
 #include "libavutil/opt.h"
-#include "libavutil/thread.h"
 
 #include 
 #include 
 #include 
 
-static int openssl_init;
-
 typedef struct TLSContext {
 const AVClass *class;
 TLSShared tls_shared;
@@ -44,10 +40,22 @@ typedef struct TLSContext {
 int io_err;
 } TLSContext;
 
+/* OpenSSL 1.0.2 or below, then you would use SSL_library_init. If you are
+ * using OpenSSL 1.1.0 or above, then the library will initialize
+ * itself automatically.
+ * https://wiki.openssl.org/index.php/Library_Initialization
+ */
+#if OPENSSL_VERSION_NUMBER < 0x1010L
+#include "libavutil/thread.h"
+
 static AVMutex openssl_mutex = AV_MUTEX_INITIALIZER;
 
-#if HAVE_THREADS && OPENSSL_VERSION_NUMBER < 0x1010L
+static int openssl_init;
+
+#if HAVE_THREADS
 #include 
+#include "libavutil/mem.h"
+
 pthread_mutex_t *openssl_mutexes;
 static void openssl_lock(int mode, int type, const char *file, int line)
 {
@@ -68,16 +76,9 @@ int ff_openssl_init(void)
 {
 ff_mutex_lock(_mutex);
 if (!openssl_init) {
-/* OpenSSL 1.0.2 or below, then you would use SSL_library_init. If you 
are
- * using OpenSSL 1.1.0 or above, then the library will initialize
- * itself automatically.
- * https://wiki.openssl.org/index.php/Library_Initialization
- */
-#if OPENSSL_VERSION_NUMBER < 0x1010L
 SSL_library_init();
 SSL_load_error_strings();
-#endif
-#if HAVE_THREADS && OPENSSL_VERSION_NUMBER < 0x1010L
+#if HAVE_THREADS
 if (!CRYPTO_get_locking_callback()) {
 int i;
 openssl_mutexes = av_malloc_array(sizeof(pthread_mutex_t), 
CRYPTO_num_locks());
@@ -106,7 +107,7 @@ void ff_openssl_deinit(void)
 ff_mutex_lock(_mutex);
 openssl_init--;
 if (!openssl_init) {
-#if HAVE_THREADS && OPENSSL_VERSION_NUMBER < 0x1010L
+#if HAVE_THREADS
 if (CRYPTO_get_locking_callback() == openssl_lock) {
 int i;
 CRYPTO_set_locking_callback(NULL);
@@ -118,6 +119,7 @@ void ff_openssl_deinit(void)
 }
 ff_mutex_unlock(_mutex);
 }
+#endif
 
 static int print_tls_error(URLContext *h, int ret)
 {
@@ -157,7 +159,9 @@ static int tls_close(URLContext *h)
 if (c->url_bio_method)
 BIO_meth_free(c->url_bio_method);
 #endif
+#if OPENSSL_VERSION_NUMBER < 0x1010L
 ff_openssl_deinit();
+#endif
 return 0;
 }
 
@@ -253,8 +257,10 @@ static int tls_open(URLContext *h, const char *uri, int 
flags, AVDictionary **op
 BIO *bio;
 int ret;
 
+#if OPENSSL_VERSION_NUMBER < 0x1010L
 if ((ret = ff_openssl_init()) < 0)
 return ret;
+#endif
 
 if ((ret = ff_tls_open_underlying(c, h, uri, options)) < 0)
 goto fail;
-- 
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] [RFC] STF 2025

2024-05-17 Thread Andrew Sayers
On Fri, May 17, 2024 at 03:49:58PM +0200, Michael Niedermayer wrote:
> Hi all
> 
> Before this is forgotten again, better start some dicsussion too early than 
> too late
> 
> I propose that if we have the oppertunity again next year to receive a grant
> from STF. That we use it to fund:
> 
> * Paul to work on FFmpeg full time. My idea here is that he can work on 
> whatever
>   he likes in FFmpeg (so its not full time employment for specific work but
>   simply full time employment for him to work on whatever he likes in FFmpeg 
> any
>   way he likes) Paul is the 2nd largest contributor to FFmpeg (git shortlog 
> -s -n)

Instead of one person creating code five days a week, how about paying five
people to review code one day a week each?  As well as being less divisive
among maintainers, a public list of people who are obliged to do reviews would
make us peripheral developers feel less like we're shouting into a void.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v3 5/9] lavc/vp9dsp: R-V V mc avg

2024-05-17 Thread Rémi Denis-Courmont
Le maanantaina 13. toukokuuta 2024, 19.59.22 EEST u...@foxmail.com a écrit :
> From: sunyuechi 
> 
> C908:
> vp9_avg4_8bpp_c: 1.2
> vp9_avg4_8bpp_rvv_i64: 1.0
> vp9_avg8_8bpp_c: 3.7
> vp9_avg8_8bpp_rvv_i64: 1.5
> vp9_avg16_8bpp_c: 14.7
> vp9_avg16_8bpp_rvv_i64: 3.5
> vp9_avg32_8bpp_c: 57.7
> vp9_avg32_8bpp_rvv_i64: 10.0
> vp9_avg64_8bpp_c: 229.0
> vp9_avg64_8bpp_rvv_i64: 31.7
> ---
>  libavcodec/riscv/Makefile  |  3 +-
>  libavcodec/riscv/vp9_mc_rvv.S  | 58 ++
>  libavcodec/riscv/vp9dsp_init.c | 18 +++
>  3 files changed, 78 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/riscv/vp9_mc_rvv.S
> 
> diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
> index 0cd900104f..1183357b37 100644
> --- a/libavcodec/riscv/Makefile
> +++ b/libavcodec/riscv/Makefile
> @@ -64,6 +64,7 @@ RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
>  OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
>  RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \
>   riscv/vp9_mc_rvi.o
> -RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o
> +RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
> +  riscv/vp9_mc_rvv.o
>  OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
>  RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
> diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
> new file mode 100644
> index 00..5d917e7b98
> --- /dev/null
> +++ b/libavcodec/riscv/vp9_mc_rvv.S
> @@ -0,0 +1,58 @@
> +/*
> + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences
> (ISCAS). + *
> + * 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/riscv/asm.S"
> +
> +.macro vsetvlstatic8 len an maxlen mn=m4
> +.if \len == 4
> +vsetivlizero, \len, e8, mf4, ta, ma
> +.elseif \len == 8
> +vsetivlizero, \len, e8, mf2, ta, ma
> +.elseif \len == 16
> +vsetivlizero, \len, e8, m1, ta, ma
> +.elseif \len == 32
> +li  \an, \len
> +vsetvli zero, \an, e8, m2, ta, ma
> +.elseif \len == 64
> +li  \an, \maxlen
> +vsetvli zero, \an, e8, \mn, ta, ma
> +.endif
> +.endm
> +
> +.macro copy_avg len
> +func ff_avg\len\()_rvv, zve32x
> +csrwi   vxrm, 0
> +vsetvlstatic8   \len t0 64
> +1:
> +addia4, a4, -1
> +vle8.v  v8, (a2)
> +vle8.v  v16, (a0)
> +vaaddu.vv   v8, v8, v16
> +vse8.v  v8, (a0)
> +add a2, a2, a3
> +add a0, a0, a1
> +bneza4, 1b
> +ret

Doesn't this get slightly faster by interleaving scalar and vector 
instructions?

> +endfunc
> +.endm
> +
> +.irp len 64, 32, 16, 8, 4
> +copy_avg \len
> +.endr
> diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
> index 184fadbaf7..1922484a1d 100644
> --- a/libavcodec/riscv/vp9dsp_init.c
> +++ b/libavcodec/riscv/vp9dsp_init.c
> @@ -48,6 +48,24 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext
> *dsp, int bpp) }
>  # endif
> 
> +#if HAVE_RVV
> +if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128))
> { +
> +#define init_fpel(idx1, sz)   \
> +dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv;  \
> +dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv;  \
> +dsp->mc[idx1][FILTER_8TAP_SHARP  ][1][0][0] = ff_avg##sz##_rvv;  \
> +dsp->mc[idx1][FILTER_BILINEAR][1][0][0] = ff_avg##sz##_rvv
> +
> +init_fpel(0, 64);
> +init_fpel(1, 32);
> +init_fpel(2, 16);
> +init_fpel(3, 8);
> +init_fpel(4, 4);
> +
> +#undef init_fpel
> +}
> +#endif
>  #endif
>  }


-- 
雷米‧德尼-库尔蒙
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] [RFC] STF 2025

2024-05-17 Thread Vittorio Giovara
On Fri, May 17, 2024 at 9:50 AM Michael Niedermayer 
wrote:

> Hi all
>
> Before this is forgotten again, better start some dicsussion too early
> than too late
>
> I propose that if we have the oppertunity again next year to receive a
> grant
> from STF. That we use it to fund:
>
> * Paul to work on FFmpeg full time. My idea here is that he can work on
> whatever
>   he likes in FFmpeg (so its not full time employment for specific work but
>   simply full time employment for him to work on whatever he likes in
> FFmpeg any
>   way he likes) Paul is the 2nd largest contributor to FFmpeg (git
> shortlog -s -n)
>

why? nothing against Paul, but this seems pretty arbitrary, and many people
would like to be paid to do whatever they want
if we start sponsoring people there should be clear statements of work,
goals, and everything in between

* Fund administrative / maintainance work (one example is the mailman
> upgrade that is needed
>   with the next OS upgrade on one of our servers (this is not as trivial
> as one might
>   expect). Another example here may be some git related tools if we find
> something that
>   theres a broad consensus about.
>
> * Fund maintaince on the bug tracker, try to reproduce bugs, ask users to
> provide
>   reproduceable cases, close bugs still unreproduceable, ...
>   ATM we have over 2000 "new" bugs that are not even marked as open
>

I see no mention of github/gitlab work, despite being highly requested on
the list.
Is it because we assume it'll be done already by next year? :)


>   something like a video chat. Also we need more cute girls on these
> events, everything i hear
>   its 100% male geeks/hackers. Also a "24/7" realtime stream from any
> booth would be nice
>

I understand the idea comes from a good place, but the way it is phrased is
very sketchy.
-- 
Vittorio
___
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] [RFC] STF 2025

2024-05-17 Thread Rémi Denis-Courmont


Le 17 mai 2024 16:49:58 GMT+03:00, Michael Niedermayer  
a écrit :
>Hi all
>
>Before this is forgotten again, better start some dicsussion too early than 
>too late
>
>I propose that if we have the oppertunity again next year to receive a grant
>from STF. That we use it to fund:
>
>* Paul to work on FFmpeg full time. My idea here is that he can work on 
>whatever
>  he likes in FFmpeg (so its not full time employment for specific work but
>  simply full time employment for him to work on whatever he likes in FFmpeg 
> any
>  way he likes) Paul is the 2nd largest contributor to FFmpeg (git shortlog -s 
> -n)

There are many grave flaws with such an idea. In the first place, it is far 
from certain that he himself would agree to such a deal at this point. And if 
he did, it is not clear that he would agree to follow the project's defined 
practices.

And ultimately, being paid to do whatever you want is not much different from 
fictitious employment or embezzlement, which is probably illegal in Germany 
(for good reasons).

It is also a less than ideal time for that sort of proposal: there are quite a 
few members of the community who may be wanting to be paid to work on FFmpeg, 
and it just doesn't seem fair that someone would be paid to do literally 
whatever they want, no matter how much they have contributed.

>* Fund administrative / maintainance work (one example is the mailman upgrade 
>that is needed
>  with the next OS upgrade on one of our servers (this is not as trivial as 
> one might
>  expect). Another example here may be some git related tools if we find 
> something that
>  theres a broad consensus about.

I agree that this should be paid but I would expect that STF would not be too 
keen on it, not that I'd know really.

>* Fund maintaince on the bug tracker, try to reproduce bugs, ask users to 
>provide
>  reproduceable cases, close bugs still unreproduceable, ...
>  ATM we have over 2000 "new" bugs that are not even marked as open

This is a double-edged sword. If somebody gets paid to do that, then that is 
one more reason for others not to do it.

And again, it is completely reasonable to be paid for that, and also for code 
reviews and writing test cases (if we want to complete the menial task list), 
but I am perplexed as to STF's stance on that.

>* Fund professional real live presence on multimedia / FOSS / buisness related
>  events. we already refund individuals but i think we are lacking on the 
> organizational
>  side. We should also have on these events at least one person who can awnser 
> developer/user
>  questions and someone who can awnser buisness questions (on buisness related 
> events).
>  Also we need some eye catching things there, a big screen/projector that 
> plays some
>  real time filtered version from a camera. Or maybe have more people remotely 
> be available
>  from the FFmpeg team through real time streaming (as in, if someone wants to 
> be on some event
>  but cant physically go there, we could put a notebook on the table facing 
> visitors showing
>  something like a video chat. Also we need more cute girls on these events, 
> everything i hear
>  its 100% male geeks/hackers. Also a "24/7" realtime stream from any booth 
> would be nice

This is not something that STF should pay for, AFAIU. This is something that 
professionals should pay out of their budget (or their employer's) for the 
business events, and SPI for cheap/community events, IMO.

Br,
___
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] [RFC] STF 2025

2024-05-17 Thread Ronald S. Bultje
Hi,

On Fri, May 17, 2024 at 9:50 AM Michael Niedermayer 
wrote:

> * Fund professional real live presence on multimedia / FOSS / buisness
> related
>   events. we already refund individuals but i think we are lacking on the
> organizational
>   side. We should also have on these events at least one person who can
> awnser developer/user
>   questions and someone who can awnser buisness questions (on buisness
> related events).
>

Maybe not 100% the same thing, but ... As you say, there's several of us
(including me) that attend some of these events. In addition to sponsoring
more people to go, I'd be very excited to wear FFmpeg gear and at least
make the FFmpeg brand more visible. (Right now I wear videolan gear at most
events.) Make some nice-looking hoodies etc. that we'd like to wear and
find an efficient way to distribute them.

Ronald
___
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] [RFC] STF 2025

2024-05-17 Thread Michael Niedermayer
Hi all

Before this is forgotten again, better start some dicsussion too early than too 
late

I propose that if we have the oppertunity again next year to receive a grant
from STF. That we use it to fund:

* Paul to work on FFmpeg full time. My idea here is that he can work on whatever
  he likes in FFmpeg (so its not full time employment for specific work but
  simply full time employment for him to work on whatever he likes in FFmpeg any
  way he likes) Paul is the 2nd largest contributor to FFmpeg (git shortlog -s 
-n)

* Fund administrative / maintainance work (one example is the mailman upgrade 
that is needed
  with the next OS upgrade on one of our servers (this is not as trivial as one 
might
  expect). Another example here may be some git related tools if we find 
something that
  theres a broad consensus about.

* Fund maintaince on the bug tracker, try to reproduce bugs, ask users to 
provide
  reproduceable cases, close bugs still unreproduceable, ...
  ATM we have over 2000 "new" bugs that are not even marked as open

* Fund professional real live presence on multimedia / FOSS / buisness related
  events. we already refund individuals but i think we are lacking on the 
organizational
  side. We should also have on these events at least one person who can awnser 
developer/user
  questions and someone who can awnser buisness questions (on buisness related 
events).
  Also we need some eye catching things there, a big screen/projector that 
plays some
  real time filtered version from a camera. Or maybe have more people remotely 
be available
  from the FFmpeg team through real time streaming (as in, if someone wants to 
be on some event
  but cant physically go there, we could put a notebook on the table facing 
visitors showing
  something like a video chat. Also we need more cute girls on these events, 
everything i hear
  its 100% male geeks/hackers. Also a "24/7" realtime stream from any booth 
would be nice

Thanks

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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 3/3] configure: split ISOBMFF writer helpers into a separate component

2024-05-17 Thread James Almer
Signed-off-by: James Almer 
---
 configure| 10 ++
 libavformat/Makefile | 16 
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index 275fa59bfd..b16722d83d 100755
--- a/configure
+++ b/configure
@@ -2587,6 +2587,7 @@ CONFIG_EXTRA="
 inflate_wrapper
 intrax8
 iso_media
+iso_writer
 ividsp
 jpegtables
 lgplv3
@@ -3611,7 +3612,7 @@ evc_demuxer_select="evc_frame_merge_bsf evc_parser"
 f4v_muxer_select="mov_muxer"
 fifo_muxer_deps="threads"
 flac_demuxer_select="flac_parser"
-flv_muxer_select="aac_adtstoasc_bsf"
+flv_muxer_select="aac_adtstoasc_bsf iso_writer"
 gxf_muxer_select="pcm_rechunk_bsf"
 hds_muxer_select="flv_muxer"
 hls_demuxer_select="aac_demuxer ac3_demuxer adts_header ac3_parser 
eac3_demuxer mov_demuxer mpegts_demuxer"
@@ -3629,12 +3630,12 @@ latm_muxer_select="aac_adtstoasc_bsf mpeg4audio"
 matroska_audio_muxer_select="matroska_muxer"
 matroska_demuxer_select="riffdec"
 matroska_demuxer_suggest="bzlib zlib"
-matroska_muxer_select="mpeg4audio riffenc aac_adtstoasc_bsf 
pgs_frame_merge_bsf vp9_superframe_bsf"
+matroska_muxer_select="iso_writer mpeg4audio riffenc aac_adtstoasc_bsf 
pgs_frame_merge_bsf vp9_superframe_bsf"
 mlp_demuxer_select="mlp_parser"
 mmf_muxer_select="riffenc"
 mov_demuxer_select="iso_media riffdec"
 mov_demuxer_suggest="iamfdec zlib"
-mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf 
aac_adtstoasc_bsf ac3_parser"
+mov_muxer_select="iso_media iso_writer riffenc rtpenc_chain vp9_superframe_bsf 
aac_adtstoasc_bsf ac3_parser"
 mov_muxer_suggest="iamfenc"
 mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
@@ -3642,7 +3643,7 @@ mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
 mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
-mxf_muxer_select="pcm_rechunk_bsf rangecoder"
+mxf_muxer_select="iso_writer pcm_rechunk_bsf rangecoder"
 mxf_d10_muxer_select="mxf_muxer"
 mxf_opatom_muxer_select="mxf_muxer"
 nut_muxer_select="riffenc"
@@ -3655,6 +3656,7 @@ ogv_muxer_select="ogg_muxer"
 opus_muxer_select="ogg_muxer"
 psp_muxer_select="mov_muxer"
 rtp_demuxer_select="sdp_demuxer"
+rtp_muxer_select="iso_writer"
 rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
 rtpdec_select="asf_demuxer mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol 
srtp"
 rtsp_demuxer_select="http_protocol rtpdec"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 211ccf45e5..1c4d9deccd 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -35,6 +35,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
 
 # subsystems
 OBJS-$(CONFIG_ISO_MEDIA) += isom.o
+OBJS-$(CONFIG_ISO_WRITER)+= av1.o avc.o hevc.o vvc.o vpcc.o
 OBJS-$(CONFIG_IAMFDEC)   += iamf_reader.o iamf_parse.o iamf.o
 OBJS-$(CONFIG_IAMFENC)   += iamf_writer.o iamf.o
 OBJS-$(CONFIG_NETWORK)   += network.o
@@ -220,7 +221,7 @@ OBJS-$(CONFIG_FLAC_MUXER)+= flacenc.o 
flacenc_header.o \
 OBJS-$(CONFIG_FLIC_DEMUXER)  += flic.o
 OBJS-$(CONFIG_FLV_DEMUXER)   += flvdec.o
 OBJS-$(CONFIG_LIVE_FLV_DEMUXER)  += flvdec.o
-OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o vpcc.o
+OBJS-$(CONFIG_FLV_MUXER) += flvenc.o
 OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o
 OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o
 OBJS-$(CONFIG_FRAMEHASH_MUXER)   += hashenc.o framehash.o
@@ -260,7 +261,7 @@ OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
 OBJS-$(CONFIG_EVC_DEMUXER)   += evcdec.o rawdec.o
 OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
-OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
+OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
 OBJS-$(CONFIG_IAMF_DEMUXER)  += iamfdec.o
 OBJS-$(CONFIG_IAMF_MUXER)+= iamfenc.o
@@ -349,7 +350,6 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -371,7 +371,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += 

[FFmpeg-devel] [PATCH 2/3] avformat/vvc: include additional bits in general_constraint_info

2024-05-17 Thread James Almer
Based on code from cbs_h266.

Signed-off-by: James Almer 
---
 libavformat/vvc.c | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 98177a7ad8..e8301d4247 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -46,7 +46,7 @@ typedef struct VVCPTLRecord {
 uint8_t general_level_idc;
 uint8_t ptl_frame_only_constraint_flag;
 uint8_t ptl_multilayer_enabled_flag;
-uint8_t general_constraint_info[9];
+uint8_t general_constraint_info[10];
 uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1];
 uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1];
 uint8_t ptl_num_sub_profiles;
@@ -77,8 +77,8 @@ typedef struct VVCCProfileTierLevel {
 uint8_t ptl_multilayer_enabled_flag;
 // general_constraint_info
 uint8_t gci_present_flag;
-uint8_t gci_general_constraints[9];
-uint8_t gci_num_reserved_bits;
+uint8_t gci_general_constraints[10];
+uint8_t num_bytes_constraint_info;
 // end general_constraint_info
 uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1];
 uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1];
@@ -135,13 +135,12 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord 
*vvcc,
 /*
  * Constraints Info
  */
+vvcc->ptl.num_bytes_constraint_info = ptl->num_bytes_constraint_info;
 if (ptl->gci_present_flag) {
-vvcc->ptl.num_bytes_constraint_info = 9;
 memcpy(>ptl.general_constraint_info[0],
-   >gci_general_constraints[0], sizeof(uint8_t) * 9);
+   >gci_general_constraints[0], 
ptl->num_bytes_constraint_info);
 } else {
-vvcc->ptl.num_bytes_constraint_info = 0;
-memset(>ptl.general_constraint_info[0], 0, sizeof(uint8_t) * 9);
+memset(>ptl.general_constraint_info[0], 0, 
sizeof(vvcc->ptl.general_constraint_info));
 }
 
 /*
@@ -186,7 +185,6 @@ static void vvcc_parse_ptl(GetBitContext *gb,
unsigned int max_sub_layers_minus1)
 {
 VVCCProfileTierLevel general_ptl = { 0 };
-int j;
 
 if (profileTierPresentFlag) {
 general_ptl.profile_idc = get_bits(gb, 7);
@@ -199,12 +197,20 @@ static void vvcc_parse_ptl(GetBitContext *gb,
 if (profileTierPresentFlag) {   // parse constraint info
 general_ptl.gci_present_flag = get_bits1(gb);
 if (general_ptl.gci_present_flag) {
+int gci_num_reserved_bits, j;
 for (j = 0; j < 8; j++)
 general_ptl.gci_general_constraints[j] = get_bits(gb, 8);
-general_ptl.gci_general_constraints[8] = get_bits(gb, 7);
-
-general_ptl.gci_num_reserved_bits = get_bits(gb, 8);
-skip_bits(gb, general_ptl.gci_num_reserved_bits);
+general_ptl.gci_general_constraints[j++] = get_bits(gb, 7);
+
+gci_num_reserved_bits = get_bits(gb, 8);
+if (gci_num_reserved_bits > 5) {
+general_ptl.gci_general_constraints[8] =
+(general_ptl.gci_general_constraints[8] << 1) | 
get_bits1(gb);
+general_ptl.gci_general_constraints[j++] = get_bits(gb, 5);
+gci_num_reserved_bits -= 6;
+}
+general_ptl.num_bytes_constraint_info = j;
+skip_bits(gb, gci_num_reserved_bits);
 }
 while (gb->index % 8 != 0)
 skip_bits1(gb);
-- 
2.45.1

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

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


[FFmpeg-devel] [PATCH 1/3 v3] avformat/vvc: fix writing general_constraint_info bytes

2024-05-17 Thread James Almer
The existing implementation was completely broken.

Signed-off-by: James Almer 
---
 libavformat/Makefile|  2 +-
 libavformat/bitstream.c |  1 +
 libavformat/vvc.c   | 38 --
 tests/ref/fate/source   |  1 +
 4 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 libavformat/bitstream.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2d4e0e0c95..211ccf45e5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -727,7 +727,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL)   += libssh.o
 OBJS-$(CONFIG_LIBZMQ_PROTOCOL)   += libzmq.o
 
 # Objects duplicated from other libraries for shared builds
-SHLIBOBJS+= log2_tab.o to_upper4.o
+SHLIBOBJS+= log2_tab.o to_upper4.o bitstream.o
 SHLIBOBJS-$(CONFIG_ISO_MEDIA)+= mpegaudiotabs.o
 SHLIBOBJS-$(CONFIG_FLV_MUXER)+= mpeg4audio_sample_rates.o
 SHLIBOBJS-$(CONFIG_HLS_DEMUXER)  += ac3_channel_layout_tab.o
diff --git a/libavformat/bitstream.c b/libavformat/bitstream.c
new file mode 100644
index 00..2afda37c30
--- /dev/null
+++ b/libavformat/bitstream.c
@@ -0,0 +1 @@
+#include "libavcodec/bitstream.c"
diff --git a/libavformat/vvc.c b/libavformat/vvc.c
index 3123cd8d83..98177a7ad8 100644
--- a/libavformat/vvc.c
+++ b/libavformat/vvc.c
@@ -21,6 +21,7 @@
  */
 
 #include "libavcodec/get_bits.h"
+#include "libavcodec/put_bits.h"
 #include "libavcodec/golomb.h"
 #include "libavcodec/vvc.h"
 #include "libavutil/intreadwrite.h"
@@ -138,9 +139,8 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord 
*vvcc,
 vvcc->ptl.num_bytes_constraint_info = 9;
 memcpy(>ptl.general_constraint_info[0],
>gci_general_constraints[0], sizeof(uint8_t) * 9);
-
 } else {
-vvcc->ptl.num_bytes_constraint_info = 1;
+vvcc->ptl.num_bytes_constraint_info = 0;
 memset(>ptl.general_constraint_info[0], 0, sizeof(uint8_t) * 9);
 }
 
@@ -185,7 +185,7 @@ static void vvcc_parse_ptl(GetBitContext *gb,
unsigned int profileTierPresentFlag,
unsigned int max_sub_layers_minus1)
 {
-VVCCProfileTierLevel general_ptl;
+VVCCProfileTierLevel general_ptl = { 0 };
 int j;
 
 if (profileTierPresentFlag) {
@@ -326,6 +326,7 @@ static int vvcc_parse_vps(GetBitContext *gb,
 
 for (int i = 0; i <= vps_num_ptls_minus1; i++)
 vvcc_parse_ptl(gb, vvcc, vps_pt_present_flag[i], vps_ptl_max_tid[i]);
+vvcc->ptl_present_flag = 1;
 
 /* nothing useful for vvcc past this point */
 return 0;
@@ -356,8 +357,10 @@ static int vvcc_parse_sps(GetBitContext *gb,
 vvcc->chroma_format_idc = get_bits(gb, 2);
 sps_log2_ctu_size_minus5 = get_bits(gb, 2);
 
-if (get_bits1(gb))  // sps_ptl_dpb_hrd_params_present_flag
+if (get_bits1(gb)) {// sps_ptl_dpb_hrd_params_present_flag
+vvcc->ptl_present_flag = 1;
 vvcc_parse_ptl(gb, vvcc, 1, sps_max_sublayers_minus1);
+}
 
 skip_bits1(gb); // sps_gdr_enabled_flag
 if (get_bits(gb, 1))// sps_ref_pic_resampling_enabled_flag
@@ -579,10 +582,6 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
 {
 memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord));
 vvcc->lengthSizeMinusOne = 3;   // 4 bytes
-
-vvcc->ptl.num_bytes_constraint_info = 1;
-
-vvcc->ptl_present_flag = 1;
 }
 
 static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
@@ -603,7 +602,6 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
 {
 uint8_t i;
 uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
-unsigned char *buf = NULL;
 /*
  * It's unclear how to properly compute these fields, so
  * let's always set them to values meaning 'unspecified'.
@@ -735,6 +733,10 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
 avio_w8(pb, vvcc->lengthSizeMinusOne << 1 | vvcc->ptl_present_flag | 0xf8);
 
 if (vvcc->ptl_present_flag) {
+uint8_t buf[64];
+PutBitContext pbc;
+
+init_put_bits(, buf, sizeof(buf));
 /*
  * unsigned int(9) ols_idx;
  * unsigned int(3) num_sublayers;
@@ -766,15 +768,15 @@ static int vvcc_write(AVIOContext *pb, 
VVCDecoderConfigurationRecord *vvcc)
  * unsigned int (1) ptl_frame_only_constraint_flag
  * unsigned int (1) ptl_multilayer_enabled_flag
  * unsigned int (8*num_bytes_constraint_info -2) 
general_constraint_info */
-buf =
-(unsigned char *) malloc(sizeof(unsigned char) *
- vvcc->ptl.num_bytes_constraint_info);
-*buf = vvcc->ptl.ptl_frame_only_constraint_flag << vvcc->ptl.
-num_bytes_constraint_info * 8 - 1 | vvcc->ptl.
-ptl_multilayer_enabled_flag << vvcc->ptl.num_bytes_constraint_info 
*
-8 - 2 | 

Re: [FFmpeg-devel] [PATCH v3 2/2] avcodec: add external dec libvvdec for H266/VVC

2024-05-17 Thread Christian



> On 14. May 2024, at 18:28, Lynne via ffmpeg-devel  
> wrote:
> 
> On 14/05/2024 17:09, Christian Bartnik wrote:
>> From: Thomas Siedel 
>> Add external decoder VVdeC for H266/VVC decoding.
>> Register new decoder libvvdec.
>> 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
> 
> I would prefer to have this one skipped, as initially suggested.

Ok, the next patch version will only contain libvvenc


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

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

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


Re: [FFmpeg-devel] [PATCH 3/6] lavf/tls_mbedtls: hook up debug message callback

2024-05-17 Thread Rémi Denis-Courmont


Le 17 mai 2024 11:34:35 GMT+03:00, Sfan5  a écrit :
>Signed-off-by: sfan5 
>---
> libavformat/tls_mbedtls.c | 14 ++
> 1 file changed, 14 insertions(+)
>
>diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
>index 24c3afd94c..9508fe3436 100644
>--- a/libavformat/tls_mbedtls.c
>+++ b/libavformat/tls_mbedtls.c
>@@ -26,6 +26,7 @@
> #include 
> #include 
> #include 
>+#include 
> #ifdef MBEDTLS_PSA_CRYPTO_C
> #include 
> #endif
>@@ -36,6 +37,7 @@
> #include "tls.h"
> #include "libavutil/mem.h"
> #include "libavutil/parseutils.h"
>+#include "libavutil/avstring.h"
>  typedef struct TLSContext {
> const AVClass *class;
>@@ -112,6 +114,13 @@ static int mbedtls_recv(void *ctx, unsigned char *buf, 
>size_t len)
> return handle_transport_error(h, "ffurl_read", MBEDTLS_ERR_SSL_WANT_READ, 
> ret);
> }
> +static void mbedtls_debug(void *ctx, int lvl, const char *file, int line, 
> const char *msg)
>+{
>+URLContext *h = (URLContext*) ctx;
>+int av_lvl = lvl >= 4 ? AV_LOG_TRACE : AV_LOG_DEBUG;
>+av_log(h, av_lvl, "%s:%d: %s", av_basename(file), line, msg);
>+}
>+
> static void handle_pk_parse_error(URLContext *h, int ret)
> {
> switch (ret) {
>@@ -201,6 +210,11 @@ static int tls_open(URLContext *h, const char *uri, int 
>flags, AVDictionary **op
> mbedtls_x509_crt_init(_ctx->ca_cert);
> mbedtls_pk_init(_ctx->priv_key);
> +if (av_log_get_level() >= AV_LOG_DEBUG) {
>+mbedtls_ssl_conf_dbg(_ctx->ssl_config, mbedtls_debug, shr->tcp);
>+mbedtls_debug_set_threshold(4); // maximum

This doesn't look thread-safe / reentrant.

>+}
>+
> // load trusted CA
> if (shr->ca_file) {
> if ((ret = mbedtls_x509_crt_parse_file(_ctx->ca_cert, 
> shr->ca_file)) != 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/6] lavf/tls_mbedtls: handle more error codes for human-readable message

2024-05-17 Thread Andrew Sayers
On Fri, May 17, 2024 at 10:34:26AM +0200, Sfan5 wrote:
> Signed-off-by: sfan5 
> ---
>  libavformat/tls_mbedtls.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
> index 1a182e735e..fd6ba0b1f5 100644
> --- a/libavformat/tls_mbedtls.c
> +++ b/libavformat/tls_mbedtls.c
> @@ -138,6 +138,9 @@ static void handle_handshake_error(URLContext *h, int
> ret)
>  case MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE:
>  av_log(h, AV_LOG_ERROR, "TLS handshake failed.\n");
>  break;
> +case MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION:
> +av_log(h, AV_LOG_ERROR, "TLS protocol version mismatches.\n");

"... mismatch" or "... does not match" would be more readable than "mismatches".

The word "matches" can mean either "does match" or "plural of match".
It's technically valid to use "mismatches" to mean "does not match",
but in practice the word is only ever used to mean "plural of mismatch".
___
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/6] lavf/tls_mbedtls: add workaround for TLSv1.3 vs. verify=0

2024-05-17 Thread Sfan5
As of mbedTLS 3.6.0 TLSv1.3 is enabled by default and certificate 
verification

is now mandatory. Our default configuration does not do verification, so
downgrade to 1.2 in these situations to avoid breaking it.

ref: https://github.com/Mbed-TLS/mbedtls/issues/7075
Signed-off-by: sfan5 
---
 libavformat/tls_mbedtls.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 8268e74638..5d5c7bfb25 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -163,6 +163,10 @@ static void handle_handshake_error(URLContext *h, 
int ret)

 case MBEDTLS_ERR_SSL_INTERNAL_ERROR:
 av_log(h, AV_LOG_ERROR, "Internal error encountered.\n");
 break;
+case MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:
+// This error only happens with TLSv1.3, we normally use 
mbedtls_ssl_get_verify_result().

+av_log(h, AV_LOG_ERROR, "Certificate verification failed.\n");
+break;
 case MBEDTLS_ERR_NET_CONN_RESET:
 av_log(h, AV_LOG_ERROR, "TLS handshake was aborted by peer.\n");
 break;
@@ -263,6 +267,14 @@ static int tls_open(URLContext *h, const char *uri, 
int flags, AVDictionary **op

 goto fail;
 }
 +#ifdef MBEDTLS_SSL_PROTO_TLS1_3
+// mbedTLS does not allow disabling certificate verification with 
TLSv1.3 (yes, really).

+if (!shr->verify) {
+av_log(h, AV_LOG_INFO, "Forcing TLSv1.2 because certificate 
verification is disabled\n");
+mbedtls_ssl_conf_max_tls_version(_ctx->ssl_config, 
MBEDTLS_SSL_VERSION_TLS1_2);

+}
+#endif
+
 // not VERIFY_REQUIRED because we manually check after handshake
 mbedtls_ssl_conf_authmode(_ctx->ssl_config,
   shr->verify ? 
MBEDTLS_SSL_VERIFY_OPTIONAL : MBEDTLS_SSL_VERIFY_NONE);

--
2.45.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 5/6] lavf/tls_mbedtls: handle session ticket error code as no-op

2024-05-17 Thread Sfan5

When TLSv1.3 and session tickets are enabled mbedtls_ssl_read()
will return an error code to inform about a received session ticket.
This can simply be handled like EAGAIN instead of errornously
aborting the connection.

ref: https://github.com/Mbed-TLS/mbedtls/issues/8749
Signed-off-by: sfan5 
---
 libavformat/tls_mbedtls.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 67d5c568b9..8268e74638 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -322,6 +322,9 @@ static int handle_tls_error(URLContext *h, const 
char* func_name, int ret)

 switch (ret) {
 case MBEDTLS_ERR_SSL_WANT_READ:
 case MBEDTLS_ERR_SSL_WANT_WRITE:
+#ifdef MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET
+case MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET:
+#endif
 return AVERROR(EAGAIN);
 case MBEDTLS_ERR_NET_SEND_FAILED:
 case MBEDTLS_ERR_NET_RECV_FAILED:
--
2.45.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/6] lavf/tls_mbedtls: fix handling of certification validation failures

2024-05-17 Thread Sfan5

We manually check the verification status after the handshake has completed
using mbedtls_ssl_get_verify_result(). However with VERIFY_REQUIRED
mbedtls_ssl_handshake() already returns an error, so this code is never 
reached.

Fix that by using VERIFY_OPTIONAL, which performs the verification but
does not abort the handshake.

Signed-off-by: sfan5 
---
 libavformat/tls_mbedtls.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 9508fe3436..67d5c568b9 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -263,8 +263,9 @@ static int tls_open(URLContext *h, const char *uri, 
int flags, AVDictionary **op

 goto fail;
 }
 +// not VERIFY_REQUIRED because we manually check after handshake
 mbedtls_ssl_conf_authmode(_ctx->ssl_config,
-  shr->verify ? MBEDTLS_SSL_VERIFY_REQUIRED 
: MBEDTLS_SSL_VERIFY_NONE);
+  shr->verify ? MBEDTLS_SSL_VERIFY_OPTIONAL 
: MBEDTLS_SSL_VERIFY_NONE);
 mbedtls_ssl_conf_rng(_ctx->ssl_config, 
mbedtls_ctr_drbg_random, _ctx->ctr_drbg_context);
 mbedtls_ssl_conf_ca_chain(_ctx->ssl_config, _ctx->ca_cert, 
NULL);

 -- 2.45.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/6] lavf/tls_mbedtls: hook up debug message callback

2024-05-17 Thread Sfan5

Signed-off-by: sfan5 
---
 libavformat/tls_mbedtls.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 24c3afd94c..9508fe3436 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef MBEDTLS_PSA_CRYPTO_C
 #include 
 #endif
@@ -36,6 +37,7 @@
 #include "tls.h"
 #include "libavutil/mem.h"
 #include "libavutil/parseutils.h"
+#include "libavutil/avstring.h"
  typedef struct TLSContext {
 const AVClass *class;
@@ -112,6 +114,13 @@ static int mbedtls_recv(void *ctx, unsigned char 
*buf, size_t len)
 return handle_transport_error(h, "ffurl_read", 
MBEDTLS_ERR_SSL_WANT_READ, ret);

 }
 +static void mbedtls_debug(void *ctx, int lvl, const char *file, int 
line, const char *msg)

+{
+URLContext *h = (URLContext*) ctx;
+int av_lvl = lvl >= 4 ? AV_LOG_TRACE : AV_LOG_DEBUG;
+av_log(h, av_lvl, "%s:%d: %s", av_basename(file), line, msg);
+}
+
 static void handle_pk_parse_error(URLContext *h, int ret)
 {
 switch (ret) {
@@ -201,6 +210,11 @@ static int tls_open(URLContext *h, const char *uri, 
int flags, AVDictionary **op

 mbedtls_x509_crt_init(_ctx->ca_cert);
 mbedtls_pk_init(_ctx->priv_key);
 +if (av_log_get_level() >= AV_LOG_DEBUG) {
+mbedtls_ssl_conf_dbg(_ctx->ssl_config, mbedtls_debug, 
shr->tcp);

+mbedtls_debug_set_threshold(4); // maximum
+}
+
 // load trusted CA
 if (shr->ca_file) {
 if ((ret = mbedtls_x509_crt_parse_file(_ctx->ca_cert, 
shr->ca_file)) != 0) {

--
2.45.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/6] lavf/tls_mbedtls: add missing call to psa_crypto_init

2024-05-17 Thread Sfan5

This is mandatory depending on configuration or at least with mbedTLS 3.6.0.

Signed-off-by: sfan5 
---
 libavformat/tls_mbedtls.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index fd6ba0b1f5..24c3afd94c 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -26,6 +26,9 @@
 #include 
 #include 
 #include 
+#ifdef MBEDTLS_PSA_CRYPTO_C
+#include 
+#endif
  #include "avformat.h"
 #include "internal.h"
@@ -184,6 +187,13 @@ static int tls_open(URLContext *h, const char *uri, 
int flags, AVDictionary **op

 if ((ret = ff_tls_open_underlying(shr, h, uri, options)) < 0)
 goto fail;
 +#ifdef MBEDTLS_PSA_CRYPTO_C
+if ((ret = psa_crypto_init()) != PSA_SUCCESS) {
+av_log(h, AV_LOG_ERROR, "psa_crypto_init returned %d\n", ret);
+goto fail;
+}
+#endif
+
 mbedtls_ssl_init(_ctx->ssl_context);
 mbedtls_ssl_config_init(_ctx->ssl_config);
 mbedtls_entropy_init(_ctx->entropy_context);
--
2.45.1

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

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


[FFmpeg-devel] [PATCH 1/6] lavf/tls_mbedtls: handle more error codes for human-readable message

2024-05-17 Thread Sfan5

Signed-off-by: sfan5 
---
 libavformat/tls_mbedtls.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/tls_mbedtls.c b/libavformat/tls_mbedtls.c
index 1a182e735e..fd6ba0b1f5 100644
--- a/libavformat/tls_mbedtls.c
+++ b/libavformat/tls_mbedtls.c
@@ -138,6 +138,9 @@ static void handle_handshake_error(URLContext *h, 
int ret)

 case MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE:
 av_log(h, AV_LOG_ERROR, "TLS handshake failed.\n");
 break;
+case MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION:
+av_log(h, AV_LOG_ERROR, "TLS protocol version mismatches.\n");
+break;
 #endif
 case MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE:
 av_log(h, AV_LOG_ERROR, "A fatal alert message was received 
from the peer, has the peer a correct certificate?\n");
@@ -145,6 +148,9 @@ static void handle_handshake_error(URLContext *h, 
int ret)

 case MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED:
 av_log(h, AV_LOG_ERROR, "No CA chain is set, but required to 
operate. Was the CA correctly set?\n");

 break;
+case MBEDTLS_ERR_SSL_INTERNAL_ERROR:
+av_log(h, AV_LOG_ERROR, "Internal error encountered.\n");
+break;
 case MBEDTLS_ERR_NET_CONN_RESET:
 av_log(h, AV_LOG_ERROR, "TLS handshake was aborted by peer.\n");
 break;
--
2.45.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 4/5] avcodec/sga: Check non constant init_get_bits8()

2024-05-17 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: CID1473562 Unchecked return value
> Fixes: CID1473592 Unchecked return value
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/sga.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/sga.c b/libavcodec/sga.c
> index 0f42cf912b2..aca941e057e 100644
> --- a/libavcodec/sga.c
> +++ b/libavcodec/sga.c
> @@ -254,11 +254,14 @@ static int decode_palmapdata(AVCodecContext *avctx)
>  const int bits = (s->nb_pal + 1) / 2;
>  GetByteContext *gb = >gb;
>  GetBitContext pm;
> +int ret;
>  
>  bytestream2_seek(gb, s->palmapdata_offset, SEEK_SET);
>  if (bytestream2_get_bytes_left(gb) < s->palmapdata_size)
>  return AVERROR_INVALIDDATA;
> -init_get_bits8(, gb->buffer, s->palmapdata_size);
> +ret = init_get_bits8(, gb->buffer, s->palmapdata_size);
> +if (ret < 0)
> +return ret;
>  
>  for (int y = 0; y < s->tiles_h; y++) {
>  uint8_t *dst = s->palmapindex_data + y * s->tiles_w;
> @@ -277,11 +280,14 @@ static int decode_tiledata(AVCodecContext *avctx)
>  SGAVideoContext *s = avctx->priv_data;
>  GetByteContext *gb = >gb;
>  GetBitContext tm;
> +int ret;
>  
>  bytestream2_seek(gb, s->tiledata_offset, SEEK_SET);
>  if (bytestream2_get_bytes_left(gb) < s->tiledata_size)
>  return AVERROR_INVALIDDATA;
> -init_get_bits8(, gb->buffer, s->tiledata_size);
> +ret = init_get_bits8(, gb->buffer, s->tiledata_size);
> +if (ret < 0)
> +return ret;
>  
>  for (int n = 0; n < s->nb_tiles; n++) {
>  uint8_t *dst = s->tileindex_data + n * 64;

Both of these can not fail and could be checked via av_assert1:
palmapdata_size is given by (s->tiles_w * s->tiles_h * ((s->nb_pal + 1)
/ 2) + 7) / 8 with tiles_w and tiles_h being in the 0..255 range and
nb_pal being in the 0..4 range.
tiledata_size is given by s->nb_tiles * 32; nb_tiles fits in 16 bits (it
is either read via AV_RB16 or is given as the product of tiles_h *
tiles_w, both of which are read from simple uint8_t.

- Andreas

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

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