[FFmpeg-devel] [PATCH 0/4] Check sample rate generically

2025-06-23 Thread ffmpegagent
This is an alternative to
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-June/345575.html.

Andreas Rheinhardt (4):
  avcodec/avcodec: Check sample_rate generically
  avcodec/wma,wmaprodec: Remove always-false checks
  avcodec/wma: Remove redundant nb_channels check
  avcodec/wmaprodec: Avoid branch for setting block_align

 libavcodec/avcodec.c   |  6 +-
 libavcodec/encode.c|  5 -
 libavcodec/wma.c   |  4 ++--
 libavcodec/wmaprodec.c | 20 +++-
 4 files changed, 14 insertions(+), 21 deletions(-)


base-commit: 34953e195fe108224abdfe25d147f1a7ba5477c8
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-101%2Fmkver%2Fsample_rate_check-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-101/mkver/sample_rate_check-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/101
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 4/4] avcodec/wmaprodec: Avoid branch for setting block_align

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wmaprodec.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 7f3dc7fd8b..d87ed0433e 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -370,14 +370,6 @@ static av_cold int decode_init(WMAProDecodeCtx *s, 
AVCodecContext *avctx, int nu
 int log2_max_num_subframes;
 int num_possible_block_sizes;
 
-if (avctx->codec_id == AV_CODEC_ID_XMA1 || avctx->codec_id == 
AV_CODEC_ID_XMA2)
-avctx->block_align = 2048;
-
-if (!avctx->block_align) {
-av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
-return AVERROR(EINVAL);
-}
-
 s->avctx = avctx;
 
 init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
@@ -603,6 +595,11 @@ static av_cold int wmapro_decode_init(AVCodecContext 
*avctx)
 {
 WMAProDecodeCtx *s = avctx->priv_data;
 
+if (!avctx->block_align) {
+av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
+return AVERROR(EINVAL);
+}
+
 return decode_init(s, avctx, 0);
 }
 
@@ -1957,6 +1954,8 @@ static av_cold int xma_decode_init(AVCodecContext *avctx)
 XMADecodeCtx *s = avctx->priv_data;
 int i, ret, start_channels = 0;
 
+avctx->block_align = 2048;
+
 if (avctx->ch_layout.nb_channels <= 0 || avctx->extradata_size == 0)
 return AVERROR_INVALIDDATA;
 
-- 
ffmpeg-codebot
___
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/mss2dsp: use FF_PTR_ADD to add offsets to a pointer

2025-06-23 Thread James Almer
Fixes: libavcodec/mss2dsp.c:59:14: runtime error: applying zero offset to null 
pointer

Signed-off-by: James Almer 
---
Untested, as gcc-usan on Linux x86_64 doesn't complain about it, but it can be 
seen in
https://fate.ffmpeg.org/report.cgi?time=20250622122557&slot=amd64-clang-cl-msvc-asan

 libavcodec/mss2dsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mss2dsp.c b/libavcodec/mss2dsp.c
index cc39dd637f..4180c65577 100644
--- a/libavcodec/mss2dsp.c
+++ b/libavcodec/mss2dsp.c
@@ -56,7 +56,7 @@ static av_always_inline void mss2_blit_wmv9_template(uint8_t 
*dst,
 }
 }
 }
-mask +=  mask_stride;
+FF_PTR_ADD(mask, mask_stride);
 dst  +=   dst_stride;
 srcy +=  srcy_stride;
 srcu += srcuv_stride * (r & 1);
-- 
2.50.0

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

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


[FFmpeg-devel] [PATCH] avcodec/g728dec: Remove AVCodec.sample_fmts

2025-06-23 Thread Andreas Rheinhardt
Patch attached.

- Andreas
From e2b8892a583a09ca4aa607af8813b4947c2e6fc1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt 
Date: Mon, 23 Jun 2025 12:41:36 +0200
Subject: [PATCH] avcodec/g728dec: Remove AVCodec.sample_fmts

It is unnecessary for decoders (they just set
AVCodecContext.sample_fmt). This also fixes a warning
with Clang (because sample_fmts is set directly,
not via CODEC_SAMPLEFMTS).

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

diff --git a/libavcodec/g728dec.c b/libavcodec/g728dec.c
index fdaf0a853e..edf45c589b 100644
--- a/libavcodec/g728dec.c
+++ b/libavcodec/g728dec.c
@@ -215,6 +215,4 @@ const FFCodec ff_g728_decoder = {
 FF_CODEC_DECODE_CB(g728_decode_frame),
 .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
   AV_CODEC_CAP_DR1,
-.p.sample_fmts  = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
-  AV_SAMPLE_FMT_NONE },
 };
-- 
2.45.2

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

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/osq: Fix signed integer overflow in update_stats()

2025-06-23 Thread Michael Niedermayer
On Tue, Jun 17, 2025 at 03:17:23AM +0200, Michael Niedermayer wrote:
> Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to 
> an unsigned type to negate this value to itself
> Fixes: 
> 410109093/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6550900028276736
> 
> Note, none of the available osq files uses update_stats(), this change may 
> fix or break
> files using coding_mode == 2. The code prior looks wrong though
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/osq.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset

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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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] avcodec/osq: Request a coding mode 2 sample

2025-06-23 Thread Michael Niedermayer
On Wed, Jun 18, 2025 at 02:44:21AM +0200, Michael Niedermayer wrote:
> On Wed, Jun 18, 2025 at 09:14:40AM +1000, Peter Ross wrote:
> > On Tue, Jun 17, 2025 at 10:32:16PM +0200, Michael Niedermayer wrote:
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavcodec/osq.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/libavcodec/osq.c b/libavcodec/osq.c
> > > index 025be667a35..0de9af5f623 100644
> > > --- a/libavcodec/osq.c
> > > +++ b/libavcodec/osq.c
> > > @@ -212,6 +212,8 @@ static int osq_channel_parameters(AVCodecContext 
> > > *avctx, int ch)
> > >  cb->residue_parameter = get_urice(gb, 4);
> > >  if (!cb->residue_parameter || cb->residue_parameter >= 31)
> > >  return AVERROR_INVALIDDATA;
> > > +if (cb->coding_mode == 2)
> > > +avpriv_request_sample(avctx, "coding mode 2\n");
> > 
> > nit: there is no need for newline character with avpriv_request_sample()
> 
> corrected locally

will apply

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/iamf_parse: Check extradata size

2025-06-23 Thread Michael Niedermayer
On Fri, Jun 20, 2025 at 12:28:13AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
> > Fixes: 
> > 398527871/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6602025714647040
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/iamf_parse.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
> > index 71497876ac3..330e01733dd 100644
> > --- a/libavformat/iamf_parse.c
> > +++ b/libavformat/iamf_parse.c
> > @@ -305,6 +305,8 @@ static int update_extradata(AVCodecParameters *codecpar)
> >  skip_bits(&gb, 4);
> >  put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set channel 
> > config
> >  ret = put_bits_left(&pb);
> > +if (ret < 0)
> > +return AVERROR_INVALIDDATA;
> >  while (ret >= 32) {
> > put_bits32(&pb, get_bits_long(&gb, 32));
> > ret -= 32;
> 
> There is only one way for put_bits_left() to return a negative value: If
> there is more data in the internal buffer than can be written out. And
> this scenario is already a violation of the PutBit API. Given that the
> size of the internal buffer depends upon the arch, it could be that one
> would have already hit an assert in case one is not using x64. In other
> words, your check is too late.

the patches puprose was mainly to show that
3f9420132441345b7ccd57001f230bb98f655696
was insufficient to fix 398527871

I do not expect my patch would be the correct solution even if the
check is done earlier. IAMF is cursed

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

You can kill me, but you cannot change the truth.


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 3/4] avcodec/sanm: Check w, h for subversion < 2

2025-06-23 Thread Michael Niedermayer
Hi Manuel

On Thu, Jun 19, 2025 at 05:04:30AM +0200, Michael Niedermayer wrote:
> Fixes: 
> 410609432/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-4935159201988608
> Fixes: out of array access
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/sanm.c | 2 ++
>  1 file changed, 2 insertions(+)

is this and the next patch correct ?
please review

thx

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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


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

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/iamf_parse: Check extradata size

2025-06-23 Thread James Almer

On 6/23/2025 9:44 AM, Michael Niedermayer wrote:

On Fri, Jun 20, 2025 at 12:28:13AM +0200, Andreas Rheinhardt wrote:

Michael Niedermayer:

Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
Fixes: 
398527871/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6602025714647040

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

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 71497876ac3..330e01733dd 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -305,6 +305,8 @@ static int update_extradata(AVCodecParameters *codecpar)
  skip_bits(&gb, 4);
  put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set channel 
config
  ret = put_bits_left(&pb);
+if (ret < 0)
+return AVERROR_INVALIDDATA;
  while (ret >= 32) {
 put_bits32(&pb, get_bits_long(&gb, 32));
 ret -= 32;


There is only one way for put_bits_left() to return a negative value: If
there is more data in the internal buffer than can be written out. And
this scenario is already a violation of the PutBit API. Given that the
size of the internal buffer depends upon the arch, it could be that one
would have already hit an assert in case one is not using x64. In other
words, your check is too late.


the patches puprose was mainly to show that
3f9420132441345b7ccd57001f230bb98f655696
was insufficient to fix 398527871

I do not expect my patch would be the correct solution even if the
check is done earlier. IAMF is cursed


Does increasing buf from 6 bytes to 8 or more fix it? I see putbits may 
do an AV_W*64(), so six bytes sounds like it was never safe.




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

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


Re: [FFmpeg-devel] [PATCH 2/4] tools/target_dec_fuzzer: Adjust RV60 threshold

2025-06-23 Thread Michael Niedermayer
On Thu, Jun 19, 2025 at 05:04:29AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 410324670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5697706586865664
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

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

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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 2/4] avfilter/asrc_sinc: fix leak in config_input()

2025-06-23 Thread ld y
Michael Niedermayer  writes:

> does the other return in config_output() not need this free too?
>

I believe all the other return behind fir_to_phase() has called
av_free(h[longer])
already. I would love to add this message to my next patch series.

Thanks,
Lidong
___
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/4] avformat/sapenc: fix leak in sap_write_header()

2025-06-23 Thread ld y
Michael Niedermayer  writes:

> this can be factored like:
>
> like
> +ret = 0;
>  fail:
> +for (i = 0; i < s->nb_streams; i++)
> +if (contexts[i])
> +av_free(contexts[i]->url);
> av_free(contexts);
> +   if (ret < 0)
> sap_write_close(s);
>

Yeah this looks much better. I will use it in my v2 patch.

One more question, would it be ok to rename fail label to end label.
I'm not sure if it's worth the change, though.

Thanks,
Lidong
___
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/4] avformat/iamf_parse: Check extradata size

2025-06-23 Thread Andreas Rheinhardt
James Almer:
> On 6/23/2025 9:44 AM, Michael Niedermayer wrote:
>> On Fri, Jun 20, 2025 at 12:28:13AM +0200, Andreas Rheinhardt wrote:
>>> Michael Niedermayer:
 Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
 Fixes: 398527871/clusterfuzz-testcase-minimized-
 ffmpeg_dem_IAMF_fuzzer-6602025714647040

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

 diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
 index 71497876ac3..330e01733dd 100644
 --- a/libavformat/iamf_parse.c
 +++ b/libavformat/iamf_parse.c
 @@ -305,6 +305,8 @@ static int update_extradata(AVCodecParameters
 *codecpar)
   skip_bits(&gb, 4);
   put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set
 channel config
   ret = put_bits_left(&pb);
 +    if (ret < 0)
 +    return AVERROR_INVALIDDATA;
   while (ret >= 32) {
  put_bits32(&pb, get_bits_long(&gb, 32));
  ret -= 32;
>>>
>>> There is only one way for put_bits_left() to return a negative value: If
>>> there is more data in the internal buffer than can be written out. And
>>> this scenario is already a violation of the PutBit API. Given that the
>>> size of the internal buffer depends upon the arch, it could be that one
>>> would have already hit an assert in case one is not using x64. In other
>>> words, your check is too late.
>>
>> the patches puprose was mainly to show that
>> 3f9420132441345b7ccd57001f230bb98f655696
>> was insufficient to fix 398527871
>>
>> I do not expect my patch would be the correct solution even if the
>> check is done earlier. IAMF is cursed
> 
> Does increasing buf from 6 bytes to 8 or more fix it? I see putbits may
> do an AV_W*64(), so six bytes sounds like it was never safe.
> 
That is only executed when the internal bit buffer is full; you will
never reach it on x64. The problem is that you initialize the put bits
buffer with FFMIN(codecpar->extradata_size, sizeof(buf)) instead of
sizeof(buf). If this were not so, there would always be bits left.
But this only fixes the API violations, it does not guarantee that the
written data is actually correct. What is actually in the data that gets
written in the loop?

- 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 09/48] avcodec/mpeg_er: Don't use MpegEncContext.block

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

It is unused (because unquantizing/the idct has been disabled)
apart from FF_DEBUG_DCT_COEFF debug code which makes no sense
when this function is called via error resilience. So pass a NULL
as block when calling ff_mpv_reconstruct_mb() from mpeg_er_decode_mb()
and disable the debug code in this scenario.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg_er.c   | 4 ++--
 libavcodec/mpegvideo_dec.c | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index 6ac3e7b3e7..951167a478 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -76,7 +76,7 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int 
mv_dir, int mv_type,
 s->mcsel  = 0;
 memcpy(s->mv, mv, sizeof(*mv));
 
-// The following disables the IDCT.
+// The following disables unquantizing and the IDCT.
 for (size_t i = 0; i < FF_ARRAY_ELEMS(s->block_last_index); i++)
 s->block_last_index[i] = -1;
 
@@ -93,7 +93,7 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int 
mv_dir, int mv_type,
 if (ref)
 av_log(s->avctx, AV_LOG_DEBUG,
"Interlaced error concealment is not fully implemented\n");
-ff_mpv_reconstruct_mb(s, s->block);
+ff_mpv_reconstruct_mb(s, NULL);
 }
 
 av_cold int ff_mpeg_er_init(MpegEncContext *s)
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 903d435e8c..928464d6c1 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -1066,6 +1066,9 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 
 static av_cold void debug_dct_coeffs(MPVContext *s, const int16_t block[][64])
 {
+if (!block) // happens when called via error resilience
+return;
+
 void *const logctx = s->avctx;
 const uint8_t *const idct_permutation = s->idsp.idct_permutation;
 
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 08/48] avcodec/mpegvideo_dec: Reindent after the previous commit

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Also use dedicated variables for the accesses.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_dec.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index c687f3a972..903d435e8c 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -1066,15 +1066,18 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 
 static av_cold void debug_dct_coeffs(MPVContext *s, const int16_t block[][64])
 {
-   /* print DCT coefficients */
-   av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, 
s->mb_y);
-   for (int i = 0; i < 6; i++) {
-   for (int j = 0; j < 64; j++) {
-   av_log(s->avctx, AV_LOG_DEBUG, "%5d",
-  block[i][s->idsp.idct_permutation[j]]);
-   }
-   av_log(s->avctx, AV_LOG_DEBUG, "\n");
-   }
+void *const logctx = s->avctx;
+const uint8_t *const idct_permutation = s->idsp.idct_permutation;
+
+/* print DCT coefficients */
+av_log(logctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, 
s->mb_y);
+for (int i = 0; i < 6; i++) {
+for (int j = 0; j < 64; j++) {
+av_log(logctx, AV_LOG_DEBUG, "%5d",
+   block[i][idct_permutation[j]]);
+}
+av_log(logctx, AV_LOG_DEBUG, "\n");
+}
 }
 
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 07/48] avcodec/mpegvideo_dec: Factor debugging dct coefficients out

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This allows to hint to the compiler that the branch is likely
not taken by marking the factored out function as av_cold.
It is also in preparation for further commits.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_dec.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index f8551b93c8..c687f3a972 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -1064,6 +1064,19 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, 
int16_t block[12][64],
 }
 }
 
+static av_cold void debug_dct_coeffs(MPVContext *s, const int16_t block[][64])
+{
+   /* print DCT coefficients */
+   av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, 
s->mb_y);
+   for (int i = 0; i < 6; i++) {
+   for (int j = 0; j < 64; j++) {
+   av_log(s->avctx, AV_LOG_DEBUG, "%5d",
+  block[i][s->idsp.idct_permutation[j]]);
+   }
+   av_log(s->avctx, AV_LOG_DEBUG, "\n");
+   }
+}
+
 void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
 {
 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
@@ -1082,17 +1095,8 @@ void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t 
block[12][64])
 *mbskip_ptr = 0; /* not skipped */
 }
 
-if (s->avctx->debug & FF_DEBUG_DCT_COEFF) {
-   /* print DCT coefficients */
-   av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, 
s->mb_y);
-   for (int i = 0; i < 6; i++) {
-   for (int j = 0; j < 64; j++) {
-   av_log(s->avctx, AV_LOG_DEBUG, "%5d",
-  block[i][s->idsp.idct_permutation[j]]);
-   }
-   av_log(s->avctx, AV_LOG_DEBUG, "\n");
-   }
-}
+if (s->avctx->debug & FF_DEBUG_DCT_COEFF)
+debug_dct_coeffs(s, block);
 
 av_assert2((s->out_format <= FMT_H261) == (s->out_format == FMT_H261 || 
s->out_format == FMT_MPEG1));
 if (!s->avctx->lowres) {
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 06/48] avcodec/mpegvideo: Add MPVContext typedef

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

MpegEncContext is also used for decoding, so it is a misnomer.
This commit therefore adds MPVContext as typedef for it in order
to gradually switch the code to the new name (in line with
MPVEncContext).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 4ff5e8906d..fe3ae97f5d 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -332,6 +332,7 @@ typedef struct MpegEncContext {
 ERContext er;
 } MpegEncContext;
 
+typedef MpegEncContext MPVContext;
 
 /**
  * Set the given MpegEncContext to common defaults (same for encoding
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 13/48] avcodec/mpeg12dec: Put GetBitContext on the stack where advantageous

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This is in preparation for no longer using MpegEncContext.gb.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 192 ++---
 1 file changed, 102 insertions(+), 90 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 5d2719d0f0..ec8b213206 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -44,6 +44,7 @@
 #include "codec_internal.h"
 #include "decode.h"
 #include "error_resilience.h"
+#include "get_bits.h"
 #include "hwaccel_internal.h"
 #include "hwconfig.h"
 #include "idctdsp.h"
@@ -969,23 +970,24 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, 
const uint8_t *buf,
 {
 Mpeg1Context *s1  = avctx->priv_data;
 MpegEncContext *s = &s1->mpeg_enc_ctx;
+GetBitContext gb0, *const gb = &gb0;
 int ref, f_code, vbv_delay, ret;
 
-ret = init_get_bits8(&s->gb, buf, buf_size);
+ret = init_get_bits8(gb, buf, buf_size);
 if (ret < 0)
 return ret;
 
-ref = get_bits(&s->gb, 10); /* temporal ref */
-s->pict_type = get_bits(&s->gb, 3);
+ref = get_bits(gb, 10); /* temporal ref */
+s->pict_type = get_bits(gb, 3);
 if (s->pict_type == 0 || s->pict_type > 3)
 return AVERROR_INVALIDDATA;
 
-vbv_delay = get_bits(&s->gb, 16);
+vbv_delay = get_bits(gb, 16);
 s1->vbv_delay = vbv_delay;
 if (s->pict_type == AV_PICTURE_TYPE_P ||
 s->pict_type == AV_PICTURE_TYPE_B) {
-s->full_pel[0] = get_bits1(&s->gb);
-f_code = get_bits(&s->gb, 3);
+s->full_pel[0] = get_bits1(gb);
+f_code = get_bits(gb, 3);
 if (f_code == 0 && (avctx->err_recognition & 
(AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
 return AVERROR_INVALIDDATA;
 f_code += !f_code;
@@ -993,8 +995,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, 
const uint8_t *buf,
 s->mpeg_f_code[0][1] = f_code;
 }
 if (s->pict_type == AV_PICTURE_TYPE_B) {
-s->full_pel[1] = get_bits1(&s->gb);
-f_code = get_bits(&s->gb, 3);
+s->full_pel[1] = get_bits1(gb);
+f_code = get_bits(gb, 3);
 if (f_code == 0 && (avctx->err_recognition & 
(AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
 return AVERROR_INVALIDDATA;
 f_code += !f_code;
@@ -1009,38 +1011,39 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, 
const uint8_t *buf,
 return 0;
 }
 
-static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
+static void mpeg_decode_sequence_extension(Mpeg1Context *const s1,
+   GetBitContext *const gb)
 {
 MpegEncContext *s = &s1->mpeg_enc_ctx;
 int horiz_size_ext, vert_size_ext;
 int bit_rate_ext;
 
-skip_bits(&s->gb, 1); /* profile and level esc*/
-s->avctx->profile   = get_bits(&s->gb, 3);
-s->avctx->level = get_bits(&s->gb, 4);
-s->progressive_sequence = get_bits1(&s->gb);   /* progressive_sequence */
-s->chroma_format= get_bits(&s->gb, 2); /* chroma_format 1=420, 
2=422, 3=444 */
+skip_bits(gb, 1); /* profile and level esc*/
+s->avctx->profile   = get_bits(gb, 3);
+s->avctx->level = get_bits(gb, 4);
+s->progressive_sequence = get_bits1(gb);   /* progressive_sequence */
+s->chroma_format= get_bits(gb, 2); /* chroma_format 1=420, 2=422, 
3=444 */
 
 if (!s->chroma_format) {
 s->chroma_format = CHROMA_420;
 av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n");
 }
 
-horiz_size_ext  = get_bits(&s->gb, 2);
-vert_size_ext   = get_bits(&s->gb, 2);
+horiz_size_ext  = get_bits(gb, 2);
+vert_size_ext   = get_bits(gb, 2);
 s->width  |= (horiz_size_ext << 12);
 s->height |= (vert_size_ext  << 12);
-bit_rate_ext = get_bits(&s->gb, 12);  /* XXX: handle it */
+bit_rate_ext = get_bits(gb, 12);  /* XXX: handle it */
 s1->bit_rate += (bit_rate_ext << 18) * 400LL;
-check_marker(s->avctx, &s->gb, "after bit rate extension");
-s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10;
+check_marker(s->avctx, gb, "after bit rate extension");
+s->avctx->rc_buffer_size += get_bits(gb, 8) * 1024 * 16 << 10;
 
-s->low_delay = get_bits1(&s->gb);
+s->low_delay = get_bits1(gb);
 if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
 s->low_delay = 1;
 
-s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1;
-s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1;
+s1->frame_rate_ext.num = get_bits(gb, 2) + 1;
+s1->frame_rate_ext.den = get_bits(gb, 5) + 1;
 
 ff_dlog(s->avctx, "sequence extension\n");
 s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
@@ -1052,21 +1055,22 @@ static void mpeg_decode_sequence_extension(Mpeg1Context 
*s1)
s->avctx->rc_buffer_size, s1->bit_rate);
 }
 
-static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
+static void mpeg_decode_sequence_display_ext

[FFmpeg-devel] [PATCH 11/48] avcodec/h261dec: Stop using MpegEncContext.gb

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This is in preparation for removing said field from MpegEncContext.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h261dec.c | 80 +++-
 1 file changed, 41 insertions(+), 39 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 146f979a5e..50fc375c26 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -29,6 +29,7 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "decode.h"
+#include "get_bits.h"
 #include "mpeg_er.h"
 #include "mpegutils.h"
 #include "mpegvideo.h"
@@ -51,6 +52,8 @@ static VLCElem h261_cbp_vlc[512];
 typedef struct H261DecContext {
 MpegEncContext s;
 
+GetBitContext gb;
+
 H261Context common;
 
 int current_mba;
@@ -129,18 +132,18 @@ static int h261_decode_gob_header(H261DecContext *h)
 
 if (!h->gob_start_code_skipped) {
 /* Check for GOB Start Code */
-val = show_bits(&s->gb, 15);
+val = show_bits(&h->gb, 15);
 if (val)
 return -1;
 
 /* We have a GBSC */
-skip_bits(&s->gb, 16);
+skip_bits(&h->gb, 16);
 }
 
 h->gob_start_code_skipped = 0;
 
-h->gob_number = get_bits(&s->gb, 4); /* GN */
-s->qscale = get_bits(&s->gb, 5); /* GQUANT */
+h->gob_number = get_bits(&h->gb, 4); /* GN */
+s->qscale = get_bits(&h->gb, 5); /* GQUANT */
 
 /* Check if gob_number is valid */
 if (s->mb_height == 18) { // CIF
@@ -153,7 +156,7 @@ static int h261_decode_gob_header(H261DecContext *h)
 }
 
 /* GEI */
-if (skip_1stop_8data_bits(&s->gb) < 0)
+if (skip_1stop_8data_bits(&h->gb) < 0)
 return AVERROR_INVALIDDATA;
 
 if (s->qscale == 0) {
@@ -257,7 +260,7 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 scan_table = s->intra_scantable.permutated;
 if (s->mb_intra) {
 /* DC coef */
-level = get_bits(&s->gb, 8);
+level = get_bits(&h->gb, 8);
 // 0 (b) and -128 (1000b) are FORBIDDEN
 if ((level & 0x7F) == 0) {
 av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n",
@@ -275,10 +278,10 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 // EOB  Not possible for first level when cbp is available 
(that's why the table is different)
 // 01   1s
 // **   0*
-int check = show_bits(&s->gb, 2);
+int check = show_bits(&h->gb, 2);
 i = 0;
 if (check & 0x2) {
-skip_bits(&s->gb, 2);
+skip_bits(&h->gb, 2);
 block[0] = qmul + qadd;
 block[0] *= (check & 0x1) ? -1 : 1;
 i= 1;
@@ -291,14 +294,14 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 return 0;
 }
 {
-OPEN_READER(re, &s->gb);
+OPEN_READER(re, &h->gb);
 i--; // offset by -1 to allow direct indexing of scan_table
 for (;;) {
-UPDATE_CACHE(re, &s->gb);
-GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
+UPDATE_CACHE(re, &h->gb);
+GET_RL_VLC(level, run, re, &h->gb, rl->rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
 if (run == 66) {
 if (level) {
-CLOSE_READER(re, &s->gb);
+CLOSE_READER(re, &h->gb);
 av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at 
%dx%d\n",
s->mb_x, s->mb_y);
 return -1;
@@ -307,25 +310,25 @@ static int h261_decode_block(H261DecContext *h, int16_t 
*block, int n, int coded
 /* The remaining combinations of (run, level) are encoded with a
  * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
  * level. */
-run   = SHOW_UBITS(re, &s->gb, 6) + 1;
-SKIP_CACHE(re, &s->gb, 6);
-level = SHOW_SBITS(re, &s->gb, 8);
+run   = SHOW_UBITS(re, &h->gb, 6) + 1;
+SKIP_CACHE(re, &h->gb, 6);
+level = SHOW_SBITS(re, &h->gb, 8);
 if (level > 0)
 level = level * qmul + qadd;
 else if (level < 0)
 level = level * qmul - qadd;
-SKIP_COUNTER(re, &s->gb, 6 + 8);
+SKIP_COUNTER(re, &h->gb, 6 + 8);
 } else if (level == 0) {
 break;
 } else {
 level = level * qmul + qadd;
-if (SHOW_UBITS(re, &s->gb, 1))
+if (SHOW_UBITS(re, &h->gb, 1))
 level = -level;
-SKIP_COUNTER(re, &s->gb, 1);
+SKIP_COUNTER(re, &h->gb, 1);
 }
 i += run;
 if (i >= 64) {
-CLOSE_READER(re, &s->gb);
+CLOSE_READER(re, &h->gb);
 av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n",
s->mb_x, s->mb_y);
 return -1;
@@ -333,7 +336,7 @@ static int h

[FFmpeg-devel] [PATCH 12/48] avcodec/h261dec: Don't use MpegEncContext.block

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Instead put it into H261DecContext. This is in preparation
for removing MpegEncContext.block.

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

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 50fc375c26..e47bc00a71 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -25,6 +25,7 @@
  * H.261 decoder.
  */
 
+#include "libavutil/mem_internal.h"
 #include "libavutil/thread.h"
 #include "avcodec.h"
 #include "codec_internal.h"
@@ -62,6 +63,8 @@ typedef struct H261DecContext {
 int current_mv_y;
 int gob_number;
 int gob_start_code_skipped; // 1 if gob start code is already read before 
gob header is read
+
+DECLARE_ALIGNED_32(int16_t, block)[6][64];
 } H261DecContext;
 
 static av_cold void h261_decode_init_static(void)
@@ -213,7 +216,7 @@ static int h261_decode_mb_skipped(H261DecContext *h, int 
mba1, int mba2)
 s->cur_pic.motion_val[0][b_xy][1] = s->mv[0][0][1];
 }
 
-ff_mpv_reconstruct_mb(s, s->block);
+ff_mpv_reconstruct_mb(s, h->block);
 }
 
 return 0;
@@ -446,9 +449,9 @@ static int h261_decode_mb(H261DecContext *h)
 intra:
 /* decode each block */
 if (s->mb_intra || HAS_CBP(com->mtype)) {
-s->bdsp.clear_blocks(s->block[0]);
+s->bdsp.clear_blocks(h->block[0]);
 for (i = 0; i < 6; i++) {
-if (h261_decode_block(h, s->block[i], i, cbp & 32) < 0)
+if (h261_decode_block(h, h->block[i], i, cbp & 32) < 0)
 return SLICE_ERROR;
 cbp += cbp;
 }
@@ -457,7 +460,7 @@ intra:
 s->block_last_index[i] = -1;
 }
 
-ff_mpv_reconstruct_mb(s, s->block);
+ff_mpv_reconstruct_mb(s, h->block);
 
 return SLICE_OK;
 }
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 10/48] avcodec/mpegvideodec: Remove size expectation from ff_mpv_reconstruct_mb

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

In the common case of decoding 420 content, only six blocks are used
and it makes perfect sense for the caller to only have that many.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo_dec.c | 2 +-
 libavcodec/mpegvideodec.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 928464d6c1..c4831bf85b 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -1083,7 +1083,7 @@ static av_cold void debug_dct_coeffs(MPVContext *s, const 
int16_t block[][64])
 }
 }
 
-void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64])
+void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[][64])
 {
 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h
index 8bc70b02c0..5b2a38d1c8 100644
--- a/libavcodec/mpegvideodec.h
+++ b/libavcodec/mpegvideodec.h
@@ -56,7 +56,7 @@ int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext 
*avctx);
  * Ensure that the dummy frames are allocated according to pict_type if 
necessary.
  */
 int ff_mpv_alloc_dummy_frames(MpegEncContext *s);
-void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]);
+void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[][64]);
 void ff_mpv_frame_end(MpegEncContext *s);
 
 int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f,
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 14/48] avcodec/mpeg12dec: Remove unused function parameter

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

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

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index ec8b213206..a056dd87cc 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -395,7 +395,7 @@ static inline int get_dmv(MpegEncContext *s)
 #define MT_16X8  2
 #define MT_DMV   3
 
-static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
+static int mpeg_decode_mb(MPVContext *const s)
 {
 int i, j, k, cbp, val, mb_type, motion_type;
 const int mb_block_count = 4 + (1 << s->chroma_format);
@@ -1449,7 +1449,8 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
 }
 
 for (;;) {
-if ((ret = mpeg_decode_mb(s, s->block)) < 0)
+ret = mpeg_decode_mb(s);
+if (ret < 0)
 return ret;
 
 // Note motion_val is normally NULL unless we want to extract the MVs.
-- 
ffmpeg-codebot

___
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 18/48] avcodec/vc1: Stop using MpegEncContext.gb

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Add a GetBitContext to VC1Context instead. This is in preparation
for removing MpegEncContext.gb.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dxva2_vc1.c |  2 +-
 libavcodec/mss2.c  |  4 +-
 libavcodec/vaapi_vc1.c |  2 +-
 libavcodec/vc1.c   | 14 +++
 libavcodec/vc1.h   |  2 +
 libavcodec/vc1_block.c | 92 +-
 libavcodec/vc1_pred.c  | 12 +++---
 libavcodec/vc1dec.c| 52 
 8 files changed, 91 insertions(+), 89 deletions(-)

diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 1f5db8156a..3400480f1f 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -177,7 +177,7 @@ void ff_dxva2_vc1_fill_slice(AVCodecContext *avctx, 
DXVA_SliceInfo *slice,
 slice->dwSliceDataLocation = position;
 slice->bStartCodeBitOffset = 0;
 slice->bReservedBits   = (s->pict_type == AV_PICTURE_TYPE_B && 
!v->bi_type) ? v->bfraction_lut_index + 9 : 0;
-slice->wMBbitOffset= v->p_frame_skipped ? 0x : 
get_bits_count(&s->gb) + (avctx->codec_id == AV_CODEC_ID_VC1 ? 32 : 0);
+slice->wMBbitOffset= v->p_frame_skipped ? 0x : 
get_bits_count(&v->gb) + (avctx->codec_id == AV_CODEC_ID_VC1 ? 32 : 0);
 /* XXX We store the index of the first MB and it will be fixed later */
 slice->wNumberMBsInSlice   = (s->mb_y >> v->field_mode) * s->mb_width + 
s->mb_x;
 slice->wQuantizerScaleCode = v->pq;
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 74a25b3e55..3758313fa8 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -387,12 +387,12 @@ static int decode_wmv9(AVCodecContext *avctx, const 
uint8_t *buf, int buf_size,
 
 ff_mpeg_flush(avctx);
 
-if ((ret = init_get_bits8(&s->gb, buf, buf_size)) < 0)
+if ((ret = init_get_bits8(&v->gb, buf, buf_size)) < 0)
 return ret;
 
 s->loop_filter = avctx->skip_loop_filter < AVDISCARD_ALL;
 
-if (ff_vc1_parse_frame_header(v, &s->gb) < 0) {
+if (ff_vc1_parse_frame_header(v, &v->gb) < 0) {
 av_log(v->s.avctx, AV_LOG_ERROR, "header error\n");
 return AVERROR_INVALIDDATA;
 }
diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c
index f2285c396b..7a955ac7f3 100644
--- a/libavcodec/vaapi_vc1.c
+++ b/libavcodec/vaapi_vc1.c
@@ -490,7 +490,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, 
const uint8_t *buffer,
 .slice_data_size = size,
 .slice_data_offset   = 0,
 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
-.macroblock_offset   = get_bits_count(&s->gb),
+.macroblock_offset   = get_bits_count(&v->gb),
 .slice_vertical_position = s->mb_y % mb_height,
 };
 
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index 076127a1be..c136f14c82 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -94,7 +94,7 @@ static void decode_colskip(uint8_t* plane, int width, int 
height, int stride,
  */
 static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
 {
-GetBitContext *gb = &v->s.gb;
+GetBitContext *const gb = &v->gb;
 
 int imode, x, y, code, offset;
 uint8_t invert, *planep = data;
@@ -161,7 +161,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, 
VC1Context *v)
 planep += stride * 3;
 }
 if (width & 1)
-decode_colskip(data, 1, height, stride, &v->s.gb);
+decode_colskip(data, 1, height, stride, &v->gb);
 } else { // 3x2
 planep += (height & 1) * stride;
 for (y = height & 1; y < height; y += 2) {
@@ -182,16 +182,16 @@ static int bitplane_decoding(uint8_t* data, int 
*raw_flag, VC1Context *v)
 }
 x = width % 3;
 if (x)
-decode_colskip(data, x, height, stride, &v->s.gb);
+decode_colskip(data, x, height, stride, &v->gb);
 if (height & 1)
-decode_rowskip(data + x, width - x,  1, stride, &v->s.gb);
+decode_rowskip(data + x, width - x,  1, stride, &v->gb);
 }
 break;
 case IMODE_ROWSKIP:
-decode_rowskip(data, width, height, stride, &v->s.gb);
+decode_rowskip(data, width, height, stride, &v->gb);
 break;
 case IMODE_COLSKIP:
-decode_colskip(data, width, height, stride, &v->s.gb);
+decode_colskip(data, width, height, stride, &v->gb);
 break;
 default:
 break;
@@ -227,7 +227,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, 
VC1Context *v)
  */
 static int vop_dquant_decoding(VC1Context *v)
 {
-GetBitContext *gb = &v->s.gb;
+GetBitContext *const gb = &v->gb;
 int pqdiff;
 
 //variable size
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 992c073cdc..1be97aebfd 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -24,6 +24,7 @@
 #define AVCODEC_VC1_H
 
 #include "avcodec.h

[FFmpeg-devel] [PATCH 15/48] avcodec/rv34: Don't use MpegEncContext.gb

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This is in preparation for removing MpegEncContext.gb.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/rv30.c |  2 +-
 libavcodec/rv34.c | 28 ++--
 libavcodec/rv34.h |  2 ++
 libavcodec/rv40.c |  2 +-
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c
index 351276995b..e0b5395fa6 100644
--- a/libavcodec/rv30.c
+++ b/libavcodec/rv30.c
@@ -116,7 +116,7 @@ static int rv30_decode_mb_info(RV34DecContext *r)
 static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, 
RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
 static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, 
RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, 
RV34_MB_TYPE_INTRA16x16 };
 MpegEncContext *s = &r->s;
-GetBitContext *gb = &s->gb;
+GetBitContext *const gb = &r->gb;
 unsigned code = get_interleaved_ue_golomb(gb);
 
 if (code > 11) {
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 5dcbe9a222..73fd16b3e2 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -363,7 +363,7 @@ static inline RV34VLC* choose_vlc_set(int quant, int mod, 
int type)
 static int rv34_decode_intra_mb_header(RV34DecContext *r, int8_t *intra_types)
 {
 MpegEncContext *s = &r->s;
-GetBitContext *gb = &s->gb;
+GetBitContext *const gb = &r->gb;
 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
 int t;
 
@@ -398,7 +398,7 @@ static int rv34_decode_intra_mb_header(RV34DecContext *r, 
int8_t *intra_types)
 static int rv34_decode_inter_mb_header(RV34DecContext *r, int8_t *intra_types)
 {
 MpegEncContext *s = &r->s;
-GetBitContext *gb = &s->gb;
+GetBitContext *const gb = &r->gb;
 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
 int i, t;
 
@@ -871,7 +871,7 @@ static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 
1, 0, 0, 2, 2, 2, 1 }
 static int rv34_decode_mv(RV34DecContext *r, int block_type)
 {
 MpegEncContext *s = &r->s;
-GetBitContext *gb = &s->gb;
+GetBitContext *const gb = &r->gb;
 int i, j, k, l;
 int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
 int next_bt;
@@ -1031,7 +1031,7 @@ static inline void rv34_process_block(RV34DecContext *r,
 {
 MpegEncContext *s = &r->s;
 int16_t *ptr = s->block[0];
-int has_ac = rv34_decode_block(ptr, &s->gb, r->cur_vlcs,
+int has_ac = rv34_decode_block(ptr, &r->gb, r->cur_vlcs,
fc, sc, q_dc, q_ac, q_ac);
 if(has_ac){
 r->rdsp.rv34_idct_add(pdst, stride, ptr);
@@ -1045,7 +1045,7 @@ static void rv34_output_i16x16(RV34DecContext *r, int8_t 
*intra_types, int cbp)
 {
 LOCAL_ALIGNED_16(int16_t, block16, [16]);
 MpegEncContext *s= &r->s;
-GetBitContext  *gb   = &s->gb;
+GetBitContext *const gb = &r->gb;
 int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
 q_ac = rv34_qscale_tab[s->qscale];
 uint8_t*dst  = s->dest[0];
@@ -1213,7 +1213,7 @@ static int rv34_set_deblock_coef(RV34DecContext *r)
 static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types)
 {
 MpegEncContext *s   = &r->s;
-GetBitContext  *gb  = &s->gb;
+GetBitContext *const gb = &r->gb;
 uint8_t*dst = s->dest[0];
 int16_t*ptr = s->block[0];
 int  mb_pos = s->mb_x + s->mb_y * s->mb_stride;
@@ -1367,8 +1367,8 @@ static int check_slice_end(RV34DecContext *r, 
MpegEncContext *s)
 return 1;
 if(r->s.mb_skip_run > 1)
 return 0;
-bits = get_bits_left(&s->gb);
-if(bits <= 0 || (bits < 8 && !show_bits(&s->gb, bits)))
+bits = get_bits_left(&r->gb);
+if (bits <= 0 || (bits < 8 && !show_bits(&r->gb, bits)))
 return 1;
 return 0;
 }
@@ -1424,11 +1424,11 @@ static int rv34_decoder_realloc(RV34DecContext *r)
 static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, 
int buf_size)
 {
 MpegEncContext *s = &r->s;
-GetBitContext *gb = &s->gb;
+GetBitContext *const gb = &r->gb;
 int mb_pos, slice_type;
 int res;
 
-init_get_bits(&r->s.gb, buf, buf_size*8);
+init_get_bits(gb, buf, buf_size*8);
 res = r->parse_slice_header(r, gb, &r->si);
 if(res < 0){
 av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n");
@@ -1651,8 +1651,8 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
 return AVERROR_INVALIDDATA;
 }
-init_get_bits(&s->gb, buf+offset, (buf_size-offset)*8);
-if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){
+init_get_bits(&r->gb, buf+offset, (buf_size-offset)*8);
+if (r->parse_slice_header(r, &r->gb, &si) < 0 || si.start) {
 av_log(avctx, AV_LOG_ERROR, "First slice header is incorrect\n");
 return AVERROR_INVALIDDATA;
 }
@@ -1781,8 +1781,8 @@ int ff_rv34_decode_fra

[FFmpeg-devel] [PATCH 16/48] avcodec/rv34: Don't use MpegEncContext.block

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

These decoders only need a single 4x4 block; put it in RV34DecContext.
This is in preparation for removing MpegEncContext.block.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/rv34.c | 7 +++
 libavcodec/rv34.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 73fd16b3e2..9f8a0f12b8 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1029,8 +1029,7 @@ static inline void rv34_process_block(RV34DecContext *r,
   uint8_t *pdst, int stride,
   int fc, int sc, int q_dc, int q_ac)
 {
-MpegEncContext *s = &r->s;
-int16_t *ptr = s->block[0];
+int16_t *const ptr = r->block;
 int has_ac = rv34_decode_block(ptr, &r->gb, r->cur_vlcs,
fc, sc, q_dc, q_ac, q_ac);
 if(has_ac){
@@ -1049,7 +1048,7 @@ static void rv34_output_i16x16(RV34DecContext *r, int8_t 
*intra_types, int cbp)
 int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
 q_ac = rv34_qscale_tab[s->qscale];
 uint8_t*dst  = s->dest[0];
-int16_t*ptr  = s->block[0];
+int16_t  *const ptr  = r->block;
 int i, j, itype, has_ac;
 
 memset(block16, 0, 16 * sizeof(*block16));
@@ -1215,7 +1214,7 @@ static int rv34_decode_inter_macroblock(RV34DecContext 
*r, int8_t *intra_types)
 MpegEncContext *s   = &r->s;
 GetBitContext *const gb = &r->gb;
 uint8_t*dst = s->dest[0];
-int16_t*ptr = s->block[0];
+int16_t  *const ptr = r->block;
 int  mb_pos = s->mb_x + s->mb_y * s->mb_stride;
 int cbp, cbp2;
 int q_dc, q_ac, has_ac;
diff --git a/libavcodec/rv34.h b/libavcodec/rv34.h
index 485a034f9e..5bed46ea4f 100644
--- a/libavcodec/rv34.h
+++ b/libavcodec/rv34.h
@@ -119,6 +119,7 @@ typedef struct RV34DecContext{
 uint8_t  *cbp_chroma;///< CBP values for chroma subblocks
 uint16_t *deblock_coefs; ///< deblock coefficients for each macroblock
 
+DECLARE_ALIGNED_16(int16_t, block)[16];
 /** 8x8 block available flags (for MV prediction) */
 DECLARE_ALIGNED(8, uint32_t, avail_cache)[3*4];
 
-- 
ffmpeg-codebot

___
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 17/48] avcodec/intrax8: Don't pretend to need more than one int16_t[64]

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Intrax8 needs only a single block.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/intrax8.c | 16 
 libavcodec/intrax8.h |  4 ++--
 libavcodec/vc1dec.c  |  2 +-
 libavcodec/wmv2dec.c |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c
index 684f15d904..89b70e5902 100644
--- a/libavcodec/intrax8.c
+++ b/libavcodec/intrax8.c
@@ -437,7 +437,7 @@ static void x8_ac_compensation(IntraX8Context *const w, 
const int direction,
const int dc_level)
 {
 int t;
-#define B(x,y)  w->block[0][w->idct_permutation[(x) + (y) * 8]]
+#define B(x,y)  w->block[w->idct_permutation[(x) + (y) * 8]]
 #define T(x)  ((x) * dc_level + 0x8000) >> 16;
 switch (direction) {
 case 0:
@@ -530,7 +530,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 int sign;
 
 av_assert2(w->orient < 12);
-w->bdsp.clear_block(w->block[0]);
+w->bdsp.clear_block(w->block);
 
 if (chroma)
 dc_mode = 2;
@@ -591,7 +591,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 if (use_quant_matrix)
 level = (level * quant_table[pos]) >> 8;
 
-w->block[0][scantable[pos]] = level;
+w->block[scantable[pos]] = level;
 } while (!final);
 } else { // DC only
 if (w->flat_dc && ((unsigned) (dc_level + 1)) < 3) { // [-1; 1]
@@ -613,9 +613,9 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 zeros_only = dc_level == 0;
 }
 if (!chroma)
-w->block[0][0] = dc_level * w->quant;
+w->block[0] = dc_level * w->quant;
 else
-w->block[0][0] = dc_level * w->quant_dc_chroma;
+w->block[0] = dc_level * w->quant_dc_chroma;
 
 // there is !zero_only check in the original, but dc_level check is enough
 if ((unsigned int) (dc_level + 1) >= 3 && (w->edges & 3) != 3) {
@@ -624,7 +624,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
  * -> 01'10' 10'10' 00'00' 00'01' 01'11' 11'00 => 0x6A017C */
 direction = (0x6A017C >> (w->orient * 2)) & 3;
 if (direction != 3) {
-x8_ac_compensation(w, direction, w->block[0][0]);
+x8_ac_compensation(w, direction, w->block[0]);
 }
 }
 
@@ -639,7 +639,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, 
const int chroma)
 if (!zeros_only)
 w->wdsp.idct_add(w->dest[chroma],
  w->frame->linesize[!!chroma],
- w->block[0]);
+ w->block);
 
 block_placed:
 if (!chroma)
@@ -678,7 +678,7 @@ static void x8_init_block_index(IntraX8Context *w, AVFrame 
*frame)
 
 av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w,
-   int16_t (*block)[64],
+   int16_t block[64],
int mb_width, int mb_height)
 {
 static AVOnce init_static_once = AV_ONCE_INIT;
diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h
index 38ad09c837..2ec90963a8 100644
--- a/libavcodec/intrax8.h
+++ b/libavcodec/intrax8.h
@@ -38,7 +38,7 @@ typedef struct IntraX8Context {
 WMV2DSPContext wdsp;
 uint8_t idct_permutation[64];
 AVCodecContext *avctx;
-int16_t (*block)[64];
+int16_t *block;
 
 // set by the caller codec
 IntraX8DSPContext dsp;
@@ -82,7 +82,7 @@ typedef struct IntraX8Context {
  */
 int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w,
-   int16_t (*block)[64],
+   int16_t block[64],
int mb_width, int mb_height);
 
 /**
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 97174d10e3..8bcc7c60df 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -420,7 +420,7 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context 
*v)
 return AVERROR(ENOMEM);
 }
 
-ret = ff_intrax8_common_init(s->avctx, &v->x8, s->block,
+ret = ff_intrax8_common_init(s->avctx, &v->x8, s->block[0],
  s->mb_width, s->mb_height);
 if (ret < 0)
 return ret;
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 964d6a4c06..301c786633 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -581,7 +581,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 
 decode_ext_header(w);
 
-return ff_intrax8_common_init(avctx, &w->x8, s->block,
+return ff_intrax8_common_init(avctx, &w->x8, s->block[0],
   s->mb_width, s->mb_height);
 }
 
-- 
ffmpeg-codebot

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


[FFmpeg-devel] [PATCH 22/48] avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/motion_est.c|  4 ++--
 libavcodec/motion_est.h|  1 +
 libavcodec/mpegvideo.h |  1 -
 libavcodec/mpegvideo_enc.c | 18 +-
 libavcodec/rv20enc.c   |  2 +-
 libavcodec/snowenc.c   |  2 +-
 libavcodec/svq1enc.c   |  2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 333048d1c8..93be712cc0 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -551,7 +551,7 @@ static inline void get_limits(MPVEncContext *const s, int 
x, int y, int bframe)
 if(c->avctx->me_range) c->range= c->avctx->me_range >> 1;
 else   c->range= 16;
 */
-if (s->c.unrestricted_mv) {
+if (c->unrestricted_mv) {
 c->xmin = - x - 16;
 c->ymin = - y - 16;
 c->xmax = - x + s->c.width;
@@ -600,7 +600,7 @@ static inline int h263_mv4_search(MPVEncContext *const s, 
int mx, int my, int sh
 int same=1;
 const int stride= c->stride;
 const uint8_t *mv_penalty = c->current_mv_penalty;
-int safety_clipping = s->c.unrestricted_mv && (s->c.width&15) && 
(s->c.height&15);
+int safety_clipping = c->unrestricted_mv && (s->c.width&15) && 
(s->c.height&15);
 
 init_mv4_ref(c);
 
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index 89a2f41b75..7e57a3a79b 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -69,6 +69,7 @@ typedef struct MotionEstContext {
 int mb_flags;
 int pre_pass;   ///< = 1 for the pre pass
 int dia_size;
+int unrestricted_mv;///< mv can point outside of the coded 
picture
 int xmin;
 int xmax;
 int ymin;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index a439c1878b..d95cebedd8 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -164,7 +164,6 @@ typedef struct MpegEncContext {
 int droppable;
 
 /* motion compensation */
-int unrestricted_mv;///< mv can point outside of the coded picture
 int h263_long_vectors;  ///< use horrible H.263v1 long vector mode
 
 BlockDSPContext bdsp;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8a38e54982..afdc2fb787 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -926,7 +926,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->c.h263_aic= (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0;
 s->c.modified_quant  = s->c.h263_aic;
 s->c.loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 
: 0;
-s->c.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->c.umvplus;
+s->me.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->c.umvplus;
 s->flipflop_rounding = 1;
 
 /* /Fx */
@@ -937,7 +937,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 case AV_CODEC_ID_FLV1:
 s->c.out_format  = FMT_H263;
 s->c.h263_flv= 2; /* format = 1; 11-bit codes */
-s->c.unrestricted_mv = 1;
+s->me.unrestricted_mv = 1;
 s->rtp_mode  = 0; /* don't allow GOB */
 avctx->delay = 0;
 s->c.low_delay = 1;
@@ -961,13 +961,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 // will be set later on a per-frame basis.
 s->c.h263_aic= 1;
 s->c.loop_filter = 1;
-s->c.unrestricted_mv = 0;
+s->me.unrestricted_mv = 0;
 break;
 #endif
 case AV_CODEC_ID_MPEG4:
 s->c.out_format  = FMT_H263;
 s->c.h263_pred   = 1;
-s->c.unrestricted_mv = 1;
+s->me.unrestricted_mv = 1;
 s->flipflop_rounding = 1;
 s->c.low_delay   = m->max_b_frames ? 0 : 1;
 avctx->delay   = s->c.low_delay ? 0 : (m->max_b_frames + 1);
@@ -975,7 +975,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 case AV_CODEC_ID_MSMPEG4V2:
 s->c.out_format  = FMT_H263;
 s->c.h263_pred   = 1;
-s->c.unrestricted_mv = 1;
+s->me.unrestricted_mv = 1;
 s->c.msmpeg4_version = MSMP4_V2;
 avctx->delay   = 0;
 s->c.low_delay   = 1;
@@ -983,7 +983,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 case AV_CODEC_ID_MSMPEG4V3:
 s->c.out_format= FMT_H263;
 s->c.h263_pred = 1;
-s->c.unrestricted_mv   = 1;
+s->me.unrestricted_mv = 1;
 s->c.msmpeg4_version   = MSMP4_V3;
 s->flipflop_rounding = 1;
 avctx->delay = 0;
@@ -992,7 +992,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 case AV_CODEC_ID_WMV1:
 s->c.out_format= FMT_H263;
 s->c.h263_pred = 1;
-s->c.unrestricted_mv   = 1;
+s->me.unrestricted_mv = 1;
 s->c.msmpeg4_version   = MSMP4_WMV1;
 s->flipflop_rounding = 1;
 avctx-

[FFmpeg-devel] [PATCH 19/48] avcodec/vc1: Don't use MpegEncContext.block

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Instead add the necessary blocks directly to VC1Context
(only six are needed, not 12 as ff_mpv_common_init()
currently allocates).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vc1.h   |  4 
 libavcodec/vc1_block.c | 28 ++--
 libavcodec/vc1dec.c|  2 +-
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 1be97aebfd..5eee646e31 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -31,6 +31,8 @@
 #include "vc1_common.h"
 #include "vc1dsp.h"
 
+#include "libavutil/mem_internal.h"
+
 #define AC_VLC_BITS 9
 
 /** Sequence quantizer mode */
@@ -399,6 +401,8 @@ typedef struct VC1Context{
 
 int parse_only;  ///< Context is used within parser
 int resync_marker;   ///< could this stream contain resync markers
+
+DECLARE_ALIGNED_32(int16_t, blocks)[6][64];
 } VC1Context;
 
 /**
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 0e709f5f08..165d875458 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -1950,22 +1950,22 @@ static int vc1_decode_b_mb(VC1Context *v)
 if (i == 1 || i == 3 || s->mb_x)
 v->c_avail = v->mb_type[s->block_index[i] - 1];
 
-ret = vc1_decode_intra_block(v, s->block[i], i, val, mquant,
+ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
  (i & 4) ? v->codingset2 : 
v->codingset);
 if (ret < 0)
 return ret;
 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & 
AV_CODEC_FLAG_GRAY))
 continue;
-v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
+v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
 if (v->rangeredfrm)
 for (j = 0; j < 64; j++)
-s->block[i][j] *= 2;
-s->idsp.put_signed_pixels_clamped(s->block[i],
+v->blocks[i][j] *= 2;
+s->idsp.put_signed_pixels_clamped(v->blocks[i],
   s->dest[dst_idx] + off,
   i & 4 ? s->uvlinesize
 : s->linesize);
 } else if (val) {
-int pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
+int pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
  first_block, s->dest[dst_idx] + off,
  (i & 4) ? s->uvlinesize : s->linesize,
  CONFIG_GRAY && (i & 4) && 
(s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL);
@@ -2031,18 +2031,18 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
 if (i == 1 || i == 3 || s->mb_x)
 v->c_avail = v->mb_type[s->block_index[i] - 1];
 
-ret = vc1_decode_intra_block(v, s->block[i], i, val, mquant,
+ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
  (i & 4) ? v->codingset2 : 
v->codingset);
 if (ret < 0)
 return ret;
 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & 
AV_CODEC_FLAG_GRAY))
 continue;
-v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
+v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
 if (v->rangeredfrm)
 for (j = 0; j < 64; j++)
-s->block[i][j] <<= 1;
+v->blocks[i][j] <<= 1;
 off  = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
-s->idsp.put_signed_pixels_clamped(s->block[i],
+s->idsp.put_signed_pixels_clamped(v->blocks[i],
   s->dest[dst_idx] + off,
   (i & 4) ? s->uvlinesize
   : s->linesize);
@@ -2129,7 +2129,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
 val = ((cbp >> (5 - i)) & 1);
 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
 if (val) {
-pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
+pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
  first_block, s->dest[dst_idx] + off,
  (i & 4) ? s->uvlinesize : s->linesize,
  CONFIG_GRAY && (i & 4) && 
(s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
@@ -2227,13 +2227,13 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
 if (i == 1 || i == 3 || s->mb_x)
 v->c_avail = v->mb_type[s->block_index[i] - 1];
 
-ret = vc1_decode_intra_block(v, s->block[i], i, val, mquant,
+ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
   

[FFmpeg-devel] [PATCH 24/48] avcodec/{h263, mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext*

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

The code in h263dec.c is not supposed to know that the MPEG-4
decoder uses an Mpeg4DecContext as private context at all
(said context is only exposed in a header so that hardware
accelerations can access it and for the parser to use).
Passing an MPVContext* directly also allows to remove
the indirection via AVCodecContext.priv_data.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c   |  4 ++--
 libavcodec/ituh263dec.c|  4 ++--
 libavcodec/mpeg4videodec.c | 12 ++--
 libavcodec/mpeg4videodec.h |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 52b17663db..7e454e3406 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -194,7 +194,7 @@ static int decode_slice(MpegEncContext *s)
 ff_set_qscale(s, s->qscale);
 
 if (s->studio_profile) {
-if ((ret = ff_mpeg4_decode_studio_slice_header(s->avctx->priv_data)) < 
0)
+if ((ret = ff_mpeg4_decode_studio_slice_header(s)) < 0)
 return ret;
 }
 
@@ -210,7 +210,7 @@ static int decode_slice(MpegEncContext *s)
 const int qscale = s->qscale;
 
 if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4)
-if ((ret = ff_mpeg4_decode_partitions(s->avctx->priv_data)) < 0)
+if ((ret = ff_mpeg4_decode_partitions(s)) < 0)
 return ret;
 
 /* restore variables which were modified */
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index fa09ebb84b..f5001200fe 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -240,7 +240,7 @@ int ff_h263_resync(MpegEncContext *s){
 if(show_bits(&s->gb, 16)==0){
 pos= get_bits_count(&s->gb);
 if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
-ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
+ret = ff_mpeg4_decode_video_packet_header(s);
 else
 ret= h263_decode_gob_header(s);
 if(ret>=0)
@@ -257,7 +257,7 @@ int ff_h263_resync(MpegEncContext *s){
 
 pos= get_bits_count(&s->gb);
 if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
-ret= ff_mpeg4_decode_video_packet_header(s->avctx->priv_data);
+ret = ff_mpeg4_decode_video_packet_header(s);
 else
 ret= h263_decode_gob_header(s);
 if(ret>=0)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c61fd23c48..91b1687884 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -700,9 +700,9 @@ static int decode_new_pred(Mpeg4DecContext *ctx, 
GetBitContext *gb) {
  * Decode the next video packet.
  * @return <0 if something went wrong
  */
-int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx)
+int ff_mpeg4_decode_video_packet_header(MPVContext *const s)
 {
-MpegEncContext *s = &ctx->m;
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 
 int mb_num_bits  = av_log2(s->mb_num - 1) + 1;
 int header_extension = 0, mb_num, len;
@@ -799,9 +799,9 @@ static void reset_studio_dc_predictors(MpegEncContext *s)
  * Decode the next video packet.
  * @return <0 if something went wrong
  */
-int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx)
+int ff_mpeg4_decode_studio_slice_header(MPVContext *const s)
 {
-MpegEncContext *s = &ctx->m;
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 GetBitContext *gb = &s->gb;
 unsigned vlc_len;
 uint16_t mb_num;
@@ -1307,9 +1307,9 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, 
int mb_count)
  * Decode the first and second partition.
  * @return <0 if error (and sets error type in the error_status_table)
  */
-int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
+int ff_mpeg4_decode_partitions(MPVContext *const s)
 {
-MpegEncContext *s = &ctx->m;
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 int mb_num;
 int ret;
 const int part_a_error = s->pict_type == AV_PICTURE_TYPE_I ? (ER_DC_ERROR 
| ER_MV_ERROR) : ER_MV_ERROR;
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index ae8428fd2b..32ad081df3 100644
--- a/libavcodec/mpeg4videodec.h
+++ b/libavcodec/mpeg4videodec.h
@@ -116,9 +116,9 @@ void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t 
*dest_y, uint8_t *dest_cb
 void ff_mpeg4_mcsel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t *const *ref_picture);
-int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx);
-int ff_mpeg4_decode_video_packet_header(Mpeg4DecContext *ctx);
-int ff_mpeg4_decode_studio_slice_header(Mpeg4DecContext *ctx);
+int ff_mpeg4_decode_partitions(MPVContext *const s);
+int ff_mpeg4_decode_video_packet_header(MPVContext *const s);
+int ff_mpeg4_decode_studio_slice_header(MPVContext *const s);
 void ff_mpeg4_workaround_bugs(AVCodecContext *avctx);
 void

[FFmpeg-devel] [PATCH 21/48] avcodec/mpegvideo: Move flipflop_rounding to {MSMPEG4Dec, MPVEnc}Context

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Forgotten in 9964212545554d9ae1afaabd23a7f9a361997d01.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegvideo.h |  1 -
 libavcodec/mpegvideo_enc.c | 14 +++---
 libavcodec/mpegvideoenc.h  |  1 +
 libavcodec/msmpeg4dec.c|  8 
 libavcodec/msmpeg4dec.h|  1 +
 libavcodec/msmpeg4enc.c|  4 ++--
 libavcodec/wmv2enc.c   |  2 +-
 7 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index fe3ae97f5d..a439c1878b 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -265,7 +265,6 @@ typedef struct MpegEncContext {
 /* MSMPEG4 specific */
 int slice_height;  ///< in macroblocks
 int first_slice_line;  ///< used in MPEG-4 too to handle resync markers
-int flipflop_rounding;
 enum {
 MSMP4_UNUSED,
 MSMP4_V1,
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 1ceb6296c4..8a38e54982 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -927,7 +927,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->c.modified_quant  = s->c.h263_aic;
 s->c.loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 
: 0;
 s->c.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->c.umvplus;
-s->c.flipflop_rounding = 1;
+s->flipflop_rounding = 1;
 
 /* /Fx */
 /* These are just to be sure */
@@ -968,7 +968,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->c.out_format  = FMT_H263;
 s->c.h263_pred   = 1;
 s->c.unrestricted_mv = 1;
-s->c.flipflop_rounding = 1;
+s->flipflop_rounding = 1;
 s->c.low_delay   = m->max_b_frames ? 0 : 1;
 avctx->delay   = s->c.low_delay ? 0 : (m->max_b_frames + 1);
 break;
@@ -985,7 +985,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->c.h263_pred = 1;
 s->c.unrestricted_mv   = 1;
 s->c.msmpeg4_version   = MSMP4_V3;
-s->c.flipflop_rounding = 1;
+s->flipflop_rounding = 1;
 avctx->delay = 0;
 s->c.low_delay = 1;
 break;
@@ -994,7 +994,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->c.h263_pred = 1;
 s->c.unrestricted_mv   = 1;
 s->c.msmpeg4_version   = MSMP4_WMV1;
-s->c.flipflop_rounding = 1;
+s->flipflop_rounding = 1;
 avctx->delay = 0;
 s->c.low_delay = 1;
 break;
@@ -1003,7 +1003,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 s->c.h263_pred = 1;
 s->c.unrestricted_mv   = 1;
 s->c.msmpeg4_version   = MSMP4_WMV2;
-s->c.flipflop_rounding = 1;
+s->flipflop_rounding = 1;
 avctx->delay = 0;
 s->c.low_delay = 1;
 break;
@@ -2022,7 +2022,7 @@ vbv_retry:
 s->c.mb_skipped = 0;// done in frame_start()
 // done in encode_picture() so we must undo it
 if (s->c.pict_type == AV_PICTURE_TYPE_P) {
-s->c.no_rounding ^= s->c.flipflop_rounding;
+s->c.no_rounding ^= s->flipflop_rounding;
 }
 if (s->c.pict_type != AV_PICTURE_TYPE_B) {
 s->c.time_base   = s->c.last_time_base;
@@ -3734,7 +3734,7 @@ static int encode_picture(MPVMainEncContext *const m, 
const AVPacket *pkt)
 if (s->c.pict_type == AV_PICTURE_TYPE_I) {
 s->c.no_rounding = s->c.msmpeg4_version >= MSMP4_V3;
 } else if (s->c.pict_type != AV_PICTURE_TYPE_B) {
-s->c.no_rounding ^= s->c.flipflop_rounding;
+s->c.no_rounding ^= s->flipflop_rounding;
 }
 
 if (s->c.avctx->flags & AV_CODEC_FLAG_PASS2) {
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 8ad2fe2e8a..2a04abab26 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -155,6 +155,7 @@ typedef struct MPVEncContext {
 PutBitContext pb2; ///< used for data partitioned VOPs
 
 /* MSMPEG4 specific */
+int flipflop_rounding; ///< also used for MPEG-4, H.263+
 int esc3_level_length;
 
 /* RTP specific */
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index df5ab5186e..55e51aff3c 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -544,7 +544,7 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
 ms->per_mb_rl_table,
 s->qscale);
 
-if(s->flipflop_rounding){
+if (ms->flipflop_rounding) {
 s->no_rounding ^= 1;
 }else{
 s->no_rounding = 0;
@@ -570,13 +570,13 @@ int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int 
buf_size)
 skip_bits(&s->gb, 5); /* fps */
 ms->bit_rate = get_bits(&s->gb, 11) * 1024;
 if (s->msmpeg4_version >= MSMP4

[FFmpeg-devel] [PATCH 20/48] avcodec/mpeg12dec: Deduplicate variables

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This situation was created in merge commit
71d008ebe4f96974433eecfd3575bc82eb4b06a8.

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

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index a056dd87cc..cba57369cd 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2095,7 +2095,6 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 static void mpeg_decode_user_data(AVCodecContext *avctx,
   const uint8_t *p, int buf_size)
 {
-Mpeg1Context *s = avctx->priv_data;
 const uint8_t *buf_end = p + buf_size;
 Mpeg1Context *s1 = avctx->priv_data;
 
@@ -2111,7 +2110,7 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
 int i;
 for(i=0; i<20; i++)
 if (!memcmp(p+i, "\0TMPGEXS\0", 9)){
-s->tmpgexs= 1;
+s1->tmpgexs = 1;
 }
 }
 /* we parse the DTG active format information */
-- 
ffmpeg-codebot

___
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] avdevice/android_camera: image linesize aligment is 1

2025-06-23 Thread Zhao Zhili
LGTM.

> On Jun 23, 2025, at 13:31, Wang Bin  wrote:
> 
> <0001-avdevice-android_camera-image-linesize-aligment-is-1.patch>___
> 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] libavcodec/hcadec: fix header parsing after 'comp' section

2025-06-23 Thread Michael Niedermayer
Hi Pavel

On Tue, Jun 17, 2025 at 11:05:55AM -0700, Pavel Roslyy wrote:
> Need to skip 2 more bytes because comp sections are 12 bytes long.
> Fixes decryption since ciph_type is now being set.
> 
> Signed-off-by: Pavel Roslyy 
> ---
>  libavcodec/hcadec.c | 1 +
>  1 file changed, 1 insertion(+)

will apply
thx

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

There will always be a question for which you do not know the correct answer.


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

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/iamf_parse: Check extradata size

2025-06-23 Thread Michael Niedermayer
On Mon, Jun 23, 2025 at 04:19:52PM +0200, Michael Niedermayer wrote:
> On Mon, Jun 23, 2025 at 09:47:55AM -0300, James Almer wrote:
> > On 6/23/2025 9:44 AM, Michael Niedermayer wrote:
> > > On Fri, Jun 20, 2025 at 12:28:13AM +0200, Andreas Rheinhardt wrote:
> > > > Michael Niedermayer:
> > > > > Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
> > > > > Fixes: 
> > > > > 398527871/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6602025714647040
> > > > > 
> > > > > Found-by: continuous fuzzing process 
> > > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > > > Signed-off-by: Michael Niedermayer 
> > > > > ---
> > > > >   libavformat/iamf_parse.c | 2 ++
> > > > >   1 file changed, 2 insertions(+)
> > > > > 
> > > > > diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
> > > > > index 71497876ac3..330e01733dd 100644
> > > > > --- a/libavformat/iamf_parse.c
> > > > > +++ b/libavformat/iamf_parse.c
> > > > > @@ -305,6 +305,8 @@ static int update_extradata(AVCodecParameters 
> > > > > *codecpar)
> > > > >   skip_bits(&gb, 4);
> > > > >   put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set 
> > > > > channel config
> > > > >   ret = put_bits_left(&pb);
> > > > > +if (ret < 0)
> > > > > +return AVERROR_INVALIDDATA;
> > > > >   while (ret >= 32) {
> > > > >  put_bits32(&pb, get_bits_long(&gb, 32));
> > > > >  ret -= 32;
> > > > 
> > > > There is only one way for put_bits_left() to return a negative value: If
> > > > there is more data in the internal buffer than can be written out. And
> > > > this scenario is already a violation of the PutBit API. Given that the
> > > > size of the internal buffer depends upon the arch, it could be that one
> > > > would have already hit an assert in case one is not using x64. In other
> > > > words, your check is too late.
> > > 
> > > the patches puprose was mainly to show that
> > > 3f9420132441345b7ccd57001f230bb98f655696
> > > was insufficient to fix 398527871
> > > 
> > > I do not expect my patch would be the correct solution even if the
> > > check is done earlier. IAMF is cursed
> > 
> > Does increasing buf from 6 bytes to 8 or more fix it? I see putbits may do
> > an AV_W*64(), so six bytes sounds like it was never safe.
> 
> i set buffer to 1000 and it still fails with put_bits_left()
> returning -19
> 
> what will fix this specific case is:
> -if (ret == 0x0f)
> -put_bits(&pb, 24, get_bits(&gb, 24));
> +if (ret == 0x0f) {
> +if (get_bits_left(&gb) >= 24+4+4)

this should be only one +4

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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 4/8] tools/target_dec_fuzzer: adjust threshold for VP8

2025-06-23 Thread Michael Niedermayer
On Fri, Jun 20, 2025 at 02:32:51AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 416589179/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP8_fuzzer-5432788428062720
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

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

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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 4/5] avformat/iff: Check nb_channels == 0 in CHNL

2025-06-23 Thread Michael Niedermayer
On Sun, Jun 22, 2025 at 02:40:23PM +1000, Peter Ross wrote:
> On Sat, Jun 21, 2025 at 11:15:20PM +0200, Michael Niedermayer wrote:
> > Fixes: division by 0
> > Fixes: 
> > 418396712/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6104388018176000
> > Fixes: 
> > 418478219/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4569544410857472
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/iff.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/iff.c b/libavformat/iff.c
> > index 9402be48c98..4ff10beb38a 100644
> > --- a/libavformat/iff.c
> > +++ b/libavformat/iff.c
> > @@ -284,7 +284,7 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream 
> > *st, uint64_t eof)
> >  return AVERROR_INVALIDDATA;
> >  st->codecpar->ch_layout.order   = AV_CHANNEL_ORDER_UNSPEC;
> >  st->codecpar->ch_layout.nb_channels = avio_rb16(pb);
> > -if (size < 2 + st->codecpar->ch_layout.nb_channels * 4)
> > +if (size < 2 + st->codecpar->ch_layout.nb_channels * 4 || 
> > !st->codecpar->ch_layout.nb_channels)
> >  return AVERROR_INVALIDDATA;
> >  if (st->codecpar->ch_layout.nb_channels > 
> > FF_ARRAY_ELEMS(dsd_layout)) {
> >  avpriv_request_sample(s, "channel layout");
> 
> please apply

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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

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


Re: [FFmpeg-devel] [PATCH 1/5] avformat/mov: Check that sample_count is allocated in mov_parse_heif_items()

2025-06-23 Thread James Almer

On 6/21/2025 6:15 PM, Michael Niedermayer wrote:

Fixes: NULL pointer dereference
Fixes: 
416811958/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5425269114732544

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8a094b1ea0a..6e9e3498fb5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -10336,7 +10336,7 @@ static int mov_parse_heif_items(AVFormatContext *s)
  st->codecpar->height = item->height;
  
  err = sanity_checks(s, sc, item->item_id);

-if (err)
+if (err || !sc->sample_count)
  return AVERROR_INVALIDDATA;
  
  sc->sample_sizes[0]  = item->extent_length;


LGTM


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

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


Re: [FFmpeg-devel] [PATCH] avfilter/codecview: Enable QP visualization for H.264

2025-06-23 Thread Michael Niedermayer
On Thu, Jun 19, 2025 at 11:37:43AM +0200, Timothée wrote:
> Context from the first version : Subject was "avcodec/h264: fixed qp table 
> attach for h264"
> 
> 
> > Here is a patch where I fixed the attach of per-macroblock qp tables for
> > H.264. It was implemented for MPEG2 so I have only extended it.
> > 
> > I tested the functionality with the codecview filter using the following
> > command: `./ffmpeg -export_side_data 4 -i input.mp4 -vf codecview=qp=1
> > output.mp4`
> 
> Here is the new version of the patch.
> 
> I have remove the unnecessary line in qp_table.h and changed the commit
> message.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



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 2/4] avfilter/asrc_sinc: fix leak in config_input()

2025-06-23 Thread Michael Niedermayer
Hi

On Tue, Jun 17, 2025 at 10:14:14PM +0800, Lidong Yan wrote:
> In config_input(), fir_to_phase() allocates memory in h[longer].
> But if av_calloc() to s->coeffs failed, memory in h[longer] would
> leak. Add av_free(h[longer]) in !s->coeffs path.

does the other return in config_output() not need this free too?

thx

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

Some people wanted to paint the bikeshed green, some blue and some pink.
People argued and fought, when they finally agreed, only rust was left.


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/amfdec: Add VP9 AMF decoder

2025-06-23 Thread Dmitrii Ovchinnikov
From: nyanmisaka 

---
 configure  |  1 +
 libavcodec/Makefile|  1 +
 libavcodec/allcodecs.c |  1 +
 libavcodec/amfdec.c| 16 
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index f76f946dfe..fcc0af5681 100755
--- a/configure
+++ b/configure
@@ -3457,6 +3457,7 @@ vp8_vaapi_encoder_deps="VAEncPictureParameterBufferVP8"
 vp8_vaapi_encoder_select="vaapi_encode"
 vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
+vp9_amf_decoder_deps="amf"
 vp9_cuvid_decoder_deps="cuvid"
 vp9_mediacodec_decoder_deps="mediacodec"
 vp9_mediacodec_encoder_deps="mediacodec"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9630074205..3157729e55 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -799,6 +799,7 @@ OBJS-$(CONFIG_VP8_V4L2M2M_ENCODER) += v4l2_m2m_enc.o
 OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o vp9lpf.o 
vp9recon.o \
   vp9block.o vp9prob.o vp9mvs.o 
vpx_rac.o \
   vp9dsp_8bpp.o vp9dsp_10bpp.o 
vp9dsp_12bpp.o
+OBJS-$(CONFIG_VP9_AMF_DECODER) += amfdec.o
 OBJS-$(CONFIG_VP9_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER)  += mediacodecdec.o
 OBJS-$(CONFIG_VP9_MEDIACODEC_ENCODER)  += mediacodecenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 3be33f5cc4..fa90e25633 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -899,6 +899,7 @@ extern const FFCodec ff_vp8_mediacodec_encoder;
 extern const FFCodec ff_vp8_qsv_decoder;
 extern const FFCodec ff_vp8_v4l2m2m_encoder;
 extern const FFCodec ff_vp8_vaapi_encoder;
+extern const FFCodec ff_vp9_amf_decoder;
 extern const FFCodec ff_vp9_cuvid_decoder;
 extern const FFCodec ff_vp9_mediacodec_decoder;
 extern const FFCodec ff_vp9_mediacodec_encoder;
diff --git a/libavcodec/amfdec.c b/libavcodec/amfdec.c
index 88e55a7752..75a624d48c 100644
--- a/libavcodec/amfdec.c
+++ b/libavcodec/amfdec.c
@@ -89,6 +89,9 @@ static int amf_init_decoder(AVCodecContext *avctx)
 AMFBuffer   *buffer;
 amf_int64   color_profile;
 int pool_size = 36;
+// way-around for older drivers that don't support dynamic bitness 
detection -
+// define HEVC and VP9 10-bit based on container info
+int no_bitness_detect = 
amf_legacy_driver_no_bitness_detect(amf_device_ctx);
 
 ctx->drain = 0;
 ctx->resolution_changed = 0;
@@ -99,13 +102,17 @@ static int amf_init_decoder(AVCodecContext *avctx)
 break;
 case AV_CODEC_ID_HEVC: {
 codec_id = AMFVideoDecoderHW_H265_HEVC;
-// way-around for older drivers that don't support dynamic butness 
detection -
-// define HEVC 10-bit based on container info
-if(amf_legacy_driver_no_bitness_detect(amf_device_ctx)){
+if(no_bitness_detect){
 if(avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
 codec_id = AMFVideoDecoderHW_H265_MAIN10;
 }
-
+} break;
+case AV_CODEC_ID_VP9: {
+codec_id = AMFVideoDecoderHW_VP9;
+if(no_bitness_detect){
+if(avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
+codec_id = AMFVideoDecoderHW_VP9_10BIT;
+}
 } break;
 case AV_CODEC_ID_AV1:
 codec_id = AMFVideoDecoderHW_AV1;
@@ -713,4 +720,5 @@ const FFCodec ff_##x##_amf_decoder = { \
 
 DEFINE_AMF_DECODER(h264, H264, "h264_mp4toannexb")
 DEFINE_AMF_DECODER(hevc, HEVC, NULL)
+DEFINE_AMF_DECODER(vp9, VP9, NULL)
 DEFINE_AMF_DECODER(av1, AV1, NULL)
-- 
2.47.1.windows.2

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

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


[FFmpeg-devel] [PATCH 01/48] avcodec/ituh263dec: Use correct logcontext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

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

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index f1f96010b2..95cd8f0b13 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -1295,7 +1295,8 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
 s->qscale = get_bits(&s->gb, 5);
 }
 
-if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0)
+ret = av_image_check_size(s->width, s->height, 0, s->avctx);
+if (ret < 0)
 return ret;
 
 if (!(s->avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
-- 
ffmpeg-codebot

___
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 00/48] H263DecContext

2025-06-23 Thread ffmpegagent
This patchset adds a H263DecContext and moves the fields of MpegEncContext
that are only used by the H.263-based decoders (those using h263dec.c) to
it. It also adds a special slice context for the MPEG-1/2 decoders and moves
the GetBitContext from MpegEncContext to the actual decoder contexts (no
get_bits.h inclusion in encoders any longer). Furthermore, MpegEncContext.
is put into the codec contexts and no longer separately allocated.

Andreas Rheinhardt (48):
  avcodec/ituh263dec: Use correct logcontext
  avcodec/rl: Avoid branch in index lookup
  avcodec/ituh263enc: Simplify creating LUT
  avcodec/ituh263dec: Only initialize ff_h263_rl_inter when needed
  avcodec/mpegvideoenc: Allocate blocks as part of MPVEncContext
  avcodec/mpegvideo: Add MPVContext typedef
  avcodec/mpegvideo_dec: Factor debugging dct coefficients out
  avcodec/mpegvideo_dec: Reindent after the previous commit
  avcodec/mpeg_er: Don't use MpegEncContext.block
  avcodec/mpegvideodec: Remove size expectation from
ff_mpv_reconstruct_mb
  avcodec/h261dec: Stop using MpegEncContext.gb
  avcodec/h261dec: Don't use MpegEncContext.block
  avcodec/mpeg12dec: Put GetBitContext on the stack where advantageous
  avcodec/mpeg12dec: Remove unused function parameter
  avcodec/rv34: Don't use MpegEncContext.gb
  avcodec/rv34: Don't use MpegEncContext.block
  avcodec/intrax8: Don't pretend to need more than one int16_t[64]
  avcodec/vc1: Stop using MpegEncContext.gb
  avcodec/vc1: Don't use MpegEncContext.block
  avcodec/mpeg12dec: Deduplicate variables
  avcodec/mpegvideo: Move flipflop_rounding to
{MSMPEG4Dec,MPVEnc}Context
  avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext
  avcodec/mpeg4videodec: Avoid unnecessary indirections
  avcodec/{h263,mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext*
  avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext
  avcodec/h263dec: Add H263DecContext
  avcodec/h263dec: Remove redundant block parameter from decode_mb
  avcodec/h263dec: Don't use MpegEncContext.block
  avcodec/h263dec: Stop using MpegEncContext.gb
  avcodec/mpeg12dec: Add Mpeg12SliceContext
  avcodec/mpegvideo: Add missing headers
  avcodec/mpeg12dec: Move MpegEncContext.gb to Mpeg12SliceContext
  avcodec/mpeg12dec: Don't use MPVContext.block
  avcodec/mpegvideo: Move fields only used by H.263 decoders to
H263DecCtx
  avcodec/mpegvideo: Move mb_num_left to {H263,RV34}DecContext
  avcodec/mpeg12dec: Put mb_skip_run on the stack
  avcodec/mpegvideo: Move mb_skip_run to {RV34Dec,MPVEnc}Context
  avcodec/mpegvideo: Move SLICE_* defs to h263dec.h, h261dec.c
  avcodec/msmpeg4dec: Move ff_msmpeg4_decode_init() down
  avcodec/h263dec: Use function ptr for decode_picture_header
  avcodec/ituh263enc: Inline value of h263_flv
  avcodec/flvdec: Binarize h263_flv
  avcodec/mpegvideo: Move fields to {H263Dec,MPVEnc}Context when
possible
  avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time
  avcodec/mpegvideo: Move partitioned_frame to {H263Dec,MPVEnc}Context
  avcodec/mpegvideo: Move loop_filter to {H263Dec,MPVEnc,VC1}Context
  avcodec/rv34: Don't report progress unnecessarily
  avcodec/rv34: Fix spelling mistake

 libavcodec/dxva2_vc1.c |6 +-
 libavcodec/error_resilience.c  |2 +
 libavcodec/flvdec.c|   60 +-
 libavcodec/flvdec.h|4 +-
 libavcodec/flvenc.c|4 +-
 libavcodec/h261dec.c   |   95 +-
 libavcodec/h261enc.c   |   18 +-
 libavcodec/h263data.h  |4 +
 libavcodec/h263dec.c   |  427 +++---
 libavcodec/h263dec.h   |   81 +-
 libavcodec/h263enc.h   |2 +-
 libavcodec/intelh263dec.c  |  110 +-
 libavcodec/intrax8.c   |   16 +-
 libavcodec/intrax8.h   |4 +-
 libavcodec/ituh263dec.c|  950 ++---
 libavcodec/ituh263enc.c|  112 +-
 libavcodec/me_cmp.c|1 +
 libavcodec/mips/mpegvideo_msa.c|1 +
 libavcodec/motion_est.c|4 +-
 libavcodec/motion_est.h|1 +
 libavcodec/mpeg12dec.c |  909 +++--
 libavcodec/mpeg12enc.c |   11 +-
 libavcodec/mpeg4video_parser.c |4 +-
 libavcodec/mpeg4videodec.c | 1741 
 libavcodec/mpeg4videodec.h |   13 +-
 libavcodec/mpeg4videoenc.c |   21 +-
 libavcodec/mpeg_er.c   |7 +-
 libavcodec/mpeg_er.h   |9 +
 libavcodec/mpegvideo.c |   28 +-
 libavcodec/mpegvideo.h |   49 +-
 libavcodec/mpegvideo_dec.c |   37 +-
 libavcodec/mpegvideo_enc.c |  178 +--
 libavcodec/mpegvideodec.h  |8 +-
 libavcodec/mpegvideoenc.h  |   21 +
 libavcodec/msmpeg4.c   |1 +
 libavcodec/msmpeg4dec.c  

[FFmpeg-devel] [PATCH 03/48] avcodec/ituh263enc: Simplify creating LUT

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Only very few combinations (2x102) of 16384 correspond to
valid codes; so just initialize all codes via memset
and then set the few valid codes explicitly instead of initializing
everything in the same way.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263data.h   |  4 +++
 libavcodec/ituh263enc.c | 54 +
 2 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h
index 06554bdf0d..e733089e83 100644
--- a/libavcodec/h263data.h
+++ b/libavcodec/h263data.h
@@ -59,6 +59,10 @@ extern const uint16_t ff_inter_vlc[103][2];
 extern const int8_t ff_inter_level[102];
 extern const int8_t ff_inter_run[102];
 
+/* the following defines are valid for both ff_h263_rl_inter and 
ff_rl_intra_aic */
+#define H263_RL_NB_ELEMS 102 // does not include escape
+#define H263_RL_NON_LAST_CODES 58
+#define H263_ESCAPE_CODE_LENGTH 7
 extern RLTable ff_h263_rl_inter;
 extern RLTable ff_rl_intra_aic;
 
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 903bb45fce..4ec851cab9 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -99,41 +99,31 @@ static uint8_t  uni_h263_inter_rl_len [64*64*2*2];
 
 static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab)
 {
+const uint16_t (*table_vlc)[2] = rl->table_vlc;
+const uint8_t   *table_run = rl->table_run;
+const uint8_t *table_level = rl->table_level;
+
 av_assert0(MAX_LEVEL >= 64);
 av_assert0(MAX_RUN   >= 63);
 
-for (int slevel = -64; slevel < 64; slevel++) {
-if (slevel == 0) continue;
-for (int run = 0; run < 64; run++) {
-for (int last = 0; last <= 1; last++) {
-const int index = UNI_MPEG4_ENC_INDEX(last, run, slevel + 64);
-int level = slevel < 0 ? -slevel : slevel;
-int sign  = slevel < 0 ? 1 : 0;
-int bits, len, code;
-
-len_tab[index] = 100;
-
-/* ESC0 */
-code = get_rl_index(rl, last, run, level);
-bits = rl->table_vlc[code][0];
-len  = rl->table_vlc[code][1];
-bits = bits * 2 + sign;
-len++;
-
-if (code != rl->n && len < len_tab[index])
-len_tab[index] = len;
-
-/* ESC */
-bits = rl->table_vlc[rl->n][0];
-len  = rl->table_vlc[rl->n][1];
-bits = bits *   2 + last; len++;
-bits = bits *  64 + run;  len += 6;
-bits = bits * 256 + (level & 0xff); len += 8;
-
-if (len < len_tab[index])
-len_tab[index] = len;
-}
-}
+// Note: The LUT only covers level values for which the escape value
+//   is eight bits (not 8 + 5 + 6)
+memset(len_tab, H263_ESCAPE_CODE_LENGTH + 1 + 6 + 8,
+   sizeof(uni_h263_intra_aic_rl_len));
+
+len_tab += 64; // simplifies addressing
+for (int i = 0; i < H263_RL_NB_ELEMS; ++i) {
+int run   = table_run[i];
+int level = table_level[i];
+int last  = i >= H263_RL_NON_LAST_CODES;
+int len   = table_vlc[i][1];
+
+len_tab[UNI_MPEG4_ENC_INDEX(last, run,  level)] =
+len_tab[UNI_MPEG4_ENC_INDEX(last, run, -level)] = len + 1 /* sign */;
+}
+for (int run = 0; run < MAX_RUN; ++run) {
+len_tab[UNI_MPEG4_ENC_INDEX(0, run, 0)] =
+len_tab[UNI_MPEG4_ENC_INDEX(1, run, 0)] = 0; // is this necessary?
 }
 }
 #endif
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 05/48] avcodec/mpegvideoenc: Allocate blocks as part of MPVEncContext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This avoids mpegvideo.c having to deal with the fact that
the encoders use two sets of blocks and is in preparation
for not allocating blocks at all.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263enc.h   |  2 +-
 libavcodec/mpeg4videodec.c |  1 -
 libavcodec/mpeg4videoenc.c |  2 +-
 libavcodec/mpegvideo.c | 12 +++---
 libavcodec/mpegvideo.h |  3 +-
 libavcodec/mpegvideo_enc.c | 78 +++---
 libavcodec/mpegvideoenc.h  |  5 +++
 7 files changed, 54 insertions(+), 49 deletions(-)

diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h
index 20e0c57326..5a6e7d500d 100644
--- a/libavcodec/h263enc.h
+++ b/libavcodec/h263enc.h
@@ -87,7 +87,7 @@ static inline int get_p_cbp(MPVEncContext *const s,
 for (int i = 0; i < 6; i++) {
 if (s->c.block_last_index[i] >= 0 && !((cbp >> (5 - i)) & 1)) {
 s->c.block_last_index[i] = -1;
-s->c.bdsp.clear_block(s->c.block[i]);
+s->c.bdsp.clear_block(s->block[i]);
 }
 }
 } else {
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 2e3609b0d5..34f383bbbd 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3826,7 +3826,6 @@ static av_cold void clear_context(MpegEncContext *s)
 memset(s->thread_context, 0, sizeof(s->thread_context));
 
 s->block = NULL;
-s->blocks = NULL;
 s->ac_val_base = NULL;
 s->ac_val = NULL;
 memset(&s->sc, 0, sizeof(s->sc));
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index a9d673707a..1aa35aa70a 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -433,7 +433,7 @@ static inline int get_b_cbp(MPVEncContext *const s, int16_t 
block[6][64],
 for (i = 0; i < 6; i++) {
 if (s->c.block_last_index[i] >= 0 && ((cbp >> (5 - i)) & 1) == 0) {
 s->c.block_last_index[i] = -1;
-s->c.bdsp.clear_block(s->c.block[i]);
+s->c.bdsp.clear_block(s->block[i]);
 }
 }
 } else {
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ff2703f487..3cbd686558 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -116,9 +116,11 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s)
 
 static av_cold int init_duplicate_context(MpegEncContext *s)
 {
-if (!FF_ALLOCZ_TYPED_ARRAY(s->blocks,  1 + s->encoding))
-return AVERROR(ENOMEM);
-s->block = s->blocks[0];
+if (!s->encoding) {
+s->block = av_mallocz(12 * sizeof(*s->block));
+if (!s->block)
+return AVERROR(ENOMEM);
+}
 
 return 0;
 }
@@ -158,8 +160,7 @@ static av_cold void free_duplicate_context(MpegEncContext 
*s)
 s->sc.obmc_scratchpad = NULL;
 s->sc.linesize = 0;
 
-av_freep(&s->blocks);
-s->block = NULL;
+av_freep(&s->block);
 }
 
 static av_cold void free_duplicate_contexts(MpegEncContext *s)
@@ -175,7 +176,6 @@ int ff_update_duplicate_context(MpegEncContext *dst, const 
MpegEncContext *src)
 {
 #define COPY(M)  \
 M(ScratchpadContext, sc) \
-M(void*, blocks) \
 M(void*, block)  \
 M(int, start_mb_y)   \
 M(int, end_mb_y) \
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 55a490adc7..4ff5e8906d 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -309,8 +309,7 @@ typedef struct MpegEncContext {
 int interlaced_dct;
 int first_field; ///< is 1 for the first field of a field picture 
0 otherwise
 
-int16_t (*block)[64]; ///< points to one of the following blocks
-int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block
+int16_t (*block)[64];
 int (*decode_mb)(struct MpegEncContext *s, int16_t block[12][64]); // used 
by some codecs to avoid a switch()
 
 #define SLICE_OK 0
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 1f51f237fa..1ceb6296c4 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -538,6 +538,8 @@ static av_cold int init_slice_buffers(MPVMainEncContext 
*const m)
 for (unsigned i = 0; i < nb_slices; ++i) {
 MPVEncContext *const s2 = s->c.enc_contexts[i];
 
+s2->block = s2->blocks[0];
+
 if (dct_error) {
 s2->dct_offset= s->dct_offset;
 s2->dct_error_sum = (void*)dct_error;
@@ -2184,7 +2186,7 @@ static inline void 
dct_single_coeff_elimination(MPVEncContext *const s,
 int score = 0;
 int run = 0;
 int i;
-int16_t *block = s->c.block[n];
+int16_t *block = s->block[n];
 const int last_index = s->c.block_last_index[n];
 int skip_dc;
 
@@ -2399,27 +2401,27 @@ static av_always_inline void 
encode_mb_internal(MPVEncContext *const s,
 }
 }
 
-s->pdsp.get_pixels(s->c.block[0], ptr_y,  wrap_y);
-s->pdsp.get_pixels(s->c.block[1], ptr_

[FFmpeg-devel] [PATCH 02/48] avcodec/rl: Avoid branch in index lookup

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This uses the same logic as the MPEG-1/2 and SpeedHQ encoders.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/rl.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index c45d8659d1..2588de2440 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -100,13 +100,9 @@ do {\
 
 static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
 {
-int index;
-index = rl->index_run[last][run];
-if (index >= rl->n)
-return rl->n;
 if (level > rl->max_level[last][run])
 return rl->n;
-return index + level - 1;
+return rl->index_run[last][run] + level - 1;
 }
 
 #endif /* AVCODEC_RL_H */
-- 
ffmpeg-codebot

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

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


[FFmpeg-devel] [PATCH 04/48] avcodec/ituh263dec: Only initialize ff_h263_rl_inter when needed

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

The H.263 decoder itself does not need max_run/max_level
of this RLTable, only the MPEG-4 decoder does.

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

diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 95cd8f0b13..fa09ebb84b 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -123,7 +123,6 @@ static av_cold void h263_decode_init_vlc(void)
 VLC_INIT_STATIC_TABLE(ff_h263_mv_vlc, H263_MV_VLC_BITS, 33,
   &ff_mvtab[0][1], 2, 1,
   &ff_mvtab[0][0], 2, 1, 0);
-ff_h263_init_rl_inter();
 VLC_INIT_RL(ff_h263_rl_inter, 554);
 INIT_FIRST_VLC_RL(ff_rl_intra_aic, 554);
 VLC_INIT_STATIC_SPARSE_TABLE(h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 522242de40..2e3609b0d5 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3962,6 +3962,7 @@ static av_cold void mpeg4_init_static(void)
 
 static uint8_t mpeg4_rl_intra_table[2][2 * MAX_RUN + MAX_LEVEL + 3];
 ff_rl_init(&ff_mpeg4_rl_intra, mpeg4_rl_intra_table);
+ff_h263_init_rl_inter();
 
 INIT_FIRST_VLC_RL(ff_mpeg4_rl_intra, 554);
 VLC_INIT_RL(ff_rvlc_rl_inter, 1072);
-- 
ffmpeg-codebot

___
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 29/48] avcodec/h263dec: Stop using MpegEncContext.gb

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Add a GetBitContext to H263DecContext instead. This is in preparation
for removing MpegEncContext.gb.
Also move last_resync_gb to H263DecContext.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/flvdec.c|  24 +--
 libavcodec/h263dec.c   |  52 +++---
 libavcodec/h263dec.h   |   5 +
 libavcodec/intelh263dec.c  |  64 +++
 libavcodec/ituh263dec.c| 339 +++--
 libavcodec/mpeg12dec.c |  10 +-
 libavcodec/mpeg4videodec.c | 320 +-
 libavcodec/mpegvideo.h |   1 -
 libavcodec/mpegvideodec.h  |   6 +-
 libavcodec/msmpeg4dec.c| 188 ++--
 libavcodec/rv10.c  |  62 +++
 libavcodec/vaapi_mpeg4.c   |   8 +-
 libavcodec/wmv2dec.c   |  92 +-
 13 files changed, 588 insertions(+), 583 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index a5d96584f1..f2d0b642b7 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -31,26 +31,26 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 int format, width, height;
 
 /* picture header */
-if (get_bits(&h->c.gb, 17) != 1) {
+if (get_bits(&h->gb, 17) != 1) {
 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture start code\n");
 return AVERROR_INVALIDDATA;
 }
-format = get_bits(&h->c.gb, 5);
+format = get_bits(&h->gb, 5);
 if (format != 0 && format != 1) {
 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
 return AVERROR_INVALIDDATA;
 }
 h->c.h263_flv   = format + 1;
-h->c.picture_number = get_bits(&h->c.gb, 8); /* picture timestamp */
-format= get_bits(&h->c.gb, 3);
+h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
+format= get_bits(&h->gb, 3);
 switch (format) {
 case 0:
-width  = get_bits(&h->c.gb, 8);
-height = get_bits(&h->c.gb, 8);
+width  = get_bits(&h->gb, 8);
+height = get_bits(&h->gb, 8);
 break;
 case 1:
-width  = get_bits(&h->c.gb, 16);
-height = get_bits(&h->c.gb, 16);
+width  = get_bits(&h->gb, 16);
+height = get_bits(&h->gb, 16);
 break;
 case 2:
 width  = 352;
@@ -81,18 +81,18 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 h->c.width  = width;
 h->c.height = height;
 
-h->c.pict_type = AV_PICTURE_TYPE_I + get_bits(&h->c.gb, 2);
+h->c.pict_type = AV_PICTURE_TYPE_I + get_bits(&h->gb, 2);
 h->c.droppable = h->c.pict_type > AV_PICTURE_TYPE_P;
 if (h->c.droppable)
 h->c.pict_type = AV_PICTURE_TYPE_P;
 
-skip_bits1(&h->c.gb); /* deblocking flag */
-h->c.chroma_qscale = h->c.qscale = get_bits(&h->c.gb, 5);
+skip_bits1(&h->gb); /* deblocking flag */
+h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
 
 h->c.h263_long_vectors = 0;
 
 /* PEI */
-if (skip_1stop_8data_bits(&h->c.gb) < 0)
+if (skip_1stop_8data_bits(&h->gb) < 0)
 return AVERROR_INVALIDDATA;
 
 if (h->c.ehc_mode)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 161f13b1e1..fc63e8a5d8 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -187,7 +187,7 @@ static int decode_slice(H263DecContext *const h)
 const int mb_size   = 16 >> h->c.avctx->lowres;
 int ret;
 
-h->c.last_resync_gb   = h->c.gb;
+h->last_resync_gb = h->gb;
 h->c.first_slice_line = 1;
 h->c.resync_mb_x  = h->c.mb_x;
 h->c.resync_mb_y  = h->c.mb_y;
@@ -200,8 +200,8 @@ static int decode_slice(H263DecContext *const h)
 }
 
 if (h->c.avctx->hwaccel) {
-const uint8_t *start = h->c.gb.buffer + get_bits_count(&h->c.gb) / 8;
-ret = FF_HW_CALL(h->c.avctx, decode_slice, start, h->c.gb.buffer_end - 
start);
+const uint8_t *start = h->gb.buffer + get_bits_count(&h->gb) / 8;
+ret = FF_HW_CALL(h->c.avctx, decode_slice, start, h->gb.buffer_end - 
start);
 // ensure we exit decode loop
 h->c.mb_y = h->c.mb_height;
 return ret;
@@ -253,7 +253,7 @@ static int decode_slice(H263DecContext *const h)
 h->c.mv_dir  = MV_DIR_FORWARD;
 h->c.mv_type = MV_TYPE_16X16;
 ff_dlog(h->c.avctx, "%d %06X\n",
-get_bits_count(&h->c.gb), show_bits(&h->c.gb, 24));
+get_bits_count(&h->gb), show_bits(&h->gb, 24));
 
 ff_tlog(NULL, "Decoding MB at %dx%d\n", h->c.mb_x, h->c.mb_y);
 ret = h->decode_mb(h);
@@ -300,7 +300,7 @@ static int decode_slice(H263DecContext *const h)
 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,
 h->c.mb_x, h->c.mb_y, ER_MB_ERROR & part_mask);
 
-if ((h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) && 
get_bits_left(&h->c.gb) > 0)
+if ((h->c.avctx->err_recognition & AV_EF_IGNORE_ERR) && 
get_bits_left(&h->gb) > 0)
  

[FFmpeg-devel] [PATCH 38/48] avcodec/mpegvideo: Move SLICE_* defs to h263dec.h, h261dec.c

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h261dec.c   | 4 
 libavcodec/h263dec.h   | 4 
 libavcodec/mpegvideo.h | 5 -
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index e47bc00a71..32d41903e7 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -37,6 +37,10 @@
 #include "mpegvideodec.h"
 #include "h261.h"
 
+#define SLICE_OK 0
+#define SLICE_ERROR -1
+#define SLICE_END   -2 ///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 37/48] avcodec/mpegvideo: Move mb_skip_run to {RV34Dec, MPVEnc}Context

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h261enc.c   | 12 ++--
 libavcodec/mpeg12enc.c |  8 
 libavcodec/mpegvideo.h |  1 -
 libavcodec/mpegvideo_enc.c | 11 ++-
 libavcodec/mpegvideoenc.h  |  2 ++
 libavcodec/rv34.c  |  4 ++--
 libavcodec/rv34.h  |  1 +
 libavcodec/rv40.c  |  8 
 8 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index c217fb6233..466a0387c5 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -92,7 +92,7 @@ static int h261_encode_picture_header(MPVMainEncContext 
*const m)
 
 put_bits(&s->pb, 1, 0); /* no PEI */
 h->gob_number = h->format - 1;
-s->c.mb_skip_run = 0;
+s->mb_skip_run = 0;
 
 return 0;
 }
@@ -112,7 +112,7 @@ static void h261_encode_gob_header(MPVEncContext *const s, 
int mb_line)
 put_bits(&s->pb, 4, h->gob_number); /* GN */
 put_bits(&s->pb, 5, s->c.qscale); /* GQUANT */
 put_bits(&s->pb, 1, 0); /* no GEI */
-s->c.mb_skip_run = 0;
+s->mb_skip_run = 0;
 s->c.last_mv[0][0][0] = 0;
 s->c.last_mv[0][0][1] = 0;
 }
@@ -248,7 +248,7 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t 
block[6][64],
 
 if ((cbp | mvd) == 0) {
 /* skip macroblock */
-s->c.mb_skip_run++;
+s->mb_skip_run++;
 s->c.last_mv[0][0][0] = 0;
 s->c.last_mv[0][0][1] = 0;
 s->c.qscale -= s->dquant;
@@ -258,9 +258,9 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t 
block[6][64],
 
 /* MB is not skipped, encode MBA */
 put_bits(&s->pb,
- ff_h261_mba_bits[s->c.mb_skip_run],
- ff_h261_mba_code[s->c.mb_skip_run]);
-s->c.mb_skip_run = 0;
+ ff_h261_mba_bits[s->mb_skip_run],
+ ff_h261_mba_code[s->mb_skip_run]);
+s->mb_skip_run = 0;
 
 /* calculate MTYPE */
 if (!s->c.mb_intra) {
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 96957235e9..521a915aa0 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -688,7 +688,7 @@ static av_always_inline void 
mpeg1_encode_mb_internal(MPVEncContext *const s,
((s->c.mv_dir & MV_DIR_BACKWARD)
 ? ((s->c.mv[1][0][0] - s->c.last_mv[1][0][0]) |
(s->c.mv[1][0][1] - s->c.last_mv[1][0][1])) : 0)) == 0))) {
-s->c.mb_skip_run++;
+s->mb_skip_run++;
 s->c.qscale -= s->dquant;
 s->misc_bits++;
 s->last_bits++;
@@ -700,10 +700,10 @@ static av_always_inline void 
mpeg1_encode_mb_internal(MPVEncContext *const s,
 }
 } else {
 if (first_mb) {
-av_assert0(s->c.mb_skip_run == 0);
+av_assert0(s->mb_skip_run == 0);
 encode_mb_skip_run(s, s->c.mb_x);
 } else {
-encode_mb_skip_run(s, s->c.mb_skip_run);
+encode_mb_skip_run(s, s->mb_skip_run);
 }
 
 if (s->c.pict_type == AV_PICTURE_TYPE_I) {
@@ -925,7 +925,7 @@ static av_always_inline void 
mpeg1_encode_mb_internal(MPVEncContext *const s,
 for (i = 0; i < mb_block_count; i++)
 if (cbp & (1 << (mb_block_count - 1 - i)))
 mpeg1_encode_block(s, block[i], i);
-s->c.mb_skip_run = 0;
+s->mb_skip_run = 0;
 if (s->c.mb_intra)
 s->i_tex_bits += get_bits_diff(s);
 else
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 7e92ac8be9..4c5f034690 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -196,7 +196,6 @@ typedef struct MpegEncContext {
 
 /* macroblock layer */
 int mb_x, mb_y;
-int mb_skip_run;
 int mb_intra;
 
 int block_index[6]; ///< index to current MB in block based arrays with 
edges
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index afdc2fb787..a16cb6bd19 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2647,11 +2647,12 @@ typedef struct MBBackup {
 int last_mv[2][2][2];
 int mv_type, mv_dir;
 int last_dc[3];
-int mb_intra, mb_skipped, mb_skip_run;
+int mb_intra, mb_skipped;
 int qscale;
 int block_last_index[8];
 int interlaced_dct;
 } c;
+int mb_skip_run;
 int mv_bits, i_tex_bits, p_tex_bits, i_count, misc_bits, last_bits;
 int dquant;
 int esc3_level_length;
@@ -2667,7 +2668,7 @@ static inline void BEFORE 
##_context_before_encode(DST_TYPE *const d,   \
 memcpy(d->c.last_mv, s->c.last_mv, 2*2*2*sizeof(int));  \
 \
 /* MPEG-1 */\
-d->c.mb_skip_run = s->c.mb_skip_run;\
+d->mb_skip_run = s->mb_skip_run;\
 for (int i = 0; i < 3

[FFmpeg-devel] [PATCH 35/48] avcodec/mpegvideo: Move mb_num_left to {H263, RV34}DecContext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.h   |  2 ++
 libavcodec/ituh263dec.c|  2 +-
 libavcodec/mpeg4videodec.c |  4 ++--
 libavcodec/mpegvideo.h |  1 -
 libavcodec/rv10.c  |  2 +-
 libavcodec/rv34.c  | 16 
 libavcodec/rv34.h  |  2 ++
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index dd63eca5be..90340a59bd 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -50,6 +50,8 @@ typedef struct H263DecContext {
 
 GetBitContext gb;
 
+int mb_num_left;///< number of MBs left in this video packet 
(for partitioned slices only)
+
 int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
 
 /* motion compensation */
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 11be8189a6..94cde850b5 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -1061,7 +1061,7 @@ intra:
 return -1;
 if (h->c.obmc && !h->c.mb_intra) {
 if (h->c.pict_type == AV_PICTURE_TYPE_P &&
-h->c.mb_x + 1 < h->c.mb_width && h->c.mb_num_left != 1)
+h->c.mb_x + 1 < h->c.mb_width && h->mb_num_left != 1)
 preview_obmc(h);
 }
 end:
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index f3af523b7c..c53f5c103a 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1335,7 +1335,7 @@ int ff_mpeg4_decode_partitions(H263DecContext *const h)
 return AVERROR_INVALIDDATA;
 }
 
-h->c.mb_num_left = mb_num;
+h->mb_num_left = mb_num;
 
 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
 while (show_bits(&h->gb, 9) == 1)
@@ -1723,7 +1723,7 @@ static int mpeg4_decode_partitioned_mb(H263DecContext 
*const h)
 }
 
 /* per-MB end of slice check */
-if (--h->c.mb_num_left <= 0) {
+if (--h->mb_num_left <= 0) {
 if (mpeg4_is_resync(ctx))
 return SLICE_END;
 else
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index ff3a249512..7e92ac8be9 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -214,7 +214,6 @@ typedef struct MpegEncContext {
 /* error concealment / resync */
 int resync_mb_x; ///< x position of last resync marker
 int resync_mb_y; ///< y position of last resync marker
-int mb_num_left; ///< number of MBs left in this video 
packet (for partitioned Slices only)
 
 /* H.263 specific */
 int gob_index;
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index bbd0482d59..c104efc212 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -481,7 +481,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const 
uint8_t *buf,
 ff_init_block_index(&h->c);
 
 /* decode each macroblock */
-for (h->c.mb_num_left = mb_count; h->c.mb_num_left > 0; 
h->c.mb_num_left--) {
+for (h->mb_num_left = mb_count; h->mb_num_left > 0; h->mb_num_left--) {
 int ret;
 ff_update_block_index(&h->c, 8, h->c.avctx->lowres, 1);
 ff_tlog(avctx, "**mb x=%d y=%d\n", h->c.mb_x, h->c.mb_y);
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 9f8a0f12b8..bb08c9bc5c 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1362,7 +1362,7 @@ static int check_slice_end(RV34DecContext *r, 
MpegEncContext *s)
 int bits;
 if(s->mb_y >= s->mb_height)
 return 1;
-if(!s->mb_num_left)
+if (!r->mb_num_left)
 return 1;
 if(r->s.mb_skip_run > 1)
 return 0;
@@ -1446,7 +1446,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, 
const uint8_t* buf, int
 
 r->si.end = end;
 s->qscale = r->si.quant;
-s->mb_num_left = r->si.end - r->si.start;
+r->mb_num_left = r->si.end - r->si.start;
 r->s.mb_skip_run = 0;
 
 mb_pos = s->mb_x + s->mb_y * s->mb_width;
@@ -1492,7 +1492,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, 
const uint8_t* buf, int
 }
 if(s->mb_x == s->resync_mb_x)
 s->first_slice_line=0;
-s->mb_num_left--;
+r->mb_num_left--;
 }
 ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, 
s->mb_y, ER_MB_END);
 
@@ -1579,7 +1579,7 @@ static int finish_frame(AVCodecContext *avctx, AVFrame 
*pict)
 
 ff_er_frame_end(&s->er, NULL);
 ff_mpv_frame_end(s);
-s->mb_num_left = 0;
+r->mb_num_left = 0;
 
 if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
 ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX);
@@ -1667,9 +1667,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 
 /* first slice */
 if (si.start == 0) {
-if (s->mb_num_left > 0 && s->cur_pic.ptr) {
+if (r->mb_num_left > 0 && s->cur_pic.ptr) {
 av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n",
-   s->mb_num_left)

[FFmpeg-devel] [PATCH 39/48] avcodec/msmpeg4dec: Move ff_msmpeg4_decode_init() down

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Will avoid a forward declaration lateron.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msmpeg4dec.c | 79 +
 1 file changed, 40 insertions(+), 39 deletions(-)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 36243e14c9..59ceb7dac6 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -360,45 +360,6 @@ static av_cold void msmpeg4_decode_init_static(void)
 ff_msmp4_vc1_vlcs_init_once();
 }
 
-av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
-{
-static AVOnce init_static_once = AV_ONCE_INIT;
-H263DecContext *const h = avctx->priv_data;
-int ret;
-
-if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
-return ret;
-
-if (ff_h263_decode_init(avctx) < 0)
-return -1;
-
-// We unquantize inter blocks as we parse them.
-h->c.dct_unquantize_inter = NULL;
-
-ff_msmpeg4_common_init(&h->c);
-
-switch (h->c.msmpeg4_version) {
-case MSMP4_V1:
-case MSMP4_V2:
-h->decode_mb = msmpeg4v12_decode_mb;
-break;
-case MSMP4_V3:
-case MSMP4_WMV1:
-h->decode_mb = msmpeg4v34_decode_mb;
-break;
-case MSMP4_WMV2:
-break;
-default:
-av_unreachable("List contains all cases using 
ff_msmpeg4_decode_init()");
-}
-
-h->c.slice_height = h->c.mb_height; //to avoid 1/0 if the first frame is 
not a keyframe
-
-ff_thread_once(&init_static_once, msmpeg4_decode_init_static);
-
-return 0;
-}
-
 int ff_msmpeg4_decode_picture_header(H263DecContext *const h)
 {
 MSMP4DecContext *const ms = mpv_to_msmpeg4(h);
@@ -870,6 +831,46 @@ void ff_msmpeg4_decode_motion(MSMP4DecContext *const ms, 
int *mx_ptr, int *my_pt
 *my_ptr = my;
 }
 
+av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
+{
+static AVOnce init_static_once = AV_ONCE_INIT;
+H263DecContext *const h = avctx->priv_data;
+int ret;
+
+ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
+if (ret < 0)
+return ret;
+
+if (ff_h263_decode_init(avctx) < 0)
+return -1;
+
+// We unquantize inter blocks as we parse them.
+h->c.dct_unquantize_inter = NULL;
+
+ff_msmpeg4_common_init(&h->c);
+
+switch (h->c.msmpeg4_version) {
+case MSMP4_V1:
+case MSMP4_V2:
+h->decode_mb = msmpeg4v12_decode_mb;
+break;
+case MSMP4_V3:
+case MSMP4_WMV1:
+h->decode_mb = msmpeg4v34_decode_mb;
+break;
+case MSMP4_WMV2:
+break;
+default:
+av_unreachable("List contains all cases using 
ff_msmpeg4_decode_init()");
+}
+
+h->c.slice_height = h->c.mb_height; //to avoid 1/0 if the first frame is 
not a keyframe
+
+ff_thread_once(&init_static_once, msmpeg4_decode_init_static);
+
+return 0;
+}
+
 const FFCodec ff_msmpeg4v1_decoder = {
 .p.name = "msmpeg4v1",
 CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 1"),
-- 
ffmpeg-codebot

___
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 36/48] avcodec/mpeg12dec: Put mb_skip_run on the stack

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index db6f9d66a5..998f6aa2e5 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -402,7 +402,7 @@ static inline int get_dmv(Mpeg12SliceContext *const s)
 #define MT_16X8  2
 #define MT_DMV   3
 
-static int mpeg_decode_mb(Mpeg12SliceContext *const s)
+static int mpeg_decode_mb(Mpeg12SliceContext *const s, int *mb_skip_run)
 {
 int i, j, k, cbp, val, mb_type, motion_type;
 const int mb_block_count = 4 + (1 << s->c.chroma_format);
@@ -412,7 +412,7 @@ static int mpeg_decode_mb(Mpeg12SliceContext *const s)
 
 av_assert2(s->c.mb_skipped == 0);
 
-if (s->c.mb_skip_run-- != 0) {
+if ((*mb_skip_run)-- != 0) {
 if (s->c.pict_type == AV_PICTURE_TYPE_P) {
 s->c.mb_skipped = 1;
 s->c.cur_pic.mb_type[s->c.mb_x + s->c.mb_y * s->c.mb_stride] =
@@ -1432,7 +1432,6 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, 
int mb_y,
 
 s->c.resync_mb_x = s->c.mb_x;
 s->c.resync_mb_y = s->c.mb_y = mb_y;
-s->c.mb_skip_run = 0;
 ff_init_block_index(&s->c);
 
 if (s->c.mb_y == 0 && s->c.mb_x == 0 && (s->c.first_field || 
s->c.picture_structure == PICT_FRAME)) {
@@ -1456,8 +1455,8 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, 
int mb_y,
 }
 }
 
-for (;;) {
-ret = mpeg_decode_mb(s);
+for (int mb_skip_run = 0;;) {
+ret = mpeg_decode_mb(s, &mb_skip_run);
 if (ret < 0)
 return ret;
 
@@ -1552,7 +1551,7 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, 
int mb_y,
 !s->c.progressive_sequence &&
 left <= 25 &&
 left >= 0 &&
-s->c.mb_skip_run == -1 &&
+mb_skip_run == -1 &&
 (!left || show_bits(&s->gb, left) == 0))
 goto eos;
 
@@ -1560,9 +1559,9 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, 
int mb_y,
 }
 
 /* skip mb handling */
-if (s->c.mb_skip_run == -1) {
+if (mb_skip_run == -1) {
 /* read increment again */
-s->c.mb_skip_run = 0;
+mb_skip_run = 0;
 for (;;) {
 int code = get_vlc2(&s->gb, ff_mbincr_vlc,
 MBINCR_VLC_BITS, 2);
@@ -1572,9 +1571,9 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, 
int mb_y,
 }
 if (code >= 33) {
 if (code == 33) {
-s->c.mb_skip_run += 33;
+mb_skip_run += 33;
 } else if (code == 35) {
-if (s->c.mb_skip_run != 0 || show_bits(&s->gb, 15) != 
0) {
+if (mb_skip_run != 0 || show_bits(&s->gb, 15) != 0) {
 av_log(s->c.avctx, AV_LOG_ERROR, "slice 
mismatch\n");
 return AVERROR_INVALIDDATA;
 }
@@ -1582,11 +1581,11 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const 
s, int mb_y,
 }
 /* otherwise, stuffing, nothing to do */
 } else {
-s->c.mb_skip_run += code;
+mb_skip_run += code;
 break;
 }
 }
-if (s->c.mb_skip_run) {
+if (mb_skip_run) {
 int i;
 if (s->c.pict_type == AV_PICTURE_TYPE_I) {
 av_log(s->c.avctx, AV_LOG_ERROR,
-- 
ffmpeg-codebot

___
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 43/48] avcodec/mpegvideo: Move fields to {H263Dec, MPVEnc}Context when possible

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/flvdec.c|  6 +--
 libavcodec/flvenc.c|  2 +-
 libavcodec/h261enc.c   |  2 +-
 libavcodec/h263dec.c   | 14 +++
 libavcodec/h263dec.h   | 14 +++
 libavcodec/intelh263dec.c  |  4 +-
 libavcodec/ituh263dec.c| 84 +++---
 libavcodec/ituh263enc.c| 44 ++--
 libavcodec/mpeg12enc.c |  3 +-
 libavcodec/mpeg4videodec.c | 20 +
 libavcodec/mpeg4videoenc.c | 18 
 libavcodec/mpegvideo.c |  2 -
 libavcodec/mpegvideo.h | 11 -
 libavcodec/mpegvideo_dec.c |  2 -
 libavcodec/mpegvideo_enc.c | 40 +-
 libavcodec/mpegvideoenc.h  | 11 +
 libavcodec/msmpeg4dec.c|  8 ++--
 libavcodec/msmpeg4enc.c|  6 +--
 libavcodec/ratecontrol.c   |  4 +-
 libavcodec/rv10.c  |  2 +-
 libavcodec/rv20enc.c   |  8 ++--
 libavcodec/snowenc.c   |  2 +-
 libavcodec/vaapi_mpeg4.c   |  2 +-
 libavcodec/wmv2dec.c   |  2 +-
 libavcodec/wmv2enc.c   |  2 +-
 25 files changed, 162 insertions(+), 151 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 881f63ed1a..0f6eaad5c6 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -40,8 +40,8 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
 return AVERROR_INVALIDDATA;
 }
-h->c.h263_flv   = format;
-h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
+h->flv= format;
+h->picture_number = get_bits(&h->gb, 8); /* picture timestamp */
 format= get_bits(&h->gb, 3);
 switch (format) {
 case 0:
@@ -101,7 +101,7 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
 av_log(h->c.avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
h->c.droppable ? 'D' : av_get_picture_type_char(h->c.pict_type),
-   h->c.h263_flv, h->c.qscale, h->c.picture_number);
+   h->flv, h->c.qscale, h->picture_number);
 }
 
 return 0;
diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c
index 91e1f07365..0b6e73b11e 100644
--- a/libavcodec/flvenc.c
+++ b/libavcodec/flvenc.c
@@ -35,7 +35,7 @@ int ff_flv_encode_picture_header(MPVMainEncContext *const m)
 /* 0: H.263 escape codes 1: 11-bit escape codes */
 put_bits(&s->pb, 5, 1);
 put_bits(&s->pb, 8,
- (((int64_t) s->c.picture_number * 30 * s->c.avctx->time_base.num) 
/   // FIXME use timestamp
+ (((int64_t) s->picture_number * 30 * s->c.avctx->time_base.num) / 
  // FIXME use timestamp
   s->c.avctx->time_base.den) & 0xff);   /* TemporalReference */
 if (s->c.width == 352 && s->c.height == 288)
 format = 2;
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 466a0387c5..89a6a69755 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -77,7 +77,7 @@ static int h261_encode_picture_header(MPVMainEncContext 
*const m)
 
 put_bits(&s->pb, 20, 0x10); /* PSC */
 
-temp_ref = s->c.picture_number * 3LL * s->c.avctx->time_base.num /
+temp_ref = s->picture_number * 3LL * s->c.avctx->time_base.num /
(1001LL * s->c.avctx->time_base.den);   // FIXME maybe this 
should use a timestamp
 put_sbits(&s->pb, 5, temp_ref); /* TemporalReference */
 
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 0bbc8e989e..723040146f 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -231,7 +231,7 @@ static int decode_slice(H263DecContext *const h)
 for (; h->c.mb_y < h->c.mb_height; h->c.mb_y++) {
 /* per-row end of slice checks */
 if (h->c.msmpeg4_version != MSMP4_UNUSED) {
-if (h->c.resync_mb_y + h->c.slice_height == h->c.mb_y) {
+if (h->c.resync_mb_y + h->slice_height == h->c.mb_y) {
 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,
 h->c.mb_x - 1, h->c.mb_y, ER_MB_END);
 
@@ -330,7 +330,7 @@ static int decode_slice(H263DecContext *const h)
 (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
 get_bits_left(&h->gb) >= 48&&
 show_bits(&h->gb, 24) == 0x4010&&
-!h->c.data_partitioning)
+!h->data_partitioning)
 h->padding_bug_score += 32;
 
 /* try to detect the padding bug */
@@ -338,7 +338,7 @@ static int decode_slice(H263DecContext *const h)
 (h->c.workaround_bugs & FF_BUG_AUTODETECT) &&
 get_bits_left(&h->gb) >= 0 &&
 get_bits_left(&h->gb) < 137&&
-!h->c.data_partitioning) {
+!h->data_partitioning) {
 const int bits_count = get_bits_count(&h->gb);
 const int bits_left  = h->gb.size_in_bits - bits_count;
 
@@ -364,7 +364,7 @@ static int decode_slice(H263DecContext *const h)

[FFmpeg-devel] [PATCH 40/48] avcodec/h263dec: Use function ptr for decode_picture_header

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c   | 27 ++-
 libavcodec/h263dec.h   |  8 +++-
 libavcodec/mpeg4videodec.c |  3 ++-
 libavcodec/mpeg4videodec.h |  1 -
 libavcodec/msmpeg4dec.c|  8 +---
 libavcodec/msmpeg4dec.h|  1 -
 libavcodec/wmv2dec.c   |  3 ++-
 libavcodec/wmv2dec.h   |  1 -
 8 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 541eb34789..592a22df0d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -121,6 +121,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 case AV_CODEC_ID_H263:
 case AV_CODEC_ID_H263P:
 avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
+h->decode_header = ff_h263_decode_picture_header;
 break;
 case AV_CODEC_ID_MPEG4:
 break;
@@ -144,13 +145,20 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 s->h263_pred   = 1;
 s->msmpeg4_version = MSMP4_WMV2;
 break;
-case AV_CODEC_ID_H263I:
 case AV_CODEC_ID_RV10:
 case AV_CODEC_ID_RV20:
 break;
+#if CONFIG_H263I_DECODER
+case AV_CODEC_ID_H263I:
+h->decode_header = ff_intel_h263_decode_picture_header;
+break;
+#endif
+#if CONFIG_FLV_DECODER
 case AV_CODEC_ID_FLV1:
 s->h263_flv = 1;
+h->decode_header = ff_flv_decode_picture_header;
 break;
+#endif
 default:
 av_unreachable("Switch contains a case for every codec using 
ff_h263_decode_init()");
 }
@@ -461,22 +469,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 bak_height = h->c.height;
 
 /* let's go :-) */
-if (CONFIG_WMV2_DECODER && h->c.msmpeg4_version == MSMP4_WMV2) {
-ret = ff_wmv2_decode_picture_header(h);
-#if CONFIG_MSMPEG4DEC
-} else if (h->c.msmpeg4_version != MSMP4_UNUSED) {
-ret = ff_msmpeg4_decode_picture_header(h);
-#endif
-} else if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {
-ret = ff_mpeg4_decode_picture_header(h);
-} else if (CONFIG_H263I_DECODER && h->c.codec_id == AV_CODEC_ID_H263I) {
-ret = ff_intel_h263_decode_picture_header(h);
-} else if (CONFIG_FLV_DECODER && h->c.h263_flv) {
-ret = ff_flv_decode_picture_header(h);
-} else {
-ret = ff_h263_decode_picture_header(h);
-}
-
+ret = h->decode_header(h);
 if (ret < 0 || ret == FRAME_SKIPPED) {
 if (   h->c.width  != bak_width
 || h->c.height != bak_height) {
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index 0c6228f9d9..2b43dda568 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -25,11 +25,6 @@
 #include "vlc.h"
 #include "libavutil/mem_internal.h"
 
-/**
- * Return value for header parsers if frame is not coded.
- * */
-#define FRAME_SKIPPED 100
-
 // The defines below define the number of bits that are read at once for
 // reading vlc values. Changing these may improve speed and data cache needs
 // be aware though that decreasing them may need the number of stages that is
@@ -72,6 +67,9 @@ typedef struct H263DecContext {
 int rv10_version; ///< RV10 version: 0 or 3
 int rv10_first_dc_coded[3];
 
+int (*decode_header)(struct H263DecContext *const h);
+#define FRAME_SKIPPED 100 ///< Frame is not coded
+
 int (*decode_mb)(struct H263DecContext *h);
 #define SLICE_OK 0
 #define SLICE_ERROR -1
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index c53f5c103a..bc17b0ed09 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3736,7 +3736,7 @@ end:
 return decode_vop_header(ctx, gb, parse_only);
 }
 
-int ff_mpeg4_decode_picture_header(H263DecContext *const h)
+static int mpeg4_decode_picture_header(H263DecContext *const h)
 {
 Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
 
@@ -4017,6 +4017,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
 h->c.h263_pred = 1;
 h->c.low_delay = 0; /* default, might be overridden in the vol header 
during header parsing */
+h->decode_header = mpeg4_decode_picture_header;
 h->decode_mb   = mpeg4_decode_mb;
 ctx->time_increment_bits = 4; /* default value for broken headers */
 ctx->quant_precision = 5;
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index 337125d4e3..aafde454ea 100644
--- a/libavcodec/mpeg4videodec.h
+++ b/libavcodec/mpeg4videodec.h
@@ -109,7 +109,6 @@ typedef struct Mpeg4DecContext {
 int dct_precision;
 } Mpeg4DecContext;
 
-int ff_mpeg4_decode_picture_header(H263DecContext *const h);
 int ff_mpeg4_parse_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb,
   int header, int parse_only);
 void ff_mpeg4_decode_studio(MpegEncContext *s, uint8_t *dest_y, uint8_t 
*dest_cb,
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 59ceb7dac6..a96a0335f7 10064

[FFmpeg-devel] [PATCH 41/48] avcodec/ituh263enc: Inline value of h263_flv

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

It is always two when we encode FLV1.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/flvenc.c|  2 +-
 libavcodec/ituh263enc.c| 12 
 libavcodec/mpegvideo_enc.c |  1 -
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c
index 4143e7eecf..91e1f07365 100644
--- a/libavcodec/flvenc.c
+++ b/libavcodec/flvenc.c
@@ -33,7 +33,7 @@ int ff_flv_encode_picture_header(MPVMainEncContext *const m)
 
 put_bits(&s->pb, 17, 1);
 /* 0: H.263 escape codes 1: 11-bit escape codes */
-put_bits(&s->pb, 5, (s->c.h263_flv - 1));
+put_bits(&s->pb, 5, 1);
 put_bits(&s->pb, 8,
  (((int64_t) s->c.picture_number * 30 * s->c.avctx->time_base.num) 
/   // FIXME use timestamp
   s->c.avctx->time_base.den) & 0xff);   /* TemporalReference */
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 4ec851cab9..682d4bd24e 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -536,7 +536,7 @@ static void h263_encode_block(MPVEncContext *const s, 
int16_t block[], int n)
 code = get_rl_index(rl, last, run, level);
 put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
 if (code == rl->n) {
-if (!CONFIG_FLV_ENCODER || s->c.h263_flv <= 1) {
+if (!CONFIG_FLV_ENCODER || s->c.codec_id != AV_CODEC_ID_FLV1) {
 put_bits(&s->pb, 1, last);
 put_bits(&s->pb, 6, run);
 
@@ -861,13 +861,9 @@ av_cold void ff_h263_encode_init(MPVMainEncContext *const 
m)
 #if CONFIG_FLV_ENCODER
 case AV_CODEC_ID_FLV1:
 m->encode_picture_header = ff_flv_encode_picture_header;
-if (s->c.h263_flv > 1) {
-s->min_qcoeff= -1023;
-s->max_qcoeff=  1023;
-} else {
-s->min_qcoeff= -127;
-s->max_qcoeff=  127;
-}
+/* format = 1; 11-bit codes */
+s->min_qcoeff = -1023;
+s->max_qcoeff =  1023;
 break;
 #endif
 default: //nothing needed - default table already set in mpegvideo.c
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index a16cb6bd19..f54f458ab8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -936,7 +936,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
 break;
 case AV_CODEC_ID_FLV1:
 s->c.out_format  = FMT_H263;
-s->c.h263_flv= 2; /* format = 1; 11-bit codes */
 s->me.unrestricted_mv = 1;
 s->rtp_mode  = 0; /* don't allow GOB */
 avctx->delay = 0;
-- 
ffmpeg-codebot

___
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 42/48] avcodec/flvdec: Binarize h263_flv

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

It used to be a tri-state encoding both whether to use FLV picture
headers and whether to use the FLV way of encoding escape values,
but the former is now unnecessary due to the switch to a function
pointer for reading the header. So binarize h263_flv.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/flvdec.c | 4 ++--
 libavcodec/h263dec.c| 1 -
 libavcodec/ituh263dec.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index c70d79f483..881f63ed1a 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -40,7 +40,7 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 av_log(h->c.avctx, AV_LOG_ERROR, "Bad picture format\n");
 return AVERROR_INVALIDDATA;
 }
-h->c.h263_flv   = format + 1;
+h->c.h263_flv   = format;
 h->c.picture_number = get_bits(&h->gb, 8); /* picture timestamp */
 format= get_bits(&h->gb, 3);
 switch (format) {
@@ -101,7 +101,7 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
 av_log(h->c.avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
h->c.droppable ? 'D' : av_get_picture_type_char(h->c.pict_type),
-   h->c.h263_flv - 1, h->c.qscale, h->c.picture_number);
+   h->c.h263_flv, h->c.qscale, h->c.picture_number);
 }
 
 return 0;
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 592a22df0d..0bbc8e989e 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -155,7 +155,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 #endif
 #if CONFIG_FLV_DECODER
 case AV_CODEC_ID_FLV1:
-s->h263_flv = 1;
 h->decode_header = ff_flv_decode_picture_header;
 break;
 #endif
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 94cde850b5..0cd5d073ed 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -598,7 +598,7 @@ retry:
 return -1;
 }
 /* escape */
-if (CONFIG_FLV_DECODER && h->c.h263_flv > 1) {
+if (CONFIG_FLV_DECODER && h->c.h263_flv) {
 int is11 = SHOW_UBITS(re, &h->gb, 1);
 SKIP_CACHE(re, &h->gb, 1);
 run = SHOW_UBITS(re, &h->gb, 7) + 1;
-- 
ffmpeg-codebot

___
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 25/48] avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg4videodec.c | 25 ++---
 libavcodec/mpeg4videodec.h |  1 +
 libavcodec/mpegvideo.h |  1 -
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 91b1687884..677b372fee 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -787,12 +787,13 @@ int ff_mpeg4_decode_video_packet_header(MPVContext *const 
s)
 return 0;
 }
 
-static void reset_studio_dc_predictors(MpegEncContext *s)
+static void reset_studio_dc_predictors(Mpeg4DecContext *const ctx)
 {
+MPVContext *const s = &ctx->m;
 /* Reset DC Predictors */
 s->last_dc[0] =
 s->last_dc[1] =
-s->last_dc[2] = 1 << (s->avctx->bits_per_raw_sample + s->dct_precision + 
s->intra_dc_precision - 1);
+s->last_dc[2] = 1 << (s->avctx->bits_per_raw_sample + ctx->dct_precision + 
s->intra_dc_precision - 1);
 }
 
 /**
@@ -827,7 +828,7 @@ int ff_mpeg4_decode_studio_slice_header(MPVContext *const s)
 skip_bits(gb, 8); /* extra_information_slice */
 }
 
-reset_studio_dc_predictors(s);
+reset_studio_dc_predictors(ctx);
 }
 else {
 return AVERROR_INVALIDDATA;
@@ -2160,7 +2161,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, 
int32_t block[64], int n
 uint32_t flc;
 const int min = -1 *  (1 << (s->avctx->bits_per_raw_sample + 6));
 const int max =  ((1 << (s->avctx->bits_per_raw_sample + 6)) - 1);
-int shift =  3 - s->dct_precision;
+int shift =  3 - ctx->dct_precision;
 
 mismatch = 1;
 
@@ -2196,7 +2197,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, 
int32_t block[64], int n
 if (ctx->mpeg_quant)
 block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision);
 else
-block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision) * (8 >> 
s->dct_precision);
+block[0] = s->last_dc[cc] * (8 >> s->intra_dc_precision) * (8 >> 
ctx->dct_precision);
 /* TODO: support mpeg_quant for AC coefficients */
 
 block[0] = av_clip(block[0], min, max);
@@ -2246,7 +2247,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, 
int32_t block[64], int n
 if (idx > 63)
 return AVERROR_INVALIDDATA;
 j = scantable[idx++];
-additional_code_len = s->avctx->bits_per_raw_sample + 
s->dct_precision + 4;
+additional_code_len = s->avctx->bits_per_raw_sample + 
ctx->dct_precision + 4;
 flc = get_bits(&s->gb, additional_code_len);
 if (flc >> (additional_code_len-1))
 block[j] = -1 * (( flc ^ ((1 << additional_code_len) -1)) + 1);
@@ -2263,8 +2264,10 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, 
int32_t block[64], int n
 return 0;
 }
 
-static int mpeg4_decode_dpcm_macroblock(MpegEncContext *s, int16_t 
macroblock[256], int n)
+static int mpeg4_decode_dpcm_macroblock(Mpeg4DecContext *const ctx,
+int16_t macroblock[256], int n)
 {
+MPVContext *const s = &ctx->m;
 int i, j, w, h, idx = 0;
 int block_mean, rice_parameter, rice_prefix_code, rice_suffix_code,
 dpcm_residual, left, top, topleft, min_left_top, max_left_top, p, p2, 
output;
@@ -2276,7 +2279,7 @@ static int mpeg4_decode_dpcm_macroblock(MpegEncContext 
*s, int16_t macroblock[25
 av_log(s->avctx, AV_LOG_ERROR, "Forbidden block_mean\n");
 return AVERROR_INVALIDDATA;
 }
-s->last_dc[n] = block_mean * (1 << (s->dct_precision + 
s->intra_dc_precision));
+s->last_dc[n] = block_mean * (1 << (ctx->dct_precision + 
s->intra_dc_precision));
 
 rice_parameter = get_bits(&s->gb, 4);
 if (rice_parameter == 0) {
@@ -2373,7 +2376,7 @@ static int mpeg4_decode_studio_mb(MpegEncContext *s, 
int16_t block_[12][64])
 check_marker(s->avctx, &s->gb, "DPCM block start");
 ctx->dpcm_direction = get_bits1(&s->gb) ? -1 : 1;
 for (i = 0; i < 3; i++) {
-if (mpeg4_decode_dpcm_macroblock(s, ctx->dpcm_macroblock[i], i) < 
0)
+if (mpeg4_decode_dpcm_macroblock(ctx, ctx->dpcm_macroblock[i], i) 
< 0)
 return AVERROR_INVALIDDATA;
 }
 }
@@ -3521,13 +3524,13 @@ static int decode_studio_vop_header(Mpeg4DecContext 
*ctx, GetBitContext *gb)
 
 if (s->pict_type == AV_PICTURE_TYPE_I) {
 if (get_bits1(gb))
-reset_studio_dc_predictors(s);
+reset_studio_dc_predictors(ctx);
 }
 
 if (ctx->shape != BIN_ONLY_SHAPE) {
 s->alternate_scan = get_bits1(gb);
 s->frame_pred_frame_dct = get_bits1(gb);
-s->dct_precision = get_bits(gb, 2);
+ctx->dct_precision  = get_bits(gb, 2);
 s->intra_dc_precision = get_bits(gb, 2);
 s->q_scale_type = get_bits1(gb);
 }
diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h
index 32ad081df3..9598429d08 100644
---

[FFmpeg-devel] [PATCH 28/48] avcodec/h263dec: Don't use MpegEncContext.block

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Instead add the necessary blocks directly to H263DecContext
(only six are needed, not 12 as ff_mpv_common_init()
currently allocates).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c   |  4 ++--
 libavcodec/h263dec.h   |  3 +++
 libavcodec/ituh263dec.c|  8 
 libavcodec/mpeg4videodec.c | 14 +++---
 libavcodec/msmpeg4dec.c|  8 
 libavcodec/rv10.c  |  2 +-
 libavcodec/wmv2dec.c   | 10 +-
 7 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 5a5a91e675..161f13b1e1 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -272,7 +272,7 @@ static int decode_slice(H263DecContext *const h)
 if (ret < 0) {
 const int xy = h->c.mb_x + h->c.mb_y * h->c.mb_stride;
 if (ret == SLICE_END) {
-ff_mpv_reconstruct_mb(&h->c, h->c.block);
+ff_mpv_reconstruct_mb(&h->c, h->block);
 if (h->c.loop_filter)
 ff_h263_loop_filter(&h->c);
 
@@ -305,7 +305,7 @@ static int decode_slice(H263DecContext *const h)
 return AVERROR_INVALIDDATA;
 }
 
-ff_mpv_reconstruct_mb(&h->c, h->c.block);
+ff_mpv_reconstruct_mb(&h->c, h->block);
 if (h->c.loop_filter)
 ff_h263_loop_filter(&h->c);
 }
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index f414da16b1..dd5e37a719 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -22,6 +22,7 @@
 
 #include "mpegvideo.h"
 #include "vlc.h"
+#include "libavutil/mem_internal.h"
 
 /**
  * Return value for header parsers if frame is not coded.
@@ -47,6 +48,8 @@ typedef struct H263DecContext {
 MPVContext c;
 
 int (*decode_mb)(struct H263DecContext *h);
+
+DECLARE_ALIGNED_32(int16_t, block)[6][64];
 } H263DecContext;
 
 int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code);
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 25a0781024..0c8531dea9 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -808,7 +808,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
 }
 }while(cbpc == 20);
 
-h->c.bdsp.clear_blocks(h->c.block[0]);
+h->c.bdsp.clear_blocks(h->block[0]);
 
 dquant = cbpc & 8;
 h->c.mb_intra = ((cbpc & 4) != 0);
@@ -910,7 +910,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
 
 h->c.mb_intra = IS_INTRA(mb_type);
 if(HAS_CBP(mb_type)){
-h->c.bdsp.clear_blocks(h->c.block[0]);
+h->c.bdsp.clear_blocks(h->block[0]);
 cbpc = get_vlc2(&h->c.gb, cbpc_b_vlc, CBPC_B_VLC_BITS, 1);
 if (h->c.mb_intra) {
 dquant = IS_QUANT(mb_type);
@@ -1012,7 +1012,7 @@ int ff_h263_decode_mb(H263DecContext *const h)
 }
 }while(cbpc == 8);
 
-h->c.bdsp.clear_blocks(h->c.block[0]);
+h->c.bdsp.clear_blocks(h->block[0]);
 
 dquant = cbpc & 4;
 h->c.mb_intra = 1;
@@ -1051,7 +1051,7 @@ intra:
 
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (h263_decode_block(h, h->c.block[i], i, cbp&32) < 0)
+if (h263_decode_block(h, h->block[i], i, cbp&32) < 0)
 return -1;
 cbp+=cbp;
 }
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index b2f675b9bc..88ddacc87f 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1708,10 +1708,10 @@ static int mpeg4_decode_partitioned_mb(H263DecContext 
*const h)
 
 if (!IS_SKIP(mb_type)) {
 int i;
-h->c.bdsp.clear_blocks(h->c.block[0]);
+h->c.bdsp.clear_blocks(h->block[0]);
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32, 
h->c.mb_intra,
+if (mpeg4_decode_block(ctx, h->block[i], i, cbp & 32, 
h->c.mb_intra,
use_intra_dc_vlc, ctx->rvlc) < 0) {
 av_log(h->c.avctx, AV_LOG_ERROR,
"texture corrupted at %d %d %d\n",
@@ -1792,7 +1792,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
 h->c.mb_intra = ((cbpc & 4) != 0);
 if (h->c.mb_intra)
 goto intra;
-h->c.bdsp.clear_blocks(h->c.block[0]);
+h->c.bdsp.clear_blocks(h->block[0]);
 
 if (h->c.pict_type == AV_PICTURE_TYPE_S &&
 ctx->vol_sprite_usage == GMC_SPRITE && (cbpc & 16) == 0)
@@ -1936,7 +1936,7 @@ static int mpeg4_decode_mb(H263DecContext *const h)
 if (modb2) {
 cbp = 0;
 } else {
-h->c.bdsp.clear_blocks(h->c.block[0]);
+h->c.bdsp.clear_blocks(h->block[0]);
 cbp = get_bits(&h->c.gb, 6);
 }
 
@@ -2073,10 +2073,10 @@ intra:
 if (!h->c.progressive_sequenc

[FFmpeg-devel] [PATCH 27/48] avcodec/h263dec: Remove redundant block parameter from decode_mb

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

With the exception of mpeg4_decode_studio_mb(), all decode_mb
functions implicitly presumed that the block provided as
argument coincides with MpegEncContext.block (they zeroed the latter
and then used the former to decode the block); mpeg4_decode_studio_mb()
meanwhile did not use the provided block at all (it uses blocks of
int32_t). So remove said parameter.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c   |  2 +-
 libavcodec/h263dec.h   |  5 ++---
 libavcodec/ituh263dec.c|  8 
 libavcodec/mpeg4videodec.c | 12 ++--
 libavcodec/msmpeg4dec.c|  8 
 libavcodec/rv10.c  |  2 +-
 libavcodec/wmv2dec.c   |  6 +++---
 7 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 22bcf40681..5a5a91e675 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -256,7 +256,7 @@ static int decode_slice(H263DecContext *const h)
 get_bits_count(&h->c.gb), show_bits(&h->c.gb, 24));
 
 ff_tlog(NULL, "Decoding MB at %dx%d\n", h->c.mb_x, h->c.mb_y);
-ret = h->decode_mb(h, h->c.block);
+ret = h->decode_mb(h);
 
 if (h->c.h263_pred || h->c.h263_aic) {
 int mb_xy = h->c.mb_y * h->c.mb_stride + h->c.mb_x;
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index 0600e0bcb0..f414da16b1 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -46,7 +46,7 @@ extern VLCElem ff_h263_mv_vlc[];
 typedef struct H263DecContext {
 MPVContext c;
 
-int (*decode_mb)(struct H263DecContext *h, int16_t block[6][64]);
+int (*decode_mb)(struct H263DecContext *h);
 } H263DecContext;
 
 int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code);
@@ -64,8 +64,7 @@ int ff_h263_decode_mba(H263DecContext *const h);
 void ff_h263_show_pict_info(H263DecContext *const h, int h263_plus);
 
 int ff_intel_h263_decode_picture_header(H263DecContext *const h);
-int ff_h263_decode_mb(H263DecContext *const h,
-  int16_t block[6][64]);
+int ff_h263_decode_mb(H263DecContext *const h);
 
 int ff_h263_resync(H263DecContext *const h);
 
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index d37ebaeb0b..25a0781024 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -776,7 +776,7 @@ static int set_direct_mv(MpegEncContext *s)
 }
 }
 
-int ff_h263_decode_mb(H263DecContext *const h, int16_t block[6][64])
+int ff_h263_decode_mb(H263DecContext *const h)
 {
 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
 int16_t *mot_val;
@@ -947,7 +947,7 @@ int ff_h263_decode_mb(H263DecContext *const h, int16_t 
block[6][64])
 //FIXME UMV
 
 if (HAS_FORWARD_MV(mb_type)) {
-int16_t *mot_val= ff_h263_pred_motion(&h->c, 0, 0, &pred_x, 
&pred_y);
+int16_t *mot_val = ff_h263_pred_motion(&h->c, 0, 0, &pred_x, 
&pred_y);
 h->c.mv_dir = MV_DIR_FORWARD;
 
 if (h->c.umvplus)
@@ -974,7 +974,7 @@ int ff_h263_decode_mb(H263DecContext *const h, int16_t 
block[6][64])
 }
 
 if (HAS_BACKWARD_MV(mb_type)) {
-int16_t *mot_val= ff_h263_pred_motion(&h->c, 0, 1, &pred_x, 
&pred_y);
+int16_t *mot_val = ff_h263_pred_motion(&h->c, 0, 1, &pred_x, 
&pred_y);
 h->c.mv_dir |= MV_DIR_BACKWARD;
 
 if (h->c.umvplus)
@@ -1051,7 +1051,7 @@ intra:
 
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (h263_decode_block(h, block[i], i, cbp&32) < 0)
+if (h263_decode_block(h, h->c.block[i], i, cbp&32) < 0)
 return -1;
 cbp+=cbp;
 }
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index e3503b1aca..b2f675b9bc 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1651,7 +1651,7 @@ not_coded:
  * decode partition C of one MB.
  * @return <0 if an error occurred
  */
-static int mpeg4_decode_partitioned_mb(H263DecContext *const h, int16_t 
block[6][64])
+static int mpeg4_decode_partitioned_mb(H263DecContext *const h)
 {
 Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
 const int xy = h->c.mb_x + h->c.mb_y * h->c.mb_stride;
@@ -1711,7 +1711,7 @@ static int mpeg4_decode_partitioned_mb(H263DecContext 
*const h, int16_t block[6]
 h->c.bdsp.clear_blocks(h->c.block[0]);
 /* decode each block */
 for (i = 0; i < 6; i++) {
-if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, h->c.mb_intra,
+if (mpeg4_decode_block(ctx, h->c.block[i], i, cbp & 32, 
h->c.mb_intra,
use_intra_dc_vlc, ctx->rvlc) < 0) {
 av_log(h->c.avctx, AV_LOG_ERROR,
"texture corrupted at %d %d %d\n",
@@ -1738,7 +1738,7 @@ static int mpeg4_decode_partitioned_mb(H263DecContext 
*const h, int16_t block[6]
 }
 }
 
-static int mpeg4_decode_mb(H263Dec

[FFmpeg-devel] [PATCH 23/48] avcodec/mpeg4videodec: Avoid unnecessary indirections

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This basically reverts d4967c04e040b3b2f937cad88599af825147ec94.
Said commit was based on the false premise that it would
be an aliasing violation to upcast a pointer to structure
to a pointer to a bigger structure containing the original
structure as its first element, but this is just not true.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg4videodec.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 34f383bbbd..c61fd23c48 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1647,12 +1647,10 @@ not_coded:
  */
 static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
 {
-Mpeg4DecContext *ctx = s->avctx->priv_data;
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 int cbp, mb_type, use_intra_dc_vlc;
 const int xy = s->mb_x + s->mb_y * s->mb_stride;
 
-av_assert2(s == (void*)ctx);
-
 mb_type = s->cur_pic.mb_type[xy];
 cbp = s->cbp_table[xy];
 
@@ -1737,13 +1735,12 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext 
*s, int16_t block[6][64])
 
 static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
 {
-Mpeg4DecContext *ctx = s->avctx->priv_data;
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
 const int xy = s->mb_x + s->mb_y * s->mb_stride;
 int next;
 
-av_assert2(s ==  (void*)ctx);
 av_assert2(s->h263_pred);
 
 if (s->pict_type == AV_PICTURE_TYPE_P ||
@@ -2153,7 +2150,7 @@ static const uint8_t ac_state_tab[22][2] =
 
 static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int 
n)
 {
-Mpeg4DecContext *ctx = s->avctx->priv_data;
+Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s;
 
 int cc, dct_dc_size, dct_diff, code, j, idx = 1, group = 0, run = 0,
 additional_code_len, sign, mismatch;
-- 
ffmpeg-codebot

___
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 30/48] avcodec/mpeg12dec: Add Mpeg12SliceContext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

This is in preparation for removing the GetBitContext
from MPVContext.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 863 +
 libavcodec/mpegvideo.c |   2 +-
 libavcodec/mpegvideo.h |   1 +
 3 files changed, 436 insertions(+), 430 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 15bfab9623..1ef581ff99 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -70,8 +70,12 @@ enum Mpeg2ClosedCaptionsFormat {
 CC_FORMAT_DISH
 };
 
+typedef struct Mpeg12SliceContext {
+MPVContext c;
+} Mpeg12SliceContext;
+
 typedef struct Mpeg1Context {
-MpegEncContext mpeg_enc_ctx;
+Mpeg12SliceContext slice;
 AVPanScan pan_scan; /* some temporary storage for the panscan */
 enum AVStereo3DType stereo3d_type;
 int has_stereo3d;
@@ -95,22 +99,22 @@ typedef struct Mpeg1Context {
 } Mpeg1Context;
 
 /* as H.263, but only 17 codes */
-static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
+static int mpeg_decode_motion(Mpeg12SliceContext *const s, int fcode, int pred)
 {
 int code, sign, val, shift;
 
-code = get_vlc2(&s->gb, ff_mv_vlc, MV_VLC_BITS, 2);
+code = get_vlc2(&s->c.gb, ff_mv_vlc, MV_VLC_BITS, 2);
 if (code == 0)
 return pred;
 if (code < 0)
 return 0x;
 
-sign  = get_bits1(&s->gb);
+sign  = get_bits1(&s->c.gb);
 shift = fcode - 1;
 val   = code;
 if (shift) {
 val  = (val - 1) << shift;
-val |= get_bits(&s->gb, shift);
+val |= get_bits(&s->c.gb, shift);
 val++;
 }
 if (sign)
@@ -125,39 +129,39 @@ static int mpeg_decode_motion(MpegEncContext *s, int 
fcode, int pred)
 #define check_scantable_index(ctx, x) \
 do {  \
 if ((x) > MAX_INDEX) {\
-av_log(ctx->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", \
-   ctx->mb_x, ctx->mb_y); \
+av_log(ctx->c.avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n",   \
+   ctx->c.mb_x, ctx->c.mb_y); \
 return AVERROR_INVALIDDATA;   \
 } \
 } while (0)
 
-static inline int mpeg1_decode_block_inter(MpegEncContext *s,
+static inline int mpeg1_decode_block_inter(Mpeg12SliceContext *const s,
int16_t *block, int n)
 {
 int level, i, j, run;
-const uint8_t *const scantable = s->intra_scantable.permutated;
-const uint16_t *quant_matrix = s->inter_matrix;
-const int qscale = s->qscale;
+const uint8_t *const scantable = s->c.intra_scantable.permutated;
+const uint16_t *quant_matrix = s->c.inter_matrix;
+const int qscale = s->c.qscale;
 
 {
-OPEN_READER(re, &s->gb);
+OPEN_READER(re, &s->c.gb);
 i = -1;
 // special case for first coefficient, no need to add second VLC table
-UPDATE_CACHE(re, &s->gb);
-if (((int32_t) GET_CACHE(re, &s->gb)) < 0) {
+UPDATE_CACHE(re, &s->c.gb);
+if (((int32_t) GET_CACHE(re, &s->c.gb)) < 0) {
 level = (3 * qscale * quant_matrix[0]) >> 5;
 level = (level - 1) | 1;
-if (GET_CACHE(re, &s->gb) & 0x4000)
+if (GET_CACHE(re, &s->c.gb) & 0x4000)
 level = -level;
 block[0] = level;
 i++;
-SKIP_BITS(re, &s->gb, 2);
-if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFF)
+SKIP_BITS(re, &s->c.gb, 2);
+if (((int32_t) GET_CACHE(re, &s->c.gb)) <= (int32_t) 0xBFFF)
 goto end;
 }
 /* now quantify & encode AC coefficients */
 for (;;) {
-GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc,
+GET_RL_VLC(level, run, re, &s->c.gb, ff_mpeg1_rl_vlc,
TEX_VLC_BITS, 2, 0);
 
 if (level != 0) {
@@ -167,22 +171,22 @@ static inline int mpeg1_decode_block_inter(MpegEncContext 
*s,
 j = scantable[i];
 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
 level = (level - 1) | 1;
-level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
-SHOW_SBITS(re, &s->gb, 1);
-SKIP_BITS(re, &s->gb, 1);
+level = (level ^ SHOW_SBITS(re, &s->c.gb, 1)) -
+SHOW_SBITS(re, &s->c.gb, 1);
+SKIP_BITS(re, &s->c.gb, 1);
 } else {
 /* escape */
-run = SHOW_UBITS(re, &s->gb, 6) + 1;
-LAST_SKIP_BITS(re, &s->gb, 6);
-

[FFmpeg-devel] [PATCH 32/48] avcodec/mpeg12dec: Move MpegEncContext.gb to Mpeg12SliceContext

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

It was its last user.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 207 +
 libavcodec/mpegvideo.h |   4 -
 2 files changed, 104 insertions(+), 107 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 1ef581ff99..8ca26c0d37 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -72,6 +72,7 @@ enum Mpeg2ClosedCaptionsFormat {
 
 typedef struct Mpeg12SliceContext {
 MPVContext c;
+GetBitContext gb;
 } Mpeg12SliceContext;
 
 typedef struct Mpeg1Context {
@@ -103,18 +104,18 @@ static int mpeg_decode_motion(Mpeg12SliceContext *const 
s, int fcode, int pred)
 {
 int code, sign, val, shift;
 
-code = get_vlc2(&s->c.gb, ff_mv_vlc, MV_VLC_BITS, 2);
+code = get_vlc2(&s->gb, ff_mv_vlc, MV_VLC_BITS, 2);
 if (code == 0)
 return pred;
 if (code < 0)
 return 0x;
 
-sign  = get_bits1(&s->c.gb);
+sign  = get_bits1(&s->gb);
 shift = fcode - 1;
 val   = code;
 if (shift) {
 val  = (val - 1) << shift;
-val |= get_bits(&s->c.gb, shift);
+val |= get_bits(&s->gb, shift);
 val++;
 }
 if (sign)
@@ -144,24 +145,24 @@ static inline int 
mpeg1_decode_block_inter(Mpeg12SliceContext *const s,
 const int qscale = s->c.qscale;
 
 {
-OPEN_READER(re, &s->c.gb);
+OPEN_READER(re, &s->gb);
 i = -1;
 // special case for first coefficient, no need to add second VLC table
-UPDATE_CACHE(re, &s->c.gb);
-if (((int32_t) GET_CACHE(re, &s->c.gb)) < 0) {
+UPDATE_CACHE(re, &s->gb);
+if (((int32_t) GET_CACHE(re, &s->gb)) < 0) {
 level = (3 * qscale * quant_matrix[0]) >> 5;
 level = (level - 1) | 1;
-if (GET_CACHE(re, &s->c.gb) & 0x4000)
+if (GET_CACHE(re, &s->gb) & 0x4000)
 level = -level;
 block[0] = level;
 i++;
-SKIP_BITS(re, &s->c.gb, 2);
-if (((int32_t) GET_CACHE(re, &s->c.gb)) <= (int32_t) 0xBFFF)
+SKIP_BITS(re, &s->gb, 2);
+if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFF)
 goto end;
 }
 /* now quantify & encode AC coefficients */
 for (;;) {
-GET_RL_VLC(level, run, re, &s->c.gb, ff_mpeg1_rl_vlc,
+GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc,
TEX_VLC_BITS, 2, 0);
 
 if (level != 0) {
@@ -171,22 +172,22 @@ static inline int 
mpeg1_decode_block_inter(Mpeg12SliceContext *const s,
 j = scantable[i];
 level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
 level = (level - 1) | 1;
-level = (level ^ SHOW_SBITS(re, &s->c.gb, 1)) -
-SHOW_SBITS(re, &s->c.gb, 1);
-SKIP_BITS(re, &s->c.gb, 1);
+level = (level ^ SHOW_SBITS(re, &s->gb, 1)) -
+SHOW_SBITS(re, &s->gb, 1);
+SKIP_BITS(re, &s->gb, 1);
 } else {
 /* escape */
-run = SHOW_UBITS(re, &s->c.gb, 6) + 1;
-LAST_SKIP_BITS(re, &s->c.gb, 6);
-UPDATE_CACHE(re, &s->c.gb);
-level = SHOW_SBITS(re, &s->c.gb, 8);
-SKIP_BITS(re, &s->c.gb, 8);
+run = SHOW_UBITS(re, &s->gb, 6) + 1;
+LAST_SKIP_BITS(re, &s->gb, 6);
+UPDATE_CACHE(re, &s->gb);
+level = SHOW_SBITS(re, &s->gb, 8);
+SKIP_BITS(re, &s->gb, 8);
 if (level == -128) {
-level = SHOW_UBITS(re, &s->c.gb, 8) - 256;
-SKIP_BITS(re, &s->c.gb, 8);
+level = SHOW_UBITS(re, &s->gb, 8) - 256;
+SKIP_BITS(re, &s->gb, 8);
 } else if (level == 0) {
-level = SHOW_UBITS(re, &s->c.gb, 8);
-SKIP_BITS(re, &s->c.gb, 8);
+level = SHOW_UBITS(re, &s->gb, 8);
+SKIP_BITS(re, &s->gb, 8);
 }
 i += run;
 if (i > MAX_INDEX)
@@ -204,13 +205,13 @@ static inline int 
mpeg1_decode_block_inter(Mpeg12SliceContext *const s,
 }
 
 block[j] = level;
-if (((int32_t) GET_CACHE(re, &s->c.gb)) <= (int32_t) 0xBFFF)
+if (((int32_t) GET_CACHE(re, &s->gb)) <= (int32_t) 0xBFFF)
 break;
-UPDATE_CACHE(re, &s->c.gb);
+UPDATE_CACHE(re, &s->gb);
 }
 end:
-LAST_SKIP_BITS(re, &s->c.gb, 2);
-CLOSE_READER(re, &s->c.gb);
+LAST_SKIP_BITS(re, &s->gb, 2);
+CLOSE_READER(re, &s->gb);
 }
 
 check_scantable_index(s, i);
@@ -231,7 +232,7 @@ static inline int 
mpeg2_decode_block_non_intra(Mpeg12SliceContext *const s,
 mismatch = 1;

[FFmpeg-devel] [PATCH 34/48] avcodec/mpegvideo: Move fields only used by H.263 decoders to H263DecCtx

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/flvdec.c|  4 ++--
 libavcodec/h263dec.c   | 28 +-
 libavcodec/h263dec.h   | 20 +++
 libavcodec/intelh263dec.c  |  8 
 libavcodec/ituh263dec.c| 40 +++---
 libavcodec/mpeg4videodec.c | 36 ++
 libavcodec/mpegvideo.h | 15 --
 libavcodec/mpegvideo_dec.c |  1 -
 libavcodec/nvdec_mpeg4.c   |  2 +-
 libavcodec/rv10.c  | 12 ++--
 10 files changed, 86 insertions(+), 80 deletions(-)

diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index f2d0b642b7..c70d79f483 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -89,13 +89,13 @@ int ff_flv_decode_picture_header(H263DecContext *const h)
 skip_bits1(&h->gb); /* deblocking flag */
 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
 
-h->c.h263_long_vectors = 0;
+h->h263_long_vectors = 0;
 
 /* PEI */
 if (skip_1stop_8data_bits(&h->gb) < 0)
 return AVERROR_INVALIDDATA;
 
-if (h->c.ehc_mode)
+if (h->ehc_mode)
 h->c.avctx->sample_aspect_ratio= (AVRational){1,2};
 
 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index fc63e8a5d8..541eb34789 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -157,7 +157,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 
 if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == 
AV_RL32("S263"))
 if (avctx->extradata_size == 56 && avctx->extradata[0] == 1)
-s->ehc_mode = 1;
+h->ehc_mode = 1;
 
 /* for H.263, we allocate the images after having read the header */
 if (avctx->codec->id != AV_CODEC_ID_H263 &&
@@ -279,7 +279,7 @@ static int decode_slice(H263DecContext *const h)
 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, 
h->c.resync_mb_y,
 h->c.mb_x, h->c.mb_y, ER_MB_END & 
part_mask);
 
-h->c.padding_bug_score--;
+h->padding_bug_score--;
 
 if (++h->c.mb_x >= h->c.mb_width) {
 h->c.mb_x = 0;
@@ -324,7 +324,7 @@ static int decode_slice(H263DecContext *const h)
 get_bits_left(&h->gb) >= 48&&
 show_bits(&h->gb, 24) == 0x4010&&
 !h->c.data_partitioning)
-h->c.padding_bug_score += 32;
+h->padding_bug_score += 32;
 
 /* try to detect the padding bug */
 if (h->c.codec_id == AV_CODEC_ID_MPEG4 &&
@@ -336,18 +336,18 @@ static int decode_slice(H263DecContext *const h)
 const int bits_left  = h->gb.size_in_bits - bits_count;
 
 if (bits_left == 0) {
-h->c.padding_bug_score += 16;
+h->padding_bug_score += 16;
 } else if (bits_left != 1) {
 int v = show_bits(&h->gb, 8);
 v |= 0x7F >> (7 - (bits_count & 7));
 
 if (v == 0x7F && bits_left <= 8)
-h->c.padding_bug_score--;
+h->padding_bug_score--;
 else if (v == 0x7F && ((get_bits_count(&h->gb) + 8) & 8) &&
  bits_left <= 16)
-h->c.padding_bug_score += 4;
+h->padding_bug_score += 4;
 else
-h->c.padding_bug_score++;
+h->padding_bug_score++;
 }
 }
 
@@ -359,7 +359,7 @@ static int decode_slice(H263DecContext *const h)
 show_bits(&h->gb, 8) == 0  &&
 !h->c.data_partitioning) {
 
-h->c.padding_bug_score += 32;
+h->padding_bug_score += 32;
 }
 
 if (h->c.codec_id == AV_CODEC_ID_H263  &&
@@ -367,12 +367,12 @@ static int decode_slice(H263DecContext *const h)
 get_bits_left(&h->gb) >= 64&&
 AV_RB64(h->gb.buffer_end - 8) == 0xCDCDCDCDFC7F) {
 
-h->c.padding_bug_score += 32;
+h->padding_bug_score += 32;
 }
 
 if (h->c.workaround_bugs & FF_BUG_AUTODETECT) {
 if (
-(h->c.padding_bug_score > -2 && !h->c.data_partitioning))
+(h->padding_bug_score > -2 && !h->c.data_partitioning))
 h->c.workaround_bugs |= FF_BUG_NO_PADDING;
 else
 h->c.workaround_bugs &= ~FF_BUG_NO_PADDING;
@@ -410,7 +410,7 @@ static int decode_slice(H263DecContext *const h)
 
 av_log(h->c.avctx, AV_LOG_ERROR,
"slice end not reached but screenspace end (%d left %06X, score= 
%d)\n",
-   get_bits_left(&h->gb), show_bits(&h->gb, 24), 
h->c.padding_bug_score);
+   get_bits_left(&h->gb), show_bits(&h->gb, 24), h->padding_bug_score);
 
 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, h->c.mb_x, 
h->c.mb_y,
 ER_MB_END & part_mask);
@@ -432,10 +432,10 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 /* 

[FFmpeg-devel] [PATCH 31/48] avcodec/mpegvideo: Add missing headers

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

These files currently rely on implicit inclusions of avassert.h
and/or mathops.h via get_bits.h.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/error_resilience.c  | 2 ++
 libavcodec/me_cmp.c| 1 +
 libavcodec/mips/mpegvideo_msa.c| 1 +
 libavcodec/mpeg4videoenc.c | 1 +
 libavcodec/mpegvideo.c | 1 +
 libavcodec/msmpeg4.c   | 1 +
 libavcodec/ppc/mpegvideo_altivec.c | 1 +
 libavcodec/speedhqenc.c| 1 +
 libavcodec/x86/mpegvideo.c | 2 +-
 libavcodec/x86/mpegvideoenc.c  | 1 -
 libavcodec/x86/mpegvideoenc_template.c | 1 +
 11 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 6edc2dc15f..cf6f83e096 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -27,9 +27,11 @@
 
 #include 
 
+#include "libavutil/avassert.h"
 #include "libavutil/mem.h"
 #include "avcodec.h"
 #include "error_resilience.h"
+#include "mathops.h"
 #include "me_cmp.h"
 #include "mpegutils.h"
 #include "mpegvideo.h"
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 419b8d30c9..8e53f6d573 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -27,6 +27,7 @@
 #include "libavutil/mem_internal.h"
 #include "avcodec.h"
 #include "copy_block.h"
+#include "mathops.h"
 #include "simple_idct.h"
 #include "me_cmp.h"
 #include "mpegvideoenc.h"
diff --git a/libavcodec/mips/mpegvideo_msa.c b/libavcodec/mips/mpegvideo_msa.c
index aa9ef770eb..cd4adc0f77 100644
--- a/libavcodec/mips/mpegvideo_msa.c
+++ b/libavcodec/mips/mpegvideo_msa.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/mips/generic_macros_msa.h"
 #include "h263dsp_mips.h"
 
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 1aa35aa70a..540ab8e4c3 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -29,6 +29,7 @@
 #include "mpegvideo.h"
 #include "h263.h"
 #include "h263enc.h"
+#include "mathops.h"
 #include "mpeg4video.h"
 #include "mpeg4videodata.h"
 #include "mpeg4videodefs.h"
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ae294e9dd8..7ef0dacc80 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -31,6 +31,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 
 #include "avcodec.h"
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 740dbdcba8..3073ca6193 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -36,6 +36,7 @@
 
 #include "avcodec.h"
 #include "idctdsp.h"
+#include "mathops.h"
 #include "mpegvideo.h"
 #include "msmpeg4.h"
 #include "mpeg4videodata.h"
diff --git a/libavcodec/ppc/mpegvideo_altivec.c 
b/libavcodec/ppc/mpegvideo_altivec.c
index 8cc213efe4..26e98acfb8 100644
--- a/libavcodec/ppc/mpegvideo_altivec.c
+++ b/libavcodec/ppc/mpegvideo_altivec.c
@@ -27,6 +27,7 @@
 #include "config.h"
 
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "libavutil/cpu.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/ppc/cpu.h"
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 23ab86e8e2..da7aba6ec9 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "mathops.h"
 #include "mpeg12data.h"
 #include "mpeg12vlc.h"
 #include "mpegvideo.h"
diff --git a/libavcodec/x86/mpegvideo.c b/libavcodec/x86/mpegvideo.c
index 24f1e14007..8632acd412 100644
--- a/libavcodec/x86/mpegvideo.c
+++ b/libavcodec/x86/mpegvideo.c
@@ -20,10 +20,10 @@
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
 #include "libavutil/cpu.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
-#include "libavcodec/avcodec.h"
 #include "libavcodec/mpegvideo.h"
 #include "libavcodec/mpegvideodata.h"
 #include "libavcodec/mpegvideo_unquantize.h"
diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c
index d81a8ef14d..eac9947590 100644
--- a/libavcodec/x86/mpegvideoenc.c
+++ b/libavcodec/x86/mpegvideoenc.c
@@ -25,7 +25,6 @@
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/avcodec.h"
-#include "libavcodec/dct.h"
 #include "libavcodec/mpegvideoenc.h"
 
 /* not permutated inverse zigzag_direct + 1 for MMX quantizer */
diff --git a/libavcodec/x86/mpegvideoenc_template.c 
b/libavcodec/x86/mpegvideoenc_template.c
index dbb2187121..f0b95c1621 100644
--- a/libavcodec/x86/mpegvideoenc_template.c
+++ b/libavcodec/x86/mpegvideoenc_template.c
@@ -25,6 +25,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
 #include "libavutil/x86/asm.h"
+#include "libavcodec/mathops.h"
 #include "libavcodec/mp

[FFmpeg-devel] [PATCH 33/48] avcodec/mpeg12dec: Don't use MPVContext.block

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Instead add the necessary blocks directly into Mpeg12SliceContext.
This allows to completely remove MPVContext.block.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg12dec.c | 40 --
 libavcodec/mpeg4videodec.c |  1 -
 libavcodec/mpegvideo.c | 23 ++
 libavcodec/mpegvideo.h |  2 --
 4 files changed, 23 insertions(+), 43 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 8ca26c0d37..db6f9d66a5 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -73,6 +73,8 @@ enum Mpeg2ClosedCaptionsFormat {
 typedef struct Mpeg12SliceContext {
 MPVContext c;
 GetBitContext gb;
+
+DECLARE_ALIGNED_32(int16_t, block)[12][64];
 } Mpeg12SliceContext;
 
 typedef struct Mpeg1Context {
@@ -472,10 +474,10 @@ static int mpeg_decode_mb(Mpeg12SliceContext *const s)
 ff_tlog(s->c.avctx, "mb_type=%x\n", mb_type);
 //motion_type = 0; /* avoid warning */
 if (IS_INTRA(mb_type)) {
-s->c.bdsp.clear_blocks(s->c.block[0]);
+s->c.bdsp.clear_blocks(s->block[0]);
 
 if (!s->c.chroma_y_shift)
-s->c.bdsp.clear_blocks(s->c.block[6]);
+s->c.bdsp.clear_blocks(s->block[6]);
 
 /* compute DCT type */
 // FIXME: add an interlaced_dct coded var?
@@ -509,14 +511,14 @@ static int mpeg_decode_mb(Mpeg12SliceContext *const s)
 
 if (s->c.codec_id == AV_CODEC_ID_MPEG2VIDEO) {
 for (i = 0; i < mb_block_count; i++)
-if ((ret = mpeg2_decode_block_intra(s, s->c.block[i], i)) < 0)
+if ((ret = mpeg2_decode_block_intra(s, s->block[i], i)) < 0)
 return ret;
 } else {
 for (i = 0; i < 6; i++) {
 ret = ff_mpeg1_decode_block_intra(&s->gb,
   s->c.intra_matrix,
   
s->c.intra_scantable.permutated,
-  s->c.last_dc, s->c.block[i],
+  s->c.last_dc, s->block[i],
   i, s->c.qscale);
 if (ret < 0) {
 av_log(s->c.avctx, AV_LOG_ERROR, "ac-tex damaged at %d 
%d\n",
@@ -714,13 +716,13 @@ static int mpeg_decode_mb(Mpeg12SliceContext *const s)
 s->c.mb_intra = 0;
 s->c.last_dc[0] = s->c.last_dc[1] = s->c.last_dc[2] = 128 << 
s->c.intra_dc_precision;
 if (HAS_CBP(mb_type)) {
-s->c.bdsp.clear_blocks(s->c.block[0]);
+s->c.bdsp.clear_blocks(s->block[0]);
 
 cbp = get_vlc2(&s->gb, ff_mb_pat_vlc, MB_PAT_VLC_BITS, 1);
 if (mb_block_count > 6) {
 cbp *= 1 << mb_block_count - 6;
 cbp |= get_bits(&s->gb, mb_block_count - 6);
-s->c.bdsp.clear_blocks(s->c.block[6]);
+s->c.bdsp.clear_blocks(s->block[6]);
 }
 if (cbp <= 0) {
 av_log(s->c.avctx, AV_LOG_ERROR,
@@ -733,7 +735,7 @@ static int mpeg_decode_mb(Mpeg12SliceContext *const s)
 
 for (i = 0; i < mb_block_count; i++) {
 if (cbp & (1 << 11)) {
-if ((ret = mpeg2_decode_block_non_intra(s, 
s->c.block[i], i)) < 0)
+if ((ret = mpeg2_decode_block_non_intra(s, 
s->block[i], i)) < 0)
 return ret;
 } else {
 s->c.block_last_index[i] = -1;
@@ -743,7 +745,7 @@ static int mpeg_decode_mb(Mpeg12SliceContext *const s)
 } else {
 for (i = 0; i < 6; i++) {
 if (cbp & 32) {
-if ((ret = mpeg1_decode_block_inter(s, s->c.block[i], 
i)) < 0)
+if ((ret = mpeg1_decode_block_inter(s, s->block[i], 
i)) < 0)
 return ret;
 } else {
 s->c.block_last_index[i] = -1;
@@ -1498,7 +1500,7 @@ static int mpeg_decode_slice(Mpeg12SliceContext *const s, 
int mb_y,
 s->c.dest[1] +=(16 >> lowres) >> s->c.chroma_x_shift;
 s->c.dest[2] +=(16 >> lowres) >> s->c.chroma_x_shift;
 
-ff_mpv_reconstruct_mb(&s->c, s->c.block);
+ff_mpv_reconstruct_mb(&s->c, s->block);
 
 if (++s->c.mb_x >= s->c.mb_width) {
 const int mb_size = 16 >> s->c.avctx->lowres;
@@ -2755,7 +2757,6 @@ typedef struct IPUContext {
 Mpeg12SliceContext m;
 
 int flags;
-DECLARE_ALIGNED(32, int16_t, block)[6][64];
 } IPUContext;
 
 static int ipu_decode_frame(AVCodecContext *avctx, AVFrame *frame,
@@ -2764,6 +2765,7 @@ static int ipu_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 IPUContext *s = avctx->priv_data;
 MPVContext *const m = &s->m.c;
 GetBitContext *const gb = &s->m.gb;
+int16_t (*const block)[64] = s->m.block;
 int ret;
 
 /

[FFmpeg-devel] [PATCH 46/48] avcodec/mpegvideo: Move loop_filter to {H263Dec, MPVEnc, VC1}Context

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dxva2_vc1.c |  4 ++--
 libavcodec/h261enc.c   |  4 ++--
 libavcodec/h263dec.c   |  4 ++--
 libavcodec/h263dec.h   |  1 +
 libavcodec/intelh263dec.c  |  2 +-
 libavcodec/ituh263dec.c|  8 
 libavcodec/ituh263enc.c|  2 +-
 libavcodec/mpegvideo.h |  1 -
 libavcodec/mpegvideo_enc.c | 10 +-
 libavcodec/mpegvideoenc.h  |  1 +
 libavcodec/mss2.c  |  2 +-
 libavcodec/nvdec_vc1.c |  2 +-
 libavcodec/rv10.c  |  6 +++---
 libavcodec/rv20enc.c   |  2 +-
 libavcodec/vaapi_vc1.c |  2 +-
 libavcodec/vc1.c   | 16 
 libavcodec/vc1.h   |  1 +
 libavcodec/vc1_block.c | 14 +++---
 libavcodec/vdpau_vc1.c |  2 +-
 libavcodec/wmv2dec.c   |  6 +++---
 libavcodec/wmv2enc.c   |  2 +-
 21 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 3400480f1f..f1dcea1e84 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -108,7 +108,7 @@ void ff_dxva2_vc1_fill_picture_parameters(AVCodecContext 
*avctx,
 pp->bRcontrol   = v->rnd;
 pp->bPicSpatialResid8   = (v->panscanflag  << 7) |
   (v->refdist_flag << 6) |
-  (s->loop_filter  << 5) |
+  (v->loop_filter  << 5) |
   (v->fastuvmc << 4) |
   (v->extended_mv  << 3) |
   (v->dquant   << 1) |
@@ -121,7 +121,7 @@ void ff_dxva2_vc1_fill_picture_parameters(AVCodecContext 
*avctx,
 pp->bPicExtrapolation   = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 
: 2;
 pp->bPicDeblocked   = ((!pp->bPicBackwardPrediction && v->overlap) 
   << 6) |
   ((v->profile != PROFILE_ADVANCED && 
v->rangeredfrm) << 5) |
-  (s->loop_filter  
   << 1);
+  (v->loop_filter  
   << 1);
 pp->bPicDeblockConfined = (v->postprocflag << 7) |
   (v->broadcast<< 6) |
   (v->interlace<< 5) |
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 89a6a69755..c75e029d68 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -266,9 +266,9 @@ static void h261_encode_mb(MPVEncContext *const s, int16_t 
block[6][64],
 if (!s->c.mb_intra) {
 com->mtype++;
 
-if (mvd || s->c.loop_filter)
+if (mvd || s->loop_filter)
 com->mtype += 3;
-if (s->c.loop_filter)
+if (s->loop_filter)
 com->mtype += 3;
 if (cbp)
 com->mtype++;
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 7cd8be850b..204476dfd6 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -280,7 +280,7 @@ static int decode_slice(H263DecContext *const h)
 const int xy = h->c.mb_x + h->c.mb_y * h->c.mb_stride;
 if (ret == SLICE_END) {
 ff_mpv_reconstruct_mb(&h->c, h->block);
-if (h->c.loop_filter)
+if (h->loop_filter)
 ff_h263_loop_filter(&h->c);
 
 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, 
h->c.resync_mb_y,
@@ -313,7 +313,7 @@ static int decode_slice(H263DecContext *const h)
 }
 
 ff_mpv_reconstruct_mb(&h->c, h->block);
-if (h->c.loop_filter)
+if (h->loop_filter)
 ff_h263_loop_filter(&h->c);
 }
 
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index c2cca57dea..ace210b036 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -66,6 +66,7 @@ typedef struct H263DecContext {
 int umvplus;///< == H.263+ && unrestricted_mv
 int h263_slice_structured;
 int alt_inter_vlc;  ///< alternative inter vlc
+int loop_filter;
 int modified_quant;
 
 /* MPEG-4 specific */
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index 73d56f4195..27a3cadbad 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -82,7 +82,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const 
h)
 }
 if (get_bits(&h->gb, 2))
 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
-h->c.loop_filter = get_bits1(&h->gb) * !h->c.avctx->lowres;
+h->loop_filter = get_bits1(&h->gb) * !h->c.avctx->lowres;
 if (get_bits1(&h->gb))
 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 if (get_bits1(&h->gb))
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index b99100590c..7a78b95c50 100644

[FFmpeg-devel] [PATCH 45/48] avcodec/mpegvideo: Move partitioned_frame to {H263Dec, MPVEnc}Context

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c   | 16 
 libavcodec/h263dec.h   |  1 +
 libavcodec/mpeg4videodec.c | 10 +-
 libavcodec/mpeg4videoenc.c |  2 +-
 libavcodec/mpegvideo.h |  1 -
 libavcodec/mpegvideo_enc.c | 10 +-
 libavcodec/mpegvideoenc.h  |  1 +
 7 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index aee52dd2b2..7cd8be850b 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -181,15 +181,15 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
 return 0;
 }
 
-static void report_decode_progress(MpegEncContext *s)
+static void report_decode_progress(H263DecContext *const h)
 {
-if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && 
!s->er.error_occurred)
-ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y);
+if (h->c.pict_type != AV_PICTURE_TYPE_B && !h->partitioned_frame && 
!h->c.er.error_occurred)
+ff_thread_progress_report(&h->c.cur_pic.ptr->progress, h->c.mb_y);
 }
 
 static int decode_slice(H263DecContext *const h)
 {
-const int part_mask = h->c.partitioned_frame
+const int part_mask = h->partitioned_frame
   ? (ER_AC_END | ER_AC_ERROR) : 0x7F;
 const int mb_size   = 16 >> h->c.avctx->lowres;
 int ret;
@@ -214,7 +214,7 @@ static int decode_slice(H263DecContext *const h)
 return ret;
 }
 
-if (h->c.partitioned_frame) {
+if (h->partitioned_frame) {
 const int qscale = h->c.qscale;
 
 if (CONFIG_MPEG4_DECODER && h->c.codec_id == AV_CODEC_ID_MPEG4)
@@ -290,7 +290,7 @@ static int decode_slice(H263DecContext *const h)
 
 if (++h->c.mb_x >= h->c.mb_width) {
 h->c.mb_x = 0;
-report_decode_progress(&h->c);
+report_decode_progress(h);
 ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, 
mb_size);
 h->c.mb_y++;
 }
@@ -317,7 +317,7 @@ static int decode_slice(H263DecContext *const h)
 ff_h263_loop_filter(&h->c);
 }
 
-report_decode_progress(&h->c);
+report_decode_progress(h);
 ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
 
 h->c.mb_x = 0;
@@ -553,7 +553,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 return ret;
 }
 
-ff_mpv_er_frame_start_ext(s, s->partitioned_frame,
+ff_mpv_er_frame_start_ext(s, h->partitioned_frame,
   s->pp_time, s->pb_time);
 
 /* the second part of the wmv2 header contains the MB skip bits which
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index a7b5e54ae7..c2cca57dea 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -73,6 +73,7 @@ typedef struct H263DecContext {
 int skipped_last_frame;
 int divx_packed;///< divx specific, used to workaround (many) 
bugs in divx5
 int data_partitioning;  ///< data partitioning flag from header
+int partitioned_frame;  ///< is current frame partitioned
 
 /* MSMPEG4 specific */
 int slice_height;   ///< in macroblocks
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index aaf2ecf7c4..df6cfff04b 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -391,7 +391,7 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx)
 
 while (v <= 0xFF) {
 if (h->c.pict_type == AV_PICTURE_TYPE_B ||
-(v >> (8 - h->c.pict_type) != 1) || h->c.partitioned_frame)
+(v >> (8 - h->c.pict_type) != 1) || h->partitioned_frame)
 break;
 skip_bits(&h->gb, 8 + h->c.pict_type);
 bits_count += 8 + h->c.pict_type;
@@ -1395,7 +1395,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext 
*ctx, int16_t *block,
 // FIXME add short header support
 if (use_intra_dc_vlc) {
 /* DC coef */
-if (h->c.partitioned_frame) {
+if (h->partitioned_frame) {
 level = h->c.dc_val[h->c.block_index[n]];
 if (n < 4)
 level = FASTDIV((level + (h->c.y_dc_scale >> 1)), 
h->c.y_dc_scale);
@@ -3222,8 +3222,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb,
 h->c.low_delay = 0;
 }
 
-h->c.partitioned_frame = h->data_partitioning && h->c.pict_type != 
AV_PICTURE_TYPE_B;
-if (h->c.partitioned_frame)
+h->partitioned_frame = h->data_partitioning && h->c.pict_type != 
AV_PICTURE_TYPE_B;
+if (h->partitioned_frame)
 h->decode_mb = mpeg4_decode_partitioned_mb;
 else
 h->decode_mb = mpeg4_decode_mb;
@@ -3513,7 +3513,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, 
GetBitContext *gb)
 if (get_bits_left(gb) <= 32)
 return 0;
 
-h->c.partiti

[FFmpeg-devel] [PATCH 47/48] avcodec/rv34: Don't report progress unnecessarily

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

ff_mpv_frame_end() already does it.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/rv34.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 4feab95eb5..bd8800ee5d 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1581,9 +1581,6 @@ static int finish_frame(AVCodecContext *avctx, AVFrame 
*pict)
 ff_mpv_frame_end(s);
 r->mb_num_left = 0;
 
-if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
-ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX);
-
 if (s->pict_type == AV_PICTURE_TYPE_B) {
 if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0)
 return ret;
@@ -1809,7 +1806,6 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 ff_er_frame_end(&s->er, NULL);
 ff_mpv_frame_end(s);
 r->mb_num_left = 0;
-ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX);
 return AVERROR_INVALIDDATA;
 }
 }
-- 
ffmpeg-codebot

___
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 44/48] avcodec/mpeg_er: Allow to skip setting partitioned_frame, p[pb]_time

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

Instead of setting these unconditionally (they are always zero
for H.261, MPEG-1/2, RV30/40, VC-1), add a variant of
ff_mpeg_er_frame_start() that sets them and remove setting them
from ff_mpeg_er_frame_start(). Also pass these values via parameters
instead of reading them from the MPVContext itself.
This will allow to move them from MPVContext.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h263dec.c | 3 ++-
 libavcodec/mpeg_er.c | 3 ---
 libavcodec/mpeg_er.h | 9 +
 libavcodec/rv10.c| 2 +-
 4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 723040146f..aee52dd2b2 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -553,7 +553,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 return ret;
 }
 
-ff_mpeg_er_frame_start(s);
+ff_mpv_er_frame_start_ext(s, s->partitioned_frame,
+  s->pp_time, s->pb_time);
 
 /* the second part of the wmv2 header contains the MB skip bits which
  * are stored in current_picture->mb_type which is not available before
diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index 951167a478..5df75d8e85 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -51,10 +51,7 @@ void ff_mpeg_er_frame_start(MpegEncContext *s)
 set_erpic(&er->next_pic, s->next_pic.ptr);
 set_erpic(&er->last_pic, s->last_pic.ptr);
 
-er->pp_time   = s->pp_time;
-er->pb_time   = s->pb_time;
 er->quarter_sample= s->quarter_sample;
-er->partitioned_frame = s->partitioned_frame;
 
 ff_er_frame_start(er);
 }
diff --git a/libavcodec/mpeg_er.h b/libavcodec/mpeg_er.h
index bb627a4d06..145d1866ed 100644
--- a/libavcodec/mpeg_er.h
+++ b/libavcodec/mpeg_er.h
@@ -24,4 +24,13 @@
 int ff_mpeg_er_init(MpegEncContext *s);
 void ff_mpeg_er_frame_start(MpegEncContext *s);
 
+static inline void ff_mpv_er_frame_start_ext(MPVContext *const s, int 
partitioned_frame,
+ uint16_t pp_time, uint16_t 
pb_time)
+{
+s->er.partitioned_frame = partitioned_frame;
+s->er.pp_time   = pp_time;
+s->er.pb_time   = pb_time;
+ff_mpeg_er_frame_start(s);
+}
+
 #endif /* AVCODEC_MPEG_ER_H */
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index ed702dfb66..677db1cd42 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -451,7 +451,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const 
uint8_t *buf,
 }
 if ((ret = ff_mpv_frame_start(&h->c, avctx)) < 0)
 return ret;
-ff_mpeg_er_frame_start(&h->c);
+ff_mpv_er_frame_start_ext(&h->c, 0, h->c.pp_time, h->c.pb_time);
 } else {
 if (h->c.cur_pic.ptr->f->pict_type != h->c.pict_type) {
 av_log(h->c.avctx, AV_LOG_ERROR, "Slice type mismatch\n");
-- 
ffmpeg-codebot

___
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 48/48] avcodec/rv34: Fix spelling mistake

2025-06-23 Thread Andreas Rheinhardt
From: Andreas Rheinhardt 

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

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index bd8800ee5d..f78b91e7df 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1800,7 +1800,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame 
*pict,
 *got_picture_ptr = ret;
 } else if (HAVE_THREADS &&
(s->avctx->active_thread_type & FF_THREAD_FRAME)) {
-av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n");
+av_log(avctx, AV_LOG_INFO, "marking unfinished frame as 
finished\n");
 /* always mark the current frame as finished, frame-mt supports
  * only complete frames */
 ff_er_frame_end(&s->er, NULL);
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH, v4] avcodec/d3d12va_encode: texture array support for HEVC

2025-06-23 Thread Araz Iusubov
This patch adds support for the texture array feature
used by AMD boards in the D3D12 HEVC encoder.
In texture array mode, a single texture array is shared for all
reference and reconstructed pictures using different subresources.
The implementation ensures compatibility
and has been successfully tested on AMD, Intel, and NVIDIA GPUs.

v2 updates: 
1. The reference to MaxL1ReferencesForB for the H.264 codec 
was updated to use the corresponding H.264 field instead of the HEVC one.
2. Max_subresource_array_size calculation was adjusted 
by removing the D3D12VA_VIDEO_ENC_ASYNC_DEPTH offset.

v3 updates:
1. Fixed a type mismatch by explicitly casting AVD3D12VAFrame* to 
(uint8_t*) when assigning to data[0].
2. Adjusted logging format specifier for HRESULT to use `%lx`.

v4 updates:
1. Moved texture array management to hwcontext_d3d12va 
for proper abstraction.
2. Added `texture_array` and `texture_array_size` fields 
to AVD3D12VAFramesContext.
3. Implemented shared texture array allocation 
during `av_hwframe_ctx_init`.
4. Frames now receive unique subresource indices 
via `d3d12va_pool_alloc_texture_array`.
5. Removed `d3d12va_create_texture_array`, 
allocation is now handled entirely within hwcontext.
6. Encoder now uses subresource indices provided 
by hwcontext instead of managing them manually.

---
 libavcodec/d3d12va_encode.c  | 191 +++
 libavcodec/d3d12va_encode.h  |  12 ++
 libavcodec/d3d12va_encode_hevc.c |   5 +-
 libavutil/hwcontext_d3d12va.c|  66 ++-
 libavutil/hwcontext_d3d12va.h|  18 +++
 5 files changed, 242 insertions(+), 50 deletions(-)

diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c
index e24a5b8d24..f9f4ca8903 100644
--- a/libavcodec/d3d12va_encode.c
+++ b/libavcodec/d3d12va_encode.c
@@ -191,7 +191,8 @@ static int d3d12va_encode_issue(AVCodecContext *avctx,
 FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
 D3D12VAEncodeContext   *ctx = avctx->priv_data;
 D3D12VAEncodePicture   *pic = base_pic->priv;
-AVD3D12VAFramesContext *frames_hwctx = base_ctx->input_frames->hwctx;
+AVD3D12VAFramesContext *frames_hwctx_input = 
base_ctx->input_frames->hwctx;
+AVD3D12VAFramesContext *frames_hwctx_recon = 
((AVHWFramesContext*)base_pic->recon_image->hw_frames_ctx->data)->hwctx;
 int err, i, j;
 HRESULT hr;
 char data[MAX_PARAM_BUFFER_SIZE];
@@ -221,7 +222,7 @@ static int d3d12va_encode_issue(AVCodecContext *avctx,
 D3D12_VIDEO_ENCODER_RESOLVE_METADATA_INPUT_ARGUMENTS input_metadata = {
 .EncoderCodec = ctx->codec->d3d12_codec,
 .EncoderProfile = ctx->profile->d3d12_profile,
-.EncoderInputFormat = frames_hwctx->format,
+.EncoderInputFormat = frames_hwctx_input->format,
 .EncodedPictureEffectiveResolution = ctx->resolution,
 };

@@ -264,6 +265,9 @@ static int d3d12va_encode_issue(AVCodecContext *avctx,

 av_log(avctx, AV_LOG_DEBUG, "Input surface is %p.\n", 
pic->input_surface->texture);

+if (ctx->is_texture_array)
+pic->subresource_index = 
((AVD3D12VAFrame*)base_pic->recon_image->data[0])->subresource_index;
+
 pic->recon_surface = (AVD3D12VAFrame *)base_pic->recon_image->data[0];
 av_log(avctx, AV_LOG_DEBUG, "Recon surface is %p.\n",
pic->recon_surface->texture);
@@ -325,11 +329,28 @@ static int d3d12va_encode_issue(AVCodecContext *avctx,
 goto fail;
 }

+if (ctx->is_texture_array) {
+d3d12_refs.pSubresources = av_calloc(d3d12_refs.NumTexture2Ds,
+
sizeof(*d3d12_refs.pSubresources));
+if (!d3d12_refs.pSubresources) {
+err = AVERROR(ENOMEM);
+goto fail;
+}
+}
+
 i = 0;
-for (j = 0; j < base_pic->nb_refs[0]; j++)
-d3d12_refs.ppTexture2Ds[i++] = ((D3D12VAEncodePicture 
*)base_pic->refs[0][j]->priv)->recon_surface->texture;
-for (j = 0; j < base_pic->nb_refs[1]; j++)
-d3d12_refs.ppTexture2Ds[i++] = ((D3D12VAEncodePicture 
*)base_pic->refs[1][j]->priv)->recon_surface->texture;
+for (j = 0; j < base_pic->nb_refs[0]; j++) {
+d3d12_refs.ppTexture2Ds[i]  = ((D3D12VAEncodePicture 
*)base_pic->refs[0][j]->priv)->recon_surface->texture;
+if (ctx->is_texture_array)
+d3d12_refs.pSubresources[i] = ((D3D12VAEncodePicture 
*)base_pic->refs[0][j]->priv)->subresource_index;
+i++;
+}
+for (j = 0; j < base_pic->nb_refs[1]; j++) {
+d3d12_refs.ppTexture2Ds[i]  = ((D3D12VAEncodePicture 
*)base_pic->refs[1][j]->priv)->recon_surface->texture;
+if (ctx->is_texture_array)
+d3d12_refs.pSubresources[i] = ((D3D12VAEncodePicture 
*)base_pic->refs[1][j]->priv)->subresource_index;
+i++;
+}
 }

 input_args.PictureControlDesc.IntraRefreshFrameIndex  = 0;
@@ -343,7 +364,10 @@ static int d3

[FFmpeg-devel] [PATCH] tools/pktdumper: dump extradata buffers

2025-06-23 Thread Peter Ross
---

useful for re'ing files with extradata

 tools/pktdumper.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index c51f5c8922..d7d3147b22 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -37,6 +37,7 @@
 
 #define FILENAME_BUF_SIZE 4096
 #define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
+#define EXTRADATAFILESUFF "_extradata_%02d_%06d.bin"
 
 static int usage(int ret)
 {
@@ -52,6 +53,7 @@ static int usage(int ret)
 int main(int argc, char **argv)
 {
 char fntemplate[FILENAME_BUF_SIZE];
+char fntemplate2[FILENAME_BUF_SIZE];
 char pktfilename[FILENAME_BUF_SIZE];
 AVFormatContext *fctx = NULL;
 AVPacket *pkt;
@@ -86,8 +88,6 @@ int main(int argc, char **argv)
 fprintf(stderr, "filename too long\n");
 return usage(1);
 }
-strcat(fntemplate, PKTFILESUFF);
-printf("FNTEMPLATE: '%s'\n", fntemplate);
 
 err = avformat_open_input(&fctx, argv[1], NULL, NULL);
 if (err < 0) {
@@ -107,6 +107,30 @@ int main(int argc, char **argv)
 return 1;
 }
 
+strcpy(fntemplate2, fntemplate);
+strcat(fntemplate2, EXTRADATAFILESUFF);
+
+for (int i = 0; i < fctx->nb_streams; i++) {
+AVCodecParameters * par = fctx->streams[i]->codecpar;
+int fd;
+if (par->extradata_size) {
+snprintf(pktfilename, sizeof(pktfilename), fntemplate2, i, 
par->extradata_size);
+printf(EXTRADATAFILESUFF "\n", i, par->extradata_size);
+if (!nowrite) {
+fd  = open(pktfilename, O_WRONLY | O_CREAT, 0644);
+err = write(fd, par->extradata, par->extradata_size);
+if (err < 0) {
+fprintf(stderr, "write: error %d\n", err);
+return 1;
+}
+close(fd);
+}
+}
+}
+
+strcat(fntemplate, PKTFILESUFF);
+printf("FNTEMPLATE: '%s'\n", fntemplate);
+
 while ((err = av_read_frame(fctx, pkt)) >= 0) {
 int fd;
 snprintf(pktfilename, sizeof(pktfilename), fntemplate, pktnum,
-- 
2.47.2

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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 v3 1/3] avformat/whip: replace AV_OPT_FLAG_DECODING_PARAM to ENCODING

2025-06-23 Thread Jack Lau


> On Jun 21, 2025, at 12:58, Zhao Zhili  
> wrote:
> 
> 
> 
>> On Jun 21, 2025, at 10:15, Jack Lau  
>> wrote:
>> 
>> 
>> 
>>> On Jun 13, 2025, at 16:56, Jack Lau via ffmpeg-devel 
>>>  wrote:
>>> 
>>> 
>>> From: Jack Lau 
>>> Subject: [PATCH v3 1/3] avformat/whip: replace AV_OPT_FLAG_DECODING_PARAM 
>>> to ENCODING
>>> Date: June 13, 2025 at 16:56:03 GMT+8
>>> To: ffmpeg-devel@ffmpeg.org
>>> Cc: Jack Lau 
>>> 
>>> 
>>> Signed-off-by: Jack Lau 
>>> ---
>>> libavformat/whip.c | 12 ++--
>>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>> 
>>> diff --git a/libavformat/whip.c b/libavformat/whip.c
>>> index 710f24fc5a..a6827d3478 100644
>>> --- a/libavformat/whip.c
>>> +++ b/libavformat/whip.c
>>> @@ -1885,13 +1885,13 @@ static int whip_check_bitstream(AVFormatContext *s, 
>>> AVStream *st, const AVPacket
>>> }
>>> 
>>> #define OFFSET(x) offsetof(WHIPContext, x)
>>> -#define DEC AV_OPT_FLAG_DECODING_PARAM
>>> +#define ENC AV_OPT_FLAG_ENCODING_PARAM
>>> static const AVOption options[] = {
>>> -{ "handshake_timeout",  "Timeout in milliseconds for ICE and DTLS 
>>> handshake.",  OFFSET(handshake_timeout),  AV_OPT_TYPE_INT,{ .i64 = 
>>> 5000 },-1, INT_MAX, DEC },
>>> -{ "pkt_size",   "The maximum size, in bytes, of RTP packets 
>>> that send out", OFFSET(pkt_size),   AV_OPT_TYPE_INT,{ .i64 = 
>>> 1200 },-1, INT_MAX, DEC },
>>> -{ "authorization",  "The optional Bearer token for WHIP 
>>> Authorization", OFFSET(authorization),  AV_OPT_TYPE_STRING, { 
>>> .str = NULL }, 0,   0, DEC },
>>> -{ "cert_file",  "The optional certificate file path for DTLS", 
>>>  OFFSET(cert_file),  AV_OPT_TYPE_STRING, { .str = NULL 
>>> }, 0,   0, DEC },
>>> -{ "key_file",   "The optional private key file path for DTLS", 
>>>  OFFSET(key_file),  AV_OPT_TYPE_STRING, { .str = NULL },
>>>  0,   0, DEC },
>>> +{ "handshake_timeout",  "Timeout in milliseconds for ICE and DTLS 
>>> handshake.",  OFFSET(handshake_timeout),  AV_OPT_TYPE_INT,{ .i64 = 
>>> 5000 },-1, INT_MAX, ENC },
>>> +{ "pkt_size",   "The maximum size, in bytes, of RTP packets 
>>> that send out", OFFSET(pkt_size),   AV_OPT_TYPE_INT,{ .i64 = 
>>> 1200 },-1, INT_MAX, ENC },
>>> +{ "authorization",  "The optional Bearer token for WHIP 
>>> Authorization", OFFSET(authorization),  AV_OPT_TYPE_STRING, { 
>>> .str = NULL }, 0,   0, ENC },
>>> +{ "cert_file",  "The optional certificate file path for DTLS", 
>>>  OFFSET(cert_file),  AV_OPT_TYPE_STRING, { .str = NULL 
>>> }, 0,   0, ENC },
>>> +{ "key_file",   "The optional private key file path for DTLS", 
>>>  OFFSET(key_file),  AV_OPT_TYPE_STRING, { .str = NULL },
>>>  0,   0, ENC },
>>>   { NULL },
>>> };
>>> 
>>> -- 
>>> 2.49.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”.
>> PING.
> 
> Applied, 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”.

There’re two other patches in this patchset 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=14768
, Could you help merge these please?

I want to submit WHIP NACK patch that depends on these patches.

Best regards
Jack



___
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/4] avformat/iamf_parse: Check extradata size

2025-06-23 Thread Michael Niedermayer
On Mon, Jun 23, 2025 at 09:47:55AM -0300, James Almer wrote:
> On 6/23/2025 9:44 AM, Michael Niedermayer wrote:
> > On Fri, Jun 20, 2025 at 12:28:13AM +0200, Andreas Rheinhardt wrote:
> > > Michael Niedermayer:
> > > > Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
> > > > Fixes: 
> > > > 398527871/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6602025714647040
> > > > 
> > > > Found-by: continuous fuzzing process 
> > > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > > Signed-off-by: Michael Niedermayer 
> > > > ---
> > > >   libavformat/iamf_parse.c | 2 ++
> > > >   1 file changed, 2 insertions(+)
> > > > 
> > > > diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
> > > > index 71497876ac3..330e01733dd 100644
> > > > --- a/libavformat/iamf_parse.c
> > > > +++ b/libavformat/iamf_parse.c
> > > > @@ -305,6 +305,8 @@ static int update_extradata(AVCodecParameters 
> > > > *codecpar)
> > > >   skip_bits(&gb, 4);
> > > >   put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set 
> > > > channel config
> > > >   ret = put_bits_left(&pb);
> > > > +if (ret < 0)
> > > > +return AVERROR_INVALIDDATA;
> > > >   while (ret >= 32) {
> > > >  put_bits32(&pb, get_bits_long(&gb, 32));
> > > >  ret -= 32;
> > > 
> > > There is only one way for put_bits_left() to return a negative value: If
> > > there is more data in the internal buffer than can be written out. And
> > > this scenario is already a violation of the PutBit API. Given that the
> > > size of the internal buffer depends upon the arch, it could be that one
> > > would have already hit an assert in case one is not using x64. In other
> > > words, your check is too late.
> > 
> > the patches puprose was mainly to show that
> > 3f9420132441345b7ccd57001f230bb98f655696
> > was insufficient to fix 398527871
> > 
> > I do not expect my patch would be the correct solution even if the
> > check is done earlier. IAMF is cursed
> 
> Does increasing buf from 6 bytes to 8 or more fix it? I see putbits may do
> an AV_W*64(), so six bytes sounds like it was never safe.

i set buffer to 1000 and it still fails with put_bits_left()
returning -19

what will fix this specific case is:
-if (ret == 0x0f)
-put_bits(&pb, 24, get_bits(&gb, 24));
+if (ret == 0x0f) {
+if (get_bits_left(&gb) >= 24+4+4)
+put_bits(&pb, 24, get_bits(&gb, 24));
+}


thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


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

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/iamf_parse: Check extradata size

2025-06-23 Thread James Almer

On 6/23/2025 9:57 AM, Andreas Rheinhardt wrote:

James Almer:

On 6/23/2025 9:44 AM, Michael Niedermayer wrote:

On Fri, Jun 20, 2025 at 12:28:13AM +0200, Andreas Rheinhardt wrote:

Michael Niedermayer:

Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
Fixes: 398527871/clusterfuzz-testcase-minimized-
ffmpeg_dem_IAMF_fuzzer-6602025714647040

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

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 71497876ac3..330e01733dd 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -305,6 +305,8 @@ static int update_extradata(AVCodecParameters
*codecpar)
   skip_bits(&gb, 4);
   put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set
channel config
   ret = put_bits_left(&pb);
+    if (ret < 0)
+    return AVERROR_INVALIDDATA;
   while (ret >= 32) {
  put_bits32(&pb, get_bits_long(&gb, 32));
  ret -= 32;


There is only one way for put_bits_left() to return a negative value: If
there is more data in the internal buffer than can be written out. And
this scenario is already a violation of the PutBit API. Given that the
size of the internal buffer depends upon the arch, it could be that one
would have already hit an assert in case one is not using x64. In other
words, your check is too late.


the patches puprose was mainly to show that
3f9420132441345b7ccd57001f230bb98f655696
was insufficient to fix 398527871

I do not expect my patch would be the correct solution even if the
check is done earlier. IAMF is cursed


Does increasing buf from 6 bytes to 8 or more fix it? I see putbits may
do an AV_W*64(), so six bytes sounds like it was never safe.


That is only executed when the internal bit buffer is full; you will
never reach it on x64. The problem is that you initialize the put bits
buffer with FFMIN(codecpar->extradata_size, sizeof(buf)) instead of
sizeof(buf). If this were not so, there would always be bits left.
But this only fixes the API violations, it does not guarantee that the
written data is actually correct. What is actually in the data that gets
written in the loop?
The remaining bits in the GetBitContext buffer in order to fill the 
PutBitContext buffer.


The following probably fixes it, based on what you said.


diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 71497876ac..19c549d4ac 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -288,7 +288,7 @@ static int update_extradata(AVCodecParameters *codecpar)
 uint8_t buf[6];
 int size = FFMIN(codecpar->extradata_size, sizeof(buf));

-init_put_bits(&pb, buf, size);
+init_put_bits(&pb, buf, sizeof(buf));
 ret = init_get_bits8(&gb, codecpar->extradata, size);
 if (ret < 0)
 return ret;
@@ -312,6 +312,9 @@ static int update_extradata(AVCodecParameters *codecpar)
 put_bits(&pb, ret, get_bits_long(&gb, ret));
 flush_put_bits(&pb);

+if (get_bits_left(&gb) < 0)
+   return AVERROR_INVALIDDATA;
+
 memcpy(codecpar->extradata, buf, put_bytes_output(&pb));
 break;
 }





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

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


[FFmpeg-devel] [PATCH v2 17/20] fate/all: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/api.mak  | 2 +-
 tests/fate/cbs.mak  | 2 +-
 tests/fate/ffmpeg.mak   | 6 +++---
 tests/fate/filter-audio.mak | 8 
 tests/fate/filter-video.mak | 2 +-
 tests/fate/fits.mak | 4 ++--
 tests/fate/gif.mak  | 2 +-
 tests/fate/h264.mak | 6 +++---
 tests/fate/image.mak| 2 +-
 tests/fate/libavformat.mak  | 2 +-
 tests/fate/matroska.mak | 7 ---
 tests/fate/ogg-flac.mak | 2 +-
 tests/fate/pixfmt.mak   | 1 +
 tests/fate/segment.mak  | 6 +++---
 tests/fate/vcodec.mak   | 4 +++-
 tests/fate/video.mak| 2 +-
 tests/fate/voice.mak| 4 ++--
 tests/fate/xvid.mak | 2 +-
 18 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/tests/fate/api.mak b/tests/fate/api.mak
index d2868e57ac..6a4752e32b 100644
--- a/tests/fate/api.mak
+++ b/tests/fate/api.mak
@@ -8,7 +8,7 @@ fate-api-band: $(APITESTSDIR)/api-band-test$(EXESUF)
 fate-api-band: CMD = run $(APITESTSDIR)/api-band-test$(EXESUF) 
$(TARGET_SAMPLES)/mpeg4/resize_down-up.h263
 fate-api-band: CMP = null
 
-FATE_API_SAMPLES_LIBAVFORMAT-$(call DEMDEC, H264, H264) += fate-api-h264
+FATE_API_SAMPLES_LIBAVFORMAT-$(call DEMDEC, H264, H264, H264_PARSER) += 
fate-api-h264
 fate-api-h264: $(APITESTSDIR)/api-h264-test$(EXESUF)
 fate-api-h264: CMD = run $(APITESTSDIR)/api-h264-test$(EXESUF) 
$(TARGET_SAMPLES)/h264-conformance/SVA_NL2_E.264
 
diff --git a/tests/fate/cbs.mak b/tests/fate/cbs.mak
index 138dab67a9..2b6cf0df73 100644
--- a/tests/fate/cbs.mak
+++ b/tests/fate/cbs.mak
@@ -175,7 +175,7 @@ FATE_CBS_HEVC-$(call ALLYES, HEVC_DEMUXER HEVC_MUXER 
HEVC_PARSER FILTER_UNITS_BS
 fate-cbs-hevc-metadata-set-color: CMD = md5 -i 
$(TARGET_SAMPLES)/hevc-conformance/AMP_A_Samsung_4.bit -c:v copy -bsf:v 
hevc_metadata=colour_primaries=0:transfer_characteristics=0:matrix_coefficients=3
 -f hevc
 fate-cbs-hevc-metadata-set-color: CMP = oneline
 fate-cbs-hevc-metadata-set-color: REF = d073124fca9e30a46c173292f948967c
-FATE_CBS_HEVC-$(call ALLYES, HEVC_DEMUXER, HEVC_METADATA_BSF, HEVC_MUXER) += 
fate-cbs-hevc-metadata-set-color
+FATE_CBS_HEVC-$(call ALLYES, HEVC_DEMUXER HEVC_METADATA_BSF HEVC_MUXER) += 
fate-cbs-hevc-metadata-set-color
 
 FATE_SAMPLES_AVCONV += $(FATE_CBS_HEVC-yes)
 fate-cbs-hevc: $(FATE_CBS_HEVC-yes)
diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index d9348ee837..87130428d1 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -40,7 +40,7 @@ fate-force_key_frames-source-dup: CMD = framecrc -i 
$(TARGET_SAMPLES)/h264/intra
   -c:v mpeg2video -g 400 -sc_threshold 9 \
   -force_key_frames source -r 39 -force_fps -strict experimental
 
-FATE_SAMPLES_FFMPEG-$(call ENCDEC, MPEG2VIDEO H264, FRAMECRC H264, CROP_FILTER 
DRAWBOX_FILTER) += \
+FATE_SAMPLES_FFMPEG-$(call ENCDEC, MPEG2VIDEO H264, FRAMECRC H264, H264_PARSER 
CROP_FILTER DRAWBOX_FILTER) += \
 fate-force_key_frames-source fate-force_key_frames-source-drop 
fate-force_key_frames-source-dup
 
 # Tests that the video is properly autorotated using the contained
@@ -171,7 +171,7 @@ FATE_STREAMCOPY-$(call REMUX, PSP MOV, H264_PARSER 
H264_DECODER) += fate-copy-ps
 fate-copy-psp: CMD = transcode "mov" $(TARGET_SAMPLES)/h264/wwwq_cut.mp4\
   psp "-c copy" "-codec copy"
 
-FATE_STREAMCOPY-$(call FRAMEMD5, FLV, H264) += fate-ffmpeg-streamloop-copy
+FATE_STREAMCOPY-$(call FRAMEMD5, FLV, H264, H264_PARSER) += 
fate-ffmpeg-streamloop-copy
 fate-ffmpeg-streamloop-copy: CMD = framemd5 -stream_loop 2 -i 
$(TARGET_SAMPLES)/flv/streamloop.flv -c copy
 
 tests/data/audio_shorter_than_video.nut: TAG = GEN
@@ -255,7 +255,7 @@ fate-ffmpeg-streamcopy-t: CMP = null
 fate-ffmpeg-streamcopy-t: CMD = ffmpeg 
   \
 -stream_loop -1 -f rawvideo -s 352x288 -pix_fmt yuv420p -i 
$(TARGET_PATH)/tests/data/vsynth1.yuv  \
 -c copy -f null -t 1 -
-FATE_FFMPEG-$(call REMUX, RAWVIDEO) += fate-ffmpeg-streamcopy-t
+FATE_FFMPEG-$(call REMUX, RAWVIDEO, NULL_MUXER) += fate-ffmpeg-streamcopy-t
 
 # Test loopback decoding and passing the output to a complex graph.
 fate-ffmpeg-loopback-decoding: tests/data/vsynth1.yuv
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 343fa40e9d..22b544e3ef 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -210,7 +210,7 @@ tests/data/hls-list.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
 -f lavfi -i "aevalsrc=cos(2*PI*t)*sin(2*PI*(440+4*t)*t):d=20" -f 
segment -segment_time 10 -map 0 -flags +bitexact -codec:a mp2fixed \
 -segment_list $(TARGET_PATH)/$@ -y 
$(TARGET_PATH)/tests/data/hls-out-%03d.ts 2>/dev/null
 
-FATE_AFILTER-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-filter-hls
+FATE_AFILTER-$(call FILTERDEMDECENCMUX, ARESAMPLE AEVALSRC, HLS MPEGTS, MP2 
PCM_F64LE, MP2FIXED, SEGMENT MPEGTS, LAVFI_INDEV) += f

[FFmpeg-devel] [PATCH v2 15/20] fate/pcm: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/pcm.mak | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/fate/pcm.mak b/tests/fate/pcm.mak
index b10233a9eb..75636118b2 100644
--- a/tests/fate/pcm.mak
+++ b/tests/fate/pcm.mak
@@ -1,4 +1,4 @@
-FATE_SAMPLES_PCM-$(call DEMDEC, WAV, PCM_U8, ARESAMPLE_FILTER) += fate-iff-pcm
+FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_S16LE PCM_U8, PCM_S16LE WAV, 
ARESAMPLE_FILTER) += fate-iff-pcm
 fate-iff-pcm: CMD = md5 -i $(TARGET_SAMPLES)/iff/Bells -f s16le -af aresample
 
 FATE_SAMPLES_PCM-$(call DEMDEC, MPEGPS, PCM_DVD, ARESAMPLE_FILTER) += 
fate-pcm_dvd
@@ -7,22 +7,22 @@ fate-pcm_dvd: CMD = framecrc -i 
$(TARGET_SAMPLES)/pcm-dvd/coolitnow-partial.vob
 FATE_SAMPLES_PCM-$(call DEMDEC, EA, PCM_S16LE_PLANAR, ARESAMPLE_FILTER) += 
fate-pcm-planar
 fate-pcm-planar: CMD = framecrc -i $(TARGET_SAMPLES)/ea-mad/xeasport.mad -vn 
-af aresample
 
-FATE_SAMPLES_PCM-$(call DEMDEC, MOV, PCM_S16BE) += fate-pcm_s16be-stereo
+FATE_SAMPLES_PCM-$(call DEMDEC, MOV, PCM_S16BE, PCM_S16LE_MUXER) += 
fate-pcm_s16be-stereo
 fate-pcm_s16be-stereo: CMD = md5 -i 
$(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-B-twos.mov -f s16le
 
-FATE_SAMPLES_PCM-$(call DEMDEC, MOV, PCM_S16LE) += fate-pcm_s16le-stereo
+FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_S16LE, PCM_S16LE MOV) += 
fate-pcm_s16le-stereo
 fate-pcm_s16le-stereo: CMD = md5 -i 
$(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-L-sowt.mov -f s16le
 
-FATE_SAMPLES_PCM-$(call DEMDEC, MOV, PCM_U8, ARESAMPLE_FILTER) += 
fate-pcm_u8-mono
+FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_S16LE PCM_U8, PCM_S16LE MOV, 
ARESAMPLE_FILTER) += fate-pcm_u8-mono
 fate-pcm_u8-mono: CMD = md5 -i 
$(TARGET_SAMPLES)/qt-surge-suite/surge-1-8-raw.mov -f s16le -af aresample
 
-FATE_SAMPLES_PCM-$(call DEMDEC, MOV, PCM_U8, ARESAMPLE_FILTER) += 
fate-pcm_u8-stereo
+FATE_SAMPLES_PCM-$(call TRANSCODE, PCM_S16LE PCM_U8, PCM_S16LE MOV, 
ARESAMPLE_FILTER) += fate-pcm_u8-stereo
 fate-pcm_u8-stereo: CMD = md5 -i 
$(TARGET_SAMPLES)/qt-surge-suite/surge-2-8-raw.mov -f s16le -af aresample
 
 FATE_SAMPLES_PCM-$(call DEMDEC, W64, PCM_S16LE) += fate-w64
 fate-w64: CMD = crc -i $(TARGET_SAMPLES)/w64/w64-pcm16.w64
 
-FATE_PCM-$(call ENCMUX, PCM_S24DAUD, DAUD) += fate-dcinema-encode
+FATE_PCM-$(call ENCMUX, PCM_S24DAUD, DAUD, WAV_DEMUXER) += fate-dcinema-encode
 fate-dcinema-encode: tests/data/asynth-96000-6.wav
 fate-dcinema-encode: SRC = tests/data/asynth-96000-6.wav
 fate-dcinema-encode: CMD = enc_dec_pcm daud framemd5 s16le $(SRC) -c:a 
pcm_s24daud -frames:a 20
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 11/20] fate/ac3: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/ac3.mak | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/fate/ac3.mak b/tests/fate/ac3.mak
index e52678a2fd..30f8b98ff1 100644
--- a/tests/fate/ac3.mak
+++ b/tests/fate/ac3.mak
@@ -65,17 +65,17 @@ fate-eac3-5: REF = $(SAMPLES)/eac3/the_great_wall_7.1.pcm
 
 $(FATE_AC3) $(FATE_EAC3): CMP = oneoff
 
-FATE_AC3-$(call  DEMDEC, AC3,  AC3,  ARESAMPLE_FILTER)  += $(FATE_AC3)
-FATE_EAC3-$(call DEMDEC, EAC3, EAC3, ARESAMPLE_FILTER) += $(FATE_EAC3)
+FATE_AC3-$(call  DEMDEC, AC3,  AC3 AC3_FIXED, PCM_S16LE_MUXER 
ARESAMPLE_FILTER)  += $(FATE_AC3)
+FATE_EAC3-$(call DEMDEC, EAC3, EAC3,  PCM_S16LE_MUXER 
ARESAMPLE_FILTER) += $(FATE_EAC3)
 
-FATE_AC3-$(call ENCDEC, AC3, AC3, ARESAMPLE_FILTER) += fate-ac3-encode
+FATE_AC3-$(call ENCDEC, AC3, AC3, WAV_MUXER WAV_DEMUXER ARESAMPLE_FILTER 
PCM_S16LE_ENCODER PIPE_PROTOCOL) += fate-ac3-encode
 fate-ac3-encode: CMD = enc_dec_pcm ac3 wav s16le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c:a ac3 -b:a 128k
 fate-ac3-encode: CMP_SHIFT = -1024
 fate-ac3-encode: CMP_TARGET = 404.53
 fate-ac3-encode: SIZE_TOLERANCE = 488
 
 
-FATE_EAC3-$(call ENCDEC, EAC3, EAC3, ARESAMPLE_FILTER) += fate-eac3-encode
+FATE_EAC3-$(call ENCDEC, EAC3, EAC3, WAV_MUXER WAV_DEMUXER ARESAMPLE_FILTER 
PCM_S16LE_ENCODER PIPE_PROTOCOL) += fate-eac3-encode
 fate-eac3-encode: CMD = enc_dec_pcm eac3 wav s16le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c:a eac3 -b:a 128k
 fate-eac3-encode: CMP_SHIFT = -1024
 fate-eac3-encode: CMP_TARGET = 516.94
@@ -84,7 +84,7 @@ fate-eac3-encode: SIZE_TOLERANCE = 488
 fate-ac3-encode fate-eac3-encode: CMP = stddev
 fate-ac3-encode fate-eac3-encode: REF = 
$(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
 
-FATE_AC3-$(call ENCMUX, AC3_FIXED, AC3, ARESAMPLE_FILTER) += 
fate-ac3-fixed-encode
+FATE_AC3-$(call ENCMUX, AC3_FIXED, AC3, WAV_DEMUXER PCM_S16LE_DECODER 
ARESAMPLE_FILTER) += fate-ac3-fixed-encode
 fate-ac3-fixed-encode: tests/data/asynth-44100-2.wav
 fate-ac3-fixed-encode: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
 fate-ac3-fixed-encode: CMD = md5 -i $(SRC) -c ac3_fixed -ab 128k -f ac3 -flags 
+bitexact -af aresample
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 13/20] fate/hlsenc: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/hlsenc.mak | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak
index 98341b2b81..72c75bec3a 100644
--- a/tests/fate/hlsenc.mak
+++ b/tests/fate/hlsenc.mak
@@ -5,7 +5,7 @@ tests/data/live_no_endlist.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
 -hls_flags omit_endlist -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/live_no_endlist_%03d.ts \
 $(TARGET_PATH)/tests/data/live_no_endlist.m3u8 2>/dev/null
 
-FATE_HLSENC-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-hls-live-no-endlist
+FATE_HLSENC-$(call FILTERDEMDECENCMUX, HDCD AEVALSRC ARESAMPLE, HLS MPEGTS, 
MP2 PCM_F64LE, MP2FIXED PCM_S24LE, HLS MPEGTS PCM_S24LE, LAVFI_INDEV) += 
fate-hls-live-no-endlist
 fate-hls-live-no-endlist: tests/data/live_no_endlist.m3u8
 fate-hls-live-no-endlist: SRC = $(TARGET_PATH)/tests/data/live_no_endlist.m3u8
 fate-hls-live-no-endlist: CMD = md5 -i $(SRC) -af hdcd=process_stereo=false -t 
6 -f s24le
@@ -19,7 +19,7 @@ tests/data/live_last_endlist.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) 
| tests/data
 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/live_last_endlist_%03d.ts \
 $(TARGET_PATH)/tests/data/live_last_endlist.m3u8 2>/dev/null
 
-FATE_HLSENC-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-hls-live-last-endlist
+FATE_HLSENC-$(call FILTERDEMDECENCMUX, HDCD AEVALSRC ARESAMPLE, HLS MPEGTS, 
MP2 PCM_F64LE, MP2FIXED PCM_S24LE, HLS MPEGTS PCM_S24LE, LAVFI_INDEV) += 
fate-hls-live-last-endlist
 fate-hls-live-last-endlist: tests/data/live_last_endlist.m3u8
 fate-hls-live-last-endlist: SRC = 
$(TARGET_PATH)/tests/data/live_last_endlist.m3u8
 fate-hls-live-last-endlist: CMD = md5 -i $(SRC) -af hdcd=process_stereo=false 
-t 6 -f s24le
@@ -34,7 +34,7 @@ tests/data/live_endlist.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
 -hls_list_size 0 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/live_endlist_%d.ts \
 $(TARGET_PATH)/tests/data/live_endlist.m3u8 2>/dev/null
 
-FATE_HLSENC-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-hls-live-endlist
+FATE_HLSENC-$(call FILTERDEMDECENCMUX, HDCD AEVALSRC ARESAMPLE, HLS MPEGTS, 
MP2 PCM_F64LE, MP2FIXED PCM_S24LE, HLS MPEGTS PCM_S24LE, LAVFI_INDEV ) += 
fate-hls-live-endlist
 fate-hls-live-endlist: tests/data/live_endlist.m3u8
 fate-hls-live-endlist: SRC = $(TARGET_PATH)/tests/data/live_endlist.m3u8
 fate-hls-live-endlist: CMD = md5 -i $(SRC) -af hdcd=process_stereo=false -t 20 
-f s24le
@@ -48,7 +48,7 @@ tests/data/hls_segment_size.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) 
| tests/data
-hls_list_size 0 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/hls_segment_size_%d.ts \
$(TARGET_PATH)/tests/data/hls_segment_size.m3u8 2>/dev/null
 
-FATE_HLSENC-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-hls-segment-size
+FATE_HLSENC-$(call FILTERDEMDECENCMUX, AEVALSRC ARESAMPLE, HLS MPEGTS, MP2 
PCM_F64LE, MP2FIXED, HLS MPEGTS, LAVFI_INDEV) += fate-hls-segment-size
 fate-hls-segment-size: tests/data/hls_segment_size.m3u8
 fate-hls-segment-size: CMD = framecrc -auto_conversion_filters -flags 
+bitexact -i $(TARGET_PATH)/tests/data/hls_segment_size.m3u8 -vf setpts=N*23
 
@@ -59,7 +59,7 @@ tests/data/hls_segment_single.m3u8: 
ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
-hls_list_size 0 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/hls_segment_single.ts \
$(TARGET_PATH)/tests/data/hls_segment_single.m3u8 2>/dev/null
 
-FATE_HLSENC-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-hls-segment-single
+FATE_HLSENC-$(call FILTERDEMDECENCMUX, AEVALSRC ARESAMPLE, HLS MPEGTS, MP2 
PCM_F64LE, MP2FIXED, HLS MPEGTS, LAVFI_INDEV) += fate-hls-segment-single
 fate-hls-segment-single: tests/data/hls_segment_single.m3u8
 fate-hls-segment-single: CMD = framecrc -auto_conversion_filters -flags 
+bitexact -i $(TARGET_PATH)/tests/data/hls_segment_single.m3u8 -vf setpts=N*23
 
@@ -70,7 +70,7 @@ tests/data/hls_init_time.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
-hls_list_size 5 -codec:a mp2fixed -hls_segment_filename 
$(TARGET_PATH)/tests/data/hls_init_time_%d.ts \
$(TARGET_PATH)/tests/data/hls_init_time.m3u8 2>/dev/null
 
-FATE_HLSENC-$(call ALLYES, HLS_DEMUXER MPEGTS_MUXER MPEGTS_DEMUXER 
AEVALSRC_FILTER ARESAMPLE_FILTER LAVFI_INDEV MP2FIXED_ENCODER) += 
fate-hls-init-time
+FATE_HLSENC-$(call FILTERDEMDECENCMUX, AEVALSRC ARESAMPLE, HLS MPEGTS, MP2 
PCM_F64LE, MP2FIXED, HLS MPEGTS, LAVFI_INDEV) += fate-hls-init-time
 fate-hls-i

[FFmpeg-devel] [PATCH v2 14/20] fate/mpeg4: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/mpeg4.mak | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tests/fate/mpeg4.mak b/tests/fate/mpeg4.mak
index 9a3cd4e2fb..d6cce97a70 100644
--- a/tests/fate/mpeg4.mak
+++ b/tests/fate/mpeg4.mak
@@ -3,23 +3,22 @@ MPEG4_RESOLUTION_CHANGE = down-down down-up up-down up-up
 
 fate-mpeg4-resolution-change-%: CMD = framemd5 -flags +bitexact -idct simple 
-i $(TARGET_SAMPLES)/mpeg4/resize_$(@:fate-mpeg4-resolution-change-%=%).h263 
-sws_flags +bitexact
 
-FATE_MPEG4-$(call FRAMEMD5, M4V, MPEG4, SCALE_FILTER) := $(addprefix 
fate-mpeg4-resolution-change-, $(MPEG4_RESOLUTION_CHANGE))
+FATE_MPEG4-$(call FRAMEMD5, M4V, MPEG4, MPEG4VIDEO_PARSER SCALE_FILTER) := 
$(addprefix fate-mpeg4-resolution-change-, $(MPEG4_RESOLUTION_CHANGE))
 
 fate-mpeg4-bsf-unpack-bframes: CMD = md5 -i 
$(TARGET_SAMPLES)/mpeg4/packed_bframes.avi -flags +bitexact -fflags +bitexact 
-c:v copy -bsf mpeg4_unpack_bframes -f avi
 FATE_MPEG4-$(call DEMMUX, AVI, AVI, MPEG4_UNPACK_BFRAMES_BSF) += 
fate-mpeg4-bsf-unpack-bframes
 
 fate-mpeg4-packed: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg4/packed_bframes.avi -flags +bitexact -fflags +bitexact 
-fps_mode cfr
-FATE_MPEG4-$(call FRAMECRC, AVI, MPEG4) += fate-mpeg4-packed
+FATE_MPEG4-$(call FRAMECRC, AVI, MPEG4, MPEG4VIDEO_PARSER) += fate-mpeg4-packed
 
-FATE_MPEG4-$(call ALLYES, FILE_PROTOCOL M4V_DEMUXER MPEG4_DECODER SCALE_FILTER 
\
-  RAWVIDEO_ENCODER FRAMECRC_MUXER PIPE_PROTOCOL) \
+FATE_MPEG4-$(call FRAMECRC, M4V, MPEG4, MPEG4VIDEO_PARSER SCALE_FILTER) \
   += fate-mpeg4-simple-studio-profile
 fate-mpeg4-simple-studio-profile: CMD = framecrc -bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg4/mpeg4_sstp_dpcm.m4v -sws_flags +accurate_rnd+bitexact 
-pix_fmt yuv422p10le -vf scale
 
-FATE_MPEG4-$(call FRAMECRC, M4V, MPEG4) += fate-m4v
+FATE_MPEG4-$(call FRAMECRC, M4V, MPEG4, MPEG4VIDEO_PARSER) += fate-m4v
 fate-m4v: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg4/demo.m4v
 
-FATE_MPEG4-$(call FRAMECRC, M4V, MPEG4, FPS_FILTER) += fate-m4v-cfr
+FATE_MPEG4-$(call FRAMECRC, M4V, MPEG4, MPEG4VIDEO_PARSER FPS_FILTER) += 
fate-m4v-cfr
 fate-m4v-cfr: CMD = framecrc -flags +bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg4/demo.m4v -vf fps=5
 
 FATE_SAMPLES_AVCONV += $(FATE_MPEG4-yes)
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 16/20] fate/hevc: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/hevc.mak | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 3ad6e255a9..7b22e36a3d 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -219,7 +219,7 @@ FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER 
SCALE_FILTER) += \
 $(HEVC_TESTS_422_10BIN) \
 $(HEVC_TESTS_444_12BIT) \
 
-FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER) += 
$(HEVC_TESTS_MULTIVIEW)
+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER SETPTS_FILTER) 
+= $(HEVC_TESTS_MULTIVIEW)
 
 fate-hevc-paramchange-yuv420p-yuv420p10: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/paramchange_yuv420p_yuv420p10.hevc -fps_mode passthrough 
-sws_flags area+accurate_rnd+bitexact
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER LARGE_TESTS) 
+= fate-hevc-paramchange-yuv420p-yuv420p10
@@ -229,7 +229,7 @@ tests/data/hevc-mp4.mov: ffmpeg$(PROGSSUF)$(EXESUF) | 
tests/data
$(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin \
-i $(TARGET_SAMPLES)/hevc-conformance/WPP_A_ericsson_MAIN10_2.bit -c 
copy -flags +bitexact $(TARGET_PATH)/$@ -y 2>/dev/null
 
-FATE_HEVC-$(call ALLYES, HEVC_DEMUXER MOV_DEMUXER HEVC_PARSER 
HEVC_MP4TOANNEXB_BSF EXTRACT_EXTRADATA_BSF MOV_MUXER HEVC_MUXER) += 
fate-hevc-bsf-mp4toannexb
+FATE_HEVC-$(call DEMMUX, HEVC MOV, MOV HEVC, HEVC_PARSER HEVC_MP4TOANNEXB_BSF 
EXTRACT_EXTRADATA_BSF) += fate-hevc-bsf-mp4toannexb
 fate-hevc-bsf-mp4toannexb: tests/data/hevc-mp4.mov
 fate-hevc-bsf-mp4toannexb: CMD = md5 -i $(TARGET_PATH)/tests/data/hevc-mp4.mov 
-c:v copy -fflags +bitexact -f hevc
 fate-hevc-bsf-mp4toannexb: CMP = oneline
@@ -270,11 +270,11 @@ fate-hevc-small422chroma: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/food.hevc -pi
 FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER SCALE_FILTER) += 
fate-hevc-small422chroma
 
 fate-hevc-pir: CMD = framecrc -i $(TARGET_SAMPLES)/hevc/pir.hevc
-FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-pir
+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER) += fate-hevc-pir
 
 # multiview stream, where the secondary layer has a nontrivial nuh_layer_id=6
 fate-hevc-mv-nuh-layer-id: CMD = framecrc -i 
$(TARGET_SAMPLES)/hevc/mv_nuh_layer_id.bit -map 0:view:all
-FATE_HEVC-$(call FRAMECRC, HEVC, HEVC) += fate-hevc-mv-nuh-layer-id
+FATE_HEVC-$(call FRAMECRC, HEVC, HEVC, HEVC_PARSER) += 
fate-hevc-mv-nuh-layer-id
 
 # NB: $\ at the end of line joins lines without adding whitespace;
 # this trick is recommended by GNU make manual
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 12/20] fate/cover-art: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/cover-art.mak | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/fate/cover-art.mak b/tests/fate/cover-art.mak
index faa2182745..7ee9443864 100644
--- a/tests/fate/cover-art.mak
+++ b/tests/fate/cover-art.mak
@@ -1,32 +1,32 @@
-FATE_COVER_ART-$(CONFIG_APE_DEMUXER) += fate-cover-art-ape
+FATE_COVER_ART-$(call DEMDEC, APE, MJPEG) += fate-cover-art-ape
 fate-cover-art-ape: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/luckynight_cover.ape -an -c:v copy -f rawvideo
 fate-cover-art-ape: REF = 45333c983c45af54449dff10af144317
 
-FATE_COVER_ART-$(CONFIG_FLAC_DEMUXER) += fate-cover-art-flac
+FATE_COVER_ART-$(call DEMDEC, FLAC, MJPEG) += fate-cover-art-flac
 fate-cover-art-flac: CMD = md5 -i $(TARGET_SAMPLES)/cover_art/cover_art.flac 
-an -c:v copy -f rawvideo
 fate-cover-art-flac: REF = 0de1fc6200596fa32b8f7300a14c0261
 
-FATE_COVER_ART-$(CONFIG_MOV_DEMUXER) += fate-cover-art-m4a
+FATE_COVER_ART-$(call DEMDEC, MOV, MJPEG) += fate-cover-art-m4a
 fate-cover-art-m4a: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/Owner-iTunes_9.0.3.15.m4a -an -c:v copy -f rawvideo
 fate-cover-art-m4a: REF = 08ba70a3b594ff6345a93965e96a9d3e
 
-FATE_COVER_ART-$(CONFIG_OGG_DEMUXER) += fate-cover-art-ogg
+FATE_COVER_ART-$(call DEMDEC, OGG, MJPEG) += fate-cover-art-ogg
 fate-cover-art-ogg: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/ogg_vorbiscomment_cover.opus -map 0:v -c:v copy -f 
rawvideo
 fate-cover-art-ogg: REF = 7f117e073620eabb4ed02680cf70af41
 
-FATE_COVER_ART-$(CONFIG_ASF_DEMUXER) += fate-cover-art-wma
+FATE_COVER_ART-$(call DEMDEC, ASF, MJPEG) += fate-cover-art-wma
 fate-cover-art-wma: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/Californication_cover.wma -an -c:v copy -f rawvideo
 fate-cover-art-wma: REF = 0808bd0e1b61542a16e1906812dd924b
 
-FATE_COVER_ART-$(CONFIG_ASF_DEMUXER) += fate-cover-art-wma-id3
+FATE_COVER_ART-$(call DEMDEC, ASF, MJPEG) += fate-cover-art-wma-id3
 fate-cover-art-wma-id3: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/wma_with_ID3_APIC_trimmed.wma -an -c:v copy -f 
rawvideo
 fate-cover-art-wma-id3: REF = e6a8dd03687d5178bc13fc7d3316696e
 
-FATE_COVER_ART-$(CONFIG_ASF_DEMUXER) += fate-cover-art-wma-metadatalib
+FATE_COVER_ART-$(call DEMDEC, ASF, MJPEG) += fate-cover-art-wma-metadatalib
 fate-cover-art-wma-metadatalib: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/wma_with_metadata_library_object_tag_trimmed.wma 
-map 0:v -c:v copy -f rawvideo
 fate-cover-art-wma-metadatalib: REF = 32e8bd4fad546f63d881a0256f083aea
 
-FATE_COVER_ART-$(CONFIG_WV_DEMUXER) += fate-cover-art-wv
+FATE_COVER_ART-$(call DEMDEC, WV, MJPEG) += fate-cover-art-wv
 fate-cover-art-wv: CMD = md5 -i 
$(TARGET_SAMPLES)/cover_art/luckynight_cover.wv -an -c:v copy -f rawvideo
 fate-cover-art-wv: REF = 45333c983c45af54449dff10af144317
 
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 07/20] fate/lavf-container: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/lavf-container.mak | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak
index 6a46f98b5d..395b97b492 100644
--- a/tests/fate/lavf-container.mak
+++ b/tests/fate/lavf-container.mak
@@ -79,9 +79,9 @@ FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, HEVC, MP4, 
HEVC_PARSER EXTRACT_EXTRADATA
 FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MOV, MOV)  
 += mv_hevc.mov
 FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, VVC, MATROSKA, VVC_PARSER 
EXTRACT_EXTRADATA_BSF SETTS_BSF MATROSKA_DEMUXER) += vvc.mkv
 FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, VVC, MP4, VVC_PARSER MOV_DEMUXER)  
 += vvc.mp4
-FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MATROSKA, OGG, VP3_DECODER 
OGG_DEMUXER) += vp3.ogg
-FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MATROSKA, OGV, VP8_DECODER 
OGG_DEMUXER) += vp8.ogg
-FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MOV, LATM) 
 += latm
+FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MATROSKA, OGG, VP3_DECODER 
THEORA_DECODER OGG_DEMUXER)  += vp3.ogg
+FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MATROSKA, OGV, VP8_DECODER 
VORBIS_DECODER VORBIS_PARSER OGG_DEMUXER)+= vp8.ogg
+FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MOV LOAS, LATM, AAC_LATM_DECODER)  
 += latm
 FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MP3, MP3)  
 += mp3
 FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, MOV, MOV, QTRLE_DECODER MACE6_DECODER 
ARESAMPLE_FILTER) += qtrle_mace6.mov
 FATE_LAVF_CONTAINER_FATE-$(call DEMMUX, AVI, AVI, MSVIDEO1_DECODER 
PCM_U8_DECODER ARESAMPLE_FILTER) += cram.avi
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 05/20] fate/mov: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/mov.mak | 38 ++
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index a21b024015..8d4077da66 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -1,4 +1,4 @@
-FATE_MOV-$(call FRAMEMD5, MOV) = fate-mov-3elist \
+FATE_MOV-$(call FRAMEMD5, MOV, H264) += fate-mov-3elist \
fate-mov-3elist-1ctts \
fate-mov-1elist-1ctts \
fate-mov-1elist-noctts \
@@ -8,16 +8,21 @@ FATE_MOV-$(call FRAMEMD5, MOV) = fate-mov-3elist \
fate-mov-3elist-encrypted \
fate-mov-frag-encrypted \
fate-mov-tenc-only-encrypted \
-   fate-mov-invalid-elst-entry-count \
-   fate-mov-gpmf-remux \
-   fate-mov-ibi-elst-starts-b \
-   fate-mov-elst-ends-betn-b-and-i \
fate-mov-frag-overlap \
fate-mov-neg-firstpts-discard-frames \
-   fate-mov-stream-shorter-than-movie \
-   fate-mov-pcm-remux \
 
-FATE_MOV_FFPROBE-$(call FRAMEMD5, MOV) = fate-mov-neg-firstpts-discard \
+FATE_MOV-$(call FRAMEMD5, MOV, H264, FPS_FILTER) += 
fate-mov-stream-shorter-than-movie \
+
+FATE_MOV-$(call FRAMEMD5, MOV, MPEG4) += fate-mov-invalid-elst-entry-count \
+
+FATE_MOV-$(call FRAMEMD5, MOV, HEVC) += fate-mov-ibi-elst-starts-b \
+   fate-mov-elst-ends-betn-b-and-i \
+
+FATE_MOV_REMUX-$(call REMUX, MP4 MOV) += fate-mov-gpmf-remux \
+
+FATE_MOV_REMUX-$(call REMUX, MP4 WAV) += fate-mov-pcm-remux \
+
+FATE_MOV_FFPROBE-$(call FRAMEMD5, MOV, H264, H264_PARSER) += 
fate-mov-neg-firstpts-discard \
fate-mov-neg-firstpts-discard-vorbis \
fate-mov-aac-2048-priming \
fate-mov-zombie \
@@ -29,11 +34,12 @@ FATE_MOV_FFPROBE-$(call FRAMEMD5, MOV) = 
fate-mov-neg-firstpts-discard \
fate-mov-guess-delay-2 \
fate-mov-guess-delay-3 \
fate-mov-mp4-with-mov-in24-ver \
-   fate-mov-mp4-extended-atom \
+
+FATE_MOV_FFPROBE-$(call FRAMEMD5, MOV, MPEG4, H264_PARSER) += 
fate-mov-mp4-extended-atom \
 
 FATE_MOV_FASTSTART = fate-mov-faststart-4gb-overflow \
 
-FATE_SAMPLES_FFMPEG += $(FATE_MOV-yes)
+FATE_SAMPLES_FFMPEG += $(FATE_MOV-yes) $(FATE_MOV_REMUX-yes)
 FATE_SAMPLES_FFPROBE += $(FATE_MOV_FFPROBE-yes)
 FATE_SAMPLES_FASTSTART += $(FATE_MOV_FASTSTART)
 
@@ -95,7 +101,7 @@ FATE_MOV_FFMPEG-$(call ALLYES, LAVFI_INDEV COLOR_FILTER 
FORMAT_FILTER TRIM_FILTE
 # Makes sure that we pick the right frames according to edit list when there 
is no keyframe with PTS < edit list start.
 # For example, when video starts on a B-frame, and edit list starts on that 
B-frame too.
 # GOP structure : B B I in presentation order.
-FATE_MOV_FFMPEG_SAMPLES-$(call FRAMEMD5, MOV, AAC_FIXED, ARESAMPLE_FILTER) \
+FATE_MOV_FFMPEG_SAMPLES-$(call FRAMEMD5, MOV, AAC_FIXED H264, 
ARESAMPLE_FILTER) \
 += fate-mov-bbi-elst-starts-b
 fate-mov-bbi-elst-starts-b: CMD = framemd5 -flags +bitexact -acodec aac_fixed 
-i $(TARGET_SAMPLES)/h264/twofields_packet.mp4 -af aresample
 
@@ -203,7 +209,7 @@ FATE_MOV_FFMPEG_FFPROBE_SAMPLES-$(call REMUX, MP4 MOV, 
MPEGTS_DEMUXER AC3_DECODE
   += fate-mov-mp4-disposition-mpegts-remux
 fate-mov-mp4-disposition-mpegts-remux: CMD = transcode mpegts 
$(TARGET_SAMPLES)/mpegts/pmtchange.ts mp4 "-map 0:1 -map 0:2 -c copy 
-disposition:a:0 +hearing_impaired" "-map 0 -c copy" "-of json -show_entries 
stream_disposition:stream=index"
 
-FATE_MOV_FFMPEG_FFPROBE_SAMPLES-$(call REMUX, MP4 MOV) \
+FATE_MOV_FFMPEG_FFPROBE_SAMPLES-$(call REMUX, MP4 MOV, H264_DECODER) \
   += fate-mov-write-amve
 fate-mov-write-amve: CMD = transcode mov $(TARGET_SAMPLES)/mov/amve.mov mp4 
"-c:v copy" "-c:v copy -t 0.5" "-show_entries stream_side_data_list"
 
@@ -222,7 +228,7 @@ fate-mov-mp4-pcm: tests/data/asynth-44100-1.wav 
tests/data/filtergraphs/mov-mp4-
 fate-mov-mp4-pcm: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-/filter_complex 
$(TARGET_PATH)/tests/data/filtergraphs/mov-mp4-pcm -map [mono] -map [stereo] 
-map [2.1] -map [5.1] -map [7.1] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
 
 # Test floating sample format PCM in mp4 and unusual channel layout
-FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MP4 WAV, PAN_FILTER) \
+FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_F32LE, MP4 WAV, PAN_FILTER) \
   += fate-mov-mp4-pcm-float
 fate-mov-mp4-pcm-float: tests/data/asynth-44100-1.wav
 fate-mov-mp4-pcm-float: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-af 
aresample,pan=FR+FL+FR|c0=c0|c1=c0|c2=c0 -c:a pcm_f32le" "-map 0 -c copy 
-frames:a 0"
@@ -257,7 +263,7 @@ fate-mov-mp4-iamf-5_1_4: CMD = transcode wav $(SRC) mp4 
"-auto_conversion_filter
   "-show_entries 
stream_group=index,id,nb_streams,type:stream_group_components:stream_group_disposition:stream_grou

[FFmpeg-devel] [PATCH v2 06/20] fate/gapless: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/gapless.mak | 76 +-
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak
index dfae964662..e6fba1436b 100644
--- a/tests/fate/gapless.mak
+++ b/tests/fate/gapless.mak
@@ -4,44 +4,44 @@ fate-gapless-mp3: CMD = gapless 
$(TARGET_SAMPLES)/gapless/gapless.mp3 "-c:a mp3"
 FATE_GAPLESSINFO_PROBE-$(CONFIG_MP3_DEMUXER) += fate-gapless-mp3-side-data
 fate-gapless-mp3-side-data: CMD = ffprobe_demux 
$(TARGET_SAMPLES)/gapless/gapless.mp3
 
-FATE_GAPLESS-$(call DEMDEC, MP3, MP3, ARESAMPLE_FILTER) += 
fate-audiomatch-square-mp3
+FATE_GAPLESS-$(call DEMDEC, MP3, MP3, ARESAMPLE_FILTER WAV_MUXER) += 
fate-audiomatch-square-mp3
 fate-audiomatch-square-mp3: CMD = audio_match 
$(TARGET_SAMPLES)/audiomatch/square3.mp3 $(SAMPLES)/audiomatch/square3.wav
 
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-square-aac
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-16000-mono-lc-adts
fate-audiomatch-afconvert-16000-mono-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-44100-mono-lc-adts
fate-audiomatch-afconvert-44100-mono-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-16000-mono-he-adts
fate-audiomatch-afconvert-16000-mono-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-44100-mono-he-adts
fate-audiomatch-afconvert-44100-mono-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-16000-stereo-he-adts  
fate-audiomatch-afconvert-16000-stereo-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-44100-stereo-he-adts  
fate-audiomatch-afconvert-44100-stereo-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-16000-stereo-he2-adts 
fate-audiomatch-afconvert-16000-stereo-he2-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-44100-stereo-he2-adts 
fate-audiomatch-afconvert-44100-stereo-he2-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-16000-stereo-lc-adts  
fate-audiomatch-afconvert-16000-stereo-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-afconvert-44100-stereo-lc-adts  
fate-audiomatch-afconvert-44100-stereo-lc-m4a
-
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-faac-16000-mono-lc-adts
fate-audiomatch-faac-16000-mono-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-faac-44100-mono-lc-adts
fate-audiomatch-faac-44100-mono-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-faac-16000-stereo-lc-adts  
fate-audiomatch-faac-16000-stereo-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-faac-44100-stereo-lc-adts  
fate-audiomatch-faac-44100-stereo-lc-m4a
-
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-dolby-44100-mono-lc-mp4
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-dolby-44100-mono-he-mp4
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-dolby-44100-stereo-he-mp4
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-dolby-44100-stereo-he2-mp4
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-dolby-44100-stereo-lc-mp4
-
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-16000-mono-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-44100-mono-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-16000-mono-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-44100-mono-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-16000-stereo-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-44100-stereo-he-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-16000-stereo-he2-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-44100-stereo-he2-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-16000-stereo-lc-m4a
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-nero-44100-stereo-lc-m4a
-
-FATE_GAPLESS-$(call DEMDEC, MOV, AAC, ARESAMPLE_FILTER) += 
fate-audiomatch-quicktime7-44100-stereo-lc-mp4 
fate-audiomatch-quicktimeX-44100-stereo-lc-m4a
+FATE_GAPLESS-$(call TRANSCODE, PCM_S16LE AAC, WAV MOV, ARESAMPLE_FILTER) += 
fate-audiomatch-square-aac
+FATE_GAPLESS-$(call TRANSCODE, PCM_S16LE AAC, WAV MOV, AAC_DEMUXER 
ARESAMPLE_FILTER) +=

[FFmpeg-devel] [PATCH v2 08/20] fate/vorbis: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/vorbis.mak | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/tests/fate/vorbis.mak b/tests/fate/vorbis.mak
index 781430bcd3..73e837f5a6 100644
--- a/tests/fate/vorbis.mak
+++ b/tests/fate/vorbis.mak
@@ -1,10 +1,10 @@
-FATE_VORBIS += fate-vorbis-encode
-fate-vorbis-encode: CMD = enc_dec_pcm ogg wav s16le 
$(TARGET_SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav -c:a vorbis 
-strict experimental
-fate-vorbis-encode: REF = 
$(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
-fate-vorbis-encode: CMP_SHIFT = 0
-fate-vorbis-encode: CMP_TARGET = 296
-fate-vorbis-encode: SIZE_TOLERANCE = 3560
-fate-vorbis-encode: FUZZ = 30
+FATE_VORBIS_ENCODE += fate-vorbis-encode-1
+fate-vorbis-encode-1: CMD = enc_dec_pcm ogg wav s16le 
$(TARGET_SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav -c:a vorbis 
-strict experimental
+fate-vorbis-encode-1: REF = 
$(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
+fate-vorbis-encode-1: CMP_SHIFT = 0
+fate-vorbis-encode-1: CMP_TARGET = 296
+fate-vorbis-encode-1: SIZE_TOLERANCE = 3560
+fate-vorbis-encode-1: FUZZ = 30
 
 FATE_VORBIS += fate-vorbis-1
 fate-vorbis-1: CMD = pcm -i $(TARGET_SAMPLES)/vorbis/1.0.1-test_small.ogg
@@ -94,9 +94,11 @@ fate-vorbis-1833-chapters: CMD = probechapters 
$(TARGET_SAMPLES)/vorbis/vorbis_c
 
 FATE_SAMPLES_FFPROBE += $(FATE_VORBIS_FFPROBE-yes)
 
-FATE_VORBIS-$(call DEMDEC, OGG, VORBIS, ARESAMPLE_FILTER) += $(FATE_VORBIS)
+FATE_VORBIS-$(call PCM, OGG, VORBIS, ARESAMPLE_FILTER) += $(FATE_VORBIS)
+FATE_VORBIS_ENCODE-$(call TRANSCODE, VORBIS, OGG, WAV_MUXER WAV_DEMUXER 
PCM_S16LE_DECODER ARESAMPLE_FILTER) += $(FATE_VORBIS_ENCODE)
 
-FATE_SAMPLES_AVCONV += $(FATE_VORBIS-yes)
-fate-vorbis: $(FATE_VORBIS-yes) $(FATE_VORBIS_FFPROBE-yes)
+FATE_SAMPLES_AVCONV += $(FATE_VORBIS-yes) $(FATE_VORBIS_ENCODE-yes)
+fate-vorbis: $(FATE_VORBIS-yes) $(FATE_VORBIS_ENCODE-yes) 
$(FATE_VORBIS_FFPROBE-yes)
 $(FATE_VORBIS-yes): CMP = oneoff
-fate-vorbis-encode: CMP = stddev
+fate-vorbis-encode: $(FATE_VORBIS_ENCODE-yes)
+$(FATE_VORBIS_ENCODE-yes): CMP = stddev
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH] avformat/iamf_parse: prevent overreads in update_extradata

2025-06-23 Thread James Almer
Fixes: libavcodec/put_bits.h:232:32: runtime error: shift exponent -19 is 
negative
Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:406
Fixes: 
398527871/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6602025714647040

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer 
---
 libavformat/iamf_parse.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c
index 71497876ac..46a74ea679 100644
--- a/libavformat/iamf_parse.c
+++ b/libavformat/iamf_parse.c
@@ -288,7 +288,7 @@ static int update_extradata(AVCodecParameters *codecpar)
 uint8_t buf[6];
 int size = FFMIN(codecpar->extradata_size, sizeof(buf));
 
-init_put_bits(&pb, buf, size);
+init_put_bits(&pb, buf, sizeof(buf));
 ret = init_get_bits8(&gb, codecpar->extradata, size);
 if (ret < 0)
 return ret;
@@ -304,7 +304,10 @@ static int update_extradata(AVCodecParameters *codecpar)
 
 skip_bits(&gb, 4);
 put_bits(&pb, 4, codecpar->ch_layout.nb_channels); // set channel 
config
-ret = put_bits_left(&pb);
+ret = get_bits_left(&gb);
+if (ret < 0)
+return AVERROR_INVALIDDATA;
+ret = FFMIN(ret, put_bits_left(&pb));
 while (ret >= 32) {
put_bits32(&pb, get_bits_long(&gb, 32));
ret -= 32;
@@ -317,9 +320,10 @@ static int update_extradata(AVCodecParameters *codecpar)
 }
 case AV_CODEC_ID_FLAC: {
 uint8_t buf[13];
+int size = FFMIN(codecpar->extradata_size, sizeof(buf));
 
 init_put_bits(&pb, buf, sizeof(buf));
-ret = init_get_bits8(&gb, codecpar->extradata, 
codecpar->extradata_size);
+ret = init_get_bits8(&gb, codecpar->extradata, size);
 if (ret < 0)
 return ret;
 
@@ -328,11 +332,14 @@ static int update_extradata(AVCodecParameters *codecpar)
 put_bits(&pb, 20, get_bits(&gb, 20)); // samplerate
 skip_bits(&gb, 3);
 put_bits(&pb, 3, codecpar->ch_layout.nb_channels - 1);
-ret = put_bits_left(&pb);
+ret = get_bits_left(&gb);
+if (ret < 0)
+return AVERROR_INVALIDDATA;
+ret = FFMIN(ret, put_bits_left(&pb));
 put_bits(&pb, ret, get_bits(&gb, ret));
 flush_put_bits(&pb);
 
-memcpy(codecpar->extradata, buf, sizeof(buf));
+memcpy(codecpar->extradata, buf, put_bytes_output(&pb));
 break;
 }
 }
-- 
2.50.0

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

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


[FFmpeg-devel] [PATCH v2 09/20] fate/aac: fix multiple dependencies

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/aac.mak | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index f5a41458e6..48a4410d6c 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -241,21 +241,21 @@ fate-aac-latm_stereo_to_51: REF = 
$(SAMPLES)/aac/latm_stereo_to_51_ref.s16
 fate-aac-autobsf-adtstoasc: CMD = transcode "aac" 
$(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.adts \
 matroska "-c:a copy" "-c:a copy"
 
-FATE_AAC-$(call  DEMDEC, AAC,AAC,   ARESAMPLE_FILTER) += 
$(FATE_AAC_CT_RAW)
-FATE_AAC-$(call  DEMDEC, MOV,AAC,   ARESAMPLE_FILTER) += 
$(FATE_AAC)
-FATE_AAC_LATM-$(call DEMDEC, MPEGTS, AAC_LATM,  ARESAMPLE_FILTER) += 
$(FATE_AAC_LATM)
-FATE_AAC-$(call  DEMDEC, AAC,AAC_FIXED, ARESAMPLE_FILTER) += 
$(FATE_AAC_FIXED)
+FATE_AAC-$(call  PCM,AAC,AAC,   ARESAMPLE_FILTER) += 
$(FATE_AAC_CT_RAW)
+FATE_AAC-$(call  PCM,MOV,AAC,   ARESAMPLE_FILTER) += 
$(FATE_AAC)
+FATE_AAC_LATM-$(call PCM,MPEGTS, AAC_LATM,  ARESAMPLE_FILTER) += 
$(FATE_AAC_LATM)
+FATE_AAC-$(call  PCM,AAC,AAC_FIXED, ARESAMPLE_FILTER) += 
$(FATE_AAC_FIXED)
 
 FATE_AAC_ALL = $(FATE_AAC-yes) $(FATE_AAC_LATM-yes) $(FATE_AAC_FIXED-yes)
 
 $(FATE_AAC_ALL): CMP  = oneoff
 $(FATE_AAC_ALL): FUZZ = 2
 
-FATE_AAC_ENCODE-$(call ENCMUX, AAC, ADTS, ARESAMPLE_FILTER) += 
$(FATE_AAC_ENCODE)
+FATE_AAC_ENCODE-$(call TRANSCODE, AAC, ADTS AAC, WAV_MUXER WAV_DEMUXER 
PCM_S16LE_DECODER ARESAMPLE_FILTER) += $(FATE_AAC_ENCODE)
 
-FATE_AAC_BSF-$(call ALLYES, AAC_DEMUXER AAC_ADTSTOASC_BSF MATROSKA_MUXER) += 
fate-aac-autobsf-adtstoasc
+FATE_AAC_BSF-$(call DEMDEC, AAC MATROSKA, AAC, AAC_PARSER AAC_ADTSTOASC_BSF 
MATROSKA_MUXER) += fate-aac-autobsf-adtstoasc
 
 FATE_SAMPLES_FFMPEG += $(FATE_AAC_ALL) $(FATE_AAC_ENCODE-yes) 
$(FATE_AAC_BSF-yes)
 
-fate-aac: $(FATE_AAC_ALL) $(FATE_AAC_ENCODE) $(FATE_AAC_BSF-yes)
+fate-aac: $(FATE_AAC_ALL) $(FATE_AAC_ENCODE-yes) $(FATE_AAC_BSF-yes)
 fate-aac-latm: $(FATE_AAC_LATM-yes)
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v7 0/3] ffbuild/commonmak: Fix rebuild check with implicit rule chains

2025-06-23 Thread ffmpegagent


V2
==

 * Fix MSVC build
   (use the universal command pattern)


V3
==

 * Skip dependency generation by clearing CC_DEPS instead
   (as suggested by Ramiro - thanks!)


V4
==

 * Always keep .ptx files (as suggested by Timo - thanks) Tested all
   scenarios:
   * .ptx.c and .ptx.gz still get deleted (as intermediates)
   * repeated make shows "up-to-date"
   * removing a .ptx file does not cause a rebuild (it's still an
 intermediate, but an "intermediate to keep")
   * but changing a .ptx does (in case of dev/debugging)
   * changed .cu files always rebuild of course


V5
==

 * First patch remains unchanged
 * Added second patch to clean up and consolidate the rules around
   compression


V6
==

 * Rebased
 * Confirmed that it also resolves MSVC-CLang compilation
   (as reported by Kasper Michalow - thanks!)


V7
==

 * As the log line about intermediate file deletion ("RM ") didn't find
   much love, this version uses the workaround via the .SECONDARY special
   make target to prevent intermediate file deletion

.

softworkz (3):
  fftools/resources: Fix double-build by disabling .d file generation
  ffbuild/commonmak: Consolidate pattern rules for compression
  fftools/resources: Update .gitignore

 ffbuild/common.mak   | 49 ++--
 fftools/Makefile |  1 +
 fftools/resources/.gitignore |  5 ++--
 fftools/resources/Makefile   | 12 ++---
 4 files changed, 31 insertions(+), 36 deletions(-)


base-commit: e6298e0759430f64e9bd9298775de92597be8a50
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-80%2Fsoftworkz%2Fsubmit_commonmak-v7
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-80/softworkz/submit_commonmak-v7
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/80

Range-diff vs v6:

 1:  a8da0e9d17 ! 1:  391217966f ffbuild/commonmak: Fix rebuild check with 
implicit rule chains
 @@ Metadata
  Author: softworkz 
  
   ## Commit message ##
 -ffbuild/commonmak: Fix rebuild check with implicit rule chains
 -
 -When there's a chain of implicit rules, make treats files generated
 -inside that chain as intermediate files. Those intermediate files are
 -removed after completion of make. When make is run again, it normally
 -determines the need for a rebuild by comparing the timestamps of the
 -original source file and the final output of the chain and if still
 -up-to-date, it doesn't rebuild, even when the intermediate files are
 -not present. That makes sense of course - why would it delete them
 -otherwise, it would end up in builds being never up-to-date.
 -But this original by-the-book logic appeared to be broken and has been
 -worked around by adding all intermediate files to the .SECONDARY
 -special target, which required extra logic and issues with make clean.
 -
 -What broke the up-to-date checking is the dependency file generation.
 -For the .c files generated by BIN2C the compile target created a .d
 -file which indicated that the .ptx.o file has a dependency on the
 -ptx.c file. And that dependency broke the normal make behavior with
 -intermediate files.
 -
 -This patch compiles the BIN2C generated .c files without generating
 -.d files. In turn the files do not longer need to be added to the
 -.SECONDARY target in common.mak.
 -
 -When interested in those files for debugging, a line can be added to
 -the corresponding Makefile like
 -
 -.SECONDARY: %.ptx.c %.ptx.gz
 +fftools/resources: Fix double-build by disabling .d file generation
  
  Signed-off-by: softworkz 
  
   ## ffbuild/common.mak ##
 -@@ ffbuild/common.mak: else
 -  $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst 
.,_,$(basename $(notdir $@)))
 - endif
 - 
 -+%.ptx.o: CCDEP   =
 -+%.ptx.o: CC_DEPFLAGS =
 -+
 -+
 - # 1) Preprocess CSS to a minified version
 - %.css.min: TAG = SED
 - %.css.min: %.css
 -@@ ffbuild/common.mak: else   # NO COMPRESSION
 -  $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
 - endif
 - 
 -+%.html.o %.css.o: CCDEP   =
 -+%.html.o %.css.o: CC_DEPFLAGS =
 -+
 -+
 - clean::
 -  $(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
 - 
  @@ ffbuild/common.mak: SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) 
$(SKIPHEADERS-)
   SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
   HOBJS= $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
 @@ ffbuild/common.mak: SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) 
$(SKIPHEADERS-)
   $(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
   checkheaders: $(HOBJS)
  -.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) 
$(PTXOBJS:.o=) $(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:%.css.o=%.

[FFmpeg-devel] [PATCH v7 2/3] ffbuild/commonmak: Consolidate pattern rules for compression

2025-06-23 Thread softworkz
From: softworkz 

This commit simplifies and consolidates all the rules around
ptx and resource file compression.

Signed-off-by: softworkz 
---
 ffbuild/common.mak | 43 +--
 1 file changed, 17 insertions(+), 26 deletions(-)

diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index 81e8a46d0c..0a60d01623 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -115,6 +115,12 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS)
 $(BIN2CEXE): ffbuild/bin2c_host.o
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)
 
+RUN_BIN2C = $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst 
.,_,$(basename $(notdir $@)))
+RUN_GZIP  = $(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
+RUN_MINIFY = $(M)sed 's!/\\*.*\\*/!!g' $< | tr '\n' ' ' | tr -s ' ' | sed 's/^ 
//; s/ $$//' > $@
+%.gz: TAG = GZIP
+%.min: TAG = MINIFY
+
 %.metal.air: %.metal
$(METALCC) $< -o $@
 
@@ -122,61 +128,46 @@ $(BIN2CEXE): ffbuild/bin2c_host.o
$(METALLIB) --split-module-without-linking $< -o $@
 
 %.metallib.c: %.metallib $(BIN2CEXE)
-   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 
 %.ptx: %.cu $(SRC_PATH)/compat/cuda/cuda_runtime.h
$(COMPILE_NVCC)
 
 ifdef CONFIG_PTX_COMPRESSION
-%.ptx.gz: TAG = GZIP
 %.ptx.gz: %.ptx
-   $(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
+   $(RUN_GZIP)
 
 %.ptx.c: %.ptx.gz $(BIN2CEXE)
-   $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst 
.,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 else
 %.ptx.c: %.ptx $(BIN2CEXE)
-   $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst 
.,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 endif
 
-# 1) Preprocess CSS to a minified version
-%.css.min: TAG = SED
 %.css.min: %.css
-   $(M)sed 's!/\\*.*\\*/!!g' $< \
-   | tr '\n' ' ' \
-   | tr -s ' ' \
-   | sed 's/^ //; s/ $$//' \
-   > $@
+   $(RUN_MINIFY)
 
 ifdef CONFIG_RESOURCE_COMPRESSION
 
-# 2) Gzip the minified CSS
-%.css.min.gz: TAG = GZIP
 %.css.min.gz: %.css.min
-   $(M)gzip -nc9 $< > $@
+   $(RUN_GZIP)
 
-# 3) Convert the gzipped CSS to a .c array
 %.css.c: %.css.min.gz $(BIN2CEXE)
-   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 
-# 4) Gzip the HTML file (no minification needed)
-%.html.gz: TAG = GZIP
 %.html.gz: %.html
-   $(M)gzip -nc9 $< > $@
+   $(RUN_GZIP)
 
-# 5) Convert the gzipped HTML to a .c array
 %.html.c: %.html.gz $(BIN2CEXE)
-   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 
 else   # NO COMPRESSION
 
-# 2) Convert the minified CSS to a .c array
 %.css.c: %.css.min $(BIN2CEXE)
-   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 
-# 3) Convert the plain HTML to a .c array
 %.html.c: %.html $(BIN2CEXE)
-   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+   $(RUN_BIN2C)
 endif
 
 clean::
-- 
ffmpeg-codebot

___
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 v7 1/3] fftools/resources: Fix double-build by disabling .d file generation

2025-06-23 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 ffbuild/common.mak |  6 ++
 fftools/Makefile   |  1 +
 fftools/resources/Makefile | 12 +---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index ddf48923ea..81e8a46d0c 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -229,11 +229,9 @@ SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
 SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
 HOBJS= $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
 PTXOBJS  = $(filter %.ptx.o,$(OBJS))
-RESOURCEOBJS = $(filter %.css.o %.html.o,$(OBJS))
 $(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
 checkheaders: $(HOBJS)
-.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=) 
$(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:%.css.o=%.css.min) 
$(RESOURCEOBJS:%.css.o=%.css.min.gz) $(RESOURCEOBJS:%.html.o=%.html.gz) 
$(RESOURCEOBJS:.o=)
-
+.SECONDARY:   $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=)
 alltools: $(TOOLS)
 
 $(HOSTOBJS): %.o: %.c
@@ -252,7 +250,7 @@ $(TOOLOBJS): | tools
 
 OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SHLIBOBJS) 
$(STLIBOBJS) $(TESTOBJS))
 
-CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx 
*.ptx.gz *.ptx.c *.ver *.version *.html.gz *.html.c *.css.gz *.css.c  
*$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
+CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx 
*.ptx.gz *.ptx.c *.ver *.version *.html.gz *.html.c *.css.min.gz *.css.min 
*.css.c  *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
 LIBSUFFIXES   = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
 
 define RULES
diff --git a/fftools/Makefile b/fftools/Makefile
index b3c08ae5a0..bdb44fc5ce 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -36,6 +36,7 @@ OBJS-ffmpeg +=  \
 fftools/textformat/tw_buffer.o\
 fftools/textformat/tw_stdout.o\
 $(OBJS-resman)\
+$(RESOBJS)\
 
 OBJS-ffprobe +=   \
 fftools/textformat/avtextformat.o \
diff --git a/fftools/resources/Makefile b/fftools/resources/Makefile
index 8579a52678..3c936484d1 100644
--- a/fftools/resources/Makefile
+++ b/fftools/resources/Makefile
@@ -4,10 +4,16 @@ clean::
 vpath %.html $(SRC_PATH)
 vpath %.css  $(SRC_PATH)
 
-# Uncomment to prevent deletion during build
-#.PRECIOUS: %.css.c %.css.min %.css.gz %.css.min.gz %.html.gz %.html.c
-
 OBJS-resman += \
 fftools/resources/resman.o \
+
+
+RESOBJS += \
 fftools/resources/graph.html.o \
 fftools/resources/graph.css.o  \
+
+
+$(RESOBJS): CCDEP   =
+$(RESOBJS): CC_DEPFLAGS =
+
+.SECONDARY: $(RESOBJS:.o=.gz) $(RESOBJS:.o=.c) $(RESOBJS:%.css.o=%.css.min) 
$(RESOBJS:%.css.o=%.css.min.gz) $(RESOBJS:%.html.o=%.html.gz) $(RESOBJS:.o=)
-- 
ffmpeg-codebot

___
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 v7 3/3] fftools/resources: Update .gitignore

2025-06-23 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 fftools/resources/.gitignore | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fftools/resources/.gitignore b/fftools/resources/.gitignore
index bda2c59a1c..cc742817b5 100644
--- a/fftools/resources/.gitignore
+++ b/fftools/resources/.gitignore
@@ -1,6 +1,5 @@
 *.html.c
 *.css.c
 *.html.gz
-*.css.gz
-*.min
-*.min.gz
+*.css.min
+*.css.min.gz
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH v2 02/20] fate/all: add missing dependencies for extradata bsf

2025-06-23 Thread Nicolas Gaullier
---
 tests/fate/concatdec.mak  |  2 +-
 tests/fate/demux.mak  | 16 
 tests/fate/flvenc.mak |  2 +-
 tests/fate/h264.mak   |  8 +---
 tests/fate/hevc.mak   |  4 ++--
 tests/fate/lavf-container.mak |  8 
 tests/fate/segment.mak|  2 +-
 7 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/tests/fate/concatdec.mak b/tests/fate/concatdec.mak
index c0dc6d4c94..9b21f1dd4b 100644
--- a/tests/fate/concatdec.mak
+++ b/tests/fate/concatdec.mak
@@ -23,5 +23,5 @@ $(foreach D,$(FATE_CONCAT_DEMUXER_EXTENDED_LAVF),$(eval 
fate-concat-demuxer-exte
 $(foreach D,$(FATE_CONCAT_DEMUXER_EXTENDED_LAVF),$(eval 
fate-concat-demuxer-extended-lavf-$(D): CMD = concat 
$(SRC_PATH)/tests/extended.ffconcat ../lavf/lavf.$(D) md5))
 FATE_CONCAT_DEMUXER += 
$(FATE_CONCAT_DEMUXER_EXTENDED_LAVF:%=fate-concat-demuxer-extended-lavf-%)
 
-FATE_CONCAT_DEMUXER := $(if $(CONFIG_CONCAT_DEMUXER), $(FATE_CONCAT_DEMUXER))
+FATE_CONCAT_DEMUXER := $(if $(call ALLYES, CONCAT_DEMUXER 
EXTRACT_EXTRADATA_BSF), $(FATE_CONCAT_DEMUXER))
 FATE_FFPROBE += $(FATE_CONCAT_DEMUXER)
diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index ead5ad4b10..a654cdcbbf 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -13,7 +13,7 @@ fate-aa-demux: CMD = framecrc -i $(TARGET_SAMPLES)/aa/bush.aa 
-c:a copy
 FATE_SAMPLES_DEMUX-$(CONFIG_AEA_DEMUXER) += fate-aea-demux
 fate-aea-demux: CMD = crc -i $(TARGET_SAMPLES)/aea/chirp.aea -c:a copy
 
-FATE_SAMPLES_DEMUX-$(call DEMDEC, AV1, AV1) += fate-av1-annexb-demux
+FATE_SAMPLES_DEMUX-$(call DEMDEC, AV1, AV1, EXTRACT_EXTRADATA_BSF) += 
fate-av1-annexb-demux
 fate-av1-annexb-demux: CMD = framecrc -c:v av1 -i 
$(TARGET_SAMPLES)/av1/annexb.obu -c:v copy
 
 FATE_SAMPLES_DEMUX-$(CONFIG_AST_DEMUXER) += fate-ast
@@ -29,7 +29,7 @@ fate-bcstm: CMD = crc -i 
$(TARGET_SAMPLES)/bfstm/loz-mm-mikau.bcstm -c:a copy
 FATE_SAMPLES_DEMUX-$(CONFIG_BRSTM_DEMUXER) += fate-brstm
 fate-brstm: CMD = crc -i $(TARGET_SAMPLES)/brstm/lozswd_partial.brstm -c:a copy
 
-FATE_FFPROBE_DEMUX-$(call ALLYES, CAVSVIDEO_DEMUXER CAVSVIDEO_PARSER) += 
fate-cavs-demux
+FATE_FFPROBE_DEMUX-$(call ALLYES, CAVSVIDEO_DEMUXER CAVSVIDEO_PARSER 
EXTRACT_EXTRADATA_BSF) += fate-cavs-demux
 fate-cavs-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/cavs/bunny.mp4
 
 FATE_SAMPLES_DEMUX-$(CONFIG_CDXL_DEMUXER) += fate-cdxl-demux
@@ -54,13 +54,13 @@ fate-flv-demux: CMD = ffprobe_demux 
$(TARGET_SAMPLES)/flv/Enigma_Principles_of_L
 FATE_SAMPLES_DEMUX-$(CONFIG_GIF_DEMUXER) += fate-gif-demux
 fate-gif-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/gif/Newtons_cradle_animation_book_2.gif -c:v copy
 
-FATE_SAMPLES_DEMUX-$(call ALLYES, IV8_DEMUXER MPEG4VIDEO_PARSER) += 
fate-iv8-demux
+FATE_SAMPLES_DEMUX-$(call ALLYES, IV8_DEMUXER MPEG4VIDEO_PARSER 
EXTRACT_EXTRADATA_BSF) += fate-iv8-demux
 fate-iv8-demux: CMD = framecrc -i $(TARGET_SAMPLES)/iv8/zzz-partial.mpg -c:v 
copy
 
 FATE_SAMPLES_DEMUX-$(CONFIG_JV_DEMUXER) += fate-jv-demux
 fate-jv-demux: CMD = framecrc -i $(TARGET_SAMPLES)/jv/intro.jv -c:v copy -c:a 
copy
 
-FATE_SAMPLES_DEMUX-$(call ALLYES, LMLM4_DEMUXER MPEG4VIDEO_PARSER) += 
fate-lmlm4-demux
+FATE_SAMPLES_DEMUX-$(call ALLYES, LMLM4_DEMUXER MPEG4VIDEO_PARSER 
EXTRACT_EXTRADATA_BSF) += fate-lmlm4-demux
 fate-lmlm4-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/lmlm4/LMLM4_CIFat30fps.divx -t 3 -c:a copy -c:v copy
 
 FATE_SAMPLES_DEMUX-$(CONFIG_XA_DEMUXER) += fate-maxis-xa
@@ -82,7 +82,7 @@ fate-mov-mp3-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/mpegaudio/packed_maindat
 FATE_FFPROBE_DEMUX-$(call ALLYES, MPEGTS_DEMUXER ARESAMPLE_FILTER) += 
fate-ts-opus-demux
 fate-ts-opus-demux: CMD = ffprobe_demux 
$(TARGET_SAMPLES)/opus/test-8-7.1.opus-small.ts
 
-FATE_FFPROBE_DEMUX-$(CONFIG_MPEGTS_DEMUXER) += fate-ts-small-demux
+FATE_FFPROBE_DEMUX-$(call ALLYES, MPEGTS_DEMUXER EXTRACT_EXTRADATA_BSF) += 
fate-ts-small-demux
 fate-ts-small-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/mpegts/h264small.ts
 
 FATE_SAMPLES_DEMUX-$(CONFIG_MTV_DEMUXER) += fate-mtv
@@ -91,7 +91,7 @@ fate-mtv: CMD = framecrc -i 
$(TARGET_SAMPLES)/mtv/comedian_auto-partial.mtv -c c
 FATE_SAMPLES_DEMUX-$(call DEMDEC, MXF, MPEG4) += fate-mxf-demux
 fate-mxf-demux: CMD = framecrc -i $(TARGET_SAMPLES)/mxf/C0023S01.mxf -c:a copy 
-c:v copy
 
-FATE_SAMPLES_DEMUX-$(call ALLYES, NC_DEMUXER MPEG4VIDEO_PARSER) += 
fate-nc-demux
+FATE_SAMPLES_DEMUX-$(call ALLYES, NC_DEMUXER MPEG4VIDEO_PARSER 
EXTRACT_EXTRADATA_BSF) += fate-nc-demux
 fate-nc-demux: CMD = framecrc -i $(TARGET_SAMPLES)/nc-camera/nc-sample-partial 
-c:v copy
 
 FATE_SAMPLES_DEMUX-$(CONFIG_NISTSPHERE_DEMUXER) += fate-nistsphere-demux
@@ -148,7 +148,7 @@ fate-wav-ac3: CMD = framecrc -i 
$(TARGET_SAMPLES)/ac3/diatonis_invisible_order_a
 FATE_SAMPLES_DEMUX-$(CONFIG_WSAUD_DEMUXER) += fate-westwood-aud
 fate-westwood-aud: CMD = framecrc -i 
$(TARGET_SAMPLES)/westwood-aud/excellent.aud -c copy
 
-FATE_SAMPLES_DEMUX-$(call ALLYES, WTV_DEMUXER MPEGVIDEO_PARSER) += 
fate-wtv-demux
+FATE_SAMPL

[FFmpeg-devel] [PATCH v2 04/20] fate/all: switch-fix mov muxer dependency to mp4 muxer dependency

2025-06-23 Thread Nicolas Gaullier
Signed-off-by: Nicolas Gaullier 
---
 tests/fate/enc_external.mak   |  6 +++---
 tests/fate/lavf-container.mak |  2 +-
 tests/fate/mov.mak| 14 +++---
 tests/fate/subtitles.mak  |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak
index 4095a4b51a..705f733db7 100644
--- a/tests/fate/enc_external.mak
+++ b/tests/fate/enc_external.mak
@@ -1,14 +1,14 @@
-FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 H264, MOV, H264_DEMUXER) += 
fate-libx264-simple
+FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 H264, MP4 MOV, H264_DEMUXER) += 
fate-libx264-simple
 fate-libx264-simple: CMD = enc_external 
$(TARGET_SAMPLES)/h264-conformance/BA1_Sony_D.jsv \
 mp4 "-c:v libx264" "-show_entries frame=width,height,pix_fmt,pts,pkt_dts 
-of flat"
 
 # test for SVT-AV1 MDCV and CLL passthrough during encoding
-FATE_ENC_EXTERNAL-$(call ENCDEC, LIBSVTAV1 HEVC, MOV, HEVC_DEMUXER 
LIBDAV1D_DECODER) += fate-libsvtav1-hdr10
+FATE_ENC_EXTERNAL-$(call ENCDEC, LIBSVTAV1 HEVC, MP4 MOV, HEVC_DEMUXER 
LIBDAV1D_DECODER) += fate-libsvtav1-hdr10
 fate-libsvtav1-hdr10: CMD = enc_external 
$(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \
 mp4 "-c:v libsvtav1" "-show_frames -show_entries frame=side_data_list -of 
flat"
 
 # test for x264 MDCV and CLL passthrough during encoding
-FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 HEVC, MOV, LIBX264_HDR10 HEVC_DEMUXER 
H264_DECODER) += fate-libx264-hdr10
+FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 HEVC, MP4 MOV, LIBX264_HDR10 
HEVC_DEMUXER H264_DECODER) += fate-libx264-hdr10
 fate-libx264-hdr10: CMD = enc_external 
$(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \
 mp4 "-c:v libx264" "-show_frames -show_entries frame=side_data_list -of 
flat"
 
diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak
index 6f8136f5df..6a46f98b5d 100644
--- a/tests/fate/lavf-container.mak
+++ b/tests/fate/lavf-container.mak
@@ -6,7 +6,7 @@ FATE_LAVF_CONTAINER-$(call ENCDEC,  RAWVIDEO,  
FILMSTRIP)  +
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, GXF)
+= gxf gxf_pal gxf_ntsc
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG4,  MP2,   MATROSKA)   
+= mkv mkv_attachment
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG4,  PCM_ALAW,  MOV)
+= mov mov_rtphint mov_hybrid_frag ismv
-FATE_LAVF_CONTAINER-$(call ENCDEC,  MPEG4, MOV)
+= mp4
+FATE_LAVF_CONTAINER-$(call ENCDEC,  MPEG4, MP4 MOV)
+= mp4
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG1VIDEO, MP2,   MPEG1SYSTEM MPEGPS) 
+= mpg
 FATE_LAVF_CONTAINER-$(call ENCDEC , FFV1,  MXF)
+= mxf_ffv1
 FATE_LAVF_CONTAINER-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF)
+= mxf
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 71796879c3..a21b024015 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -216,13 +216,13 @@ fate-mov-channel-description: 
tests/data/asynth-44100-1.wav tests/data/filtergra
 fate-mov-channel-description: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mov "-/filter_complex 
$(TARGET_PATH)/tests/data/filtergraphs/mov-channel-description -map [outFL] 
-map [outFR] -map [outFC] -map [outLFE] -map [outBL] -map [outBR] -map [outDL] 
-map [outDR] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
 
 # Test PCM in mp4 and channel layout
-FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
+FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MP4 WAV, PAN_FILTER) \
   += fate-mov-mp4-pcm
 fate-mov-mp4-pcm: tests/data/asynth-44100-1.wav 
tests/data/filtergraphs/mov-mp4-pcm
 fate-mov-mp4-pcm: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-/filter_complex 
$(TARGET_PATH)/tests/data/filtergraphs/mov-mp4-pcm -map [mono] -map [stereo] 
-map [2.1] -map [5.1] -map [7.1] -c:a pcm_s16le" "-map 0 -c copy -frames:a 0"
 
 # Test floating sample format PCM in mp4 and unusual channel layout
-FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MOV, WAV_DEMUXER PAN_FILTER) \
+FATE_MOV_FFMPEG-$(call TRANSCODE, PCM_S16LE, MP4 WAV, PAN_FILTER) \
   += fate-mov-mp4-pcm-float
 fate-mov-mp4-pcm-float: tests/data/asynth-44100-1.wav
 fate-mov-mp4-pcm-float: CMD = transcode wav 
$(TARGET_PATH)/tests/data/asynth-44100-1.wav mp4 "-af 
aresample,pan=FR+FL+FR|c0=c0|c1=c0|c2=c0 -c:a pcm_f32le" "-map 0 -c copy 
-frames:a 0"
@@ -237,7 +237,7 @@ fate-mov-vfr: CMD = md5 -filter_complex 
testsrc=size=2x2:duration=1,setpts=N*N:s
 fate-mov-vfr: CMP = oneline
 fate-mov-vfr: REF = 1558b4a9398d8635783c93f84eb5a60d
 
-FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, FLAC, MOV, WAV_DEMUXER 
PCM_S16LE_DECODER) += fate-mov-mp4-iamf-stereo
+FATE_MOV_FFMPEG_FFPROBE-$(call TRANSCODE, FLAC, MP4 WAV, PCM_S16LE_DECODER) += 
fate-mov-mp4-iamf-stereo
 fate-mov-mp4-iamf-stereo: tests/data/asynth-44100-2.wav 
tests/data/streamgroups/audio_el

[FFmpeg-devel] [PATCH v2 00/20] fate: fix several dependencies

2025-06-23 Thread Nicolas Gaullier
For remembering
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-October/335422.html

This v2 is a "full rebase", which means
some problems have been fixed in the while (not many),
some others are new.

Nicolas Gaullier (20):
  tests/Makefile: make easier to check for multiple dependencies
  fate/all: add missing dependencies for extradata bsf
  fate/demux: fix multiple dependencies
  fate/all: switch-fix mov muxer dependency to mp4 muxer dependency
  fate/mov: fix multiple dependencies
  fate/gapless: fix multiple dependencies
  fate/lavf-container: fix multiple dependencies
  fate/vorbis: fix multiple dependencies
  fate/aac: fix multiple dependencies
  fate/audio: fix multiple dependencies
  fate/ac3: fix multiple dependencies
  fate/cover-art: fix multiple dependencies
  fate/hlsenc: fix multiple dependencies
  fate/mpeg4: fix multiple dependencies
  fate/pcm: fix multiple dependencies
  fate/hevc: fix multiple dependencies
  fate/all: fix multiple dependencies
  fate/all: add missing file protocol dependencies
  fate/all: add missing crc/framecrc/md5/framemd5/pipe dependencies
  libavcodec/tests: fix gitignore hashtable

 libavcodec/tests/.gitignore   |   1 +
 tests/Makefile|  20 ---
 tests/fate/aac.mak|  14 ++---
 tests/fate/ac3.mak|  10 ++--
 tests/fate/acodec.mak |   4 +-
 tests/fate/adpcm.mak  |  38 ++---
 tests/fate/alac.mak   |   2 +-
 tests/fate/als.mak|   3 +-
 tests/fate/amrnb.mak  |   2 +-
 tests/fate/amrwb.mak  |   2 +-
 tests/fate/api.mak|   2 +-
 tests/fate/apng.mak   |   2 +-
 tests/fate/atrac.mak  |   6 +-
 tests/fate/audio.mak  |  32 +--
 tests/fate/caf.mak|   2 +-
 tests/fate/cbs.mak|   6 +-
 tests/fate/concatdec.mak  |   2 +-
 tests/fate/cover-art.mak  |  24 
 tests/fate/demux.mak  | 104 +-
 tests/fate/dpcm.mak   |   4 +-
 tests/fate/enc_external.mak   |   6 +-
 tests/fate/ffmpeg.mak |  10 ++--
 tests/fate/fifo-muxer.mak |   2 +-
 tests/fate/filter-audio.mak   |  24 
 tests/fate/filter-video.mak   |  22 +++
 tests/fate/fits.mak   |   4 +-
 tests/fate/flac.mak   |   2 +-
 tests/fate/flvenc.mak |   2 +-
 tests/fate/gapless.mak|  78 -
 tests/fate/gif.mak|   2 +-
 tests/fate/h264.mak   |  14 +++--
 tests/fate/hevc.mak   |  10 ++--
 tests/fate/hlsenc.mak |  20 ---
 tests/fate/image.mak  |   6 +-
 tests/fate/imf.mak|   3 +-
 tests/fate/indeo.mak  |  18 +++---
 tests/fate/lavf-container.mak |  32 +--
 tests/fate/lavf-video.mak |   2 +-
 tests/fate/libavformat.mak|   2 +-
 tests/fate/libswresample.mak  |   2 +-
 tests/fate/lossless-audio.mak |   8 +--
 tests/fate/matroska.mak   |  31 +-
 tests/fate/microsoft.mak  |   4 +-
 tests/fate/monkeysaudio.mak   |   3 +-
 tests/fate/mov.mak|  52 +
 tests/fate/mp3.mak|   2 +-
 tests/fate/mpc.mak|   8 +--
 tests/fate/mpeg4.mak  |  11 ++--
 tests/fate/mpegps.mak |   2 +-
 tests/fate/ogg-flac.mak   |   2 +-
 tests/fate/oma.mak|   2 +-
 tests/fate/pcm.mak|  19 ---
 tests/fate/pixfmt.mak |   1 +
 tests/fate/qoa.mak|   6 +-
 tests/fate/real.mak   |  16 +++---
 tests/fate/seek.mak   |   8 +--
 tests/fate/segment.mak|   6 +-
 tests/fate/subtitles.mak  |   7 ++-
 tests/fate/vcodec.mak |   4 +-
 tests/fate/video.mak  |   4 +-
 tests/fate/voice.mak  |  16 +++---
 tests/fate/vorbis.mak |  24 
 tests/fate/vpx.mak|   4 +-
 tests/fate/vqf.mak|   4 +-
 tests/fate/wavpack.mak|   2 +-
 tests/fate/wma.mak|  16 +++---
 tests/fate/xvid.mak   |   2 +-
 67 files changed, 415 insertions(+), 390 deletions(-)

-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH v2 01/20] tests/Makefile: make easier to check for multiple dependencies

2025-06-23 Thread Nicolas Gaullier
---
 tests/Makefile | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 505d7f9c6d..7187b744cb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -97,21 +97,21 @@ TRANSCODE = $(call ALLYES, $(firstword $(1))_ENCODER 
$(lastword $(1))_DECODER \
 REMUX = $(call ALLYES, $(firstword $(1))_MUXER $(lastword $(1))_DEMUXER \
$(2) FILE_PROTOCOL PIPE_PROTOCOL FRAMECRC_MUXER)
 
-DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER) $(3) FILE_PROTOCOL)
-ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER   $(3))
+DEMDEC  = $(call ALLYES, $(1:%=%_DEMUXER) $(2:%=%_DECODER) $(3) FILE_PROTOCOL)
+ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2:%=%_MUXER)   $(3))
 
-FRAMEMD5 = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER) $(3)  \
+FRAMEMD5 = $(call ALLYES, $(1:%=%_DEMUXER) $(2:%=%_DECODER) $(3)  \
   PCM_S16LE_ENCODER RAWVIDEO_ENCODER FRAMEMD5_MUXER   \
   PIPE_PROTOCOL FILE_PROTOCOL)
-FRAMECRC = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER) $(3)  \
+FRAMECRC = $(call ALLYES, $(1:%=%_DEMUXER) $(2:%=%_DECODER) $(3)  \
   PCM_S16LE_ENCODER RAWVIDEO_ENCODER FRAMECRC_MUXER   \
   PIPE_PROTOCOL FILE_PROTOCOL)
 
 # Variant of DEMDEC for use with the "pcm" command.
-PCM = $(call ALLYES, $(1)_DEMUXER $(2)_DECODER  $(3) FILE_PROTOCOL\
+PCM = $(call ALLYES, $(1:%=%_DEMUXER) $(2:%=%_DECODER)  $(3) FILE_PROTOCOL\
  PCM_S16LE_ENCODER PCM_S16LE_MUXER PIPE_PROTOCOL)
 
-DEMMUX  = $(call ALLYES, $(1)_DEMUXER $(2)_MUXER $(3) FILE_PROTOCOL)
+DEMMUX  = $(call ALLYES, $(1:%=%_DEMUXER) $(2:%=%_MUXER) $(3) FILE_PROTOCOL)
 
 # Variant of FRAMECRC for the cases with -lavfi where no demuxer is involved.
 FILTERFRAMECRC = $(call ALLYES, $(1:%=%_FILTER) $(2) PCM_S16LE_ENCODER\
@@ -120,9 +120,9 @@ FILTERFRAMECRC = $(call ALLYES, $(1:%=%_FILTER) $(2) 
PCM_S16LE_ENCODER\
 FILTERDEMDEC   = $(call ALLYES, $(1:%=%_FILTER) $(2:%=%_DEMUXER) 
$(3:%=%_DECODER) \
 $(4) PCM_S16LE_ENCODER RAWVIDEO_ENCODER   \
 FRAMECRC_MUXER FILE_PROTOCOL PIPE_PROTOCOL)
-FILTERDEMDECENCMUX = $(call ALLYES, $(1:%=%_FILTER) $(2)_DEMUXER $(3)_DECODER 
$(4)_ENCODER $(5)_MUXER $(6) FILE_PROTOCOL)
+FILTERDEMDECENCMUX = $(call ALLYES, $(1:%=%_FILTER) $(2:%=%_DEMUXER) 
$(3:%=%_DECODER) $(4:%=%_ENCODER) $(5:%=%_MUXER) $(6) FILE_PROTOCOL)
 
-PARSERDEMDEC   = $(call ALLYES, $(1)_PARSER $(2)_DEMUXER $(3)_DECODER $(4) 
FILE_PROTOCOL)
+PARSERDEMDEC   = $(call ALLYES, $(1:%=%_PARSER) $(2:%=%_DEMUXER) 
$(3:%=%_DECODER) $(4) FILE_PROTOCOL)
 
 # Allow overriding CONFIG_LARGE_TESTS via LARGE_TESTS, if set on the
 # make command line.
-- 
2.47.2

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

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


[FFmpeg-devel] [PATCH] avfilter/f_ebur128: properly propagate true peak

2025-06-23 Thread Niklas Haas
From: Niklas Haas 

After 3b26b782ee, `ebur128->true_peak` was only set to the maximum of the
current "true peak per frame" values, when it should report the true peak for
the entire stream.

Fixes: 3b26b782eeded9b9ab7fac013cd1a83a30d68206
---
 libavfilter/f_ebur128.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 80cbe20330..63669b71de 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -692,11 +692,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*insamples)
 double peak = dsp->find_peak(ebur128->true_peaks_per_frame, 
nb_channels,
  swr_samples, ret);
 
-ebur128->true_peak = DBFS(peak);
 for (int ch = 0; ch < nb_channels; ch++) {
+peak = FFMAX(peak, ebur128->true_peaks[ch]);
 ebur128->true_peaks[ch] = FFMAX(ebur128->true_peaks[ch],
 ebur128->true_peaks_per_frame[ch]);
 }
+
+ebur128->true_peak = DBFS(peak);
 }
 #endif
 
-- 
2.49.0

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

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


[FFmpeg-devel] [PATCH] hwcontext_vulkan: add option to disable video queues when creating a device

2025-06-23 Thread Lynne
This helps reduce queue usage even further.
---
 libavutil/hwcontext_vulkan.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 88145ef2d0..f31020c416 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -147,6 +147,9 @@ typedef struct VulkanDevicePriv {
 /* Disable host image transfer */
 int disable_host_transfer;
 
+/* Disable all video support */
+int disable_video;
+
 /* Maximum queues */
 int limit_queues;
 
@@ -1540,14 +1543,16 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 PICK_QF(VK_QUEUE_COMPUTE_BIT, VK_VIDEO_CODEC_OPERATION_NONE_KHR);
 PICK_QF(VK_QUEUE_TRANSFER_BIT, VK_VIDEO_CODEC_OPERATION_NONE_KHR);
 
-PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR);
-PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR);
+if (!p->disable_video) {
+PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR);
+PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR);
 
-PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR);
-PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR);
+PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR);
+PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR);
 
-PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_AV1_BIT_KHR);
-PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR);
+PICK_QF(VK_QUEUE_VIDEO_ENCODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_ENCODE_AV1_BIT_KHR);
+PICK_QF(VK_QUEUE_VIDEO_DECODE_BIT_KHR, 
VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR);
+}
 
 av_free(qf);
 av_free(qf_vid);
@@ -1764,6 +1769,11 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
 if (opt_d)
 p->limit_queues = strtol(opt_d->value, NULL, 10);
 
+/* Disable video if really needed */
+opt_d = av_dict_get(opts, "disable_video", NULL, 0);
+if (opt_d)
+p->disable_video = strtol(opt_d->value, NULL, 10);
+
 /* The disable_multiplane argument takes precedent over the option */
 p->disable_multiplane = disable_multiplane;
 if (!p->disable_multiplane) {
-- 
2.49.0.395.g12beb8f557c
___
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] Revert "Add FUNDING.json"

2025-06-23 Thread Michael Niedermayer
Hi Derek

You said
"The only mails you'll see from me in the future are code or reviews."

On Mon, Jun 23, 2025 at 09:20:56PM +0100, Derek Buitenhuis wrote:
> This was pushed with outstanding reservations,

there where 2 comments in one mail but no objection
The first was about SPI and taxes
The second was about the domain owner of avcodec.org


> with no positive
> affirmation or review from any other devs,

The General Assembly was informed about the donation on the 9th june
and on the 18th about the solution with the json file
as well as my intend to implement this within 48h
that would be the 20th. i waited 3 more days both for members
of the GA as well as the public to comment


> and without a push noticed
> to say it was going to be pushed.

All members of the GA knew i intended to move forward
with this. And they also knew that there was a deadline of june 27th
for this. So everyone knew it would be pushed if theres no objection
because they saw the deadline date


> Further, the wallet is controlled by a single individual, and not
> FFmpeg.

The wallet belongs to the FFmpeg community. And its content, if it ever
has any content. Also belongs to FFmpeg.

It is currently managed by me. Which brings me tax complexities and work.

The wallet can be handed over to the SPI treassurer, if the SPI treassurer
accepts it.
The community can also discuss other ways to manage this wallet, it is
the FFmpeg communities wallet after all.

But the antagonizing and accusational tone of your mail is unacceptable.
Manging this wallet costs time, costs money, means responsibility.
Today alone i spend like 1-2 hours manually verifying the transaction
to connect this thing to the drips network.

reverting FUNDING.json will reduce trust by donators in FFmpeg.

thx

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 v5] Mark C globals with small code model

2025-06-23 Thread Pranav Kant via ffmpeg-devel
--- Begin Message ---
Apologies for the late reply.

Yeah, the other solution to solve this problem is to sprinkle .gotpcrel all
over the x86 assembly whenever it tries to access a variable that's defined
in the C file.

Using `attribute(small)`, as in this patch, is behind a macro that implies
that variable is referenced from the assembly file which only gets
activated for x86 and ELF. We are not putting x86-specific hacks all over
the code. We are putting indicators/macros all over the code against
variables that are defined in C files but accessed in assembly files. This
will also help us to extend the definitions of these macros in future as
alluded to by Andreas and Martin in above discussion. It's good to wrap
these variables that are referenced from external assembly for this reason.

Please make sure you are seeing version 6 of this patch. What you are
describing was done in the first version of this patch.

On Wed, May 7, 2025 at 5:15 AM Rémi Denis-Courmont  wrote:

> Hi,
>
> This looks like a kludge to me. If static variables are too far away, then
> the assembler code that refers to them needs to be fixed, and that's all
> that there is to it.
>
> You can't just magically make the data and the code closer, especially if
> FFmpeg is compiled as a static library (a very common use case).
>
> Also putting x86-specific hacks all over the code base, meh. Other
> architectures have all dealt with that issue cleanly already.
> ___
> 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".
>
--- End Message ---
___
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".


  1   2   >